[dali_2.3.19] Merge branch 'devel/master'
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Actor.cpp
1 /*
2  * Copyright (c) 2023 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 ChildOrderChangedFunctor
280 {
281   ChildOrderChangedFunctor(bool& signalCalled, Actor& actor)
282   : mSignalCalled(signalCalled),
283     mActor(actor)
284   {
285   }
286
287   void operator()(Actor actor)
288   {
289     mSignalCalled = true;
290     mActor        = actor;
291   }
292
293   bool&  mSignalCalled;
294   Actor& mActor;
295 };
296
297 struct CulledPropertyNotificationFunctor
298 {
299   CulledPropertyNotificationFunctor(bool& signalCalled, PropertyNotification& propertyNotification)
300   : mSignalCalled(signalCalled),
301     mPropertyNotification(propertyNotification)
302   {
303   }
304
305   void operator()(PropertyNotification& source)
306   {
307     mSignalCalled         = true;
308     mPropertyNotification = source;
309   }
310
311   bool&                 mSignalCalled;
312   PropertyNotification& mPropertyNotification;
313 };
314
315 // Clipping test helper functions:
316 Actor CreateActorWithContent(uint32_t width, uint32_t height)
317 {
318   Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
319   Actor   actor = CreateRenderableActor(image);
320
321   // Setup dimensions and position so actor is not skipped by culling.
322   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
323   actor.SetProperty(Actor::Property::SIZE, Vector2(width, height));
324   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
325   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
326
327   return actor;
328 }
329
330 Actor CreateActorWithContent16x16()
331 {
332   return CreateActorWithContent(16, 16);
333 }
334
335 void GenerateTrace(TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& callTrace)
336 {
337   enabledDisableTrace.Reset();
338   callTrace.Reset();
339   enabledDisableTrace.Enable(true);
340   callTrace.Enable(true);
341
342   application.SendNotification();
343   application.Render();
344
345   enabledDisableTrace.Enable(false);
346   callTrace.Enable(false);
347 }
348
349 void CheckColorMask(TestGlAbstraction& glAbstraction, bool maskValue)
350 {
351   const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
352
353   DALI_TEST_EQUALS<bool>(colorMaskParams.red, maskValue, TEST_LOCATION);
354   DALI_TEST_EQUALS<bool>(colorMaskParams.green, maskValue, TEST_LOCATION);
355   DALI_TEST_EQUALS<bool>(colorMaskParams.blue, maskValue, TEST_LOCATION);
356
357   // @todo only test alpha if the framebuffer has an alpha channel
358   //DALI_TEST_EQUALS<bool>(colorMaskParams.alpha, maskValue, TEST_LOCATION);
359 }
360
361 } // anonymous namespace
362
363 //& purpose: Testing New API
364 int UtcDaliActorNew(void)
365 {
366   TestApplication application;
367
368   Actor actor = Actor::New();
369
370   DALI_TEST_CHECK(actor);
371   END_TEST;
372 }
373
374 //& purpose: Testing Dali::Actor::DownCast()
375 int UtcDaliActorDownCastP(void)
376 {
377   TestApplication application;
378   tet_infoline("Testing Dali::Actor::DownCast()");
379
380   Actor      actor = Actor::New();
381   BaseHandle object(actor);
382   Actor      actor2 = Actor::DownCast(object);
383   DALI_TEST_CHECK(actor2);
384   END_TEST;
385 }
386
387 //& purpose: Testing Dali::Actor::DownCast()
388 int UtcDaliActorDownCastN(void)
389 {
390   TestApplication application;
391   tet_infoline("Testing Dali::Actor::DownCast()");
392
393   BaseHandle unInitializedObject;
394   Actor      actor = Actor::DownCast(unInitializedObject);
395   DALI_TEST_CHECK(!actor);
396   END_TEST;
397 }
398
399 int UtcDaliActorMoveConstructor(void)
400 {
401   TestApplication application;
402
403   Actor actor = Actor::New();
404   DALI_TEST_CHECK(actor);
405
406   int id = actor.GetProperty<int>(Actor::Property::ID);
407
408   Actor moved = std::move(actor);
409   DALI_TEST_CHECK(moved);
410   DALI_TEST_EQUALS(id, moved.GetProperty<int>(Actor::Property::ID), TEST_LOCATION);
411   DALI_TEST_CHECK(!actor);
412
413   END_TEST;
414 }
415
416 int UtcDaliActorMoveAssignment(void)
417 {
418   TestApplication application;
419
420   Actor actor = Actor::New();
421   DALI_TEST_CHECK(actor);
422
423   int id = actor.GetProperty<int>(Actor::Property::ID);
424
425   Actor moved;
426   moved = std::move(actor);
427   DALI_TEST_CHECK(moved);
428   DALI_TEST_EQUALS(id, moved.GetProperty<int>(Actor::Property::ID), TEST_LOCATION);
429   DALI_TEST_CHECK(!actor);
430
431   END_TEST;
432 }
433
434 //& purpose: Testing Dali::Actor::GetName()
435 int UtcDaliActorGetName(void)
436 {
437   TestApplication application;
438
439   Actor actor = Actor::New();
440
441   DALI_TEST_CHECK(actor.GetProperty<std::string>(Actor::Property::NAME).empty());
442   END_TEST;
443 }
444
445 //& purpose: Testing Dali::Actor::SetName()
446 int UtcDaliActorSetName(void)
447 {
448   TestApplication application;
449
450   string str("ActorName");
451   Actor  actor = Actor::New();
452
453   actor.SetProperty(Actor::Property::NAME, str);
454   DALI_TEST_CHECK(actor.GetProperty<std::string>(Actor::Property::NAME) == str);
455   END_TEST;
456 }
457
458 int UtcDaliActorGetId(void)
459 {
460   tet_infoline("Testing Dali::Actor::UtcDaliActo.GetProperty< int >( Actor::Property::ID )");
461   TestApplication application;
462
463   Actor first  = Actor::New();
464   Actor second = Actor::New();
465   Actor third  = Actor::New();
466
467   DALI_TEST_CHECK(first.GetProperty<int>(Actor::Property::ID) != second.GetProperty<int>(Actor::Property::ID));
468   DALI_TEST_CHECK(second.GetProperty<int>(Actor::Property::ID) != third.GetProperty<int>(Actor::Property::ID));
469   END_TEST;
470 }
471
472 int UtcDaliActorIsRoot(void)
473 {
474   TestApplication application;
475
476   Actor actor = Actor::New();
477   DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::IS_ROOT));
478
479   // get the root layer
480   actor = application.GetScene().GetLayer(0);
481   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::IS_ROOT));
482   END_TEST;
483 }
484
485 int UtcDaliActorOnScene(void)
486 {
487   TestApplication application;
488
489   Actor actor = Actor::New();
490   DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
491
492   // get the root layer
493   actor = application.GetScene().GetLayer(0);
494   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
495   END_TEST;
496 }
497
498 int UtcDaliActorIsLayer(void)
499 {
500   TestApplication application;
501
502   Actor actor = Actor::New();
503   DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::IS_LAYER));
504
505   // get the root layer
506   actor = application.GetScene().GetLayer(0);
507   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::IS_LAYER));
508   END_TEST;
509 }
510
511 int UtcDaliActorGetLayer(void)
512 {
513   TestApplication application;
514
515   Actor actor = Actor::New();
516   application.GetScene().Add(actor);
517   Layer layer = actor.GetLayer();
518
519   DALI_TEST_CHECK(layer);
520
521   // get the root layers layer
522   actor = application.GetScene().GetLayer(0);
523   DALI_TEST_CHECK(actor.GetLayer());
524   END_TEST;
525 }
526
527 int UtcDaliActorAddP(void)
528 {
529   tet_infoline("Testing Actor::Add");
530   TestApplication application;
531
532   Actor parent = Actor::New();
533   Actor child  = Actor::New();
534
535   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
536
537   parent.Add(child);
538
539   DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
540
541   Actor parent2 = Actor::New();
542   parent2.Add(child);
543
544   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
545   DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
546
547   // try Adding to same parent again, works
548   parent2.Add(child);
549   DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
550
551   // try reparenting an orphaned child
552   {
553     Actor temporaryParent = Actor::New();
554     temporaryParent.Add(child);
555     DALI_TEST_EQUALS(parent2.GetChildCount(), 0u, TEST_LOCATION);
556   }
557   // temporaryParent has now died, reparent the orphaned child
558   parent2.Add(child);
559   DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
560
561   END_TEST;
562 }
563
564 int UtcDaliActorAddN(void)
565 {
566   tet_infoline("Testing Actor::Add");
567   TestApplication application;
568
569   Actor child = Actor::New();
570
571   Actor parent2 = Actor::New();
572   parent2.Add(child);
573
574   // try illegal Add
575   try
576   {
577     parent2.Add(parent2);
578     tet_printf("Assertion test failed - no Exception\n");
579     tet_result(TET_FAIL);
580   }
581   catch(Dali::DaliException& e)
582   {
583     DALI_TEST_PRINT_ASSERT(e);
584     DALI_TEST_ASSERT(e, "&mOwner != &child", TEST_LOCATION);
585     DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
586   }
587   catch(...)
588   {
589     tet_printf("Assertion test failed - wrong Exception\n");
590     tet_result(TET_FAIL);
591   }
592
593   // try reparenting root
594   try
595   {
596     parent2.Add(application.GetScene().GetLayer(0));
597     tet_printf("Assertion test failed - no Exception\n");
598     tet_result(TET_FAIL);
599   }
600   catch(Dali::DaliException& e)
601   {
602     DALI_TEST_PRINT_ASSERT(e);
603     DALI_TEST_ASSERT(e, "!child.IsRoot()", TEST_LOCATION);
604     DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
605   }
606   catch(...)
607   {
608     tet_printf("Assertion test failed - wrong Exception\n");
609     tet_result(TET_FAIL);
610   }
611
612   // try Add empty
613   try
614   {
615     Actor empty;
616     parent2.Add(empty);
617     tet_printf("Assertion test failed - no Exception\n");
618     tet_result(TET_FAIL);
619   }
620   catch(Dali::DaliException& e)
621   {
622     DALI_TEST_PRINT_ASSERT(e);
623     DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
624     DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
625   }
626   catch(...)
627   {
628     tet_printf("Assertion test failed - wrong Exception\n");
629     tet_result(TET_FAIL);
630   }
631
632   END_TEST;
633 }
634
635 int UtcDaliActorRemoveN(void)
636 {
637   tet_infoline("Testing Actor::Remove");
638   TestApplication application;
639
640   Actor parent = Actor::New();
641   Actor child  = Actor::New();
642   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
643
644   parent.Add(child);
645   DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
646
647   parent.Remove(child);
648   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
649
650   // remove again, no problem
651   parent.Remove(child);
652   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
653
654   // add child back
655   parent.Add(child);
656   DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
657   // try Remove self, its a no-op
658   parent.Remove(parent);
659   DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
660
661   // try Remove empty
662   try
663   {
664     Actor empty;
665     parent.Remove(empty);
666     tet_printf("Assertion test failed - no Exception\n");
667     tet_result(TET_FAIL);
668   }
669   catch(Dali::DaliException& e)
670   {
671     DALI_TEST_PRINT_ASSERT(e);
672     DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
673     DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
674   }
675   catch(...)
676   {
677     tet_printf("Assertion test failed - wrong Exception\n");
678     tet_result(TET_FAIL);
679   }
680   END_TEST;
681 }
682
683 int UtcDaliActorRemoveP(void)
684 {
685   TestApplication application;
686
687   Actor parent = Actor::New();
688   Actor child  = Actor::New();
689   Actor random = Actor::New();
690
691   application.GetScene().Add(parent);
692
693   DALI_TEST_CHECK(parent.GetChildCount() == 0);
694
695   parent.Add(child);
696
697   DALI_TEST_CHECK(parent.GetChildCount() == 1);
698
699   parent.Remove(random);
700
701   DALI_TEST_CHECK(parent.GetChildCount() == 1);
702
703   application.GetScene().Remove(parent);
704
705   DALI_TEST_CHECK(parent.GetChildCount() == 1);
706   END_TEST;
707 }
708
709 int UtcDaliActorSwitchParentN(void)
710 {
711   tet_infoline("Testing Actor::UtcDaliActorSwitchParentN");
712   TestApplication application;
713
714   Actor parent1 = Actor::New();
715   Actor child   = Actor::New();
716
717   DALI_TEST_EQUALS(parent1.GetChildCount(), 0u, TEST_LOCATION);
718
719   parent1.Add(child);
720
721   DALI_TEST_EQUALS(parent1.GetChildCount(), 1u, TEST_LOCATION);
722
723   Actor parent2 = Actor::New();
724
725   DALI_TEST_EQUALS(parent2.GetChildCount(), 0u, TEST_LOCATION);
726
727   // Try switch parent with that both of parent1 and parent2 are off scene.
728   DevelActor::SwitchParent(child, parent2);
729
730   DALI_TEST_EQUALS(parent1.GetChildCount(), 1u, TEST_LOCATION);
731   DALI_TEST_EQUALS(parent2.GetChildCount(), 0u, TEST_LOCATION);
732   END_TEST;
733 }
734
735 int UtcDaliActorGetChildCount(void)
736 {
737   TestApplication application;
738
739   Actor parent = Actor::New();
740   Actor child  = Actor::New();
741
742   DALI_TEST_CHECK(parent.GetChildCount() == 0);
743
744   parent.Add(child);
745
746   DALI_TEST_CHECK(parent.GetChildCount() == 1);
747   END_TEST;
748 }
749
750 int UtcDaliActorGetChildren01(void)
751 {
752   TestApplication application;
753
754   Actor parent = Actor::New();
755   Actor first  = Actor::New();
756   Actor second = Actor::New();
757   Actor third  = Actor::New();
758
759   parent.Add(first);
760   parent.Add(second);
761   parent.Add(third);
762
763   DALI_TEST_CHECK(parent.GetChildAt(0) == first);
764   DALI_TEST_CHECK(parent.GetChildAt(1) == second);
765   DALI_TEST_CHECK(parent.GetChildAt(2) == third);
766   END_TEST;
767 }
768
769 int UtcDaliActorGetChildren02(void)
770 {
771   TestApplication application;
772
773   Actor parent = Actor::New();
774   Actor first  = Actor::New();
775   Actor second = Actor::New();
776   Actor third  = Actor::New();
777
778   parent.Add(first);
779   parent.Add(second);
780   parent.Add(third);
781
782   const Actor& constParent = parent;
783
784   DALI_TEST_CHECK(constParent.GetChildAt(0) == first);
785   DALI_TEST_CHECK(constParent.GetChildAt(1) == second);
786   DALI_TEST_CHECK(constParent.GetChildAt(2) == third);
787   END_TEST;
788 }
789
790 int UtcDaliActorGetParent01(void)
791 {
792   TestApplication application;
793
794   Actor parent = Actor::New();
795   Actor child  = Actor::New();
796
797   parent.Add(child);
798
799   DALI_TEST_CHECK(child.GetParent() == parent);
800   END_TEST;
801 }
802
803 int UtcDaliActorGetParent02(void)
804 {
805   TestApplication application;
806
807   Actor actor = Actor::New();
808
809   DALI_TEST_CHECK(!actor.GetParent());
810   END_TEST;
811 }
812
813 int UtcDaliActorCustomProperty(void)
814 {
815   TestApplication application;
816
817   Actor actor = Actor::New();
818   application.GetScene().Add(actor);
819
820   float           startValue(1.0f);
821   Property::Index index = actor.RegisterProperty("testProperty", startValue);
822   DALI_TEST_CHECK(actor.GetProperty<float>(index) == startValue);
823
824   application.SendNotification();
825   application.Render(0);
826   DALI_TEST_CHECK(actor.GetProperty<float>(index) == startValue);
827
828   actor.SetProperty(index, 5.0f);
829
830   application.SendNotification();
831   application.Render(0);
832   DALI_TEST_CHECK(actor.GetProperty<float>(index) == 5.0f);
833   END_TEST;
834 }
835
836 int UtcDaliActorCustomPropertyIntToFloat(void)
837 {
838   TestApplication application;
839
840   Actor actor = Actor::New();
841   application.GetScene().Add(actor);
842
843   float           startValue(5.0f);
844   Property::Index index = actor.RegisterProperty("testProperty", startValue);
845   DALI_TEST_CHECK(actor.GetProperty<float>(index) == startValue);
846
847   application.SendNotification();
848   application.Render(0);
849   DALI_TEST_CHECK(actor.GetProperty<float>(index) == startValue);
850
851   actor.SetProperty(index, int(1));
852
853   application.SendNotification();
854   application.Render(0);
855   DALI_TEST_CHECK(actor.GetProperty<float>(index) == 1.0f);
856   END_TEST;
857 }
858
859 int UtcDaliActorCustomPropertyFloatToInt(void)
860 {
861   TestApplication application;
862
863   Actor actor = Actor::New();
864   application.GetScene().Add(actor);
865
866   int             startValue(5);
867   Property::Index index = actor.RegisterProperty("testProperty", startValue);
868   DALI_TEST_CHECK(actor.GetProperty<int>(index) == startValue);
869
870   application.SendNotification();
871   application.Render(0);
872   DALI_TEST_CHECK(actor.GetProperty<int>(index) == startValue);
873
874   actor.SetProperty(index, float(1.5));
875
876   application.SendNotification();
877   application.Render(0);
878   DALI_TEST_CHECK(actor.GetProperty<int>(index) == 1);
879   END_TEST;
880 }
881
882 int UtcDaliActorSetParentOrigin(void)
883 {
884   TestApplication application;
885
886   Actor actor = Actor::New();
887
888   Vector3 vector(0.7f, 0.8f, 0.9f);
889   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
890
891   actor.SetProperty(Actor::Property::PARENT_ORIGIN, vector);
892
893   // flush the queue and render once
894   application.SendNotification();
895   application.Render();
896
897   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
898
899   application.GetScene().Add(actor);
900
901   actor.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0.1f, 0.2f, 0.3f));
902
903   // flush the queue and render once
904   application.SendNotification();
905   application.Render();
906
907   DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), TEST_LOCATION);
908
909   application.GetScene().Remove(actor);
910   END_TEST;
911 }
912
913 int UtcDaliActorSetParentOriginIndividual(void)
914 {
915   TestApplication application;
916
917   Actor actor = Actor::New();
918
919   Vector3 vector(0.7f, 0.8f, 0.9f);
920   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
921
922   actor.SetProperty(Actor::Property::PARENT_ORIGIN_X, vector.x);
923
924   // flush the queue and render once
925   application.SendNotification();
926   application.Render();
927
928   DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN).x, TEST_LOCATION);
929
930   actor.SetProperty(Actor::Property::PARENT_ORIGIN_Y, vector.y);
931
932   // flush the queue and render once
933   application.SendNotification();
934   application.Render();
935
936   DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN).y, TEST_LOCATION);
937
938   actor.SetProperty(Actor::Property::PARENT_ORIGIN_Z, vector.z);
939
940   // flush the queue and render once
941   application.SendNotification();
942   application.Render();
943
944   DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN).z, TEST_LOCATION);
945
946   END_TEST;
947 }
948
949 int UtcDaliActorGetCurrentParentOrigin(void)
950 {
951   TestApplication application;
952
953   Actor actor = Actor::New();
954
955   Vector3 vector(0.7f, 0.8f, 0.9f);
956   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
957
958   actor.SetProperty(Actor::Property::PARENT_ORIGIN, vector);
959
960   // flush the queue and render once
961   application.SendNotification();
962   application.Render();
963
964   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
965   END_TEST;
966 }
967
968 int UtcDaliActorSetAnchorPoint(void)
969 {
970   TestApplication application;
971
972   Actor actor = Actor::New();
973
974   Vector3 vector(0.7f, 0.8f, 0.9f);
975   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
976
977   actor.SetProperty(Actor::Property::ANCHOR_POINT, vector);
978
979   // flush the queue and render once
980   application.SendNotification();
981   application.Render();
982
983   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
984
985   application.GetScene().Add(actor);
986
987   actor.SetProperty(Actor::Property::ANCHOR_POINT, Vector3(0.1f, 0.2f, 0.3f));
988   // flush the queue and render once
989   application.SendNotification();
990   application.Render();
991
992   DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), TEST_LOCATION);
993
994   application.GetScene().Remove(actor);
995   END_TEST;
996 }
997
998 int UtcDaliActorSetAnchorPointIndividual(void)
999 {
1000   TestApplication application;
1001
1002   Actor actor = Actor::New();
1003
1004   Vector3 vector(0.7f, 0.8f, 0.9f);
1005   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
1006
1007   actor.SetProperty(Actor::Property::ANCHOR_POINT_X, vector.x);
1008
1009   // flush the queue and render once
1010   application.SendNotification();
1011   application.Render();
1012
1013   DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT).x, TEST_LOCATION);
1014
1015   actor.SetProperty(Actor::Property::ANCHOR_POINT_Y, vector.y);
1016
1017   // flush the queue and render once
1018   application.SendNotification();
1019   application.Render();
1020
1021   DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT).y, TEST_LOCATION);
1022
1023   actor.SetProperty(Actor::Property::ANCHOR_POINT_Z, vector.z);
1024
1025   // flush the queue and render once
1026   application.SendNotification();
1027   application.Render();
1028
1029   DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT).z, TEST_LOCATION);
1030
1031   END_TEST;
1032 }
1033
1034 int UtcDaliActorGetCurrentAnchorPoint(void)
1035 {
1036   TestApplication application;
1037
1038   Actor actor = Actor::New();
1039
1040   Vector3 vector(0.7f, 0.8f, 0.9f);
1041   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
1042
1043   actor.SetProperty(Actor::Property::ANCHOR_POINT, vector);
1044
1045   // flush the queue and render once
1046   application.SendNotification();
1047   application.Render();
1048
1049   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
1050   END_TEST;
1051 }
1052
1053 int UtcDaliActorSetSize01(void)
1054 {
1055   TestApplication application;
1056
1057   Actor   actor = Actor::New();
1058   Vector3 vector(100.0f, 100.0f, 0.0f);
1059
1060   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1061
1062   actor.SetProperty(Actor::Property::SIZE, Vector2(vector.x, vector.y));
1063
1064   // Immediately retrieve the size after setting
1065   Vector3 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1066   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1067   DALI_TEST_EQUALS(vector.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
1068   DALI_TEST_EQUALS(vector.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
1069   DALI_TEST_EQUALS(vector.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
1070
1071   // Flush the queue and render once
1072   application.SendNotification();
1073   application.Render();
1074
1075   // Check the size in the new frame
1076   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1077
1078   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1079   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1080   DALI_TEST_EQUALS(vector.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
1081   DALI_TEST_EQUALS(vector.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
1082   DALI_TEST_EQUALS(vector.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
1083
1084   // Check async behaviour
1085   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
1086   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1087   DALI_TEST_EQUALS(vector.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
1088   DALI_TEST_EQUALS(vector.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
1089   DALI_TEST_EQUALS(vector.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
1090
1091   // Change the resize policy and check whether the size stays the same
1092   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
1093
1094   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1095   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1096
1097   // Set a new size after resize policy is changed and check the new size
1098   actor.SetProperty(Actor::Property::SIZE, Vector3(0.1f, 0.2f, 0.0f));
1099
1100   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1101   DALI_TEST_EQUALS(currentSize, Vector3(0.1f, 0.2f, 0.0f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1102
1103   // Change the resize policy again and check whether the new size stays the same
1104   actor.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
1105
1106   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1107   DALI_TEST_EQUALS(currentSize, Vector3(0.1f, 0.2f, 0.0f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1108
1109   // Set another new size after resize policy is changed and check the new size
1110   actor.SetProperty(Actor::Property::SIZE, Vector3(50.0f, 60.0f, 0.0f));
1111
1112   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1113   DALI_TEST_EQUALS(currentSize, Vector3(50.0f, 60.0f, 0.0f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1114
1115   END_TEST;
1116 }
1117
1118 int UtcDaliActorSetSize02(void)
1119 {
1120   TestApplication application;
1121
1122   Actor   actor = Actor::New();
1123   Vector3 vector(100.0f, 100.0f, 100.0f);
1124
1125   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1126
1127   actor.SetProperty(Actor::Property::SIZE, Vector3(vector.x, vector.y, vector.z));
1128
1129   // Immediately check the size after setting
1130   Vector3 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1131   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1132
1133   // flush the queue and render once
1134   application.SendNotification();
1135   application.Render();
1136
1137   // Check the size in the new frame
1138   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1139
1140   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1141   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1142
1143   END_TEST;
1144 }
1145
1146 // SetSize(Vector2 size)
1147 int UtcDaliActorSetSize03(void)
1148 {
1149   TestApplication application;
1150
1151   Actor   actor = Actor::New();
1152   Vector3 vector(100.0f, 100.0f, 0.0f);
1153
1154   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1155
1156   actor.SetProperty(Actor::Property::SIZE, Vector2(vector.x, vector.y));
1157
1158   // Immediately check the size after setting
1159   Vector3 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1160   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1161
1162   // flush the queue and render once
1163   application.SendNotification();
1164   application.Render();
1165
1166   // Check the size in the new frame
1167   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1168
1169   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1170   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1171
1172   END_TEST;
1173 }
1174
1175 // SetSize(Vector3 size)
1176 int UtcDaliActorSetSize04(void)
1177 {
1178   TestApplication application;
1179
1180   Actor   actor = Actor::New();
1181   Vector3 vector(100.0f, 100.0f, 100.0f);
1182
1183   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1184
1185   actor.SetProperty(Actor::Property::SIZE, vector);
1186
1187   // Immediately check the size after setting
1188   Vector3 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1189   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1190
1191   // flush the queue and render once
1192   application.SendNotification();
1193   application.Render();
1194
1195   // Check the size in the new frame
1196   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1197
1198   application.GetScene().Add(actor);
1199   actor.SetProperty(Actor::Property::SIZE, Vector3(0.1f, 0.2f, 0.3f));
1200
1201   // Immediately check the size after setting
1202   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1203   DALI_TEST_EQUALS(currentSize, Vector3(0.1f, 0.2f, 0.3f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1204
1205   // flush the queue and render once
1206   application.SendNotification();
1207   application.Render();
1208
1209   // Check the size in the new frame
1210   DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE), TEST_LOCATION);
1211
1212   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1213   DALI_TEST_EQUALS(currentSize, Vector3(0.1f, 0.2f, 0.3f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1214
1215   application.GetScene().Remove(actor);
1216   END_TEST;
1217 }
1218
1219 int UtcDaliActorSetSize05(void)
1220 {
1221   TestApplication application;
1222
1223   Actor   parent = Actor::New();
1224   Vector2 vector(200.0f, 200.0f);
1225   DALI_TEST_CHECK(vector != parent.GetCurrentProperty<Vector2>(Actor::Property::SIZE));
1226
1227   parent.SetProperty(Actor::Property::SIZE, vector);
1228   Vector2 size = parent.GetProperty(Actor::Property::SIZE).Get<Vector2>();
1229   DALI_TEST_EQUALS(size, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1230
1231   Actor child = Actor::New();
1232   DALI_TEST_CHECK(vector != child.GetCurrentProperty<Vector2>(Actor::Property::SIZE));
1233   child.SetProperty(Actor::Property::SIZE, vector);
1234   size = parent.GetProperty(Actor::Property::SIZE).Get<Vector2>();
1235   DALI_TEST_EQUALS(size, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1236
1237   // flush the queue and render once
1238   application.SendNotification();
1239   application.Render();
1240
1241   DALI_TEST_CHECK(vector == parent.GetCurrentProperty<Vector2>(Actor::Property::SIZE));
1242
1243   END_TEST;
1244 }
1245
1246 int UtcDaliActorSetSizeIndividual(void)
1247 {
1248   TestApplication application;
1249
1250   Actor actor = Actor::New();
1251
1252   Vector3 vector(0.7f, 0.8f, 0.9f);
1253   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1254
1255   actor.SetProperty(Actor::Property::SIZE_WIDTH, vector.width);
1256
1257   // Immediately check the width after setting
1258   float sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1259   DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1260
1261   // flush the queue and render once
1262   application.SendNotification();
1263   application.Render();
1264
1265   // Check the width in the new frame
1266   DALI_TEST_EQUALS(vector.width, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, TEST_LOCATION);
1267
1268   sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1269   DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1270
1271   actor.SetProperty(Actor::Property::SIZE_HEIGHT, vector.height);
1272
1273   // Immediately check the height after setting
1274   float sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1275   DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1276
1277   // flush the queue and render once
1278   application.SendNotification();
1279   application.Render();
1280
1281   // Check the height in the new frame
1282   DALI_TEST_EQUALS(vector.height, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, TEST_LOCATION);
1283
1284   sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1285   DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1286
1287   actor.SetProperty(Actor::Property::SIZE_DEPTH, vector.depth);
1288
1289   // Immediately check the depth after setting
1290   float sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1291   DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1292
1293   // flush the queue and render once
1294   application.SendNotification();
1295   application.Render();
1296
1297   // Check the depth in the new frame
1298   DALI_TEST_EQUALS(vector.depth, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).depth, TEST_LOCATION);
1299
1300   sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1301   DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1302
1303   // Change the resize policy and check whether the size stays the same
1304   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
1305
1306   sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1307   DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1308
1309   sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1310   DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1311
1312   sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1313   DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1314
1315   // Change the resize policy again and check whether the size stays the same
1316   actor.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
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   sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1322   DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1323
1324   sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1325   DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1326
1327   END_TEST;
1328 }
1329
1330 int UtcDaliActorSetSizeIndividual02(void)
1331 {
1332   TestApplication application;
1333
1334   Actor actor = Actor::New();
1335   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
1336   application.GetScene().Add(actor);
1337
1338   Vector3 vector(100.0f, 200.0f, 400.0f);
1339   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1340
1341   actor.SetProperty(Actor::Property::SIZE_WIDTH, vector.width);
1342   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>(), vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1343
1344   actor.SetProperty(Actor::Property::SIZE_HEIGHT, vector.height);
1345   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>(), vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1346
1347   actor.SetProperty(Actor::Property::SIZE_DEPTH, vector.depth);
1348   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>(), vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1349
1350   // flush the queue and render once
1351   application.SendNotification();
1352   application.Render();
1353
1354   // Check the width in the new frame
1355   DALI_TEST_EQUALS(vector.width, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, TEST_LOCATION);
1356   DALI_TEST_EQUALS(vector.height, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, TEST_LOCATION);
1357
1358   END_TEST;
1359 }
1360
1361 int UtcDaliActorGetCurrentSize(void)
1362 {
1363   TestApplication application;
1364
1365   Actor   actor = Actor::New();
1366   Vector3 vector(100.0f, 100.0f, 20.0f);
1367
1368   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1369
1370   actor.SetProperty(Actor::Property::SIZE, vector);
1371
1372   // flush the queue and render once
1373   application.SendNotification();
1374   application.Render();
1375
1376   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1377   END_TEST;
1378 }
1379
1380 int UtcDaliActorGetNaturalSize(void)
1381 {
1382   TestApplication application;
1383
1384   Actor   actor = Actor::New();
1385   Vector3 vector(0.0f, 0.0f, 0.0f);
1386
1387   DALI_TEST_CHECK(actor.GetNaturalSize() == vector);
1388
1389   END_TEST;
1390 }
1391
1392 int UtcDaliActorGetCurrentSizeImmediate(void)
1393 {
1394   TestApplication application;
1395
1396   Actor   actor = Actor::New();
1397   Vector3 vector(100.0f, 100.0f, 20.0f);
1398
1399   DALI_TEST_CHECK(vector != actor.GetTargetSize());
1400   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1401
1402   actor.SetProperty(Actor::Property::SIZE, vector);
1403
1404   DALI_TEST_CHECK(vector == actor.GetTargetSize());
1405   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1406
1407   // flush the queue and render once
1408   application.SendNotification();
1409   application.Render();
1410
1411   DALI_TEST_CHECK(vector == actor.GetTargetSize());
1412   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1413
1414   // Animation
1415   // Build the animation
1416   const float   durationSeconds = 2.0f;
1417   Animation     animation       = Animation::New(durationSeconds);
1418   const Vector3 targetValue(10.0f, 20.0f, 30.0f);
1419   animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
1420
1421   DALI_TEST_CHECK(actor.GetTargetSize() == vector);
1422
1423   application.GetScene().Add(actor);
1424
1425   // Start the animation
1426   animation.Play();
1427
1428   application.SendNotification();
1429   application.Render(static_cast<unsigned int>(durationSeconds * 1000.0f));
1430
1431   DALI_TEST_CHECK(actor.GetTargetSize() == targetValue);
1432
1433   END_TEST;
1434 }
1435
1436 int UtcDaliActorCalculateScreenExtents(void)
1437 {
1438   TestApplication application;
1439
1440   Actor actor = Actor::New();
1441
1442   actor.SetProperty(Actor::Property::POSITION, Vector3(2.0f, 2.0f, 16.0f));
1443   actor.SetProperty(Actor::Property::SIZE, Vector3{1.0f, 1.0f, 1.0f});
1444
1445   application.GetScene().Add(actor);
1446
1447   application.SendNotification();
1448   application.Render();
1449
1450   auto expectedExtent = Rect<>{1.5f, 1.5f, 1.0f, 1.0f};
1451   auto actualExtent   = DevelActor::CalculateScreenExtents(actor);
1452   DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1453   DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1454   DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1455   DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1456
1457   application.GetScene().Remove(actor);
1458   END_TEST;
1459 }
1460
1461 int UtcDaliActorCalculateCurrentScreenExtents(void)
1462 {
1463   TestApplication application;
1464
1465   Actor actor = Actor::New();
1466
1467   actor.SetProperty(Actor::Property::POSITION, Vector3(2.0f, 2.0f, 16.0f));
1468   actor.SetProperty(Actor::Property::SIZE, Vector3{1.0f, 1.0f, 1.0f});
1469
1470   application.GetScene().Add(actor);
1471
1472   application.SendNotification();
1473   application.Render();
1474
1475   auto expectedPosition = Vector2(2.0f, 2.0f);
1476   auto actualPosition   = DevelActor::CalculateScreenPosition(actor);
1477   DALI_TEST_EQUALS(expectedPosition.x, actualPosition.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1478   DALI_TEST_EQUALS(expectedPosition.y, actualPosition.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1479
1480   auto expectedExtent = Rect<>{1.5f, 1.5f, 1.0f, 1.0f};
1481   auto actualExtent   = DevelActor::CalculateScreenExtents(actor);
1482   DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1483   DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1484   DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1485   DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1486
1487   Animation animation = Animation::New(1.0f);
1488   animation.AnimateTo(Property(actor, Actor::Property::POSITION), Vector3(6.0f, 4.0f, 0.0f));
1489   animation.AnimateTo(Property(actor, Actor::Property::SIZE), Vector3(3.0f, 7.0f, 1.0f));
1490   animation.Play();
1491
1492   application.SendNotification();
1493   application.Render(500u);
1494
1495   // Animate 50%.
1496   expectedPosition = Vector2(6.0f, 4.0f);
1497   actualPosition   = DevelActor::CalculateScreenPosition(actor);
1498   DALI_TEST_EQUALS(expectedPosition.x, actualPosition.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1499   DALI_TEST_EQUALS(expectedPosition.y, actualPosition.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1500
1501   expectedExtent = Rect<>(4.5f, 0.5f, 3.0f, 7.0f);
1502   actualExtent   = DevelActor::CalculateScreenExtents(actor);
1503   DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1504   DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1505   DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1506   DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1507
1508   expectedPosition = Vector2(4.0f, 3.0f);
1509   actualPosition   = actor.GetProperty<Vector2>(Actor::Property::SCREEN_POSITION);
1510   DALI_TEST_EQUALS(expectedPosition.x, actualPosition.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1511   DALI_TEST_EQUALS(expectedPosition.y, actualPosition.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1512
1513   expectedExtent = Rect<>(3.0f, 1.0f, 2.0f, 4.0f);
1514   actualExtent   = DevelActor::CalculateCurrentScreenExtents(actor);
1515   DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1516   DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1517   DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1518   DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1519
1520   application.GetScene().Remove(actor);
1521   END_TEST;
1522 }
1523
1524 int UtcDaliActorCalculateScreenExtentsInCustomCameraAndLayer3D(void)
1525 {
1526   TestApplication    application;
1527   Integration::Scene scene = application.GetScene();
1528
1529   // Make 3D Layer
1530   Layer layer = Layer::New();
1531   layer.SetProperty(Layer::Property::BEHAVIOR, Layer::Behavior::LAYER_3D);
1532   layer.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1533   layer.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1534
1535   scene.Add(layer);
1536
1537   // Build custom camera with top-view
1538   CameraActor cameraActor = scene.GetRenderTaskList().GetTask(0).GetCameraActor();
1539   {
1540     // Default camera position at +z and looking -z axis. (orientation is [ Axis: [0, 1, 0], Angle: 180 degrees ])
1541     Vector3    cameraPos    = cameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
1542     Quaternion cameraOrient = cameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
1543
1544     {
1545       std::ostringstream oss;
1546       oss << cameraPos << "\n";
1547       oss << cameraOrient << "\n";
1548       tet_printf("%s\n", oss.str().c_str());
1549     }
1550
1551     cameraActor.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -cameraPos.z, 0.0f));
1552     cameraActor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::XAXIS) * cameraOrient);
1553
1554     // Now, upside : -Z, leftside : -X, foward : +Y
1555
1556     cameraPos    = cameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
1557     cameraOrient = cameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
1558     {
1559       std::ostringstream oss;
1560       oss << cameraPos << "\n";
1561       oss << cameraOrient << "\n";
1562       tet_printf("%s\n", oss.str().c_str());
1563     }
1564   }
1565
1566   Actor actor = Actor::New();
1567   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1568   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1569   actor.SetProperty(Actor::Property::POSITION, Vector3(2.0f, 0.0f, 16.0f));
1570   actor.SetProperty(Actor::Property::SIZE, Vector3{1.0f, 0.0f, 3.0f});
1571
1572   layer.Add(actor);
1573
1574   application.SendNotification();
1575   application.Render();
1576
1577   Vector2 sceneSize = scene.GetSize();
1578
1579   auto expectedExtent = Rect<>{sceneSize.x * 0.5f + 1.5f, sceneSize.y * 0.5f + 14.5f, 1.0f, 3.0f};
1580   auto actualExtent   = DevelActor::CalculateScreenExtents(actor);
1581   auto actualPosition = DevelActor::CalculateScreenPosition(actor);
1582   {
1583     std::ostringstream oss;
1584     oss << expectedExtent << "\n";
1585     oss << actualExtent << "\n";
1586     oss << actualPosition << "\n";
1587     tet_printf("%s\n", oss.str().c_str());
1588   }
1589
1590   DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1591   DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1592   DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1593   DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1594
1595   // Since anchor point is center, screen position is same as center of expect extents
1596   DALI_TEST_EQUALS(expectedExtent.x + expectedExtent.width * 0.5f, actualPosition.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1597   DALI_TEST_EQUALS(expectedExtent.y + expectedExtent.height * 0.5f, actualPosition.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1598
1599   END_TEST;
1600 }
1601
1602 int UtcDaliActorCalculateScreenInCustomCameraAndOffscreenLayer3D(void)
1603 {
1604   TestApplication    application;
1605   Integration::Scene scene     = application.GetScene();
1606   Vector2            sceneSize = scene.GetSize();
1607
1608   // Make 3D Layer
1609   Layer layer = Layer::New();
1610   layer.SetProperty(Layer::Property::BEHAVIOR, Layer::Behavior::LAYER_3D);
1611   layer.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1612   layer.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1613   layer.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
1614   layer.SetProperty(Actor::Property::SIZE, sceneSize);
1615
1616   scene.Add(layer);
1617
1618   // Build custom camera with top-view
1619   CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
1620
1621   offscreenCameraActor.SetPerspectiveProjection(sceneSize);
1622   offscreenCameraActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1623   offscreenCameraActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1624
1625   scene.Add(offscreenCameraActor);
1626   {
1627     // Default camera position at +z and looking -z axis. (orientation is [ Axis: [0, 1, 0], Angle: 180 degrees ])
1628     Vector3    cameraPos    = offscreenCameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
1629     Quaternion cameraOrient = offscreenCameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
1630
1631     {
1632       std::ostringstream oss;
1633       oss << cameraPos << "\n";
1634       oss << cameraOrient << "\n";
1635       tet_printf("%s\n", oss.str().c_str());
1636     }
1637
1638     offscreenCameraActor.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -cameraPos.z, 0.0f));
1639     offscreenCameraActor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::XAXIS) * cameraOrient);
1640
1641     // Now, upside : -Z, leftside : -X, foward : +Y
1642
1643     cameraPos    = offscreenCameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
1644     cameraOrient = offscreenCameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
1645     {
1646       std::ostringstream oss;
1647       oss << cameraPos << "\n";
1648       oss << cameraOrient << "\n";
1649       tet_printf("%s\n", oss.str().c_str());
1650     }
1651   }
1652   Vector3 sourcePosition{2.0f, 0.0f, 16.0f};
1653   Vector3 sourceSize{1.0f, 0.0f, 3.0f};
1654
1655   Actor sourceActor = Actor::New();
1656   sourceActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1657   sourceActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1658   sourceActor.SetProperty(Actor::Property::POSITION, sourcePosition);
1659   sourceActor.SetProperty(Actor::Property::SIZE, sourceSize);
1660
1661   layer.Add(sourceActor);
1662
1663   // Create framebuffer
1664   unsigned int width(64);
1665   unsigned int height(64);
1666   Texture      texture     = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
1667   FrameBuffer  frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::DEPTH_STENCIL);
1668   frameBuffer.AttachColorTexture(texture);
1669
1670   Actor rootActor = Actor::New();
1671   rootActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1672   rootActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1673   rootActor.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
1674   rootActor.SetProperty(Actor::Property::SIZE, sceneSize);
1675   scene.Add(rootActor);
1676
1677   RenderTaskList taskList = scene.GetRenderTaskList();
1678   RenderTask     newTask  = taskList.CreateTask();
1679   newTask.SetCameraActor(offscreenCameraActor);
1680   newTask.SetSourceActor(layer);
1681   newTask.SetInputEnabled(false);
1682   newTask.SetClearColor(Vector4(0.f, 0.f, 0.f, 0.f));
1683   newTask.SetClearEnabled(true);
1684   newTask.SetExclusive(true);
1685   newTask.SetFrameBuffer(frameBuffer);
1686   newTask.SetScreenToFrameBufferMappingActor(rootActor);
1687
1688   application.SendNotification();
1689   application.Render(16u);
1690
1691   auto expectedExtent = Rect<>{sceneSize.x * 0.5f + sourcePosition.x - sourceSize.x * 0.5f,
1692                                sceneSize.y * 0.5f + sourcePosition.z - sourceSize.z * 0.5f,
1693                                sourceSize.x,
1694                                sourceSize.z};
1695   auto actualExtent   = DevelActor::CalculateCurrentScreenExtents(sourceActor);
1696   {
1697     std::ostringstream oss;
1698     oss << expectedExtent << "\n";
1699     oss << actualExtent << "\n";
1700     tet_printf("%s\n", oss.str().c_str());
1701   }
1702
1703   auto expectedScreen = Vector2{sceneSize.x * 0.5f + sourcePosition.x, sceneSize.y * 0.5f + sourcePosition.z};
1704   auto actualScreen   = sourceActor.GetProperty<Vector2>(Actor::Property::SCREEN_POSITION);
1705   {
1706     std::ostringstream oss;
1707     oss << expectedScreen << "\n";
1708     oss << actualScreen << "\n";
1709     tet_printf("%s\n", oss.str().c_str());
1710   }
1711
1712   DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1713   DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1714   DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1715   DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1716
1717   DALI_TEST_EQUALS(expectedScreen.x, actualScreen.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1718   DALI_TEST_EQUALS(expectedScreen.y, actualScreen.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1719
1720   // Change rootActor's size and position
1721
1722   Vector3 rootPosition{100.0f, 200.0f, 0.0f};
1723   Vector3 rootSize{200.0f, 100.0f, 0.0f};
1724
1725   rootActor.SetProperty(Actor::Property::POSITION, rootPosition);
1726   rootActor.SetProperty(Actor::Property::SIZE, rootSize);
1727
1728   application.SendNotification();
1729   application.Render(16u);
1730
1731   expectedExtent = Rect<>{sceneSize.x * 0.5f + rootPosition.x + (sourcePosition.x - sourceSize.x * 0.5f) * rootSize.x / sceneSize.x,
1732                           sceneSize.y * 0.5f + rootPosition.y + (sourcePosition.z - sourceSize.z * 0.5f) * rootSize.y / sceneSize.y,
1733                           sourceSize.x * rootSize.x / sceneSize.x,
1734                           sourceSize.z * rootSize.y / sceneSize.y};
1735   actualExtent   = DevelActor::CalculateCurrentScreenExtents(sourceActor);
1736   {
1737     std::ostringstream oss;
1738     oss << expectedExtent << "\n";
1739     oss << actualExtent << "\n";
1740     tet_printf("%s\n", oss.str().c_str());
1741   }
1742
1743   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};
1744   actualScreen   = sourceActor.GetProperty<Vector2>(Actor::Property::SCREEN_POSITION);
1745   {
1746     std::ostringstream oss;
1747     oss << expectedScreen << "\n";
1748     oss << actualScreen << "\n";
1749     tet_printf("%s\n", oss.str().c_str());
1750   }
1751
1752   DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1753   DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1754   DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1755   DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1756
1757   DALI_TEST_EQUALS(expectedScreen.x, actualScreen.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1758   DALI_TEST_EQUALS(expectedScreen.y, actualScreen.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1759
1760   END_TEST;
1761 }
1762
1763 // SetPosition(float x, float y)
1764 int UtcDaliActorSetPosition01(void)
1765 {
1766   TestApplication application;
1767
1768   Actor actor = Actor::New();
1769
1770   // Set to random to start off with
1771   actor.SetProperty(Actor::Property::POSITION, Vector3(120.0f, 120.0f, 0.0f));
1772
1773   Vector3 vector(100.0f, 100.0f, 0.0f);
1774
1775   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1776
1777   actor.SetProperty(Actor::Property::POSITION, Vector2(vector.x, vector.y));
1778   // flush the queue and render once
1779   application.SendNotification();
1780   application.Render();
1781   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1782
1783   application.GetScene().Add(actor);
1784   actor.SetProperty(Actor::Property::POSITION, Vector3(0.1f, 0.2f, 0.3f));
1785   // flush the queue and render once
1786   application.SendNotification();
1787   application.Render();
1788   DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
1789
1790   actor.SetProperty(Actor::Property::POSITION_X, 1.0f);
1791   actor.SetProperty(Actor::Property::POSITION_Y, 1.1f);
1792   actor.SetProperty(Actor::Property::POSITION_Z, 1.2f);
1793   // flush the queue and render once
1794   application.SendNotification();
1795   application.Render();
1796   DALI_TEST_EQUALS(Vector3(1.0f, 1.1f, 1.2f), actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
1797
1798   actor.TranslateBy(Vector3(0.1f, 0.1f, 0.1f));
1799   // flush the queue and render once
1800   application.SendNotification();
1801   application.Render();
1802   DALI_TEST_EQUALS(Vector3(1.1f, 1.2f, 1.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1803
1804   application.GetScene().Remove(actor);
1805   END_TEST;
1806 }
1807
1808 // SetPosition(float x, float y, float z)
1809 int UtcDaliActorSetPosition02(void)
1810 {
1811   TestApplication application;
1812
1813   Actor actor = Actor::New();
1814
1815   // Set to random to start off with
1816   actor.SetProperty(Actor::Property::POSITION, Vector3(120.0f, 120.0f, 120.0f));
1817
1818   Vector3 vector(100.0f, 100.0f, 100.0f);
1819
1820   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1821
1822   actor.SetProperty(Actor::Property::POSITION, Vector3(vector.x, vector.y, vector.z));
1823
1824   // flush the queue and render once
1825   application.SendNotification();
1826   application.Render();
1827
1828   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1829   END_TEST;
1830 }
1831
1832 // SetPosition(Vector3 position)
1833 int UtcDaliActorSetPosition03(void)
1834 {
1835   TestApplication application;
1836
1837   Actor actor = Actor::New();
1838
1839   // Set to random to start off with
1840   actor.SetProperty(Actor::Property::POSITION, Vector3(120.0f, 120.0f, 120.0f));
1841
1842   Vector3 vector(100.0f, 100.0f, 100.0f);
1843
1844   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1845
1846   actor.SetProperty(Actor::Property::POSITION, vector);
1847
1848   // flush the queue and render once
1849   application.SendNotification();
1850   application.Render();
1851
1852   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1853   END_TEST;
1854 }
1855
1856 int UtcDaliActorSetX(void)
1857 {
1858   TestApplication application;
1859
1860   Actor actor = Actor::New();
1861
1862   Vector3 vector(100.0f, 0.0f, 0.0f);
1863
1864   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1865
1866   actor.SetProperty(Actor::Property::POSITION_X, 100.0f);
1867
1868   // flush the queue and render once
1869   application.SendNotification();
1870   application.Render();
1871
1872   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1873   END_TEST;
1874 }
1875
1876 int UtcDaliActorSetY(void)
1877 {
1878   TestApplication application;
1879
1880   Actor actor = Actor::New();
1881
1882   Vector3 vector(0.0f, 100.0f, 0.0f);
1883
1884   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1885
1886   actor.SetProperty(Actor::Property::POSITION_Y, 100.0f);
1887
1888   // flush the queue and render once
1889   application.SendNotification();
1890   application.Render();
1891
1892   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1893   END_TEST;
1894 }
1895
1896 int UtcDaliActorSetZ(void)
1897 {
1898   TestApplication application;
1899
1900   Actor actor = Actor::New();
1901
1902   Vector3 vector(0.0f, 0.0f, 100.0f);
1903
1904   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1905
1906   actor.SetProperty(Actor::Property::POSITION_Z, 100.0f);
1907
1908   // flush the queue and render once
1909   application.SendNotification();
1910   application.Render();
1911
1912   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1913   END_TEST;
1914 }
1915
1916 int UtcDaliActorSetPositionProperties(void)
1917 {
1918   TestApplication application;
1919
1920   Actor actor = Actor::New();
1921
1922   Vector3 vector(0.7f, 0.8f, 0.9f);
1923   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1924
1925   actor.SetProperty(Actor::Property::POSITION_X, vector.x);
1926   DALI_TEST_EQUALS(vector.x, actor.GetProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1927   DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::POSITION_X), TEST_LOCATION);
1928
1929   // flush the queue and render once
1930   application.SendNotification();
1931   application.Render();
1932
1933   DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1934   DALI_TEST_EQUALS(vector.x, actor.GetProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1935   DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::POSITION_X), TEST_LOCATION);
1936   DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1937   DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<float>(Actor::Property::POSITION_X), TEST_LOCATION);
1938
1939   actor.SetProperty(Actor::Property::POSITION_Y, vector.y);
1940   DALI_TEST_EQUALS(vector.y, actor.GetProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1941   DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::POSITION_Y), TEST_LOCATION);
1942
1943   // flush the queue and render once
1944   application.SendNotification();
1945   application.Render();
1946
1947   DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1948   DALI_TEST_EQUALS(vector.y, actor.GetProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1949   DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::POSITION_Y), TEST_LOCATION);
1950   DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1951   DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<float>(Actor::Property::POSITION_Y), TEST_LOCATION);
1952
1953   actor.SetProperty(Actor::Property::POSITION_Z, vector.z);
1954   DALI_TEST_EQUALS(vector.z, actor.GetProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1955   DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::POSITION_Z), TEST_LOCATION);
1956
1957   // flush the queue and render once
1958   application.SendNotification();
1959   application.Render();
1960
1961   DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1962   DALI_TEST_EQUALS(vector.z, actor.GetProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1963   DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::POSITION_Z), TEST_LOCATION);
1964   DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1965   DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<float>(Actor::Property::POSITION_Z), TEST_LOCATION);
1966
1967   END_TEST;
1968 }
1969
1970 int UtcDaliActorTranslateBy(void)
1971 {
1972   TestApplication application;
1973
1974   Actor   actor = Actor::New();
1975   Vector3 vector(100.0f, 100.0f, 100.0f);
1976
1977   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1978
1979   actor.SetProperty(Actor::Property::POSITION, vector);
1980
1981   // flush the queue and render once
1982   application.SendNotification();
1983   application.Render();
1984
1985   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1986
1987   actor.TranslateBy(vector);
1988
1989   // flush the queue and render once
1990   application.SendNotification();
1991   application.Render();
1992
1993   DALI_TEST_CHECK(vector * 2.0f == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1994   END_TEST;
1995 }
1996
1997 int UtcDaliActorGetCurrentPosition(void)
1998 {
1999   TestApplication application;
2000
2001   Actor   actor = Actor::New();
2002   Vector3 setVector(100.0f, 100.0f, 0.0f);
2003   actor.SetProperty(Actor::Property::POSITION, setVector);
2004
2005   // flush the queue and render once
2006   application.SendNotification();
2007   application.Render();
2008
2009   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION) == setVector);
2010   END_TEST;
2011 }
2012
2013 int UtcDaliActorGetCurrentWorldPosition(void)
2014 {
2015   TestApplication application;
2016
2017   Actor   parent = Actor::New();
2018   Vector3 parentPosition(1.0f, 2.0f, 3.0f);
2019   parent.SetProperty(Actor::Property::POSITION, parentPosition);
2020   parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
2021   parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
2022   application.GetScene().Add(parent);
2023
2024   Actor child = Actor::New();
2025   child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
2026   child.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
2027   Vector3 childPosition(6.0f, 6.0f, 6.0f);
2028   child.SetProperty(Actor::Property::POSITION, childPosition);
2029   parent.Add(child);
2030
2031   // The actors should not have a world position yet
2032   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
2033   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
2034
2035   application.SendNotification();
2036   application.Render(0);
2037
2038   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
2039   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childPosition, TEST_LOCATION);
2040
2041   // The actors should have a world position now
2042   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
2043   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition + childPosition, TEST_LOCATION);
2044   END_TEST;
2045 }
2046
2047 int UtcDaliActorSetInheritPosition(void)
2048 {
2049   tet_infoline("Testing Actor::SetInheritPosition");
2050   TestApplication application;
2051
2052   Actor   parent = Actor::New();
2053   Vector3 parentPosition(1.0f, 2.0f, 3.0f);
2054   parent.SetProperty(Actor::Property::POSITION, parentPosition);
2055   parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
2056   parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
2057   application.GetScene().Add(parent);
2058
2059   Actor child = Actor::New();
2060   child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
2061   child.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
2062   Vector3 childPosition(10.0f, 11.0f, 12.0f);
2063   child.SetProperty(Actor::Property::POSITION, childPosition);
2064   parent.Add(child);
2065
2066   // The actors should not have a world position yet
2067   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
2068   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
2069
2070   // first test default, which is to inherit position
2071   DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_POSITION), true, TEST_LOCATION);
2072   application.SendNotification();
2073   application.Render(0); // should only really call Update as Render is not required to update scene
2074   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
2075   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childPosition, TEST_LOCATION);
2076   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
2077   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition + childPosition, TEST_LOCATION);
2078
2079   //Change child position
2080   Vector3 childOffset(-1.0f, 1.0f, 0.0f);
2081   child.SetProperty(Actor::Property::POSITION, childOffset);
2082
2083   // Use local position as world postion
2084   child.SetProperty(Actor::Property::INHERIT_POSITION, false);
2085   DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_POSITION), false, TEST_LOCATION);
2086   application.SendNotification();
2087   application.Render(0); // should only really call Update as Render is not required to update scene
2088   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
2089   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childOffset, TEST_LOCATION);
2090   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
2091   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), childOffset, TEST_LOCATION);
2092
2093   //Change back to inherit position from parent
2094   child.SetProperty(Actor::Property::INHERIT_POSITION, true);
2095   DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_POSITION), true, TEST_LOCATION);
2096   application.SendNotification();
2097   application.Render(0); // should only really call Update as Render is not required to update scene
2098   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
2099   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childOffset, TEST_LOCATION);
2100   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
2101   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition + childOffset, TEST_LOCATION);
2102   END_TEST;
2103 }
2104
2105 int UtcDaliActorInheritOpacity(void)
2106 {
2107   tet_infoline("Testing Actor::Inherit Opacity");
2108   TestApplication application;
2109
2110   Actor parent = Actor::New();
2111   Actor child  = Actor::New();
2112   parent.Add(child);
2113   application.GetScene().Add(parent);
2114
2115   DALI_TEST_EQUALS(parent.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION);
2116   DALI_TEST_EQUALS(child.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION);
2117
2118   // flush the queue and render once
2119   application.SendNotification();
2120   application.Render();
2121
2122   parent.SetProperty(Actor::Property::OPACITY, 0.1f);
2123
2124   DALI_TEST_EQUALS(parent.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION);
2125   DALI_TEST_EQUALS(child.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION);
2126
2127   application.SendNotification();
2128   application.Render();
2129
2130   DALI_TEST_EQUALS(parent.GetProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
2131   DALI_TEST_EQUALS(parent.GetCurrentProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION);
2132   DALI_TEST_EQUALS(parent.GetCurrentProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
2133   DALI_TEST_EQUALS(child.GetProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
2134   DALI_TEST_EQUALS(child.GetCurrentProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
2135   DALI_TEST_EQUALS(child.GetCurrentProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.f, 0.0001f, TEST_LOCATION);
2136
2137   END_TEST;
2138 }
2139
2140 // SetOrientation(float angleRadians, Vector3 axis)
2141 int UtcDaliActorSetOrientation01(void)
2142 {
2143   TestApplication application;
2144
2145   Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
2146   Actor      actor = Actor::New();
2147
2148   actor.SetProperty(Actor::Property::ORIENTATION, rotation);
2149
2150   // flush the queue and render once
2151   application.SendNotification();
2152   application.Render();
2153
2154   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2155   END_TEST;
2156 }
2157
2158 int UtcDaliActorSetOrientation02(void)
2159 {
2160   TestApplication application;
2161
2162   Actor actor = Actor::New();
2163
2164   Radian  angle(0.785f);
2165   Vector3 axis(1.0f, 1.0f, 0.0f);
2166
2167   actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(angle, axis));
2168   Quaternion rotation(angle, axis);
2169   // flush the queue and render once
2170   application.SendNotification();
2171   application.Render();
2172   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2173
2174   application.GetScene().Add(actor);
2175   actor.RotateBy(Degree(360), axis);
2176   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2177
2178   actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(0), Vector3(1.0f, 0.0f, 0.0f)));
2179   Quaternion result(Radian(0), Vector3(1.0f, 0.0f, 0.0f));
2180   // flush the queue and render once
2181   application.SendNotification();
2182   application.Render();
2183   DALI_TEST_EQUALS(result, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2184
2185   actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(angle, axis));
2186   // flush the queue and render once
2187   application.SendNotification();
2188   application.Render();
2189   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2190
2191   application.GetScene().Remove(actor);
2192   END_TEST;
2193 }
2194
2195 // SetOrientation(float angleRadians, Vector3 axis)
2196 int UtcDaliActorSetOrientationProperty(void)
2197 {
2198   TestApplication application;
2199
2200   Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
2201   Actor      actor = Actor::New();
2202
2203   actor.SetProperty(Actor::Property::ORIENTATION, rotation);
2204   DALI_TEST_EQUALS(rotation, actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2205
2206   // flush the queue and render once
2207   application.SendNotification();
2208   application.Render();
2209
2210   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2211   DALI_TEST_EQUALS(rotation, actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2212   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2213   END_TEST;
2214 }
2215
2216 // RotateBy(float angleRadians, Vector3 axis)
2217 int UtcDaliActorRotateBy01(void)
2218 {
2219   TestApplication application;
2220
2221   Actor actor = Actor::New();
2222
2223   Radian angle(M_PI * 0.25f);
2224   actor.RotateBy((angle), Vector3::ZAXIS);
2225   // flush the queue and render once
2226   application.SendNotification();
2227   application.Render();
2228   DALI_TEST_EQUALS(Quaternion(angle, Vector3::ZAXIS), actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2229
2230   application.GetScene().Add(actor);
2231
2232   actor.RotateBy(angle, Vector3::ZAXIS);
2233   // flush the queue and render once
2234   application.SendNotification();
2235   application.Render();
2236   DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2237
2238   application.GetScene().Remove(actor);
2239   END_TEST;
2240 }
2241
2242 // RotateBy(Quaternion relativeRotation)
2243 int UtcDaliActorRotateBy02(void)
2244 {
2245   TestApplication application;
2246
2247   Actor actor = Actor::New();
2248
2249   Radian     angle(M_PI * 0.25f);
2250   Quaternion rotation(angle, Vector3::ZAXIS);
2251   actor.RotateBy(rotation);
2252   // flush the queue and render once
2253   application.SendNotification();
2254   application.Render();
2255   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2256
2257   actor.RotateBy(rotation);
2258   // flush the queue and render once
2259   application.SendNotification();
2260   application.Render();
2261   DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2262   END_TEST;
2263 }
2264
2265 int UtcDaliActorGetCurrentOrientation(void)
2266 {
2267   TestApplication application;
2268   Actor           actor = Actor::New();
2269
2270   Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
2271   actor.SetProperty(Actor::Property::ORIENTATION, rotation);
2272   // flush the queue and render once
2273   application.SendNotification();
2274   application.Render();
2275   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2276   END_TEST;
2277 }
2278
2279 int UtcDaliActorGetCurrentWorldOrientation(void)
2280 {
2281   tet_infoline("Testing Actor::GetCurrentWorldRotation");
2282   TestApplication application;
2283
2284   Actor      parent = Actor::New();
2285   Radian     rotationAngle(Degree(90.0f));
2286   Quaternion rotation(rotationAngle, Vector3::YAXIS);
2287   parent.SetProperty(Actor::Property::ORIENTATION, rotation);
2288   application.GetScene().Add(parent);
2289
2290   Actor child = Actor::New();
2291   child.SetProperty(Actor::Property::ORIENTATION, rotation);
2292   parent.Add(child);
2293
2294   // The actors should not have a world rotation yet
2295   DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION);
2296   DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION);
2297
2298   application.SendNotification();
2299   application.Render(0);
2300
2301   DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), rotation, 0.001, TEST_LOCATION);
2302   DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), rotation, 0.001, TEST_LOCATION);
2303
2304   // The actors should have a world rotation now
2305   DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(rotationAngle, Vector3::YAXIS), 0.001, TEST_LOCATION);
2306   DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(rotationAngle * 2.0f, Vector3::YAXIS), 0.001, TEST_LOCATION);
2307
2308   // turn off child rotation inheritance
2309   child.SetProperty(Actor::Property::INHERIT_ORIENTATION, false);
2310   DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_ORIENTATION), false, TEST_LOCATION);
2311   application.SendNotification();
2312   application.Render(0);
2313
2314   // The actors should have a world rotation now
2315   DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(rotationAngle, Vector3::YAXIS), 0.001, TEST_LOCATION);
2316   DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), rotation, 0.001, TEST_LOCATION);
2317   END_TEST;
2318 }
2319
2320 // SetScale(float scale)
2321 int UtcDaliActorSetScale01(void)
2322 {
2323   TestApplication application;
2324
2325   Actor actor = Actor::New();
2326
2327   // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
2328   actor.SetProperty(Actor::Property::SCALE, 0.25f);
2329
2330   Vector3 scale(10.0f, 10.0f, 10.0f);
2331   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) != scale);
2332
2333   actor.SetProperty(Actor::Property::SCALE, scale.x);
2334
2335   // flush the queue and render once
2336   application.SendNotification();
2337   application.Render();
2338
2339   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
2340   END_TEST;
2341 }
2342
2343 // SetScale(float scaleX, float scaleY, float scaleZ)
2344 int UtcDaliActorSetScale02(void)
2345 {
2346   TestApplication application;
2347   Vector3         scale(10.0f, 10.0f, 10.0f);
2348
2349   Actor actor = Actor::New();
2350
2351   // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
2352   actor.SetProperty(Actor::Property::SCALE, Vector3(12.0f, 1.0f, 2.0f));
2353
2354   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) != scale);
2355
2356   actor.SetProperty(Actor::Property::SCALE, Vector3(scale.x, scale.y, scale.z));
2357   // flush the queue and render once
2358   application.SendNotification();
2359   application.Render();
2360   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
2361
2362   // add to stage and test
2363   application.GetScene().Add(actor);
2364   actor.SetProperty(Actor::Property::SCALE, Vector3(2.0f, 2.0f, 2.0f));
2365   // flush the queue and render once
2366   application.SendNotification();
2367   application.Render();
2368   DALI_TEST_EQUALS(Vector3(2.0f, 2.0f, 2.0f), actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE), 0.001, TEST_LOCATION);
2369
2370   application.GetScene().Remove(actor);
2371
2372   END_TEST;
2373 }
2374
2375 // SetScale(Vector3 scale)
2376 int UtcDaliActorSetScale03(void)
2377 {
2378   TestApplication application;
2379   Vector3         scale(10.0f, 10.0f, 10.0f);
2380
2381   Actor actor = Actor::New();
2382
2383   // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
2384   actor.SetProperty(Actor::Property::SCALE, Vector3(12.0f, 1.0f, 2.0f));
2385
2386   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) != scale);
2387
2388   actor.SetProperty(Actor::Property::SCALE, scale);
2389
2390   // flush the queue and render once
2391   application.SendNotification();
2392   application.Render();
2393
2394   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
2395   END_TEST;
2396 }
2397
2398 int UtcDaliActorSetScaleIndividual(void)
2399 {
2400   TestApplication application;
2401
2402   Actor actor = Actor::New();
2403
2404   Vector3 vector(0.7f, 0.8f, 0.9f);
2405   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2406
2407   actor.SetProperty(Actor::Property::SCALE_X, vector.x);
2408   DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::SCALE_X), TEST_LOCATION);
2409
2410   // flush the queue and render once
2411   application.SendNotification();
2412   application.Render();
2413
2414   DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE).x, TEST_LOCATION);
2415   DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::SCALE_X), TEST_LOCATION);
2416   DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<float>(Actor::Property::SCALE_X), TEST_LOCATION);
2417
2418   actor.SetProperty(Actor::Property::SCALE_Y, vector.y);
2419   DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::SCALE_Y), TEST_LOCATION);
2420
2421   // flush the queue and render once
2422   application.SendNotification();
2423   application.Render();
2424
2425   DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE).y, TEST_LOCATION);
2426   DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::SCALE_Y), TEST_LOCATION);
2427   DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<float>(Actor::Property::SCALE_Y), TEST_LOCATION);
2428
2429   actor.SetProperty(Actor::Property::SCALE_Z, vector.z);
2430   DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::SCALE_Z), TEST_LOCATION);
2431
2432   // flush the queue and render once
2433   application.SendNotification();
2434   application.Render();
2435
2436   DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE).z, TEST_LOCATION);
2437   DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::SCALE_Z), TEST_LOCATION);
2438   DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<float>(Actor::Property::SCALE_Z), TEST_LOCATION);
2439
2440   DALI_TEST_EQUALS(vector, actor.GetProperty<Vector3>(Actor::Property::SCALE), TEST_LOCATION);
2441   DALI_TEST_EQUALS(vector, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE), TEST_LOCATION);
2442
2443   END_TEST;
2444 }
2445
2446 int UtcDaliActorScaleBy(void)
2447 {
2448   TestApplication application;
2449   Actor           actor = Actor::New();
2450   Vector3         vector(100.0f, 100.0f, 100.0f);
2451
2452   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2453
2454   actor.SetProperty(Actor::Property::SCALE, vector);
2455
2456   // flush the queue and render once
2457   application.SendNotification();
2458   application.Render();
2459
2460   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2461
2462   actor.ScaleBy(vector);
2463
2464   // flush the queue and render once
2465   application.SendNotification();
2466   application.Render();
2467
2468   DALI_TEST_CHECK(vector * 100.0f == actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2469   END_TEST;
2470 }
2471
2472 int UtcDaliActorGetCurrentScale(void)
2473 {
2474   TestApplication application;
2475   Vector3         scale(12.0f, 1.0f, 2.0f);
2476
2477   Actor actor = Actor::New();
2478
2479   actor.SetProperty(Actor::Property::SCALE, scale);
2480
2481   // flush the queue and render once
2482   application.SendNotification();
2483   application.Render();
2484
2485   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
2486   END_TEST;
2487 }
2488
2489 int UtcDaliActorGetCurrentWorldScale(void)
2490 {
2491   TestApplication application;
2492
2493   Actor   parent = Actor::New();
2494   Vector3 parentScale(1.0f, 2.0f, 3.0f);
2495   parent.SetProperty(Actor::Property::SCALE, parentScale);
2496   application.GetScene().Add(parent);
2497
2498   Actor   child = Actor::New();
2499   Vector3 childScale(2.0f, 2.0f, 2.0f);
2500   child.SetProperty(Actor::Property::SCALE, childScale);
2501   parent.Add(child);
2502
2503   // The actors should not have a scale yet
2504   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::SCALE), Vector3::ONE, TEST_LOCATION);
2505   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::SCALE), Vector3::ONE, TEST_LOCATION);
2506
2507   // The actors should not have a world scale yet
2508   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), Vector3::ONE, TEST_LOCATION);
2509   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), Vector3::ONE, TEST_LOCATION);
2510
2511   application.SendNotification();
2512   application.Render(0);
2513
2514   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::SCALE), parentScale, TEST_LOCATION);
2515   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::SCALE), childScale, TEST_LOCATION);
2516
2517   // The actors should have a world scale now
2518   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), parentScale, TEST_LOCATION);
2519   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), parentScale * childScale, TEST_LOCATION);
2520   END_TEST;
2521 }
2522
2523 int UtcDaliActorInheritScale(void)
2524 {
2525   tet_infoline("Testing Actor::SetInheritScale");
2526   TestApplication application;
2527
2528   Actor   parent = Actor::New();
2529   Vector3 parentScale(1.0f, 2.0f, 3.0f);
2530   parent.SetProperty(Actor::Property::SCALE, parentScale);
2531   application.GetScene().Add(parent);
2532
2533   Actor   child = Actor::New();
2534   Vector3 childScale(2.0f, 2.0f, 2.0f);
2535   child.SetProperty(Actor::Property::SCALE, childScale);
2536   parent.Add(child);
2537
2538   application.SendNotification();
2539   application.Render(0);
2540
2541   DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_SCALE), true, TEST_LOCATION);
2542   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), parentScale * childScale, TEST_LOCATION);
2543
2544   child.SetProperty(Actor::Property::INHERIT_SCALE, false);
2545   DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_SCALE), false, TEST_LOCATION);
2546
2547   application.SendNotification();
2548   application.Render(0);
2549
2550   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), childScale, TEST_LOCATION);
2551   END_TEST;
2552 }
2553
2554 int UtcDaliActorSetVisible(void)
2555 {
2556   TestApplication application;
2557
2558   Actor actor = Actor::New();
2559   actor.SetProperty(Actor::Property::VISIBLE, false);
2560   // flush the queue and render once
2561   application.SendNotification();
2562   application.Render();
2563   DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == false);
2564
2565   actor.SetProperty(Actor::Property::VISIBLE, true);
2566   // flush the queue and render once
2567   application.SendNotification();
2568   application.Render();
2569   DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == true);
2570
2571   // put actor on stage
2572   application.GetScene().Add(actor);
2573   actor.SetProperty(Actor::Property::VISIBLE, false);
2574   // flush the queue and render once
2575   application.SendNotification();
2576   application.Render();
2577   DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == false);
2578   END_TEST;
2579 }
2580
2581 int UtcDaliActorIsVisible(void)
2582 {
2583   TestApplication application;
2584
2585   Actor actor = Actor::New();
2586
2587   DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == true);
2588   END_TEST;
2589 }
2590
2591 int UtcDaliActorSetOpacity(void)
2592 {
2593   TestApplication application;
2594
2595   Actor actor = Actor::New();
2596   // initial opacity is 1
2597   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, TEST_LOCATION);
2598
2599   actor.SetProperty(Actor::Property::OPACITY, 0.4f);
2600   // flush the queue and render once
2601   application.SendNotification();
2602   application.Render();
2603   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.4f, TEST_LOCATION);
2604
2605   // change opacity, actor is on stage to change is not immediate
2606   actor.SetProperty(Actor::Property::OPACITY, actor.GetCurrentProperty<float>(Actor::Property::OPACITY) + 0.1f);
2607   // flush the queue and render once
2608   application.SendNotification();
2609   application.Render();
2610   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.5f, TEST_LOCATION);
2611
2612   // put actor on stage
2613   application.GetScene().Add(actor);
2614
2615   // change opacity, actor is on stage to change is not immediate
2616   actor.SetProperty(Actor::Property::OPACITY, 0.9f);
2617   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.5f, TEST_LOCATION);
2618   // flush the queue and render once
2619   application.SendNotification();
2620   application.Render();
2621   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.9f, TEST_LOCATION);
2622
2623   // change opacity, actor is on stage to change is not immediate
2624   actor.SetProperty(Actor::Property::OPACITY, actor.GetCurrentProperty<float>(Actor::Property::OPACITY) - 0.9f);
2625   // flush the queue and render once
2626   application.SendNotification();
2627   application.Render();
2628   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, TEST_LOCATION);
2629   END_TEST;
2630 }
2631
2632 int UtcDaliActorGetCurrentOpacity(void)
2633 {
2634   TestApplication application;
2635
2636   Actor actor = Actor::New();
2637   DALI_TEST_CHECK(actor.GetCurrentProperty<float>(Actor::Property::OPACITY) != 0.5f);
2638
2639   actor.SetProperty(Actor::Property::OPACITY, 0.5f);
2640   // flush the queue and render once
2641   application.SendNotification();
2642   application.Render();
2643   DALI_TEST_CHECK(actor.GetCurrentProperty<float>(Actor::Property::OPACITY) == 0.5f);
2644   END_TEST;
2645 }
2646
2647 int UtcDaliActorSetSensitive(void)
2648 {
2649   TestApplication application;
2650   Actor           actor = Actor::New();
2651
2652   bool sensitive = !actor.GetProperty<bool>(Actor::Property::SENSITIVE);
2653
2654   actor.SetProperty(Actor::Property::SENSITIVE, sensitive);
2655
2656   DALI_TEST_CHECK(sensitive == actor.GetProperty<bool>(Actor::Property::SENSITIVE));
2657   END_TEST;
2658 }
2659
2660 int UtcDaliActorIsSensitive(void)
2661 {
2662   TestApplication application;
2663   Actor           actor = Actor::New();
2664   actor.SetProperty(Actor::Property::SENSITIVE, false);
2665
2666   DALI_TEST_CHECK(false == actor.GetProperty<bool>(Actor::Property::SENSITIVE));
2667   END_TEST;
2668 }
2669
2670 int UtcDaliActorSetColor(void)
2671 {
2672   TestApplication application;
2673   Actor           actor = Actor::New();
2674   Vector4         color(1.0f, 1.0f, 1.0f, 0.5f);
2675
2676   DALI_TEST_CHECK(color != actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2677
2678   actor.SetProperty(Actor::Property::COLOR, color);
2679   // flush the queue and render once
2680   application.SendNotification();
2681   application.Render();
2682   DALI_TEST_CHECK(color == actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2683
2684   actor.SetProperty(Actor::Property::COLOR, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR) + Vector4(-0.4f, -0.5f, -0.6f, -0.4f));
2685   // flush the queue and render once
2686   application.SendNotification();
2687   application.Render();
2688   DALI_TEST_EQUALS(Vector4(0.6f, 0.5f, 0.4f, 0.1f), actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2689
2690   application.GetScene().Add(actor);
2691   actor.SetProperty(Actor::Property::COLOR, color);
2692   // flush the queue and render once
2693   application.SendNotification();
2694   application.Render();
2695   DALI_TEST_EQUALS(color, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2696
2697   actor.SetProperty(Actor::Property::COLOR, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR) + Vector4(1.1f, 1.1f, 1.1f, 1.1f));
2698   // flush the queue and render once
2699   application.SendNotification();
2700   application.Render();
2701   // Actor color is not clamped
2702   DALI_TEST_EQUALS(Vector4(2.1f, 2.1f, 2.1f, 1.6f), actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2703   // world color is clamped
2704   DALI_TEST_EQUALS(Vector4(1.0f, 1.0f, 1.0f, 1.0f), actor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), TEST_LOCATION);
2705
2706   actor.SetProperty(Actor::Property::COLOR, color);
2707   DALI_TEST_EQUALS(color, actor.GetProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2708
2709   Vector3 newColor(1.0f, 0.0f, 0.0f);
2710   actor.SetProperty(Actor::Property::COLOR, newColor);
2711   DALI_TEST_EQUALS(Vector4(newColor.r, newColor.g, newColor.b, 1.0f), actor.GetProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2712
2713   application.GetScene().Remove(actor);
2714   END_TEST;
2715 }
2716
2717 int UtcDaliActorSetColorIndividual(void)
2718 {
2719   TestApplication application;
2720
2721   Actor actor = Actor::New();
2722
2723   Vector4 vector(0.7f, 0.8f, 0.9f, 0.6f);
2724   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2725
2726   actor.SetProperty(Actor::Property::COLOR_RED, vector.r);
2727   DALI_TEST_EQUALS(vector.r, actor.GetProperty<float>(Actor::Property::COLOR_RED), TEST_LOCATION);
2728
2729   // flush the queue and render once
2730   application.SendNotification();
2731   application.Render();
2732
2733   DALI_TEST_EQUALS(vector.r, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).r, TEST_LOCATION);
2734   DALI_TEST_EQUALS(vector.r, actor.GetProperty<float>(Actor::Property::COLOR_RED), TEST_LOCATION);
2735   DALI_TEST_EQUALS(vector.r, actor.GetCurrentProperty<float>(Actor::Property::COLOR_RED), TEST_LOCATION);
2736
2737   actor.SetProperty(Actor::Property::COLOR_GREEN, vector.g);
2738   DALI_TEST_EQUALS(vector.g, actor.GetProperty<float>(Actor::Property::COLOR_GREEN), TEST_LOCATION);
2739
2740   // flush the queue and render once
2741   application.SendNotification();
2742   application.Render();
2743
2744   DALI_TEST_EQUALS(vector.g, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).g, TEST_LOCATION);
2745   DALI_TEST_EQUALS(vector.g, actor.GetProperty<float>(Actor::Property::COLOR_GREEN), TEST_LOCATION);
2746   DALI_TEST_EQUALS(vector.g, actor.GetCurrentProperty<float>(Actor::Property::COLOR_GREEN), TEST_LOCATION);
2747
2748   actor.SetProperty(Actor::Property::COLOR_BLUE, vector.b);
2749   DALI_TEST_EQUALS(vector.b, actor.GetProperty<float>(Actor::Property::COLOR_BLUE), TEST_LOCATION);
2750
2751   // flush the queue and render once
2752   application.SendNotification();
2753   application.Render();
2754
2755   DALI_TEST_EQUALS(vector.b, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).b, TEST_LOCATION);
2756   DALI_TEST_EQUALS(vector.b, actor.GetProperty<float>(Actor::Property::COLOR_BLUE), TEST_LOCATION);
2757   DALI_TEST_EQUALS(vector.b, actor.GetCurrentProperty<float>(Actor::Property::COLOR_BLUE), TEST_LOCATION);
2758
2759   actor.SetProperty(Actor::Property::COLOR_ALPHA, vector.a);
2760   DALI_TEST_EQUALS(vector.a, actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), TEST_LOCATION);
2761
2762   // flush the queue and render once
2763   application.SendNotification();
2764   application.Render();
2765
2766   DALI_TEST_EQUALS(vector.a, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).a, TEST_LOCATION);
2767   DALI_TEST_EQUALS(vector.a, actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), TEST_LOCATION);
2768   DALI_TEST_EQUALS(vector.a, actor.GetCurrentProperty<float>(Actor::Property::COLOR_ALPHA), TEST_LOCATION);
2769
2770   DALI_TEST_EQUALS(vector, actor.GetProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2771   DALI_TEST_EQUALS(vector, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2772
2773   actor.SetProperty(Actor::Property::OPACITY, 0.2f);
2774
2775   // flush the queue and render once
2776   application.SendNotification();
2777   application.Render();
2778
2779   DALI_TEST_EQUALS(0.2f, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).a, TEST_LOCATION);
2780
2781   END_TEST;
2782 }
2783
2784 int UtcDaliActorGetCurrentColor(void)
2785 {
2786   TestApplication application;
2787   Actor           actor = Actor::New();
2788   Vector4         color(1.0f, 1.0f, 1.0f, 0.5f);
2789
2790   actor.SetProperty(Actor::Property::COLOR, color);
2791   // flush the queue and render once
2792   application.SendNotification();
2793   application.Render();
2794   DALI_TEST_CHECK(color == actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2795   END_TEST;
2796 }
2797
2798 int UtcDaliActorGetCurrentWorldColor(void)
2799 {
2800   tet_infoline("Actor::GetCurrentWorldColor");
2801   TestApplication application;
2802
2803   Actor   parent = Actor::New();
2804   Vector4 parentColor(1.0f, 0.5f, 0.0f, 0.8f);
2805   parent.SetProperty(Actor::Property::COLOR, parentColor);
2806   application.GetScene().Add(parent);
2807
2808   Actor   child = Actor::New();
2809   Vector4 childColor(0.5f, 0.6f, 0.5f, 1.0f);
2810   child.SetProperty(Actor::Property::COLOR, childColor);
2811   parent.Add(child);
2812
2813   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::COLOR), Color::WHITE, TEST_LOCATION);
2814   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), Color::WHITE, TEST_LOCATION);
2815
2816   // verify the default color mode
2817   DALI_TEST_EQUALS(USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2818
2819   // The actors should not have a world color yet
2820   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), Color::WHITE, TEST_LOCATION);
2821   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), Color::WHITE, TEST_LOCATION);
2822
2823   application.SendNotification();
2824   application.Render(0);
2825
2826   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::COLOR), parentColor, TEST_LOCATION);
2827   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), childColor, TEST_LOCATION);
2828
2829   // The actors should have a world color now
2830   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), parentColor, TEST_LOCATION);
2831   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), Vector4(childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION);
2832
2833   // use own color
2834   child.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
2835   application.SendNotification();
2836   application.Render(0);
2837   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), childColor, TEST_LOCATION);
2838
2839   // use parent color
2840   child.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
2841   application.SendNotification();
2842   application.Render(0);
2843   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), childColor, TEST_LOCATION);
2844   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), parentColor, TEST_LOCATION);
2845
2846   // use parent alpha
2847   child.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
2848   application.SendNotification();
2849   application.Render(0);
2850   Vector4 expectedColor(childColor);
2851   expectedColor.a *= parentColor.a;
2852   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), childColor, TEST_LOCATION);
2853   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), expectedColor, TEST_LOCATION);
2854   END_TEST;
2855 }
2856
2857 int UtcDaliActorSetColorMode(void)
2858 {
2859   tet_infoline("Actor::SetColorMode");
2860   TestApplication application;
2861   Actor           actor = Actor::New();
2862   Actor           child = Actor::New();
2863   actor.Add(child);
2864
2865   actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
2866   DALI_TEST_EQUALS(USE_OWN_COLOR, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2867
2868   actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR);
2869   DALI_TEST_EQUALS(USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2870
2871   actor.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
2872   DALI_TEST_EQUALS(USE_PARENT_COLOR, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2873
2874   actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
2875   DALI_TEST_EQUALS(USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2876   END_TEST;
2877 }
2878
2879 int UtcDaliActorScreenToLocal(void)
2880 {
2881   TestApplication application;
2882   Actor           actor = Actor::New();
2883   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2884   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2885   actor.SetProperty(Actor::Property::POSITION, Vector2(10.0f, 10.0f));
2886   application.GetScene().Add(actor);
2887
2888   // flush the queue and render once
2889   application.SendNotification();
2890   application.Render();
2891
2892   float localX;
2893   float localY;
2894
2895   application.SendNotification();
2896   application.Render();
2897
2898   DALI_TEST_CHECK(actor.ScreenToLocal(localX, localY, 50.0f, 50.0f));
2899
2900   DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
2901   DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
2902   END_TEST;
2903 }
2904
2905 int UtcDaliActorSetLeaveRequired(void)
2906 {
2907   TestApplication application;
2908
2909   Actor actor = Actor::New();
2910
2911   actor.SetProperty(Actor::Property::LEAVE_REQUIRED, false);
2912   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::LEAVE_REQUIRED) == false);
2913
2914   actor.SetProperty(Actor::Property::LEAVE_REQUIRED, true);
2915   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::LEAVE_REQUIRED) == true);
2916   END_TEST;
2917 }
2918
2919 int UtcDaliActorGetLeaveRequired(void)
2920 {
2921   TestApplication application;
2922
2923   Actor actor = Actor::New();
2924
2925   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::LEAVE_REQUIRED) == false);
2926   END_TEST;
2927 }
2928
2929 int UtcDaliActorSetKeyboardFocusable(void)
2930 {
2931   TestApplication application;
2932
2933   Actor actor = Actor::New();
2934
2935   actor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
2936   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) == true);
2937
2938   actor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, false);
2939   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) == false);
2940   END_TEST;
2941 }
2942
2943 int UtcDaliActorIsKeyboardFocusable(void)
2944 {
2945   TestApplication application;
2946
2947   Actor actor = Actor::New();
2948
2949   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) == false);
2950   END_TEST;
2951 }
2952
2953 int UtcDaliActorSetKeyboardFocusableChildren(void)
2954 {
2955   TestApplication application;
2956
2957   Actor actor = Actor::New();
2958
2959   actor.SetProperty(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN, true);
2960   DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN) == true);
2961
2962   actor.SetProperty(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN, false);
2963   DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN) == false);
2964   END_TEST;
2965 }
2966
2967 int UtcDaliActorAreChildrenKeyBoardFocusable(void)
2968 {
2969   TestApplication application;
2970
2971   Actor actor = Actor::New();
2972
2973   DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN) == true);
2974   END_TEST;
2975 }
2976
2977 int UtcDaliActorSetTouchFocusable(void)
2978 {
2979   TestApplication application;
2980
2981   Actor actor = Actor::New();
2982
2983   actor.SetProperty(DevelActor::Property::TOUCH_FOCUSABLE, true);
2984   DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::TOUCH_FOCUSABLE) == true);
2985
2986   actor.SetProperty(DevelActor::Property::TOUCH_FOCUSABLE, false);
2987   DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::TOUCH_FOCUSABLE) == false);
2988   END_TEST;
2989 }
2990
2991 int UtcDaliActorIsTouchFocusable(void)
2992 {
2993   TestApplication application;
2994
2995   Actor actor = Actor::New();
2996
2997   DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::TOUCH_FOCUSABLE) == false);
2998   END_TEST;
2999 }
3000
3001 int UtcDaliActorSetUserInteractionEnabled(void)
3002 {
3003   TestApplication application;
3004   Actor           actor = Actor::New();
3005
3006   bool enabled = !actor.GetProperty<bool>(DevelActor::Property::USER_INTERACTION_ENABLED);
3007
3008   actor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, enabled);
3009
3010   DALI_TEST_CHECK(enabled == actor.GetProperty<bool>(DevelActor::Property::USER_INTERACTION_ENABLED));
3011   END_TEST;
3012 }
3013
3014 int UtcDaliActorIsUserInteractionEnabled(void)
3015 {
3016   TestApplication application;
3017   Actor           actor = Actor::New();
3018   actor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, true);
3019
3020   DALI_TEST_CHECK(true == actor.GetProperty<bool>(DevelActor::Property::USER_INTERACTION_ENABLED));
3021   END_TEST;
3022 }
3023
3024 int UtcDaliActorRemoveConstraints(void)
3025 {
3026   tet_infoline(" UtcDaliActorRemoveConstraints");
3027   TestApplication application;
3028
3029   gTestConstraintCalled = false;
3030
3031   Actor actor = Actor::New();
3032
3033   Constraint constraint = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraint());
3034   constraint.Apply();
3035   actor.RemoveConstraints();
3036
3037   DALI_TEST_CHECK(gTestConstraintCalled == false);
3038
3039   application.GetScene().Add(actor);
3040   constraint.Apply();
3041
3042   // flush the queue and render once
3043   application.SendNotification();
3044   application.Render();
3045
3046   actor.RemoveConstraints();
3047
3048   DALI_TEST_CHECK(gTestConstraintCalled == true);
3049   END_TEST;
3050 }
3051
3052 int UtcDaliActorRemoveConstraintTag(void)
3053 {
3054   tet_infoline(" UtcDaliActorRemoveConstraintTag");
3055   TestApplication application;
3056
3057   Actor actor = Actor::New();
3058
3059   // 1. Apply Constraint1 and Constraint2, and test...
3060   unsigned int result1 = 0u;
3061   unsigned int result2 = 0u;
3062
3063   unsigned   constraint1Tag = 1u;
3064   Constraint constraint1    = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1));
3065   constraint1.SetTag(constraint1Tag);
3066   constraint1.Apply();
3067
3068   unsigned   constraint2Tag = 2u;
3069   Constraint constraint2    = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2));
3070   constraint2.SetTag(constraint2Tag);
3071   constraint2.Apply();
3072
3073   application.GetScene().Add(actor);
3074   // flush the queue and render once
3075   application.SendNotification();
3076   application.Render();
3077
3078   DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
3079   DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
3080
3081   // 2. Remove Constraint1 and test...
3082   result1 = 0;
3083   result2 = 0;
3084   actor.RemoveConstraints(constraint1Tag);
3085   // make color property dirty, which will trigger constraints to be reapplied.
3086   actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
3087   // flush the queue and render once
3088   application.SendNotification();
3089   application.Render();
3090
3091   DALI_TEST_EQUALS(result1, 0u, TEST_LOCATION); ///< constraint 1 should not apply now.
3092   DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
3093
3094   // 3. Re-Apply Constraint1 and test...
3095   result1 = 0;
3096   result2 = 0;
3097   constraint1.Apply();
3098   // make color property dirty, which will trigger constraints to be reapplied.
3099   actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
3100   // flush the queue and render once
3101   application.SendNotification();
3102   application.Render();
3103
3104   DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
3105   DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
3106
3107   // 2. Remove Constraint2 and test...
3108   result1 = 0;
3109   result2 = 0;
3110   actor.RemoveConstraints(constraint2Tag);
3111   // make color property dirty, which will trigger constraints to be reapplied.
3112   actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
3113   // flush the queue and render once
3114   application.SendNotification();
3115   application.Render();
3116
3117   DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
3118   DALI_TEST_EQUALS(result2, 0u, TEST_LOCATION); ///< constraint 2 should not apply now.
3119
3120   // 2. Remove Constraint1 as well and test...
3121   result1 = 0;
3122   result2 = 0;
3123   actor.RemoveConstraints(constraint1Tag);
3124   // make color property dirty, which will trigger constraints to be reapplied.
3125   actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
3126   // flush the queue and render once
3127   application.SendNotification();
3128   application.Render();
3129
3130   DALI_TEST_EQUALS(result1, 0u, TEST_LOCATION); ///< constraint 1 should not apply now.
3131   DALI_TEST_EQUALS(result2, 0u, TEST_LOCATION); ///< constraint 2 should not apply now.
3132   END_TEST;
3133 }
3134
3135 int UtcDaliActorTouchedSignal(void)
3136 {
3137   TestApplication application;
3138
3139   ResetTouchCallbacks();
3140
3141   // get the root layer
3142   Actor actor = application.GetScene().GetRootLayer();
3143   DALI_TEST_CHECK(gTouchCallBackCalled == false);
3144
3145   application.SendNotification();
3146   application.Render();
3147
3148   // connect to its touch signal
3149   actor.TouchedSignal().Connect(TestTouchCallback);
3150
3151   // simulate a touch event in the middle of the screen
3152   Vector2                  touchPoint(application.GetScene().GetSize() * 0.5);
3153   Dali::Integration::Point point;
3154   point.SetDeviceId(1);
3155   point.SetState(PointState::DOWN);
3156   point.SetScreenPosition(Vector2(touchPoint.x, touchPoint.y));
3157   Dali::Integration::TouchEvent touchEvent;
3158   touchEvent.AddPoint(point);
3159   application.ProcessEvent(touchEvent);
3160
3161   DALI_TEST_CHECK(gTouchCallBackCalled == true);
3162   END_TEST;
3163 }
3164
3165 int UtcDaliActorGeoTouchedSignal(void)
3166 {
3167   TestApplication application;
3168
3169   application.GetScene().SetGeometryHittestEnabled(true);
3170   ResetTouchCallbacks(application);
3171
3172   // get the root layer
3173   Actor actor = application.GetScene().GetRootLayer();
3174   DALI_TEST_CHECK(gTouchCallBackCalled == false);
3175
3176   application.SendNotification();
3177   application.Render();
3178
3179   // connect to its touch signal
3180   actor.TouchedSignal().Connect(TestTouchCallback);
3181
3182   // simulate a touch event in the middle of the screen
3183   Vector2                  touchPoint(application.GetScene().GetSize() * 0.5);
3184   Dali::Integration::Point point;
3185   point.SetDeviceId(1);
3186   point.SetState(PointState::DOWN);
3187   point.SetScreenPosition(Vector2(touchPoint.x, touchPoint.y));
3188   Dali::Integration::TouchEvent touchEvent;
3189   touchEvent.AddPoint(point);
3190   application.ProcessEvent(touchEvent);
3191
3192   DALI_TEST_CHECK(gTouchCallBackCalled == true);
3193   END_TEST;
3194 }
3195
3196 int UtcDaliActorHoveredSignal(void)
3197 {
3198   TestApplication application;
3199
3200   gHoverCallBackCalled = false;
3201
3202   // get the root layer
3203   Actor actor = application.GetScene().GetRootLayer();
3204   DALI_TEST_CHECK(gHoverCallBackCalled == false);
3205
3206   application.SendNotification();
3207   application.Render();
3208
3209   // connect to its hover signal
3210   actor.HoveredSignal().Connect(TestCallback3);
3211
3212   // simulate a hover event in the middle of the screen
3213   Vector2                  touchPoint(application.GetScene().GetSize() * 0.5);
3214   Dali::Integration::Point point;
3215   point.SetDeviceId(1);
3216   point.SetState(PointState::MOTION);
3217   point.SetScreenPosition(Vector2(touchPoint.x, touchPoint.y));
3218   Dali::Integration::HoverEvent hoverEvent;
3219   hoverEvent.AddPoint(point);
3220   application.ProcessEvent(hoverEvent);
3221
3222   DALI_TEST_CHECK(gHoverCallBackCalled == true);
3223   END_TEST;
3224 }
3225
3226 int UtcDaliActorOnOffSceneSignal(void)
3227 {
3228   tet_infoline("Testing Dali::Actor::OnSceneSignal() and OffSceneSignal()");
3229
3230   TestApplication application;
3231
3232   // clean test data
3233   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
3234   gActorNamesOnOffScene.clear();
3235
3236   Actor parent = Actor::New();
3237   parent.SetProperty(Actor::Property::NAME, "parent");
3238   parent.OnSceneSignal().Connect(OnSceneCallback);
3239   parent.OffSceneSignal().Connect(OffSceneCallback);
3240   // sanity check
3241   DALI_TEST_CHECK(gOnSceneCallBackCalled == 0);
3242   DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
3243
3244   // add parent to the scene
3245   application.GetScene().Add(parent);
3246   // onstage emitted, offstage not
3247   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 1, TEST_LOCATION);
3248   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
3249   DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
3250
3251   // test adding a child, should get onstage emitted
3252   // clean test data
3253   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
3254   gActorNamesOnOffScene.clear();
3255
3256   Actor child = Actor::New();
3257   child.SetProperty(Actor::Property::NAME, "child");
3258   child.OnSceneSignal().Connect(OnSceneCallback);
3259   child.OffSceneSignal().Connect(OffSceneCallback);
3260   parent.Add(child); // add child
3261   // onscene emitted, offscene not
3262   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 1, TEST_LOCATION);
3263   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
3264   DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
3265
3266   // test removing parent from the scene
3267   // clean test data
3268   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
3269   gActorNamesOnOffScene.clear();
3270
3271   application.GetScene().Remove(parent);
3272   // onscene not emitted, offscene is
3273   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
3274   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 2, TEST_LOCATION);
3275   DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
3276   DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[1], TEST_LOCATION);
3277
3278   // test adding parent back to the scene
3279   // clean test data
3280   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
3281   gActorNamesOnOffScene.clear();
3282
3283   application.GetScene().Add(parent);
3284   // onscene emitted, offscene not
3285   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 2, TEST_LOCATION);
3286   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
3287   DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
3288   DALI_TEST_EQUALS("child", gActorNamesOnOffScene[1], TEST_LOCATION);
3289
3290   // test removing child
3291   // clean test data
3292   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
3293   gActorNamesOnOffScene.clear();
3294
3295   parent.Remove(child);
3296   // onscene not emitted, offscene is
3297   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
3298   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 1, TEST_LOCATION);
3299   DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
3300
3301   // test removing parent
3302   // clean test data
3303   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
3304   gActorNamesOnOffScene.clear();
3305
3306   application.GetScene().Remove(parent);
3307   // onscene not emitted, offscene is
3308   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
3309   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 1, TEST_LOCATION);
3310   DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
3311   END_TEST;
3312 }
3313
3314 int UtcDaliActorFindChildByName(void)
3315 {
3316   tet_infoline("Testing Dali::Actor::FindChildByName()");
3317   TestApplication application;
3318
3319   Actor parent = Actor::New();
3320   parent.SetProperty(Actor::Property::NAME, "parent");
3321   Actor first = Actor::New();
3322   first.SetProperty(Actor::Property::NAME, "first");
3323   Actor second = Actor::New();
3324   second.SetProperty(Actor::Property::NAME, "second");
3325
3326   parent.Add(first);
3327   first.Add(second);
3328
3329   Actor found = parent.FindChildByName("foo");
3330   DALI_TEST_CHECK(!found);
3331
3332   found = parent.FindChildByName("parent");
3333   DALI_TEST_CHECK(found == parent);
3334
3335   found = parent.FindChildByName("first");
3336   DALI_TEST_CHECK(found == first);
3337
3338   found = parent.FindChildByName("second");
3339   DALI_TEST_CHECK(found == second);
3340   END_TEST;
3341 }
3342
3343 int UtcDaliActorFindChildById(void)
3344 {
3345   tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
3346   TestApplication application;
3347
3348   Actor parent = Actor::New();
3349   Actor first  = Actor::New();
3350   Actor second = Actor::New();
3351
3352   parent.Add(first);
3353   first.Add(second);
3354
3355   Actor found = parent.FindChildById(100000);
3356   DALI_TEST_CHECK(!found);
3357
3358   found = parent.FindChildById(parent.GetProperty<int>(Actor::Property::ID));
3359   DALI_TEST_CHECK(found == parent);
3360
3361   found = parent.FindChildById(first.GetProperty<int>(Actor::Property::ID));
3362   DALI_TEST_CHECK(found == first);
3363
3364   found = parent.FindChildById(second.GetProperty<int>(Actor::Property::ID));
3365   DALI_TEST_CHECK(found == second);
3366   END_TEST;
3367 }
3368
3369 int UtcDaliActorHitTest(void)
3370 {
3371   struct HitTestData
3372   {
3373   public:
3374     HitTestData(const Vector3& scale, const Vector2& touchPoint, bool result)
3375     : mScale(scale),
3376       mTouchPoint(touchPoint),
3377       mResult(result)
3378     {
3379     }
3380
3381     Vector3 mScale;
3382     Vector2 mTouchPoint;
3383     bool    mResult;
3384   };
3385
3386   TestApplication application;
3387   tet_infoline(" UtcDaliActorHitTest");
3388
3389   // Fill a vector with different hit tests.
3390   struct HitTestData* hitTestData[] = {
3391     //                    scale                     touch point           result
3392     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(289.f, 400.f), true),  // touch point close to the right edge (inside)
3393     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(291.f, 400.f), false), // touch point close to the right edge (outside)
3394     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.
3395     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(200.f, 451.f), false), // touch point close to the down edge (outside)
3396     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.
3397     NULL,
3398   };
3399
3400   // get the root layer
3401   Actor actor = Actor::New();
3402   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3403   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3404
3405   application.GetScene().Add(actor);
3406
3407   ResetTouchCallbacks();
3408
3409   unsigned int index = 0;
3410   while(NULL != hitTestData[index])
3411   {
3412     actor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f));
3413     actor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z));
3414
3415     // flush the queue and render once
3416     application.SendNotification();
3417     application.Render();
3418
3419     DALI_TEST_CHECK(!gTouchCallBackCalled);
3420
3421     // connect to its touch signal
3422     actor.TouchedSignal().Connect(TestTouchCallback);
3423
3424     Dali::Integration::Point point;
3425     point.SetState(PointState::DOWN);
3426     point.SetScreenPosition(Vector2(hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y));
3427     Dali::Integration::TouchEvent event;
3428     event.AddPoint(point);
3429
3430     // flush the queue and render once
3431     application.SendNotification();
3432     application.Render();
3433     application.ProcessEvent(event);
3434
3435     DALI_TEST_CHECK(gTouchCallBackCalled == hitTestData[index]->mResult);
3436
3437     if(gTouchCallBackCalled != hitTestData[index]->mResult)
3438       tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
3439                  hitTestData[index]->mScale.x,
3440                  hitTestData[index]->mScale.y,
3441                  hitTestData[index]->mScale.z,
3442                  hitTestData[index]->mTouchPoint.x,
3443                  hitTestData[index]->mTouchPoint.y,
3444                  hitTestData[index]->mResult);
3445
3446     ResetTouchCallbacks();
3447     ++index;
3448   }
3449   END_TEST;
3450 }
3451
3452 int UtcDaliActorGeoHitTest(void)
3453 {
3454   struct HitTestData
3455   {
3456   public:
3457     HitTestData(const Vector3& scale, const Vector2& touchPoint, bool result)
3458     : mScale(scale),
3459       mTouchPoint(touchPoint),
3460       mResult(result)
3461     {
3462     }
3463
3464     Vector3 mScale;
3465     Vector2 mTouchPoint;
3466     bool    mResult;
3467   };
3468
3469   TestApplication application;
3470   tet_infoline(" UtcDaliActorHitTest");
3471
3472   // Fill a vector with different hit tests.
3473   struct HitTestData* hitTestData[] = {
3474     //                    scale                     touch point           result
3475     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(289.f, 400.f), true),  // touch point close to the right edge (inside)
3476     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(291.f, 400.f), false), // touch point close to the right edge (outside)
3477     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.
3478     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(200.f, 451.f), false), // touch point close to the down edge (outside)
3479     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.
3480     NULL,
3481   };
3482
3483   // get the root layer
3484   Actor actor = Actor::New();
3485   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3486   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3487
3488   application.GetScene().Add(actor);
3489   application.GetScene().SetGeometryHittestEnabled(true);
3490
3491   ResetTouchCallbacks(application);
3492
3493   unsigned int index = 0;
3494   while(NULL != hitTestData[index])
3495   {
3496     actor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f));
3497     actor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z));
3498
3499     // flush the queue and render once
3500     application.SendNotification();
3501     application.Render();
3502
3503     DALI_TEST_CHECK(!gTouchCallBackCalled);
3504
3505     // connect to its touch signal
3506     actor.TouchedSignal().Connect(TestTouchCallback);
3507
3508     Dali::Integration::Point point;
3509     point.SetState(PointState::DOWN);
3510     point.SetScreenPosition(Vector2(hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y));
3511     Dali::Integration::TouchEvent event;
3512     event.AddPoint(point);
3513
3514     // flush the queue and render once
3515     application.SendNotification();
3516     application.Render();
3517     application.ProcessEvent(event);
3518
3519     DALI_TEST_CHECK(gTouchCallBackCalled == hitTestData[index]->mResult);
3520
3521     if(gTouchCallBackCalled != hitTestData[index]->mResult)
3522       tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
3523                  hitTestData[index]->mScale.x,
3524                  hitTestData[index]->mScale.y,
3525                  hitTestData[index]->mScale.z,
3526                  hitTestData[index]->mTouchPoint.x,
3527                  hitTestData[index]->mTouchPoint.y,
3528                  hitTestData[index]->mResult);
3529
3530     ResetTouchCallbacks(application);
3531     ++index;
3532   }
3533   END_TEST;
3534 }
3535
3536 int UtcDaliActorSetDrawMode(void)
3537 {
3538   TestApplication application;
3539   tet_infoline(" UtcDaliActorSetDrawModeOverlay");
3540
3541   Actor a = Actor::New();
3542
3543   application.GetScene().Add(a);
3544   application.SendNotification();
3545   application.Render(0);
3546   application.SendNotification();
3547   application.Render(1);
3548
3549   DALI_TEST_CHECK(DrawMode::NORMAL == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Ensure overlay is off by default
3550
3551   a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3552   application.SendNotification();
3553   application.Render(1);
3554
3555   DALI_TEST_CHECK(DrawMode::OVERLAY_2D == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Check Actor is overlay
3556
3557   a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::NORMAL);
3558   application.SendNotification();
3559   application.Render(1);
3560
3561   DALI_TEST_CHECK(DrawMode::NORMAL == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Check Actor is normal
3562   END_TEST;
3563 }
3564
3565 int UtcDaliActorSetDrawModeOverlayRender(void)
3566 {
3567   TestApplication application;
3568   tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
3569
3570   application.SendNotification();
3571   application.Render(1);
3572
3573   std::vector<GLuint> ids;
3574   ids.push_back(8);  // first rendered actor
3575   ids.push_back(9);  // second rendered actor
3576   ids.push_back(10); // third rendered actor
3577   application.GetGlAbstraction().SetNextTextureIds(ids);
3578
3579   Texture imageA = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
3580   Texture imageB = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
3581   Texture imageC = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
3582   Actor   a      = CreateRenderableActor(imageA);
3583   Actor   b      = CreateRenderableActor(imageB);
3584   Actor   c      = CreateRenderableActor(imageC);
3585
3586   application.SendNotification();
3587   application.Render(1);
3588
3589   //Textures are bound when first created. Clear bound textures vector
3590   application.GetGlAbstraction().ClearBoundTextures();
3591
3592   // Render a,b,c as regular non-overlays. so order will be:
3593   // a (8)
3594   // b (9)
3595   // c (10)
3596   application.GetScene().Add(a);
3597   application.GetScene().Add(b);
3598   application.GetScene().Add(c);
3599
3600   application.SendNotification();
3601   application.Render(1);
3602
3603   // Should be 3 textures changes.
3604   const std::vector<GLuint>&             boundTextures = application.GetGlAbstraction().GetBoundTextures(GL_TEXTURE0);
3605   typedef std::vector<GLuint>::size_type TextureSize;
3606   DALI_TEST_EQUALS(boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION);
3607   if(boundTextures.size() == 3)
3608   {
3609     DALI_TEST_CHECK(boundTextures[0] == 8u);
3610     DALI_TEST_CHECK(boundTextures[1] == 9u);
3611     DALI_TEST_CHECK(boundTextures[2] == 10u);
3612   }
3613
3614   // Now texture ids have been set, we can monitor their render order.
3615   // render a as an overlay (last), so order will be:
3616   // b (9)
3617   // c (10)
3618   // a (8)
3619   a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3620   application.GetGlAbstraction().ClearBoundTextures();
3621
3622   application.SendNotification();
3623   application.Render(1);
3624
3625   // Should be 3 texture changes.
3626   DALI_TEST_EQUALS(boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION);
3627   if(boundTextures.size() == 3)
3628   {
3629     DALI_TEST_CHECK(boundTextures[0] == 9u);
3630     DALI_TEST_CHECK(boundTextures[1] == 10u);
3631     DALI_TEST_CHECK(boundTextures[2] == 8u);
3632   }
3633   END_TEST;
3634 }
3635
3636 int UtcDaliActorSetDrawModeOverlayWithClipping(void)
3637 {
3638   TestApplication application;
3639   tet_infoline(" UtcDaliActorSetDrawModeOverlayWithClipping");
3640
3641   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
3642   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
3643   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
3644
3645   const Vector2 surfaceSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
3646   const Vector2 imageSize(16.0f, 16.0f);
3647
3648   std::vector<GLuint> ids;
3649   ids.push_back(8);  // first rendered actor
3650   ids.push_back(9);  // second rendered actor
3651   ids.push_back(10); // third rendered actor
3652   ids.push_back(11); // forth rendered actor
3653   application.GetGlAbstraction().SetNextTextureIds(ids);
3654
3655   Actor a = CreateActorWithContent16x16();
3656   Actor b = CreateActorWithContent16x16();
3657   Actor c = CreateActorWithContent16x16();
3658   Actor d = CreateActorWithContent16x16();
3659
3660   application.SendNotification();
3661   application.Render();
3662
3663   //Textures are bound when first created. Clear bound textures vector
3664   application.GetGlAbstraction().ClearBoundTextures();
3665
3666   b[Actor::Property::PARENT_ORIGIN] = ParentOrigin::BOTTOM_LEFT;
3667   b[Actor::Property::ANCHOR_POINT]  = AnchorPoint::BOTTOM_LEFT;
3668   b[Actor::Property::DRAW_MODE]     = DrawMode::OVERLAY_2D;
3669   b[Actor::Property::CLIPPING_MODE] = ClippingMode::CLIP_TO_BOUNDING_BOX;
3670
3671   c[Actor::Property::PARENT_ORIGIN] = ParentOrigin::BOTTOM_LEFT;
3672   c[Actor::Property::ANCHOR_POINT]  = AnchorPoint::BOTTOM_LEFT;
3673   c[Actor::Property::CLIPPING_MODE] = ClippingMode::CLIP_TO_BOUNDING_BOX;
3674   c[Actor::Property::POSITION]      = Vector2(100.0f, -100.0f);
3675
3676   application.GetScene().Add(a);
3677   application.GetScene().Add(b);
3678   application.GetScene().Add(c);
3679   b.Add(d);
3680
3681   GenerateTrace(application, enabledDisableTrace, scissorTrace);
3682
3683   const std::vector<GLuint>&             boundTextures = application.GetGlAbstraction().GetBoundTextures(GL_TEXTURE0);
3684   typedef std::vector<GLuint>::size_type TextureSize;
3685   DALI_TEST_EQUALS(boundTextures.size(), static_cast<TextureSize>(4), TEST_LOCATION);
3686   if(boundTextures.size() == 4)
3687   {
3688     DALI_TEST_CHECK(boundTextures[0] == 8u);
3689     DALI_TEST_CHECK(boundTextures[1] == 10u);
3690     DALI_TEST_CHECK(boundTextures[2] == 9u);
3691     DALI_TEST_CHECK(boundTextures[3] == 11u);
3692   }
3693
3694   // Check scissor test was enabled.
3695   std::ostringstream scissor;
3696   scissor << std::hex << GL_SCISSOR_TEST;
3697   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
3698
3699   // Check the scissor was set, and the coordinates are correct.
3700   DALI_TEST_CHECK(scissorTrace.TestMethodAndParams(0, "Scissor", "100, 100, 16, 16")); // First compare with c area
3701   DALI_TEST_CHECK(scissorTrace.TestMethodAndParams(1, "Scissor", "0, 0, 16, 16"));     // Second compare with b area
3702
3703   application.GetGlAbstraction().ClearBoundTextures();
3704
3705   // Remove a Renderer of overlay actor
3706   Renderer renderer = b.GetRendererAt(0);
3707   b.RemoveRenderer(renderer);
3708
3709   GenerateTrace(application, enabledDisableTrace, scissorTrace);
3710
3711   DALI_TEST_EQUALS(boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION);
3712   if(boundTextures.size() == 3)
3713   {
3714     DALI_TEST_CHECK(boundTextures[0] == 8u);
3715     DALI_TEST_CHECK(boundTextures[1] == 10u);
3716     DALI_TEST_CHECK(boundTextures[2] == 11u);
3717   }
3718
3719   DALI_TEST_CHECK(scissorTrace.TestMethodAndParams(0, "Scissor", "100, 100, 16, 16")); // First compare with c area
3720   DALI_TEST_CHECK(scissorTrace.TestMethodAndParams(1, "Scissor", "0, 0, 16, 16"));     // Second compare with b area
3721
3722   END_TEST;
3723 }
3724
3725 int UtcDaliActorGetCurrentWorldMatrix(void)
3726 {
3727   TestApplication application;
3728   tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
3729
3730   Actor parent = Actor::New();
3731   parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3732   parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3733   Vector3    parentPosition(10.0f, 20.0f, 30.0f);
3734   Radian     rotationAngle(Degree(85.0f));
3735   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3736   Vector3    parentScale(1.0f, 2.0f, 3.0f);
3737   parent.SetProperty(Actor::Property::POSITION, parentPosition);
3738   parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3739   parent.SetProperty(Actor::Property::SCALE, parentScale);
3740   application.GetScene().Add(parent);
3741
3742   Actor child = Actor::New();
3743   child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3744   Vector3    childPosition(0.0f, 0.0f, 100.0f);
3745   Radian     childRotationAngle(Degree(23.0f));
3746   Quaternion childRotation(childRotationAngle, Vector3::YAXIS);
3747   Vector3    childScale(2.0f, 2.0f, 2.0f);
3748   child.SetProperty(Actor::Property::POSITION, childPosition);
3749   child.SetProperty(Actor::Property::ORIENTATION, childRotation);
3750   child.SetProperty(Actor::Property::SCALE, childScale);
3751   parent.Add(child);
3752
3753   application.SendNotification();
3754   application.Render(0);
3755   application.Render();
3756   application.SendNotification();
3757
3758   Matrix parentMatrix(false);
3759   parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3760
3761   Matrix childMatrix(false);
3762   childMatrix.SetTransformComponents(childScale, childRotation, childPosition);
3763
3764   //Child matrix should be the composition of child and parent
3765   Matrix childWorldMatrix(false);
3766   Matrix::Multiply(childWorldMatrix, childMatrix, parentMatrix);
3767
3768   DALI_TEST_EQUALS(parent.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), parentMatrix, 0.001, TEST_LOCATION);
3769   DALI_TEST_EQUALS(child.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), childWorldMatrix, 0.001, TEST_LOCATION);
3770   END_TEST;
3771 }
3772
3773 int UtcDaliActorConstrainedToWorldMatrix(void)
3774 {
3775   TestApplication application;
3776   tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
3777
3778   Actor parent = Actor::New();
3779   parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3780   parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3781   Vector3    parentPosition(10.0f, 20.0f, 30.0f);
3782   Radian     rotationAngle(Degree(85.0f));
3783   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3784   Vector3    parentScale(1.0f, 2.0f, 3.0f);
3785   parent.SetProperty(Actor::Property::POSITION, parentPosition);
3786   parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3787   parent.SetProperty(Actor::Property::SCALE, parentScale);
3788   application.GetScene().Add(parent);
3789
3790   Actor child = Actor::New();
3791   child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3792   Constraint posConstraint = Constraint::New<Vector3>(child, Actor::Property::POSITION, PositionComponentConstraint());
3793   posConstraint.AddSource(Source(parent, Actor::Property::WORLD_MATRIX));
3794   posConstraint.Apply();
3795
3796   application.GetScene().Add(child);
3797
3798   application.SendNotification();
3799   application.Render(0);
3800   application.Render();
3801   application.SendNotification();
3802
3803   Matrix parentMatrix(false);
3804   parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3805
3806   DALI_TEST_EQUALS(parent.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), parentMatrix, 0.001, TEST_LOCATION);
3807   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), 0.001, TEST_LOCATION);
3808   END_TEST;
3809 }
3810
3811 int UtcDaliActorConstrainedToOrientation(void)
3812 {
3813   TestApplication application;
3814   tet_infoline(" UtcDaliActorConstrainedToOrientation");
3815
3816   Actor parent = Actor::New();
3817   parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3818   parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3819   Vector3    parentPosition(10.0f, 20.0f, 30.0f);
3820   Radian     rotationAngle(Degree(85.0f));
3821   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3822   Vector3    parentScale(1.0f, 2.0f, 3.0f);
3823   parent.SetProperty(Actor::Property::POSITION, parentPosition);
3824   parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3825   parent.SetProperty(Actor::Property::SCALE, parentScale);
3826   application.GetScene().Add(parent);
3827
3828   Actor child = Actor::New();
3829   child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3830   Constraint posConstraint = Constraint::New<Quaternion>(child, Actor::Property::ORIENTATION, OrientationComponentConstraint());
3831   posConstraint.AddSource(Source(parent, Actor::Property::ORIENTATION));
3832   posConstraint.Apply();
3833
3834   application.GetScene().Add(child);
3835
3836   application.SendNotification();
3837   application.Render(0);
3838   application.Render();
3839   application.SendNotification();
3840
3841   DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), parent.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
3842   END_TEST;
3843 }
3844
3845 int UtcDaliActorConstrainedToOpacity(void)
3846 {
3847   TestApplication application;
3848   tet_infoline(" UtcDaliActorConstrainedToOpacity");
3849
3850   Actor parent = Actor::New();
3851   parent.SetProperty(Actor::Property::OPACITY, 0.7f);
3852   application.GetScene().Add(parent);
3853
3854   Actor      child             = Actor::New();
3855   Constraint opacityConstraint = Constraint::New<float>(child, Actor::Property::OPACITY, EqualToConstraint());
3856   opacityConstraint.AddSource(Source(parent, Actor::Property::OPACITY));
3857   opacityConstraint.Apply();
3858
3859   application.GetScene().Add(child);
3860
3861   application.SendNotification();
3862   application.Render(0);
3863   application.Render();
3864   application.SendNotification();
3865
3866   DALI_TEST_EQUALS(child.GetCurrentProperty<float>(Actor::Property::OPACITY), parent.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.001f, TEST_LOCATION);
3867
3868   parent.SetProperty(Actor::Property::OPACITY, 0.3f);
3869
3870   application.SendNotification();
3871   application.Render(0);
3872   application.Render();
3873   application.SendNotification();
3874
3875   DALI_TEST_EQUALS(child.GetCurrentProperty<float>(Actor::Property::OPACITY), parent.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.001f, TEST_LOCATION);
3876
3877   END_TEST;
3878 }
3879
3880 int UtcDaliActorUnparent(void)
3881 {
3882   TestApplication application;
3883   tet_infoline(" UtcDaliActorUnparent");
3884
3885   Actor parent = Actor::New();
3886   application.GetScene().Add(parent);
3887
3888   Actor child = Actor::New();
3889
3890   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3891   DALI_TEST_CHECK(!child.GetParent());
3892
3893   // Test that calling Unparent with no parent is a NOOP
3894   child.Unparent();
3895
3896   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3897   DALI_TEST_CHECK(!child.GetParent());
3898
3899   // Test that Unparent works
3900   parent.Add(child);
3901
3902   DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
3903   DALI_TEST_CHECK(parent == child.GetParent());
3904
3905   child.Unparent();
3906
3907   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3908   DALI_TEST_CHECK(!child.GetParent());
3909
3910   // Test that UnparentAndReset works
3911   parent.Add(child);
3912
3913   DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
3914   DALI_TEST_CHECK(parent == child.GetParent());
3915
3916   UnparentAndReset(child);
3917
3918   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3919   DALI_TEST_CHECK(!child);
3920
3921   // Test that UnparentAndReset is a NOOP with empty handle
3922   UnparentAndReset(child);
3923
3924   DALI_TEST_CHECK(!child);
3925   END_TEST;
3926 }
3927
3928 int UtcDaliActorGetChildAt(void)
3929 {
3930   TestApplication application;
3931   tet_infoline(" UtcDaliActorGetChildAt");
3932
3933   Actor parent = Actor::New();
3934   application.GetScene().Add(parent);
3935
3936   Actor child0 = Actor::New();
3937   parent.Add(child0);
3938
3939   Actor child1 = Actor::New();
3940   parent.Add(child1);
3941
3942   Actor child2 = Actor::New();
3943   parent.Add(child2);
3944
3945   DALI_TEST_EQUALS(parent.GetChildAt(0), child0, TEST_LOCATION);
3946   DALI_TEST_EQUALS(parent.GetChildAt(1), child1, TEST_LOCATION);
3947   DALI_TEST_EQUALS(parent.GetChildAt(2), child2, TEST_LOCATION);
3948   END_TEST;
3949 }
3950
3951 int UtcDaliActorSetGetOverlay(void)
3952 {
3953   TestApplication application;
3954   tet_infoline(" UtcDaliActorSetGetOverlay");
3955
3956   Actor parent = Actor::New();
3957   parent.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3958   DALI_TEST_CHECK(parent.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE) == DrawMode::OVERLAY_2D);
3959   END_TEST;
3960 }
3961
3962 int UtcDaliActorCreateDestroy(void)
3963 {
3964   Actor* actor = new Actor;
3965   DALI_TEST_CHECK(actor);
3966   delete actor;
3967   END_TEST;
3968 }
3969
3970 namespace
3971 {
3972 struct PropertyStringIndex
3973 {
3974   const char* const     name;
3975   const Property::Index index;
3976   const Property::Type  type;
3977 };
3978
3979 const PropertyStringIndex PROPERTY_TABLE[] =
3980   {
3981     {"parentOrigin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3},
3982     {"parentOriginX", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT},
3983     {"parentOriginY", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT},
3984     {"parentOriginZ", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT},
3985     {"anchorPoint", Actor::Property::ANCHOR_POINT, Property::VECTOR3},
3986     {"anchorPointX", Actor::Property::ANCHOR_POINT_X, Property::FLOAT},
3987     {"anchorPointY", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT},
3988     {"anchorPointZ", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT},
3989     {"size", Actor::Property::SIZE, Property::VECTOR3},
3990     {"sizeWidth", Actor::Property::SIZE_WIDTH, Property::FLOAT},
3991     {"sizeHeight", Actor::Property::SIZE_HEIGHT, Property::FLOAT},
3992     {"sizeDepth", Actor::Property::SIZE_DEPTH, Property::FLOAT},
3993     {"position", Actor::Property::POSITION, Property::VECTOR3},
3994     {"positionX", Actor::Property::POSITION_X, Property::FLOAT},
3995     {"positionY", Actor::Property::POSITION_Y, Property::FLOAT},
3996     {"positionZ", Actor::Property::POSITION_Z, Property::FLOAT},
3997     {"worldPosition", Actor::Property::WORLD_POSITION, Property::VECTOR3},
3998     {"worldPositionX", Actor::Property::WORLD_POSITION_X, Property::FLOAT},
3999     {"worldPositionY", Actor::Property::WORLD_POSITION_Y, Property::FLOAT},
4000     {"worldPositionZ", Actor::Property::WORLD_POSITION_Z, Property::FLOAT},
4001     {"orientation", Actor::Property::ORIENTATION, Property::ROTATION},
4002     {"worldOrientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION},
4003     {"scale", Actor::Property::SCALE, Property::VECTOR3},
4004     {"scaleX", Actor::Property::SCALE_X, Property::FLOAT},
4005     {"scaleY", Actor::Property::SCALE_Y, Property::FLOAT},
4006     {"scaleZ", Actor::Property::SCALE_Z, Property::FLOAT},
4007     {"worldScale", Actor::Property::WORLD_SCALE, Property::VECTOR3},
4008     {"visible", Actor::Property::VISIBLE, Property::BOOLEAN},
4009     {"color", Actor::Property::COLOR, Property::VECTOR4},
4010     {"colorRed", Actor::Property::COLOR_RED, Property::FLOAT},
4011     {"colorGreen", Actor::Property::COLOR_GREEN, Property::FLOAT},
4012     {"colorBlue", Actor::Property::COLOR_BLUE, Property::FLOAT},
4013     {"colorAlpha", Actor::Property::COLOR_ALPHA, Property::FLOAT},
4014     {"worldColor", Actor::Property::WORLD_COLOR, Property::VECTOR4},
4015     {"worldMatrix", Actor::Property::WORLD_MATRIX, Property::MATRIX},
4016     {"name", Actor::Property::NAME, Property::STRING},
4017     {"sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN},
4018     {"leaveRequired", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN},
4019     {"inheritOrientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN},
4020     {"inheritScale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN},
4021     {"colorMode", Actor::Property::COLOR_MODE, Property::INTEGER},
4022     {"drawMode", Actor::Property::DRAW_MODE, Property::INTEGER},
4023     {"sizeModeFactor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3},
4024     {"widthResizePolicy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING},
4025     {"heightResizePolicy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING},
4026     {"sizeScalePolicy", Actor::Property::SIZE_SCALE_POLICY, Property::INTEGER},
4027     {"widthForHeight", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN},
4028     {"heightForWidth", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN},
4029     {"padding", Actor::Property::PADDING, Property::VECTOR4},
4030     {"minimumSize", Actor::Property::MINIMUM_SIZE, Property::VECTOR2},
4031     {"maximumSize", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2},
4032     {"inheritPosition", Actor::Property::INHERIT_POSITION, Property::BOOLEAN},
4033     {"clippingMode", Actor::Property::CLIPPING_MODE, Property::STRING},
4034     {"opacity", Actor::Property::OPACITY, Property::FLOAT},
4035 };
4036 const unsigned int PROPERTY_TABLE_COUNT = sizeof(PROPERTY_TABLE) / sizeof(PROPERTY_TABLE[0]);
4037 } // unnamed namespace
4038
4039 int UtcDaliActorProperties(void)
4040 {
4041   TestApplication application;
4042
4043   Actor actor = Actor::New();
4044
4045   for(unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i)
4046   {
4047     tet_printf("Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index);
4048     DALI_TEST_EQUALS(actor.GetPropertyName(PROPERTY_TABLE[i].index), PROPERTY_TABLE[i].name, TEST_LOCATION);
4049     DALI_TEST_EQUALS(actor.GetPropertyIndex(PROPERTY_TABLE[i].name), PROPERTY_TABLE[i].index, TEST_LOCATION);
4050     DALI_TEST_EQUALS(actor.GetPropertyType(PROPERTY_TABLE[i].index), PROPERTY_TABLE[i].type, TEST_LOCATION);
4051   }
4052   END_TEST;
4053 }
4054
4055 int UtcDaliRelayoutProperties_ResizePolicies(void)
4056 {
4057   TestApplication application;
4058
4059   Actor actor = Actor::New();
4060
4061   // Defaults
4062   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_RESIZE_POLICY).Get<std::string>(), "USE_NATURAL_SIZE", TEST_LOCATION);
4063   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_RESIZE_POLICY).Get<std::string>(), "USE_NATURAL_SIZE", TEST_LOCATION);
4064
4065   // Set resize policy for all dimensions
4066   actor.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
4067   for(unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
4068   {
4069     DALI_TEST_EQUALS(actor.GetResizePolicy(static_cast<Dimension::Type>(1 << i)), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION);
4070   }
4071
4072   // Set individual dimensions
4073   const char* const widthPolicy  = "FILL_TO_PARENT";
4074   const char* const heightPolicy = "FIXED";
4075
4076   actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy);
4077   actor.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy);
4078
4079   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_RESIZE_POLICY).Get<std::string>(), widthPolicy, TEST_LOCATION);
4080   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_RESIZE_POLICY).Get<std::string>(), heightPolicy, TEST_LOCATION);
4081
4082   // Set individual dimensions using enums
4083   ResizePolicy::Type widthPolicyEnum  = ResizePolicy::USE_ASSIGNED_SIZE;
4084   ResizePolicy::Type heightPolicyEnum = ResizePolicy::SIZE_RELATIVE_TO_PARENT;
4085
4086   actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, widthPolicyEnum);
4087   actor.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicyEnum);
4088
4089   DALI_TEST_EQUALS(static_cast<int>(actor.GetResizePolicy(Dimension::WIDTH)), static_cast<int>(widthPolicyEnum), TEST_LOCATION);
4090   DALI_TEST_EQUALS(static_cast<int>(actor.GetResizePolicy(Dimension::HEIGHT)), static_cast<int>(heightPolicyEnum), TEST_LOCATION);
4091
4092   END_TEST;
4093 }
4094
4095 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
4096 {
4097   TestApplication application;
4098
4099   Actor actor = Actor::New();
4100
4101   // Defaults
4102   DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION);
4103
4104   SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
4105   actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy);
4106   DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy, TEST_LOCATION);
4107
4108   // Set
4109   const SizeScalePolicy::Type policy1 = SizeScalePolicy::FIT_WITH_ASPECT_RATIO;
4110   const SizeScalePolicy::Type policy2 = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
4111
4112   actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy1);
4113   DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy1, TEST_LOCATION);
4114
4115   actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy2);
4116   DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy2, TEST_LOCATION);
4117
4118   END_TEST;
4119 }
4120
4121 int UtcDaliRelayoutProperties_SizeModeFactor(void)
4122 {
4123   TestApplication application;
4124
4125   Actor actor = Actor::New();
4126
4127   // Defaults
4128   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_MODE_FACTOR).Get<Vector3>(), Vector3(1.0f, 1.0f, 1.0f), TEST_LOCATION);
4129   DALI_TEST_EQUALS(actor.GetProperty<Vector3>(Actor::Property::SIZE_MODE_FACTOR), Vector3(1.0f, 1.0f, 1.0f), TEST_LOCATION);
4130
4131   Vector3 sizeMode(1.0f, 2.0f, 3.0f);
4132   actor.SetProperty(Actor::Property::SIZE_MODE_FACTOR, sizeMode);
4133   DALI_TEST_EQUALS(actor.GetProperty<Vector3>(Actor::Property::SIZE_MODE_FACTOR), sizeMode, TEST_LOCATION);
4134
4135   // Set
4136   Vector3 sizeMode1(2.0f, 3.0f, 4.0f);
4137
4138   actor.SetProperty(Actor::Property::SIZE_MODE_FACTOR, sizeMode1);
4139   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_MODE_FACTOR).Get<Vector3>(), sizeMode1, TEST_LOCATION);
4140
4141   END_TEST;
4142 }
4143
4144 int UtcDaliRelayoutProperties_DimensionDependency(void)
4145 {
4146   TestApplication application;
4147
4148   Actor actor = Actor::New();
4149
4150   // Defaults
4151   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), false, TEST_LOCATION);
4152   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_FOR_WIDTH).Get<bool>(), false, TEST_LOCATION);
4153
4154   // Set
4155   actor.SetProperty(Actor::Property::WIDTH_FOR_HEIGHT, true);
4156   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), true, TEST_LOCATION);
4157
4158   actor.SetProperty(Actor::Property::HEIGHT_FOR_WIDTH, true);
4159   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_FOR_WIDTH).Get<bool>(), true, TEST_LOCATION);
4160
4161   // Test setting another resize policy
4162   actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FIXED");
4163   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), false, TEST_LOCATION);
4164
4165   END_TEST;
4166 }
4167
4168 int UtcDaliRelayoutProperties_Padding(void)
4169 {
4170   TestApplication application;
4171
4172   Actor actor = Actor::New();
4173
4174   // Data
4175   Vector4 padding(1.0f, 2.0f, 3.0f, 4.0f);
4176
4177   // PADDING
4178   actor.SetProperty(Actor::Property::PADDING, padding);
4179   Vector4 paddingResult = actor.GetProperty(Actor::Property::PADDING).Get<Vector4>();
4180
4181   DALI_TEST_EQUALS(paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION);
4182
4183   END_TEST;
4184 }
4185
4186 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
4187 {
4188   TestApplication application;
4189
4190   Actor actor = Actor::New();
4191
4192   // Data
4193   Vector2 minSize(1.0f, 2.0f);
4194
4195   actor.SetProperty(Actor::Property::MINIMUM_SIZE, minSize);
4196   Vector2 resultMin = actor.GetProperty(Actor::Property::MINIMUM_SIZE).Get<Vector2>();
4197
4198   DALI_TEST_EQUALS(resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
4199
4200   Vector2 maxSize(3.0f, 4.0f);
4201
4202   actor.SetProperty(Actor::Property::MAXIMUM_SIZE, maxSize);
4203   Vector2 resultMax = actor.GetProperty(Actor::Property::MAXIMUM_SIZE).Get<Vector2>();
4204
4205   DALI_TEST_EQUALS(resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
4206
4207   END_TEST;
4208 }
4209
4210 int UtcDaliActorGetHeightForWidth(void)
4211 {
4212   TestApplication application;
4213
4214   Actor actor = Actor::New();
4215
4216   DALI_TEST_EQUALS(actor.GetHeightForWidth(1.0f), 1.0f, TEST_LOCATION);
4217
4218   END_TEST;
4219 }
4220
4221 int UtcDaliActorGetWidthForHeight(void)
4222 {
4223   TestApplication application;
4224
4225   Actor actor = Actor::New();
4226
4227   DALI_TEST_EQUALS(actor.GetWidthForHeight(1.0f), 1.0f, TEST_LOCATION);
4228
4229   END_TEST;
4230 }
4231
4232 int UtcDaliActorGetRelayoutSize(void)
4233 {
4234   TestApplication application;
4235
4236   Actor actor = Actor::New();
4237
4238   // Add actor to stage
4239   application.GetScene().Add(actor);
4240
4241   DALI_TEST_EQUALS(actor.GetRelayoutSize(Dimension::WIDTH), 0.0f, TEST_LOCATION);
4242
4243   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::WIDTH);
4244   actor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 0.0f));
4245
4246   // Flush the queue and render once
4247   application.SendNotification();
4248   application.Render();
4249
4250   DALI_TEST_EQUALS(actor.GetRelayoutSize(Dimension::WIDTH), 1.0f, TEST_LOCATION);
4251
4252   END_TEST;
4253 }
4254
4255 int UtcDaliActorSetPadding(void)
4256 {
4257   TestApplication application;
4258
4259   Actor actor = Actor::New();
4260
4261   Padding padding;
4262   padding = actor.GetProperty<Vector4>(Actor::Property::PADDING);
4263
4264   DALI_TEST_EQUALS(padding.left, 0.0f, TEST_LOCATION);
4265   DALI_TEST_EQUALS(padding.right, 0.0f, TEST_LOCATION);
4266   DALI_TEST_EQUALS(padding.bottom, 0.0f, TEST_LOCATION);
4267   DALI_TEST_EQUALS(padding.top, 0.0f, TEST_LOCATION);
4268
4269   Padding padding2(1.0f, 2.0f, 3.0f, 4.0f);
4270   actor.SetProperty(Actor::Property::PADDING, padding2);
4271
4272   padding = actor.GetProperty<Vector4>(Actor::Property::PADDING);
4273
4274   DALI_TEST_EQUALS(padding.left, padding2.left, TEST_LOCATION);
4275   DALI_TEST_EQUALS(padding.right, padding2.right, TEST_LOCATION);
4276   DALI_TEST_EQUALS(padding.bottom, padding2.bottom, TEST_LOCATION);
4277   DALI_TEST_EQUALS(padding.top, padding2.top, TEST_LOCATION);
4278
4279   END_TEST;
4280 }
4281
4282 int UtcDaliActorSetMinimumSize(void)
4283 {
4284   TestApplication application;
4285
4286   Actor actor = Actor::New();
4287
4288   Vector2 size = actor.GetProperty<Vector2>(Actor::Property::MINIMUM_SIZE);
4289
4290   DALI_TEST_EQUALS(size.width, 0.0f, TEST_LOCATION);
4291   DALI_TEST_EQUALS(size.height, 0.0f, TEST_LOCATION);
4292
4293   Vector2 size2(1.0f, 2.0f);
4294   actor.SetProperty(Actor::Property::MINIMUM_SIZE, size2);
4295
4296   size = actor.GetProperty<Vector2>(Actor::Property::MINIMUM_SIZE);
4297
4298   DALI_TEST_EQUALS(size.width, size2.width, TEST_LOCATION);
4299   DALI_TEST_EQUALS(size.height, size2.height, TEST_LOCATION);
4300
4301   END_TEST;
4302 }
4303
4304 int UtcDaliActorSetMaximumSize(void)
4305 {
4306   TestApplication application;
4307
4308   Actor actor = Actor::New();
4309
4310   Vector2 size = actor.GetProperty<Vector2>(Actor::Property::MAXIMUM_SIZE);
4311
4312   DALI_TEST_EQUALS(size.width, FLT_MAX, TEST_LOCATION);
4313   DALI_TEST_EQUALS(size.height, FLT_MAX, TEST_LOCATION);
4314
4315   Vector2 size2(1.0f, 2.0f);
4316   actor.SetProperty(Actor::Property::MAXIMUM_SIZE, size2);
4317
4318   size = actor.GetProperty<Vector2>(Actor::Property::MAXIMUM_SIZE);
4319
4320   DALI_TEST_EQUALS(size.width, size2.width, TEST_LOCATION);
4321   DALI_TEST_EQUALS(size.height, size2.height, TEST_LOCATION);
4322
4323   END_TEST;
4324 }
4325
4326 int UtcDaliActorOnRelayoutSignal(void)
4327 {
4328   tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
4329
4330   TestApplication application;
4331
4332   // Clean test data
4333   gOnRelayoutCallBackCalled = false;
4334   gActorNamesRelayout.clear();
4335
4336   Actor actor = Actor::New();
4337   actor.SetProperty(Actor::Property::NAME, "actor");
4338   actor.OnRelayoutSignal().Connect(OnRelayoutCallback);
4339
4340   // Sanity check
4341   DALI_TEST_CHECK(!gOnRelayoutCallBackCalled);
4342
4343   // Add actor to stage
4344   application.GetScene().Add(actor);
4345
4346   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
4347   actor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 2.0));
4348
4349   // Flush the queue and render once
4350   application.SendNotification();
4351   application.Render();
4352
4353   // OnRelayout emitted
4354   DALI_TEST_EQUALS(gOnRelayoutCallBackCalled, true, TEST_LOCATION);
4355   DALI_TEST_EQUALS("actor", gActorNamesRelayout[0], TEST_LOCATION);
4356
4357   END_TEST;
4358 }
4359
4360 int UtcDaliActorGetHierachyDepth(void)
4361 {
4362   TestApplication application;
4363   tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
4364
4365   /* Build tree of actors:
4366    *
4367    *                      Depth
4368    *
4369    *       A (parent)       1
4370    *      / \
4371    *     B   C              2`
4372    *    / \   \
4373    *   D   E   F            3
4374    *
4375    * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
4376    */
4377   Integration::Scene stage(application.GetScene());
4378
4379   Actor actorA = Actor::New();
4380   Actor actorB = Actor::New();
4381   Actor actorC = Actor::New();
4382   Actor actorD = Actor::New();
4383   Actor actorE = Actor::New();
4384   Actor actorF = Actor::New();
4385
4386   //Test that root actor has depth equal 0
4387   DALI_TEST_EQUALS(0, stage.GetRootLayer().GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4388
4389   //Test actors return depth -1 when not connected to the tree
4390   DALI_TEST_EQUALS(-1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4391   DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4392   DALI_TEST_EQUALS(-1, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4393   DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4394   DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4395   DALI_TEST_EQUALS(-1, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4396
4397   //Create the hierarchy
4398   stage.Add(actorA);
4399   actorA.Add(actorB);
4400   actorA.Add(actorC);
4401   actorB.Add(actorD);
4402   actorB.Add(actorE);
4403   actorC.Add(actorF);
4404
4405   //Test actors return correct depth
4406   DALI_TEST_EQUALS(1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4407   DALI_TEST_EQUALS(2, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4408   DALI_TEST_EQUALS(2, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4409   DALI_TEST_EQUALS(3, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4410   DALI_TEST_EQUALS(3, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4411   DALI_TEST_EQUALS(3, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4412
4413   //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
4414   actorA.Remove(actorB);
4415
4416   DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4417   DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4418   DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4419
4420   //Removing actorA from the stage. All actors should have depth equal -1
4421   stage.Remove(actorA);
4422
4423   DALI_TEST_EQUALS(-1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4424   DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4425   DALI_TEST_EQUALS(-1, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4426   DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4427   DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4428   DALI_TEST_EQUALS(-1, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4429
4430   END_TEST;
4431 }
4432
4433 int UtcDaliActorAnchorPointPropertyAsString(void)
4434 {
4435   TestApplication application;
4436
4437   Actor actor = Actor::New();
4438
4439   actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_LEFT");
4440   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_LEFT, TEST_LOCATION);
4441
4442   actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_CENTER");
4443   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_CENTER, TEST_LOCATION);
4444
4445   actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_RIGHT");
4446   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_RIGHT, TEST_LOCATION);
4447
4448   actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER_LEFT");
4449   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER_LEFT, TEST_LOCATION);
4450
4451   actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER");
4452   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER, TEST_LOCATION);
4453
4454   actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER_RIGHT");
4455   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER_RIGHT, TEST_LOCATION);
4456
4457   actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT");
4458   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION);
4459
4460   actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER");
4461   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION);
4462
4463   actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT");
4464   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
4465
4466   // Invalid should not change anything
4467   actor.SetProperty(Actor::Property::ANCHOR_POINT, "INVALID_ARG");
4468   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
4469
4470   END_TEST;
4471 }
4472
4473 int UtcDaliActorParentOriginPropertyAsString(void)
4474 {
4475   TestApplication application;
4476
4477   Actor actor = Actor::New();
4478
4479   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_LEFT");
4480   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_LEFT, TEST_LOCATION);
4481
4482   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_CENTER");
4483   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_CENTER, TEST_LOCATION);
4484
4485   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_RIGHT");
4486   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_RIGHT, TEST_LOCATION);
4487
4488   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER_LEFT");
4489   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER_LEFT, TEST_LOCATION);
4490
4491   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER");
4492   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER, TEST_LOCATION);
4493
4494   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT");
4495   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER_RIGHT, TEST_LOCATION);
4496
4497   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT");
4498   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION);
4499
4500   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER");
4501   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION);
4502
4503   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT");
4504   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
4505
4506   // Invalid should not change anything
4507   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "INVALID_ARG");
4508   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
4509
4510   END_TEST;
4511 }
4512
4513 int UtcDaliActorColorModePropertyAsString(void)
4514 {
4515   TestApplication application;
4516
4517   Actor actor = Actor::New();
4518
4519   actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_COLOR");
4520   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_COLOR, TEST_LOCATION);
4521
4522   actor.SetProperty(Actor::Property::COLOR_MODE, "USE_PARENT_COLOR");
4523   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_PARENT_COLOR, TEST_LOCATION);
4524
4525   actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR");
4526   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION);
4527
4528   actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA");
4529   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
4530
4531   // Invalid should not change anything
4532   actor.SetProperty(Actor::Property::COLOR_MODE, "INVALID_ARG");
4533   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
4534
4535   END_TEST;
4536 }
4537
4538 int UtcDaliActorDrawModePropertyAsString(void)
4539 {
4540   TestApplication application;
4541
4542   Actor actor = Actor::New();
4543
4544   actor.SetProperty(Actor::Property::DRAW_MODE, "NORMAL");
4545   DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::NORMAL, TEST_LOCATION);
4546
4547   actor.SetProperty(Actor::Property::DRAW_MODE, "OVERLAY_2D");
4548   DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
4549
4550   // Invalid should not change anything
4551   actor.SetProperty(Actor::Property::DRAW_MODE, "INVALID_ARG");
4552   DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
4553
4554   END_TEST;
4555 }
4556
4557 int UtcDaliActorColorModePropertyAsEnum(void)
4558 {
4559   TestApplication application;
4560
4561   Actor actor = Actor::New();
4562
4563   actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
4564   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_COLOR, TEST_LOCATION);
4565
4566   actor.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
4567   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_PARENT_COLOR, TEST_LOCATION);
4568
4569   actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR);
4570   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION);
4571
4572   actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
4573   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
4574
4575   END_TEST;
4576 }
4577
4578 int UtcDaliActorDrawModePropertyAsEnum(void)
4579 {
4580   TestApplication application;
4581
4582   Actor actor = Actor::New();
4583
4584   actor.SetProperty(Actor::Property::DRAW_MODE, DrawMode::NORMAL);
4585   DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::NORMAL, TEST_LOCATION);
4586
4587   actor.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
4588   DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
4589
4590   END_TEST;
4591 }
4592
4593 int UtcDaliActorAddRendererP(void)
4594 {
4595   tet_infoline("Testing Actor::AddRenderer");
4596   TestApplication application;
4597
4598   Actor actor = Actor::New();
4599
4600   DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4601
4602   Geometry geometry = CreateQuadGeometry();
4603   Shader   shader   = CreateShader();
4604   Renderer renderer = Renderer::New(geometry, shader);
4605
4606   actor.AddRenderer(renderer);
4607   DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4608   DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4609
4610   END_TEST;
4611 }
4612
4613 int UtcDaliActorAddRendererN01(void)
4614 {
4615   tet_infoline("Testing Actor::AddRenderer");
4616   TestApplication application;
4617
4618   Actor    actor = Actor::New();
4619   Renderer renderer;
4620
4621   // try illegal Add
4622   try
4623   {
4624     actor.AddRenderer(renderer);
4625     tet_printf("Assertion test failed - no Exception\n");
4626     tet_result(TET_FAIL);
4627   }
4628   catch(Dali::DaliException& e)
4629   {
4630     DALI_TEST_PRINT_ASSERT(e);
4631     DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
4632     DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4633   }
4634   catch(...)
4635   {
4636     tet_printf("Assertion test failed - wrong Exception\n");
4637     tet_result(TET_FAIL);
4638   }
4639
4640   END_TEST;
4641 }
4642
4643 int UtcDaliActorAddRendererN02(void)
4644 {
4645   tet_infoline("UtcDaliActorAddRendererN02");
4646
4647   Actor    actor;
4648   Renderer renderer;
4649
4650   {
4651     TestApplication application;
4652
4653     Geometry geometry = CreateQuadGeometry();
4654     Shader   shader   = CreateShader();
4655     renderer          = Renderer::New(geometry, shader);
4656
4657     actor = Actor::New();
4658   }
4659
4660   // try illegal AddRenderer
4661   try
4662   {
4663     actor.AddRenderer(renderer);
4664     tet_printf("Assertion test failed - no Exception\n");
4665     tet_result(TET_FAIL);
4666   }
4667   catch(Dali::DaliException& e)
4668   {
4669     DALI_TEST_PRINT_ASSERT(e);
4670     DALI_TEST_ASSERT(e, "EventThreadServices::IsCoreRunning()", TEST_LOCATION);
4671   }
4672   catch(...)
4673   {
4674     tet_printf("Assertion test failed - wrong Exception\n");
4675     tet_result(TET_FAIL);
4676   }
4677
4678   END_TEST;
4679 }
4680
4681 int UtcDaliActorAddRendererOnScene(void)
4682 {
4683   tet_infoline("Testing Actor::AddRenderer");
4684   TestApplication application;
4685
4686   Actor actor = Actor::New();
4687   application.GetScene().Add(actor);
4688
4689   application.SendNotification();
4690   application.Render(0);
4691
4692   Geometry geometry = CreateQuadGeometry();
4693   Shader   shader   = CreateShader();
4694   Renderer renderer = Renderer::New(geometry, shader);
4695
4696   application.SendNotification();
4697   application.Render(0);
4698
4699   try
4700   {
4701     actor.AddRenderer(renderer);
4702     tet_result(TET_PASS);
4703   }
4704   catch(...)
4705   {
4706     tet_result(TET_FAIL);
4707   }
4708
4709   END_TEST;
4710 }
4711
4712 int UtcDaliActorRemoveRendererP1(void)
4713 {
4714   tet_infoline("Testing Actor::RemoveRenderer");
4715   TestApplication application;
4716
4717   Actor actor = Actor::New();
4718
4719   DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4720
4721   {
4722     Geometry geometry = CreateQuadGeometry();
4723     Shader   shader   = CreateShader();
4724     Renderer renderer = Renderer::New(geometry, shader);
4725
4726     actor.AddRenderer(renderer);
4727     DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4728     DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4729
4730     application.SendNotification();
4731     application.Render();
4732   }
4733
4734   {
4735     Renderer renderer = actor.GetRendererAt(0);
4736     actor.RemoveRenderer(renderer);
4737     DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4738
4739     application.SendNotification();
4740     application.Render();
4741   }
4742
4743   // Call one final time to ensure that the renderer is actually removed after
4744   // the handle goes out of scope, and excercises the deletion code path in
4745   // scene graph and render.
4746   application.SendNotification();
4747   application.Render();
4748
4749   END_TEST;
4750 }
4751
4752 int UtcDaliActorRemoveRendererP2(void)
4753 {
4754   tet_infoline("Testing Actor::RemoveRenderer");
4755   TestApplication application;
4756
4757   Actor actor = Actor::New();
4758
4759   DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4760
4761   Geometry geometry = CreateQuadGeometry();
4762   Shader   shader   = CreateShader();
4763   Renderer renderer = Renderer::New(geometry, shader);
4764
4765   actor.AddRenderer(renderer);
4766   application.SendNotification();
4767   application.Render();
4768
4769   DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4770   DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4771
4772   actor.RemoveRenderer(0);
4773   application.SendNotification();
4774   application.Render();
4775
4776   DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4777
4778   // Shut down whilst holding onto the renderer handle.
4779   END_TEST;
4780 }
4781
4782 int UtcDaliActorRemoveRendererP3(void)
4783 {
4784   tet_infoline("Testing Actor::RemoveRenderer");
4785   TestApplication application;
4786
4787   Actor actor1 = Actor::New();
4788   Actor actor2 = Actor::New();
4789   Actor actor3 = Actor::New();
4790
4791   application.GetScene().Add(actor1);
4792   application.GetScene().Add(actor2);
4793   application.GetScene().Add(actor3);
4794
4795   // Make each actors size bigger than zero, so we can assuem that actor is rendered
4796   actor1.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
4797   actor2.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
4798   actor3.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
4799
4800   // Register some dummy property to seperate actor1 and actor2 in Render::Renderer
4801   actor1.RegisterProperty("dummy1", 1);
4802   actor2.RegisterProperty("dummy2", 2.0f);
4803   actor3.RegisterProperty("dummy3", Vector2(3.0f, 4.0f));
4804
4805   DALI_TEST_EQUALS(actor1.GetRendererCount(), 0u, TEST_LOCATION);
4806   DALI_TEST_EQUALS(actor2.GetRendererCount(), 0u, TEST_LOCATION);
4807   DALI_TEST_EQUALS(actor3.GetRendererCount(), 0u, TEST_LOCATION);
4808
4809   Geometry geometry  = CreateQuadGeometry();
4810   Shader   shader    = CreateShader();
4811   Renderer renderer1 = Renderer::New(geometry, shader);
4812   Renderer renderer2 = Renderer::New(geometry, shader);
4813
4814   actor1.AddRenderer(renderer1);
4815   actor1.AddRenderer(renderer2);
4816   actor2.AddRenderer(renderer1);
4817   actor2.AddRenderer(renderer2);
4818   actor3.AddRenderer(renderer1);
4819   actor3.AddRenderer(renderer2);
4820   application.SendNotification();
4821   application.Render();
4822
4823   DALI_TEST_EQUALS(actor1.GetRendererCount(), 2u, TEST_LOCATION);
4824   DALI_TEST_EQUALS(actor1.GetRendererAt(0), renderer1, TEST_LOCATION);
4825   DALI_TEST_EQUALS(actor1.GetRendererAt(1), renderer2, TEST_LOCATION);
4826
4827   DALI_TEST_EQUALS(actor2.GetRendererCount(), 2u, TEST_LOCATION);
4828   DALI_TEST_EQUALS(actor2.GetRendererAt(0), renderer1, TEST_LOCATION);
4829   DALI_TEST_EQUALS(actor2.GetRendererAt(1), renderer2, TEST_LOCATION);
4830
4831   DALI_TEST_EQUALS(actor3.GetRendererCount(), 2u, TEST_LOCATION);
4832   DALI_TEST_EQUALS(actor3.GetRendererAt(0), renderer1, TEST_LOCATION);
4833   DALI_TEST_EQUALS(actor3.GetRendererAt(1), renderer2, TEST_LOCATION);
4834
4835   actor1.RemoveRenderer(0);
4836   actor2.RemoveRenderer(1);
4837   actor3.RemoveRenderer(0);
4838   application.SendNotification();
4839   application.Render();
4840
4841   DALI_TEST_EQUALS(actor1.GetRendererCount(), 1u, TEST_LOCATION);
4842   DALI_TEST_EQUALS(actor1.GetRendererAt(0), renderer2, TEST_LOCATION);
4843   DALI_TEST_EQUALS(actor2.GetRendererCount(), 1u, TEST_LOCATION);
4844   DALI_TEST_EQUALS(actor2.GetRendererAt(0), renderer1, TEST_LOCATION);
4845   DALI_TEST_EQUALS(actor3.GetRendererCount(), 1u, TEST_LOCATION);
4846   DALI_TEST_EQUALS(actor3.GetRendererAt(0), renderer2, TEST_LOCATION);
4847
4848   // Shut down whilst holding onto the renderer handle.
4849   END_TEST;
4850 }
4851
4852 int UtcDaliActorRemoveRendererN(void)
4853 {
4854   tet_infoline("Testing Actor::RemoveRenderer");
4855   TestApplication application;
4856
4857   Actor actor = Actor::New();
4858
4859   DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4860
4861   Geometry geometry = CreateQuadGeometry();
4862   Shader   shader   = CreateShader();
4863   Renderer renderer = Renderer::New(geometry, shader);
4864
4865   actor.AddRenderer(renderer);
4866   DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4867   DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4868
4869   actor.RemoveRenderer(10);
4870   DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4871   DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4872
4873   END_TEST;
4874 }
4875
4876 int UtcDaliActorPropertyClippingP(void)
4877 {
4878   // This test checks the clippingMode property.
4879   tet_infoline("Testing Actor::Property::ClippingMode: P");
4880   TestApplication application;
4881
4882   Actor actor = Actor::New();
4883
4884   // Check default clippingEnabled value.
4885   Property::Value getValue(actor.GetProperty(Actor::Property::CLIPPING_MODE));
4886
4887   int  value          = 0;
4888   bool getValueResult = getValue.Get(value);
4889   DALI_TEST_CHECK(getValueResult);
4890
4891   if(getValueResult)
4892   {
4893     DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4894   }
4895
4896   // Check setting the property to the stencil mode.
4897   actor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4898
4899   // Check the new value was set.
4900   getValue       = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4901   getValueResult = getValue.Get(value);
4902   DALI_TEST_CHECK(getValueResult);
4903
4904   if(getValueResult)
4905   {
4906     DALI_TEST_EQUALS<int>(value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION);
4907   }
4908
4909   // Check setting the property to the scissor mode.
4910   actor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4911
4912   // Check the new value was set.
4913   getValue       = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4914   getValueResult = getValue.Get(value);
4915   DALI_TEST_CHECK(getValueResult);
4916
4917   if(getValueResult)
4918   {
4919     DALI_TEST_EQUALS<int>(value, ClippingMode::CLIP_TO_BOUNDING_BOX, TEST_LOCATION);
4920   }
4921   END_TEST;
4922 }
4923
4924 int UtcDaliActorPropertyClippingN(void)
4925 {
4926   // Negative test case for Clipping.
4927   tet_infoline("Testing Actor::Property::ClippingMode: N");
4928   TestApplication application;
4929
4930   Actor actor = Actor::New();
4931
4932   // Check default clippingEnabled value.
4933   Property::Value getValue(actor.GetProperty(Actor::Property::CLIPPING_MODE));
4934
4935   int  value          = 0;
4936   bool getValueResult = getValue.Get(value);
4937   DALI_TEST_CHECK(getValueResult);
4938
4939   if(getValueResult)
4940   {
4941     DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4942   }
4943
4944   // Check setting an invalid property value won't change the current property value.
4945   actor.SetProperty(Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY");
4946
4947   getValue       = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4948   getValueResult = getValue.Get(value);
4949   DALI_TEST_CHECK(getValueResult);
4950
4951   if(getValueResult)
4952   {
4953     DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4954   }
4955
4956   END_TEST;
4957 }
4958
4959 int UtcDaliActorPropertyClippingActor(void)
4960 {
4961   // This test checks that an actor is correctly setup for clipping.
4962   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor");
4963   TestApplication application;
4964
4965   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4966   TraceCallStack&    stencilTrace        = glAbstraction.GetStencilFunctionTrace();
4967   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4968   size_t             startIndex          = 0u;
4969
4970   // Create a clipping actor.
4971   Actor actorDepth1Clip = CreateActorWithContent16x16();
4972   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4973   application.GetScene().Add(actorDepth1Clip);
4974
4975   // Gather the call trace.
4976   GenerateTrace(application, enabledDisableTrace, stencilTrace);
4977
4978   // Check we are writing to the color buffer.
4979   CheckColorMask(glAbstraction, true);
4980
4981   // Check the stencil buffer was enabled.
4982   std::ostringstream oss;
4983   oss << std::hex << GL_STENCIL_TEST;
4984   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
4985
4986   // Check the stencil buffer was cleared.
4987   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4988
4989   // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4990   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4991   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));
4992   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4993
4994   END_TEST;
4995 }
4996
4997 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
4998 {
4999   // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
5000   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor enable and then disable");
5001   TestApplication application;
5002
5003   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
5004   TraceCallStack&    stencilTrace        = glAbstraction.GetStencilFunctionTrace();
5005   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5006   size_t             startIndex          = 0u;
5007
5008   // Create a clipping actor.
5009   Actor actorDepth1Clip = CreateActorWithContent16x16();
5010   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
5011   application.GetScene().Add(actorDepth1Clip);
5012
5013   // Gather the call trace.
5014   GenerateTrace(application, enabledDisableTrace, stencilTrace);
5015
5016   // Check we are writing to the color buffer.
5017   CheckColorMask(glAbstraction, true);
5018
5019   // Check the stencil buffer was enabled.
5020   std::ostringstream oss;
5021   oss << std::hex << GL_STENCIL_TEST;
5022   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
5023
5024   // Check the stencil buffer was cleared.
5025   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
5026
5027   // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
5028   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
5029   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));
5030   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
5031
5032   // Now disable the clipping
5033   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED);
5034
5035   // Gather the call trace.
5036   GenerateTrace(application, enabledDisableTrace, stencilTrace);
5037
5038   // Check the stencil buffer was disabled.
5039   std::ostringstream stencil;
5040   stencil << std::hex << GL_STENCIL_TEST;
5041   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Disable", stencil.str()));
5042
5043   // Ensure all values in stencil-mask are set to 1.
5044   startIndex = 0u;
5045   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "255", startIndex));
5046
5047   END_TEST;
5048 }
5049
5050 int UtcDaliActorPropertyClippingNestedChildren(void)
5051 {
5052   // This test checks that a hierarchy of actors are clipped correctly by
5053   // writing to and reading from the correct bit-planes of the stencil buffer.
5054   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN nested children");
5055   TestApplication    application;
5056   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
5057   TraceCallStack&    stencilTrace        = glAbstraction.GetStencilFunctionTrace();
5058   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5059
5060   // Create a clipping actor.
5061   Actor actorDepth1Clip = CreateActorWithContent16x16();
5062   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
5063   application.GetScene().Add(actorDepth1Clip);
5064
5065   // Create a child actor.
5066   Actor childDepth2 = CreateActorWithContent16x16();
5067   actorDepth1Clip.Add(childDepth2);
5068
5069   // Create another clipping actor.
5070   Actor childDepth2Clip = CreateActorWithContent16x16();
5071   childDepth2Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
5072   childDepth2.Add(childDepth2Clip);
5073
5074   // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
5075   // This tests the sort algorithm.
5076   Actor childDepth3 = CreateActorWithContent16x16();
5077   childDepth2Clip.Add(childDepth3);
5078   Actor childDepth4 = CreateActorWithContent16x16();
5079   childDepth3.Add(childDepth4);
5080
5081   // Gather the call trace.
5082   GenerateTrace(application, enabledDisableTrace, stencilTrace);
5083
5084   // Check we are writing to the color buffer.
5085   CheckColorMask(glAbstraction, true);
5086
5087   // Check the stencil buffer was enabled.
5088   std::ostringstream oss;
5089   oss << std::hex << GL_STENCIL_TEST;
5090   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
5091
5092   // Perform the test twice, once for 2D layer, and once for 3D.
5093   for(unsigned int i = 0u; i < 2u; ++i)
5094   {
5095     size_t startIndex = 0u;
5096
5097     // Check the stencil buffer was cleared.
5098     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
5099
5100     // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
5101     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex));      // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
5102     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));              // Write to the first bit-plane
5103     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
5104
5105     // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
5106     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 1", startIndex));      // 514 is GL_EQUAL
5107     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7680, 7680", startIndex)); // GL_KEEP, GL_KEEP, GL_KEEP
5108
5109     // Check we are set up to write to the second bitplane of the stencil buffer (only).
5110     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 3, 1", startIndex));      // 514 is GL_EQUAL, Test both bit-planes 1 & 2
5111     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "3", startIndex));              // Write to second (and previous) bit-planes
5112     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
5113
5114     // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
5115     // (Both must be set to pass the check).
5116     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 3, 3", startIndex));      // 514 is GL_EQUAL, Test both bit-planes 1 & 2
5117     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7680, 7680", startIndex)); // GL_KEEP, GL_KEEP, GL_KEEP
5118
5119     // If we are on the first loop, set the layer to 3D and loop to perform the test again.
5120     if(i == 0u)
5121     {
5122       application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D);
5123       GenerateTrace(application, enabledDisableTrace, stencilTrace);
5124     }
5125   }
5126
5127   END_TEST;
5128 }
5129
5130 int UtcDaliActorPropertyClippingActorDrawOrder(void)
5131 {
5132   // This test checks that a hierarchy of actors are drawn in the correct order when clipping is enabled.
5133   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN draw order");
5134   TestApplication    application;
5135   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
5136   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5137
5138   /* We create a small tree of actors as follows:
5139
5140                            A
5141                           / \
5142      Clipping enabled -> B   D
5143                          |   |
5144                          C   E
5145
5146      The correct draw order is "ABCDE" (the same as if clipping was not enabled).
5147   */
5148   Actor actors[5];
5149   for(int i = 0; i < 5; ++i)
5150   {
5151     Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
5152     Actor   actor = CreateRenderableActor(image);
5153
5154     // Setup dimensions and position so actor is not skipped by culling.
5155     actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
5156     actor.SetProperty(Actor::Property::SIZE, Vector2(16.0f, 16.0f));
5157
5158     if(i == 0)
5159     {
5160       actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5161     }
5162     else
5163     {
5164       float b = i > 2 ? 1.0f : -1.0f;
5165       actor.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0.5 + (0.2f * b), 0.8f, 0.8f));
5166     }
5167
5168     actors[i] = actor;
5169   }
5170
5171   // Enable clipping on the actor at the top of the left branch.
5172   actors[1].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
5173
5174   // Build the scene graph.
5175   application.GetScene().Add(actors[0]);
5176
5177   // Left branch:
5178   actors[0].Add(actors[1]);
5179   actors[1].Add(actors[2]);
5180
5181   // Right branch:
5182   actors[0].Add(actors[3]);
5183   actors[3].Add(actors[4]);
5184
5185   // Gather the call trace.
5186   enabledDisableTrace.Reset();
5187   enabledDisableTrace.Enable(true);
5188   application.SendNotification();
5189   application.Render();
5190   enabledDisableTrace.Enable(false);
5191
5192   /* Check stencil is enabled and disabled again (as right-hand branch of tree is drawn).
5193
5194      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
5195            Incorrect enable call trace:  StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960
5196   */
5197   size_t             startIndex = 0u;
5198   std::ostringstream blend;
5199   blend << std::hex << GL_BLEND;
5200   std::ostringstream stencil;
5201   stencil << std::hex << GL_STENCIL_TEST;
5202
5203   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", blend.str(), startIndex));
5204   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", stencil.str(), startIndex));
5205   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", stencil.str(), startIndex));
5206
5207   // Swap the clipping actor from top of left branch to top of right branch.
5208   actors[1].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED);
5209   actors[3].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
5210
5211   // Gather the call trace.
5212   enabledDisableTrace.Reset();
5213   enabledDisableTrace.Enable(true);
5214   application.SendNotification();
5215   application.Render();
5216   enabledDisableTrace.Enable(false);
5217
5218   // Check stencil is enabled but NOT disabled again (as right-hand branch of tree is drawn).
5219   // This proves the draw order has remained the same.
5220   startIndex = 0u;
5221   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", stencil.str(), startIndex));
5222   DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", stencil.str(), startIndex));
5223
5224   END_TEST;
5225 }
5226
5227 int UtcDaliActorPropertyScissorClippingActor01(void)
5228 {
5229   // This test checks that an actor is correctly setup for clipping.
5230   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor");
5231   TestApplication application;
5232
5233   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
5234   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
5235   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5236
5237   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
5238   const Vector2 imageSize(16.0f, 16.0f);
5239
5240   // Create a clipping actor.
5241   Actor clippingActorA = CreateActorWithContent16x16();
5242   // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
5243   // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
5244   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
5245   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
5246   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5247   application.GetScene().Add(clippingActorA);
5248
5249   // Gather the call trace.
5250   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5251
5252   // Check we are writing to the color buffer.
5253   CheckColorMask(glAbstraction, true);
5254
5255   // Check scissor test was enabled.
5256
5257   std::ostringstream scissor;
5258   scissor << std::hex << GL_SCISSOR_TEST;
5259   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5260
5261   // Check the scissor was set, and the coordinates are correct.
5262   std::stringstream compareParametersString;
5263   compareParametersString << "0, 0, " << imageSize.x << ", " << imageSize.y;
5264   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
5265
5266   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
5267   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_RIGHT);
5268
5269   // Gather the call trace.
5270   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5271
5272   // Check the scissor was set, and the coordinates are correct.
5273   compareParametersString.str(std::string());
5274   compareParametersString.clear();
5275   compareParametersString << (stageSize.x - imageSize.x) << ", " << (stageSize.y - imageSize.y) << ", " << imageSize.x << ", " << imageSize.y;
5276   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 464, 784, 16, 16
5277
5278   END_TEST;
5279 }
5280
5281 int UtcDaliActorPropertyScissorClippingActor02(void)
5282 {
5283   // This test checks that an actor is correctly setup for clipping.
5284   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor with a transparent renderer");
5285   TestApplication application;
5286
5287   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
5288   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
5289   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5290
5291   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
5292   const Vector2 actorSize(16.0f, 16.0f);
5293
5294   // Create a clipping actor.
5295   Actor clippingActorA                  = CreateRenderableActor();
5296   clippingActorA[Actor::Property::SIZE] = actorSize;
5297
5298   Renderer renderer = clippingActorA.GetRendererAt(0);
5299   DALI_TEST_CHECK(renderer);
5300
5301   // Make Renderer opacity 0.
5302   renderer[DevelRenderer::Property::OPACITY] = 0.0f;
5303
5304   // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
5305   // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
5306   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
5307   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
5308   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5309   application.GetScene().Add(clippingActorA);
5310
5311   // Gather the call trace.
5312   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5313
5314   // Check we are writing to the color buffer.
5315   CheckColorMask(glAbstraction, true);
5316
5317   // Check scissor test was enabled.
5318
5319   std::ostringstream scissor;
5320   scissor << std::hex << GL_SCISSOR_TEST;
5321   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5322
5323   // Check the scissor was set, and the coordinates are correct.
5324   std::stringstream compareParametersString;
5325   compareParametersString << "0, 0, " << actorSize.x << ", " << actorSize.y;
5326   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
5327
5328   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
5329   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_RIGHT);
5330
5331   // Gather the call trace.
5332   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5333
5334   // Check the scissor was set, and the coordinates are correct.
5335   compareParametersString.str(std::string());
5336   compareParametersString.clear();
5337   compareParametersString << (stageSize.x - actorSize.x) << ", " << (stageSize.y - actorSize.y) << ", " << actorSize.x << ", " << actorSize.y;
5338   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 464, 784, 16, 16
5339
5340   END_TEST;
5341 }
5342 int UtcDaliActorPropertyScissorClippingActorWihtoutRenderer(void)
5343 {
5344   // This test checks that an actor is correctly setup for clipping.
5345   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor without renderer");
5346   TestApplication application;
5347
5348   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
5349   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
5350   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5351
5352   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
5353   const Vector2 actorSize(16.0f, 16.0f);
5354
5355   // Create a clipping actor without renderer
5356   Actor clippingActorA                  = Actor::New();
5357   clippingActorA[Actor::Property::SIZE] = actorSize;
5358
5359   // Add dummy actor, to make application would be rendering.
5360   Actor dummyActor = CreateRenderableActor();
5361   dummyActor[Actor::Property::SIZE] = actorSize;
5362   clippingActorA.Add(dummyActor);
5363
5364   // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
5365   // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
5366   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
5367   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
5368   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5369   application.GetScene().Add(clippingActorA);
5370
5371   // Gather the call trace.
5372   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5373
5374   // Check we are writing to the color buffer.
5375   CheckColorMask(glAbstraction, true);
5376
5377   // Check scissor test was enabled.
5378
5379   std::ostringstream scissor;
5380   scissor << std::hex << GL_SCISSOR_TEST;
5381   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5382
5383   // Check the scissor was set, and the coordinates are correct.
5384   std::stringstream compareParametersString;
5385   compareParametersString << "0, 0, " << actorSize.x << ", " << actorSize.y;
5386   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
5387
5388   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
5389   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_RIGHT);
5390
5391   // Gather the call trace.
5392   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5393
5394   // Check the scissor was set, and the coordinates are correct.
5395   compareParametersString.str(std::string());
5396   compareParametersString.clear();
5397   compareParametersString << (stageSize.x - actorSize.x) << ", " << (stageSize.y - actorSize.y) << ", " << actorSize.x << ", " << actorSize.y;
5398   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 464, 784, 16, 16
5399
5400   END_TEST;
5401 }
5402
5403 int UtcDaliActorPropertyScissorClippingActorWihtoutRendererUnderLayer3D(void)
5404 {
5405   // This test checks that an actor is correctly setup for clipping.
5406   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor without renderer under layer 3d");
5407   TestApplication application;
5408
5409   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
5410   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
5411   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5412
5413   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
5414   const Vector2 actorSize(16.0f, 16.0f);
5415
5416   // Make root layer as LAYER_3D, to make we follow 3d flow.
5417   application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D);
5418
5419   // Create a clipping actor without renderer
5420   Actor clippingActorA                  = Actor::New();
5421   clippingActorA[Actor::Property::SIZE] = actorSize;
5422
5423   // Add dummy actor, to make application would be rendering.
5424   Actor dummyActor = CreateRenderableActor();
5425   dummyActor[Actor::Property::SIZE] = actorSize;
5426   clippingActorA.Add(dummyActor);
5427
5428   // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
5429   // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
5430   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
5431   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
5432   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5433   application.GetScene().Add(clippingActorA);
5434
5435   // Gather the call trace.
5436   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5437
5438   // Check we are writing to the color buffer.
5439   CheckColorMask(glAbstraction, true);
5440
5441   // Check scissor test was enabled.
5442
5443   std::ostringstream scissor;
5444   scissor << std::hex << GL_SCISSOR_TEST;
5445   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5446
5447   // Check the scissor was set, and the coordinates are correct.
5448   std::stringstream compareParametersString;
5449   compareParametersString << "0, 0, " << actorSize.x << ", " << actorSize.y;
5450   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
5451
5452   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
5453   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_RIGHT);
5454
5455   // Gather the call trace.
5456   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5457
5458   // Check the scissor was set, and the coordinates are correct.
5459   compareParametersString.str(std::string());
5460   compareParametersString.clear();
5461   compareParametersString << (stageSize.x - actorSize.x) << ", " << (stageSize.y - actorSize.y) << ", " << actorSize.x << ", " << actorSize.y;
5462   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 464, 784, 16, 16
5463
5464   END_TEST;
5465 }
5466
5467 int UtcDaliActorPropertyScissorClippingActorSiblings(void)
5468 {
5469   // This test checks that an actor is correctly setup for clipping.
5470   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actors which are siblings");
5471   TestApplication application;
5472
5473   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
5474   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
5475   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5476
5477   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
5478   const Vector2 sizeA{stageSize.width, stageSize.height * 0.25f};
5479   const Vector2 sizeB{stageSize.width, stageSize.height * 0.05f};
5480
5481   // Create a clipping actors.
5482   Actor clippingActorA = CreateActorWithContent(sizeA.width, sizeA.height);
5483   Actor clippingActorB = CreateActorWithContent(sizeB.width, sizeB.height);
5484
5485   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5486   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5487   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5488
5489   clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5490   clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5491   clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5492
5493   clippingActorA.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -200.0f, 0.0f));
5494   clippingActorB.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
5495
5496   application.GetScene().Add(clippingActorA);
5497   application.GetScene().Add(clippingActorB);
5498
5499   // Gather the call trace.
5500   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5501
5502   // Check we are writing to the color buffer.
5503   CheckColorMask(glAbstraction, true);
5504
5505   // Check scissor test was enabled.
5506   std::ostringstream scissor;
5507   scissor << std::hex << GL_SCISSOR_TEST;
5508   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5509
5510   // Check the scissor was set, and the coordinates are correct.
5511   std::stringstream compareParametersString;
5512
5513   std::string clipA("0, 500, 480, 200");
5514   std::string clipB("0, 380, 480, 40");
5515
5516   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipA));
5517   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipB));
5518
5519   END_TEST;
5520 }
5521
5522 int UtcDaliActorPropertyScissorClippingActorNested01(void)
5523 {
5524   // This test checks that an actor is correctly setup for clipping.
5525   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested");
5526   TestApplication application;
5527
5528   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
5529   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
5530   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5531
5532   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
5533   const Vector2 imageSize(16.0f, 16.0f);
5534
5535   /* Create a nest of 2 scissors to test nesting (intersecting clips).
5536
5537      A is drawn first - with scissor clipping on
5538      B is drawn second - also with scissor clipping on
5539      C is the generated clipping region, the intersection ( A ∩ B )
5540
5541            ┏━━━━━━━┓                   ┌───────┐
5542            ┃     B ┃                   │     B │
5543        ┌───╂┄┄┄┐   ┃               ┌┄┄┄╆━━━┓   │
5544        │   ┃   ┊   ┃     ━━━━━>    ┊   ┃ C ┃   │
5545        │   ┗━━━┿━━━┛               ┊   ┗━━━╃───┘
5546        │ A     │                   ┊ A     ┊
5547        └───────┘                   └┄┄┄┄┄┄┄┘
5548
5549      We then reposition B around each corner of A to test the 4 overlap combinations (thus testing intersecting works correctly).
5550   */
5551
5552   // Create a clipping actor.
5553   Actor clippingActorA = CreateActorWithContent16x16();
5554   // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
5555   // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
5556   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5557   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5558   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5559   application.GetScene().Add(clippingActorA);
5560
5561   // Create a child clipping actor.
5562   Actor clippingActorB = CreateActorWithContent16x16();
5563   clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5564   clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5565   clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5566   clippingActorA.Add(clippingActorB);
5567
5568   // positionModifiers is an array of positions to position B around.
5569   // expect is an array of expected scissor clip coordinate results.
5570   const Vector2 positionModifiers[4] = {Vector2(1.0f, 1.0f), Vector2(-1.0f, 1.0f), Vector2(-1.0f, -1.0f), Vector2(1.0f, -1.0f)};
5571   const Vector4 expect[4]            = {Vector4(240, 392, 8, 8), Vector4(232, 392, 8, 8), Vector4(232, 400, 8, 8), Vector4(240, 400, 8, 8)};
5572
5573   // Loop through each overlap combination.
5574   for(unsigned int test = 0u; test < 4u; ++test)
5575   {
5576     // Position the child clipping actor so it intersects with the 1st clipping actor. This changes each loop.
5577     const Vector2 position = (imageSize / 2.0f) * positionModifiers[test];
5578     clippingActorB.SetProperty(Actor::Property::POSITION, Vector2(position.x, position.y));
5579
5580     // Gather the call trace.
5581     GenerateTrace(application, enabledDisableTrace, scissorTrace);
5582
5583     // Check we are writing to the color buffer.
5584     CheckColorMask(glAbstraction, true);
5585
5586     // Check scissor test was enabled.
5587     std::ostringstream scissor;
5588     scissor << std::hex << GL_SCISSOR_TEST;
5589     DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5590
5591     // Check the scissor was set, and the coordinates are correct.
5592     const Vector4&    expectResults(expect[test]);
5593     std::stringstream compareParametersString;
5594     compareParametersString << expectResults.x << ", " << expectResults.y << ", " << expectResults.z << ", " << expectResults.w;
5595     DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with the expected result
5596   }
5597
5598   END_TEST;
5599 }
5600
5601 int UtcDaliActorPropertyScissorClippingActorNested02(void)
5602 {
5603   // This test checks that an actor is correctly setup for clipping.
5604   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested");
5605   TestApplication application;
5606
5607   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
5608   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
5609   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5610
5611   /* Create a nest of 2 scissors and siblings of the parent.
5612
5613             stage
5614               |
5615         ┌─────┐─────┐
5616         A     C     D
5617         |           |
5618         B           E
5619   */
5620
5621   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
5622   const Vector2 sizeA{stageSize.width, stageSize.height * 0.25f};
5623   const Vector2 sizeB{stageSize.width, stageSize.height * 0.05f};
5624   const Vector2 sizeC{stageSize.width, stageSize.height * 0.25f};
5625   const Vector2 sizeD{stageSize.width, stageSize.height * 0.25f};
5626   const Vector2 sizeE{stageSize.width, stageSize.height * 0.05f};
5627
5628   // Create a clipping actors.
5629   Actor clippingActorA = CreateActorWithContent(sizeA.width, sizeA.height);
5630   Actor clippingActorB = CreateActorWithContent(sizeB.width, sizeB.height);
5631   Actor clippingActorC = CreateActorWithContent(sizeC.width, sizeC.height);
5632   Actor clippingActorD = CreateActorWithContent(sizeD.width, sizeD.height);
5633   Actor clippingActorE = CreateActorWithContent(sizeE.width, sizeE.height);
5634
5635   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5636   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5637   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5638
5639   clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5640   clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5641   clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5642
5643   clippingActorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5644   clippingActorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5645   clippingActorC.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5646
5647   clippingActorD.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5648   clippingActorD.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5649   clippingActorD.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5650
5651   clippingActorE.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5652   clippingActorE.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5653
5654   clippingActorA.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -200.0f, 0.0f));
5655   clippingActorB.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
5656   clippingActorC.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 100.0f, 0.0f));
5657   clippingActorD.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
5658   clippingActorE.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
5659
5660   application.GetScene().Add(clippingActorA);
5661   clippingActorA.Add(clippingActorB);
5662   application.GetScene().Add(clippingActorC);
5663   application.GetScene().Add(clippingActorD);
5664   clippingActorD.Add(clippingActorE);
5665
5666   // Gather the call trace.
5667   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5668
5669   // Check we are writing to the color buffer.
5670   CheckColorMask(glAbstraction, true);
5671
5672   // Check scissor test was enabled.
5673   std::ostringstream scissor;
5674   scissor << std::hex << GL_SCISSOR_TEST;
5675   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5676
5677   // Check the scissor was set, and the coordinates are correct.
5678   std::string clipA("0, 500, 480, 200");
5679   std::string clipB("0, 580, 480, 40");
5680   std::string clipC("0, 200, 480, 200");
5681   std::string clipD("0, 300, 480, 200");
5682
5683   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipA));
5684   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipB));
5685   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipC));
5686   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipD));
5687   DALI_TEST_EQUALS(scissorTrace.CountMethod("Scissor"), 4, TEST_LOCATION); // Scissor rect should not be changed in clippingActorE case. So count should be 4.
5688
5689   END_TEST;
5690 }
5691
5692 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
5693 {
5694   // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
5695   tet_infoline("Testing Actor::Property::CLIPPING_MODE actor with renderer override");
5696   TestApplication application;
5697
5698   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
5699   TraceCallStack&    stencilTrace        = glAbstraction.GetStencilFunctionTrace();
5700   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5701
5702   // Create a clipping actor.
5703   Actor actorDepth1Clip = CreateActorWithContent16x16();
5704   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
5705   application.GetScene().Add(actorDepth1Clip);
5706
5707   // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
5708   actorDepth1Clip.GetRendererAt(0).SetProperty(Renderer::Property::RENDER_MODE, RenderMode::COLOR);
5709
5710   // Gather the call trace.
5711   GenerateTrace(application, enabledDisableTrace, stencilTrace);
5712
5713   // Check we are writing to the color buffer.
5714   CheckColorMask(glAbstraction, true);
5715
5716   // Check the stencil buffer was not enabled.
5717   std::ostringstream stencil;
5718   stencil << std::hex << GL_STENCIL_TEST;
5719   DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", stencil.str()));
5720
5721   // Check stencil functions are not called.
5722   DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilFunc"));
5723   DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilOp"));
5724
5725   // Check that scissor clipping is overriden by the renderer properties.
5726   TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
5727
5728   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5729
5730   // Gather the call trace.
5731   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5732
5733   // Check the stencil buffer was not enabled.
5734   std::ostringstream scissor;
5735   scissor << std::hex << GL_SCISSOR_TEST;
5736   DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5737
5738   DALI_TEST_CHECK(!scissorTrace.FindMethod("StencilFunc"));
5739
5740   END_TEST;
5741 }
5742
5743 int UtcDaliActorPropertyClippingActorCulled(void)
5744 {
5745   // This test checks that child actors are clipped by an culled parent actor.
5746   tet_infoline("Testing child actors are clipped by an culled parent actor");
5747   TestApplication application;
5748
5749   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
5750   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
5751   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5752
5753   const Vector2 actorSize(160.0f, 160.0f);
5754
5755   // Create a clipping actor.
5756   Actor clippingActorA                  = CreateRenderableActor();
5757   clippingActorA[Actor::Property::SIZE] = actorSize;
5758
5759   // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
5760   // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
5761   clippingActorA[Actor::Property::PARENT_ORIGIN] = ParentOrigin::BOTTOM_LEFT;
5762   clippingActorA[Actor::Property::ANCHOR_POINT]  = AnchorPoint::BOTTOM_LEFT;
5763   clippingActorA[Actor::Property::CLIPPING_MODE] = ClippingMode::CLIP_TO_BOUNDING_BOX;
5764   application.GetScene().Add(clippingActorA);
5765
5766   // Create a child actor
5767   Actor childActor                              = CreateRenderableActor();
5768   childActor[Actor::Property::PARENT_ORIGIN]    = ParentOrigin::BOTTOM_LEFT;
5769   childActor[Actor::Property::ANCHOR_POINT]     = AnchorPoint::BOTTOM_LEFT;
5770   childActor[Actor::Property::SIZE]             = Vector2(50.0f, 50.0f);
5771   childActor[Actor::Property::INHERIT_POSITION] = false;
5772
5773   // Gather the call trace.
5774   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5775
5776   // Check scissor test was enabled.
5777   std::ostringstream scissor;
5778   scissor << std::hex << GL_SCISSOR_TEST;
5779   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5780
5781   // Check the scissor was set, and the coordinates are correct.
5782   std::stringstream compareParametersString;
5783   compareParametersString << "0, 0, " << actorSize.x << ", " << actorSize.y;
5784   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
5785
5786   // Move the clipping actor out of screen
5787   clippingActorA[Actor::Property::POSITION] = Vector2(2000.0f, 2000.0f);
5788
5789   // Gather the call trace.
5790   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5791
5792   // Check the scissor was set, and the coordinates are correct.
5793   compareParametersString.str(std::string());
5794   compareParametersString.clear();
5795   compareParametersString << 2000 << ", " << 0 << ", " << 0 << ", " << 0;
5796   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Clipping area should be empty.
5797
5798   END_TEST;
5799 }
5800
5801 int UtcDaliGetPropertyN(void)
5802 {
5803   tet_infoline("Testing Actor::GetProperty returns a non valid value if property index is out of range");
5804   TestApplication application;
5805
5806   Actor actor = Actor::New();
5807
5808   unsigned int propertyCount = actor.GetPropertyCount();
5809   DALI_TEST_EQUALS(actor.GetProperty(Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION);
5810   END_TEST;
5811 }
5812
5813 int UtcDaliActorRaiseLower(void)
5814 {
5815   tet_infoline("UtcDaliActor Raise and Lower test\n");
5816
5817   TestApplication application;
5818
5819   Debug::Filter::SetGlobalLogLevel(Debug::Verbose);
5820   Debug::Filter::EnableGlobalTrace();
5821
5822   Integration::Scene stage(application.GetScene());
5823
5824   Actor actorA = Actor::New();
5825   Actor actorB = Actor::New();
5826   Actor actorC = Actor::New();
5827
5828   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5829   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5830
5831   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5832   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5833
5834   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5835   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5836
5837   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5838   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5839
5840   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5841   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5842
5843   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5844   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5845
5846   stage.Add(actorA);
5847   stage.Add(actorB);
5848   stage.Add(actorC);
5849
5850   ResetTouchCallbacks();
5851
5852   application.SendNotification();
5853   application.Render();
5854
5855   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5856   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5857   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5858
5859   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5860   // Only top actor will get touched.
5861   actorA.TouchedSignal().Connect(TestTouchCallback);
5862   actorB.TouchedSignal().Connect(TestTouchCallback2);
5863   actorC.TouchedSignal().Connect(TestTouchCallback3);
5864
5865   // Connect ChildOrderChangedSignal
5866   bool                     orderChangedSignal(false);
5867   Actor                    orderChangedActor;
5868   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5869   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5870
5871   Dali::Integration::Point point;
5872   point.SetDeviceId(1);
5873   point.SetState(PointState::DOWN);
5874   point.SetScreenPosition(Vector2(10.f, 10.f));
5875   Dali::Integration::TouchEvent touchEvent;
5876   touchEvent.AddPoint(point);
5877
5878   application.ProcessEvent(touchEvent);
5879
5880   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5881   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5882   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5883
5884   ResetTouchCallbacks();
5885
5886   tet_printf("Testing Raising of Actor\n");
5887
5888   int preActorOrder(0);
5889   int postActorOrder(0);
5890
5891   Property::Value value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5892   value.Get(preActorOrder);
5893
5894   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5895   actorB.Raise();
5896   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5897   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5898
5899   // Ensure sort order is calculated before next touch event
5900   application.SendNotification();
5901
5902   value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5903   value.Get(postActorOrder);
5904
5905   tet_printf("Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder);
5906
5907   application.ProcessEvent(touchEvent);
5908
5909   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5910   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5911   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5912
5913   ResetTouchCallbacks();
5914
5915   tet_printf("Testing Lowering of Actor\n");
5916
5917   value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5918   value.Get(preActorOrder);
5919
5920   orderChangedSignal = false;
5921
5922   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5923   actorB.Lower();
5924   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5925   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5926
5927   application.SendNotification(); // ensure sort order calculated before next touch event
5928
5929   value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5930   value.Get(postActorOrder);
5931
5932   tet_printf("Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder);
5933
5934   application.ProcessEvent(touchEvent);
5935
5936   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5937   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5938   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5939
5940   ResetTouchCallbacks();
5941
5942   Debug::Filter::DisableGlobalTrace();
5943   Debug::Filter::SetGlobalLogLevel(Debug::NoLogging);
5944
5945   END_TEST;
5946 }
5947
5948 int UtcDaliActorGeoTouchRaiseLower(void)
5949 {
5950   tet_infoline("UtcDaliActor Raise and Lower test\n");
5951
5952   TestApplication application;
5953
5954   Debug::Filter::SetGlobalLogLevel(Debug::Verbose);
5955   Debug::Filter::EnableGlobalTrace();
5956
5957   Integration::Scene stage(application.GetScene());
5958
5959   Actor actorA = Actor::New();
5960   Actor actorB = Actor::New();
5961   Actor actorC = Actor::New();
5962
5963   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5964   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5965
5966   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5967   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5968
5969   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5970   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5971
5972   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5973   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5974
5975   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5976   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5977
5978   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5979   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5980
5981   stage.Add(actorA);
5982   stage.Add(actorB);
5983   stage.Add(actorC);
5984
5985   application.GetScene().SetGeometryHittestEnabled(true);
5986   ResetTouchCallbacks(application);
5987
5988   application.SendNotification();
5989   application.Render();
5990
5991   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5992   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5993   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5994
5995   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5996   // Only top actor will get touched.
5997   actorA.TouchedSignal().Connect(TestTouchCallback);
5998   actorB.TouchedSignal().Connect(TestTouchCallback2);
5999   actorC.TouchedSignal().Connect(TestTouchCallback3);
6000
6001   // Connect ChildOrderChangedSignal
6002   bool                     orderChangedSignal(false);
6003   Actor                    orderChangedActor;
6004   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6005   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6006
6007   Dali::Integration::Point point;
6008   point.SetDeviceId(1);
6009   point.SetState(PointState::DOWN);
6010   point.SetScreenPosition(Vector2(10.f, 10.f));
6011   Dali::Integration::TouchEvent touchEvent;
6012   touchEvent.AddPoint(point);
6013
6014   application.ProcessEvent(touchEvent);
6015
6016   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6017   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6018   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6019
6020   ResetTouchCallbacks(application);
6021
6022   tet_printf("Testing Raising of Actor\n");
6023
6024   int preActorOrder(0);
6025   int postActorOrder(0);
6026
6027   Property::Value value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
6028   value.Get(preActorOrder);
6029
6030   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6031   actorB.Raise();
6032   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6033   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
6034
6035   // Ensure sort order is calculated before next touch event
6036   application.SendNotification();
6037
6038   value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
6039   value.Get(postActorOrder);
6040
6041   tet_printf("Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder);
6042
6043   application.ProcessEvent(touchEvent);
6044
6045   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6046   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6047   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6048
6049   ResetTouchCallbacks(application);
6050
6051   tet_printf("Testing Lowering of Actor\n");
6052
6053   value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
6054   value.Get(preActorOrder);
6055
6056   orderChangedSignal = false;
6057
6058   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6059   actorB.Lower();
6060   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6061   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
6062
6063   application.SendNotification(); // ensure sort order calculated before next touch event
6064
6065   value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
6066   value.Get(postActorOrder);
6067
6068   tet_printf("Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder);
6069
6070   application.ProcessEvent(touchEvent);
6071
6072   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6073   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6074   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6075
6076   ResetTouchCallbacks(application);
6077
6078   Debug::Filter::DisableGlobalTrace();
6079   Debug::Filter::SetGlobalLogLevel(Debug::NoLogging);
6080
6081   END_TEST;
6082 }
6083
6084 int UtcDaliActorRaiseToTopLowerToBottom(void)
6085 {
6086   tet_infoline("UtcDaliActorRaiseToTop and LowerToBottom test \n");
6087
6088   TestApplication application;
6089
6090   Integration::Scene stage(application.GetScene());
6091
6092   Actor actorA = Actor::New();
6093   Actor actorB = Actor::New();
6094   Actor actorC = Actor::New();
6095
6096   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
6097   // enables checking of which actor the uniform is assigned too
6098   Shader shaderA = CreateShader();
6099   shaderA.RegisterProperty("uRendererColor", 1.f);
6100
6101   Shader shaderB = CreateShader();
6102   shaderB.RegisterProperty("uRendererColor", 2.f);
6103
6104   Shader shaderC = CreateShader();
6105   shaderC.RegisterProperty("uRendererColor", 3.f);
6106
6107   Geometry geometry = CreateQuadGeometry();
6108
6109   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
6110   Renderer rendererA = Renderer::New(geometry, shaderA);
6111   actorA.AddRenderer(rendererA);
6112
6113   Renderer rendererB = Renderer::New(geometry, shaderB);
6114   actorB.AddRenderer(rendererB);
6115
6116   Renderer rendererC = Renderer::New(geometry, shaderC);
6117   actorC.AddRenderer(rendererC);
6118
6119   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6120   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6121
6122   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6123   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6124
6125   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6126   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6127
6128   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6129   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6130
6131   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6132   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6133
6134   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6135   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6136
6137   stage.Add(actorA);
6138   stage.Add(actorB);
6139   stage.Add(actorC);
6140
6141   ResetTouchCallbacks();
6142
6143   // Connect ChildOrderChangedSignal
6144   bool                     orderChangedSignal(false);
6145   Actor                    orderChangedActor;
6146   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6147   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6148
6149   // Set up gl abstraction trace so can query the set uniform order
6150   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
6151   glAbstraction.EnableSetUniformCallTrace(true);
6152   glAbstraction.ResetSetUniformCallStack();
6153
6154   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
6155
6156   application.SendNotification();
6157   application.Render();
6158
6159   tet_printf("Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str());
6160
6161   // Test order of uniforms in stack
6162   int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6163   int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6164   int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6165
6166   bool CBA = (indexC > indexB) && (indexB > indexA);
6167
6168   DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
6169
6170   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6171   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6172   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6173
6174   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6175   // Only top actor will get touched.
6176   actorA.TouchedSignal().Connect(TestTouchCallback);
6177   actorB.TouchedSignal().Connect(TestTouchCallback2);
6178   actorC.TouchedSignal().Connect(TestTouchCallback3);
6179
6180   Dali::Integration::Point point;
6181   point.SetDeviceId(1);
6182   point.SetState(PointState::DOWN);
6183   point.SetScreenPosition(Vector2(10.f, 10.f));
6184   Dali::Integration::TouchEvent touchEvent;
6185   touchEvent.AddPoint(point);
6186
6187   application.ProcessEvent(touchEvent);
6188
6189   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6190   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6191   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6192
6193   ResetTouchCallbacks();
6194
6195   tet_printf("RaiseToTop ActorA\n");
6196
6197   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6198   actorA.RaiseToTop();
6199   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6200   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6201
6202   application.SendNotification(); // ensure sorting order is calculated before next touch event
6203
6204   application.ProcessEvent(touchEvent);
6205
6206   glSetUniformStack.Reset();
6207
6208   application.SendNotification();
6209   application.Render();
6210
6211   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6212
6213   // Test order of uniforms in stack
6214   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6215   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6216   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6217
6218   tet_infoline("Testing A above C and B at bottom\n");
6219   bool ACB = (indexA > indexC) && (indexC > indexB);
6220
6221   DALI_TEST_EQUALS(ACB, true, TEST_LOCATION);
6222
6223   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6224   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6225   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6226
6227   ResetTouchCallbacks();
6228
6229   tet_printf("RaiseToTop ActorB\n");
6230
6231   orderChangedSignal = false;
6232
6233   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6234   actorB.RaiseToTop();
6235   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6236   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
6237
6238   application.SendNotification(); // Ensure sort order is calculated before next touch event
6239
6240   application.ProcessEvent(touchEvent);
6241
6242   glSetUniformStack.Reset();
6243
6244   application.SendNotification();
6245   application.Render();
6246
6247   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6248
6249   // Test order of uniforms in stack
6250   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6251   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6252   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6253
6254   tet_infoline("Testing B above A and C at bottom\n");
6255   bool BAC = (indexB > indexA) && (indexA > indexC);
6256
6257   DALI_TEST_EQUALS(BAC, true, TEST_LOCATION);
6258
6259   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6260   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6261   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6262
6263   ResetTouchCallbacks();
6264
6265   tet_printf("LowerToBottom ActorA then ActorB leaving Actor C at Top\n");
6266
6267   orderChangedSignal = false;
6268
6269   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6270   actorA.LowerToBottom();
6271   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6272   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6273
6274   application.SendNotification();
6275   application.Render();
6276
6277   orderChangedSignal = false;
6278
6279   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6280   actorB.LowerToBottom();
6281   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6282   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
6283
6284   application.SendNotification();
6285   application.Render();
6286
6287   application.ProcessEvent(touchEvent);
6288
6289   glSetUniformStack.Reset();
6290
6291   application.SendNotification();
6292   application.Render();
6293
6294   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6295
6296   // Test order of uniforms in stack
6297   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6298   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6299   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6300
6301   tet_infoline("Testing C above A and B at bottom\n");
6302   bool CAB = (indexC > indexA) && (indexA > indexB);
6303
6304   DALI_TEST_EQUALS(CAB, true, TEST_LOCATION);
6305
6306   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6307   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6308   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6309
6310   ResetTouchCallbacks();
6311
6312   END_TEST;
6313 }
6314
6315 int UtcDaliActorGeoTouchRaiseToTopLowerToBottom(void)
6316 {
6317   tet_infoline("UtcDaliActorRaiseToTop and LowerToBottom test \n");
6318
6319   TestApplication application;
6320
6321   Integration::Scene stage(application.GetScene());
6322
6323   Actor actorA = Actor::New();
6324   Actor actorB = Actor::New();
6325   Actor actorC = Actor::New();
6326
6327   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
6328   // enables checking of which actor the uniform is assigned too
6329   Shader shaderA = CreateShader();
6330   shaderA.RegisterProperty("uRendererColor", 1.f);
6331
6332   Shader shaderB = CreateShader();
6333   shaderB.RegisterProperty("uRendererColor", 2.f);
6334
6335   Shader shaderC = CreateShader();
6336   shaderC.RegisterProperty("uRendererColor", 3.f);
6337
6338   Geometry geometry = CreateQuadGeometry();
6339
6340   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
6341   Renderer rendererA = Renderer::New(geometry, shaderA);
6342   actorA.AddRenderer(rendererA);
6343
6344   Renderer rendererB = Renderer::New(geometry, shaderB);
6345   actorB.AddRenderer(rendererB);
6346
6347   Renderer rendererC = Renderer::New(geometry, shaderC);
6348   actorC.AddRenderer(rendererC);
6349
6350   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6351   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6352
6353   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6354   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6355
6356   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6357   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6358
6359   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6360   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6361
6362   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6363   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6364
6365   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6366   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6367
6368   stage.Add(actorA);
6369   stage.Add(actorB);
6370   stage.Add(actorC);
6371
6372   application.GetScene().SetGeometryHittestEnabled(true);
6373   ResetTouchCallbacks(application);
6374
6375   // Connect ChildOrderChangedSignal
6376   bool                     orderChangedSignal(false);
6377   Actor                    orderChangedActor;
6378   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6379   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6380
6381   // Set up gl abstraction trace so can query the set uniform order
6382   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
6383   glAbstraction.EnableSetUniformCallTrace(true);
6384   glAbstraction.ResetSetUniformCallStack();
6385
6386   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
6387
6388   application.SendNotification();
6389   application.Render();
6390
6391   tet_printf("Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str());
6392
6393   // Test order of uniforms in stack
6394   int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6395   int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6396   int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6397
6398   bool CBA = (indexC > indexB) && (indexB > indexA);
6399
6400   DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
6401
6402   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6403   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6404   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6405
6406   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6407   // Only top actor will get touched.
6408   actorA.TouchedSignal().Connect(TestTouchCallback);
6409   actorB.TouchedSignal().Connect(TestTouchCallback2);
6410   actorC.TouchedSignal().Connect(TestTouchCallback3);
6411
6412   Dali::Integration::Point point;
6413   point.SetDeviceId(1);
6414   point.SetState(PointState::DOWN);
6415   point.SetScreenPosition(Vector2(10.f, 10.f));
6416   Dali::Integration::TouchEvent touchEvent;
6417   touchEvent.AddPoint(point);
6418
6419   application.ProcessEvent(touchEvent);
6420
6421   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6422   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6423   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6424
6425   ResetTouchCallbacks(application);
6426
6427   tet_printf("RaiseToTop ActorA\n");
6428
6429   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6430   actorA.RaiseToTop();
6431   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6432   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6433
6434   application.SendNotification(); // ensure sorting order is calculated before next touch event
6435
6436   application.ProcessEvent(touchEvent);
6437
6438   glSetUniformStack.Reset();
6439
6440   application.SendNotification();
6441   application.Render();
6442
6443   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6444
6445   // Test order of uniforms in stack
6446   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6447   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6448   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6449
6450   tet_infoline("Testing A above C and B at bottom\n");
6451   bool ACB = (indexA > indexC) && (indexC > indexB);
6452
6453   DALI_TEST_EQUALS(ACB, true, TEST_LOCATION);
6454
6455   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6456   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6457   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6458
6459   ResetTouchCallbacks(application);
6460
6461   tet_printf("RaiseToTop ActorB\n");
6462
6463   orderChangedSignal = false;
6464
6465   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6466   actorB.RaiseToTop();
6467   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6468   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
6469
6470   application.SendNotification(); // Ensure sort order is calculated before next touch event
6471
6472   application.ProcessEvent(touchEvent);
6473
6474   glSetUniformStack.Reset();
6475
6476   application.SendNotification();
6477   application.Render();
6478
6479   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6480
6481   // Test order of uniforms in stack
6482   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6483   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6484   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6485
6486   tet_infoline("Testing B above A and C at bottom\n");
6487   bool BAC = (indexB > indexA) && (indexA > indexC);
6488
6489   DALI_TEST_EQUALS(BAC, true, TEST_LOCATION);
6490
6491   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6492   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6493   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6494
6495   ResetTouchCallbacks(application);
6496
6497   tet_printf("LowerToBottom ActorA then ActorB leaving Actor C at Top\n");
6498
6499   orderChangedSignal = false;
6500
6501   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6502   actorA.LowerToBottom();
6503   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6504   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6505
6506   application.SendNotification();
6507   application.Render();
6508
6509   orderChangedSignal = false;
6510
6511   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6512   actorB.LowerToBottom();
6513   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6514   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
6515
6516   application.SendNotification();
6517   application.Render();
6518
6519   application.ProcessEvent(touchEvent);
6520
6521   glSetUniformStack.Reset();
6522
6523   application.SendNotification();
6524   application.Render();
6525
6526   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6527
6528   // Test order of uniforms in stack
6529   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6530   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6531   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6532
6533   tet_infoline("Testing C above A and B at bottom\n");
6534   bool CAB = (indexC > indexA) && (indexA > indexB);
6535
6536   DALI_TEST_EQUALS(CAB, true, TEST_LOCATION);
6537
6538   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6539   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6540   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6541
6542   ResetTouchCallbacks(application);
6543
6544   END_TEST;
6545 }
6546
6547 int UtcDaliActorRaiseAbove(void)
6548 {
6549   tet_infoline("UtcDaliActor RaiseToAbove test \n");
6550
6551   TestApplication application;
6552
6553   Integration::Scene stage(application.GetScene());
6554
6555   Actor actorA = Actor::New();
6556   Actor actorB = Actor::New();
6557   Actor actorC = Actor::New();
6558
6559   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6560   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6561
6562   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6563   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6564
6565   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6566   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6567
6568   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6569   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6570
6571   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6572   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6573
6574   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6575   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6576
6577   stage.Add(actorA);
6578   stage.Add(actorB);
6579   stage.Add(actorC);
6580
6581   ResetTouchCallbacks();
6582
6583   application.SendNotification();
6584   application.Render();
6585
6586   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6587   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6588   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6589
6590   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6591   // Only top actor will get touched.
6592   actorA.TouchedSignal().Connect(TestTouchCallback);
6593   actorB.TouchedSignal().Connect(TestTouchCallback2);
6594   actorC.TouchedSignal().Connect(TestTouchCallback3);
6595
6596   bool                     orderChangedSignal(false);
6597   Actor                    orderChangedActor;
6598   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6599   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6600
6601   Dali::Integration::Point point;
6602   point.SetDeviceId(1);
6603   point.SetState(PointState::DOWN);
6604   point.SetScreenPosition(Vector2(10.f, 10.f));
6605   Dali::Integration::TouchEvent touchEvent;
6606   touchEvent.AddPoint(point);
6607
6608   application.ProcessEvent(touchEvent);
6609
6610   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6611   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6612   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6613
6614   ResetTouchCallbacks();
6615
6616   tet_printf("Raise actor B Above Actor C\n");
6617
6618   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6619   actorB.RaiseAbove(actorC);
6620   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6621   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
6622
6623   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6624   application.SendNotification();
6625   application.ProcessEvent(touchEvent);
6626
6627   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6628   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6629   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6630
6631   ResetTouchCallbacks();
6632
6633   tet_printf("Raise actor A Above Actor B\n");
6634
6635   orderChangedSignal = false;
6636
6637   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6638   actorA.RaiseAbove(actorB);
6639   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6640   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6641
6642   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6643   application.SendNotification();
6644
6645   application.ProcessEvent(touchEvent); // process a touch event on ordered actors.
6646
6647   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6648   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6649   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6650
6651   ResetTouchCallbacks();
6652
6653   END_TEST;
6654 }
6655
6656 int UtcDaliActorGeoTouchRaiseAbove(void)
6657 {
6658   tet_infoline("UtcDaliActor RaiseToAbove test \n");
6659
6660   TestApplication application;
6661
6662   Integration::Scene stage(application.GetScene());
6663
6664   Actor actorA = Actor::New();
6665   Actor actorB = Actor::New();
6666   Actor actorC = Actor::New();
6667
6668   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6669   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6670
6671   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6672   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6673
6674   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6675   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6676
6677   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6678   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6679
6680   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6681   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6682
6683   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6684   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6685
6686   stage.Add(actorA);
6687   stage.Add(actorB);
6688   stage.Add(actorC);
6689
6690   application.GetScene().SetGeometryHittestEnabled(true);
6691   ResetTouchCallbacks(application);
6692
6693   application.SendNotification();
6694   application.Render();
6695
6696   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6697   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6698   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6699
6700   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6701   // Only top actor will get touched.
6702   actorA.TouchedSignal().Connect(TestTouchCallback);
6703   actorB.TouchedSignal().Connect(TestTouchCallback2);
6704   actorC.TouchedSignal().Connect(TestTouchCallback3);
6705
6706   bool                     orderChangedSignal(false);
6707   Actor                    orderChangedActor;
6708   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6709   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6710
6711   Dali::Integration::Point point;
6712   point.SetDeviceId(1);
6713   point.SetState(PointState::DOWN);
6714   point.SetScreenPosition(Vector2(10.f, 10.f));
6715   Dali::Integration::TouchEvent touchEvent;
6716   touchEvent.AddPoint(point);
6717
6718   application.ProcessEvent(touchEvent);
6719
6720   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6721   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6722   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6723
6724   ResetTouchCallbacks(application);
6725
6726   tet_printf("Raise actor B Above Actor C\n");
6727
6728   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6729   actorB.RaiseAbove(actorC);
6730   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6731   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
6732
6733   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6734   application.SendNotification();
6735   application.ProcessEvent(touchEvent);
6736
6737   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6738   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6739   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6740
6741   ResetTouchCallbacks(application);
6742
6743   tet_printf("Raise actor A Above Actor B\n");
6744
6745   orderChangedSignal = false;
6746
6747   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6748   actorA.RaiseAbove(actorB);
6749   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6750   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6751
6752   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6753   application.SendNotification();
6754
6755   application.ProcessEvent(touchEvent); // process a touch event on ordered actors.
6756
6757   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6758   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6759   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6760
6761   ResetTouchCallbacks(application);
6762
6763   END_TEST;
6764 }
6765
6766
6767 int UtcDaliActorRaiseAbove2(void)
6768 {
6769   tet_infoline("UtcDaliActor RaiseToAbove test using SIBLING_ORDER property\n");
6770
6771   TestApplication application;
6772
6773   Integration::Scene stage(application.GetScene());
6774
6775   Actor actorA = Actor::New();
6776   Actor actorB = Actor::New();
6777   Actor actorC = Actor::New();
6778
6779   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6780   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6781
6782   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6783   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6784
6785   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6786   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6787
6788   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6789   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6790
6791   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6792   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6793
6794   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6795   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6796
6797   stage.Add(actorA);
6798   stage.Add(actorB);
6799   stage.Add(actorC);
6800
6801   ResetTouchCallbacks();
6802
6803   application.SendNotification();
6804   application.Render();
6805
6806   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6807   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6808   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6809
6810   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6811   // Only top actor will get touched.
6812   actorA.TouchedSignal().Connect(TestTouchCallback);
6813   actorB.TouchedSignal().Connect(TestTouchCallback2);
6814   actorC.TouchedSignal().Connect(TestTouchCallback3);
6815
6816   bool                     orderChangedSignal(false);
6817   Actor                    orderChangedActor;
6818   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6819   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6820
6821   Dali::Integration::Point point;
6822   point.SetDeviceId(1);
6823   point.SetState(PointState::DOWN);
6824   point.SetScreenPosition(Vector2(10.f, 10.f));
6825   Dali::Integration::TouchEvent touchEvent;
6826   touchEvent.AddPoint(point);
6827
6828   application.ProcessEvent(touchEvent);
6829
6830   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6831   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6832   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6833
6834   ResetTouchCallbacks();
6835
6836   tet_printf("Raise actor B Above Actor C\n");
6837
6838   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6839   int newOrder                                = actorC[DevelActor::Property::SIBLING_ORDER];
6840   actorB[DevelActor::Property::SIBLING_ORDER] = newOrder;
6841   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6842   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
6843
6844   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6845   application.SendNotification();
6846   application.ProcessEvent(touchEvent);
6847
6848   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6849   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6850   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6851
6852   ResetTouchCallbacks();
6853
6854   tet_printf("Raise actor A Above Actor B\n");
6855
6856   orderChangedSignal = false;
6857
6858   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6859   newOrder                                    = actorB[DevelActor::Property::SIBLING_ORDER];
6860   actorA[DevelActor::Property::SIBLING_ORDER] = newOrder;
6861   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6862   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6863
6864   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6865   application.SendNotification();
6866
6867   application.ProcessEvent(touchEvent); // process a touch event on ordered actors.
6868
6869   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6870   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6871   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6872
6873   ResetTouchCallbacks();
6874
6875   END_TEST;
6876 }
6877
6878 int UtcDaliActorGeoTouchRaiseAbove2(void)
6879 {
6880   tet_infoline("UtcDaliActor RaiseToAbove test using SIBLING_ORDER property\n");
6881
6882   TestApplication application;
6883
6884   Integration::Scene stage(application.GetScene());
6885
6886   Actor actorA = Actor::New();
6887   Actor actorB = Actor::New();
6888   Actor actorC = Actor::New();
6889
6890   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6891   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6892
6893   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6894   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6895
6896   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6897   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6898
6899   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6900   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6901
6902   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6903   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6904
6905   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6906   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6907
6908   stage.Add(actorA);
6909   stage.Add(actorB);
6910   stage.Add(actorC);
6911
6912   application.GetScene().SetGeometryHittestEnabled(true);
6913   ResetTouchCallbacks(application);
6914
6915   application.SendNotification();
6916   application.Render();
6917
6918   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6919   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6920   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6921
6922   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6923   // Only top actor will get touched.
6924   actorA.TouchedSignal().Connect(TestTouchCallback);
6925   actorB.TouchedSignal().Connect(TestTouchCallback2);
6926   actorC.TouchedSignal().Connect(TestTouchCallback3);
6927
6928   bool                     orderChangedSignal(false);
6929   Actor                    orderChangedActor;
6930   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6931   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6932
6933   Dali::Integration::Point point;
6934   point.SetDeviceId(1);
6935   point.SetState(PointState::DOWN);
6936   point.SetScreenPosition(Vector2(10.f, 10.f));
6937   Dali::Integration::TouchEvent touchEvent;
6938   touchEvent.AddPoint(point);
6939
6940   application.ProcessEvent(touchEvent);
6941
6942   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6943   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6944   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6945
6946   ResetTouchCallbacks(application);
6947
6948   tet_printf("Raise actor B Above Actor C\n");
6949
6950   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6951   int newOrder                                = actorC[DevelActor::Property::SIBLING_ORDER];
6952   actorB[DevelActor::Property::SIBLING_ORDER] = newOrder;
6953   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6954   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
6955
6956   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6957   application.SendNotification();
6958   application.ProcessEvent(touchEvent);
6959
6960   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6961   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6962   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6963
6964   ResetTouchCallbacks(application);
6965
6966   tet_printf("Raise actor A Above Actor B\n");
6967
6968   orderChangedSignal = false;
6969
6970   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6971   newOrder                                    = actorB[DevelActor::Property::SIBLING_ORDER];
6972   actorA[DevelActor::Property::SIBLING_ORDER] = newOrder;
6973   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6974   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6975
6976   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6977   application.SendNotification();
6978
6979   application.ProcessEvent(touchEvent); // process a touch event on ordered actors.
6980
6981   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6982   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6983   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6984
6985   ResetTouchCallbacks(application);
6986
6987   END_TEST;
6988 }
6989
6990 int UtcDaliActorLowerBelow(void)
6991 {
6992   tet_infoline("UtcDaliActor LowerBelow test \n");
6993
6994   TestApplication application;
6995
6996   Integration::Scene stage(application.GetScene());
6997
6998   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
6999   // enables checking of which actor the uniform is assigned too
7000   Shader shaderA = CreateShader();
7001   shaderA.RegisterProperty("uRendererColor", 1.f);
7002
7003   Shader shaderB = CreateShader();
7004   shaderB.RegisterProperty("uRendererColor", 2.f);
7005
7006   Shader shaderC = CreateShader();
7007   shaderC.RegisterProperty("uRendererColor", 3.f);
7008
7009   Actor actorA = Actor::New();
7010   Actor actorB = Actor::New();
7011   Actor actorC = Actor::New();
7012
7013   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
7014   Geometry geometry = CreateQuadGeometry();
7015
7016   Renderer rendererA = Renderer::New(geometry, shaderA);
7017   actorA.AddRenderer(rendererA);
7018
7019   Renderer rendererB = Renderer::New(geometry, shaderB);
7020   actorB.AddRenderer(rendererB);
7021
7022   Renderer rendererC = Renderer::New(geometry, shaderC);
7023   actorC.AddRenderer(rendererC);
7024
7025   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7026   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7027
7028   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7029   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7030
7031   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7032   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7033
7034   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
7035   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
7036
7037   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
7038   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
7039
7040   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
7041   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
7042
7043   Actor container = Actor::New();
7044   container.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7045   container.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
7046   stage.Add(container);
7047
7048   container.Add(actorA);
7049   container.Add(actorB);
7050   container.Add(actorC);
7051
7052   ResetTouchCallbacks();
7053
7054   // Connect ChildOrderChangedSignal
7055   bool                     orderChangedSignal(false);
7056   Actor                    orderChangedActor;
7057   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
7058   DevelActor::ChildOrderChangedSignal(container).Connect(&application, f);
7059
7060   // Set up gl abstraction trace so can query the set uniform order
7061   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
7062   glAbstraction.EnableSetUniformCallTrace(true);
7063   glAbstraction.ResetSetUniformCallStack();
7064   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
7065
7066   glAbstraction.ResetSetUniformCallStack();
7067
7068   application.SendNotification();
7069   application.Render();
7070
7071   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
7072
7073   // Test order of uniforms in stack
7074   int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
7075   int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
7076   int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
7077
7078   tet_infoline("Testing C above B and A at bottom\n");
7079   bool CBA = (indexC > indexB) && (indexB > indexA);
7080
7081   DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
7082
7083   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
7084   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
7085   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
7086
7087   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
7088   // Only top actor will get touched.
7089   actorA.TouchedSignal().Connect(TestTouchCallback);
7090   actorB.TouchedSignal().Connect(TestTouchCallback2);
7091   actorC.TouchedSignal().Connect(TestTouchCallback3);
7092
7093   Dali::Integration::Point point;
7094   point.SetDeviceId(1);
7095   point.SetState(PointState::DOWN);
7096   point.SetScreenPosition(Vector2(10.f, 10.f));
7097   Dali::Integration::TouchEvent touchEvent;
7098   touchEvent.AddPoint(point);
7099
7100   tet_infoline("UtcDaliActor Test Set up completed \n");
7101
7102   application.ProcessEvent(touchEvent);
7103
7104   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
7105   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
7106   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
7107
7108   ResetTouchCallbacks();
7109
7110   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");
7111
7112   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
7113   actorC.LowerBelow(actorB);
7114   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
7115   DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
7116
7117   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
7118   application.SendNotification();
7119   application.Render();
7120
7121   application.ProcessEvent(touchEvent); // touch event
7122
7123   glSetUniformStack.Reset();
7124
7125   application.SendNotification();
7126   application.Render();
7127
7128   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
7129
7130   // Test order of uniforms in stack
7131   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
7132   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
7133   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
7134
7135   tet_infoline("Testing render order is A, C, B");
7136   DALI_TEST_EQUALS(indexC > indexA, true, TEST_LOCATION);
7137   DALI_TEST_EQUALS(indexB > indexC, true, TEST_LOCATION);
7138
7139   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
7140   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
7141   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
7142
7143   ResetTouchCallbacks();
7144
7145   tet_printf("Lower actor C below Actor A leaving B on top\n");
7146
7147   orderChangedSignal = false;
7148
7149   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
7150   actorC.LowerBelow(actorA);
7151   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
7152   DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
7153
7154   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
7155   application.SendNotification();
7156   application.Render();
7157
7158   application.ProcessEvent(touchEvent);
7159
7160   glSetUniformStack.Reset();
7161
7162   application.Render();
7163   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
7164
7165   // Test order of uniforms in stack
7166   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
7167   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
7168   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
7169
7170   DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
7171   DALI_TEST_EQUALS(indexB > indexA, true, TEST_LOCATION);
7172
7173   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
7174   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
7175   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
7176
7177   ResetTouchCallbacks();
7178
7179   tet_printf("Lower actor B below Actor C leaving A on top\n");
7180
7181   orderChangedSignal = false;
7182
7183   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
7184   actorB.LowerBelow(actorC);
7185   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
7186   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
7187
7188   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
7189   application.SendNotification();
7190   application.Render();
7191
7192   application.ProcessEvent(touchEvent);
7193
7194   glSetUniformStack.Reset();
7195
7196   application.Render();
7197   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
7198
7199   // Test order of uniforms in stack
7200   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
7201   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
7202   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
7203
7204   DALI_TEST_EQUALS(indexC > indexB, true, TEST_LOCATION);
7205   DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
7206
7207   END_TEST;
7208 }
7209
7210 int UtcDaliActorGeoTouchLowerBelow(void)
7211 {
7212   tet_infoline("UtcDaliActor LowerBelow test \n");
7213
7214   TestApplication application;
7215
7216   Integration::Scene stage(application.GetScene());
7217
7218   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
7219   // enables checking of which actor the uniform is assigned too
7220   Shader shaderA = CreateShader();
7221   shaderA.RegisterProperty("uRendererColor", 1.f);
7222
7223   Shader shaderB = CreateShader();
7224   shaderB.RegisterProperty("uRendererColor", 2.f);
7225
7226   Shader shaderC = CreateShader();
7227   shaderC.RegisterProperty("uRendererColor", 3.f);
7228
7229   Actor actorA = Actor::New();
7230   Actor actorB = Actor::New();
7231   Actor actorC = Actor::New();
7232
7233   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
7234   Geometry geometry = CreateQuadGeometry();
7235
7236   Renderer rendererA = Renderer::New(geometry, shaderA);
7237   actorA.AddRenderer(rendererA);
7238
7239   Renderer rendererB = Renderer::New(geometry, shaderB);
7240   actorB.AddRenderer(rendererB);
7241
7242   Renderer rendererC = Renderer::New(geometry, shaderC);
7243   actorC.AddRenderer(rendererC);
7244
7245   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7246   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7247
7248   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7249   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7250
7251   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7252   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7253
7254   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
7255   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
7256
7257   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
7258   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
7259
7260   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
7261   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
7262
7263   Actor container = Actor::New();
7264   container.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7265   container.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
7266   stage.Add(container);
7267
7268   container.Add(actorA);
7269   container.Add(actorB);
7270   container.Add(actorC);
7271
7272   application.GetScene().SetGeometryHittestEnabled(true);
7273   ResetTouchCallbacks(application);
7274
7275   // Connect ChildOrderChangedSignal
7276   bool                     orderChangedSignal(false);
7277   Actor                    orderChangedActor;
7278   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
7279   DevelActor::ChildOrderChangedSignal(container).Connect(&application, f);
7280
7281   // Set up gl abstraction trace so can query the set uniform order
7282   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
7283   glAbstraction.EnableSetUniformCallTrace(true);
7284   glAbstraction.ResetSetUniformCallStack();
7285   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
7286
7287   glAbstraction.ResetSetUniformCallStack();
7288
7289   application.SendNotification();
7290   application.Render();
7291
7292   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
7293
7294   // Test order of uniforms in stack
7295   int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
7296   int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
7297   int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
7298
7299   tet_infoline("Testing C above B and A at bottom\n");
7300   bool CBA = (indexC > indexB) && (indexB > indexA);
7301
7302   DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
7303
7304   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
7305   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
7306   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
7307
7308   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
7309   // Only top actor will get touched.
7310   actorA.TouchedSignal().Connect(TestTouchCallback);
7311   actorB.TouchedSignal().Connect(TestTouchCallback2);
7312   actorC.TouchedSignal().Connect(TestTouchCallback3);
7313
7314   Dali::Integration::Point point;
7315   point.SetDeviceId(1);
7316   point.SetState(PointState::DOWN);
7317   point.SetScreenPosition(Vector2(10.f, 10.f));
7318   Dali::Integration::TouchEvent touchEvent;
7319   touchEvent.AddPoint(point);
7320
7321   tet_infoline("UtcDaliActor Test Set up completed \n");
7322
7323   application.ProcessEvent(touchEvent);
7324
7325   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
7326   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
7327   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
7328
7329   ResetTouchCallbacks(application);
7330
7331   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");
7332
7333   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
7334   actorC.LowerBelow(actorB);
7335   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
7336   DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
7337
7338   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
7339   application.SendNotification();
7340   application.Render();
7341
7342   application.ProcessEvent(touchEvent); // touch event
7343
7344   glSetUniformStack.Reset();
7345
7346   application.SendNotification();
7347   application.Render();
7348
7349   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
7350
7351   // Test order of uniforms in stack
7352   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
7353   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
7354   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
7355
7356   tet_infoline("Testing render order is A, C, B");
7357   DALI_TEST_EQUALS(indexC > indexA, true, TEST_LOCATION);
7358   DALI_TEST_EQUALS(indexB > indexC, true, TEST_LOCATION);
7359
7360   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
7361   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
7362   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
7363
7364   ResetTouchCallbacks(application);
7365
7366   tet_printf("Lower actor C below Actor A leaving B on top\n");
7367
7368   orderChangedSignal = false;
7369
7370   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
7371   actorC.LowerBelow(actorA);
7372   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
7373   DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
7374
7375   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
7376   application.SendNotification();
7377   application.Render();
7378
7379   application.ProcessEvent(touchEvent);
7380
7381   glSetUniformStack.Reset();
7382
7383   application.Render();
7384   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
7385
7386   // Test order of uniforms in stack
7387   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
7388   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
7389   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
7390
7391   DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
7392   DALI_TEST_EQUALS(indexB > indexA, true, TEST_LOCATION);
7393
7394   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
7395   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
7396   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
7397
7398   ResetTouchCallbacks(application);
7399
7400   tet_printf("Lower actor B below Actor C leaving A on top\n");
7401
7402   orderChangedSignal = false;
7403
7404   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
7405   actorB.LowerBelow(actorC);
7406   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
7407   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
7408
7409   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
7410   application.SendNotification();
7411   application.Render();
7412
7413   application.ProcessEvent(touchEvent);
7414
7415   glSetUniformStack.Reset();
7416
7417   application.Render();
7418   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
7419
7420   // Test order of uniforms in stack
7421   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
7422   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
7423   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
7424
7425   DALI_TEST_EQUALS(indexC > indexB, true, TEST_LOCATION);
7426   DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
7427
7428   END_TEST;
7429 }
7430
7431 int UtcDaliActorLowerBelow2(void)
7432 {
7433   tet_infoline("UtcDaliActor LowerBelow test using SIBLING_ORDER property\n");
7434
7435   TestApplication application;
7436
7437   Integration::Scene stage(application.GetScene());
7438
7439   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
7440   // enables checking of which actor the uniform is assigned too
7441   Shader shaderA = CreateShader();
7442   shaderA.RegisterProperty("uRendererColor", 1.f);
7443
7444   Shader shaderB = CreateShader();
7445   shaderB.RegisterProperty("uRendererColor", 2.f);
7446
7447   Shader shaderC = CreateShader();
7448   shaderC.RegisterProperty("uRendererColor", 3.f);
7449
7450   Actor actorA = Actor::New();
7451   Actor actorB = Actor::New();
7452   Actor actorC = Actor::New();
7453
7454   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
7455   Geometry geometry = CreateQuadGeometry();
7456
7457   Renderer rendererA = Renderer::New(geometry, shaderA);
7458   actorA.AddRenderer(rendererA);
7459
7460   Renderer rendererB = Renderer::New(geometry, shaderB);
7461   actorB.AddRenderer(rendererB);
7462
7463   Renderer rendererC = Renderer::New(geometry, shaderC);
7464   actorC.AddRenderer(rendererC);
7465
7466   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7467   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7468
7469   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7470   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7471
7472   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7473   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7474
7475   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
7476   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
7477
7478   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
7479   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
7480
7481   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
7482   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
7483
7484   Actor container = Actor::New();
7485   container.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7486   container.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
7487   stage.Add(container);
7488
7489   container.Add(actorA);
7490   container.Add(actorB);
7491   container.Add(actorC);
7492
7493   ResetTouchCallbacks();
7494
7495   // Connect ChildOrderChangedSignal
7496   bool                     orderChangedSignal(false);
7497   Actor                    orderChangedActor;
7498   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
7499   DevelActor::ChildOrderChangedSignal(container).Connect(&application, f);
7500
7501   // Set up gl abstraction trace so can query the set uniform order
7502   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
7503   glAbstraction.EnableSetUniformCallTrace(true);
7504   glAbstraction.ResetSetUniformCallStack();
7505   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
7506
7507   glAbstraction.ResetSetUniformCallStack();
7508
7509   application.SendNotification();
7510   application.Render();
7511
7512   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
7513
7514   // Test order of uniforms in stack
7515   int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
7516   int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
7517   int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
7518
7519   tet_infoline("Testing C above B and A at bottom\n");
7520   bool CBA = (indexC > indexB) && (indexB > indexA);
7521
7522   DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
7523
7524   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
7525   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
7526   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
7527
7528   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
7529   // Only top actor will get touched.
7530   actorA.TouchedSignal().Connect(TestTouchCallback);
7531   actorB.TouchedSignal().Connect(TestTouchCallback2);
7532   actorC.TouchedSignal().Connect(TestTouchCallback3);
7533
7534   Dali::Integration::Point point;
7535   point.SetDeviceId(1);
7536   point.SetState(PointState::DOWN);
7537   point.SetScreenPosition(Vector2(10.f, 10.f));
7538   Dali::Integration::TouchEvent touchEvent;
7539   touchEvent.AddPoint(point);
7540
7541   tet_infoline("UtcDaliActor Test Set up completed \n");
7542
7543   application.ProcessEvent(touchEvent);
7544
7545   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
7546   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
7547   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
7548
7549   ResetTouchCallbacks();
7550
7551   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");
7552
7553   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
7554   actorC[DevelActor::Property::SIBLING_ORDER] = 1;
7555   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
7556   DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
7557
7558   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
7559   application.SendNotification();
7560   application.Render();
7561
7562   application.ProcessEvent(touchEvent); // touch event
7563
7564   glSetUniformStack.Reset();
7565
7566   application.SendNotification();
7567   application.Render();
7568
7569   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
7570
7571   // Test order of uniforms in stack
7572   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
7573   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
7574   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
7575
7576   tet_infoline("Testing render order is A, C, B");
7577   DALI_TEST_EQUALS(indexC > indexA, true, TEST_LOCATION);
7578   DALI_TEST_EQUALS(indexB > indexC, true, TEST_LOCATION);
7579
7580   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
7581   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
7582   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
7583
7584   ResetTouchCallbacks();
7585
7586   tet_printf("Lower actor C below Actor A leaving B on top\n");
7587
7588   orderChangedSignal = false;
7589
7590   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
7591   actorC[DevelActor::Property::SIBLING_ORDER] = 0;
7592   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
7593   DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
7594
7595   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
7596   application.SendNotification();
7597   application.Render();
7598
7599   application.ProcessEvent(touchEvent);
7600
7601   glSetUniformStack.Reset();
7602
7603   application.Render();
7604   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
7605
7606   // Test order of uniforms in stack
7607   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
7608   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
7609   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
7610
7611   DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
7612   DALI_TEST_EQUALS(indexB > indexA, true, TEST_LOCATION);
7613
7614   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
7615   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
7616   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
7617
7618   ResetTouchCallbacks();
7619
7620   tet_printf("Lower actor B below Actor C leaving A on top\n");
7621
7622   orderChangedSignal = false;
7623
7624   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
7625   actorB[DevelActor::Property::SIBLING_ORDER] = 0;
7626   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
7627   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
7628
7629   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
7630   application.SendNotification();
7631   application.Render();
7632
7633   application.ProcessEvent(touchEvent);
7634
7635   glSetUniformStack.Reset();
7636
7637   application.Render();
7638   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
7639
7640   // Test order of uniforms in stack
7641   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
7642   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
7643   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
7644
7645   DALI_TEST_EQUALS(indexC > indexB, true, TEST_LOCATION);
7646   DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
7647
7648   END_TEST;
7649 }
7650
7651 int UtcDaliActorGeoTouchLowerBelow2(void)
7652 {
7653   tet_infoline("UtcDaliActor LowerBelow test using SIBLING_ORDER property\n");
7654
7655   TestApplication application;
7656
7657   Integration::Scene stage(application.GetScene());
7658
7659   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
7660   // enables checking of which actor the uniform is assigned too
7661   Shader shaderA = CreateShader();
7662   shaderA.RegisterProperty("uRendererColor", 1.f);
7663
7664   Shader shaderB = CreateShader();
7665   shaderB.RegisterProperty("uRendererColor", 2.f);
7666
7667   Shader shaderC = CreateShader();
7668   shaderC.RegisterProperty("uRendererColor", 3.f);
7669
7670   Actor actorA = Actor::New();
7671   Actor actorB = Actor::New();
7672   Actor actorC = Actor::New();
7673
7674   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
7675   Geometry geometry = CreateQuadGeometry();
7676
7677   Renderer rendererA = Renderer::New(geometry, shaderA);
7678   actorA.AddRenderer(rendererA);
7679
7680   Renderer rendererB = Renderer::New(geometry, shaderB);
7681   actorB.AddRenderer(rendererB);
7682
7683   Renderer rendererC = Renderer::New(geometry, shaderC);
7684   actorC.AddRenderer(rendererC);
7685
7686   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7687   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7688
7689   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7690   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7691
7692   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7693   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7694
7695   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
7696   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
7697
7698   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
7699   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
7700
7701   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
7702   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
7703
7704   Actor container = Actor::New();
7705   container.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7706   container.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
7707   stage.Add(container);
7708
7709   container.Add(actorA);
7710   container.Add(actorB);
7711   container.Add(actorC);
7712
7713   application.GetScene().SetGeometryHittestEnabled(true);
7714   ResetTouchCallbacks(application);
7715
7716   // Connect ChildOrderChangedSignal
7717   bool                     orderChangedSignal(false);
7718   Actor                    orderChangedActor;
7719   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
7720   DevelActor::ChildOrderChangedSignal(container).Connect(&application, f);
7721
7722   // Set up gl abstraction trace so can query the set uniform order
7723   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
7724   glAbstraction.EnableSetUniformCallTrace(true);
7725   glAbstraction.ResetSetUniformCallStack();
7726   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
7727
7728   glAbstraction.ResetSetUniformCallStack();
7729
7730   application.SendNotification();
7731   application.Render();
7732
7733   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
7734
7735   // Test order of uniforms in stack
7736   int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
7737   int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
7738   int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
7739
7740   tet_infoline("Testing C above B and A at bottom\n");
7741   bool CBA = (indexC > indexB) && (indexB > indexA);
7742
7743   DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
7744
7745   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
7746   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
7747   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
7748
7749   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
7750   // Only top actor will get touched.
7751   actorA.TouchedSignal().Connect(TestTouchCallback);
7752   actorB.TouchedSignal().Connect(TestTouchCallback2);
7753   actorC.TouchedSignal().Connect(TestTouchCallback3);
7754
7755   Dali::Integration::Point point;
7756   point.SetDeviceId(1);
7757   point.SetState(PointState::DOWN);
7758   point.SetScreenPosition(Vector2(10.f, 10.f));
7759   Dali::Integration::TouchEvent touchEvent;
7760   touchEvent.AddPoint(point);
7761
7762   tet_infoline("UtcDaliActor Test Set up completed \n");
7763
7764   application.ProcessEvent(touchEvent);
7765
7766   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
7767   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
7768   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
7769
7770   ResetTouchCallbacks(application);
7771
7772   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");
7773
7774   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
7775   actorC[DevelActor::Property::SIBLING_ORDER] = 1;
7776   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
7777   DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
7778
7779   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
7780   application.SendNotification();
7781   application.Render();
7782
7783   application.ProcessEvent(touchEvent); // touch event
7784
7785   glSetUniformStack.Reset();
7786
7787   application.SendNotification();
7788   application.Render();
7789
7790   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
7791
7792   // Test order of uniforms in stack
7793   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
7794   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
7795   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
7796
7797   tet_infoline("Testing render order is A, C, B");
7798   DALI_TEST_EQUALS(indexC > indexA, true, TEST_LOCATION);
7799   DALI_TEST_EQUALS(indexB > indexC, true, TEST_LOCATION);
7800
7801   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
7802   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
7803   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
7804
7805   ResetTouchCallbacks(application);
7806
7807   tet_printf("Lower actor C below Actor A leaving B on top\n");
7808
7809   orderChangedSignal = false;
7810
7811   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
7812   actorC[DevelActor::Property::SIBLING_ORDER] = 0;
7813   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
7814   DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
7815
7816   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
7817   application.SendNotification();
7818   application.Render();
7819
7820   application.ProcessEvent(touchEvent);
7821
7822   glSetUniformStack.Reset();
7823
7824   application.Render();
7825   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
7826
7827   // Test order of uniforms in stack
7828   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
7829   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
7830   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
7831
7832   DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
7833   DALI_TEST_EQUALS(indexB > indexA, true, TEST_LOCATION);
7834
7835   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
7836   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
7837   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
7838
7839   ResetTouchCallbacks(application);
7840
7841   tet_printf("Lower actor B below Actor C leaving A on top\n");
7842
7843   orderChangedSignal = false;
7844
7845   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
7846   actorB[DevelActor::Property::SIBLING_ORDER] = 0;
7847   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
7848   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
7849
7850   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
7851   application.SendNotification();
7852   application.Render();
7853
7854   application.ProcessEvent(touchEvent);
7855
7856   glSetUniformStack.Reset();
7857
7858   application.Render();
7859   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
7860
7861   // Test order of uniforms in stack
7862   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
7863   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
7864   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
7865
7866   DALI_TEST_EQUALS(indexC > indexB, true, TEST_LOCATION);
7867   DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
7868
7869   END_TEST;
7870 }
7871
7872 int UtcDaliActorRaiseAboveDifferentParentsN(void)
7873 {
7874   tet_infoline("UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n");
7875
7876   TestApplication application;
7877
7878   Integration::Scene stage(application.GetScene());
7879
7880   Actor parentA = Actor::New();
7881   Actor parentB = Actor::New();
7882   parentA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
7883   parentA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
7884   parentB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
7885   parentB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
7886
7887   parentA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7888   parentA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7889
7890   parentB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7891   parentB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7892
7893   stage.Add(parentA);
7894   stage.Add(parentB);
7895
7896   Actor actorA = Actor::New();
7897   Actor actorB = Actor::New();
7898   Actor actorC = Actor::New();
7899
7900   parentA.Add(actorA);
7901   parentA.Add(actorB);
7902
7903   tet_printf("Actor C added to different parent from A and B \n");
7904   parentB.Add(actorC);
7905
7906   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7907   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7908
7909   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7910   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7911
7912   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7913   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7914
7915   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
7916   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
7917
7918   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
7919   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
7920
7921   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
7922   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
7923
7924   ResetTouchCallbacks();
7925
7926   // Connect ChildOrderChangedSignal
7927   bool                     orderChangedSignal(false);
7928   Actor                    orderChangedActor;
7929   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
7930   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
7931
7932   application.SendNotification();
7933   application.Render();
7934
7935   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
7936   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
7937   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
7938
7939   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
7940   // Only top actor will get touched.
7941   actorA.TouchedSignal().Connect(TestTouchCallback);
7942   actorB.TouchedSignal().Connect(TestTouchCallback2);
7943   actorC.TouchedSignal().Connect(TestTouchCallback3);
7944
7945   Dali::Integration::Point point;
7946   point.SetDeviceId(1);
7947   point.SetState(PointState::DOWN);
7948   point.SetScreenPosition(Vector2(10.f, 10.f));
7949   Dali::Integration::TouchEvent touchEvent;
7950   touchEvent.AddPoint(point);
7951
7952   application.ProcessEvent(touchEvent);
7953
7954   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
7955   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
7956   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
7957
7958   ResetTouchCallbacks();
7959
7960   tet_printf("Raise actor A Above Actor C which have different parents\n");
7961
7962   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
7963   actorA.RaiseAbove(actorC);
7964   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
7965
7966   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
7967   application.SendNotification();
7968
7969   application.ProcessEvent(touchEvent); // touch event
7970
7971   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
7972   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
7973   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
7974
7975   ResetTouchCallbacks();
7976
7977   END_TEST;
7978 }
7979
7980 int UtcDaliActorGeoTouchRaiseAboveDifferentParentsN(void)
7981 {
7982   tet_infoline("UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n");
7983
7984   TestApplication application;
7985
7986   Integration::Scene stage(application.GetScene());
7987
7988   Actor parentA = Actor::New();
7989   Actor parentB = Actor::New();
7990   parentA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
7991   parentA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
7992   parentB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
7993   parentB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
7994
7995   parentA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7996   parentA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7997
7998   parentB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7999   parentB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
8000
8001   stage.Add(parentA);
8002   stage.Add(parentB);
8003
8004   Actor actorA = Actor::New();
8005   Actor actorB = Actor::New();
8006   Actor actorC = Actor::New();
8007
8008   parentA.Add(actorA);
8009   parentA.Add(actorB);
8010
8011   tet_printf("Actor C added to different parent from A and B \n");
8012   parentB.Add(actorC);
8013
8014   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
8015   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
8016
8017   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
8018   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
8019
8020   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
8021   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
8022
8023   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
8024   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
8025
8026   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
8027   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
8028
8029   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
8030   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
8031
8032   application.GetScene().SetGeometryHittestEnabled(true);
8033   ResetTouchCallbacks(application);
8034
8035   // Connect ChildOrderChangedSignal
8036   bool                     orderChangedSignal(false);
8037   Actor                    orderChangedActor;
8038   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
8039   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
8040
8041   application.SendNotification();
8042   application.Render();
8043
8044   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
8045   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8046   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
8047
8048   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
8049   // Only top actor will get touched.
8050   actorA.TouchedSignal().Connect(TestTouchCallback);
8051   actorB.TouchedSignal().Connect(TestTouchCallback2);
8052   actorC.TouchedSignal().Connect(TestTouchCallback3);
8053
8054   Dali::Integration::Point point;
8055   point.SetDeviceId(1);
8056   point.SetState(PointState::DOWN);
8057   point.SetScreenPosition(Vector2(10.f, 10.f));
8058   Dali::Integration::TouchEvent touchEvent;
8059   touchEvent.AddPoint(point);
8060
8061   application.ProcessEvent(touchEvent);
8062
8063   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
8064   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8065   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
8066
8067   ResetTouchCallbacks(application);
8068
8069   tet_printf("Raise actor A Above Actor C which have different parents\n");
8070
8071   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8072   actorA.RaiseAbove(actorC);
8073   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8074
8075   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
8076   application.SendNotification();
8077
8078   application.ProcessEvent(touchEvent); // touch event
8079
8080   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
8081   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8082   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
8083
8084   ResetTouchCallbacks(application);
8085
8086   END_TEST;
8087 }
8088
8089 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
8090 {
8091   tet_infoline("UtcDaliActor Test  raiseAbove and lowerBelow api when target Actor has no parent \n");
8092
8093   TestApplication application;
8094
8095   Integration::Scene stage(application.GetScene());
8096
8097   Actor actorA = Actor::New();
8098   Actor actorB = Actor::New();
8099   Actor actorC = Actor::New();
8100
8101   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
8102   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
8103
8104   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
8105   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
8106
8107   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
8108   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
8109
8110   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
8111   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
8112
8113   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
8114   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
8115
8116   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
8117   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
8118
8119   ResetTouchCallbacks();
8120
8121   // Connect ChildOrderChangedSignal
8122   bool                     orderChangedSignal(false);
8123   Actor                    orderChangedActor;
8124   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
8125   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
8126
8127   application.SendNotification();
8128   application.Render();
8129
8130   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
8131   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8132   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
8133
8134   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
8135   // Only top actor will get touched.
8136   actorA.TouchedSignal().Connect(TestTouchCallback);
8137   actorB.TouchedSignal().Connect(TestTouchCallback2);
8138   actorC.TouchedSignal().Connect(TestTouchCallback3);
8139
8140   Dali::Integration::Point point;
8141   point.SetDeviceId(1);
8142   point.SetState(PointState::DOWN);
8143   point.SetScreenPosition(Vector2(10.f, 10.f));
8144   Dali::Integration::TouchEvent touchEvent;
8145   touchEvent.AddPoint(point);
8146
8147   tet_printf("Raise actor A Above Actor C which have no parents\n");
8148
8149   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8150   actorA.RaiseAbove(actorC);
8151   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8152
8153   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
8154   application.SendNotification();
8155
8156   application.ProcessEvent(touchEvent);
8157
8158   tet_printf("Not parented so RaiseAbove should show no effect\n");
8159
8160   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
8161   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8162   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
8163
8164   ResetTouchCallbacks();
8165
8166   orderChangedSignal = false;
8167
8168   stage.Add(actorB);
8169   tet_printf("Lower actor A below Actor C when only A is not on stage \n");
8170
8171   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8172   actorA.LowerBelow(actorC);
8173   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8174
8175   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
8176   application.SendNotification();
8177   application.Render();
8178
8179   application.ProcessEvent(touchEvent);
8180
8181   tet_printf("Actor A not parented so LowerBelow should show no effect\n");
8182   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
8183   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
8184   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
8185
8186   ResetTouchCallbacks();
8187
8188   orderChangedSignal = false;
8189
8190   tet_printf("Adding Actor A to stage, will be on top\n");
8191
8192   stage.Add(actorA);
8193   application.SendNotification();
8194   application.Render();
8195
8196   tet_printf("Raise actor B Above Actor C when only B has a parent\n");
8197
8198   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8199   actorB.RaiseAbove(actorC);
8200   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8201
8202   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
8203   application.SendNotification();
8204
8205   application.ProcessEvent(touchEvent);
8206
8207   tet_printf("C not parented so RaiseAbove should show no effect\n");
8208   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
8209   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8210   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
8211
8212   ResetTouchCallbacks();
8213
8214   orderChangedSignal = false;
8215
8216   tet_printf("Lower actor A below Actor C when only A has a parent\n");
8217
8218   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8219   actorA.LowerBelow(actorC);
8220   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8221
8222   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
8223   application.SendNotification();
8224
8225   application.ProcessEvent(touchEvent);
8226
8227   tet_printf("C not parented so LowerBelow should show no effect\n");
8228   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
8229   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8230   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
8231
8232   ResetTouchCallbacks();
8233
8234   orderChangedSignal = false;
8235
8236   stage.Add(actorC);
8237
8238   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8239   actorA.RaiseAbove(actorC);
8240   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
8241   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
8242
8243   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
8244   application.SendNotification();
8245   application.Render();
8246
8247   application.ProcessEvent(touchEvent);
8248
8249   tet_printf("Raise actor A Above Actor C, now both have same parent \n");
8250   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
8251   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8252   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
8253
8254   END_TEST;
8255 }
8256
8257 int UtcDaliActorGeoTouchRaiseLowerWhenUnparentedTargetN(void)
8258 {
8259   tet_infoline("UtcDaliActor Test  raiseAbove and lowerBelow api when target Actor has no parent \n");
8260
8261   TestApplication application;
8262
8263   Integration::Scene stage(application.GetScene());
8264
8265   Actor actorA = Actor::New();
8266   Actor actorB = Actor::New();
8267   Actor actorC = Actor::New();
8268
8269   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
8270   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
8271
8272   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
8273   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
8274
8275   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
8276   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
8277
8278   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
8279   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
8280
8281   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
8282   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
8283
8284   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
8285   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
8286
8287   application.GetScene().SetGeometryHittestEnabled(true);
8288   ResetTouchCallbacks(application);
8289
8290   // Connect ChildOrderChangedSignal
8291   bool                     orderChangedSignal(false);
8292   Actor                    orderChangedActor;
8293   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
8294   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
8295
8296   application.SendNotification();
8297   application.Render();
8298
8299   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
8300   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8301   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
8302
8303   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
8304   // Only top actor will get touched.
8305   actorA.TouchedSignal().Connect(TestTouchCallback);
8306   actorB.TouchedSignal().Connect(TestTouchCallback2);
8307   actorC.TouchedSignal().Connect(TestTouchCallback3);
8308
8309   Dali::Integration::Point point;
8310   point.SetDeviceId(1);
8311   point.SetState(PointState::DOWN);
8312   point.SetScreenPosition(Vector2(10.f, 10.f));
8313   Dali::Integration::TouchEvent touchEvent;
8314   touchEvent.AddPoint(point);
8315
8316   tet_printf("Raise actor A Above Actor C which have no parents\n");
8317
8318   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8319   actorA.RaiseAbove(actorC);
8320   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8321
8322   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
8323   application.SendNotification();
8324
8325   application.ProcessEvent(touchEvent);
8326
8327   tet_printf("Not parented so RaiseAbove should show no effect\n");
8328
8329   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
8330   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8331   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
8332
8333   ResetTouchCallbacks(application);
8334
8335   orderChangedSignal = false;
8336
8337   stage.Add(actorB);
8338   tet_printf("Lower actor A below Actor C when only A is not on stage \n");
8339
8340   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8341   actorA.LowerBelow(actorC);
8342   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8343
8344   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
8345   application.SendNotification();
8346   application.Render();
8347
8348   application.ProcessEvent(touchEvent);
8349
8350   tet_printf("Actor A not parented so LowerBelow should show no effect\n");
8351   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
8352   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
8353   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
8354
8355   ResetTouchCallbacks(application);
8356
8357   orderChangedSignal = false;
8358
8359   tet_printf("Adding Actor A to stage, will be on top\n");
8360
8361   stage.Add(actorA);
8362   application.SendNotification();
8363   application.Render();
8364
8365   tet_printf("Raise actor B Above Actor C when only B has a parent\n");
8366
8367   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8368   actorB.RaiseAbove(actorC);
8369   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8370
8371   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
8372   application.SendNotification();
8373
8374   application.ProcessEvent(touchEvent);
8375
8376   tet_printf("C not parented so RaiseAbove should show no effect\n");
8377   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
8378   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8379   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
8380
8381   ResetTouchCallbacks(application);
8382
8383   orderChangedSignal = false;
8384
8385   tet_printf("Lower actor A below Actor C when only A has a parent\n");
8386
8387   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8388   actorA.LowerBelow(actorC);
8389   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8390
8391   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
8392   application.SendNotification();
8393
8394   application.ProcessEvent(touchEvent);
8395
8396   tet_printf("C not parented so LowerBelow should show no effect\n");
8397   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
8398   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8399   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
8400
8401   ResetTouchCallbacks(application);
8402
8403   orderChangedSignal = false;
8404
8405   stage.Add(actorC);
8406
8407   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8408   actorA.RaiseAbove(actorC);
8409   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
8410   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
8411
8412   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
8413   application.SendNotification();
8414   application.Render();
8415
8416   application.ProcessEvent(touchEvent);
8417
8418   tet_printf("Raise actor A Above Actor C, now both have same parent \n");
8419   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
8420   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8421   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
8422
8423   END_TEST;
8424 }
8425
8426 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
8427 {
8428   tet_infoline("UtcDaliActor Test all raise/lower api when actor has no parent \n");
8429
8430   TestApplication application;
8431
8432   Integration::Scene stage(application.GetScene());
8433
8434   Actor actorA = Actor::New();
8435   Actor actorB = Actor::New();
8436   Actor actorC = Actor::New();
8437
8438   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
8439   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
8440
8441   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
8442   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
8443
8444   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
8445   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
8446
8447   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
8448   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
8449
8450   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
8451   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
8452
8453   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
8454   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
8455
8456   ResetTouchCallbacks();
8457
8458   // Connect ChildOrderChangedSignal
8459   bool                     orderChangedSignal(false);
8460   Actor                    orderChangedActor;
8461   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
8462   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
8463
8464   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
8465   // Only top actor will get touched.
8466   actorA.TouchedSignal().Connect(TestTouchCallback);
8467   actorB.TouchedSignal().Connect(TestTouchCallback2);
8468   actorC.TouchedSignal().Connect(TestTouchCallback3);
8469
8470   Dali::Integration::Point point;
8471   point.SetDeviceId(1);
8472   point.SetState(PointState::DOWN);
8473   point.SetScreenPosition(Vector2(10.f, 10.f));
8474   Dali::Integration::TouchEvent touchEvent;
8475   touchEvent.AddPoint(point);
8476
8477   stage.Add(actorA);
8478   tet_printf("Raise actor B Above Actor C but B not parented\n");
8479
8480   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8481   actorB.Raise();
8482   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8483
8484   application.SendNotification();
8485   application.Render();
8486
8487   application.ProcessEvent(touchEvent);
8488
8489   tet_printf("Not parented so RaiseAbove should show no effect\n");
8490
8491   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
8492   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8493   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
8494
8495   tet_printf("Raise actor B Above Actor C but B not parented\n");
8496   ResetTouchCallbacks();
8497
8498   orderChangedSignal = false;
8499
8500   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8501   actorC.Lower();
8502   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8503
8504   // Sort actor tree before next touch event
8505   application.SendNotification();
8506   application.Render();
8507
8508   application.ProcessEvent(touchEvent);
8509
8510   tet_printf("Not parented so RaiseAbove should show no effect\n");
8511
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   ResetTouchCallbacks();
8516
8517   orderChangedSignal = false;
8518
8519   tet_printf("Lower actor C below B but C not parented\n");
8520
8521   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8522   actorB.Lower();
8523   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8524
8525   // Sort actor tree before next touch event
8526   application.SendNotification();
8527   application.Render();
8528
8529   application.ProcessEvent(touchEvent);
8530
8531   tet_printf("Not parented so Lower should show no effect\n");
8532
8533   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
8534   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8535   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
8536   ResetTouchCallbacks();
8537
8538   orderChangedSignal = false;
8539
8540   tet_printf("Raise actor B to top\n");
8541
8542   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8543   actorB.RaiseToTop();
8544   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8545
8546   // Sort actor tree before next touch event
8547   application.SendNotification();
8548   application.Render();
8549
8550   application.ProcessEvent(touchEvent);
8551
8552   tet_printf("Not parented so RaiseToTop should show no effect\n");
8553
8554   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
8555   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8556   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
8557   ResetTouchCallbacks();
8558
8559   orderChangedSignal = false;
8560
8561   tet_printf("Add ActorB to stage so only Actor C not parented\n");
8562
8563   stage.Add(actorB);
8564
8565   tet_printf("Lower actor C to Bottom, B stays at top\n");
8566
8567   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8568   actorC.LowerToBottom();
8569   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8570
8571   application.SendNotification();
8572   application.Render();
8573
8574   application.ProcessEvent(touchEvent);
8575
8576   tet_printf("Not parented so LowerToBottom should show no effect\n");
8577
8578   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
8579   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
8580   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
8581   ResetTouchCallbacks();
8582
8583   END_TEST;
8584 }
8585
8586 int UtcDaliActorGeoTouchTestAllAPIwhenActorNotParented(void)
8587 {
8588   tet_infoline("UtcDaliActor Test all raise/lower api when actor has no parent \n");
8589
8590   TestApplication application;
8591
8592   Integration::Scene stage(application.GetScene());
8593
8594   Actor actorA = Actor::New();
8595   Actor actorB = Actor::New();
8596   Actor actorC = Actor::New();
8597
8598   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
8599   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
8600
8601   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
8602   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
8603
8604   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
8605   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
8606
8607   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
8608   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
8609
8610   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
8611   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
8612
8613   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
8614   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
8615
8616   application.GetScene().SetGeometryHittestEnabled(true);
8617   ResetTouchCallbacks(application);
8618
8619   // Connect ChildOrderChangedSignal
8620   bool                     orderChangedSignal(false);
8621   Actor                    orderChangedActor;
8622   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
8623   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
8624
8625   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
8626   // Only top actor will get touched.
8627   actorA.TouchedSignal().Connect(TestTouchCallback);
8628   actorB.TouchedSignal().Connect(TestTouchCallback2);
8629   actorC.TouchedSignal().Connect(TestTouchCallback3);
8630
8631   Dali::Integration::Point point;
8632   point.SetDeviceId(1);
8633   point.SetState(PointState::DOWN);
8634   point.SetScreenPosition(Vector2(10.f, 10.f));
8635   Dali::Integration::TouchEvent touchEvent;
8636   touchEvent.AddPoint(point);
8637
8638   stage.Add(actorA);
8639   tet_printf("Raise actor B Above Actor C but B not parented\n");
8640
8641   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8642   actorB.Raise();
8643   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8644
8645   application.SendNotification();
8646   application.Render();
8647
8648   application.ProcessEvent(touchEvent);
8649
8650   tet_printf("Not parented so RaiseAbove should show no effect\n");
8651
8652   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
8653   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8654   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
8655
8656   tet_printf("Raise actor B Above Actor C but B not parented\n");
8657   ResetTouchCallbacks(application);
8658
8659   orderChangedSignal = false;
8660
8661   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8662   actorC.Lower();
8663   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8664
8665   // Sort actor tree before next touch event
8666   application.SendNotification();
8667   application.Render();
8668
8669   application.ProcessEvent(touchEvent);
8670
8671   tet_printf("Not parented so RaiseAbove should show no effect\n");
8672
8673   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
8674   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8675   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
8676   ResetTouchCallbacks(application);
8677
8678   orderChangedSignal = false;
8679
8680   tet_printf("Lower actor C below B but C not parented\n");
8681
8682   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8683   actorB.Lower();
8684   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8685
8686   // Sort actor tree before next touch event
8687   application.SendNotification();
8688   application.Render();
8689
8690   application.ProcessEvent(touchEvent);
8691
8692   tet_printf("Not parented so Lower should show no effect\n");
8693
8694   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
8695   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8696   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
8697   ResetTouchCallbacks(application);
8698
8699   orderChangedSignal = false;
8700
8701   tet_printf("Raise actor B to top\n");
8702
8703   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8704   actorB.RaiseToTop();
8705   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8706
8707   // Sort actor tree before next touch event
8708   application.SendNotification();
8709   application.Render();
8710
8711   application.ProcessEvent(touchEvent);
8712
8713   tet_printf("Not parented so RaiseToTop should show no effect\n");
8714
8715   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
8716   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8717   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
8718   ResetTouchCallbacks(application);
8719
8720   orderChangedSignal = false;
8721
8722   tet_printf("Add ActorB to stage so only Actor C not parented\n");
8723
8724   stage.Add(actorB);
8725
8726   tet_printf("Lower actor C to Bottom, B stays at top\n");
8727
8728   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8729   actorC.LowerToBottom();
8730   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8731
8732   application.SendNotification();
8733   application.Render();
8734
8735   application.ProcessEvent(touchEvent);
8736
8737   tet_printf("Not parented so LowerToBottom should show no effect\n");
8738
8739   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
8740   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
8741   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
8742   ResetTouchCallbacks(application);
8743
8744   END_TEST;
8745 }
8746
8747 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
8748 {
8749   tet_infoline("UtcDaliActor RaiseToAbove and  test with actor provided as target resulting in a no operation \n");
8750
8751   TestApplication application;
8752
8753   Integration::Scene stage(application.GetScene());
8754
8755   Actor actorA = Actor::New();
8756   Actor actorB = Actor::New();
8757   Actor actorC = Actor::New();
8758
8759   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
8760   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
8761
8762   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
8763   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
8764
8765   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
8766   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
8767
8768   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
8769   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
8770
8771   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
8772   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
8773
8774   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
8775   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
8776
8777   stage.Add(actorA);
8778   stage.Add(actorB);
8779   stage.Add(actorC);
8780
8781   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
8782   // Only top actor will get touched.
8783   actorA.TouchedSignal().Connect(TestTouchCallback);
8784   actorB.TouchedSignal().Connect(TestTouchCallback2);
8785   actorC.TouchedSignal().Connect(TestTouchCallback3);
8786
8787   ResetTouchCallbacks();
8788
8789   // Connect ChildOrderChangedSignal
8790   bool                     orderChangedSignal(false);
8791   Actor                    orderChangedActor;
8792   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
8793   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
8794
8795   application.SendNotification();
8796   application.Render();
8797
8798   Dali::Integration::Point point;
8799   point.SetDeviceId(1);
8800   point.SetState(PointState::DOWN);
8801   point.SetScreenPosition(Vector2(10.f, 10.f));
8802   Dali::Integration::TouchEvent touchEvent;
8803   touchEvent.AddPoint(point);
8804
8805   application.ProcessEvent(touchEvent);
8806
8807   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
8808   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8809   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
8810
8811   ResetTouchCallbacks();
8812
8813   tet_infoline("Raise actor A Above Actor A which is the same actor!!\n");
8814
8815   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8816   actorA.RaiseAbove(actorA);
8817   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
8818   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
8819
8820   application.SendNotification();
8821   application.Render();
8822
8823   application.ProcessEvent(touchEvent);
8824
8825   tet_infoline("No target is source Actor so RaiseAbove should show no effect\n");
8826
8827   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
8828   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8829   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
8830
8831   ResetTouchCallbacks();
8832
8833   orderChangedSignal = false;
8834
8835   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8836   actorA.RaiseAbove(actorC);
8837   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
8838   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
8839
8840   application.SendNotification();
8841   application.Render();
8842
8843   application.ProcessEvent(touchEvent);
8844
8845   tet_infoline("Raise actor A Above Actor C which will now be successful \n");
8846   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
8847   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8848   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
8849
8850   END_TEST;
8851 }
8852
8853 int UtcDaliActorGeoTouchRaiseAboveActorAndTargetTheSameN(void)
8854 {
8855   tet_infoline("UtcDaliActor RaiseToAbove and  test with actor provided as target resulting in a no operation \n");
8856
8857   TestApplication application;
8858
8859   Integration::Scene stage(application.GetScene());
8860
8861   Actor actorA = Actor::New();
8862   Actor actorB = Actor::New();
8863   Actor actorC = Actor::New();
8864
8865   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
8866   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
8867
8868   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
8869   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
8870
8871   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
8872   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
8873
8874   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
8875   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
8876
8877   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
8878   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
8879
8880   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
8881   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
8882
8883   stage.Add(actorA);
8884   stage.Add(actorB);
8885   stage.Add(actorC);
8886
8887   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
8888   // Only top actor will get touched.
8889   actorA.TouchedSignal().Connect(TestTouchCallback);
8890   actorB.TouchedSignal().Connect(TestTouchCallback2);
8891   actorC.TouchedSignal().Connect(TestTouchCallback3);
8892
8893   application.GetScene().SetGeometryHittestEnabled(true);
8894   ResetTouchCallbacks(application);
8895
8896   // Connect ChildOrderChangedSignal
8897   bool                     orderChangedSignal(false);
8898   Actor                    orderChangedActor;
8899   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
8900   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
8901
8902   application.SendNotification();
8903   application.Render();
8904
8905   Dali::Integration::Point point;
8906   point.SetDeviceId(1);
8907   point.SetState(PointState::DOWN);
8908   point.SetScreenPosition(Vector2(10.f, 10.f));
8909   Dali::Integration::TouchEvent touchEvent;
8910   touchEvent.AddPoint(point);
8911
8912   application.ProcessEvent(touchEvent);
8913
8914   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
8915   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8916   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
8917
8918   ResetTouchCallbacks(application);
8919
8920   tet_infoline("Raise actor A Above Actor A which is the same actor!!\n");
8921
8922   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8923   actorA.RaiseAbove(actorA);
8924   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
8925   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
8926
8927   application.SendNotification();
8928   application.Render();
8929
8930   application.ProcessEvent(touchEvent);
8931
8932   tet_infoline("No target is source Actor so RaiseAbove should show no effect\n");
8933
8934   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
8935   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8936   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
8937
8938   ResetTouchCallbacks(application);
8939
8940   orderChangedSignal = false;
8941
8942   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
8943   actorA.RaiseAbove(actorC);
8944   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
8945   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
8946
8947   application.SendNotification();
8948   application.Render();
8949
8950   application.ProcessEvent(touchEvent);
8951
8952   tet_infoline("Raise actor A Above Actor C which will now be successful \n");
8953   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
8954   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
8955   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
8956
8957   END_TEST;
8958 }
8959
8960 int UtcDaliActorGetScreenPosition(void)
8961 {
8962   tet_infoline("UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n");
8963
8964   TestApplication application;
8965
8966   Integration::Scene stage(application.GetScene());
8967
8968   Actor actorA = Actor::New();
8969   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
8970
8971   Vector2 size2(10.0f, 20.0f);
8972   actorA.SetProperty(Actor::Property::SIZE, size2);
8973
8974   actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
8975
8976   tet_infoline("UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n");
8977
8978   stage.Add(actorA);
8979
8980   application.SendNotification();
8981   application.Render();
8982
8983   Vector3 actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
8984   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
8985
8986   tet_printf("Actor World Position ( %f %f ) AnchorPoint::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
8987   tet_printf("Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y);
8988
8989   DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
8990   DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
8991
8992   tet_infoline("UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n");
8993
8994   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8995
8996   application.SendNotification();
8997   application.Render();
8998
8999   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
9000   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
9001
9002   tet_printf("Actor World Position  ( %f %f ) AnchorPoint::TOP_LEFT  \n", actorWorldPosition.x, actorWorldPosition.y);
9003   tet_printf("Actor Screen Position  ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y);
9004
9005   DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
9006   DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
9007
9008   tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n");
9009
9010   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
9011
9012   application.SendNotification();
9013   application.Render();
9014
9015   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
9016   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
9017
9018   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT   \n", actorWorldPosition.x, actorWorldPosition.y);
9019   tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT  \n", actorScreenPosition.x, actorScreenPosition.y);
9020
9021   DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
9022   DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
9023
9024   tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n");
9025
9026   actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 0.0));
9027
9028   application.SendNotification();
9029   application.Render();
9030
9031   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
9032   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
9033
9034   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorWorldPosition.x, actorWorldPosition.y);
9035   tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0   \n", actorScreenPosition.x, actorScreenPosition.y);
9036
9037   DALI_TEST_EQUALS(actorScreenPosition.x, 30lu, TEST_LOCATION);
9038   DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
9039
9040   tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n");
9041
9042   actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 420.0));
9043
9044   application.SendNotification();
9045   application.Render();
9046
9047   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
9048   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
9049
9050   DALI_TEST_EQUALS(actorScreenPosition.x, 30lu, TEST_LOCATION);
9051   DALI_TEST_EQUALS(actorScreenPosition.y, 420lu, TEST_LOCATION);
9052
9053   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n", actorWorldPosition.x, actorWorldPosition.y);
9054   tet_printf("Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y);
9055
9056   tet_infoline("UtcDaliActorGetScreenPosition Scale parent and check child's screen position \n");
9057
9058   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9059   actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 30.0));
9060
9061   Actor actorB = Actor::New();
9062   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9063   actorB.SetProperty(Actor::Property::SIZE, size2);
9064   actorB.SetProperty(Actor::Property::POSITION, Vector2(10.f, 10.f));
9065   actorA.Add(actorB);
9066
9067   actorA.SetProperty(Actor::Property::SCALE, 2.0f);
9068
9069   application.SendNotification();
9070   application.Render();
9071
9072   actorScreenPosition = actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
9073
9074   DALI_TEST_EQUALS(actorScreenPosition.x, 50lu, TEST_LOCATION);
9075   DALI_TEST_EQUALS(actorScreenPosition.y, 50lu, TEST_LOCATION);
9076
9077   END_TEST;
9078 }
9079
9080 int UtcDaliActorGetScreenPositionAfterScaling(void)
9081 {
9082   tet_infoline("UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n");
9083
9084   TestApplication application;
9085
9086   Integration::Scene stage(application.GetScene());
9087
9088   Actor actorA = Actor::New();
9089   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9090
9091   Vector2 size2(10.0f, 20.0f);
9092   actorA.SetProperty(Actor::Property::SIZE, size2);
9093   actorA.SetProperty(Actor::Property::SCALE, 1.5f);
9094   actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
9095
9096   tet_infoline("UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n");
9097
9098   stage.Add(actorA);
9099
9100   application.SendNotification();
9101   application.Render();
9102
9103   Vector3 actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
9104   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
9105
9106   tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y);
9107   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
9108
9109   DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
9110   DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
9111
9112   tet_infoline("UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n");
9113
9114   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
9115
9116   application.SendNotification();
9117   application.Render();
9118
9119   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
9120   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
9121
9122   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
9123   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
9124
9125   DALI_TEST_EQUALS(actorScreenPosition.x, 0.0f, TEST_LOCATION);
9126   DALI_TEST_EQUALS(actorScreenPosition.y, 0.0f, TEST_LOCATION);
9127
9128   END_TEST;
9129 }
9130
9131 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
9132 {
9133   tet_infoline("UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n");
9134
9135   TestApplication application;
9136
9137   Integration::Scene stage(application.GetScene());
9138
9139   Actor actorA = Actor::New();
9140   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9141   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
9142   Vector2 size2(10.0f, 20.0f);
9143   actorA.SetProperty(Actor::Property::SIZE, size2);
9144   actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
9145
9146   tet_infoline(" TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
9147
9148   stage.Add(actorA);
9149
9150   application.SendNotification();
9151   application.Render();
9152
9153   Vector3 actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
9154   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
9155
9156   tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n", actorWorldPosition.x, actorWorldPosition.y);
9157   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
9158
9159   DALI_TEST_EQUALS(actorScreenPosition.x, 240.0f, TEST_LOCATION);
9160   DALI_TEST_EQUALS(actorScreenPosition.y, 400.0f, TEST_LOCATION);
9161
9162   tet_infoline(" BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n");
9163
9164   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
9165   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
9166
9167   application.SendNotification();
9168   application.Render();
9169
9170   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
9171   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
9172
9173   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
9174   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
9175
9176   DALI_TEST_EQUALS(actorScreenPosition.x, 480.0f, TEST_LOCATION);
9177   DALI_TEST_EQUALS(actorScreenPosition.y, 0.0f, TEST_LOCATION);
9178
9179   END_TEST;
9180   END_TEST;
9181 }
9182
9183 int UtcDaliActorGetScreenPositionWithChildActors(void)
9184 {
9185   tet_infoline("UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n");
9186
9187   TestApplication application;
9188
9189   Integration::Scene stage(application.GetScene());
9190
9191   tet_infoline("Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
9192
9193   Actor actorA = Actor::New();
9194   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9195   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
9196   Vector2 size1(10.0f, 20.0f);
9197   actorA.SetProperty(Actor::Property::SIZE, size1);
9198   actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
9199
9200   tet_infoline("Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
9201
9202   Actor parentActorA = Actor::New();
9203   parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9204   parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
9205   Vector2 size2(30.0f, 60.0f);
9206   parentActorA.SetProperty(Actor::Property::SIZE, size2);
9207   parentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
9208
9209   tet_infoline("Add child 1 to Parent 1 and check screen position \n");
9210
9211   stage.Add(parentActorA);
9212   parentActorA.Add(actorA);
9213
9214   application.SendNotification();
9215   application.Render();
9216
9217   Vector3 actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
9218   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
9219
9220   tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n", actorWorldPosition.x, actorWorldPosition.y);
9221   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
9222
9223   DALI_TEST_EQUALS(actorScreenPosition.x, 255.0f, TEST_LOCATION);
9224   DALI_TEST_EQUALS(actorScreenPosition.y, 430.0f, TEST_LOCATION);
9225
9226   tet_infoline("Test 2\n");
9227
9228   tet_infoline("change parent anchor point and parent origin then check screen position \n");
9229
9230   parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
9231   parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
9232
9233   application.SendNotification();
9234   application.Render();
9235
9236   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
9237   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
9238
9239   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT  \n", actorWorldPosition.x, actorWorldPosition.y);
9240   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
9241
9242   DALI_TEST_EQUALS(actorScreenPosition.x, 15.0f, TEST_LOCATION);
9243   DALI_TEST_EQUALS(actorScreenPosition.y, -30.0f, TEST_LOCATION);
9244
9245   END_TEST;
9246 }
9247
9248 int UtcDaliActorGetScreenPositionWithChildActors02(void)
9249 {
9250   tet_infoline("UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n");
9251
9252   TestApplication application;
9253
9254   Integration::Scene stage(application.GetScene());
9255
9256   tet_infoline("Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
9257
9258   Actor actorA = Actor::New();
9259   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9260   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
9261   Vector2 size1(10.0f, 20.0f);
9262   actorA.SetProperty(Actor::Property::SIZE, size1);
9263   actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
9264
9265   tet_infoline("Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
9266
9267   Actor parentActorA = Actor::New();
9268   parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9269   parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
9270   Vector2 size2(30.0f, 60.0f);
9271   parentActorA.SetProperty(Actor::Property::SIZE, size2);
9272   parentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
9273
9274   tet_infoline("Create Grand Parent Actor 1 BOTTOM_LEFT Anchor Point, ParentOrigin::BOTTOM_LEFT and 0,0 position \n");
9275
9276   Actor grandParentActorA = Actor::New();
9277   grandParentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
9278   grandParentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
9279   Vector2 size3(60.0f, 120.0f);
9280   grandParentActorA.SetProperty(Actor::Property::SIZE, size3);
9281   grandParentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
9282
9283   tet_infoline("Add Parent 1 to Grand Parent 1 \n");
9284
9285   stage.Add(grandParentActorA);
9286   grandParentActorA.Add(parentActorA);
9287
9288   tet_infoline("Add child 1 to Parent 1 and check screen position \n");
9289
9290   parentActorA.Add(actorA);
9291
9292   application.SendNotification();
9293   application.Render();
9294
9295   Vector3 actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
9296   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
9297
9298   tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n", actorWorldPosition.x, actorWorldPosition.y);
9299   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
9300
9301   DALI_TEST_EQUALS(actorScreenPosition.x, 45.0f, TEST_LOCATION);
9302   DALI_TEST_EQUALS(actorScreenPosition.y, 770.0f, TEST_LOCATION);
9303
9304   END_TEST;
9305 }
9306
9307 int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void)
9308 {
9309   tet_infoline("UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse Check screen position where the position does not use the anchor point");
9310
9311   TestApplication application;
9312
9313   Integration::Scene stage(application.GetScene());
9314
9315   tet_infoline("Create an actor with AnchorPoint::TOP_LEFT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
9316
9317   Actor actorA = Actor::New();
9318   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9319   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
9320   actorA.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
9321   actorA.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 20.0f));
9322   stage.Add(actorA);
9323
9324   tet_infoline("Create an Actor with AnchorPoint::BOTTOM_RIGHT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
9325
9326   Actor actorB = Actor::New();
9327   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
9328   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
9329   actorB.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
9330   Vector2 actorBSize(30.0f, 60.0f);
9331   actorB.SetProperty(Actor::Property::SIZE, actorBSize);
9332   stage.Add(actorB);
9333
9334   tet_infoline("Create an actor with AnchorPoint::CENTER, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
9335
9336   Actor actorC = Actor::New();
9337   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
9338   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
9339   actorC.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
9340   Vector2 actorCSize(60.0f, 120.0f);
9341   actorC.SetProperty(Actor::Property::SIZE, actorCSize);
9342   stage.Add(actorC);
9343
9344   application.SendNotification();
9345   application.Render();
9346
9347   tet_infoline("Despite differing sizes and anchor-points, the screen position for all actors is the same");
9348
9349   Vector2 center(stage.GetSize() * 0.5f);
9350
9351   DALI_TEST_EQUALS(actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
9352   DALI_TEST_EQUALS(actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
9353   DALI_TEST_EQUALS(actorC.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
9354
9355   tet_infoline("Add scale to all actors");
9356
9357   actorA.SetProperty(Actor::Property::SCALE, 2.0f);
9358   actorB.SetProperty(Actor::Property::SCALE, 2.0f);
9359   actorC.SetProperty(Actor::Property::SCALE, 2.0f);
9360
9361   application.SendNotification();
9362   application.Render();
9363
9364   DALI_TEST_EQUALS(actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center /* TOP_LEFT Anchor */, TEST_LOCATION);
9365   DALI_TEST_EQUALS(actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center - actorBSize /* BOTTOM_RIGHT Anchor */, TEST_LOCATION);
9366   DALI_TEST_EQUALS(actorC.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center - actorCSize * 0.5f /* CENTER Anchor*/, TEST_LOCATION);
9367
9368   END_TEST;
9369 }
9370
9371 int UtcDaliActorGetScreenPositionResizeScene(void)
9372 {
9373   tet_infoline("UtcDaliActorGetScreenPositionResizeScene Check screen position after resizing the scene size");
9374
9375   TestApplication    application;
9376   Integration::Scene scene = application.GetScene();
9377
9378   Actor actorA = Actor::New();
9379   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
9380   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
9381   actorA.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
9382
9383   scene.Add(actorA);
9384
9385   application.SendNotification();
9386   application.Render();
9387
9388   Vector2 sceneSize           = scene.GetSize();
9389   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
9390
9391   DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2, TEST_LOCATION);
9392
9393   // Resize the scene
9394   Vector2 newSize(1000.0f, 2000.0f);
9395   DALI_TEST_CHECK(scene.GetSize() != newSize);
9396
9397   scene.SurfaceResized(newSize.width, newSize.height);
9398
9399   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
9400
9401   // The screen position should not be updated yet
9402   DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2, TEST_LOCATION);
9403
9404   application.SendNotification();
9405   application.Render();
9406
9407   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
9408
9409   // The screen position should be updated
9410   sceneSize = scene.GetSize();
9411   DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2, TEST_LOCATION);
9412
9413   END_TEST;
9414 }
9415
9416 int UtcDaliActorGetScreenPositionInCustomCameraAndLayer3D(void)
9417 {
9418   tet_infoline("UtcDaliActorGetScreenPositionInCustomCameraAndLayer3D Check screen position under LAYER_3D and custom camera");
9419
9420   TestApplication    application;
9421   Integration::Scene scene = application.GetScene();
9422
9423   // Make 3D Layer
9424   Layer layer = scene.GetRootLayer();
9425   layer.SetProperty(Layer::Property::BEHAVIOR, Layer::Behavior::LAYER_3D);
9426
9427   // Build custom camera with top-view
9428   CameraActor cameraActor = scene.GetRenderTaskList().GetTask(0).GetCameraActor();
9429   {
9430     // Default camera position at +z and looking -z axis. (orientation is [ Axis: [0, 1, 0], Angle: 180 degrees ])
9431     Vector3    cameraPos    = cameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
9432     Quaternion cameraOrient = cameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
9433
9434     {
9435       std::ostringstream oss;
9436       oss << cameraPos << "\n";
9437       oss << cameraOrient << "\n";
9438       tet_printf("%s\n", oss.str().c_str());
9439     }
9440
9441     cameraActor.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -cameraPos.z, 0.0f));
9442     cameraActor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::XAXIS) * cameraOrient);
9443
9444     // Now, upside : -Z, leftside : -X, foward : +Y
9445
9446     cameraPos    = cameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
9447     cameraOrient = cameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
9448     {
9449       std::ostringstream oss;
9450       oss << cameraPos << "\n";
9451       oss << cameraOrient << "\n";
9452       tet_printf("%s\n", oss.str().c_str());
9453     }
9454   }
9455
9456   Actor actorA = Actor::New();
9457   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
9458   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
9459   actorA.SetProperty(Actor::Property::SIZE, Vector3(10.0f, 10.0f, 10.0f));
9460   actorA.SetProperty(Actor::Property::POSITION, Vector3(20.0f, 0.0f, 10.0f));
9461
9462   Actor actorB = Actor::New();
9463   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
9464   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
9465   actorB.SetProperty(Actor::Property::SIZE, Vector3(10.0f, 10.0f, 10.0f));
9466   actorB.SetProperty(Actor::Property::POSITION, Vector3(-20.0f, 0.0f, -10.0f));
9467
9468   scene.Add(actorA);
9469   scene.Add(actorB);
9470
9471   application.SendNotification();
9472   application.Render();
9473
9474   Vector2 sceneSize           = scene.GetSize();
9475   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
9476
9477   DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2 + Vector2(20.0f, 10.0f), TEST_LOCATION);
9478
9479   actorScreenPosition = actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
9480
9481   DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2 - Vector2(20.0f, 10.0f), TEST_LOCATION);
9482
9483   END_TEST;
9484 }
9485
9486 int utcDaliActorPositionUsesAnchorPoint(void)
9487 {
9488   TestApplication application;
9489   tet_infoline("Check default behaviour\n");
9490
9491   Actor actor = Actor::New();
9492   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
9493   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
9494   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
9495   application.GetScene().Add(actor);
9496
9497   application.SendNotification();
9498   application.Render();
9499
9500   tet_infoline("Check that the world position is in the center\n");
9501   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
9502
9503   tet_infoline("Set the position uses anchor point property to false\n");
9504   actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
9505
9506   application.SendNotification();
9507   application.Render();
9508
9509   tet_infoline("Check that the world position has changed appropriately\n");
9510   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
9511
9512   END_TEST;
9513 }
9514
9515 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
9516 {
9517   TestApplication application;
9518   tet_infoline("Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
9519
9520   Actor actor = Actor::New();
9521   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
9522   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
9523   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
9524   actor.SetProperty(Actor::Property::SCALE, 2.0f);
9525   actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
9526   application.GetScene().Add(actor);
9527
9528   application.SendNotification();
9529   application.Render();
9530
9531   tet_infoline("Check the world position is the same as it would be without a scale\n");
9532   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
9533
9534   tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
9535   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9536   application.SendNotification();
9537   application.Render();
9538   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(100.0f, 100.0f, 0.0f), TEST_LOCATION);
9539
9540   tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
9541   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
9542   application.SendNotification();
9543   application.Render();
9544   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
9545
9546   END_TEST;
9547 }
9548
9549 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
9550 {
9551   TestApplication application;
9552   tet_infoline("Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
9553
9554   Actor actor = Actor::New();
9555   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
9556   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
9557   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
9558   actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::ZAXIS));
9559   actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
9560   application.GetScene().Add(actor);
9561
9562   application.SendNotification();
9563   application.Render();
9564
9565   tet_infoline("Check the world position is the same as it would be without a rotation\n");
9566   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
9567
9568   tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
9569   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9570   application.SendNotification();
9571   application.Render();
9572   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(-50.0f, 50.0f, 0.0f), TEST_LOCATION);
9573
9574   tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
9575   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
9576   application.SendNotification();
9577   application.Render();
9578   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(150.0f, 50.0f, 0.0f), TEST_LOCATION);
9579
9580   END_TEST;
9581 }
9582
9583 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
9584 {
9585   TestApplication application;
9586   tet_infoline("Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
9587
9588   Actor actor = Actor::New();
9589   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
9590   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
9591   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
9592   actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::ZAXIS));
9593   actor.SetProperty(Actor::Property::SCALE, 2.0f);
9594   actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
9595   application.GetScene().Add(actor);
9596
9597   application.SendNotification();
9598   application.Render();
9599
9600   tet_infoline("Check the world position is the same as it would be without a scale and rotation\n");
9601   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
9602
9603   tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
9604   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9605   application.SendNotification();
9606   application.Render();
9607   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(-100.0f, 100.0f, 0.0f), TEST_LOCATION);
9608
9609   tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
9610   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
9611   application.SendNotification();
9612   application.Render();
9613   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(200.0f, 0.0f, 0.0f), TEST_LOCATION);
9614
9615   END_TEST;
9616 }
9617
9618 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
9619 {
9620   TestApplication application;
9621   tet_infoline("Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
9622
9623   Actor parent = Actor::New();
9624
9625   application.GetScene().Add(parent);
9626   Vector2 stageSize(application.GetScene().GetSize());
9627
9628   Actor actor = Actor::New();
9629   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
9630   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
9631   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
9632   actor.SetProperty(Actor::Property::INHERIT_SCALE, false);
9633   actor.SetProperty(Actor::Property::INHERIT_ORIENTATION, false);
9634   actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
9635   parent.Add(actor);
9636
9637   application.SendNotification();
9638   application.Render();
9639
9640   const Vector3 expectedWorldPosition(-stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f);
9641
9642   tet_infoline("Check the world position is in the right place\n");
9643   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
9644
9645   tet_infoline("Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed");
9646   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9647   application.SendNotification();
9648   application.Render();
9649   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
9650
9651   tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed");
9652   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
9653   application.SendNotification();
9654   application.Render();
9655   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
9656
9657   END_TEST;
9658 }
9659
9660 int utcDaliActorVisibilityChangeSignalSelf(void)
9661 {
9662   TestApplication application;
9663   tet_infoline("Check that the visibility change signal is called when the visibility changes for the actor itself");
9664
9665   Actor actor = Actor::New();
9666
9667   VisibilityChangedFunctorData data;
9668   DevelActor::VisibilityChangedSignal(actor).Connect(&application, VisibilityChangedFunctor(data));
9669
9670   actor.SetProperty(Actor::Property::VISIBLE, false);
9671
9672   data.Check(true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
9673
9674   tet_infoline("Ensure functor is not called if we attempt to change the visibility to what it already is at");
9675   data.Reset();
9676
9677   actor.SetProperty(Actor::Property::VISIBLE, false);
9678   data.Check(false /* not called */, TEST_LOCATION);
9679
9680   tet_infoline("Change the visibility using properties, ensure called");
9681   data.Reset();
9682
9683   actor.SetProperty(Actor::Property::VISIBLE, true);
9684   data.Check(true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
9685
9686   tet_infoline("Set the visibility to current using properties, ensure not called");
9687   data.Reset();
9688
9689   actor.SetProperty(Actor::Property::VISIBLE, true);
9690   data.Check(false /* not called */, TEST_LOCATION);
9691
9692   END_TEST;
9693 }
9694
9695 int utcDaliActorVisibilityChangeSignalChildren(void)
9696 {
9697   TestApplication application;
9698   tet_infoline("Check that the visibility change signal is called for the children when the visibility changes for the parent");
9699
9700   Actor parent = Actor::New();
9701   Actor child  = Actor::New();
9702   parent.Add(child);
9703
9704   Actor grandChild = Actor::New();
9705   child.Add(grandChild);
9706
9707   VisibilityChangedFunctorData parentData;
9708   VisibilityChangedFunctorData childData;
9709   VisibilityChangedFunctorData grandChildData;
9710
9711   tet_infoline("Only connect the child and grandchild, ensure they are called and not the parent");
9712   DevelActor::VisibilityChangedSignal(child).Connect(&application, VisibilityChangedFunctor(childData));
9713   DevelActor::VisibilityChangedSignal(grandChild).Connect(&application, VisibilityChangedFunctor(grandChildData));
9714
9715   parent.SetProperty(Actor::Property::VISIBLE, false);
9716   parentData.Check(false /* not called */, TEST_LOCATION);
9717   childData.Check(true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
9718   grandChildData.Check(true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
9719
9720   tet_infoline("Connect to the parent's signal as well and ensure all three are called");
9721   parentData.Reset();
9722   childData.Reset();
9723   grandChildData.Reset();
9724
9725   DevelActor::VisibilityChangedSignal(parent).Connect(&application, VisibilityChangedFunctor(parentData));
9726
9727   parent.SetProperty(Actor::Property::VISIBLE, true);
9728   parentData.Check(true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
9729   childData.Check(true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
9730   grandChildData.Check(true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
9731
9732   tet_infoline("Ensure none of the functors are called if we attempt to change the visibility to what it already is at");
9733   parentData.Reset();
9734   childData.Reset();
9735   grandChildData.Reset();
9736
9737   parent.SetProperty(Actor::Property::VISIBLE, true);
9738   parentData.Check(false /* not called */, TEST_LOCATION);
9739   childData.Check(false /* not called */, TEST_LOCATION);
9740   grandChildData.Check(false /* not called */, TEST_LOCATION);
9741
9742   END_TEST;
9743 }
9744
9745 int utcDaliActorVisibilityChangeSignalAfterAnimation(void)
9746 {
9747   TestApplication application;
9748   tet_infoline("Check that the visibility change signal is emitted when the visibility changes when an animation starts");
9749
9750   Actor actor = Actor::New();
9751   application.GetScene().Add(actor);
9752
9753   application.SendNotification();
9754   application.Render();
9755
9756   VisibilityChangedFunctorData data;
9757   DevelActor::VisibilityChangedSignal(actor).Connect(&application, VisibilityChangedFunctor(data));
9758
9759   Animation animation = Animation::New(1.0f);
9760   animation.AnimateTo(Property(actor, Actor::Property::VISIBLE), false);
9761
9762   data.Check(false, TEST_LOCATION);
9763   DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
9764   DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
9765
9766   tet_infoline("Play the animation and check the property value");
9767   animation.Play();
9768
9769   data.Check(true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
9770   DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::VISIBLE), false, TEST_LOCATION);
9771
9772   tet_infoline("Animation not currently finished, so the current visibility should still be true");
9773   DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
9774
9775   application.SendNotification();
9776   application.Render(1100); // After the animation
9777
9778   DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), false, TEST_LOCATION);
9779
9780   END_TEST;
9781 }
9782
9783 int utcDaliActorVisibilityChangeSignalByName(void)
9784 {
9785   TestApplication application;
9786   tet_infoline("Check that the visibility change signal is called when the visibility changes for the actor itself");
9787
9788   Actor actor = Actor::New();
9789
9790   bool signalCalled = false;
9791   actor.ConnectSignal(&application, "visibilityChanged", VisibilityChangedVoidFunctor(signalCalled));
9792   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
9793   actor.SetProperty(Actor::Property::VISIBLE, false);
9794   DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
9795
9796   tet_infoline("Ensure functor is not called if we attempt to change the visibility to what it already is at");
9797   signalCalled = false;
9798   actor.SetProperty(Actor::Property::VISIBLE, false);
9799   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
9800
9801   tet_infoline("Change the visibility using properties, ensure called");
9802   actor.SetProperty(Actor::Property::VISIBLE, true);
9803   DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
9804
9805   tet_infoline("Set the visibility to current using properties, ensure not called");
9806   signalCalled = false;
9807
9808   actor.SetProperty(Actor::Property::VISIBLE, true);
9809   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
9810
9811   END_TEST;
9812 }
9813
9814 static void LayoutDirectionChanged(Actor actor, LayoutDirection::Type type)
9815 {
9816   gLayoutDirectionType = type;
9817 }
9818
9819 int UtcDaliActorLayoutDirectionProperty(void)
9820 {
9821   TestApplication application;
9822   tet_infoline("Check layout direction property");
9823
9824   Actor actor0 = Actor::New();
9825   DALI_TEST_EQUALS(actor0.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
9826   application.GetScene().Add(actor0);
9827
9828   application.SendNotification();
9829   application.Render();
9830
9831   Actor actor1 = Actor::New();
9832   DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
9833   Actor actor2 = Actor::New();
9834   DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
9835   Actor actor3 = Actor::New();
9836   DALI_TEST_EQUALS(actor3.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
9837   Actor actor4 = Actor::New();
9838   DALI_TEST_EQUALS(actor4.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
9839   Actor actor5 = Actor::New();
9840   DALI_TEST_EQUALS(actor5.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
9841   Actor actor6 = Actor::New();
9842   DALI_TEST_EQUALS(actor6.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
9843   Actor actor7 = Actor::New();
9844   DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
9845   Actor actor8 = Actor::New();
9846   DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
9847   Actor actor9 = Actor::New();
9848   DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
9849
9850   actor1.Add(actor2);
9851   gLayoutDirectionType = LayoutDirection::LEFT_TO_RIGHT;
9852   actor2.LayoutDirectionChangedSignal().Connect(LayoutDirectionChanged);
9853
9854   DALI_TEST_EQUALS(actor1.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), true, TEST_LOCATION);
9855   actor1.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
9856   DALI_TEST_EQUALS(actor1.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), false, TEST_LOCATION);
9857
9858   DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
9859   DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
9860   DALI_TEST_EQUALS(gLayoutDirectionType, LayoutDirection::RIGHT_TO_LEFT, TEST_LOCATION);
9861
9862   actor1.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, true);
9863   actor0.Add(actor1);
9864   DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
9865   DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
9866
9867   application.GetScene().Add(actor3);
9868   actor3.Add(actor4);
9869   actor4.Add(actor5);
9870   actor5.Add(actor6);
9871   actor5.Add(actor7);
9872   actor7.Add(actor8);
9873   actor8.Add(actor9);
9874   actor3.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
9875   actor5.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
9876
9877   DALI_TEST_EQUALS(actor8.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), true, TEST_LOCATION);
9878   actor8.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, false);
9879   DALI_TEST_EQUALS(actor8.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), false, TEST_LOCATION);
9880
9881   actor7.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
9882
9883   DALI_TEST_EQUALS(actor3.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
9884   DALI_TEST_EQUALS(actor4.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
9885   DALI_TEST_EQUALS(actor5.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
9886   DALI_TEST_EQUALS(actor6.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
9887   DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
9888   DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
9889   DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
9890
9891   actor8.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
9892   DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
9893   DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
9894
9895   actor7.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
9896   DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
9897   DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
9898   DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
9899
9900   actor8.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, true);
9901   DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
9902   DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
9903
9904   END_TEST;
9905 }
9906
9907 struct LayoutDirectionFunctor
9908 {
9909   LayoutDirectionFunctor(bool& signalCalled)
9910   : mSignalCalled(signalCalled)
9911   {
9912   }
9913
9914   LayoutDirectionFunctor(const LayoutDirectionFunctor& rhs)
9915   : mSignalCalled(rhs.mSignalCalled)
9916   {
9917   }
9918
9919   void operator()()
9920   {
9921     mSignalCalled = true;
9922   }
9923
9924   bool& mSignalCalled;
9925 };
9926
9927 int UtcDaliActorLayoutDirectionSignal(void)
9928 {
9929   TestApplication application;
9930   tet_infoline("Check changing layout direction property sends a signal");
9931
9932   Actor actor = Actor::New();
9933   DALI_TEST_EQUALS(actor.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
9934   application.GetScene().Add(actor);
9935   bool                   signalCalled = false;
9936   LayoutDirectionFunctor layoutDirectionFunctor(signalCalled);
9937
9938   actor.ConnectSignal(&application, "layoutDirectionChanged", layoutDirectionFunctor);
9939   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
9940
9941   // Test that writing the same value doesn't send a signal
9942   actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
9943   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
9944
9945   // Test that writing a different value sends the signal
9946   signalCalled = false;
9947   actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
9948   DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
9949
9950   signalCalled = false;
9951   actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
9952   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
9953
9954   END_TEST;
9955 }
9956
9957 struct ChildAddedSignalCheck
9958 {
9959   ChildAddedSignalCheck(bool& signalReceived, Actor& childHandle)
9960   : mSignalReceived(signalReceived),
9961     mChildHandle(childHandle)
9962   {
9963   }
9964
9965   void operator()(Actor childHandle)
9966   {
9967     mSignalReceived = true;
9968     mChildHandle    = childHandle;
9969   }
9970   void operator()()
9971   {
9972     mSignalReceived = true;
9973     mChildHandle    = Actor();
9974   }
9975
9976   bool&  mSignalReceived;
9977   Actor& mChildHandle;
9978 };
9979
9980 int UtcDaliChildAddedSignalP1(void)
9981 {
9982   TestApplication application;
9983   auto            stage = application.GetScene();
9984
9985   bool  signalReceived = false;
9986   Actor childActor;
9987
9988   ChildAddedSignalCheck signal(signalReceived, childActor);
9989   DevelActor::ChildAddedSignal(stage.GetRootLayer()).Connect(&application, signal);
9990   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
9991
9992   auto actorA = Actor::New();
9993   stage.Add(actorA);
9994   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
9995   DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
9996   signalReceived = false;
9997
9998   auto actorB = Actor::New();
9999   stage.Add(actorB);
10000   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
10001   DALI_TEST_EQUALS(childActor, actorB, TEST_LOCATION);
10002
10003   END_TEST;
10004 }
10005
10006 int UtcDaliChildAddedSignalP2(void)
10007 {
10008   TestApplication application;
10009   auto            stage = application.GetScene();
10010
10011   bool  signalReceived = false;
10012   Actor childActor;
10013
10014   ChildAddedSignalCheck signal(signalReceived, childActor);
10015   tet_infoline("Connect to childAdded signal by name");
10016
10017   stage.GetRootLayer().ConnectSignal(&application, "childAdded", signal);
10018   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
10019
10020   auto actorA = Actor::New();
10021   stage.Add(actorA);
10022   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
10023
10024   // Can't test which actor was added; signal signature is void() when connecting via name.
10025   signalReceived = false;
10026
10027   auto actorB = Actor::New();
10028   stage.Add(actorB);
10029   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
10030
10031   END_TEST;
10032 }
10033
10034 int UtcDaliChildAddedSignalN(void)
10035 {
10036   TestApplication application;
10037   auto            stage = application.GetScene();
10038
10039   bool  signalReceived = false;
10040   Actor childActor;
10041
10042   ChildAddedSignalCheck signal(signalReceived, childActor);
10043   DevelActor::ChildAddedSignal(stage.GetRootLayer()).Connect(&application, signal);
10044   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
10045
10046   auto actorA = Actor::New();
10047   stage.Add(actorA);
10048   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
10049   DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
10050   signalReceived = false;
10051
10052   auto actorB = Actor::New();
10053   actorA.Add(actorB);
10054   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
10055   END_TEST;
10056 }
10057
10058 struct ChildRemovedSignalCheck
10059 {
10060   ChildRemovedSignalCheck(bool& signalReceived, Actor& childHandle)
10061   : mSignalReceived(signalReceived),
10062     mChildHandle(childHandle)
10063   {
10064   }
10065
10066   void operator()(Actor childHandle)
10067   {
10068     mSignalReceived = true;
10069     mChildHandle    = childHandle;
10070   }
10071
10072   void operator()()
10073   {
10074     mSignalReceived = true;
10075   }
10076
10077   bool&  mSignalReceived;
10078   Actor& mChildHandle;
10079 };
10080
10081 int UtcDaliChildRemovedSignalP1(void)
10082 {
10083   TestApplication application;
10084   auto            stage = application.GetScene();
10085
10086   bool  signalReceived = false;
10087   Actor childActor;
10088
10089   ChildRemovedSignalCheck signal(signalReceived, childActor);
10090   DevelActor::ChildRemovedSignal(stage.GetRootLayer()).Connect(&application, signal);
10091   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
10092
10093   auto actorA = Actor::New();
10094   stage.Add(actorA);
10095   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
10096   DALI_TEST_CHECK(!childActor);
10097
10098   stage.Remove(actorA);
10099   DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
10100   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
10101
10102   signalReceived = false;
10103   auto actorB    = Actor::New();
10104   stage.Add(actorB);
10105   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
10106
10107   stage.Remove(actorB);
10108   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
10109   DALI_TEST_EQUALS(childActor, actorB, TEST_LOCATION);
10110
10111   END_TEST;
10112 }
10113
10114 int UtcDaliChildRemovedSignalP2(void)
10115 {
10116   TestApplication application;
10117   auto            stage = application.GetScene();
10118
10119   bool  signalReceived = false;
10120   Actor childActor;
10121
10122   ChildAddedSignalCheck signal(signalReceived, childActor);
10123   tet_infoline("Connect to childRemoved signal by name");
10124
10125   stage.GetRootLayer().ConnectSignal(&application, "childRemoved", signal);
10126   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
10127
10128   auto actorA = Actor::New();
10129   stage.Add(actorA);
10130   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
10131
10132   stage.Remove(actorA);
10133   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
10134
10135   signalReceived = false;
10136   auto actorB    = Actor::New();
10137   stage.Add(actorB);
10138   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
10139
10140   stage.Remove(actorB);
10141   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
10142
10143   END_TEST;
10144 }
10145
10146 int UtcDaliChildRemovedSignalN(void)
10147 {
10148   TestApplication application;
10149   auto            stage = application.GetScene();
10150
10151   bool  signalReceived = false;
10152   Actor childActor;
10153
10154   ChildRemovedSignalCheck signal(signalReceived, childActor);
10155   DevelActor::ChildRemovedSignal(stage.GetRootLayer()).Connect(&application, signal);
10156   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
10157
10158   auto actorA = Actor::New();
10159   stage.Add(actorA);
10160
10161   auto actorB = Actor::New();
10162   actorA.Add(actorB);
10163
10164   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
10165   DALI_TEST_CHECK(!childActor);
10166
10167   actorA.Remove(actorB);
10168   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
10169   END_TEST;
10170 }
10171
10172 int UtcDaliChildMovedSignalP(void)
10173 {
10174   TestApplication application;
10175   auto            stage = application.GetScene();
10176
10177   bool  addedASignalReceived   = false;
10178   bool  removedASignalReceived = false;
10179   bool  addedBSignalReceived   = false;
10180   bool  removedBSignalReceived = false;
10181   Actor childActor;
10182
10183   auto actorA = Actor::New();
10184   auto actorB = Actor::New();
10185   stage.Add(actorA);
10186   stage.Add(actorB);
10187
10188   ChildAddedSignalCheck   addedSignalA(addedASignalReceived, childActor);
10189   ChildRemovedSignalCheck removedSignalA(removedASignalReceived, childActor);
10190   ChildAddedSignalCheck   addedSignalB(addedBSignalReceived, childActor);
10191   ChildRemovedSignalCheck removedSignalB(removedBSignalReceived, childActor);
10192
10193   DevelActor::ChildAddedSignal(actorA).Connect(&application, addedSignalA);
10194   DevelActor::ChildRemovedSignal(actorA).Connect(&application, removedSignalA);
10195   DevelActor::ChildAddedSignal(actorB).Connect(&application, addedSignalB);
10196   DevelActor::ChildRemovedSignal(actorB).Connect(&application, removedSignalB);
10197
10198   DALI_TEST_EQUALS(addedASignalReceived, false, TEST_LOCATION);
10199   DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
10200   DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
10201   DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
10202
10203   // Create a child of A
10204
10205   auto child = Actor::New();
10206   actorA.Add(child);
10207
10208   DALI_TEST_EQUALS(addedASignalReceived, true, TEST_LOCATION);
10209   DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
10210   DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
10211   DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
10212   DALI_TEST_EQUALS(childActor, child, TEST_LOCATION);
10213
10214   // Move child to B:
10215   addedASignalReceived   = false;
10216   addedBSignalReceived   = false;
10217   removedASignalReceived = false;
10218   removedBSignalReceived = false;
10219
10220   actorB.Add(child); // Expect this child to be re-parented
10221   DALI_TEST_EQUALS(addedASignalReceived, false, TEST_LOCATION);
10222   DALI_TEST_EQUALS(removedASignalReceived, true, TEST_LOCATION);
10223   DALI_TEST_EQUALS(addedBSignalReceived, true, TEST_LOCATION);
10224   DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
10225
10226   // Move child back to A:
10227   addedASignalReceived   = false;
10228   addedBSignalReceived   = false;
10229   removedASignalReceived = false;
10230   removedBSignalReceived = false;
10231
10232   actorA.Add(child); // Expect this child to be re-parented
10233   DALI_TEST_EQUALS(addedASignalReceived, true, TEST_LOCATION);
10234   DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
10235   DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
10236   DALI_TEST_EQUALS(removedBSignalReceived, true, TEST_LOCATION);
10237
10238   END_TEST;
10239 }
10240
10241 int UtcDaliActorSwitchParentP(void)
10242 {
10243   tet_infoline("Testing Actor::UtcDaliActorSwitchParentP");
10244   TestApplication application;
10245
10246   Actor parent1 = Actor::New();
10247   Actor child   = Actor::New();
10248
10249   application.GetScene().Add(parent1);
10250
10251   DALI_TEST_EQUALS(parent1.GetChildCount(), 0u, TEST_LOCATION);
10252
10253   child.OnSceneSignal().Connect(OnSceneCallback);
10254   child.OffSceneSignal().Connect(OffSceneCallback);
10255
10256   // sanity check
10257   DALI_TEST_CHECK(gOnSceneCallBackCalled == 0);
10258   DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
10259
10260   parent1.Add(child);
10261
10262   DALI_TEST_EQUALS(parent1.GetChildCount(), 1u, TEST_LOCATION);
10263
10264   DALI_TEST_CHECK(gOnSceneCallBackCalled == 1);
10265   DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
10266
10267   Actor parent2 = Actor::New();
10268   application.GetScene().Add(parent2);
10269
10270   bool                  addSignalReceived = false;
10271   ChildAddedSignalCheck addedSignal(addSignalReceived, child);
10272   DevelActor::ChildAddedSignal(application.GetScene().GetRootLayer()).Connect(&application, addedSignal);
10273   DALI_TEST_EQUALS(addSignalReceived, false, TEST_LOCATION);
10274
10275   bool                    removedSignalReceived = false;
10276   ChildRemovedSignalCheck removedSignal(removedSignalReceived, child);
10277   DevelActor::ChildRemovedSignal(application.GetScene().GetRootLayer()).Connect(&application, removedSignal);
10278   DALI_TEST_EQUALS(removedSignalReceived, false, TEST_LOCATION);
10279
10280   DevelActor::SwitchParent(child, parent2);
10281
10282   DALI_TEST_EQUALS(addSignalReceived, false, TEST_LOCATION);
10283   DALI_TEST_EQUALS(removedSignalReceived, false, TEST_LOCATION);
10284
10285   DALI_TEST_EQUALS(parent1.GetChildCount(), 0u, TEST_LOCATION);
10286   DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
10287
10288   DALI_TEST_CHECK(gOnSceneCallBackCalled == 1);
10289   DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
10290   DALI_TEST_CHECK(child.GetProperty<bool>(Dali::Actor::Property::CONNECTED_TO_SCENE));
10291   DALI_TEST_CHECK(child.GetParent() == parent2);
10292
10293   END_TEST;
10294 }
10295
10296 int utcDaliActorCulled(void)
10297 {
10298   TestApplication application;
10299   auto            stage = application.GetScene();
10300
10301   tet_infoline("Check that the actor is culled if the actor is out of the screen");
10302
10303   Actor actor = Actor::New();
10304   actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
10305
10306   Geometry geometry = CreateQuadGeometry();
10307   Shader   shader   = CreateShader();
10308   Renderer renderer = Renderer::New(geometry, shader);
10309   actor.AddRenderer(renderer);
10310
10311   stage.Add(actor);
10312
10313   application.SendNotification();
10314   application.Render(0);
10315
10316   DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::CULLED), false, TEST_LOCATION);
10317
10318   PropertyNotification notification = actor.AddPropertyNotification(Actor::Property::CULLED, LessThanCondition(0.5f));
10319   notification.SetNotifyMode(PropertyNotification::NOTIFY_ON_CHANGED);
10320
10321   // Connect NotifySignal
10322   bool                              propertyNotificationSignal(false);
10323   PropertyNotification              source;
10324   CulledPropertyNotificationFunctor f(propertyNotificationSignal, source);
10325   notification.NotifySignal().Connect(&application, f);
10326
10327   actor.SetProperty(Actor::Property::POSITION, Vector2(1000.0f, 1000.0f));
10328
10329   application.SendNotification();
10330   application.Render();
10331
10332   application.SendNotification();
10333
10334   DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::CULLED), true, TEST_LOCATION);
10335
10336   DALI_TEST_EQUALS(propertyNotificationSignal, true, TEST_LOCATION);
10337   DALI_TEST_EQUALS(source.GetTargetProperty(), static_cast<int>(Actor::Property::CULLED), TEST_LOCATION);
10338   DALI_TEST_EQUALS(source.GetTarget().GetProperty<bool>(source.GetTargetProperty()), true, TEST_LOCATION);
10339
10340   END_TEST;
10341 }
10342
10343 int utcDaliEnsureRenderWhenRemovingLastRenderableActor(void)
10344 {
10345   TestApplication application;
10346   auto            stage = application.GetScene();
10347
10348   tet_infoline("Ensure we clear the screen when the last actor is removed");
10349
10350   Actor actor = CreateRenderableActor();
10351   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
10352   stage.Add(actor);
10353
10354   application.SendNotification();
10355   application.Render();
10356
10357   auto&      glAbstraction    = application.GetGlAbstraction();
10358   const auto clearCountBefore = glAbstraction.GetClearCountCalled();
10359
10360   actor.Unparent();
10361
10362   application.SendNotification();
10363   application.Render();
10364
10365   DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION);
10366
10367   END_TEST;
10368 }
10369
10370 int utcDaliEnsureRenderWhenMakingLastActorInvisible(void)
10371 {
10372   TestApplication application;
10373   auto            stage = application.GetScene();
10374
10375   tet_infoline("Ensure we clear the screen when the last actor is made invisible");
10376
10377   Actor actor = CreateRenderableActor();
10378   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
10379   stage.Add(actor);
10380
10381   application.SendNotification();
10382   application.Render();
10383
10384   auto&      glAbstraction    = application.GetGlAbstraction();
10385   const auto clearCountBefore = glAbstraction.GetClearCountCalled();
10386
10387   actor.SetProperty(Actor::Property::VISIBLE, false);
10388
10389   application.SendNotification();
10390   application.Render();
10391
10392   DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION);
10393
10394   END_TEST;
10395 }
10396
10397 int utcDaliActorGetSizeAfterAnimation(void)
10398 {
10399   TestApplication application;
10400   tet_infoline("Check the actor size before / after an animation is finished");
10401
10402   Vector3 actorSize(100.0f, 100.0f, 0.0f);
10403
10404   Actor actor = Actor::New();
10405   actor.SetProperty(Actor::Property::SIZE, actorSize);
10406   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10407   application.GetScene().Add(actor);
10408
10409   // Size should be updated without rendering.
10410   Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
10411   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10412
10413   application.SendNotification();
10414   application.Render();
10415
10416   // Size and current size should be updated.
10417   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
10418   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10419   DALI_TEST_EQUALS(actorSize.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
10420   DALI_TEST_EQUALS(actorSize.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
10421   DALI_TEST_EQUALS(actorSize.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
10422
10423   Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
10424   DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10425   DALI_TEST_EQUALS(actorSize.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
10426   DALI_TEST_EQUALS(actorSize.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
10427   DALI_TEST_EQUALS(actorSize.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
10428
10429   // Set size again
10430   actorSize = Vector3(200.0f, 200.0f, 0.0f);
10431   actor.SetProperty(Actor::Property::SIZE, actorSize);
10432
10433   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
10434   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10435
10436   Vector3 targetValue(10.0f, 20.0f, 0.0f);
10437
10438   Animation animation = Animation::New(1.0f);
10439   animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
10440   animation.Play();
10441
10442   // Size should be updated without rendering.
10443   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
10444   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10445
10446   application.SendNotification();
10447   application.Render(1100); // After the animation
10448
10449   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
10450   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10451   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
10452   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
10453   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
10454
10455   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
10456   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10457   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
10458   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
10459   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
10460
10461   targetValue.width = 50.0f;
10462
10463   animation.Clear();
10464   animation.AnimateTo(Property(actor, Actor::Property::SIZE_WIDTH), targetValue.width);
10465   animation.Play();
10466
10467   application.SendNotification();
10468   application.Render(1100); // After the animation
10469
10470   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
10471   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10472   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
10473   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
10474   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
10475
10476   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
10477   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10478   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
10479   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
10480   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
10481
10482   targetValue.height = 70.0f;
10483
10484   animation.Clear();
10485   animation.AnimateTo(Property(actor, Actor::Property::SIZE_HEIGHT), targetValue.height);
10486   animation.Play();
10487
10488   application.SendNotification();
10489   application.Render(1100); // After the animation
10490
10491   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
10492   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10493   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
10494   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
10495   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
10496
10497   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
10498   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10499   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
10500   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
10501   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
10502
10503   Vector3 offset(10.0f, 20.0f, 0.0f);
10504
10505   animation.Clear();
10506   animation.AnimateBy(Property(actor, Actor::Property::SIZE), offset);
10507   animation.Play();
10508
10509   application.SendNotification();
10510   application.Render(1100); // After the animation
10511
10512   targetValue += offset;
10513
10514   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
10515   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10516   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
10517   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
10518   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
10519
10520   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
10521   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10522   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
10523   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
10524   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
10525
10526   offset.width = 20.0f;
10527
10528   animation.Clear();
10529   animation.AnimateBy(Property(actor, Actor::Property::SIZE_WIDTH), offset.width);
10530   animation.Play();
10531
10532   application.SendNotification();
10533   application.Render(1100); // After the animation
10534
10535   targetValue.width += offset.width;
10536
10537   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
10538   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10539   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
10540   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
10541   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
10542
10543   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
10544   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10545   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
10546   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
10547   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
10548
10549   offset.height = 10.0f;
10550
10551   animation.Clear();
10552   animation.AnimateBy(Property(actor, Actor::Property::SIZE_HEIGHT), offset.height);
10553   animation.Play();
10554
10555   application.SendNotification();
10556   application.Render(1100); // After the animation
10557
10558   targetValue.height += offset.height;
10559
10560   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
10561   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10562   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
10563   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
10564   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
10565
10566   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
10567   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10568   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
10569   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
10570   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
10571
10572   // Set size again
10573   actorSize = Vector3(300.0f, 300.0f, 0.0f);
10574
10575   actor.SetProperty(Actor::Property::SIZE, actorSize);
10576
10577   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
10578   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10579
10580   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
10581   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10582
10583   application.SendNotification();
10584   application.Render();
10585
10586   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
10587   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10588
10589   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
10590   DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10591
10592   END_TEST;
10593 }
10594
10595 int utcDaliActorGetSizeAfterAnimation2(void)
10596 {
10597   TestApplication application;
10598   tet_infoline("Check the actor size before / after an animation is finished if before size is equal to animation target size");
10599
10600   Vector3 actorSize(100.0f, 100.0f, 0.0f);
10601
10602   Actor actor = Actor::New();
10603   actor.SetProperty(Actor::Property::SIZE, actorSize);
10604   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10605   application.GetScene().Add(actor);
10606
10607   // Size should be updated without rendering.
10608   Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
10609   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10610
10611   application.SendNotification();
10612   application.Render();
10613
10614   // Size and current size should be updated.
10615   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
10616   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10617   DALI_TEST_EQUALS(actorSize.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
10618   DALI_TEST_EQUALS(actorSize.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
10619   DALI_TEST_EQUALS(actorSize.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
10620
10621   Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
10622   DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10623   DALI_TEST_EQUALS(actorSize.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
10624   DALI_TEST_EQUALS(actorSize.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
10625   DALI_TEST_EQUALS(actorSize.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
10626
10627   // Set size again
10628   actorSize = Vector3(200.0f, 200.0f, 0.0f);
10629   actor.SetProperty(Actor::Property::SIZE, actorSize);
10630
10631   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
10632   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10633
10634   Vector3 targetValue(actorSize);
10635
10636   Animation animation = Animation::New(1.0f);
10637   animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
10638   animation.Play();
10639
10640   // Size should be updated without rendering.
10641   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
10642   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10643
10644   application.SendNotification();
10645   application.Render(100); // During the animation
10646
10647   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
10648   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10649   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
10650   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
10651   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
10652
10653   // We should get target value because targetValue is equal to current actor size.
10654   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
10655   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10656   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
10657   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
10658   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
10659
10660   application.SendNotification();
10661   application.Render(1000); // After animation finished
10662
10663   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
10664   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10665
10666   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
10667   DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10668
10669   END_TEST;
10670 }
10671
10672 int utcDaliActorRelayoutAndAnimation(void)
10673 {
10674   TestApplication application;
10675   tet_infoline("Check the actor size when relayoutting and playing animation");
10676
10677   Vector3 parentSize(300.0f, 300.0f, 0.0f);
10678   Vector3 actorSize(100.0f, 100.0f, 0.0f);
10679
10680   {
10681     Actor parentA = Actor::New();
10682     parentA.SetProperty(Actor::Property::SIZE, parentSize);
10683     parentA.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10684     application.GetScene().Add(parentA);
10685
10686     Actor parentB = Actor::New();
10687     parentB.SetProperty(Actor::Property::SIZE, parentSize);
10688     parentB.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10689     application.GetScene().Add(parentB);
10690
10691     Actor actor = Actor::New();
10692     actor.SetProperty(Actor::Property::SIZE, actorSize);
10693     actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10694     parentA.Add(actor);
10695
10696     Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
10697     DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10698
10699     Vector3 targetValue(200.0f, 200.0f, 0.0f);
10700
10701     Animation animation = Animation::New(1.0f);
10702     animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
10703     animation.Play();
10704
10705     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
10706     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10707
10708     application.SendNotification();
10709     application.Render(1100); // After the animation
10710
10711     // Size and current size should be updated.
10712     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
10713     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10714
10715     Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
10716     DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10717
10718     // Trigger relayout
10719     parentB.Add(actor);
10720
10721     application.SendNotification();
10722     application.Render();
10723
10724     // Size and current size should be same.
10725     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
10726     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10727
10728     currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
10729     DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10730
10731     actor.Unparent();
10732     parentA.Unparent();
10733     parentB.Unparent();
10734   }
10735
10736   {
10737     Actor parentA = Actor::New();
10738     parentA.SetProperty(Actor::Property::SIZE, parentSize);
10739     parentA.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10740     application.GetScene().Add(parentA);
10741
10742     Actor parentB = Actor::New();
10743     parentB.SetProperty(Actor::Property::SIZE, parentSize);
10744     parentB.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10745     application.GetScene().Add(parentB);
10746
10747     Actor actor = Actor::New();
10748     actor.SetProperty(Actor::Property::SIZE, actorSize);
10749     actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10750     parentA.Add(actor);
10751
10752     Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
10753     DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10754
10755     application.SendNotification();
10756     application.Render();
10757
10758     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
10759     DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10760
10761     Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
10762     DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10763
10764     Vector3 targetValue(200.0f, 200.0f, 0.0f);
10765
10766     // Make an animation
10767     Animation animation = Animation::New(1.0f);
10768     animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
10769     animation.Play();
10770
10771     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
10772     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10773
10774     application.SendNotification();
10775     application.Render(1100); // After the animation
10776
10777     // Size and current size should be updated.
10778     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
10779     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10780
10781     currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
10782     DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10783
10784     // Trigger relayout
10785     parentB.Add(actor);
10786
10787     application.SendNotification();
10788     application.Render();
10789
10790     // Size and current size should be same.
10791     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
10792     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10793
10794     currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
10795     DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
10796
10797     actor.Unparent();
10798     parentA.Unparent();
10799     parentB.Unparent();
10800   }
10801
10802   END_TEST;
10803 }
10804
10805 int utcDaliActorPartialUpdate(void)
10806 {
10807   TestApplication application(
10808     TestApplication::DEFAULT_SURFACE_WIDTH,
10809     TestApplication::DEFAULT_SURFACE_HEIGHT,
10810     TestApplication::DEFAULT_HORIZONTAL_DPI,
10811     TestApplication::DEFAULT_VERTICAL_DPI,
10812     true,
10813     true);
10814
10815   tet_infoline("Check the damaged area");
10816
10817   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
10818
10819   std::vector<Rect<int>> damagedRects;
10820   Rect<int>              clippingRect;
10821   application.SendNotification();
10822   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10823
10824   // First render pass, nothing to render, adaptor would just do swap buffer.
10825   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10826
10827   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
10828   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10829
10830   Actor actor = CreateRenderableActor();
10831   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
10832   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
10833   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
10834   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10835   application.GetScene().Add(actor);
10836
10837   application.SendNotification();
10838
10839   // 1. Actor added, damaged rect is added size of actor
10840   damagedRects.clear();
10841   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10842   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10843
10844   // Aligned by 16
10845   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10846   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10847   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10848   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
10849   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
10850   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
10851   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
10852
10853   // 2. Set new size
10854   actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0));
10855   application.SendNotification();
10856
10857   damagedRects.clear();
10858   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10859   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10860
10861   // Aligned by 16
10862   clippingRect = Rect<int>(16, 752, 48, 48); // in screen coordinates
10863   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10864   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10865   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
10866   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
10867   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
10868   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
10869
10870   // 3. Set new position
10871   actor.SetProperty(Actor::Property::POSITION, Vector3(32.0f, 32.0f, 0));
10872   application.SendNotification();
10873
10874   damagedRects.clear();
10875   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10876   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10877
10878   // Aligned by 16
10879   clippingRect = Rect<int>(16, 736, 64, 64); // in screen coordinates
10880   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10881   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10882   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
10883   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
10884   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
10885   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
10886
10887   application.GetScene().Remove(actor);
10888   application.SendNotification();
10889
10890   // Actor removed, last a dirty rect is reported.
10891   damagedRects.clear();
10892   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10893   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10894
10895   clippingRect = damagedRects[0];
10896
10897   DALI_TEST_EQUALS(clippingRect.IsValid(), true, TEST_LOCATION);
10898   DALI_TEST_EQUALS<Rect<int>>(clippingRect, Rect<int>(32, 736, 48, 48), TEST_LOCATION);
10899
10900   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10901   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
10902   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
10903   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
10904   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
10905
10906   END_TEST;
10907 }
10908
10909 int utcDaliActorPartialUpdateSetColor(void)
10910 {
10911   TestApplication application(
10912     TestApplication::DEFAULT_SURFACE_WIDTH,
10913     TestApplication::DEFAULT_SURFACE_HEIGHT,
10914     TestApplication::DEFAULT_HORIZONTAL_DPI,
10915     TestApplication::DEFAULT_VERTICAL_DPI,
10916     true,
10917     true);
10918
10919   tet_infoline("Check uniform update");
10920
10921   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
10922
10923   std::vector<Rect<int>> damagedRects;
10924   Rect<int>              clippingRect;
10925   application.SendNotification();
10926   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10927
10928   // First render pass, nothing to render, adaptor would just do swap buffer.
10929   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10930
10931   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
10932   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10933
10934   Actor actor = CreateRenderableActor();
10935   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
10936   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
10937   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
10938   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10939   application.GetScene().Add(actor);
10940
10941   application.SendNotification();
10942
10943   // 1. Actor added, damaged rect is added size of actor
10944   damagedRects.clear();
10945   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10946   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10947
10948   // Aligned by 16
10949   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10950   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10951   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10952   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
10953   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
10954   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
10955   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
10956
10957   damagedRects.clear();
10958   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10959   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10960
10961   damagedRects.clear();
10962   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10963   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10964
10965   // 2. Set new color
10966   actor.SetProperty(Actor::Property::COLOR, Vector3(1.0f, 0.0f, 0.0f));
10967   application.SendNotification();
10968
10969   damagedRects.clear();
10970   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10971   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10972
10973   // Aligned by 16
10974   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10975   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10976   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10977   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
10978   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
10979   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
10980   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
10981
10982   END_TEST;
10983 }
10984
10985 const std::string SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME("uLightCameraProjectionMatrix");
10986 const std::string SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME("uLightCameraViewMatrix");
10987 const std::string SHADER_SHADOW_COLOR_PROPERTY_NAME("uShadowColor");
10988 const char* const RENDER_SHADOW_VERTEX_SOURCE =
10989   " uniform mediump mat4 uLightCameraProjectionMatrix;\n"
10990   " uniform mediump mat4 uLightCameraViewMatrix;\n"
10991   "\n"
10992   "void main()\n"
10993   "{\n"
10994   "  gl_Position = uProjection * uModelView * vec4(aPosition,1.0);\n"
10995   "  vec4 textureCoords = uLightCameraProjectionMatrix * uLightCameraViewMatrix * uModelMatrix  * vec4(aPosition,1.0);\n"
10996   "  vTexCoord = 0.5 + 0.5 * (textureCoords.xy/textureCoords.w);\n"
10997   "}\n";
10998
10999 const char* const RENDER_SHADOW_FRAGMENT_SOURCE =
11000   "uniform lowp vec4 uShadowColor;\n"
11001   "void main()\n"
11002   "{\n"
11003   "  lowp float alpha;\n"
11004   "  alpha = texture2D(sTexture, vec2(vTexCoord.x, vTexCoord.y)).a;\n"
11005   "  gl_FragColor = vec4(uShadowColor.rgb, uShadowColor.a * alpha);\n"
11006   "}\n";
11007
11008 int utcDaliActorPartialUpdateSetProperty(void)
11009 {
11010   TestApplication application(
11011     TestApplication::DEFAULT_SURFACE_WIDTH,
11012     TestApplication::DEFAULT_SURFACE_HEIGHT,
11013     TestApplication::DEFAULT_HORIZONTAL_DPI,
11014     TestApplication::DEFAULT_VERTICAL_DPI,
11015     true,
11016     true);
11017
11018   tet_infoline("Set/Update property with partial update");
11019
11020   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
11021
11022   std::vector<Rect<int>> damagedRects;
11023   Rect<int>              clippingRect;
11024   application.SendNotification();
11025   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11026
11027   // First render pass, nothing to render, adaptor would just do swap buffer.
11028   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
11029
11030   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
11031   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11032
11033   Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 4u, 4u);
11034   Actor   actor = CreateRenderableActor(image, RENDER_SHADOW_VERTEX_SOURCE, RENDER_SHADOW_FRAGMENT_SOURCE);
11035   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
11036   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
11037   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
11038   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
11039   application.GetScene().Add(actor);
11040
11041   actor.RegisterProperty(SHADER_SHADOW_COLOR_PROPERTY_NAME, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
11042
11043   damagedRects.clear();
11044   application.SendNotification();
11045   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11046   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
11047
11048   // Aligned by 16
11049   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
11050   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
11051   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11052   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
11053   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
11054   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
11055   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
11056
11057   Property::Index shadowColorPropertyIndex = actor.GetPropertyIndex(SHADER_SHADOW_COLOR_PROPERTY_NAME);
11058   actor.SetProperty(shadowColorPropertyIndex, Vector4(1.0f, 1.0f, 0.0f, 1.0f));
11059
11060   damagedRects.clear();
11061   application.SendNotification();
11062   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11063   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
11064
11065   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
11066   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11067   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
11068   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
11069   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
11070   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
11071
11072   // Should be no damage rects, nothing changed
11073   damagedRects.clear();
11074   application.SendNotification();
11075   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11076   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
11077
11078   // Should be 1 damage rect due to change in size
11079   damagedRects.clear();
11080   actor.SetProperty(Actor::Property::SIZE, Vector3(26.0f, 26.0f, 0.0f));
11081   application.SendNotification();
11082   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11083   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
11084
11085   clippingRect = Rect<int>(16, 752, 32, 48); // new clipping rect size increased due to change in actor size
11086   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
11087   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11088   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
11089   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
11090   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
11091   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
11092
11093   damagedRects.clear();
11094   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11095   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
11096
11097   END_TEST;
11098 }
11099
11100 int utcDaliActorPartialUpdateTwoActors(void)
11101 {
11102   TestApplication application(
11103     TestApplication::DEFAULT_SURFACE_WIDTH,
11104     TestApplication::DEFAULT_SURFACE_HEIGHT,
11105     TestApplication::DEFAULT_HORIZONTAL_DPI,
11106     TestApplication::DEFAULT_VERTICAL_DPI,
11107     true,
11108     true);
11109
11110   tet_infoline("Check the damaged rects with partial update and two actors");
11111
11112   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
11113
11114   Actor actor = CreateRenderableActor();
11115   actor.SetProperty(Actor::Property::POSITION, Vector3(100.0f, 100.0f, 0.0f));
11116   actor.SetProperty(Actor::Property::SIZE, Vector3(50.0f, 50.0f, 0.0f));
11117   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
11118   application.GetScene().Add(actor);
11119
11120   Actor actor2 = CreateRenderableActor();
11121   actor2.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
11122   actor2.SetProperty(Actor::Property::SIZE, Vector3(100.0f, 100.0f, 0.0f));
11123   actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
11124   application.GetScene().Add(actor2);
11125
11126   application.SendNotification();
11127   std::vector<Rect<int>> damagedRects;
11128   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
11129
11130   DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
11131   DirtyRectChecker(damagedRects, {Rect<int>(64, 672, 64, 64), Rect<int>(96, 592, 112, 112)}, true, TEST_LOCATION);
11132
11133   // in screen coordinates, adaptor would calculate it using previous frames information
11134   Rect<int> clippingRect = Rect<int>(64, 592, 144, 192);
11135   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11136
11137   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
11138   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
11139   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
11140   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
11141
11142   // Change a Renderer of actor1
11143   Geometry geometry    = CreateQuadGeometry();
11144   Shader   shader      = CreateShader();
11145   Renderer newRenderer = Renderer::New(geometry, shader);
11146   Renderer renderer    = actor.GetRendererAt(0);
11147
11148   actor.RemoveRenderer(renderer);
11149   actor.AddRenderer(newRenderer);
11150
11151   damagedRects.clear();
11152
11153   application.SendNotification();
11154   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
11155
11156   DALI_TEST_CHECK(damagedRects.size() > 0);
11157   DirtyRectChecker(damagedRects, {Rect<int>(64, 672, 64, 64)}, false, TEST_LOCATION);
11158
11159   // in screen coordinates, adaptor would calculate it using previous frames information
11160   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11161
11162   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
11163   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
11164   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
11165   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
11166
11167   END_TEST;
11168 }
11169
11170 int utcDaliActorPartialUpdateActorsWithSizeHint01(void)
11171 {
11172   TestApplication application(
11173     TestApplication::DEFAULT_SURFACE_WIDTH,
11174     TestApplication::DEFAULT_SURFACE_HEIGHT,
11175     TestApplication::DEFAULT_HORIZONTAL_DPI,
11176     TestApplication::DEFAULT_VERTICAL_DPI,
11177     true,
11178     true);
11179
11180   tet_infoline("Check the damaged rect with partial update and update area hint");
11181
11182   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
11183
11184   Actor actor = CreateRenderableActor();
11185   actor.SetProperty(Actor::Property::POSITION, Vector3(64.0f, 64.0f, 0.0f));
11186   actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0.0f));
11187   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(0.0f, 0.0f, 64.0f, 64.0f));
11188   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
11189   application.GetScene().Add(actor);
11190
11191   application.SendNotification();
11192   std::vector<Rect<int>> damagedRects;
11193   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
11194
11195   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
11196
11197   Rect<int> clippingRect = Rect<int>(32, 704, 80, 80);
11198   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
11199
11200   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11201
11202   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
11203   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
11204   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
11205   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
11206
11207   // Reset
11208   actor.Unparent();
11209
11210   damagedRects.clear();
11211   application.SendNotification();
11212   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
11213
11214   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
11215   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
11216
11217   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11218
11219   damagedRects.clear();
11220   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11221   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11222
11223   // Ensure the damaged rect is empty
11224   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
11225
11226   // Change UPDATE_AREA_HINT
11227   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(16.0f, 16.0f, 32.0f, 32.0f));
11228   application.GetScene().Add(actor);
11229
11230   application.SendNotification();
11231   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
11232
11233   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
11234
11235   clippingRect = Rect<int>(64, 704, 48, 48);
11236   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
11237
11238   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11239
11240   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
11241   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
11242   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
11243   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
11244
11245   // Reset
11246   actor.Unparent();
11247
11248   damagedRects.clear();
11249   application.SendNotification();
11250   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
11251
11252   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
11253   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
11254
11255   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11256
11257   damagedRects.clear();
11258   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11259   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11260
11261   // Ensure the damaged rect is empty
11262   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
11263
11264   // Change UPDATE_AREA_HINT
11265   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(-32.0f, -16.0f, 64.0f, 64.0f));
11266   application.GetScene().Add(actor);
11267
11268   application.SendNotification();
11269   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
11270
11271   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
11272
11273   clippingRect = Rect<int>(0, 720, 80, 80);
11274   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
11275
11276   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11277
11278   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
11279   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
11280   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
11281   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
11282
11283   END_TEST;
11284 }
11285
11286 int utcDaliActorPartialUpdateActorsWithSizeHint02(void)
11287 {
11288   TestApplication application(
11289     TestApplication::DEFAULT_SURFACE_WIDTH,
11290     TestApplication::DEFAULT_SURFACE_HEIGHT,
11291     TestApplication::DEFAULT_HORIZONTAL_DPI,
11292     TestApplication::DEFAULT_VERTICAL_DPI,
11293     true,
11294     true);
11295
11296   tet_infoline("Check the damaged rect with partial update and update area hint");
11297
11298   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
11299
11300   Actor actor = CreateRenderableActor();
11301   actor.SetProperty(Actor::Property::POSITION, Vector3(64.0f, 64.0f, 0.0f));
11302   actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0.0f));
11303   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
11304   application.GetScene().Add(actor);
11305
11306   application.SendNotification();
11307   std::vector<Rect<int>> damagedRects;
11308   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
11309
11310   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
11311
11312   Rect<int> clippingRect = Rect<int>(48, 720, 48, 48);
11313   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
11314
11315   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11316
11317   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
11318   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
11319   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
11320   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
11321
11322   damagedRects.clear();
11323   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11324   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11325
11326   // Ensure the damaged rect is empty
11327   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
11328
11329   // Change UPDATE_AREA_HINT
11330   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(0.0f, 0.0f, 64.0f, 64.0f));
11331
11332   application.SendNotification();
11333   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
11334
11335   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
11336
11337   clippingRect = Rect<int>(32, 704, 80, 80);
11338   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
11339
11340   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11341
11342   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
11343   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
11344   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
11345   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
11346
11347   damagedRects.clear();
11348   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11349   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11350
11351   // Ensure the damaged rect is empty
11352   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
11353
11354   // Change UPDATE_AREA_HINT
11355   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(16.0f, 16.0f, 64.0f, 64.0f));
11356   application.GetScene().Add(actor);
11357
11358   application.SendNotification();
11359   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
11360
11361   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
11362
11363   clippingRect = Rect<int>(32, 688, 96, 96);
11364   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
11365
11366   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11367
11368   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
11369   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
11370   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
11371   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
11372
11373   END_TEST;
11374 }
11375
11376 int utcDaliActorPartialUpdateActorsWithSizeHint03(void)
11377 {
11378   TestApplication application(
11379     TestApplication::DEFAULT_SURFACE_WIDTH,
11380     TestApplication::DEFAULT_SURFACE_HEIGHT,
11381     TestApplication::DEFAULT_HORIZONTAL_DPI,
11382     TestApplication::DEFAULT_VERTICAL_DPI,
11383     true,
11384     true);
11385
11386   tet_infoline("Check the damaged rect with partial update and update area hint");
11387
11388   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
11389
11390   Actor actor = CreateRenderableActor();
11391   actor.SetProperty(Actor::Property::POSITION, Vector3(64.0f, 64.0f, 0.0f));
11392   actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0.0f));
11393   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(0.0f, 0.0f, 64.0f, 64.0f));
11394   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
11395   application.GetScene().Add(actor);
11396
11397   application.SendNotification();
11398   std::vector<Rect<int>> damagedRects;
11399   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
11400
11401   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
11402
11403   Rect<int> clippingRect = Rect<int>(32, 704, 80, 80);
11404   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
11405
11406   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11407
11408   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
11409   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
11410   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
11411   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
11412
11413   damagedRects.clear();
11414   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11415   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11416
11417   // Ensure the damaged rect is empty
11418   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
11419
11420   // Set UPDATE_AREA_HINT twice before rendering
11421   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(0.0f, 0.0f, 32.0f, 32.0f));
11422   application.SendNotification();
11423
11424   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(32.0f, -32.0f, 32.0f, 32.0f));
11425   application.SendNotification();
11426
11427   damagedRects.clear();
11428   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
11429
11430   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
11431
11432   clippingRect = Rect<int>(32, 704, 96, 96);
11433   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
11434
11435   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11436
11437   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
11438   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
11439   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
11440   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
11441
11442   END_TEST;
11443 }
11444
11445 int utcDaliActorPartialUpdateAnimation01(void)
11446 {
11447   TestApplication application(
11448     TestApplication::DEFAULT_SURFACE_WIDTH,
11449     TestApplication::DEFAULT_SURFACE_HEIGHT,
11450     TestApplication::DEFAULT_HORIZONTAL_DPI,
11451     TestApplication::DEFAULT_VERTICAL_DPI,
11452     true,
11453     true);
11454
11455   tet_infoline("Check the damaged area with partial update and animation");
11456
11457   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
11458   drawTrace.Enable(true);
11459   drawTrace.Reset();
11460
11461   Actor actor1 = CreateRenderableActor();
11462   actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
11463   actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
11464   application.GetScene().Add(actor1);
11465
11466   Actor actor2 = CreateRenderableActor();
11467   actor2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
11468   actor2.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
11469   application.GetScene().Add(actor2);
11470
11471   std::vector<Rect<int>> damagedRects;
11472   Rect<int>              clippingRect;
11473   Rect<int>              expectedRect1, expectedRect2;
11474
11475   application.SendNotification();
11476   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11477
11478   DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
11479
11480   // Aligned by 16
11481   expectedRect1 = Rect<int>(0, 720, 96, 96); // in screen coordinates, includes 1 last frames updates
11482   expectedRect2 = Rect<int>(0, 784, 32, 32); // in screen coordinates, includes 1 last frames updates
11483   DirtyRectChecker(damagedRects, {expectedRect1, expectedRect2}, true, TEST_LOCATION);
11484
11485   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
11486   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11487
11488   // Make an animation
11489   Animation animation = Animation::New(1.0f);
11490   animation.AnimateTo(Property(actor2, Actor::Property::POSITION_X), 160.0f, TimePeriod(0.5f, 0.5f));
11491   animation.Play();
11492
11493   application.SendNotification();
11494
11495   damagedRects.clear();
11496   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
11497   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11498   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11499
11500   drawTrace.Reset();
11501   damagedRects.clear();
11502
11503   // In animation deley time
11504   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
11505   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11506   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11507
11508   // Skip rendering
11509   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
11510
11511   drawTrace.Reset();
11512   damagedRects.clear();
11513
11514   // Also in animation deley time
11515   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
11516   application.PreRenderWithPartialUpdate(100, nullptr, damagedRects);
11517   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11518
11519   // Skip rendering
11520   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
11521
11522   // Unparent 2 actors and make a new actor
11523   actor1.Unparent();
11524   actor2.Unparent();
11525
11526   Actor actor3 = CreateRenderableActor();
11527   actor3.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
11528   actor3.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
11529   application.GetScene().Add(actor3);
11530
11531   application.SendNotification();
11532
11533   // Started animation
11534   damagedRects.clear();
11535   application.PreRenderWithPartialUpdate(500, nullptr, damagedRects);
11536   DALI_TEST_EQUALS(damagedRects.size(), 3, TEST_LOCATION);
11537
11538   // One of dirty rect is actor3's.
11539   // We don't know the exact dirty rect of actor1 and actor2.
11540   DirtyRectChecker(damagedRects, {expectedRect1, expectedRect2, expectedRect2}, true, TEST_LOCATION);
11541
11542   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
11543   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11544
11545   // Finished animation, but the actor was already unparented
11546   damagedRects.clear();
11547   application.PreRenderWithPartialUpdate(500, nullptr, damagedRects);
11548
11549   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
11550
11551   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
11552   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11553
11554   END_TEST;
11555 }
11556
11557 int utcDaliActorPartialUpdateAnimation02(void)
11558 {
11559   TestApplication application(
11560     TestApplication::DEFAULT_SURFACE_WIDTH,
11561     TestApplication::DEFAULT_SURFACE_HEIGHT,
11562     TestApplication::DEFAULT_HORIZONTAL_DPI,
11563     TestApplication::DEFAULT_VERTICAL_DPI,
11564     true,
11565     true);
11566
11567   tet_infoline("Check the damaged area with partial update and animation delay");
11568
11569   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
11570   drawTrace.Enable(true);
11571   drawTrace.Reset();
11572
11573   Actor actor = CreateRenderableActor();
11574   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
11575   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
11576   application.GetScene().Add(actor);
11577
11578   std::vector<Rect<int>> damagedRects;
11579   Rect<int>              clippingRect;
11580
11581   application.SendNotification();
11582   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11583
11584   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
11585
11586   // Aligned by 16
11587   clippingRect = Rect<int>(0, 784, 32, 32); // in screen coordinates, includes 1 last frames updates
11588   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
11589
11590   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11591
11592   // Make an animation
11593   Renderer  renderer  = actor.GetRendererAt(0);
11594   Animation animation = Animation::New(1.0f);
11595   animation.AnimateTo(Property(renderer, DevelRenderer::Property::OPACITY), 0.5f, TimePeriod(0.5f, 0.5f));
11596   animation.SetLoopCount(3);
11597   animation.Play();
11598
11599   application.SendNotification();
11600
11601   damagedRects.clear();
11602   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11603   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11604
11605   // Delay time
11606   damagedRects.clear();
11607   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11608   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
11609
11610   clippingRect = Rect<int>(0, 784, 32, 32);
11611   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11612
11613   // Started animation
11614   damagedRects.clear();
11615   application.PreRenderWithPartialUpdate(500, nullptr, damagedRects);
11616   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
11617
11618   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11619
11620   // Delay time
11621   damagedRects.clear();
11622   application.PreRenderWithPartialUpdate(500, nullptr, damagedRects);
11623
11624   // The property is reset to base value. Should be updated
11625   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
11626
11627   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11628
11629   // Next render during delay time
11630   damagedRects.clear();
11631   application.PreRenderWithPartialUpdate(50, nullptr, damagedRects);
11632
11633   // Should not be updated
11634   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
11635
11636   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11637
11638   END_TEST;
11639 }
11640
11641 int utcDaliActorPartialUpdateChangeVisibility(void)
11642 {
11643   TestApplication application(
11644     TestApplication::DEFAULT_SURFACE_WIDTH,
11645     TestApplication::DEFAULT_SURFACE_HEIGHT,
11646     TestApplication::DEFAULT_HORIZONTAL_DPI,
11647     TestApplication::DEFAULT_VERTICAL_DPI,
11648     true,
11649     true);
11650
11651   tet_infoline("Check the damaged rect with partial update and visibility change");
11652
11653   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
11654
11655   Actor actor = CreateRenderableActor();
11656   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
11657   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
11658   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
11659   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
11660   application.GetScene().Add(actor);
11661
11662   application.SendNotification();
11663
11664   std::vector<Rect<int>> damagedRects;
11665   Rect<int>              clippingRect;
11666
11667   // 1. Actor added, damaged rect is added size of actor
11668   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11669   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
11670
11671   // Aligned by 16
11672   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
11673   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
11674   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11675   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
11676   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
11677   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
11678   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
11679
11680   damagedRects.clear();
11681   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11682   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11683
11684   // Ensure the damaged rect is empty
11685   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
11686
11687   // 2. Make the Actor invisible
11688   actor.SetProperty(Actor::Property::VISIBLE, false);
11689   application.SendNotification();
11690
11691   damagedRects.clear();
11692   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11693   DALI_TEST_CHECK(damagedRects.size() > 0);
11694   DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
11695
11696   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11697   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
11698   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
11699   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
11700   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
11701
11702   // 3. Make the Actor visible again
11703   actor.SetProperty(Actor::Property::VISIBLE, true);
11704   application.SendNotification();
11705
11706   damagedRects.clear();
11707   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11708   DALI_TEST_CHECK(damagedRects.size() > 0);
11709   DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
11710
11711   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11712   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
11713   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
11714   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
11715   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
11716
11717   END_TEST;
11718 }
11719
11720 int utcDaliActorPartialUpdateOnOffScene(void)
11721 {
11722   TestApplication application(
11723     TestApplication::DEFAULT_SURFACE_WIDTH,
11724     TestApplication::DEFAULT_SURFACE_HEIGHT,
11725     TestApplication::DEFAULT_HORIZONTAL_DPI,
11726     TestApplication::DEFAULT_VERTICAL_DPI,
11727     true,
11728     true);
11729
11730   tet_infoline("Check the damaged rect with partial update and on/off scene");
11731
11732   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
11733
11734   Actor actor = CreateRenderableActor();
11735   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
11736   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
11737   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
11738   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
11739   application.GetScene().Add(actor);
11740
11741   application.SendNotification();
11742
11743   std::vector<Rect<int>> damagedRects;
11744   Rect<int>              clippingRect;
11745
11746   // 1. Actor added, damaged rect is added size of actor
11747   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11748   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
11749
11750   // Aligned by 16
11751   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
11752   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
11753   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11754   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
11755   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
11756   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
11757   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
11758
11759   damagedRects.clear();
11760   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11761   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11762
11763   damagedRects.clear();
11764   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11765   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11766
11767   // Ensure the damaged rect is empty
11768   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
11769
11770   // 2. Remove the Actor from the Scene
11771   actor.Unparent();
11772   application.SendNotification();
11773
11774   damagedRects.clear();
11775   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11776   DALI_TEST_CHECK(damagedRects.size() > 0);
11777   DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
11778
11779   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11780   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
11781   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
11782   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
11783   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
11784
11785   // 3. Add the Actor to the Scene again
11786   application.GetScene().Add(actor);
11787   application.SendNotification();
11788
11789   damagedRects.clear();
11790   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11791   DALI_TEST_CHECK(damagedRects.size() > 0);
11792   DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
11793
11794   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11795   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
11796   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
11797   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
11798   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
11799
11800   END_TEST;
11801 }
11802
11803 int utcDaliActorPartialUpdateSkipRendering(void)
11804 {
11805   TestApplication application(
11806     TestApplication::DEFAULT_SURFACE_WIDTH,
11807     TestApplication::DEFAULT_SURFACE_HEIGHT,
11808     TestApplication::DEFAULT_HORIZONTAL_DPI,
11809     TestApplication::DEFAULT_VERTICAL_DPI,
11810     true,
11811     true);
11812
11813   tet_infoline("Check to skip rendering in case of the empty damaged rect");
11814
11815   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
11816   drawTrace.Enable(true);
11817   drawTrace.Reset();
11818
11819   Actor actor1 = CreateRenderableActor();
11820   actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
11821   actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
11822   application.GetScene().Add(actor1);
11823
11824   std::vector<Rect<int>> damagedRects;
11825   Rect<int>              clippingRect;
11826   Rect<int>              expectedRect1;
11827
11828   application.SendNotification();
11829   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11830
11831   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
11832
11833   // Aligned by 16
11834   expectedRect1 = Rect<int>(0, 720, 96, 96); // in screen coordinates
11835   DirtyRectChecker(damagedRects, {expectedRect1}, true, TEST_LOCATION);
11836
11837   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
11838   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11839
11840   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
11841
11842   damagedRects.clear();
11843   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
11844   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11845   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11846
11847   // Remove the actor
11848   actor1.Unparent();
11849
11850   application.SendNotification();
11851
11852   damagedRects.clear();
11853   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11854
11855   DirtyRectChecker(damagedRects, {expectedRect1}, true, TEST_LOCATION);
11856
11857   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
11858   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11859
11860   // Render again without any change
11861   damagedRects.clear();
11862   drawTrace.Reset();
11863   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11864
11865   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
11866
11867   clippingRect = Rect<int>();
11868   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11869
11870   // Skip rendering
11871   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
11872
11873   // Add the actor again
11874   application.GetScene().Add(actor1);
11875
11876   application.SendNotification();
11877
11878   damagedRects.clear();
11879   drawTrace.Reset();
11880   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11881
11882   DirtyRectChecker(damagedRects, {expectedRect1}, true, TEST_LOCATION);
11883
11884   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
11885   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11886
11887   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
11888
11889   END_TEST;
11890 }
11891
11892 int utcDaliActorPartialUpdate3DNode(void)
11893 {
11894   TestApplication application(
11895     TestApplication::DEFAULT_SURFACE_WIDTH,
11896     TestApplication::DEFAULT_SURFACE_HEIGHT,
11897     TestApplication::DEFAULT_HORIZONTAL_DPI,
11898     TestApplication::DEFAULT_VERTICAL_DPI,
11899     true,
11900     true);
11901
11902   tet_infoline("Partial update should be ignored in case of 3d layer of 3d node");
11903
11904   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
11905   drawTrace.Enable(true);
11906   drawTrace.Reset();
11907
11908   Actor actor1 = CreateRenderableActor();
11909   actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
11910   actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
11911   application.GetScene().Add(actor1);
11912
11913   std::vector<Rect<int>> damagedRects;
11914   Rect<int>              clippingRect;
11915
11916   application.SendNotification();
11917   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11918
11919   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
11920
11921   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
11922   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11923
11924   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
11925
11926   // Change the layer to 3D
11927   application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D);
11928
11929   application.SendNotification();
11930
11931   damagedRects.clear();
11932   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11933
11934   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
11935   DirtyRectChecker(damagedRects, {TestApplication::DEFAULT_SURFACE_RECT}, true, TEST_LOCATION);
11936
11937   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
11938   drawTrace.Reset();
11939   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11940
11941   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
11942
11943   // Change the layer to 2D
11944   application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_UI);
11945
11946   application.SendNotification();
11947
11948   damagedRects.clear();
11949   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11950
11951   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
11952
11953   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
11954   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11955
11956   // Make 3D transform
11957   actor1.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::YAXIS));
11958
11959   application.SendNotification();
11960
11961   damagedRects.clear();
11962   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
11963
11964   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
11965   DirtyRectChecker(damagedRects, {TestApplication::DEFAULT_SURFACE_RECT}, true, TEST_LOCATION);
11966
11967   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
11968   drawTrace.Reset();
11969   application.RenderWithPartialUpdate(damagedRects, clippingRect);
11970
11971   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
11972
11973   END_TEST;
11974 }
11975
11976 int utcDaliActorPartialUpdateNotRenderableActor(void)
11977 {
11978   TestApplication application(
11979     TestApplication::DEFAULT_SURFACE_WIDTH,
11980     TestApplication::DEFAULT_SURFACE_HEIGHT,
11981     TestApplication::DEFAULT_HORIZONTAL_DPI,
11982     TestApplication::DEFAULT_VERTICAL_DPI,
11983     true,
11984     true);
11985
11986   tet_infoline("Check the damaged rect with not renderable parent actor");
11987
11988   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
11989
11990   Actor parent                          = Actor::New();
11991   parent[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11992   parent[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
11993   parent[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
11994   parent.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
11995   application.GetScene().Add(parent);
11996
11997   Actor child                          = CreateRenderableActor();
11998   child[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11999   child[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
12000   child.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
12001   parent.Add(child);
12002
12003   application.SendNotification();
12004
12005   std::vector<Rect<int>> damagedRects;
12006
12007   // 1. Actor added, damaged rect is added size of actor
12008   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12009   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
12010
12011   // Aligned by 16
12012   Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
12013   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
12014
12015   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12016   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
12017   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
12018   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
12019   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
12020
12021   damagedRects.clear();
12022   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12023   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12024
12025   damagedRects.clear();
12026   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12027   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12028
12029   // Ensure the damaged rect is empty
12030   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
12031
12032   END_TEST;
12033 }
12034
12035 int utcDaliActorPartialUpdateChangeTransparency(void)
12036 {
12037   TestApplication application(
12038     TestApplication::DEFAULT_SURFACE_WIDTH,
12039     TestApplication::DEFAULT_SURFACE_HEIGHT,
12040     TestApplication::DEFAULT_HORIZONTAL_DPI,
12041     TestApplication::DEFAULT_VERTICAL_DPI,
12042     true,
12043     true);
12044
12045   tet_infoline("Check the damaged rect with changing transparency");
12046
12047   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
12048
12049   Actor actor                          = CreateRenderableActor();
12050   actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
12051   actor[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
12052   actor[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
12053   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
12054   application.GetScene().Add(actor);
12055
12056   application.SendNotification();
12057
12058   std::vector<Rect<int>> damagedRects;
12059
12060   // Actor added, damaged rect is added size of actor
12061   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12062   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
12063
12064   // Aligned by 16
12065   Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
12066   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
12067
12068   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12069   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
12070   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
12071   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
12072   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
12073
12074   damagedRects.clear();
12075   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12076   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12077
12078   // Ensure the damaged rect is empty
12079   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
12080
12081   // Make the actor transparent by changing opacity of the Renderer
12082   // It changes a uniform value
12083   Renderer renderer                          = actor.GetRendererAt(0);
12084   renderer[DevelRenderer::Property::OPACITY] = 0.0f;
12085
12086   application.SendNotification();
12087
12088   // The damaged rect should be same
12089   damagedRects.clear();
12090   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12091   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
12092   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
12093   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12094
12095   damagedRects.clear();
12096   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12097   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12098
12099   // Ensure the damaged rect is empty
12100   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
12101
12102   // Make the actor opaque again
12103   renderer[DevelRenderer::Property::OPACITY] = 1.0f;
12104
12105   application.SendNotification();
12106
12107   // The damaged rect should not be empty
12108   damagedRects.clear();
12109   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12110   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
12111   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
12112   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12113
12114   damagedRects.clear();
12115   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12116   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12117
12118   // Ensure the damaged rect is empty
12119   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
12120
12121   // Make the actor translucent
12122   renderer[DevelRenderer::Property::OPACITY] = 0.5f;
12123
12124   application.SendNotification();
12125
12126   // The damaged rect should not be empty
12127   damagedRects.clear();
12128   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12129   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
12130   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
12131   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12132
12133   damagedRects.clear();
12134   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12135   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12136
12137   // Ensure the damaged rect is empty
12138   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
12139
12140   // Change Renderer opacity - also translucent
12141   renderer[DevelRenderer::Property::OPACITY] = 0.2f;
12142
12143   application.SendNotification();
12144
12145   // The damaged rect should not be empty
12146   damagedRects.clear();
12147   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12148   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
12149   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
12150   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12151
12152   damagedRects.clear();
12153   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12154   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12155
12156   // Ensure the damaged rect is empty
12157   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
12158
12159   // Make the actor culled
12160   actor[Actor::Property::SIZE] = Vector3(0.0f, 0.0f, 0.0f);
12161
12162   application.SendNotification();
12163
12164   // The damaged rect should be same
12165   damagedRects.clear();
12166   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12167   DALI_TEST_CHECK(damagedRects.size() > 0);
12168   DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
12169   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12170
12171   damagedRects.clear();
12172   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12173   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12174
12175   // Ensure the damaged rect is empty
12176   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
12177
12178   // Make the actor not culled again
12179   actor[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 16.0f);
12180
12181   application.SendNotification();
12182
12183   // The damaged rect should not be empty
12184   damagedRects.clear();
12185   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12186   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
12187   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
12188   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12189
12190   END_TEST;
12191 }
12192
12193 int utcDaliActorPartialUpdateChangeParentOpacity(void)
12194 {
12195   TestApplication application(
12196     TestApplication::DEFAULT_SURFACE_WIDTH,
12197     TestApplication::DEFAULT_SURFACE_HEIGHT,
12198     TestApplication::DEFAULT_HORIZONTAL_DPI,
12199     TestApplication::DEFAULT_VERTICAL_DPI,
12200     true,
12201     true);
12202
12203   tet_infoline("Check the damaged rect with changing parent's opacity");
12204
12205   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
12206
12207   Actor parent                          = Actor::New();
12208   parent[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
12209   parent[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
12210   parent[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
12211   parent.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
12212   application.GetScene().Add(parent);
12213
12214   Texture texture                      = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
12215   Actor   child                        = CreateRenderableActor(texture);
12216   child[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
12217   child[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
12218   child.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
12219   parent.Add(child);
12220
12221   application.SendNotification();
12222
12223   std::vector<Rect<int>> damagedRects;
12224
12225   // Actor added, damaged rect is added size of actor
12226   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12227   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
12228
12229   // Aligned by 16
12230   Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
12231   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
12232
12233   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12234   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
12235   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
12236   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
12237   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
12238
12239   damagedRects.clear();
12240   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12241   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12242
12243   damagedRects.clear();
12244   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12245   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12246
12247   // Ensure the damaged rect is empty
12248   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
12249
12250   // Change the parent's opacity
12251   parent[Actor::Property::OPACITY] = 0.5f;
12252
12253   application.SendNotification();
12254
12255   // The damaged rect should be same
12256   damagedRects.clear();
12257   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12258   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12259   DALI_TEST_CHECK(damagedRects.size() > 0);
12260   DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
12261
12262   END_TEST;
12263 }
12264
12265 int utcDaliActorPartialUpdateAddRemoveRenderer(void)
12266 {
12267   TestApplication application(
12268     TestApplication::DEFAULT_SURFACE_WIDTH,
12269     TestApplication::DEFAULT_SURFACE_HEIGHT,
12270     TestApplication::DEFAULT_HORIZONTAL_DPI,
12271     TestApplication::DEFAULT_VERTICAL_DPI,
12272     true,
12273     true);
12274
12275   tet_infoline("Check the damaged rect with adding / removing renderer");
12276
12277   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
12278
12279   Actor actor                          = CreateRenderableActor();
12280   actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
12281   actor[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
12282   actor[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
12283   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
12284   application.GetScene().Add(actor);
12285
12286   application.SendNotification();
12287
12288   std::vector<Rect<int>> damagedRects;
12289
12290   // Actor added, damaged rect is added size of actor
12291   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12292   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
12293
12294   // Aligned by 16
12295   Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
12296   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
12297
12298   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12299   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
12300   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
12301   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
12302   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
12303
12304   damagedRects.clear();
12305   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12306   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12307
12308   damagedRects.clear();
12309   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12310   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12311
12312   // Remove the Renderer
12313   Renderer renderer = actor.GetRendererAt(0);
12314   actor.RemoveRenderer(renderer);
12315
12316   application.SendNotification();
12317
12318   // The damaged rect should be the actor area
12319   damagedRects.clear();
12320   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12321   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12322   DALI_TEST_CHECK(damagedRects.size() > 0);
12323   DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
12324
12325   damagedRects.clear();
12326   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12327   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12328
12329   // Ensure the damaged rect is empty
12330   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
12331
12332   // Add the Renderer again
12333   actor.AddRenderer(renderer);
12334
12335   application.SendNotification();
12336
12337   // The damaged rect should be the actor area
12338   damagedRects.clear();
12339   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12340   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12341   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
12342   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
12343
12344   END_TEST;
12345 }
12346
12347 int utcDaliActorPartialUpdate3DTransform(void)
12348 {
12349   TestApplication application(
12350     TestApplication::DEFAULT_SURFACE_WIDTH,
12351     TestApplication::DEFAULT_SURFACE_HEIGHT,
12352     TestApplication::DEFAULT_HORIZONTAL_DPI,
12353     TestApplication::DEFAULT_VERTICAL_DPI,
12354     true,
12355     true);
12356
12357   tet_infoline("Check the damaged rect with 3D transformed actors");
12358
12359   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
12360
12361   Actor actor1                          = CreateRenderableActor();
12362   actor1[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
12363   actor1[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
12364   actor1[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
12365   actor1.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
12366   application.GetScene().Add(actor1);
12367
12368   // Add a new actor
12369   Actor actor2                          = CreateRenderableActor();
12370   actor2[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
12371   actor2[Actor::Property::POSITION]     = Vector3(160.0f, 160.0f, 0.0f);
12372   actor2[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
12373   actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
12374   application.GetScene().Add(actor2);
12375
12376   application.SendNotification();
12377
12378   std::vector<Rect<int>> damagedRects;
12379
12380   // Actor added, damaged rect is added size of actor
12381   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12382   DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
12383
12384   // Aligned by 16
12385   Rect<int> clippingRect1 = Rect<int>(16, 768, 32, 32); // in screen coordinates
12386   Rect<int> clippingRect2 = Rect<int>(160, 624, 32, 32);
12387   DirtyRectChecker(damagedRects, {clippingRect1, clippingRect2}, true, TEST_LOCATION);
12388
12389   Rect<int> surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
12390   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
12391
12392   damagedRects.clear();
12393   surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
12394   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12395   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
12396
12397   damagedRects.clear();
12398   surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
12399   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12400   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
12401
12402   // Rotate actor1 on y axis
12403   actor1[Actor::Property::ORIENTATION] = Quaternion(Radian(Degree(90.0)), Vector3::YAXIS);
12404
12405   // Remove actor2
12406   actor2.Unparent();
12407
12408   application.SendNotification();
12409
12410   damagedRects.clear();
12411   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12412
12413   // Should update full area
12414   surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
12415   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
12416   DirtyRectChecker(damagedRects, {surfaceRect}, true, TEST_LOCATION);
12417   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
12418
12419   // Add actor2 again
12420   application.GetScene().Add(actor2);
12421
12422   application.SendNotification();
12423
12424   damagedRects.clear();
12425   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12426
12427   // Should update full area
12428   surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
12429   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
12430   DirtyRectChecker(damagedRects, {surfaceRect}, true, TEST_LOCATION);
12431   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
12432
12433   // Reset the orientation of actor1
12434   actor1[Actor::Property::ORIENTATION] = Quaternion::IDENTITY;
12435
12436   application.SendNotification();
12437
12438   damagedRects.clear();
12439   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12440
12441   // Should update full area
12442   surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
12443   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
12444   DirtyRectChecker(damagedRects, {surfaceRect}, true, TEST_LOCATION);
12445   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
12446
12447   // Make actor2 dirty
12448   actor2[Actor::Property::SIZE] = Vector3(32.0f, 32.0f, 0.0f);
12449
12450   application.SendNotification();
12451
12452   damagedRects.clear();
12453   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12454
12455   clippingRect2 = Rect<int>(160, 608, 48, 48);
12456   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
12457   DirtyRectChecker(damagedRects, {clippingRect2}, true, TEST_LOCATION);
12458
12459   application.RenderWithPartialUpdate(damagedRects, clippingRect2);
12460   DALI_TEST_EQUALS(clippingRect2.x, glScissorParams.x, TEST_LOCATION);
12461   DALI_TEST_EQUALS(clippingRect2.y, glScissorParams.y, TEST_LOCATION);
12462   DALI_TEST_EQUALS(clippingRect2.width, glScissorParams.width, TEST_LOCATION);
12463   DALI_TEST_EQUALS(clippingRect2.height, glScissorParams.height, TEST_LOCATION);
12464
12465   // Remove actor1
12466   actor1.Unparent();
12467
12468   application.SendNotification();
12469
12470   damagedRects.clear();
12471   surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
12472   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12473   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
12474
12475   // Rotate actor1 on y axis
12476   actor1[Actor::Property::ORIENTATION] = Quaternion(Radian(Degree(90.0)), Vector3::YAXIS);
12477
12478   // Add actor1 again
12479   application.GetScene().Add(actor1);
12480
12481   application.SendNotification();
12482
12483   damagedRects.clear();
12484   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12485
12486   // Should update full area
12487   surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
12488   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
12489   DirtyRectChecker(damagedRects, {surfaceRect}, true, TEST_LOCATION);
12490   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
12491
12492   END_TEST;
12493 }
12494
12495 int utcDaliActorPartialUpdateOneActorMultipleRenderers(void)
12496 {
12497   TestApplication application(
12498     TestApplication::DEFAULT_SURFACE_WIDTH,
12499     TestApplication::DEFAULT_SURFACE_HEIGHT,
12500     TestApplication::DEFAULT_HORIZONTAL_DPI,
12501     TestApplication::DEFAULT_VERTICAL_DPI,
12502     true,
12503     true);
12504
12505   tet_infoline("Check the damaged rect with one actor which has multiple renderers");
12506
12507   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
12508
12509   Actor actor = CreateRenderableActor();
12510
12511   // Create another renderer
12512   Geometry geometry  = CreateQuadGeometry();
12513   Shader   shader    = CreateShader();
12514   Renderer renderer2 = Renderer::New(geometry, shader);
12515   actor.AddRenderer(renderer2);
12516
12517   actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
12518   actor[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
12519   actor[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
12520   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
12521   application.GetScene().Add(actor);
12522
12523   application.SendNotification();
12524
12525   DALI_TEST_EQUALS(actor.GetRendererCount(), 2u, TEST_LOCATION);
12526
12527   std::vector<Rect<int>> damagedRects;
12528
12529   // Actor added, damaged rect is added size of actor
12530   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12531   DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
12532
12533   // Aligned by 16
12534   Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
12535   DirtyRectChecker(damagedRects, {clippingRect, clippingRect}, true, TEST_LOCATION);
12536
12537   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12538   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
12539   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
12540   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
12541   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
12542
12543   damagedRects.clear();
12544   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12545   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12546
12547   // Ensure the damaged rect is empty
12548   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
12549
12550   // Make renderer2 dirty
12551   renderer2[DevelRenderer::Property::OPACITY] = 0.5f;
12552
12553   application.SendNotification();
12554
12555   // The damaged rect should be the actor area
12556   damagedRects.clear();
12557   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12558
12559   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
12560   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
12561   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
12562
12563   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12564
12565   damagedRects.clear();
12566   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12567   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12568
12569   // Ensure the damaged rect is empty
12570   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
12571
12572   // Make renderer2 dirty
12573   renderer2[Renderer::Property::FACE_CULLING_MODE] = FaceCullingMode::BACK;
12574
12575   application.SendNotification();
12576
12577   // The damaged rect should be the actor area
12578   damagedRects.clear();
12579   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12580
12581   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
12582   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
12583   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
12584
12585   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12586
12587   damagedRects.clear();
12588   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12589   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12590
12591   // Ensure the damaged rect is empty
12592   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
12593
12594   END_TEST;
12595 }
12596
12597 int utcDaliActorPartialUpdateMultipleActorsOneRenderer(void)
12598 {
12599   TestApplication application(
12600     TestApplication::DEFAULT_SURFACE_WIDTH,
12601     TestApplication::DEFAULT_SURFACE_HEIGHT,
12602     TestApplication::DEFAULT_HORIZONTAL_DPI,
12603     TestApplication::DEFAULT_VERTICAL_DPI,
12604     true,
12605     true);
12606
12607   tet_infoline("Check the damaged rect with multiple actors which share a same renderer");
12608
12609   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
12610
12611   Actor actor                          = CreateRenderableActor();
12612   actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
12613   actor[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
12614   actor[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
12615   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
12616   application.GetScene().Add(actor);
12617
12618   // Create another actor which has the same renderer with actor1
12619   Actor    actor2   = Actor::New();
12620   Renderer renderer = actor.GetRendererAt(0);
12621   actor2.AddRenderer(renderer);
12622   actor2[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
12623   actor2[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
12624   actor2[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
12625   actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
12626   application.GetScene().Add(actor2);
12627
12628   application.SendNotification();
12629
12630   std::vector<Rect<int>> damagedRects;
12631
12632   // Actor added, damaged rect is added size of actor
12633   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12634   DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
12635
12636   // Aligned by 16
12637   Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
12638   DirtyRectChecker(damagedRects, {clippingRect, clippingRect}, true, TEST_LOCATION);
12639
12640   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12641   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
12642   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
12643   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
12644   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
12645
12646   damagedRects.clear();
12647   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12648   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12649
12650   // Ensure the damaged rect is empty
12651   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
12652
12653   // Make renderer dirty
12654   renderer[DevelRenderer::Property::OPACITY] = 0.5f;
12655
12656   application.SendNotification();
12657
12658   // The damaged rect should be the actor area
12659   damagedRects.clear();
12660   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12661
12662   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
12663   DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
12664   DirtyRectChecker(damagedRects, {clippingRect, clippingRect}, true, TEST_LOCATION);
12665
12666   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12667
12668   damagedRects.clear();
12669   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12670   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12671
12672   // Ensure the damaged rect is empty
12673   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
12674
12675   END_TEST;
12676 }
12677
12678 int utcDaliActorPartialUpdateUseTextureUpdateArea01(void)
12679 {
12680   TestApplication application(
12681     TestApplication::DEFAULT_SURFACE_WIDTH,
12682     TestApplication::DEFAULT_SURFACE_HEIGHT,
12683     TestApplication::DEFAULT_HORIZONTAL_DPI,
12684     TestApplication::DEFAULT_VERTICAL_DPI,
12685     true,
12686     true);
12687
12688   tet_infoline("Check the damaged rect with USE_TEXTURE_UPDATE_AREA property");
12689
12690   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
12691
12692   Actor actor                              = CreateRenderableActor();
12693   actor[Actor::Property::ANCHOR_POINT]     = AnchorPoint::TOP_LEFT;
12694   actor[Actor::Property::POSITION]         = Vector3(0.0f, 0.0f, 0.0f);
12695   actor[Actor::Property::SIZE]             = Vector3(64.0f, 64.0f, 0.0f);
12696   actor[Actor::Property::UPDATE_AREA_HINT] = Vector4(0.0f, 0.0f, 32.0f, 32.0f);
12697   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
12698
12699   // Create a native image source.
12700   TestNativeImagePointer testNativeImage = TestNativeImage::New(64u, 64u);
12701   Texture                texture         = Texture::New(*testNativeImage);
12702   TextureSet             textureSet      = TextureSet::New();
12703   textureSet.SetTexture(0u, texture);
12704   actor.GetRendererAt(0).SetTextures(textureSet);
12705
12706   application.GetScene().Add(actor);
12707
12708   application.SendNotification();
12709
12710   std::vector<Rect<int>> damagedRects;
12711
12712   // Actor added, damaged rect is added size of actor
12713   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12714   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
12715
12716   // Aligned by 16
12717   Rect<int> clippingRect = Rect<int>(16, 752, 48, 48); // in screen coordinates
12718   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
12719
12720   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12721   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
12722   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
12723   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
12724   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
12725
12726   // Set USE_TEXTURE_UPDATE_AREA
12727   actor[DevelActor::Property::USE_TEXTURE_UPDATE_AREA] = true;
12728
12729   // Set updated area of native image
12730   testNativeImage->SetUpdatedArea(Rect<uint32_t>(16, 16, 48, 48));
12731
12732   DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::USE_TEXTURE_UPDATE_AREA).Get<bool>(), true, TEST_LOCATION);
12733   DALI_TEST_EQUALS(actor.GetCurrentProperty(DevelActor::Property::USE_TEXTURE_UPDATE_AREA).Get<bool>(), false, TEST_LOCATION);
12734
12735   application.SendNotification();
12736
12737   damagedRects.clear();
12738   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12739   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12740   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
12741
12742   // Aligned by 16
12743   clippingRect = Rect<int>(16, 736, 64, 64); // in screen coordinates
12744   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
12745
12746   DALI_TEST_EQUALS(actor.GetCurrentProperty(DevelActor::Property::USE_TEXTURE_UPDATE_AREA).Get<bool>(), true, TEST_LOCATION);
12747
12748   END_TEST;
12749 }
12750
12751 int utcDaliActorPartialUpdateUseTextureUpdateArea02(void)
12752 {
12753   TestApplication application(
12754     TestApplication::DEFAULT_SURFACE_WIDTH,
12755     TestApplication::DEFAULT_SURFACE_HEIGHT,
12756     TestApplication::DEFAULT_HORIZONTAL_DPI,
12757     TestApplication::DEFAULT_VERTICAL_DPI,
12758     true,
12759     true);
12760
12761   tet_infoline("Check the damaged rect with USE_TEXTURE_UPDATE_AREA property and multiple native textures");
12762
12763   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
12764
12765   Actor actor                              = CreateRenderableActor();
12766   actor[Actor::Property::ANCHOR_POINT]     = AnchorPoint::TOP_LEFT;
12767   actor[Actor::Property::POSITION]         = Vector3(0.0f, 0.0f, 0.0f);
12768   actor[Actor::Property::SIZE]             = Vector3(64.0f, 64.0f, 0.0f);
12769   actor[Actor::Property::UPDATE_AREA_HINT] = Vector4(0.0f, 0.0f, 32.0f, 32.0f);
12770   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
12771
12772   // Create a native image source.
12773   TestNativeImagePointer testNativeImage1 = TestNativeImage::New(64u, 64u);
12774   Texture                texture1         = Texture::New(*testNativeImage1);
12775   TestNativeImagePointer testNativeImage2 = TestNativeImage::New(64u, 64u);
12776   Texture                texture2         = Texture::New(*testNativeImage2);
12777
12778   TextureSet textureSet = TextureSet::New();
12779   textureSet.SetTexture(0u, texture1);
12780   textureSet.SetTexture(1u, texture2);
12781   actor.GetRendererAt(0).SetTextures(textureSet);
12782
12783   application.GetScene().Add(actor);
12784
12785   application.SendNotification();
12786
12787   std::vector<Rect<int>> damagedRects;
12788
12789   // Actor added, damaged rect is added size of actor
12790   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12791   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
12792
12793   // Aligned by 16
12794   Rect<int> clippingRect = Rect<int>(16, 752, 48, 48); // in screen coordinates
12795   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
12796
12797   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12798   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
12799   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
12800   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
12801   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
12802
12803   // Set USE_TEXTURE_UPDATE_AREA
12804   actor[DevelActor::Property::USE_TEXTURE_UPDATE_AREA] = true;
12805
12806   // Set updated area of native image
12807   testNativeImage1->SetUpdatedArea(Rect<uint32_t>(0, 0, 32, 32));
12808   testNativeImage2->SetUpdatedArea(Rect<uint32_t>(32, 0, 32, 32));
12809
12810   DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::USE_TEXTURE_UPDATE_AREA).Get<bool>(), true, TEST_LOCATION);
12811   DALI_TEST_EQUALS(actor.GetCurrentProperty(DevelActor::Property::USE_TEXTURE_UPDATE_AREA).Get<bool>(), false, TEST_LOCATION);
12812
12813   application.SendNotification();
12814
12815   damagedRects.clear();
12816   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12817   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12818   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
12819
12820   // Aligned by 16
12821   clippingRect = Rect<int>(0, 752, 80, 64); // in screen coordinates
12822   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
12823
12824   DALI_TEST_EQUALS(actor.GetCurrentProperty(DevelActor::Property::USE_TEXTURE_UPDATE_AREA).Get<bool>(), true, TEST_LOCATION);
12825
12826   END_TEST;
12827 }
12828
12829 int utcDaliActorPartialUpdateUseTextureUpdateArea03(void)
12830 {
12831   TestApplication application(
12832     TestApplication::DEFAULT_SURFACE_WIDTH,
12833     TestApplication::DEFAULT_SURFACE_HEIGHT,
12834     TestApplication::DEFAULT_HORIZONTAL_DPI,
12835     TestApplication::DEFAULT_VERTICAL_DPI,
12836     true,
12837     true);
12838
12839   tet_infoline("Check the damaged rect with USE_TEXTURE_UPDATE_AREA property and multiple normal textures");
12840
12841   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
12842
12843   uint32_t width = 64, height = 64;
12844
12845   Texture texture1 = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, width, height);
12846   Texture texture2 = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, width, height);
12847   Actor   actor    = CreateRenderableActor(texture1);
12848   actor.GetRendererAt(0).GetTextures().SetTexture(1u, texture2);
12849
12850   actor[Actor::Property::ANCHOR_POINT]     = AnchorPoint::TOP_LEFT;
12851   actor[Actor::Property::POSITION]         = Vector3(0.0f, 0.0f, 0.0f);
12852   actor[Actor::Property::SIZE]             = Vector3(64.0f, 64.0f, 0.0f);
12853   actor[Actor::Property::UPDATE_AREA_HINT] = Vector4(0.0f, 0.0f, 32.0f, 32.0f);
12854   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
12855
12856   application.GetScene().Add(actor);
12857
12858   application.SendNotification();
12859
12860   std::vector<Rect<int>> damagedRects;
12861
12862   // Actor added, damaged rect is added size of actor
12863   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12864   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
12865
12866   // Aligned by 16
12867   Rect<int> clippingRect = Rect<int>(16, 752, 48, 48); // in screen coordinates
12868   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
12869
12870   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12871   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
12872   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
12873   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
12874   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
12875
12876   // Set USE_TEXTURE_UPDATE_AREA
12877   actor[DevelActor::Property::USE_TEXTURE_UPDATE_AREA] = true;
12878
12879   int       bufferSize = width * height * 4;
12880   uint8_t*  buffer     = reinterpret_cast<uint8_t*>(malloc(bufferSize));
12881   PixelData pixelData  = PixelData::New(buffer, bufferSize, width, height, Pixel::Format::RGBA8888, PixelData::FREE);
12882
12883   // Update textures
12884   texture1.Upload(pixelData, 0u, 0u, 0u, 0u, 32u, 32u);
12885   texture2.Upload(pixelData, 0u, 0u, 32u, 0u, 32u, 32u);
12886
12887   DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::USE_TEXTURE_UPDATE_AREA).Get<bool>(), true, TEST_LOCATION);
12888   DALI_TEST_EQUALS(actor.GetCurrentProperty(DevelActor::Property::USE_TEXTURE_UPDATE_AREA).Get<bool>(), false, TEST_LOCATION);
12889
12890   application.SendNotification();
12891
12892   damagedRects.clear();
12893   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12894   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12895   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
12896
12897   // Aligned by 16
12898   clippingRect = Rect<int>(0, 752, 80, 64); // in screen coordinates
12899   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
12900
12901   DALI_TEST_EQUALS(actor.GetCurrentProperty(DevelActor::Property::USE_TEXTURE_UPDATE_AREA).Get<bool>(), true, TEST_LOCATION);
12902
12903   // Update full area of the texture
12904   texture1.Upload(pixelData);
12905
12906   application.SendNotification();
12907
12908   damagedRects.clear();
12909   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
12910   application.RenderWithPartialUpdate(damagedRects, clippingRect);
12911   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
12912
12913   // Aligned by 16
12914   clippingRect = Rect<int>(0, 736, 80, 80); // in screen coordinates
12915   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
12916
12917   END_TEST;
12918 }
12919
12920 int UtcDaliActorCaptureAllTouchAfterStartPropertyP(void)
12921 {
12922   TestApplication application;
12923
12924   Actor actor = Actor::New();
12925   DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), false, TEST_LOCATION);
12926   actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, true);
12927   DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), true, TEST_LOCATION);
12928   DALI_TEST_EQUALS(actor.GetPropertyType(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), Property::BOOLEAN, TEST_LOCATION);
12929   DALI_TEST_EQUALS(actor.IsPropertyWritable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), true, TEST_LOCATION);
12930   DALI_TEST_EQUALS(actor.IsPropertyAnimatable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
12931   DALI_TEST_EQUALS(actor.IsPropertyAConstraintInput(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
12932   DALI_TEST_EQUALS(actor.GetPropertyName(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), "captureAllTouchAfterStart", TEST_LOCATION);
12933   END_TEST;
12934 }
12935
12936 int UtcDaliActorCaptureAllTouchAfterStartPropertyN(void)
12937 {
12938   TestApplication application;
12939
12940   Actor actor = Actor::New();
12941
12942   // Make sure setting invalid types does not cause a crash
12943   try
12944   {
12945     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, 1.0f);
12946     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector2::ONE);
12947     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector3::ONE);
12948     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector4::ONE);
12949     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Map());
12950     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Array());
12951     tet_result(TET_PASS);
12952   }
12953   catch(...)
12954   {
12955     tet_result(TET_FAIL);
12956   }
12957   END_TEST;
12958 }
12959
12960 int UtcDaliActorTouchAreaOffsetPropertyP(void)
12961 {
12962   TestApplication application;
12963
12964   Actor     actor           = Actor::New();
12965   Rect<int> touchAreaOffset = actor.GetProperty(DevelActor::Property::TOUCH_AREA_OFFSET).Get<Rect<int>>();
12966   DALI_TEST_EQUALS(Rect<int>(0, 0, 0, 0), touchAreaOffset, TEST_LOCATION);
12967   actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Rect<int>(10, 20, 30, 40));
12968   touchAreaOffset = actor.GetProperty(DevelActor::Property::TOUCH_AREA_OFFSET).Get<Rect<int>>();
12969   DALI_TEST_EQUALS(Rect<int>(10, 20, 30, 40), touchAreaOffset, TEST_LOCATION);
12970   END_TEST;
12971 }
12972
12973 int UtcDaliActorTouchAreaOffsetPropertyN(void)
12974 {
12975   TestApplication application;
12976
12977   Actor actor = Actor::New();
12978
12979   // Make sure setting invalid types does not cause a crash
12980   try
12981   {
12982     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, 1.0f);
12983     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector2::ONE);
12984     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector3::ONE);
12985     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector4::ONE);
12986     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Property::Map());
12987     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Property::Array());
12988     tet_result(TET_PASS);
12989   }
12990   catch(...)
12991   {
12992     tet_result(TET_FAIL);
12993   }
12994   END_TEST;
12995 }
12996
12997 int UtcDaliActorLowerBelowNegative(void)
12998 {
12999   TestApplication application;
13000   Dali::Actor     instance;
13001   try
13002   {
13003     Dali::Actor arg1;
13004     instance.LowerBelow(arg1);
13005     DALI_TEST_CHECK(false); // Should not get here
13006   }
13007   catch(...)
13008   {
13009     DALI_TEST_CHECK(true); // We expect an assert
13010   }
13011   END_TEST;
13012 }
13013
13014 int UtcDaliActorRaiseAboveNegative(void)
13015 {
13016   TestApplication application;
13017   Dali::Actor     instance;
13018   try
13019   {
13020     Dali::Actor arg1;
13021     instance.RaiseAbove(arg1);
13022     DALI_TEST_CHECK(false); // Should not get here
13023   }
13024   catch(...)
13025   {
13026     DALI_TEST_CHECK(true); // We expect an assert
13027   }
13028   END_TEST;
13029 }
13030
13031 int UtcDaliActorRaiseToTopNegative(void)
13032 {
13033   TestApplication application;
13034   Dali::Actor     instance;
13035   try
13036   {
13037     instance.RaiseToTop();
13038     DALI_TEST_CHECK(false); // Should not get here
13039   }
13040   catch(...)
13041   {
13042     DALI_TEST_CHECK(true); // We expect an assert
13043   }
13044   END_TEST;
13045 }
13046
13047 int UtcDaliActorAddRendererNegative(void)
13048 {
13049   TestApplication application;
13050   Dali::Actor     instance;
13051   try
13052   {
13053     Dali::Renderer arg1;
13054     instance.AddRenderer(arg1);
13055     DALI_TEST_CHECK(false); // Should not get here
13056   }
13057   catch(...)
13058   {
13059     DALI_TEST_CHECK(true); // We expect an assert
13060   }
13061   END_TEST;
13062 }
13063
13064 int UtcDaliActorTouchedSignalNegative(void)
13065 {
13066   TestApplication application;
13067   Dali::Actor     instance;
13068   try
13069   {
13070     instance.TouchedSignal();
13071     DALI_TEST_CHECK(false); // Should not get here
13072   }
13073   catch(...)
13074   {
13075     DALI_TEST_CHECK(true); // We expect an assert
13076   }
13077   END_TEST;
13078 }
13079
13080 int UtcDaliActorTranslateByNegative(void)
13081 {
13082   TestApplication application;
13083   Dali::Actor     instance;
13084   try
13085   {
13086     Dali::Vector3 arg1;
13087     instance.TranslateBy(arg1);
13088     DALI_TEST_CHECK(false); // Should not get here
13089   }
13090   catch(...)
13091   {
13092     DALI_TEST_CHECK(true); // We expect an assert
13093   }
13094   END_TEST;
13095 }
13096
13097 int UtcDaliActorFindChildByIdNegative(void)
13098 {
13099   TestApplication application;
13100   Dali::Actor     instance;
13101   try
13102   {
13103     unsigned int arg1 = 0u;
13104     instance.FindChildById(arg1);
13105     DALI_TEST_CHECK(false); // Should not get here
13106   }
13107   catch(...)
13108   {
13109     DALI_TEST_CHECK(true); // We expect an assert
13110   }
13111   END_TEST;
13112 }
13113
13114 int UtcDaliActorGetRendererAtNegative(void)
13115 {
13116   TestApplication application;
13117   Dali::Actor     instance;
13118   try
13119   {
13120     unsigned int arg1 = 0u;
13121     instance.GetRendererAt(arg1);
13122     DALI_TEST_CHECK(false); // Should not get here
13123   }
13124   catch(...)
13125   {
13126     DALI_TEST_CHECK(true); // We expect an assert
13127   }
13128   END_TEST;
13129 }
13130
13131 int UtcDaliActorHoveredSignalNegative(void)
13132 {
13133   TestApplication application;
13134   Dali::Actor     instance;
13135   try
13136   {
13137     instance.HoveredSignal();
13138     DALI_TEST_CHECK(false); // Should not get here
13139   }
13140   catch(...)
13141   {
13142     DALI_TEST_CHECK(true); // We expect an assert
13143   }
13144   END_TEST;
13145 }
13146
13147 int UtcDaliActorLowerToBottomNegative(void)
13148 {
13149   TestApplication application;
13150   Dali::Actor     instance;
13151   try
13152   {
13153     instance.LowerToBottom();
13154     DALI_TEST_CHECK(false); // Should not get here
13155   }
13156   catch(...)
13157   {
13158     DALI_TEST_CHECK(true); // We expect an assert
13159   }
13160   END_TEST;
13161 }
13162
13163 int UtcDaliActorOnSceneSignalNegative(void)
13164 {
13165   TestApplication application;
13166   Dali::Actor     instance;
13167   try
13168   {
13169     instance.OnSceneSignal();
13170     DALI_TEST_CHECK(false); // Should not get here
13171   }
13172   catch(...)
13173   {
13174     DALI_TEST_CHECK(true); // We expect an assert
13175   }
13176   END_TEST;
13177 }
13178
13179 int UtcDaliActorOffSceneSignalNegative(void)
13180 {
13181   TestApplication application;
13182   Dali::Actor     instance;
13183   try
13184   {
13185     instance.OffSceneSignal();
13186     DALI_TEST_CHECK(false); // Should not get here
13187   }
13188   catch(...)
13189   {
13190     DALI_TEST_CHECK(true); // We expect an assert
13191   }
13192   END_TEST;
13193 }
13194
13195 int UtcDaliActorRemoveRendererNegative01(void)
13196 {
13197   TestApplication application;
13198   Dali::Actor     instance;
13199   try
13200   {
13201     unsigned int arg1 = 0u;
13202     instance.RemoveRenderer(arg1);
13203     DALI_TEST_CHECK(false); // Should not get here
13204   }
13205   catch(...)
13206   {
13207     DALI_TEST_CHECK(true); // We expect an assert
13208   }
13209   END_TEST;
13210 }
13211
13212 int UtcDaliActorRemoveRendererNegative02(void)
13213 {
13214   TestApplication application;
13215   Dali::Actor     instance;
13216   try
13217   {
13218     Dali::Renderer arg1;
13219     instance.RemoveRenderer(arg1);
13220     DALI_TEST_CHECK(false); // Should not get here
13221   }
13222   catch(...)
13223   {
13224     DALI_TEST_CHECK(true); // We expect an assert
13225   }
13226   END_TEST;
13227 }
13228
13229 int UtcDaliActorFindChildByNameNegative(void)
13230 {
13231   TestApplication application;
13232   Dali::Actor     instance;
13233   try
13234   {
13235     std::string arg1;
13236     instance.FindChildByName(arg1);
13237     DALI_TEST_CHECK(false); // Should not get here
13238   }
13239   catch(...)
13240   {
13241     DALI_TEST_CHECK(true); // We expect an assert
13242   }
13243   END_TEST;
13244 }
13245
13246 int UtcDaliActorSetResizePolicyNegative(void)
13247 {
13248   TestApplication application;
13249   Dali::Actor     instance;
13250   try
13251   {
13252     Dali::ResizePolicy::Type arg1 = ResizePolicy::USE_NATURAL_SIZE;
13253     Dali::Dimension::Type    arg2 = Dimension::ALL_DIMENSIONS;
13254     instance.SetResizePolicy(arg1, arg2);
13255     DALI_TEST_CHECK(false); // Should not get here
13256   }
13257   catch(...)
13258   {
13259     DALI_TEST_CHECK(true); // We expect an assert
13260   }
13261   END_TEST;
13262 }
13263
13264 int UtcDaliActorOnRelayoutSignalNegative(void)
13265 {
13266   TestApplication application;
13267   Dali::Actor     instance;
13268   try
13269   {
13270     instance.OnRelayoutSignal();
13271     DALI_TEST_CHECK(false); // Should not get here
13272   }
13273   catch(...)
13274   {
13275     DALI_TEST_CHECK(true); // We expect an assert
13276   }
13277   END_TEST;
13278 }
13279
13280 int UtcDaliActorWheelEventSignalNegative(void)
13281 {
13282   TestApplication application;
13283   Dali::Actor     instance;
13284   try
13285   {
13286     instance.WheelEventSignal();
13287     DALI_TEST_CHECK(false); // Should not get here
13288   }
13289   catch(...)
13290   {
13291     DALI_TEST_CHECK(true); // We expect an assert
13292   }
13293   END_TEST;
13294 }
13295
13296 int UtcDaliActorGetHeightForWidthNegative(void)
13297 {
13298   TestApplication application;
13299   Dali::Actor     instance;
13300   try
13301   {
13302     float arg1 = 0.0f;
13303     instance.GetHeightForWidth(arg1);
13304     DALI_TEST_CHECK(false); // Should not get here
13305   }
13306   catch(...)
13307   {
13308     DALI_TEST_CHECK(true); // We expect an assert
13309   }
13310   END_TEST;
13311 }
13312
13313 int UtcDaliActorGetWidthForHeightNegative(void)
13314 {
13315   TestApplication application;
13316   Dali::Actor     instance;
13317   try
13318   {
13319     float arg1 = 0.0f;
13320     instance.GetWidthForHeight(arg1);
13321     DALI_TEST_CHECK(false); // Should not get here
13322   }
13323   catch(...)
13324   {
13325     DALI_TEST_CHECK(true); // We expect an assert
13326   }
13327   END_TEST;
13328 }
13329
13330 int UtcDaliActorLayoutDirectionChangedSignalNegative(void)
13331 {
13332   TestApplication application;
13333   Dali::Actor     instance;
13334   try
13335   {
13336     instance.LayoutDirectionChangedSignal();
13337     DALI_TEST_CHECK(false); // Should not get here
13338   }
13339   catch(...)
13340   {
13341     DALI_TEST_CHECK(true); // We expect an assert
13342   }
13343   END_TEST;
13344 }
13345
13346 int UtcDaliActorAddNegative(void)
13347 {
13348   TestApplication application;
13349   Dali::Actor     instance;
13350   try
13351   {
13352     Dali::Actor arg1;
13353     instance.Add(arg1);
13354     DALI_TEST_CHECK(false); // Should not get here
13355   }
13356   catch(...)
13357   {
13358     DALI_TEST_CHECK(true); // We expect an assert
13359   }
13360   END_TEST;
13361 }
13362
13363 int UtcDaliActorLowerNegative(void)
13364 {
13365   TestApplication application;
13366   Dali::Actor     instance;
13367   try
13368   {
13369     instance.Lower();
13370     DALI_TEST_CHECK(false); // Should not get here
13371   }
13372   catch(...)
13373   {
13374     DALI_TEST_CHECK(true); // We expect an assert
13375   }
13376   END_TEST;
13377 }
13378
13379 int UtcDaliActorRaiseNegative(void)
13380 {
13381   TestApplication application;
13382   Dali::Actor     instance;
13383   try
13384   {
13385     instance.Raise();
13386     DALI_TEST_CHECK(false); // Should not get here
13387   }
13388   catch(...)
13389   {
13390     DALI_TEST_CHECK(true); // We expect an assert
13391   }
13392   END_TEST;
13393 }
13394
13395 int UtcDaliActorRemoveNegative(void)
13396 {
13397   TestApplication application;
13398   Dali::Actor     instance;
13399   try
13400   {
13401     Dali::Actor arg1;
13402     instance.Remove(arg1);
13403     DALI_TEST_CHECK(false); // Should not get here
13404   }
13405   catch(...)
13406   {
13407     DALI_TEST_CHECK(true); // We expect an assert
13408   }
13409   END_TEST;
13410 }
13411
13412 int UtcDaliActorScaleByNegative(void)
13413 {
13414   TestApplication application;
13415   Dali::Actor     instance;
13416   try
13417   {
13418     Dali::Vector3 arg1;
13419     instance.ScaleBy(arg1);
13420     DALI_TEST_CHECK(false); // Should not get here
13421   }
13422   catch(...)
13423   {
13424     DALI_TEST_CHECK(true); // We expect an assert
13425   }
13426   END_TEST;
13427 }
13428
13429 int UtcDaliActorGetLayerNegative(void)
13430 {
13431   TestApplication application;
13432   Dali::Actor     instance;
13433   try
13434   {
13435     instance.GetLayer();
13436     DALI_TEST_CHECK(false); // Should not get here
13437   }
13438   catch(...)
13439   {
13440     DALI_TEST_CHECK(true); // We expect an assert
13441   }
13442   END_TEST;
13443 }
13444
13445 int UtcDaliActorRotateByNegative01(void)
13446 {
13447   TestApplication application;
13448   Dali::Actor     instance;
13449   try
13450   {
13451     Dali::Quaternion arg1;
13452     instance.RotateBy(arg1);
13453     DALI_TEST_CHECK(false); // Should not get here
13454   }
13455   catch(...)
13456   {
13457     DALI_TEST_CHECK(true); // We expect an assert
13458   }
13459   END_TEST;
13460 }
13461
13462 int UtcDaliActorRotateByNegative02(void)
13463 {
13464   TestApplication application;
13465   Dali::Actor     instance;
13466   try
13467   {
13468     Dali::Radian  arg1;
13469     Dali::Vector3 arg2;
13470     instance.RotateBy(arg1, arg2);
13471     DALI_TEST_CHECK(false); // Should not get here
13472   }
13473   catch(...)
13474   {
13475     DALI_TEST_CHECK(true); // We expect an assert
13476   }
13477   END_TEST;
13478 }
13479
13480 int UtcDaliActorUnparentNegative(void)
13481 {
13482   TestApplication application;
13483   Dali::Actor     instance;
13484   try
13485   {
13486     instance.Unparent();
13487     DALI_TEST_CHECK(false); // Should not get here
13488   }
13489   catch(...)
13490   {
13491     DALI_TEST_CHECK(true); // We expect an assert
13492   }
13493   END_TEST;
13494 }
13495
13496 int UtcDaliActorGetChildAtNegative(void)
13497 {
13498   TestApplication application;
13499   Dali::Actor     instance;
13500   try
13501   {
13502     unsigned int arg1 = 0u;
13503     instance.GetChildAt(arg1);
13504     DALI_TEST_CHECK(false); // Should not get here
13505   }
13506   catch(...)
13507   {
13508     DALI_TEST_CHECK(true); // We expect an assert
13509   }
13510   END_TEST;
13511 }
13512
13513 int UtcDaliActorGetChildCountNegative(void)
13514 {
13515   TestApplication application;
13516   Dali::Actor     instance;
13517   try
13518   {
13519     instance.GetChildCount();
13520     DALI_TEST_CHECK(false); // Should not get here
13521   }
13522   catch(...)
13523   {
13524     DALI_TEST_CHECK(true); // We expect an assert
13525   }
13526   END_TEST;
13527 }
13528
13529 int UtcDaliActorGetTargetSizeNegative(void)
13530 {
13531   TestApplication application;
13532   Dali::Actor     instance;
13533   try
13534   {
13535     instance.GetTargetSize();
13536     DALI_TEST_CHECK(false); // Should not get here
13537   }
13538   catch(...)
13539   {
13540     DALI_TEST_CHECK(true); // We expect an assert
13541   }
13542   END_TEST;
13543 }
13544
13545 int UtcDaliActorScreenToLocalNegative(void)
13546 {
13547   TestApplication application;
13548   Dali::Actor     instance;
13549   try
13550   {
13551     float arg1 = 0.0f;
13552     float arg2 = 0.0f;
13553     float arg3 = 0.0f;
13554     float arg4 = 0.0f;
13555     instance.ScreenToLocal(arg1, arg2, arg3, arg4);
13556     DALI_TEST_CHECK(false); // Should not get here
13557   }
13558   catch(...)
13559   {
13560     DALI_TEST_CHECK(true); // We expect an assert
13561   }
13562   END_TEST;
13563 }
13564
13565 int UtcDaliActorGetNaturalSizeNegative(void)
13566 {
13567   TestApplication application;
13568   Dali::Actor     instance;
13569   try
13570   {
13571     instance.GetNaturalSize();
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 UtcDaliActorGetRelayoutSizeNegative(void)
13582 {
13583   TestApplication application;
13584   Dali::Actor     instance;
13585   try
13586   {
13587     Dali::Dimension::Type arg1 = Dimension::HEIGHT;
13588     instance.GetRelayoutSize(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 UtcDaliActorGetResizePolicyNegative(void)
13599 {
13600   TestApplication application;
13601   Dali::Actor     instance;
13602   try
13603   {
13604     Dali::Dimension::Type arg1 = Dimension::ALL_DIMENSIONS;
13605     instance.GetResizePolicy(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 UtcDaliActorGetRendererCountNegative(void)
13616 {
13617   TestApplication application;
13618   Dali::Actor     instance;
13619   try
13620   {
13621     instance.GetRendererCount();
13622     DALI_TEST_CHECK(false); // Should not get here
13623   }
13624   catch(...)
13625   {
13626     DALI_TEST_CHECK(true); // We expect an assert
13627   }
13628   END_TEST;
13629 }
13630
13631 int UtcDaliActorGetParentNegative(void)
13632 {
13633   TestApplication application;
13634   Dali::Actor     instance;
13635   try
13636   {
13637     instance.GetParent();
13638     DALI_TEST_CHECK(false); // Should not get here
13639   }
13640   catch(...)
13641   {
13642     DALI_TEST_CHECK(true); // We expect an assert
13643   }
13644   END_TEST;
13645 }
13646
13647 int UtcDaliActorPropertyBlendEquation(void)
13648 {
13649   TestApplication application;
13650
13651   tet_infoline("Test SetProperty AdvancedBlendEquation");
13652
13653   Geometry geometry  = CreateQuadGeometry();
13654   Shader   shader    = CreateShader();
13655   Renderer renderer1 = Renderer::New(geometry, shader);
13656
13657   Actor actor = Actor::New();
13658   actor.SetProperty(Actor::Property::OPACITY, 0.1f);
13659
13660   actor.AddRenderer(renderer1);
13661   actor.SetProperty(Actor::Property::SIZE, Vector2(400, 400));
13662   application.GetScene().Add(actor);
13663
13664   if(!Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
13665   {
13666     actor.SetProperty(Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN);
13667     int equation = actor.GetProperty<int>(Dali::DevelActor::Property::BLEND_EQUATION);
13668     DALI_TEST_EQUALS((Dali::DevelBlendEquation::SCREEN == equation), false, TEST_LOCATION);
13669   }
13670
13671   if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
13672   {
13673     actor.SetProperty(Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN);
13674     int equation = actor.GetProperty<int>(Dali::DevelActor::Property::BLEND_EQUATION);
13675     DALI_TEST_EQUALS((Dali::DevelBlendEquation::SCREEN == equation), true, TEST_LOCATION);
13676   }
13677
13678   Renderer renderer2 = Renderer::New(geometry, shader);
13679   actor.AddRenderer(renderer2);
13680
13681   END_TEST;
13682 }
13683
13684 int UtcDaliActorRegisterProperty(void)
13685 {
13686   tet_infoline("Test property registration and uniform map update\n");
13687
13688   TestApplication application;
13689
13690   Geometry geometry  = CreateQuadGeometry();
13691   Shader   shader    = CreateShader();
13692   Renderer renderer1 = Renderer::New(geometry, shader);
13693   Renderer renderer2 = Renderer::New(geometry, shader);
13694
13695   Actor actor1 = Actor::New();
13696   actor1.AddRenderer(renderer1);
13697   actor1.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
13698   actor1.RegisterProperty("uCustom", 1);
13699   application.GetScene().Add(actor1);
13700
13701   Actor actor2 = Actor::New();
13702   actor2.AddRenderer(renderer2);
13703   actor2.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
13704   application.GetScene().Add(actor2);
13705
13706   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
13707   TraceCallStack&    callStack     = glAbstraction.GetSetUniformTrace();
13708   glAbstraction.EnableSetUniformCallTrace(true);
13709
13710   application.SendNotification();
13711   application.Render();
13712
13713   std::stringstream out;
13714   out.str("1");
13715   std::string params;
13716
13717   // Test uniform value of the custom property
13718   DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("uCustom", params));
13719   DALI_TEST_EQUALS(out.str(), params, TEST_LOCATION);
13720
13721   // Make invisible
13722   actor1[Actor::Property::VISIBLE] = false;
13723
13724   application.SendNotification();
13725   application.Render();
13726
13727   // Make visible again
13728   actor1[Actor::Property::VISIBLE] = true;
13729   actor1["uCustom"]                = 2;
13730
13731   glAbstraction.ResetSetUniformCallStack();
13732
13733   application.SendNotification();
13734   application.Render();
13735
13736   out.str("2");
13737
13738   // The uniform value should not be changed
13739   DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("uCustom", params));
13740   DALI_TEST_EQUALS(out.str(), params, TEST_LOCATION);
13741
13742   END_TEST;
13743 }
13744
13745 int UtcDaliActorDoesWantedHitTest(void)
13746 {
13747   struct HitTestData
13748   {
13749   public:
13750     HitTestData(const Vector3& scale, const Vector2& touchPoint, bool result)
13751     : mScale(scale),
13752       mTouchPoint(touchPoint),
13753       mResult(result)
13754     {
13755     }
13756
13757     Vector3 mScale;
13758     Vector2 mTouchPoint;
13759     bool    mResult;
13760   };
13761
13762   TestApplication application;
13763   tet_infoline(" UtcDaliActorDoesWantedHitTest");
13764
13765   // Fill a vector with different hit tests.
13766   struct HitTestData* hitTestData[] = {
13767     //                    scale                     touch point           result
13768     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(289.f, 400.f), true),  // touch point close to the right edge (inside)
13769     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(291.f, 400.f), false), // touch point close to the right edge (outside)
13770     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.
13771     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(200.f, 451.f), false), // touch point close to the down edge (outside)
13772     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.
13773     NULL,
13774   };
13775
13776   // get the root layer
13777   Actor actor = Actor::New();
13778   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
13779   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
13780
13781   Actor lowerActor = Actor::New();
13782   lowerActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
13783   lowerActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
13784
13785   // actor and lowerActor have no relationship.
13786   application.GetScene().Add(lowerActor);
13787   application.GetScene().Add(actor);
13788
13789   ResetTouchCallbacks();
13790   gHitTestTouchCallBackCalled = false;
13791
13792   unsigned int index = 0;
13793   while(NULL != hitTestData[index])
13794   {
13795     actor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f));
13796     actor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z));
13797
13798     lowerActor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f));
13799     lowerActor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z));
13800
13801     // flush the queue and render once
13802     application.SendNotification();
13803     application.Render();
13804
13805     DALI_TEST_CHECK(!gTouchCallBackCalled);
13806     DALI_TEST_CHECK(!gTouchCallBackCalled2);
13807     DALI_TEST_CHECK(!gHitTestTouchCallBackCalled);
13808
13809     // connect to its touch signal
13810     actor.TouchedSignal().Connect(TestTouchCallback);
13811     lowerActor.TouchedSignal().Connect(TestTouchCallback2);
13812
13813     // connect to its hit-test signal
13814     Dali::DevelActor::HitTestResultSignal(actor).Connect(TestHitTestTouchCallback);
13815
13816     Dali::Integration::Point point;
13817     point.SetState(PointState::DOWN);
13818     point.SetScreenPosition(Vector2(hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y));
13819     Dali::Integration::TouchEvent event;
13820     event.AddPoint(point);
13821
13822     // flush the queue and render once
13823     application.SendNotification();
13824     application.Render();
13825     application.ProcessEvent(event);
13826
13827     // check hit-test events
13828     DALI_TEST_CHECK(gHitTestTouchCallBackCalled == hitTestData[index]->mResult);
13829     // Passed all hit-tests of actor.
13830     DALI_TEST_CHECK(gTouchCallBackCalled == false);
13831     // The lowerActor was hit-tested.
13832     DALI_TEST_CHECK(gTouchCallBackCalled2 == hitTestData[index]->mResult);
13833
13834     if(gTouchCallBackCalled2 != hitTestData[index]->mResult)
13835       tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
13836                  hitTestData[index]->mScale.x,
13837                  hitTestData[index]->mScale.y,
13838                  hitTestData[index]->mScale.z,
13839                  hitTestData[index]->mTouchPoint.x,
13840                  hitTestData[index]->mTouchPoint.y,
13841                  hitTestData[index]->mResult);
13842
13843     ResetTouchCallbacks();
13844     gHitTestTouchCallBackCalled = false;
13845     ++index;
13846   }
13847   END_TEST;
13848 }
13849
13850 int UtcDaliActorAllowOnlyOwnTouchPropertyP(void)
13851 {
13852   TestApplication application;
13853
13854   Actor actor = Actor::New();
13855   DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH).Get<bool>(), false, TEST_LOCATION);
13856   actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, true);
13857   DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH).Get<bool>(), true, TEST_LOCATION);
13858   DALI_TEST_EQUALS(actor.GetPropertyType(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), Property::BOOLEAN, TEST_LOCATION);
13859   DALI_TEST_EQUALS(actor.IsPropertyWritable(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), true, TEST_LOCATION);
13860   DALI_TEST_EQUALS(actor.IsPropertyAnimatable(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), false, TEST_LOCATION);
13861   DALI_TEST_EQUALS(actor.IsPropertyAConstraintInput(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), false, TEST_LOCATION);
13862   DALI_TEST_EQUALS(actor.GetPropertyName(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), "allowOnlyOwnTouch", TEST_LOCATION);
13863   END_TEST;
13864 }
13865
13866 int UtcDaliActorAllowOnlyOwnTouchPropertyN(void)
13867 {
13868   TestApplication application;
13869
13870   Actor actor = Actor::New();
13871
13872   // Make sure setting invalid types does not cause a crash
13873   try
13874   {
13875     actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, 1.0f);
13876     actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Vector2::ONE);
13877     actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Vector3::ONE);
13878     actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Vector4::ONE);
13879     actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Property::Map());
13880     actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Property::Array());
13881     tet_result(TET_PASS);
13882   }
13883   catch(...)
13884   {
13885     tet_result(TET_FAIL);
13886   }
13887   END_TEST;
13888 }
13889
13890 int UtcDaliActorCalculateWorldTransform01(void)
13891 {
13892   TestApplication application;
13893
13894   tet_infoline("Test that actor position inheritance produces right transform matrix");
13895
13896   Actor rootActor   = Actor::New();
13897   Actor branchActor = Actor::New();
13898   Actor leafActor   = Actor::New();
13899
13900   rootActor[Actor::Property::POSITION]   = Vector3(0.0f, 0.0f, 0.0f);
13901   branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
13902   leafActor[Actor::Property::POSITION]   = Vector3(100.0f, 50.0f, 30.0f);
13903
13904   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
13905   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
13906   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
13907
13908   // Set anchor point to the same value as parent origin
13909   rootActor[Actor::Property::PARENT_ORIGIN]   = ParentOrigin::TOP_LEFT;
13910   branchActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT;
13911   leafActor[Actor::Property::PARENT_ORIGIN]   = ParentOrigin::TOP_LEFT;
13912
13913   rootActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
13914   branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
13915   leafActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
13916
13917   application.GetScene().Add(rootActor);
13918   rootActor.Add(branchActor);
13919   branchActor.Add(leafActor);
13920
13921   application.SendNotification();
13922   application.Render(0);
13923   application.SendNotification();
13924   application.Render(0);
13925
13926   Matrix m = DevelActor::GetWorldTransform(leafActor);
13927
13928   Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
13929   DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
13930
13931   Vector3    worldPos;
13932   Vector3    worldScale;
13933   Quaternion worldRotation;
13934   m.GetTransformComponents(worldPos, worldRotation, worldScale);
13935   DALI_TEST_EQUALS(worldPos, Vector3(200.0f, 150.0f, 30.0f), 0.0001f, TEST_LOCATION);
13936
13937   END_TEST;
13938 }
13939
13940 int UtcDaliActorCalculateWorldTransform02(void)
13941 {
13942   TestApplication application;
13943
13944   tet_infoline("Test that actor position produces right transform matrix");
13945
13946   Actor rootActor   = Actor::New();
13947   Actor branchActor = Actor::New();
13948   Actor leafActor   = Actor::New();
13949
13950   rootActor[Actor::Property::POSITION]   = Vector3(0.0f, 0.0f, 0.0f);
13951   branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
13952   leafActor[Actor::Property::POSITION]   = Vector3(100.0f, 50.0f, 30.0f);
13953
13954   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
13955   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
13956   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
13957
13958   // Set anchor point to the same value as parent origin
13959   rootActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
13960   branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
13961   leafActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
13962
13963   application.GetScene().Add(rootActor);
13964   rootActor.Add(branchActor);
13965   branchActor.Add(leafActor);
13966
13967   leafActor[Actor::Property::INHERIT_POSITION]    = false;
13968   leafActor[Actor::Property::INHERIT_ORIENTATION] = false;
13969   leafActor[Actor::Property::INHERIT_SCALE]       = false;
13970
13971   application.SendNotification();
13972   application.Render(0);
13973   application.SendNotification();
13974   application.Render(0);
13975
13976   Matrix m = DevelActor::GetWorldTransform(leafActor);
13977
13978   Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
13979   DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
13980
13981   END_TEST;
13982 }
13983
13984 int UtcDaliActorCalculateWorldTransform03(void)
13985 {
13986   TestApplication application;
13987
13988   tet_infoline("Test that actor position produces right transform matrix");
13989
13990   Actor rootActor   = Actor::New();
13991   Actor branchActor = Actor::New();
13992   Actor leafActor   = Actor::New();
13993
13994   rootActor[Actor::Property::POSITION]   = Vector3(0.0f, 0.0f, 0.0f);
13995   branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
13996   leafActor[Actor::Property::POSITION]   = Vector3(100.0f, 50.0f, 30.0f);
13997
13998   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
13999   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14000   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14001
14002   // Set anchor point to the same value as parent origin
14003   rootActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
14004   branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
14005   leafActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
14006
14007   application.GetScene().Add(rootActor);
14008   rootActor.Add(branchActor);
14009   branchActor.Add(leafActor);
14010
14011   leafActor[Actor::Property::INHERIT_POSITION]    = true;
14012   leafActor[Actor::Property::INHERIT_ORIENTATION] = false;
14013   leafActor[Actor::Property::INHERIT_SCALE]       = false;
14014
14015   application.SendNotification();
14016   application.Render(0);
14017   application.SendNotification();
14018   application.Render(0);
14019
14020   Matrix m = DevelActor::GetWorldTransform(leafActor);
14021
14022   Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
14023   DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
14024
14025   END_TEST;
14026 }
14027
14028 int UtcDaliActorCalculateWorldTransform04(void)
14029 {
14030   TestApplication application;
14031
14032   tet_infoline("Test that actor inheritance scale/orientation produces right transform matrix");
14033
14034   Actor rootActor   = Actor::New();
14035   Actor branchActor = Actor::New();
14036   Actor leafActor   = Actor::New();
14037
14038   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
14039   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
14040   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
14041
14042   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14043   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14044   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14045
14046   // Set anchor point to the same value as parent origin
14047   rootActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::CENTER;
14048   rootActor[Actor::Property::PARENT_ORIGIN]  = ParentOrigin::CENTER;
14049   branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
14050   leafActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
14051
14052   branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
14053   leafActor[Actor::Property::POSITION]   = Vector3(100.0f, 50.0f, 30.0f);
14054
14055   application.GetScene().Add(rootActor);
14056   rootActor.Add(branchActor);
14057   branchActor.Add(leafActor);
14058
14059   application.SendNotification();
14060   application.Render(0);
14061   application.SendNotification();
14062   application.Render(0);
14063
14064   Matrix m = DevelActor::GetWorldTransform(leafActor);
14065
14066   Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
14067   DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
14068
14069   END_TEST;
14070 }
14071
14072 int UtcDaliActorCalculateWorldTransform05(void)
14073 {
14074   TestApplication application;
14075
14076   tet_infoline("Test that actor inheritance of scale produces right transform matrix");
14077
14078   Actor rootActor   = Actor::New();
14079   Actor branchActor = Actor::New();
14080   Actor leafActor   = Actor::New();
14081
14082   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
14083   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
14084   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
14085
14086   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14087   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14088   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14089
14090   // Set anchor point to the same value as parent origin
14091   rootActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::CENTER;
14092   rootActor[Actor::Property::PARENT_ORIGIN]  = ParentOrigin::CENTER;
14093   branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
14094   leafActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
14095
14096   branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
14097   leafActor[Actor::Property::POSITION]   = Vector3(100.0f, 50.0f, 30.0f);
14098
14099   leafActor[Actor::Property::INHERIT_POSITION]    = false;
14100   leafActor[Actor::Property::INHERIT_ORIENTATION] = false;
14101
14102   application.GetScene().Add(rootActor);
14103   rootActor.Add(branchActor);
14104   branchActor.Add(leafActor);
14105
14106   application.SendNotification();
14107   application.Render(0);
14108   application.SendNotification();
14109   application.Render(0);
14110
14111   Matrix m = DevelActor::GetWorldTransform(leafActor);
14112
14113   Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
14114   DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
14115
14116   END_TEST;
14117 }
14118
14119 int UtcDaliActorCalculateWorldTransform06(void)
14120 {
14121   TestApplication application;
14122
14123   tet_infoline("Test that actor inheritance of scale produces right transform matrix");
14124
14125   Actor rootActor   = Actor::New();
14126   Actor branchActor = Actor::New();
14127   Actor leafActor   = Actor::New();
14128
14129   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
14130   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
14131   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
14132
14133   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14134   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14135   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14136
14137   // Set anchor point to the same value as parent origin
14138   rootActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::CENTER;
14139   rootActor[Actor::Property::PARENT_ORIGIN]  = ParentOrigin::CENTER;
14140   branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
14141   leafActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
14142
14143   branchActor[Actor::Property::POSITION]    = Vector3(100.0f, 30.0f, -50.0f);
14144   branchActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(45.0f), Vector3::XAXIS);
14145   leafActor[Actor::Property::POSITION]      = Vector3(100.0f, 50.0f, 30.0f);
14146
14147   leafActor[Actor::Property::INHERIT_POSITION] = false;
14148   leafActor[Actor::Property::INHERIT_SCALE]    = false;
14149
14150   application.GetScene().Add(rootActor);
14151   rootActor.Add(branchActor);
14152   branchActor.Add(leafActor);
14153
14154   application.SendNotification();
14155   application.Render(0);
14156   application.SendNotification();
14157   application.Render(0);
14158
14159   Matrix m = DevelActor::GetWorldTransform(leafActor);
14160
14161   Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
14162   DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
14163
14164   END_TEST;
14165 }
14166
14167 int UtcDaliActorCalculateWorldTransform07(void)
14168 {
14169   TestApplication application;
14170
14171   tet_infoline("Test that actor inheritance of scale produces right transform matrix");
14172
14173   Actor rootActor   = Actor::New();
14174   Actor branchActor = Actor::New();
14175   Actor leafActor   = Actor::New();
14176
14177   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
14178   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
14179   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
14180
14181   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14182   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14183   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14184
14185   // Set anchor point to the same value as parent origin
14186   rootActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::CENTER;
14187   rootActor[Actor::Property::PARENT_ORIGIN]  = ParentOrigin::CENTER;
14188   branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
14189
14190   // This should be ignored.
14191   leafActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
14192   leafActor[Actor::Property::ANCHOR_POINT]  = AnchorPoint::CENTER;
14193
14194   branchActor[Actor::Property::POSITION]    = Vector3(100.0f, 30.0f, -50.0f);
14195   branchActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(45.0f), Vector3::XAXIS);
14196   leafActor[Actor::Property::POSITION]      = Vector3(100.0f, 50.0f, 30.0f);
14197
14198   leafActor[Actor::Property::INHERIT_POSITION]           = false;
14199   leafActor[Actor::Property::INHERIT_SCALE]              = false;
14200   leafActor[Actor::Property::POSITION_USES_ANCHOR_POINT] = false;
14201
14202   application.GetScene().Add(rootActor);
14203   rootActor.Add(branchActor);
14204   branchActor.Add(leafActor);
14205
14206   application.SendNotification();
14207   application.Render(0);
14208   application.SendNotification();
14209   application.Render(0);
14210
14211   Matrix m = DevelActor::GetWorldTransform(leafActor);
14212
14213   Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
14214   DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
14215
14216   END_TEST;
14217 }
14218
14219 int UtcDaliActorCalculateWorldTransform08(void)
14220 {
14221   TestApplication application;
14222
14223   tet_infoline("Test that actor inheritance of scale produces right transform matrix");
14224
14225   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)};
14226
14227   struct TestCase
14228   {
14229     bool translation;
14230     bool rotation;
14231     bool scaling;
14232   };
14233   TestCase testCases[] = {
14234     {false, false, true},
14235     {false, true, false},
14236     {true, false, false},
14237     {false, true, true},
14238     {true, false, true},
14239     {true, true, false},
14240     {false, false, false},
14241     {true, true, true},
14242   };
14243
14244   Actor rootActor = Actor::New();
14245   Actor leafActor = Actor::New();
14246
14247   rootActor[Actor::Property::POSITION]      = Vector3(0.0f, 0.0f, 0.0f);
14248   rootActor[Actor::Property::SCALE]         = Vector3(1.0f, 2.0f, 1.0f);
14249   rootActor[Actor::Property::ORIENTATION]   = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
14250   rootActor[Actor::Property::SIZE]          = Vector2(200, 400);
14251   rootActor[Actor::Property::ANCHOR_POINT]  = AnchorPoint::CENTER;
14252   rootActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
14253
14254   leafActor[Actor::Property::POSITION]                   = Vector3(0.0f, -50.0f, 0.0f);
14255   leafActor[Actor::Property::SCALE]                      = Vector3(1.0f, 1.0f, 1.0f);
14256   leafActor[Actor::Property::ORIENTATION]                = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
14257   leafActor[Actor::Property::SIZE]                       = Vector2(200, 400);
14258   leafActor[Actor::Property::ANCHOR_POINT]               = AnchorPoint::BOTTOM_CENTER;
14259   leafActor[Actor::Property::PARENT_ORIGIN]              = ParentOrigin::TOP_CENTER;
14260   leafActor[Actor::Property::POSITION_USES_ANCHOR_POINT] = true;
14261
14262   application.GetScene().Add(rootActor);
14263   rootActor.Add(leafActor);
14264
14265   for(uint32_t i = 0; i < 8; ++i)
14266   {
14267     leafActor[Actor::Property::INHERIT_POSITION]    = testCases[i].translation;
14268     leafActor[Actor::Property::INHERIT_ORIENTATION] = testCases[i].rotation;
14269     leafActor[Actor::Property::INHERIT_SCALE]       = testCases[i].scaling;
14270
14271     application.SendNotification();
14272     application.Render(0);
14273     application.SendNotification();
14274     application.Render(0);
14275
14276     Matrix m            = DevelActor::GetWorldTransform(leafActor);
14277     Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
14278
14279     Vector3 worldPosition1 = Vector3(m.GetTranslation());
14280     Vector3 worldPosition2 = Vector3(actualMatrix.GetTranslation());
14281
14282     DALI_TEST_EQUALS(solutions[i], worldPosition1, 0.001f, TEST_LOCATION);
14283     DALI_TEST_EQUALS(solutions[i], worldPosition2, 0.001f, TEST_LOCATION);
14284   }
14285
14286   END_TEST;
14287 }
14288
14289 int UtcDaliActorCalculateWorldColor01(void)
14290 {
14291   TestApplication application;
14292
14293   tet_infoline("Test that actor inheritance of color produces right final color");
14294
14295   Actor rootActor   = Actor::New();
14296   Actor branchActor = Actor::New();
14297   Actor leafActor   = Actor::New();
14298
14299   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
14300   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
14301   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
14302
14303   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14304   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14305   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14306
14307   rootActor[Actor::Property::COLOR] = Color::WHITE;
14308   Vector4 testColor1(1.0f, 1.0f, 0.5f, 0.8f);
14309   branchActor[Actor::Property::COLOR] = testColor1;
14310   leafActor[Actor::Property::COLOR]   = Vector4(0.1f, 0.5f, 0.5f, 0.8f);
14311
14312   // Default is to inherit:
14313   leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_OWN_MULTIPLY_PARENT_ALPHA;
14314
14315   application.GetScene().Add(rootActor);
14316   rootActor.Add(branchActor);
14317   branchActor.Add(leafActor);
14318
14319   application.SendNotification();
14320   application.Render(16);
14321   Vector4 color = branchActor.GetCurrentProperty<Vector4>(Actor::Property::COLOR);
14322   DALI_TEST_EQUALS(color, testColor1, TEST_LOCATION);
14323
14324   application.SendNotification();
14325   application.Render(16);
14326   color = branchActor.GetCurrentProperty<Vector4>(Actor::Property::COLOR);
14327   DALI_TEST_EQUALS(color, testColor1, TEST_LOCATION);
14328
14329   application.SendNotification();
14330   application.Render(16);
14331   color = branchActor.GetCurrentProperty<Vector4>(Actor::Property::COLOR);
14332   DALI_TEST_EQUALS(color, testColor1, TEST_LOCATION);
14333
14334   color = DevelActor::GetWorldColor(leafActor);
14335
14336   Vector4 actualColor = leafActor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR);
14337   DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION);
14338
14339   END_TEST;
14340 }
14341
14342 int UtcDaliActorCalculateWorldColor02(void)
14343 {
14344   TestApplication application;
14345
14346   tet_infoline("Test that actor uses own color");
14347
14348   Actor rootActor   = Actor::New();
14349   Actor branchActor = Actor::New();
14350   Actor leafActor   = Actor::New();
14351
14352   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
14353   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
14354   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
14355
14356   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14357   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14358   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14359
14360   rootActor[Actor::Property::COLOR]   = Color::WHITE;
14361   branchActor[Actor::Property::COLOR] = Vector4(1.0f, 1.0f, 0.5f, 0.8f);
14362   leafActor[Actor::Property::COLOR]   = Vector4(0.1f, 0.5f, 0.5f, 0.8f);
14363
14364   leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_OWN_COLOR;
14365
14366   application.GetScene().Add(rootActor);
14367   rootActor.Add(branchActor);
14368   branchActor.Add(leafActor);
14369
14370   application.SendNotification();
14371   application.Render(0);
14372
14373   Vector4 color = DevelActor::GetWorldColor(leafActor);
14374
14375   Vector4 actualColor = leafActor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR);
14376   DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION);
14377   DALI_TEST_EQUALS(color, Vector4(0.1f, 0.5f, 0.5f, 0.8f), 0.001f, TEST_LOCATION);
14378   END_TEST;
14379 }
14380
14381 int UtcDaliActorCalculateWorldColor03(void)
14382 {
14383   TestApplication application;
14384
14385   tet_infoline("Test that actor uses parent color");
14386
14387   Actor rootActor   = Actor::New();
14388   Actor branchActor = Actor::New();
14389   Actor leafActor   = Actor::New();
14390
14391   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
14392   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
14393   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
14394
14395   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14396   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14397   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14398
14399   rootActor[Actor::Property::COLOR]   = Color::WHITE * 0.9f;
14400   branchActor[Actor::Property::COLOR] = Vector4(1.0f, 1.0f, 0.5f, 0.8f);
14401   leafActor[Actor::Property::COLOR]   = Vector4(0.1f, 0.5f, 0.5f, 0.8f);
14402
14403   leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_PARENT_COLOR;
14404
14405   application.GetScene().Add(rootActor);
14406   rootActor.Add(branchActor);
14407   branchActor.Add(leafActor);
14408
14409   application.SendNotification();
14410   application.Render(0);
14411
14412   Vector4 color = DevelActor::GetWorldColor(leafActor);
14413
14414   Vector4 actualColor = leafActor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR);
14415   DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION);
14416   DALI_TEST_EQUALS(color, Vector4(1.0f, 1.0f, 0.5f, 0.72f), 0.001f, TEST_LOCATION);
14417   END_TEST;
14418 }
14419
14420 int UtcDaliActorCalculateWorldColor04(void)
14421 {
14422   TestApplication application;
14423
14424   tet_infoline("Test that actor blends with parent color");
14425
14426   Actor rootActor   = Actor::New();
14427   Actor branchActor = Actor::New();
14428   Actor leafActor   = Actor::New();
14429
14430   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
14431   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
14432   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
14433
14434   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14435   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14436   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
14437
14438   rootActor[Actor::Property::COLOR]   = Color::WHITE * 0.9f;
14439   branchActor[Actor::Property::COLOR] = Vector4(1.0f, 1.0f, 0.5f, 0.8f);
14440   leafActor[Actor::Property::COLOR]   = Vector4(0.1f, 0.5f, 0.5f, 0.8f);
14441
14442   leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_OWN_MULTIPLY_PARENT_COLOR;
14443
14444   application.GetScene().Add(rootActor);
14445   rootActor.Add(branchActor);
14446   branchActor.Add(leafActor);
14447
14448   application.SendNotification();
14449   application.Render(0);
14450
14451   Vector4 color = DevelActor::GetWorldColor(leafActor);
14452
14453   Vector4 actualColor = leafActor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR);
14454   DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION);
14455
14456   END_TEST;
14457 }
14458
14459 int UtcDaliActorCalculateLookAt(void)
14460 {
14461   TestApplication application;
14462
14463   tet_infoline("Test that actor rotate right value of orientation");
14464
14465   Actor actor = Actor::New();
14466
14467   actor[Actor::Property::POSITION]      = Vector3(100.0f, 0.0f, 0.0f);
14468   actor[Actor::Property::ANCHOR_POINT]  = AnchorPoint::CENTER;
14469   actor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
14470
14471   application.GetScene().Add(actor);
14472
14473   application.SendNotification();
14474   application.Render(0);
14475
14476   Quaternion actorQuaternion;
14477
14478   tet_printf("Test with target only\n");
14479   Dali::DevelActor::LookAt(actor, Vector3::ZERO);
14480   actorQuaternion = actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
14481   DALI_TEST_EQUALS(actorQuaternion, Quaternion(Radian(Degree(90.0f)), Vector3::NEGATIVE_YAXIS), TEST_LOCATION);
14482
14483   tet_printf("Test with target + up\n");
14484   Dali::DevelActor::LookAt(actor, Vector3::ZERO, Vector3::ZAXIS);
14485   actorQuaternion = actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
14486   DALI_TEST_EQUALS(actorQuaternion, Quaternion(Radian(Degree(90.0f)), Vector3::XAXIS) * Quaternion(Radian(Degree(90.0f)), Vector3::NEGATIVE_YAXIS), TEST_LOCATION);
14487
14488   tet_printf("Test with target + up + localForward\n");
14489   Dali::DevelActor::LookAt(actor, Vector3::ZERO, Vector3::NEGATIVE_YAXIS, Vector3::NEGATIVE_XAXIS);
14490   actorQuaternion = actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
14491   DALI_TEST_EQUALS(actorQuaternion, Quaternion(Radian(Degree(180.0f)), Vector3::XAXIS), TEST_LOCATION);
14492
14493   tet_printf("Test with target + up + localForward + localUp\n");
14494   Dali::DevelActor::LookAt(actor, Vector3::ZERO, Vector3::NEGATIVE_YAXIS, Vector3::NEGATIVE_YAXIS, Vector3::XAXIS);
14495   actorQuaternion = actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
14496   DALI_TEST_EQUALS(actorQuaternion, Quaternion(Radian(Degree(90.0f)), Vector3::NEGATIVE_ZAXIS), TEST_LOCATION);
14497
14498   // Reset quaternion
14499   actor[Actor::Property::ORIENTATION] = Quaternion();
14500
14501   Actor actor2                           = Actor::New();
14502   actor2[Actor::Property::POSITION]      = Vector3(0.0f, 50.0f, -10.0f);
14503   actor2[Actor::Property::ANCHOR_POINT]  = AnchorPoint::CENTER;
14504   actor2[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
14505   actor.Add(actor2);
14506
14507   tet_printf("Test whether lookat calculate well by using event side values only\n");
14508   Dali::DevelActor::LookAt(actor2, Vector3(100.0f, 50.0f, 1.0f));
14509   actorQuaternion = actor2.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
14510   DALI_TEST_EQUALS(actorQuaternion, Quaternion(), TEST_LOCATION);
14511
14512   actor[Actor::Property::ORIENTATION] = Quaternion(Radian(Degree(90.0f)), Vector3::ZAXIS);
14513
14514   DALI_TEST_EQUALS(Dali::DevelActor::GetWorldTransform(actor2).GetTranslation3(), Vector3(50.0f, 0.0f, -10.0f), TEST_LOCATION);
14515
14516   tet_printf("Test whether lookat calculate well inherit by parent orientation\n");
14517   Dali::DevelActor::LookAt(actor2, Vector3(50.0f, 0.0f, 1.0f), Vector3::NEGATIVE_XAXIS);
14518   actorQuaternion = actor2.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
14519   DALI_TEST_EQUALS(actorQuaternion, Quaternion(), TEST_LOCATION);
14520
14521   END_TEST;
14522 }
14523
14524 int UtcDaliActorIsHittable(void)
14525 {
14526   TestApplication application;
14527
14528   Actor   parent = Actor::New();
14529   Vector4 parentColor(1.0f, 0.5f, 0.0f, 0.8f);
14530   parent.SetProperty(Actor::Property::COLOR, parentColor);
14531   application.GetScene().Add(parent);
14532
14533   Actor   actor = Actor::New();
14534   Vector4 childColor(0.5f, 0.6f, 0.5f, 1.0f);
14535   actor.SetProperty(Actor::Property::COLOR, childColor);
14536   parent.Add(actor);
14537
14538   actor.SetProperty(Actor::Property::SENSITIVE, true);
14539   actor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, true);
14540   actor.SetProperty(Actor::Property::VISIBLE, true);
14541
14542   application.SendNotification();
14543   application.Render();
14544
14545   DALI_TEST_CHECK(DevelActor::IsHittable(actor) == true);
14546
14547   actor.SetProperty(Actor::Property::SENSITIVE, false);
14548   DALI_TEST_CHECK(DevelActor::IsHittable(actor) == false);
14549   actor.SetProperty(Actor::Property::SENSITIVE, true);
14550
14551   actor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, false);
14552   DALI_TEST_CHECK(DevelActor::IsHittable(actor) == false);
14553   actor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, true);
14554
14555   actor.SetProperty(Actor::Property::VISIBLE, false);
14556   application.SendNotification();
14557   application.Render();
14558   DALI_TEST_CHECK(DevelActor::IsHittable(actor) == false);
14559
14560   END_TEST;
14561 }
14562
14563 int UtcDaliActorGetTouchRequired(void)
14564 {
14565   TestApplication application;
14566
14567   Actor actor = Actor::New();
14568   DALI_TEST_CHECK(DevelActor::GetTouchRequired(actor) == false);
14569
14570   actor.TouchedSignal().Connect(TestTouchCallback);
14571   DALI_TEST_CHECK(DevelActor::GetTouchRequired(actor) == true);
14572
14573   END_TEST;
14574 }
14575
14576 int UtcDaliActorDispatchTouchMotionPropertyP(void)
14577 {
14578   TestApplication application;
14579
14580   Actor actor = Actor::New();
14581   DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::DISPATCH_TOUCH_MOTION).Get<bool>(), true, TEST_LOCATION);
14582   actor.SetProperty(DevelActor::Property::DISPATCH_TOUCH_MOTION, false);
14583   DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::DISPATCH_TOUCH_MOTION).Get<bool>(), false, TEST_LOCATION);
14584   DALI_TEST_EQUALS(actor.GetPropertyType(DevelActor::Property::DISPATCH_TOUCH_MOTION), Property::BOOLEAN, TEST_LOCATION);
14585   DALI_TEST_EQUALS(actor.IsPropertyWritable(DevelActor::Property::DISPATCH_TOUCH_MOTION), true, TEST_LOCATION);
14586   DALI_TEST_EQUALS(actor.IsPropertyAnimatable(DevelActor::Property::DISPATCH_TOUCH_MOTION), false, TEST_LOCATION);
14587   DALI_TEST_EQUALS(actor.IsPropertyAConstraintInput(DevelActor::Property::DISPATCH_TOUCH_MOTION), false, TEST_LOCATION);
14588   DALI_TEST_EQUALS(actor.GetPropertyName(DevelActor::Property::DISPATCH_TOUCH_MOTION), "dispatchTouchMotion", TEST_LOCATION);
14589   END_TEST;
14590 }
14591
14592 int UtcDaliActorDispatchTouchMotionPropertyN(void)
14593 {
14594   TestApplication application;
14595
14596   Actor actor = Actor::New();
14597
14598   // Make sure setting invalid types does not cause a crash
14599   try
14600   {
14601     actor.SetProperty(DevelActor::Property::DISPATCH_TOUCH_MOTION, 1.0f);
14602     actor.SetProperty(DevelActor::Property::DISPATCH_TOUCH_MOTION, Vector2::ONE);
14603     actor.SetProperty(DevelActor::Property::DISPATCH_TOUCH_MOTION, Vector3::ONE);
14604     actor.SetProperty(DevelActor::Property::DISPATCH_TOUCH_MOTION, Vector4::ONE);
14605     actor.SetProperty(DevelActor::Property::DISPATCH_TOUCH_MOTION, Property::Map());
14606     actor.SetProperty(DevelActor::Property::DISPATCH_TOUCH_MOTION, Property::Array());
14607     tet_result(TET_PASS);
14608   }
14609   catch(...)
14610   {
14611     tet_result(TET_FAIL);
14612   }
14613   END_TEST;
14614 }
14615
14616 int UtcDaliActorDispatchHoverMotionPropertyP(void)
14617 {
14618   TestApplication application;
14619
14620   Actor actor = Actor::New();
14621   DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::DISPATCH_HOVER_MOTION).Get<bool>(), true, TEST_LOCATION);
14622   actor.SetProperty(DevelActor::Property::DISPATCH_HOVER_MOTION, false);
14623   DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::DISPATCH_HOVER_MOTION).Get<bool>(), false, TEST_LOCATION);
14624   DALI_TEST_EQUALS(actor.GetPropertyType(DevelActor::Property::DISPATCH_HOVER_MOTION), Property::BOOLEAN, TEST_LOCATION);
14625   DALI_TEST_EQUALS(actor.IsPropertyWritable(DevelActor::Property::DISPATCH_HOVER_MOTION), true, TEST_LOCATION);
14626   DALI_TEST_EQUALS(actor.IsPropertyAnimatable(DevelActor::Property::DISPATCH_HOVER_MOTION), false, TEST_LOCATION);
14627   DALI_TEST_EQUALS(actor.IsPropertyAConstraintInput(DevelActor::Property::DISPATCH_HOVER_MOTION), false, TEST_LOCATION);
14628   DALI_TEST_EQUALS(actor.GetPropertyName(DevelActor::Property::DISPATCH_HOVER_MOTION), "dispatchHoverMotion", TEST_LOCATION);
14629   END_TEST;
14630 }
14631
14632 int UtcDaliActorDispatchHoverMotionPropertyN(void)
14633 {
14634   TestApplication application;
14635
14636   Actor actor = Actor::New();
14637
14638   // Make sure setting invalid types does not cause a crash
14639   try
14640   {
14641     actor.SetProperty(DevelActor::Property::DISPATCH_HOVER_MOTION, 1.0f);
14642     actor.SetProperty(DevelActor::Property::DISPATCH_HOVER_MOTION, Vector2::ONE);
14643     actor.SetProperty(DevelActor::Property::DISPATCH_HOVER_MOTION, Vector3::ONE);
14644     actor.SetProperty(DevelActor::Property::DISPATCH_HOVER_MOTION, Vector4::ONE);
14645     actor.SetProperty(DevelActor::Property::DISPATCH_HOVER_MOTION, Property::Map());
14646     actor.SetProperty(DevelActor::Property::DISPATCH_HOVER_MOTION, Property::Array());
14647     tet_result(TET_PASS);
14648   }
14649   catch(...)
14650   {
14651     tet_result(TET_FAIL);
14652   }
14653   END_TEST;
14654 }