Fix a clipping mode bug
[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
31 #include <cfloat> // For FLT_MAX
32 #include <set>    // For std::multiset
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 bool TestCallback3(Actor actor, const HoverEvent& event)
132 {
133   gHoverCallBackCalled = true;
134   return false;
135   END_TEST;
136 }
137
138 // validation stuff for onstage & offstage signals
139 static std::vector<std::string> gActorNamesOnOffScene;
140 static int                      gOnSceneCallBackCalled;
141 void                            OnSceneCallback(Actor actor)
142 {
143   ++gOnSceneCallBackCalled;
144   gActorNamesOnOffScene.push_back(actor.GetProperty<std::string>(Actor::Property::NAME));
145   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE) == true);
146 }
147 static int gOffSceneCallBackCalled;
148 void       OffSceneCallback(Actor actor)
149 {
150   ++gOffSceneCallBackCalled;
151   gActorNamesOnOffScene.push_back(actor.GetProperty<std::string>(Actor::Property::NAME));
152   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE) == false);
153 }
154
155 struct PositionComponentConstraint
156 {
157   PositionComponentConstraint()
158   {
159   }
160
161   void operator()(Vector3& pos, const PropertyInputContainer& inputs)
162   {
163     const Matrix& m = inputs[0]->GetMatrix();
164     Vector3       scale;
165     Quaternion    rot;
166     m.GetTransformComponents(pos, rot, scale);
167   }
168 };
169
170 struct OrientationComponentConstraint
171 {
172   OrientationComponentConstraint()
173   {
174   }
175
176   void operator()(Quaternion& orientation, const PropertyInputContainer& inputs)
177   {
178     const Quaternion& parentOrientation = inputs[0]->GetQuaternion();
179     Vector3           pos, scale;
180     Quaternion        rot;
181     orientation = parentOrientation;
182   }
183 };
184 // OnRelayout
185
186 static bool                     gOnRelayoutCallBackCalled = false;
187 static std::vector<std::string> gActorNamesRelayout;
188
189 void OnRelayoutCallback(Actor actor)
190 {
191   gOnRelayoutCallBackCalled = true;
192   gActorNamesRelayout.push_back(actor.GetProperty<std::string>(Actor::Property::NAME));
193 }
194
195 struct VisibilityChangedFunctorData
196 {
197   VisibilityChangedFunctorData()
198   : actor(),
199     visible(false),
200     type(DevelActor::VisibilityChange::SELF),
201     called(false)
202   {
203   }
204
205   void Reset()
206   {
207     actor.Reset();
208     visible = false;
209     type    = DevelActor::VisibilityChange::SELF;
210     called  = false;
211   }
212
213   void Check(bool compareCalled, Actor compareActor, bool compareVisible, DevelActor::VisibilityChange::Type compareType, const char* location)
214   {
215     DALI_TEST_EQUALS(called, compareCalled, TEST_INNER_LOCATION(location));
216     DALI_TEST_EQUALS(actor, compareActor, TEST_INNER_LOCATION(location));
217     DALI_TEST_EQUALS(visible, compareVisible, TEST_INNER_LOCATION(location));
218     DALI_TEST_EQUALS((int)type, (int)compareType, TEST_INNER_LOCATION(location));
219   }
220
221   void Check(bool compareCalled, const std::string& location)
222   {
223     DALI_TEST_EQUALS(called, compareCalled, TEST_INNER_LOCATION(location));
224   }
225
226   Actor                              actor;
227   bool                               visible;
228   DevelActor::VisibilityChange::Type type;
229   bool                               called;
230 };
231
232 struct VisibilityChangedFunctor
233 {
234   VisibilityChangedFunctor(VisibilityChangedFunctorData& dataVar)
235   : data(dataVar)
236   {
237   }
238
239   void operator()(Actor actor, bool visible, DevelActor::VisibilityChange::Type type)
240   {
241     data.actor   = actor;
242     data.visible = visible;
243     data.type    = type;
244     data.called  = true;
245   }
246
247   VisibilityChangedFunctorData& data;
248 };
249
250 struct VisibilityChangedVoidFunctor
251 {
252   VisibilityChangedVoidFunctor(bool& signalCalled)
253   : mSignalCalled(signalCalled)
254   {
255   }
256
257   void operator()()
258   {
259     mSignalCalled = true;
260   }
261
262   bool& mSignalCalled;
263 };
264
265 struct ChildOrderChangedFunctor
266 {
267   ChildOrderChangedFunctor(bool& signalCalled, Actor& actor)
268   : mSignalCalled(signalCalled),
269     mActor(actor)
270   {
271   }
272
273   void operator()(Actor actor)
274   {
275     mSignalCalled = true;
276     mActor        = actor;
277   }
278
279   bool&  mSignalCalled;
280   Actor& mActor;
281 };
282
283 struct CulledPropertyNotificationFunctor
284 {
285   CulledPropertyNotificationFunctor(bool& signalCalled, PropertyNotification& propertyNotification)
286   : mSignalCalled(signalCalled),
287     mPropertyNotification(propertyNotification)
288   {
289   }
290
291   void operator()(PropertyNotification& source)
292   {
293     mSignalCalled         = true;
294     mPropertyNotification = source;
295   }
296
297   bool&                 mSignalCalled;
298   PropertyNotification& mPropertyNotification;
299 };
300
301 // Check dirtyRect is equal with expected multiset.
302 // Note that the order of damagedRect is not important
303 struct RectSorter
304 {
305   bool operator()(const Rect<int>& lhs, const Rect<int>& rhs) const
306   {
307     if(lhs.x != rhs.x)
308     {
309       return lhs.x < rhs.x;
310     }
311     if(lhs.y != rhs.y)
312     {
313       return lhs.y < rhs.y;
314     }
315     if(lhs.width != rhs.width)
316     {
317       return lhs.width < rhs.width;
318     }
319     return lhs.height < rhs.height;
320   }
321 };
322
323 void DirtyRectChecker(const std::vector<Rect<int>>& damagedRects, std::multiset<Rect<int>, RectSorter> expectedRectList, bool checkRectsExact, const char* testLocation)
324 {
325   // Just check damagedRect contain all expectRectList.
326   DALI_TEST_GREATER(damagedRects.size() + 1u, expectedRectList.size(), testLocation);
327
328   for(auto& rect : damagedRects)
329   {
330     auto iter = expectedRectList.find(rect);
331     if(iter != expectedRectList.end())
332     {
333       expectedRectList.erase(iter);
334     }
335     else if(checkRectsExact)
336     {
337       std::ostringstream o;
338       o << rect << " exist in expectRectList" << std::endl;
339       fprintf(stderr, "Test failed in %s, checking %s", testLocation, o.str().c_str());
340       tet_result(TET_FAIL);
341     }
342   }
343
344   // Check all rects are matched
345   DALI_TEST_EQUALS(expectedRectList.empty(), true, testLocation);
346 }
347
348 // Clipping test helper functions:
349 Actor CreateActorWithContent(uint32_t width, uint32_t height)
350 {
351   Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
352   Actor   actor = CreateRenderableActor(image);
353
354   // Setup dimensions and position so actor is not skipped by culling.
355   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
356   actor.SetProperty(Actor::Property::SIZE, Vector2(width, height));
357   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
358   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
359
360   return actor;
361 }
362
363 Actor CreateActorWithContent16x16()
364 {
365   return CreateActorWithContent(16, 16);
366 }
367
368 void GenerateTrace(TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& callTrace)
369 {
370   enabledDisableTrace.Reset();
371   callTrace.Reset();
372   enabledDisableTrace.Enable(true);
373   callTrace.Enable(true);
374
375   application.SendNotification();
376   application.Render();
377
378   enabledDisableTrace.Enable(false);
379   callTrace.Enable(false);
380 }
381
382 void CheckColorMask(TestGlAbstraction& glAbstraction, bool maskValue)
383 {
384   const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
385
386   DALI_TEST_EQUALS<bool>(colorMaskParams.red, maskValue, TEST_LOCATION);
387   DALI_TEST_EQUALS<bool>(colorMaskParams.green, maskValue, TEST_LOCATION);
388   DALI_TEST_EQUALS<bool>(colorMaskParams.blue, maskValue, TEST_LOCATION);
389
390   // @todo only test alpha if the framebuffer has an alpha channel
391   //DALI_TEST_EQUALS<bool>(colorMaskParams.alpha, maskValue, TEST_LOCATION);
392 }
393
394 } // anonymous namespace
395
396 //& purpose: Testing New API
397 int UtcDaliActorNew(void)
398 {
399   TestApplication application;
400
401   Actor actor = Actor::New();
402
403   DALI_TEST_CHECK(actor);
404   END_TEST;
405 }
406
407 //& purpose: Testing Dali::Actor::DownCast()
408 int UtcDaliActorDownCastP(void)
409 {
410   TestApplication application;
411   tet_infoline("Testing Dali::Actor::DownCast()");
412
413   Actor      actor = Actor::New();
414   BaseHandle object(actor);
415   Actor      actor2 = Actor::DownCast(object);
416   DALI_TEST_CHECK(actor2);
417   END_TEST;
418 }
419
420 //& purpose: Testing Dali::Actor::DownCast()
421 int UtcDaliActorDownCastN(void)
422 {
423   TestApplication application;
424   tet_infoline("Testing Dali::Actor::DownCast()");
425
426   BaseHandle unInitializedObject;
427   Actor      actor = Actor::DownCast(unInitializedObject);
428   DALI_TEST_CHECK(!actor);
429   END_TEST;
430 }
431
432 int UtcDaliActorMoveConstructor(void)
433 {
434   TestApplication application;
435
436   Actor actor = Actor::New();
437   DALI_TEST_CHECK(actor);
438
439   int id = actor.GetProperty<int>(Actor::Property::ID);
440
441   Actor moved = std::move(actor);
442   DALI_TEST_CHECK(moved);
443   DALI_TEST_EQUALS(id, moved.GetProperty<int>(Actor::Property::ID), TEST_LOCATION);
444   DALI_TEST_CHECK(!actor);
445
446   END_TEST;
447 }
448
449 int UtcDaliActorMoveAssignment(void)
450 {
451   TestApplication application;
452
453   Actor actor = Actor::New();
454   DALI_TEST_CHECK(actor);
455
456   int id = actor.GetProperty<int>(Actor::Property::ID);
457
458   Actor moved;
459   moved = std::move(actor);
460   DALI_TEST_CHECK(moved);
461   DALI_TEST_EQUALS(id, moved.GetProperty<int>(Actor::Property::ID), TEST_LOCATION);
462   DALI_TEST_CHECK(!actor);
463
464   END_TEST;
465 }
466
467 //& purpose: Testing Dali::Actor::GetName()
468 int UtcDaliActorGetName(void)
469 {
470   TestApplication application;
471
472   Actor actor = Actor::New();
473
474   DALI_TEST_CHECK(actor.GetProperty<std::string>(Actor::Property::NAME).empty());
475   END_TEST;
476 }
477
478 //& purpose: Testing Dali::Actor::SetName()
479 int UtcDaliActorSetName(void)
480 {
481   TestApplication application;
482
483   string str("ActorName");
484   Actor  actor = Actor::New();
485
486   actor.SetProperty(Actor::Property::NAME, str);
487   DALI_TEST_CHECK(actor.GetProperty<std::string>(Actor::Property::NAME) == str);
488   END_TEST;
489 }
490
491 int UtcDaliActorGetId(void)
492 {
493   tet_infoline("Testing Dali::Actor::UtcDaliActo.GetProperty< int >( Actor::Property::ID )");
494   TestApplication application;
495
496   Actor first  = Actor::New();
497   Actor second = Actor::New();
498   Actor third  = Actor::New();
499
500   DALI_TEST_CHECK(first.GetProperty<int>(Actor::Property::ID) != second.GetProperty<int>(Actor::Property::ID));
501   DALI_TEST_CHECK(second.GetProperty<int>(Actor::Property::ID) != third.GetProperty<int>(Actor::Property::ID));
502   END_TEST;
503 }
504
505 int UtcDaliActorIsRoot(void)
506 {
507   TestApplication application;
508
509   Actor actor = Actor::New();
510   DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::IS_ROOT));
511
512   // get the root layer
513   actor = application.GetScene().GetLayer(0);
514   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::IS_ROOT));
515   END_TEST;
516 }
517
518 int UtcDaliActorOnScene(void)
519 {
520   TestApplication application;
521
522   Actor actor = Actor::New();
523   DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
524
525   // get the root layer
526   actor = application.GetScene().GetLayer(0);
527   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
528   END_TEST;
529 }
530
531 int UtcDaliActorIsLayer(void)
532 {
533   TestApplication application;
534
535   Actor actor = Actor::New();
536   DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::IS_LAYER));
537
538   // get the root layer
539   actor = application.GetScene().GetLayer(0);
540   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::IS_LAYER));
541   END_TEST;
542 }
543
544 int UtcDaliActorGetLayer(void)
545 {
546   TestApplication application;
547
548   Actor actor = Actor::New();
549   application.GetScene().Add(actor);
550   Layer layer = actor.GetLayer();
551
552   DALI_TEST_CHECK(layer);
553
554   // get the root layers layer
555   actor = application.GetScene().GetLayer(0);
556   DALI_TEST_CHECK(actor.GetLayer());
557   END_TEST;
558 }
559
560 int UtcDaliActorAddP(void)
561 {
562   tet_infoline("Testing Actor::Add");
563   TestApplication application;
564
565   Actor parent = Actor::New();
566   Actor child  = Actor::New();
567
568   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
569
570   parent.Add(child);
571
572   DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
573
574   Actor parent2 = Actor::New();
575   parent2.Add(child);
576
577   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
578   DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
579
580   // try Adding to same parent again, works
581   parent2.Add(child);
582   DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
583
584   // try reparenting an orphaned child
585   {
586     Actor temporaryParent = Actor::New();
587     temporaryParent.Add(child);
588     DALI_TEST_EQUALS(parent2.GetChildCount(), 0u, TEST_LOCATION);
589   }
590   // temporaryParent has now died, reparent the orphaned child
591   parent2.Add(child);
592   DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
593
594   END_TEST;
595 }
596
597 int UtcDaliActorAddN(void)
598 {
599   tet_infoline("Testing Actor::Add");
600   TestApplication application;
601
602   Actor child = Actor::New();
603
604   Actor parent2 = Actor::New();
605   parent2.Add(child);
606
607   // try illegal Add
608   try
609   {
610     parent2.Add(parent2);
611     tet_printf("Assertion test failed - no Exception\n");
612     tet_result(TET_FAIL);
613   }
614   catch(Dali::DaliException& e)
615   {
616     DALI_TEST_PRINT_ASSERT(e);
617     DALI_TEST_ASSERT(e, "&mOwner != &child", TEST_LOCATION);
618     DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
619   }
620   catch(...)
621   {
622     tet_printf("Assertion test failed - wrong Exception\n");
623     tet_result(TET_FAIL);
624   }
625
626   // try reparenting root
627   try
628   {
629     parent2.Add(application.GetScene().GetLayer(0));
630     tet_printf("Assertion test failed - no Exception\n");
631     tet_result(TET_FAIL);
632   }
633   catch(Dali::DaliException& e)
634   {
635     DALI_TEST_PRINT_ASSERT(e);
636     DALI_TEST_ASSERT(e, "!child.IsRoot()", TEST_LOCATION);
637     DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
638   }
639   catch(...)
640   {
641     tet_printf("Assertion test failed - wrong Exception\n");
642     tet_result(TET_FAIL);
643   }
644
645   // try Add empty
646   try
647   {
648     Actor empty;
649     parent2.Add(empty);
650     tet_printf("Assertion test failed - no Exception\n");
651     tet_result(TET_FAIL);
652   }
653   catch(Dali::DaliException& e)
654   {
655     DALI_TEST_PRINT_ASSERT(e);
656     DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
657     DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
658   }
659   catch(...)
660   {
661     tet_printf("Assertion test failed - wrong Exception\n");
662     tet_result(TET_FAIL);
663   }
664
665   END_TEST;
666 }
667
668 int UtcDaliActorRemoveN(void)
669 {
670   tet_infoline("Testing Actor::Remove");
671   TestApplication application;
672
673   Actor parent = Actor::New();
674   Actor child  = Actor::New();
675   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
676
677   parent.Add(child);
678   DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
679
680   parent.Remove(child);
681   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
682
683   // remove again, no problem
684   parent.Remove(child);
685   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
686
687   // add child back
688   parent.Add(child);
689   DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
690   // try Remove self, its a no-op
691   parent.Remove(parent);
692   DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
693
694   // try Remove empty
695   try
696   {
697     Actor empty;
698     parent.Remove(empty);
699     tet_printf("Assertion test failed - no Exception\n");
700     tet_result(TET_FAIL);
701   }
702   catch(Dali::DaliException& e)
703   {
704     DALI_TEST_PRINT_ASSERT(e);
705     DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
706     DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
707   }
708   catch(...)
709   {
710     tet_printf("Assertion test failed - wrong Exception\n");
711     tet_result(TET_FAIL);
712   }
713   END_TEST;
714 }
715
716 int UtcDaliActorRemoveP(void)
717 {
718   TestApplication application;
719
720   Actor parent = Actor::New();
721   Actor child  = Actor::New();
722   Actor random = Actor::New();
723
724   application.GetScene().Add(parent);
725
726   DALI_TEST_CHECK(parent.GetChildCount() == 0);
727
728   parent.Add(child);
729
730   DALI_TEST_CHECK(parent.GetChildCount() == 1);
731
732   parent.Remove(random);
733
734   DALI_TEST_CHECK(parent.GetChildCount() == 1);
735
736   application.GetScene().Remove(parent);
737
738   DALI_TEST_CHECK(parent.GetChildCount() == 1);
739   END_TEST;
740 }
741
742 int UtcDaliActorSwitchParentN(void)
743 {
744   tet_infoline("Testing Actor::UtcDaliActorSwitchParentN");
745   TestApplication application;
746
747   Actor parent1 = Actor::New();
748   Actor child   = Actor::New();
749
750   DALI_TEST_EQUALS(parent1.GetChildCount(), 0u, TEST_LOCATION);
751
752   parent1.Add(child);
753
754   DALI_TEST_EQUALS(parent1.GetChildCount(), 1u, TEST_LOCATION);
755
756   Actor parent2 = Actor::New();
757
758   DALI_TEST_EQUALS(parent2.GetChildCount(), 0u, TEST_LOCATION);
759
760   // Try switch parent with that both of parent1 and parent2 are off scene.
761   DevelActor::SwitchParent(child, parent2);
762
763   DALI_TEST_EQUALS(parent1.GetChildCount(), 1u, TEST_LOCATION);
764   DALI_TEST_EQUALS(parent2.GetChildCount(), 0u, TEST_LOCATION);
765   END_TEST;
766 }
767
768 int UtcDaliActorGetChildCount(void)
769 {
770   TestApplication application;
771
772   Actor parent = Actor::New();
773   Actor child  = Actor::New();
774
775   DALI_TEST_CHECK(parent.GetChildCount() == 0);
776
777   parent.Add(child);
778
779   DALI_TEST_CHECK(parent.GetChildCount() == 1);
780   END_TEST;
781 }
782
783 int UtcDaliActorGetChildren01(void)
784 {
785   TestApplication application;
786
787   Actor parent = Actor::New();
788   Actor first  = Actor::New();
789   Actor second = Actor::New();
790   Actor third  = Actor::New();
791
792   parent.Add(first);
793   parent.Add(second);
794   parent.Add(third);
795
796   DALI_TEST_CHECK(parent.GetChildAt(0) == first);
797   DALI_TEST_CHECK(parent.GetChildAt(1) == second);
798   DALI_TEST_CHECK(parent.GetChildAt(2) == third);
799   END_TEST;
800 }
801
802 int UtcDaliActorGetChildren02(void)
803 {
804   TestApplication application;
805
806   Actor parent = Actor::New();
807   Actor first  = Actor::New();
808   Actor second = Actor::New();
809   Actor third  = Actor::New();
810
811   parent.Add(first);
812   parent.Add(second);
813   parent.Add(third);
814
815   const Actor& constParent = parent;
816
817   DALI_TEST_CHECK(constParent.GetChildAt(0) == first);
818   DALI_TEST_CHECK(constParent.GetChildAt(1) == second);
819   DALI_TEST_CHECK(constParent.GetChildAt(2) == third);
820   END_TEST;
821 }
822
823 int UtcDaliActorGetParent01(void)
824 {
825   TestApplication application;
826
827   Actor parent = Actor::New();
828   Actor child  = Actor::New();
829
830   parent.Add(child);
831
832   DALI_TEST_CHECK(child.GetParent() == parent);
833   END_TEST;
834 }
835
836 int UtcDaliActorGetParent02(void)
837 {
838   TestApplication application;
839
840   Actor actor = Actor::New();
841
842   DALI_TEST_CHECK(!actor.GetParent());
843   END_TEST;
844 }
845
846 int UtcDaliActorCustomProperty(void)
847 {
848   TestApplication application;
849
850   Actor actor = Actor::New();
851   application.GetScene().Add(actor);
852
853   float           startValue(1.0f);
854   Property::Index index = actor.RegisterProperty("testProperty", startValue);
855   DALI_TEST_CHECK(actor.GetProperty<float>(index) == startValue);
856
857   application.SendNotification();
858   application.Render(0);
859   DALI_TEST_CHECK(actor.GetProperty<float>(index) == startValue);
860
861   actor.SetProperty(index, 5.0f);
862
863   application.SendNotification();
864   application.Render(0);
865   DALI_TEST_CHECK(actor.GetProperty<float>(index) == 5.0f);
866   END_TEST;
867 }
868
869 int UtcDaliActorCustomPropertyIntToFloat(void)
870 {
871   TestApplication application;
872
873   Actor actor = Actor::New();
874   application.GetScene().Add(actor);
875
876   float           startValue(5.0f);
877   Property::Index index = actor.RegisterProperty("testProperty", startValue);
878   DALI_TEST_CHECK(actor.GetProperty<float>(index) == startValue);
879
880   application.SendNotification();
881   application.Render(0);
882   DALI_TEST_CHECK(actor.GetProperty<float>(index) == startValue);
883
884   actor.SetProperty(index, int(1));
885
886   application.SendNotification();
887   application.Render(0);
888   DALI_TEST_CHECK(actor.GetProperty<float>(index) == 1.0f);
889   END_TEST;
890 }
891
892 int UtcDaliActorCustomPropertyFloatToInt(void)
893 {
894   TestApplication application;
895
896   Actor actor = Actor::New();
897   application.GetScene().Add(actor);
898
899   int             startValue(5);
900   Property::Index index = actor.RegisterProperty("testProperty", startValue);
901   DALI_TEST_CHECK(actor.GetProperty<int>(index) == startValue);
902
903   application.SendNotification();
904   application.Render(0);
905   DALI_TEST_CHECK(actor.GetProperty<int>(index) == startValue);
906
907   actor.SetProperty(index, float(1.5));
908
909   application.SendNotification();
910   application.Render(0);
911   DALI_TEST_CHECK(actor.GetProperty<int>(index) == 1);
912   END_TEST;
913 }
914
915 int UtcDaliActorSetParentOrigin(void)
916 {
917   TestApplication application;
918
919   Actor actor = Actor::New();
920
921   Vector3 vector(0.7f, 0.8f, 0.9f);
922   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
923
924   actor.SetProperty(Actor::Property::PARENT_ORIGIN, vector);
925
926   // flush the queue and render once
927   application.SendNotification();
928   application.Render();
929
930   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
931
932   application.GetScene().Add(actor);
933
934   actor.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0.1f, 0.2f, 0.3f));
935
936   // flush the queue and render once
937   application.SendNotification();
938   application.Render();
939
940   DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), TEST_LOCATION);
941
942   application.GetScene().Remove(actor);
943   END_TEST;
944 }
945
946 int UtcDaliActorSetParentOriginIndividual(void)
947 {
948   TestApplication application;
949
950   Actor actor = Actor::New();
951
952   Vector3 vector(0.7f, 0.8f, 0.9f);
953   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
954
955   actor.SetProperty(Actor::Property::PARENT_ORIGIN_X, vector.x);
956
957   // flush the queue and render once
958   application.SendNotification();
959   application.Render();
960
961   DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN).x, TEST_LOCATION);
962
963   actor.SetProperty(Actor::Property::PARENT_ORIGIN_Y, vector.y);
964
965   // flush the queue and render once
966   application.SendNotification();
967   application.Render();
968
969   DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN).y, TEST_LOCATION);
970
971   actor.SetProperty(Actor::Property::PARENT_ORIGIN_Z, vector.z);
972
973   // flush the queue and render once
974   application.SendNotification();
975   application.Render();
976
977   DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN).z, TEST_LOCATION);
978
979   END_TEST;
980 }
981
982 int UtcDaliActorGetCurrentParentOrigin(void)
983 {
984   TestApplication application;
985
986   Actor actor = Actor::New();
987
988   Vector3 vector(0.7f, 0.8f, 0.9f);
989   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
990
991   actor.SetProperty(Actor::Property::PARENT_ORIGIN, vector);
992
993   // flush the queue and render once
994   application.SendNotification();
995   application.Render();
996
997   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
998   END_TEST;
999 }
1000
1001 int UtcDaliActorSetAnchorPoint(void)
1002 {
1003   TestApplication application;
1004
1005   Actor actor = Actor::New();
1006
1007   Vector3 vector(0.7f, 0.8f, 0.9f);
1008   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
1009
1010   actor.SetProperty(Actor::Property::ANCHOR_POINT, vector);
1011
1012   // flush the queue and render once
1013   application.SendNotification();
1014   application.Render();
1015
1016   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
1017
1018   application.GetScene().Add(actor);
1019
1020   actor.SetProperty(Actor::Property::ANCHOR_POINT, Vector3(0.1f, 0.2f, 0.3f));
1021   // flush the queue and render once
1022   application.SendNotification();
1023   application.Render();
1024
1025   DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), TEST_LOCATION);
1026
1027   application.GetScene().Remove(actor);
1028   END_TEST;
1029 }
1030
1031 int UtcDaliActorSetAnchorPointIndividual(void)
1032 {
1033   TestApplication application;
1034
1035   Actor actor = Actor::New();
1036
1037   Vector3 vector(0.7f, 0.8f, 0.9f);
1038   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
1039
1040   actor.SetProperty(Actor::Property::ANCHOR_POINT_X, vector.x);
1041
1042   // flush the queue and render once
1043   application.SendNotification();
1044   application.Render();
1045
1046   DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT).x, TEST_LOCATION);
1047
1048   actor.SetProperty(Actor::Property::ANCHOR_POINT_Y, vector.y);
1049
1050   // flush the queue and render once
1051   application.SendNotification();
1052   application.Render();
1053
1054   DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT).y, TEST_LOCATION);
1055
1056   actor.SetProperty(Actor::Property::ANCHOR_POINT_Z, vector.z);
1057
1058   // flush the queue and render once
1059   application.SendNotification();
1060   application.Render();
1061
1062   DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT).z, TEST_LOCATION);
1063
1064   END_TEST;
1065 }
1066
1067 int UtcDaliActorGetCurrentAnchorPoint(void)
1068 {
1069   TestApplication application;
1070
1071   Actor actor = Actor::New();
1072
1073   Vector3 vector(0.7f, 0.8f, 0.9f);
1074   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
1075
1076   actor.SetProperty(Actor::Property::ANCHOR_POINT, vector);
1077
1078   // flush the queue and render once
1079   application.SendNotification();
1080   application.Render();
1081
1082   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
1083   END_TEST;
1084 }
1085
1086 int UtcDaliActorSetSize01(void)
1087 {
1088   TestApplication application;
1089
1090   Actor   actor = Actor::New();
1091   Vector3 vector(100.0f, 100.0f, 0.0f);
1092
1093   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1094
1095   actor.SetProperty(Actor::Property::SIZE, Vector2(vector.x, vector.y));
1096
1097   // Immediately retrieve the size after setting
1098   Vector3 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1099   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1100   DALI_TEST_EQUALS(vector.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
1101   DALI_TEST_EQUALS(vector.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
1102   DALI_TEST_EQUALS(vector.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
1103
1104   // Flush the queue and render once
1105   application.SendNotification();
1106   application.Render();
1107
1108   // Check the size in the new frame
1109   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1110
1111   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1112   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1113   DALI_TEST_EQUALS(vector.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
1114   DALI_TEST_EQUALS(vector.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
1115   DALI_TEST_EQUALS(vector.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
1116
1117   // Check async behaviour
1118   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
1119   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1120   DALI_TEST_EQUALS(vector.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
1121   DALI_TEST_EQUALS(vector.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
1122   DALI_TEST_EQUALS(vector.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
1123
1124   // Change the resize policy and check whether the size stays the same
1125   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
1126
1127   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1128   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1129
1130   // Set a new size after resize policy is changed and check the new size
1131   actor.SetProperty(Actor::Property::SIZE, Vector3(0.1f, 0.2f, 0.0f));
1132
1133   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1134   DALI_TEST_EQUALS(currentSize, Vector3(0.1f, 0.2f, 0.0f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1135
1136   // Change the resize policy again and check whether the new size stays the same
1137   actor.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
1138
1139   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1140   DALI_TEST_EQUALS(currentSize, Vector3(0.1f, 0.2f, 0.0f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1141
1142   // Set another new size after resize policy is changed and check the new size
1143   actor.SetProperty(Actor::Property::SIZE, Vector3(50.0f, 60.0f, 0.0f));
1144
1145   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1146   DALI_TEST_EQUALS(currentSize, Vector3(50.0f, 60.0f, 0.0f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1147
1148   END_TEST;
1149 }
1150
1151 int UtcDaliActorSetSize02(void)
1152 {
1153   TestApplication application;
1154
1155   Actor   actor = Actor::New();
1156   Vector3 vector(100.0f, 100.0f, 100.0f);
1157
1158   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1159
1160   actor.SetProperty(Actor::Property::SIZE, Vector3(vector.x, vector.y, vector.z));
1161
1162   // Immediately check the size after setting
1163   Vector3 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1164   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1165
1166   // flush the queue and render once
1167   application.SendNotification();
1168   application.Render();
1169
1170   // Check the size in the new frame
1171   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1172
1173   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1174   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1175
1176   END_TEST;
1177 }
1178
1179 // SetSize(Vector2 size)
1180 int UtcDaliActorSetSize03(void)
1181 {
1182   TestApplication application;
1183
1184   Actor   actor = Actor::New();
1185   Vector3 vector(100.0f, 100.0f, 0.0f);
1186
1187   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1188
1189   actor.SetProperty(Actor::Property::SIZE, Vector2(vector.x, vector.y));
1190
1191   // Immediately check the size after setting
1192   Vector3 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1193   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1194
1195   // flush the queue and render once
1196   application.SendNotification();
1197   application.Render();
1198
1199   // Check the size in the new frame
1200   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1201
1202   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1203   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1204
1205   END_TEST;
1206 }
1207
1208 // SetSize(Vector3 size)
1209 int UtcDaliActorSetSize04(void)
1210 {
1211   TestApplication application;
1212
1213   Actor   actor = Actor::New();
1214   Vector3 vector(100.0f, 100.0f, 100.0f);
1215
1216   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1217
1218   actor.SetProperty(Actor::Property::SIZE, vector);
1219
1220   // Immediately check the size after setting
1221   Vector3 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1222   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1223
1224   // flush the queue and render once
1225   application.SendNotification();
1226   application.Render();
1227
1228   // Check the size in the new frame
1229   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1230
1231   application.GetScene().Add(actor);
1232   actor.SetProperty(Actor::Property::SIZE, Vector3(0.1f, 0.2f, 0.3f));
1233
1234   // Immediately check the size after setting
1235   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1236   DALI_TEST_EQUALS(currentSize, Vector3(0.1f, 0.2f, 0.3f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1237
1238   // flush the queue and render once
1239   application.SendNotification();
1240   application.Render();
1241
1242   // Check the size in the new frame
1243   DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE), TEST_LOCATION);
1244
1245   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1246   DALI_TEST_EQUALS(currentSize, Vector3(0.1f, 0.2f, 0.3f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1247
1248   application.GetScene().Remove(actor);
1249   END_TEST;
1250 }
1251
1252 int UtcDaliActorSetSize05(void)
1253 {
1254   TestApplication application;
1255
1256   Actor   parent = Actor::New();
1257   Vector2 vector(200.0f, 200.0f);
1258   DALI_TEST_CHECK(vector != parent.GetCurrentProperty<Vector2>(Actor::Property::SIZE));
1259
1260   parent.SetProperty(Actor::Property::SIZE, vector);
1261   Vector2 size = parent.GetProperty(Actor::Property::SIZE).Get<Vector2>();
1262   DALI_TEST_EQUALS(size, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1263
1264   Actor child = Actor::New();
1265   DALI_TEST_CHECK(vector != child.GetCurrentProperty<Vector2>(Actor::Property::SIZE));
1266   child.SetProperty(Actor::Property::SIZE, vector);
1267   size = parent.GetProperty(Actor::Property::SIZE).Get<Vector2>();
1268   DALI_TEST_EQUALS(size, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1269
1270   // flush the queue and render once
1271   application.SendNotification();
1272   application.Render();
1273
1274   DALI_TEST_CHECK(vector == parent.GetCurrentProperty<Vector2>(Actor::Property::SIZE));
1275
1276   END_TEST;
1277 }
1278
1279 int UtcDaliActorSetSizeIndividual(void)
1280 {
1281   TestApplication application;
1282
1283   Actor actor = Actor::New();
1284
1285   Vector3 vector(0.7f, 0.8f, 0.9f);
1286   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1287
1288   actor.SetProperty(Actor::Property::SIZE_WIDTH, vector.width);
1289
1290   // Immediately check the width after setting
1291   float sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1292   DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1293
1294   // flush the queue and render once
1295   application.SendNotification();
1296   application.Render();
1297
1298   // Check the width in the new frame
1299   DALI_TEST_EQUALS(vector.width, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, TEST_LOCATION);
1300
1301   sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1302   DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1303
1304   actor.SetProperty(Actor::Property::SIZE_HEIGHT, vector.height);
1305
1306   // Immediately check the height after setting
1307   float sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1308   DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1309
1310   // flush the queue and render once
1311   application.SendNotification();
1312   application.Render();
1313
1314   // Check the height in the new frame
1315   DALI_TEST_EQUALS(vector.height, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, TEST_LOCATION);
1316
1317   sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1318   DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1319
1320   actor.SetProperty(Actor::Property::SIZE_DEPTH, vector.depth);
1321
1322   // Immediately check the depth after setting
1323   float sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1324   DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1325
1326   // flush the queue and render once
1327   application.SendNotification();
1328   application.Render();
1329
1330   // Check the depth in the new frame
1331   DALI_TEST_EQUALS(vector.depth, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).depth, TEST_LOCATION);
1332
1333   sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1334   DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1335
1336   // Change the resize policy and check whether the size stays the same
1337   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
1338
1339   sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1340   DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1341
1342   sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1343   DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1344
1345   sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1346   DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1347
1348   // Change the resize policy again and check whether the size stays the same
1349   actor.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
1350
1351   sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1352   DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1353
1354   sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1355   DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1356
1357   sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1358   DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1359
1360   END_TEST;
1361 }
1362
1363 int UtcDaliActorSetSizeIndividual02(void)
1364 {
1365   TestApplication application;
1366
1367   Actor actor = Actor::New();
1368   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
1369   application.GetScene().Add(actor);
1370
1371   Vector3 vector(100.0f, 200.0f, 400.0f);
1372   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1373
1374   actor.SetProperty(Actor::Property::SIZE_WIDTH, vector.width);
1375   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>(), vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1376
1377   actor.SetProperty(Actor::Property::SIZE_HEIGHT, vector.height);
1378   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>(), vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1379
1380   actor.SetProperty(Actor::Property::SIZE_DEPTH, vector.depth);
1381   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>(), vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1382
1383   // flush the queue and render once
1384   application.SendNotification();
1385   application.Render();
1386
1387   // Check the width in the new frame
1388   DALI_TEST_EQUALS(vector.width, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, TEST_LOCATION);
1389   DALI_TEST_EQUALS(vector.height, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, TEST_LOCATION);
1390
1391   END_TEST;
1392 }
1393
1394 int UtcDaliActorGetCurrentSize(void)
1395 {
1396   TestApplication application;
1397
1398   Actor   actor = Actor::New();
1399   Vector3 vector(100.0f, 100.0f, 20.0f);
1400
1401   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1402
1403   actor.SetProperty(Actor::Property::SIZE, vector);
1404
1405   // flush the queue and render once
1406   application.SendNotification();
1407   application.Render();
1408
1409   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1410   END_TEST;
1411 }
1412
1413 int UtcDaliActorGetNaturalSize(void)
1414 {
1415   TestApplication application;
1416
1417   Actor   actor = Actor::New();
1418   Vector3 vector(0.0f, 0.0f, 0.0f);
1419
1420   DALI_TEST_CHECK(actor.GetNaturalSize() == vector);
1421
1422   END_TEST;
1423 }
1424
1425 int UtcDaliActorGetCurrentSizeImmediate(void)
1426 {
1427   TestApplication application;
1428
1429   Actor   actor = Actor::New();
1430   Vector3 vector(100.0f, 100.0f, 20.0f);
1431
1432   DALI_TEST_CHECK(vector != actor.GetTargetSize());
1433   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1434
1435   actor.SetProperty(Actor::Property::SIZE, vector);
1436
1437   DALI_TEST_CHECK(vector == actor.GetTargetSize());
1438   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1439
1440   // flush the queue and render once
1441   application.SendNotification();
1442   application.Render();
1443
1444   DALI_TEST_CHECK(vector == actor.GetTargetSize());
1445   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1446
1447   // Animation
1448   // Build the animation
1449   const float   durationSeconds = 2.0f;
1450   Animation     animation       = Animation::New(durationSeconds);
1451   const Vector3 targetValue(10.0f, 20.0f, 30.0f);
1452   animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
1453
1454   DALI_TEST_CHECK(actor.GetTargetSize() == vector);
1455
1456   application.GetScene().Add(actor);
1457
1458   // Start the animation
1459   animation.Play();
1460
1461   application.SendNotification();
1462   application.Render(static_cast<unsigned int>(durationSeconds * 1000.0f));
1463
1464   DALI_TEST_CHECK(actor.GetTargetSize() == targetValue);
1465
1466   END_TEST;
1467 }
1468
1469 int UtcDaliActorCalculateScreenExtents(void)
1470 {
1471   TestApplication application;
1472
1473   Actor actor = Actor::New();
1474
1475   actor.SetProperty(Actor::Property::POSITION, Vector3(2.0f, 2.0f, 16.0f));
1476   actor.SetProperty(Actor::Property::SIZE, Vector3{1.0f, 1.0f, 1.0f});
1477
1478   application.GetScene().Add(actor);
1479
1480   application.SendNotification();
1481   application.Render();
1482
1483   auto expectedExtent = Rect<>{1.5f, 1.5f, 1.0f, 1.0f};
1484   auto actualExtent   = DevelActor::CalculateScreenExtents(actor);
1485   DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1486   DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1487   DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1488   DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1489
1490   application.GetScene().Remove(actor);
1491   END_TEST;
1492 }
1493
1494 int UtcDaliActorCalculateScreenExtentsInCustomCameraAndLayer3D(void)
1495 {
1496   TestApplication    application;
1497   Integration::Scene scene = application.GetScene();
1498
1499   // Make 3D Layer
1500   Layer layer = Layer::New();
1501   layer.SetProperty(Layer::Property::BEHAVIOR, Layer::Behavior::LAYER_3D);
1502   layer.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1503   layer.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1504
1505   scene.Add(layer);
1506
1507   // Build custom camera with top-view
1508   CameraActor cameraActor = scene.GetRenderTaskList().GetTask(0).GetCameraActor();
1509   {
1510     // Default camera position at +z and looking -z axis. (orientation is [ Axis: [0, 1, 0], Angle: 180 degrees ])
1511     Vector3    cameraPos    = cameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
1512     Quaternion cameraOrient = cameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
1513
1514     {
1515       std::ostringstream oss;
1516       oss << cameraPos << "\n";
1517       oss << cameraOrient << "\n";
1518       tet_printf("%s\n", oss.str().c_str());
1519     }
1520
1521     cameraActor.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -cameraPos.z, 0.0f));
1522     cameraActor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::XAXIS) * cameraOrient);
1523
1524     // Now, upside : -Z, leftside : -X, foward : +Y
1525
1526     cameraPos    = cameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
1527     cameraOrient = cameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
1528     {
1529       std::ostringstream oss;
1530       oss << cameraPos << "\n";
1531       oss << cameraOrient << "\n";
1532       tet_printf("%s\n", oss.str().c_str());
1533     }
1534   }
1535
1536   Actor actor = Actor::New();
1537   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1538   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1539   actor.SetProperty(Actor::Property::POSITION, Vector3(2.0f, 0.0f, 16.0f));
1540   actor.SetProperty(Actor::Property::SIZE, Vector3{1.0f, 0.0f, 3.0f});
1541
1542   layer.Add(actor);
1543
1544   application.SendNotification();
1545   application.Render();
1546
1547   Vector2 sceneSize = scene.GetSize();
1548
1549   auto expectedExtent = Rect<>{sceneSize.x * 0.5f + 1.5f, sceneSize.y * 0.5f + 14.5f, 1.0f, 3.0f};
1550   auto actualExtent   = DevelActor::CalculateScreenExtents(actor);
1551   {
1552     std::ostringstream oss;
1553     oss << expectedExtent << "\n";
1554     oss << actualExtent << "\n";
1555     tet_printf("%s\n", oss.str().c_str());
1556   }
1557
1558   DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1559   DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1560   DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1561   DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1562
1563   END_TEST;
1564 }
1565
1566 int UtcDaliActorCalculateScreenInCustomCameraAndOffscreenLayer3D(void)
1567 {
1568   // TODO : Need to make it works well
1569   TestApplication    application;
1570   Integration::Scene scene     = application.GetScene();
1571   Vector2            sceneSize = scene.GetSize();
1572
1573   // Make 3D Layer
1574   Layer layer = Layer::New();
1575   layer.SetProperty(Layer::Property::BEHAVIOR, Layer::Behavior::LAYER_3D);
1576   layer.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1577   layer.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1578   layer.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
1579   layer.SetProperty(Actor::Property::SIZE, sceneSize);
1580
1581   scene.Add(layer);
1582
1583   // Build custom camera with top-view
1584   CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
1585
1586   offscreenCameraActor.SetPerspectiveProjection(sceneSize);
1587   offscreenCameraActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1588   offscreenCameraActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1589
1590   scene.Add(offscreenCameraActor);
1591   {
1592     // Default camera position at +z and looking -z axis. (orientation is [ Axis: [0, 1, 0], Angle: 180 degrees ])
1593     Vector3    cameraPos    = offscreenCameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
1594     Quaternion cameraOrient = offscreenCameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
1595
1596     {
1597       std::ostringstream oss;
1598       oss << cameraPos << "\n";
1599       oss << cameraOrient << "\n";
1600       tet_printf("%s\n", oss.str().c_str());
1601     }
1602
1603     offscreenCameraActor.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -cameraPos.z, 0.0f));
1604     offscreenCameraActor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::XAXIS) * cameraOrient);
1605
1606     // Now, upside : -Z, leftside : -X, foward : +Y
1607
1608     cameraPos    = offscreenCameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
1609     cameraOrient = offscreenCameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
1610     {
1611       std::ostringstream oss;
1612       oss << cameraPos << "\n";
1613       oss << cameraOrient << "\n";
1614       tet_printf("%s\n", oss.str().c_str());
1615     }
1616   }
1617   Vector3 sourcePosition{2.0f, 0.0f, 16.0f};
1618   Vector3 sourceSize{1.0f, 0.0f, 3.0f};
1619
1620   Actor sourceActor = Actor::New();
1621   sourceActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1622   sourceActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1623   sourceActor.SetProperty(Actor::Property::POSITION, sourcePosition);
1624   sourceActor.SetProperty(Actor::Property::SIZE, sourceSize);
1625
1626   layer.Add(sourceActor);
1627
1628   // Create framebuffer
1629   unsigned int width(64);
1630   unsigned int height(64);
1631   Texture      texture     = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
1632   FrameBuffer  frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::DEPTH_STENCIL);
1633   frameBuffer.AttachColorTexture(texture);
1634
1635   Actor rootActor = Actor::New();
1636   rootActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1637   rootActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1638   rootActor.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
1639   rootActor.SetProperty(Actor::Property::SIZE, sceneSize);
1640   scene.Add(rootActor);
1641
1642   RenderTaskList taskList = scene.GetRenderTaskList();
1643   RenderTask     newTask  = taskList.CreateTask();
1644   newTask.SetCameraActor(offscreenCameraActor);
1645   newTask.SetSourceActor(layer);
1646   newTask.SetInputEnabled(false);
1647   newTask.SetClearColor(Vector4(0.f, 0.f, 0.f, 0.f));
1648   newTask.SetClearEnabled(true);
1649   newTask.SetExclusive(true);
1650   newTask.SetFrameBuffer(frameBuffer);
1651   newTask.SetScreenToFrameBufferMappingActor(rootActor);
1652
1653   application.SendNotification();
1654   application.Render(16u);
1655
1656   auto expectedExtent = Rect<>{sceneSize.x * 0.5f + sourcePosition.x - sourceSize.x * 0.5f,
1657                                sceneSize.y * 0.5f + sourcePosition.z - sourceSize.z * 0.5f,
1658                                sourceSize.x,
1659                                sourceSize.z};
1660   auto actualExtent   = DevelActor::CalculateScreenExtents(sourceActor);
1661   {
1662     std::ostringstream oss;
1663     oss << expectedExtent << "\n";
1664     oss << actualExtent << "\n";
1665     tet_printf("%s\n", oss.str().c_str());
1666   }
1667
1668   auto expectedScreen = Vector2{sceneSize.x * 0.5f + sourcePosition.x, sceneSize.y * 0.5f + sourcePosition.z};
1669   auto actualScreen   = sourceActor.GetProperty<Vector2>(Actor::Property::SCREEN_POSITION);
1670   {
1671     std::ostringstream oss;
1672     oss << expectedScreen << "\n";
1673     oss << actualScreen << "\n";
1674     tet_printf("%s\n", oss.str().c_str());
1675   }
1676
1677   DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1678   DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1679   DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1680   DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1681
1682   DALI_TEST_EQUALS(expectedScreen.x, actualScreen.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1683   DALI_TEST_EQUALS(expectedScreen.y, actualScreen.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1684
1685   // Change rootActor's size and position
1686
1687   Vector3 rootPosition{100.0f, 200.0f, 0.0f};
1688   Vector3 rootSize{200.0f, 100.0f, 0.0f};
1689
1690   rootActor.SetProperty(Actor::Property::POSITION, rootPosition);
1691   rootActor.SetProperty(Actor::Property::SIZE, rootSize);
1692
1693   application.SendNotification();
1694   application.Render(16u);
1695
1696   expectedExtent = Rect<>{sceneSize.x * 0.5f + rootPosition.x + (sourcePosition.x - sourceSize.x * 0.5f) * rootSize.x / sceneSize.x,
1697                           sceneSize.y * 0.5f + rootPosition.y + (sourcePosition.z - sourceSize.z * 0.5f) * rootSize.y / sceneSize.y,
1698                           sourceSize.x * rootSize.x / sceneSize.x,
1699                           sourceSize.z * rootSize.y / sceneSize.y};
1700   actualExtent   = DevelActor::CalculateScreenExtents(sourceActor);
1701   {
1702     std::ostringstream oss;
1703     oss << expectedExtent << "\n";
1704     oss << actualExtent << "\n";
1705     tet_printf("%s\n", oss.str().c_str());
1706   }
1707
1708   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};
1709   actualScreen   = sourceActor.GetProperty<Vector2>(Actor::Property::SCREEN_POSITION);
1710   {
1711     std::ostringstream oss;
1712     oss << expectedScreen << "\n";
1713     oss << actualScreen << "\n";
1714     tet_printf("%s\n", oss.str().c_str());
1715   }
1716
1717   DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1718   DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1719   DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1720   DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1721
1722   DALI_TEST_EQUALS(expectedScreen.x, actualScreen.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1723   DALI_TEST_EQUALS(expectedScreen.y, actualScreen.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1724
1725   END_TEST;
1726 }
1727
1728 // SetPosition(float x, float y)
1729 int UtcDaliActorSetPosition01(void)
1730 {
1731   TestApplication application;
1732
1733   Actor actor = Actor::New();
1734
1735   // Set to random to start off with
1736   actor.SetProperty(Actor::Property::POSITION, Vector3(120.0f, 120.0f, 0.0f));
1737
1738   Vector3 vector(100.0f, 100.0f, 0.0f);
1739
1740   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1741
1742   actor.SetProperty(Actor::Property::POSITION, Vector2(vector.x, vector.y));
1743   // flush the queue and render once
1744   application.SendNotification();
1745   application.Render();
1746   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1747
1748   application.GetScene().Add(actor);
1749   actor.SetProperty(Actor::Property::POSITION, Vector3(0.1f, 0.2f, 0.3f));
1750   // flush the queue and render once
1751   application.SendNotification();
1752   application.Render();
1753   DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
1754
1755   actor.SetProperty(Actor::Property::POSITION_X, 1.0f);
1756   actor.SetProperty(Actor::Property::POSITION_Y, 1.1f);
1757   actor.SetProperty(Actor::Property::POSITION_Z, 1.2f);
1758   // flush the queue and render once
1759   application.SendNotification();
1760   application.Render();
1761   DALI_TEST_EQUALS(Vector3(1.0f, 1.1f, 1.2f), actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
1762
1763   actor.TranslateBy(Vector3(0.1f, 0.1f, 0.1f));
1764   // flush the queue and render once
1765   application.SendNotification();
1766   application.Render();
1767   DALI_TEST_EQUALS(Vector3(1.1f, 1.2f, 1.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1768
1769   application.GetScene().Remove(actor);
1770   END_TEST;
1771 }
1772
1773 // SetPosition(float x, float y, float z)
1774 int UtcDaliActorSetPosition02(void)
1775 {
1776   TestApplication application;
1777
1778   Actor actor = Actor::New();
1779
1780   // Set to random to start off with
1781   actor.SetProperty(Actor::Property::POSITION, Vector3(120.0f, 120.0f, 120.0f));
1782
1783   Vector3 vector(100.0f, 100.0f, 100.0f);
1784
1785   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1786
1787   actor.SetProperty(Actor::Property::POSITION, Vector3(vector.x, vector.y, vector.z));
1788
1789   // flush the queue and render once
1790   application.SendNotification();
1791   application.Render();
1792
1793   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1794   END_TEST;
1795 }
1796
1797 // SetPosition(Vector3 position)
1798 int UtcDaliActorSetPosition03(void)
1799 {
1800   TestApplication application;
1801
1802   Actor actor = Actor::New();
1803
1804   // Set to random to start off with
1805   actor.SetProperty(Actor::Property::POSITION, Vector3(120.0f, 120.0f, 120.0f));
1806
1807   Vector3 vector(100.0f, 100.0f, 100.0f);
1808
1809   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1810
1811   actor.SetProperty(Actor::Property::POSITION, vector);
1812
1813   // flush the queue and render once
1814   application.SendNotification();
1815   application.Render();
1816
1817   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1818   END_TEST;
1819 }
1820
1821 int UtcDaliActorSetX(void)
1822 {
1823   TestApplication application;
1824
1825   Actor actor = Actor::New();
1826
1827   Vector3 vector(100.0f, 0.0f, 0.0f);
1828
1829   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1830
1831   actor.SetProperty(Actor::Property::POSITION_X, 100.0f);
1832
1833   // flush the queue and render once
1834   application.SendNotification();
1835   application.Render();
1836
1837   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1838   END_TEST;
1839 }
1840
1841 int UtcDaliActorSetY(void)
1842 {
1843   TestApplication application;
1844
1845   Actor actor = Actor::New();
1846
1847   Vector3 vector(0.0f, 100.0f, 0.0f);
1848
1849   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1850
1851   actor.SetProperty(Actor::Property::POSITION_Y, 100.0f);
1852
1853   // flush the queue and render once
1854   application.SendNotification();
1855   application.Render();
1856
1857   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1858   END_TEST;
1859 }
1860
1861 int UtcDaliActorSetZ(void)
1862 {
1863   TestApplication application;
1864
1865   Actor actor = Actor::New();
1866
1867   Vector3 vector(0.0f, 0.0f, 100.0f);
1868
1869   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1870
1871   actor.SetProperty(Actor::Property::POSITION_Z, 100.0f);
1872
1873   // flush the queue and render once
1874   application.SendNotification();
1875   application.Render();
1876
1877   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1878   END_TEST;
1879 }
1880
1881 int UtcDaliActorSetPositionProperties(void)
1882 {
1883   TestApplication application;
1884
1885   Actor actor = Actor::New();
1886
1887   Vector3 vector(0.7f, 0.8f, 0.9f);
1888   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1889
1890   actor.SetProperty(Actor::Property::POSITION_X, vector.x);
1891   DALI_TEST_EQUALS(vector.x, actor.GetProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1892   DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::POSITION_X), TEST_LOCATION);
1893
1894   // flush the queue and render once
1895   application.SendNotification();
1896   application.Render();
1897
1898   DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1899   DALI_TEST_EQUALS(vector.x, actor.GetProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1900   DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::POSITION_X), TEST_LOCATION);
1901   DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1902   DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<float>(Actor::Property::POSITION_X), TEST_LOCATION);
1903
1904   actor.SetProperty(Actor::Property::POSITION_Y, vector.y);
1905   DALI_TEST_EQUALS(vector.y, actor.GetProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1906   DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::POSITION_Y), TEST_LOCATION);
1907
1908   // flush the queue and render once
1909   application.SendNotification();
1910   application.Render();
1911
1912   DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1913   DALI_TEST_EQUALS(vector.y, actor.GetProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1914   DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::POSITION_Y), TEST_LOCATION);
1915   DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1916   DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<float>(Actor::Property::POSITION_Y), TEST_LOCATION);
1917
1918   actor.SetProperty(Actor::Property::POSITION_Z, vector.z);
1919   DALI_TEST_EQUALS(vector.z, actor.GetProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1920   DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::POSITION_Z), TEST_LOCATION);
1921
1922   // flush the queue and render once
1923   application.SendNotification();
1924   application.Render();
1925
1926   DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1927   DALI_TEST_EQUALS(vector.z, actor.GetProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1928   DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::POSITION_Z), TEST_LOCATION);
1929   DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1930   DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<float>(Actor::Property::POSITION_Z), TEST_LOCATION);
1931
1932   END_TEST;
1933 }
1934
1935 int UtcDaliActorTranslateBy(void)
1936 {
1937   TestApplication application;
1938
1939   Actor   actor = Actor::New();
1940   Vector3 vector(100.0f, 100.0f, 100.0f);
1941
1942   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1943
1944   actor.SetProperty(Actor::Property::POSITION, vector);
1945
1946   // flush the queue and render once
1947   application.SendNotification();
1948   application.Render();
1949
1950   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1951
1952   actor.TranslateBy(vector);
1953
1954   // flush the queue and render once
1955   application.SendNotification();
1956   application.Render();
1957
1958   DALI_TEST_CHECK(vector * 2.0f == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1959   END_TEST;
1960 }
1961
1962 int UtcDaliActorGetCurrentPosition(void)
1963 {
1964   TestApplication application;
1965
1966   Actor   actor = Actor::New();
1967   Vector3 setVector(100.0f, 100.0f, 0.0f);
1968   actor.SetProperty(Actor::Property::POSITION, setVector);
1969
1970   // flush the queue and render once
1971   application.SendNotification();
1972   application.Render();
1973
1974   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION) == setVector);
1975   END_TEST;
1976 }
1977
1978 int UtcDaliActorGetCurrentWorldPosition(void)
1979 {
1980   TestApplication application;
1981
1982   Actor   parent = Actor::New();
1983   Vector3 parentPosition(1.0f, 2.0f, 3.0f);
1984   parent.SetProperty(Actor::Property::POSITION, parentPosition);
1985   parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1986   parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1987   application.GetScene().Add(parent);
1988
1989   Actor child = Actor::New();
1990   child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1991   child.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1992   Vector3 childPosition(6.0f, 6.0f, 6.0f);
1993   child.SetProperty(Actor::Property::POSITION, childPosition);
1994   parent.Add(child);
1995
1996   // The actors should not have a world position yet
1997   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1998   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1999
2000   application.SendNotification();
2001   application.Render(0);
2002
2003   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
2004   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childPosition, TEST_LOCATION);
2005
2006   // The actors should have a world position now
2007   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
2008   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition + childPosition, TEST_LOCATION);
2009   END_TEST;
2010 }
2011
2012 int UtcDaliActorSetInheritPosition(void)
2013 {
2014   tet_infoline("Testing Actor::SetInheritPosition");
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(10.0f, 11.0f, 12.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   // first test default, which is to inherit position
2036   DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_POSITION), true, TEST_LOCATION);
2037   application.SendNotification();
2038   application.Render(0); // should only really call Update as Render is not required to update scene
2039   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
2040   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childPosition, TEST_LOCATION);
2041   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
2042   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition + childPosition, TEST_LOCATION);
2043
2044   //Change child position
2045   Vector3 childOffset(-1.0f, 1.0f, 0.0f);
2046   child.SetProperty(Actor::Property::POSITION, childOffset);
2047
2048   // Use local position as world postion
2049   child.SetProperty(Actor::Property::INHERIT_POSITION, false);
2050   DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_POSITION), false, TEST_LOCATION);
2051   application.SendNotification();
2052   application.Render(0); // should only really call Update as Render is not required to update scene
2053   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
2054   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childOffset, TEST_LOCATION);
2055   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
2056   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), childOffset, TEST_LOCATION);
2057
2058   //Change back to inherit position from parent
2059   child.SetProperty(Actor::Property::INHERIT_POSITION, true);
2060   DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_POSITION), true, TEST_LOCATION);
2061   application.SendNotification();
2062   application.Render(0); // should only really call Update as Render is not required to update scene
2063   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
2064   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childOffset, TEST_LOCATION);
2065   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
2066   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition + childOffset, TEST_LOCATION);
2067   END_TEST;
2068 }
2069
2070 int UtcDaliActorInheritOpacity(void)
2071 {
2072   tet_infoline("Testing Actor::Inherit Opacity");
2073   TestApplication application;
2074
2075   Actor parent = Actor::New();
2076   Actor child  = Actor::New();
2077   parent.Add(child);
2078   application.GetScene().Add(parent);
2079
2080   DALI_TEST_EQUALS(parent.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION);
2081   DALI_TEST_EQUALS(child.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION);
2082
2083   // flush the queue and render once
2084   application.SendNotification();
2085   application.Render();
2086
2087   parent.SetProperty(Actor::Property::OPACITY, 0.1f);
2088
2089   DALI_TEST_EQUALS(parent.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION);
2090   DALI_TEST_EQUALS(child.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION);
2091
2092   application.SendNotification();
2093   application.Render();
2094
2095   DALI_TEST_EQUALS(parent.GetProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
2096   DALI_TEST_EQUALS(parent.GetCurrentProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION);
2097   DALI_TEST_EQUALS(parent.GetCurrentProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
2098   DALI_TEST_EQUALS(child.GetProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
2099   DALI_TEST_EQUALS(child.GetCurrentProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
2100   DALI_TEST_EQUALS(child.GetCurrentProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.f, 0.0001f, TEST_LOCATION);
2101
2102   END_TEST;
2103 }
2104
2105 // SetOrientation(float angleRadians, Vector3 axis)
2106 int UtcDaliActorSetOrientation01(void)
2107 {
2108   TestApplication application;
2109
2110   Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
2111   Actor      actor = Actor::New();
2112
2113   actor.SetProperty(Actor::Property::ORIENTATION, rotation);
2114
2115   // flush the queue and render once
2116   application.SendNotification();
2117   application.Render();
2118
2119   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2120   END_TEST;
2121 }
2122
2123 int UtcDaliActorSetOrientation02(void)
2124 {
2125   TestApplication application;
2126
2127   Actor actor = Actor::New();
2128
2129   Radian  angle(0.785f);
2130   Vector3 axis(1.0f, 1.0f, 0.0f);
2131
2132   actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(angle, axis));
2133   Quaternion rotation(angle, axis);
2134   // flush the queue and render once
2135   application.SendNotification();
2136   application.Render();
2137   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2138
2139   application.GetScene().Add(actor);
2140   actor.RotateBy(Degree(360), axis);
2141   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2142
2143   actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(0), Vector3(1.0f, 0.0f, 0.0f)));
2144   Quaternion result(Radian(0), Vector3(1.0f, 0.0f, 0.0f));
2145   // flush the queue and render once
2146   application.SendNotification();
2147   application.Render();
2148   DALI_TEST_EQUALS(result, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2149
2150   actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(angle, axis));
2151   // flush the queue and render once
2152   application.SendNotification();
2153   application.Render();
2154   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2155
2156   application.GetScene().Remove(actor);
2157   END_TEST;
2158 }
2159
2160 // SetOrientation(float angleRadians, Vector3 axis)
2161 int UtcDaliActorSetOrientationProperty(void)
2162 {
2163   TestApplication application;
2164
2165   Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
2166   Actor      actor = Actor::New();
2167
2168   actor.SetProperty(Actor::Property::ORIENTATION, rotation);
2169   DALI_TEST_EQUALS(rotation, actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2170
2171   // flush the queue and render once
2172   application.SendNotification();
2173   application.Render();
2174
2175   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2176   DALI_TEST_EQUALS(rotation, actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2177   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2178   END_TEST;
2179 }
2180
2181 // RotateBy(float angleRadians, Vector3 axis)
2182 int UtcDaliActorRotateBy01(void)
2183 {
2184   TestApplication application;
2185
2186   Actor actor = Actor::New();
2187
2188   Radian angle(M_PI * 0.25f);
2189   actor.RotateBy((angle), Vector3::ZAXIS);
2190   // flush the queue and render once
2191   application.SendNotification();
2192   application.Render();
2193   DALI_TEST_EQUALS(Quaternion(angle, Vector3::ZAXIS), actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2194
2195   application.GetScene().Add(actor);
2196
2197   actor.RotateBy(angle, Vector3::ZAXIS);
2198   // flush the queue and render once
2199   application.SendNotification();
2200   application.Render();
2201   DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2202
2203   application.GetScene().Remove(actor);
2204   END_TEST;
2205 }
2206
2207 // RotateBy(Quaternion relativeRotation)
2208 int UtcDaliActorRotateBy02(void)
2209 {
2210   TestApplication application;
2211
2212   Actor actor = Actor::New();
2213
2214   Radian     angle(M_PI * 0.25f);
2215   Quaternion rotation(angle, Vector3::ZAXIS);
2216   actor.RotateBy(rotation);
2217   // flush the queue and render once
2218   application.SendNotification();
2219   application.Render();
2220   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2221
2222   actor.RotateBy(rotation);
2223   // flush the queue and render once
2224   application.SendNotification();
2225   application.Render();
2226   DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2227   END_TEST;
2228 }
2229
2230 int UtcDaliActorGetCurrentOrientation(void)
2231 {
2232   TestApplication application;
2233   Actor           actor = Actor::New();
2234
2235   Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
2236   actor.SetProperty(Actor::Property::ORIENTATION, rotation);
2237   // flush the queue and render once
2238   application.SendNotification();
2239   application.Render();
2240   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2241   END_TEST;
2242 }
2243
2244 int UtcDaliActorGetCurrentWorldOrientation(void)
2245 {
2246   tet_infoline("Testing Actor::GetCurrentWorldRotation");
2247   TestApplication application;
2248
2249   Actor      parent = Actor::New();
2250   Radian     rotationAngle(Degree(90.0f));
2251   Quaternion rotation(rotationAngle, Vector3::YAXIS);
2252   parent.SetProperty(Actor::Property::ORIENTATION, rotation);
2253   application.GetScene().Add(parent);
2254
2255   Actor child = Actor::New();
2256   child.SetProperty(Actor::Property::ORIENTATION, rotation);
2257   parent.Add(child);
2258
2259   // The actors should not have a world rotation yet
2260   DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION);
2261   DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION);
2262
2263   application.SendNotification();
2264   application.Render(0);
2265
2266   DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), rotation, 0.001, TEST_LOCATION);
2267   DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), rotation, 0.001, TEST_LOCATION);
2268
2269   // The actors should have a world rotation now
2270   DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(rotationAngle, Vector3::YAXIS), 0.001, TEST_LOCATION);
2271   DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(rotationAngle * 2.0f, Vector3::YAXIS), 0.001, TEST_LOCATION);
2272
2273   // turn off child rotation inheritance
2274   child.SetProperty(Actor::Property::INHERIT_ORIENTATION, false);
2275   DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_ORIENTATION), false, TEST_LOCATION);
2276   application.SendNotification();
2277   application.Render(0);
2278
2279   // The actors should have a world rotation now
2280   DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(rotationAngle, Vector3::YAXIS), 0.001, TEST_LOCATION);
2281   DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), rotation, 0.001, TEST_LOCATION);
2282   END_TEST;
2283 }
2284
2285 // SetScale(float scale)
2286 int UtcDaliActorSetScale01(void)
2287 {
2288   TestApplication application;
2289
2290   Actor actor = Actor::New();
2291
2292   // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
2293   actor.SetProperty(Actor::Property::SCALE, 0.25f);
2294
2295   Vector3 scale(10.0f, 10.0f, 10.0f);
2296   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) != scale);
2297
2298   actor.SetProperty(Actor::Property::SCALE, scale.x);
2299
2300   // flush the queue and render once
2301   application.SendNotification();
2302   application.Render();
2303
2304   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
2305   END_TEST;
2306 }
2307
2308 // SetScale(float scaleX, float scaleY, float scaleZ)
2309 int UtcDaliActorSetScale02(void)
2310 {
2311   TestApplication application;
2312   Vector3         scale(10.0f, 10.0f, 10.0f);
2313
2314   Actor actor = Actor::New();
2315
2316   // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
2317   actor.SetProperty(Actor::Property::SCALE, Vector3(12.0f, 1.0f, 2.0f));
2318
2319   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) != scale);
2320
2321   actor.SetProperty(Actor::Property::SCALE, Vector3(scale.x, scale.y, scale.z));
2322   // flush the queue and render once
2323   application.SendNotification();
2324   application.Render();
2325   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
2326
2327   // add to stage and test
2328   application.GetScene().Add(actor);
2329   actor.SetProperty(Actor::Property::SCALE, Vector3(2.0f, 2.0f, 2.0f));
2330   // flush the queue and render once
2331   application.SendNotification();
2332   application.Render();
2333   DALI_TEST_EQUALS(Vector3(2.0f, 2.0f, 2.0f), actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE), 0.001, TEST_LOCATION);
2334
2335   application.GetScene().Remove(actor);
2336
2337   END_TEST;
2338 }
2339
2340 // SetScale(Vector3 scale)
2341 int UtcDaliActorSetScale03(void)
2342 {
2343   TestApplication application;
2344   Vector3         scale(10.0f, 10.0f, 10.0f);
2345
2346   Actor actor = Actor::New();
2347
2348   // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
2349   actor.SetProperty(Actor::Property::SCALE, Vector3(12.0f, 1.0f, 2.0f));
2350
2351   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) != scale);
2352
2353   actor.SetProperty(Actor::Property::SCALE, scale);
2354
2355   // flush the queue and render once
2356   application.SendNotification();
2357   application.Render();
2358
2359   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
2360   END_TEST;
2361 }
2362
2363 int UtcDaliActorSetScaleIndividual(void)
2364 {
2365   TestApplication application;
2366
2367   Actor actor = Actor::New();
2368
2369   Vector3 vector(0.7f, 0.8f, 0.9f);
2370   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2371
2372   actor.SetProperty(Actor::Property::SCALE_X, vector.x);
2373   DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::SCALE_X), TEST_LOCATION);
2374
2375   // flush the queue and render once
2376   application.SendNotification();
2377   application.Render();
2378
2379   DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE).x, TEST_LOCATION);
2380   DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::SCALE_X), TEST_LOCATION);
2381   DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<float>(Actor::Property::SCALE_X), TEST_LOCATION);
2382
2383   actor.SetProperty(Actor::Property::SCALE_Y, vector.y);
2384   DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::SCALE_Y), TEST_LOCATION);
2385
2386   // flush the queue and render once
2387   application.SendNotification();
2388   application.Render();
2389
2390   DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE).y, TEST_LOCATION);
2391   DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::SCALE_Y), TEST_LOCATION);
2392   DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<float>(Actor::Property::SCALE_Y), TEST_LOCATION);
2393
2394   actor.SetProperty(Actor::Property::SCALE_Z, vector.z);
2395   DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::SCALE_Z), TEST_LOCATION);
2396
2397   // flush the queue and render once
2398   application.SendNotification();
2399   application.Render();
2400
2401   DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE).z, TEST_LOCATION);
2402   DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::SCALE_Z), TEST_LOCATION);
2403   DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<float>(Actor::Property::SCALE_Z), TEST_LOCATION);
2404
2405   DALI_TEST_EQUALS(vector, actor.GetProperty<Vector3>(Actor::Property::SCALE), TEST_LOCATION);
2406   DALI_TEST_EQUALS(vector, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE), TEST_LOCATION);
2407
2408   END_TEST;
2409 }
2410
2411 int UtcDaliActorScaleBy(void)
2412 {
2413   TestApplication application;
2414   Actor           actor = Actor::New();
2415   Vector3         vector(100.0f, 100.0f, 100.0f);
2416
2417   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2418
2419   actor.SetProperty(Actor::Property::SCALE, vector);
2420
2421   // flush the queue and render once
2422   application.SendNotification();
2423   application.Render();
2424
2425   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2426
2427   actor.ScaleBy(vector);
2428
2429   // flush the queue and render once
2430   application.SendNotification();
2431   application.Render();
2432
2433   DALI_TEST_CHECK(vector * 100.0f == actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2434   END_TEST;
2435 }
2436
2437 int UtcDaliActorGetCurrentScale(void)
2438 {
2439   TestApplication application;
2440   Vector3         scale(12.0f, 1.0f, 2.0f);
2441
2442   Actor actor = Actor::New();
2443
2444   actor.SetProperty(Actor::Property::SCALE, scale);
2445
2446   // flush the queue and render once
2447   application.SendNotification();
2448   application.Render();
2449
2450   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
2451   END_TEST;
2452 }
2453
2454 int UtcDaliActorGetCurrentWorldScale(void)
2455 {
2456   TestApplication application;
2457
2458   Actor   parent = Actor::New();
2459   Vector3 parentScale(1.0f, 2.0f, 3.0f);
2460   parent.SetProperty(Actor::Property::SCALE, parentScale);
2461   application.GetScene().Add(parent);
2462
2463   Actor   child = Actor::New();
2464   Vector3 childScale(2.0f, 2.0f, 2.0f);
2465   child.SetProperty(Actor::Property::SCALE, childScale);
2466   parent.Add(child);
2467
2468   // The actors should not have a scale yet
2469   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::SCALE), Vector3::ONE, TEST_LOCATION);
2470   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::SCALE), Vector3::ONE, TEST_LOCATION);
2471
2472   // The actors should not have a world scale yet
2473   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), Vector3::ONE, TEST_LOCATION);
2474   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), Vector3::ONE, TEST_LOCATION);
2475
2476   application.SendNotification();
2477   application.Render(0);
2478
2479   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::SCALE), parentScale, TEST_LOCATION);
2480   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::SCALE), childScale, TEST_LOCATION);
2481
2482   // The actors should have a world scale now
2483   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), parentScale, TEST_LOCATION);
2484   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), parentScale * childScale, TEST_LOCATION);
2485   END_TEST;
2486 }
2487
2488 int UtcDaliActorInheritScale(void)
2489 {
2490   tet_infoline("Testing Actor::SetInheritScale");
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   application.SendNotification();
2504   application.Render(0);
2505
2506   DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_SCALE), true, TEST_LOCATION);
2507   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), parentScale * childScale, TEST_LOCATION);
2508
2509   child.SetProperty(Actor::Property::INHERIT_SCALE, false);
2510   DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_SCALE), false, TEST_LOCATION);
2511
2512   application.SendNotification();
2513   application.Render(0);
2514
2515   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), childScale, TEST_LOCATION);
2516   END_TEST;
2517 }
2518
2519 int UtcDaliActorSetVisible(void)
2520 {
2521   TestApplication application;
2522
2523   Actor actor = Actor::New();
2524   actor.SetProperty(Actor::Property::VISIBLE, false);
2525   // flush the queue and render once
2526   application.SendNotification();
2527   application.Render();
2528   DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == false);
2529
2530   actor.SetProperty(Actor::Property::VISIBLE, true);
2531   // flush the queue and render once
2532   application.SendNotification();
2533   application.Render();
2534   DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == true);
2535
2536   // put actor on stage
2537   application.GetScene().Add(actor);
2538   actor.SetProperty(Actor::Property::VISIBLE, false);
2539   // flush the queue and render once
2540   application.SendNotification();
2541   application.Render();
2542   DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == false);
2543   END_TEST;
2544 }
2545
2546 int UtcDaliActorIsVisible(void)
2547 {
2548   TestApplication application;
2549
2550   Actor actor = Actor::New();
2551
2552   DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == true);
2553   END_TEST;
2554 }
2555
2556 int UtcDaliActorSetOpacity(void)
2557 {
2558   TestApplication application;
2559
2560   Actor actor = Actor::New();
2561   // initial opacity is 1
2562   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, TEST_LOCATION);
2563
2564   actor.SetProperty(Actor::Property::OPACITY, 0.4f);
2565   // flush the queue and render once
2566   application.SendNotification();
2567   application.Render();
2568   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.4f, TEST_LOCATION);
2569
2570   // change opacity, actor is on stage to change is not immediate
2571   actor.SetProperty(Actor::Property::OPACITY, actor.GetCurrentProperty<float>(Actor::Property::OPACITY) + 0.1f);
2572   // flush the queue and render once
2573   application.SendNotification();
2574   application.Render();
2575   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.5f, TEST_LOCATION);
2576
2577   // put actor on stage
2578   application.GetScene().Add(actor);
2579
2580   // change opacity, actor is on stage to change is not immediate
2581   actor.SetProperty(Actor::Property::OPACITY, 0.9f);
2582   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.5f, TEST_LOCATION);
2583   // flush the queue and render once
2584   application.SendNotification();
2585   application.Render();
2586   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.9f, TEST_LOCATION);
2587
2588   // change opacity, actor is on stage to change is not immediate
2589   actor.SetProperty(Actor::Property::OPACITY, actor.GetCurrentProperty<float>(Actor::Property::OPACITY) - 0.9f);
2590   // flush the queue and render once
2591   application.SendNotification();
2592   application.Render();
2593   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, TEST_LOCATION);
2594   END_TEST;
2595 }
2596
2597 int UtcDaliActorGetCurrentOpacity(void)
2598 {
2599   TestApplication application;
2600
2601   Actor actor = Actor::New();
2602   DALI_TEST_CHECK(actor.GetCurrentProperty<float>(Actor::Property::OPACITY) != 0.5f);
2603
2604   actor.SetProperty(Actor::Property::OPACITY, 0.5f);
2605   // flush the queue and render once
2606   application.SendNotification();
2607   application.Render();
2608   DALI_TEST_CHECK(actor.GetCurrentProperty<float>(Actor::Property::OPACITY) == 0.5f);
2609   END_TEST;
2610 }
2611
2612 int UtcDaliActorSetSensitive(void)
2613 {
2614   TestApplication application;
2615   Actor           actor = Actor::New();
2616
2617   bool sensitive = !actor.GetProperty<bool>(Actor::Property::SENSITIVE);
2618
2619   actor.SetProperty(Actor::Property::SENSITIVE, sensitive);
2620
2621   DALI_TEST_CHECK(sensitive == actor.GetProperty<bool>(Actor::Property::SENSITIVE));
2622   END_TEST;
2623 }
2624
2625 int UtcDaliActorIsSensitive(void)
2626 {
2627   TestApplication application;
2628   Actor           actor = Actor::New();
2629   actor.SetProperty(Actor::Property::SENSITIVE, false);
2630
2631   DALI_TEST_CHECK(false == actor.GetProperty<bool>(Actor::Property::SENSITIVE));
2632   END_TEST;
2633 }
2634
2635 int UtcDaliActorSetColor(void)
2636 {
2637   TestApplication application;
2638   Actor           actor = Actor::New();
2639   Vector4         color(1.0f, 1.0f, 1.0f, 0.5f);
2640
2641   DALI_TEST_CHECK(color != actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2642
2643   actor.SetProperty(Actor::Property::COLOR, color);
2644   // flush the queue and render once
2645   application.SendNotification();
2646   application.Render();
2647   DALI_TEST_CHECK(color == actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2648
2649   actor.SetProperty(Actor::Property::COLOR, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR) + Vector4(-0.4f, -0.5f, -0.6f, -0.4f));
2650   // flush the queue and render once
2651   application.SendNotification();
2652   application.Render();
2653   DALI_TEST_EQUALS(Vector4(0.6f, 0.5f, 0.4f, 0.1f), actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2654
2655   application.GetScene().Add(actor);
2656   actor.SetProperty(Actor::Property::COLOR, color);
2657   // flush the queue and render once
2658   application.SendNotification();
2659   application.Render();
2660   DALI_TEST_EQUALS(color, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2661
2662   actor.SetProperty(Actor::Property::COLOR, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR) + Vector4(1.1f, 1.1f, 1.1f, 1.1f));
2663   // flush the queue and render once
2664   application.SendNotification();
2665   application.Render();
2666   // Actor color is not clamped
2667   DALI_TEST_EQUALS(Vector4(2.1f, 2.1f, 2.1f, 1.6f), actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2668   // world color is clamped
2669   DALI_TEST_EQUALS(Vector4(1.0f, 1.0f, 1.0f, 1.0f), actor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), TEST_LOCATION);
2670
2671   actor.SetProperty(Actor::Property::COLOR, color);
2672   DALI_TEST_EQUALS(color, actor.GetProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2673
2674   Vector3 newColor(1.0f, 0.0f, 0.0f);
2675   actor.SetProperty(Actor::Property::COLOR, newColor);
2676   DALI_TEST_EQUALS(Vector4(newColor.r, newColor.g, newColor.b, 1.0f), actor.GetProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2677
2678   application.GetScene().Remove(actor);
2679   END_TEST;
2680 }
2681
2682 int UtcDaliActorSetColorIndividual(void)
2683 {
2684   TestApplication application;
2685
2686   Actor actor = Actor::New();
2687
2688   Vector4 vector(0.7f, 0.8f, 0.9f, 0.6f);
2689   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2690
2691   actor.SetProperty(Actor::Property::COLOR_RED, vector.r);
2692   DALI_TEST_EQUALS(vector.r, actor.GetProperty<float>(Actor::Property::COLOR_RED), TEST_LOCATION);
2693
2694   // flush the queue and render once
2695   application.SendNotification();
2696   application.Render();
2697
2698   DALI_TEST_EQUALS(vector.r, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).r, TEST_LOCATION);
2699   DALI_TEST_EQUALS(vector.r, actor.GetProperty<float>(Actor::Property::COLOR_RED), TEST_LOCATION);
2700   DALI_TEST_EQUALS(vector.r, actor.GetCurrentProperty<float>(Actor::Property::COLOR_RED), TEST_LOCATION);
2701
2702   actor.SetProperty(Actor::Property::COLOR_GREEN, vector.g);
2703   DALI_TEST_EQUALS(vector.g, actor.GetProperty<float>(Actor::Property::COLOR_GREEN), TEST_LOCATION);
2704
2705   // flush the queue and render once
2706   application.SendNotification();
2707   application.Render();
2708
2709   DALI_TEST_EQUALS(vector.g, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).g, TEST_LOCATION);
2710   DALI_TEST_EQUALS(vector.g, actor.GetProperty<float>(Actor::Property::COLOR_GREEN), TEST_LOCATION);
2711   DALI_TEST_EQUALS(vector.g, actor.GetCurrentProperty<float>(Actor::Property::COLOR_GREEN), TEST_LOCATION);
2712
2713   actor.SetProperty(Actor::Property::COLOR_BLUE, vector.b);
2714   DALI_TEST_EQUALS(vector.b, actor.GetProperty<float>(Actor::Property::COLOR_BLUE), TEST_LOCATION);
2715
2716   // flush the queue and render once
2717   application.SendNotification();
2718   application.Render();
2719
2720   DALI_TEST_EQUALS(vector.b, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).b, TEST_LOCATION);
2721   DALI_TEST_EQUALS(vector.b, actor.GetProperty<float>(Actor::Property::COLOR_BLUE), TEST_LOCATION);
2722   DALI_TEST_EQUALS(vector.b, actor.GetCurrentProperty<float>(Actor::Property::COLOR_BLUE), TEST_LOCATION);
2723
2724   actor.SetProperty(Actor::Property::COLOR_ALPHA, vector.a);
2725   DALI_TEST_EQUALS(vector.a, actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), TEST_LOCATION);
2726
2727   // flush the queue and render once
2728   application.SendNotification();
2729   application.Render();
2730
2731   DALI_TEST_EQUALS(vector.a, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).a, TEST_LOCATION);
2732   DALI_TEST_EQUALS(vector.a, actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), TEST_LOCATION);
2733   DALI_TEST_EQUALS(vector.a, actor.GetCurrentProperty<float>(Actor::Property::COLOR_ALPHA), TEST_LOCATION);
2734
2735   DALI_TEST_EQUALS(vector, actor.GetProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2736   DALI_TEST_EQUALS(vector, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2737
2738   actor.SetProperty(Actor::Property::OPACITY, 0.2f);
2739
2740   // flush the queue and render once
2741   application.SendNotification();
2742   application.Render();
2743
2744   DALI_TEST_EQUALS(0.2f, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).a, TEST_LOCATION);
2745
2746   END_TEST;
2747 }
2748
2749 int UtcDaliActorGetCurrentColor(void)
2750 {
2751   TestApplication application;
2752   Actor           actor = Actor::New();
2753   Vector4         color(1.0f, 1.0f, 1.0f, 0.5f);
2754
2755   actor.SetProperty(Actor::Property::COLOR, color);
2756   // flush the queue and render once
2757   application.SendNotification();
2758   application.Render();
2759   DALI_TEST_CHECK(color == actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2760   END_TEST;
2761 }
2762
2763 int UtcDaliActorGetCurrentWorldColor(void)
2764 {
2765   tet_infoline("Actor::GetCurrentWorldColor");
2766   TestApplication application;
2767
2768   Actor   parent = Actor::New();
2769   Vector4 parentColor(1.0f, 0.5f, 0.0f, 0.8f);
2770   parent.SetProperty(Actor::Property::COLOR, parentColor);
2771   application.GetScene().Add(parent);
2772
2773   Actor   child = Actor::New();
2774   Vector4 childColor(0.5f, 0.6f, 0.5f, 1.0f);
2775   child.SetProperty(Actor::Property::COLOR, childColor);
2776   parent.Add(child);
2777
2778   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::COLOR), Color::WHITE, TEST_LOCATION);
2779   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), Color::WHITE, TEST_LOCATION);
2780
2781   // verify the default color mode
2782   DALI_TEST_EQUALS(USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2783
2784   // The actors should not have a world color yet
2785   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), Color::WHITE, TEST_LOCATION);
2786   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), Color::WHITE, TEST_LOCATION);
2787
2788   application.SendNotification();
2789   application.Render(0);
2790
2791   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::COLOR), parentColor, TEST_LOCATION);
2792   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), childColor, TEST_LOCATION);
2793
2794   // The actors should have a world color now
2795   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), parentColor, TEST_LOCATION);
2796   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), Vector4(childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION);
2797
2798   // use own color
2799   child.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
2800   application.SendNotification();
2801   application.Render(0);
2802   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), childColor, TEST_LOCATION);
2803
2804   // use parent color
2805   child.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
2806   application.SendNotification();
2807   application.Render(0);
2808   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), childColor, TEST_LOCATION);
2809   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), parentColor, TEST_LOCATION);
2810
2811   // use parent alpha
2812   child.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
2813   application.SendNotification();
2814   application.Render(0);
2815   Vector4 expectedColor(childColor);
2816   expectedColor.a *= parentColor.a;
2817   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), childColor, TEST_LOCATION);
2818   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), expectedColor, TEST_LOCATION);
2819   END_TEST;
2820 }
2821
2822 int UtcDaliActorSetColorMode(void)
2823 {
2824   tet_infoline("Actor::SetColorMode");
2825   TestApplication application;
2826   Actor           actor = Actor::New();
2827   Actor           child = Actor::New();
2828   actor.Add(child);
2829
2830   actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
2831   DALI_TEST_EQUALS(USE_OWN_COLOR, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2832
2833   actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR);
2834   DALI_TEST_EQUALS(USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2835
2836   actor.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
2837   DALI_TEST_EQUALS(USE_PARENT_COLOR, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2838
2839   actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
2840   DALI_TEST_EQUALS(USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2841   END_TEST;
2842 }
2843
2844 int UtcDaliActorScreenToLocal(void)
2845 {
2846   TestApplication application;
2847   Actor           actor = Actor::New();
2848   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2849   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2850   actor.SetProperty(Actor::Property::POSITION, Vector2(10.0f, 10.0f));
2851   application.GetScene().Add(actor);
2852
2853   // flush the queue and render once
2854   application.SendNotification();
2855   application.Render();
2856
2857   float localX;
2858   float localY;
2859
2860   application.SendNotification();
2861   application.Render();
2862
2863   DALI_TEST_CHECK(actor.ScreenToLocal(localX, localY, 50.0f, 50.0f));
2864
2865   DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
2866   DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
2867   END_TEST;
2868 }
2869
2870 int UtcDaliActorSetLeaveRequired(void)
2871 {
2872   TestApplication application;
2873
2874   Actor actor = Actor::New();
2875
2876   actor.SetProperty(Actor::Property::LEAVE_REQUIRED, false);
2877   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::LEAVE_REQUIRED) == false);
2878
2879   actor.SetProperty(Actor::Property::LEAVE_REQUIRED, true);
2880   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::LEAVE_REQUIRED) == true);
2881   END_TEST;
2882 }
2883
2884 int UtcDaliActorGetLeaveRequired(void)
2885 {
2886   TestApplication application;
2887
2888   Actor actor = Actor::New();
2889
2890   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::LEAVE_REQUIRED) == false);
2891   END_TEST;
2892 }
2893
2894 int UtcDaliActorSetKeyboardFocusable(void)
2895 {
2896   TestApplication application;
2897
2898   Actor actor = Actor::New();
2899
2900   actor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
2901   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) == true);
2902
2903   actor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, false);
2904   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) == false);
2905   END_TEST;
2906 }
2907
2908 int UtcDaliActorIsKeyboardFocusable(void)
2909 {
2910   TestApplication application;
2911
2912   Actor actor = Actor::New();
2913
2914   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) == false);
2915   END_TEST;
2916 }
2917
2918 int UtcDaliActorSetKeyboardFocusableChildren(void)
2919 {
2920   TestApplication application;
2921
2922   Actor actor = Actor::New();
2923
2924   actor.SetProperty(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN, true);
2925   DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN) == true);
2926
2927   actor.SetProperty(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN, false);
2928   DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN) == false);
2929   END_TEST;
2930 }
2931
2932 int UtcDaliActorAreChildrenKeyBoardFocusable(void)
2933 {
2934   TestApplication application;
2935
2936   Actor actor = Actor::New();
2937
2938   DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN) == true);
2939   END_TEST;
2940 }
2941
2942 int UtcDaliActorSetTouchFocusable(void)
2943 {
2944   TestApplication application;
2945
2946   Actor actor = Actor::New();
2947
2948   actor.SetProperty(DevelActor::Property::TOUCH_FOCUSABLE, true);
2949   DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::TOUCH_FOCUSABLE) == true);
2950
2951   actor.SetProperty(DevelActor::Property::TOUCH_FOCUSABLE, false);
2952   DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::TOUCH_FOCUSABLE) == false);
2953   END_TEST;
2954 }
2955
2956 int UtcDaliActorIsTouchFocusable(void)
2957 {
2958   TestApplication application;
2959
2960   Actor actor = Actor::New();
2961
2962   DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::TOUCH_FOCUSABLE) == false);
2963   END_TEST;
2964 }
2965
2966 int UtcDaliActorSetUserInteractionEnabled(void)
2967 {
2968   TestApplication application;
2969   Actor           actor = Actor::New();
2970
2971   bool enabled = !actor.GetProperty<bool>(DevelActor::Property::USER_INTERACTION_ENABLED);
2972
2973   actor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, enabled);
2974
2975   DALI_TEST_CHECK(enabled == actor.GetProperty<bool>(DevelActor::Property::USER_INTERACTION_ENABLED));
2976   END_TEST;
2977 }
2978
2979 int UtcDaliActorIsUserInteractionEnabled(void)
2980 {
2981   TestApplication application;
2982   Actor           actor = Actor::New();
2983   actor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, true);
2984
2985   DALI_TEST_CHECK(true == actor.GetProperty<bool>(DevelActor::Property::USER_INTERACTION_ENABLED));
2986   END_TEST;
2987 }
2988
2989 int UtcDaliActorRemoveConstraints(void)
2990 {
2991   tet_infoline(" UtcDaliActorRemoveConstraints");
2992   TestApplication application;
2993
2994   gTestConstraintCalled = false;
2995
2996   Actor actor = Actor::New();
2997
2998   Constraint constraint = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraint());
2999   constraint.Apply();
3000   actor.RemoveConstraints();
3001
3002   DALI_TEST_CHECK(gTestConstraintCalled == false);
3003
3004   application.GetScene().Add(actor);
3005   constraint.Apply();
3006
3007   // flush the queue and render once
3008   application.SendNotification();
3009   application.Render();
3010
3011   actor.RemoveConstraints();
3012
3013   DALI_TEST_CHECK(gTestConstraintCalled == true);
3014   END_TEST;
3015 }
3016
3017 int UtcDaliActorRemoveConstraintTag(void)
3018 {
3019   tet_infoline(" UtcDaliActorRemoveConstraintTag");
3020   TestApplication application;
3021
3022   Actor actor = Actor::New();
3023
3024   // 1. Apply Constraint1 and Constraint2, and test...
3025   unsigned int result1 = 0u;
3026   unsigned int result2 = 0u;
3027
3028   unsigned   constraint1Tag = 1u;
3029   Constraint constraint1    = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1));
3030   constraint1.SetTag(constraint1Tag);
3031   constraint1.Apply();
3032
3033   unsigned   constraint2Tag = 2u;
3034   Constraint constraint2    = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2));
3035   constraint2.SetTag(constraint2Tag);
3036   constraint2.Apply();
3037
3038   application.GetScene().Add(actor);
3039   // flush the queue and render once
3040   application.SendNotification();
3041   application.Render();
3042
3043   DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
3044   DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
3045
3046   // 2. Remove Constraint1 and test...
3047   result1 = 0;
3048   result2 = 0;
3049   actor.RemoveConstraints(constraint1Tag);
3050   // make color property dirty, which will trigger constraints to be reapplied.
3051   actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
3052   // flush the queue and render once
3053   application.SendNotification();
3054   application.Render();
3055
3056   DALI_TEST_EQUALS(result1, 0u, TEST_LOCATION); ///< constraint 1 should not apply now.
3057   DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
3058
3059   // 3. Re-Apply Constraint1 and test...
3060   result1 = 0;
3061   result2 = 0;
3062   constraint1.Apply();
3063   // make color property dirty, which will trigger constraints to be reapplied.
3064   actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
3065   // flush the queue and render once
3066   application.SendNotification();
3067   application.Render();
3068
3069   DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
3070   DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
3071
3072   // 2. Remove Constraint2 and test...
3073   result1 = 0;
3074   result2 = 0;
3075   actor.RemoveConstraints(constraint2Tag);
3076   // make color property dirty, which will trigger constraints to be reapplied.
3077   actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
3078   // flush the queue and render once
3079   application.SendNotification();
3080   application.Render();
3081
3082   DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
3083   DALI_TEST_EQUALS(result2, 0u, TEST_LOCATION); ///< constraint 2 should not apply now.
3084
3085   // 2. Remove Constraint1 as well and test...
3086   result1 = 0;
3087   result2 = 0;
3088   actor.RemoveConstraints(constraint1Tag);
3089   // make color property dirty, which will trigger constraints to be reapplied.
3090   actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
3091   // flush the queue and render once
3092   application.SendNotification();
3093   application.Render();
3094
3095   DALI_TEST_EQUALS(result1, 0u, TEST_LOCATION); ///< constraint 1 should not apply now.
3096   DALI_TEST_EQUALS(result2, 0u, TEST_LOCATION); ///< constraint 2 should not apply now.
3097   END_TEST;
3098 }
3099
3100 int UtcDaliActorTouchedSignal(void)
3101 {
3102   TestApplication application;
3103
3104   ResetTouchCallbacks();
3105
3106   // get the root layer
3107   Actor actor = application.GetScene().GetRootLayer();
3108   DALI_TEST_CHECK(gTouchCallBackCalled == false);
3109
3110   application.SendNotification();
3111   application.Render();
3112
3113   // connect to its touch signal
3114   actor.TouchedSignal().Connect(TestTouchCallback);
3115
3116   // simulate a touch event in the middle of the screen
3117   Vector2                  touchPoint(application.GetScene().GetSize() * 0.5);
3118   Dali::Integration::Point point;
3119   point.SetDeviceId(1);
3120   point.SetState(PointState::DOWN);
3121   point.SetScreenPosition(Vector2(touchPoint.x, touchPoint.y));
3122   Dali::Integration::TouchEvent touchEvent;
3123   touchEvent.AddPoint(point);
3124   application.ProcessEvent(touchEvent);
3125
3126   DALI_TEST_CHECK(gTouchCallBackCalled == true);
3127   END_TEST;
3128 }
3129
3130 int UtcDaliActorHoveredSignal(void)
3131 {
3132   TestApplication application;
3133
3134   gHoverCallBackCalled = false;
3135
3136   // get the root layer
3137   Actor actor = application.GetScene().GetRootLayer();
3138   DALI_TEST_CHECK(gHoverCallBackCalled == false);
3139
3140   application.SendNotification();
3141   application.Render();
3142
3143   // connect to its hover signal
3144   actor.HoveredSignal().Connect(TestCallback3);
3145
3146   // simulate a hover event in the middle of the screen
3147   Vector2                  touchPoint(application.GetScene().GetSize() * 0.5);
3148   Dali::Integration::Point point;
3149   point.SetDeviceId(1);
3150   point.SetState(PointState::MOTION);
3151   point.SetScreenPosition(Vector2(touchPoint.x, touchPoint.y));
3152   Dali::Integration::HoverEvent hoverEvent;
3153   hoverEvent.AddPoint(point);
3154   application.ProcessEvent(hoverEvent);
3155
3156   DALI_TEST_CHECK(gHoverCallBackCalled == true);
3157   END_TEST;
3158 }
3159
3160 int UtcDaliActorOnOffSceneSignal(void)
3161 {
3162   tet_infoline("Testing Dali::Actor::OnSceneSignal() and OffSceneSignal()");
3163
3164   TestApplication application;
3165
3166   // clean test data
3167   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
3168   gActorNamesOnOffScene.clear();
3169
3170   Actor parent = Actor::New();
3171   parent.SetProperty(Actor::Property::NAME, "parent");
3172   parent.OnSceneSignal().Connect(OnSceneCallback);
3173   parent.OffSceneSignal().Connect(OffSceneCallback);
3174   // sanity check
3175   DALI_TEST_CHECK(gOnSceneCallBackCalled == 0);
3176   DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
3177
3178   // add parent to the scene
3179   application.GetScene().Add(parent);
3180   // onstage emitted, offstage not
3181   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 1, TEST_LOCATION);
3182   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
3183   DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
3184
3185   // test adding a child, should get onstage emitted
3186   // clean test data
3187   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
3188   gActorNamesOnOffScene.clear();
3189
3190   Actor child = Actor::New();
3191   child.SetProperty(Actor::Property::NAME, "child");
3192   child.OnSceneSignal().Connect(OnSceneCallback);
3193   child.OffSceneSignal().Connect(OffSceneCallback);
3194   parent.Add(child); // add child
3195   // onscene emitted, offscene not
3196   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 1, TEST_LOCATION);
3197   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
3198   DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
3199
3200   // test removing parent from the scene
3201   // clean test data
3202   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
3203   gActorNamesOnOffScene.clear();
3204
3205   application.GetScene().Remove(parent);
3206   // onscene not emitted, offscene is
3207   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
3208   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 2, TEST_LOCATION);
3209   DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
3210   DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[1], TEST_LOCATION);
3211
3212   // test adding parent back to the scene
3213   // clean test data
3214   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
3215   gActorNamesOnOffScene.clear();
3216
3217   application.GetScene().Add(parent);
3218   // onscene emitted, offscene not
3219   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 2, TEST_LOCATION);
3220   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
3221   DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
3222   DALI_TEST_EQUALS("child", gActorNamesOnOffScene[1], TEST_LOCATION);
3223
3224   // test removing child
3225   // clean test data
3226   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
3227   gActorNamesOnOffScene.clear();
3228
3229   parent.Remove(child);
3230   // onscene not emitted, offscene is
3231   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
3232   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 1, TEST_LOCATION);
3233   DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
3234
3235   // test removing parent
3236   // clean test data
3237   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
3238   gActorNamesOnOffScene.clear();
3239
3240   application.GetScene().Remove(parent);
3241   // onscene not emitted, offscene is
3242   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
3243   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 1, TEST_LOCATION);
3244   DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
3245   END_TEST;
3246 }
3247
3248 int UtcDaliActorFindChildByName(void)
3249 {
3250   tet_infoline("Testing Dali::Actor::FindChildByName()");
3251   TestApplication application;
3252
3253   Actor parent = Actor::New();
3254   parent.SetProperty(Actor::Property::NAME, "parent");
3255   Actor first = Actor::New();
3256   first.SetProperty(Actor::Property::NAME, "first");
3257   Actor second = Actor::New();
3258   second.SetProperty(Actor::Property::NAME, "second");
3259
3260   parent.Add(first);
3261   first.Add(second);
3262
3263   Actor found = parent.FindChildByName("foo");
3264   DALI_TEST_CHECK(!found);
3265
3266   found = parent.FindChildByName("parent");
3267   DALI_TEST_CHECK(found == parent);
3268
3269   found = parent.FindChildByName("first");
3270   DALI_TEST_CHECK(found == first);
3271
3272   found = parent.FindChildByName("second");
3273   DALI_TEST_CHECK(found == second);
3274   END_TEST;
3275 }
3276
3277 int UtcDaliActorFindChildById(void)
3278 {
3279   tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
3280   TestApplication application;
3281
3282   Actor parent = Actor::New();
3283   Actor first  = Actor::New();
3284   Actor second = Actor::New();
3285
3286   parent.Add(first);
3287   first.Add(second);
3288
3289   Actor found = parent.FindChildById(100000);
3290   DALI_TEST_CHECK(!found);
3291
3292   found = parent.FindChildById(parent.GetProperty<int>(Actor::Property::ID));
3293   DALI_TEST_CHECK(found == parent);
3294
3295   found = parent.FindChildById(first.GetProperty<int>(Actor::Property::ID));
3296   DALI_TEST_CHECK(found == first);
3297
3298   found = parent.FindChildById(second.GetProperty<int>(Actor::Property::ID));
3299   DALI_TEST_CHECK(found == second);
3300   END_TEST;
3301 }
3302
3303 int UtcDaliActorHitTest(void)
3304 {
3305   struct HitTestData
3306   {
3307   public:
3308     HitTestData(const Vector3& scale, const Vector2& touchPoint, bool result)
3309     : mScale(scale),
3310       mTouchPoint(touchPoint),
3311       mResult(result)
3312     {
3313     }
3314
3315     Vector3 mScale;
3316     Vector2 mTouchPoint;
3317     bool    mResult;
3318   };
3319
3320   TestApplication application;
3321   tet_infoline(" UtcDaliActorHitTest");
3322
3323   // Fill a vector with different hit tests.
3324   struct HitTestData* hitTestData[] = {
3325     //                    scale                     touch point           result
3326     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(289.f, 400.f), true),  // touch point close to the right edge (inside)
3327     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(291.f, 400.f), false), // touch point close to the right edge (outside)
3328     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.
3329     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(200.f, 451.f), false), // touch point close to the down edge (outside)
3330     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.
3331     NULL,
3332   };
3333
3334   // get the root layer
3335   Actor actor = Actor::New();
3336   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3337   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3338
3339   application.GetScene().Add(actor);
3340
3341   ResetTouchCallbacks();
3342
3343   unsigned int index = 0;
3344   while(NULL != hitTestData[index])
3345   {
3346     actor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f));
3347     actor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z));
3348
3349     // flush the queue and render once
3350     application.SendNotification();
3351     application.Render();
3352
3353     DALI_TEST_CHECK(!gTouchCallBackCalled);
3354
3355     // connect to its touch signal
3356     actor.TouchedSignal().Connect(TestTouchCallback);
3357
3358     Dali::Integration::Point point;
3359     point.SetState(PointState::DOWN);
3360     point.SetScreenPosition(Vector2(hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y));
3361     Dali::Integration::TouchEvent event;
3362     event.AddPoint(point);
3363
3364     // flush the queue and render once
3365     application.SendNotification();
3366     application.Render();
3367     application.ProcessEvent(event);
3368
3369     DALI_TEST_CHECK(gTouchCallBackCalled == hitTestData[index]->mResult);
3370
3371     if(gTouchCallBackCalled != hitTestData[index]->mResult)
3372       tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
3373                  hitTestData[index]->mScale.x,
3374                  hitTestData[index]->mScale.y,
3375                  hitTestData[index]->mScale.z,
3376                  hitTestData[index]->mTouchPoint.x,
3377                  hitTestData[index]->mTouchPoint.y,
3378                  hitTestData[index]->mResult);
3379
3380     ResetTouchCallbacks();
3381     ++index;
3382   }
3383   END_TEST;
3384 }
3385
3386 int UtcDaliActorSetDrawMode(void)
3387 {
3388   TestApplication application;
3389   tet_infoline(" UtcDaliActorSetDrawModeOverlay");
3390
3391   Actor a = Actor::New();
3392
3393   application.GetScene().Add(a);
3394   application.SendNotification();
3395   application.Render(0);
3396   application.SendNotification();
3397   application.Render(1);
3398
3399   DALI_TEST_CHECK(DrawMode::NORMAL == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Ensure overlay is off by default
3400
3401   a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3402   application.SendNotification();
3403   application.Render(1);
3404
3405   DALI_TEST_CHECK(DrawMode::OVERLAY_2D == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Check Actor is overlay
3406
3407   a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::NORMAL);
3408   application.SendNotification();
3409   application.Render(1);
3410
3411   DALI_TEST_CHECK(DrawMode::NORMAL == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Check Actor is normal
3412   END_TEST;
3413 }
3414
3415 int UtcDaliActorSetDrawModeOverlayRender(void)
3416 {
3417   TestApplication application;
3418   tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
3419
3420   application.SendNotification();
3421   application.Render(1);
3422
3423   std::vector<GLuint> ids;
3424   ids.push_back(8);  // first rendered actor
3425   ids.push_back(9);  // second rendered actor
3426   ids.push_back(10); // third rendered actor
3427   application.GetGlAbstraction().SetNextTextureIds(ids);
3428
3429   Texture imageA = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
3430   Texture imageB = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
3431   Texture imageC = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
3432   Actor   a      = CreateRenderableActor(imageA);
3433   Actor   b      = CreateRenderableActor(imageB);
3434   Actor   c      = CreateRenderableActor(imageC);
3435
3436   application.SendNotification();
3437   application.Render(1);
3438
3439   //Textures are bound when first created. Clear bound textures vector
3440   application.GetGlAbstraction().ClearBoundTextures();
3441
3442   // Render a,b,c as regular non-overlays. so order will be:
3443   // a (8)
3444   // b (9)
3445   // c (10)
3446   application.GetScene().Add(a);
3447   application.GetScene().Add(b);
3448   application.GetScene().Add(c);
3449
3450   application.SendNotification();
3451   application.Render(1);
3452
3453   // Should be 3 textures changes.
3454   const std::vector<GLuint>&             boundTextures = application.GetGlAbstraction().GetBoundTextures(GL_TEXTURE0);
3455   typedef std::vector<GLuint>::size_type TextureSize;
3456   DALI_TEST_EQUALS(boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION);
3457   if(boundTextures.size() == 3)
3458   {
3459     DALI_TEST_CHECK(boundTextures[0] == 8u);
3460     DALI_TEST_CHECK(boundTextures[1] == 9u);
3461     DALI_TEST_CHECK(boundTextures[2] == 10u);
3462   }
3463
3464   // Now texture ids have been set, we can monitor their render order.
3465   // render a as an overlay (last), so order will be:
3466   // b (9)
3467   // c (10)
3468   // a (8)
3469   a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3470   application.GetGlAbstraction().ClearBoundTextures();
3471
3472   application.SendNotification();
3473   application.Render(1);
3474
3475   // Should be 3 texture changes.
3476   DALI_TEST_EQUALS(boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION);
3477   if(boundTextures.size() == 3)
3478   {
3479     DALI_TEST_CHECK(boundTextures[0] == 9u);
3480     DALI_TEST_CHECK(boundTextures[1] == 10u);
3481     DALI_TEST_CHECK(boundTextures[2] == 8u);
3482   }
3483   END_TEST;
3484 }
3485
3486 int UtcDaliActorSetDrawModeOverlayWithClipping(void)
3487 {
3488   TestApplication application;
3489   tet_infoline(" UtcDaliActorSetDrawModeOverlayWithClipping");
3490
3491   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
3492   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
3493   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
3494
3495   const Vector2 surfaceSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
3496   const Vector2 imageSize(16.0f, 16.0f);
3497
3498   std::vector<GLuint> ids;
3499   ids.push_back(8);  // first rendered actor
3500   ids.push_back(9);  // second rendered actor
3501   ids.push_back(10); // third rendered actor
3502   ids.push_back(11); // forth rendered actor
3503   application.GetGlAbstraction().SetNextTextureIds(ids);
3504
3505   Actor a = CreateActorWithContent16x16();
3506   Actor b = CreateActorWithContent16x16();
3507   Actor c = CreateActorWithContent16x16();
3508   Actor d = CreateActorWithContent16x16();
3509
3510   application.SendNotification();
3511   application.Render();
3512
3513   //Textures are bound when first created. Clear bound textures vector
3514   application.GetGlAbstraction().ClearBoundTextures();
3515
3516   b[Actor::Property::PARENT_ORIGIN] = ParentOrigin::BOTTOM_LEFT;
3517   b[Actor::Property::ANCHOR_POINT]  = AnchorPoint::BOTTOM_LEFT;
3518   b[Actor::Property::DRAW_MODE]     = DrawMode::OVERLAY_2D;
3519   b[Actor::Property::CLIPPING_MODE] = ClippingMode::CLIP_TO_BOUNDING_BOX;
3520
3521   c[Actor::Property::PARENT_ORIGIN] = ParentOrigin::BOTTOM_LEFT;
3522   c[Actor::Property::ANCHOR_POINT]  = AnchorPoint::BOTTOM_LEFT;
3523   c[Actor::Property::CLIPPING_MODE] = ClippingMode::CLIP_TO_BOUNDING_BOX;
3524   c[Actor::Property::POSITION]      = Vector2(100.0f, -100.0f);
3525
3526   application.GetScene().Add(a);
3527   application.GetScene().Add(b);
3528   application.GetScene().Add(c);
3529   b.Add(d);
3530
3531   GenerateTrace(application, enabledDisableTrace, scissorTrace);
3532
3533   const std::vector<GLuint>&             boundTextures = application.GetGlAbstraction().GetBoundTextures(GL_TEXTURE0);
3534   typedef std::vector<GLuint>::size_type TextureSize;
3535   DALI_TEST_EQUALS(boundTextures.size(), static_cast<TextureSize>(4), TEST_LOCATION);
3536   if(boundTextures.size() == 4)
3537   {
3538     DALI_TEST_CHECK(boundTextures[0] == 8u);
3539     DALI_TEST_CHECK(boundTextures[1] == 10u);
3540     DALI_TEST_CHECK(boundTextures[2] == 9u);
3541     DALI_TEST_CHECK(boundTextures[3] == 11u);
3542   }
3543
3544   // Check scissor test was enabled.
3545   std::ostringstream scissor;
3546   scissor << std::hex << GL_SCISSOR_TEST;
3547   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
3548
3549   // Check the scissor was set, and the coordinates are correct.
3550   DALI_TEST_CHECK(scissorTrace.TestMethodAndParams(0, "Scissor", "100, 100, 16, 16")); // First compare with c area
3551   DALI_TEST_CHECK(scissorTrace.TestMethodAndParams(1, "Scissor", "0, 0, 16, 16"));     // Second compare with b area
3552
3553   application.GetGlAbstraction().ClearBoundTextures();
3554
3555   // Remove a Renderer of overlay actor
3556   Renderer renderer = b.GetRendererAt(0);
3557   b.RemoveRenderer(renderer);
3558
3559   GenerateTrace(application, enabledDisableTrace, scissorTrace);
3560
3561   DALI_TEST_EQUALS(boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION);
3562   if(boundTextures.size() == 3)
3563   {
3564     DALI_TEST_CHECK(boundTextures[0] == 8u);
3565     DALI_TEST_CHECK(boundTextures[1] == 10u);
3566     DALI_TEST_CHECK(boundTextures[2] == 11u);
3567   }
3568
3569   DALI_TEST_CHECK(scissorTrace.TestMethodAndParams(0, "Scissor", "100, 100, 16, 16")); // First compare with c area
3570   DALI_TEST_CHECK(scissorTrace.TestMethodAndParams(1, "Scissor", "0, 0, 16, 16"));     // Second compare with b area
3571
3572   END_TEST;
3573 }
3574
3575 int UtcDaliActorGetCurrentWorldMatrix(void)
3576 {
3577   TestApplication application;
3578   tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
3579
3580   Actor parent = Actor::New();
3581   parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3582   parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3583   Vector3    parentPosition(10.0f, 20.0f, 30.0f);
3584   Radian     rotationAngle(Degree(85.0f));
3585   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3586   Vector3    parentScale(1.0f, 2.0f, 3.0f);
3587   parent.SetProperty(Actor::Property::POSITION, parentPosition);
3588   parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3589   parent.SetProperty(Actor::Property::SCALE, parentScale);
3590   application.GetScene().Add(parent);
3591
3592   Actor child = Actor::New();
3593   child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3594   Vector3    childPosition(0.0f, 0.0f, 100.0f);
3595   Radian     childRotationAngle(Degree(23.0f));
3596   Quaternion childRotation(childRotationAngle, Vector3::YAXIS);
3597   Vector3    childScale(2.0f, 2.0f, 2.0f);
3598   child.SetProperty(Actor::Property::POSITION, childPosition);
3599   child.SetProperty(Actor::Property::ORIENTATION, childRotation);
3600   child.SetProperty(Actor::Property::SCALE, childScale);
3601   parent.Add(child);
3602
3603   application.SendNotification();
3604   application.Render(0);
3605   application.Render();
3606   application.SendNotification();
3607
3608   Matrix parentMatrix(false);
3609   parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3610
3611   Matrix childMatrix(false);
3612   childMatrix.SetTransformComponents(childScale, childRotation, childPosition);
3613
3614   //Child matrix should be the composition of child and parent
3615   Matrix childWorldMatrix(false);
3616   Matrix::Multiply(childWorldMatrix, childMatrix, parentMatrix);
3617
3618   DALI_TEST_EQUALS(parent.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), parentMatrix, 0.001, TEST_LOCATION);
3619   DALI_TEST_EQUALS(child.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), childWorldMatrix, 0.001, TEST_LOCATION);
3620   END_TEST;
3621 }
3622
3623 int UtcDaliActorConstrainedToWorldMatrix(void)
3624 {
3625   TestApplication application;
3626   tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
3627
3628   Actor parent = Actor::New();
3629   parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3630   parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3631   Vector3    parentPosition(10.0f, 20.0f, 30.0f);
3632   Radian     rotationAngle(Degree(85.0f));
3633   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3634   Vector3    parentScale(1.0f, 2.0f, 3.0f);
3635   parent.SetProperty(Actor::Property::POSITION, parentPosition);
3636   parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3637   parent.SetProperty(Actor::Property::SCALE, parentScale);
3638   application.GetScene().Add(parent);
3639
3640   Actor child = Actor::New();
3641   child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3642   Constraint posConstraint = Constraint::New<Vector3>(child, Actor::Property::POSITION, PositionComponentConstraint());
3643   posConstraint.AddSource(Source(parent, Actor::Property::WORLD_MATRIX));
3644   posConstraint.Apply();
3645
3646   application.GetScene().Add(child);
3647
3648   application.SendNotification();
3649   application.Render(0);
3650   application.Render();
3651   application.SendNotification();
3652
3653   Matrix parentMatrix(false);
3654   parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3655
3656   DALI_TEST_EQUALS(parent.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), parentMatrix, 0.001, TEST_LOCATION);
3657   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), 0.001, TEST_LOCATION);
3658   END_TEST;
3659 }
3660
3661 int UtcDaliActorConstrainedToOrientation(void)
3662 {
3663   TestApplication application;
3664   tet_infoline(" UtcDaliActorConstrainedToOrientation");
3665
3666   Actor parent = Actor::New();
3667   parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3668   parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3669   Vector3    parentPosition(10.0f, 20.0f, 30.0f);
3670   Radian     rotationAngle(Degree(85.0f));
3671   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3672   Vector3    parentScale(1.0f, 2.0f, 3.0f);
3673   parent.SetProperty(Actor::Property::POSITION, parentPosition);
3674   parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3675   parent.SetProperty(Actor::Property::SCALE, parentScale);
3676   application.GetScene().Add(parent);
3677
3678   Actor child = Actor::New();
3679   child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3680   Constraint posConstraint = Constraint::New<Quaternion>(child, Actor::Property::ORIENTATION, OrientationComponentConstraint());
3681   posConstraint.AddSource(Source(parent, Actor::Property::ORIENTATION));
3682   posConstraint.Apply();
3683
3684   application.GetScene().Add(child);
3685
3686   application.SendNotification();
3687   application.Render(0);
3688   application.Render();
3689   application.SendNotification();
3690
3691   DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), parent.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
3692   END_TEST;
3693 }
3694
3695 int UtcDaliActorConstrainedToOpacity(void)
3696 {
3697   TestApplication application;
3698   tet_infoline(" UtcDaliActorConstrainedToOpacity");
3699
3700   Actor parent = Actor::New();
3701   parent.SetProperty(Actor::Property::OPACITY, 0.7f);
3702   application.GetScene().Add(parent);
3703
3704   Actor      child             = Actor::New();
3705   Constraint opacityConstraint = Constraint::New<float>(child, Actor::Property::OPACITY, EqualToConstraint());
3706   opacityConstraint.AddSource(Source(parent, Actor::Property::OPACITY));
3707   opacityConstraint.Apply();
3708
3709   application.GetScene().Add(child);
3710
3711   application.SendNotification();
3712   application.Render(0);
3713   application.Render();
3714   application.SendNotification();
3715
3716   DALI_TEST_EQUALS(child.GetCurrentProperty<float>(Actor::Property::OPACITY), parent.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.001f, TEST_LOCATION);
3717
3718   parent.SetProperty(Actor::Property::OPACITY, 0.3f);
3719
3720   application.SendNotification();
3721   application.Render(0);
3722   application.Render();
3723   application.SendNotification();
3724
3725   DALI_TEST_EQUALS(child.GetCurrentProperty<float>(Actor::Property::OPACITY), parent.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.001f, TEST_LOCATION);
3726
3727   END_TEST;
3728 }
3729
3730 int UtcDaliActorUnparent(void)
3731 {
3732   TestApplication application;
3733   tet_infoline(" UtcDaliActorUnparent");
3734
3735   Actor parent = Actor::New();
3736   application.GetScene().Add(parent);
3737
3738   Actor child = Actor::New();
3739
3740   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3741   DALI_TEST_CHECK(!child.GetParent());
3742
3743   // Test that calling Unparent with no parent is a NOOP
3744   child.Unparent();
3745
3746   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3747   DALI_TEST_CHECK(!child.GetParent());
3748
3749   // Test that Unparent works
3750   parent.Add(child);
3751
3752   DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
3753   DALI_TEST_CHECK(parent == child.GetParent());
3754
3755   child.Unparent();
3756
3757   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3758   DALI_TEST_CHECK(!child.GetParent());
3759
3760   // Test that UnparentAndReset works
3761   parent.Add(child);
3762
3763   DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
3764   DALI_TEST_CHECK(parent == child.GetParent());
3765
3766   UnparentAndReset(child);
3767
3768   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3769   DALI_TEST_CHECK(!child);
3770
3771   // Test that UnparentAndReset is a NOOP with empty handle
3772   UnparentAndReset(child);
3773
3774   DALI_TEST_CHECK(!child);
3775   END_TEST;
3776 }
3777
3778 int UtcDaliActorGetChildAt(void)
3779 {
3780   TestApplication application;
3781   tet_infoline(" UtcDaliActorGetChildAt");
3782
3783   Actor parent = Actor::New();
3784   application.GetScene().Add(parent);
3785
3786   Actor child0 = Actor::New();
3787   parent.Add(child0);
3788
3789   Actor child1 = Actor::New();
3790   parent.Add(child1);
3791
3792   Actor child2 = Actor::New();
3793   parent.Add(child2);
3794
3795   DALI_TEST_EQUALS(parent.GetChildAt(0), child0, TEST_LOCATION);
3796   DALI_TEST_EQUALS(parent.GetChildAt(1), child1, TEST_LOCATION);
3797   DALI_TEST_EQUALS(parent.GetChildAt(2), child2, TEST_LOCATION);
3798   END_TEST;
3799 }
3800
3801 int UtcDaliActorSetGetOverlay(void)
3802 {
3803   TestApplication application;
3804   tet_infoline(" UtcDaliActorSetGetOverlay");
3805
3806   Actor parent = Actor::New();
3807   parent.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3808   DALI_TEST_CHECK(parent.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE) == DrawMode::OVERLAY_2D);
3809   END_TEST;
3810 }
3811
3812 int UtcDaliActorCreateDestroy(void)
3813 {
3814   Actor* actor = new Actor;
3815   DALI_TEST_CHECK(actor);
3816   delete actor;
3817   END_TEST;
3818 }
3819
3820 namespace
3821 {
3822 struct PropertyStringIndex
3823 {
3824   const char* const     name;
3825   const Property::Index index;
3826   const Property::Type  type;
3827 };
3828
3829 const PropertyStringIndex PROPERTY_TABLE[] =
3830   {
3831     {"parentOrigin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3},
3832     {"parentOriginX", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT},
3833     {"parentOriginY", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT},
3834     {"parentOriginZ", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT},
3835     {"anchorPoint", Actor::Property::ANCHOR_POINT, Property::VECTOR3},
3836     {"anchorPointX", Actor::Property::ANCHOR_POINT_X, Property::FLOAT},
3837     {"anchorPointY", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT},
3838     {"anchorPointZ", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT},
3839     {"size", Actor::Property::SIZE, Property::VECTOR3},
3840     {"sizeWidth", Actor::Property::SIZE_WIDTH, Property::FLOAT},
3841     {"sizeHeight", Actor::Property::SIZE_HEIGHT, Property::FLOAT},
3842     {"sizeDepth", Actor::Property::SIZE_DEPTH, Property::FLOAT},
3843     {"position", Actor::Property::POSITION, Property::VECTOR3},
3844     {"positionX", Actor::Property::POSITION_X, Property::FLOAT},
3845     {"positionY", Actor::Property::POSITION_Y, Property::FLOAT},
3846     {"positionZ", Actor::Property::POSITION_Z, Property::FLOAT},
3847     {"worldPosition", Actor::Property::WORLD_POSITION, Property::VECTOR3},
3848     {"worldPositionX", Actor::Property::WORLD_POSITION_X, Property::FLOAT},
3849     {"worldPositionY", Actor::Property::WORLD_POSITION_Y, Property::FLOAT},
3850     {"worldPositionZ", Actor::Property::WORLD_POSITION_Z, Property::FLOAT},
3851     {"orientation", Actor::Property::ORIENTATION, Property::ROTATION},
3852     {"worldOrientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION},
3853     {"scale", Actor::Property::SCALE, Property::VECTOR3},
3854     {"scaleX", Actor::Property::SCALE_X, Property::FLOAT},
3855     {"scaleY", Actor::Property::SCALE_Y, Property::FLOAT},
3856     {"scaleZ", Actor::Property::SCALE_Z, Property::FLOAT},
3857     {"worldScale", Actor::Property::WORLD_SCALE, Property::VECTOR3},
3858     {"visible", Actor::Property::VISIBLE, Property::BOOLEAN},
3859     {"color", Actor::Property::COLOR, Property::VECTOR4},
3860     {"colorRed", Actor::Property::COLOR_RED, Property::FLOAT},
3861     {"colorGreen", Actor::Property::COLOR_GREEN, Property::FLOAT},
3862     {"colorBlue", Actor::Property::COLOR_BLUE, Property::FLOAT},
3863     {"colorAlpha", Actor::Property::COLOR_ALPHA, Property::FLOAT},
3864     {"worldColor", Actor::Property::WORLD_COLOR, Property::VECTOR4},
3865     {"worldMatrix", Actor::Property::WORLD_MATRIX, Property::MATRIX},
3866     {"name", Actor::Property::NAME, Property::STRING},
3867     {"sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN},
3868     {"leaveRequired", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN},
3869     {"inheritOrientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN},
3870     {"inheritScale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN},
3871     {"colorMode", Actor::Property::COLOR_MODE, Property::INTEGER},
3872     {"drawMode", Actor::Property::DRAW_MODE, Property::INTEGER},
3873     {"sizeModeFactor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3},
3874     {"widthResizePolicy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING},
3875     {"heightResizePolicy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING},
3876     {"sizeScalePolicy", Actor::Property::SIZE_SCALE_POLICY, Property::INTEGER},
3877     {"widthForHeight", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN},
3878     {"heightForWidth", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN},
3879     {"padding", Actor::Property::PADDING, Property::VECTOR4},
3880     {"minimumSize", Actor::Property::MINIMUM_SIZE, Property::VECTOR2},
3881     {"maximumSize", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2},
3882     {"inheritPosition", Actor::Property::INHERIT_POSITION, Property::BOOLEAN},
3883     {"clippingMode", Actor::Property::CLIPPING_MODE, Property::STRING},
3884     {"opacity", Actor::Property::OPACITY, Property::FLOAT},
3885 };
3886 const unsigned int PROPERTY_TABLE_COUNT = sizeof(PROPERTY_TABLE) / sizeof(PROPERTY_TABLE[0]);
3887 } // unnamed namespace
3888
3889 int UtcDaliActorProperties(void)
3890 {
3891   TestApplication application;
3892
3893   Actor actor = Actor::New();
3894
3895   for(unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i)
3896   {
3897     tet_printf("Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index);
3898     DALI_TEST_EQUALS(actor.GetPropertyName(PROPERTY_TABLE[i].index), PROPERTY_TABLE[i].name, TEST_LOCATION);
3899     DALI_TEST_EQUALS(actor.GetPropertyIndex(PROPERTY_TABLE[i].name), PROPERTY_TABLE[i].index, TEST_LOCATION);
3900     DALI_TEST_EQUALS(actor.GetPropertyType(PROPERTY_TABLE[i].index), PROPERTY_TABLE[i].type, TEST_LOCATION);
3901   }
3902   END_TEST;
3903 }
3904
3905 int UtcDaliRelayoutProperties_ResizePolicies(void)
3906 {
3907   TestApplication application;
3908
3909   Actor actor = Actor::New();
3910
3911   // Defaults
3912   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_RESIZE_POLICY).Get<std::string>(), "USE_NATURAL_SIZE", TEST_LOCATION);
3913   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_RESIZE_POLICY).Get<std::string>(), "USE_NATURAL_SIZE", TEST_LOCATION);
3914
3915   // Set resize policy for all dimensions
3916   actor.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
3917   for(unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
3918   {
3919     DALI_TEST_EQUALS(actor.GetResizePolicy(static_cast<Dimension::Type>(1 << i)), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION);
3920   }
3921
3922   // Set individual dimensions
3923   const char* const widthPolicy  = "FILL_TO_PARENT";
3924   const char* const heightPolicy = "FIXED";
3925
3926   actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy);
3927   actor.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy);
3928
3929   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_RESIZE_POLICY).Get<std::string>(), widthPolicy, TEST_LOCATION);
3930   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_RESIZE_POLICY).Get<std::string>(), heightPolicy, TEST_LOCATION);
3931
3932   // Set individual dimensions using enums
3933   ResizePolicy::Type widthPolicyEnum  = ResizePolicy::USE_ASSIGNED_SIZE;
3934   ResizePolicy::Type heightPolicyEnum = ResizePolicy::SIZE_RELATIVE_TO_PARENT;
3935
3936   actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, widthPolicyEnum);
3937   actor.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicyEnum);
3938
3939   DALI_TEST_EQUALS(static_cast<int>(actor.GetResizePolicy(Dimension::WIDTH)), static_cast<int>(widthPolicyEnum), TEST_LOCATION);
3940   DALI_TEST_EQUALS(static_cast<int>(actor.GetResizePolicy(Dimension::HEIGHT)), static_cast<int>(heightPolicyEnum), TEST_LOCATION);
3941
3942   END_TEST;
3943 }
3944
3945 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
3946 {
3947   TestApplication application;
3948
3949   Actor actor = Actor::New();
3950
3951   // Defaults
3952   DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION);
3953
3954   SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3955   actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy);
3956   DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy, TEST_LOCATION);
3957
3958   // Set
3959   const SizeScalePolicy::Type policy1 = SizeScalePolicy::FIT_WITH_ASPECT_RATIO;
3960   const SizeScalePolicy::Type policy2 = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3961
3962   actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy1);
3963   DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy1, TEST_LOCATION);
3964
3965   actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy2);
3966   DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy2, TEST_LOCATION);
3967
3968   END_TEST;
3969 }
3970
3971 int UtcDaliRelayoutProperties_SizeModeFactor(void)
3972 {
3973   TestApplication application;
3974
3975   Actor actor = Actor::New();
3976
3977   // Defaults
3978   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_MODE_FACTOR).Get<Vector3>(), Vector3(1.0f, 1.0f, 1.0f), TEST_LOCATION);
3979   DALI_TEST_EQUALS(actor.GetProperty<Vector3>(Actor::Property::SIZE_MODE_FACTOR), Vector3(1.0f, 1.0f, 1.0f), TEST_LOCATION);
3980
3981   Vector3 sizeMode(1.0f, 2.0f, 3.0f);
3982   actor.SetProperty(Actor::Property::SIZE_MODE_FACTOR, sizeMode);
3983   DALI_TEST_EQUALS(actor.GetProperty<Vector3>(Actor::Property::SIZE_MODE_FACTOR), sizeMode, TEST_LOCATION);
3984
3985   // Set
3986   Vector3 sizeMode1(2.0f, 3.0f, 4.0f);
3987
3988   actor.SetProperty(Actor::Property::SIZE_MODE_FACTOR, sizeMode1);
3989   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_MODE_FACTOR).Get<Vector3>(), sizeMode1, TEST_LOCATION);
3990
3991   END_TEST;
3992 }
3993
3994 int UtcDaliRelayoutProperties_DimensionDependency(void)
3995 {
3996   TestApplication application;
3997
3998   Actor actor = Actor::New();
3999
4000   // Defaults
4001   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), false, TEST_LOCATION);
4002   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_FOR_WIDTH).Get<bool>(), false, TEST_LOCATION);
4003
4004   // Set
4005   actor.SetProperty(Actor::Property::WIDTH_FOR_HEIGHT, true);
4006   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), true, TEST_LOCATION);
4007
4008   actor.SetProperty(Actor::Property::HEIGHT_FOR_WIDTH, true);
4009   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_FOR_WIDTH).Get<bool>(), true, TEST_LOCATION);
4010
4011   // Test setting another resize policy
4012   actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FIXED");
4013   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), false, TEST_LOCATION);
4014
4015   END_TEST;
4016 }
4017
4018 int UtcDaliRelayoutProperties_Padding(void)
4019 {
4020   TestApplication application;
4021
4022   Actor actor = Actor::New();
4023
4024   // Data
4025   Vector4 padding(1.0f, 2.0f, 3.0f, 4.0f);
4026
4027   // PADDING
4028   actor.SetProperty(Actor::Property::PADDING, padding);
4029   Vector4 paddingResult = actor.GetProperty(Actor::Property::PADDING).Get<Vector4>();
4030
4031   DALI_TEST_EQUALS(paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION);
4032
4033   END_TEST;
4034 }
4035
4036 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
4037 {
4038   TestApplication application;
4039
4040   Actor actor = Actor::New();
4041
4042   // Data
4043   Vector2 minSize(1.0f, 2.0f);
4044
4045   actor.SetProperty(Actor::Property::MINIMUM_SIZE, minSize);
4046   Vector2 resultMin = actor.GetProperty(Actor::Property::MINIMUM_SIZE).Get<Vector2>();
4047
4048   DALI_TEST_EQUALS(resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
4049
4050   Vector2 maxSize(3.0f, 4.0f);
4051
4052   actor.SetProperty(Actor::Property::MAXIMUM_SIZE, maxSize);
4053   Vector2 resultMax = actor.GetProperty(Actor::Property::MAXIMUM_SIZE).Get<Vector2>();
4054
4055   DALI_TEST_EQUALS(resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
4056
4057   END_TEST;
4058 }
4059
4060 int UtcDaliActorGetHeightForWidth(void)
4061 {
4062   TestApplication application;
4063
4064   Actor actor = Actor::New();
4065
4066   DALI_TEST_EQUALS(actor.GetHeightForWidth(1.0f), 1.0f, TEST_LOCATION);
4067
4068   END_TEST;
4069 }
4070
4071 int UtcDaliActorGetWidthForHeight(void)
4072 {
4073   TestApplication application;
4074
4075   Actor actor = Actor::New();
4076
4077   DALI_TEST_EQUALS(actor.GetWidthForHeight(1.0f), 1.0f, TEST_LOCATION);
4078
4079   END_TEST;
4080 }
4081
4082 int UtcDaliActorGetRelayoutSize(void)
4083 {
4084   TestApplication application;
4085
4086   Actor actor = Actor::New();
4087
4088   // Add actor to stage
4089   application.GetScene().Add(actor);
4090
4091   DALI_TEST_EQUALS(actor.GetRelayoutSize(Dimension::WIDTH), 0.0f, TEST_LOCATION);
4092
4093   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::WIDTH);
4094   actor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 0.0f));
4095
4096   // Flush the queue and render once
4097   application.SendNotification();
4098   application.Render();
4099
4100   DALI_TEST_EQUALS(actor.GetRelayoutSize(Dimension::WIDTH), 1.0f, TEST_LOCATION);
4101
4102   END_TEST;
4103 }
4104
4105 int UtcDaliActorSetPadding(void)
4106 {
4107   TestApplication application;
4108
4109   Actor actor = Actor::New();
4110
4111   Padding padding;
4112   padding = actor.GetProperty<Vector4>(Actor::Property::PADDING);
4113
4114   DALI_TEST_EQUALS(padding.left, 0.0f, TEST_LOCATION);
4115   DALI_TEST_EQUALS(padding.right, 0.0f, TEST_LOCATION);
4116   DALI_TEST_EQUALS(padding.bottom, 0.0f, TEST_LOCATION);
4117   DALI_TEST_EQUALS(padding.top, 0.0f, TEST_LOCATION);
4118
4119   Padding padding2(1.0f, 2.0f, 3.0f, 4.0f);
4120   actor.SetProperty(Actor::Property::PADDING, padding2);
4121
4122   padding = actor.GetProperty<Vector4>(Actor::Property::PADDING);
4123
4124   DALI_TEST_EQUALS(padding.left, padding2.left, TEST_LOCATION);
4125   DALI_TEST_EQUALS(padding.right, padding2.right, TEST_LOCATION);
4126   DALI_TEST_EQUALS(padding.bottom, padding2.bottom, TEST_LOCATION);
4127   DALI_TEST_EQUALS(padding.top, padding2.top, TEST_LOCATION);
4128
4129   END_TEST;
4130 }
4131
4132 int UtcDaliActorSetMinimumSize(void)
4133 {
4134   TestApplication application;
4135
4136   Actor actor = Actor::New();
4137
4138   Vector2 size = actor.GetProperty<Vector2>(Actor::Property::MINIMUM_SIZE);
4139
4140   DALI_TEST_EQUALS(size.width, 0.0f, TEST_LOCATION);
4141   DALI_TEST_EQUALS(size.height, 0.0f, TEST_LOCATION);
4142
4143   Vector2 size2(1.0f, 2.0f);
4144   actor.SetProperty(Actor::Property::MINIMUM_SIZE, size2);
4145
4146   size = actor.GetProperty<Vector2>(Actor::Property::MINIMUM_SIZE);
4147
4148   DALI_TEST_EQUALS(size.width, size2.width, TEST_LOCATION);
4149   DALI_TEST_EQUALS(size.height, size2.height, TEST_LOCATION);
4150
4151   END_TEST;
4152 }
4153
4154 int UtcDaliActorSetMaximumSize(void)
4155 {
4156   TestApplication application;
4157
4158   Actor actor = Actor::New();
4159
4160   Vector2 size = actor.GetProperty<Vector2>(Actor::Property::MAXIMUM_SIZE);
4161
4162   DALI_TEST_EQUALS(size.width, FLT_MAX, TEST_LOCATION);
4163   DALI_TEST_EQUALS(size.height, FLT_MAX, TEST_LOCATION);
4164
4165   Vector2 size2(1.0f, 2.0f);
4166   actor.SetProperty(Actor::Property::MAXIMUM_SIZE, size2);
4167
4168   size = actor.GetProperty<Vector2>(Actor::Property::MAXIMUM_SIZE);
4169
4170   DALI_TEST_EQUALS(size.width, size2.width, TEST_LOCATION);
4171   DALI_TEST_EQUALS(size.height, size2.height, TEST_LOCATION);
4172
4173   END_TEST;
4174 }
4175
4176 int UtcDaliActorOnRelayoutSignal(void)
4177 {
4178   tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
4179
4180   TestApplication application;
4181
4182   // Clean test data
4183   gOnRelayoutCallBackCalled = false;
4184   gActorNamesRelayout.clear();
4185
4186   Actor actor = Actor::New();
4187   actor.SetProperty(Actor::Property::NAME, "actor");
4188   actor.OnRelayoutSignal().Connect(OnRelayoutCallback);
4189
4190   // Sanity check
4191   DALI_TEST_CHECK(!gOnRelayoutCallBackCalled);
4192
4193   // Add actor to stage
4194   application.GetScene().Add(actor);
4195
4196   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
4197   actor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 2.0));
4198
4199   // Flush the queue and render once
4200   application.SendNotification();
4201   application.Render();
4202
4203   // OnRelayout emitted
4204   DALI_TEST_EQUALS(gOnRelayoutCallBackCalled, true, TEST_LOCATION);
4205   DALI_TEST_EQUALS("actor", gActorNamesRelayout[0], TEST_LOCATION);
4206
4207   END_TEST;
4208 }
4209
4210 int UtcDaliActorGetHierachyDepth(void)
4211 {
4212   TestApplication application;
4213   tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
4214
4215   /* Build tree of actors:
4216    *
4217    *                      Depth
4218    *
4219    *       A (parent)       1
4220    *      / \
4221    *     B   C              2`
4222    *    / \   \
4223    *   D   E   F            3
4224    *
4225    * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
4226    */
4227   Integration::Scene stage(application.GetScene());
4228
4229   Actor actorA = Actor::New();
4230   Actor actorB = Actor::New();
4231   Actor actorC = Actor::New();
4232   Actor actorD = Actor::New();
4233   Actor actorE = Actor::New();
4234   Actor actorF = Actor::New();
4235
4236   //Test that root actor has depth equal 0
4237   DALI_TEST_EQUALS(0, stage.GetRootLayer().GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4238
4239   //Test actors return depth -1 when not connected to the tree
4240   DALI_TEST_EQUALS(-1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4241   DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4242   DALI_TEST_EQUALS(-1, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4243   DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4244   DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4245   DALI_TEST_EQUALS(-1, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4246
4247   //Create the hierarchy
4248   stage.Add(actorA);
4249   actorA.Add(actorB);
4250   actorA.Add(actorC);
4251   actorB.Add(actorD);
4252   actorB.Add(actorE);
4253   actorC.Add(actorF);
4254
4255   //Test actors return correct depth
4256   DALI_TEST_EQUALS(1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4257   DALI_TEST_EQUALS(2, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4258   DALI_TEST_EQUALS(2, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4259   DALI_TEST_EQUALS(3, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4260   DALI_TEST_EQUALS(3, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4261   DALI_TEST_EQUALS(3, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4262
4263   //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
4264   actorA.Remove(actorB);
4265
4266   DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4267   DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4268   DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4269
4270   //Removing actorA from the stage. All actors should have depth equal -1
4271   stage.Remove(actorA);
4272
4273   DALI_TEST_EQUALS(-1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4274   DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4275   DALI_TEST_EQUALS(-1, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4276   DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4277   DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4278   DALI_TEST_EQUALS(-1, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4279
4280   END_TEST;
4281 }
4282
4283 int UtcDaliActorAnchorPointPropertyAsString(void)
4284 {
4285   TestApplication application;
4286
4287   Actor actor = Actor::New();
4288
4289   actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_LEFT");
4290   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_LEFT, TEST_LOCATION);
4291
4292   actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_CENTER");
4293   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_CENTER, TEST_LOCATION);
4294
4295   actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_RIGHT");
4296   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_RIGHT, TEST_LOCATION);
4297
4298   actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER_LEFT");
4299   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER_LEFT, TEST_LOCATION);
4300
4301   actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER");
4302   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER, TEST_LOCATION);
4303
4304   actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER_RIGHT");
4305   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER_RIGHT, TEST_LOCATION);
4306
4307   actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT");
4308   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION);
4309
4310   actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER");
4311   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION);
4312
4313   actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT");
4314   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
4315
4316   // Invalid should not change anything
4317   actor.SetProperty(Actor::Property::ANCHOR_POINT, "INVALID_ARG");
4318   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
4319
4320   END_TEST;
4321 }
4322
4323 int UtcDaliActorParentOriginPropertyAsString(void)
4324 {
4325   TestApplication application;
4326
4327   Actor actor = Actor::New();
4328
4329   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_LEFT");
4330   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_LEFT, TEST_LOCATION);
4331
4332   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_CENTER");
4333   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_CENTER, TEST_LOCATION);
4334
4335   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_RIGHT");
4336   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_RIGHT, TEST_LOCATION);
4337
4338   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER_LEFT");
4339   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER_LEFT, TEST_LOCATION);
4340
4341   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER");
4342   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER, TEST_LOCATION);
4343
4344   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT");
4345   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER_RIGHT, TEST_LOCATION);
4346
4347   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT");
4348   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION);
4349
4350   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER");
4351   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION);
4352
4353   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT");
4354   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
4355
4356   // Invalid should not change anything
4357   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "INVALID_ARG");
4358   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
4359
4360   END_TEST;
4361 }
4362
4363 int UtcDaliActorColorModePropertyAsString(void)
4364 {
4365   TestApplication application;
4366
4367   Actor actor = Actor::New();
4368
4369   actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_COLOR");
4370   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_COLOR, TEST_LOCATION);
4371
4372   actor.SetProperty(Actor::Property::COLOR_MODE, "USE_PARENT_COLOR");
4373   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_PARENT_COLOR, TEST_LOCATION);
4374
4375   actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR");
4376   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION);
4377
4378   actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA");
4379   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
4380
4381   // Invalid should not change anything
4382   actor.SetProperty(Actor::Property::COLOR_MODE, "INVALID_ARG");
4383   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
4384
4385   END_TEST;
4386 }
4387
4388 int UtcDaliActorDrawModePropertyAsString(void)
4389 {
4390   TestApplication application;
4391
4392   Actor actor = Actor::New();
4393
4394   actor.SetProperty(Actor::Property::DRAW_MODE, "NORMAL");
4395   DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::NORMAL, TEST_LOCATION);
4396
4397   actor.SetProperty(Actor::Property::DRAW_MODE, "OVERLAY_2D");
4398   DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
4399
4400   // Invalid should not change anything
4401   actor.SetProperty(Actor::Property::DRAW_MODE, "INVALID_ARG");
4402   DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
4403
4404   END_TEST;
4405 }
4406
4407 int UtcDaliActorColorModePropertyAsEnum(void)
4408 {
4409   TestApplication application;
4410
4411   Actor actor = Actor::New();
4412
4413   actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
4414   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_COLOR, TEST_LOCATION);
4415
4416   actor.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
4417   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_PARENT_COLOR, TEST_LOCATION);
4418
4419   actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR);
4420   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION);
4421
4422   actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
4423   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
4424
4425   END_TEST;
4426 }
4427
4428 int UtcDaliActorDrawModePropertyAsEnum(void)
4429 {
4430   TestApplication application;
4431
4432   Actor actor = Actor::New();
4433
4434   actor.SetProperty(Actor::Property::DRAW_MODE, DrawMode::NORMAL);
4435   DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::NORMAL, TEST_LOCATION);
4436
4437   actor.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
4438   DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
4439
4440   END_TEST;
4441 }
4442
4443 int UtcDaliActorAddRendererP(void)
4444 {
4445   tet_infoline("Testing Actor::AddRenderer");
4446   TestApplication application;
4447
4448   Actor actor = Actor::New();
4449
4450   DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4451
4452   Geometry geometry = CreateQuadGeometry();
4453   Shader   shader   = CreateShader();
4454   Renderer renderer = Renderer::New(geometry, shader);
4455
4456   actor.AddRenderer(renderer);
4457   DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4458   DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4459
4460   END_TEST;
4461 }
4462
4463 int UtcDaliActorAddRendererN01(void)
4464 {
4465   tet_infoline("Testing Actor::AddRenderer");
4466   TestApplication application;
4467
4468   Actor    actor = Actor::New();
4469   Renderer renderer;
4470
4471   // try illegal Add
4472   try
4473   {
4474     actor.AddRenderer(renderer);
4475     tet_printf("Assertion test failed - no Exception\n");
4476     tet_result(TET_FAIL);
4477   }
4478   catch(Dali::DaliException& e)
4479   {
4480     DALI_TEST_PRINT_ASSERT(e);
4481     DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
4482     DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4483   }
4484   catch(...)
4485   {
4486     tet_printf("Assertion test failed - wrong Exception\n");
4487     tet_result(TET_FAIL);
4488   }
4489
4490   END_TEST;
4491 }
4492
4493 int UtcDaliActorAddRendererN02(void)
4494 {
4495   tet_infoline("UtcDaliActorAddRendererN02");
4496
4497   Actor    actor;
4498   Renderer renderer;
4499
4500   {
4501     TestApplication application;
4502
4503     Geometry geometry = CreateQuadGeometry();
4504     Shader   shader   = CreateShader();
4505     renderer          = Renderer::New(geometry, shader);
4506
4507     actor = Actor::New();
4508   }
4509
4510   // try illegal AddRenderer
4511   try
4512   {
4513     actor.AddRenderer(renderer);
4514     tet_printf("Assertion test failed - no Exception\n");
4515     tet_result(TET_FAIL);
4516   }
4517   catch(Dali::DaliException& e)
4518   {
4519     DALI_TEST_PRINT_ASSERT(e);
4520     DALI_TEST_ASSERT(e, "EventThreadServices::IsCoreRunning()", TEST_LOCATION);
4521   }
4522   catch(...)
4523   {
4524     tet_printf("Assertion test failed - wrong Exception\n");
4525     tet_result(TET_FAIL);
4526   }
4527
4528   END_TEST;
4529 }
4530
4531 int UtcDaliActorAddRendererOnScene(void)
4532 {
4533   tet_infoline("Testing Actor::AddRenderer");
4534   TestApplication application;
4535
4536   Actor actor = Actor::New();
4537   application.GetScene().Add(actor);
4538
4539   application.SendNotification();
4540   application.Render(0);
4541
4542   Geometry geometry = CreateQuadGeometry();
4543   Shader   shader   = CreateShader();
4544   Renderer renderer = Renderer::New(geometry, shader);
4545
4546   application.SendNotification();
4547   application.Render(0);
4548
4549   try
4550   {
4551     actor.AddRenderer(renderer);
4552     tet_result(TET_PASS);
4553   }
4554   catch(...)
4555   {
4556     tet_result(TET_FAIL);
4557   }
4558
4559   END_TEST;
4560 }
4561
4562 int UtcDaliActorRemoveRendererP1(void)
4563 {
4564   tet_infoline("Testing Actor::RemoveRenderer");
4565   TestApplication application;
4566
4567   Actor actor = Actor::New();
4568
4569   DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4570
4571   {
4572     Geometry geometry = CreateQuadGeometry();
4573     Shader   shader   = CreateShader();
4574     Renderer renderer = Renderer::New(geometry, shader);
4575
4576     actor.AddRenderer(renderer);
4577     DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4578     DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4579
4580     application.SendNotification();
4581     application.Render();
4582   }
4583
4584   {
4585     Renderer renderer = actor.GetRendererAt(0);
4586     actor.RemoveRenderer(renderer);
4587     DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4588
4589     application.SendNotification();
4590     application.Render();
4591   }
4592
4593   // Call one final time to ensure that the renderer is actually removed after
4594   // the handle goes out of scope, and excercises the deletion code path in
4595   // scene graph and render.
4596   application.SendNotification();
4597   application.Render();
4598
4599   END_TEST;
4600 }
4601
4602 int UtcDaliActorRemoveRendererP2(void)
4603 {
4604   tet_infoline("Testing Actor::RemoveRenderer");
4605   TestApplication application;
4606
4607   Actor actor = Actor::New();
4608
4609   DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4610
4611   Geometry geometry = CreateQuadGeometry();
4612   Shader   shader   = CreateShader();
4613   Renderer renderer = Renderer::New(geometry, shader);
4614
4615   actor.AddRenderer(renderer);
4616   application.SendNotification();
4617   application.Render();
4618
4619   DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4620   DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4621
4622   actor.RemoveRenderer(0);
4623   application.SendNotification();
4624   application.Render();
4625
4626   DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4627
4628   // Shut down whilst holding onto the renderer handle.
4629   END_TEST;
4630 }
4631
4632 int UtcDaliActorRemoveRendererP3(void)
4633 {
4634   tet_infoline("Testing Actor::RemoveRenderer");
4635   TestApplication application;
4636
4637   Actor actor1 = Actor::New();
4638   Actor actor2 = Actor::New();
4639   Actor actor3 = Actor::New();
4640
4641   application.GetScene().Add(actor1);
4642   application.GetScene().Add(actor2);
4643   application.GetScene().Add(actor3);
4644
4645   // Make each actors size bigger than zero, so we can assuem that actor is rendered
4646   actor1.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
4647   actor2.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
4648   actor3.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
4649
4650   // Register some dummy property to seperate actor1 and actor2 in Render::Renderer
4651   actor1.RegisterProperty("dummy1", 1);
4652   actor2.RegisterProperty("dummy2", 2.0f);
4653   actor3.RegisterProperty("dummy3", Vector2(3.0f, 4.0f));
4654
4655   DALI_TEST_EQUALS(actor1.GetRendererCount(), 0u, TEST_LOCATION);
4656   DALI_TEST_EQUALS(actor2.GetRendererCount(), 0u, TEST_LOCATION);
4657   DALI_TEST_EQUALS(actor3.GetRendererCount(), 0u, TEST_LOCATION);
4658
4659   Geometry geometry  = CreateQuadGeometry();
4660   Shader   shader    = CreateShader();
4661   Renderer renderer1 = Renderer::New(geometry, shader);
4662   Renderer renderer2 = Renderer::New(geometry, shader);
4663
4664   actor1.AddRenderer(renderer1);
4665   actor1.AddRenderer(renderer2);
4666   actor2.AddRenderer(renderer1);
4667   actor2.AddRenderer(renderer2);
4668   actor3.AddRenderer(renderer1);
4669   actor3.AddRenderer(renderer2);
4670   application.SendNotification();
4671   application.Render();
4672
4673   DALI_TEST_EQUALS(actor1.GetRendererCount(), 2u, TEST_LOCATION);
4674   DALI_TEST_EQUALS(actor1.GetRendererAt(0), renderer1, TEST_LOCATION);
4675   DALI_TEST_EQUALS(actor1.GetRendererAt(1), renderer2, TEST_LOCATION);
4676
4677   DALI_TEST_EQUALS(actor2.GetRendererCount(), 2u, TEST_LOCATION);
4678   DALI_TEST_EQUALS(actor2.GetRendererAt(0), renderer1, TEST_LOCATION);
4679   DALI_TEST_EQUALS(actor2.GetRendererAt(1), renderer2, TEST_LOCATION);
4680
4681   DALI_TEST_EQUALS(actor3.GetRendererCount(), 2u, TEST_LOCATION);
4682   DALI_TEST_EQUALS(actor3.GetRendererAt(0), renderer1, TEST_LOCATION);
4683   DALI_TEST_EQUALS(actor3.GetRendererAt(1), renderer2, TEST_LOCATION);
4684
4685   actor1.RemoveRenderer(0);
4686   actor2.RemoveRenderer(1);
4687   actor3.RemoveRenderer(0);
4688   application.SendNotification();
4689   application.Render();
4690
4691   DALI_TEST_EQUALS(actor1.GetRendererCount(), 1u, TEST_LOCATION);
4692   DALI_TEST_EQUALS(actor1.GetRendererAt(0), renderer2, TEST_LOCATION);
4693   DALI_TEST_EQUALS(actor2.GetRendererCount(), 1u, TEST_LOCATION);
4694   DALI_TEST_EQUALS(actor2.GetRendererAt(0), renderer1, TEST_LOCATION);
4695   DALI_TEST_EQUALS(actor3.GetRendererCount(), 1u, TEST_LOCATION);
4696   DALI_TEST_EQUALS(actor3.GetRendererAt(0), renderer2, TEST_LOCATION);
4697
4698   // Shut down whilst holding onto the renderer handle.
4699   END_TEST;
4700 }
4701
4702 int UtcDaliActorRemoveRendererN(void)
4703 {
4704   tet_infoline("Testing Actor::RemoveRenderer");
4705   TestApplication application;
4706
4707   Actor actor = Actor::New();
4708
4709   DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4710
4711   Geometry geometry = CreateQuadGeometry();
4712   Shader   shader   = CreateShader();
4713   Renderer renderer = Renderer::New(geometry, shader);
4714
4715   actor.AddRenderer(renderer);
4716   DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4717   DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4718
4719   actor.RemoveRenderer(10);
4720   DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4721   DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4722
4723   END_TEST;
4724 }
4725
4726 int UtcDaliActorPropertyClippingP(void)
4727 {
4728   // This test checks the clippingMode property.
4729   tet_infoline("Testing Actor::Property::ClippingMode: P");
4730   TestApplication application;
4731
4732   Actor actor = Actor::New();
4733
4734   // Check default clippingEnabled value.
4735   Property::Value getValue(actor.GetProperty(Actor::Property::CLIPPING_MODE));
4736
4737   int  value          = 0;
4738   bool getValueResult = getValue.Get(value);
4739   DALI_TEST_CHECK(getValueResult);
4740
4741   if(getValueResult)
4742   {
4743     DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4744   }
4745
4746   // Check setting the property to the stencil mode.
4747   actor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4748
4749   // Check the new value was set.
4750   getValue       = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4751   getValueResult = getValue.Get(value);
4752   DALI_TEST_CHECK(getValueResult);
4753
4754   if(getValueResult)
4755   {
4756     DALI_TEST_EQUALS<int>(value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION);
4757   }
4758
4759   // Check setting the property to the scissor mode.
4760   actor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4761
4762   // Check the new value was set.
4763   getValue       = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4764   getValueResult = getValue.Get(value);
4765   DALI_TEST_CHECK(getValueResult);
4766
4767   if(getValueResult)
4768   {
4769     DALI_TEST_EQUALS<int>(value, ClippingMode::CLIP_TO_BOUNDING_BOX, TEST_LOCATION);
4770   }
4771   END_TEST;
4772 }
4773
4774 int UtcDaliActorPropertyClippingN(void)
4775 {
4776   // Negative test case for Clipping.
4777   tet_infoline("Testing Actor::Property::ClippingMode: N");
4778   TestApplication application;
4779
4780   Actor actor = Actor::New();
4781
4782   // Check default clippingEnabled value.
4783   Property::Value getValue(actor.GetProperty(Actor::Property::CLIPPING_MODE));
4784
4785   int  value          = 0;
4786   bool getValueResult = getValue.Get(value);
4787   DALI_TEST_CHECK(getValueResult);
4788
4789   if(getValueResult)
4790   {
4791     DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4792   }
4793
4794   // Check setting an invalid property value won't change the current property value.
4795   actor.SetProperty(Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY");
4796
4797   getValue       = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4798   getValueResult = getValue.Get(value);
4799   DALI_TEST_CHECK(getValueResult);
4800
4801   if(getValueResult)
4802   {
4803     DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4804   }
4805
4806   END_TEST;
4807 }
4808
4809 int UtcDaliActorPropertyClippingActor(void)
4810 {
4811   // This test checks that an actor is correctly setup for clipping.
4812   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor");
4813   TestApplication application;
4814
4815   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4816   TraceCallStack&    stencilTrace        = glAbstraction.GetStencilFunctionTrace();
4817   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4818   size_t             startIndex          = 0u;
4819
4820   // Create a clipping actor.
4821   Actor actorDepth1Clip = CreateActorWithContent16x16();
4822   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4823   application.GetScene().Add(actorDepth1Clip);
4824
4825   // Gather the call trace.
4826   GenerateTrace(application, enabledDisableTrace, stencilTrace);
4827
4828   // Check we are writing to the color buffer.
4829   CheckColorMask(glAbstraction, true);
4830
4831   // Check the stencil buffer was enabled.
4832   std::ostringstream oss;
4833   oss << std::hex << GL_STENCIL_TEST;
4834   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
4835
4836   // Check the stencil buffer was cleared.
4837   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4838
4839   // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4840   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4841   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));
4842   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4843
4844   END_TEST;
4845 }
4846
4847 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
4848 {
4849   // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
4850   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor enable and then disable");
4851   TestApplication application;
4852
4853   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4854   TraceCallStack&    stencilTrace        = glAbstraction.GetStencilFunctionTrace();
4855   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4856   size_t             startIndex          = 0u;
4857
4858   // Create a clipping actor.
4859   Actor actorDepth1Clip = CreateActorWithContent16x16();
4860   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4861   application.GetScene().Add(actorDepth1Clip);
4862
4863   // Gather the call trace.
4864   GenerateTrace(application, enabledDisableTrace, stencilTrace);
4865
4866   // Check we are writing to the color buffer.
4867   CheckColorMask(glAbstraction, true);
4868
4869   // Check the stencil buffer was enabled.
4870   std::ostringstream oss;
4871   oss << std::hex << GL_STENCIL_TEST;
4872   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
4873
4874   // Check the stencil buffer was cleared.
4875   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4876
4877   // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4878   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4879   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));
4880   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4881
4882   // Now disable the clipping
4883   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED);
4884
4885   // Gather the call trace.
4886   GenerateTrace(application, enabledDisableTrace, stencilTrace);
4887
4888   // Check the stencil buffer was disabled.
4889   std::ostringstream stencil;
4890   stencil << std::hex << GL_STENCIL_TEST;
4891   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Disable", stencil.str()));
4892
4893   // Ensure all values in stencil-mask are set to 1.
4894   startIndex = 0u;
4895   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "255", startIndex));
4896
4897   END_TEST;
4898 }
4899
4900 int UtcDaliActorPropertyClippingNestedChildren(void)
4901 {
4902   // This test checks that a hierarchy of actors are clipped correctly by
4903   // writing to and reading from the correct bit-planes of the stencil buffer.
4904   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN nested children");
4905   TestApplication    application;
4906   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4907   TraceCallStack&    stencilTrace        = glAbstraction.GetStencilFunctionTrace();
4908   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4909
4910   // Create a clipping actor.
4911   Actor actorDepth1Clip = CreateActorWithContent16x16();
4912   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4913   application.GetScene().Add(actorDepth1Clip);
4914
4915   // Create a child actor.
4916   Actor childDepth2 = CreateActorWithContent16x16();
4917   actorDepth1Clip.Add(childDepth2);
4918
4919   // Create another clipping actor.
4920   Actor childDepth2Clip = CreateActorWithContent16x16();
4921   childDepth2Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4922   childDepth2.Add(childDepth2Clip);
4923
4924   // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
4925   // This tests the sort algorithm.
4926   Actor childDepth3 = CreateActorWithContent16x16();
4927   childDepth2Clip.Add(childDepth3);
4928   Actor childDepth4 = CreateActorWithContent16x16();
4929   childDepth3.Add(childDepth4);
4930
4931   // Gather the call trace.
4932   GenerateTrace(application, enabledDisableTrace, stencilTrace);
4933
4934   // Check we are writing to the color buffer.
4935   CheckColorMask(glAbstraction, true);
4936
4937   // Check the stencil buffer was enabled.
4938   std::ostringstream oss;
4939   oss << std::hex << GL_STENCIL_TEST;
4940   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
4941
4942   // Perform the test twice, once for 2D layer, and once for 3D.
4943   for(unsigned int i = 0u; i < 2u; ++i)
4944   {
4945     size_t startIndex = 0u;
4946
4947     // Check the stencil buffer was cleared.
4948     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4949
4950     // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4951     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex));      // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4952     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));              // Write to the first bit-plane
4953     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4954
4955     // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
4956     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 1", startIndex));      // 514 is GL_EQUAL
4957     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7680, 7680", startIndex)); // GL_KEEP, GL_KEEP, GL_KEEP
4958
4959     // Check we are set up to write to the second bitplane of the stencil buffer (only).
4960     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 3, 1", startIndex));      // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4961     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "3", startIndex));              // Write to second (and previous) bit-planes
4962     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4963
4964     // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4965     // (Both must be set to pass the check).
4966     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 3, 3", startIndex));      // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4967     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7680, 7680", startIndex)); // GL_KEEP, GL_KEEP, GL_KEEP
4968
4969     // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4970     if(i == 0u)
4971     {
4972       application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D);
4973       GenerateTrace(application, enabledDisableTrace, stencilTrace);
4974     }
4975   }
4976
4977   END_TEST;
4978 }
4979
4980 int UtcDaliActorPropertyClippingActorDrawOrder(void)
4981 {
4982   // This test checks that a hierarchy of actors are drawn in the correct order when clipping is enabled.
4983   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN draw order");
4984   TestApplication    application;
4985   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4986   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4987
4988   /* We create a small tree of actors as follows:
4989
4990                            A
4991                           / \
4992      Clipping enabled -> B   D
4993                          |   |
4994                          C   E
4995
4996      The correct draw order is "ABCDE" (the same as if clipping was not enabled).
4997   */
4998   Actor actors[5];
4999   for(int i = 0; i < 5; ++i)
5000   {
5001     Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
5002     Actor   actor = CreateRenderableActor(image);
5003
5004     // Setup dimensions and position so actor is not skipped by culling.
5005     actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
5006     actor.SetProperty(Actor::Property::SIZE, Vector2(16.0f, 16.0f));
5007
5008     if(i == 0)
5009     {
5010       actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5011     }
5012     else
5013     {
5014       float b = i > 2 ? 1.0f : -1.0f;
5015       actor.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0.5 + (0.2f * b), 0.8f, 0.8f));
5016     }
5017
5018     actors[i] = actor;
5019   }
5020
5021   // Enable clipping on the actor at the top of the left branch.
5022   actors[1].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
5023
5024   // Build the scene graph.
5025   application.GetScene().Add(actors[0]);
5026
5027   // Left branch:
5028   actors[0].Add(actors[1]);
5029   actors[1].Add(actors[2]);
5030
5031   // Right branch:
5032   actors[0].Add(actors[3]);
5033   actors[3].Add(actors[4]);
5034
5035   // Gather the call trace.
5036   enabledDisableTrace.Reset();
5037   enabledDisableTrace.Enable(true);
5038   application.SendNotification();
5039   application.Render();
5040   enabledDisableTrace.Enable(false);
5041
5042   /* Check stencil is enabled and disabled again (as right-hand branch of tree is drawn).
5043
5044      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
5045            Incorrect enable call trace:  StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960
5046   */
5047   size_t             startIndex = 0u;
5048   std::ostringstream blend;
5049   blend << std::hex << GL_BLEND;
5050   std::ostringstream stencil;
5051   stencil << std::hex << GL_STENCIL_TEST;
5052
5053   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", blend.str(), startIndex));
5054   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", stencil.str(), startIndex));
5055   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", stencil.str(), startIndex));
5056
5057   // Swap the clipping actor from top of left branch to top of right branch.
5058   actors[1].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED);
5059   actors[3].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
5060
5061   // Gather the call trace.
5062   enabledDisableTrace.Reset();
5063   enabledDisableTrace.Enable(true);
5064   application.SendNotification();
5065   application.Render();
5066   enabledDisableTrace.Enable(false);
5067
5068   // Check stencil is enabled but NOT disabled again (as right-hand branch of tree is drawn).
5069   // This proves the draw order has remained the same.
5070   startIndex = 0u;
5071   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", stencil.str(), startIndex));
5072   DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", stencil.str(), startIndex));
5073
5074   END_TEST;
5075 }
5076
5077 int UtcDaliActorPropertyScissorClippingActor01(void)
5078 {
5079   // This test checks that an actor is correctly setup for clipping.
5080   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor");
5081   TestApplication application;
5082
5083   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
5084   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
5085   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5086
5087   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
5088   const Vector2 imageSize(16.0f, 16.0f);
5089
5090   // Create a clipping actor.
5091   Actor clippingActorA = CreateActorWithContent16x16();
5092   // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
5093   // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
5094   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
5095   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
5096   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5097   application.GetScene().Add(clippingActorA);
5098
5099   // Gather the call trace.
5100   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5101
5102   // Check we are writing to the color buffer.
5103   CheckColorMask(glAbstraction, true);
5104
5105   // Check scissor test was enabled.
5106
5107   std::ostringstream scissor;
5108   scissor << std::hex << GL_SCISSOR_TEST;
5109   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5110
5111   // Check the scissor was set, and the coordinates are correct.
5112   std::stringstream compareParametersString;
5113   compareParametersString << "0, 0, " << imageSize.x << ", " << imageSize.y;
5114   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
5115
5116   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
5117   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_RIGHT);
5118
5119   // Gather the call trace.
5120   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5121
5122   // Check the scissor was set, and the coordinates are correct.
5123   compareParametersString.str(std::string());
5124   compareParametersString.clear();
5125   compareParametersString << (stageSize.x - imageSize.x) << ", " << (stageSize.y - imageSize.y) << ", " << imageSize.x << ", " << imageSize.y;
5126   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 464, 784, 16, 16
5127
5128   END_TEST;
5129 }
5130
5131 int UtcDaliActorPropertyScissorClippingActor02(void)
5132 {
5133   // This test checks that an actor is correctly setup for clipping.
5134   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor with a transparent renderer");
5135   TestApplication application;
5136
5137   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
5138   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
5139   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5140
5141   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
5142   const Vector2 actorSize(16.0f, 16.0f);
5143
5144   // Create a clipping actor.
5145   Actor clippingActorA                  = CreateRenderableActor();
5146   clippingActorA[Actor::Property::SIZE] = actorSize;
5147
5148   Renderer renderer = clippingActorA.GetRendererAt(0);
5149   DALI_TEST_CHECK(renderer);
5150
5151   // Make Renderer opacity 0.
5152   renderer[DevelRenderer::Property::OPACITY] = 0.0f;
5153
5154   // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
5155   // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
5156   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
5157   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
5158   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5159   application.GetScene().Add(clippingActorA);
5160
5161   // Gather the call trace.
5162   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5163
5164   // Check we are writing to the color buffer.
5165   CheckColorMask(glAbstraction, true);
5166
5167   // Check scissor test was enabled.
5168
5169   std::ostringstream scissor;
5170   scissor << std::hex << GL_SCISSOR_TEST;
5171   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5172
5173   // Check the scissor was set, and the coordinates are correct.
5174   std::stringstream compareParametersString;
5175   compareParametersString << "0, 0, " << actorSize.x << ", " << actorSize.y;
5176   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
5177
5178   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
5179   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_RIGHT);
5180
5181   // Gather the call trace.
5182   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5183
5184   // Check the scissor was set, and the coordinates are correct.
5185   compareParametersString.str(std::string());
5186   compareParametersString.clear();
5187   compareParametersString << (stageSize.x - actorSize.x) << ", " << (stageSize.y - actorSize.y) << ", " << actorSize.x << ", " << actorSize.y;
5188   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 464, 784, 16, 16
5189
5190   END_TEST;
5191 }
5192
5193 int UtcDaliActorPropertyScissorClippingActorSiblings(void)
5194 {
5195   // This test checks that an actor is correctly setup for clipping.
5196   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actors which are siblings");
5197   TestApplication application;
5198
5199   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
5200   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
5201   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5202
5203   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
5204   const Vector2 sizeA{stageSize.width, stageSize.height * 0.25f};
5205   const Vector2 sizeB{stageSize.width, stageSize.height * 0.05f};
5206
5207   // Create a clipping actors.
5208   Actor clippingActorA = CreateActorWithContent(sizeA.width, sizeA.height);
5209   Actor clippingActorB = CreateActorWithContent(sizeB.width, sizeB.height);
5210
5211   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5212   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5213   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5214
5215   clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5216   clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5217   clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5218
5219   clippingActorA.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -200.0f, 0.0f));
5220   clippingActorB.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
5221
5222   application.GetScene().Add(clippingActorA);
5223   application.GetScene().Add(clippingActorB);
5224
5225   // Gather the call trace.
5226   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5227
5228   // Check we are writing to the color buffer.
5229   CheckColorMask(glAbstraction, true);
5230
5231   // Check scissor test was enabled.
5232   std::ostringstream scissor;
5233   scissor << std::hex << GL_SCISSOR_TEST;
5234   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5235
5236   // Check the scissor was set, and the coordinates are correct.
5237   std::stringstream compareParametersString;
5238
5239   std::string clipA("0, 500, 480, 200");
5240   std::string clipB("0, 380, 480, 40");
5241
5242   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipA));
5243   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipB));
5244
5245   END_TEST;
5246 }
5247
5248 int UtcDaliActorPropertyScissorClippingActorNested01(void)
5249 {
5250   // This test checks that an actor is correctly setup for clipping.
5251   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested");
5252   TestApplication application;
5253
5254   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
5255   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
5256   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5257
5258   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
5259   const Vector2 imageSize(16.0f, 16.0f);
5260
5261   /* Create a nest of 2 scissors to test nesting (intersecting clips).
5262
5263      A is drawn first - with scissor clipping on
5264      B is drawn second - also with scissor clipping on
5265      C is the generated clipping region, the intersection ( A ∩ B )
5266
5267            ┏━━━━━━━┓                   ┌───────┐
5268            ┃     B ┃                   │     B │
5269        ┌───╂┄┄┄┐   ┃               ┌┄┄┄╆━━━┓   │
5270        │   ┃   ┊   ┃     ━━━━━>    ┊   ┃ C ┃   │
5271        │   ┗━━━┿━━━┛               ┊   ┗━━━╃───┘
5272        │ A     │                   ┊ A     ┊
5273        └───────┘                   └┄┄┄┄┄┄┄┘
5274
5275      We then reposition B around each corner of A to test the 4 overlap combinations (thus testing intersecting works correctly).
5276   */
5277
5278   // Create a clipping actor.
5279   Actor clippingActorA = CreateActorWithContent16x16();
5280   // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
5281   // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
5282   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5283   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5284   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5285   application.GetScene().Add(clippingActorA);
5286
5287   // Create a child clipping actor.
5288   Actor clippingActorB = CreateActorWithContent16x16();
5289   clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5290   clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5291   clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5292   clippingActorA.Add(clippingActorB);
5293
5294   // positionModifiers is an array of positions to position B around.
5295   // expect is an array of expected scissor clip coordinate results.
5296   const Vector2 positionModifiers[4] = {Vector2(1.0f, 1.0f), Vector2(-1.0f, 1.0f), Vector2(-1.0f, -1.0f), Vector2(1.0f, -1.0f)};
5297   const Vector4 expect[4]            = {Vector4(240, 392, 8, 8), Vector4(232, 392, 8, 8), Vector4(232, 400, 8, 8), Vector4(240, 400, 8, 8)};
5298
5299   // Loop through each overlap combination.
5300   for(unsigned int test = 0u; test < 4u; ++test)
5301   {
5302     // Position the child clipping actor so it intersects with the 1st clipping actor. This changes each loop.
5303     const Vector2 position = (imageSize / 2.0f) * positionModifiers[test];
5304     clippingActorB.SetProperty(Actor::Property::POSITION, Vector2(position.x, position.y));
5305
5306     // Gather the call trace.
5307     GenerateTrace(application, enabledDisableTrace, scissorTrace);
5308
5309     // Check we are writing to the color buffer.
5310     CheckColorMask(glAbstraction, true);
5311
5312     // Check scissor test was enabled.
5313     std::ostringstream scissor;
5314     scissor << std::hex << GL_SCISSOR_TEST;
5315     DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5316
5317     // Check the scissor was set, and the coordinates are correct.
5318     const Vector4&    expectResults(expect[test]);
5319     std::stringstream compareParametersString;
5320     compareParametersString << expectResults.x << ", " << expectResults.y << ", " << expectResults.z << ", " << expectResults.w;
5321     DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with the expected result
5322   }
5323
5324   END_TEST;
5325 }
5326
5327 int UtcDaliActorPropertyScissorClippingActorNested02(void)
5328 {
5329   // This test checks that an actor is correctly setup for clipping.
5330   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested");
5331   TestApplication application;
5332
5333   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
5334   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
5335   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5336
5337   /* Create a nest of 2 scissors and siblings of the parent.
5338
5339             stage
5340               |
5341         ┌─────┐─────┐
5342         A     C     D
5343         |           |
5344         B           E
5345   */
5346
5347   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
5348   const Vector2 sizeA{stageSize.width, stageSize.height * 0.25f};
5349   const Vector2 sizeB{stageSize.width, stageSize.height * 0.05f};
5350   const Vector2 sizeC{stageSize.width, stageSize.height * 0.25f};
5351   const Vector2 sizeD{stageSize.width, stageSize.height * 0.25f};
5352   const Vector2 sizeE{stageSize.width, stageSize.height * 0.05f};
5353
5354   // Create a clipping actors.
5355   Actor clippingActorA = CreateActorWithContent(sizeA.width, sizeA.height);
5356   Actor clippingActorB = CreateActorWithContent(sizeB.width, sizeB.height);
5357   Actor clippingActorC = CreateActorWithContent(sizeC.width, sizeC.height);
5358   Actor clippingActorD = CreateActorWithContent(sizeD.width, sizeD.height);
5359   Actor clippingActorE = CreateActorWithContent(sizeE.width, sizeE.height);
5360
5361   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5362   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5363   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5364
5365   clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5366   clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5367   clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5368
5369   clippingActorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5370   clippingActorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5371   clippingActorC.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5372
5373   clippingActorD.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5374   clippingActorD.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5375   clippingActorD.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5376
5377   clippingActorE.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5378   clippingActorE.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5379
5380   clippingActorA.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -200.0f, 0.0f));
5381   clippingActorB.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
5382   clippingActorC.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 100.0f, 0.0f));
5383   clippingActorD.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
5384   clippingActorE.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
5385
5386   application.GetScene().Add(clippingActorA);
5387   clippingActorA.Add(clippingActorB);
5388   application.GetScene().Add(clippingActorC);
5389   application.GetScene().Add(clippingActorD);
5390   clippingActorD.Add(clippingActorE);
5391
5392   // Gather the call trace.
5393   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5394
5395   // Check we are writing to the color buffer.
5396   CheckColorMask(glAbstraction, true);
5397
5398   // Check scissor test was enabled.
5399   std::ostringstream scissor;
5400   scissor << std::hex << GL_SCISSOR_TEST;
5401   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5402
5403   // Check the scissor was set, and the coordinates are correct.
5404   std::string clipA("0, 500, 480, 200");
5405   std::string clipB("0, 580, 480, 40");
5406   std::string clipC("0, 200, 480, 200");
5407   std::string clipD("0, 300, 480, 200");
5408
5409   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipA));
5410   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipB));
5411   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipC));
5412   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipD));
5413   DALI_TEST_EQUALS(scissorTrace.CountMethod("Scissor"), 4, TEST_LOCATION); // Scissor rect should not be changed in clippingActorE case. So count should be 4.
5414
5415   END_TEST;
5416 }
5417
5418 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
5419 {
5420   // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
5421   tet_infoline("Testing Actor::Property::CLIPPING_MODE actor with renderer override");
5422   TestApplication application;
5423
5424   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
5425   TraceCallStack&    stencilTrace        = glAbstraction.GetStencilFunctionTrace();
5426   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5427
5428   // Create a clipping actor.
5429   Actor actorDepth1Clip = CreateActorWithContent16x16();
5430   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
5431   application.GetScene().Add(actorDepth1Clip);
5432
5433   // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
5434   actorDepth1Clip.GetRendererAt(0).SetProperty(Renderer::Property::RENDER_MODE, RenderMode::COLOR);
5435
5436   // Gather the call trace.
5437   GenerateTrace(application, enabledDisableTrace, stencilTrace);
5438
5439   // Check we are writing to the color buffer.
5440   CheckColorMask(glAbstraction, true);
5441
5442   // Check the stencil buffer was not enabled.
5443   std::ostringstream stencil;
5444   stencil << std::hex << GL_STENCIL_TEST;
5445   DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", stencil.str()));
5446
5447   // Check stencil functions are not called.
5448   DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilFunc"));
5449   DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilOp"));
5450
5451   // Check that scissor clipping is overriden by the renderer properties.
5452   TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
5453
5454   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5455
5456   // Gather the call trace.
5457   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5458
5459   // Check the stencil buffer was not enabled.
5460   std::ostringstream scissor;
5461   scissor << std::hex << GL_SCISSOR_TEST;
5462   DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5463
5464   DALI_TEST_CHECK(!scissorTrace.FindMethod("StencilFunc"));
5465
5466   END_TEST;
5467 }
5468
5469 int UtcDaliActorPropertyClippingActorCulled(void)
5470 {
5471   // This test checks that child actors are clipped by an culled parent actor.
5472   tet_infoline("Testing child actors are clipped by an culled parent actor");
5473   TestApplication application;
5474
5475   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
5476   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
5477   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5478
5479   const Vector2 actorSize(160.0f, 160.0f);
5480
5481   // Create a clipping actor.
5482   Actor clippingActorA                  = CreateRenderableActor();
5483   clippingActorA[Actor::Property::SIZE] = actorSize;
5484
5485   // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
5486   // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
5487   clippingActorA[Actor::Property::PARENT_ORIGIN] = ParentOrigin::BOTTOM_LEFT;
5488   clippingActorA[Actor::Property::ANCHOR_POINT]  = AnchorPoint::BOTTOM_LEFT;
5489   clippingActorA[Actor::Property::CLIPPING_MODE] = ClippingMode::CLIP_TO_BOUNDING_BOX;
5490   application.GetScene().Add(clippingActorA);
5491
5492   // Create a child actor
5493   Actor childActor                              = CreateRenderableActor();
5494   childActor[Actor::Property::PARENT_ORIGIN]    = ParentOrigin::BOTTOM_LEFT;
5495   childActor[Actor::Property::ANCHOR_POINT]     = AnchorPoint::BOTTOM_LEFT;
5496   childActor[Actor::Property::SIZE]             = Vector2(50.0f, 50.0f);
5497   childActor[Actor::Property::INHERIT_POSITION] = false;
5498
5499   // Gather the call trace.
5500   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5501
5502   // Check scissor test was enabled.
5503   std::ostringstream scissor;
5504   scissor << std::hex << GL_SCISSOR_TEST;
5505   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5506
5507   // Check the scissor was set, and the coordinates are correct.
5508   std::stringstream compareParametersString;
5509   compareParametersString << "0, 0, " << actorSize.x << ", " << actorSize.y;
5510   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
5511
5512   // Move the clipping actor out of screen
5513   clippingActorA[Actor::Property::POSITION] = Vector2(2000.0f, 2000.0f);
5514
5515   // Gather the call trace.
5516   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5517
5518   // Check the scissor was set, and the coordinates are correct.
5519   compareParametersString.str(std::string());
5520   compareParametersString.clear();
5521   compareParametersString << 2000 << ", " << 0 << ", " << 0 << ", " << 0;
5522   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Clipping area should be empty.
5523
5524   END_TEST;
5525 }
5526
5527 int UtcDaliGetPropertyN(void)
5528 {
5529   tet_infoline("Testing Actor::GetProperty returns a non valid value if property index is out of range");
5530   TestApplication application;
5531
5532   Actor actor = Actor::New();
5533
5534   unsigned int propertyCount = actor.GetPropertyCount();
5535   DALI_TEST_EQUALS(actor.GetProperty(Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION);
5536   END_TEST;
5537 }
5538
5539 int UtcDaliActorRaiseLower(void)
5540 {
5541   tet_infoline("UtcDaliActor Raise and Lower test\n");
5542
5543   TestApplication application;
5544
5545   Debug::Filter::SetGlobalLogLevel(Debug::Verbose);
5546
5547   Integration::Scene stage(application.GetScene());
5548
5549   Actor actorA = Actor::New();
5550   Actor actorB = Actor::New();
5551   Actor actorC = Actor::New();
5552
5553   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5554   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5555
5556   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5557   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5558
5559   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5560   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5561
5562   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5563   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5564
5565   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5566   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5567
5568   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5569   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5570
5571   stage.Add(actorA);
5572   stage.Add(actorB);
5573   stage.Add(actorC);
5574
5575   ResetTouchCallbacks();
5576
5577   application.SendNotification();
5578   application.Render();
5579
5580   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5581   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5582   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5583
5584   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5585   // Only top actor will get touched.
5586   actorA.TouchedSignal().Connect(TestTouchCallback);
5587   actorB.TouchedSignal().Connect(TestTouchCallback2);
5588   actorC.TouchedSignal().Connect(TestTouchCallback3);
5589
5590   // Connect ChildOrderChangedSignal
5591   bool                     orderChangedSignal(false);
5592   Actor                    orderChangedActor;
5593   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5594   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5595
5596   Dali::Integration::Point point;
5597   point.SetDeviceId(1);
5598   point.SetState(PointState::DOWN);
5599   point.SetScreenPosition(Vector2(10.f, 10.f));
5600   Dali::Integration::TouchEvent touchEvent;
5601   touchEvent.AddPoint(point);
5602
5603   application.ProcessEvent(touchEvent);
5604
5605   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5606   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5607   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5608
5609   ResetTouchCallbacks();
5610
5611   tet_printf("Testing Raising of Actor\n");
5612
5613   int preActorOrder(0);
5614   int postActorOrder(0);
5615
5616   Property::Value value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5617   value.Get(preActorOrder);
5618
5619   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5620   actorB.Raise();
5621   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5622   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5623
5624   // Ensure sort order is calculated before next touch event
5625   application.SendNotification();
5626
5627   value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5628   value.Get(postActorOrder);
5629
5630   tet_printf("Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder);
5631
5632   application.ProcessEvent(touchEvent);
5633
5634   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5635   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5636   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5637
5638   ResetTouchCallbacks();
5639
5640   tet_printf("Testing Lowering of Actor\n");
5641
5642   value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5643   value.Get(preActorOrder);
5644
5645   orderChangedSignal = false;
5646
5647   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5648   actorB.Lower();
5649   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5650   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5651
5652   application.SendNotification(); // ensure sort order calculated before next touch event
5653
5654   value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5655   value.Get(postActorOrder);
5656
5657   tet_printf("Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder);
5658
5659   application.ProcessEvent(touchEvent);
5660
5661   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5662   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5663   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5664
5665   ResetTouchCallbacks();
5666
5667   Debug::Filter::SetGlobalLogLevel(Debug::NoLogging);
5668
5669   END_TEST;
5670 }
5671
5672 int UtcDaliActorRaiseToTopLowerToBottom(void)
5673 {
5674   tet_infoline("UtcDaliActorRaiseToTop and LowerToBottom test \n");
5675
5676   TestApplication application;
5677
5678   Integration::Scene stage(application.GetScene());
5679
5680   Actor actorA = Actor::New();
5681   Actor actorB = Actor::New();
5682   Actor actorC = Actor::New();
5683
5684   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5685   // enables checking of which actor the uniform is assigned too
5686   Shader shaderA = CreateShader();
5687   shaderA.RegisterProperty("uRendererColor", 1.f);
5688
5689   Shader shaderB = CreateShader();
5690   shaderB.RegisterProperty("uRendererColor", 2.f);
5691
5692   Shader shaderC = CreateShader();
5693   shaderC.RegisterProperty("uRendererColor", 3.f);
5694
5695   Geometry geometry = CreateQuadGeometry();
5696
5697   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5698   Renderer rendererA = Renderer::New(geometry, shaderA);
5699   actorA.AddRenderer(rendererA);
5700
5701   Renderer rendererB = Renderer::New(geometry, shaderB);
5702   actorB.AddRenderer(rendererB);
5703
5704   Renderer rendererC = Renderer::New(geometry, shaderC);
5705   actorC.AddRenderer(rendererC);
5706
5707   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5708   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5709
5710   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5711   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5712
5713   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5714   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5715
5716   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5717   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5718
5719   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5720   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5721
5722   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5723   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5724
5725   stage.Add(actorA);
5726   stage.Add(actorB);
5727   stage.Add(actorC);
5728
5729   ResetTouchCallbacks();
5730
5731   // Connect ChildOrderChangedSignal
5732   bool                     orderChangedSignal(false);
5733   Actor                    orderChangedActor;
5734   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5735   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5736
5737   // Set up gl abstraction trace so can query the set uniform order
5738   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5739   glAbstraction.EnableSetUniformCallTrace(true);
5740   glAbstraction.ResetSetUniformCallStack();
5741
5742   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5743
5744   application.SendNotification();
5745   application.Render();
5746
5747   tet_printf("Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str());
5748
5749   // Test order of uniforms in stack
5750   int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5751   int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5752   int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5753
5754   bool CBA = (indexC > indexB) && (indexB > indexA);
5755
5756   DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
5757
5758   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5759   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5760   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5761
5762   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5763   // Only top actor will get touched.
5764   actorA.TouchedSignal().Connect(TestTouchCallback);
5765   actorB.TouchedSignal().Connect(TestTouchCallback2);
5766   actorC.TouchedSignal().Connect(TestTouchCallback3);
5767
5768   Dali::Integration::Point point;
5769   point.SetDeviceId(1);
5770   point.SetState(PointState::DOWN);
5771   point.SetScreenPosition(Vector2(10.f, 10.f));
5772   Dali::Integration::TouchEvent touchEvent;
5773   touchEvent.AddPoint(point);
5774
5775   application.ProcessEvent(touchEvent);
5776
5777   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5778   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5779   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5780
5781   ResetTouchCallbacks();
5782
5783   tet_printf("RaiseToTop ActorA\n");
5784
5785   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5786   actorA.RaiseToTop();
5787   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5788   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5789
5790   application.SendNotification(); // ensure sorting order is calculated before next touch event
5791
5792   application.ProcessEvent(touchEvent);
5793
5794   glSetUniformStack.Reset();
5795
5796   application.SendNotification();
5797   application.Render();
5798
5799   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5800
5801   // Test order of uniforms in stack
5802   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5803   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5804   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5805
5806   tet_infoline("Testing A above C and B at bottom\n");
5807   bool ACB = (indexA > indexC) && (indexC > indexB);
5808
5809   DALI_TEST_EQUALS(ACB, true, TEST_LOCATION);
5810
5811   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5812   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5813   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5814
5815   ResetTouchCallbacks();
5816
5817   tet_printf("RaiseToTop ActorB\n");
5818
5819   orderChangedSignal = false;
5820
5821   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5822   actorB.RaiseToTop();
5823   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5824   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5825
5826   application.SendNotification(); // Ensure sort order is calculated before next touch event
5827
5828   application.ProcessEvent(touchEvent);
5829
5830   glSetUniformStack.Reset();
5831
5832   application.SendNotification();
5833   application.Render();
5834
5835   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5836
5837   // Test order of uniforms in stack
5838   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5839   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5840   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5841
5842   tet_infoline("Testing B above A and C at bottom\n");
5843   bool BAC = (indexB > indexA) && (indexA > indexC);
5844
5845   DALI_TEST_EQUALS(BAC, true, TEST_LOCATION);
5846
5847   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5848   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5849   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5850
5851   ResetTouchCallbacks();
5852
5853   tet_printf("LowerToBottom ActorA then ActorB leaving Actor C at Top\n");
5854
5855   orderChangedSignal = false;
5856
5857   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5858   actorA.LowerToBottom();
5859   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5860   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5861
5862   application.SendNotification();
5863   application.Render();
5864
5865   orderChangedSignal = false;
5866
5867   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5868   actorB.LowerToBottom();
5869   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5870   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5871
5872   application.SendNotification();
5873   application.Render();
5874
5875   application.ProcessEvent(touchEvent);
5876
5877   glSetUniformStack.Reset();
5878
5879   application.SendNotification();
5880   application.Render();
5881
5882   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5883
5884   // Test order of uniforms in stack
5885   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5886   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5887   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5888
5889   tet_infoline("Testing C above A and B at bottom\n");
5890   bool CAB = (indexC > indexA) && (indexA > indexB);
5891
5892   DALI_TEST_EQUALS(CAB, true, TEST_LOCATION);
5893
5894   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5895   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5896   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5897
5898   ResetTouchCallbacks();
5899
5900   END_TEST;
5901 }
5902
5903 int UtcDaliActorRaiseAbove(void)
5904 {
5905   tet_infoline("UtcDaliActor RaiseToAbove test \n");
5906
5907   TestApplication application;
5908
5909   Integration::Scene stage(application.GetScene());
5910
5911   Actor actorA = Actor::New();
5912   Actor actorB = Actor::New();
5913   Actor actorC = Actor::New();
5914
5915   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5916   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5917
5918   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5919   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5920
5921   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5922   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5923
5924   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5925   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5926
5927   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5928   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5929
5930   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5931   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5932
5933   stage.Add(actorA);
5934   stage.Add(actorB);
5935   stage.Add(actorC);
5936
5937   ResetTouchCallbacks();
5938
5939   application.SendNotification();
5940   application.Render();
5941
5942   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5943   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5944   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5945
5946   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5947   // Only top actor will get touched.
5948   actorA.TouchedSignal().Connect(TestTouchCallback);
5949   actorB.TouchedSignal().Connect(TestTouchCallback2);
5950   actorC.TouchedSignal().Connect(TestTouchCallback3);
5951
5952   bool                     orderChangedSignal(false);
5953   Actor                    orderChangedActor;
5954   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5955   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5956
5957   Dali::Integration::Point point;
5958   point.SetDeviceId(1);
5959   point.SetState(PointState::DOWN);
5960   point.SetScreenPosition(Vector2(10.f, 10.f));
5961   Dali::Integration::TouchEvent touchEvent;
5962   touchEvent.AddPoint(point);
5963
5964   application.ProcessEvent(touchEvent);
5965
5966   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5967   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5968   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5969
5970   ResetTouchCallbacks();
5971
5972   tet_printf("Raise actor B Above Actor C\n");
5973
5974   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5975   actorB.RaiseAbove(actorC);
5976   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5977   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5978
5979   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5980   application.SendNotification();
5981   application.ProcessEvent(touchEvent);
5982
5983   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5984   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5985   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5986
5987   ResetTouchCallbacks();
5988
5989   tet_printf("Raise actor A Above Actor B\n");
5990
5991   orderChangedSignal = false;
5992
5993   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5994   actorA.RaiseAbove(actorB);
5995   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5996   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5997
5998   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5999   application.SendNotification();
6000
6001   application.ProcessEvent(touchEvent); // process a touch event on ordered actors.
6002
6003   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6004   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6005   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6006
6007   ResetTouchCallbacks();
6008
6009   END_TEST;
6010 }
6011
6012 int UtcDaliActorRaiseAbove2(void)
6013 {
6014   tet_infoline("UtcDaliActor RaiseToAbove test using SIBLING_ORDER property\n");
6015
6016   TestApplication application;
6017
6018   Integration::Scene stage(application.GetScene());
6019
6020   Actor actorA = Actor::New();
6021   Actor actorB = Actor::New();
6022   Actor actorC = Actor::New();
6023
6024   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6025   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6026
6027   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6028   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6029
6030   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6031   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6032
6033   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6034   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6035
6036   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6037   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6038
6039   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6040   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6041
6042   stage.Add(actorA);
6043   stage.Add(actorB);
6044   stage.Add(actorC);
6045
6046   ResetTouchCallbacks();
6047
6048   application.SendNotification();
6049   application.Render();
6050
6051   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6052   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6053   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6054
6055   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6056   // Only top actor will get touched.
6057   actorA.TouchedSignal().Connect(TestTouchCallback);
6058   actorB.TouchedSignal().Connect(TestTouchCallback2);
6059   actorC.TouchedSignal().Connect(TestTouchCallback3);
6060
6061   bool                     orderChangedSignal(false);
6062   Actor                    orderChangedActor;
6063   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6064   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6065
6066   Dali::Integration::Point point;
6067   point.SetDeviceId(1);
6068   point.SetState(PointState::DOWN);
6069   point.SetScreenPosition(Vector2(10.f, 10.f));
6070   Dali::Integration::TouchEvent touchEvent;
6071   touchEvent.AddPoint(point);
6072
6073   application.ProcessEvent(touchEvent);
6074
6075   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6076   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6077   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6078
6079   ResetTouchCallbacks();
6080
6081   tet_printf("Raise actor B Above Actor C\n");
6082
6083   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6084   int newOrder                                = actorC[DevelActor::Property::SIBLING_ORDER];
6085   actorB[DevelActor::Property::SIBLING_ORDER] = newOrder;
6086   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6087   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
6088
6089   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6090   application.SendNotification();
6091   application.ProcessEvent(touchEvent);
6092
6093   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6094   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6095   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6096
6097   ResetTouchCallbacks();
6098
6099   tet_printf("Raise actor A Above Actor B\n");
6100
6101   orderChangedSignal = false;
6102
6103   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6104   newOrder                                    = actorB[DevelActor::Property::SIBLING_ORDER];
6105   actorA[DevelActor::Property::SIBLING_ORDER] = newOrder;
6106   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6107   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6108
6109   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6110   application.SendNotification();
6111
6112   application.ProcessEvent(touchEvent); // process a touch event on ordered actors.
6113
6114   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6115   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6116   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6117
6118   ResetTouchCallbacks();
6119
6120   END_TEST;
6121 }
6122
6123 int UtcDaliActorLowerBelow(void)
6124 {
6125   tet_infoline("UtcDaliActor LowerBelow test \n");
6126
6127   TestApplication application;
6128
6129   Integration::Scene stage(application.GetScene());
6130
6131   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
6132   // enables checking of which actor the uniform is assigned too
6133   Shader shaderA = CreateShader();
6134   shaderA.RegisterProperty("uRendererColor", 1.f);
6135
6136   Shader shaderB = CreateShader();
6137   shaderB.RegisterProperty("uRendererColor", 2.f);
6138
6139   Shader shaderC = CreateShader();
6140   shaderC.RegisterProperty("uRendererColor", 3.f);
6141
6142   Actor actorA = Actor::New();
6143   Actor actorB = Actor::New();
6144   Actor actorC = Actor::New();
6145
6146   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
6147   Geometry geometry = CreateQuadGeometry();
6148
6149   Renderer rendererA = Renderer::New(geometry, shaderA);
6150   actorA.AddRenderer(rendererA);
6151
6152   Renderer rendererB = Renderer::New(geometry, shaderB);
6153   actorB.AddRenderer(rendererB);
6154
6155   Renderer rendererC = Renderer::New(geometry, shaderC);
6156   actorC.AddRenderer(rendererC);
6157
6158   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6159   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6160
6161   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6162   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6163
6164   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6165   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6166
6167   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6168   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6169
6170   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6171   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6172
6173   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6174   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6175
6176   Actor container = Actor::New();
6177   container.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6178   container.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
6179   stage.Add(container);
6180
6181   container.Add(actorA);
6182   container.Add(actorB);
6183   container.Add(actorC);
6184
6185   ResetTouchCallbacks();
6186
6187   // Connect ChildOrderChangedSignal
6188   bool                     orderChangedSignal(false);
6189   Actor                    orderChangedActor;
6190   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6191   DevelActor::ChildOrderChangedSignal(container).Connect(&application, f);
6192
6193   // Set up gl abstraction trace so can query the set uniform order
6194   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
6195   glAbstraction.EnableSetUniformCallTrace(true);
6196   glAbstraction.ResetSetUniformCallStack();
6197   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
6198
6199   glAbstraction.ResetSetUniformCallStack();
6200
6201   application.SendNotification();
6202   application.Render();
6203
6204   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6205
6206   // Test order of uniforms in stack
6207   int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6208   int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6209   int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6210
6211   tet_infoline("Testing C above B and A at bottom\n");
6212   bool CBA = (indexC > indexB) && (indexB > indexA);
6213
6214   DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
6215
6216   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6217   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6218   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6219
6220   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6221   // Only top actor will get touched.
6222   actorA.TouchedSignal().Connect(TestTouchCallback);
6223   actorB.TouchedSignal().Connect(TestTouchCallback2);
6224   actorC.TouchedSignal().Connect(TestTouchCallback3);
6225
6226   Dali::Integration::Point point;
6227   point.SetDeviceId(1);
6228   point.SetState(PointState::DOWN);
6229   point.SetScreenPosition(Vector2(10.f, 10.f));
6230   Dali::Integration::TouchEvent touchEvent;
6231   touchEvent.AddPoint(point);
6232
6233   tet_infoline("UtcDaliActor Test Set up completed \n");
6234
6235   application.ProcessEvent(touchEvent);
6236
6237   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6238   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6239   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6240
6241   ResetTouchCallbacks();
6242
6243   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");
6244
6245   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6246   actorC.LowerBelow(actorB);
6247   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6248   DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
6249
6250   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6251   application.SendNotification();
6252   application.Render();
6253
6254   application.ProcessEvent(touchEvent); // touch event
6255
6256   glSetUniformStack.Reset();
6257
6258   application.SendNotification();
6259   application.Render();
6260
6261   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6262
6263   // Test order of uniforms in stack
6264   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6265   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6266   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6267
6268   tet_infoline("Testing render order is A, C, B");
6269   DALI_TEST_EQUALS(indexC > indexA, true, TEST_LOCATION);
6270   DALI_TEST_EQUALS(indexB > indexC, true, TEST_LOCATION);
6271
6272   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6273   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6274   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6275
6276   ResetTouchCallbacks();
6277
6278   tet_printf("Lower actor C below Actor A leaving B on top\n");
6279
6280   orderChangedSignal = false;
6281
6282   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6283   actorC.LowerBelow(actorA);
6284   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6285   DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
6286
6287   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6288   application.SendNotification();
6289   application.Render();
6290
6291   application.ProcessEvent(touchEvent);
6292
6293   glSetUniformStack.Reset();
6294
6295   application.Render();
6296   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6297
6298   // Test order of uniforms in stack
6299   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6300   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6301   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6302
6303   DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
6304   DALI_TEST_EQUALS(indexB > indexA, true, TEST_LOCATION);
6305
6306   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6307   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6308   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6309
6310   ResetTouchCallbacks();
6311
6312   tet_printf("Lower actor B below Actor C leaving A on top\n");
6313
6314   orderChangedSignal = false;
6315
6316   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6317   actorB.LowerBelow(actorC);
6318   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6319   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
6320
6321   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6322   application.SendNotification();
6323   application.Render();
6324
6325   application.ProcessEvent(touchEvent);
6326
6327   glSetUniformStack.Reset();
6328
6329   application.Render();
6330   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6331
6332   // Test order of uniforms in stack
6333   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6334   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6335   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6336
6337   DALI_TEST_EQUALS(indexC > indexB, true, TEST_LOCATION);
6338   DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
6339
6340   END_TEST;
6341 }
6342
6343 int UtcDaliActorLowerBelow2(void)
6344 {
6345   tet_infoline("UtcDaliActor LowerBelow test using SIBLING_ORDER property\n");
6346
6347   TestApplication application;
6348
6349   Integration::Scene stage(application.GetScene());
6350
6351   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
6352   // enables checking of which actor the uniform is assigned too
6353   Shader shaderA = CreateShader();
6354   shaderA.RegisterProperty("uRendererColor", 1.f);
6355
6356   Shader shaderB = CreateShader();
6357   shaderB.RegisterProperty("uRendererColor", 2.f);
6358
6359   Shader shaderC = CreateShader();
6360   shaderC.RegisterProperty("uRendererColor", 3.f);
6361
6362   Actor actorA = Actor::New();
6363   Actor actorB = Actor::New();
6364   Actor actorC = Actor::New();
6365
6366   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
6367   Geometry geometry = CreateQuadGeometry();
6368
6369   Renderer rendererA = Renderer::New(geometry, shaderA);
6370   actorA.AddRenderer(rendererA);
6371
6372   Renderer rendererB = Renderer::New(geometry, shaderB);
6373   actorB.AddRenderer(rendererB);
6374
6375   Renderer rendererC = Renderer::New(geometry, shaderC);
6376   actorC.AddRenderer(rendererC);
6377
6378   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6379   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6380
6381   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6382   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6383
6384   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6385   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6386
6387   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6388   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6389
6390   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6391   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6392
6393   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6394   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6395
6396   Actor container = Actor::New();
6397   container.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6398   container.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
6399   stage.Add(container);
6400
6401   container.Add(actorA);
6402   container.Add(actorB);
6403   container.Add(actorC);
6404
6405   ResetTouchCallbacks();
6406
6407   // Connect ChildOrderChangedSignal
6408   bool                     orderChangedSignal(false);
6409   Actor                    orderChangedActor;
6410   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6411   DevelActor::ChildOrderChangedSignal(container).Connect(&application, f);
6412
6413   // Set up gl abstraction trace so can query the set uniform order
6414   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
6415   glAbstraction.EnableSetUniformCallTrace(true);
6416   glAbstraction.ResetSetUniformCallStack();
6417   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
6418
6419   glAbstraction.ResetSetUniformCallStack();
6420
6421   application.SendNotification();
6422   application.Render();
6423
6424   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6425
6426   // Test order of uniforms in stack
6427   int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6428   int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6429   int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6430
6431   tet_infoline("Testing C above B and A at bottom\n");
6432   bool CBA = (indexC > indexB) && (indexB > indexA);
6433
6434   DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
6435
6436   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6437   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6438   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6439
6440   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6441   // Only top actor will get touched.
6442   actorA.TouchedSignal().Connect(TestTouchCallback);
6443   actorB.TouchedSignal().Connect(TestTouchCallback2);
6444   actorC.TouchedSignal().Connect(TestTouchCallback3);
6445
6446   Dali::Integration::Point point;
6447   point.SetDeviceId(1);
6448   point.SetState(PointState::DOWN);
6449   point.SetScreenPosition(Vector2(10.f, 10.f));
6450   Dali::Integration::TouchEvent touchEvent;
6451   touchEvent.AddPoint(point);
6452
6453   tet_infoline("UtcDaliActor Test Set up completed \n");
6454
6455   application.ProcessEvent(touchEvent);
6456
6457   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6458   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6459   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6460
6461   ResetTouchCallbacks();
6462
6463   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");
6464
6465   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6466   actorC[DevelActor::Property::SIBLING_ORDER] = 1;
6467   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6468   DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
6469
6470   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6471   application.SendNotification();
6472   application.Render();
6473
6474   application.ProcessEvent(touchEvent); // touch event
6475
6476   glSetUniformStack.Reset();
6477
6478   application.SendNotification();
6479   application.Render();
6480
6481   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6482
6483   // Test order of uniforms in stack
6484   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6485   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6486   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6487
6488   tet_infoline("Testing render order is A, C, B");
6489   DALI_TEST_EQUALS(indexC > indexA, true, TEST_LOCATION);
6490   DALI_TEST_EQUALS(indexB > indexC, true, TEST_LOCATION);
6491
6492   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6493   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6494   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6495
6496   ResetTouchCallbacks();
6497
6498   tet_printf("Lower actor C below Actor A leaving B on top\n");
6499
6500   orderChangedSignal = false;
6501
6502   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6503   actorC[DevelActor::Property::SIBLING_ORDER] = 0;
6504   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6505   DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
6506
6507   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6508   application.SendNotification();
6509   application.Render();
6510
6511   application.ProcessEvent(touchEvent);
6512
6513   glSetUniformStack.Reset();
6514
6515   application.Render();
6516   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6517
6518   // Test order of uniforms in stack
6519   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6520   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6521   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6522
6523   DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
6524   DALI_TEST_EQUALS(indexB > indexA, true, TEST_LOCATION);
6525
6526   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6527   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6528   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6529
6530   ResetTouchCallbacks();
6531
6532   tet_printf("Lower actor B below Actor C leaving A on top\n");
6533
6534   orderChangedSignal = false;
6535
6536   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6537   actorB[DevelActor::Property::SIBLING_ORDER] = 0;
6538   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6539   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
6540
6541   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6542   application.SendNotification();
6543   application.Render();
6544
6545   application.ProcessEvent(touchEvent);
6546
6547   glSetUniformStack.Reset();
6548
6549   application.Render();
6550   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6551
6552   // Test order of uniforms in stack
6553   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6554   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6555   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6556
6557   DALI_TEST_EQUALS(indexC > indexB, true, TEST_LOCATION);
6558   DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
6559
6560   END_TEST;
6561 }
6562
6563 int UtcDaliActorRaiseAboveDifferentParentsN(void)
6564 {
6565   tet_infoline("UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n");
6566
6567   TestApplication application;
6568
6569   Integration::Scene stage(application.GetScene());
6570
6571   Actor parentA = Actor::New();
6572   Actor parentB = Actor::New();
6573   parentA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6574   parentA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6575   parentB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6576   parentB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6577
6578   parentA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6579   parentA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6580
6581   parentB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6582   parentB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6583
6584   stage.Add(parentA);
6585   stage.Add(parentB);
6586
6587   Actor actorA = Actor::New();
6588   Actor actorB = Actor::New();
6589   Actor actorC = Actor::New();
6590
6591   parentA.Add(actorA);
6592   parentA.Add(actorB);
6593
6594   tet_printf("Actor C added to different parent from A and B \n");
6595   parentB.Add(actorC);
6596
6597   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6598   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6599
6600   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6601   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6602
6603   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6604   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6605
6606   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6607   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6608
6609   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6610   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6611
6612   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6613   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6614
6615   ResetTouchCallbacks();
6616
6617   // Connect ChildOrderChangedSignal
6618   bool                     orderChangedSignal(false);
6619   Actor                    orderChangedActor;
6620   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6621   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6622
6623   application.SendNotification();
6624   application.Render();
6625
6626   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6627   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6628   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6629
6630   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6631   // Only top actor will get touched.
6632   actorA.TouchedSignal().Connect(TestTouchCallback);
6633   actorB.TouchedSignal().Connect(TestTouchCallback2);
6634   actorC.TouchedSignal().Connect(TestTouchCallback3);
6635
6636   Dali::Integration::Point point;
6637   point.SetDeviceId(1);
6638   point.SetState(PointState::DOWN);
6639   point.SetScreenPosition(Vector2(10.f, 10.f));
6640   Dali::Integration::TouchEvent touchEvent;
6641   touchEvent.AddPoint(point);
6642
6643   application.ProcessEvent(touchEvent);
6644
6645   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6646   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6647   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6648
6649   ResetTouchCallbacks();
6650
6651   tet_printf("Raise actor A Above Actor C which have different parents\n");
6652
6653   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6654   actorA.RaiseAbove(actorC);
6655   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6656
6657   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6658   application.SendNotification();
6659
6660   application.ProcessEvent(touchEvent); // touch event
6661
6662   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6663   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6664   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6665
6666   ResetTouchCallbacks();
6667
6668   END_TEST;
6669 }
6670
6671 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
6672 {
6673   tet_infoline("UtcDaliActor Test  raiseAbove and lowerBelow api when target Actor has no parent \n");
6674
6675   TestApplication application;
6676
6677   Integration::Scene stage(application.GetScene());
6678
6679   Actor actorA = Actor::New();
6680   Actor actorB = Actor::New();
6681   Actor actorC = Actor::New();
6682
6683   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6684   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6685
6686   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6687   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6688
6689   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6690   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6691
6692   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6693   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6694
6695   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6696   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6697
6698   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6699   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6700
6701   ResetTouchCallbacks();
6702
6703   // Connect ChildOrderChangedSignal
6704   bool                     orderChangedSignal(false);
6705   Actor                    orderChangedActor;
6706   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6707   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6708
6709   application.SendNotification();
6710   application.Render();
6711
6712   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6713   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6714   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6715
6716   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6717   // Only top actor will get touched.
6718   actorA.TouchedSignal().Connect(TestTouchCallback);
6719   actorB.TouchedSignal().Connect(TestTouchCallback2);
6720   actorC.TouchedSignal().Connect(TestTouchCallback3);
6721
6722   Dali::Integration::Point point;
6723   point.SetDeviceId(1);
6724   point.SetState(PointState::DOWN);
6725   point.SetScreenPosition(Vector2(10.f, 10.f));
6726   Dali::Integration::TouchEvent touchEvent;
6727   touchEvent.AddPoint(point);
6728
6729   tet_printf("Raise actor A Above Actor C which have no parents\n");
6730
6731   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6732   actorA.RaiseAbove(actorC);
6733   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6734
6735   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6736   application.SendNotification();
6737
6738   application.ProcessEvent(touchEvent);
6739
6740   tet_printf("Not parented so RaiseAbove should show no effect\n");
6741
6742   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6743   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6744   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6745
6746   ResetTouchCallbacks();
6747
6748   orderChangedSignal = false;
6749
6750   stage.Add(actorB);
6751   tet_printf("Lower actor A below Actor C when only A is not on stage \n");
6752
6753   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6754   actorA.LowerBelow(actorC);
6755   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6756
6757   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6758   application.SendNotification();
6759   application.Render();
6760
6761   application.ProcessEvent(touchEvent);
6762
6763   tet_printf("Actor A not parented so LowerBelow should show no effect\n");
6764   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6765   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6766   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6767
6768   ResetTouchCallbacks();
6769
6770   orderChangedSignal = false;
6771
6772   tet_printf("Adding Actor A to stage, will be on top\n");
6773
6774   stage.Add(actorA);
6775   application.SendNotification();
6776   application.Render();
6777
6778   tet_printf("Raise actor B Above Actor C when only B has a parent\n");
6779
6780   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6781   actorB.RaiseAbove(actorC);
6782   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6783
6784   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6785   application.SendNotification();
6786
6787   application.ProcessEvent(touchEvent);
6788
6789   tet_printf("C not parented so RaiseAbove should show no effect\n");
6790   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6791   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6792   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6793
6794   ResetTouchCallbacks();
6795
6796   orderChangedSignal = false;
6797
6798   tet_printf("Lower actor A below Actor C when only A has a parent\n");
6799
6800   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6801   actorA.LowerBelow(actorC);
6802   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6803
6804   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6805   application.SendNotification();
6806
6807   application.ProcessEvent(touchEvent);
6808
6809   tet_printf("C not parented so LowerBelow should show no effect\n");
6810   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6811   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6812   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6813
6814   ResetTouchCallbacks();
6815
6816   orderChangedSignal = false;
6817
6818   stage.Add(actorC);
6819
6820   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6821   actorA.RaiseAbove(actorC);
6822   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6823   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6824
6825   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6826   application.SendNotification();
6827   application.Render();
6828
6829   application.ProcessEvent(touchEvent);
6830
6831   tet_printf("Raise actor A Above Actor C, now both have same parent \n");
6832   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6833   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6834   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6835
6836   END_TEST;
6837 }
6838
6839 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
6840 {
6841   tet_infoline("UtcDaliActor Test all raise/lower api when actor has no parent \n");
6842
6843   TestApplication application;
6844
6845   Integration::Scene stage(application.GetScene());
6846
6847   Actor actorA = Actor::New();
6848   Actor actorB = Actor::New();
6849   Actor actorC = Actor::New();
6850
6851   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6852   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6853
6854   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6855   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6856
6857   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6858   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6859
6860   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6861   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6862
6863   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6864   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6865
6866   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6867   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6868
6869   ResetTouchCallbacks();
6870
6871   // Connect ChildOrderChangedSignal
6872   bool                     orderChangedSignal(false);
6873   Actor                    orderChangedActor;
6874   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6875   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6876
6877   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6878   // Only top actor will get touched.
6879   actorA.TouchedSignal().Connect(TestTouchCallback);
6880   actorB.TouchedSignal().Connect(TestTouchCallback2);
6881   actorC.TouchedSignal().Connect(TestTouchCallback3);
6882
6883   Dali::Integration::Point point;
6884   point.SetDeviceId(1);
6885   point.SetState(PointState::DOWN);
6886   point.SetScreenPosition(Vector2(10.f, 10.f));
6887   Dali::Integration::TouchEvent touchEvent;
6888   touchEvent.AddPoint(point);
6889
6890   stage.Add(actorA);
6891   tet_printf("Raise actor B Above Actor C but B not parented\n");
6892
6893   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6894   actorB.Raise();
6895   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6896
6897   application.SendNotification();
6898   application.Render();
6899
6900   application.ProcessEvent(touchEvent);
6901
6902   tet_printf("Not parented so RaiseAbove should show no effect\n");
6903
6904   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6905   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6906   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6907
6908   tet_printf("Raise actor B Above Actor C but B not parented\n");
6909   ResetTouchCallbacks();
6910
6911   orderChangedSignal = false;
6912
6913   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6914   actorC.Lower();
6915   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6916
6917   // Sort actor tree before next touch event
6918   application.SendNotification();
6919   application.Render();
6920
6921   application.ProcessEvent(touchEvent);
6922
6923   tet_printf("Not parented so RaiseAbove should show no effect\n");
6924
6925   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6926   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6927   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6928   ResetTouchCallbacks();
6929
6930   orderChangedSignal = false;
6931
6932   tet_printf("Lower actor C below B but C not parented\n");
6933
6934   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6935   actorB.Lower();
6936   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6937
6938   // Sort actor tree before next touch event
6939   application.SendNotification();
6940   application.Render();
6941
6942   application.ProcessEvent(touchEvent);
6943
6944   tet_printf("Not parented so Lower should show no effect\n");
6945
6946   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6947   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6948   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6949   ResetTouchCallbacks();
6950
6951   orderChangedSignal = false;
6952
6953   tet_printf("Raise actor B to top\n");
6954
6955   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6956   actorB.RaiseToTop();
6957   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6958
6959   // Sort actor tree before next touch event
6960   application.SendNotification();
6961   application.Render();
6962
6963   application.ProcessEvent(touchEvent);
6964
6965   tet_printf("Not parented so RaiseToTop should show no effect\n");
6966
6967   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6968   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6969   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6970   ResetTouchCallbacks();
6971
6972   orderChangedSignal = false;
6973
6974   tet_printf("Add ActorB to stage so only Actor C not parented\n");
6975
6976   stage.Add(actorB);
6977
6978   tet_printf("Lower actor C to Bottom, B stays at top\n");
6979
6980   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6981   actorC.LowerToBottom();
6982   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6983
6984   application.SendNotification();
6985   application.Render();
6986
6987   application.ProcessEvent(touchEvent);
6988
6989   tet_printf("Not parented so LowerToBottom should show no effect\n");
6990
6991   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6992   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6993   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6994   ResetTouchCallbacks();
6995
6996   END_TEST;
6997 }
6998
6999 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
7000 {
7001   tet_infoline("UtcDaliActor RaiseToAbove and  test with actor provided as target resulting in a no operation \n");
7002
7003   TestApplication application;
7004
7005   Integration::Scene stage(application.GetScene());
7006
7007   Actor actorA = Actor::New();
7008   Actor actorB = Actor::New();
7009   Actor actorC = Actor::New();
7010
7011   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7012   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7013
7014   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7015   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7016
7017   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7018   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7019
7020   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
7021   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
7022
7023   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
7024   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
7025
7026   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
7027   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
7028
7029   stage.Add(actorA);
7030   stage.Add(actorB);
7031   stage.Add(actorC);
7032
7033   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
7034   // Only top actor will get touched.
7035   actorA.TouchedSignal().Connect(TestTouchCallback);
7036   actorB.TouchedSignal().Connect(TestTouchCallback2);
7037   actorC.TouchedSignal().Connect(TestTouchCallback3);
7038
7039   ResetTouchCallbacks();
7040
7041   // Connect ChildOrderChangedSignal
7042   bool                     orderChangedSignal(false);
7043   Actor                    orderChangedActor;
7044   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
7045   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
7046
7047   application.SendNotification();
7048   application.Render();
7049
7050   Dali::Integration::Point point;
7051   point.SetDeviceId(1);
7052   point.SetState(PointState::DOWN);
7053   point.SetScreenPosition(Vector2(10.f, 10.f));
7054   Dali::Integration::TouchEvent touchEvent;
7055   touchEvent.AddPoint(point);
7056
7057   application.ProcessEvent(touchEvent);
7058
7059   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
7060   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
7061   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
7062
7063   ResetTouchCallbacks();
7064
7065   tet_infoline("Raise actor A Above Actor A which is the same actor!!\n");
7066
7067   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
7068   actorA.RaiseAbove(actorA);
7069   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
7070   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
7071
7072   application.SendNotification();
7073   application.Render();
7074
7075   application.ProcessEvent(touchEvent);
7076
7077   tet_infoline("No target is source Actor so RaiseAbove should show no effect\n");
7078
7079   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
7080   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
7081   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
7082
7083   ResetTouchCallbacks();
7084
7085   orderChangedSignal = false;
7086
7087   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
7088   actorA.RaiseAbove(actorC);
7089   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
7090   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
7091
7092   application.SendNotification();
7093   application.Render();
7094
7095   application.ProcessEvent(touchEvent);
7096
7097   tet_infoline("Raise actor A Above Actor C which will now be successful \n");
7098   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
7099   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
7100   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
7101
7102   END_TEST;
7103 }
7104
7105 int UtcDaliActorGetScreenPosition(void)
7106 {
7107   tet_infoline("UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n");
7108
7109   TestApplication application;
7110
7111   Integration::Scene stage(application.GetScene());
7112
7113   Actor actorA = Actor::New();
7114   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7115
7116   Vector2 size2(10.0f, 20.0f);
7117   actorA.SetProperty(Actor::Property::SIZE, size2);
7118
7119   actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7120
7121   tet_infoline("UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n");
7122
7123   stage.Add(actorA);
7124
7125   application.SendNotification();
7126   application.Render();
7127
7128   Vector3 actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7129   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7130
7131   tet_printf("Actor World Position ( %f %f ) AnchorPoint::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
7132   tet_printf("Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y);
7133
7134   DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
7135   DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
7136
7137   tet_infoline("UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n");
7138
7139   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7140
7141   application.SendNotification();
7142   application.Render();
7143
7144   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7145   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7146
7147   tet_printf("Actor World Position  ( %f %f ) AnchorPoint::TOP_LEFT  \n", actorWorldPosition.x, actorWorldPosition.y);
7148   tet_printf("Actor Screen Position  ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y);
7149
7150   DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
7151   DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
7152
7153   tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n");
7154
7155   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7156
7157   application.SendNotification();
7158   application.Render();
7159
7160   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7161   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7162
7163   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT   \n", actorWorldPosition.x, actorWorldPosition.y);
7164   tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT  \n", actorScreenPosition.x, actorScreenPosition.y);
7165
7166   DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
7167   DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
7168
7169   tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n");
7170
7171   actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 0.0));
7172
7173   application.SendNotification();
7174   application.Render();
7175
7176   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7177   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7178
7179   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorWorldPosition.x, actorWorldPosition.y);
7180   tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0   \n", actorScreenPosition.x, actorScreenPosition.y);
7181
7182   DALI_TEST_EQUALS(actorScreenPosition.x, 30lu, TEST_LOCATION);
7183   DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
7184
7185   tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n");
7186
7187   actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 420.0));
7188
7189   application.SendNotification();
7190   application.Render();
7191
7192   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7193   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7194
7195   DALI_TEST_EQUALS(actorScreenPosition.x, 30lu, TEST_LOCATION);
7196   DALI_TEST_EQUALS(actorScreenPosition.y, 420lu, TEST_LOCATION);
7197
7198   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n", actorWorldPosition.x, actorWorldPosition.y);
7199   tet_printf("Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y);
7200
7201   tet_infoline("UtcDaliActorGetScreenPosition Scale parent and check child's screen position \n");
7202
7203   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7204   actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 30.0));
7205
7206   Actor actorB = Actor::New();
7207   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7208   actorB.SetProperty(Actor::Property::SIZE, size2);
7209   actorB.SetProperty(Actor::Property::POSITION, Vector2(10.f, 10.f));
7210   actorA.Add(actorB);
7211
7212   actorA.SetProperty(Actor::Property::SCALE, 2.0f);
7213
7214   application.SendNotification();
7215   application.Render();
7216
7217   actorScreenPosition = actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7218
7219   DALI_TEST_EQUALS(actorScreenPosition.x, 50lu, TEST_LOCATION);
7220   DALI_TEST_EQUALS(actorScreenPosition.y, 50lu, TEST_LOCATION);
7221
7222   END_TEST;
7223 }
7224
7225 int UtcDaliActorGetScreenPositionAfterScaling(void)
7226 {
7227   tet_infoline("UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n");
7228
7229   TestApplication application;
7230
7231   Integration::Scene stage(application.GetScene());
7232
7233   Actor actorA = Actor::New();
7234   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7235
7236   Vector2 size2(10.0f, 20.0f);
7237   actorA.SetProperty(Actor::Property::SIZE, size2);
7238   actorA.SetProperty(Actor::Property::SCALE, 1.5f);
7239   actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7240
7241   tet_infoline("UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n");
7242
7243   stage.Add(actorA);
7244
7245   application.SendNotification();
7246   application.Render();
7247
7248   Vector3 actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7249   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7250
7251   tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y);
7252   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7253
7254   DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
7255   DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
7256
7257   tet_infoline("UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n");
7258
7259   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7260
7261   application.SendNotification();
7262   application.Render();
7263
7264   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7265   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7266
7267   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
7268   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7269
7270   DALI_TEST_EQUALS(actorScreenPosition.x, 0.0f, TEST_LOCATION);
7271   DALI_TEST_EQUALS(actorScreenPosition.y, 0.0f, TEST_LOCATION);
7272
7273   END_TEST;
7274 }
7275
7276 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
7277 {
7278   tet_infoline("UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n");
7279
7280   TestApplication application;
7281
7282   Integration::Scene stage(application.GetScene());
7283
7284   Actor actorA = Actor::New();
7285   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7286   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7287   Vector2 size2(10.0f, 20.0f);
7288   actorA.SetProperty(Actor::Property::SIZE, size2);
7289   actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7290
7291   tet_infoline(" TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
7292
7293   stage.Add(actorA);
7294
7295   application.SendNotification();
7296   application.Render();
7297
7298   Vector3 actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7299   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7300
7301   tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n", actorWorldPosition.x, actorWorldPosition.y);
7302   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7303
7304   DALI_TEST_EQUALS(actorScreenPosition.x, 240.0f, TEST_LOCATION);
7305   DALI_TEST_EQUALS(actorScreenPosition.y, 400.0f, TEST_LOCATION);
7306
7307   tet_infoline(" BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n");
7308
7309   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
7310   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7311
7312   application.SendNotification();
7313   application.Render();
7314
7315   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7316   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7317
7318   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
7319   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7320
7321   DALI_TEST_EQUALS(actorScreenPosition.x, 480.0f, TEST_LOCATION);
7322   DALI_TEST_EQUALS(actorScreenPosition.y, 0.0f, TEST_LOCATION);
7323
7324   END_TEST;
7325   END_TEST;
7326 }
7327
7328 int UtcDaliActorGetScreenPositionWithChildActors(void)
7329 {
7330   tet_infoline("UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n");
7331
7332   TestApplication application;
7333
7334   Integration::Scene stage(application.GetScene());
7335
7336   tet_infoline("Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
7337
7338   Actor actorA = Actor::New();
7339   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7340   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7341   Vector2 size1(10.0f, 20.0f);
7342   actorA.SetProperty(Actor::Property::SIZE, size1);
7343   actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7344
7345   tet_infoline("Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
7346
7347   Actor parentActorA = Actor::New();
7348   parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7349   parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7350   Vector2 size2(30.0f, 60.0f);
7351   parentActorA.SetProperty(Actor::Property::SIZE, size2);
7352   parentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7353
7354   tet_infoline("Add child 1 to Parent 1 and check screen position \n");
7355
7356   stage.Add(parentActorA);
7357   parentActorA.Add(actorA);
7358
7359   application.SendNotification();
7360   application.Render();
7361
7362   Vector3 actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7363   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7364
7365   tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n", actorWorldPosition.x, actorWorldPosition.y);
7366   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7367
7368   DALI_TEST_EQUALS(actorScreenPosition.x, 255.0f, TEST_LOCATION);
7369   DALI_TEST_EQUALS(actorScreenPosition.y, 430.0f, TEST_LOCATION);
7370
7371   tet_infoline("Test 2\n");
7372
7373   tet_infoline("change parent anchor point and parent origin then check screen position \n");
7374
7375   parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
7376   parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
7377
7378   application.SendNotification();
7379   application.Render();
7380
7381   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7382   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7383
7384   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT  \n", actorWorldPosition.x, actorWorldPosition.y);
7385   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7386
7387   DALI_TEST_EQUALS(actorScreenPosition.x, 15.0f, TEST_LOCATION);
7388   DALI_TEST_EQUALS(actorScreenPosition.y, -30.0f, TEST_LOCATION);
7389
7390   END_TEST;
7391 }
7392
7393 int UtcDaliActorGetScreenPositionWithChildActors02(void)
7394 {
7395   tet_infoline("UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n");
7396
7397   TestApplication application;
7398
7399   Integration::Scene stage(application.GetScene());
7400
7401   tet_infoline("Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
7402
7403   Actor actorA = Actor::New();
7404   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7405   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7406   Vector2 size1(10.0f, 20.0f);
7407   actorA.SetProperty(Actor::Property::SIZE, size1);
7408   actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7409
7410   tet_infoline("Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
7411
7412   Actor parentActorA = Actor::New();
7413   parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7414   parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7415   Vector2 size2(30.0f, 60.0f);
7416   parentActorA.SetProperty(Actor::Property::SIZE, size2);
7417   parentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7418
7419   tet_infoline("Create Grand Parent Actor 1 BOTTOM_LEFT Anchor Point, ParentOrigin::BOTTOM_LEFT and 0,0 position \n");
7420
7421   Actor grandParentActorA = Actor::New();
7422   grandParentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
7423   grandParentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
7424   Vector2 size3(60.0f, 120.0f);
7425   grandParentActorA.SetProperty(Actor::Property::SIZE, size3);
7426   grandParentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7427
7428   tet_infoline("Add Parent 1 to Grand Parent 1 \n");
7429
7430   stage.Add(grandParentActorA);
7431   grandParentActorA.Add(parentActorA);
7432
7433   tet_infoline("Add child 1 to Parent 1 and check screen position \n");
7434
7435   parentActorA.Add(actorA);
7436
7437   application.SendNotification();
7438   application.Render();
7439
7440   Vector3 actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7441   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7442
7443   tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n", actorWorldPosition.x, actorWorldPosition.y);
7444   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7445
7446   DALI_TEST_EQUALS(actorScreenPosition.x, 45.0f, TEST_LOCATION);
7447   DALI_TEST_EQUALS(actorScreenPosition.y, 770.0f, TEST_LOCATION);
7448
7449   END_TEST;
7450 }
7451
7452 int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void)
7453 {
7454   tet_infoline("UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse Check screen position where the position does not use the anchor point");
7455
7456   TestApplication application;
7457
7458   Integration::Scene stage(application.GetScene());
7459
7460   tet_infoline("Create an actor with AnchorPoint::TOP_LEFT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
7461
7462   Actor actorA = Actor::New();
7463   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7464   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7465   actorA.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7466   actorA.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 20.0f));
7467   stage.Add(actorA);
7468
7469   tet_infoline("Create an Actor with AnchorPoint::BOTTOM_RIGHT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
7470
7471   Actor actorB = Actor::New();
7472   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7473   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7474   actorB.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7475   Vector2 actorBSize(30.0f, 60.0f);
7476   actorB.SetProperty(Actor::Property::SIZE, actorBSize);
7477   stage.Add(actorB);
7478
7479   tet_infoline("Create an actor with AnchorPoint::CENTER, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
7480
7481   Actor actorC = Actor::New();
7482   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7483   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7484   actorC.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7485   Vector2 actorCSize(60.0f, 120.0f);
7486   actorC.SetProperty(Actor::Property::SIZE, actorCSize);
7487   stage.Add(actorC);
7488
7489   application.SendNotification();
7490   application.Render();
7491
7492   tet_infoline("Despite differing sizes and anchor-points, the screen position for all actors is the same");
7493
7494   Vector2 center(stage.GetSize() * 0.5f);
7495
7496   DALI_TEST_EQUALS(actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
7497   DALI_TEST_EQUALS(actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
7498   DALI_TEST_EQUALS(actorC.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
7499
7500   tet_infoline("Add scale to all actors");
7501
7502   actorA.SetProperty(Actor::Property::SCALE, 2.0f);
7503   actorB.SetProperty(Actor::Property::SCALE, 2.0f);
7504   actorC.SetProperty(Actor::Property::SCALE, 2.0f);
7505
7506   application.SendNotification();
7507   application.Render();
7508
7509   DALI_TEST_EQUALS(actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center /* TOP_LEFT Anchor */, TEST_LOCATION);
7510   DALI_TEST_EQUALS(actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center - actorBSize /* BOTTOM_RIGHT Anchor */, TEST_LOCATION);
7511   DALI_TEST_EQUALS(actorC.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center - actorCSize * 0.5f /* CENTER Anchor*/, TEST_LOCATION);
7512
7513   END_TEST;
7514 }
7515
7516 int UtcDaliActorGetScreenPositionResizeScene(void)
7517 {
7518   tet_infoline("UtcDaliActorGetScreenPositionResizeScene Check screen position after resizing the scene size");
7519
7520   TestApplication    application;
7521   Integration::Scene scene = application.GetScene();
7522
7523   Actor actorA = Actor::New();
7524   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7525   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7526   actorA.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
7527
7528   scene.Add(actorA);
7529
7530   application.SendNotification();
7531   application.Render();
7532
7533   Vector2 sceneSize           = scene.GetSize();
7534   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7535
7536   DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2, TEST_LOCATION);
7537
7538   // Resize the scene
7539   Vector2 newSize(1000.0f, 2000.0f);
7540   DALI_TEST_CHECK(scene.GetSize() != newSize);
7541
7542   scene.SurfaceResized(newSize.width, newSize.height);
7543
7544   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7545
7546   // The screen position should not be updated yet
7547   DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2, TEST_LOCATION);
7548
7549   application.SendNotification();
7550   application.Render();
7551
7552   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7553
7554   // The screen position should be updated
7555   sceneSize = scene.GetSize();
7556   DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2, TEST_LOCATION);
7557
7558   END_TEST;
7559 }
7560
7561 int UtcDaliActorGetScreenPositionInCustomCameraAndLayer3D(void)
7562 {
7563   tet_infoline("UtcDaliActorGetScreenPositionInCustomCameraAndLayer3D Check screen position under LAYER_3D and custom camera");
7564
7565   TestApplication    application;
7566   Integration::Scene scene = application.GetScene();
7567
7568   // Make 3D Layer
7569   Layer layer = scene.GetRootLayer();
7570   layer.SetProperty(Layer::Property::BEHAVIOR, Layer::Behavior::LAYER_3D);
7571
7572   // Build custom camera with top-view
7573   CameraActor cameraActor = scene.GetRenderTaskList().GetTask(0).GetCameraActor();
7574   {
7575     // Default camera position at +z and looking -z axis. (orientation is [ Axis: [0, 1, 0], Angle: 180 degrees ])
7576     Vector3    cameraPos    = cameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
7577     Quaternion cameraOrient = cameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
7578
7579     {
7580       std::ostringstream oss;
7581       oss << cameraPos << "\n";
7582       oss << cameraOrient << "\n";
7583       tet_printf("%s\n", oss.str().c_str());
7584     }
7585
7586     cameraActor.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -cameraPos.z, 0.0f));
7587     cameraActor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::XAXIS) * cameraOrient);
7588
7589     // Now, upside : -Z, leftside : -X, foward : +Y
7590
7591     cameraPos    = cameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
7592     cameraOrient = cameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
7593     {
7594       std::ostringstream oss;
7595       oss << cameraPos << "\n";
7596       oss << cameraOrient << "\n";
7597       tet_printf("%s\n", oss.str().c_str());
7598     }
7599   }
7600
7601   Actor actorA = Actor::New();
7602   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7603   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7604   actorA.SetProperty(Actor::Property::SIZE, Vector3(10.0f, 10.0f, 10.0f));
7605   actorA.SetProperty(Actor::Property::POSITION, Vector3(20.0f, 0.0f, 10.0f));
7606
7607   Actor actorB = Actor::New();
7608   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7609   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7610   actorB.SetProperty(Actor::Property::SIZE, Vector3(10.0f, 10.0f, 10.0f));
7611   actorB.SetProperty(Actor::Property::POSITION, Vector3(-20.0f, 0.0f, -10.0f));
7612
7613   scene.Add(actorA);
7614   scene.Add(actorB);
7615
7616   application.SendNotification();
7617   application.Render();
7618
7619   Vector2 sceneSize           = scene.GetSize();
7620   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7621
7622   DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2 + Vector2(20.0f, 10.0f), TEST_LOCATION);
7623
7624   actorScreenPosition = actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7625
7626   DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2 - Vector2(20.0f, 10.0f), TEST_LOCATION);
7627
7628   END_TEST;
7629 }
7630
7631 int utcDaliActorPositionUsesAnchorPoint(void)
7632 {
7633   TestApplication application;
7634   tet_infoline("Check default behaviour\n");
7635
7636   Actor actor = Actor::New();
7637   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7638   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7639   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7640   application.GetScene().Add(actor);
7641
7642   application.SendNotification();
7643   application.Render();
7644
7645   tet_infoline("Check that the world position is in the center\n");
7646   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
7647
7648   tet_infoline("Set the position uses anchor point property to false\n");
7649   actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7650
7651   application.SendNotification();
7652   application.Render();
7653
7654   tet_infoline("Check that the world position has changed appropriately\n");
7655   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7656
7657   END_TEST;
7658 }
7659
7660 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
7661 {
7662   TestApplication application;
7663   tet_infoline("Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7664
7665   Actor actor = Actor::New();
7666   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7667   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7668   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7669   actor.SetProperty(Actor::Property::SCALE, 2.0f);
7670   actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7671   application.GetScene().Add(actor);
7672
7673   application.SendNotification();
7674   application.Render();
7675
7676   tet_infoline("Check the world position is the same as it would be without a scale\n");
7677   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7678
7679   tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
7680   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7681   application.SendNotification();
7682   application.Render();
7683   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(100.0f, 100.0f, 0.0f), TEST_LOCATION);
7684
7685   tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
7686   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7687   application.SendNotification();
7688   application.Render();
7689   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
7690
7691   END_TEST;
7692 }
7693
7694 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
7695 {
7696   TestApplication application;
7697   tet_infoline("Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7698
7699   Actor actor = Actor::New();
7700   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7701   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7702   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7703   actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::ZAXIS));
7704   actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7705   application.GetScene().Add(actor);
7706
7707   application.SendNotification();
7708   application.Render();
7709
7710   tet_infoline("Check the world position is the same as it would be without a rotation\n");
7711   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7712
7713   tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
7714   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7715   application.SendNotification();
7716   application.Render();
7717   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(-50.0f, 50.0f, 0.0f), TEST_LOCATION);
7718
7719   tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
7720   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7721   application.SendNotification();
7722   application.Render();
7723   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(150.0f, 50.0f, 0.0f), TEST_LOCATION);
7724
7725   END_TEST;
7726 }
7727
7728 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
7729 {
7730   TestApplication application;
7731   tet_infoline("Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7732
7733   Actor actor = Actor::New();
7734   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7735   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7736   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7737   actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::ZAXIS));
7738   actor.SetProperty(Actor::Property::SCALE, 2.0f);
7739   actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7740   application.GetScene().Add(actor);
7741
7742   application.SendNotification();
7743   application.Render();
7744
7745   tet_infoline("Check the world position is the same as it would be without a scale and rotation\n");
7746   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7747
7748   tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
7749   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7750   application.SendNotification();
7751   application.Render();
7752   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(-100.0f, 100.0f, 0.0f), TEST_LOCATION);
7753
7754   tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
7755   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7756   application.SendNotification();
7757   application.Render();
7758   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(200.0f, 0.0f, 0.0f), TEST_LOCATION);
7759
7760   END_TEST;
7761 }
7762
7763 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
7764 {
7765   TestApplication application;
7766   tet_infoline("Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7767
7768   Actor parent = Actor::New();
7769
7770   application.GetScene().Add(parent);
7771   Vector2 stageSize(application.GetScene().GetSize());
7772
7773   Actor actor = Actor::New();
7774   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7775   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7776   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7777   actor.SetProperty(Actor::Property::INHERIT_SCALE, false);
7778   actor.SetProperty(Actor::Property::INHERIT_ORIENTATION, false);
7779   actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7780   parent.Add(actor);
7781
7782   application.SendNotification();
7783   application.Render();
7784
7785   const Vector3 expectedWorldPosition(-stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f);
7786
7787   tet_infoline("Check the world position is in the right place\n");
7788   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
7789
7790   tet_infoline("Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed");
7791   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7792   application.SendNotification();
7793   application.Render();
7794   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
7795
7796   tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed");
7797   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7798   application.SendNotification();
7799   application.Render();
7800   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
7801
7802   END_TEST;
7803 }
7804
7805 int utcDaliActorVisibilityChangeSignalSelf(void)
7806 {
7807   TestApplication application;
7808   tet_infoline("Check that the visibility change signal is called when the visibility changes for the actor itself");
7809
7810   Actor actor = Actor::New();
7811
7812   VisibilityChangedFunctorData data;
7813   DevelActor::VisibilityChangedSignal(actor).Connect(&application, VisibilityChangedFunctor(data));
7814
7815   actor.SetProperty(Actor::Property::VISIBLE, false);
7816
7817   data.Check(true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7818
7819   tet_infoline("Ensure functor is not called if we attempt to change the visibility to what it already is at");
7820   data.Reset();
7821
7822   actor.SetProperty(Actor::Property::VISIBLE, false);
7823   data.Check(false /* not called */, TEST_LOCATION);
7824
7825   tet_infoline("Change the visibility using properties, ensure called");
7826   data.Reset();
7827
7828   actor.SetProperty(Actor::Property::VISIBLE, true);
7829   data.Check(true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7830
7831   tet_infoline("Set the visibility to current using properties, ensure not called");
7832   data.Reset();
7833
7834   actor.SetProperty(Actor::Property::VISIBLE, true);
7835   data.Check(false /* not called */, TEST_LOCATION);
7836
7837   END_TEST;
7838 }
7839
7840 int utcDaliActorVisibilityChangeSignalChildren(void)
7841 {
7842   TestApplication application;
7843   tet_infoline("Check that the visibility change signal is called for the children when the visibility changes for the parent");
7844
7845   Actor parent = Actor::New();
7846   Actor child  = Actor::New();
7847   parent.Add(child);
7848
7849   Actor grandChild = Actor::New();
7850   child.Add(grandChild);
7851
7852   VisibilityChangedFunctorData parentData;
7853   VisibilityChangedFunctorData childData;
7854   VisibilityChangedFunctorData grandChildData;
7855
7856   tet_infoline("Only connect the child and grandchild, ensure they are called and not the parent");
7857   DevelActor::VisibilityChangedSignal(child).Connect(&application, VisibilityChangedFunctor(childData));
7858   DevelActor::VisibilityChangedSignal(grandChild).Connect(&application, VisibilityChangedFunctor(grandChildData));
7859
7860   parent.SetProperty(Actor::Property::VISIBLE, false);
7861   parentData.Check(false /* not called */, TEST_LOCATION);
7862   childData.Check(true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7863   grandChildData.Check(true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7864
7865   tet_infoline("Connect to the parent's signal as well and ensure all three are called");
7866   parentData.Reset();
7867   childData.Reset();
7868   grandChildData.Reset();
7869
7870   DevelActor::VisibilityChangedSignal(parent).Connect(&application, VisibilityChangedFunctor(parentData));
7871
7872   parent.SetProperty(Actor::Property::VISIBLE, true);
7873   parentData.Check(true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7874   childData.Check(true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7875   grandChildData.Check(true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7876
7877   tet_infoline("Ensure none of the functors are called if we attempt to change the visibility to what it already is at");
7878   parentData.Reset();
7879   childData.Reset();
7880   grandChildData.Reset();
7881
7882   parent.SetProperty(Actor::Property::VISIBLE, true);
7883   parentData.Check(false /* not called */, TEST_LOCATION);
7884   childData.Check(false /* not called */, TEST_LOCATION);
7885   grandChildData.Check(false /* not called */, TEST_LOCATION);
7886
7887   END_TEST;
7888 }
7889
7890 int utcDaliActorVisibilityChangeSignalAfterAnimation(void)
7891 {
7892   TestApplication application;
7893   tet_infoline("Check that the visibility change signal is emitted when the visibility changes when an animation starts");
7894
7895   Actor actor = Actor::New();
7896   application.GetScene().Add(actor);
7897
7898   application.SendNotification();
7899   application.Render();
7900
7901   VisibilityChangedFunctorData data;
7902   DevelActor::VisibilityChangedSignal(actor).Connect(&application, VisibilityChangedFunctor(data));
7903
7904   Animation animation = Animation::New(1.0f);
7905   animation.AnimateTo(Property(actor, Actor::Property::VISIBLE), false);
7906
7907   data.Check(false, TEST_LOCATION);
7908   DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7909   DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7910
7911   tet_infoline("Play the animation and check the property value");
7912   animation.Play();
7913
7914   data.Check(true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7915   DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::VISIBLE), false, TEST_LOCATION);
7916
7917   tet_infoline("Animation not currently finished, so the current visibility should still be true");
7918   DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7919
7920   application.SendNotification();
7921   application.Render(1100); // After the animation
7922
7923   DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), false, TEST_LOCATION);
7924
7925   END_TEST;
7926 }
7927
7928 int utcDaliActorVisibilityChangeSignalByName(void)
7929 {
7930   TestApplication application;
7931   tet_infoline("Check that the visibility change signal is called when the visibility changes for the actor itself");
7932
7933   Actor actor = Actor::New();
7934
7935   bool signalCalled = false;
7936   actor.ConnectSignal(&application, "visibilityChanged", VisibilityChangedVoidFunctor(signalCalled));
7937   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7938   actor.SetProperty(Actor::Property::VISIBLE, false);
7939   DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7940
7941   tet_infoline("Ensure functor is not called if we attempt to change the visibility to what it already is at");
7942   signalCalled = false;
7943   actor.SetProperty(Actor::Property::VISIBLE, false);
7944   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7945
7946   tet_infoline("Change the visibility using properties, ensure called");
7947   actor.SetProperty(Actor::Property::VISIBLE, true);
7948   DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7949
7950   tet_infoline("Set the visibility to current using properties, ensure not called");
7951   signalCalled = false;
7952
7953   actor.SetProperty(Actor::Property::VISIBLE, true);
7954   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7955
7956   END_TEST;
7957 }
7958
7959 static void LayoutDirectionChanged(Actor actor, LayoutDirection::Type type)
7960 {
7961   gLayoutDirectionType = type;
7962 }
7963
7964 int UtcDaliActorLayoutDirectionProperty(void)
7965 {
7966   TestApplication application;
7967   tet_infoline("Check layout direction property");
7968
7969   Actor actor0 = Actor::New();
7970   DALI_TEST_EQUALS(actor0.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7971   application.GetScene().Add(actor0);
7972
7973   application.SendNotification();
7974   application.Render();
7975
7976   Actor actor1 = Actor::New();
7977   DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7978   Actor actor2 = Actor::New();
7979   DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7980   Actor actor3 = Actor::New();
7981   DALI_TEST_EQUALS(actor3.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7982   Actor actor4 = Actor::New();
7983   DALI_TEST_EQUALS(actor4.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7984   Actor actor5 = Actor::New();
7985   DALI_TEST_EQUALS(actor5.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7986   Actor actor6 = Actor::New();
7987   DALI_TEST_EQUALS(actor6.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7988   Actor actor7 = Actor::New();
7989   DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7990   Actor actor8 = Actor::New();
7991   DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7992   Actor actor9 = Actor::New();
7993   DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7994
7995   actor1.Add(actor2);
7996   gLayoutDirectionType = LayoutDirection::LEFT_TO_RIGHT;
7997   actor2.LayoutDirectionChangedSignal().Connect(LayoutDirectionChanged);
7998
7999   DALI_TEST_EQUALS(actor1.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), true, TEST_LOCATION);
8000   actor1.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
8001   DALI_TEST_EQUALS(actor1.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), false, TEST_LOCATION);
8002
8003   DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
8004   DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
8005   DALI_TEST_EQUALS(gLayoutDirectionType, LayoutDirection::RIGHT_TO_LEFT, TEST_LOCATION);
8006
8007   actor1.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, true);
8008   actor0.Add(actor1);
8009   DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
8010   DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
8011
8012   application.GetScene().Add(actor3);
8013   actor3.Add(actor4);
8014   actor4.Add(actor5);
8015   actor5.Add(actor6);
8016   actor5.Add(actor7);
8017   actor7.Add(actor8);
8018   actor8.Add(actor9);
8019   actor3.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
8020   actor5.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
8021
8022   DALI_TEST_EQUALS(actor8.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), true, TEST_LOCATION);
8023   actor8.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, false);
8024   DALI_TEST_EQUALS(actor8.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), false, TEST_LOCATION);
8025
8026   actor7.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
8027
8028   DALI_TEST_EQUALS(actor3.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
8029   DALI_TEST_EQUALS(actor4.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
8030   DALI_TEST_EQUALS(actor5.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
8031   DALI_TEST_EQUALS(actor6.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
8032   DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
8033   DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
8034   DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
8035
8036   actor8.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
8037   DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
8038   DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
8039
8040   actor7.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
8041   DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
8042   DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
8043   DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
8044
8045   actor8.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, true);
8046   DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
8047   DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
8048
8049   END_TEST;
8050 }
8051
8052 struct LayoutDirectionFunctor
8053 {
8054   LayoutDirectionFunctor(bool& signalCalled)
8055   : mSignalCalled(signalCalled)
8056   {
8057   }
8058
8059   LayoutDirectionFunctor(const LayoutDirectionFunctor& rhs)
8060   : mSignalCalled(rhs.mSignalCalled)
8061   {
8062   }
8063
8064   void operator()()
8065   {
8066     mSignalCalled = true;
8067   }
8068
8069   bool& mSignalCalled;
8070 };
8071
8072 int UtcDaliActorLayoutDirectionSignal(void)
8073 {
8074   TestApplication application;
8075   tet_infoline("Check changing layout direction property sends a signal");
8076
8077   Actor actor = Actor::New();
8078   DALI_TEST_EQUALS(actor.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
8079   application.GetScene().Add(actor);
8080   bool                   signalCalled = false;
8081   LayoutDirectionFunctor layoutDirectionFunctor(signalCalled);
8082
8083   actor.ConnectSignal(&application, "layoutDirectionChanged", layoutDirectionFunctor);
8084   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
8085
8086   // Test that writing the same value doesn't send a signal
8087   actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
8088   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
8089
8090   // Test that writing a different value sends the signal
8091   signalCalled = false;
8092   actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
8093   DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
8094
8095   signalCalled = false;
8096   actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
8097   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
8098
8099   END_TEST;
8100 }
8101
8102 struct ChildAddedSignalCheck
8103 {
8104   ChildAddedSignalCheck(bool& signalReceived, Actor& childHandle)
8105   : mSignalReceived(signalReceived),
8106     mChildHandle(childHandle)
8107   {
8108   }
8109
8110   void operator()(Actor childHandle)
8111   {
8112     mSignalReceived = true;
8113     mChildHandle    = childHandle;
8114   }
8115   void operator()()
8116   {
8117     mSignalReceived = true;
8118     mChildHandle    = Actor();
8119   }
8120
8121   bool&  mSignalReceived;
8122   Actor& mChildHandle;
8123 };
8124
8125 int UtcDaliChildAddedSignalP1(void)
8126 {
8127   TestApplication application;
8128   auto            stage = application.GetScene();
8129
8130   bool  signalReceived = false;
8131   Actor childActor;
8132
8133   ChildAddedSignalCheck signal(signalReceived, childActor);
8134   DevelActor::ChildAddedSignal(stage.GetRootLayer()).Connect(&application, signal);
8135   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8136
8137   auto actorA = Actor::New();
8138   stage.Add(actorA);
8139   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8140   DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
8141   signalReceived = false;
8142
8143   auto actorB = Actor::New();
8144   stage.Add(actorB);
8145   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8146   DALI_TEST_EQUALS(childActor, actorB, TEST_LOCATION);
8147
8148   END_TEST;
8149 }
8150
8151 int UtcDaliChildAddedSignalP2(void)
8152 {
8153   TestApplication application;
8154   auto            stage = application.GetScene();
8155
8156   bool  signalReceived = false;
8157   Actor childActor;
8158
8159   ChildAddedSignalCheck signal(signalReceived, childActor);
8160   tet_infoline("Connect to childAdded signal by name");
8161
8162   stage.GetRootLayer().ConnectSignal(&application, "childAdded", signal);
8163   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8164
8165   auto actorA = Actor::New();
8166   stage.Add(actorA);
8167   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8168
8169   // Can't test which actor was added; signal signature is void() when connecting via name.
8170   signalReceived = false;
8171
8172   auto actorB = Actor::New();
8173   stage.Add(actorB);
8174   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8175
8176   END_TEST;
8177 }
8178
8179 int UtcDaliChildAddedSignalN(void)
8180 {
8181   TestApplication application;
8182   auto            stage = application.GetScene();
8183
8184   bool  signalReceived = false;
8185   Actor childActor;
8186
8187   ChildAddedSignalCheck signal(signalReceived, childActor);
8188   DevelActor::ChildAddedSignal(stage.GetRootLayer()).Connect(&application, signal);
8189   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8190
8191   auto actorA = Actor::New();
8192   stage.Add(actorA);
8193   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8194   DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
8195   signalReceived = false;
8196
8197   auto actorB = Actor::New();
8198   actorA.Add(actorB);
8199   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8200   END_TEST;
8201 }
8202
8203 struct ChildRemovedSignalCheck
8204 {
8205   ChildRemovedSignalCheck(bool& signalReceived, Actor& childHandle)
8206   : mSignalReceived(signalReceived),
8207     mChildHandle(childHandle)
8208   {
8209   }
8210
8211   void operator()(Actor childHandle)
8212   {
8213     mSignalReceived = true;
8214     mChildHandle    = childHandle;
8215   }
8216
8217   void operator()()
8218   {
8219     mSignalReceived = true;
8220   }
8221
8222   bool&  mSignalReceived;
8223   Actor& mChildHandle;
8224 };
8225
8226 int UtcDaliChildRemovedSignalP1(void)
8227 {
8228   TestApplication application;
8229   auto            stage = application.GetScene();
8230
8231   bool  signalReceived = false;
8232   Actor childActor;
8233
8234   ChildRemovedSignalCheck signal(signalReceived, childActor);
8235   DevelActor::ChildRemovedSignal(stage.GetRootLayer()).Connect(&application, signal);
8236   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8237
8238   auto actorA = Actor::New();
8239   stage.Add(actorA);
8240   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8241   DALI_TEST_CHECK(!childActor);
8242
8243   stage.Remove(actorA);
8244   DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
8245   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8246
8247   signalReceived = false;
8248   auto actorB    = Actor::New();
8249   stage.Add(actorB);
8250   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8251
8252   stage.Remove(actorB);
8253   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8254   DALI_TEST_EQUALS(childActor, actorB, TEST_LOCATION);
8255
8256   END_TEST;
8257 }
8258
8259 int UtcDaliChildRemovedSignalP2(void)
8260 {
8261   TestApplication application;
8262   auto            stage = application.GetScene();
8263
8264   bool  signalReceived = false;
8265   Actor childActor;
8266
8267   ChildAddedSignalCheck signal(signalReceived, childActor);
8268   tet_infoline("Connect to childRemoved signal by name");
8269
8270   stage.GetRootLayer().ConnectSignal(&application, "childRemoved", signal);
8271   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8272
8273   auto actorA = Actor::New();
8274   stage.Add(actorA);
8275   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8276
8277   stage.Remove(actorA);
8278   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8279
8280   signalReceived = false;
8281   auto actorB    = Actor::New();
8282   stage.Add(actorB);
8283   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8284
8285   stage.Remove(actorB);
8286   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8287
8288   END_TEST;
8289 }
8290
8291 int UtcDaliChildRemovedSignalN(void)
8292 {
8293   TestApplication application;
8294   auto            stage = application.GetScene();
8295
8296   bool  signalReceived = false;
8297   Actor childActor;
8298
8299   ChildRemovedSignalCheck signal(signalReceived, childActor);
8300   DevelActor::ChildRemovedSignal(stage.GetRootLayer()).Connect(&application, signal);
8301   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8302
8303   auto actorA = Actor::New();
8304   stage.Add(actorA);
8305
8306   auto actorB = Actor::New();
8307   actorA.Add(actorB);
8308
8309   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8310   DALI_TEST_CHECK(!childActor);
8311
8312   actorA.Remove(actorB);
8313   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8314   END_TEST;
8315 }
8316
8317 int UtcDaliChildMovedSignalP(void)
8318 {
8319   TestApplication application;
8320   auto            stage = application.GetScene();
8321
8322   bool  addedASignalReceived   = false;
8323   bool  removedASignalReceived = false;
8324   bool  addedBSignalReceived   = false;
8325   bool  removedBSignalReceived = false;
8326   Actor childActor;
8327
8328   auto actorA = Actor::New();
8329   auto actorB = Actor::New();
8330   stage.Add(actorA);
8331   stage.Add(actorB);
8332
8333   ChildAddedSignalCheck   addedSignalA(addedASignalReceived, childActor);
8334   ChildRemovedSignalCheck removedSignalA(removedASignalReceived, childActor);
8335   ChildAddedSignalCheck   addedSignalB(addedBSignalReceived, childActor);
8336   ChildRemovedSignalCheck removedSignalB(removedBSignalReceived, childActor);
8337
8338   DevelActor::ChildAddedSignal(actorA).Connect(&application, addedSignalA);
8339   DevelActor::ChildRemovedSignal(actorA).Connect(&application, removedSignalA);
8340   DevelActor::ChildAddedSignal(actorB).Connect(&application, addedSignalB);
8341   DevelActor::ChildRemovedSignal(actorB).Connect(&application, removedSignalB);
8342
8343   DALI_TEST_EQUALS(addedASignalReceived, false, TEST_LOCATION);
8344   DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
8345   DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
8346   DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
8347
8348   // Create a child of A
8349
8350   auto child = Actor::New();
8351   actorA.Add(child);
8352
8353   DALI_TEST_EQUALS(addedASignalReceived, true, TEST_LOCATION);
8354   DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
8355   DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
8356   DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
8357   DALI_TEST_EQUALS(childActor, child, TEST_LOCATION);
8358
8359   // Move child to B:
8360   addedASignalReceived   = false;
8361   addedBSignalReceived   = false;
8362   removedASignalReceived = false;
8363   removedBSignalReceived = false;
8364
8365   actorB.Add(child); // Expect this child to be re-parented
8366   DALI_TEST_EQUALS(addedASignalReceived, false, TEST_LOCATION);
8367   DALI_TEST_EQUALS(removedASignalReceived, true, TEST_LOCATION);
8368   DALI_TEST_EQUALS(addedBSignalReceived, true, TEST_LOCATION);
8369   DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
8370
8371   // Move child back to A:
8372   addedASignalReceived   = false;
8373   addedBSignalReceived   = false;
8374   removedASignalReceived = false;
8375   removedBSignalReceived = false;
8376
8377   actorA.Add(child); // Expect this child to be re-parented
8378   DALI_TEST_EQUALS(addedASignalReceived, true, TEST_LOCATION);
8379   DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
8380   DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
8381   DALI_TEST_EQUALS(removedBSignalReceived, true, TEST_LOCATION);
8382
8383   END_TEST;
8384 }
8385
8386 int UtcDaliActorSwitchParentP(void)
8387 {
8388   tet_infoline("Testing Actor::UtcDaliActorSwitchParentP");
8389   TestApplication application;
8390
8391   Actor parent1 = Actor::New();
8392   Actor child   = Actor::New();
8393
8394   application.GetScene().Add(parent1);
8395
8396   DALI_TEST_EQUALS(parent1.GetChildCount(), 0u, TEST_LOCATION);
8397
8398   child.OnSceneSignal().Connect(OnSceneCallback);
8399   child.OffSceneSignal().Connect(OffSceneCallback);
8400
8401   // sanity check
8402   DALI_TEST_CHECK(gOnSceneCallBackCalled == 0);
8403   DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
8404
8405   parent1.Add(child);
8406
8407   DALI_TEST_EQUALS(parent1.GetChildCount(), 1u, TEST_LOCATION);
8408
8409   DALI_TEST_CHECK(gOnSceneCallBackCalled == 1);
8410   DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
8411
8412   Actor parent2 = Actor::New();
8413   application.GetScene().Add(parent2);
8414
8415   bool                  addSignalReceived = false;
8416   ChildAddedSignalCheck addedSignal(addSignalReceived, child);
8417   DevelActor::ChildAddedSignal(application.GetScene().GetRootLayer()).Connect(&application, addedSignal);
8418   DALI_TEST_EQUALS(addSignalReceived, false, TEST_LOCATION);
8419
8420   bool                    removedSignalReceived = false;
8421   ChildRemovedSignalCheck removedSignal(removedSignalReceived, child);
8422   DevelActor::ChildRemovedSignal(application.GetScene().GetRootLayer()).Connect(&application, removedSignal);
8423   DALI_TEST_EQUALS(removedSignalReceived, false, TEST_LOCATION);
8424
8425   DevelActor::SwitchParent(child, parent2);
8426
8427   DALI_TEST_EQUALS(addSignalReceived, false, TEST_LOCATION);
8428   DALI_TEST_EQUALS(removedSignalReceived, false, TEST_LOCATION);
8429
8430   DALI_TEST_EQUALS(parent1.GetChildCount(), 0u, TEST_LOCATION);
8431   DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
8432
8433   DALI_TEST_CHECK(gOnSceneCallBackCalled == 1);
8434   DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
8435   DALI_TEST_CHECK(child.GetProperty<bool>(Dali::Actor::Property::CONNECTED_TO_SCENE));
8436   DALI_TEST_CHECK(child.GetParent() == parent2);
8437
8438   END_TEST;
8439 }
8440
8441 int utcDaliActorCulled(void)
8442 {
8443   TestApplication application;
8444   auto            stage = application.GetScene();
8445
8446   tet_infoline("Check that the actor is culled if the actor is out of the screen");
8447
8448   Actor actor = Actor::New();
8449   actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
8450
8451   Geometry geometry = CreateQuadGeometry();
8452   Shader   shader   = CreateShader();
8453   Renderer renderer = Renderer::New(geometry, shader);
8454   actor.AddRenderer(renderer);
8455
8456   stage.Add(actor);
8457
8458   application.SendNotification();
8459   application.Render(0);
8460
8461   DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::CULLED), false, TEST_LOCATION);
8462
8463   PropertyNotification notification = actor.AddPropertyNotification(Actor::Property::CULLED, LessThanCondition(0.5f));
8464   notification.SetNotifyMode(PropertyNotification::NOTIFY_ON_CHANGED);
8465
8466   // Connect NotifySignal
8467   bool                              propertyNotificationSignal(false);
8468   PropertyNotification              source;
8469   CulledPropertyNotificationFunctor f(propertyNotificationSignal, source);
8470   notification.NotifySignal().Connect(&application, f);
8471
8472   actor.SetProperty(Actor::Property::POSITION, Vector2(1000.0f, 1000.0f));
8473
8474   application.SendNotification();
8475   application.Render();
8476
8477   application.SendNotification();
8478
8479   DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::CULLED), true, TEST_LOCATION);
8480
8481   DALI_TEST_EQUALS(propertyNotificationSignal, true, TEST_LOCATION);
8482   DALI_TEST_EQUALS(source.GetTargetProperty(), static_cast<int>(Actor::Property::CULLED), TEST_LOCATION);
8483   DALI_TEST_EQUALS(source.GetTarget().GetProperty<bool>(source.GetTargetProperty()), true, TEST_LOCATION);
8484
8485   END_TEST;
8486 }
8487
8488 int utcDaliEnsureRenderWhenRemovingLastRenderableActor(void)
8489 {
8490   TestApplication application;
8491   auto            stage = application.GetScene();
8492
8493   tet_infoline("Ensure we clear the screen when the last actor is removed");
8494
8495   Actor actor = CreateRenderableActor();
8496   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
8497   stage.Add(actor);
8498
8499   application.SendNotification();
8500   application.Render();
8501
8502   auto&      glAbstraction    = application.GetGlAbstraction();
8503   const auto clearCountBefore = glAbstraction.GetClearCountCalled();
8504
8505   actor.Unparent();
8506
8507   application.SendNotification();
8508   application.Render();
8509
8510   DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION);
8511
8512   END_TEST;
8513 }
8514
8515 int utcDaliEnsureRenderWhenMakingLastActorInvisible(void)
8516 {
8517   TestApplication application;
8518   auto            stage = application.GetScene();
8519
8520   tet_infoline("Ensure we clear the screen when the last actor is made invisible");
8521
8522   Actor actor = CreateRenderableActor();
8523   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
8524   stage.Add(actor);
8525
8526   application.SendNotification();
8527   application.Render();
8528
8529   auto&      glAbstraction    = application.GetGlAbstraction();
8530   const auto clearCountBefore = glAbstraction.GetClearCountCalled();
8531
8532   actor.SetProperty(Actor::Property::VISIBLE, false);
8533
8534   application.SendNotification();
8535   application.Render();
8536
8537   DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION);
8538
8539   END_TEST;
8540 }
8541
8542 int utcDaliActorGetSizeAfterAnimation(void)
8543 {
8544   TestApplication application;
8545   tet_infoline("Check the actor size before / after an animation is finished");
8546
8547   Vector3 actorSize(100.0f, 100.0f, 0.0f);
8548
8549   Actor actor = Actor::New();
8550   actor.SetProperty(Actor::Property::SIZE, actorSize);
8551   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8552   application.GetScene().Add(actor);
8553
8554   // Size should be updated without rendering.
8555   Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8556   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8557
8558   application.SendNotification();
8559   application.Render();
8560
8561   // Size and current size should be updated.
8562   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8563   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8564   DALI_TEST_EQUALS(actorSize.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8565   DALI_TEST_EQUALS(actorSize.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8566   DALI_TEST_EQUALS(actorSize.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8567
8568   Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8569   DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8570   DALI_TEST_EQUALS(actorSize.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8571   DALI_TEST_EQUALS(actorSize.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8572   DALI_TEST_EQUALS(actorSize.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8573
8574   // Set size again
8575   actorSize = Vector3(200.0f, 200.0f, 0.0f);
8576   actor.SetProperty(Actor::Property::SIZE, actorSize);
8577
8578   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8579   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8580
8581   Vector3 targetValue(10.0f, 20.0f, 0.0f);
8582
8583   Animation animation = Animation::New(1.0f);
8584   animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
8585   animation.Play();
8586
8587   // Size should be updated without rendering.
8588   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8589   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8590
8591   application.SendNotification();
8592   application.Render(1100); // After the animation
8593
8594   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8595   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8596   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8597   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8598   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8599
8600   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8601   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8602   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8603   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8604   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8605
8606   targetValue.width = 50.0f;
8607
8608   animation.Clear();
8609   animation.AnimateTo(Property(actor, Actor::Property::SIZE_WIDTH), targetValue.width);
8610   animation.Play();
8611
8612   application.SendNotification();
8613   application.Render(1100); // After the animation
8614
8615   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8616   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8617   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8618   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8619   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8620
8621   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8622   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8623   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8624   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8625   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8626
8627   targetValue.height = 70.0f;
8628
8629   animation.Clear();
8630   animation.AnimateTo(Property(actor, Actor::Property::SIZE_HEIGHT), targetValue.height);
8631   animation.Play();
8632
8633   application.SendNotification();
8634   application.Render(1100); // After the animation
8635
8636   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8637   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8638   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8639   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8640   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8641
8642   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8643   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8644   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8645   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8646   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8647
8648   Vector3 offset(10.0f, 20.0f, 0.0f);
8649
8650   animation.Clear();
8651   animation.AnimateBy(Property(actor, Actor::Property::SIZE), offset);
8652   animation.Play();
8653
8654   application.SendNotification();
8655   application.Render(1100); // After the animation
8656
8657   targetValue += offset;
8658
8659   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8660   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8661   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8662   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8663   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8664
8665   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8666   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8667   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8668   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8669   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8670
8671   offset.width = 20.0f;
8672
8673   animation.Clear();
8674   animation.AnimateBy(Property(actor, Actor::Property::SIZE_WIDTH), offset.width);
8675   animation.Play();
8676
8677   application.SendNotification();
8678   application.Render(1100); // After the animation
8679
8680   targetValue.width += offset.width;
8681
8682   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8683   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8684   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8685   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8686   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8687
8688   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8689   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8690   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8691   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8692   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8693
8694   offset.height = 10.0f;
8695
8696   animation.Clear();
8697   animation.AnimateBy(Property(actor, Actor::Property::SIZE_HEIGHT), offset.height);
8698   animation.Play();
8699
8700   application.SendNotification();
8701   application.Render(1100); // After the animation
8702
8703   targetValue.height += offset.height;
8704
8705   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8706   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8707   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8708   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8709   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8710
8711   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8712   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8713   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8714   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8715   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8716
8717   // Set size again
8718   actorSize = Vector3(300.0f, 300.0f, 0.0f);
8719
8720   actor.SetProperty(Actor::Property::SIZE, actorSize);
8721
8722   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8723   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8724
8725   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8726   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8727
8728   application.SendNotification();
8729   application.Render();
8730
8731   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8732   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8733
8734   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8735   DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8736
8737   END_TEST;
8738 }
8739
8740 int utcDaliActorGetSizeAfterAnimation2(void)
8741 {
8742   TestApplication application;
8743   tet_infoline("Check the actor size before / after an animation is finished if before size is equal to animation target size");
8744
8745   Vector3 actorSize(100.0f, 100.0f, 0.0f);
8746
8747   Actor actor = Actor::New();
8748   actor.SetProperty(Actor::Property::SIZE, actorSize);
8749   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8750   application.GetScene().Add(actor);
8751
8752   // Size should be updated without rendering.
8753   Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8754   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8755
8756   application.SendNotification();
8757   application.Render();
8758
8759   // Size and current size should be updated.
8760   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8761   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8762   DALI_TEST_EQUALS(actorSize.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8763   DALI_TEST_EQUALS(actorSize.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8764   DALI_TEST_EQUALS(actorSize.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8765
8766   Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8767   DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8768   DALI_TEST_EQUALS(actorSize.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8769   DALI_TEST_EQUALS(actorSize.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8770   DALI_TEST_EQUALS(actorSize.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8771
8772   // Set size again
8773   actorSize = Vector3(200.0f, 200.0f, 0.0f);
8774   actor.SetProperty(Actor::Property::SIZE, actorSize);
8775
8776   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8777   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8778
8779   Vector3 targetValue(actorSize);
8780
8781   Animation animation = Animation::New(1.0f);
8782   animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
8783   animation.Play();
8784
8785   // Size should be updated without rendering.
8786   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8787   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8788
8789   application.SendNotification();
8790   application.Render(100); // During the animation
8791
8792   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8793   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8794   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8795   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8796   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8797
8798   // We should get target value because targetValue is equal to current actor size.
8799   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8800   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8801   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8802   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8803   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8804
8805   application.SendNotification();
8806   application.Render(1000); // After animation finished
8807
8808   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8809   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8810
8811   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8812   DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8813
8814   END_TEST;
8815 }
8816
8817 int utcDaliActorRelayoutAndAnimation(void)
8818 {
8819   TestApplication application;
8820   tet_infoline("Check the actor size when relayoutting and playing animation");
8821
8822   Vector3 parentSize(300.0f, 300.0f, 0.0f);
8823   Vector3 actorSize(100.0f, 100.0f, 0.0f);
8824
8825   {
8826     Actor parentA = Actor::New();
8827     parentA.SetProperty(Actor::Property::SIZE, parentSize);
8828     parentA.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8829     application.GetScene().Add(parentA);
8830
8831     Actor parentB = Actor::New();
8832     parentB.SetProperty(Actor::Property::SIZE, parentSize);
8833     parentB.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8834     application.GetScene().Add(parentB);
8835
8836     Actor actor = Actor::New();
8837     actor.SetProperty(Actor::Property::SIZE, actorSize);
8838     actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8839     parentA.Add(actor);
8840
8841     Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8842     DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8843
8844     Vector3 targetValue(200.0f, 200.0f, 0.0f);
8845
8846     Animation animation = Animation::New(1.0f);
8847     animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
8848     animation.Play();
8849
8850     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8851     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8852
8853     application.SendNotification();
8854     application.Render(1100); // After the animation
8855
8856     // Size and current size should be updated.
8857     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8858     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8859
8860     Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8861     DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8862
8863     // Trigger relayout
8864     parentB.Add(actor);
8865
8866     application.SendNotification();
8867     application.Render();
8868
8869     // Size and current size should be same.
8870     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8871     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8872
8873     currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8874     DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8875
8876     actor.Unparent();
8877     parentA.Unparent();
8878     parentB.Unparent();
8879   }
8880
8881   {
8882     Actor parentA = Actor::New();
8883     parentA.SetProperty(Actor::Property::SIZE, parentSize);
8884     parentA.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8885     application.GetScene().Add(parentA);
8886
8887     Actor parentB = Actor::New();
8888     parentB.SetProperty(Actor::Property::SIZE, parentSize);
8889     parentB.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8890     application.GetScene().Add(parentB);
8891
8892     Actor actor = Actor::New();
8893     actor.SetProperty(Actor::Property::SIZE, actorSize);
8894     actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8895     parentA.Add(actor);
8896
8897     Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8898     DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8899
8900     application.SendNotification();
8901     application.Render();
8902
8903     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8904     DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8905
8906     Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8907     DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8908
8909     Vector3 targetValue(200.0f, 200.0f, 0.0f);
8910
8911     // Make an animation
8912     Animation animation = Animation::New(1.0f);
8913     animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
8914     animation.Play();
8915
8916     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8917     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8918
8919     application.SendNotification();
8920     application.Render(1100); // After the animation
8921
8922     // Size and current size should be updated.
8923     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8924     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8925
8926     currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8927     DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8928
8929     // Trigger relayout
8930     parentB.Add(actor);
8931
8932     application.SendNotification();
8933     application.Render();
8934
8935     // Size and current size should be same.
8936     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8937     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8938
8939     currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8940     DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8941
8942     actor.Unparent();
8943     parentA.Unparent();
8944     parentB.Unparent();
8945   }
8946
8947   END_TEST;
8948 }
8949
8950 int utcDaliActorPartialUpdate(void)
8951 {
8952   TestApplication application(
8953     TestApplication::DEFAULT_SURFACE_WIDTH,
8954     TestApplication::DEFAULT_SURFACE_HEIGHT,
8955     TestApplication::DEFAULT_HORIZONTAL_DPI,
8956     TestApplication::DEFAULT_VERTICAL_DPI,
8957     true,
8958     true);
8959
8960   tet_infoline("Check the damaged area");
8961
8962   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8963
8964   std::vector<Rect<int>> damagedRects;
8965   Rect<int>              clippingRect;
8966   application.SendNotification();
8967   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8968
8969   // First render pass, nothing to render, adaptor would just do swap buffer.
8970   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8971
8972   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8973   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8974
8975   Actor actor = CreateRenderableActor();
8976   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8977   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8978   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8979   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8980   application.GetScene().Add(actor);
8981
8982   application.SendNotification();
8983
8984   // 1. Actor added, damaged rect is added size of actor
8985   damagedRects.clear();
8986   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8987   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8988
8989   // Aligned by 16
8990   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
8991   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
8992   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8993   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8994   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8995   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8996   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8997
8998   // 2. Set new size
8999   actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0));
9000   application.SendNotification();
9001
9002   damagedRects.clear();
9003   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9004   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9005
9006   // Aligned by 16
9007   clippingRect = Rect<int>(16, 752, 48, 48); // in screen coordinates
9008   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9009   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9010   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9011   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9012   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9013   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9014
9015   // 3. Set new position
9016   actor.SetProperty(Actor::Property::POSITION, Vector3(32.0f, 32.0f, 0));
9017   application.SendNotification();
9018
9019   damagedRects.clear();
9020   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9021   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9022
9023   // Aligned by 16
9024   clippingRect = Rect<int>(16, 736, 64, 64); // in screen coordinates
9025   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9026   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9027   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9028   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9029   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9030   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9031
9032   application.GetScene().Remove(actor);
9033   application.SendNotification();
9034
9035   // Actor removed, last a dirty rect is reported.
9036   damagedRects.clear();
9037   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9038   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9039
9040   clippingRect = damagedRects[0];
9041
9042   DALI_TEST_EQUALS(clippingRect.IsValid(), true, TEST_LOCATION);
9043   DALI_TEST_EQUALS<Rect<int>>(clippingRect, Rect<int>(32, 736, 48, 48), TEST_LOCATION);
9044
9045   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9046   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9047   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9048   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9049   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9050
9051   END_TEST;
9052 }
9053
9054 int utcDaliActorPartialUpdateSetColor(void)
9055 {
9056   TestApplication application(
9057     TestApplication::DEFAULT_SURFACE_WIDTH,
9058     TestApplication::DEFAULT_SURFACE_HEIGHT,
9059     TestApplication::DEFAULT_HORIZONTAL_DPI,
9060     TestApplication::DEFAULT_VERTICAL_DPI,
9061     true,
9062     true);
9063
9064   tet_infoline("Check uniform update");
9065
9066   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9067
9068   std::vector<Rect<int>> damagedRects;
9069   Rect<int>              clippingRect;
9070   application.SendNotification();
9071   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9072
9073   // First render pass, nothing to render, adaptor would just do swap buffer.
9074   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9075
9076   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9077   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9078
9079   Actor actor = CreateRenderableActor();
9080   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9081   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
9082   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
9083   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9084   application.GetScene().Add(actor);
9085
9086   application.SendNotification();
9087
9088   // 1. Actor added, damaged rect is added size of actor
9089   damagedRects.clear();
9090   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9091   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9092
9093   // Aligned by 16
9094   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
9095   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9096   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9097   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9098   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9099   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9100   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9101
9102   damagedRects.clear();
9103   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9104   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9105
9106   damagedRects.clear();
9107   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9108   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9109
9110   // 2. Set new color
9111   actor.SetProperty(Actor::Property::COLOR, Vector3(1.0f, 0.0f, 0.0f));
9112   application.SendNotification();
9113
9114   damagedRects.clear();
9115   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9116   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9117
9118   // Aligned by 16
9119   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
9120   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9121   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9122   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9123   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9124   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9125   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9126
9127   END_TEST;
9128 }
9129
9130 const std::string SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME("uLightCameraProjectionMatrix");
9131 const std::string SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME("uLightCameraViewMatrix");
9132 const std::string SHADER_SHADOW_COLOR_PROPERTY_NAME("uShadowColor");
9133 const char* const RENDER_SHADOW_VERTEX_SOURCE =
9134   " uniform mediump mat4 uLightCameraProjectionMatrix;\n"
9135   " uniform mediump mat4 uLightCameraViewMatrix;\n"
9136   "\n"
9137   "void main()\n"
9138   "{\n"
9139   "  gl_Position = uProjection * uModelView * vec4(aPosition,1.0);\n"
9140   "  vec4 textureCoords = uLightCameraProjectionMatrix * uLightCameraViewMatrix * uModelMatrix  * vec4(aPosition,1.0);\n"
9141   "  vTexCoord = 0.5 + 0.5 * (textureCoords.xy/textureCoords.w);\n"
9142   "}\n";
9143
9144 const char* const RENDER_SHADOW_FRAGMENT_SOURCE =
9145   "uniform lowp vec4 uShadowColor;\n"
9146   "void main()\n"
9147   "{\n"
9148   "  lowp float alpha;\n"
9149   "  alpha = texture2D(sTexture, vec2(vTexCoord.x, vTexCoord.y)).a;\n"
9150   "  gl_FragColor = vec4(uShadowColor.rgb, uShadowColor.a * alpha);\n"
9151   "}\n";
9152
9153 int utcDaliActorPartialUpdateSetProperty(void)
9154 {
9155   TestApplication application(
9156     TestApplication::DEFAULT_SURFACE_WIDTH,
9157     TestApplication::DEFAULT_SURFACE_HEIGHT,
9158     TestApplication::DEFAULT_HORIZONTAL_DPI,
9159     TestApplication::DEFAULT_VERTICAL_DPI,
9160     true,
9161     true);
9162
9163   tet_infoline("Set/Update property with partial update");
9164
9165   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9166
9167   std::vector<Rect<int>> damagedRects;
9168   Rect<int>              clippingRect;
9169   application.SendNotification();
9170   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9171
9172   // First render pass, nothing to render, adaptor would just do swap buffer.
9173   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9174
9175   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9176   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9177
9178   Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 4u, 4u);
9179   Actor   actor = CreateRenderableActor(image, RENDER_SHADOW_VERTEX_SOURCE, RENDER_SHADOW_FRAGMENT_SOURCE);
9180   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9181   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
9182   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
9183   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9184   application.GetScene().Add(actor);
9185
9186   actor.RegisterProperty(SHADER_SHADOW_COLOR_PROPERTY_NAME, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
9187
9188   damagedRects.clear();
9189   application.SendNotification();
9190   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9191   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9192
9193   // Aligned by 16
9194   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
9195   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9196   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9197   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9198   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9199   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9200   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9201
9202   Property::Index shadowColorPropertyIndex = actor.GetPropertyIndex(SHADER_SHADOW_COLOR_PROPERTY_NAME);
9203   actor.SetProperty(shadowColorPropertyIndex, Vector4(1.0f, 1.0f, 0.0f, 1.0f));
9204
9205   damagedRects.clear();
9206   application.SendNotification();
9207   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9208   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9209
9210   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9211   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9212   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9213   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9214   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9215   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9216
9217   // Should be no damage rects, nothing changed
9218   damagedRects.clear();
9219   application.SendNotification();
9220   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9221   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9222
9223   // Should be 1 damage rect due to change in size
9224   damagedRects.clear();
9225   actor.SetProperty(Actor::Property::SIZE, Vector3(26.0f, 26.0f, 0.0f));
9226   application.SendNotification();
9227   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9228   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9229
9230   clippingRect = Rect<int>(16, 752, 32, 48); // new clipping rect size increased due to change in actor size
9231   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9232   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9233   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9234   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9235   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9236   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9237
9238   damagedRects.clear();
9239   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9240   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9241
9242   END_TEST;
9243 }
9244
9245 int utcDaliActorPartialUpdateTwoActors(void)
9246 {
9247   TestApplication application(
9248     TestApplication::DEFAULT_SURFACE_WIDTH,
9249     TestApplication::DEFAULT_SURFACE_HEIGHT,
9250     TestApplication::DEFAULT_HORIZONTAL_DPI,
9251     TestApplication::DEFAULT_VERTICAL_DPI,
9252     true,
9253     true);
9254
9255   tet_infoline("Check the damaged rects with partial update and two actors");
9256
9257   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9258
9259   Actor actor = CreateRenderableActor();
9260   actor.SetProperty(Actor::Property::POSITION, Vector3(100.0f, 100.0f, 0.0f));
9261   actor.SetProperty(Actor::Property::SIZE, Vector3(50.0f, 50.0f, 0.0f));
9262   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9263   application.GetScene().Add(actor);
9264
9265   Actor actor2 = CreateRenderableActor();
9266   actor2.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
9267   actor2.SetProperty(Actor::Property::SIZE, Vector3(100.0f, 100.0f, 0.0f));
9268   actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9269   application.GetScene().Add(actor2);
9270
9271   application.SendNotification();
9272   std::vector<Rect<int>> damagedRects;
9273   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9274
9275   DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
9276   DirtyRectChecker(damagedRects, {Rect<int>(64, 672, 64, 64), Rect<int>(96, 592, 112, 112)}, true, TEST_LOCATION);
9277
9278   // in screen coordinates, adaptor would calculate it using previous frames information
9279   Rect<int> clippingRect = Rect<int>(64, 592, 144, 192);
9280   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9281
9282   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9283   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9284   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9285   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9286
9287   // Change a Renderer of actor1
9288   Geometry geometry    = CreateQuadGeometry();
9289   Shader   shader      = CreateShader();
9290   Renderer newRenderer = Renderer::New(geometry, shader);
9291   Renderer renderer    = actor.GetRendererAt(0);
9292
9293   actor.RemoveRenderer(renderer);
9294   actor.AddRenderer(newRenderer);
9295
9296   damagedRects.clear();
9297
9298   application.SendNotification();
9299   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9300
9301   DALI_TEST_CHECK(damagedRects.size() > 0);
9302   DirtyRectChecker(damagedRects, {Rect<int>(64, 672, 64, 64)}, false, TEST_LOCATION);
9303
9304   // in screen coordinates, adaptor would calculate it using previous frames information
9305   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9306
9307   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9308   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9309   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9310   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9311
9312   END_TEST;
9313 }
9314
9315 int utcDaliActorPartialUpdateActorsWithSizeHint01(void)
9316 {
9317   TestApplication application(
9318     TestApplication::DEFAULT_SURFACE_WIDTH,
9319     TestApplication::DEFAULT_SURFACE_HEIGHT,
9320     TestApplication::DEFAULT_HORIZONTAL_DPI,
9321     TestApplication::DEFAULT_VERTICAL_DPI,
9322     true,
9323     true);
9324
9325   tet_infoline("Check the damaged rect with partial update and update area hint");
9326
9327   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9328
9329   Actor actor = CreateRenderableActor();
9330   actor.SetProperty(Actor::Property::POSITION, Vector3(64.0f, 64.0f, 0.0f));
9331   actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0.0f));
9332   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(0.0f, 0.0f, 64.0f, 64.0f));
9333   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9334   application.GetScene().Add(actor);
9335
9336   application.SendNotification();
9337   std::vector<Rect<int>> damagedRects;
9338   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9339
9340   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9341
9342   Rect<int> clippingRect = Rect<int>(32, 704, 80, 80);
9343   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9344
9345   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9346
9347   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9348   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9349   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9350   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9351
9352   // Reset
9353   actor.Unparent();
9354
9355   damagedRects.clear();
9356   application.SendNotification();
9357   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9358
9359   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9360   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9361
9362   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9363
9364   damagedRects.clear();
9365   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9366   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9367
9368   // Ensure the damaged rect is empty
9369   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9370
9371   // Chnage UPDATE_AREA_HINT
9372   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(16.0f, 16.0f, 32.0f, 32.0f));
9373   application.GetScene().Add(actor);
9374
9375   application.SendNotification();
9376   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9377
9378   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9379
9380   clippingRect = Rect<int>(64, 704, 48, 48);
9381   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9382
9383   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9384
9385   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9386   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9387   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9388   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9389
9390   // Reset
9391   actor.Unparent();
9392
9393   damagedRects.clear();
9394   application.SendNotification();
9395   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9396
9397   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9398   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9399
9400   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9401
9402   damagedRects.clear();
9403   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9404   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9405
9406   // Ensure the damaged rect is empty
9407   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9408
9409   // Chnage UPDATE_AREA_HINT
9410   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(-32.0f, -16.0f, 64.0f, 64.0f));
9411   application.GetScene().Add(actor);
9412
9413   application.SendNotification();
9414   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9415
9416   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9417
9418   clippingRect = Rect<int>(0, 720, 80, 80);
9419   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9420
9421   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9422
9423   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9424   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9425   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9426   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9427
9428   END_TEST;
9429 }
9430
9431 int utcDaliActorPartialUpdateActorsWithSizeHint02(void)
9432 {
9433   TestApplication application(
9434     TestApplication::DEFAULT_SURFACE_WIDTH,
9435     TestApplication::DEFAULT_SURFACE_HEIGHT,
9436     TestApplication::DEFAULT_HORIZONTAL_DPI,
9437     TestApplication::DEFAULT_VERTICAL_DPI,
9438     true,
9439     true);
9440
9441   tet_infoline("Check the damaged rect with partial update and update area hint");
9442
9443   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9444
9445   Actor actor = CreateRenderableActor();
9446   actor.SetProperty(Actor::Property::POSITION, Vector3(64.0f, 64.0f, 0.0f));
9447   actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0.0f));
9448   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9449   application.GetScene().Add(actor);
9450
9451   application.SendNotification();
9452   std::vector<Rect<int>> damagedRects;
9453   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9454
9455   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9456
9457   Rect<int> clippingRect = Rect<int>(48, 720, 48, 48);
9458   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9459
9460   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9461
9462   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9463   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9464   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9465   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9466
9467   damagedRects.clear();
9468   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9469   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9470
9471   // Ensure the damaged rect is empty
9472   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9473
9474   // Change UPDATE_AREA_HINT
9475   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(0.0f, 0.0f, 64.0f, 64.0f));
9476
9477   application.SendNotification();
9478   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9479
9480   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9481
9482   clippingRect = Rect<int>(32, 704, 80, 80);
9483   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9484
9485   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9486
9487   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9488   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9489   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9490   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9491
9492   damagedRects.clear();
9493   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9494   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9495
9496   // Ensure the damaged rect is empty
9497   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9498
9499   // Chnage UPDATE_AREA_HINT
9500   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(16.0f, 16.0f, 64.0f, 64.0f));
9501   application.GetScene().Add(actor);
9502
9503   application.SendNotification();
9504   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9505
9506   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9507
9508   clippingRect = Rect<int>(32, 688, 96, 96);
9509   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9510
9511   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9512
9513   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9514   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9515   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9516   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9517
9518   END_TEST;
9519 }
9520
9521 int utcDaliActorPartialUpdateActorsWithSizeHint03(void)
9522 {
9523   TestApplication application(
9524     TestApplication::DEFAULT_SURFACE_WIDTH,
9525     TestApplication::DEFAULT_SURFACE_HEIGHT,
9526     TestApplication::DEFAULT_HORIZONTAL_DPI,
9527     TestApplication::DEFAULT_VERTICAL_DPI,
9528     true,
9529     true);
9530
9531   tet_infoline("Check the damaged rect with partial update and update area hint");
9532
9533   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9534
9535   Actor actor = CreateRenderableActor();
9536   actor.SetProperty(Actor::Property::POSITION, Vector3(64.0f, 64.0f, 0.0f));
9537   actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0.0f));
9538   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(0.0f, 0.0f, 64.0f, 64.0f));
9539   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9540   application.GetScene().Add(actor);
9541
9542   application.SendNotification();
9543   std::vector<Rect<int>> damagedRects;
9544   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9545
9546   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9547
9548   Rect<int> clippingRect = Rect<int>(32, 704, 80, 80);
9549   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9550
9551   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9552
9553   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9554   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9555   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9556   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9557
9558   damagedRects.clear();
9559   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9560   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9561
9562   // Ensure the damaged rect is empty
9563   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9564
9565   // Set UPDATE_AREA_HINT twice before rendering
9566   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(0.0f, 0.0f, 32.0f, 32.0f));
9567   application.SendNotification();
9568
9569   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(32.0f, -32.0f, 32.0f, 32.0f));
9570   application.SendNotification();
9571
9572   damagedRects.clear();
9573   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9574
9575   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9576
9577   clippingRect = Rect<int>(32, 704, 96, 96);
9578   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9579
9580   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9581
9582   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9583   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9584   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9585   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9586
9587   END_TEST;
9588 }
9589
9590 int utcDaliActorPartialUpdateAnimation(void)
9591 {
9592   TestApplication application(
9593     TestApplication::DEFAULT_SURFACE_WIDTH,
9594     TestApplication::DEFAULT_SURFACE_HEIGHT,
9595     TestApplication::DEFAULT_HORIZONTAL_DPI,
9596     TestApplication::DEFAULT_VERTICAL_DPI,
9597     true,
9598     true);
9599
9600   tet_infoline("Check the damaged area with partial update and animation");
9601
9602   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
9603   drawTrace.Enable(true);
9604   drawTrace.Reset();
9605
9606   Actor actor1 = CreateRenderableActor();
9607   actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9608   actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
9609   application.GetScene().Add(actor1);
9610
9611   Actor actor2 = CreateRenderableActor();
9612   actor2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9613   actor2.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
9614   application.GetScene().Add(actor2);
9615
9616   std::vector<Rect<int>> damagedRects;
9617   Rect<int>              clippingRect;
9618   Rect<int>              expectedRect1, expectedRect2;
9619
9620   application.SendNotification();
9621   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9622
9623   DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
9624
9625   // Aligned by 16
9626   expectedRect1 = Rect<int>(0, 720, 96, 96); // in screen coordinates, includes 1 last frames updates
9627   expectedRect2 = Rect<int>(0, 784, 32, 32); // in screen coordinates, includes 1 last frames updates
9628   DirtyRectChecker(damagedRects, {expectedRect1, expectedRect2}, true, TEST_LOCATION);
9629
9630   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9631   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9632
9633   // Make an animation
9634   Animation animation = Animation::New(1.0f);
9635   animation.AnimateTo(Property(actor2, Actor::Property::POSITION_X), 160.0f, TimePeriod(0.5f, 0.5f));
9636   animation.Play();
9637
9638   application.SendNotification();
9639
9640   damagedRects.clear();
9641   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9642   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9643   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9644
9645   drawTrace.Reset();
9646   damagedRects.clear();
9647
9648   // In animation deley time
9649   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9650   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9651   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9652
9653   // Skip rendering
9654   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
9655
9656   drawTrace.Reset();
9657   damagedRects.clear();
9658
9659   // Also in animation deley time
9660   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9661   application.PreRenderWithPartialUpdate(100, nullptr, damagedRects);
9662   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9663
9664   // Skip rendering
9665   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
9666
9667   // Unparent 2 actors and make a new actor
9668   actor1.Unparent();
9669   actor2.Unparent();
9670
9671   Actor actor3 = CreateRenderableActor();
9672   actor3.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9673   actor3.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
9674   application.GetScene().Add(actor3);
9675
9676   application.SendNotification();
9677
9678   // Started animation
9679   damagedRects.clear();
9680   application.PreRenderWithPartialUpdate(500, nullptr, damagedRects);
9681   DALI_TEST_EQUALS(damagedRects.size(), 3, TEST_LOCATION);
9682
9683   // One of dirty rect is actor3's.
9684   // We don't know the exact dirty rect of actor1 and actor2.
9685   DirtyRectChecker(damagedRects, {expectedRect1, expectedRect2, expectedRect2}, true, TEST_LOCATION);
9686
9687   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9688   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9689
9690   // Finished animation, but the actor was already unparented
9691   damagedRects.clear();
9692   application.PreRenderWithPartialUpdate(500, nullptr, damagedRects);
9693
9694   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9695
9696   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9697   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9698
9699   END_TEST;
9700 }
9701
9702 int utcDaliActorPartialUpdateChangeVisibility(void)
9703 {
9704   TestApplication application(
9705     TestApplication::DEFAULT_SURFACE_WIDTH,
9706     TestApplication::DEFAULT_SURFACE_HEIGHT,
9707     TestApplication::DEFAULT_HORIZONTAL_DPI,
9708     TestApplication::DEFAULT_VERTICAL_DPI,
9709     true,
9710     true);
9711
9712   tet_infoline("Check the damaged rect with partial update and visibility change");
9713
9714   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9715
9716   Actor actor = CreateRenderableActor();
9717   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9718   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
9719   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
9720   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9721   application.GetScene().Add(actor);
9722
9723   application.SendNotification();
9724
9725   std::vector<Rect<int>> damagedRects;
9726   Rect<int>              clippingRect;
9727
9728   // 1. Actor added, damaged rect is added size of actor
9729   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9730   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9731
9732   // Aligned by 16
9733   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
9734   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9735   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9736   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9737   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9738   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9739   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9740
9741   damagedRects.clear();
9742   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9743   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9744
9745   // Ensure the damaged rect is empty
9746   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9747
9748   // 2. Make the Actor invisible
9749   actor.SetProperty(Actor::Property::VISIBLE, false);
9750   application.SendNotification();
9751
9752   damagedRects.clear();
9753   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9754   DALI_TEST_CHECK(damagedRects.size() > 0);
9755   DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
9756
9757   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9758   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9759   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9760   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9761   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9762
9763   // 3. Make the Actor visible again
9764   actor.SetProperty(Actor::Property::VISIBLE, true);
9765   application.SendNotification();
9766
9767   damagedRects.clear();
9768   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9769   DALI_TEST_CHECK(damagedRects.size() > 0);
9770   DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
9771
9772   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9773   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9774   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9775   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9776   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9777
9778   END_TEST;
9779 }
9780
9781 int utcDaliActorPartialUpdateOnOffScene(void)
9782 {
9783   TestApplication application(
9784     TestApplication::DEFAULT_SURFACE_WIDTH,
9785     TestApplication::DEFAULT_SURFACE_HEIGHT,
9786     TestApplication::DEFAULT_HORIZONTAL_DPI,
9787     TestApplication::DEFAULT_VERTICAL_DPI,
9788     true,
9789     true);
9790
9791   tet_infoline("Check the damaged rect with partial update and on/off scene");
9792
9793   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9794
9795   Actor actor = CreateRenderableActor();
9796   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9797   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
9798   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
9799   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9800   application.GetScene().Add(actor);
9801
9802   application.SendNotification();
9803
9804   std::vector<Rect<int>> damagedRects;
9805   Rect<int>              clippingRect;
9806
9807   // 1. Actor added, damaged rect is added size of actor
9808   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9809   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9810
9811   // Aligned by 16
9812   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
9813   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9814   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9815   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9816   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9817   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9818   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9819
9820   damagedRects.clear();
9821   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9822   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9823
9824   damagedRects.clear();
9825   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9826   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9827
9828   // Ensure the damaged rect is empty
9829   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9830
9831   // 2. Remove the Actor from the Scene
9832   actor.Unparent();
9833   application.SendNotification();
9834
9835   damagedRects.clear();
9836   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9837   DALI_TEST_CHECK(damagedRects.size() > 0);
9838   DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
9839
9840   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9841   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9842   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9843   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9844   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9845
9846   // 3. Add the Actor to the Scene again
9847   application.GetScene().Add(actor);
9848   application.SendNotification();
9849
9850   damagedRects.clear();
9851   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9852   DALI_TEST_CHECK(damagedRects.size() > 0);
9853   DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
9854
9855   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9856   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9857   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9858   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9859   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9860
9861   END_TEST;
9862 }
9863
9864 int utcDaliActorPartialUpdateSkipRendering(void)
9865 {
9866   TestApplication application(
9867     TestApplication::DEFAULT_SURFACE_WIDTH,
9868     TestApplication::DEFAULT_SURFACE_HEIGHT,
9869     TestApplication::DEFAULT_HORIZONTAL_DPI,
9870     TestApplication::DEFAULT_VERTICAL_DPI,
9871     true,
9872     true);
9873
9874   tet_infoline("Check to skip rendering in case of the empty damaged rect");
9875
9876   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
9877   drawTrace.Enable(true);
9878   drawTrace.Reset();
9879
9880   Actor actor1 = CreateRenderableActor();
9881   actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9882   actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
9883   application.GetScene().Add(actor1);
9884
9885   std::vector<Rect<int>> damagedRects;
9886   Rect<int>              clippingRect;
9887   Rect<int>              expectedRect1;
9888
9889   application.SendNotification();
9890   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9891
9892   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9893
9894   // Aligned by 16
9895   expectedRect1 = Rect<int>(0, 720, 96, 96); // in screen coordinates
9896   DirtyRectChecker(damagedRects, {expectedRect1}, true, TEST_LOCATION);
9897
9898   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9899   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9900
9901   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9902
9903   damagedRects.clear();
9904   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9905   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9906   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9907
9908   // Remove the actor
9909   actor1.Unparent();
9910
9911   application.SendNotification();
9912
9913   damagedRects.clear();
9914   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9915
9916   DirtyRectChecker(damagedRects, {expectedRect1}, true, TEST_LOCATION);
9917
9918   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9919   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9920
9921   // Render again without any change
9922   damagedRects.clear();
9923   drawTrace.Reset();
9924   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9925
9926   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9927
9928   clippingRect = Rect<int>();
9929   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9930
9931   // Skip rendering
9932   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
9933
9934   // Add the actor again
9935   application.GetScene().Add(actor1);
9936
9937   application.SendNotification();
9938
9939   damagedRects.clear();
9940   drawTrace.Reset();
9941   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9942
9943   DirtyRectChecker(damagedRects, {expectedRect1}, true, TEST_LOCATION);
9944
9945   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9946   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9947
9948   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9949
9950   END_TEST;
9951 }
9952
9953 int utcDaliActorPartialUpdate3DNode(void)
9954 {
9955   TestApplication application(
9956     TestApplication::DEFAULT_SURFACE_WIDTH,
9957     TestApplication::DEFAULT_SURFACE_HEIGHT,
9958     TestApplication::DEFAULT_HORIZONTAL_DPI,
9959     TestApplication::DEFAULT_VERTICAL_DPI,
9960     true,
9961     true);
9962
9963   tet_infoline("Partial update should be ignored in case of 3d layer of 3d node");
9964
9965   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
9966   drawTrace.Enable(true);
9967   drawTrace.Reset();
9968
9969   Actor actor1 = CreateRenderableActor();
9970   actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9971   actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
9972   application.GetScene().Add(actor1);
9973
9974   std::vector<Rect<int>> damagedRects;
9975   Rect<int>              clippingRect;
9976
9977   application.SendNotification();
9978   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9979
9980   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9981
9982   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9983   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9984
9985   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9986
9987   // Change the layer to 3D
9988   application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D);
9989
9990   application.SendNotification();
9991
9992   damagedRects.clear();
9993   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9994
9995   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9996   DirtyRectChecker(damagedRects, {TestApplication::DEFAULT_SURFACE_RECT}, true, TEST_LOCATION);
9997
9998   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9999   drawTrace.Reset();
10000   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10001
10002   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
10003
10004   // Change the layer to 2D
10005   application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_UI);
10006
10007   application.SendNotification();
10008
10009   damagedRects.clear();
10010   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10011
10012   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10013
10014   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
10015   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10016
10017   // Make 3D transform
10018   actor1.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::YAXIS));
10019
10020   application.SendNotification();
10021
10022   damagedRects.clear();
10023   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10024
10025   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10026   DirtyRectChecker(damagedRects, {TestApplication::DEFAULT_SURFACE_RECT}, true, TEST_LOCATION);
10027
10028   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
10029   drawTrace.Reset();
10030   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10031
10032   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
10033
10034   END_TEST;
10035 }
10036
10037 int utcDaliActorPartialUpdateNotRenderableActor(void)
10038 {
10039   TestApplication application(
10040     TestApplication::DEFAULT_SURFACE_WIDTH,
10041     TestApplication::DEFAULT_SURFACE_HEIGHT,
10042     TestApplication::DEFAULT_HORIZONTAL_DPI,
10043     TestApplication::DEFAULT_VERTICAL_DPI,
10044     true,
10045     true);
10046
10047   tet_infoline("Check the damaged rect with not renderable parent actor");
10048
10049   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
10050
10051   Actor parent                          = Actor::New();
10052   parent[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10053   parent[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
10054   parent[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
10055   parent.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10056   application.GetScene().Add(parent);
10057
10058   Actor child                          = CreateRenderableActor();
10059   child[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10060   child[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
10061   child.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10062   parent.Add(child);
10063
10064   application.SendNotification();
10065
10066   std::vector<Rect<int>> damagedRects;
10067
10068   // 1. Actor added, damaged rect is added size of actor
10069   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10070   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10071
10072   // Aligned by 16
10073   Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10074   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10075
10076   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10077   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
10078   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
10079   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
10080   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
10081
10082   damagedRects.clear();
10083   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10084   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10085
10086   damagedRects.clear();
10087   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10088   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10089
10090   // Ensure the damaged rect is empty
10091   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10092
10093   END_TEST;
10094 }
10095
10096 int utcDaliActorPartialUpdateChangeTransparency(void)
10097 {
10098   TestApplication application(
10099     TestApplication::DEFAULT_SURFACE_WIDTH,
10100     TestApplication::DEFAULT_SURFACE_HEIGHT,
10101     TestApplication::DEFAULT_HORIZONTAL_DPI,
10102     TestApplication::DEFAULT_VERTICAL_DPI,
10103     true,
10104     true);
10105
10106   tet_infoline("Check the damaged rect with changing transparency");
10107
10108   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
10109
10110   Actor actor                          = CreateRenderableActor();
10111   actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10112   actor[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
10113   actor[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
10114   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10115   application.GetScene().Add(actor);
10116
10117   application.SendNotification();
10118
10119   std::vector<Rect<int>> damagedRects;
10120
10121   // Actor added, damaged rect is added size of actor
10122   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10123   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10124
10125   // Aligned by 16
10126   Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10127   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10128
10129   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10130   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
10131   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
10132   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
10133   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
10134
10135   damagedRects.clear();
10136   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10137   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10138
10139   // Ensure the damaged rect is empty
10140   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10141
10142   // Make the actor transparent by changing opacity of the Renderer
10143   // It changes a uniform value
10144   Renderer renderer                          = actor.GetRendererAt(0);
10145   renderer[DevelRenderer::Property::OPACITY] = 0.0f;
10146
10147   application.SendNotification();
10148
10149   // The damaged rect should be same
10150   damagedRects.clear();
10151   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10152   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10153   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10154   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10155
10156   damagedRects.clear();
10157   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10158   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10159
10160   // Ensure the damaged rect is empty
10161   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10162
10163   // Make the actor opaque again
10164   renderer[DevelRenderer::Property::OPACITY] = 1.0f;
10165
10166   application.SendNotification();
10167
10168   // The damaged rect should not be empty
10169   damagedRects.clear();
10170   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10171   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10172   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10173   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10174
10175   damagedRects.clear();
10176   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10177   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10178
10179   // Ensure the damaged rect is empty
10180   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10181
10182   // Make the actor translucent
10183   renderer[DevelRenderer::Property::OPACITY] = 0.5f;
10184
10185   application.SendNotification();
10186
10187   // The damaged rect should not be empty
10188   damagedRects.clear();
10189   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10190   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10191   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10192   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10193
10194   damagedRects.clear();
10195   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10196   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10197
10198   // Ensure the damaged rect is empty
10199   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10200
10201   // Change Renderer opacity - also translucent
10202   renderer[DevelRenderer::Property::OPACITY] = 0.2f;
10203
10204   application.SendNotification();
10205
10206   // The damaged rect should not be empty
10207   damagedRects.clear();
10208   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10209   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10210   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10211   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10212
10213   damagedRects.clear();
10214   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10215   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10216
10217   // Ensure the damaged rect is empty
10218   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10219
10220   // Make the actor culled
10221   actor[Actor::Property::SIZE] = Vector3(0.0f, 0.0f, 0.0f);
10222
10223   application.SendNotification();
10224
10225   // The damaged rect should be same
10226   damagedRects.clear();
10227   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10228   DALI_TEST_CHECK(damagedRects.size() > 0);
10229   DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
10230   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10231
10232   damagedRects.clear();
10233   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10234   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10235
10236   // Ensure the damaged rect is empty
10237   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10238
10239   // Make the actor not culled again
10240   actor[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 16.0f);
10241
10242   application.SendNotification();
10243
10244   // The damaged rect should not be empty
10245   damagedRects.clear();
10246   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10247   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10248   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10249   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10250
10251   END_TEST;
10252 }
10253
10254 int utcDaliActorPartialUpdateChangeParentOpacity(void)
10255 {
10256   TestApplication application(
10257     TestApplication::DEFAULT_SURFACE_WIDTH,
10258     TestApplication::DEFAULT_SURFACE_HEIGHT,
10259     TestApplication::DEFAULT_HORIZONTAL_DPI,
10260     TestApplication::DEFAULT_VERTICAL_DPI,
10261     true,
10262     true);
10263
10264   tet_infoline("Check the damaged rect with changing parent's opacity");
10265
10266   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
10267
10268   Actor parent                          = Actor::New();
10269   parent[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10270   parent[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
10271   parent[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
10272   parent.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10273   application.GetScene().Add(parent);
10274
10275   Texture texture                      = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
10276   Actor   child                        = CreateRenderableActor(texture);
10277   child[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10278   child[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
10279   child.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10280   parent.Add(child);
10281
10282   application.SendNotification();
10283
10284   std::vector<Rect<int>> damagedRects;
10285
10286   // Actor added, damaged rect is added size of actor
10287   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10288   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10289
10290   // Aligned by 16
10291   Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10292   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10293
10294   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10295   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
10296   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
10297   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
10298   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
10299
10300   damagedRects.clear();
10301   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10302   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10303
10304   damagedRects.clear();
10305   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10306   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10307
10308   // Ensure the damaged rect is empty
10309   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10310
10311   // Change the parent's opacity
10312   parent[Actor::Property::OPACITY] = 0.5f;
10313
10314   application.SendNotification();
10315
10316   // The damaged rect should be same
10317   damagedRects.clear();
10318   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10319   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10320   DALI_TEST_CHECK(damagedRects.size() > 0);
10321   DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
10322
10323   END_TEST;
10324 }
10325
10326 int utcDaliActorPartialUpdateAddRemoveRenderer(void)
10327 {
10328   TestApplication application(
10329     TestApplication::DEFAULT_SURFACE_WIDTH,
10330     TestApplication::DEFAULT_SURFACE_HEIGHT,
10331     TestApplication::DEFAULT_HORIZONTAL_DPI,
10332     TestApplication::DEFAULT_VERTICAL_DPI,
10333     true,
10334     true);
10335
10336   tet_infoline("Check the damaged rect with adding / removing renderer");
10337
10338   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
10339
10340   Actor actor                          = CreateRenderableActor();
10341   actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10342   actor[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
10343   actor[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
10344   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10345   application.GetScene().Add(actor);
10346
10347   application.SendNotification();
10348
10349   std::vector<Rect<int>> damagedRects;
10350
10351   // Actor added, damaged rect is added size of actor
10352   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10353   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10354
10355   // Aligned by 16
10356   Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10357   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10358
10359   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10360   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
10361   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
10362   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
10363   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
10364
10365   damagedRects.clear();
10366   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10367   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10368
10369   damagedRects.clear();
10370   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10371   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10372
10373   // Remove the Renderer
10374   Renderer renderer = actor.GetRendererAt(0);
10375   actor.RemoveRenderer(renderer);
10376
10377   application.SendNotification();
10378
10379   // The damaged rect should be the actor area
10380   damagedRects.clear();
10381   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10382   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10383   DALI_TEST_CHECK(damagedRects.size() > 0);
10384   DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
10385
10386   damagedRects.clear();
10387   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10388   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10389
10390   // Ensure the damaged rect is empty
10391   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10392
10393   // Add the Renderer again
10394   actor.AddRenderer(renderer);
10395
10396   application.SendNotification();
10397
10398   // The damaged rect should be the actor area
10399   damagedRects.clear();
10400   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10401   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10402   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10403   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10404
10405   END_TEST;
10406 }
10407
10408 int utcDaliActorPartialUpdate3DTransform(void)
10409 {
10410   TestApplication application(
10411     TestApplication::DEFAULT_SURFACE_WIDTH,
10412     TestApplication::DEFAULT_SURFACE_HEIGHT,
10413     TestApplication::DEFAULT_HORIZONTAL_DPI,
10414     TestApplication::DEFAULT_VERTICAL_DPI,
10415     true,
10416     true);
10417
10418   tet_infoline("Check the damaged rect with 3D transformed actors");
10419
10420   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
10421
10422   Actor actor1                          = CreateRenderableActor();
10423   actor1[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10424   actor1[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
10425   actor1[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
10426   actor1.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10427   application.GetScene().Add(actor1);
10428
10429   // Add a new actor
10430   Actor actor2                          = CreateRenderableActor();
10431   actor2[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10432   actor2[Actor::Property::POSITION]     = Vector3(160.0f, 160.0f, 0.0f);
10433   actor2[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
10434   actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10435   application.GetScene().Add(actor2);
10436
10437   application.SendNotification();
10438
10439   std::vector<Rect<int>> damagedRects;
10440
10441   // Actor added, damaged rect is added size of actor
10442   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10443   DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
10444
10445   // Aligned by 16
10446   Rect<int> clippingRect1 = Rect<int>(16, 768, 32, 32); // in screen coordinates
10447   Rect<int> clippingRect2 = Rect<int>(160, 624, 32, 32);
10448   DirtyRectChecker(damagedRects, {clippingRect1, clippingRect2}, true, TEST_LOCATION);
10449
10450   Rect<int> surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10451   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10452
10453   damagedRects.clear();
10454   surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10455   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10456   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10457
10458   damagedRects.clear();
10459   surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10460   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10461   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10462
10463   // Rotate actor1 on y axis
10464   actor1[Actor::Property::ORIENTATION] = Quaternion(Radian(Degree(90.0)), Vector3::YAXIS);
10465
10466   // Remove actor2
10467   actor2.Unparent();
10468
10469   application.SendNotification();
10470
10471   damagedRects.clear();
10472   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10473
10474   // Should update full area
10475   surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10476   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10477   DirtyRectChecker(damagedRects, {surfaceRect}, true, TEST_LOCATION);
10478   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10479
10480   // Add actor2 again
10481   application.GetScene().Add(actor2);
10482
10483   application.SendNotification();
10484
10485   damagedRects.clear();
10486   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10487
10488   // Should update full area
10489   surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10490   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10491   DirtyRectChecker(damagedRects, {surfaceRect}, true, TEST_LOCATION);
10492   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10493
10494   // Reset the orientation of actor1
10495   actor1[Actor::Property::ORIENTATION] = Quaternion::IDENTITY;
10496
10497   application.SendNotification();
10498
10499   damagedRects.clear();
10500   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10501
10502   // Should update full area
10503   surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10504   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10505   DirtyRectChecker(damagedRects, {surfaceRect}, true, TEST_LOCATION);
10506   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10507
10508   // Make actor2 dirty
10509   actor2[Actor::Property::SIZE] = Vector3(32.0f, 32.0f, 0.0f);
10510
10511   application.SendNotification();
10512
10513   damagedRects.clear();
10514   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10515
10516   clippingRect2 = Rect<int>(160, 608, 48, 48);
10517   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10518   DirtyRectChecker(damagedRects, {clippingRect2}, true, TEST_LOCATION);
10519
10520   application.RenderWithPartialUpdate(damagedRects, clippingRect2);
10521   DALI_TEST_EQUALS(clippingRect2.x, glScissorParams.x, TEST_LOCATION);
10522   DALI_TEST_EQUALS(clippingRect2.y, glScissorParams.y, TEST_LOCATION);
10523   DALI_TEST_EQUALS(clippingRect2.width, glScissorParams.width, TEST_LOCATION);
10524   DALI_TEST_EQUALS(clippingRect2.height, glScissorParams.height, TEST_LOCATION);
10525
10526   // Remove actor1
10527   actor1.Unparent();
10528
10529   application.SendNotification();
10530
10531   damagedRects.clear();
10532   surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10533   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10534   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10535
10536   // Rotate actor1 on y axis
10537   actor1[Actor::Property::ORIENTATION] = Quaternion(Radian(Degree(90.0)), Vector3::YAXIS);
10538
10539   // Add actor1 again
10540   application.GetScene().Add(actor1);
10541
10542   application.SendNotification();
10543
10544   damagedRects.clear();
10545   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10546
10547   // Should update full area
10548   surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10549   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10550   DirtyRectChecker(damagedRects, {surfaceRect}, true, TEST_LOCATION);
10551   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10552
10553   END_TEST;
10554 }
10555
10556 int utcDaliActorPartialUpdateOneActorMultipleRenderers(void)
10557 {
10558   TestApplication application(
10559     TestApplication::DEFAULT_SURFACE_WIDTH,
10560     TestApplication::DEFAULT_SURFACE_HEIGHT,
10561     TestApplication::DEFAULT_HORIZONTAL_DPI,
10562     TestApplication::DEFAULT_VERTICAL_DPI,
10563     true,
10564     true);
10565
10566   tet_infoline("Check the damaged rect with one actor which has multiple renderers");
10567
10568   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
10569
10570   Actor actor = CreateRenderableActor();
10571
10572   // Create another renderer
10573   Geometry geometry  = CreateQuadGeometry();
10574   Shader   shader    = CreateShader();
10575   Renderer renderer2 = Renderer::New(geometry, shader);
10576   actor.AddRenderer(renderer2);
10577
10578   actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10579   actor[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
10580   actor[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
10581   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10582   application.GetScene().Add(actor);
10583
10584   application.SendNotification();
10585
10586   DALI_TEST_EQUALS(actor.GetRendererCount(), 2u, TEST_LOCATION);
10587
10588   std::vector<Rect<int>> damagedRects;
10589
10590   // Actor added, damaged rect is added size of actor
10591   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10592   DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
10593
10594   // Aligned by 16
10595   Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10596   DirtyRectChecker(damagedRects, {clippingRect, clippingRect}, true, TEST_LOCATION);
10597
10598   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10599   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
10600   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
10601   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
10602   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
10603
10604   damagedRects.clear();
10605   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10606   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10607
10608   // Ensure the damaged rect is empty
10609   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10610
10611   // Make renderer2 dirty
10612   renderer2[DevelRenderer::Property::OPACITY] = 0.5f;
10613
10614   application.SendNotification();
10615
10616   // The damaged rect should be the actor area
10617   damagedRects.clear();
10618   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10619
10620   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10621   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10622   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10623
10624   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10625
10626   damagedRects.clear();
10627   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10628   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10629
10630   // Ensure the damaged rect is empty
10631   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10632
10633   // Make renderer2 dirty
10634   renderer2[Renderer::Property::FACE_CULLING_MODE] = FaceCullingMode::BACK;
10635
10636   application.SendNotification();
10637
10638   // The damaged rect should be the actor area
10639   damagedRects.clear();
10640   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10641
10642   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10643   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10644   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10645
10646   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10647
10648   damagedRects.clear();
10649   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10650   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10651
10652   // Ensure the damaged rect is empty
10653   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10654
10655   END_TEST;
10656 }
10657
10658 int utcDaliActorPartialUpdateMultipleActorsOneRenderer(void)
10659 {
10660   TestApplication application(
10661     TestApplication::DEFAULT_SURFACE_WIDTH,
10662     TestApplication::DEFAULT_SURFACE_HEIGHT,
10663     TestApplication::DEFAULT_HORIZONTAL_DPI,
10664     TestApplication::DEFAULT_VERTICAL_DPI,
10665     true,
10666     true);
10667
10668   tet_infoline("Check the damaged rect with multiple actors which share a same renderer");
10669
10670   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
10671
10672   Actor actor                          = CreateRenderableActor();
10673   actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10674   actor[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
10675   actor[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
10676   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10677   application.GetScene().Add(actor);
10678
10679   // Create another actor which has the same renderer with actor1
10680   Actor    actor2   = Actor::New();
10681   Renderer renderer = actor.GetRendererAt(0);
10682   actor2.AddRenderer(renderer);
10683   actor2[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10684   actor2[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
10685   actor2[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
10686   actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10687   application.GetScene().Add(actor2);
10688
10689   application.SendNotification();
10690
10691   std::vector<Rect<int>> damagedRects;
10692
10693   // Actor added, damaged rect is added size of actor
10694   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10695   DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
10696
10697   // Aligned by 16
10698   Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10699   DirtyRectChecker(damagedRects, {clippingRect, clippingRect}, true, TEST_LOCATION);
10700
10701   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10702   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
10703   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
10704   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
10705   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
10706
10707   damagedRects.clear();
10708   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10709   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10710
10711   // Ensure the damaged rect is empty
10712   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10713
10714   // Make renderer dirty
10715   renderer[DevelRenderer::Property::OPACITY] = 0.5f;
10716
10717   application.SendNotification();
10718
10719   // The damaged rect should be the actor area
10720   damagedRects.clear();
10721   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10722
10723   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10724   DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
10725   DirtyRectChecker(damagedRects, {clippingRect, clippingRect}, true, TEST_LOCATION);
10726
10727   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10728
10729   damagedRects.clear();
10730   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10731   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10732
10733   // Ensure the damaged rect is empty
10734   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10735
10736   END_TEST;
10737 }
10738
10739 int UtcDaliActorCaptureAllTouchAfterStartPropertyP(void)
10740 {
10741   TestApplication application;
10742
10743   Actor actor = Actor::New();
10744   DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), false, TEST_LOCATION);
10745   actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, true);
10746   DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), true, TEST_LOCATION);
10747   DALI_TEST_EQUALS(actor.GetPropertyType(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), Property::BOOLEAN, TEST_LOCATION);
10748   DALI_TEST_EQUALS(actor.IsPropertyWritable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), true, TEST_LOCATION);
10749   DALI_TEST_EQUALS(actor.IsPropertyAnimatable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
10750   DALI_TEST_EQUALS(actor.IsPropertyAConstraintInput(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
10751   DALI_TEST_EQUALS(actor.GetPropertyName(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), "captureAllTouchAfterStart", TEST_LOCATION);
10752   END_TEST;
10753 }
10754
10755 int UtcDaliActorCaptureAllTouchAfterStartPropertyN(void)
10756 {
10757   TestApplication application;
10758
10759   Actor actor = Actor::New();
10760
10761   // Make sure setting invalid types does not cause a crash
10762   try
10763   {
10764     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, 1.0f);
10765     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector2::ONE);
10766     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector3::ONE);
10767     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector4::ONE);
10768     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Map());
10769     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Array());
10770     tet_result(TET_PASS);
10771   }
10772   catch(...)
10773   {
10774     tet_result(TET_FAIL);
10775   }
10776   END_TEST;
10777 }
10778
10779 int UtcDaliActorTouchAreaOffsetPropertyP(void)
10780 {
10781   TestApplication application;
10782
10783   Actor     actor           = Actor::New();
10784   Rect<int> touchAreaOffset = actor.GetProperty(DevelActor::Property::TOUCH_AREA_OFFSET).Get<Rect<int>>();
10785   DALI_TEST_EQUALS(Rect<int>(0, 0, 0, 0), touchAreaOffset, TEST_LOCATION);
10786   actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Rect<int>(10, 20, 30, 40));
10787   touchAreaOffset = actor.GetProperty(DevelActor::Property::TOUCH_AREA_OFFSET).Get<Rect<int>>();
10788   DALI_TEST_EQUALS(Rect<int>(10, 20, 30, 40), touchAreaOffset, TEST_LOCATION);
10789   END_TEST;
10790 }
10791
10792 int UtcDaliActorTouchAreaOffsetPropertyN(void)
10793 {
10794   TestApplication application;
10795
10796   Actor actor = Actor::New();
10797
10798   // Make sure setting invalid types does not cause a crash
10799   try
10800   {
10801     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, 1.0f);
10802     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector2::ONE);
10803     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector3::ONE);
10804     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector4::ONE);
10805     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Property::Map());
10806     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Property::Array());
10807     tet_result(TET_PASS);
10808   }
10809   catch(...)
10810   {
10811     tet_result(TET_FAIL);
10812   }
10813   END_TEST;
10814 }
10815
10816 int UtcDaliActorLowerBelowNegative(void)
10817 {
10818   TestApplication application;
10819   Dali::Actor     instance;
10820   try
10821   {
10822     Dali::Actor arg1;
10823     instance.LowerBelow(arg1);
10824     DALI_TEST_CHECK(false); // Should not get here
10825   }
10826   catch(...)
10827   {
10828     DALI_TEST_CHECK(true); // We expect an assert
10829   }
10830   END_TEST;
10831 }
10832
10833 int UtcDaliActorRaiseAboveNegative(void)
10834 {
10835   TestApplication application;
10836   Dali::Actor     instance;
10837   try
10838   {
10839     Dali::Actor arg1;
10840     instance.RaiseAbove(arg1);
10841     DALI_TEST_CHECK(false); // Should not get here
10842   }
10843   catch(...)
10844   {
10845     DALI_TEST_CHECK(true); // We expect an assert
10846   }
10847   END_TEST;
10848 }
10849
10850 int UtcDaliActorRaiseToTopNegative(void)
10851 {
10852   TestApplication application;
10853   Dali::Actor     instance;
10854   try
10855   {
10856     instance.RaiseToTop();
10857     DALI_TEST_CHECK(false); // Should not get here
10858   }
10859   catch(...)
10860   {
10861     DALI_TEST_CHECK(true); // We expect an assert
10862   }
10863   END_TEST;
10864 }
10865
10866 int UtcDaliActorAddRendererNegative(void)
10867 {
10868   TestApplication application;
10869   Dali::Actor     instance;
10870   try
10871   {
10872     Dali::Renderer arg1;
10873     instance.AddRenderer(arg1);
10874     DALI_TEST_CHECK(false); // Should not get here
10875   }
10876   catch(...)
10877   {
10878     DALI_TEST_CHECK(true); // We expect an assert
10879   }
10880   END_TEST;
10881 }
10882
10883 int UtcDaliActorTouchedSignalNegative(void)
10884 {
10885   TestApplication application;
10886   Dali::Actor     instance;
10887   try
10888   {
10889     instance.TouchedSignal();
10890     DALI_TEST_CHECK(false); // Should not get here
10891   }
10892   catch(...)
10893   {
10894     DALI_TEST_CHECK(true); // We expect an assert
10895   }
10896   END_TEST;
10897 }
10898
10899 int UtcDaliActorTranslateByNegative(void)
10900 {
10901   TestApplication application;
10902   Dali::Actor     instance;
10903   try
10904   {
10905     Dali::Vector3 arg1;
10906     instance.TranslateBy(arg1);
10907     DALI_TEST_CHECK(false); // Should not get here
10908   }
10909   catch(...)
10910   {
10911     DALI_TEST_CHECK(true); // We expect an assert
10912   }
10913   END_TEST;
10914 }
10915
10916 int UtcDaliActorFindChildByIdNegative(void)
10917 {
10918   TestApplication application;
10919   Dali::Actor     instance;
10920   try
10921   {
10922     unsigned int arg1 = 0u;
10923     instance.FindChildById(arg1);
10924     DALI_TEST_CHECK(false); // Should not get here
10925   }
10926   catch(...)
10927   {
10928     DALI_TEST_CHECK(true); // We expect an assert
10929   }
10930   END_TEST;
10931 }
10932
10933 int UtcDaliActorGetRendererAtNegative(void)
10934 {
10935   TestApplication application;
10936   Dali::Actor     instance;
10937   try
10938   {
10939     unsigned int arg1 = 0u;
10940     instance.GetRendererAt(arg1);
10941     DALI_TEST_CHECK(false); // Should not get here
10942   }
10943   catch(...)
10944   {
10945     DALI_TEST_CHECK(true); // We expect an assert
10946   }
10947   END_TEST;
10948 }
10949
10950 int UtcDaliActorHoveredSignalNegative(void)
10951 {
10952   TestApplication application;
10953   Dali::Actor     instance;
10954   try
10955   {
10956     instance.HoveredSignal();
10957     DALI_TEST_CHECK(false); // Should not get here
10958   }
10959   catch(...)
10960   {
10961     DALI_TEST_CHECK(true); // We expect an assert
10962   }
10963   END_TEST;
10964 }
10965
10966 int UtcDaliActorLowerToBottomNegative(void)
10967 {
10968   TestApplication application;
10969   Dali::Actor     instance;
10970   try
10971   {
10972     instance.LowerToBottom();
10973     DALI_TEST_CHECK(false); // Should not get here
10974   }
10975   catch(...)
10976   {
10977     DALI_TEST_CHECK(true); // We expect an assert
10978   }
10979   END_TEST;
10980 }
10981
10982 int UtcDaliActorOnSceneSignalNegative(void)
10983 {
10984   TestApplication application;
10985   Dali::Actor     instance;
10986   try
10987   {
10988     instance.OnSceneSignal();
10989     DALI_TEST_CHECK(false); // Should not get here
10990   }
10991   catch(...)
10992   {
10993     DALI_TEST_CHECK(true); // We expect an assert
10994   }
10995   END_TEST;
10996 }
10997
10998 int UtcDaliActorOffSceneSignalNegative(void)
10999 {
11000   TestApplication application;
11001   Dali::Actor     instance;
11002   try
11003   {
11004     instance.OffSceneSignal();
11005     DALI_TEST_CHECK(false); // Should not get here
11006   }
11007   catch(...)
11008   {
11009     DALI_TEST_CHECK(true); // We expect an assert
11010   }
11011   END_TEST;
11012 }
11013
11014 int UtcDaliActorRemoveRendererNegative01(void)
11015 {
11016   TestApplication application;
11017   Dali::Actor     instance;
11018   try
11019   {
11020     unsigned int arg1 = 0u;
11021     instance.RemoveRenderer(arg1);
11022     DALI_TEST_CHECK(false); // Should not get here
11023   }
11024   catch(...)
11025   {
11026     DALI_TEST_CHECK(true); // We expect an assert
11027   }
11028   END_TEST;
11029 }
11030
11031 int UtcDaliActorRemoveRendererNegative02(void)
11032 {
11033   TestApplication application;
11034   Dali::Actor     instance;
11035   try
11036   {
11037     Dali::Renderer arg1;
11038     instance.RemoveRenderer(arg1);
11039     DALI_TEST_CHECK(false); // Should not get here
11040   }
11041   catch(...)
11042   {
11043     DALI_TEST_CHECK(true); // We expect an assert
11044   }
11045   END_TEST;
11046 }
11047
11048 int UtcDaliActorFindChildByNameNegative(void)
11049 {
11050   TestApplication application;
11051   Dali::Actor     instance;
11052   try
11053   {
11054     std::string arg1;
11055     instance.FindChildByName(arg1);
11056     DALI_TEST_CHECK(false); // Should not get here
11057   }
11058   catch(...)
11059   {
11060     DALI_TEST_CHECK(true); // We expect an assert
11061   }
11062   END_TEST;
11063 }
11064
11065 int UtcDaliActorSetResizePolicyNegative(void)
11066 {
11067   TestApplication application;
11068   Dali::Actor     instance;
11069   try
11070   {
11071     Dali::ResizePolicy::Type arg1 = ResizePolicy::USE_NATURAL_SIZE;
11072     Dali::Dimension::Type    arg2 = Dimension::ALL_DIMENSIONS;
11073     instance.SetResizePolicy(arg1, arg2);
11074     DALI_TEST_CHECK(false); // Should not get here
11075   }
11076   catch(...)
11077   {
11078     DALI_TEST_CHECK(true); // We expect an assert
11079   }
11080   END_TEST;
11081 }
11082
11083 int UtcDaliActorOnRelayoutSignalNegative(void)
11084 {
11085   TestApplication application;
11086   Dali::Actor     instance;
11087   try
11088   {
11089     instance.OnRelayoutSignal();
11090     DALI_TEST_CHECK(false); // Should not get here
11091   }
11092   catch(...)
11093   {
11094     DALI_TEST_CHECK(true); // We expect an assert
11095   }
11096   END_TEST;
11097 }
11098
11099 int UtcDaliActorWheelEventSignalNegative(void)
11100 {
11101   TestApplication application;
11102   Dali::Actor     instance;
11103   try
11104   {
11105     instance.WheelEventSignal();
11106     DALI_TEST_CHECK(false); // Should not get here
11107   }
11108   catch(...)
11109   {
11110     DALI_TEST_CHECK(true); // We expect an assert
11111   }
11112   END_TEST;
11113 }
11114
11115 int UtcDaliActorGetHeightForWidthNegative(void)
11116 {
11117   TestApplication application;
11118   Dali::Actor     instance;
11119   try
11120   {
11121     float arg1 = 0.0f;
11122     instance.GetHeightForWidth(arg1);
11123     DALI_TEST_CHECK(false); // Should not get here
11124   }
11125   catch(...)
11126   {
11127     DALI_TEST_CHECK(true); // We expect an assert
11128   }
11129   END_TEST;
11130 }
11131
11132 int UtcDaliActorGetWidthForHeightNegative(void)
11133 {
11134   TestApplication application;
11135   Dali::Actor     instance;
11136   try
11137   {
11138     float arg1 = 0.0f;
11139     instance.GetWidthForHeight(arg1);
11140     DALI_TEST_CHECK(false); // Should not get here
11141   }
11142   catch(...)
11143   {
11144     DALI_TEST_CHECK(true); // We expect an assert
11145   }
11146   END_TEST;
11147 }
11148
11149 int UtcDaliActorLayoutDirectionChangedSignalNegative(void)
11150 {
11151   TestApplication application;
11152   Dali::Actor     instance;
11153   try
11154   {
11155     instance.LayoutDirectionChangedSignal();
11156     DALI_TEST_CHECK(false); // Should not get here
11157   }
11158   catch(...)
11159   {
11160     DALI_TEST_CHECK(true); // We expect an assert
11161   }
11162   END_TEST;
11163 }
11164
11165 int UtcDaliActorAddNegative(void)
11166 {
11167   TestApplication application;
11168   Dali::Actor     instance;
11169   try
11170   {
11171     Dali::Actor arg1;
11172     instance.Add(arg1);
11173     DALI_TEST_CHECK(false); // Should not get here
11174   }
11175   catch(...)
11176   {
11177     DALI_TEST_CHECK(true); // We expect an assert
11178   }
11179   END_TEST;
11180 }
11181
11182 int UtcDaliActorLowerNegative(void)
11183 {
11184   TestApplication application;
11185   Dali::Actor     instance;
11186   try
11187   {
11188     instance.Lower();
11189     DALI_TEST_CHECK(false); // Should not get here
11190   }
11191   catch(...)
11192   {
11193     DALI_TEST_CHECK(true); // We expect an assert
11194   }
11195   END_TEST;
11196 }
11197
11198 int UtcDaliActorRaiseNegative(void)
11199 {
11200   TestApplication application;
11201   Dali::Actor     instance;
11202   try
11203   {
11204     instance.Raise();
11205     DALI_TEST_CHECK(false); // Should not get here
11206   }
11207   catch(...)
11208   {
11209     DALI_TEST_CHECK(true); // We expect an assert
11210   }
11211   END_TEST;
11212 }
11213
11214 int UtcDaliActorRemoveNegative(void)
11215 {
11216   TestApplication application;
11217   Dali::Actor     instance;
11218   try
11219   {
11220     Dali::Actor arg1;
11221     instance.Remove(arg1);
11222     DALI_TEST_CHECK(false); // Should not get here
11223   }
11224   catch(...)
11225   {
11226     DALI_TEST_CHECK(true); // We expect an assert
11227   }
11228   END_TEST;
11229 }
11230
11231 int UtcDaliActorScaleByNegative(void)
11232 {
11233   TestApplication application;
11234   Dali::Actor     instance;
11235   try
11236   {
11237     Dali::Vector3 arg1;
11238     instance.ScaleBy(arg1);
11239     DALI_TEST_CHECK(false); // Should not get here
11240   }
11241   catch(...)
11242   {
11243     DALI_TEST_CHECK(true); // We expect an assert
11244   }
11245   END_TEST;
11246 }
11247
11248 int UtcDaliActorGetLayerNegative(void)
11249 {
11250   TestApplication application;
11251   Dali::Actor     instance;
11252   try
11253   {
11254     instance.GetLayer();
11255     DALI_TEST_CHECK(false); // Should not get here
11256   }
11257   catch(...)
11258   {
11259     DALI_TEST_CHECK(true); // We expect an assert
11260   }
11261   END_TEST;
11262 }
11263
11264 int UtcDaliActorRotateByNegative01(void)
11265 {
11266   TestApplication application;
11267   Dali::Actor     instance;
11268   try
11269   {
11270     Dali::Quaternion arg1;
11271     instance.RotateBy(arg1);
11272     DALI_TEST_CHECK(false); // Should not get here
11273   }
11274   catch(...)
11275   {
11276     DALI_TEST_CHECK(true); // We expect an assert
11277   }
11278   END_TEST;
11279 }
11280
11281 int UtcDaliActorRotateByNegative02(void)
11282 {
11283   TestApplication application;
11284   Dali::Actor     instance;
11285   try
11286   {
11287     Dali::Radian  arg1;
11288     Dali::Vector3 arg2;
11289     instance.RotateBy(arg1, arg2);
11290     DALI_TEST_CHECK(false); // Should not get here
11291   }
11292   catch(...)
11293   {
11294     DALI_TEST_CHECK(true); // We expect an assert
11295   }
11296   END_TEST;
11297 }
11298
11299 int UtcDaliActorUnparentNegative(void)
11300 {
11301   TestApplication application;
11302   Dali::Actor     instance;
11303   try
11304   {
11305     instance.Unparent();
11306     DALI_TEST_CHECK(false); // Should not get here
11307   }
11308   catch(...)
11309   {
11310     DALI_TEST_CHECK(true); // We expect an assert
11311   }
11312   END_TEST;
11313 }
11314
11315 int UtcDaliActorGetChildAtNegative(void)
11316 {
11317   TestApplication application;
11318   Dali::Actor     instance;
11319   try
11320   {
11321     unsigned int arg1 = 0u;
11322     instance.GetChildAt(arg1);
11323     DALI_TEST_CHECK(false); // Should not get here
11324   }
11325   catch(...)
11326   {
11327     DALI_TEST_CHECK(true); // We expect an assert
11328   }
11329   END_TEST;
11330 }
11331
11332 int UtcDaliActorGetChildCountNegative(void)
11333 {
11334   TestApplication application;
11335   Dali::Actor     instance;
11336   try
11337   {
11338     instance.GetChildCount();
11339     DALI_TEST_CHECK(false); // Should not get here
11340   }
11341   catch(...)
11342   {
11343     DALI_TEST_CHECK(true); // We expect an assert
11344   }
11345   END_TEST;
11346 }
11347
11348 int UtcDaliActorGetTargetSizeNegative(void)
11349 {
11350   TestApplication application;
11351   Dali::Actor     instance;
11352   try
11353   {
11354     instance.GetTargetSize();
11355     DALI_TEST_CHECK(false); // Should not get here
11356   }
11357   catch(...)
11358   {
11359     DALI_TEST_CHECK(true); // We expect an assert
11360   }
11361   END_TEST;
11362 }
11363
11364 int UtcDaliActorScreenToLocalNegative(void)
11365 {
11366   TestApplication application;
11367   Dali::Actor     instance;
11368   try
11369   {
11370     float arg1 = 0.0f;
11371     float arg2 = 0.0f;
11372     float arg3 = 0.0f;
11373     float arg4 = 0.0f;
11374     instance.ScreenToLocal(arg1, arg2, arg3, arg4);
11375     DALI_TEST_CHECK(false); // Should not get here
11376   }
11377   catch(...)
11378   {
11379     DALI_TEST_CHECK(true); // We expect an assert
11380   }
11381   END_TEST;
11382 }
11383
11384 int UtcDaliActorGetNaturalSizeNegative(void)
11385 {
11386   TestApplication application;
11387   Dali::Actor     instance;
11388   try
11389   {
11390     instance.GetNaturalSize();
11391     DALI_TEST_CHECK(false); // Should not get here
11392   }
11393   catch(...)
11394   {
11395     DALI_TEST_CHECK(true); // We expect an assert
11396   }
11397   END_TEST;
11398 }
11399
11400 int UtcDaliActorGetRelayoutSizeNegative(void)
11401 {
11402   TestApplication application;
11403   Dali::Actor     instance;
11404   try
11405   {
11406     Dali::Dimension::Type arg1 = Dimension::HEIGHT;
11407     instance.GetRelayoutSize(arg1);
11408     DALI_TEST_CHECK(false); // Should not get here
11409   }
11410   catch(...)
11411   {
11412     DALI_TEST_CHECK(true); // We expect an assert
11413   }
11414   END_TEST;
11415 }
11416
11417 int UtcDaliActorGetResizePolicyNegative(void)
11418 {
11419   TestApplication application;
11420   Dali::Actor     instance;
11421   try
11422   {
11423     Dali::Dimension::Type arg1 = Dimension::ALL_DIMENSIONS;
11424     instance.GetResizePolicy(arg1);
11425     DALI_TEST_CHECK(false); // Should not get here
11426   }
11427   catch(...)
11428   {
11429     DALI_TEST_CHECK(true); // We expect an assert
11430   }
11431   END_TEST;
11432 }
11433
11434 int UtcDaliActorGetRendererCountNegative(void)
11435 {
11436   TestApplication application;
11437   Dali::Actor     instance;
11438   try
11439   {
11440     instance.GetRendererCount();
11441     DALI_TEST_CHECK(false); // Should not get here
11442   }
11443   catch(...)
11444   {
11445     DALI_TEST_CHECK(true); // We expect an assert
11446   }
11447   END_TEST;
11448 }
11449
11450 int UtcDaliActorGetParentNegative(void)
11451 {
11452   TestApplication application;
11453   Dali::Actor     instance;
11454   try
11455   {
11456     instance.GetParent();
11457     DALI_TEST_CHECK(false); // Should not get here
11458   }
11459   catch(...)
11460   {
11461     DALI_TEST_CHECK(true); // We expect an assert
11462   }
11463   END_TEST;
11464 }
11465
11466 int UtcDaliActorPropertyBlendEquation(void)
11467 {
11468   TestApplication application;
11469
11470   tet_infoline("Test SetProperty AdvancedBlendEquation");
11471
11472   Geometry geometry  = CreateQuadGeometry();
11473   Shader   shader    = CreateShader();
11474   Renderer renderer1 = Renderer::New(geometry, shader);
11475
11476   Actor actor = Actor::New();
11477   actor.SetProperty(Actor::Property::OPACITY, 0.1f);
11478
11479   actor.AddRenderer(renderer1);
11480   actor.SetProperty(Actor::Property::SIZE, Vector2(400, 400));
11481   application.GetScene().Add(actor);
11482
11483   if(!Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
11484   {
11485     actor.SetProperty(Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN);
11486     int equation = actor.GetProperty<int>(Dali::DevelActor::Property::BLEND_EQUATION);
11487     DALI_TEST_EQUALS((Dali::DevelBlendEquation::SCREEN == equation), false, TEST_LOCATION);
11488   }
11489
11490   if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
11491   {
11492     actor.SetProperty(Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN);
11493     int equation = actor.GetProperty<int>(Dali::DevelActor::Property::BLEND_EQUATION);
11494     DALI_TEST_EQUALS((Dali::DevelBlendEquation::SCREEN == equation), true, TEST_LOCATION);
11495   }
11496
11497   Renderer renderer2 = Renderer::New(geometry, shader);
11498   actor.AddRenderer(renderer2);
11499
11500   END_TEST;
11501 }
11502
11503 int UtcDaliActorRegisterProperty(void)
11504 {
11505   tet_infoline("Test property registration and uniform map update\n");
11506
11507   TestApplication application;
11508
11509   Geometry geometry  = CreateQuadGeometry();
11510   Shader   shader    = CreateShader();
11511   Renderer renderer1 = Renderer::New(geometry, shader);
11512   Renderer renderer2 = Renderer::New(geometry, shader);
11513
11514   Actor actor1 = Actor::New();
11515   actor1.AddRenderer(renderer1);
11516   actor1.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
11517   actor1.RegisterProperty("uCustom", 1);
11518   application.GetScene().Add(actor1);
11519
11520   Actor actor2 = Actor::New();
11521   actor2.AddRenderer(renderer2);
11522   actor2.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
11523   application.GetScene().Add(actor2);
11524
11525   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
11526   TraceCallStack&    callStack     = glAbstraction.GetSetUniformTrace();
11527   glAbstraction.EnableSetUniformCallTrace(true);
11528
11529   application.SendNotification();
11530   application.Render();
11531
11532   std::stringstream out;
11533   out.str("1");
11534   std::string params;
11535
11536   // Test uniform value of the custom property
11537   DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("uCustom", params));
11538   DALI_TEST_EQUALS(out.str(), params, TEST_LOCATION);
11539
11540   // Make invisible
11541   actor1[Actor::Property::VISIBLE] = false;
11542
11543   application.SendNotification();
11544   application.Render();
11545
11546   // Make visible again
11547   actor1[Actor::Property::VISIBLE] = true;
11548   actor1["uCustom"]                = 2;
11549
11550   glAbstraction.ResetSetUniformCallStack();
11551
11552   application.SendNotification();
11553   application.Render();
11554
11555   out.str("2");
11556
11557   // The uniform value should not be changed
11558   DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("uCustom", params));
11559   DALI_TEST_EQUALS(out.str(), params, TEST_LOCATION);
11560
11561   END_TEST;
11562 }
11563
11564 int UtcDaliActorDoesWantedHitTest(void)
11565 {
11566   struct HitTestData
11567   {
11568   public:
11569     HitTestData(const Vector3& scale, const Vector2& touchPoint, bool result)
11570     : mScale(scale),
11571       mTouchPoint(touchPoint),
11572       mResult(result)
11573     {
11574     }
11575
11576     Vector3 mScale;
11577     Vector2 mTouchPoint;
11578     bool    mResult;
11579   };
11580
11581   TestApplication application;
11582   tet_infoline(" UtcDaliActorDoesWantedHitTest");
11583
11584   // Fill a vector with different hit tests.
11585   struct HitTestData* hitTestData[] = {
11586     //                    scale                     touch point           result
11587     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(289.f, 400.f), true),  // touch point close to the right edge (inside)
11588     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(291.f, 400.f), false), // touch point close to the right edge (outside)
11589     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.
11590     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(200.f, 451.f), false), // touch point close to the down edge (outside)
11591     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.
11592     NULL,
11593   };
11594
11595   // get the root layer
11596   Actor actor = Actor::New();
11597   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
11598   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
11599
11600   Actor lowerActor = Actor::New();
11601   lowerActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
11602   lowerActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
11603
11604   // actor and lowerActor have no relationship.
11605   application.GetScene().Add(lowerActor);
11606   application.GetScene().Add(actor);
11607
11608   ResetTouchCallbacks();
11609   gHitTestTouchCallBackCalled = false;
11610
11611   unsigned int index = 0;
11612   while(NULL != hitTestData[index])
11613   {
11614     actor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f));
11615     actor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z));
11616
11617     lowerActor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f));
11618     lowerActor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z));
11619
11620     // flush the queue and render once
11621     application.SendNotification();
11622     application.Render();
11623
11624     DALI_TEST_CHECK(!gTouchCallBackCalled);
11625     DALI_TEST_CHECK(!gTouchCallBackCalled2);
11626     DALI_TEST_CHECK(!gHitTestTouchCallBackCalled);
11627
11628     // connect to its touch signal
11629     actor.TouchedSignal().Connect(TestTouchCallback);
11630     lowerActor.TouchedSignal().Connect(TestTouchCallback2);
11631
11632     // connect to its hit-test signal
11633     Dali::DevelActor::HitTestResultSignal(actor).Connect(TestHitTestTouchCallback);
11634
11635     Dali::Integration::Point point;
11636     point.SetState(PointState::DOWN);
11637     point.SetScreenPosition(Vector2(hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y));
11638     Dali::Integration::TouchEvent event;
11639     event.AddPoint(point);
11640
11641     // flush the queue and render once
11642     application.SendNotification();
11643     application.Render();
11644     application.ProcessEvent(event);
11645
11646     // check hit-test events
11647     DALI_TEST_CHECK(gHitTestTouchCallBackCalled == hitTestData[index]->mResult);
11648     // Passed all hit-tests of actor.
11649     DALI_TEST_CHECK(gTouchCallBackCalled == false);
11650     // The lowerActor was hit-tested.
11651     DALI_TEST_CHECK(gTouchCallBackCalled2 == hitTestData[index]->mResult);
11652
11653     if(gTouchCallBackCalled2 != hitTestData[index]->mResult)
11654       tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
11655                  hitTestData[index]->mScale.x,
11656                  hitTestData[index]->mScale.y,
11657                  hitTestData[index]->mScale.z,
11658                  hitTestData[index]->mTouchPoint.x,
11659                  hitTestData[index]->mTouchPoint.y,
11660                  hitTestData[index]->mResult);
11661
11662     ResetTouchCallbacks();
11663     gHitTestTouchCallBackCalled = false;
11664     ++index;
11665   }
11666   END_TEST;
11667 }
11668
11669 int UtcDaliActorAllowOnlyOwnTouchPropertyP(void)
11670 {
11671   TestApplication application;
11672
11673   Actor actor = Actor::New();
11674   DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH).Get<bool>(), false, TEST_LOCATION);
11675   actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, true);
11676   DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH).Get<bool>(), true, TEST_LOCATION);
11677   DALI_TEST_EQUALS(actor.GetPropertyType(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), Property::BOOLEAN, TEST_LOCATION);
11678   DALI_TEST_EQUALS(actor.IsPropertyWritable(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), true, TEST_LOCATION);
11679   DALI_TEST_EQUALS(actor.IsPropertyAnimatable(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), false, TEST_LOCATION);
11680   DALI_TEST_EQUALS(actor.IsPropertyAConstraintInput(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), false, TEST_LOCATION);
11681   DALI_TEST_EQUALS(actor.GetPropertyName(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), "allowOnlyOwnTouch", TEST_LOCATION);
11682   END_TEST;
11683 }
11684
11685 int UtcDaliActorAllowOnlyOwnTouchPropertyN(void)
11686 {
11687   TestApplication application;
11688
11689   Actor actor = Actor::New();
11690
11691   // Make sure setting invalid types does not cause a crash
11692   try
11693   {
11694     actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, 1.0f);
11695     actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Vector2::ONE);
11696     actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Vector3::ONE);
11697     actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Vector4::ONE);
11698     actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Property::Map());
11699     actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Property::Array());
11700     tet_result(TET_PASS);
11701   }
11702   catch(...)
11703   {
11704     tet_result(TET_FAIL);
11705   }
11706   END_TEST;
11707 }
11708
11709 int UtcDaliActorCalculateWorldTransform01(void)
11710 {
11711   TestApplication application;
11712
11713   tet_infoline("Test that actor position inheritance produces right transform matrix");
11714
11715   Actor rootActor   = Actor::New();
11716   Actor branchActor = Actor::New();
11717   Actor leafActor   = Actor::New();
11718
11719   rootActor[Actor::Property::POSITION]   = Vector3(0.0f, 0.0f, 0.0f);
11720   branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
11721   leafActor[Actor::Property::POSITION]   = Vector3(100.0f, 50.0f, 30.0f);
11722
11723   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11724   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11725   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11726
11727   // Set anchor point to the same value as parent origin
11728   rootActor[Actor::Property::PARENT_ORIGIN]   = ParentOrigin::TOP_LEFT;
11729   branchActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT;
11730   leafActor[Actor::Property::PARENT_ORIGIN]   = ParentOrigin::TOP_LEFT;
11731
11732   rootActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
11733   branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11734   leafActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
11735
11736   application.GetScene().Add(rootActor);
11737   rootActor.Add(branchActor);
11738   branchActor.Add(leafActor);
11739
11740   application.SendNotification();
11741   application.Render(0);
11742   application.SendNotification();
11743   application.Render(0);
11744
11745   Matrix m = DevelActor::GetWorldTransform(leafActor);
11746
11747   Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11748   DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11749
11750   Vector3    worldPos;
11751   Vector3    worldScale;
11752   Quaternion worldRotation;
11753   m.GetTransformComponents(worldPos, worldRotation, worldScale);
11754   DALI_TEST_EQUALS(worldPos, Vector3(200.0f, 150.0f, 30.0f), 0.0001f, TEST_LOCATION);
11755
11756   END_TEST;
11757 }
11758
11759 int UtcDaliActorCalculateWorldTransform02(void)
11760 {
11761   TestApplication application;
11762
11763   tet_infoline("Test that actor position produces right transform matrix");
11764
11765   Actor rootActor   = Actor::New();
11766   Actor branchActor = Actor::New();
11767   Actor leafActor   = Actor::New();
11768
11769   rootActor[Actor::Property::POSITION]   = Vector3(0.0f, 0.0f, 0.0f);
11770   branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
11771   leafActor[Actor::Property::POSITION]   = Vector3(100.0f, 50.0f, 30.0f);
11772
11773   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11774   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11775   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11776
11777   // Set anchor point to the same value as parent origin
11778   rootActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
11779   branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11780   leafActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
11781
11782   application.GetScene().Add(rootActor);
11783   rootActor.Add(branchActor);
11784   branchActor.Add(leafActor);
11785
11786   leafActor[Actor::Property::INHERIT_POSITION]    = false;
11787   leafActor[Actor::Property::INHERIT_ORIENTATION] = false;
11788   leafActor[Actor::Property::INHERIT_SCALE]       = false;
11789
11790   application.SendNotification();
11791   application.Render(0);
11792   application.SendNotification();
11793   application.Render(0);
11794
11795   Matrix m = DevelActor::GetWorldTransform(leafActor);
11796
11797   Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11798   DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11799
11800   END_TEST;
11801 }
11802
11803 int UtcDaliActorCalculateWorldTransform03(void)
11804 {
11805   TestApplication application;
11806
11807   tet_infoline("Test that actor position produces right transform matrix");
11808
11809   Actor rootActor   = Actor::New();
11810   Actor branchActor = Actor::New();
11811   Actor leafActor   = Actor::New();
11812
11813   rootActor[Actor::Property::POSITION]   = Vector3(0.0f, 0.0f, 0.0f);
11814   branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
11815   leafActor[Actor::Property::POSITION]   = Vector3(100.0f, 50.0f, 30.0f);
11816
11817   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11818   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11819   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11820
11821   // Set anchor point to the same value as parent origin
11822   rootActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
11823   branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11824   leafActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
11825
11826   application.GetScene().Add(rootActor);
11827   rootActor.Add(branchActor);
11828   branchActor.Add(leafActor);
11829
11830   leafActor[Actor::Property::INHERIT_POSITION]    = true;
11831   leafActor[Actor::Property::INHERIT_ORIENTATION] = false;
11832   leafActor[Actor::Property::INHERIT_SCALE]       = false;
11833
11834   application.SendNotification();
11835   application.Render(0);
11836   application.SendNotification();
11837   application.Render(0);
11838
11839   Matrix m = DevelActor::GetWorldTransform(leafActor);
11840
11841   Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11842   DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11843
11844   END_TEST;
11845 }
11846
11847 int UtcDaliActorCalculateWorldTransform04(void)
11848 {
11849   TestApplication application;
11850
11851   tet_infoline("Test that actor inheritance scale/orientation produces right transform matrix");
11852
11853   Actor rootActor   = Actor::New();
11854   Actor branchActor = Actor::New();
11855   Actor leafActor   = Actor::New();
11856
11857   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
11858   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
11859   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11860
11861   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11862   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11863   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11864
11865   // Set anchor point to the same value as parent origin
11866   rootActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::CENTER;
11867   rootActor[Actor::Property::PARENT_ORIGIN]  = ParentOrigin::CENTER;
11868   branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11869   leafActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
11870
11871   branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
11872   leafActor[Actor::Property::POSITION]   = Vector3(100.0f, 50.0f, 30.0f);
11873
11874   application.GetScene().Add(rootActor);
11875   rootActor.Add(branchActor);
11876   branchActor.Add(leafActor);
11877
11878   application.SendNotification();
11879   application.Render(0);
11880   application.SendNotification();
11881   application.Render(0);
11882
11883   Matrix m = DevelActor::GetWorldTransform(leafActor);
11884
11885   Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11886   DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11887
11888   END_TEST;
11889 }
11890
11891 int UtcDaliActorCalculateWorldTransform05(void)
11892 {
11893   TestApplication application;
11894
11895   tet_infoline("Test that actor inheritance of scale produces right transform matrix");
11896
11897   Actor rootActor   = Actor::New();
11898   Actor branchActor = Actor::New();
11899   Actor leafActor   = Actor::New();
11900
11901   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
11902   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
11903   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11904
11905   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11906   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11907   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11908
11909   // Set anchor point to the same value as parent origin
11910   rootActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::CENTER;
11911   rootActor[Actor::Property::PARENT_ORIGIN]  = ParentOrigin::CENTER;
11912   branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11913   leafActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
11914
11915   branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
11916   leafActor[Actor::Property::POSITION]   = Vector3(100.0f, 50.0f, 30.0f);
11917
11918   leafActor[Actor::Property::INHERIT_POSITION]    = false;
11919   leafActor[Actor::Property::INHERIT_ORIENTATION] = false;
11920
11921   application.GetScene().Add(rootActor);
11922   rootActor.Add(branchActor);
11923   branchActor.Add(leafActor);
11924
11925   application.SendNotification();
11926   application.Render(0);
11927   application.SendNotification();
11928   application.Render(0);
11929
11930   Matrix m = DevelActor::GetWorldTransform(leafActor);
11931
11932   Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11933   DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11934
11935   END_TEST;
11936 }
11937
11938 int UtcDaliActorCalculateWorldTransform06(void)
11939 {
11940   TestApplication application;
11941
11942   tet_infoline("Test that actor inheritance of scale produces right transform matrix");
11943
11944   Actor rootActor   = Actor::New();
11945   Actor branchActor = Actor::New();
11946   Actor leafActor   = Actor::New();
11947
11948   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
11949   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
11950   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11951
11952   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11953   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11954   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11955
11956   // Set anchor point to the same value as parent origin
11957   rootActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::CENTER;
11958   rootActor[Actor::Property::PARENT_ORIGIN]  = ParentOrigin::CENTER;
11959   branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11960   leafActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
11961
11962   branchActor[Actor::Property::POSITION]    = Vector3(100.0f, 30.0f, -50.0f);
11963   branchActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(45.0f), Vector3::XAXIS);
11964   leafActor[Actor::Property::POSITION]      = Vector3(100.0f, 50.0f, 30.0f);
11965
11966   leafActor[Actor::Property::INHERIT_POSITION] = false;
11967   leafActor[Actor::Property::INHERIT_SCALE]    = false;
11968
11969   application.GetScene().Add(rootActor);
11970   rootActor.Add(branchActor);
11971   branchActor.Add(leafActor);
11972
11973   application.SendNotification();
11974   application.Render(0);
11975   application.SendNotification();
11976   application.Render(0);
11977
11978   Matrix m = DevelActor::GetWorldTransform(leafActor);
11979
11980   Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11981   DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11982
11983   END_TEST;
11984 }
11985
11986 int UtcDaliActorCalculateWorldTransform07(void)
11987 {
11988   TestApplication application;
11989
11990   tet_infoline("Test that actor inheritance of scale produces right transform matrix");
11991
11992   Actor rootActor   = Actor::New();
11993   Actor branchActor = Actor::New();
11994   Actor leafActor   = Actor::New();
11995
11996   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
11997   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
11998   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11999
12000   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12001   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12002   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12003
12004   // Set anchor point to the same value as parent origin
12005   rootActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::CENTER;
12006   rootActor[Actor::Property::PARENT_ORIGIN]  = ParentOrigin::CENTER;
12007   branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
12008
12009   // This should be ignored.
12010   leafActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
12011   leafActor[Actor::Property::ANCHOR_POINT]  = AnchorPoint::CENTER;
12012
12013   branchActor[Actor::Property::POSITION]    = Vector3(100.0f, 30.0f, -50.0f);
12014   branchActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(45.0f), Vector3::XAXIS);
12015   leafActor[Actor::Property::POSITION]      = Vector3(100.0f, 50.0f, 30.0f);
12016
12017   leafActor[Actor::Property::INHERIT_POSITION]           = false;
12018   leafActor[Actor::Property::INHERIT_SCALE]              = false;
12019   leafActor[Actor::Property::POSITION_USES_ANCHOR_POINT] = false;
12020
12021   application.GetScene().Add(rootActor);
12022   rootActor.Add(branchActor);
12023   branchActor.Add(leafActor);
12024
12025   application.SendNotification();
12026   application.Render(0);
12027   application.SendNotification();
12028   application.Render(0);
12029
12030   Matrix m = DevelActor::GetWorldTransform(leafActor);
12031
12032   Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
12033   DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
12034
12035   END_TEST;
12036 }
12037
12038 int UtcDaliActorCalculateWorldTransform08(void)
12039 {
12040   TestApplication application;
12041
12042   tet_infoline("Test that actor inheritance of scale produces right transform matrix");
12043
12044   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)};
12045
12046   struct TestCase
12047   {
12048     bool translation;
12049     bool rotation;
12050     bool scaling;
12051   };
12052   TestCase testCases[] = {
12053     {false, false, true},
12054     {false, true, false},
12055     {true, false, false},
12056     {false, true, true},
12057     {true, false, true},
12058     {true, true, false},
12059     {false, false, false},
12060     {true, true, true},
12061   };
12062
12063   Actor rootActor = Actor::New();
12064   Actor leafActor = Actor::New();
12065
12066   rootActor[Actor::Property::POSITION]      = Vector3(0.0f, 0.0f, 0.0f);
12067   rootActor[Actor::Property::SCALE]         = Vector3(1.0f, 2.0f, 1.0f);
12068   rootActor[Actor::Property::ORIENTATION]   = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
12069   rootActor[Actor::Property::SIZE]          = Vector2(200, 400);
12070   rootActor[Actor::Property::ANCHOR_POINT]  = AnchorPoint::CENTER;
12071   rootActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
12072
12073   leafActor[Actor::Property::POSITION]                   = Vector3(0.0f, -50.0f, 0.0f);
12074   leafActor[Actor::Property::SCALE]                      = Vector3(1.0f, 1.0f, 1.0f);
12075   leafActor[Actor::Property::ORIENTATION]                = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
12076   leafActor[Actor::Property::SIZE]                       = Vector2(200, 400);
12077   leafActor[Actor::Property::ANCHOR_POINT]               = AnchorPoint::BOTTOM_CENTER;
12078   leafActor[Actor::Property::PARENT_ORIGIN]              = ParentOrigin::TOP_CENTER;
12079   leafActor[Actor::Property::POSITION_USES_ANCHOR_POINT] = true;
12080
12081   application.GetScene().Add(rootActor);
12082   rootActor.Add(leafActor);
12083
12084   for(uint32_t i = 0; i < 8; ++i)
12085   {
12086     leafActor[Actor::Property::INHERIT_POSITION]    = testCases[i].translation;
12087     leafActor[Actor::Property::INHERIT_ORIENTATION] = testCases[i].rotation;
12088     leafActor[Actor::Property::INHERIT_SCALE]       = testCases[i].scaling;
12089
12090     application.SendNotification();
12091     application.Render(0);
12092     application.SendNotification();
12093     application.Render(0);
12094
12095     Matrix m            = DevelActor::GetWorldTransform(leafActor);
12096     Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
12097
12098     Vector3 worldPosition1 = Vector3(m.GetTranslation());
12099     Vector3 worldPosition2 = Vector3(actualMatrix.GetTranslation());
12100
12101     DALI_TEST_EQUALS(solutions[i], worldPosition1, 0.001f, TEST_LOCATION);
12102     DALI_TEST_EQUALS(solutions[i], worldPosition2, 0.001f, TEST_LOCATION);
12103   }
12104
12105   END_TEST;
12106 }
12107
12108 int UtcDaliActorCalculateWorldColor01(void)
12109 {
12110   TestApplication application;
12111
12112   tet_infoline("Test that actor inheritance of color produces right final color");
12113
12114   Actor rootActor   = Actor::New();
12115   Actor branchActor = Actor::New();
12116   Actor leafActor   = Actor::New();
12117
12118   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
12119   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
12120   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
12121
12122   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12123   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12124   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12125
12126   rootActor[Actor::Property::COLOR] = Color::WHITE;
12127   Vector4 testColor1(1.0f, 1.0f, 0.5f, 0.8f);
12128   branchActor[Actor::Property::COLOR] = testColor1;
12129   leafActor[Actor::Property::COLOR]   = Vector4(0.1f, 0.5f, 0.5f, 0.8f);
12130
12131   // Default is to inherit:
12132   leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_OWN_MULTIPLY_PARENT_ALPHA;
12133
12134   application.GetScene().Add(rootActor);
12135   rootActor.Add(branchActor);
12136   branchActor.Add(leafActor);
12137
12138   application.SendNotification();
12139   application.Render(16);
12140   Vector4 color = branchActor.GetCurrentProperty<Vector4>(Actor::Property::COLOR);
12141   DALI_TEST_EQUALS(color, testColor1, TEST_LOCATION);
12142
12143   application.SendNotification();
12144   application.Render(16);
12145   color = branchActor.GetCurrentProperty<Vector4>(Actor::Property::COLOR);
12146   DALI_TEST_EQUALS(color, testColor1, TEST_LOCATION);
12147
12148   application.SendNotification();
12149   application.Render(16);
12150   color = branchActor.GetCurrentProperty<Vector4>(Actor::Property::COLOR);
12151   DALI_TEST_EQUALS(color, testColor1, TEST_LOCATION);
12152
12153   color = DevelActor::GetWorldColor(leafActor);
12154
12155   Vector4 actualColor = leafActor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR);
12156   DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION);
12157
12158   END_TEST;
12159 }
12160
12161 int UtcDaliActorCalculateWorldColor02(void)
12162 {
12163   TestApplication application;
12164
12165   tet_infoline("Test that actor uses own color");
12166
12167   Actor rootActor   = Actor::New();
12168   Actor branchActor = Actor::New();
12169   Actor leafActor   = Actor::New();
12170
12171   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
12172   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
12173   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
12174
12175   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12176   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12177   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12178
12179   rootActor[Actor::Property::COLOR]   = Color::WHITE;
12180   branchActor[Actor::Property::COLOR] = Vector4(1.0f, 1.0f, 0.5f, 0.8f);
12181   leafActor[Actor::Property::COLOR]   = Vector4(0.1f, 0.5f, 0.5f, 0.8f);
12182
12183   leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_OWN_COLOR;
12184
12185   application.GetScene().Add(rootActor);
12186   rootActor.Add(branchActor);
12187   branchActor.Add(leafActor);
12188
12189   application.SendNotification();
12190   application.Render(0);
12191
12192   Vector4 color = DevelActor::GetWorldColor(leafActor);
12193
12194   Vector4 actualColor = leafActor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR);
12195   DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION);
12196   DALI_TEST_EQUALS(color, Vector4(0.1f, 0.5f, 0.5f, 0.8f), 0.001f, TEST_LOCATION);
12197   END_TEST;
12198 }
12199
12200 int UtcDaliActorCalculateWorldColor03(void)
12201 {
12202   TestApplication application;
12203
12204   tet_infoline("Test that actor uses parent color");
12205
12206   Actor rootActor   = Actor::New();
12207   Actor branchActor = Actor::New();
12208   Actor leafActor   = Actor::New();
12209
12210   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
12211   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
12212   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
12213
12214   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12215   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12216   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12217
12218   rootActor[Actor::Property::COLOR]   = Color::WHITE * 0.9f;
12219   branchActor[Actor::Property::COLOR] = Vector4(1.0f, 1.0f, 0.5f, 0.8f);
12220   leafActor[Actor::Property::COLOR]   = Vector4(0.1f, 0.5f, 0.5f, 0.8f);
12221
12222   leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_PARENT_COLOR;
12223
12224   application.GetScene().Add(rootActor);
12225   rootActor.Add(branchActor);
12226   branchActor.Add(leafActor);
12227
12228   application.SendNotification();
12229   application.Render(0);
12230
12231   Vector4 color = DevelActor::GetWorldColor(leafActor);
12232
12233   Vector4 actualColor = leafActor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR);
12234   DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION);
12235   DALI_TEST_EQUALS(color, Vector4(1.0f, 1.0f, 0.5f, 0.72f), 0.001f, TEST_LOCATION);
12236   END_TEST;
12237 }
12238
12239 int UtcDaliActorCalculateWorldColor04(void)
12240 {
12241   TestApplication application;
12242
12243   tet_infoline("Test that actor blends with parent color");
12244
12245   Actor rootActor   = Actor::New();
12246   Actor branchActor = Actor::New();
12247   Actor leafActor   = Actor::New();
12248
12249   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
12250   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
12251   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
12252
12253   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12254   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12255   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12256
12257   rootActor[Actor::Property::COLOR]   = Color::WHITE * 0.9f;
12258   branchActor[Actor::Property::COLOR] = Vector4(1.0f, 1.0f, 0.5f, 0.8f);
12259   leafActor[Actor::Property::COLOR]   = Vector4(0.1f, 0.5f, 0.5f, 0.8f);
12260
12261   leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_OWN_MULTIPLY_PARENT_COLOR;
12262
12263   application.GetScene().Add(rootActor);
12264   rootActor.Add(branchActor);
12265   branchActor.Add(leafActor);
12266
12267   application.SendNotification();
12268   application.Render(0);
12269
12270   Vector4 color = DevelActor::GetWorldColor(leafActor);
12271
12272   Vector4 actualColor = leafActor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR);
12273   DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION);
12274
12275   END_TEST;
12276 }
12277
12278 int UtcDaliActorCalculateLookAt(void)
12279 {
12280   TestApplication application;
12281
12282   tet_infoline("Test that actor rotate right value of orientation");
12283
12284   Actor actor = Actor::New();
12285
12286   actor[Actor::Property::POSITION]      = Vector3(100.0f, 0.0f, 0.0f);
12287   actor[Actor::Property::ANCHOR_POINT]  = AnchorPoint::CENTER;
12288   actor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
12289
12290   application.GetScene().Add(actor);
12291
12292   application.SendNotification();
12293   application.Render(0);
12294
12295   Quaternion actorQuaternion;
12296
12297   tet_printf("Test with target only\n");
12298   Dali::DevelActor::LookAt(actor, Vector3::ZERO);
12299   actorQuaternion = actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
12300   DALI_TEST_EQUALS(actorQuaternion, Quaternion(Radian(Degree(90.0f)), Vector3::NEGATIVE_YAXIS), TEST_LOCATION);
12301
12302   tet_printf("Test with target + up\n");
12303   Dali::DevelActor::LookAt(actor, Vector3::ZERO, Vector3::ZAXIS);
12304   actorQuaternion = actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
12305   DALI_TEST_EQUALS(actorQuaternion, Quaternion(Radian(Degree(90.0f)), Vector3::XAXIS) * Quaternion(Radian(Degree(90.0f)), Vector3::NEGATIVE_YAXIS), TEST_LOCATION);
12306
12307   tet_printf("Test with target + up + localForward\n");
12308   Dali::DevelActor::LookAt(actor, Vector3::ZERO, Vector3::NEGATIVE_YAXIS, Vector3::NEGATIVE_XAXIS);
12309   actorQuaternion = actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
12310   DALI_TEST_EQUALS(actorQuaternion, Quaternion(Radian(Degree(180.0f)), Vector3::XAXIS), TEST_LOCATION);
12311
12312   tet_printf("Test with target + up + localForward + localUp\n");
12313   Dali::DevelActor::LookAt(actor, Vector3::ZERO, Vector3::NEGATIVE_YAXIS, Vector3::NEGATIVE_YAXIS, Vector3::XAXIS);
12314   actorQuaternion = actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
12315   DALI_TEST_EQUALS(actorQuaternion, Quaternion(Radian(Degree(90.0f)), Vector3::NEGATIVE_ZAXIS), TEST_LOCATION);
12316
12317   // Reset quaternion
12318   actor[Actor::Property::ORIENTATION] = Quaternion();
12319
12320   Actor actor2                           = Actor::New();
12321   actor2[Actor::Property::POSITION]      = Vector3(0.0f, 50.0f, -10.0f);
12322   actor2[Actor::Property::ANCHOR_POINT]  = AnchorPoint::CENTER;
12323   actor2[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
12324   actor.Add(actor2);
12325
12326   tet_printf("Test whether lookat calculate well by using event side values only\n");
12327   Dali::DevelActor::LookAt(actor2, Vector3(100.0f, 50.0f, 1.0f));
12328   actorQuaternion = actor2.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
12329   DALI_TEST_EQUALS(actorQuaternion, Quaternion(), TEST_LOCATION);
12330
12331   actor[Actor::Property::ORIENTATION] = Quaternion(Radian(Degree(90.0f)), Vector3::ZAXIS);
12332
12333   DALI_TEST_EQUALS(Dali::DevelActor::GetWorldTransform(actor2).GetTranslation3(), Vector3(50.0f, 0.0f, -10.0f), TEST_LOCATION);
12334
12335   tet_printf("Test whether lookat calculate well inherit by parent orientation\n");
12336   Dali::DevelActor::LookAt(actor2, Vector3(50.0f, 0.0f, 1.0f), Vector3::NEGATIVE_XAXIS);
12337   actorQuaternion = actor2.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
12338   DALI_TEST_EQUALS(actorQuaternion, Quaternion(), TEST_LOCATION);
12339
12340   END_TEST;
12341 }