Merge "Add BuildPickingRay to devel api" into devel/master
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Actor.cpp
1 /*
2  * Copyright (c) 2023 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // Enable debug log for test coverage
19 #define DEBUG_ENABLED 1
20
21 #include <dali-test-suite-utils.h>
22 #include <dali/devel-api/actors/actor-devel.h>
23 #include <dali/devel-api/common/capabilities.h>
24 #include <dali/integration-api/debug.h>
25 #include <dali/integration-api/events/hover-event-integ.h>
26 #include <dali/integration-api/events/touch-event-integ.h>
27 #include <dali/public-api/dali-core.h>
28 #include <mesh-builder.h>
29 #include <test-actor-utils.h>
30
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 } // anonymous namespace
349
350 //& purpose: Testing New API
351 int UtcDaliActorNew(void)
352 {
353   TestApplication application;
354
355   Actor actor = Actor::New();
356
357   DALI_TEST_CHECK(actor);
358   END_TEST;
359 }
360
361 //& purpose: Testing Dali::Actor::DownCast()
362 int UtcDaliActorDownCastP(void)
363 {
364   TestApplication application;
365   tet_infoline("Testing Dali::Actor::DownCast()");
366
367   Actor      actor = Actor::New();
368   BaseHandle object(actor);
369   Actor      actor2 = Actor::DownCast(object);
370   DALI_TEST_CHECK(actor2);
371   END_TEST;
372 }
373
374 //& purpose: Testing Dali::Actor::DownCast()
375 int UtcDaliActorDownCastN(void)
376 {
377   TestApplication application;
378   tet_infoline("Testing Dali::Actor::DownCast()");
379
380   BaseHandle unInitializedObject;
381   Actor      actor = Actor::DownCast(unInitializedObject);
382   DALI_TEST_CHECK(!actor);
383   END_TEST;
384 }
385
386 int UtcDaliActorMoveConstructor(void)
387 {
388   TestApplication application;
389
390   Actor actor = Actor::New();
391   DALI_TEST_CHECK(actor);
392
393   int id = actor.GetProperty<int>(Actor::Property::ID);
394
395   Actor moved = std::move(actor);
396   DALI_TEST_CHECK(moved);
397   DALI_TEST_EQUALS(id, moved.GetProperty<int>(Actor::Property::ID), TEST_LOCATION);
398   DALI_TEST_CHECK(!actor);
399
400   END_TEST;
401 }
402
403 int UtcDaliActorMoveAssignment(void)
404 {
405   TestApplication application;
406
407   Actor actor = Actor::New();
408   DALI_TEST_CHECK(actor);
409
410   int id = actor.GetProperty<int>(Actor::Property::ID);
411
412   Actor moved;
413   moved = std::move(actor);
414   DALI_TEST_CHECK(moved);
415   DALI_TEST_EQUALS(id, moved.GetProperty<int>(Actor::Property::ID), TEST_LOCATION);
416   DALI_TEST_CHECK(!actor);
417
418   END_TEST;
419 }
420
421 //& purpose: Testing Dali::Actor::GetName()
422 int UtcDaliActorGetName(void)
423 {
424   TestApplication application;
425
426   Actor actor = Actor::New();
427
428   DALI_TEST_CHECK(actor.GetProperty<std::string>(Actor::Property::NAME).empty());
429   END_TEST;
430 }
431
432 //& purpose: Testing Dali::Actor::SetName()
433 int UtcDaliActorSetName(void)
434 {
435   TestApplication application;
436
437   string str("ActorName");
438   Actor  actor = Actor::New();
439
440   actor.SetProperty(Actor::Property::NAME, str);
441   DALI_TEST_CHECK(actor.GetProperty<std::string>(Actor::Property::NAME) == str);
442   END_TEST;
443 }
444
445 int UtcDaliActorGetId(void)
446 {
447   tet_infoline("Testing Dali::Actor::UtcDaliActo.GetProperty< int >( Actor::Property::ID )");
448   TestApplication application;
449
450   Actor first  = Actor::New();
451   Actor second = Actor::New();
452   Actor third  = Actor::New();
453
454   DALI_TEST_CHECK(first.GetProperty<int>(Actor::Property::ID) != second.GetProperty<int>(Actor::Property::ID));
455   DALI_TEST_CHECK(second.GetProperty<int>(Actor::Property::ID) != third.GetProperty<int>(Actor::Property::ID));
456   END_TEST;
457 }
458
459 int UtcDaliActorIsRoot(void)
460 {
461   TestApplication application;
462
463   Actor actor = Actor::New();
464   DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::IS_ROOT));
465
466   // get the root layer
467   actor = application.GetScene().GetLayer(0);
468   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::IS_ROOT));
469   END_TEST;
470 }
471
472 int UtcDaliActorOnScene(void)
473 {
474   TestApplication application;
475
476   Actor actor = Actor::New();
477   DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
478
479   // get the root layer
480   actor = application.GetScene().GetLayer(0);
481   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
482   END_TEST;
483 }
484
485 int UtcDaliActorIsLayer(void)
486 {
487   TestApplication application;
488
489   Actor actor = Actor::New();
490   DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::IS_LAYER));
491
492   // get the root layer
493   actor = application.GetScene().GetLayer(0);
494   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::IS_LAYER));
495   END_TEST;
496 }
497
498 int UtcDaliActorGetLayer(void)
499 {
500   TestApplication application;
501
502   Actor actor = Actor::New();
503   application.GetScene().Add(actor);
504   Layer layer = actor.GetLayer();
505
506   DALI_TEST_CHECK(layer);
507
508   // get the root layers layer
509   actor = application.GetScene().GetLayer(0);
510   DALI_TEST_CHECK(actor.GetLayer());
511   END_TEST;
512 }
513
514 int UtcDaliActorAddP(void)
515 {
516   tet_infoline("Testing Actor::Add");
517   TestApplication application;
518
519   Actor parent = Actor::New();
520   Actor child  = Actor::New();
521
522   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
523
524   parent.Add(child);
525
526   DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
527
528   Actor parent2 = Actor::New();
529   parent2.Add(child);
530
531   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
532   DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
533
534   // try Adding to same parent again, works
535   parent2.Add(child);
536   DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
537
538   // try reparenting an orphaned child
539   {
540     Actor temporaryParent = Actor::New();
541     temporaryParent.Add(child);
542     DALI_TEST_EQUALS(parent2.GetChildCount(), 0u, TEST_LOCATION);
543   }
544   // temporaryParent has now died, reparent the orphaned child
545   parent2.Add(child);
546   DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
547
548   END_TEST;
549 }
550
551 int UtcDaliActorAddN(void)
552 {
553   tet_infoline("Testing Actor::Add");
554   TestApplication application;
555
556   Actor child = Actor::New();
557
558   Actor parent2 = Actor::New();
559   parent2.Add(child);
560
561   // try illegal Add
562   try
563   {
564     parent2.Add(parent2);
565     tet_printf("Assertion test failed - no Exception\n");
566     tet_result(TET_FAIL);
567   }
568   catch(Dali::DaliException& e)
569   {
570     DALI_TEST_PRINT_ASSERT(e);
571     DALI_TEST_ASSERT(e, "&mOwner != &child", TEST_LOCATION);
572     DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
573   }
574   catch(...)
575   {
576     tet_printf("Assertion test failed - wrong Exception\n");
577     tet_result(TET_FAIL);
578   }
579
580   // try reparenting root
581   try
582   {
583     parent2.Add(application.GetScene().GetLayer(0));
584     tet_printf("Assertion test failed - no Exception\n");
585     tet_result(TET_FAIL);
586   }
587   catch(Dali::DaliException& e)
588   {
589     DALI_TEST_PRINT_ASSERT(e);
590     DALI_TEST_ASSERT(e, "!child.IsRoot()", TEST_LOCATION);
591     DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
592   }
593   catch(...)
594   {
595     tet_printf("Assertion test failed - wrong Exception\n");
596     tet_result(TET_FAIL);
597   }
598
599   // try Add empty
600   try
601   {
602     Actor empty;
603     parent2.Add(empty);
604     tet_printf("Assertion test failed - no Exception\n");
605     tet_result(TET_FAIL);
606   }
607   catch(Dali::DaliException& e)
608   {
609     DALI_TEST_PRINT_ASSERT(e);
610     DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
611     DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
612   }
613   catch(...)
614   {
615     tet_printf("Assertion test failed - wrong Exception\n");
616     tet_result(TET_FAIL);
617   }
618
619   END_TEST;
620 }
621
622 int UtcDaliActorRemoveN(void)
623 {
624   tet_infoline("Testing Actor::Remove");
625   TestApplication application;
626
627   Actor parent = Actor::New();
628   Actor child  = Actor::New();
629   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
630
631   parent.Add(child);
632   DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
633
634   parent.Remove(child);
635   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
636
637   // remove again, no problem
638   parent.Remove(child);
639   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
640
641   // add child back
642   parent.Add(child);
643   DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
644   // try Remove self, its a no-op
645   parent.Remove(parent);
646   DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
647
648   // try Remove empty
649   try
650   {
651     Actor empty;
652     parent.Remove(empty);
653     tet_printf("Assertion test failed - no Exception\n");
654     tet_result(TET_FAIL);
655   }
656   catch(Dali::DaliException& e)
657   {
658     DALI_TEST_PRINT_ASSERT(e);
659     DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
660     DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
661   }
662   catch(...)
663   {
664     tet_printf("Assertion test failed - wrong Exception\n");
665     tet_result(TET_FAIL);
666   }
667   END_TEST;
668 }
669
670 int UtcDaliActorRemoveP(void)
671 {
672   TestApplication application;
673
674   Actor parent = Actor::New();
675   Actor child  = Actor::New();
676   Actor random = Actor::New();
677
678   application.GetScene().Add(parent);
679
680   DALI_TEST_CHECK(parent.GetChildCount() == 0);
681
682   parent.Add(child);
683
684   DALI_TEST_CHECK(parent.GetChildCount() == 1);
685
686   parent.Remove(random);
687
688   DALI_TEST_CHECK(parent.GetChildCount() == 1);
689
690   application.GetScene().Remove(parent);
691
692   DALI_TEST_CHECK(parent.GetChildCount() == 1);
693   END_TEST;
694 }
695
696 int UtcDaliActorSwitchParentN(void)
697 {
698   tet_infoline("Testing Actor::UtcDaliActorSwitchParentN");
699   TestApplication application;
700
701   Actor parent1 = Actor::New();
702   Actor child   = Actor::New();
703
704   DALI_TEST_EQUALS(parent1.GetChildCount(), 0u, TEST_LOCATION);
705
706   parent1.Add(child);
707
708   DALI_TEST_EQUALS(parent1.GetChildCount(), 1u, TEST_LOCATION);
709
710   Actor parent2 = Actor::New();
711
712   DALI_TEST_EQUALS(parent2.GetChildCount(), 0u, TEST_LOCATION);
713
714   // Try switch parent with that both of parent1 and parent2 are off scene.
715   DevelActor::SwitchParent(child, parent2);
716
717   DALI_TEST_EQUALS(parent1.GetChildCount(), 1u, TEST_LOCATION);
718   DALI_TEST_EQUALS(parent2.GetChildCount(), 0u, TEST_LOCATION);
719   END_TEST;
720 }
721
722 int UtcDaliActorGetChildCount(void)
723 {
724   TestApplication application;
725
726   Actor parent = Actor::New();
727   Actor child  = Actor::New();
728
729   DALI_TEST_CHECK(parent.GetChildCount() == 0);
730
731   parent.Add(child);
732
733   DALI_TEST_CHECK(parent.GetChildCount() == 1);
734   END_TEST;
735 }
736
737 int UtcDaliActorGetChildren01(void)
738 {
739   TestApplication application;
740
741   Actor parent = Actor::New();
742   Actor first  = Actor::New();
743   Actor second = Actor::New();
744   Actor third  = Actor::New();
745
746   parent.Add(first);
747   parent.Add(second);
748   parent.Add(third);
749
750   DALI_TEST_CHECK(parent.GetChildAt(0) == first);
751   DALI_TEST_CHECK(parent.GetChildAt(1) == second);
752   DALI_TEST_CHECK(parent.GetChildAt(2) == third);
753   END_TEST;
754 }
755
756 int UtcDaliActorGetChildren02(void)
757 {
758   TestApplication application;
759
760   Actor parent = Actor::New();
761   Actor first  = Actor::New();
762   Actor second = Actor::New();
763   Actor third  = Actor::New();
764
765   parent.Add(first);
766   parent.Add(second);
767   parent.Add(third);
768
769   const Actor& constParent = parent;
770
771   DALI_TEST_CHECK(constParent.GetChildAt(0) == first);
772   DALI_TEST_CHECK(constParent.GetChildAt(1) == second);
773   DALI_TEST_CHECK(constParent.GetChildAt(2) == third);
774   END_TEST;
775 }
776
777 int UtcDaliActorGetParent01(void)
778 {
779   TestApplication application;
780
781   Actor parent = Actor::New();
782   Actor child  = Actor::New();
783
784   parent.Add(child);
785
786   DALI_TEST_CHECK(child.GetParent() == parent);
787   END_TEST;
788 }
789
790 int UtcDaliActorGetParent02(void)
791 {
792   TestApplication application;
793
794   Actor actor = Actor::New();
795
796   DALI_TEST_CHECK(!actor.GetParent());
797   END_TEST;
798 }
799
800 int UtcDaliActorCustomProperty(void)
801 {
802   TestApplication application;
803
804   Actor actor = Actor::New();
805   application.GetScene().Add(actor);
806
807   float           startValue(1.0f);
808   Property::Index index = actor.RegisterProperty("testProperty", startValue);
809   DALI_TEST_CHECK(actor.GetProperty<float>(index) == startValue);
810
811   application.SendNotification();
812   application.Render(0);
813   DALI_TEST_CHECK(actor.GetProperty<float>(index) == startValue);
814
815   actor.SetProperty(index, 5.0f);
816
817   application.SendNotification();
818   application.Render(0);
819   DALI_TEST_CHECK(actor.GetProperty<float>(index) == 5.0f);
820   END_TEST;
821 }
822
823 int UtcDaliActorCustomPropertyIntToFloat(void)
824 {
825   TestApplication application;
826
827   Actor actor = Actor::New();
828   application.GetScene().Add(actor);
829
830   float           startValue(5.0f);
831   Property::Index index = actor.RegisterProperty("testProperty", startValue);
832   DALI_TEST_CHECK(actor.GetProperty<float>(index) == startValue);
833
834   application.SendNotification();
835   application.Render(0);
836   DALI_TEST_CHECK(actor.GetProperty<float>(index) == startValue);
837
838   actor.SetProperty(index, int(1));
839
840   application.SendNotification();
841   application.Render(0);
842   DALI_TEST_CHECK(actor.GetProperty<float>(index) == 1.0f);
843   END_TEST;
844 }
845
846 int UtcDaliActorCustomPropertyFloatToInt(void)
847 {
848   TestApplication application;
849
850   Actor actor = Actor::New();
851   application.GetScene().Add(actor);
852
853   int             startValue(5);
854   Property::Index index = actor.RegisterProperty("testProperty", startValue);
855   DALI_TEST_CHECK(actor.GetProperty<int>(index) == startValue);
856
857   application.SendNotification();
858   application.Render(0);
859   DALI_TEST_CHECK(actor.GetProperty<int>(index) == startValue);
860
861   actor.SetProperty(index, float(1.5));
862
863   application.SendNotification();
864   application.Render(0);
865   DALI_TEST_CHECK(actor.GetProperty<int>(index) == 1);
866   END_TEST;
867 }
868
869 int UtcDaliActorSetParentOrigin(void)
870 {
871   TestApplication application;
872
873   Actor actor = Actor::New();
874
875   Vector3 vector(0.7f, 0.8f, 0.9f);
876   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
877
878   actor.SetProperty(Actor::Property::PARENT_ORIGIN, vector);
879
880   // flush the queue and render once
881   application.SendNotification();
882   application.Render();
883
884   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
885
886   application.GetScene().Add(actor);
887
888   actor.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0.1f, 0.2f, 0.3f));
889
890   // flush the queue and render once
891   application.SendNotification();
892   application.Render();
893
894   DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), TEST_LOCATION);
895
896   application.GetScene().Remove(actor);
897   END_TEST;
898 }
899
900 int UtcDaliActorSetParentOriginIndividual(void)
901 {
902   TestApplication application;
903
904   Actor actor = Actor::New();
905
906   Vector3 vector(0.7f, 0.8f, 0.9f);
907   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
908
909   actor.SetProperty(Actor::Property::PARENT_ORIGIN_X, vector.x);
910
911   // flush the queue and render once
912   application.SendNotification();
913   application.Render();
914
915   DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN).x, TEST_LOCATION);
916
917   actor.SetProperty(Actor::Property::PARENT_ORIGIN_Y, vector.y);
918
919   // flush the queue and render once
920   application.SendNotification();
921   application.Render();
922
923   DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN).y, TEST_LOCATION);
924
925   actor.SetProperty(Actor::Property::PARENT_ORIGIN_Z, vector.z);
926
927   // flush the queue and render once
928   application.SendNotification();
929   application.Render();
930
931   DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN).z, TEST_LOCATION);
932
933   END_TEST;
934 }
935
936 int UtcDaliActorGetCurrentParentOrigin(void)
937 {
938   TestApplication application;
939
940   Actor actor = Actor::New();
941
942   Vector3 vector(0.7f, 0.8f, 0.9f);
943   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
944
945   actor.SetProperty(Actor::Property::PARENT_ORIGIN, vector);
946
947   // flush the queue and render once
948   application.SendNotification();
949   application.Render();
950
951   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
952   END_TEST;
953 }
954
955 int UtcDaliActorSetAnchorPoint(void)
956 {
957   TestApplication application;
958
959   Actor actor = Actor::New();
960
961   Vector3 vector(0.7f, 0.8f, 0.9f);
962   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
963
964   actor.SetProperty(Actor::Property::ANCHOR_POINT, vector);
965
966   // flush the queue and render once
967   application.SendNotification();
968   application.Render();
969
970   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
971
972   application.GetScene().Add(actor);
973
974   actor.SetProperty(Actor::Property::ANCHOR_POINT, Vector3(0.1f, 0.2f, 0.3f));
975   // flush the queue and render once
976   application.SendNotification();
977   application.Render();
978
979   DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), TEST_LOCATION);
980
981   application.GetScene().Remove(actor);
982   END_TEST;
983 }
984
985 int UtcDaliActorSetAnchorPointIndividual(void)
986 {
987   TestApplication application;
988
989   Actor actor = Actor::New();
990
991   Vector3 vector(0.7f, 0.8f, 0.9f);
992   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
993
994   actor.SetProperty(Actor::Property::ANCHOR_POINT_X, vector.x);
995
996   // flush the queue and render once
997   application.SendNotification();
998   application.Render();
999
1000   DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT).x, TEST_LOCATION);
1001
1002   actor.SetProperty(Actor::Property::ANCHOR_POINT_Y, vector.y);
1003
1004   // flush the queue and render once
1005   application.SendNotification();
1006   application.Render();
1007
1008   DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT).y, TEST_LOCATION);
1009
1010   actor.SetProperty(Actor::Property::ANCHOR_POINT_Z, vector.z);
1011
1012   // flush the queue and render once
1013   application.SendNotification();
1014   application.Render();
1015
1016   DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT).z, TEST_LOCATION);
1017
1018   END_TEST;
1019 }
1020
1021 int UtcDaliActorGetCurrentAnchorPoint(void)
1022 {
1023   TestApplication application;
1024
1025   Actor actor = Actor::New();
1026
1027   Vector3 vector(0.7f, 0.8f, 0.9f);
1028   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
1029
1030   actor.SetProperty(Actor::Property::ANCHOR_POINT, vector);
1031
1032   // flush the queue and render once
1033   application.SendNotification();
1034   application.Render();
1035
1036   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
1037   END_TEST;
1038 }
1039
1040 int UtcDaliActorSetSize01(void)
1041 {
1042   TestApplication application;
1043
1044   Actor   actor = Actor::New();
1045   Vector3 vector(100.0f, 100.0f, 0.0f);
1046
1047   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1048
1049   actor.SetProperty(Actor::Property::SIZE, Vector2(vector.x, vector.y));
1050
1051   // Immediately retrieve the size after setting
1052   Vector3 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1053   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1054   DALI_TEST_EQUALS(vector.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
1055   DALI_TEST_EQUALS(vector.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
1056   DALI_TEST_EQUALS(vector.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
1057
1058   // Flush the queue and render once
1059   application.SendNotification();
1060   application.Render();
1061
1062   // Check the size in the new frame
1063   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1064
1065   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1066   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1067   DALI_TEST_EQUALS(vector.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
1068   DALI_TEST_EQUALS(vector.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
1069   DALI_TEST_EQUALS(vector.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
1070
1071   // Check async behaviour
1072   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
1073   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1074   DALI_TEST_EQUALS(vector.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
1075   DALI_TEST_EQUALS(vector.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
1076   DALI_TEST_EQUALS(vector.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
1077
1078   // Change the resize policy and check whether the size stays the same
1079   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
1080
1081   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1082   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1083
1084   // Set a new size after resize policy is changed and check the new size
1085   actor.SetProperty(Actor::Property::SIZE, Vector3(0.1f, 0.2f, 0.0f));
1086
1087   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1088   DALI_TEST_EQUALS(currentSize, Vector3(0.1f, 0.2f, 0.0f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1089
1090   // Change the resize policy again and check whether the new size stays the same
1091   actor.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
1092
1093   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1094   DALI_TEST_EQUALS(currentSize, Vector3(0.1f, 0.2f, 0.0f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1095
1096   // Set another new size after resize policy is changed and check the new size
1097   actor.SetProperty(Actor::Property::SIZE, Vector3(50.0f, 60.0f, 0.0f));
1098
1099   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1100   DALI_TEST_EQUALS(currentSize, Vector3(50.0f, 60.0f, 0.0f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1101
1102   END_TEST;
1103 }
1104
1105 int UtcDaliActorSetSize02(void)
1106 {
1107   TestApplication application;
1108
1109   Actor   actor = Actor::New();
1110   Vector3 vector(100.0f, 100.0f, 100.0f);
1111
1112   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1113
1114   actor.SetProperty(Actor::Property::SIZE, Vector3(vector.x, vector.y, vector.z));
1115
1116   // Immediately check the size after setting
1117   Vector3 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1118   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1119
1120   // flush the queue and render once
1121   application.SendNotification();
1122   application.Render();
1123
1124   // Check the size in the new frame
1125   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1126
1127   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1128   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1129
1130   END_TEST;
1131 }
1132
1133 // SetSize(Vector2 size)
1134 int UtcDaliActorSetSize03(void)
1135 {
1136   TestApplication application;
1137
1138   Actor   actor = Actor::New();
1139   Vector3 vector(100.0f, 100.0f, 0.0f);
1140
1141   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1142
1143   actor.SetProperty(Actor::Property::SIZE, Vector2(vector.x, vector.y));
1144
1145   // Immediately check the size after setting
1146   Vector3 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1147   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1148
1149   // flush the queue and render once
1150   application.SendNotification();
1151   application.Render();
1152
1153   // Check the size in the new frame
1154   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1155
1156   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1157   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1158
1159   END_TEST;
1160 }
1161
1162 // SetSize(Vector3 size)
1163 int UtcDaliActorSetSize04(void)
1164 {
1165   TestApplication application;
1166
1167   Actor   actor = Actor::New();
1168   Vector3 vector(100.0f, 100.0f, 100.0f);
1169
1170   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1171
1172   actor.SetProperty(Actor::Property::SIZE, vector);
1173
1174   // Immediately check the size after setting
1175   Vector3 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1176   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1177
1178   // flush the queue and render once
1179   application.SendNotification();
1180   application.Render();
1181
1182   // Check the size in the new frame
1183   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1184
1185   application.GetScene().Add(actor);
1186   actor.SetProperty(Actor::Property::SIZE, Vector3(0.1f, 0.2f, 0.3f));
1187
1188   // Immediately check the size after setting
1189   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1190   DALI_TEST_EQUALS(currentSize, Vector3(0.1f, 0.2f, 0.3f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1191
1192   // flush the queue and render once
1193   application.SendNotification();
1194   application.Render();
1195
1196   // Check the size in the new frame
1197   DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE), TEST_LOCATION);
1198
1199   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1200   DALI_TEST_EQUALS(currentSize, Vector3(0.1f, 0.2f, 0.3f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1201
1202   application.GetScene().Remove(actor);
1203   END_TEST;
1204 }
1205
1206 int UtcDaliActorSetSize05(void)
1207 {
1208   TestApplication application;
1209
1210   Actor   parent = Actor::New();
1211   Vector2 vector(200.0f, 200.0f);
1212   DALI_TEST_CHECK(vector != parent.GetCurrentProperty<Vector2>(Actor::Property::SIZE));
1213
1214   parent.SetProperty(Actor::Property::SIZE, vector);
1215   Vector2 size = parent.GetProperty(Actor::Property::SIZE).Get<Vector2>();
1216   DALI_TEST_EQUALS(size, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1217
1218   Actor child = Actor::New();
1219   DALI_TEST_CHECK(vector != child.GetCurrentProperty<Vector2>(Actor::Property::SIZE));
1220   child.SetProperty(Actor::Property::SIZE, vector);
1221   size = parent.GetProperty(Actor::Property::SIZE).Get<Vector2>();
1222   DALI_TEST_EQUALS(size, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1223
1224   // flush the queue and render once
1225   application.SendNotification();
1226   application.Render();
1227
1228   DALI_TEST_CHECK(vector == parent.GetCurrentProperty<Vector2>(Actor::Property::SIZE));
1229
1230   END_TEST;
1231 }
1232
1233 int UtcDaliActorSetSizeIndividual(void)
1234 {
1235   TestApplication application;
1236
1237   Actor actor = Actor::New();
1238
1239   Vector3 vector(0.7f, 0.8f, 0.9f);
1240   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1241
1242   actor.SetProperty(Actor::Property::SIZE_WIDTH, vector.width);
1243
1244   // Immediately check the width after setting
1245   float sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1246   DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1247
1248   // flush the queue and render once
1249   application.SendNotification();
1250   application.Render();
1251
1252   // Check the width in the new frame
1253   DALI_TEST_EQUALS(vector.width, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, TEST_LOCATION);
1254
1255   sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1256   DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1257
1258   actor.SetProperty(Actor::Property::SIZE_HEIGHT, vector.height);
1259
1260   // Immediately check the height after setting
1261   float sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1262   DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1263
1264   // flush the queue and render once
1265   application.SendNotification();
1266   application.Render();
1267
1268   // Check the height in the new frame
1269   DALI_TEST_EQUALS(vector.height, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, TEST_LOCATION);
1270
1271   sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1272   DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1273
1274   actor.SetProperty(Actor::Property::SIZE_DEPTH, vector.depth);
1275
1276   // Immediately check the depth after setting
1277   float sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1278   DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1279
1280   // flush the queue and render once
1281   application.SendNotification();
1282   application.Render();
1283
1284   // Check the depth in the new frame
1285   DALI_TEST_EQUALS(vector.depth, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).depth, TEST_LOCATION);
1286
1287   sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1288   DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1289
1290   // Change the resize policy and check whether the size stays the same
1291   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
1292
1293   sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1294   DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1295
1296   sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1297   DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1298
1299   sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1300   DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1301
1302   // Change the resize policy again and check whether the size stays the same
1303   actor.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
1304
1305   sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1306   DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1307
1308   sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1309   DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1310
1311   sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1312   DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1313
1314   END_TEST;
1315 }
1316
1317 int UtcDaliActorSetSizeIndividual02(void)
1318 {
1319   TestApplication application;
1320
1321   Actor actor = Actor::New();
1322   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
1323   application.GetScene().Add(actor);
1324
1325   Vector3 vector(100.0f, 200.0f, 400.0f);
1326   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1327
1328   actor.SetProperty(Actor::Property::SIZE_WIDTH, vector.width);
1329   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>(), vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1330
1331   actor.SetProperty(Actor::Property::SIZE_HEIGHT, vector.height);
1332   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>(), vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1333
1334   actor.SetProperty(Actor::Property::SIZE_DEPTH, vector.depth);
1335   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>(), vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1336
1337   // flush the queue and render once
1338   application.SendNotification();
1339   application.Render();
1340
1341   // Check the width in the new frame
1342   DALI_TEST_EQUALS(vector.width, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, TEST_LOCATION);
1343   DALI_TEST_EQUALS(vector.height, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, TEST_LOCATION);
1344
1345   END_TEST;
1346 }
1347
1348 int UtcDaliActorGetCurrentSize(void)
1349 {
1350   TestApplication application;
1351
1352   Actor   actor = Actor::New();
1353   Vector3 vector(100.0f, 100.0f, 20.0f);
1354
1355   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1356
1357   actor.SetProperty(Actor::Property::SIZE, vector);
1358
1359   // flush the queue and render once
1360   application.SendNotification();
1361   application.Render();
1362
1363   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1364   END_TEST;
1365 }
1366
1367 int UtcDaliActorGetNaturalSize(void)
1368 {
1369   TestApplication application;
1370
1371   Actor   actor = Actor::New();
1372   Vector3 vector(0.0f, 0.0f, 0.0f);
1373
1374   DALI_TEST_CHECK(actor.GetNaturalSize() == vector);
1375
1376   END_TEST;
1377 }
1378
1379 int UtcDaliActorGetCurrentSizeImmediate(void)
1380 {
1381   TestApplication application;
1382
1383   Actor   actor = Actor::New();
1384   Vector3 vector(100.0f, 100.0f, 20.0f);
1385
1386   DALI_TEST_CHECK(vector != actor.GetTargetSize());
1387   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1388
1389   actor.SetProperty(Actor::Property::SIZE, vector);
1390
1391   DALI_TEST_CHECK(vector == actor.GetTargetSize());
1392   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1393
1394   // flush the queue and render once
1395   application.SendNotification();
1396   application.Render();
1397
1398   DALI_TEST_CHECK(vector == actor.GetTargetSize());
1399   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1400
1401   // Animation
1402   // Build the animation
1403   const float   durationSeconds = 2.0f;
1404   Animation     animation       = Animation::New(durationSeconds);
1405   const Vector3 targetValue(10.0f, 20.0f, 30.0f);
1406   animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
1407
1408   DALI_TEST_CHECK(actor.GetTargetSize() == vector);
1409
1410   application.GetScene().Add(actor);
1411
1412   // Start the animation
1413   animation.Play();
1414
1415   application.SendNotification();
1416   application.Render(static_cast<unsigned int>(durationSeconds * 1000.0f));
1417
1418   DALI_TEST_CHECK(actor.GetTargetSize() == targetValue);
1419
1420   END_TEST;
1421 }
1422
1423 int UtcDaliActorCalculateScreenExtents(void)
1424 {
1425   TestApplication application;
1426
1427   Actor actor = Actor::New();
1428
1429   actor.SetProperty(Actor::Property::POSITION, Vector3(2.0f, 2.0f, 16.0f));
1430   actor.SetProperty(Actor::Property::SIZE, Vector3{1.0f, 1.0f, 1.0f});
1431
1432   application.GetScene().Add(actor);
1433
1434   application.SendNotification();
1435   application.Render();
1436
1437   auto expectedExtent = Rect<>{1.5f, 1.5f, 1.0f, 1.0f};
1438   auto actualExtent   = DevelActor::CalculateScreenExtents(actor);
1439   DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1440   DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1441   DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1442   DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1443
1444   application.GetScene().Remove(actor);
1445   END_TEST;
1446 }
1447
1448 int UtcDaliActorCalculateScreenExtentsInCustomCameraAndLayer3D(void)
1449 {
1450   TestApplication    application;
1451   Integration::Scene scene = application.GetScene();
1452
1453   // Make 3D Layer
1454   Layer layer = Layer::New();
1455   layer.SetProperty(Layer::Property::BEHAVIOR, Layer::Behavior::LAYER_3D);
1456   layer.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1457   layer.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1458
1459   scene.Add(layer);
1460
1461   // Build custom camera with top-view
1462   CameraActor cameraActor = scene.GetRenderTaskList().GetTask(0).GetCameraActor();
1463   {
1464     // Default camera position at +z and looking -z axis. (orientation is [ Axis: [0, 1, 0], Angle: 180 degrees ])
1465     Vector3    cameraPos    = cameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
1466     Quaternion cameraOrient = cameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
1467
1468     {
1469       std::ostringstream oss;
1470       oss << cameraPos << "\n";
1471       oss << cameraOrient << "\n";
1472       tet_printf("%s\n", oss.str().c_str());
1473     }
1474
1475     cameraActor.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -cameraPos.z, 0.0f));
1476     cameraActor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::XAXIS) * cameraOrient);
1477
1478     // Now, upside : -Z, leftside : -X, foward : +Y
1479
1480     cameraPos    = cameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
1481     cameraOrient = cameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
1482     {
1483       std::ostringstream oss;
1484       oss << cameraPos << "\n";
1485       oss << cameraOrient << "\n";
1486       tet_printf("%s\n", oss.str().c_str());
1487     }
1488   }
1489
1490   Actor actor = Actor::New();
1491   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1492   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1493   actor.SetProperty(Actor::Property::POSITION, Vector3(2.0f, 0.0f, 16.0f));
1494   actor.SetProperty(Actor::Property::SIZE, Vector3{1.0f, 0.0f, 3.0f});
1495
1496   layer.Add(actor);
1497
1498   application.SendNotification();
1499   application.Render();
1500
1501   Vector2 sceneSize = scene.GetSize();
1502
1503   auto expectedExtent = Rect<>{sceneSize.x * 0.5f + 1.5f, sceneSize.y * 0.5f + 14.5f, 1.0f, 3.0f};
1504   auto actualExtent   = DevelActor::CalculateScreenExtents(actor);
1505   {
1506     std::ostringstream oss;
1507     oss << expectedExtent << "\n";
1508     oss << actualExtent << "\n";
1509     tet_printf("%s\n", oss.str().c_str());
1510   }
1511
1512   DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1513   DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1514   DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1515   DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1516
1517   END_TEST;
1518 }
1519
1520 int UtcDaliActorCalculateScreenInCustomCameraAndOffscreenLayer3D(void)
1521 {
1522   // TODO : Need to make it works well
1523   TestApplication    application;
1524   Integration::Scene scene     = application.GetScene();
1525   Vector2            sceneSize = scene.GetSize();
1526
1527   // Make 3D Layer
1528   Layer layer = Layer::New();
1529   layer.SetProperty(Layer::Property::BEHAVIOR, Layer::Behavior::LAYER_3D);
1530   layer.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1531   layer.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1532   layer.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
1533   layer.SetProperty(Actor::Property::SIZE, sceneSize);
1534
1535   scene.Add(layer);
1536
1537   // Build custom camera with top-view
1538   CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
1539
1540   offscreenCameraActor.SetPerspectiveProjection(sceneSize);
1541   offscreenCameraActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1542   offscreenCameraActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1543
1544   scene.Add(offscreenCameraActor);
1545   {
1546     // Default camera position at +z and looking -z axis. (orientation is [ Axis: [0, 1, 0], Angle: 180 degrees ])
1547     Vector3    cameraPos    = offscreenCameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
1548     Quaternion cameraOrient = offscreenCameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
1549
1550     {
1551       std::ostringstream oss;
1552       oss << cameraPos << "\n";
1553       oss << cameraOrient << "\n";
1554       tet_printf("%s\n", oss.str().c_str());
1555     }
1556
1557     offscreenCameraActor.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -cameraPos.z, 0.0f));
1558     offscreenCameraActor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::XAXIS) * cameraOrient);
1559
1560     // Now, upside : -Z, leftside : -X, foward : +Y
1561
1562     cameraPos    = offscreenCameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
1563     cameraOrient = offscreenCameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
1564     {
1565       std::ostringstream oss;
1566       oss << cameraPos << "\n";
1567       oss << cameraOrient << "\n";
1568       tet_printf("%s\n", oss.str().c_str());
1569     }
1570   }
1571   Vector3 sourcePosition{2.0f, 0.0f, 16.0f};
1572   Vector3 sourceSize{1.0f, 0.0f, 3.0f};
1573
1574   Actor sourceActor = Actor::New();
1575   sourceActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1576   sourceActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1577   sourceActor.SetProperty(Actor::Property::POSITION, sourcePosition);
1578   sourceActor.SetProperty(Actor::Property::SIZE, sourceSize);
1579
1580   layer.Add(sourceActor);
1581
1582   // Create framebuffer
1583   unsigned int width(64);
1584   unsigned int height(64);
1585   Texture      texture     = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
1586   FrameBuffer  frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::DEPTH_STENCIL);
1587   frameBuffer.AttachColorTexture(texture);
1588
1589   Actor rootActor = Actor::New();
1590   rootActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1591   rootActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1592   rootActor.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
1593   rootActor.SetProperty(Actor::Property::SIZE, sceneSize);
1594   scene.Add(rootActor);
1595
1596   RenderTaskList taskList = scene.GetRenderTaskList();
1597   RenderTask     newTask  = taskList.CreateTask();
1598   newTask.SetCameraActor(offscreenCameraActor);
1599   newTask.SetSourceActor(layer);
1600   newTask.SetInputEnabled(false);
1601   newTask.SetClearColor(Vector4(0.f, 0.f, 0.f, 0.f));
1602   newTask.SetClearEnabled(true);
1603   newTask.SetExclusive(true);
1604   newTask.SetFrameBuffer(frameBuffer);
1605   newTask.SetScreenToFrameBufferMappingActor(rootActor);
1606
1607   application.SendNotification();
1608   application.Render(16u);
1609
1610   auto expectedExtent = Rect<>{sceneSize.x * 0.5f + sourcePosition.x - sourceSize.x * 0.5f,
1611                                sceneSize.y * 0.5f + sourcePosition.z - sourceSize.z * 0.5f,
1612                                sourceSize.x,
1613                                sourceSize.z};
1614   auto actualExtent   = DevelActor::CalculateScreenExtents(sourceActor);
1615   {
1616     std::ostringstream oss;
1617     oss << expectedExtent << "\n";
1618     oss << actualExtent << "\n";
1619     tet_printf("%s\n", oss.str().c_str());
1620   }
1621
1622   auto expectedScreen = Vector2{sceneSize.x * 0.5f + sourcePosition.x, sceneSize.y * 0.5f + sourcePosition.z};
1623   auto actualScreen   = sourceActor.GetProperty<Vector2>(Actor::Property::SCREEN_POSITION);
1624   {
1625     std::ostringstream oss;
1626     oss << expectedScreen << "\n";
1627     oss << actualScreen << "\n";
1628     tet_printf("%s\n", oss.str().c_str());
1629   }
1630
1631   DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1632   DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1633   DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1634   DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1635
1636   DALI_TEST_EQUALS(expectedScreen.x, actualScreen.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1637   DALI_TEST_EQUALS(expectedScreen.y, actualScreen.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1638
1639   // Change rootActor's size and position
1640
1641   Vector3 rootPosition{100.0f, 200.0f, 0.0f};
1642   Vector3 rootSize{200.0f, 100.0f, 0.0f};
1643
1644   rootActor.SetProperty(Actor::Property::POSITION, rootPosition);
1645   rootActor.SetProperty(Actor::Property::SIZE, rootSize);
1646
1647   application.SendNotification();
1648   application.Render(16u);
1649
1650   expectedExtent = Rect<>{sceneSize.x * 0.5f + rootPosition.x + (sourcePosition.x - sourceSize.x * 0.5f) * rootSize.x / sceneSize.x,
1651                           sceneSize.y * 0.5f + rootPosition.y + (sourcePosition.z - sourceSize.z * 0.5f) * rootSize.y / sceneSize.y,
1652                           sourceSize.x * rootSize.x / sceneSize.x,
1653                           sourceSize.z * rootSize.y / sceneSize.y};
1654   actualExtent   = DevelActor::CalculateScreenExtents(sourceActor);
1655   {
1656     std::ostringstream oss;
1657     oss << expectedExtent << "\n";
1658     oss << actualExtent << "\n";
1659     tet_printf("%s\n", oss.str().c_str());
1660   }
1661
1662   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};
1663   actualScreen   = sourceActor.GetProperty<Vector2>(Actor::Property::SCREEN_POSITION);
1664   {
1665     std::ostringstream oss;
1666     oss << expectedScreen << "\n";
1667     oss << actualScreen << "\n";
1668     tet_printf("%s\n", oss.str().c_str());
1669   }
1670
1671   DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1672   DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1673   DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1674   DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1675
1676   DALI_TEST_EQUALS(expectedScreen.x, actualScreen.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1677   DALI_TEST_EQUALS(expectedScreen.y, actualScreen.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1678
1679   END_TEST;
1680 }
1681
1682 // SetPosition(float x, float y)
1683 int UtcDaliActorSetPosition01(void)
1684 {
1685   TestApplication application;
1686
1687   Actor actor = Actor::New();
1688
1689   // Set to random to start off with
1690   actor.SetProperty(Actor::Property::POSITION, Vector3(120.0f, 120.0f, 0.0f));
1691
1692   Vector3 vector(100.0f, 100.0f, 0.0f);
1693
1694   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1695
1696   actor.SetProperty(Actor::Property::POSITION, Vector2(vector.x, vector.y));
1697   // flush the queue and render once
1698   application.SendNotification();
1699   application.Render();
1700   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1701
1702   application.GetScene().Add(actor);
1703   actor.SetProperty(Actor::Property::POSITION, Vector3(0.1f, 0.2f, 0.3f));
1704   // flush the queue and render once
1705   application.SendNotification();
1706   application.Render();
1707   DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
1708
1709   actor.SetProperty(Actor::Property::POSITION_X, 1.0f);
1710   actor.SetProperty(Actor::Property::POSITION_Y, 1.1f);
1711   actor.SetProperty(Actor::Property::POSITION_Z, 1.2f);
1712   // flush the queue and render once
1713   application.SendNotification();
1714   application.Render();
1715   DALI_TEST_EQUALS(Vector3(1.0f, 1.1f, 1.2f), actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
1716
1717   actor.TranslateBy(Vector3(0.1f, 0.1f, 0.1f));
1718   // flush the queue and render once
1719   application.SendNotification();
1720   application.Render();
1721   DALI_TEST_EQUALS(Vector3(1.1f, 1.2f, 1.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1722
1723   application.GetScene().Remove(actor);
1724   END_TEST;
1725 }
1726
1727 // SetPosition(float x, float y, float z)
1728 int UtcDaliActorSetPosition02(void)
1729 {
1730   TestApplication application;
1731
1732   Actor actor = Actor::New();
1733
1734   // Set to random to start off with
1735   actor.SetProperty(Actor::Property::POSITION, Vector3(120.0f, 120.0f, 120.0f));
1736
1737   Vector3 vector(100.0f, 100.0f, 100.0f);
1738
1739   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1740
1741   actor.SetProperty(Actor::Property::POSITION, Vector3(vector.x, vector.y, vector.z));
1742
1743   // flush the queue and render once
1744   application.SendNotification();
1745   application.Render();
1746
1747   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1748   END_TEST;
1749 }
1750
1751 // SetPosition(Vector3 position)
1752 int UtcDaliActorSetPosition03(void)
1753 {
1754   TestApplication application;
1755
1756   Actor actor = Actor::New();
1757
1758   // Set to random to start off with
1759   actor.SetProperty(Actor::Property::POSITION, Vector3(120.0f, 120.0f, 120.0f));
1760
1761   Vector3 vector(100.0f, 100.0f, 100.0f);
1762
1763   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1764
1765   actor.SetProperty(Actor::Property::POSITION, vector);
1766
1767   // flush the queue and render once
1768   application.SendNotification();
1769   application.Render();
1770
1771   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1772   END_TEST;
1773 }
1774
1775 int UtcDaliActorSetX(void)
1776 {
1777   TestApplication application;
1778
1779   Actor actor = Actor::New();
1780
1781   Vector3 vector(100.0f, 0.0f, 0.0f);
1782
1783   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1784
1785   actor.SetProperty(Actor::Property::POSITION_X, 100.0f);
1786
1787   // flush the queue and render once
1788   application.SendNotification();
1789   application.Render();
1790
1791   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1792   END_TEST;
1793 }
1794
1795 int UtcDaliActorSetY(void)
1796 {
1797   TestApplication application;
1798
1799   Actor actor = Actor::New();
1800
1801   Vector3 vector(0.0f, 100.0f, 0.0f);
1802
1803   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1804
1805   actor.SetProperty(Actor::Property::POSITION_Y, 100.0f);
1806
1807   // flush the queue and render once
1808   application.SendNotification();
1809   application.Render();
1810
1811   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1812   END_TEST;
1813 }
1814
1815 int UtcDaliActorSetZ(void)
1816 {
1817   TestApplication application;
1818
1819   Actor actor = Actor::New();
1820
1821   Vector3 vector(0.0f, 0.0f, 100.0f);
1822
1823   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1824
1825   actor.SetProperty(Actor::Property::POSITION_Z, 100.0f);
1826
1827   // flush the queue and render once
1828   application.SendNotification();
1829   application.Render();
1830
1831   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1832   END_TEST;
1833 }
1834
1835 int UtcDaliActorSetPositionProperties(void)
1836 {
1837   TestApplication application;
1838
1839   Actor actor = Actor::New();
1840
1841   Vector3 vector(0.7f, 0.8f, 0.9f);
1842   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1843
1844   actor.SetProperty(Actor::Property::POSITION_X, vector.x);
1845   DALI_TEST_EQUALS(vector.x, actor.GetProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1846   DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::POSITION_X), TEST_LOCATION);
1847
1848   // flush the queue and render once
1849   application.SendNotification();
1850   application.Render();
1851
1852   DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1853   DALI_TEST_EQUALS(vector.x, actor.GetProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1854   DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::POSITION_X), TEST_LOCATION);
1855   DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1856   DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<float>(Actor::Property::POSITION_X), TEST_LOCATION);
1857
1858   actor.SetProperty(Actor::Property::POSITION_Y, vector.y);
1859   DALI_TEST_EQUALS(vector.y, actor.GetProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1860   DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::POSITION_Y), TEST_LOCATION);
1861
1862   // flush the queue and render once
1863   application.SendNotification();
1864   application.Render();
1865
1866   DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1867   DALI_TEST_EQUALS(vector.y, actor.GetProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1868   DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::POSITION_Y), TEST_LOCATION);
1869   DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1870   DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<float>(Actor::Property::POSITION_Y), TEST_LOCATION);
1871
1872   actor.SetProperty(Actor::Property::POSITION_Z, vector.z);
1873   DALI_TEST_EQUALS(vector.z, actor.GetProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1874   DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::POSITION_Z), TEST_LOCATION);
1875
1876   // flush the queue and render once
1877   application.SendNotification();
1878   application.Render();
1879
1880   DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1881   DALI_TEST_EQUALS(vector.z, actor.GetProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1882   DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::POSITION_Z), TEST_LOCATION);
1883   DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1884   DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<float>(Actor::Property::POSITION_Z), TEST_LOCATION);
1885
1886   END_TEST;
1887 }
1888
1889 int UtcDaliActorTranslateBy(void)
1890 {
1891   TestApplication application;
1892
1893   Actor   actor = Actor::New();
1894   Vector3 vector(100.0f, 100.0f, 100.0f);
1895
1896   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1897
1898   actor.SetProperty(Actor::Property::POSITION, vector);
1899
1900   // flush the queue and render once
1901   application.SendNotification();
1902   application.Render();
1903
1904   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1905
1906   actor.TranslateBy(vector);
1907
1908   // flush the queue and render once
1909   application.SendNotification();
1910   application.Render();
1911
1912   DALI_TEST_CHECK(vector * 2.0f == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1913   END_TEST;
1914 }
1915
1916 int UtcDaliActorGetCurrentPosition(void)
1917 {
1918   TestApplication application;
1919
1920   Actor   actor = Actor::New();
1921   Vector3 setVector(100.0f, 100.0f, 0.0f);
1922   actor.SetProperty(Actor::Property::POSITION, setVector);
1923
1924   // flush the queue and render once
1925   application.SendNotification();
1926   application.Render();
1927
1928   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION) == setVector);
1929   END_TEST;
1930 }
1931
1932 int UtcDaliActorGetCurrentWorldPosition(void)
1933 {
1934   TestApplication application;
1935
1936   Actor   parent = Actor::New();
1937   Vector3 parentPosition(1.0f, 2.0f, 3.0f);
1938   parent.SetProperty(Actor::Property::POSITION, parentPosition);
1939   parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1940   parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1941   application.GetScene().Add(parent);
1942
1943   Actor child = Actor::New();
1944   child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1945   child.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1946   Vector3 childPosition(6.0f, 6.0f, 6.0f);
1947   child.SetProperty(Actor::Property::POSITION, childPosition);
1948   parent.Add(child);
1949
1950   // The actors should not have a world position yet
1951   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1952   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1953
1954   application.SendNotification();
1955   application.Render(0);
1956
1957   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
1958   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childPosition, TEST_LOCATION);
1959
1960   // The actors should have a world position now
1961   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
1962   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition + childPosition, TEST_LOCATION);
1963   END_TEST;
1964 }
1965
1966 int UtcDaliActorSetInheritPosition(void)
1967 {
1968   tet_infoline("Testing Actor::SetInheritPosition");
1969   TestApplication application;
1970
1971   Actor   parent = Actor::New();
1972   Vector3 parentPosition(1.0f, 2.0f, 3.0f);
1973   parent.SetProperty(Actor::Property::POSITION, parentPosition);
1974   parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1975   parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1976   application.GetScene().Add(parent);
1977
1978   Actor child = Actor::New();
1979   child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1980   child.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1981   Vector3 childPosition(10.0f, 11.0f, 12.0f);
1982   child.SetProperty(Actor::Property::POSITION, childPosition);
1983   parent.Add(child);
1984
1985   // The actors should not have a world position yet
1986   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1987   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1988
1989   // first test default, which is to inherit position
1990   DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_POSITION), true, TEST_LOCATION);
1991   application.SendNotification();
1992   application.Render(0); // should only really call Update as Render is not required to update scene
1993   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
1994   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childPosition, TEST_LOCATION);
1995   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
1996   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition + childPosition, TEST_LOCATION);
1997
1998   //Change child position
1999   Vector3 childOffset(-1.0f, 1.0f, 0.0f);
2000   child.SetProperty(Actor::Property::POSITION, childOffset);
2001
2002   // Use local position as world postion
2003   child.SetProperty(Actor::Property::INHERIT_POSITION, false);
2004   DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_POSITION), false, TEST_LOCATION);
2005   application.SendNotification();
2006   application.Render(0); // should only really call Update as Render is not required to update scene
2007   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
2008   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childOffset, TEST_LOCATION);
2009   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
2010   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), childOffset, TEST_LOCATION);
2011
2012   //Change back to inherit position from parent
2013   child.SetProperty(Actor::Property::INHERIT_POSITION, true);
2014   DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_POSITION), true, TEST_LOCATION);
2015   application.SendNotification();
2016   application.Render(0); // should only really call Update as Render is not required to update scene
2017   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
2018   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childOffset, TEST_LOCATION);
2019   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
2020   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition + childOffset, TEST_LOCATION);
2021   END_TEST;
2022 }
2023
2024 int UtcDaliActorInheritOpacity(void)
2025 {
2026   tet_infoline("Testing Actor::Inherit Opacity");
2027   TestApplication application;
2028
2029   Actor parent = Actor::New();
2030   Actor child  = Actor::New();
2031   parent.Add(child);
2032   application.GetScene().Add(parent);
2033
2034   DALI_TEST_EQUALS(parent.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION);
2035   DALI_TEST_EQUALS(child.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION);
2036
2037   // flush the queue and render once
2038   application.SendNotification();
2039   application.Render();
2040
2041   parent.SetProperty(Actor::Property::OPACITY, 0.1f);
2042
2043   DALI_TEST_EQUALS(parent.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION);
2044   DALI_TEST_EQUALS(child.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION);
2045
2046   application.SendNotification();
2047   application.Render();
2048
2049   DALI_TEST_EQUALS(parent.GetProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
2050   DALI_TEST_EQUALS(parent.GetCurrentProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION);
2051   DALI_TEST_EQUALS(parent.GetCurrentProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
2052   DALI_TEST_EQUALS(child.GetProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
2053   DALI_TEST_EQUALS(child.GetCurrentProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
2054   DALI_TEST_EQUALS(child.GetCurrentProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.f, 0.0001f, TEST_LOCATION);
2055
2056   END_TEST;
2057 }
2058
2059 // SetOrientation(float angleRadians, Vector3 axis)
2060 int UtcDaliActorSetOrientation01(void)
2061 {
2062   TestApplication application;
2063
2064   Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
2065   Actor      actor = Actor::New();
2066
2067   actor.SetProperty(Actor::Property::ORIENTATION, rotation);
2068
2069   // flush the queue and render once
2070   application.SendNotification();
2071   application.Render();
2072
2073   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2074   END_TEST;
2075 }
2076
2077 int UtcDaliActorSetOrientation02(void)
2078 {
2079   TestApplication application;
2080
2081   Actor actor = Actor::New();
2082
2083   Radian  angle(0.785f);
2084   Vector3 axis(1.0f, 1.0f, 0.0f);
2085
2086   actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(angle, axis));
2087   Quaternion rotation(angle, axis);
2088   // flush the queue and render once
2089   application.SendNotification();
2090   application.Render();
2091   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2092
2093   application.GetScene().Add(actor);
2094   actor.RotateBy(Degree(360), axis);
2095   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2096
2097   actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(0), Vector3(1.0f, 0.0f, 0.0f)));
2098   Quaternion result(Radian(0), Vector3(1.0f, 0.0f, 0.0f));
2099   // flush the queue and render once
2100   application.SendNotification();
2101   application.Render();
2102   DALI_TEST_EQUALS(result, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2103
2104   actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(angle, axis));
2105   // flush the queue and render once
2106   application.SendNotification();
2107   application.Render();
2108   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2109
2110   application.GetScene().Remove(actor);
2111   END_TEST;
2112 }
2113
2114 // SetOrientation(float angleRadians, Vector3 axis)
2115 int UtcDaliActorSetOrientationProperty(void)
2116 {
2117   TestApplication application;
2118
2119   Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
2120   Actor      actor = Actor::New();
2121
2122   actor.SetProperty(Actor::Property::ORIENTATION, rotation);
2123   DALI_TEST_EQUALS(rotation, actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2124
2125   // flush the queue and render once
2126   application.SendNotification();
2127   application.Render();
2128
2129   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2130   DALI_TEST_EQUALS(rotation, actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2131   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2132   END_TEST;
2133 }
2134
2135 // RotateBy(float angleRadians, Vector3 axis)
2136 int UtcDaliActorRotateBy01(void)
2137 {
2138   TestApplication application;
2139
2140   Actor actor = Actor::New();
2141
2142   Radian angle(M_PI * 0.25f);
2143   actor.RotateBy((angle), Vector3::ZAXIS);
2144   // flush the queue and render once
2145   application.SendNotification();
2146   application.Render();
2147   DALI_TEST_EQUALS(Quaternion(angle, Vector3::ZAXIS), actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2148
2149   application.GetScene().Add(actor);
2150
2151   actor.RotateBy(angle, Vector3::ZAXIS);
2152   // flush the queue and render once
2153   application.SendNotification();
2154   application.Render();
2155   DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2156
2157   application.GetScene().Remove(actor);
2158   END_TEST;
2159 }
2160
2161 // RotateBy(Quaternion relativeRotation)
2162 int UtcDaliActorRotateBy02(void)
2163 {
2164   TestApplication application;
2165
2166   Actor actor = Actor::New();
2167
2168   Radian     angle(M_PI * 0.25f);
2169   Quaternion rotation(angle, Vector3::ZAXIS);
2170   actor.RotateBy(rotation);
2171   // flush the queue and render once
2172   application.SendNotification();
2173   application.Render();
2174   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2175
2176   actor.RotateBy(rotation);
2177   // flush the queue and render once
2178   application.SendNotification();
2179   application.Render();
2180   DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2181   END_TEST;
2182 }
2183
2184 int UtcDaliActorGetCurrentOrientation(void)
2185 {
2186   TestApplication application;
2187   Actor           actor = Actor::New();
2188
2189   Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
2190   actor.SetProperty(Actor::Property::ORIENTATION, rotation);
2191   // flush the queue and render once
2192   application.SendNotification();
2193   application.Render();
2194   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2195   END_TEST;
2196 }
2197
2198 int UtcDaliActorGetCurrentWorldOrientation(void)
2199 {
2200   tet_infoline("Testing Actor::GetCurrentWorldRotation");
2201   TestApplication application;
2202
2203   Actor      parent = Actor::New();
2204   Radian     rotationAngle(Degree(90.0f));
2205   Quaternion rotation(rotationAngle, Vector3::YAXIS);
2206   parent.SetProperty(Actor::Property::ORIENTATION, rotation);
2207   application.GetScene().Add(parent);
2208
2209   Actor child = Actor::New();
2210   child.SetProperty(Actor::Property::ORIENTATION, rotation);
2211   parent.Add(child);
2212
2213   // The actors should not have a world rotation yet
2214   DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION);
2215   DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION);
2216
2217   application.SendNotification();
2218   application.Render(0);
2219
2220   DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), rotation, 0.001, TEST_LOCATION);
2221   DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), rotation, 0.001, TEST_LOCATION);
2222
2223   // The actors should have a world rotation now
2224   DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(rotationAngle, Vector3::YAXIS), 0.001, TEST_LOCATION);
2225   DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(rotationAngle * 2.0f, Vector3::YAXIS), 0.001, TEST_LOCATION);
2226
2227   // turn off child rotation inheritance
2228   child.SetProperty(Actor::Property::INHERIT_ORIENTATION, false);
2229   DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_ORIENTATION), false, TEST_LOCATION);
2230   application.SendNotification();
2231   application.Render(0);
2232
2233   // The actors should have a world rotation now
2234   DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(rotationAngle, Vector3::YAXIS), 0.001, TEST_LOCATION);
2235   DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), rotation, 0.001, TEST_LOCATION);
2236   END_TEST;
2237 }
2238
2239 // SetScale(float scale)
2240 int UtcDaliActorSetScale01(void)
2241 {
2242   TestApplication application;
2243
2244   Actor actor = Actor::New();
2245
2246   // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
2247   actor.SetProperty(Actor::Property::SCALE, 0.25f);
2248
2249   Vector3 scale(10.0f, 10.0f, 10.0f);
2250   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) != scale);
2251
2252   actor.SetProperty(Actor::Property::SCALE, scale.x);
2253
2254   // flush the queue and render once
2255   application.SendNotification();
2256   application.Render();
2257
2258   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
2259   END_TEST;
2260 }
2261
2262 // SetScale(float scaleX, float scaleY, float scaleZ)
2263 int UtcDaliActorSetScale02(void)
2264 {
2265   TestApplication application;
2266   Vector3         scale(10.0f, 10.0f, 10.0f);
2267
2268   Actor actor = Actor::New();
2269
2270   // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
2271   actor.SetProperty(Actor::Property::SCALE, Vector3(12.0f, 1.0f, 2.0f));
2272
2273   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) != scale);
2274
2275   actor.SetProperty(Actor::Property::SCALE, Vector3(scale.x, scale.y, scale.z));
2276   // flush the queue and render once
2277   application.SendNotification();
2278   application.Render();
2279   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
2280
2281   // add to stage and test
2282   application.GetScene().Add(actor);
2283   actor.SetProperty(Actor::Property::SCALE, Vector3(2.0f, 2.0f, 2.0f));
2284   // flush the queue and render once
2285   application.SendNotification();
2286   application.Render();
2287   DALI_TEST_EQUALS(Vector3(2.0f, 2.0f, 2.0f), actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE), 0.001, TEST_LOCATION);
2288
2289   application.GetScene().Remove(actor);
2290
2291   END_TEST;
2292 }
2293
2294 // SetScale(Vector3 scale)
2295 int UtcDaliActorSetScale03(void)
2296 {
2297   TestApplication application;
2298   Vector3         scale(10.0f, 10.0f, 10.0f);
2299
2300   Actor actor = Actor::New();
2301
2302   // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
2303   actor.SetProperty(Actor::Property::SCALE, Vector3(12.0f, 1.0f, 2.0f));
2304
2305   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) != scale);
2306
2307   actor.SetProperty(Actor::Property::SCALE, scale);
2308
2309   // flush the queue and render once
2310   application.SendNotification();
2311   application.Render();
2312
2313   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
2314   END_TEST;
2315 }
2316
2317 int UtcDaliActorSetScaleIndividual(void)
2318 {
2319   TestApplication application;
2320
2321   Actor actor = Actor::New();
2322
2323   Vector3 vector(0.7f, 0.8f, 0.9f);
2324   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2325
2326   actor.SetProperty(Actor::Property::SCALE_X, vector.x);
2327   DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::SCALE_X), TEST_LOCATION);
2328
2329   // flush the queue and render once
2330   application.SendNotification();
2331   application.Render();
2332
2333   DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE).x, TEST_LOCATION);
2334   DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::SCALE_X), TEST_LOCATION);
2335   DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<float>(Actor::Property::SCALE_X), TEST_LOCATION);
2336
2337   actor.SetProperty(Actor::Property::SCALE_Y, vector.y);
2338   DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::SCALE_Y), TEST_LOCATION);
2339
2340   // flush the queue and render once
2341   application.SendNotification();
2342   application.Render();
2343
2344   DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE).y, TEST_LOCATION);
2345   DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::SCALE_Y), TEST_LOCATION);
2346   DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<float>(Actor::Property::SCALE_Y), TEST_LOCATION);
2347
2348   actor.SetProperty(Actor::Property::SCALE_Z, vector.z);
2349   DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::SCALE_Z), TEST_LOCATION);
2350
2351   // flush the queue and render once
2352   application.SendNotification();
2353   application.Render();
2354
2355   DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE).z, TEST_LOCATION);
2356   DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::SCALE_Z), TEST_LOCATION);
2357   DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<float>(Actor::Property::SCALE_Z), TEST_LOCATION);
2358
2359   DALI_TEST_EQUALS(vector, actor.GetProperty<Vector3>(Actor::Property::SCALE), TEST_LOCATION);
2360   DALI_TEST_EQUALS(vector, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE), TEST_LOCATION);
2361
2362   END_TEST;
2363 }
2364
2365 int UtcDaliActorScaleBy(void)
2366 {
2367   TestApplication application;
2368   Actor           actor = Actor::New();
2369   Vector3         vector(100.0f, 100.0f, 100.0f);
2370
2371   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2372
2373   actor.SetProperty(Actor::Property::SCALE, vector);
2374
2375   // flush the queue and render once
2376   application.SendNotification();
2377   application.Render();
2378
2379   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2380
2381   actor.ScaleBy(vector);
2382
2383   // flush the queue and render once
2384   application.SendNotification();
2385   application.Render();
2386
2387   DALI_TEST_CHECK(vector * 100.0f == actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2388   END_TEST;
2389 }
2390
2391 int UtcDaliActorGetCurrentScale(void)
2392 {
2393   TestApplication application;
2394   Vector3         scale(12.0f, 1.0f, 2.0f);
2395
2396   Actor actor = Actor::New();
2397
2398   actor.SetProperty(Actor::Property::SCALE, scale);
2399
2400   // flush the queue and render once
2401   application.SendNotification();
2402   application.Render();
2403
2404   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
2405   END_TEST;
2406 }
2407
2408 int UtcDaliActorGetCurrentWorldScale(void)
2409 {
2410   TestApplication application;
2411
2412   Actor   parent = Actor::New();
2413   Vector3 parentScale(1.0f, 2.0f, 3.0f);
2414   parent.SetProperty(Actor::Property::SCALE, parentScale);
2415   application.GetScene().Add(parent);
2416
2417   Actor   child = Actor::New();
2418   Vector3 childScale(2.0f, 2.0f, 2.0f);
2419   child.SetProperty(Actor::Property::SCALE, childScale);
2420   parent.Add(child);
2421
2422   // The actors should not have a scale yet
2423   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::SCALE), Vector3::ONE, TEST_LOCATION);
2424   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::SCALE), Vector3::ONE, TEST_LOCATION);
2425
2426   // The actors should not have a world scale yet
2427   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), Vector3::ONE, TEST_LOCATION);
2428   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), Vector3::ONE, TEST_LOCATION);
2429
2430   application.SendNotification();
2431   application.Render(0);
2432
2433   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::SCALE), parentScale, TEST_LOCATION);
2434   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::SCALE), childScale, TEST_LOCATION);
2435
2436   // The actors should have a world scale now
2437   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), parentScale, TEST_LOCATION);
2438   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), parentScale * childScale, TEST_LOCATION);
2439   END_TEST;
2440 }
2441
2442 int UtcDaliActorInheritScale(void)
2443 {
2444   tet_infoline("Testing Actor::SetInheritScale");
2445   TestApplication application;
2446
2447   Actor   parent = Actor::New();
2448   Vector3 parentScale(1.0f, 2.0f, 3.0f);
2449   parent.SetProperty(Actor::Property::SCALE, parentScale);
2450   application.GetScene().Add(parent);
2451
2452   Actor   child = Actor::New();
2453   Vector3 childScale(2.0f, 2.0f, 2.0f);
2454   child.SetProperty(Actor::Property::SCALE, childScale);
2455   parent.Add(child);
2456
2457   application.SendNotification();
2458   application.Render(0);
2459
2460   DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_SCALE), true, TEST_LOCATION);
2461   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), parentScale * childScale, TEST_LOCATION);
2462
2463   child.SetProperty(Actor::Property::INHERIT_SCALE, false);
2464   DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_SCALE), false, TEST_LOCATION);
2465
2466   application.SendNotification();
2467   application.Render(0);
2468
2469   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), childScale, TEST_LOCATION);
2470   END_TEST;
2471 }
2472
2473 int UtcDaliActorSetVisible(void)
2474 {
2475   TestApplication application;
2476
2477   Actor actor = Actor::New();
2478   actor.SetProperty(Actor::Property::VISIBLE, false);
2479   // flush the queue and render once
2480   application.SendNotification();
2481   application.Render();
2482   DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == false);
2483
2484   actor.SetProperty(Actor::Property::VISIBLE, true);
2485   // flush the queue and render once
2486   application.SendNotification();
2487   application.Render();
2488   DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == true);
2489
2490   // put actor on stage
2491   application.GetScene().Add(actor);
2492   actor.SetProperty(Actor::Property::VISIBLE, false);
2493   // flush the queue and render once
2494   application.SendNotification();
2495   application.Render();
2496   DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == false);
2497   END_TEST;
2498 }
2499
2500 int UtcDaliActorIsVisible(void)
2501 {
2502   TestApplication application;
2503
2504   Actor actor = Actor::New();
2505
2506   DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == true);
2507   END_TEST;
2508 }
2509
2510 int UtcDaliActorSetOpacity(void)
2511 {
2512   TestApplication application;
2513
2514   Actor actor = Actor::New();
2515   // initial opacity is 1
2516   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, TEST_LOCATION);
2517
2518   actor.SetProperty(Actor::Property::OPACITY, 0.4f);
2519   // flush the queue and render once
2520   application.SendNotification();
2521   application.Render();
2522   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.4f, TEST_LOCATION);
2523
2524   // change opacity, actor is on stage to change is not immediate
2525   actor.SetProperty(Actor::Property::OPACITY, actor.GetCurrentProperty<float>(Actor::Property::OPACITY) + 0.1f);
2526   // flush the queue and render once
2527   application.SendNotification();
2528   application.Render();
2529   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.5f, TEST_LOCATION);
2530
2531   // put actor on stage
2532   application.GetScene().Add(actor);
2533
2534   // change opacity, actor is on stage to change is not immediate
2535   actor.SetProperty(Actor::Property::OPACITY, 0.9f);
2536   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.5f, TEST_LOCATION);
2537   // flush the queue and render once
2538   application.SendNotification();
2539   application.Render();
2540   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.9f, TEST_LOCATION);
2541
2542   // change opacity, actor is on stage to change is not immediate
2543   actor.SetProperty(Actor::Property::OPACITY, actor.GetCurrentProperty<float>(Actor::Property::OPACITY) - 0.9f);
2544   // flush the queue and render once
2545   application.SendNotification();
2546   application.Render();
2547   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, TEST_LOCATION);
2548   END_TEST;
2549 }
2550
2551 int UtcDaliActorGetCurrentOpacity(void)
2552 {
2553   TestApplication application;
2554
2555   Actor actor = Actor::New();
2556   DALI_TEST_CHECK(actor.GetCurrentProperty<float>(Actor::Property::OPACITY) != 0.5f);
2557
2558   actor.SetProperty(Actor::Property::OPACITY, 0.5f);
2559   // flush the queue and render once
2560   application.SendNotification();
2561   application.Render();
2562   DALI_TEST_CHECK(actor.GetCurrentProperty<float>(Actor::Property::OPACITY) == 0.5f);
2563   END_TEST;
2564 }
2565
2566 int UtcDaliActorSetSensitive(void)
2567 {
2568   TestApplication application;
2569   Actor           actor = Actor::New();
2570
2571   bool sensitive = !actor.GetProperty<bool>(Actor::Property::SENSITIVE);
2572
2573   actor.SetProperty(Actor::Property::SENSITIVE, sensitive);
2574
2575   DALI_TEST_CHECK(sensitive == actor.GetProperty<bool>(Actor::Property::SENSITIVE));
2576   END_TEST;
2577 }
2578
2579 int UtcDaliActorIsSensitive(void)
2580 {
2581   TestApplication application;
2582   Actor           actor = Actor::New();
2583   actor.SetProperty(Actor::Property::SENSITIVE, false);
2584
2585   DALI_TEST_CHECK(false == actor.GetProperty<bool>(Actor::Property::SENSITIVE));
2586   END_TEST;
2587 }
2588
2589 int UtcDaliActorSetColor(void)
2590 {
2591   TestApplication application;
2592   Actor           actor = Actor::New();
2593   Vector4         color(1.0f, 1.0f, 1.0f, 0.5f);
2594
2595   DALI_TEST_CHECK(color != actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2596
2597   actor.SetProperty(Actor::Property::COLOR, color);
2598   // flush the queue and render once
2599   application.SendNotification();
2600   application.Render();
2601   DALI_TEST_CHECK(color == actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2602
2603   actor.SetProperty(Actor::Property::COLOR, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR) + Vector4(-0.4f, -0.5f, -0.6f, -0.4f));
2604   // flush the queue and render once
2605   application.SendNotification();
2606   application.Render();
2607   DALI_TEST_EQUALS(Vector4(0.6f, 0.5f, 0.4f, 0.1f), actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2608
2609   application.GetScene().Add(actor);
2610   actor.SetProperty(Actor::Property::COLOR, color);
2611   // flush the queue and render once
2612   application.SendNotification();
2613   application.Render();
2614   DALI_TEST_EQUALS(color, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2615
2616   actor.SetProperty(Actor::Property::COLOR, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR) + Vector4(1.1f, 1.1f, 1.1f, 1.1f));
2617   // flush the queue and render once
2618   application.SendNotification();
2619   application.Render();
2620   // Actor color is not clamped
2621   DALI_TEST_EQUALS(Vector4(2.1f, 2.1f, 2.1f, 1.6f), actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2622   // world color is clamped
2623   DALI_TEST_EQUALS(Vector4(1.0f, 1.0f, 1.0f, 1.0f), actor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), TEST_LOCATION);
2624
2625   actor.SetProperty(Actor::Property::COLOR, color);
2626   DALI_TEST_EQUALS(color, actor.GetProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2627
2628   Vector3 newColor(1.0f, 0.0f, 0.0f);
2629   actor.SetProperty(Actor::Property::COLOR, newColor);
2630   DALI_TEST_EQUALS(Vector4(newColor.r, newColor.g, newColor.b, 1.0f), actor.GetProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2631
2632   application.GetScene().Remove(actor);
2633   END_TEST;
2634 }
2635
2636 int UtcDaliActorSetColorIndividual(void)
2637 {
2638   TestApplication application;
2639
2640   Actor actor = Actor::New();
2641
2642   Vector4 vector(0.7f, 0.8f, 0.9f, 0.6f);
2643   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2644
2645   actor.SetProperty(Actor::Property::COLOR_RED, vector.r);
2646   DALI_TEST_EQUALS(vector.r, actor.GetProperty<float>(Actor::Property::COLOR_RED), TEST_LOCATION);
2647
2648   // flush the queue and render once
2649   application.SendNotification();
2650   application.Render();
2651
2652   DALI_TEST_EQUALS(vector.r, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).r, TEST_LOCATION);
2653   DALI_TEST_EQUALS(vector.r, actor.GetProperty<float>(Actor::Property::COLOR_RED), TEST_LOCATION);
2654   DALI_TEST_EQUALS(vector.r, actor.GetCurrentProperty<float>(Actor::Property::COLOR_RED), TEST_LOCATION);
2655
2656   actor.SetProperty(Actor::Property::COLOR_GREEN, vector.g);
2657   DALI_TEST_EQUALS(vector.g, actor.GetProperty<float>(Actor::Property::COLOR_GREEN), TEST_LOCATION);
2658
2659   // flush the queue and render once
2660   application.SendNotification();
2661   application.Render();
2662
2663   DALI_TEST_EQUALS(vector.g, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).g, TEST_LOCATION);
2664   DALI_TEST_EQUALS(vector.g, actor.GetProperty<float>(Actor::Property::COLOR_GREEN), TEST_LOCATION);
2665   DALI_TEST_EQUALS(vector.g, actor.GetCurrentProperty<float>(Actor::Property::COLOR_GREEN), TEST_LOCATION);
2666
2667   actor.SetProperty(Actor::Property::COLOR_BLUE, vector.b);
2668   DALI_TEST_EQUALS(vector.b, actor.GetProperty<float>(Actor::Property::COLOR_BLUE), TEST_LOCATION);
2669
2670   // flush the queue and render once
2671   application.SendNotification();
2672   application.Render();
2673
2674   DALI_TEST_EQUALS(vector.b, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).b, TEST_LOCATION);
2675   DALI_TEST_EQUALS(vector.b, actor.GetProperty<float>(Actor::Property::COLOR_BLUE), TEST_LOCATION);
2676   DALI_TEST_EQUALS(vector.b, actor.GetCurrentProperty<float>(Actor::Property::COLOR_BLUE), TEST_LOCATION);
2677
2678   actor.SetProperty(Actor::Property::COLOR_ALPHA, vector.a);
2679   DALI_TEST_EQUALS(vector.a, actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), TEST_LOCATION);
2680
2681   // flush the queue and render once
2682   application.SendNotification();
2683   application.Render();
2684
2685   DALI_TEST_EQUALS(vector.a, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).a, TEST_LOCATION);
2686   DALI_TEST_EQUALS(vector.a, actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), TEST_LOCATION);
2687   DALI_TEST_EQUALS(vector.a, actor.GetCurrentProperty<float>(Actor::Property::COLOR_ALPHA), TEST_LOCATION);
2688
2689   DALI_TEST_EQUALS(vector, actor.GetProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2690   DALI_TEST_EQUALS(vector, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2691
2692   actor.SetProperty(Actor::Property::OPACITY, 0.2f);
2693
2694   // flush the queue and render once
2695   application.SendNotification();
2696   application.Render();
2697
2698   DALI_TEST_EQUALS(0.2f, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).a, TEST_LOCATION);
2699
2700   END_TEST;
2701 }
2702
2703 int UtcDaliActorGetCurrentColor(void)
2704 {
2705   TestApplication application;
2706   Actor           actor = Actor::New();
2707   Vector4         color(1.0f, 1.0f, 1.0f, 0.5f);
2708
2709   actor.SetProperty(Actor::Property::COLOR, color);
2710   // flush the queue and render once
2711   application.SendNotification();
2712   application.Render();
2713   DALI_TEST_CHECK(color == actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2714   END_TEST;
2715 }
2716
2717 int UtcDaliActorGetCurrentWorldColor(void)
2718 {
2719   tet_infoline("Actor::GetCurrentWorldColor");
2720   TestApplication application;
2721
2722   Actor   parent = Actor::New();
2723   Vector4 parentColor(1.0f, 0.5f, 0.0f, 0.8f);
2724   parent.SetProperty(Actor::Property::COLOR, parentColor);
2725   application.GetScene().Add(parent);
2726
2727   Actor   child = Actor::New();
2728   Vector4 childColor(0.5f, 0.6f, 0.5f, 1.0f);
2729   child.SetProperty(Actor::Property::COLOR, childColor);
2730   parent.Add(child);
2731
2732   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::COLOR), Color::WHITE, TEST_LOCATION);
2733   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), Color::WHITE, TEST_LOCATION);
2734
2735   // verify the default color mode
2736   DALI_TEST_EQUALS(USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2737
2738   // The actors should not have a world color yet
2739   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), Color::WHITE, TEST_LOCATION);
2740   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), Color::WHITE, TEST_LOCATION);
2741
2742   application.SendNotification();
2743   application.Render(0);
2744
2745   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::COLOR), parentColor, TEST_LOCATION);
2746   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), childColor, TEST_LOCATION);
2747
2748   // The actors should have a world color now
2749   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), parentColor, TEST_LOCATION);
2750   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), Vector4(childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION);
2751
2752   // use own color
2753   child.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
2754   application.SendNotification();
2755   application.Render(0);
2756   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), childColor, TEST_LOCATION);
2757
2758   // use parent color
2759   child.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
2760   application.SendNotification();
2761   application.Render(0);
2762   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), childColor, TEST_LOCATION);
2763   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), parentColor, TEST_LOCATION);
2764
2765   // use parent alpha
2766   child.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
2767   application.SendNotification();
2768   application.Render(0);
2769   Vector4 expectedColor(childColor);
2770   expectedColor.a *= parentColor.a;
2771   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), childColor, TEST_LOCATION);
2772   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), expectedColor, TEST_LOCATION);
2773   END_TEST;
2774 }
2775
2776 int UtcDaliActorSetColorMode(void)
2777 {
2778   tet_infoline("Actor::SetColorMode");
2779   TestApplication application;
2780   Actor           actor = Actor::New();
2781   Actor           child = Actor::New();
2782   actor.Add(child);
2783
2784   actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
2785   DALI_TEST_EQUALS(USE_OWN_COLOR, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2786
2787   actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR);
2788   DALI_TEST_EQUALS(USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2789
2790   actor.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
2791   DALI_TEST_EQUALS(USE_PARENT_COLOR, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2792
2793   actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
2794   DALI_TEST_EQUALS(USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2795   END_TEST;
2796 }
2797
2798 int UtcDaliActorScreenToLocal(void)
2799 {
2800   TestApplication application;
2801   Actor           actor = Actor::New();
2802   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2803   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2804   actor.SetProperty(Actor::Property::POSITION, Vector2(10.0f, 10.0f));
2805   application.GetScene().Add(actor);
2806
2807   // flush the queue and render once
2808   application.SendNotification();
2809   application.Render();
2810
2811   float localX;
2812   float localY;
2813
2814   application.SendNotification();
2815   application.Render();
2816
2817   DALI_TEST_CHECK(actor.ScreenToLocal(localX, localY, 50.0f, 50.0f));
2818
2819   DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
2820   DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
2821   END_TEST;
2822 }
2823
2824 int UtcDaliActorSetLeaveRequired(void)
2825 {
2826   TestApplication application;
2827
2828   Actor actor = Actor::New();
2829
2830   actor.SetProperty(Actor::Property::LEAVE_REQUIRED, false);
2831   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::LEAVE_REQUIRED) == false);
2832
2833   actor.SetProperty(Actor::Property::LEAVE_REQUIRED, true);
2834   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::LEAVE_REQUIRED) == true);
2835   END_TEST;
2836 }
2837
2838 int UtcDaliActorGetLeaveRequired(void)
2839 {
2840   TestApplication application;
2841
2842   Actor actor = Actor::New();
2843
2844   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::LEAVE_REQUIRED) == false);
2845   END_TEST;
2846 }
2847
2848 int UtcDaliActorSetKeyboardFocusable(void)
2849 {
2850   TestApplication application;
2851
2852   Actor actor = Actor::New();
2853
2854   actor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
2855   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) == true);
2856
2857   actor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, false);
2858   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) == false);
2859   END_TEST;
2860 }
2861
2862 int UtcDaliActorIsKeyboardFocusable(void)
2863 {
2864   TestApplication application;
2865
2866   Actor actor = Actor::New();
2867
2868   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) == false);
2869   END_TEST;
2870 }
2871
2872 int UtcDaliActorSetKeyboardFocusableChildren(void)
2873 {
2874   TestApplication application;
2875
2876   Actor actor = Actor::New();
2877
2878   actor.SetProperty(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN, true);
2879   DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN) == true);
2880
2881   actor.SetProperty(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN, false);
2882   DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN) == false);
2883   END_TEST;
2884 }
2885
2886 int UtcDaliActorAreChildrenKeyBoardFocusable(void)
2887 {
2888   TestApplication application;
2889
2890   Actor actor = Actor::New();
2891
2892   DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN) == true);
2893   END_TEST;
2894 }
2895
2896 int UtcDaliActorSetTouchFocusable(void)
2897 {
2898   TestApplication application;
2899
2900   Actor actor = Actor::New();
2901
2902   actor.SetProperty(DevelActor::Property::TOUCH_FOCUSABLE, true);
2903   DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::TOUCH_FOCUSABLE) == true);
2904
2905   actor.SetProperty(DevelActor::Property::TOUCH_FOCUSABLE, false);
2906   DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::TOUCH_FOCUSABLE) == false);
2907   END_TEST;
2908 }
2909
2910 int UtcDaliActorIsTouchFocusable(void)
2911 {
2912   TestApplication application;
2913
2914   Actor actor = Actor::New();
2915
2916   DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::TOUCH_FOCUSABLE) == false);
2917   END_TEST;
2918 }
2919
2920 int UtcDaliActorSetUserInteractionEnabled(void)
2921 {
2922   TestApplication application;
2923   Actor           actor = Actor::New();
2924
2925   bool enabled = !actor.GetProperty<bool>(DevelActor::Property::USER_INTERACTION_ENABLED);
2926
2927   actor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, enabled);
2928
2929   DALI_TEST_CHECK(enabled == actor.GetProperty<bool>(DevelActor::Property::USER_INTERACTION_ENABLED));
2930   END_TEST;
2931 }
2932
2933 int UtcDaliActorIsUserInteractionEnabled(void)
2934 {
2935   TestApplication application;
2936   Actor           actor = Actor::New();
2937   actor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, true);
2938
2939   DALI_TEST_CHECK(true == actor.GetProperty<bool>(DevelActor::Property::USER_INTERACTION_ENABLED));
2940   END_TEST;
2941 }
2942
2943 int UtcDaliActorRemoveConstraints(void)
2944 {
2945   tet_infoline(" UtcDaliActorRemoveConstraints");
2946   TestApplication application;
2947
2948   gTestConstraintCalled = false;
2949
2950   Actor actor = Actor::New();
2951
2952   Constraint constraint = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraint());
2953   constraint.Apply();
2954   actor.RemoveConstraints();
2955
2956   DALI_TEST_CHECK(gTestConstraintCalled == false);
2957
2958   application.GetScene().Add(actor);
2959   constraint.Apply();
2960
2961   // flush the queue and render once
2962   application.SendNotification();
2963   application.Render();
2964
2965   actor.RemoveConstraints();
2966
2967   DALI_TEST_CHECK(gTestConstraintCalled == true);
2968   END_TEST;
2969 }
2970
2971 int UtcDaliActorRemoveConstraintTag(void)
2972 {
2973   tet_infoline(" UtcDaliActorRemoveConstraintTag");
2974   TestApplication application;
2975
2976   Actor actor = Actor::New();
2977
2978   // 1. Apply Constraint1 and Constraint2, and test...
2979   unsigned int result1 = 0u;
2980   unsigned int result2 = 0u;
2981
2982   unsigned   constraint1Tag = 1u;
2983   Constraint constraint1    = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1));
2984   constraint1.SetTag(constraint1Tag);
2985   constraint1.Apply();
2986
2987   unsigned   constraint2Tag = 2u;
2988   Constraint constraint2    = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2));
2989   constraint2.SetTag(constraint2Tag);
2990   constraint2.Apply();
2991
2992   application.GetScene().Add(actor);
2993   // flush the queue and render once
2994   application.SendNotification();
2995   application.Render();
2996
2997   DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
2998   DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
2999
3000   // 2. Remove Constraint1 and test...
3001   result1 = 0;
3002   result2 = 0;
3003   actor.RemoveConstraints(constraint1Tag);
3004   // make color property dirty, which will trigger constraints to be reapplied.
3005   actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
3006   // flush the queue and render once
3007   application.SendNotification();
3008   application.Render();
3009
3010   DALI_TEST_EQUALS(result1, 0u, TEST_LOCATION); ///< constraint 1 should not apply now.
3011   DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
3012
3013   // 3. Re-Apply Constraint1 and test...
3014   result1 = 0;
3015   result2 = 0;
3016   constraint1.Apply();
3017   // make color property dirty, which will trigger constraints to be reapplied.
3018   actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
3019   // flush the queue and render once
3020   application.SendNotification();
3021   application.Render();
3022
3023   DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
3024   DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
3025
3026   // 2. Remove Constraint2 and test...
3027   result1 = 0;
3028   result2 = 0;
3029   actor.RemoveConstraints(constraint2Tag);
3030   // make color property dirty, which will trigger constraints to be reapplied.
3031   actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
3032   // flush the queue and render once
3033   application.SendNotification();
3034   application.Render();
3035
3036   DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
3037   DALI_TEST_EQUALS(result2, 0u, TEST_LOCATION); ///< constraint 2 should not apply now.
3038
3039   // 2. Remove Constraint1 as well and test...
3040   result1 = 0;
3041   result2 = 0;
3042   actor.RemoveConstraints(constraint1Tag);
3043   // make color property dirty, which will trigger constraints to be reapplied.
3044   actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
3045   // flush the queue and render once
3046   application.SendNotification();
3047   application.Render();
3048
3049   DALI_TEST_EQUALS(result1, 0u, TEST_LOCATION); ///< constraint 1 should not apply now.
3050   DALI_TEST_EQUALS(result2, 0u, TEST_LOCATION); ///< constraint 2 should not apply now.
3051   END_TEST;
3052 }
3053
3054 int UtcDaliActorTouchedSignal(void)
3055 {
3056   TestApplication application;
3057
3058   ResetTouchCallbacks();
3059
3060   // get the root layer
3061   Actor actor = application.GetScene().GetRootLayer();
3062   DALI_TEST_CHECK(gTouchCallBackCalled == false);
3063
3064   application.SendNotification();
3065   application.Render();
3066
3067   // connect to its touch signal
3068   actor.TouchedSignal().Connect(TestTouchCallback);
3069
3070   // simulate a touch event in the middle of the screen
3071   Vector2                  touchPoint(application.GetScene().GetSize() * 0.5);
3072   Dali::Integration::Point point;
3073   point.SetDeviceId(1);
3074   point.SetState(PointState::DOWN);
3075   point.SetScreenPosition(Vector2(touchPoint.x, touchPoint.y));
3076   Dali::Integration::TouchEvent touchEvent;
3077   touchEvent.AddPoint(point);
3078   application.ProcessEvent(touchEvent);
3079
3080   DALI_TEST_CHECK(gTouchCallBackCalled == true);
3081   END_TEST;
3082 }
3083
3084 int UtcDaliActorHoveredSignal(void)
3085 {
3086   TestApplication application;
3087
3088   gHoverCallBackCalled = false;
3089
3090   // get the root layer
3091   Actor actor = application.GetScene().GetRootLayer();
3092   DALI_TEST_CHECK(gHoverCallBackCalled == false);
3093
3094   application.SendNotification();
3095   application.Render();
3096
3097   // connect to its hover signal
3098   actor.HoveredSignal().Connect(TestCallback3);
3099
3100   // simulate a hover event in the middle of the screen
3101   Vector2                  touchPoint(application.GetScene().GetSize() * 0.5);
3102   Dali::Integration::Point point;
3103   point.SetDeviceId(1);
3104   point.SetState(PointState::MOTION);
3105   point.SetScreenPosition(Vector2(touchPoint.x, touchPoint.y));
3106   Dali::Integration::HoverEvent hoverEvent;
3107   hoverEvent.AddPoint(point);
3108   application.ProcessEvent(hoverEvent);
3109
3110   DALI_TEST_CHECK(gHoverCallBackCalled == true);
3111   END_TEST;
3112 }
3113
3114 int UtcDaliActorOnOffSceneSignal(void)
3115 {
3116   tet_infoline("Testing Dali::Actor::OnSceneSignal() and OffSceneSignal()");
3117
3118   TestApplication application;
3119
3120   // clean test data
3121   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
3122   gActorNamesOnOffScene.clear();
3123
3124   Actor parent = Actor::New();
3125   parent.SetProperty(Actor::Property::NAME, "parent");
3126   parent.OnSceneSignal().Connect(OnSceneCallback);
3127   parent.OffSceneSignal().Connect(OffSceneCallback);
3128   // sanity check
3129   DALI_TEST_CHECK(gOnSceneCallBackCalled == 0);
3130   DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
3131
3132   // add parent to the scene
3133   application.GetScene().Add(parent);
3134   // onstage emitted, offstage not
3135   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 1, TEST_LOCATION);
3136   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
3137   DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
3138
3139   // test adding a child, should get onstage emitted
3140   // clean test data
3141   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
3142   gActorNamesOnOffScene.clear();
3143
3144   Actor child = Actor::New();
3145   child.SetProperty(Actor::Property::NAME, "child");
3146   child.OnSceneSignal().Connect(OnSceneCallback);
3147   child.OffSceneSignal().Connect(OffSceneCallback);
3148   parent.Add(child); // add child
3149   // onscene emitted, offscene not
3150   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 1, TEST_LOCATION);
3151   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
3152   DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
3153
3154   // test removing parent from the scene
3155   // clean test data
3156   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
3157   gActorNamesOnOffScene.clear();
3158
3159   application.GetScene().Remove(parent);
3160   // onscene not emitted, offscene is
3161   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
3162   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 2, TEST_LOCATION);
3163   DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
3164   DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[1], TEST_LOCATION);
3165
3166   // test adding parent back to the scene
3167   // clean test data
3168   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
3169   gActorNamesOnOffScene.clear();
3170
3171   application.GetScene().Add(parent);
3172   // onscene emitted, offscene not
3173   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 2, TEST_LOCATION);
3174   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
3175   DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
3176   DALI_TEST_EQUALS("child", gActorNamesOnOffScene[1], TEST_LOCATION);
3177
3178   // test removing child
3179   // clean test data
3180   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
3181   gActorNamesOnOffScene.clear();
3182
3183   parent.Remove(child);
3184   // onscene not emitted, offscene is
3185   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
3186   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 1, TEST_LOCATION);
3187   DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
3188
3189   // test removing parent
3190   // clean test data
3191   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
3192   gActorNamesOnOffScene.clear();
3193
3194   application.GetScene().Remove(parent);
3195   // onscene not emitted, offscene is
3196   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
3197   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 1, TEST_LOCATION);
3198   DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
3199   END_TEST;
3200 }
3201
3202 int UtcDaliActorFindChildByName(void)
3203 {
3204   tet_infoline("Testing Dali::Actor::FindChildByName()");
3205   TestApplication application;
3206
3207   Actor parent = Actor::New();
3208   parent.SetProperty(Actor::Property::NAME, "parent");
3209   Actor first = Actor::New();
3210   first.SetProperty(Actor::Property::NAME, "first");
3211   Actor second = Actor::New();
3212   second.SetProperty(Actor::Property::NAME, "second");
3213
3214   parent.Add(first);
3215   first.Add(second);
3216
3217   Actor found = parent.FindChildByName("foo");
3218   DALI_TEST_CHECK(!found);
3219
3220   found = parent.FindChildByName("parent");
3221   DALI_TEST_CHECK(found == parent);
3222
3223   found = parent.FindChildByName("first");
3224   DALI_TEST_CHECK(found == first);
3225
3226   found = parent.FindChildByName("second");
3227   DALI_TEST_CHECK(found == second);
3228   END_TEST;
3229 }
3230
3231 int UtcDaliActorFindChildById(void)
3232 {
3233   tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
3234   TestApplication application;
3235
3236   Actor parent = Actor::New();
3237   Actor first  = Actor::New();
3238   Actor second = Actor::New();
3239
3240   parent.Add(first);
3241   first.Add(second);
3242
3243   Actor found = parent.FindChildById(100000);
3244   DALI_TEST_CHECK(!found);
3245
3246   found = parent.FindChildById(parent.GetProperty<int>(Actor::Property::ID));
3247   DALI_TEST_CHECK(found == parent);
3248
3249   found = parent.FindChildById(first.GetProperty<int>(Actor::Property::ID));
3250   DALI_TEST_CHECK(found == first);
3251
3252   found = parent.FindChildById(second.GetProperty<int>(Actor::Property::ID));
3253   DALI_TEST_CHECK(found == second);
3254   END_TEST;
3255 }
3256
3257 int UtcDaliActorHitTest(void)
3258 {
3259   struct HitTestData
3260   {
3261   public:
3262     HitTestData(const Vector3& scale, const Vector2& touchPoint, bool result)
3263     : mScale(scale),
3264       mTouchPoint(touchPoint),
3265       mResult(result)
3266     {
3267     }
3268
3269     Vector3 mScale;
3270     Vector2 mTouchPoint;
3271     bool    mResult;
3272   };
3273
3274   TestApplication application;
3275   tet_infoline(" UtcDaliActorHitTest");
3276
3277   // Fill a vector with different hit tests.
3278   struct HitTestData* hitTestData[] = {
3279     //                    scale                     touch point           result
3280     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(289.f, 400.f), true),  // touch point close to the right edge (inside)
3281     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(291.f, 400.f), false), // touch point close to the right edge (outside)
3282     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.
3283     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(200.f, 451.f), false), // touch point close to the down edge (outside)
3284     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.
3285     NULL,
3286   };
3287
3288   // get the root layer
3289   Actor actor = Actor::New();
3290   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3291   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3292
3293   application.GetScene().Add(actor);
3294
3295   ResetTouchCallbacks();
3296
3297   unsigned int index = 0;
3298   while(NULL != hitTestData[index])
3299   {
3300     actor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f));
3301     actor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z));
3302
3303     // flush the queue and render once
3304     application.SendNotification();
3305     application.Render();
3306
3307     DALI_TEST_CHECK(!gTouchCallBackCalled);
3308
3309     // connect to its touch signal
3310     actor.TouchedSignal().Connect(TestTouchCallback);
3311
3312     Dali::Integration::Point point;
3313     point.SetState(PointState::DOWN);
3314     point.SetScreenPosition(Vector2(hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y));
3315     Dali::Integration::TouchEvent event;
3316     event.AddPoint(point);
3317
3318     // flush the queue and render once
3319     application.SendNotification();
3320     application.Render();
3321     application.ProcessEvent(event);
3322
3323     DALI_TEST_CHECK(gTouchCallBackCalled == hitTestData[index]->mResult);
3324
3325     if(gTouchCallBackCalled != hitTestData[index]->mResult)
3326       tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
3327                  hitTestData[index]->mScale.x,
3328                  hitTestData[index]->mScale.y,
3329                  hitTestData[index]->mScale.z,
3330                  hitTestData[index]->mTouchPoint.x,
3331                  hitTestData[index]->mTouchPoint.y,
3332                  hitTestData[index]->mResult);
3333
3334     ResetTouchCallbacks();
3335     ++index;
3336   }
3337   END_TEST;
3338 }
3339
3340 int UtcDaliActorSetDrawMode(void)
3341 {
3342   TestApplication application;
3343   tet_infoline(" UtcDaliActorSetDrawModeOverlay");
3344
3345   Actor a = Actor::New();
3346
3347   application.GetScene().Add(a);
3348   application.SendNotification();
3349   application.Render(0);
3350   application.SendNotification();
3351   application.Render(1);
3352
3353   DALI_TEST_CHECK(DrawMode::NORMAL == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Ensure overlay is off by default
3354
3355   a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3356   application.SendNotification();
3357   application.Render(1);
3358
3359   DALI_TEST_CHECK(DrawMode::OVERLAY_2D == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Check Actor is overlay
3360
3361   a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::NORMAL);
3362   application.SendNotification();
3363   application.Render(1);
3364
3365   DALI_TEST_CHECK(DrawMode::NORMAL == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Check Actor is normal
3366   END_TEST;
3367 }
3368
3369 int UtcDaliActorSetDrawModeOverlayRender(void)
3370 {
3371   TestApplication application;
3372   tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
3373
3374   application.SendNotification();
3375   application.Render(1);
3376
3377   std::vector<GLuint> ids;
3378   ids.push_back(8);  // first rendered actor
3379   ids.push_back(9);  // second rendered actor
3380   ids.push_back(10); // third rendered actor
3381   application.GetGlAbstraction().SetNextTextureIds(ids);
3382
3383   Texture imageA = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
3384   Texture imageB = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
3385   Texture imageC = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
3386   Actor   a      = CreateRenderableActor(imageA);
3387   Actor   b      = CreateRenderableActor(imageB);
3388   Actor   c      = CreateRenderableActor(imageC);
3389
3390   application.SendNotification();
3391   application.Render(1);
3392
3393   //Textures are bound when first created. Clear bound textures vector
3394   application.GetGlAbstraction().ClearBoundTextures();
3395
3396   // Render a,b,c as regular non-overlays. so order will be:
3397   // a (8)
3398   // b (9)
3399   // c (10)
3400   application.GetScene().Add(a);
3401   application.GetScene().Add(b);
3402   application.GetScene().Add(c);
3403
3404   application.SendNotification();
3405   application.Render(1);
3406
3407   // Should be 3 textures changes.
3408   const std::vector<GLuint>&             boundTextures = application.GetGlAbstraction().GetBoundTextures(GL_TEXTURE0);
3409   typedef std::vector<GLuint>::size_type TextureSize;
3410   DALI_TEST_EQUALS(boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION);
3411   if(boundTextures.size() == 3)
3412   {
3413     DALI_TEST_CHECK(boundTextures[0] == 8u);
3414     DALI_TEST_CHECK(boundTextures[1] == 9u);
3415     DALI_TEST_CHECK(boundTextures[2] == 10u);
3416   }
3417
3418   // Now texture ids have been set, we can monitor their render order.
3419   // render a as an overlay (last), so order will be:
3420   // b (9)
3421   // c (10)
3422   // a (8)
3423   a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3424   application.GetGlAbstraction().ClearBoundTextures();
3425
3426   application.SendNotification();
3427   application.Render(1);
3428
3429   // Should be 3 texture changes.
3430   DALI_TEST_EQUALS(boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION);
3431   if(boundTextures.size() == 3)
3432   {
3433     DALI_TEST_CHECK(boundTextures[0] == 9u);
3434     DALI_TEST_CHECK(boundTextures[1] == 10u);
3435     DALI_TEST_CHECK(boundTextures[2] == 8u);
3436   }
3437   END_TEST;
3438 }
3439
3440 int UtcDaliActorGetCurrentWorldMatrix(void)
3441 {
3442   TestApplication application;
3443   tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
3444
3445   Actor parent = Actor::New();
3446   parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3447   parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3448   Vector3    parentPosition(10.0f, 20.0f, 30.0f);
3449   Radian     rotationAngle(Degree(85.0f));
3450   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3451   Vector3    parentScale(1.0f, 2.0f, 3.0f);
3452   parent.SetProperty(Actor::Property::POSITION, parentPosition);
3453   parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3454   parent.SetProperty(Actor::Property::SCALE, parentScale);
3455   application.GetScene().Add(parent);
3456
3457   Actor child = Actor::New();
3458   child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3459   Vector3    childPosition(0.0f, 0.0f, 100.0f);
3460   Radian     childRotationAngle(Degree(23.0f));
3461   Quaternion childRotation(childRotationAngle, Vector3::YAXIS);
3462   Vector3    childScale(2.0f, 2.0f, 2.0f);
3463   child.SetProperty(Actor::Property::POSITION, childPosition);
3464   child.SetProperty(Actor::Property::ORIENTATION, childRotation);
3465   child.SetProperty(Actor::Property::SCALE, childScale);
3466   parent.Add(child);
3467
3468   application.SendNotification();
3469   application.Render(0);
3470   application.Render();
3471   application.SendNotification();
3472
3473   Matrix parentMatrix(false);
3474   parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3475
3476   Matrix childMatrix(false);
3477   childMatrix.SetTransformComponents(childScale, childRotation, childPosition);
3478
3479   //Child matrix should be the composition of child and parent
3480   Matrix childWorldMatrix(false);
3481   Matrix::Multiply(childWorldMatrix, childMatrix, parentMatrix);
3482
3483   DALI_TEST_EQUALS(parent.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), parentMatrix, 0.001, TEST_LOCATION);
3484   DALI_TEST_EQUALS(child.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), childWorldMatrix, 0.001, TEST_LOCATION);
3485   END_TEST;
3486 }
3487
3488 int UtcDaliActorConstrainedToWorldMatrix(void)
3489 {
3490   TestApplication application;
3491   tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
3492
3493   Actor parent = Actor::New();
3494   parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3495   parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3496   Vector3    parentPosition(10.0f, 20.0f, 30.0f);
3497   Radian     rotationAngle(Degree(85.0f));
3498   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3499   Vector3    parentScale(1.0f, 2.0f, 3.0f);
3500   parent.SetProperty(Actor::Property::POSITION, parentPosition);
3501   parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3502   parent.SetProperty(Actor::Property::SCALE, parentScale);
3503   application.GetScene().Add(parent);
3504
3505   Actor child = Actor::New();
3506   child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3507   Constraint posConstraint = Constraint::New<Vector3>(child, Actor::Property::POSITION, PositionComponentConstraint());
3508   posConstraint.AddSource(Source(parent, Actor::Property::WORLD_MATRIX));
3509   posConstraint.Apply();
3510
3511   application.GetScene().Add(child);
3512
3513   application.SendNotification();
3514   application.Render(0);
3515   application.Render();
3516   application.SendNotification();
3517
3518   Matrix parentMatrix(false);
3519   parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3520
3521   DALI_TEST_EQUALS(parent.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), parentMatrix, 0.001, TEST_LOCATION);
3522   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), 0.001, TEST_LOCATION);
3523   END_TEST;
3524 }
3525
3526 int UtcDaliActorConstrainedToOrientation(void)
3527 {
3528   TestApplication application;
3529   tet_infoline(" UtcDaliActorConstrainedToOrientation");
3530
3531   Actor parent = Actor::New();
3532   parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3533   parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3534   Vector3    parentPosition(10.0f, 20.0f, 30.0f);
3535   Radian     rotationAngle(Degree(85.0f));
3536   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3537   Vector3    parentScale(1.0f, 2.0f, 3.0f);
3538   parent.SetProperty(Actor::Property::POSITION, parentPosition);
3539   parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3540   parent.SetProperty(Actor::Property::SCALE, parentScale);
3541   application.GetScene().Add(parent);
3542
3543   Actor child = Actor::New();
3544   child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3545   Constraint posConstraint = Constraint::New<Quaternion>(child, Actor::Property::ORIENTATION, OrientationComponentConstraint());
3546   posConstraint.AddSource(Source(parent, Actor::Property::ORIENTATION));
3547   posConstraint.Apply();
3548
3549   application.GetScene().Add(child);
3550
3551   application.SendNotification();
3552   application.Render(0);
3553   application.Render();
3554   application.SendNotification();
3555
3556   DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), parent.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
3557   END_TEST;
3558 }
3559
3560 int UtcDaliActorConstrainedToOpacity(void)
3561 {
3562   TestApplication application;
3563   tet_infoline(" UtcDaliActorConstrainedToOpacity");
3564
3565   Actor parent = Actor::New();
3566   parent.SetProperty(Actor::Property::OPACITY, 0.7f);
3567   application.GetScene().Add(parent);
3568
3569   Actor      child             = Actor::New();
3570   Constraint opacityConstraint = Constraint::New<float>(child, Actor::Property::OPACITY, EqualToConstraint());
3571   opacityConstraint.AddSource(Source(parent, Actor::Property::OPACITY));
3572   opacityConstraint.Apply();
3573
3574   application.GetScene().Add(child);
3575
3576   application.SendNotification();
3577   application.Render(0);
3578   application.Render();
3579   application.SendNotification();
3580
3581   DALI_TEST_EQUALS(child.GetCurrentProperty<float>(Actor::Property::OPACITY), parent.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.001f, TEST_LOCATION);
3582
3583   parent.SetProperty(Actor::Property::OPACITY, 0.3f);
3584
3585   application.SendNotification();
3586   application.Render(0);
3587   application.Render();
3588   application.SendNotification();
3589
3590   DALI_TEST_EQUALS(child.GetCurrentProperty<float>(Actor::Property::OPACITY), parent.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.001f, TEST_LOCATION);
3591
3592   END_TEST;
3593 }
3594
3595 int UtcDaliActorUnparent(void)
3596 {
3597   TestApplication application;
3598   tet_infoline(" UtcDaliActorUnparent");
3599
3600   Actor parent = Actor::New();
3601   application.GetScene().Add(parent);
3602
3603   Actor child = Actor::New();
3604
3605   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3606   DALI_TEST_CHECK(!child.GetParent());
3607
3608   // Test that calling Unparent with no parent is a NOOP
3609   child.Unparent();
3610
3611   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3612   DALI_TEST_CHECK(!child.GetParent());
3613
3614   // Test that Unparent works
3615   parent.Add(child);
3616
3617   DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
3618   DALI_TEST_CHECK(parent == child.GetParent());
3619
3620   child.Unparent();
3621
3622   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3623   DALI_TEST_CHECK(!child.GetParent());
3624
3625   // Test that UnparentAndReset works
3626   parent.Add(child);
3627
3628   DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
3629   DALI_TEST_CHECK(parent == child.GetParent());
3630
3631   UnparentAndReset(child);
3632
3633   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3634   DALI_TEST_CHECK(!child);
3635
3636   // Test that UnparentAndReset is a NOOP with empty handle
3637   UnparentAndReset(child);
3638
3639   DALI_TEST_CHECK(!child);
3640   END_TEST;
3641 }
3642
3643 int UtcDaliActorGetChildAt(void)
3644 {
3645   TestApplication application;
3646   tet_infoline(" UtcDaliActorGetChildAt");
3647
3648   Actor parent = Actor::New();
3649   application.GetScene().Add(parent);
3650
3651   Actor child0 = Actor::New();
3652   parent.Add(child0);
3653
3654   Actor child1 = Actor::New();
3655   parent.Add(child1);
3656
3657   Actor child2 = Actor::New();
3658   parent.Add(child2);
3659
3660   DALI_TEST_EQUALS(parent.GetChildAt(0), child0, TEST_LOCATION);
3661   DALI_TEST_EQUALS(parent.GetChildAt(1), child1, TEST_LOCATION);
3662   DALI_TEST_EQUALS(parent.GetChildAt(2), child2, TEST_LOCATION);
3663   END_TEST;
3664 }
3665
3666 int UtcDaliActorSetGetOverlay(void)
3667 {
3668   TestApplication application;
3669   tet_infoline(" UtcDaliActorSetGetOverlay");
3670
3671   Actor parent = Actor::New();
3672   parent.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3673   DALI_TEST_CHECK(parent.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE) == DrawMode::OVERLAY_2D);
3674   END_TEST;
3675 }
3676
3677 int UtcDaliActorCreateDestroy(void)
3678 {
3679   Actor* actor = new Actor;
3680   DALI_TEST_CHECK(actor);
3681   delete actor;
3682   END_TEST;
3683 }
3684
3685 namespace
3686 {
3687 struct PropertyStringIndex
3688 {
3689   const char* const     name;
3690   const Property::Index index;
3691   const Property::Type  type;
3692 };
3693
3694 const PropertyStringIndex PROPERTY_TABLE[] =
3695   {
3696     {"parentOrigin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3},
3697     {"parentOriginX", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT},
3698     {"parentOriginY", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT},
3699     {"parentOriginZ", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT},
3700     {"anchorPoint", Actor::Property::ANCHOR_POINT, Property::VECTOR3},
3701     {"anchorPointX", Actor::Property::ANCHOR_POINT_X, Property::FLOAT},
3702     {"anchorPointY", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT},
3703     {"anchorPointZ", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT},
3704     {"size", Actor::Property::SIZE, Property::VECTOR3},
3705     {"sizeWidth", Actor::Property::SIZE_WIDTH, Property::FLOAT},
3706     {"sizeHeight", Actor::Property::SIZE_HEIGHT, Property::FLOAT},
3707     {"sizeDepth", Actor::Property::SIZE_DEPTH, Property::FLOAT},
3708     {"position", Actor::Property::POSITION, Property::VECTOR3},
3709     {"positionX", Actor::Property::POSITION_X, Property::FLOAT},
3710     {"positionY", Actor::Property::POSITION_Y, Property::FLOAT},
3711     {"positionZ", Actor::Property::POSITION_Z, Property::FLOAT},
3712     {"worldPosition", Actor::Property::WORLD_POSITION, Property::VECTOR3},
3713     {"worldPositionX", Actor::Property::WORLD_POSITION_X, Property::FLOAT},
3714     {"worldPositionY", Actor::Property::WORLD_POSITION_Y, Property::FLOAT},
3715     {"worldPositionZ", Actor::Property::WORLD_POSITION_Z, Property::FLOAT},
3716     {"orientation", Actor::Property::ORIENTATION, Property::ROTATION},
3717     {"worldOrientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION},
3718     {"scale", Actor::Property::SCALE, Property::VECTOR3},
3719     {"scaleX", Actor::Property::SCALE_X, Property::FLOAT},
3720     {"scaleY", Actor::Property::SCALE_Y, Property::FLOAT},
3721     {"scaleZ", Actor::Property::SCALE_Z, Property::FLOAT},
3722     {"worldScale", Actor::Property::WORLD_SCALE, Property::VECTOR3},
3723     {"visible", Actor::Property::VISIBLE, Property::BOOLEAN},
3724     {"color", Actor::Property::COLOR, Property::VECTOR4},
3725     {"colorRed", Actor::Property::COLOR_RED, Property::FLOAT},
3726     {"colorGreen", Actor::Property::COLOR_GREEN, Property::FLOAT},
3727     {"colorBlue", Actor::Property::COLOR_BLUE, Property::FLOAT},
3728     {"colorAlpha", Actor::Property::COLOR_ALPHA, Property::FLOAT},
3729     {"worldColor", Actor::Property::WORLD_COLOR, Property::VECTOR4},
3730     {"worldMatrix", Actor::Property::WORLD_MATRIX, Property::MATRIX},
3731     {"name", Actor::Property::NAME, Property::STRING},
3732     {"sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN},
3733     {"leaveRequired", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN},
3734     {"inheritOrientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN},
3735     {"inheritScale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN},
3736     {"colorMode", Actor::Property::COLOR_MODE, Property::INTEGER},
3737     {"drawMode", Actor::Property::DRAW_MODE, Property::INTEGER},
3738     {"sizeModeFactor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3},
3739     {"widthResizePolicy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING},
3740     {"heightResizePolicy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING},
3741     {"sizeScalePolicy", Actor::Property::SIZE_SCALE_POLICY, Property::INTEGER},
3742     {"widthForHeight", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN},
3743     {"heightForWidth", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN},
3744     {"padding", Actor::Property::PADDING, Property::VECTOR4},
3745     {"minimumSize", Actor::Property::MINIMUM_SIZE, Property::VECTOR2},
3746     {"maximumSize", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2},
3747     {"inheritPosition", Actor::Property::INHERIT_POSITION, Property::BOOLEAN},
3748     {"clippingMode", Actor::Property::CLIPPING_MODE, Property::STRING},
3749     {"opacity", Actor::Property::OPACITY, Property::FLOAT},
3750 };
3751 const unsigned int PROPERTY_TABLE_COUNT = sizeof(PROPERTY_TABLE) / sizeof(PROPERTY_TABLE[0]);
3752 } // unnamed namespace
3753
3754 int UtcDaliActorProperties(void)
3755 {
3756   TestApplication application;
3757
3758   Actor actor = Actor::New();
3759
3760   for(unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i)
3761   {
3762     tet_printf("Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index);
3763     DALI_TEST_EQUALS(actor.GetPropertyName(PROPERTY_TABLE[i].index), PROPERTY_TABLE[i].name, TEST_LOCATION);
3764     DALI_TEST_EQUALS(actor.GetPropertyIndex(PROPERTY_TABLE[i].name), PROPERTY_TABLE[i].index, TEST_LOCATION);
3765     DALI_TEST_EQUALS(actor.GetPropertyType(PROPERTY_TABLE[i].index), PROPERTY_TABLE[i].type, TEST_LOCATION);
3766   }
3767   END_TEST;
3768 }
3769
3770 int UtcDaliRelayoutProperties_ResizePolicies(void)
3771 {
3772   TestApplication application;
3773
3774   Actor actor = Actor::New();
3775
3776   // Defaults
3777   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_RESIZE_POLICY).Get<std::string>(), "USE_NATURAL_SIZE", TEST_LOCATION);
3778   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_RESIZE_POLICY).Get<std::string>(), "USE_NATURAL_SIZE", TEST_LOCATION);
3779
3780   // Set resize policy for all dimensions
3781   actor.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
3782   for(unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
3783   {
3784     DALI_TEST_EQUALS(actor.GetResizePolicy(static_cast<Dimension::Type>(1 << i)), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION);
3785   }
3786
3787   // Set individual dimensions
3788   const char* const widthPolicy  = "FILL_TO_PARENT";
3789   const char* const heightPolicy = "FIXED";
3790
3791   actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy);
3792   actor.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy);
3793
3794   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_RESIZE_POLICY).Get<std::string>(), widthPolicy, TEST_LOCATION);
3795   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_RESIZE_POLICY).Get<std::string>(), heightPolicy, TEST_LOCATION);
3796
3797   // Set individual dimensions using enums
3798   ResizePolicy::Type widthPolicyEnum  = ResizePolicy::USE_ASSIGNED_SIZE;
3799   ResizePolicy::Type heightPolicyEnum = ResizePolicy::SIZE_RELATIVE_TO_PARENT;
3800
3801   actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, widthPolicyEnum);
3802   actor.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicyEnum);
3803
3804   DALI_TEST_EQUALS(static_cast<int>(actor.GetResizePolicy(Dimension::WIDTH)), static_cast<int>(widthPolicyEnum), TEST_LOCATION);
3805   DALI_TEST_EQUALS(static_cast<int>(actor.GetResizePolicy(Dimension::HEIGHT)), static_cast<int>(heightPolicyEnum), TEST_LOCATION);
3806
3807   END_TEST;
3808 }
3809
3810 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
3811 {
3812   TestApplication application;
3813
3814   Actor actor = Actor::New();
3815
3816   // Defaults
3817   DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION);
3818
3819   SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3820   actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy);
3821   DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy, TEST_LOCATION);
3822
3823   // Set
3824   const SizeScalePolicy::Type policy1 = SizeScalePolicy::FIT_WITH_ASPECT_RATIO;
3825   const SizeScalePolicy::Type policy2 = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3826
3827   actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy1);
3828   DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy1, TEST_LOCATION);
3829
3830   actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy2);
3831   DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy2, TEST_LOCATION);
3832
3833   END_TEST;
3834 }
3835
3836 int UtcDaliRelayoutProperties_SizeModeFactor(void)
3837 {
3838   TestApplication application;
3839
3840   Actor actor = Actor::New();
3841
3842   // Defaults
3843   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_MODE_FACTOR).Get<Vector3>(), Vector3(1.0f, 1.0f, 1.0f), TEST_LOCATION);
3844   DALI_TEST_EQUALS(actor.GetProperty<Vector3>(Actor::Property::SIZE_MODE_FACTOR), Vector3(1.0f, 1.0f, 1.0f), TEST_LOCATION);
3845
3846   Vector3 sizeMode(1.0f, 2.0f, 3.0f);
3847   actor.SetProperty(Actor::Property::SIZE_MODE_FACTOR, sizeMode);
3848   DALI_TEST_EQUALS(actor.GetProperty<Vector3>(Actor::Property::SIZE_MODE_FACTOR), sizeMode, TEST_LOCATION);
3849
3850   // Set
3851   Vector3 sizeMode1(2.0f, 3.0f, 4.0f);
3852
3853   actor.SetProperty(Actor::Property::SIZE_MODE_FACTOR, sizeMode1);
3854   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_MODE_FACTOR).Get<Vector3>(), sizeMode1, TEST_LOCATION);
3855
3856   END_TEST;
3857 }
3858
3859 int UtcDaliRelayoutProperties_DimensionDependency(void)
3860 {
3861   TestApplication application;
3862
3863   Actor actor = Actor::New();
3864
3865   // Defaults
3866   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), false, TEST_LOCATION);
3867   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_FOR_WIDTH).Get<bool>(), false, TEST_LOCATION);
3868
3869   // Set
3870   actor.SetProperty(Actor::Property::WIDTH_FOR_HEIGHT, true);
3871   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), true, TEST_LOCATION);
3872
3873   actor.SetProperty(Actor::Property::HEIGHT_FOR_WIDTH, true);
3874   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_FOR_WIDTH).Get<bool>(), true, TEST_LOCATION);
3875
3876   // Test setting another resize policy
3877   actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FIXED");
3878   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), false, TEST_LOCATION);
3879
3880   END_TEST;
3881 }
3882
3883 int UtcDaliRelayoutProperties_Padding(void)
3884 {
3885   TestApplication application;
3886
3887   Actor actor = Actor::New();
3888
3889   // Data
3890   Vector4 padding(1.0f, 2.0f, 3.0f, 4.0f);
3891
3892   // PADDING
3893   actor.SetProperty(Actor::Property::PADDING, padding);
3894   Vector4 paddingResult = actor.GetProperty(Actor::Property::PADDING).Get<Vector4>();
3895
3896   DALI_TEST_EQUALS(paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION);
3897
3898   END_TEST;
3899 }
3900
3901 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
3902 {
3903   TestApplication application;
3904
3905   Actor actor = Actor::New();
3906
3907   // Data
3908   Vector2 minSize(1.0f, 2.0f);
3909
3910   actor.SetProperty(Actor::Property::MINIMUM_SIZE, minSize);
3911   Vector2 resultMin = actor.GetProperty(Actor::Property::MINIMUM_SIZE).Get<Vector2>();
3912
3913   DALI_TEST_EQUALS(resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
3914
3915   Vector2 maxSize(3.0f, 4.0f);
3916
3917   actor.SetProperty(Actor::Property::MAXIMUM_SIZE, maxSize);
3918   Vector2 resultMax = actor.GetProperty(Actor::Property::MAXIMUM_SIZE).Get<Vector2>();
3919
3920   DALI_TEST_EQUALS(resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
3921
3922   END_TEST;
3923 }
3924
3925 int UtcDaliActorGetHeightForWidth(void)
3926 {
3927   TestApplication application;
3928
3929   Actor actor = Actor::New();
3930
3931   DALI_TEST_EQUALS(actor.GetHeightForWidth(1.0f), 1.0f, TEST_LOCATION);
3932
3933   END_TEST;
3934 }
3935
3936 int UtcDaliActorGetWidthForHeight(void)
3937 {
3938   TestApplication application;
3939
3940   Actor actor = Actor::New();
3941
3942   DALI_TEST_EQUALS(actor.GetWidthForHeight(1.0f), 1.0f, TEST_LOCATION);
3943
3944   END_TEST;
3945 }
3946
3947 int UtcDaliActorGetRelayoutSize(void)
3948 {
3949   TestApplication application;
3950
3951   Actor actor = Actor::New();
3952
3953   // Add actor to stage
3954   application.GetScene().Add(actor);
3955
3956   DALI_TEST_EQUALS(actor.GetRelayoutSize(Dimension::WIDTH), 0.0f, TEST_LOCATION);
3957
3958   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::WIDTH);
3959   actor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 0.0f));
3960
3961   // Flush the queue and render once
3962   application.SendNotification();
3963   application.Render();
3964
3965   DALI_TEST_EQUALS(actor.GetRelayoutSize(Dimension::WIDTH), 1.0f, TEST_LOCATION);
3966
3967   END_TEST;
3968 }
3969
3970 int UtcDaliActorSetPadding(void)
3971 {
3972   TestApplication application;
3973
3974   Actor actor = Actor::New();
3975
3976   Padding padding;
3977   padding = actor.GetProperty<Vector4>(Actor::Property::PADDING);
3978
3979   DALI_TEST_EQUALS(padding.left, 0.0f, TEST_LOCATION);
3980   DALI_TEST_EQUALS(padding.right, 0.0f, TEST_LOCATION);
3981   DALI_TEST_EQUALS(padding.bottom, 0.0f, TEST_LOCATION);
3982   DALI_TEST_EQUALS(padding.top, 0.0f, TEST_LOCATION);
3983
3984   Padding padding2(1.0f, 2.0f, 3.0f, 4.0f);
3985   actor.SetProperty(Actor::Property::PADDING, padding2);
3986
3987   padding = actor.GetProperty<Vector4>(Actor::Property::PADDING);
3988
3989   DALI_TEST_EQUALS(padding.left, padding2.left, TEST_LOCATION);
3990   DALI_TEST_EQUALS(padding.right, padding2.right, TEST_LOCATION);
3991   DALI_TEST_EQUALS(padding.bottom, padding2.bottom, TEST_LOCATION);
3992   DALI_TEST_EQUALS(padding.top, padding2.top, TEST_LOCATION);
3993
3994   END_TEST;
3995 }
3996
3997 int UtcDaliActorSetMinimumSize(void)
3998 {
3999   TestApplication application;
4000
4001   Actor actor = Actor::New();
4002
4003   Vector2 size = actor.GetProperty<Vector2>(Actor::Property::MINIMUM_SIZE);
4004
4005   DALI_TEST_EQUALS(size.width, 0.0f, TEST_LOCATION);
4006   DALI_TEST_EQUALS(size.height, 0.0f, TEST_LOCATION);
4007
4008   Vector2 size2(1.0f, 2.0f);
4009   actor.SetProperty(Actor::Property::MINIMUM_SIZE, size2);
4010
4011   size = actor.GetProperty<Vector2>(Actor::Property::MINIMUM_SIZE);
4012
4013   DALI_TEST_EQUALS(size.width, size2.width, TEST_LOCATION);
4014   DALI_TEST_EQUALS(size.height, size2.height, TEST_LOCATION);
4015
4016   END_TEST;
4017 }
4018
4019 int UtcDaliActorSetMaximumSize(void)
4020 {
4021   TestApplication application;
4022
4023   Actor actor = Actor::New();
4024
4025   Vector2 size = actor.GetProperty<Vector2>(Actor::Property::MAXIMUM_SIZE);
4026
4027   DALI_TEST_EQUALS(size.width, FLT_MAX, TEST_LOCATION);
4028   DALI_TEST_EQUALS(size.height, FLT_MAX, TEST_LOCATION);
4029
4030   Vector2 size2(1.0f, 2.0f);
4031   actor.SetProperty(Actor::Property::MAXIMUM_SIZE, size2);
4032
4033   size = actor.GetProperty<Vector2>(Actor::Property::MAXIMUM_SIZE);
4034
4035   DALI_TEST_EQUALS(size.width, size2.width, TEST_LOCATION);
4036   DALI_TEST_EQUALS(size.height, size2.height, TEST_LOCATION);
4037
4038   END_TEST;
4039 }
4040
4041 int UtcDaliActorOnRelayoutSignal(void)
4042 {
4043   tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
4044
4045   TestApplication application;
4046
4047   // Clean test data
4048   gOnRelayoutCallBackCalled = false;
4049   gActorNamesRelayout.clear();
4050
4051   Actor actor = Actor::New();
4052   actor.SetProperty(Actor::Property::NAME, "actor");
4053   actor.OnRelayoutSignal().Connect(OnRelayoutCallback);
4054
4055   // Sanity check
4056   DALI_TEST_CHECK(!gOnRelayoutCallBackCalled);
4057
4058   // Add actor to stage
4059   application.GetScene().Add(actor);
4060
4061   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
4062   actor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 2.0));
4063
4064   // Flush the queue and render once
4065   application.SendNotification();
4066   application.Render();
4067
4068   // OnRelayout emitted
4069   DALI_TEST_EQUALS(gOnRelayoutCallBackCalled, true, TEST_LOCATION);
4070   DALI_TEST_EQUALS("actor", gActorNamesRelayout[0], TEST_LOCATION);
4071
4072   END_TEST;
4073 }
4074
4075 int UtcDaliActorGetHierachyDepth(void)
4076 {
4077   TestApplication application;
4078   tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
4079
4080   /* Build tree of actors:
4081    *
4082    *                      Depth
4083    *
4084    *       A (parent)       1
4085    *      / \
4086    *     B   C              2`
4087    *    / \   \
4088    *   D   E   F            3
4089    *
4090    * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
4091    */
4092   Integration::Scene stage(application.GetScene());
4093
4094   Actor actorA = Actor::New();
4095   Actor actorB = Actor::New();
4096   Actor actorC = Actor::New();
4097   Actor actorD = Actor::New();
4098   Actor actorE = Actor::New();
4099   Actor actorF = Actor::New();
4100
4101   //Test that root actor has depth equal 0
4102   DALI_TEST_EQUALS(0, stage.GetRootLayer().GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4103
4104   //Test actors return depth -1 when not connected to the tree
4105   DALI_TEST_EQUALS(-1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4106   DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4107   DALI_TEST_EQUALS(-1, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4108   DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4109   DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4110   DALI_TEST_EQUALS(-1, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4111
4112   //Create the hierarchy
4113   stage.Add(actorA);
4114   actorA.Add(actorB);
4115   actorA.Add(actorC);
4116   actorB.Add(actorD);
4117   actorB.Add(actorE);
4118   actorC.Add(actorF);
4119
4120   //Test actors return correct depth
4121   DALI_TEST_EQUALS(1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4122   DALI_TEST_EQUALS(2, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4123   DALI_TEST_EQUALS(2, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4124   DALI_TEST_EQUALS(3, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4125   DALI_TEST_EQUALS(3, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4126   DALI_TEST_EQUALS(3, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4127
4128   //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
4129   actorA.Remove(actorB);
4130
4131   DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4132   DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4133   DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4134
4135   //Removing actorA from the stage. All actors should have depth equal -1
4136   stage.Remove(actorA);
4137
4138   DALI_TEST_EQUALS(-1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4139   DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4140   DALI_TEST_EQUALS(-1, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4141   DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4142   DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4143   DALI_TEST_EQUALS(-1, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4144
4145   END_TEST;
4146 }
4147
4148 int UtcDaliActorAnchorPointPropertyAsString(void)
4149 {
4150   TestApplication application;
4151
4152   Actor actor = Actor::New();
4153
4154   actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_LEFT");
4155   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_LEFT, TEST_LOCATION);
4156
4157   actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_CENTER");
4158   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_CENTER, TEST_LOCATION);
4159
4160   actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_RIGHT");
4161   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_RIGHT, TEST_LOCATION);
4162
4163   actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER_LEFT");
4164   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER_LEFT, TEST_LOCATION);
4165
4166   actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER");
4167   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER, TEST_LOCATION);
4168
4169   actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER_RIGHT");
4170   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER_RIGHT, TEST_LOCATION);
4171
4172   actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT");
4173   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION);
4174
4175   actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER");
4176   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION);
4177
4178   actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT");
4179   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
4180
4181   // Invalid should not change anything
4182   actor.SetProperty(Actor::Property::ANCHOR_POINT, "INVALID_ARG");
4183   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
4184
4185   END_TEST;
4186 }
4187
4188 int UtcDaliActorParentOriginPropertyAsString(void)
4189 {
4190   TestApplication application;
4191
4192   Actor actor = Actor::New();
4193
4194   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_LEFT");
4195   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_LEFT, TEST_LOCATION);
4196
4197   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_CENTER");
4198   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_CENTER, TEST_LOCATION);
4199
4200   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_RIGHT");
4201   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_RIGHT, TEST_LOCATION);
4202
4203   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER_LEFT");
4204   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER_LEFT, TEST_LOCATION);
4205
4206   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER");
4207   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER, TEST_LOCATION);
4208
4209   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT");
4210   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER_RIGHT, TEST_LOCATION);
4211
4212   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT");
4213   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION);
4214
4215   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER");
4216   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION);
4217
4218   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT");
4219   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
4220
4221   // Invalid should not change anything
4222   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "INVALID_ARG");
4223   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
4224
4225   END_TEST;
4226 }
4227
4228 int UtcDaliActorColorModePropertyAsString(void)
4229 {
4230   TestApplication application;
4231
4232   Actor actor = Actor::New();
4233
4234   actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_COLOR");
4235   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_COLOR, TEST_LOCATION);
4236
4237   actor.SetProperty(Actor::Property::COLOR_MODE, "USE_PARENT_COLOR");
4238   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_PARENT_COLOR, TEST_LOCATION);
4239
4240   actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR");
4241   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION);
4242
4243   actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA");
4244   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
4245
4246   // Invalid should not change anything
4247   actor.SetProperty(Actor::Property::COLOR_MODE, "INVALID_ARG");
4248   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
4249
4250   END_TEST;
4251 }
4252
4253 int UtcDaliActorDrawModePropertyAsString(void)
4254 {
4255   TestApplication application;
4256
4257   Actor actor = Actor::New();
4258
4259   actor.SetProperty(Actor::Property::DRAW_MODE, "NORMAL");
4260   DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::NORMAL, TEST_LOCATION);
4261
4262   actor.SetProperty(Actor::Property::DRAW_MODE, "OVERLAY_2D");
4263   DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
4264
4265   // Invalid should not change anything
4266   actor.SetProperty(Actor::Property::DRAW_MODE, "INVALID_ARG");
4267   DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
4268
4269   END_TEST;
4270 }
4271
4272 int UtcDaliActorColorModePropertyAsEnum(void)
4273 {
4274   TestApplication application;
4275
4276   Actor actor = Actor::New();
4277
4278   actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
4279   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_COLOR, TEST_LOCATION);
4280
4281   actor.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
4282   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_PARENT_COLOR, TEST_LOCATION);
4283
4284   actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR);
4285   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION);
4286
4287   actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
4288   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
4289
4290   END_TEST;
4291 }
4292
4293 int UtcDaliActorDrawModePropertyAsEnum(void)
4294 {
4295   TestApplication application;
4296
4297   Actor actor = Actor::New();
4298
4299   actor.SetProperty(Actor::Property::DRAW_MODE, DrawMode::NORMAL);
4300   DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::NORMAL, TEST_LOCATION);
4301
4302   actor.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
4303   DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
4304
4305   END_TEST;
4306 }
4307
4308 int UtcDaliActorAddRendererP(void)
4309 {
4310   tet_infoline("Testing Actor::AddRenderer");
4311   TestApplication application;
4312
4313   Actor actor = Actor::New();
4314
4315   DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4316
4317   Geometry geometry = CreateQuadGeometry();
4318   Shader   shader   = CreateShader();
4319   Renderer renderer = Renderer::New(geometry, shader);
4320
4321   actor.AddRenderer(renderer);
4322   DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4323   DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4324
4325   END_TEST;
4326 }
4327
4328 int UtcDaliActorAddRendererN01(void)
4329 {
4330   tet_infoline("Testing Actor::AddRenderer");
4331   TestApplication application;
4332
4333   Actor    actor = Actor::New();
4334   Renderer renderer;
4335
4336   // try illegal Add
4337   try
4338   {
4339     actor.AddRenderer(renderer);
4340     tet_printf("Assertion test failed - no Exception\n");
4341     tet_result(TET_FAIL);
4342   }
4343   catch(Dali::DaliException& e)
4344   {
4345     DALI_TEST_PRINT_ASSERT(e);
4346     DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
4347     DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4348   }
4349   catch(...)
4350   {
4351     tet_printf("Assertion test failed - wrong Exception\n");
4352     tet_result(TET_FAIL);
4353   }
4354
4355   END_TEST;
4356 }
4357
4358 int UtcDaliActorAddRendererN02(void)
4359 {
4360   tet_infoline("UtcDaliActorAddRendererN02");
4361
4362   Actor    actor;
4363   Renderer renderer;
4364
4365   {
4366     TestApplication application;
4367
4368     Geometry geometry = CreateQuadGeometry();
4369     Shader   shader   = CreateShader();
4370     renderer          = Renderer::New(geometry, shader);
4371
4372     actor = Actor::New();
4373   }
4374
4375   // try illegal AddRenderer
4376   try
4377   {
4378     actor.AddRenderer(renderer);
4379     tet_printf("Assertion test failed - no Exception\n");
4380     tet_result(TET_FAIL);
4381   }
4382   catch(Dali::DaliException& e)
4383   {
4384     DALI_TEST_PRINT_ASSERT(e);
4385     DALI_TEST_ASSERT(e, "EventThreadServices::IsCoreRunning()", TEST_LOCATION);
4386   }
4387   catch(...)
4388   {
4389     tet_printf("Assertion test failed - wrong Exception\n");
4390     tet_result(TET_FAIL);
4391   }
4392
4393   END_TEST;
4394 }
4395
4396 int UtcDaliActorAddRendererOnScene(void)
4397 {
4398   tet_infoline("Testing Actor::AddRenderer");
4399   TestApplication application;
4400
4401   Actor actor = Actor::New();
4402   application.GetScene().Add(actor);
4403
4404   application.SendNotification();
4405   application.Render(0);
4406
4407   Geometry geometry = CreateQuadGeometry();
4408   Shader   shader   = CreateShader();
4409   Renderer renderer = Renderer::New(geometry, shader);
4410
4411   application.SendNotification();
4412   application.Render(0);
4413
4414   try
4415   {
4416     actor.AddRenderer(renderer);
4417     tet_result(TET_PASS);
4418   }
4419   catch(...)
4420   {
4421     tet_result(TET_FAIL);
4422   }
4423
4424   END_TEST;
4425 }
4426
4427 int UtcDaliActorRemoveRendererP1(void)
4428 {
4429   tet_infoline("Testing Actor::RemoveRenderer");
4430   TestApplication application;
4431
4432   Actor actor = Actor::New();
4433
4434   DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4435
4436   {
4437     Geometry geometry = CreateQuadGeometry();
4438     Shader   shader   = CreateShader();
4439     Renderer renderer = Renderer::New(geometry, shader);
4440
4441     actor.AddRenderer(renderer);
4442     DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4443     DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4444
4445     application.SendNotification();
4446     application.Render();
4447   }
4448
4449   {
4450     Renderer renderer = actor.GetRendererAt(0);
4451     actor.RemoveRenderer(renderer);
4452     DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4453
4454     application.SendNotification();
4455     application.Render();
4456   }
4457
4458   // Call one final time to ensure that the renderer is actually removed after
4459   // the handle goes out of scope, and excercises the deletion code path in
4460   // scene graph and render.
4461   application.SendNotification();
4462   application.Render();
4463
4464   END_TEST;
4465 }
4466
4467 int UtcDaliActorRemoveRendererP2(void)
4468 {
4469   tet_infoline("Testing Actor::RemoveRenderer");
4470   TestApplication application;
4471
4472   Actor actor = Actor::New();
4473
4474   DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4475
4476   Geometry geometry = CreateQuadGeometry();
4477   Shader   shader   = CreateShader();
4478   Renderer renderer = Renderer::New(geometry, shader);
4479
4480   actor.AddRenderer(renderer);
4481   application.SendNotification();
4482   application.Render();
4483
4484   DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4485   DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4486
4487   actor.RemoveRenderer(0);
4488   application.SendNotification();
4489   application.Render();
4490
4491   DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4492
4493   // Shut down whilst holding onto the renderer handle.
4494   END_TEST;
4495 }
4496
4497 int UtcDaliActorRemoveRendererN(void)
4498 {
4499   tet_infoline("Testing Actor::RemoveRenderer");
4500   TestApplication application;
4501
4502   Actor actor = Actor::New();
4503
4504   DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4505
4506   Geometry geometry = CreateQuadGeometry();
4507   Shader   shader   = CreateShader();
4508   Renderer renderer = Renderer::New(geometry, shader);
4509
4510   actor.AddRenderer(renderer);
4511   DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4512   DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4513
4514   actor.RemoveRenderer(10);
4515   DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4516   DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4517
4518   END_TEST;
4519 }
4520
4521 // Clipping test helper functions:
4522 Actor CreateActorWithContent(uint32_t width, uint32_t height)
4523 {
4524   Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
4525   Actor   actor = CreateRenderableActor(image);
4526
4527   // Setup dimensions and position so actor is not skipped by culling.
4528   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
4529   actor.SetProperty(Actor::Property::SIZE, Vector2(width, height));
4530   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4531   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4532
4533   return actor;
4534 }
4535
4536 Actor CreateActorWithContent16x16()
4537 {
4538   return CreateActorWithContent(16, 16);
4539 }
4540
4541 void GenerateTrace(TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace)
4542 {
4543   enabledDisableTrace.Reset();
4544   stencilTrace.Reset();
4545   enabledDisableTrace.Enable(true);
4546   stencilTrace.Enable(true);
4547
4548   application.SendNotification();
4549   application.Render();
4550
4551   enabledDisableTrace.Enable(false);
4552   stencilTrace.Enable(false);
4553 }
4554
4555 void CheckColorMask(TestGlAbstraction& glAbstraction, bool maskValue)
4556 {
4557   const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
4558
4559   DALI_TEST_EQUALS<bool>(colorMaskParams.red, maskValue, TEST_LOCATION);
4560   DALI_TEST_EQUALS<bool>(colorMaskParams.green, maskValue, TEST_LOCATION);
4561   DALI_TEST_EQUALS<bool>(colorMaskParams.blue, maskValue, TEST_LOCATION);
4562
4563   // @todo only test alpha if the framebuffer has an alpha channel
4564   //DALI_TEST_EQUALS<bool>(colorMaskParams.alpha, maskValue, TEST_LOCATION);
4565 }
4566
4567 int UtcDaliActorPropertyClippingP(void)
4568 {
4569   // This test checks the clippingMode property.
4570   tet_infoline("Testing Actor::Property::ClippingMode: P");
4571   TestApplication application;
4572
4573   Actor actor = Actor::New();
4574
4575   // Check default clippingEnabled value.
4576   Property::Value getValue(actor.GetProperty(Actor::Property::CLIPPING_MODE));
4577
4578   int  value          = 0;
4579   bool getValueResult = getValue.Get(value);
4580   DALI_TEST_CHECK(getValueResult);
4581
4582   if(getValueResult)
4583   {
4584     DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4585   }
4586
4587   // Check setting the property to the stencil mode.
4588   actor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4589
4590   // Check the new value was set.
4591   getValue       = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4592   getValueResult = getValue.Get(value);
4593   DALI_TEST_CHECK(getValueResult);
4594
4595   if(getValueResult)
4596   {
4597     DALI_TEST_EQUALS<int>(value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION);
4598   }
4599
4600   // Check setting the property to the scissor mode.
4601   actor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4602
4603   // Check the new value was set.
4604   getValue       = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4605   getValueResult = getValue.Get(value);
4606   DALI_TEST_CHECK(getValueResult);
4607
4608   if(getValueResult)
4609   {
4610     DALI_TEST_EQUALS<int>(value, ClippingMode::CLIP_TO_BOUNDING_BOX, TEST_LOCATION);
4611   }
4612   END_TEST;
4613 }
4614
4615 int UtcDaliActorPropertyClippingN(void)
4616 {
4617   // Negative test case for Clipping.
4618   tet_infoline("Testing Actor::Property::ClippingMode: N");
4619   TestApplication application;
4620
4621   Actor actor = Actor::New();
4622
4623   // Check default clippingEnabled value.
4624   Property::Value getValue(actor.GetProperty(Actor::Property::CLIPPING_MODE));
4625
4626   int  value          = 0;
4627   bool getValueResult = getValue.Get(value);
4628   DALI_TEST_CHECK(getValueResult);
4629
4630   if(getValueResult)
4631   {
4632     DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4633   }
4634
4635   // Check setting an invalid property value won't change the current property value.
4636   actor.SetProperty(Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY");
4637
4638   getValue       = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4639   getValueResult = getValue.Get(value);
4640   DALI_TEST_CHECK(getValueResult);
4641
4642   if(getValueResult)
4643   {
4644     DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4645   }
4646
4647   END_TEST;
4648 }
4649
4650 int UtcDaliActorPropertyClippingActor(void)
4651 {
4652   // This test checks that an actor is correctly setup for clipping.
4653   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor");
4654   TestApplication application;
4655
4656   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4657   TraceCallStack&    stencilTrace        = glAbstraction.GetStencilFunctionTrace();
4658   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4659   size_t             startIndex          = 0u;
4660
4661   // Create a clipping actor.
4662   Actor actorDepth1Clip = CreateActorWithContent16x16();
4663   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4664   application.GetScene().Add(actorDepth1Clip);
4665
4666   // Gather the call trace.
4667   GenerateTrace(application, enabledDisableTrace, stencilTrace);
4668
4669   // Check we are writing to the color buffer.
4670   CheckColorMask(glAbstraction, true);
4671
4672   // Check the stencil buffer was enabled.
4673   std::ostringstream oss;
4674   oss << std::hex << GL_STENCIL_TEST;
4675   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
4676
4677   // Check the stencil buffer was cleared.
4678   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4679
4680   // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4681   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4682   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));
4683   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4684
4685   END_TEST;
4686 }
4687
4688 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
4689 {
4690   // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
4691   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor enable and then disable");
4692   TestApplication application;
4693
4694   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4695   TraceCallStack&    stencilTrace        = glAbstraction.GetStencilFunctionTrace();
4696   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4697   size_t             startIndex          = 0u;
4698
4699   // Create a clipping actor.
4700   Actor actorDepth1Clip = CreateActorWithContent16x16();
4701   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4702   application.GetScene().Add(actorDepth1Clip);
4703
4704   // Gather the call trace.
4705   GenerateTrace(application, enabledDisableTrace, stencilTrace);
4706
4707   // Check we are writing to the color buffer.
4708   CheckColorMask(glAbstraction, true);
4709
4710   // Check the stencil buffer was enabled.
4711   std::ostringstream oss;
4712   oss << std::hex << GL_STENCIL_TEST;
4713   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
4714
4715   // Check the stencil buffer was cleared.
4716   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4717
4718   // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4719   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4720   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));
4721   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4722
4723   // Now disable the clipping
4724   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED);
4725
4726   // Gather the call trace.
4727   GenerateTrace(application, enabledDisableTrace, stencilTrace);
4728
4729   // Check the stencil buffer was disabled.
4730   std::ostringstream stencil;
4731   stencil << std::hex << GL_STENCIL_TEST;
4732   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Disable", stencil.str()));
4733
4734   // Ensure all values in stencil-mask are set to 1.
4735   startIndex = 0u;
4736   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "255", startIndex));
4737
4738   END_TEST;
4739 }
4740
4741 int UtcDaliActorPropertyClippingNestedChildren(void)
4742 {
4743   // This test checks that a hierarchy of actors are clipped correctly by
4744   // writing to and reading from the correct bit-planes of the stencil buffer.
4745   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN nested children");
4746   TestApplication    application;
4747   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4748   TraceCallStack&    stencilTrace        = glAbstraction.GetStencilFunctionTrace();
4749   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4750
4751   // Create a clipping actor.
4752   Actor actorDepth1Clip = CreateActorWithContent16x16();
4753   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4754   application.GetScene().Add(actorDepth1Clip);
4755
4756   // Create a child actor.
4757   Actor childDepth2 = CreateActorWithContent16x16();
4758   actorDepth1Clip.Add(childDepth2);
4759
4760   // Create another clipping actor.
4761   Actor childDepth2Clip = CreateActorWithContent16x16();
4762   childDepth2Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4763   childDepth2.Add(childDepth2Clip);
4764
4765   // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
4766   // This tests the sort algorithm.
4767   Actor childDepth3 = CreateActorWithContent16x16();
4768   childDepth2Clip.Add(childDepth3);
4769   Actor childDepth4 = CreateActorWithContent16x16();
4770   childDepth3.Add(childDepth4);
4771
4772   // Gather the call trace.
4773   GenerateTrace(application, enabledDisableTrace, stencilTrace);
4774
4775   // Check we are writing to the color buffer.
4776   CheckColorMask(glAbstraction, true);
4777
4778   // Check the stencil buffer was enabled.
4779   std::ostringstream oss;
4780   oss << std::hex << GL_STENCIL_TEST;
4781   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
4782
4783   // Perform the test twice, once for 2D layer, and once for 3D.
4784   for(unsigned int i = 0u; i < 2u; ++i)
4785   {
4786     size_t startIndex = 0u;
4787
4788     // Check the stencil buffer was cleared.
4789     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4790
4791     // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4792     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex));      // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4793     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));              // Write to the first bit-plane
4794     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4795
4796     // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
4797     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 1", startIndex));      // 514 is GL_EQUAL
4798     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7680, 7680", startIndex)); // GL_KEEP, GL_KEEP, GL_KEEP
4799
4800     // Check we are set up to write to the second bitplane of the stencil buffer (only).
4801     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 3, 1", startIndex));      // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4802     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "3", startIndex));              // Write to second (and previous) bit-planes
4803     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4804
4805     // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4806     // (Both must be set to pass the check).
4807     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 3, 3", startIndex));      // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4808     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7680, 7680", startIndex)); // GL_KEEP, GL_KEEP, GL_KEEP
4809
4810     // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4811     if(i == 0u)
4812     {
4813       application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D);
4814       GenerateTrace(application, enabledDisableTrace, stencilTrace);
4815     }
4816   }
4817
4818   END_TEST;
4819 }
4820
4821 int UtcDaliActorPropertyClippingActorDrawOrder(void)
4822 {
4823   // This test checks that a hierarchy of actors are drawn in the correct order when clipping is enabled.
4824   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN draw order");
4825   TestApplication    application;
4826   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4827   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4828
4829   /* We create a small tree of actors as follows:
4830
4831                            A
4832                           / \
4833      Clipping enabled -> B   D
4834                          |   |
4835                          C   E
4836
4837      The correct draw order is "ABCDE" (the same as if clipping was not enabled).
4838   */
4839   Actor actors[5];
4840   for(int i = 0; i < 5; ++i)
4841   {
4842     Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
4843     Actor   actor = CreateRenderableActor(image);
4844
4845     // Setup dimensions and position so actor is not skipped by culling.
4846     actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
4847     actor.SetProperty(Actor::Property::SIZE, Vector2(16.0f, 16.0f));
4848
4849     if(i == 0)
4850     {
4851       actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4852     }
4853     else
4854     {
4855       float b = i > 2 ? 1.0f : -1.0f;
4856       actor.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0.5 + (0.2f * b), 0.8f, 0.8f));
4857     }
4858
4859     actors[i] = actor;
4860   }
4861
4862   // Enable clipping on the actor at the top of the left branch.
4863   actors[1].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4864
4865   // Build the scene graph.
4866   application.GetScene().Add(actors[0]);
4867
4868   // Left branch:
4869   actors[0].Add(actors[1]);
4870   actors[1].Add(actors[2]);
4871
4872   // Right branch:
4873   actors[0].Add(actors[3]);
4874   actors[3].Add(actors[4]);
4875
4876   // Gather the call trace.
4877   enabledDisableTrace.Reset();
4878   enabledDisableTrace.Enable(true);
4879   application.SendNotification();
4880   application.Render();
4881   enabledDisableTrace.Enable(false);
4882
4883   /* Check stencil is enabled and disabled again (as right-hand branch of tree is drawn).
4884
4885      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
4886            Incorrect enable call trace:  StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960
4887   */
4888   size_t             startIndex = 0u;
4889   std::ostringstream blend;
4890   blend << std::hex << GL_BLEND;
4891   std::ostringstream stencil;
4892   stencil << std::hex << GL_STENCIL_TEST;
4893
4894   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", blend.str(), startIndex));
4895   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", stencil.str(), startIndex));
4896   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", stencil.str(), startIndex));
4897
4898   // Swap the clipping actor from top of left branch to top of right branch.
4899   actors[1].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED);
4900   actors[3].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4901
4902   // Gather the call trace.
4903   enabledDisableTrace.Reset();
4904   enabledDisableTrace.Enable(true);
4905   application.SendNotification();
4906   application.Render();
4907   enabledDisableTrace.Enable(false);
4908
4909   // Check stencil is enabled but NOT disabled again (as right-hand branch of tree is drawn).
4910   // This proves the draw order has remained the same.
4911   startIndex = 0u;
4912   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", stencil.str(), startIndex));
4913   DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", stencil.str(), startIndex));
4914
4915   END_TEST;
4916 }
4917
4918 int UtcDaliActorPropertyScissorClippingActor01(void)
4919 {
4920   // This test checks that an actor is correctly setup for clipping.
4921   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor");
4922   TestApplication application;
4923
4924   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4925   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
4926   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4927
4928   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4929   const Vector2 imageSize(16.0f, 16.0f);
4930
4931   // Create a clipping actor.
4932   Actor clippingActorA = CreateActorWithContent16x16();
4933   // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4934   // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4935   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
4936   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
4937   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4938   application.GetScene().Add(clippingActorA);
4939
4940   // Gather the call trace.
4941   GenerateTrace(application, enabledDisableTrace, scissorTrace);
4942
4943   // Check we are writing to the color buffer.
4944   CheckColorMask(glAbstraction, true);
4945
4946   // Check scissor test was enabled.
4947
4948   std::ostringstream scissor;
4949   scissor << std::hex << GL_SCISSOR_TEST;
4950   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
4951
4952   // Check the scissor was set, and the coordinates are correct.
4953   std::stringstream compareParametersString;
4954   compareParametersString << "0, 0, " << imageSize.x << ", " << imageSize.y;
4955   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
4956
4957   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
4958   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_RIGHT);
4959
4960   // Gather the call trace.
4961   GenerateTrace(application, enabledDisableTrace, scissorTrace);
4962
4963   // Check the scissor was set, and the coordinates are correct.
4964   compareParametersString.str(std::string());
4965   compareParametersString.clear();
4966   compareParametersString << (stageSize.x - imageSize.x) << ", " << (stageSize.y - imageSize.y) << ", " << imageSize.x << ", " << imageSize.y;
4967   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 464, 784, 16, 16
4968
4969   END_TEST;
4970 }
4971
4972 int UtcDaliActorPropertyScissorClippingActor02(void)
4973 {
4974   // This test checks that an actor is correctly setup for clipping.
4975   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor with a transparent renderer");
4976   TestApplication application;
4977
4978   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4979   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
4980   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4981
4982   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4983   const Vector2 actorSize(16.0f, 16.0f);
4984
4985   // Create a clipping actor.
4986   Actor clippingActorA                  = CreateRenderableActor();
4987   clippingActorA[Actor::Property::SIZE] = actorSize;
4988
4989   Renderer renderer = clippingActorA.GetRendererAt(0);
4990   DALI_TEST_CHECK(renderer);
4991
4992   // Make Renderer opacity 0.
4993   renderer[DevelRenderer::Property::OPACITY] = 0.0f;
4994
4995   // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4996   // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4997   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
4998   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
4999   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5000   application.GetScene().Add(clippingActorA);
5001
5002   // Gather the call trace.
5003   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5004
5005   // Check we are writing to the color buffer.
5006   CheckColorMask(glAbstraction, true);
5007
5008   // Check scissor test was enabled.
5009
5010   std::ostringstream scissor;
5011   scissor << std::hex << GL_SCISSOR_TEST;
5012   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5013
5014   // Check the scissor was set, and the coordinates are correct.
5015   std::stringstream compareParametersString;
5016   compareParametersString << "0, 0, " << actorSize.x << ", " << actorSize.y;
5017   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
5018
5019   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
5020   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_RIGHT);
5021
5022   // Gather the call trace.
5023   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5024
5025   // Check the scissor was set, and the coordinates are correct.
5026   compareParametersString.str(std::string());
5027   compareParametersString.clear();
5028   compareParametersString << (stageSize.x - actorSize.x) << ", " << (stageSize.y - actorSize.y) << ", " << actorSize.x << ", " << actorSize.y;
5029   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 464, 784, 16, 16
5030
5031   END_TEST;
5032 }
5033
5034 int UtcDaliActorPropertyScissorClippingActorSiblings(void)
5035 {
5036   // This test checks that an actor is correctly setup for clipping.
5037   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actors which are siblings");
5038   TestApplication application;
5039
5040   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
5041   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
5042   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5043
5044   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
5045   const Vector2 sizeA{stageSize.width, stageSize.height * 0.25f};
5046   const Vector2 sizeB{stageSize.width, stageSize.height * 0.05f};
5047
5048   // Create a clipping actors.
5049   Actor clippingActorA = CreateActorWithContent(sizeA.width, sizeA.height);
5050   Actor clippingActorB = CreateActorWithContent(sizeB.width, sizeB.height);
5051
5052   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5053   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5054   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5055
5056   clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5057   clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5058   clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5059
5060   clippingActorA.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -200.0f, 0.0f));
5061   clippingActorB.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
5062
5063   application.GetScene().Add(clippingActorA);
5064   application.GetScene().Add(clippingActorB);
5065
5066   // Gather the call trace.
5067   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5068
5069   // Check we are writing to the color buffer.
5070   CheckColorMask(glAbstraction, true);
5071
5072   // Check scissor test was enabled.
5073   std::ostringstream scissor;
5074   scissor << std::hex << GL_SCISSOR_TEST;
5075   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5076
5077   // Check the scissor was set, and the coordinates are correct.
5078   std::stringstream compareParametersString;
5079
5080   std::string clipA("0, 500, 480, 200");
5081   std::string clipB("0, 380, 480, 40");
5082
5083   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipA));
5084   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipB));
5085
5086   END_TEST;
5087 }
5088
5089 int UtcDaliActorPropertyScissorClippingActorNested01(void)
5090 {
5091   // This test checks that an actor is correctly setup for clipping.
5092   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested");
5093   TestApplication application;
5094
5095   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
5096   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
5097   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5098
5099   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
5100   const Vector2 imageSize(16.0f, 16.0f);
5101
5102   /* Create a nest of 2 scissors to test nesting (intersecting clips).
5103
5104      A is drawn first - with scissor clipping on
5105      B is drawn second - also with scissor clipping on
5106      C is the generated clipping region, the intersection ( A ∩ B )
5107
5108            ┏━━━━━━━┓                   ┌───────┐
5109            ┃     B ┃                   │     B │
5110        ┌───╂┄┄┄┐   ┃               ┌┄┄┄╆━━━┓   │
5111        │   ┃   ┊   ┃     ━━━━━>    ┊   ┃ C ┃   │
5112        │   ┗━━━┿━━━┛               ┊   ┗━━━╃───┘
5113        │ A     │                   ┊ A     ┊
5114        └───────┘                   └┄┄┄┄┄┄┄┘
5115
5116      We then reposition B around each corner of A to test the 4 overlap combinations (thus testing intersecting works correctly).
5117   */
5118
5119   // Create a clipping actor.
5120   Actor clippingActorA = CreateActorWithContent16x16();
5121   // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
5122   // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
5123   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5124   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5125   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5126   application.GetScene().Add(clippingActorA);
5127
5128   // Create a child clipping actor.
5129   Actor clippingActorB = CreateActorWithContent16x16();
5130   clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5131   clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5132   clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5133   clippingActorA.Add(clippingActorB);
5134
5135   // positionModifiers is an array of positions to position B around.
5136   // expect is an array of expected scissor clip coordinate results.
5137   const Vector2 positionModifiers[4] = {Vector2(1.0f, 1.0f), Vector2(-1.0f, 1.0f), Vector2(-1.0f, -1.0f), Vector2(1.0f, -1.0f)};
5138   const Vector4 expect[4]            = {Vector4(240, 392, 8, 8), Vector4(232, 392, 8, 8), Vector4(232, 400, 8, 8), Vector4(240, 400, 8, 8)};
5139
5140   // Loop through each overlap combination.
5141   for(unsigned int test = 0u; test < 4u; ++test)
5142   {
5143     // Position the child clipping actor so it intersects with the 1st clipping actor. This changes each loop.
5144     const Vector2 position = (imageSize / 2.0f) * positionModifiers[test];
5145     clippingActorB.SetProperty(Actor::Property::POSITION, Vector2(position.x, position.y));
5146
5147     // Gather the call trace.
5148     GenerateTrace(application, enabledDisableTrace, scissorTrace);
5149
5150     // Check we are writing to the color buffer.
5151     CheckColorMask(glAbstraction, true);
5152
5153     // Check scissor test was enabled.
5154     std::ostringstream scissor;
5155     scissor << std::hex << GL_SCISSOR_TEST;
5156     DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5157
5158     // Check the scissor was set, and the coordinates are correct.
5159     const Vector4&    expectResults(expect[test]);
5160     std::stringstream compareParametersString;
5161     compareParametersString << expectResults.x << ", " << expectResults.y << ", " << expectResults.z << ", " << expectResults.w;
5162     DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with the expected result
5163   }
5164
5165   END_TEST;
5166 }
5167
5168 int UtcDaliActorPropertyScissorClippingActorNested02(void)
5169 {
5170   // This test checks that an actor is correctly setup for clipping.
5171   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested");
5172   TestApplication application;
5173
5174   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
5175   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
5176   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5177
5178   /* Create a nest of 2 scissors and siblings of the parent.
5179
5180             stage
5181               |
5182         ┌─────┐─────┐
5183         A     C     D
5184         |           |
5185         B           E
5186   */
5187
5188   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
5189   const Vector2 sizeA{stageSize.width, stageSize.height * 0.25f};
5190   const Vector2 sizeB{stageSize.width, stageSize.height * 0.05f};
5191   const Vector2 sizeC{stageSize.width, stageSize.height * 0.25f};
5192   const Vector2 sizeD{stageSize.width, stageSize.height * 0.25f};
5193   const Vector2 sizeE{stageSize.width, stageSize.height * 0.05f};
5194
5195   // Create a clipping actors.
5196   Actor clippingActorA = CreateActorWithContent(sizeA.width, sizeA.height);
5197   Actor clippingActorB = CreateActorWithContent(sizeB.width, sizeB.height);
5198   Actor clippingActorC = CreateActorWithContent(sizeC.width, sizeC.height);
5199   Actor clippingActorD = CreateActorWithContent(sizeD.width, sizeD.height);
5200   Actor clippingActorE = CreateActorWithContent(sizeE.width, sizeE.height);
5201
5202   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5203   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5204   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5205
5206   clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5207   clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5208   clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5209
5210   clippingActorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5211   clippingActorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5212   clippingActorC.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5213
5214   clippingActorD.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5215   clippingActorD.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5216   clippingActorD.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5217
5218   clippingActorE.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5219   clippingActorE.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5220
5221   clippingActorA.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -200.0f, 0.0f));
5222   clippingActorB.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
5223   clippingActorC.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 100.0f, 0.0f));
5224   clippingActorD.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
5225   clippingActorE.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
5226
5227   application.GetScene().Add(clippingActorA);
5228   clippingActorA.Add(clippingActorB);
5229   application.GetScene().Add(clippingActorC);
5230   application.GetScene().Add(clippingActorD);
5231   clippingActorD.Add(clippingActorE);
5232
5233   // Gather the call trace.
5234   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5235
5236   // Check we are writing to the color buffer.
5237   CheckColorMask(glAbstraction, true);
5238
5239   // Check scissor test was enabled.
5240   std::ostringstream scissor;
5241   scissor << std::hex << GL_SCISSOR_TEST;
5242   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5243
5244   // Check the scissor was set, and the coordinates are correct.
5245   std::string clipA("0, 500, 480, 200");
5246   std::string clipB("0, 580, 480, 40");
5247   std::string clipC("0, 200, 480, 200");
5248   std::string clipD("0, 300, 480, 200");
5249
5250   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipA));
5251   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipB));
5252   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipC));
5253   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipD));
5254   DALI_TEST_EQUALS(scissorTrace.CountMethod("Scissor"), 4, TEST_LOCATION); // Scissor rect should not be changed in clippingActorE case. So count should be 4.
5255
5256   END_TEST;
5257 }
5258
5259 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
5260 {
5261   // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
5262   tet_infoline("Testing Actor::Property::CLIPPING_MODE actor with renderer override");
5263   TestApplication application;
5264
5265   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
5266   TraceCallStack&    stencilTrace        = glAbstraction.GetStencilFunctionTrace();
5267   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5268
5269   // Create a clipping actor.
5270   Actor actorDepth1Clip = CreateActorWithContent16x16();
5271   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
5272   application.GetScene().Add(actorDepth1Clip);
5273
5274   // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
5275   actorDepth1Clip.GetRendererAt(0).SetProperty(Renderer::Property::RENDER_MODE, RenderMode::COLOR);
5276
5277   // Gather the call trace.
5278   GenerateTrace(application, enabledDisableTrace, stencilTrace);
5279
5280   // Check we are writing to the color buffer.
5281   CheckColorMask(glAbstraction, true);
5282
5283   // Check the stencil buffer was not enabled.
5284   std::ostringstream stencil;
5285   stencil << std::hex << GL_STENCIL_TEST;
5286   DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", stencil.str()));
5287
5288   // Check stencil functions are not called.
5289   DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilFunc"));
5290   DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilOp"));
5291
5292   // Check that scissor clipping is overriden by the renderer properties.
5293   TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
5294
5295   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5296
5297   // Gather the call trace.
5298   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5299
5300   // Check the stencil buffer was not enabled.
5301   std::ostringstream scissor;
5302   scissor << std::hex << GL_SCISSOR_TEST;
5303   DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5304
5305   DALI_TEST_CHECK(!scissorTrace.FindMethod("StencilFunc"));
5306
5307   END_TEST;
5308 }
5309
5310 int UtcDaliActorPropertyClippingActorCulled(void)
5311 {
5312   // This test checks that child actors are clipped by an culled parent actor.
5313   tet_infoline("Testing child actors are clipped by an culled parent actor");
5314   TestApplication application;
5315
5316   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
5317   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
5318   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5319
5320   const Vector2 actorSize(160.0f, 160.0f);
5321
5322   // Create a clipping actor.
5323   Actor clippingActorA                  = CreateRenderableActor();
5324   clippingActorA[Actor::Property::SIZE] = actorSize;
5325
5326   // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
5327   // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
5328   clippingActorA[Actor::Property::PARENT_ORIGIN] = ParentOrigin::BOTTOM_LEFT;
5329   clippingActorA[Actor::Property::ANCHOR_POINT]  = AnchorPoint::BOTTOM_LEFT;
5330   clippingActorA[Actor::Property::CLIPPING_MODE] = ClippingMode::CLIP_TO_BOUNDING_BOX;
5331   application.GetScene().Add(clippingActorA);
5332
5333   // Create a child actor
5334   Actor childActor                              = CreateRenderableActor();
5335   childActor[Actor::Property::PARENT_ORIGIN]    = ParentOrigin::BOTTOM_LEFT;
5336   childActor[Actor::Property::ANCHOR_POINT]     = AnchorPoint::BOTTOM_LEFT;
5337   childActor[Actor::Property::SIZE]             = Vector2(50.0f, 50.0f);
5338   childActor[Actor::Property::INHERIT_POSITION] = false;
5339
5340   // Gather the call trace.
5341   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5342
5343   // Check scissor test was enabled.
5344   std::ostringstream scissor;
5345   scissor << std::hex << GL_SCISSOR_TEST;
5346   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5347
5348   // Check the scissor was set, and the coordinates are correct.
5349   std::stringstream compareParametersString;
5350   compareParametersString << "0, 0, " << actorSize.x << ", " << actorSize.y;
5351   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
5352
5353   // Move the clipping actor out of screen
5354   clippingActorA[Actor::Property::POSITION] = Vector2(2000.0f, 2000.0f);
5355
5356   // Gather the call trace.
5357   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5358
5359   // Check the scissor was set, and the coordinates are correct.
5360   compareParametersString.str(std::string());
5361   compareParametersString.clear();
5362   compareParametersString << 2000 << ", " << 0 << ", " << 0 << ", " << 0;
5363   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Clipping area should be empty.
5364
5365   END_TEST;
5366 }
5367
5368 int UtcDaliGetPropertyN(void)
5369 {
5370   tet_infoline("Testing Actor::GetProperty returns a non valid value if property index is out of range");
5371   TestApplication application;
5372
5373   Actor actor = Actor::New();
5374
5375   unsigned int propertyCount = actor.GetPropertyCount();
5376   DALI_TEST_EQUALS(actor.GetProperty(Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION);
5377   END_TEST;
5378 }
5379
5380 int UtcDaliActorRaiseLower(void)
5381 {
5382   tet_infoline("UtcDaliActor Raise and Lower test\n");
5383
5384   TestApplication application;
5385
5386   Debug::Filter::SetGlobalLogLevel(Debug::Verbose);
5387
5388   Integration::Scene stage(application.GetScene());
5389
5390   Actor actorA = Actor::New();
5391   Actor actorB = Actor::New();
5392   Actor actorC = Actor::New();
5393
5394   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5395   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5396
5397   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5398   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5399
5400   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5401   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5402
5403   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5404   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5405
5406   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5407   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5408
5409   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5410   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5411
5412   stage.Add(actorA);
5413   stage.Add(actorB);
5414   stage.Add(actorC);
5415
5416   ResetTouchCallbacks();
5417
5418   application.SendNotification();
5419   application.Render();
5420
5421   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5422   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5423   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5424
5425   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5426   // Only top actor will get touched.
5427   actorA.TouchedSignal().Connect(TestTouchCallback);
5428   actorB.TouchedSignal().Connect(TestTouchCallback2);
5429   actorC.TouchedSignal().Connect(TestTouchCallback3);
5430
5431   // Connect ChildOrderChangedSignal
5432   bool                     orderChangedSignal(false);
5433   Actor                    orderChangedActor;
5434   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5435   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5436
5437   Dali::Integration::Point point;
5438   point.SetDeviceId(1);
5439   point.SetState(PointState::DOWN);
5440   point.SetScreenPosition(Vector2(10.f, 10.f));
5441   Dali::Integration::TouchEvent touchEvent;
5442   touchEvent.AddPoint(point);
5443
5444   application.ProcessEvent(touchEvent);
5445
5446   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5447   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5448   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5449
5450   ResetTouchCallbacks();
5451
5452   tet_printf("Testing Raising of Actor\n");
5453
5454   int preActorOrder(0);
5455   int postActorOrder(0);
5456
5457   Property::Value value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5458   value.Get(preActorOrder);
5459
5460   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5461   actorB.Raise();
5462   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5463   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5464
5465   // Ensure sort order is calculated before next touch event
5466   application.SendNotification();
5467
5468   value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5469   value.Get(postActorOrder);
5470
5471   tet_printf("Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder);
5472
5473   application.ProcessEvent(touchEvent);
5474
5475   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5476   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5477   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5478
5479   ResetTouchCallbacks();
5480
5481   tet_printf("Testing Lowering of Actor\n");
5482
5483   value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5484   value.Get(preActorOrder);
5485
5486   orderChangedSignal = false;
5487
5488   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5489   actorB.Lower();
5490   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5491   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5492
5493   application.SendNotification(); // ensure sort order calculated before next touch event
5494
5495   value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5496   value.Get(postActorOrder);
5497
5498   tet_printf("Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder);
5499
5500   application.ProcessEvent(touchEvent);
5501
5502   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5503   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5504   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5505
5506   ResetTouchCallbacks();
5507
5508   Debug::Filter::SetGlobalLogLevel(Debug::NoLogging);
5509
5510   END_TEST;
5511 }
5512
5513 int UtcDaliActorRaiseToTopLowerToBottom(void)
5514 {
5515   tet_infoline("UtcDaliActorRaiseToTop and LowerToBottom test \n");
5516
5517   TestApplication application;
5518
5519   Integration::Scene stage(application.GetScene());
5520
5521   Actor actorA = Actor::New();
5522   Actor actorB = Actor::New();
5523   Actor actorC = Actor::New();
5524
5525   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5526   // enables checking of which actor the uniform is assigned too
5527   Shader shaderA = CreateShader();
5528   shaderA.RegisterProperty("uRendererColor", 1.f);
5529
5530   Shader shaderB = CreateShader();
5531   shaderB.RegisterProperty("uRendererColor", 2.f);
5532
5533   Shader shaderC = CreateShader();
5534   shaderC.RegisterProperty("uRendererColor", 3.f);
5535
5536   Geometry geometry = CreateQuadGeometry();
5537
5538   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5539   Renderer rendererA = Renderer::New(geometry, shaderA);
5540   actorA.AddRenderer(rendererA);
5541
5542   Renderer rendererB = Renderer::New(geometry, shaderB);
5543   actorB.AddRenderer(rendererB);
5544
5545   Renderer rendererC = Renderer::New(geometry, shaderC);
5546   actorC.AddRenderer(rendererC);
5547
5548   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5549   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5550
5551   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5552   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5553
5554   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5555   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5556
5557   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5558   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5559
5560   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5561   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5562
5563   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5564   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5565
5566   stage.Add(actorA);
5567   stage.Add(actorB);
5568   stage.Add(actorC);
5569
5570   ResetTouchCallbacks();
5571
5572   // Connect ChildOrderChangedSignal
5573   bool                     orderChangedSignal(false);
5574   Actor                    orderChangedActor;
5575   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5576   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5577
5578   // Set up gl abstraction trace so can query the set uniform order
5579   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5580   glAbstraction.EnableSetUniformCallTrace(true);
5581   glAbstraction.ResetSetUniformCallStack();
5582
5583   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5584
5585   application.SendNotification();
5586   application.Render();
5587
5588   tet_printf("Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str());
5589
5590   // Test order of uniforms in stack
5591   int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5592   int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5593   int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5594
5595   bool CBA = (indexC > indexB) && (indexB > indexA);
5596
5597   DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
5598
5599   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5600   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5601   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5602
5603   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5604   // Only top actor will get touched.
5605   actorA.TouchedSignal().Connect(TestTouchCallback);
5606   actorB.TouchedSignal().Connect(TestTouchCallback2);
5607   actorC.TouchedSignal().Connect(TestTouchCallback3);
5608
5609   Dali::Integration::Point point;
5610   point.SetDeviceId(1);
5611   point.SetState(PointState::DOWN);
5612   point.SetScreenPosition(Vector2(10.f, 10.f));
5613   Dali::Integration::TouchEvent touchEvent;
5614   touchEvent.AddPoint(point);
5615
5616   application.ProcessEvent(touchEvent);
5617
5618   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5619   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5620   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5621
5622   ResetTouchCallbacks();
5623
5624   tet_printf("RaiseToTop ActorA\n");
5625
5626   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5627   actorA.RaiseToTop();
5628   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5629   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5630
5631   application.SendNotification(); // ensure sorting order is calculated before next touch event
5632
5633   application.ProcessEvent(touchEvent);
5634
5635   glSetUniformStack.Reset();
5636
5637   application.SendNotification();
5638   application.Render();
5639
5640   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5641
5642   // Test order of uniforms in stack
5643   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5644   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5645   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5646
5647   tet_infoline("Testing A above C and B at bottom\n");
5648   bool ACB = (indexA > indexC) && (indexC > indexB);
5649
5650   DALI_TEST_EQUALS(ACB, true, TEST_LOCATION);
5651
5652   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5653   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5654   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5655
5656   ResetTouchCallbacks();
5657
5658   tet_printf("RaiseToTop ActorB\n");
5659
5660   orderChangedSignal = false;
5661
5662   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5663   actorB.RaiseToTop();
5664   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5665   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5666
5667   application.SendNotification(); // Ensure sort order is calculated before next touch event
5668
5669   application.ProcessEvent(touchEvent);
5670
5671   glSetUniformStack.Reset();
5672
5673   application.SendNotification();
5674   application.Render();
5675
5676   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5677
5678   // Test order of uniforms in stack
5679   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5680   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5681   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5682
5683   tet_infoline("Testing B above A and C at bottom\n");
5684   bool BAC = (indexB > indexA) && (indexA > indexC);
5685
5686   DALI_TEST_EQUALS(BAC, true, TEST_LOCATION);
5687
5688   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5689   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5690   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5691
5692   ResetTouchCallbacks();
5693
5694   tet_printf("LowerToBottom ActorA then ActorB leaving Actor C at Top\n");
5695
5696   orderChangedSignal = false;
5697
5698   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5699   actorA.LowerToBottom();
5700   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5701   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5702
5703   application.SendNotification();
5704   application.Render();
5705
5706   orderChangedSignal = false;
5707
5708   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5709   actorB.LowerToBottom();
5710   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5711   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5712
5713   application.SendNotification();
5714   application.Render();
5715
5716   application.ProcessEvent(touchEvent);
5717
5718   glSetUniformStack.Reset();
5719
5720   application.SendNotification();
5721   application.Render();
5722
5723   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5724
5725   // Test order of uniforms in stack
5726   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5727   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5728   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5729
5730   tet_infoline("Testing C above A and B at bottom\n");
5731   bool CAB = (indexC > indexA) && (indexA > indexB);
5732
5733   DALI_TEST_EQUALS(CAB, true, TEST_LOCATION);
5734
5735   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5736   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5737   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5738
5739   ResetTouchCallbacks();
5740
5741   END_TEST;
5742 }
5743
5744 int UtcDaliActorRaiseAbove(void)
5745 {
5746   tet_infoline("UtcDaliActor RaiseToAbove test \n");
5747
5748   TestApplication application;
5749
5750   Integration::Scene stage(application.GetScene());
5751
5752   Actor actorA = Actor::New();
5753   Actor actorB = Actor::New();
5754   Actor actorC = Actor::New();
5755
5756   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5757   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5758
5759   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5760   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5761
5762   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5763   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5764
5765   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5766   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5767
5768   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5769   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5770
5771   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5772   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5773
5774   stage.Add(actorA);
5775   stage.Add(actorB);
5776   stage.Add(actorC);
5777
5778   ResetTouchCallbacks();
5779
5780   application.SendNotification();
5781   application.Render();
5782
5783   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5784   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5785   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5786
5787   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5788   // Only top actor will get touched.
5789   actorA.TouchedSignal().Connect(TestTouchCallback);
5790   actorB.TouchedSignal().Connect(TestTouchCallback2);
5791   actorC.TouchedSignal().Connect(TestTouchCallback3);
5792
5793   bool                     orderChangedSignal(false);
5794   Actor                    orderChangedActor;
5795   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5796   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5797
5798   Dali::Integration::Point point;
5799   point.SetDeviceId(1);
5800   point.SetState(PointState::DOWN);
5801   point.SetScreenPosition(Vector2(10.f, 10.f));
5802   Dali::Integration::TouchEvent touchEvent;
5803   touchEvent.AddPoint(point);
5804
5805   application.ProcessEvent(touchEvent);
5806
5807   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5808   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5809   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5810
5811   ResetTouchCallbacks();
5812
5813   tet_printf("Raise actor B Above Actor C\n");
5814
5815   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5816   actorB.RaiseAbove(actorC);
5817   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5818   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5819
5820   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5821   application.SendNotification();
5822   application.ProcessEvent(touchEvent);
5823
5824   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5825   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5826   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5827
5828   ResetTouchCallbacks();
5829
5830   tet_printf("Raise actor A Above Actor B\n");
5831
5832   orderChangedSignal = false;
5833
5834   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5835   actorA.RaiseAbove(actorB);
5836   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5837   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5838
5839   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5840   application.SendNotification();
5841
5842   application.ProcessEvent(touchEvent); // process a touch event on ordered actors.
5843
5844   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5845   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5846   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5847
5848   ResetTouchCallbacks();
5849
5850   END_TEST;
5851 }
5852
5853 int UtcDaliActorRaiseAbove2(void)
5854 {
5855   tet_infoline("UtcDaliActor RaiseToAbove test using SIBLING_ORDER property\n");
5856
5857   TestApplication application;
5858
5859   Integration::Scene stage(application.GetScene());
5860
5861   Actor actorA = Actor::New();
5862   Actor actorB = Actor::New();
5863   Actor actorC = Actor::New();
5864
5865   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5866   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5867
5868   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5869   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5870
5871   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5872   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5873
5874   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5875   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5876
5877   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5878   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5879
5880   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5881   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5882
5883   stage.Add(actorA);
5884   stage.Add(actorB);
5885   stage.Add(actorC);
5886
5887   ResetTouchCallbacks();
5888
5889   application.SendNotification();
5890   application.Render();
5891
5892   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5893   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5894   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5895
5896   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5897   // Only top actor will get touched.
5898   actorA.TouchedSignal().Connect(TestTouchCallback);
5899   actorB.TouchedSignal().Connect(TestTouchCallback2);
5900   actorC.TouchedSignal().Connect(TestTouchCallback3);
5901
5902   bool                     orderChangedSignal(false);
5903   Actor                    orderChangedActor;
5904   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5905   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5906
5907   Dali::Integration::Point point;
5908   point.SetDeviceId(1);
5909   point.SetState(PointState::DOWN);
5910   point.SetScreenPosition(Vector2(10.f, 10.f));
5911   Dali::Integration::TouchEvent touchEvent;
5912   touchEvent.AddPoint(point);
5913
5914   application.ProcessEvent(touchEvent);
5915
5916   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5917   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5918   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5919
5920   ResetTouchCallbacks();
5921
5922   tet_printf("Raise actor B Above Actor C\n");
5923
5924   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5925   int newOrder                                = actorC[DevelActor::Property::SIBLING_ORDER];
5926   actorB[DevelActor::Property::SIBLING_ORDER] = newOrder;
5927   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5928   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5929
5930   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5931   application.SendNotification();
5932   application.ProcessEvent(touchEvent);
5933
5934   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5935   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5936   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5937
5938   ResetTouchCallbacks();
5939
5940   tet_printf("Raise actor A Above Actor B\n");
5941
5942   orderChangedSignal = false;
5943
5944   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5945   newOrder                                    = actorB[DevelActor::Property::SIBLING_ORDER];
5946   actorA[DevelActor::Property::SIBLING_ORDER] = newOrder;
5947   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5948   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5949
5950   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5951   application.SendNotification();
5952
5953   application.ProcessEvent(touchEvent); // process a touch event on ordered actors.
5954
5955   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5956   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5957   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5958
5959   ResetTouchCallbacks();
5960
5961   END_TEST;
5962 }
5963
5964 int UtcDaliActorLowerBelow(void)
5965 {
5966   tet_infoline("UtcDaliActor LowerBelow test \n");
5967
5968   TestApplication application;
5969
5970   Integration::Scene stage(application.GetScene());
5971
5972   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5973   // enables checking of which actor the uniform is assigned too
5974   Shader shaderA = CreateShader();
5975   shaderA.RegisterProperty("uRendererColor", 1.f);
5976
5977   Shader shaderB = CreateShader();
5978   shaderB.RegisterProperty("uRendererColor", 2.f);
5979
5980   Shader shaderC = CreateShader();
5981   shaderC.RegisterProperty("uRendererColor", 3.f);
5982
5983   Actor actorA = Actor::New();
5984   Actor actorB = Actor::New();
5985   Actor actorC = Actor::New();
5986
5987   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5988   Geometry geometry = CreateQuadGeometry();
5989
5990   Renderer rendererA = Renderer::New(geometry, shaderA);
5991   actorA.AddRenderer(rendererA);
5992
5993   Renderer rendererB = Renderer::New(geometry, shaderB);
5994   actorB.AddRenderer(rendererB);
5995
5996   Renderer rendererC = Renderer::New(geometry, shaderC);
5997   actorC.AddRenderer(rendererC);
5998
5999   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6000   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6001
6002   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6003   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6004
6005   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6006   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6007
6008   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6009   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6010
6011   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6012   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6013
6014   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6015   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6016
6017   Actor container = Actor::New();
6018   container.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6019   container.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
6020   stage.Add(container);
6021
6022   container.Add(actorA);
6023   container.Add(actorB);
6024   container.Add(actorC);
6025
6026   ResetTouchCallbacks();
6027
6028   // Connect ChildOrderChangedSignal
6029   bool                     orderChangedSignal(false);
6030   Actor                    orderChangedActor;
6031   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6032   DevelActor::ChildOrderChangedSignal(container).Connect(&application, f);
6033
6034   // Set up gl abstraction trace so can query the set uniform order
6035   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
6036   glAbstraction.EnableSetUniformCallTrace(true);
6037   glAbstraction.ResetSetUniformCallStack();
6038   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
6039
6040   glAbstraction.ResetSetUniformCallStack();
6041
6042   application.SendNotification();
6043   application.Render();
6044
6045   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6046
6047   // Test order of uniforms in stack
6048   int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6049   int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6050   int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6051
6052   tet_infoline("Testing C above B and A at bottom\n");
6053   bool CBA = (indexC > indexB) && (indexB > indexA);
6054
6055   DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
6056
6057   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6058   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6059   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6060
6061   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6062   // Only top actor will get touched.
6063   actorA.TouchedSignal().Connect(TestTouchCallback);
6064   actorB.TouchedSignal().Connect(TestTouchCallback2);
6065   actorC.TouchedSignal().Connect(TestTouchCallback3);
6066
6067   Dali::Integration::Point point;
6068   point.SetDeviceId(1);
6069   point.SetState(PointState::DOWN);
6070   point.SetScreenPosition(Vector2(10.f, 10.f));
6071   Dali::Integration::TouchEvent touchEvent;
6072   touchEvent.AddPoint(point);
6073
6074   tet_infoline("UtcDaliActor Test Set up completed \n");
6075
6076   application.ProcessEvent(touchEvent);
6077
6078   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6079   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6080   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6081
6082   ResetTouchCallbacks();
6083
6084   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");
6085
6086   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6087   actorC.LowerBelow(actorB);
6088   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6089   DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
6090
6091   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6092   application.SendNotification();
6093   application.Render();
6094
6095   application.ProcessEvent(touchEvent); // touch event
6096
6097   glSetUniformStack.Reset();
6098
6099   application.SendNotification();
6100   application.Render();
6101
6102   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6103
6104   // Test order of uniforms in stack
6105   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6106   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6107   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6108
6109   tet_infoline("Testing render order is A, C, B");
6110   DALI_TEST_EQUALS(indexC > indexA, true, TEST_LOCATION);
6111   DALI_TEST_EQUALS(indexB > indexC, true, TEST_LOCATION);
6112
6113   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6114   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6115   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6116
6117   ResetTouchCallbacks();
6118
6119   tet_printf("Lower actor C below Actor A leaving B on top\n");
6120
6121   orderChangedSignal = false;
6122
6123   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6124   actorC.LowerBelow(actorA);
6125   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6126   DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
6127
6128   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6129   application.SendNotification();
6130   application.Render();
6131
6132   application.ProcessEvent(touchEvent);
6133
6134   glSetUniformStack.Reset();
6135
6136   application.Render();
6137   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6138
6139   // Test order of uniforms in stack
6140   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6141   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6142   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6143
6144   DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
6145   DALI_TEST_EQUALS(indexB > indexA, true, TEST_LOCATION);
6146
6147   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6148   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6149   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6150
6151   ResetTouchCallbacks();
6152
6153   tet_printf("Lower actor B below Actor C leaving A on top\n");
6154
6155   orderChangedSignal = false;
6156
6157   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6158   actorB.LowerBelow(actorC);
6159   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6160   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
6161
6162   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6163   application.SendNotification();
6164   application.Render();
6165
6166   application.ProcessEvent(touchEvent);
6167
6168   glSetUniformStack.Reset();
6169
6170   application.Render();
6171   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6172
6173   // Test order of uniforms in stack
6174   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6175   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6176   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6177
6178   DALI_TEST_EQUALS(indexC > indexB, true, TEST_LOCATION);
6179   DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
6180
6181   END_TEST;
6182 }
6183
6184 int UtcDaliActorLowerBelow2(void)
6185 {
6186   tet_infoline("UtcDaliActor LowerBelow test using SIBLING_ORDER property\n");
6187
6188   TestApplication application;
6189
6190   Integration::Scene stage(application.GetScene());
6191
6192   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
6193   // enables checking of which actor the uniform is assigned too
6194   Shader shaderA = CreateShader();
6195   shaderA.RegisterProperty("uRendererColor", 1.f);
6196
6197   Shader shaderB = CreateShader();
6198   shaderB.RegisterProperty("uRendererColor", 2.f);
6199
6200   Shader shaderC = CreateShader();
6201   shaderC.RegisterProperty("uRendererColor", 3.f);
6202
6203   Actor actorA = Actor::New();
6204   Actor actorB = Actor::New();
6205   Actor actorC = Actor::New();
6206
6207   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
6208   Geometry geometry = CreateQuadGeometry();
6209
6210   Renderer rendererA = Renderer::New(geometry, shaderA);
6211   actorA.AddRenderer(rendererA);
6212
6213   Renderer rendererB = Renderer::New(geometry, shaderB);
6214   actorB.AddRenderer(rendererB);
6215
6216   Renderer rendererC = Renderer::New(geometry, shaderC);
6217   actorC.AddRenderer(rendererC);
6218
6219   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6220   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6221
6222   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6223   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6224
6225   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6226   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6227
6228   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6229   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6230
6231   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6232   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6233
6234   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6235   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6236
6237   Actor container = Actor::New();
6238   container.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6239   container.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
6240   stage.Add(container);
6241
6242   container.Add(actorA);
6243   container.Add(actorB);
6244   container.Add(actorC);
6245
6246   ResetTouchCallbacks();
6247
6248   // Connect ChildOrderChangedSignal
6249   bool                     orderChangedSignal(false);
6250   Actor                    orderChangedActor;
6251   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6252   DevelActor::ChildOrderChangedSignal(container).Connect(&application, f);
6253
6254   // Set up gl abstraction trace so can query the set uniform order
6255   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
6256   glAbstraction.EnableSetUniformCallTrace(true);
6257   glAbstraction.ResetSetUniformCallStack();
6258   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
6259
6260   glAbstraction.ResetSetUniformCallStack();
6261
6262   application.SendNotification();
6263   application.Render();
6264
6265   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6266
6267   // Test order of uniforms in stack
6268   int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6269   int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6270   int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6271
6272   tet_infoline("Testing C above B and A at bottom\n");
6273   bool CBA = (indexC > indexB) && (indexB > indexA);
6274
6275   DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
6276
6277   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6278   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6279   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6280
6281   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6282   // Only top actor will get touched.
6283   actorA.TouchedSignal().Connect(TestTouchCallback);
6284   actorB.TouchedSignal().Connect(TestTouchCallback2);
6285   actorC.TouchedSignal().Connect(TestTouchCallback3);
6286
6287   Dali::Integration::Point point;
6288   point.SetDeviceId(1);
6289   point.SetState(PointState::DOWN);
6290   point.SetScreenPosition(Vector2(10.f, 10.f));
6291   Dali::Integration::TouchEvent touchEvent;
6292   touchEvent.AddPoint(point);
6293
6294   tet_infoline("UtcDaliActor Test Set up completed \n");
6295
6296   application.ProcessEvent(touchEvent);
6297
6298   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6299   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6300   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6301
6302   ResetTouchCallbacks();
6303
6304   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");
6305
6306   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6307   actorC[DevelActor::Property::SIBLING_ORDER] = 1;
6308   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6309   DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
6310
6311   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6312   application.SendNotification();
6313   application.Render();
6314
6315   application.ProcessEvent(touchEvent); // touch event
6316
6317   glSetUniformStack.Reset();
6318
6319   application.SendNotification();
6320   application.Render();
6321
6322   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6323
6324   // Test order of uniforms in stack
6325   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6326   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6327   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6328
6329   tet_infoline("Testing render order is A, C, B");
6330   DALI_TEST_EQUALS(indexC > indexA, true, TEST_LOCATION);
6331   DALI_TEST_EQUALS(indexB > indexC, true, TEST_LOCATION);
6332
6333   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6334   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6335   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6336
6337   ResetTouchCallbacks();
6338
6339   tet_printf("Lower actor C below Actor A leaving B on top\n");
6340
6341   orderChangedSignal = false;
6342
6343   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6344   actorC[DevelActor::Property::SIBLING_ORDER] = 0;
6345   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6346   DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
6347
6348   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6349   application.SendNotification();
6350   application.Render();
6351
6352   application.ProcessEvent(touchEvent);
6353
6354   glSetUniformStack.Reset();
6355
6356   application.Render();
6357   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6358
6359   // Test order of uniforms in stack
6360   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6361   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6362   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6363
6364   DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
6365   DALI_TEST_EQUALS(indexB > indexA, true, TEST_LOCATION);
6366
6367   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6368   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6369   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6370
6371   ResetTouchCallbacks();
6372
6373   tet_printf("Lower actor B below Actor C leaving A on top\n");
6374
6375   orderChangedSignal = false;
6376
6377   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6378   actorB[DevelActor::Property::SIBLING_ORDER] = 0;
6379   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6380   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
6381
6382   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6383   application.SendNotification();
6384   application.Render();
6385
6386   application.ProcessEvent(touchEvent);
6387
6388   glSetUniformStack.Reset();
6389
6390   application.Render();
6391   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6392
6393   // Test order of uniforms in stack
6394   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6395   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6396   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6397
6398   DALI_TEST_EQUALS(indexC > indexB, true, TEST_LOCATION);
6399   DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
6400
6401   END_TEST;
6402 }
6403
6404 int UtcDaliActorRaiseAboveDifferentParentsN(void)
6405 {
6406   tet_infoline("UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n");
6407
6408   TestApplication application;
6409
6410   Integration::Scene stage(application.GetScene());
6411
6412   Actor parentA = Actor::New();
6413   Actor parentB = Actor::New();
6414   parentA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6415   parentA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6416   parentB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6417   parentB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6418
6419   parentA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6420   parentA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6421
6422   parentB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6423   parentB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6424
6425   stage.Add(parentA);
6426   stage.Add(parentB);
6427
6428   Actor actorA = Actor::New();
6429   Actor actorB = Actor::New();
6430   Actor actorC = Actor::New();
6431
6432   parentA.Add(actorA);
6433   parentA.Add(actorB);
6434
6435   tet_printf("Actor C added to different parent from A and B \n");
6436   parentB.Add(actorC);
6437
6438   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6439   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6440
6441   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6442   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6443
6444   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6445   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6446
6447   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6448   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6449
6450   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6451   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6452
6453   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6454   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6455
6456   ResetTouchCallbacks();
6457
6458   // Connect ChildOrderChangedSignal
6459   bool                     orderChangedSignal(false);
6460   Actor                    orderChangedActor;
6461   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6462   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6463
6464   application.SendNotification();
6465   application.Render();
6466
6467   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6468   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6469   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6470
6471   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6472   // Only top actor will get touched.
6473   actorA.TouchedSignal().Connect(TestTouchCallback);
6474   actorB.TouchedSignal().Connect(TestTouchCallback2);
6475   actorC.TouchedSignal().Connect(TestTouchCallback3);
6476
6477   Dali::Integration::Point point;
6478   point.SetDeviceId(1);
6479   point.SetState(PointState::DOWN);
6480   point.SetScreenPosition(Vector2(10.f, 10.f));
6481   Dali::Integration::TouchEvent touchEvent;
6482   touchEvent.AddPoint(point);
6483
6484   application.ProcessEvent(touchEvent);
6485
6486   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6487   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6488   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6489
6490   ResetTouchCallbacks();
6491
6492   tet_printf("Raise actor A Above Actor C which have different parents\n");
6493
6494   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6495   actorA.RaiseAbove(actorC);
6496   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6497
6498   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6499   application.SendNotification();
6500
6501   application.ProcessEvent(touchEvent); // touch event
6502
6503   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6504   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6505   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6506
6507   ResetTouchCallbacks();
6508
6509   END_TEST;
6510 }
6511
6512 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
6513 {
6514   tet_infoline("UtcDaliActor Test  raiseAbove and lowerBelow api when target Actor has no parent \n");
6515
6516   TestApplication application;
6517
6518   Integration::Scene stage(application.GetScene());
6519
6520   Actor actorA = Actor::New();
6521   Actor actorB = Actor::New();
6522   Actor actorC = Actor::New();
6523
6524   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6525   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6526
6527   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6528   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6529
6530   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6531   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6532
6533   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6534   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6535
6536   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6537   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6538
6539   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6540   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6541
6542   ResetTouchCallbacks();
6543
6544   // Connect ChildOrderChangedSignal
6545   bool                     orderChangedSignal(false);
6546   Actor                    orderChangedActor;
6547   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6548   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6549
6550   application.SendNotification();
6551   application.Render();
6552
6553   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6554   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6555   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6556
6557   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6558   // Only top actor will get touched.
6559   actorA.TouchedSignal().Connect(TestTouchCallback);
6560   actorB.TouchedSignal().Connect(TestTouchCallback2);
6561   actorC.TouchedSignal().Connect(TestTouchCallback3);
6562
6563   Dali::Integration::Point point;
6564   point.SetDeviceId(1);
6565   point.SetState(PointState::DOWN);
6566   point.SetScreenPosition(Vector2(10.f, 10.f));
6567   Dali::Integration::TouchEvent touchEvent;
6568   touchEvent.AddPoint(point);
6569
6570   tet_printf("Raise actor A Above Actor C which have no parents\n");
6571
6572   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6573   actorA.RaiseAbove(actorC);
6574   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6575
6576   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6577   application.SendNotification();
6578
6579   application.ProcessEvent(touchEvent);
6580
6581   tet_printf("Not parented so RaiseAbove should show no effect\n");
6582
6583   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6584   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6585   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6586
6587   ResetTouchCallbacks();
6588
6589   orderChangedSignal = false;
6590
6591   stage.Add(actorB);
6592   tet_printf("Lower actor A below Actor C when only A is not on stage \n");
6593
6594   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6595   actorA.LowerBelow(actorC);
6596   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6597
6598   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6599   application.SendNotification();
6600   application.Render();
6601
6602   application.ProcessEvent(touchEvent);
6603
6604   tet_printf("Actor A not parented so LowerBelow should show no effect\n");
6605   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6606   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6607   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6608
6609   ResetTouchCallbacks();
6610
6611   orderChangedSignal = false;
6612
6613   tet_printf("Adding Actor A to stage, will be on top\n");
6614
6615   stage.Add(actorA);
6616   application.SendNotification();
6617   application.Render();
6618
6619   tet_printf("Raise actor B Above Actor C when only B has a parent\n");
6620
6621   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6622   actorB.RaiseAbove(actorC);
6623   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6624
6625   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6626   application.SendNotification();
6627
6628   application.ProcessEvent(touchEvent);
6629
6630   tet_printf("C not parented so RaiseAbove should show no effect\n");
6631   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6632   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6633   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6634
6635   ResetTouchCallbacks();
6636
6637   orderChangedSignal = false;
6638
6639   tet_printf("Lower actor A below Actor C when only A has a parent\n");
6640
6641   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6642   actorA.LowerBelow(actorC);
6643   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6644
6645   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6646   application.SendNotification();
6647
6648   application.ProcessEvent(touchEvent);
6649
6650   tet_printf("C not parented so LowerBelow should show no effect\n");
6651   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6652   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6653   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6654
6655   ResetTouchCallbacks();
6656
6657   orderChangedSignal = false;
6658
6659   stage.Add(actorC);
6660
6661   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6662   actorA.RaiseAbove(actorC);
6663   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6664   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6665
6666   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6667   application.SendNotification();
6668   application.Render();
6669
6670   application.ProcessEvent(touchEvent);
6671
6672   tet_printf("Raise actor A Above Actor C, now both have same parent \n");
6673   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6674   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6675   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6676
6677   END_TEST;
6678 }
6679
6680 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
6681 {
6682   tet_infoline("UtcDaliActor Test all raise/lower api when actor has no parent \n");
6683
6684   TestApplication application;
6685
6686   Integration::Scene stage(application.GetScene());
6687
6688   Actor actorA = Actor::New();
6689   Actor actorB = Actor::New();
6690   Actor actorC = Actor::New();
6691
6692   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6693   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6694
6695   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6696   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6697
6698   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6699   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6700
6701   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6702   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6703
6704   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6705   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6706
6707   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6708   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6709
6710   ResetTouchCallbacks();
6711
6712   // Connect ChildOrderChangedSignal
6713   bool                     orderChangedSignal(false);
6714   Actor                    orderChangedActor;
6715   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6716   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6717
6718   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6719   // Only top actor will get touched.
6720   actorA.TouchedSignal().Connect(TestTouchCallback);
6721   actorB.TouchedSignal().Connect(TestTouchCallback2);
6722   actorC.TouchedSignal().Connect(TestTouchCallback3);
6723
6724   Dali::Integration::Point point;
6725   point.SetDeviceId(1);
6726   point.SetState(PointState::DOWN);
6727   point.SetScreenPosition(Vector2(10.f, 10.f));
6728   Dali::Integration::TouchEvent touchEvent;
6729   touchEvent.AddPoint(point);
6730
6731   stage.Add(actorA);
6732   tet_printf("Raise actor B Above Actor C but B not parented\n");
6733
6734   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6735   actorB.Raise();
6736   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6737
6738   application.SendNotification();
6739   application.Render();
6740
6741   application.ProcessEvent(touchEvent);
6742
6743   tet_printf("Not parented so RaiseAbove should show no effect\n");
6744
6745   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6746   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6747   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6748
6749   tet_printf("Raise actor B Above Actor C but B not parented\n");
6750   ResetTouchCallbacks();
6751
6752   orderChangedSignal = false;
6753
6754   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6755   actorC.Lower();
6756   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6757
6758   // Sort actor tree before next touch event
6759   application.SendNotification();
6760   application.Render();
6761
6762   application.ProcessEvent(touchEvent);
6763
6764   tet_printf("Not parented so RaiseAbove should show no effect\n");
6765
6766   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6767   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6768   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6769   ResetTouchCallbacks();
6770
6771   orderChangedSignal = false;
6772
6773   tet_printf("Lower actor C below B but C not parented\n");
6774
6775   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6776   actorB.Lower();
6777   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6778
6779   // Sort actor tree before next touch event
6780   application.SendNotification();
6781   application.Render();
6782
6783   application.ProcessEvent(touchEvent);
6784
6785   tet_printf("Not parented so Lower should show no effect\n");
6786
6787   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6788   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6789   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6790   ResetTouchCallbacks();
6791
6792   orderChangedSignal = false;
6793
6794   tet_printf("Raise actor B to top\n");
6795
6796   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6797   actorB.RaiseToTop();
6798   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6799
6800   // Sort actor tree before next touch event
6801   application.SendNotification();
6802   application.Render();
6803
6804   application.ProcessEvent(touchEvent);
6805
6806   tet_printf("Not parented so RaiseToTop should show no effect\n");
6807
6808   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6809   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6810   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6811   ResetTouchCallbacks();
6812
6813   orderChangedSignal = false;
6814
6815   tet_printf("Add ActorB to stage so only Actor C not parented\n");
6816
6817   stage.Add(actorB);
6818
6819   tet_printf("Lower actor C to Bottom, B stays at top\n");
6820
6821   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6822   actorC.LowerToBottom();
6823   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6824
6825   application.SendNotification();
6826   application.Render();
6827
6828   application.ProcessEvent(touchEvent);
6829
6830   tet_printf("Not parented so LowerToBottom should show no effect\n");
6831
6832   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6833   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6834   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6835   ResetTouchCallbacks();
6836
6837   END_TEST;
6838 }
6839
6840 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
6841 {
6842   tet_infoline("UtcDaliActor RaiseToAbove and  test with actor provided as target resulting in a no operation \n");
6843
6844   TestApplication application;
6845
6846   Integration::Scene stage(application.GetScene());
6847
6848   Actor actorA = Actor::New();
6849   Actor actorB = Actor::New();
6850   Actor actorC = Actor::New();
6851
6852   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6853   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6854
6855   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6856   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6857
6858   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6859   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6860
6861   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6862   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6863
6864   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6865   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6866
6867   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6868   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6869
6870   stage.Add(actorA);
6871   stage.Add(actorB);
6872   stage.Add(actorC);
6873
6874   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6875   // Only top actor will get touched.
6876   actorA.TouchedSignal().Connect(TestTouchCallback);
6877   actorB.TouchedSignal().Connect(TestTouchCallback2);
6878   actorC.TouchedSignal().Connect(TestTouchCallback3);
6879
6880   ResetTouchCallbacks();
6881
6882   // Connect ChildOrderChangedSignal
6883   bool                     orderChangedSignal(false);
6884   Actor                    orderChangedActor;
6885   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6886   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6887
6888   application.SendNotification();
6889   application.Render();
6890
6891   Dali::Integration::Point point;
6892   point.SetDeviceId(1);
6893   point.SetState(PointState::DOWN);
6894   point.SetScreenPosition(Vector2(10.f, 10.f));
6895   Dali::Integration::TouchEvent touchEvent;
6896   touchEvent.AddPoint(point);
6897
6898   application.ProcessEvent(touchEvent);
6899
6900   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6901   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6902   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6903
6904   ResetTouchCallbacks();
6905
6906   tet_infoline("Raise actor A Above Actor A which is the same actor!!\n");
6907
6908   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6909   actorA.RaiseAbove(actorA);
6910   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6911   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6912
6913   application.SendNotification();
6914   application.Render();
6915
6916   application.ProcessEvent(touchEvent);
6917
6918   tet_infoline("No target is source Actor so RaiseAbove should show no effect\n");
6919
6920   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6921   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6922   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6923
6924   ResetTouchCallbacks();
6925
6926   orderChangedSignal = false;
6927
6928   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6929   actorA.RaiseAbove(actorC);
6930   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6931   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6932
6933   application.SendNotification();
6934   application.Render();
6935
6936   application.ProcessEvent(touchEvent);
6937
6938   tet_infoline("Raise actor A Above Actor C which will now be successful \n");
6939   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6940   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6941   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6942
6943   END_TEST;
6944 }
6945
6946 int UtcDaliActorGetScreenPosition(void)
6947 {
6948   tet_infoline("UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n");
6949
6950   TestApplication application;
6951
6952   Integration::Scene stage(application.GetScene());
6953
6954   Actor actorA = Actor::New();
6955   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6956
6957   Vector2 size2(10.0f, 20.0f);
6958   actorA.SetProperty(Actor::Property::SIZE, size2);
6959
6960   actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6961
6962   tet_infoline("UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n");
6963
6964   stage.Add(actorA);
6965
6966   application.SendNotification();
6967   application.Render();
6968
6969   Vector3 actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6970   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6971
6972   tet_printf("Actor World Position ( %f %f ) AnchorPoint::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
6973   tet_printf("Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y);
6974
6975   DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6976   DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6977
6978   tet_infoline("UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n");
6979
6980   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6981
6982   application.SendNotification();
6983   application.Render();
6984
6985   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6986   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6987
6988   tet_printf("Actor World Position  ( %f %f ) AnchorPoint::TOP_LEFT  \n", actorWorldPosition.x, actorWorldPosition.y);
6989   tet_printf("Actor Screen Position  ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y);
6990
6991   DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6992   DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6993
6994   tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n");
6995
6996   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6997
6998   application.SendNotification();
6999   application.Render();
7000
7001   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7002   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7003
7004   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT   \n", actorWorldPosition.x, actorWorldPosition.y);
7005   tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT  \n", actorScreenPosition.x, actorScreenPosition.y);
7006
7007   DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
7008   DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
7009
7010   tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n");
7011
7012   actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 0.0));
7013
7014   application.SendNotification();
7015   application.Render();
7016
7017   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7018   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7019
7020   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorWorldPosition.x, actorWorldPosition.y);
7021   tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0   \n", actorScreenPosition.x, actorScreenPosition.y);
7022
7023   DALI_TEST_EQUALS(actorScreenPosition.x, 30lu, TEST_LOCATION);
7024   DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
7025
7026   tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n");
7027
7028   actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 420.0));
7029
7030   application.SendNotification();
7031   application.Render();
7032
7033   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7034   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7035
7036   DALI_TEST_EQUALS(actorScreenPosition.x, 30lu, TEST_LOCATION);
7037   DALI_TEST_EQUALS(actorScreenPosition.y, 420lu, TEST_LOCATION);
7038
7039   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n", actorWorldPosition.x, actorWorldPosition.y);
7040   tet_printf("Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y);
7041
7042   tet_infoline("UtcDaliActorGetScreenPosition Scale parent and check child's screen position \n");
7043
7044   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7045   actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 30.0));
7046
7047   Actor actorB = Actor::New();
7048   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7049   actorB.SetProperty(Actor::Property::SIZE, size2);
7050   actorB.SetProperty(Actor::Property::POSITION, Vector2(10.f, 10.f));
7051   actorA.Add(actorB);
7052
7053   actorA.SetProperty(Actor::Property::SCALE, 2.0f);
7054
7055   application.SendNotification();
7056   application.Render();
7057
7058   actorScreenPosition = actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7059
7060   DALI_TEST_EQUALS(actorScreenPosition.x, 50lu, TEST_LOCATION);
7061   DALI_TEST_EQUALS(actorScreenPosition.y, 50lu, TEST_LOCATION);
7062
7063   END_TEST;
7064 }
7065
7066 int UtcDaliActorGetScreenPositionAfterScaling(void)
7067 {
7068   tet_infoline("UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n");
7069
7070   TestApplication application;
7071
7072   Integration::Scene stage(application.GetScene());
7073
7074   Actor actorA = Actor::New();
7075   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7076
7077   Vector2 size2(10.0f, 20.0f);
7078   actorA.SetProperty(Actor::Property::SIZE, size2);
7079   actorA.SetProperty(Actor::Property::SCALE, 1.5f);
7080   actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7081
7082   tet_infoline("UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n");
7083
7084   stage.Add(actorA);
7085
7086   application.SendNotification();
7087   application.Render();
7088
7089   Vector3 actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7090   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7091
7092   tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y);
7093   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7094
7095   DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
7096   DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
7097
7098   tet_infoline("UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n");
7099
7100   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7101
7102   application.SendNotification();
7103   application.Render();
7104
7105   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7106   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7107
7108   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
7109   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7110
7111   DALI_TEST_EQUALS(actorScreenPosition.x, 0.0f, TEST_LOCATION);
7112   DALI_TEST_EQUALS(actorScreenPosition.y, 0.0f, TEST_LOCATION);
7113
7114   END_TEST;
7115 }
7116
7117 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
7118 {
7119   tet_infoline("UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n");
7120
7121   TestApplication application;
7122
7123   Integration::Scene stage(application.GetScene());
7124
7125   Actor actorA = Actor::New();
7126   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7127   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7128   Vector2 size2(10.0f, 20.0f);
7129   actorA.SetProperty(Actor::Property::SIZE, size2);
7130   actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7131
7132   tet_infoline(" TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
7133
7134   stage.Add(actorA);
7135
7136   application.SendNotification();
7137   application.Render();
7138
7139   Vector3 actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7140   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7141
7142   tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n", actorWorldPosition.x, actorWorldPosition.y);
7143   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7144
7145   DALI_TEST_EQUALS(actorScreenPosition.x, 240.0f, TEST_LOCATION);
7146   DALI_TEST_EQUALS(actorScreenPosition.y, 400.0f, TEST_LOCATION);
7147
7148   tet_infoline(" BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n");
7149
7150   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
7151   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7152
7153   application.SendNotification();
7154   application.Render();
7155
7156   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7157   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7158
7159   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
7160   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7161
7162   DALI_TEST_EQUALS(actorScreenPosition.x, 480.0f, TEST_LOCATION);
7163   DALI_TEST_EQUALS(actorScreenPosition.y, 0.0f, TEST_LOCATION);
7164
7165   END_TEST;
7166   END_TEST;
7167 }
7168
7169 int UtcDaliActorGetScreenPositionWithChildActors(void)
7170 {
7171   tet_infoline("UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n");
7172
7173   TestApplication application;
7174
7175   Integration::Scene stage(application.GetScene());
7176
7177   tet_infoline("Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
7178
7179   Actor actorA = Actor::New();
7180   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7181   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7182   Vector2 size1(10.0f, 20.0f);
7183   actorA.SetProperty(Actor::Property::SIZE, size1);
7184   actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7185
7186   tet_infoline("Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
7187
7188   Actor parentActorA = Actor::New();
7189   parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7190   parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7191   Vector2 size2(30.0f, 60.0f);
7192   parentActorA.SetProperty(Actor::Property::SIZE, size2);
7193   parentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7194
7195   tet_infoline("Add child 1 to Parent 1 and check screen position \n");
7196
7197   stage.Add(parentActorA);
7198   parentActorA.Add(actorA);
7199
7200   application.SendNotification();
7201   application.Render();
7202
7203   Vector3 actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7204   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7205
7206   tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n", actorWorldPosition.x, actorWorldPosition.y);
7207   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7208
7209   DALI_TEST_EQUALS(actorScreenPosition.x, 255.0f, TEST_LOCATION);
7210   DALI_TEST_EQUALS(actorScreenPosition.y, 430.0f, TEST_LOCATION);
7211
7212   tet_infoline("Test 2\n");
7213
7214   tet_infoline("change parent anchor point and parent origin then check screen position \n");
7215
7216   parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
7217   parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
7218
7219   application.SendNotification();
7220   application.Render();
7221
7222   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7223   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7224
7225   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT  \n", actorWorldPosition.x, actorWorldPosition.y);
7226   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7227
7228   DALI_TEST_EQUALS(actorScreenPosition.x, 15.0f, TEST_LOCATION);
7229   DALI_TEST_EQUALS(actorScreenPosition.y, -30.0f, TEST_LOCATION);
7230
7231   END_TEST;
7232 }
7233
7234 int UtcDaliActorGetScreenPositionWithChildActors02(void)
7235 {
7236   tet_infoline("UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n");
7237
7238   TestApplication application;
7239
7240   Integration::Scene stage(application.GetScene());
7241
7242   tet_infoline("Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
7243
7244   Actor actorA = Actor::New();
7245   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7246   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7247   Vector2 size1(10.0f, 20.0f);
7248   actorA.SetProperty(Actor::Property::SIZE, size1);
7249   actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7250
7251   tet_infoline("Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
7252
7253   Actor parentActorA = Actor::New();
7254   parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7255   parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7256   Vector2 size2(30.0f, 60.0f);
7257   parentActorA.SetProperty(Actor::Property::SIZE, size2);
7258   parentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7259
7260   tet_infoline("Create Grand Parent Actor 1 BOTTOM_LEFT Anchor Point, ParentOrigin::BOTTOM_LEFT and 0,0 position \n");
7261
7262   Actor grandParentActorA = Actor::New();
7263   grandParentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
7264   grandParentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
7265   Vector2 size3(60.0f, 120.0f);
7266   grandParentActorA.SetProperty(Actor::Property::SIZE, size3);
7267   grandParentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7268
7269   tet_infoline("Add Parent 1 to Grand Parent 1 \n");
7270
7271   stage.Add(grandParentActorA);
7272   grandParentActorA.Add(parentActorA);
7273
7274   tet_infoline("Add child 1 to Parent 1 and check screen position \n");
7275
7276   parentActorA.Add(actorA);
7277
7278   application.SendNotification();
7279   application.Render();
7280
7281   Vector3 actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7282   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7283
7284   tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n", actorWorldPosition.x, actorWorldPosition.y);
7285   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7286
7287   DALI_TEST_EQUALS(actorScreenPosition.x, 45.0f, TEST_LOCATION);
7288   DALI_TEST_EQUALS(actorScreenPosition.y, 770.0f, TEST_LOCATION);
7289
7290   END_TEST;
7291 }
7292
7293 int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void)
7294 {
7295   tet_infoline("UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse Check screen position where the position does not use the anchor point");
7296
7297   TestApplication application;
7298
7299   Integration::Scene stage(application.GetScene());
7300
7301   tet_infoline("Create an actor with AnchorPoint::TOP_LEFT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
7302
7303   Actor actorA = Actor::New();
7304   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7305   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7306   actorA.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7307   actorA.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 20.0f));
7308   stage.Add(actorA);
7309
7310   tet_infoline("Create an Actor with AnchorPoint::BOTTOM_RIGHT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
7311
7312   Actor actorB = Actor::New();
7313   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7314   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7315   actorB.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7316   Vector2 actorBSize(30.0f, 60.0f);
7317   actorB.SetProperty(Actor::Property::SIZE, actorBSize);
7318   stage.Add(actorB);
7319
7320   tet_infoline("Create an actor with AnchorPoint::CENTER, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
7321
7322   Actor actorC = Actor::New();
7323   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7324   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7325   actorC.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7326   Vector2 actorCSize(60.0f, 120.0f);
7327   actorC.SetProperty(Actor::Property::SIZE, actorCSize);
7328   stage.Add(actorC);
7329
7330   application.SendNotification();
7331   application.Render();
7332
7333   tet_infoline("Despite differing sizes and anchor-points, the screen position for all actors is the same");
7334
7335   Vector2 center(stage.GetSize() * 0.5f);
7336
7337   DALI_TEST_EQUALS(actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
7338   DALI_TEST_EQUALS(actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
7339   DALI_TEST_EQUALS(actorC.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
7340
7341   tet_infoline("Add scale to all actors");
7342
7343   actorA.SetProperty(Actor::Property::SCALE, 2.0f);
7344   actorB.SetProperty(Actor::Property::SCALE, 2.0f);
7345   actorC.SetProperty(Actor::Property::SCALE, 2.0f);
7346
7347   application.SendNotification();
7348   application.Render();
7349
7350   DALI_TEST_EQUALS(actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center /* TOP_LEFT Anchor */, TEST_LOCATION);
7351   DALI_TEST_EQUALS(actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center - actorBSize /* BOTTOM_RIGHT Anchor */, TEST_LOCATION);
7352   DALI_TEST_EQUALS(actorC.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center - actorCSize * 0.5f /* CENTER Anchor*/, TEST_LOCATION);
7353
7354   END_TEST;
7355 }
7356
7357 int UtcDaliActorGetScreenPositionResizeScene(void)
7358 {
7359   tet_infoline("UtcDaliActorGetScreenPositionResizeScene Check screen position after resizing the scene size");
7360
7361   TestApplication    application;
7362   Integration::Scene scene = application.GetScene();
7363
7364   Actor actorA = Actor::New();
7365   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7366   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7367   actorA.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
7368
7369   scene.Add(actorA);
7370
7371   application.SendNotification();
7372   application.Render();
7373
7374   Vector2 sceneSize           = scene.GetSize();
7375   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7376
7377   DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2, TEST_LOCATION);
7378
7379   // Resize the scene
7380   Vector2 newSize(1000.0f, 2000.0f);
7381   DALI_TEST_CHECK(scene.GetSize() != newSize);
7382
7383   scene.SurfaceResized(newSize.width, newSize.height);
7384
7385   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7386
7387   // The screen position should not be updated yet
7388   DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2, TEST_LOCATION);
7389
7390   application.SendNotification();
7391   application.Render();
7392
7393   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7394
7395   // The screen position should be updated
7396   sceneSize = scene.GetSize();
7397   DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2, TEST_LOCATION);
7398
7399   END_TEST;
7400 }
7401
7402 int UtcDaliActorGetScreenPositionInCustomCameraAndLayer3D(void)
7403 {
7404   tet_infoline("UtcDaliActorGetScreenPositionInCustomCameraAndLayer3D Check screen position under LAYER_3D and custom camera");
7405
7406   TestApplication    application;
7407   Integration::Scene scene = application.GetScene();
7408
7409   // Make 3D Layer
7410   Layer layer = scene.GetRootLayer();
7411   layer.SetProperty(Layer::Property::BEHAVIOR, Layer::Behavior::LAYER_3D);
7412
7413   // Build custom camera with top-view
7414   CameraActor cameraActor = scene.GetRenderTaskList().GetTask(0).GetCameraActor();
7415   {
7416     // Default camera position at +z and looking -z axis. (orientation is [ Axis: [0, 1, 0], Angle: 180 degrees ])
7417     Vector3    cameraPos    = cameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
7418     Quaternion cameraOrient = cameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
7419
7420     {
7421       std::ostringstream oss;
7422       oss << cameraPos << "\n";
7423       oss << cameraOrient << "\n";
7424       tet_printf("%s\n", oss.str().c_str());
7425     }
7426
7427     cameraActor.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -cameraPos.z, 0.0f));
7428     cameraActor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::XAXIS) * cameraOrient);
7429
7430     // Now, upside : -Z, leftside : -X, foward : +Y
7431
7432     cameraPos    = cameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
7433     cameraOrient = cameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
7434     {
7435       std::ostringstream oss;
7436       oss << cameraPos << "\n";
7437       oss << cameraOrient << "\n";
7438       tet_printf("%s\n", oss.str().c_str());
7439     }
7440   }
7441
7442   Actor actorA = Actor::New();
7443   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7444   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7445   actorA.SetProperty(Actor::Property::SIZE, Vector3(10.0f, 10.0f, 10.0f));
7446   actorA.SetProperty(Actor::Property::POSITION, Vector3(20.0f, 0.0f, 10.0f));
7447
7448   Actor actorB = Actor::New();
7449   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7450   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7451   actorB.SetProperty(Actor::Property::SIZE, Vector3(10.0f, 10.0f, 10.0f));
7452   actorB.SetProperty(Actor::Property::POSITION, Vector3(-20.0f, 0.0f, -10.0f));
7453
7454   scene.Add(actorA);
7455   scene.Add(actorB);
7456
7457   application.SendNotification();
7458   application.Render();
7459
7460   Vector2 sceneSize           = scene.GetSize();
7461   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7462
7463   DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2 + Vector2(20.0f, 10.0f), TEST_LOCATION);
7464
7465   actorScreenPosition = actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7466
7467   DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2 - Vector2(20.0f, 10.0f), TEST_LOCATION);
7468
7469   END_TEST;
7470 }
7471
7472 int utcDaliActorPositionUsesAnchorPoint(void)
7473 {
7474   TestApplication application;
7475   tet_infoline("Check default behaviour\n");
7476
7477   Actor actor = Actor::New();
7478   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7479   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7480   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7481   application.GetScene().Add(actor);
7482
7483   application.SendNotification();
7484   application.Render();
7485
7486   tet_infoline("Check that the world position is in the center\n");
7487   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
7488
7489   tet_infoline("Set the position uses anchor point property to false\n");
7490   actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7491
7492   application.SendNotification();
7493   application.Render();
7494
7495   tet_infoline("Check that the world position has changed appropriately\n");
7496   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7497
7498   END_TEST;
7499 }
7500
7501 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
7502 {
7503   TestApplication application;
7504   tet_infoline("Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7505
7506   Actor actor = Actor::New();
7507   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7508   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7509   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7510   actor.SetProperty(Actor::Property::SCALE, 2.0f);
7511   actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7512   application.GetScene().Add(actor);
7513
7514   application.SendNotification();
7515   application.Render();
7516
7517   tet_infoline("Check the world position is the same as it would be without a scale\n");
7518   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7519
7520   tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
7521   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7522   application.SendNotification();
7523   application.Render();
7524   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(100.0f, 100.0f, 0.0f), TEST_LOCATION);
7525
7526   tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
7527   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7528   application.SendNotification();
7529   application.Render();
7530   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
7531
7532   END_TEST;
7533 }
7534
7535 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
7536 {
7537   TestApplication application;
7538   tet_infoline("Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7539
7540   Actor actor = Actor::New();
7541   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7542   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7543   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7544   actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::ZAXIS));
7545   actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7546   application.GetScene().Add(actor);
7547
7548   application.SendNotification();
7549   application.Render();
7550
7551   tet_infoline("Check the world position is the same as it would be without a rotation\n");
7552   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7553
7554   tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
7555   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7556   application.SendNotification();
7557   application.Render();
7558   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(-50.0f, 50.0f, 0.0f), TEST_LOCATION);
7559
7560   tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
7561   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7562   application.SendNotification();
7563   application.Render();
7564   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(150.0f, 50.0f, 0.0f), TEST_LOCATION);
7565
7566   END_TEST;
7567 }
7568
7569 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
7570 {
7571   TestApplication application;
7572   tet_infoline("Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7573
7574   Actor actor = Actor::New();
7575   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7576   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7577   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7578   actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::ZAXIS));
7579   actor.SetProperty(Actor::Property::SCALE, 2.0f);
7580   actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7581   application.GetScene().Add(actor);
7582
7583   application.SendNotification();
7584   application.Render();
7585
7586   tet_infoline("Check the world position is the same as it would be without a scale and rotation\n");
7587   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7588
7589   tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
7590   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7591   application.SendNotification();
7592   application.Render();
7593   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(-100.0f, 100.0f, 0.0f), TEST_LOCATION);
7594
7595   tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
7596   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7597   application.SendNotification();
7598   application.Render();
7599   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(200.0f, 0.0f, 0.0f), TEST_LOCATION);
7600
7601   END_TEST;
7602 }
7603
7604 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
7605 {
7606   TestApplication application;
7607   tet_infoline("Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7608
7609   Actor parent = Actor::New();
7610
7611   application.GetScene().Add(parent);
7612   Vector2 stageSize(application.GetScene().GetSize());
7613
7614   Actor actor = Actor::New();
7615   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7616   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7617   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7618   actor.SetProperty(Actor::Property::INHERIT_SCALE, false);
7619   actor.SetProperty(Actor::Property::INHERIT_ORIENTATION, false);
7620   actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7621   parent.Add(actor);
7622
7623   application.SendNotification();
7624   application.Render();
7625
7626   const Vector3 expectedWorldPosition(-stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f);
7627
7628   tet_infoline("Check the world position is in the right place\n");
7629   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
7630
7631   tet_infoline("Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed");
7632   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7633   application.SendNotification();
7634   application.Render();
7635   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
7636
7637   tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed");
7638   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7639   application.SendNotification();
7640   application.Render();
7641   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
7642
7643   END_TEST;
7644 }
7645
7646 int utcDaliActorVisibilityChangeSignalSelf(void)
7647 {
7648   TestApplication application;
7649   tet_infoline("Check that the visibility change signal is called when the visibility changes for the actor itself");
7650
7651   Actor actor = Actor::New();
7652
7653   VisibilityChangedFunctorData data;
7654   DevelActor::VisibilityChangedSignal(actor).Connect(&application, VisibilityChangedFunctor(data));
7655
7656   actor.SetProperty(Actor::Property::VISIBLE, false);
7657
7658   data.Check(true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7659
7660   tet_infoline("Ensure functor is not called if we attempt to change the visibility to what it already is at");
7661   data.Reset();
7662
7663   actor.SetProperty(Actor::Property::VISIBLE, false);
7664   data.Check(false /* not called */, TEST_LOCATION);
7665
7666   tet_infoline("Change the visibility using properties, ensure called");
7667   data.Reset();
7668
7669   actor.SetProperty(Actor::Property::VISIBLE, true);
7670   data.Check(true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7671
7672   tet_infoline("Set the visibility to current using properties, ensure not called");
7673   data.Reset();
7674
7675   actor.SetProperty(Actor::Property::VISIBLE, true);
7676   data.Check(false /* not called */, TEST_LOCATION);
7677
7678   END_TEST;
7679 }
7680
7681 int utcDaliActorVisibilityChangeSignalChildren(void)
7682 {
7683   TestApplication application;
7684   tet_infoline("Check that the visibility change signal is called for the children when the visibility changes for the parent");
7685
7686   Actor parent = Actor::New();
7687   Actor child  = Actor::New();
7688   parent.Add(child);
7689
7690   Actor grandChild = Actor::New();
7691   child.Add(grandChild);
7692
7693   VisibilityChangedFunctorData parentData;
7694   VisibilityChangedFunctorData childData;
7695   VisibilityChangedFunctorData grandChildData;
7696
7697   tet_infoline("Only connect the child and grandchild, ensure they are called and not the parent");
7698   DevelActor::VisibilityChangedSignal(child).Connect(&application, VisibilityChangedFunctor(childData));
7699   DevelActor::VisibilityChangedSignal(grandChild).Connect(&application, VisibilityChangedFunctor(grandChildData));
7700
7701   parent.SetProperty(Actor::Property::VISIBLE, false);
7702   parentData.Check(false /* not called */, TEST_LOCATION);
7703   childData.Check(true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7704   grandChildData.Check(true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7705
7706   tet_infoline("Connect to the parent's signal as well and ensure all three are called");
7707   parentData.Reset();
7708   childData.Reset();
7709   grandChildData.Reset();
7710
7711   DevelActor::VisibilityChangedSignal(parent).Connect(&application, VisibilityChangedFunctor(parentData));
7712
7713   parent.SetProperty(Actor::Property::VISIBLE, true);
7714   parentData.Check(true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7715   childData.Check(true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7716   grandChildData.Check(true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7717
7718   tet_infoline("Ensure none of the functors are called if we attempt to change the visibility to what it already is at");
7719   parentData.Reset();
7720   childData.Reset();
7721   grandChildData.Reset();
7722
7723   parent.SetProperty(Actor::Property::VISIBLE, true);
7724   parentData.Check(false /* not called */, TEST_LOCATION);
7725   childData.Check(false /* not called */, TEST_LOCATION);
7726   grandChildData.Check(false /* not called */, TEST_LOCATION);
7727
7728   END_TEST;
7729 }
7730
7731 int utcDaliActorVisibilityChangeSignalAfterAnimation(void)
7732 {
7733   TestApplication application;
7734   tet_infoline("Check that the visibility change signal is emitted when the visibility changes when an animation starts");
7735
7736   Actor actor = Actor::New();
7737   application.GetScene().Add(actor);
7738
7739   application.SendNotification();
7740   application.Render();
7741
7742   VisibilityChangedFunctorData data;
7743   DevelActor::VisibilityChangedSignal(actor).Connect(&application, VisibilityChangedFunctor(data));
7744
7745   Animation animation = Animation::New(1.0f);
7746   animation.AnimateTo(Property(actor, Actor::Property::VISIBLE), false);
7747
7748   data.Check(false, TEST_LOCATION);
7749   DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7750   DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7751
7752   tet_infoline("Play the animation and check the property value");
7753   animation.Play();
7754
7755   data.Check(true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7756   DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::VISIBLE), false, TEST_LOCATION);
7757
7758   tet_infoline("Animation not currently finished, so the current visibility should still be true");
7759   DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7760
7761   application.SendNotification();
7762   application.Render(1100); // After the animation
7763
7764   DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), false, TEST_LOCATION);
7765
7766   END_TEST;
7767 }
7768
7769 int utcDaliActorVisibilityChangeSignalByName(void)
7770 {
7771   TestApplication application;
7772   tet_infoline("Check that the visibility change signal is called when the visibility changes for the actor itself");
7773
7774   Actor actor = Actor::New();
7775
7776   bool signalCalled = false;
7777   actor.ConnectSignal(&application, "visibilityChanged", VisibilityChangedVoidFunctor(signalCalled));
7778   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7779   actor.SetProperty(Actor::Property::VISIBLE, false);
7780   DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7781
7782   tet_infoline("Ensure functor is not called if we attempt to change the visibility to what it already is at");
7783   signalCalled = false;
7784   actor.SetProperty(Actor::Property::VISIBLE, false);
7785   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7786
7787   tet_infoline("Change the visibility using properties, ensure called");
7788   actor.SetProperty(Actor::Property::VISIBLE, true);
7789   DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7790
7791   tet_infoline("Set the visibility to current using properties, ensure not called");
7792   signalCalled = false;
7793
7794   actor.SetProperty(Actor::Property::VISIBLE, true);
7795   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7796
7797   END_TEST;
7798 }
7799
7800 static void LayoutDirectionChanged(Actor actor, LayoutDirection::Type type)
7801 {
7802   gLayoutDirectionType = type;
7803 }
7804
7805 int UtcDaliActorLayoutDirectionProperty(void)
7806 {
7807   TestApplication application;
7808   tet_infoline("Check layout direction property");
7809
7810   Actor actor0 = Actor::New();
7811   DALI_TEST_EQUALS(actor0.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7812   application.GetScene().Add(actor0);
7813
7814   application.SendNotification();
7815   application.Render();
7816
7817   Actor actor1 = Actor::New();
7818   DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7819   Actor actor2 = Actor::New();
7820   DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7821   Actor actor3 = Actor::New();
7822   DALI_TEST_EQUALS(actor3.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7823   Actor actor4 = Actor::New();
7824   DALI_TEST_EQUALS(actor4.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7825   Actor actor5 = Actor::New();
7826   DALI_TEST_EQUALS(actor5.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7827   Actor actor6 = Actor::New();
7828   DALI_TEST_EQUALS(actor6.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7829   Actor actor7 = Actor::New();
7830   DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7831   Actor actor8 = Actor::New();
7832   DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7833   Actor actor9 = Actor::New();
7834   DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7835
7836   actor1.Add(actor2);
7837   gLayoutDirectionType = LayoutDirection::LEFT_TO_RIGHT;
7838   actor2.LayoutDirectionChangedSignal().Connect(LayoutDirectionChanged);
7839
7840   DALI_TEST_EQUALS(actor1.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), true, TEST_LOCATION);
7841   actor1.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
7842   DALI_TEST_EQUALS(actor1.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), false, TEST_LOCATION);
7843
7844   DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7845   DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7846   DALI_TEST_EQUALS(gLayoutDirectionType, LayoutDirection::RIGHT_TO_LEFT, TEST_LOCATION);
7847
7848   actor1.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, true);
7849   actor0.Add(actor1);
7850   DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7851   DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7852
7853   application.GetScene().Add(actor3);
7854   actor3.Add(actor4);
7855   actor4.Add(actor5);
7856   actor5.Add(actor6);
7857   actor5.Add(actor7);
7858   actor7.Add(actor8);
7859   actor8.Add(actor9);
7860   actor3.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7861   actor5.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7862
7863   DALI_TEST_EQUALS(actor8.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), true, TEST_LOCATION);
7864   actor8.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, false);
7865   DALI_TEST_EQUALS(actor8.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), false, TEST_LOCATION);
7866
7867   actor7.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7868
7869   DALI_TEST_EQUALS(actor3.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7870   DALI_TEST_EQUALS(actor4.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7871   DALI_TEST_EQUALS(actor5.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7872   DALI_TEST_EQUALS(actor6.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7873   DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7874   DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7875   DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7876
7877   actor8.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7878   DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7879   DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7880
7881   actor7.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7882   DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7883   DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7884   DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7885
7886   actor8.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, true);
7887   DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7888   DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7889
7890   END_TEST;
7891 }
7892
7893 struct LayoutDirectionFunctor
7894 {
7895   LayoutDirectionFunctor(bool& signalCalled)
7896   : mSignalCalled(signalCalled)
7897   {
7898   }
7899
7900   LayoutDirectionFunctor(const LayoutDirectionFunctor& rhs)
7901   : mSignalCalled(rhs.mSignalCalled)
7902   {
7903   }
7904
7905   void operator()()
7906   {
7907     mSignalCalled = true;
7908   }
7909
7910   bool& mSignalCalled;
7911 };
7912
7913 int UtcDaliActorLayoutDirectionSignal(void)
7914 {
7915   TestApplication application;
7916   tet_infoline("Check changing layout direction property sends a signal");
7917
7918   Actor actor = Actor::New();
7919   DALI_TEST_EQUALS(actor.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7920   application.GetScene().Add(actor);
7921   bool                   signalCalled = false;
7922   LayoutDirectionFunctor layoutDirectionFunctor(signalCalled);
7923
7924   actor.ConnectSignal(&application, "layoutDirectionChanged", layoutDirectionFunctor);
7925   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7926
7927   // Test that writing the same value doesn't send a signal
7928   actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7929   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7930
7931   // Test that writing a different value sends the signal
7932   signalCalled = false;
7933   actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
7934   DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7935
7936   signalCalled = false;
7937   actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
7938   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7939
7940   END_TEST;
7941 }
7942
7943 struct ChildAddedSignalCheck
7944 {
7945   ChildAddedSignalCheck(bool& signalReceived, Actor& childHandle)
7946   : mSignalReceived(signalReceived),
7947     mChildHandle(childHandle)
7948   {
7949   }
7950
7951   void operator()(Actor childHandle)
7952   {
7953     mSignalReceived = true;
7954     mChildHandle    = childHandle;
7955   }
7956   void operator()()
7957   {
7958     mSignalReceived = true;
7959     mChildHandle    = Actor();
7960   }
7961
7962   bool&  mSignalReceived;
7963   Actor& mChildHandle;
7964 };
7965
7966 int UtcDaliChildAddedSignalP1(void)
7967 {
7968   TestApplication application;
7969   auto            stage = application.GetScene();
7970
7971   bool  signalReceived = false;
7972   Actor childActor;
7973
7974   ChildAddedSignalCheck signal(signalReceived, childActor);
7975   DevelActor::ChildAddedSignal(stage.GetRootLayer()).Connect(&application, signal);
7976   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7977
7978   auto actorA = Actor::New();
7979   stage.Add(actorA);
7980   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7981   DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
7982   signalReceived = false;
7983
7984   auto actorB = Actor::New();
7985   stage.Add(actorB);
7986   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7987   DALI_TEST_EQUALS(childActor, actorB, TEST_LOCATION);
7988
7989   END_TEST;
7990 }
7991
7992 int UtcDaliChildAddedSignalP2(void)
7993 {
7994   TestApplication application;
7995   auto            stage = application.GetScene();
7996
7997   bool  signalReceived = false;
7998   Actor childActor;
7999
8000   ChildAddedSignalCheck signal(signalReceived, childActor);
8001   tet_infoline("Connect to childAdded signal by name");
8002
8003   stage.GetRootLayer().ConnectSignal(&application, "childAdded", signal);
8004   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8005
8006   auto actorA = Actor::New();
8007   stage.Add(actorA);
8008   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8009
8010   // Can't test which actor was added; signal signature is void() when connecting via name.
8011   signalReceived = false;
8012
8013   auto actorB = Actor::New();
8014   stage.Add(actorB);
8015   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8016
8017   END_TEST;
8018 }
8019
8020 int UtcDaliChildAddedSignalN(void)
8021 {
8022   TestApplication application;
8023   auto            stage = application.GetScene();
8024
8025   bool  signalReceived = false;
8026   Actor childActor;
8027
8028   ChildAddedSignalCheck signal(signalReceived, childActor);
8029   DevelActor::ChildAddedSignal(stage.GetRootLayer()).Connect(&application, signal);
8030   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8031
8032   auto actorA = Actor::New();
8033   stage.Add(actorA);
8034   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8035   DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
8036   signalReceived = false;
8037
8038   auto actorB = Actor::New();
8039   actorA.Add(actorB);
8040   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8041   END_TEST;
8042 }
8043
8044 struct ChildRemovedSignalCheck
8045 {
8046   ChildRemovedSignalCheck(bool& signalReceived, Actor& childHandle)
8047   : mSignalReceived(signalReceived),
8048     mChildHandle(childHandle)
8049   {
8050   }
8051
8052   void operator()(Actor childHandle)
8053   {
8054     mSignalReceived = true;
8055     mChildHandle    = childHandle;
8056   }
8057
8058   void operator()()
8059   {
8060     mSignalReceived = true;
8061   }
8062
8063   bool&  mSignalReceived;
8064   Actor& mChildHandle;
8065 };
8066
8067 int UtcDaliChildRemovedSignalP1(void)
8068 {
8069   TestApplication application;
8070   auto            stage = application.GetScene();
8071
8072   bool  signalReceived = false;
8073   Actor childActor;
8074
8075   ChildRemovedSignalCheck signal(signalReceived, childActor);
8076   DevelActor::ChildRemovedSignal(stage.GetRootLayer()).Connect(&application, signal);
8077   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8078
8079   auto actorA = Actor::New();
8080   stage.Add(actorA);
8081   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8082   DALI_TEST_CHECK(!childActor);
8083
8084   stage.Remove(actorA);
8085   DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
8086   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8087
8088   signalReceived = false;
8089   auto actorB    = Actor::New();
8090   stage.Add(actorB);
8091   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8092
8093   stage.Remove(actorB);
8094   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8095   DALI_TEST_EQUALS(childActor, actorB, TEST_LOCATION);
8096
8097   END_TEST;
8098 }
8099
8100 int UtcDaliChildRemovedSignalP2(void)
8101 {
8102   TestApplication application;
8103   auto            stage = application.GetScene();
8104
8105   bool  signalReceived = false;
8106   Actor childActor;
8107
8108   ChildAddedSignalCheck signal(signalReceived, childActor);
8109   tet_infoline("Connect to childRemoved signal by name");
8110
8111   stage.GetRootLayer().ConnectSignal(&application, "childRemoved", signal);
8112   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8113
8114   auto actorA = Actor::New();
8115   stage.Add(actorA);
8116   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8117
8118   stage.Remove(actorA);
8119   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8120
8121   signalReceived = false;
8122   auto actorB    = Actor::New();
8123   stage.Add(actorB);
8124   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8125
8126   stage.Remove(actorB);
8127   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8128
8129   END_TEST;
8130 }
8131
8132 int UtcDaliChildRemovedSignalN(void)
8133 {
8134   TestApplication application;
8135   auto            stage = application.GetScene();
8136
8137   bool  signalReceived = false;
8138   Actor childActor;
8139
8140   ChildRemovedSignalCheck signal(signalReceived, childActor);
8141   DevelActor::ChildRemovedSignal(stage.GetRootLayer()).Connect(&application, signal);
8142   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8143
8144   auto actorA = Actor::New();
8145   stage.Add(actorA);
8146
8147   auto actorB = Actor::New();
8148   actorA.Add(actorB);
8149
8150   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8151   DALI_TEST_CHECK(!childActor);
8152
8153   actorA.Remove(actorB);
8154   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8155   END_TEST;
8156 }
8157
8158 int UtcDaliChildMovedSignalP(void)
8159 {
8160   TestApplication application;
8161   auto            stage = application.GetScene();
8162
8163   bool  addedASignalReceived   = false;
8164   bool  removedASignalReceived = false;
8165   bool  addedBSignalReceived   = false;
8166   bool  removedBSignalReceived = false;
8167   Actor childActor;
8168
8169   auto actorA = Actor::New();
8170   auto actorB = Actor::New();
8171   stage.Add(actorA);
8172   stage.Add(actorB);
8173
8174   ChildAddedSignalCheck   addedSignalA(addedASignalReceived, childActor);
8175   ChildRemovedSignalCheck removedSignalA(removedASignalReceived, childActor);
8176   ChildAddedSignalCheck   addedSignalB(addedBSignalReceived, childActor);
8177   ChildRemovedSignalCheck removedSignalB(removedBSignalReceived, childActor);
8178
8179   DevelActor::ChildAddedSignal(actorA).Connect(&application, addedSignalA);
8180   DevelActor::ChildRemovedSignal(actorA).Connect(&application, removedSignalA);
8181   DevelActor::ChildAddedSignal(actorB).Connect(&application, addedSignalB);
8182   DevelActor::ChildRemovedSignal(actorB).Connect(&application, removedSignalB);
8183
8184   DALI_TEST_EQUALS(addedASignalReceived, false, TEST_LOCATION);
8185   DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
8186   DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
8187   DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
8188
8189   // Create a child of A
8190
8191   auto child = Actor::New();
8192   actorA.Add(child);
8193
8194   DALI_TEST_EQUALS(addedASignalReceived, true, TEST_LOCATION);
8195   DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
8196   DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
8197   DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
8198   DALI_TEST_EQUALS(childActor, child, TEST_LOCATION);
8199
8200   // Move child to B:
8201   addedASignalReceived   = false;
8202   addedBSignalReceived   = false;
8203   removedASignalReceived = false;
8204   removedBSignalReceived = false;
8205
8206   actorB.Add(child); // Expect this child to be re-parented
8207   DALI_TEST_EQUALS(addedASignalReceived, false, TEST_LOCATION);
8208   DALI_TEST_EQUALS(removedASignalReceived, true, TEST_LOCATION);
8209   DALI_TEST_EQUALS(addedBSignalReceived, true, TEST_LOCATION);
8210   DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
8211
8212   // Move child back to A:
8213   addedASignalReceived   = false;
8214   addedBSignalReceived   = false;
8215   removedASignalReceived = false;
8216   removedBSignalReceived = false;
8217
8218   actorA.Add(child); // Expect this child to be re-parented
8219   DALI_TEST_EQUALS(addedASignalReceived, true, TEST_LOCATION);
8220   DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
8221   DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
8222   DALI_TEST_EQUALS(removedBSignalReceived, true, TEST_LOCATION);
8223
8224   END_TEST;
8225 }
8226
8227 int UtcDaliActorSwitchParentP(void)
8228 {
8229   tet_infoline("Testing Actor::UtcDaliActorSwitchParentP");
8230   TestApplication application;
8231
8232   Actor parent1 = Actor::New();
8233   Actor child   = Actor::New();
8234
8235   application.GetScene().Add(parent1);
8236
8237   DALI_TEST_EQUALS(parent1.GetChildCount(), 0u, TEST_LOCATION);
8238
8239   child.OnSceneSignal().Connect(OnSceneCallback);
8240   child.OffSceneSignal().Connect(OffSceneCallback);
8241
8242   // sanity check
8243   DALI_TEST_CHECK(gOnSceneCallBackCalled == 0);
8244   DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
8245
8246   parent1.Add(child);
8247
8248   DALI_TEST_EQUALS(parent1.GetChildCount(), 1u, TEST_LOCATION);
8249
8250   DALI_TEST_CHECK(gOnSceneCallBackCalled == 1);
8251   DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
8252
8253   Actor parent2 = Actor::New();
8254   application.GetScene().Add(parent2);
8255
8256   bool                  addSignalReceived = false;
8257   ChildAddedSignalCheck addedSignal(addSignalReceived, child);
8258   DevelActor::ChildAddedSignal(application.GetScene().GetRootLayer()).Connect(&application, addedSignal);
8259   DALI_TEST_EQUALS(addSignalReceived, false, TEST_LOCATION);
8260
8261   bool                    removedSignalReceived = false;
8262   ChildRemovedSignalCheck removedSignal(removedSignalReceived, child);
8263   DevelActor::ChildRemovedSignal(application.GetScene().GetRootLayer()).Connect(&application, removedSignal);
8264   DALI_TEST_EQUALS(removedSignalReceived, false, TEST_LOCATION);
8265
8266   DevelActor::SwitchParent(child, parent2);
8267
8268   DALI_TEST_EQUALS(addSignalReceived, false, TEST_LOCATION);
8269   DALI_TEST_EQUALS(removedSignalReceived, false, TEST_LOCATION);
8270
8271   DALI_TEST_EQUALS(parent1.GetChildCount(), 0u, TEST_LOCATION);
8272   DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
8273
8274   DALI_TEST_CHECK(gOnSceneCallBackCalled == 1);
8275   DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
8276   DALI_TEST_CHECK(child.GetProperty<bool>(Dali::Actor::Property::CONNECTED_TO_SCENE));
8277   DALI_TEST_CHECK(child.GetParent() == parent2);
8278
8279   END_TEST;
8280 }
8281
8282 int utcDaliActorCulled(void)
8283 {
8284   TestApplication application;
8285   auto            stage = application.GetScene();
8286
8287   tet_infoline("Check that the actor is culled if the actor is out of the screen");
8288
8289   Actor actor = Actor::New();
8290   actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
8291
8292   Geometry geometry = CreateQuadGeometry();
8293   Shader   shader   = CreateShader();
8294   Renderer renderer = Renderer::New(geometry, shader);
8295   actor.AddRenderer(renderer);
8296
8297   stage.Add(actor);
8298
8299   application.SendNotification();
8300   application.Render(0);
8301
8302   DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::CULLED), false, TEST_LOCATION);
8303
8304   PropertyNotification notification = actor.AddPropertyNotification(Actor::Property::CULLED, LessThanCondition(0.5f));
8305   notification.SetNotifyMode(PropertyNotification::NOTIFY_ON_CHANGED);
8306
8307   // Connect NotifySignal
8308   bool                              propertyNotificationSignal(false);
8309   PropertyNotification              source;
8310   CulledPropertyNotificationFunctor f(propertyNotificationSignal, source);
8311   notification.NotifySignal().Connect(&application, f);
8312
8313   actor.SetProperty(Actor::Property::POSITION, Vector2(1000.0f, 1000.0f));
8314
8315   application.SendNotification();
8316   application.Render();
8317
8318   application.SendNotification();
8319
8320   DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::CULLED), true, TEST_LOCATION);
8321
8322   DALI_TEST_EQUALS(propertyNotificationSignal, true, TEST_LOCATION);
8323   DALI_TEST_EQUALS(source.GetTargetProperty(), static_cast<int>(Actor::Property::CULLED), TEST_LOCATION);
8324   DALI_TEST_EQUALS(source.GetTarget().GetProperty<bool>(source.GetTargetProperty()), true, TEST_LOCATION);
8325
8326   END_TEST;
8327 }
8328
8329 int utcDaliEnsureRenderWhenRemovingLastRenderableActor(void)
8330 {
8331   TestApplication application;
8332   auto            stage = application.GetScene();
8333
8334   tet_infoline("Ensure we clear the screen when the last actor is removed");
8335
8336   Actor actor = CreateRenderableActor();
8337   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
8338   stage.Add(actor);
8339
8340   application.SendNotification();
8341   application.Render();
8342
8343   auto&      glAbstraction    = application.GetGlAbstraction();
8344   const auto clearCountBefore = glAbstraction.GetClearCountCalled();
8345
8346   actor.Unparent();
8347
8348   application.SendNotification();
8349   application.Render();
8350
8351   DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION);
8352
8353   END_TEST;
8354 }
8355
8356 int utcDaliEnsureRenderWhenMakingLastActorInvisible(void)
8357 {
8358   TestApplication application;
8359   auto            stage = application.GetScene();
8360
8361   tet_infoline("Ensure we clear the screen when the last actor is made invisible");
8362
8363   Actor actor = CreateRenderableActor();
8364   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
8365   stage.Add(actor);
8366
8367   application.SendNotification();
8368   application.Render();
8369
8370   auto&      glAbstraction    = application.GetGlAbstraction();
8371   const auto clearCountBefore = glAbstraction.GetClearCountCalled();
8372
8373   actor.SetProperty(Actor::Property::VISIBLE, false);
8374
8375   application.SendNotification();
8376   application.Render();
8377
8378   DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION);
8379
8380   END_TEST;
8381 }
8382
8383 int utcDaliActorGetSizeAfterAnimation(void)
8384 {
8385   TestApplication application;
8386   tet_infoline("Check the actor size before / after an animation is finished");
8387
8388   Vector3 actorSize(100.0f, 100.0f, 0.0f);
8389
8390   Actor actor = Actor::New();
8391   actor.SetProperty(Actor::Property::SIZE, actorSize);
8392   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8393   application.GetScene().Add(actor);
8394
8395   // Size should be updated without rendering.
8396   Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8397   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8398
8399   application.SendNotification();
8400   application.Render();
8401
8402   // Size and current size should be updated.
8403   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8404   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8405   DALI_TEST_EQUALS(actorSize.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8406   DALI_TEST_EQUALS(actorSize.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8407   DALI_TEST_EQUALS(actorSize.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8408
8409   Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8410   DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8411   DALI_TEST_EQUALS(actorSize.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8412   DALI_TEST_EQUALS(actorSize.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8413   DALI_TEST_EQUALS(actorSize.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8414
8415   // Set size again
8416   actorSize = Vector3(200.0f, 200.0f, 0.0f);
8417   actor.SetProperty(Actor::Property::SIZE, actorSize);
8418
8419   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8420   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8421
8422   Vector3 targetValue(10.0f, 20.0f, 0.0f);
8423
8424   Animation animation = Animation::New(1.0f);
8425   animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
8426   animation.Play();
8427
8428   // Size should be updated without rendering.
8429   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8430   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8431
8432   application.SendNotification();
8433   application.Render(1100); // After the animation
8434
8435   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8436   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8437   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8438   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8439   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8440
8441   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8442   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8443   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8444   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8445   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8446
8447   targetValue.width = 50.0f;
8448
8449   animation.Clear();
8450   animation.AnimateTo(Property(actor, Actor::Property::SIZE_WIDTH), targetValue.width);
8451   animation.Play();
8452
8453   application.SendNotification();
8454   application.Render(1100); // After the animation
8455
8456   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8457   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8458   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8459   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8460   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8461
8462   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8463   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8464   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8465   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8466   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8467
8468   targetValue.height = 70.0f;
8469
8470   animation.Clear();
8471   animation.AnimateTo(Property(actor, Actor::Property::SIZE_HEIGHT), targetValue.height);
8472   animation.Play();
8473
8474   application.SendNotification();
8475   application.Render(1100); // After the animation
8476
8477   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8478   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8479   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8480   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8481   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8482
8483   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8484   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8485   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8486   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8487   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8488
8489   Vector3 offset(10.0f, 20.0f, 0.0f);
8490
8491   animation.Clear();
8492   animation.AnimateBy(Property(actor, Actor::Property::SIZE), offset);
8493   animation.Play();
8494
8495   application.SendNotification();
8496   application.Render(1100); // After the animation
8497
8498   targetValue += offset;
8499
8500   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8501   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8502   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8503   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8504   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8505
8506   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8507   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8508   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8509   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8510   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8511
8512   offset.width = 20.0f;
8513
8514   animation.Clear();
8515   animation.AnimateBy(Property(actor, Actor::Property::SIZE_WIDTH), offset.width);
8516   animation.Play();
8517
8518   application.SendNotification();
8519   application.Render(1100); // After the animation
8520
8521   targetValue.width += offset.width;
8522
8523   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8524   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8525   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8526   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8527   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8528
8529   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8530   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8531   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8532   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8533   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8534
8535   offset.height = 10.0f;
8536
8537   animation.Clear();
8538   animation.AnimateBy(Property(actor, Actor::Property::SIZE_HEIGHT), offset.height);
8539   animation.Play();
8540
8541   application.SendNotification();
8542   application.Render(1100); // After the animation
8543
8544   targetValue.height += offset.height;
8545
8546   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8547   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8548   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8549   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8550   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8551
8552   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8553   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8554   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8555   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8556   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8557
8558   // Set size again
8559   actorSize = Vector3(300.0f, 300.0f, 0.0f);
8560
8561   actor.SetProperty(Actor::Property::SIZE, actorSize);
8562
8563   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8564   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8565
8566   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8567   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8568
8569   application.SendNotification();
8570   application.Render();
8571
8572   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8573   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8574
8575   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8576   DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8577
8578   END_TEST;
8579 }
8580
8581 int utcDaliActorGetSizeAfterAnimation2(void)
8582 {
8583   TestApplication application;
8584   tet_infoline("Check the actor size before / after an animation is finished if before size is equal to animation target size");
8585
8586   Vector3 actorSize(100.0f, 100.0f, 0.0f);
8587
8588   Actor actor = Actor::New();
8589   actor.SetProperty(Actor::Property::SIZE, actorSize);
8590   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8591   application.GetScene().Add(actor);
8592
8593   // Size should be updated without rendering.
8594   Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8595   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8596
8597   application.SendNotification();
8598   application.Render();
8599
8600   // Size and current size should be updated.
8601   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8602   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8603   DALI_TEST_EQUALS(actorSize.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8604   DALI_TEST_EQUALS(actorSize.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8605   DALI_TEST_EQUALS(actorSize.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8606
8607   Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8608   DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8609   DALI_TEST_EQUALS(actorSize.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8610   DALI_TEST_EQUALS(actorSize.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8611   DALI_TEST_EQUALS(actorSize.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8612
8613   // Set size again
8614   actorSize = Vector3(200.0f, 200.0f, 0.0f);
8615   actor.SetProperty(Actor::Property::SIZE, actorSize);
8616
8617   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8618   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8619
8620   Vector3 targetValue(actorSize);
8621
8622   Animation animation = Animation::New(1.0f);
8623   animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
8624   animation.Play();
8625
8626   // Size should be updated without rendering.
8627   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8628   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8629
8630   application.SendNotification();
8631   application.Render(100); // During the animation
8632
8633   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8634   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8635   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8636   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8637   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8638
8639   // We should get target value because targetValue is equal to current actor size.
8640   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8641   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8642   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8643   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8644   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8645
8646   application.SendNotification();
8647   application.Render(1000); // After animation finished
8648
8649   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8650   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8651
8652   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8653   DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8654
8655   END_TEST;
8656 }
8657
8658 int utcDaliActorRelayoutAndAnimation(void)
8659 {
8660   TestApplication application;
8661   tet_infoline("Check the actor size when relayoutting and playing animation");
8662
8663   Vector3 parentSize(300.0f, 300.0f, 0.0f);
8664   Vector3 actorSize(100.0f, 100.0f, 0.0f);
8665
8666   {
8667     Actor parentA = Actor::New();
8668     parentA.SetProperty(Actor::Property::SIZE, parentSize);
8669     parentA.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8670     application.GetScene().Add(parentA);
8671
8672     Actor parentB = Actor::New();
8673     parentB.SetProperty(Actor::Property::SIZE, parentSize);
8674     parentB.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8675     application.GetScene().Add(parentB);
8676
8677     Actor actor = Actor::New();
8678     actor.SetProperty(Actor::Property::SIZE, actorSize);
8679     actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8680     parentA.Add(actor);
8681
8682     Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8683     DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8684
8685     Vector3 targetValue(200.0f, 200.0f, 0.0f);
8686
8687     Animation animation = Animation::New(1.0f);
8688     animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
8689     animation.Play();
8690
8691     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8692     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8693
8694     application.SendNotification();
8695     application.Render(1100); // After the animation
8696
8697     // Size and current size should be updated.
8698     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8699     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8700
8701     Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8702     DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8703
8704     // Trigger relayout
8705     parentB.Add(actor);
8706
8707     application.SendNotification();
8708     application.Render();
8709
8710     // Size and current size should be same.
8711     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8712     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8713
8714     currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8715     DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8716
8717     actor.Unparent();
8718     parentA.Unparent();
8719     parentB.Unparent();
8720   }
8721
8722   {
8723     Actor parentA = Actor::New();
8724     parentA.SetProperty(Actor::Property::SIZE, parentSize);
8725     parentA.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8726     application.GetScene().Add(parentA);
8727
8728     Actor parentB = Actor::New();
8729     parentB.SetProperty(Actor::Property::SIZE, parentSize);
8730     parentB.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8731     application.GetScene().Add(parentB);
8732
8733     Actor actor = Actor::New();
8734     actor.SetProperty(Actor::Property::SIZE, actorSize);
8735     actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8736     parentA.Add(actor);
8737
8738     Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8739     DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8740
8741     application.SendNotification();
8742     application.Render();
8743
8744     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8745     DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8746
8747     Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8748     DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8749
8750     Vector3 targetValue(200.0f, 200.0f, 0.0f);
8751
8752     // Make an animation
8753     Animation animation = Animation::New(1.0f);
8754     animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
8755     animation.Play();
8756
8757     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8758     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8759
8760     application.SendNotification();
8761     application.Render(1100); // After the animation
8762
8763     // Size and current size should be updated.
8764     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8765     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8766
8767     currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8768     DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8769
8770     // Trigger relayout
8771     parentB.Add(actor);
8772
8773     application.SendNotification();
8774     application.Render();
8775
8776     // Size and current size should be same.
8777     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8778     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8779
8780     currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8781     DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8782
8783     actor.Unparent();
8784     parentA.Unparent();
8785     parentB.Unparent();
8786   }
8787
8788   END_TEST;
8789 }
8790
8791 int utcDaliActorPartialUpdate(void)
8792 {
8793   TestApplication application(
8794     TestApplication::DEFAULT_SURFACE_WIDTH,
8795     TestApplication::DEFAULT_SURFACE_HEIGHT,
8796     TestApplication::DEFAULT_HORIZONTAL_DPI,
8797     TestApplication::DEFAULT_VERTICAL_DPI,
8798     true,
8799     true);
8800
8801   tet_infoline("Check the damaged area");
8802
8803   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8804
8805   std::vector<Rect<int>> damagedRects;
8806   Rect<int>              clippingRect;
8807   application.SendNotification();
8808   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8809
8810   // First render pass, nothing to render, adaptor would just do swap buffer.
8811   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8812
8813   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8814   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8815
8816   Actor actor = CreateRenderableActor();
8817   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8818   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8819   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8820   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8821   application.GetScene().Add(actor);
8822
8823   application.SendNotification();
8824
8825   // 1. Actor added, damaged rect is added size of actor
8826   damagedRects.clear();
8827   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8828   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8829
8830   // Aligned by 16
8831   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
8832   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
8833   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8834   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8835   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8836   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8837   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8838
8839   // 2. Set new size
8840   actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0));
8841   application.SendNotification();
8842
8843   damagedRects.clear();
8844   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8845   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8846
8847   // Aligned by 16
8848   clippingRect = Rect<int>(16, 752, 48, 48); // in screen coordinates
8849   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
8850   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8851   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8852   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8853   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8854   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8855
8856   // 3. Set new position
8857   actor.SetProperty(Actor::Property::POSITION, Vector3(32.0f, 32.0f, 0));
8858   application.SendNotification();
8859
8860   damagedRects.clear();
8861   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8862   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8863
8864   // Aligned by 16
8865   clippingRect = Rect<int>(16, 736, 64, 64); // in screen coordinates
8866   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
8867   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8868   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8869   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8870   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8871   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8872
8873   application.GetScene().Remove(actor);
8874   application.SendNotification();
8875
8876   // Actor removed, last a dirty rect is reported.
8877   damagedRects.clear();
8878   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8879   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8880
8881   clippingRect = damagedRects[0];
8882
8883   DALI_TEST_EQUALS(clippingRect.IsValid(), true, TEST_LOCATION);
8884   DALI_TEST_EQUALS<Rect<int>>(clippingRect, Rect<int>(32, 736, 48, 48), TEST_LOCATION);
8885
8886   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8887   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8888   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8889   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8890   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8891
8892   END_TEST;
8893 }
8894
8895 int utcDaliActorPartialUpdateSetColor(void)
8896 {
8897   TestApplication application(
8898     TestApplication::DEFAULT_SURFACE_WIDTH,
8899     TestApplication::DEFAULT_SURFACE_HEIGHT,
8900     TestApplication::DEFAULT_HORIZONTAL_DPI,
8901     TestApplication::DEFAULT_VERTICAL_DPI,
8902     true,
8903     true);
8904
8905   tet_infoline("Check uniform update");
8906
8907   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8908
8909   std::vector<Rect<int>> damagedRects;
8910   Rect<int>              clippingRect;
8911   application.SendNotification();
8912   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8913
8914   // First render pass, nothing to render, adaptor would just do swap buffer.
8915   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8916
8917   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8918   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8919
8920   Actor actor = CreateRenderableActor();
8921   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8922   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8923   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8924   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8925   application.GetScene().Add(actor);
8926
8927   application.SendNotification();
8928
8929   // 1. Actor added, damaged rect is added size of actor
8930   damagedRects.clear();
8931   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8932   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8933
8934   // Aligned by 16
8935   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
8936   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
8937   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8938   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8939   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8940   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8941   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8942
8943   damagedRects.clear();
8944   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8945   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8946
8947   damagedRects.clear();
8948   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8949   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8950
8951   // 2. Set new color
8952   actor.SetProperty(Actor::Property::COLOR, Vector3(1.0f, 0.0f, 0.0f));
8953   application.SendNotification();
8954
8955   damagedRects.clear();
8956   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8957   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8958
8959   // Aligned by 16
8960   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
8961   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
8962   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8963   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8964   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8965   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8966   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8967
8968   END_TEST;
8969 }
8970
8971 const std::string SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME("uLightCameraProjectionMatrix");
8972 const std::string SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME("uLightCameraViewMatrix");
8973 const std::string SHADER_SHADOW_COLOR_PROPERTY_NAME("uShadowColor");
8974 const char* const RENDER_SHADOW_VERTEX_SOURCE =
8975   " uniform mediump mat4 uLightCameraProjectionMatrix;\n"
8976   " uniform mediump mat4 uLightCameraViewMatrix;\n"
8977   "\n"
8978   "void main()\n"
8979   "{\n"
8980   "  gl_Position = uProjection * uModelView * vec4(aPosition,1.0);\n"
8981   "  vec4 textureCoords = uLightCameraProjectionMatrix * uLightCameraViewMatrix * uModelMatrix  * vec4(aPosition,1.0);\n"
8982   "  vTexCoord = 0.5 + 0.5 * (textureCoords.xy/textureCoords.w);\n"
8983   "}\n";
8984
8985 const char* const RENDER_SHADOW_FRAGMENT_SOURCE =
8986   "uniform lowp vec4 uShadowColor;\n"
8987   "void main()\n"
8988   "{\n"
8989   "  lowp float alpha;\n"
8990   "  alpha = texture2D(sTexture, vec2(vTexCoord.x, vTexCoord.y)).a;\n"
8991   "  gl_FragColor = vec4(uShadowColor.rgb, uShadowColor.a * alpha);\n"
8992   "}\n";
8993
8994 int utcDaliActorPartialUpdateSetProperty(void)
8995 {
8996   TestApplication application(
8997     TestApplication::DEFAULT_SURFACE_WIDTH,
8998     TestApplication::DEFAULT_SURFACE_HEIGHT,
8999     TestApplication::DEFAULT_HORIZONTAL_DPI,
9000     TestApplication::DEFAULT_VERTICAL_DPI,
9001     true,
9002     true);
9003
9004   tet_infoline("Set/Update property with partial update");
9005
9006   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9007
9008   std::vector<Rect<int>> damagedRects;
9009   Rect<int>              clippingRect;
9010   application.SendNotification();
9011   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9012
9013   // First render pass, nothing to render, adaptor would just do swap buffer.
9014   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9015
9016   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9017   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9018
9019   Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 4u, 4u);
9020   Actor   actor = CreateRenderableActor(image, RENDER_SHADOW_VERTEX_SOURCE, RENDER_SHADOW_FRAGMENT_SOURCE);
9021   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9022   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
9023   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
9024   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9025   application.GetScene().Add(actor);
9026
9027   actor.RegisterProperty(SHADER_SHADOW_COLOR_PROPERTY_NAME, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
9028
9029   damagedRects.clear();
9030   application.SendNotification();
9031   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9032   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9033
9034   // Aligned by 16
9035   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
9036   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9037   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9038   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9039   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9040   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9041   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9042
9043   Property::Index shadowColorPropertyIndex = actor.GetPropertyIndex(SHADER_SHADOW_COLOR_PROPERTY_NAME);
9044   actor.SetProperty(shadowColorPropertyIndex, Vector4(1.0f, 1.0f, 0.0f, 1.0f));
9045
9046   damagedRects.clear();
9047   application.SendNotification();
9048   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9049   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9050
9051   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9052   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9053   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9054   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9055   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9056   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9057
9058   // Should be no damage rects, nothing changed
9059   damagedRects.clear();
9060   application.SendNotification();
9061   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9062   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9063
9064   // Should be 1 damage rect due to change in size
9065   damagedRects.clear();
9066   actor.SetProperty(Actor::Property::SIZE, Vector3(26.0f, 26.0f, 0.0f));
9067   application.SendNotification();
9068   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9069   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9070
9071   clippingRect = Rect<int>(16, 752, 32, 48); // new clipping rect size increased due to change in actor size
9072   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9073   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9074   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9075   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9076   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9077   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9078
9079   damagedRects.clear();
9080   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9081   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9082
9083   END_TEST;
9084 }
9085
9086 int utcDaliActorPartialUpdateTwoActors(void)
9087 {
9088   TestApplication application(
9089     TestApplication::DEFAULT_SURFACE_WIDTH,
9090     TestApplication::DEFAULT_SURFACE_HEIGHT,
9091     TestApplication::DEFAULT_HORIZONTAL_DPI,
9092     TestApplication::DEFAULT_VERTICAL_DPI,
9093     true,
9094     true);
9095
9096   tet_infoline("Check the damaged rects with partial update and two actors");
9097
9098   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9099
9100   Actor actor = CreateRenderableActor();
9101   actor.SetProperty(Actor::Property::POSITION, Vector3(100.0f, 100.0f, 0.0f));
9102   actor.SetProperty(Actor::Property::SIZE, Vector3(50.0f, 50.0f, 0.0f));
9103   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9104   application.GetScene().Add(actor);
9105
9106   Actor actor2 = CreateRenderableActor();
9107   actor2.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
9108   actor2.SetProperty(Actor::Property::SIZE, Vector3(100.0f, 100.0f, 0.0f));
9109   actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9110   application.GetScene().Add(actor2);
9111
9112   application.SendNotification();
9113   std::vector<Rect<int>> damagedRects;
9114   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9115
9116   DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
9117   DirtyRectChecker(damagedRects, {Rect<int>(64, 672, 64, 64), Rect<int>(96, 592, 112, 112)}, true, TEST_LOCATION);
9118
9119   // in screen coordinates, adaptor would calculate it using previous frames information
9120   Rect<int> clippingRect = Rect<int>(64, 592, 144, 192);
9121   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9122
9123   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9124   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9125   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9126   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9127
9128   // Change a Renderer of actor1
9129   Geometry geometry    = CreateQuadGeometry();
9130   Shader   shader      = CreateShader();
9131   Renderer newRenderer = Renderer::New(geometry, shader);
9132   Renderer renderer    = actor.GetRendererAt(0);
9133
9134   actor.RemoveRenderer(renderer);
9135   actor.AddRenderer(newRenderer);
9136
9137   damagedRects.clear();
9138
9139   application.SendNotification();
9140   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9141
9142   DALI_TEST_CHECK(damagedRects.size() > 0);
9143   DirtyRectChecker(damagedRects, {Rect<int>(64, 672, 64, 64)}, false, TEST_LOCATION);
9144
9145   // in screen coordinates, adaptor would calculate it using previous frames information
9146   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9147
9148   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9149   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9150   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9151   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9152
9153   END_TEST;
9154 }
9155
9156 int utcDaliActorPartialUpdateActorsWithSizeHint01(void)
9157 {
9158   TestApplication application(
9159     TestApplication::DEFAULT_SURFACE_WIDTH,
9160     TestApplication::DEFAULT_SURFACE_HEIGHT,
9161     TestApplication::DEFAULT_HORIZONTAL_DPI,
9162     TestApplication::DEFAULT_VERTICAL_DPI,
9163     true,
9164     true);
9165
9166   tet_infoline("Check the damaged rect with partial update and update area hint");
9167
9168   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9169
9170   Actor actor = CreateRenderableActor();
9171   actor.SetProperty(Actor::Property::POSITION, Vector3(64.0f, 64.0f, 0.0f));
9172   actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0.0f));
9173   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(0.0f, 0.0f, 64.0f, 64.0f));
9174   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9175   application.GetScene().Add(actor);
9176
9177   application.SendNotification();
9178   std::vector<Rect<int>> damagedRects;
9179   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9180
9181   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9182
9183   Rect<int> clippingRect = Rect<int>(32, 704, 80, 80);
9184   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9185
9186   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9187
9188   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9189   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9190   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9191   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9192
9193   // Reset
9194   actor.Unparent();
9195
9196   damagedRects.clear();
9197   application.SendNotification();
9198   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9199
9200   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9201   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9202
9203   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9204
9205   damagedRects.clear();
9206   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9207   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9208
9209   // Ensure the damaged rect is empty
9210   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9211
9212   // Chnage UPDATE_AREA_HINT
9213   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(16.0f, 16.0f, 32.0f, 32.0f));
9214   application.GetScene().Add(actor);
9215
9216   application.SendNotification();
9217   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9218
9219   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9220
9221   clippingRect = Rect<int>(64, 704, 48, 48);
9222   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9223
9224   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9225
9226   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9227   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9228   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9229   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9230
9231   // Reset
9232   actor.Unparent();
9233
9234   damagedRects.clear();
9235   application.SendNotification();
9236   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9237
9238   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9239   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9240
9241   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9242
9243   damagedRects.clear();
9244   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9245   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9246
9247   // Ensure the damaged rect is empty
9248   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9249
9250   // Chnage UPDATE_AREA_HINT
9251   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(-32.0f, -16.0f, 64.0f, 64.0f));
9252   application.GetScene().Add(actor);
9253
9254   application.SendNotification();
9255   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9256
9257   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9258
9259   clippingRect = Rect<int>(0, 720, 80, 80);
9260   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9261
9262   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9263
9264   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9265   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9266   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9267   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9268
9269   END_TEST;
9270 }
9271
9272 int utcDaliActorPartialUpdateActorsWithSizeHint02(void)
9273 {
9274   TestApplication application(
9275     TestApplication::DEFAULT_SURFACE_WIDTH,
9276     TestApplication::DEFAULT_SURFACE_HEIGHT,
9277     TestApplication::DEFAULT_HORIZONTAL_DPI,
9278     TestApplication::DEFAULT_VERTICAL_DPI,
9279     true,
9280     true);
9281
9282   tet_infoline("Check the damaged rect with partial update and update area hint");
9283
9284   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9285
9286   Actor actor = CreateRenderableActor();
9287   actor.SetProperty(Actor::Property::POSITION, Vector3(64.0f, 64.0f, 0.0f));
9288   actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0.0f));
9289   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9290   application.GetScene().Add(actor);
9291
9292   application.SendNotification();
9293   std::vector<Rect<int>> damagedRects;
9294   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9295
9296   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9297
9298   Rect<int> clippingRect = Rect<int>(48, 720, 48, 48);
9299   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9300
9301   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9302
9303   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9304   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9305   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9306   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9307
9308   damagedRects.clear();
9309   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9310   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9311
9312   // Ensure the damaged rect is empty
9313   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9314
9315   // Change UPDATE_AREA_HINT
9316   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(0.0f, 0.0f, 64.0f, 64.0f));
9317
9318   application.SendNotification();
9319   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9320
9321   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9322
9323   clippingRect = Rect<int>(32, 704, 80, 80);
9324   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9325
9326   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9327
9328   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9329   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9330   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9331   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9332
9333   damagedRects.clear();
9334   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9335   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9336
9337   // Ensure the damaged rect is empty
9338   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9339
9340   // Chnage UPDATE_AREA_HINT
9341   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(16.0f, 16.0f, 64.0f, 64.0f));
9342   application.GetScene().Add(actor);
9343
9344   application.SendNotification();
9345   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9346
9347   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9348
9349   clippingRect = Rect<int>(32, 688, 96, 96);
9350   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9351
9352   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9353
9354   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9355   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9356   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9357   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9358
9359   END_TEST;
9360 }
9361
9362 int utcDaliActorPartialUpdateActorsWithSizeHint03(void)
9363 {
9364   TestApplication application(
9365     TestApplication::DEFAULT_SURFACE_WIDTH,
9366     TestApplication::DEFAULT_SURFACE_HEIGHT,
9367     TestApplication::DEFAULT_HORIZONTAL_DPI,
9368     TestApplication::DEFAULT_VERTICAL_DPI,
9369     true,
9370     true);
9371
9372   tet_infoline("Check the damaged rect with partial update and update area hint");
9373
9374   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9375
9376   Actor actor = CreateRenderableActor();
9377   actor.SetProperty(Actor::Property::POSITION, Vector3(64.0f, 64.0f, 0.0f));
9378   actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0.0f));
9379   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(0.0f, 0.0f, 64.0f, 64.0f));
9380   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9381   application.GetScene().Add(actor);
9382
9383   application.SendNotification();
9384   std::vector<Rect<int>> damagedRects;
9385   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9386
9387   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9388
9389   Rect<int> clippingRect = Rect<int>(32, 704, 80, 80);
9390   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9391
9392   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9393
9394   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9395   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9396   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9397   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9398
9399   damagedRects.clear();
9400   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9401   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9402
9403   // Ensure the damaged rect is empty
9404   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9405
9406   // Set UPDATE_AREA_HINT twice before rendering
9407   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(0.0f, 0.0f, 32.0f, 32.0f));
9408   application.SendNotification();
9409
9410   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(32.0f, -32.0f, 32.0f, 32.0f));
9411   application.SendNotification();
9412
9413   damagedRects.clear();
9414   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9415
9416   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9417
9418   clippingRect = Rect<int>(32, 704, 96, 96);
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 utcDaliActorPartialUpdateAnimation(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 area with partial update and animation");
9442
9443   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
9444   drawTrace.Enable(true);
9445   drawTrace.Reset();
9446
9447   Actor actor1 = CreateRenderableActor();
9448   actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9449   actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
9450   application.GetScene().Add(actor1);
9451
9452   Actor actor2 = CreateRenderableActor();
9453   actor2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9454   actor2.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
9455   application.GetScene().Add(actor2);
9456
9457   std::vector<Rect<int>> damagedRects;
9458   Rect<int>              clippingRect;
9459   Rect<int>              expectedRect1, expectedRect2;
9460
9461   application.SendNotification();
9462   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9463
9464   DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
9465
9466   // Aligned by 16
9467   expectedRect1 = Rect<int>(0, 720, 96, 96); // in screen coordinates, includes 1 last frames updates
9468   expectedRect2 = Rect<int>(0, 784, 32, 32); // in screen coordinates, includes 1 last frames updates
9469   DirtyRectChecker(damagedRects, {expectedRect1, expectedRect2}, true, TEST_LOCATION);
9470
9471   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9472   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9473
9474   // Make an animation
9475   Animation animation = Animation::New(1.0f);
9476   animation.AnimateTo(Property(actor2, Actor::Property::POSITION_X), 160.0f, TimePeriod(0.5f, 0.5f));
9477   animation.Play();
9478
9479   application.SendNotification();
9480
9481   damagedRects.clear();
9482   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9483   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9484   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9485
9486   drawTrace.Reset();
9487   damagedRects.clear();
9488
9489   // In animation deley time
9490   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9491   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9492   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9493
9494   // Skip rendering
9495   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
9496
9497   drawTrace.Reset();
9498   damagedRects.clear();
9499
9500   // Also in animation deley time
9501   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9502   application.PreRenderWithPartialUpdate(100, nullptr, damagedRects);
9503   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9504
9505   // Skip rendering
9506   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
9507
9508   // Unparent 2 actors and make a new actor
9509   actor1.Unparent();
9510   actor2.Unparent();
9511
9512   Actor actor3 = CreateRenderableActor();
9513   actor3.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9514   actor3.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
9515   application.GetScene().Add(actor3);
9516
9517   application.SendNotification();
9518
9519   // Started animation
9520   damagedRects.clear();
9521   application.PreRenderWithPartialUpdate(500, nullptr, damagedRects);
9522   DALI_TEST_EQUALS(damagedRects.size(), 3, TEST_LOCATION);
9523
9524   // One of dirty rect is actor3's.
9525   // We don't know the exact dirty rect of actor1 and actor2.
9526   DirtyRectChecker(damagedRects, {expectedRect1, expectedRect2, expectedRect2}, true, TEST_LOCATION);
9527
9528   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9529   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9530
9531   // Finished animation, but the actor was already unparented
9532   damagedRects.clear();
9533   application.PreRenderWithPartialUpdate(500, nullptr, damagedRects);
9534
9535   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9536
9537   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9538   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9539
9540   END_TEST;
9541 }
9542
9543 int utcDaliActorPartialUpdateChangeVisibility(void)
9544 {
9545   TestApplication application(
9546     TestApplication::DEFAULT_SURFACE_WIDTH,
9547     TestApplication::DEFAULT_SURFACE_HEIGHT,
9548     TestApplication::DEFAULT_HORIZONTAL_DPI,
9549     TestApplication::DEFAULT_VERTICAL_DPI,
9550     true,
9551     true);
9552
9553   tet_infoline("Check the damaged rect with partial update and visibility change");
9554
9555   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9556
9557   Actor actor = CreateRenderableActor();
9558   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9559   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
9560   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
9561   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9562   application.GetScene().Add(actor);
9563
9564   application.SendNotification();
9565
9566   std::vector<Rect<int>> damagedRects;
9567   Rect<int>              clippingRect;
9568
9569   // 1. Actor added, damaged rect is added size of actor
9570   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9571   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9572
9573   // Aligned by 16
9574   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
9575   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9576   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9577   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9578   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9579   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9580   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9581
9582   damagedRects.clear();
9583   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9584   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9585
9586   // Ensure the damaged rect is empty
9587   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9588
9589   // 2. Make the Actor invisible
9590   actor.SetProperty(Actor::Property::VISIBLE, false);
9591   application.SendNotification();
9592
9593   damagedRects.clear();
9594   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9595   DALI_TEST_CHECK(damagedRects.size() > 0);
9596   DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
9597
9598   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9599   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9600   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9601   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9602   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9603
9604   // 3. Make the Actor visible again
9605   actor.SetProperty(Actor::Property::VISIBLE, true);
9606   application.SendNotification();
9607
9608   damagedRects.clear();
9609   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9610   DALI_TEST_CHECK(damagedRects.size() > 0);
9611   DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
9612
9613   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9614   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9615   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9616   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9617   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9618
9619   END_TEST;
9620 }
9621
9622 int utcDaliActorPartialUpdateOnOffScene(void)
9623 {
9624   TestApplication application(
9625     TestApplication::DEFAULT_SURFACE_WIDTH,
9626     TestApplication::DEFAULT_SURFACE_HEIGHT,
9627     TestApplication::DEFAULT_HORIZONTAL_DPI,
9628     TestApplication::DEFAULT_VERTICAL_DPI,
9629     true,
9630     true);
9631
9632   tet_infoline("Check the damaged rect with partial update and on/off scene");
9633
9634   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9635
9636   Actor actor = CreateRenderableActor();
9637   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9638   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
9639   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
9640   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9641   application.GetScene().Add(actor);
9642
9643   application.SendNotification();
9644
9645   std::vector<Rect<int>> damagedRects;
9646   Rect<int>              clippingRect;
9647
9648   // 1. Actor added, damaged rect is added size of actor
9649   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9650   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9651
9652   // Aligned by 16
9653   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
9654   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9655   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9656   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9657   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9658   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9659   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9660
9661   damagedRects.clear();
9662   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9663   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9664
9665   damagedRects.clear();
9666   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9667   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9668
9669   // Ensure the damaged rect is empty
9670   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9671
9672   // 2. Remove the Actor from the Scene
9673   actor.Unparent();
9674   application.SendNotification();
9675
9676   damagedRects.clear();
9677   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9678   DALI_TEST_CHECK(damagedRects.size() > 0);
9679   DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
9680
9681   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9682   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9683   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9684   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9685   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9686
9687   // 3. Add the Actor to the Scene again
9688   application.GetScene().Add(actor);
9689   application.SendNotification();
9690
9691   damagedRects.clear();
9692   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9693   DALI_TEST_CHECK(damagedRects.size() > 0);
9694   DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
9695
9696   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9697   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9698   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9699   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9700   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9701
9702   END_TEST;
9703 }
9704
9705 int utcDaliActorPartialUpdateSkipRendering(void)
9706 {
9707   TestApplication application(
9708     TestApplication::DEFAULT_SURFACE_WIDTH,
9709     TestApplication::DEFAULT_SURFACE_HEIGHT,
9710     TestApplication::DEFAULT_HORIZONTAL_DPI,
9711     TestApplication::DEFAULT_VERTICAL_DPI,
9712     true,
9713     true);
9714
9715   tet_infoline("Check to skip rendering in case of the empty damaged rect");
9716
9717   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
9718   drawTrace.Enable(true);
9719   drawTrace.Reset();
9720
9721   Actor actor1 = CreateRenderableActor();
9722   actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9723   actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
9724   application.GetScene().Add(actor1);
9725
9726   std::vector<Rect<int>> damagedRects;
9727   Rect<int>              clippingRect;
9728   Rect<int>              expectedRect1;
9729
9730   application.SendNotification();
9731   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9732
9733   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9734
9735   // Aligned by 16
9736   expectedRect1 = Rect<int>(0, 720, 96, 96); // in screen coordinates
9737   DirtyRectChecker(damagedRects, {expectedRect1}, true, TEST_LOCATION);
9738
9739   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9740   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9741
9742   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9743
9744   damagedRects.clear();
9745   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9746   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9747   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9748
9749   // Remove the actor
9750   actor1.Unparent();
9751
9752   application.SendNotification();
9753
9754   damagedRects.clear();
9755   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9756
9757   DirtyRectChecker(damagedRects, {expectedRect1}, true, TEST_LOCATION);
9758
9759   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9760   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9761
9762   // Render again without any change
9763   damagedRects.clear();
9764   drawTrace.Reset();
9765   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9766
9767   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9768
9769   clippingRect = Rect<int>();
9770   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9771
9772   // Skip rendering
9773   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
9774
9775   // Add the actor again
9776   application.GetScene().Add(actor1);
9777
9778   application.SendNotification();
9779
9780   damagedRects.clear();
9781   drawTrace.Reset();
9782   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9783
9784   DirtyRectChecker(damagedRects, {expectedRect1}, true, TEST_LOCATION);
9785
9786   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9787   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9788
9789   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9790
9791   END_TEST;
9792 }
9793
9794 int utcDaliActorPartialUpdate3DNode(void)
9795 {
9796   TestApplication application(
9797     TestApplication::DEFAULT_SURFACE_WIDTH,
9798     TestApplication::DEFAULT_SURFACE_HEIGHT,
9799     TestApplication::DEFAULT_HORIZONTAL_DPI,
9800     TestApplication::DEFAULT_VERTICAL_DPI,
9801     true,
9802     true);
9803
9804   tet_infoline("Partial update should be ignored in case of 3d layer of 3d node");
9805
9806   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
9807   drawTrace.Enable(true);
9808   drawTrace.Reset();
9809
9810   Actor actor1 = CreateRenderableActor();
9811   actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9812   actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
9813   application.GetScene().Add(actor1);
9814
9815   std::vector<Rect<int>> damagedRects;
9816   Rect<int>              clippingRect;
9817
9818   application.SendNotification();
9819   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9820
9821   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9822
9823   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9824   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9825
9826   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9827
9828   // Change the layer to 3D
9829   application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D);
9830
9831   application.SendNotification();
9832
9833   damagedRects.clear();
9834   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9835
9836   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9837   DirtyRectChecker(damagedRects, {TestApplication::DEFAULT_SURFACE_RECT}, true, TEST_LOCATION);
9838
9839   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9840   drawTrace.Reset();
9841   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9842
9843   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9844
9845   // Change the layer to 2D
9846   application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_UI);
9847
9848   application.SendNotification();
9849
9850   damagedRects.clear();
9851   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9852
9853   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9854
9855   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9856   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9857
9858   // Make 3D transform
9859   actor1.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::YAXIS));
9860
9861   application.SendNotification();
9862
9863   damagedRects.clear();
9864   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9865
9866   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9867   DirtyRectChecker(damagedRects, {TestApplication::DEFAULT_SURFACE_RECT}, true, TEST_LOCATION);
9868
9869   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9870   drawTrace.Reset();
9871   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9872
9873   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9874
9875   END_TEST;
9876 }
9877
9878 int utcDaliActorPartialUpdateNotRenderableActor(void)
9879 {
9880   TestApplication application(
9881     TestApplication::DEFAULT_SURFACE_WIDTH,
9882     TestApplication::DEFAULT_SURFACE_HEIGHT,
9883     TestApplication::DEFAULT_HORIZONTAL_DPI,
9884     TestApplication::DEFAULT_VERTICAL_DPI,
9885     true,
9886     true);
9887
9888   tet_infoline("Check the damaged rect with not renderable parent actor");
9889
9890   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9891
9892   Actor parent                          = Actor::New();
9893   parent[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9894   parent[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
9895   parent[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
9896   parent.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9897   application.GetScene().Add(parent);
9898
9899   Actor child                          = CreateRenderableActor();
9900   child[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9901   child[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
9902   child.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9903   parent.Add(child);
9904
9905   application.SendNotification();
9906
9907   std::vector<Rect<int>> damagedRects;
9908
9909   // 1. Actor added, damaged rect is added size of actor
9910   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9911   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9912
9913   // Aligned by 16
9914   Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
9915   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9916
9917   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9918   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9919   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9920   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9921   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9922
9923   damagedRects.clear();
9924   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9925   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9926
9927   damagedRects.clear();
9928   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9929   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9930
9931   // Ensure the damaged rect is empty
9932   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9933
9934   END_TEST;
9935 }
9936
9937 int utcDaliActorPartialUpdateChangeTransparency(void)
9938 {
9939   TestApplication application(
9940     TestApplication::DEFAULT_SURFACE_WIDTH,
9941     TestApplication::DEFAULT_SURFACE_HEIGHT,
9942     TestApplication::DEFAULT_HORIZONTAL_DPI,
9943     TestApplication::DEFAULT_VERTICAL_DPI,
9944     true,
9945     true);
9946
9947   tet_infoline("Check the damaged rect with changing transparency");
9948
9949   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9950
9951   Actor actor                          = CreateRenderableActor();
9952   actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9953   actor[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
9954   actor[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
9955   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9956   application.GetScene().Add(actor);
9957
9958   application.SendNotification();
9959
9960   std::vector<Rect<int>> damagedRects;
9961
9962   // Actor added, damaged rect is added size of actor
9963   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9964   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9965
9966   // Aligned by 16
9967   Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
9968   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9969
9970   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9971   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9972   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9973   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9974   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9975
9976   damagedRects.clear();
9977   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9978   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9979
9980   // Ensure the damaged rect is empty
9981   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9982
9983   // Make the actor transparent by changing opacity of the Renderer
9984   // It changes a uniform value
9985   Renderer renderer                          = actor.GetRendererAt(0);
9986   renderer[DevelRenderer::Property::OPACITY] = 0.0f;
9987
9988   application.SendNotification();
9989
9990   // The damaged rect should be same
9991   damagedRects.clear();
9992   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9993   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9994   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9995   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9996
9997   damagedRects.clear();
9998   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9999   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10000
10001   // Ensure the damaged rect is empty
10002   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10003
10004   // Make the actor opaque again
10005   renderer[DevelRenderer::Property::OPACITY] = 1.0f;
10006
10007   application.SendNotification();
10008
10009   // The damaged rect should not be empty
10010   damagedRects.clear();
10011   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10012   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10013   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10014   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10015
10016   damagedRects.clear();
10017   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10018   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10019
10020   // Ensure the damaged rect is empty
10021   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10022
10023   // Make the actor translucent
10024   renderer[DevelRenderer::Property::OPACITY] = 0.5f;
10025
10026   application.SendNotification();
10027
10028   // The damaged rect should not be empty
10029   damagedRects.clear();
10030   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10031   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10032   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10033   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10034
10035   damagedRects.clear();
10036   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10037   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10038
10039   // Ensure the damaged rect is empty
10040   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10041
10042   // Change Renderer opacity - also translucent
10043   renderer[DevelRenderer::Property::OPACITY] = 0.2f;
10044
10045   application.SendNotification();
10046
10047   // The damaged rect should not be empty
10048   damagedRects.clear();
10049   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10050   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10051   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10052   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10053
10054   damagedRects.clear();
10055   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10056   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10057
10058   // Ensure the damaged rect is empty
10059   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10060
10061   // Make the actor culled
10062   actor[Actor::Property::SIZE] = Vector3(0.0f, 0.0f, 0.0f);
10063
10064   application.SendNotification();
10065
10066   // The damaged rect should be same
10067   damagedRects.clear();
10068   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10069   DALI_TEST_CHECK(damagedRects.size() > 0);
10070   DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
10071   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10072
10073   damagedRects.clear();
10074   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10075   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10076
10077   // Ensure the damaged rect is empty
10078   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10079
10080   // Make the actor not culled again
10081   actor[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 16.0f);
10082
10083   application.SendNotification();
10084
10085   // The damaged rect should not be empty
10086   damagedRects.clear();
10087   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10088   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10089   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10090   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10091
10092   END_TEST;
10093 }
10094
10095 int utcDaliActorPartialUpdateChangeParentOpacity(void)
10096 {
10097   TestApplication application(
10098     TestApplication::DEFAULT_SURFACE_WIDTH,
10099     TestApplication::DEFAULT_SURFACE_HEIGHT,
10100     TestApplication::DEFAULT_HORIZONTAL_DPI,
10101     TestApplication::DEFAULT_VERTICAL_DPI,
10102     true,
10103     true);
10104
10105   tet_infoline("Check the damaged rect with changing parent's opacity");
10106
10107   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
10108
10109   Actor parent                          = Actor::New();
10110   parent[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10111   parent[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
10112   parent[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
10113   parent.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10114   application.GetScene().Add(parent);
10115
10116   Texture texture                      = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
10117   Actor   child                        = CreateRenderableActor(texture);
10118   child[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10119   child[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
10120   child.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10121   parent.Add(child);
10122
10123   application.SendNotification();
10124
10125   std::vector<Rect<int>> damagedRects;
10126
10127   // Actor added, damaged rect is added size of actor
10128   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10129   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10130
10131   // Aligned by 16
10132   Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10133   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10134
10135   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10136   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
10137   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
10138   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
10139   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
10140
10141   damagedRects.clear();
10142   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10143   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10144
10145   damagedRects.clear();
10146   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10147   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10148
10149   // Ensure the damaged rect is empty
10150   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10151
10152   // Change the parent's opacity
10153   parent[Actor::Property::OPACITY] = 0.5f;
10154
10155   application.SendNotification();
10156
10157   // The damaged rect should be same
10158   damagedRects.clear();
10159   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10160   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10161   DALI_TEST_CHECK(damagedRects.size() > 0);
10162   DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
10163
10164   END_TEST;
10165 }
10166
10167 int utcDaliActorPartialUpdateAddRemoveRenderer(void)
10168 {
10169   TestApplication application(
10170     TestApplication::DEFAULT_SURFACE_WIDTH,
10171     TestApplication::DEFAULT_SURFACE_HEIGHT,
10172     TestApplication::DEFAULT_HORIZONTAL_DPI,
10173     TestApplication::DEFAULT_VERTICAL_DPI,
10174     true,
10175     true);
10176
10177   tet_infoline("Check the damaged rect with adding / removing renderer");
10178
10179   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
10180
10181   Actor actor                          = CreateRenderableActor();
10182   actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10183   actor[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
10184   actor[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
10185   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10186   application.GetScene().Add(actor);
10187
10188   application.SendNotification();
10189
10190   std::vector<Rect<int>> damagedRects;
10191
10192   // Actor added, damaged rect is added size of actor
10193   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10194   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10195
10196   // Aligned by 16
10197   Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10198   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10199
10200   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10201   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
10202   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
10203   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
10204   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
10205
10206   damagedRects.clear();
10207   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10208   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10209
10210   damagedRects.clear();
10211   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10212   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10213
10214   // Remove the Renderer
10215   Renderer renderer = actor.GetRendererAt(0);
10216   actor.RemoveRenderer(renderer);
10217
10218   application.SendNotification();
10219
10220   // The damaged rect should be the actor area
10221   damagedRects.clear();
10222   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10223   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10224   DALI_TEST_CHECK(damagedRects.size() > 0);
10225   DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
10226
10227   damagedRects.clear();
10228   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10229   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10230
10231   // Ensure the damaged rect is empty
10232   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10233
10234   // Add the Renderer again
10235   actor.AddRenderer(renderer);
10236
10237   application.SendNotification();
10238
10239   // The damaged rect should be the actor area
10240   damagedRects.clear();
10241   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10242   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10243   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10244   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10245
10246   END_TEST;
10247 }
10248
10249 int utcDaliActorPartialUpdate3DTransform(void)
10250 {
10251   TestApplication application(
10252     TestApplication::DEFAULT_SURFACE_WIDTH,
10253     TestApplication::DEFAULT_SURFACE_HEIGHT,
10254     TestApplication::DEFAULT_HORIZONTAL_DPI,
10255     TestApplication::DEFAULT_VERTICAL_DPI,
10256     true,
10257     true);
10258
10259   tet_infoline("Check the damaged rect with 3D transformed actors");
10260
10261   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
10262
10263   Actor actor1                          = CreateRenderableActor();
10264   actor1[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10265   actor1[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
10266   actor1[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
10267   actor1.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10268   application.GetScene().Add(actor1);
10269
10270   // Add a new actor
10271   Actor actor2                          = CreateRenderableActor();
10272   actor2[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10273   actor2[Actor::Property::POSITION]     = Vector3(160.0f, 160.0f, 0.0f);
10274   actor2[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
10275   actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10276   application.GetScene().Add(actor2);
10277
10278   application.SendNotification();
10279
10280   std::vector<Rect<int>> damagedRects;
10281
10282   // Actor added, damaged rect is added size of actor
10283   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10284   DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
10285
10286   // Aligned by 16
10287   Rect<int> clippingRect1 = Rect<int>(16, 768, 32, 32); // in screen coordinates
10288   Rect<int> clippingRect2 = Rect<int>(160, 624, 32, 32);
10289   DirtyRectChecker(damagedRects, {clippingRect1, clippingRect2}, true, TEST_LOCATION);
10290
10291   Rect<int> surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10292   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10293
10294   damagedRects.clear();
10295   surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10296   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10297   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10298
10299   damagedRects.clear();
10300   surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10301   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10302   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10303
10304   // Rotate actor1 on y axis
10305   actor1[Actor::Property::ORIENTATION] = Quaternion(Radian(Degree(90.0)), Vector3::YAXIS);
10306
10307   // Remove actor2
10308   actor2.Unparent();
10309
10310   application.SendNotification();
10311
10312   damagedRects.clear();
10313   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10314
10315   // Should update full area
10316   surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10317   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10318   DirtyRectChecker(damagedRects, {surfaceRect}, true, TEST_LOCATION);
10319   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10320
10321   // Add actor2 again
10322   application.GetScene().Add(actor2);
10323
10324   application.SendNotification();
10325
10326   damagedRects.clear();
10327   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10328
10329   // Should update full area
10330   surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10331   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10332   DirtyRectChecker(damagedRects, {surfaceRect}, true, TEST_LOCATION);
10333   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10334
10335   // Reset the orientation of actor1
10336   actor1[Actor::Property::ORIENTATION] = Quaternion::IDENTITY;
10337
10338   application.SendNotification();
10339
10340   damagedRects.clear();
10341   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10342
10343   // Should update full area
10344   surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10345   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10346   DirtyRectChecker(damagedRects, {surfaceRect}, true, TEST_LOCATION);
10347   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10348
10349   // Make actor2 dirty
10350   actor2[Actor::Property::SIZE] = Vector3(32.0f, 32.0f, 0.0f);
10351
10352   application.SendNotification();
10353
10354   damagedRects.clear();
10355   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10356
10357   clippingRect2 = Rect<int>(160, 608, 48, 48);
10358   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10359   DirtyRectChecker(damagedRects, {clippingRect2}, true, TEST_LOCATION);
10360
10361   application.RenderWithPartialUpdate(damagedRects, clippingRect2);
10362   DALI_TEST_EQUALS(clippingRect2.x, glScissorParams.x, TEST_LOCATION);
10363   DALI_TEST_EQUALS(clippingRect2.y, glScissorParams.y, TEST_LOCATION);
10364   DALI_TEST_EQUALS(clippingRect2.width, glScissorParams.width, TEST_LOCATION);
10365   DALI_TEST_EQUALS(clippingRect2.height, glScissorParams.height, TEST_LOCATION);
10366
10367   // Remove actor1
10368   actor1.Unparent();
10369
10370   application.SendNotification();
10371
10372   damagedRects.clear();
10373   surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10374   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10375   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10376
10377   // Rotate actor1 on y axis
10378   actor1[Actor::Property::ORIENTATION] = Quaternion(Radian(Degree(90.0)), Vector3::YAXIS);
10379
10380   // Add actor1 again
10381   application.GetScene().Add(actor1);
10382
10383   application.SendNotification();
10384
10385   damagedRects.clear();
10386   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10387
10388   // Should update full area
10389   surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10390   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10391   DirtyRectChecker(damagedRects, {surfaceRect}, true, TEST_LOCATION);
10392   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10393
10394   END_TEST;
10395 }
10396
10397 int utcDaliActorPartialUpdateOneActorMultipleRenderers(void)
10398 {
10399   TestApplication application(
10400     TestApplication::DEFAULT_SURFACE_WIDTH,
10401     TestApplication::DEFAULT_SURFACE_HEIGHT,
10402     TestApplication::DEFAULT_HORIZONTAL_DPI,
10403     TestApplication::DEFAULT_VERTICAL_DPI,
10404     true,
10405     true);
10406
10407   tet_infoline("Check the damaged rect with one actor which has multiple renderers");
10408
10409   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
10410
10411   Actor actor = CreateRenderableActor();
10412
10413   // Create another renderer
10414   Geometry geometry  = CreateQuadGeometry();
10415   Shader   shader    = CreateShader();
10416   Renderer renderer2 = Renderer::New(geometry, shader);
10417   actor.AddRenderer(renderer2);
10418
10419   actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10420   actor[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
10421   actor[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
10422   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10423   application.GetScene().Add(actor);
10424
10425   application.SendNotification();
10426
10427   DALI_TEST_EQUALS(actor.GetRendererCount(), 2u, TEST_LOCATION);
10428
10429   std::vector<Rect<int>> damagedRects;
10430
10431   // Actor added, damaged rect is added size of actor
10432   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10433   DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
10434
10435   // Aligned by 16
10436   Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10437   DirtyRectChecker(damagedRects, {clippingRect, clippingRect}, true, TEST_LOCATION);
10438
10439   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10440   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
10441   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
10442   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
10443   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
10444
10445   damagedRects.clear();
10446   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10447   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10448
10449   // Ensure the damaged rect is empty
10450   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10451
10452   // Make renderer2 dirty
10453   renderer2[DevelRenderer::Property::OPACITY] = 0.5f;
10454
10455   application.SendNotification();
10456
10457   // The damaged rect should be the actor area
10458   damagedRects.clear();
10459   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10460
10461   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10462   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10463   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10464
10465   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10466
10467   damagedRects.clear();
10468   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10469   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10470
10471   // Ensure the damaged rect is empty
10472   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10473
10474   // Make renderer2 dirty
10475   renderer2[Renderer::Property::FACE_CULLING_MODE] = FaceCullingMode::BACK;
10476
10477   application.SendNotification();
10478
10479   // The damaged rect should be the actor area
10480   damagedRects.clear();
10481   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10482
10483   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10484   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10485   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10486
10487   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10488
10489   damagedRects.clear();
10490   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10491   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10492
10493   // Ensure the damaged rect is empty
10494   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10495
10496   END_TEST;
10497 }
10498
10499 int utcDaliActorPartialUpdateMultipleActorsOneRenderer(void)
10500 {
10501   TestApplication application(
10502     TestApplication::DEFAULT_SURFACE_WIDTH,
10503     TestApplication::DEFAULT_SURFACE_HEIGHT,
10504     TestApplication::DEFAULT_HORIZONTAL_DPI,
10505     TestApplication::DEFAULT_VERTICAL_DPI,
10506     true,
10507     true);
10508
10509   tet_infoline("Check the damaged rect with multiple actors which share a same renderer");
10510
10511   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
10512
10513   Actor actor                          = CreateRenderableActor();
10514   actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10515   actor[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
10516   actor[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
10517   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10518   application.GetScene().Add(actor);
10519
10520   // Create another actor which has the same renderer with actor1
10521   Actor    actor2   = Actor::New();
10522   Renderer renderer = actor.GetRendererAt(0);
10523   actor2.AddRenderer(renderer);
10524   actor2[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10525   actor2[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
10526   actor2[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
10527   actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10528   application.GetScene().Add(actor2);
10529
10530   application.SendNotification();
10531
10532   std::vector<Rect<int>> damagedRects;
10533
10534   // Actor added, damaged rect is added size of actor
10535   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10536   DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
10537
10538   // Aligned by 16
10539   Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10540   DirtyRectChecker(damagedRects, {clippingRect, clippingRect}, true, TEST_LOCATION);
10541
10542   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10543   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
10544   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
10545   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
10546   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
10547
10548   damagedRects.clear();
10549   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10550   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10551
10552   // Ensure the damaged rect is empty
10553   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10554
10555   // Make renderer dirty
10556   renderer[DevelRenderer::Property::OPACITY] = 0.5f;
10557
10558   application.SendNotification();
10559
10560   // The damaged rect should be the actor area
10561   damagedRects.clear();
10562   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10563
10564   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10565   DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
10566   DirtyRectChecker(damagedRects, {clippingRect, clippingRect}, true, TEST_LOCATION);
10567
10568   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10569
10570   damagedRects.clear();
10571   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10572   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10573
10574   // Ensure the damaged rect is empty
10575   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10576
10577   END_TEST;
10578 }
10579
10580 int UtcDaliActorCaptureAllTouchAfterStartPropertyP(void)
10581 {
10582   TestApplication application;
10583
10584   Actor actor = Actor::New();
10585   DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), false, TEST_LOCATION);
10586   actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, true);
10587   DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), true, TEST_LOCATION);
10588   DALI_TEST_EQUALS(actor.GetPropertyType(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), Property::BOOLEAN, TEST_LOCATION);
10589   DALI_TEST_EQUALS(actor.IsPropertyWritable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), true, TEST_LOCATION);
10590   DALI_TEST_EQUALS(actor.IsPropertyAnimatable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
10591   DALI_TEST_EQUALS(actor.IsPropertyAConstraintInput(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
10592   DALI_TEST_EQUALS(actor.GetPropertyName(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), "captureAllTouchAfterStart", TEST_LOCATION);
10593   END_TEST;
10594 }
10595
10596 int UtcDaliActorCaptureAllTouchAfterStartPropertyN(void)
10597 {
10598   TestApplication application;
10599
10600   Actor actor = Actor::New();
10601
10602   // Make sure setting invalid types does not cause a crash
10603   try
10604   {
10605     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, 1.0f);
10606     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector2::ONE);
10607     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector3::ONE);
10608     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector4::ONE);
10609     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Map());
10610     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Array());
10611     tet_result(TET_PASS);
10612   }
10613   catch(...)
10614   {
10615     tet_result(TET_FAIL);
10616   }
10617   END_TEST;
10618 }
10619
10620 int UtcDaliActorTouchAreaOffsetPropertyP(void)
10621 {
10622   TestApplication application;
10623
10624   Actor     actor           = Actor::New();
10625   Rect<int> touchAreaOffset = actor.GetProperty(DevelActor::Property::TOUCH_AREA_OFFSET).Get<Rect<int>>();
10626   DALI_TEST_EQUALS(Rect<int>(0, 0, 0, 0), touchAreaOffset, TEST_LOCATION);
10627   actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Rect<int>(10, 20, 30, 40));
10628   touchAreaOffset = actor.GetProperty(DevelActor::Property::TOUCH_AREA_OFFSET).Get<Rect<int>>();
10629   DALI_TEST_EQUALS(Rect<int>(10, 20, 30, 40), touchAreaOffset, TEST_LOCATION);
10630   END_TEST;
10631 }
10632
10633 int UtcDaliActorTouchAreaOffsetPropertyN(void)
10634 {
10635   TestApplication application;
10636
10637   Actor actor = Actor::New();
10638
10639   // Make sure setting invalid types does not cause a crash
10640   try
10641   {
10642     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, 1.0f);
10643     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector2::ONE);
10644     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector3::ONE);
10645     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector4::ONE);
10646     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Property::Map());
10647     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Property::Array());
10648     tet_result(TET_PASS);
10649   }
10650   catch(...)
10651   {
10652     tet_result(TET_FAIL);
10653   }
10654   END_TEST;
10655 }
10656
10657 int UtcDaliActorLowerBelowNegative(void)
10658 {
10659   TestApplication application;
10660   Dali::Actor     instance;
10661   try
10662   {
10663     Dali::Actor arg1;
10664     instance.LowerBelow(arg1);
10665     DALI_TEST_CHECK(false); // Should not get here
10666   }
10667   catch(...)
10668   {
10669     DALI_TEST_CHECK(true); // We expect an assert
10670   }
10671   END_TEST;
10672 }
10673
10674 int UtcDaliActorRaiseAboveNegative(void)
10675 {
10676   TestApplication application;
10677   Dali::Actor     instance;
10678   try
10679   {
10680     Dali::Actor arg1;
10681     instance.RaiseAbove(arg1);
10682     DALI_TEST_CHECK(false); // Should not get here
10683   }
10684   catch(...)
10685   {
10686     DALI_TEST_CHECK(true); // We expect an assert
10687   }
10688   END_TEST;
10689 }
10690
10691 int UtcDaliActorRaiseToTopNegative(void)
10692 {
10693   TestApplication application;
10694   Dali::Actor     instance;
10695   try
10696   {
10697     instance.RaiseToTop();
10698     DALI_TEST_CHECK(false); // Should not get here
10699   }
10700   catch(...)
10701   {
10702     DALI_TEST_CHECK(true); // We expect an assert
10703   }
10704   END_TEST;
10705 }
10706
10707 int UtcDaliActorAddRendererNegative(void)
10708 {
10709   TestApplication application;
10710   Dali::Actor     instance;
10711   try
10712   {
10713     Dali::Renderer arg1;
10714     instance.AddRenderer(arg1);
10715     DALI_TEST_CHECK(false); // Should not get here
10716   }
10717   catch(...)
10718   {
10719     DALI_TEST_CHECK(true); // We expect an assert
10720   }
10721   END_TEST;
10722 }
10723
10724 int UtcDaliActorTouchedSignalNegative(void)
10725 {
10726   TestApplication application;
10727   Dali::Actor     instance;
10728   try
10729   {
10730     instance.TouchedSignal();
10731     DALI_TEST_CHECK(false); // Should not get here
10732   }
10733   catch(...)
10734   {
10735     DALI_TEST_CHECK(true); // We expect an assert
10736   }
10737   END_TEST;
10738 }
10739
10740 int UtcDaliActorTranslateByNegative(void)
10741 {
10742   TestApplication application;
10743   Dali::Actor     instance;
10744   try
10745   {
10746     Dali::Vector3 arg1;
10747     instance.TranslateBy(arg1);
10748     DALI_TEST_CHECK(false); // Should not get here
10749   }
10750   catch(...)
10751   {
10752     DALI_TEST_CHECK(true); // We expect an assert
10753   }
10754   END_TEST;
10755 }
10756
10757 int UtcDaliActorFindChildByIdNegative(void)
10758 {
10759   TestApplication application;
10760   Dali::Actor     instance;
10761   try
10762   {
10763     unsigned int arg1 = 0u;
10764     instance.FindChildById(arg1);
10765     DALI_TEST_CHECK(false); // Should not get here
10766   }
10767   catch(...)
10768   {
10769     DALI_TEST_CHECK(true); // We expect an assert
10770   }
10771   END_TEST;
10772 }
10773
10774 int UtcDaliActorGetRendererAtNegative(void)
10775 {
10776   TestApplication application;
10777   Dali::Actor     instance;
10778   try
10779   {
10780     unsigned int arg1 = 0u;
10781     instance.GetRendererAt(arg1);
10782     DALI_TEST_CHECK(false); // Should not get here
10783   }
10784   catch(...)
10785   {
10786     DALI_TEST_CHECK(true); // We expect an assert
10787   }
10788   END_TEST;
10789 }
10790
10791 int UtcDaliActorHoveredSignalNegative(void)
10792 {
10793   TestApplication application;
10794   Dali::Actor     instance;
10795   try
10796   {
10797     instance.HoveredSignal();
10798     DALI_TEST_CHECK(false); // Should not get here
10799   }
10800   catch(...)
10801   {
10802     DALI_TEST_CHECK(true); // We expect an assert
10803   }
10804   END_TEST;
10805 }
10806
10807 int UtcDaliActorLowerToBottomNegative(void)
10808 {
10809   TestApplication application;
10810   Dali::Actor     instance;
10811   try
10812   {
10813     instance.LowerToBottom();
10814     DALI_TEST_CHECK(false); // Should not get here
10815   }
10816   catch(...)
10817   {
10818     DALI_TEST_CHECK(true); // We expect an assert
10819   }
10820   END_TEST;
10821 }
10822
10823 int UtcDaliActorOnSceneSignalNegative(void)
10824 {
10825   TestApplication application;
10826   Dali::Actor     instance;
10827   try
10828   {
10829     instance.OnSceneSignal();
10830     DALI_TEST_CHECK(false); // Should not get here
10831   }
10832   catch(...)
10833   {
10834     DALI_TEST_CHECK(true); // We expect an assert
10835   }
10836   END_TEST;
10837 }
10838
10839 int UtcDaliActorOffSceneSignalNegative(void)
10840 {
10841   TestApplication application;
10842   Dali::Actor     instance;
10843   try
10844   {
10845     instance.OffSceneSignal();
10846     DALI_TEST_CHECK(false); // Should not get here
10847   }
10848   catch(...)
10849   {
10850     DALI_TEST_CHECK(true); // We expect an assert
10851   }
10852   END_TEST;
10853 }
10854
10855 int UtcDaliActorRemoveRendererNegative01(void)
10856 {
10857   TestApplication application;
10858   Dali::Actor     instance;
10859   try
10860   {
10861     unsigned int arg1 = 0u;
10862     instance.RemoveRenderer(arg1);
10863     DALI_TEST_CHECK(false); // Should not get here
10864   }
10865   catch(...)
10866   {
10867     DALI_TEST_CHECK(true); // We expect an assert
10868   }
10869   END_TEST;
10870 }
10871
10872 int UtcDaliActorRemoveRendererNegative02(void)
10873 {
10874   TestApplication application;
10875   Dali::Actor     instance;
10876   try
10877   {
10878     Dali::Renderer arg1;
10879     instance.RemoveRenderer(arg1);
10880     DALI_TEST_CHECK(false); // Should not get here
10881   }
10882   catch(...)
10883   {
10884     DALI_TEST_CHECK(true); // We expect an assert
10885   }
10886   END_TEST;
10887 }
10888
10889 int UtcDaliActorFindChildByNameNegative(void)
10890 {
10891   TestApplication application;
10892   Dali::Actor     instance;
10893   try
10894   {
10895     std::string arg1;
10896     instance.FindChildByName(arg1);
10897     DALI_TEST_CHECK(false); // Should not get here
10898   }
10899   catch(...)
10900   {
10901     DALI_TEST_CHECK(true); // We expect an assert
10902   }
10903   END_TEST;
10904 }
10905
10906 int UtcDaliActorSetResizePolicyNegative(void)
10907 {
10908   TestApplication application;
10909   Dali::Actor     instance;
10910   try
10911   {
10912     Dali::ResizePolicy::Type arg1 = ResizePolicy::USE_NATURAL_SIZE;
10913     Dali::Dimension::Type    arg2 = Dimension::ALL_DIMENSIONS;
10914     instance.SetResizePolicy(arg1, arg2);
10915     DALI_TEST_CHECK(false); // Should not get here
10916   }
10917   catch(...)
10918   {
10919     DALI_TEST_CHECK(true); // We expect an assert
10920   }
10921   END_TEST;
10922 }
10923
10924 int UtcDaliActorOnRelayoutSignalNegative(void)
10925 {
10926   TestApplication application;
10927   Dali::Actor     instance;
10928   try
10929   {
10930     instance.OnRelayoutSignal();
10931     DALI_TEST_CHECK(false); // Should not get here
10932   }
10933   catch(...)
10934   {
10935     DALI_TEST_CHECK(true); // We expect an assert
10936   }
10937   END_TEST;
10938 }
10939
10940 int UtcDaliActorWheelEventSignalNegative(void)
10941 {
10942   TestApplication application;
10943   Dali::Actor     instance;
10944   try
10945   {
10946     instance.WheelEventSignal();
10947     DALI_TEST_CHECK(false); // Should not get here
10948   }
10949   catch(...)
10950   {
10951     DALI_TEST_CHECK(true); // We expect an assert
10952   }
10953   END_TEST;
10954 }
10955
10956 int UtcDaliActorGetHeightForWidthNegative(void)
10957 {
10958   TestApplication application;
10959   Dali::Actor     instance;
10960   try
10961   {
10962     float arg1 = 0.0f;
10963     instance.GetHeightForWidth(arg1);
10964     DALI_TEST_CHECK(false); // Should not get here
10965   }
10966   catch(...)
10967   {
10968     DALI_TEST_CHECK(true); // We expect an assert
10969   }
10970   END_TEST;
10971 }
10972
10973 int UtcDaliActorGetWidthForHeightNegative(void)
10974 {
10975   TestApplication application;
10976   Dali::Actor     instance;
10977   try
10978   {
10979     float arg1 = 0.0f;
10980     instance.GetWidthForHeight(arg1);
10981     DALI_TEST_CHECK(false); // Should not get here
10982   }
10983   catch(...)
10984   {
10985     DALI_TEST_CHECK(true); // We expect an assert
10986   }
10987   END_TEST;
10988 }
10989
10990 int UtcDaliActorLayoutDirectionChangedSignalNegative(void)
10991 {
10992   TestApplication application;
10993   Dali::Actor     instance;
10994   try
10995   {
10996     instance.LayoutDirectionChangedSignal();
10997     DALI_TEST_CHECK(false); // Should not get here
10998   }
10999   catch(...)
11000   {
11001     DALI_TEST_CHECK(true); // We expect an assert
11002   }
11003   END_TEST;
11004 }
11005
11006 int UtcDaliActorAddNegative(void)
11007 {
11008   TestApplication application;
11009   Dali::Actor     instance;
11010   try
11011   {
11012     Dali::Actor arg1;
11013     instance.Add(arg1);
11014     DALI_TEST_CHECK(false); // Should not get here
11015   }
11016   catch(...)
11017   {
11018     DALI_TEST_CHECK(true); // We expect an assert
11019   }
11020   END_TEST;
11021 }
11022
11023 int UtcDaliActorLowerNegative(void)
11024 {
11025   TestApplication application;
11026   Dali::Actor     instance;
11027   try
11028   {
11029     instance.Lower();
11030     DALI_TEST_CHECK(false); // Should not get here
11031   }
11032   catch(...)
11033   {
11034     DALI_TEST_CHECK(true); // We expect an assert
11035   }
11036   END_TEST;
11037 }
11038
11039 int UtcDaliActorRaiseNegative(void)
11040 {
11041   TestApplication application;
11042   Dali::Actor     instance;
11043   try
11044   {
11045     instance.Raise();
11046     DALI_TEST_CHECK(false); // Should not get here
11047   }
11048   catch(...)
11049   {
11050     DALI_TEST_CHECK(true); // We expect an assert
11051   }
11052   END_TEST;
11053 }
11054
11055 int UtcDaliActorRemoveNegative(void)
11056 {
11057   TestApplication application;
11058   Dali::Actor     instance;
11059   try
11060   {
11061     Dali::Actor arg1;
11062     instance.Remove(arg1);
11063     DALI_TEST_CHECK(false); // Should not get here
11064   }
11065   catch(...)
11066   {
11067     DALI_TEST_CHECK(true); // We expect an assert
11068   }
11069   END_TEST;
11070 }
11071
11072 int UtcDaliActorScaleByNegative(void)
11073 {
11074   TestApplication application;
11075   Dali::Actor     instance;
11076   try
11077   {
11078     Dali::Vector3 arg1;
11079     instance.ScaleBy(arg1);
11080     DALI_TEST_CHECK(false); // Should not get here
11081   }
11082   catch(...)
11083   {
11084     DALI_TEST_CHECK(true); // We expect an assert
11085   }
11086   END_TEST;
11087 }
11088
11089 int UtcDaliActorGetLayerNegative(void)
11090 {
11091   TestApplication application;
11092   Dali::Actor     instance;
11093   try
11094   {
11095     instance.GetLayer();
11096     DALI_TEST_CHECK(false); // Should not get here
11097   }
11098   catch(...)
11099   {
11100     DALI_TEST_CHECK(true); // We expect an assert
11101   }
11102   END_TEST;
11103 }
11104
11105 int UtcDaliActorRotateByNegative01(void)
11106 {
11107   TestApplication application;
11108   Dali::Actor     instance;
11109   try
11110   {
11111     Dali::Quaternion arg1;
11112     instance.RotateBy(arg1);
11113     DALI_TEST_CHECK(false); // Should not get here
11114   }
11115   catch(...)
11116   {
11117     DALI_TEST_CHECK(true); // We expect an assert
11118   }
11119   END_TEST;
11120 }
11121
11122 int UtcDaliActorRotateByNegative02(void)
11123 {
11124   TestApplication application;
11125   Dali::Actor     instance;
11126   try
11127   {
11128     Dali::Radian  arg1;
11129     Dali::Vector3 arg2;
11130     instance.RotateBy(arg1, arg2);
11131     DALI_TEST_CHECK(false); // Should not get here
11132   }
11133   catch(...)
11134   {
11135     DALI_TEST_CHECK(true); // We expect an assert
11136   }
11137   END_TEST;
11138 }
11139
11140 int UtcDaliActorUnparentNegative(void)
11141 {
11142   TestApplication application;
11143   Dali::Actor     instance;
11144   try
11145   {
11146     instance.Unparent();
11147     DALI_TEST_CHECK(false); // Should not get here
11148   }
11149   catch(...)
11150   {
11151     DALI_TEST_CHECK(true); // We expect an assert
11152   }
11153   END_TEST;
11154 }
11155
11156 int UtcDaliActorGetChildAtNegative(void)
11157 {
11158   TestApplication application;
11159   Dali::Actor     instance;
11160   try
11161   {
11162     unsigned int arg1 = 0u;
11163     instance.GetChildAt(arg1);
11164     DALI_TEST_CHECK(false); // Should not get here
11165   }
11166   catch(...)
11167   {
11168     DALI_TEST_CHECK(true); // We expect an assert
11169   }
11170   END_TEST;
11171 }
11172
11173 int UtcDaliActorGetChildCountNegative(void)
11174 {
11175   TestApplication application;
11176   Dali::Actor     instance;
11177   try
11178   {
11179     instance.GetChildCount();
11180     DALI_TEST_CHECK(false); // Should not get here
11181   }
11182   catch(...)
11183   {
11184     DALI_TEST_CHECK(true); // We expect an assert
11185   }
11186   END_TEST;
11187 }
11188
11189 int UtcDaliActorGetTargetSizeNegative(void)
11190 {
11191   TestApplication application;
11192   Dali::Actor     instance;
11193   try
11194   {
11195     instance.GetTargetSize();
11196     DALI_TEST_CHECK(false); // Should not get here
11197   }
11198   catch(...)
11199   {
11200     DALI_TEST_CHECK(true); // We expect an assert
11201   }
11202   END_TEST;
11203 }
11204
11205 int UtcDaliActorScreenToLocalNegative(void)
11206 {
11207   TestApplication application;
11208   Dali::Actor     instance;
11209   try
11210   {
11211     float arg1 = 0.0f;
11212     float arg2 = 0.0f;
11213     float arg3 = 0.0f;
11214     float arg4 = 0.0f;
11215     instance.ScreenToLocal(arg1, arg2, arg3, arg4);
11216     DALI_TEST_CHECK(false); // Should not get here
11217   }
11218   catch(...)
11219   {
11220     DALI_TEST_CHECK(true); // We expect an assert
11221   }
11222   END_TEST;
11223 }
11224
11225 int UtcDaliActorGetNaturalSizeNegative(void)
11226 {
11227   TestApplication application;
11228   Dali::Actor     instance;
11229   try
11230   {
11231     instance.GetNaturalSize();
11232     DALI_TEST_CHECK(false); // Should not get here
11233   }
11234   catch(...)
11235   {
11236     DALI_TEST_CHECK(true); // We expect an assert
11237   }
11238   END_TEST;
11239 }
11240
11241 int UtcDaliActorGetRelayoutSizeNegative(void)
11242 {
11243   TestApplication application;
11244   Dali::Actor     instance;
11245   try
11246   {
11247     Dali::Dimension::Type arg1 = Dimension::HEIGHT;
11248     instance.GetRelayoutSize(arg1);
11249     DALI_TEST_CHECK(false); // Should not get here
11250   }
11251   catch(...)
11252   {
11253     DALI_TEST_CHECK(true); // We expect an assert
11254   }
11255   END_TEST;
11256 }
11257
11258 int UtcDaliActorGetResizePolicyNegative(void)
11259 {
11260   TestApplication application;
11261   Dali::Actor     instance;
11262   try
11263   {
11264     Dali::Dimension::Type arg1 = Dimension::ALL_DIMENSIONS;
11265     instance.GetResizePolicy(arg1);
11266     DALI_TEST_CHECK(false); // Should not get here
11267   }
11268   catch(...)
11269   {
11270     DALI_TEST_CHECK(true); // We expect an assert
11271   }
11272   END_TEST;
11273 }
11274
11275 int UtcDaliActorGetRendererCountNegative(void)
11276 {
11277   TestApplication application;
11278   Dali::Actor     instance;
11279   try
11280   {
11281     instance.GetRendererCount();
11282     DALI_TEST_CHECK(false); // Should not get here
11283   }
11284   catch(...)
11285   {
11286     DALI_TEST_CHECK(true); // We expect an assert
11287   }
11288   END_TEST;
11289 }
11290
11291 int UtcDaliActorGetParentNegative(void)
11292 {
11293   TestApplication application;
11294   Dali::Actor     instance;
11295   try
11296   {
11297     instance.GetParent();
11298     DALI_TEST_CHECK(false); // Should not get here
11299   }
11300   catch(...)
11301   {
11302     DALI_TEST_CHECK(true); // We expect an assert
11303   }
11304   END_TEST;
11305 }
11306
11307 int UtcDaliActorPropertyBlendEquation(void)
11308 {
11309   TestApplication application;
11310
11311   tet_infoline("Test SetProperty AdvancedBlendEquation");
11312
11313   Geometry geometry  = CreateQuadGeometry();
11314   Shader   shader    = CreateShader();
11315   Renderer renderer1 = Renderer::New(geometry, shader);
11316
11317   Actor actor = Actor::New();
11318   actor.SetProperty(Actor::Property::OPACITY, 0.1f);
11319
11320   actor.AddRenderer(renderer1);
11321   actor.SetProperty(Actor::Property::SIZE, Vector2(400, 400));
11322   application.GetScene().Add(actor);
11323
11324   if(!Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
11325   {
11326     actor.SetProperty(Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN);
11327     int equation = actor.GetProperty<int>(Dali::DevelActor::Property::BLEND_EQUATION);
11328     DALI_TEST_EQUALS((Dali::DevelBlendEquation::SCREEN == equation), false, TEST_LOCATION);
11329   }
11330
11331   if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
11332   {
11333     actor.SetProperty(Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN);
11334     int equation = actor.GetProperty<int>(Dali::DevelActor::Property::BLEND_EQUATION);
11335     DALI_TEST_EQUALS((Dali::DevelBlendEquation::SCREEN == equation), true, TEST_LOCATION);
11336   }
11337
11338   Renderer renderer2 = Renderer::New(geometry, shader);
11339   actor.AddRenderer(renderer2);
11340
11341   END_TEST;
11342 }
11343
11344 int UtcDaliActorRegisterProperty(void)
11345 {
11346   tet_infoline("Test property registration and uniform map update\n");
11347
11348   TestApplication application;
11349
11350   Geometry geometry  = CreateQuadGeometry();
11351   Shader   shader    = CreateShader();
11352   Renderer renderer1 = Renderer::New(geometry, shader);
11353   Renderer renderer2 = Renderer::New(geometry, shader);
11354
11355   Actor actor1 = Actor::New();
11356   actor1.AddRenderer(renderer1);
11357   actor1.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
11358   actor1.RegisterProperty("uCustom", 1);
11359   application.GetScene().Add(actor1);
11360
11361   Actor actor2 = Actor::New();
11362   actor2.AddRenderer(renderer2);
11363   actor2.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
11364   application.GetScene().Add(actor2);
11365
11366   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
11367   TraceCallStack&    callStack     = glAbstraction.GetSetUniformTrace();
11368   glAbstraction.EnableSetUniformCallTrace(true);
11369
11370   application.SendNotification();
11371   application.Render();
11372
11373   std::stringstream out;
11374   out.str("1");
11375   std::string params;
11376
11377   // Test uniform value of the custom property
11378   DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("uCustom", params));
11379   DALI_TEST_EQUALS(out.str(), params, TEST_LOCATION);
11380
11381   // Make invisible
11382   actor1[Actor::Property::VISIBLE] = false;
11383
11384   application.SendNotification();
11385   application.Render();
11386
11387   // Make visible again
11388   actor1[Actor::Property::VISIBLE] = true;
11389   actor1["uCustom"]                = 2;
11390
11391   glAbstraction.ResetSetUniformCallStack();
11392
11393   application.SendNotification();
11394   application.Render();
11395
11396   out.str("2");
11397
11398   // The uniform value should not be changed
11399   DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("uCustom", params));
11400   DALI_TEST_EQUALS(out.str(), params, TEST_LOCATION);
11401
11402   END_TEST;
11403 }
11404
11405 int UtcDaliActorDoesWantedHitTest(void)
11406 {
11407   struct HitTestData
11408   {
11409   public:
11410     HitTestData(const Vector3& scale, const Vector2& touchPoint, bool result)
11411     : mScale(scale),
11412       mTouchPoint(touchPoint),
11413       mResult(result)
11414     {
11415     }
11416
11417     Vector3 mScale;
11418     Vector2 mTouchPoint;
11419     bool    mResult;
11420   };
11421
11422   TestApplication application;
11423   tet_infoline(" UtcDaliActorDoesWantedHitTest");
11424
11425   // Fill a vector with different hit tests.
11426   struct HitTestData* hitTestData[] = {
11427     //                    scale                     touch point           result
11428     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(289.f, 400.f), true),  // touch point close to the right edge (inside)
11429     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(291.f, 400.f), false), // touch point close to the right edge (outside)
11430     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.
11431     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(200.f, 451.f), false), // touch point close to the down edge (outside)
11432     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.
11433     NULL,
11434   };
11435
11436   // get the root layer
11437   Actor actor = Actor::New();
11438   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
11439   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
11440
11441   Actor lowerActor = Actor::New();
11442   lowerActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
11443   lowerActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
11444
11445   // actor and lowerActor have no relationship.
11446   application.GetScene().Add(lowerActor);
11447   application.GetScene().Add(actor);
11448
11449   ResetTouchCallbacks();
11450   gHitTestTouchCallBackCalled = false;
11451
11452   unsigned int index = 0;
11453   while(NULL != hitTestData[index])
11454   {
11455     actor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f));
11456     actor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z));
11457
11458     lowerActor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f));
11459     lowerActor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z));
11460
11461     // flush the queue and render once
11462     application.SendNotification();
11463     application.Render();
11464
11465     DALI_TEST_CHECK(!gTouchCallBackCalled);
11466     DALI_TEST_CHECK(!gTouchCallBackCalled2);
11467     DALI_TEST_CHECK(!gHitTestTouchCallBackCalled);
11468
11469     // connect to its touch signal
11470     actor.TouchedSignal().Connect(TestTouchCallback);
11471     lowerActor.TouchedSignal().Connect(TestTouchCallback2);
11472
11473     // connect to its hit-test signal
11474     Dali::DevelActor::HitTestResultSignal(actor).Connect(TestHitTestTouchCallback);
11475
11476     Dali::Integration::Point point;
11477     point.SetState(PointState::DOWN);
11478     point.SetScreenPosition(Vector2(hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y));
11479     Dali::Integration::TouchEvent event;
11480     event.AddPoint(point);
11481
11482     // flush the queue and render once
11483     application.SendNotification();
11484     application.Render();
11485     application.ProcessEvent(event);
11486
11487     // check hit-test events
11488     DALI_TEST_CHECK(gHitTestTouchCallBackCalled == hitTestData[index]->mResult);
11489     // Passed all hit-tests of actor.
11490     DALI_TEST_CHECK(gTouchCallBackCalled == false);
11491     // The lowerActor was hit-tested.
11492     DALI_TEST_CHECK(gTouchCallBackCalled2 == hitTestData[index]->mResult);
11493
11494     if(gTouchCallBackCalled2 != hitTestData[index]->mResult)
11495       tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
11496                  hitTestData[index]->mScale.x,
11497                  hitTestData[index]->mScale.y,
11498                  hitTestData[index]->mScale.z,
11499                  hitTestData[index]->mTouchPoint.x,
11500                  hitTestData[index]->mTouchPoint.y,
11501                  hitTestData[index]->mResult);
11502
11503     ResetTouchCallbacks();
11504     gHitTestTouchCallBackCalled = false;
11505     ++index;
11506   }
11507   END_TEST;
11508 }
11509
11510 int UtcDaliActorAllowOnlyOwnTouchPropertyP(void)
11511 {
11512   TestApplication application;
11513
11514   Actor actor = Actor::New();
11515   DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH).Get<bool>(), false, TEST_LOCATION);
11516   actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, true);
11517   DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH).Get<bool>(), true, TEST_LOCATION);
11518   DALI_TEST_EQUALS(actor.GetPropertyType(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), Property::BOOLEAN, TEST_LOCATION);
11519   DALI_TEST_EQUALS(actor.IsPropertyWritable(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), true, TEST_LOCATION);
11520   DALI_TEST_EQUALS(actor.IsPropertyAnimatable(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), false, TEST_LOCATION);
11521   DALI_TEST_EQUALS(actor.IsPropertyAConstraintInput(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), false, TEST_LOCATION);
11522   DALI_TEST_EQUALS(actor.GetPropertyName(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), "allowOnlyOwnTouch", TEST_LOCATION);
11523   END_TEST;
11524 }
11525
11526 int UtcDaliActorAllowOnlyOwnTouchPropertyN(void)
11527 {
11528   TestApplication application;
11529
11530   Actor actor = Actor::New();
11531
11532   // Make sure setting invalid types does not cause a crash
11533   try
11534   {
11535     actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, 1.0f);
11536     actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Vector2::ONE);
11537     actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Vector3::ONE);
11538     actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Vector4::ONE);
11539     actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Property::Map());
11540     actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Property::Array());
11541     tet_result(TET_PASS);
11542   }
11543   catch(...)
11544   {
11545     tet_result(TET_FAIL);
11546   }
11547   END_TEST;
11548 }
11549
11550 int UtcDaliActorCalculateWorldTransform01(void)
11551 {
11552   TestApplication application;
11553
11554   tet_infoline("Test that actor position inheritance produces right transform matrix");
11555
11556   Actor rootActor   = Actor::New();
11557   Actor branchActor = Actor::New();
11558   Actor leafActor   = Actor::New();
11559
11560   rootActor[Actor::Property::POSITION]   = Vector3(0.0f, 0.0f, 0.0f);
11561   branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
11562   leafActor[Actor::Property::POSITION]   = Vector3(100.0f, 50.0f, 30.0f);
11563
11564   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11565   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11566   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11567
11568   // Set anchor point to the same value as parent origin
11569   rootActor[Actor::Property::PARENT_ORIGIN]   = ParentOrigin::TOP_LEFT;
11570   branchActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT;
11571   leafActor[Actor::Property::PARENT_ORIGIN]   = ParentOrigin::TOP_LEFT;
11572
11573   rootActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
11574   branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11575   leafActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
11576
11577   application.GetScene().Add(rootActor);
11578   rootActor.Add(branchActor);
11579   branchActor.Add(leafActor);
11580
11581   application.SendNotification();
11582   application.Render(0);
11583   application.SendNotification();
11584   application.Render(0);
11585
11586   Matrix m = DevelActor::GetWorldTransform(leafActor);
11587
11588   Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11589   DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11590
11591   Vector3    worldPos;
11592   Vector3    worldScale;
11593   Quaternion worldRotation;
11594   m.GetTransformComponents(worldPos, worldRotation, worldScale);
11595   DALI_TEST_EQUALS(worldPos, Vector3(200.0f, 150.0f, 30.0f), 0.0001f, TEST_LOCATION);
11596
11597   END_TEST;
11598 }
11599
11600 int UtcDaliActorCalculateWorldTransform02(void)
11601 {
11602   TestApplication application;
11603
11604   tet_infoline("Test that actor position produces right transform matrix");
11605
11606   Actor rootActor   = Actor::New();
11607   Actor branchActor = Actor::New();
11608   Actor leafActor   = Actor::New();
11609
11610   rootActor[Actor::Property::POSITION]   = Vector3(0.0f, 0.0f, 0.0f);
11611   branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
11612   leafActor[Actor::Property::POSITION]   = Vector3(100.0f, 50.0f, 30.0f);
11613
11614   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11615   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11616   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11617
11618   // Set anchor point to the same value as parent origin
11619   rootActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
11620   branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11621   leafActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
11622
11623   application.GetScene().Add(rootActor);
11624   rootActor.Add(branchActor);
11625   branchActor.Add(leafActor);
11626
11627   leafActor[Actor::Property::INHERIT_POSITION]    = false;
11628   leafActor[Actor::Property::INHERIT_ORIENTATION] = false;
11629   leafActor[Actor::Property::INHERIT_SCALE]       = false;
11630
11631   application.SendNotification();
11632   application.Render(0);
11633   application.SendNotification();
11634   application.Render(0);
11635
11636   Matrix m = DevelActor::GetWorldTransform(leafActor);
11637
11638   Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11639   DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11640
11641   END_TEST;
11642 }
11643
11644 int UtcDaliActorCalculateWorldTransform03(void)
11645 {
11646   TestApplication application;
11647
11648   tet_infoline("Test that actor position produces right transform matrix");
11649
11650   Actor rootActor   = Actor::New();
11651   Actor branchActor = Actor::New();
11652   Actor leafActor   = Actor::New();
11653
11654   rootActor[Actor::Property::POSITION]   = Vector3(0.0f, 0.0f, 0.0f);
11655   branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
11656   leafActor[Actor::Property::POSITION]   = Vector3(100.0f, 50.0f, 30.0f);
11657
11658   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11659   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11660   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11661
11662   // Set anchor point to the same value as parent origin
11663   rootActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
11664   branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11665   leafActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
11666
11667   application.GetScene().Add(rootActor);
11668   rootActor.Add(branchActor);
11669   branchActor.Add(leafActor);
11670
11671   leafActor[Actor::Property::INHERIT_POSITION]    = true;
11672   leafActor[Actor::Property::INHERIT_ORIENTATION] = false;
11673   leafActor[Actor::Property::INHERIT_SCALE]       = false;
11674
11675   application.SendNotification();
11676   application.Render(0);
11677   application.SendNotification();
11678   application.Render(0);
11679
11680   Matrix m = DevelActor::GetWorldTransform(leafActor);
11681
11682   Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11683   DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11684
11685   END_TEST;
11686 }
11687
11688 int UtcDaliActorCalculateWorldTransform04(void)
11689 {
11690   TestApplication application;
11691
11692   tet_infoline("Test that actor inheritance scale/orientation produces right transform matrix");
11693
11694   Actor rootActor   = Actor::New();
11695   Actor branchActor = Actor::New();
11696   Actor leafActor   = Actor::New();
11697
11698   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
11699   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
11700   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11701
11702   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11703   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11704   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11705
11706   // Set anchor point to the same value as parent origin
11707   rootActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::CENTER;
11708   rootActor[Actor::Property::PARENT_ORIGIN]  = ParentOrigin::CENTER;
11709   branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11710   leafActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
11711
11712   branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
11713   leafActor[Actor::Property::POSITION]   = Vector3(100.0f, 50.0f, 30.0f);
11714
11715   application.GetScene().Add(rootActor);
11716   rootActor.Add(branchActor);
11717   branchActor.Add(leafActor);
11718
11719   application.SendNotification();
11720   application.Render(0);
11721   application.SendNotification();
11722   application.Render(0);
11723
11724   Matrix m = DevelActor::GetWorldTransform(leafActor);
11725
11726   Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11727   DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11728
11729   END_TEST;
11730 }
11731
11732 int UtcDaliActorCalculateWorldTransform05(void)
11733 {
11734   TestApplication application;
11735
11736   tet_infoline("Test that actor inheritance of scale produces right transform matrix");
11737
11738   Actor rootActor   = Actor::New();
11739   Actor branchActor = Actor::New();
11740   Actor leafActor   = Actor::New();
11741
11742   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
11743   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
11744   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11745
11746   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11747   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11748   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11749
11750   // Set anchor point to the same value as parent origin
11751   rootActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::CENTER;
11752   rootActor[Actor::Property::PARENT_ORIGIN]  = ParentOrigin::CENTER;
11753   branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11754   leafActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
11755
11756   branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
11757   leafActor[Actor::Property::POSITION]   = Vector3(100.0f, 50.0f, 30.0f);
11758
11759   leafActor[Actor::Property::INHERIT_POSITION]    = false;
11760   leafActor[Actor::Property::INHERIT_ORIENTATION] = false;
11761
11762   application.GetScene().Add(rootActor);
11763   rootActor.Add(branchActor);
11764   branchActor.Add(leafActor);
11765
11766   application.SendNotification();
11767   application.Render(0);
11768   application.SendNotification();
11769   application.Render(0);
11770
11771   Matrix m = DevelActor::GetWorldTransform(leafActor);
11772
11773   Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11774   DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11775
11776   END_TEST;
11777 }
11778
11779 int UtcDaliActorCalculateWorldTransform06(void)
11780 {
11781   TestApplication application;
11782
11783   tet_infoline("Test that actor inheritance of scale produces right transform matrix");
11784
11785   Actor rootActor   = Actor::New();
11786   Actor branchActor = Actor::New();
11787   Actor leafActor   = Actor::New();
11788
11789   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
11790   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
11791   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11792
11793   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11794   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11795   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11796
11797   // Set anchor point to the same value as parent origin
11798   rootActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::CENTER;
11799   rootActor[Actor::Property::PARENT_ORIGIN]  = ParentOrigin::CENTER;
11800   branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11801   leafActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
11802
11803   branchActor[Actor::Property::POSITION]    = Vector3(100.0f, 30.0f, -50.0f);
11804   branchActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(45.0f), Vector3::XAXIS);
11805   leafActor[Actor::Property::POSITION]      = Vector3(100.0f, 50.0f, 30.0f);
11806
11807   leafActor[Actor::Property::INHERIT_POSITION] = false;
11808   leafActor[Actor::Property::INHERIT_SCALE]    = false;
11809
11810   application.GetScene().Add(rootActor);
11811   rootActor.Add(branchActor);
11812   branchActor.Add(leafActor);
11813
11814   application.SendNotification();
11815   application.Render(0);
11816   application.SendNotification();
11817   application.Render(0);
11818
11819   Matrix m = DevelActor::GetWorldTransform(leafActor);
11820
11821   Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11822   DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11823
11824   END_TEST;
11825 }
11826
11827 int UtcDaliActorCalculateWorldTransform07(void)
11828 {
11829   TestApplication application;
11830
11831   tet_infoline("Test that actor inheritance of scale produces right transform matrix");
11832
11833   Actor rootActor   = Actor::New();
11834   Actor branchActor = Actor::New();
11835   Actor leafActor   = Actor::New();
11836
11837   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
11838   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
11839   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11840
11841   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11842   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11843   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11844
11845   // Set anchor point to the same value as parent origin
11846   rootActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::CENTER;
11847   rootActor[Actor::Property::PARENT_ORIGIN]  = ParentOrigin::CENTER;
11848   branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11849
11850   // This should be ignored.
11851   leafActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
11852   leafActor[Actor::Property::ANCHOR_POINT]  = AnchorPoint::CENTER;
11853
11854   branchActor[Actor::Property::POSITION]    = Vector3(100.0f, 30.0f, -50.0f);
11855   branchActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(45.0f), Vector3::XAXIS);
11856   leafActor[Actor::Property::POSITION]      = Vector3(100.0f, 50.0f, 30.0f);
11857
11858   leafActor[Actor::Property::INHERIT_POSITION]           = false;
11859   leafActor[Actor::Property::INHERIT_SCALE]              = false;
11860   leafActor[Actor::Property::POSITION_USES_ANCHOR_POINT] = false;
11861
11862   application.GetScene().Add(rootActor);
11863   rootActor.Add(branchActor);
11864   branchActor.Add(leafActor);
11865
11866   application.SendNotification();
11867   application.Render(0);
11868   application.SendNotification();
11869   application.Render(0);
11870
11871   Matrix m = DevelActor::GetWorldTransform(leafActor);
11872
11873   Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11874   DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11875
11876   END_TEST;
11877 }
11878
11879 int UtcDaliActorCalculateWorldTransform08(void)
11880 {
11881   TestApplication application;
11882
11883   tet_infoline("Test that actor inheritance of scale produces right transform matrix");
11884
11885   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)};
11886
11887   struct TestCase
11888   {
11889     bool translation;
11890     bool rotation;
11891     bool scaling;
11892   };
11893   TestCase testCases[] = {
11894     {false, false, true},
11895     {false, true, false},
11896     {true, false, false},
11897     {false, true, true},
11898     {true, false, true},
11899     {true, true, false},
11900     {false, false, false},
11901     {true, true, true},
11902   };
11903
11904   Actor rootActor = Actor::New();
11905   Actor leafActor = Actor::New();
11906
11907   rootActor[Actor::Property::POSITION]      = Vector3(0.0f, 0.0f, 0.0f);
11908   rootActor[Actor::Property::SCALE]         = Vector3(1.0f, 2.0f, 1.0f);
11909   rootActor[Actor::Property::ORIENTATION]   = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11910   rootActor[Actor::Property::SIZE]          = Vector2(200, 400);
11911   rootActor[Actor::Property::ANCHOR_POINT]  = AnchorPoint::CENTER;
11912   rootActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
11913
11914   leafActor[Actor::Property::POSITION]                   = Vector3(0.0f, -50.0f, 0.0f);
11915   leafActor[Actor::Property::SCALE]                      = Vector3(1.0f, 1.0f, 1.0f);
11916   leafActor[Actor::Property::ORIENTATION]                = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11917   leafActor[Actor::Property::SIZE]                       = Vector2(200, 400);
11918   leafActor[Actor::Property::ANCHOR_POINT]               = AnchorPoint::BOTTOM_CENTER;
11919   leafActor[Actor::Property::PARENT_ORIGIN]              = ParentOrigin::TOP_CENTER;
11920   leafActor[Actor::Property::POSITION_USES_ANCHOR_POINT] = true;
11921
11922   application.GetScene().Add(rootActor);
11923   rootActor.Add(leafActor);
11924
11925   for(uint32_t i = 0; i < 8; ++i)
11926   {
11927     leafActor[Actor::Property::INHERIT_POSITION]    = testCases[i].translation;
11928     leafActor[Actor::Property::INHERIT_ORIENTATION] = testCases[i].rotation;
11929     leafActor[Actor::Property::INHERIT_SCALE]       = testCases[i].scaling;
11930
11931     application.SendNotification();
11932     application.Render(0);
11933     application.SendNotification();
11934     application.Render(0);
11935
11936     Matrix m            = DevelActor::GetWorldTransform(leafActor);
11937     Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11938
11939     Vector3 worldPosition1 = Vector3(m.GetTranslation());
11940     Vector3 worldPosition2 = Vector3(actualMatrix.GetTranslation());
11941
11942     DALI_TEST_EQUALS(solutions[i], worldPosition1, 0.001f, TEST_LOCATION);
11943     DALI_TEST_EQUALS(solutions[i], worldPosition2, 0.001f, TEST_LOCATION);
11944   }
11945
11946   END_TEST;
11947 }
11948
11949 int UtcDaliActorCalculateWorldColor01(void)
11950 {
11951   TestApplication application;
11952
11953   tet_infoline("Test that actor inheritance of color produces right final color");
11954
11955   Actor rootActor   = Actor::New();
11956   Actor branchActor = Actor::New();
11957   Actor leafActor   = Actor::New();
11958
11959   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
11960   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
11961   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11962
11963   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11964   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11965   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11966
11967   rootActor[Actor::Property::COLOR] = Color::WHITE;
11968   Vector4 testColor1(1.0f, 1.0f, 0.5f, 0.8f);
11969   branchActor[Actor::Property::COLOR] = testColor1;
11970   leafActor[Actor::Property::COLOR]   = Vector4(0.1f, 0.5f, 0.5f, 0.8f);
11971
11972   // Default is to inherit:
11973   leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_OWN_MULTIPLY_PARENT_ALPHA;
11974
11975   application.GetScene().Add(rootActor);
11976   rootActor.Add(branchActor);
11977   branchActor.Add(leafActor);
11978
11979   application.SendNotification();
11980   application.Render(16);
11981   Vector4 color = branchActor.GetCurrentProperty<Vector4>(Actor::Property::COLOR);
11982   DALI_TEST_EQUALS(color, testColor1, TEST_LOCATION);
11983
11984   application.SendNotification();
11985   application.Render(16);
11986   color = branchActor.GetCurrentProperty<Vector4>(Actor::Property::COLOR);
11987   DALI_TEST_EQUALS(color, testColor1, TEST_LOCATION);
11988
11989   application.SendNotification();
11990   application.Render(16);
11991   color = branchActor.GetCurrentProperty<Vector4>(Actor::Property::COLOR);
11992   DALI_TEST_EQUALS(color, testColor1, TEST_LOCATION);
11993
11994   color = DevelActor::GetWorldColor(leafActor);
11995
11996   Vector4 actualColor = leafActor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR);
11997   DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION);
11998
11999   END_TEST;
12000 }
12001
12002 int UtcDaliActorCalculateWorldColor02(void)
12003 {
12004   TestApplication application;
12005
12006   tet_infoline("Test that actor uses own color");
12007
12008   Actor rootActor   = Actor::New();
12009   Actor branchActor = Actor::New();
12010   Actor leafActor   = Actor::New();
12011
12012   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
12013   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
12014   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
12015
12016   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12017   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12018   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12019
12020   rootActor[Actor::Property::COLOR]   = Color::WHITE;
12021   branchActor[Actor::Property::COLOR] = Vector4(1.0f, 1.0f, 0.5f, 0.8f);
12022   leafActor[Actor::Property::COLOR]   = Vector4(0.1f, 0.5f, 0.5f, 0.8f);
12023
12024   leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_OWN_COLOR;
12025
12026   application.GetScene().Add(rootActor);
12027   rootActor.Add(branchActor);
12028   branchActor.Add(leafActor);
12029
12030   application.SendNotification();
12031   application.Render(0);
12032
12033   Vector4 color = DevelActor::GetWorldColor(leafActor);
12034
12035   Vector4 actualColor = leafActor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR);
12036   DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION);
12037   DALI_TEST_EQUALS(color, Vector4(0.1f, 0.5f, 0.5f, 0.8f), 0.001f, TEST_LOCATION);
12038   END_TEST;
12039 }
12040
12041 int UtcDaliActorCalculateWorldColor03(void)
12042 {
12043   TestApplication application;
12044
12045   tet_infoline("Test that actor uses parent color");
12046
12047   Actor rootActor   = Actor::New();
12048   Actor branchActor = Actor::New();
12049   Actor leafActor   = Actor::New();
12050
12051   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
12052   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
12053   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
12054
12055   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12056   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12057   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12058
12059   rootActor[Actor::Property::COLOR]   = Color::WHITE * 0.9f;
12060   branchActor[Actor::Property::COLOR] = Vector4(1.0f, 1.0f, 0.5f, 0.8f);
12061   leafActor[Actor::Property::COLOR]   = Vector4(0.1f, 0.5f, 0.5f, 0.8f);
12062
12063   leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_PARENT_COLOR;
12064
12065   application.GetScene().Add(rootActor);
12066   rootActor.Add(branchActor);
12067   branchActor.Add(leafActor);
12068
12069   application.SendNotification();
12070   application.Render(0);
12071
12072   Vector4 color = DevelActor::GetWorldColor(leafActor);
12073
12074   Vector4 actualColor = leafActor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR);
12075   DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION);
12076   DALI_TEST_EQUALS(color, Vector4(1.0f, 1.0f, 0.5f, 0.72f), 0.001f, TEST_LOCATION);
12077   END_TEST;
12078 }
12079
12080 int UtcDaliActorCalculateWorldColor04(void)
12081 {
12082   TestApplication application;
12083
12084   tet_infoline("Test that actor blends with parent color");
12085
12086   Actor rootActor   = Actor::New();
12087   Actor branchActor = Actor::New();
12088   Actor leafActor   = Actor::New();
12089
12090   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
12091   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
12092   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
12093
12094   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12095   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12096   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12097
12098   rootActor[Actor::Property::COLOR]   = Color::WHITE * 0.9f;
12099   branchActor[Actor::Property::COLOR] = Vector4(1.0f, 1.0f, 0.5f, 0.8f);
12100   leafActor[Actor::Property::COLOR]   = Vector4(0.1f, 0.5f, 0.5f, 0.8f);
12101
12102   leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_OWN_MULTIPLY_PARENT_COLOR;
12103
12104   application.GetScene().Add(rootActor);
12105   rootActor.Add(branchActor);
12106   branchActor.Add(leafActor);
12107
12108   application.SendNotification();
12109   application.Render(0);
12110
12111   Vector4 color = DevelActor::GetWorldColor(leafActor);
12112
12113   Vector4 actualColor = leafActor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR);
12114   DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION);
12115
12116   END_TEST;
12117 }