44131153cc914d2ffff9504c90a40941ab7f1f7c
[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 utcDaliActorRelayoutAndAnimation(void)
8582 {
8583   TestApplication application;
8584   tet_infoline("Check the actor size when relayoutting and playing animation");
8585
8586   Vector3 parentSize(300.0f, 300.0f, 0.0f);
8587   Vector3 actorSize(100.0f, 100.0f, 0.0f);
8588
8589   {
8590     Actor parentA = Actor::New();
8591     parentA.SetProperty(Actor::Property::SIZE, parentSize);
8592     parentA.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8593     application.GetScene().Add(parentA);
8594
8595     Actor parentB = Actor::New();
8596     parentB.SetProperty(Actor::Property::SIZE, parentSize);
8597     parentB.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8598     application.GetScene().Add(parentB);
8599
8600     Actor actor = Actor::New();
8601     actor.SetProperty(Actor::Property::SIZE, actorSize);
8602     actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8603     parentA.Add(actor);
8604
8605     Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8606     DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8607
8608     Vector3 targetValue(200.0f, 200.0f, 0.0f);
8609
8610     Animation animation = Animation::New(1.0f);
8611     animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
8612     animation.Play();
8613
8614     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8615     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8616
8617     application.SendNotification();
8618     application.Render(1100); // After the animation
8619
8620     // Size and current size should be updated.
8621     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8622     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8623
8624     Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8625     DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8626
8627     // Trigger relayout
8628     parentB.Add(actor);
8629
8630     application.SendNotification();
8631     application.Render();
8632
8633     // Size and current size should be same.
8634     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8635     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8636
8637     currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8638     DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8639
8640     actor.Unparent();
8641     parentA.Unparent();
8642     parentB.Unparent();
8643   }
8644
8645   {
8646     Actor parentA = Actor::New();
8647     parentA.SetProperty(Actor::Property::SIZE, parentSize);
8648     parentA.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8649     application.GetScene().Add(parentA);
8650
8651     Actor parentB = Actor::New();
8652     parentB.SetProperty(Actor::Property::SIZE, parentSize);
8653     parentB.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8654     application.GetScene().Add(parentB);
8655
8656     Actor actor = Actor::New();
8657     actor.SetProperty(Actor::Property::SIZE, actorSize);
8658     actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8659     parentA.Add(actor);
8660
8661     Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8662     DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8663
8664     application.SendNotification();
8665     application.Render();
8666
8667     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8668     DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8669
8670     Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8671     DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8672
8673     Vector3 targetValue(200.0f, 200.0f, 0.0f);
8674
8675     // Make an animation
8676     Animation animation = Animation::New(1.0f);
8677     animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
8678     animation.Play();
8679
8680     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8681     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8682
8683     application.SendNotification();
8684     application.Render(1100); // After the animation
8685
8686     // Size and current size should be updated.
8687     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8688     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8689
8690     currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8691     DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8692
8693     // Trigger relayout
8694     parentB.Add(actor);
8695
8696     application.SendNotification();
8697     application.Render();
8698
8699     // Size and current size should be same.
8700     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8701     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8702
8703     currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8704     DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8705
8706     actor.Unparent();
8707     parentA.Unparent();
8708     parentB.Unparent();
8709   }
8710
8711   END_TEST;
8712 }
8713
8714 int utcDaliActorPartialUpdate(void)
8715 {
8716   TestApplication application(
8717     TestApplication::DEFAULT_SURFACE_WIDTH,
8718     TestApplication::DEFAULT_SURFACE_HEIGHT,
8719     TestApplication::DEFAULT_HORIZONTAL_DPI,
8720     TestApplication::DEFAULT_VERTICAL_DPI,
8721     true,
8722     true);
8723
8724   tet_infoline("Check the damaged area");
8725
8726   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8727
8728   std::vector<Rect<int>> damagedRects;
8729   Rect<int>              clippingRect;
8730   application.SendNotification();
8731   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8732
8733   // First render pass, nothing to render, adaptor would just do swap buffer.
8734   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8735
8736   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8737   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8738
8739   Actor actor = CreateRenderableActor();
8740   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8741   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8742   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8743   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8744   application.GetScene().Add(actor);
8745
8746   application.SendNotification();
8747
8748   // 1. Actor added, damaged rect is added size of actor
8749   damagedRects.clear();
8750   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8751   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8752
8753   // Aligned by 16
8754   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
8755   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
8756   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8757   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8758   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8759   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8760   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8761
8762   // 2. Set new size
8763   actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0));
8764   application.SendNotification();
8765
8766   damagedRects.clear();
8767   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8768   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8769
8770   // Aligned by 16
8771   clippingRect = Rect<int>(16, 752, 48, 48); // in screen coordinates
8772   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
8773   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8774   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8775   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8776   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8777   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8778
8779   // 3. Set new position
8780   actor.SetProperty(Actor::Property::POSITION, Vector3(32.0f, 32.0f, 0));
8781   application.SendNotification();
8782
8783   damagedRects.clear();
8784   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8785   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8786
8787   // Aligned by 16
8788   clippingRect = Rect<int>(16, 736, 64, 64); // in screen coordinates
8789   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
8790   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8791   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8792   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8793   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8794   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8795
8796   application.GetScene().Remove(actor);
8797   application.SendNotification();
8798
8799   // Actor removed, last a dirty rect is reported.
8800   damagedRects.clear();
8801   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8802   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8803
8804   clippingRect = damagedRects[0];
8805
8806   DALI_TEST_EQUALS(clippingRect.IsValid(), true, TEST_LOCATION);
8807   DALI_TEST_EQUALS<Rect<int>>(clippingRect, Rect<int>(32, 736, 48, 48), TEST_LOCATION);
8808
8809   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8810   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8811   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8812   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8813   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8814
8815   END_TEST;
8816 }
8817
8818 int utcDaliActorPartialUpdateSetColor(void)
8819 {
8820   TestApplication application(
8821     TestApplication::DEFAULT_SURFACE_WIDTH,
8822     TestApplication::DEFAULT_SURFACE_HEIGHT,
8823     TestApplication::DEFAULT_HORIZONTAL_DPI,
8824     TestApplication::DEFAULT_VERTICAL_DPI,
8825     true,
8826     true);
8827
8828   tet_infoline("Check uniform update");
8829
8830   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8831
8832   std::vector<Rect<int>> damagedRects;
8833   Rect<int>              clippingRect;
8834   application.SendNotification();
8835   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8836
8837   // First render pass, nothing to render, adaptor would just do swap buffer.
8838   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8839
8840   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8841   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8842
8843   Actor actor = CreateRenderableActor();
8844   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8845   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8846   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8847   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8848   application.GetScene().Add(actor);
8849
8850   application.SendNotification();
8851
8852   // 1. Actor added, damaged rect is added size of actor
8853   damagedRects.clear();
8854   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8855   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8856
8857   // Aligned by 16
8858   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
8859   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
8860   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8861   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8862   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8863   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8864   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8865
8866   damagedRects.clear();
8867   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8868   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8869
8870   damagedRects.clear();
8871   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8872   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8873
8874   // 2. Set new color
8875   actor.SetProperty(Actor::Property::COLOR, Vector3(1.0f, 0.0f, 0.0f));
8876   application.SendNotification();
8877
8878   damagedRects.clear();
8879   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8880   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8881
8882   // Aligned by 16
8883   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
8884   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
8885   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8886   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8887   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8888   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8889   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8890
8891   END_TEST;
8892 }
8893
8894 const std::string SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME("uLightCameraProjectionMatrix");
8895 const std::string SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME("uLightCameraViewMatrix");
8896 const std::string SHADER_SHADOW_COLOR_PROPERTY_NAME("uShadowColor");
8897 const char* const RENDER_SHADOW_VERTEX_SOURCE =
8898   " uniform mediump mat4 uLightCameraProjectionMatrix;\n"
8899   " uniform mediump mat4 uLightCameraViewMatrix;\n"
8900   "\n"
8901   "void main()\n"
8902   "{\n"
8903   "  gl_Position = uProjection * uModelView * vec4(aPosition,1.0);\n"
8904   "  vec4 textureCoords = uLightCameraProjectionMatrix * uLightCameraViewMatrix * uModelMatrix  * vec4(aPosition,1.0);\n"
8905   "  vTexCoord = 0.5 + 0.5 * (textureCoords.xy/textureCoords.w);\n"
8906   "}\n";
8907
8908 const char* const RENDER_SHADOW_FRAGMENT_SOURCE =
8909   "uniform lowp vec4 uShadowColor;\n"
8910   "void main()\n"
8911   "{\n"
8912   "  lowp float alpha;\n"
8913   "  alpha = texture2D(sTexture, vec2(vTexCoord.x, vTexCoord.y)).a;\n"
8914   "  gl_FragColor = vec4(uShadowColor.rgb, uShadowColor.a * alpha);\n"
8915   "}\n";
8916
8917 int utcDaliActorPartialUpdateSetProperty(void)
8918 {
8919   TestApplication application(
8920     TestApplication::DEFAULT_SURFACE_WIDTH,
8921     TestApplication::DEFAULT_SURFACE_HEIGHT,
8922     TestApplication::DEFAULT_HORIZONTAL_DPI,
8923     TestApplication::DEFAULT_VERTICAL_DPI,
8924     true,
8925     true);
8926
8927   tet_infoline("Set/Update property with partial update");
8928
8929   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8930
8931   std::vector<Rect<int>> damagedRects;
8932   Rect<int>              clippingRect;
8933   application.SendNotification();
8934   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8935
8936   // First render pass, nothing to render, adaptor would just do swap buffer.
8937   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8938
8939   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8940   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8941
8942   Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 4u, 4u);
8943   Actor   actor = CreateRenderableActor(image, RENDER_SHADOW_VERTEX_SOURCE, RENDER_SHADOW_FRAGMENT_SOURCE);
8944   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8945   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8946   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8947   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8948   application.GetScene().Add(actor);
8949
8950   actor.RegisterProperty(SHADER_SHADOW_COLOR_PROPERTY_NAME, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
8951
8952   damagedRects.clear();
8953   application.SendNotification();
8954   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8955   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8956
8957   // Aligned by 16
8958   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
8959   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
8960   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8961   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8962   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8963   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8964   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8965
8966   Property::Index shadowColorPropertyIndex = actor.GetPropertyIndex(SHADER_SHADOW_COLOR_PROPERTY_NAME);
8967   actor.SetProperty(shadowColorPropertyIndex, Vector4(1.0f, 1.0f, 0.0f, 1.0f));
8968
8969   damagedRects.clear();
8970   application.SendNotification();
8971   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8972   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8973
8974   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
8975   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8976   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8977   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8978   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8979   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8980
8981   // Should be no damage rects, nothing changed
8982   damagedRects.clear();
8983   application.SendNotification();
8984   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8985   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8986
8987   // Should be 1 damage rect due to change in size
8988   damagedRects.clear();
8989   actor.SetProperty(Actor::Property::SIZE, Vector3(26.0f, 26.0f, 0.0f));
8990   application.SendNotification();
8991   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8992   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8993
8994   clippingRect = Rect<int>(16, 752, 32, 48); // new clipping rect size increased due to change in actor size
8995   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
8996   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8997   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8998   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8999   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9000   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9001
9002   damagedRects.clear();
9003   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9004   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9005
9006   END_TEST;
9007 }
9008
9009 int utcDaliActorPartialUpdateTwoActors(void)
9010 {
9011   TestApplication application(
9012     TestApplication::DEFAULT_SURFACE_WIDTH,
9013     TestApplication::DEFAULT_SURFACE_HEIGHT,
9014     TestApplication::DEFAULT_HORIZONTAL_DPI,
9015     TestApplication::DEFAULT_VERTICAL_DPI,
9016     true,
9017     true);
9018
9019   tet_infoline("Check the damaged rects with partial update and two actors");
9020
9021   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9022
9023   Actor actor = CreateRenderableActor();
9024   actor.SetProperty(Actor::Property::POSITION, Vector3(100.0f, 100.0f, 0.0f));
9025   actor.SetProperty(Actor::Property::SIZE, Vector3(50.0f, 50.0f, 0.0f));
9026   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9027   application.GetScene().Add(actor);
9028
9029   Actor actor2 = CreateRenderableActor();
9030   actor2.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
9031   actor2.SetProperty(Actor::Property::SIZE, Vector3(100.0f, 100.0f, 0.0f));
9032   actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9033   application.GetScene().Add(actor2);
9034
9035   application.SendNotification();
9036   std::vector<Rect<int>> damagedRects;
9037   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9038
9039   DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
9040   DirtyRectChecker(damagedRects, {Rect<int>(64, 672, 64, 64), Rect<int>(96, 592, 112, 112)}, true, TEST_LOCATION);
9041
9042   // in screen coordinates, adaptor would calculate it using previous frames information
9043   Rect<int> clippingRect = Rect<int>(64, 592, 144, 192);
9044   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9045
9046   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9047   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9048   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9049   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9050
9051   // Change a Renderer of actor1
9052   Geometry geometry    = CreateQuadGeometry();
9053   Shader   shader      = CreateShader();
9054   Renderer newRenderer = Renderer::New(geometry, shader);
9055   Renderer renderer    = actor.GetRendererAt(0);
9056
9057   actor.RemoveRenderer(renderer);
9058   actor.AddRenderer(newRenderer);
9059
9060   damagedRects.clear();
9061
9062   application.SendNotification();
9063   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9064
9065   DALI_TEST_CHECK(damagedRects.size() > 0);
9066   DirtyRectChecker(damagedRects, {Rect<int>(64, 672, 64, 64)}, false, TEST_LOCATION);
9067
9068   // in screen coordinates, adaptor would calculate it using previous frames information
9069   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9070
9071   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9072   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9073   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9074   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9075
9076   END_TEST;
9077 }
9078
9079 int utcDaliActorPartialUpdateActorsWithSizeHint01(void)
9080 {
9081   TestApplication application(
9082     TestApplication::DEFAULT_SURFACE_WIDTH,
9083     TestApplication::DEFAULT_SURFACE_HEIGHT,
9084     TestApplication::DEFAULT_HORIZONTAL_DPI,
9085     TestApplication::DEFAULT_VERTICAL_DPI,
9086     true,
9087     true);
9088
9089   tet_infoline("Check the damaged rect with partial update and update area hint");
9090
9091   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9092
9093   Actor actor = CreateRenderableActor();
9094   actor.SetProperty(Actor::Property::POSITION, Vector3(64.0f, 64.0f, 0.0f));
9095   actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0.0f));
9096   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(0.0f, 0.0f, 64.0f, 64.0f));
9097   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9098   application.GetScene().Add(actor);
9099
9100   application.SendNotification();
9101   std::vector<Rect<int>> damagedRects;
9102   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9103
9104   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9105
9106   Rect<int> clippingRect = Rect<int>(32, 704, 80, 80);
9107   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9108
9109   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9110
9111   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9112   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9113   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9114   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9115
9116   // Reset
9117   actor.Unparent();
9118
9119   damagedRects.clear();
9120   application.SendNotification();
9121   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9122
9123   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9124   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9125
9126   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9127
9128   damagedRects.clear();
9129   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9130   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9131
9132   // Ensure the damaged rect is empty
9133   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9134
9135   // Chnage UPDATE_AREA_HINT
9136   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(16.0f, 16.0f, 32.0f, 32.0f));
9137   application.GetScene().Add(actor);
9138
9139   application.SendNotification();
9140   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9141
9142   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9143
9144   clippingRect = Rect<int>(64, 704, 48, 48);
9145   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9146
9147   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9148
9149   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9150   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9151   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9152   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9153
9154   // Reset
9155   actor.Unparent();
9156
9157   damagedRects.clear();
9158   application.SendNotification();
9159   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9160
9161   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9162   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9163
9164   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9165
9166   damagedRects.clear();
9167   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9168   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9169
9170   // Ensure the damaged rect is empty
9171   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9172
9173   // Chnage UPDATE_AREA_HINT
9174   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(-32.0f, -16.0f, 64.0f, 64.0f));
9175   application.GetScene().Add(actor);
9176
9177   application.SendNotification();
9178   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9179
9180   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9181
9182   clippingRect = Rect<int>(0, 720, 80, 80);
9183   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9184
9185   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9186
9187   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9188   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9189   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9190   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9191
9192   END_TEST;
9193 }
9194
9195 int utcDaliActorPartialUpdateActorsWithSizeHint02(void)
9196 {
9197   TestApplication application(
9198     TestApplication::DEFAULT_SURFACE_WIDTH,
9199     TestApplication::DEFAULT_SURFACE_HEIGHT,
9200     TestApplication::DEFAULT_HORIZONTAL_DPI,
9201     TestApplication::DEFAULT_VERTICAL_DPI,
9202     true,
9203     true);
9204
9205   tet_infoline("Check the damaged rect with partial update and update area hint");
9206
9207   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9208
9209   Actor actor = CreateRenderableActor();
9210   actor.SetProperty(Actor::Property::POSITION, Vector3(64.0f, 64.0f, 0.0f));
9211   actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0.0f));
9212   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9213   application.GetScene().Add(actor);
9214
9215   application.SendNotification();
9216   std::vector<Rect<int>> damagedRects;
9217   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9218
9219   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9220
9221   Rect<int> clippingRect = Rect<int>(48, 720, 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   damagedRects.clear();
9232   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9233   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9234
9235   // Ensure the damaged rect is empty
9236   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9237
9238   // Change UPDATE_AREA_HINT
9239   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(0.0f, 0.0f, 64.0f, 64.0f));
9240
9241   application.SendNotification();
9242   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9243
9244   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9245
9246   clippingRect = Rect<int>(32, 704, 80, 80);
9247   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9248
9249   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9250
9251   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9252   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9253   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9254   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9255
9256   damagedRects.clear();
9257   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9258   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9259
9260   // Ensure the damaged rect is empty
9261   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9262
9263   // Chnage UPDATE_AREA_HINT
9264   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(16.0f, 16.0f, 64.0f, 64.0f));
9265   application.GetScene().Add(actor);
9266
9267   application.SendNotification();
9268   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9269
9270   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9271
9272   clippingRect = Rect<int>(32, 688, 96, 96);
9273   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9274
9275   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9276
9277   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9278   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9279   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9280   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9281
9282   END_TEST;
9283 }
9284
9285 int utcDaliActorPartialUpdateActorsWithSizeHint03(void)
9286 {
9287   TestApplication application(
9288     TestApplication::DEFAULT_SURFACE_WIDTH,
9289     TestApplication::DEFAULT_SURFACE_HEIGHT,
9290     TestApplication::DEFAULT_HORIZONTAL_DPI,
9291     TestApplication::DEFAULT_VERTICAL_DPI,
9292     true,
9293     true);
9294
9295   tet_infoline("Check the damaged rect with partial update and update area hint");
9296
9297   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9298
9299   Actor actor = CreateRenderableActor();
9300   actor.SetProperty(Actor::Property::POSITION, Vector3(64.0f, 64.0f, 0.0f));
9301   actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0.0f));
9302   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(0.0f, 0.0f, 64.0f, 64.0f));
9303   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9304   application.GetScene().Add(actor);
9305
9306   application.SendNotification();
9307   std::vector<Rect<int>> damagedRects;
9308   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9309
9310   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9311
9312   Rect<int> clippingRect = Rect<int>(32, 704, 80, 80);
9313   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9314
9315   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9316
9317   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9318   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9319   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9320   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9321
9322   damagedRects.clear();
9323   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9324   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9325
9326   // Ensure the damaged rect is empty
9327   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9328
9329   // Set UPDATE_AREA_HINT twice before rendering
9330   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(0.0f, 0.0f, 32.0f, 32.0f));
9331   application.SendNotification();
9332
9333   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(32.0f, -32.0f, 32.0f, 32.0f));
9334   application.SendNotification();
9335
9336   damagedRects.clear();
9337   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9338
9339   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9340
9341   clippingRect = Rect<int>(32, 704, 96, 96);
9342   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9343
9344   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9345
9346   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9347   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9348   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9349   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9350
9351   END_TEST;
9352 }
9353
9354 int utcDaliActorPartialUpdateAnimation(void)
9355 {
9356   TestApplication application(
9357     TestApplication::DEFAULT_SURFACE_WIDTH,
9358     TestApplication::DEFAULT_SURFACE_HEIGHT,
9359     TestApplication::DEFAULT_HORIZONTAL_DPI,
9360     TestApplication::DEFAULT_VERTICAL_DPI,
9361     true,
9362     true);
9363
9364   tet_infoline("Check the damaged area with partial update and animation");
9365
9366   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
9367   drawTrace.Enable(true);
9368   drawTrace.Reset();
9369
9370   Actor actor1 = CreateRenderableActor();
9371   actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9372   actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
9373   application.GetScene().Add(actor1);
9374
9375   Actor actor2 = CreateRenderableActor();
9376   actor2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9377   actor2.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
9378   application.GetScene().Add(actor2);
9379
9380   std::vector<Rect<int>> damagedRects;
9381   Rect<int>              clippingRect;
9382   Rect<int>              expectedRect1, expectedRect2;
9383
9384   application.SendNotification();
9385   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9386
9387   DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
9388
9389   // Aligned by 16
9390   expectedRect1 = Rect<int>(0, 720, 96, 96); // in screen coordinates, includes 1 last frames updates
9391   expectedRect2 = Rect<int>(0, 784, 32, 32); // in screen coordinates, includes 1 last frames updates
9392   DirtyRectChecker(damagedRects, {expectedRect1, expectedRect2}, true, TEST_LOCATION);
9393
9394   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9395   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9396
9397   // Make an animation
9398   Animation animation = Animation::New(1.0f);
9399   animation.AnimateTo(Property(actor2, Actor::Property::POSITION_X), 160.0f, TimePeriod(0.5f, 0.5f));
9400   animation.Play();
9401
9402   application.SendNotification();
9403
9404   damagedRects.clear();
9405   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9406   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9407   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9408
9409   drawTrace.Reset();
9410   damagedRects.clear();
9411
9412   // In animation deley time
9413   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9414   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9415   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9416
9417   // Skip rendering
9418   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
9419
9420   drawTrace.Reset();
9421   damagedRects.clear();
9422
9423   // Also in animation deley time
9424   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9425   application.PreRenderWithPartialUpdate(100, nullptr, damagedRects);
9426   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9427
9428   // Skip rendering
9429   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
9430
9431   // Unparent 2 actors and make a new actor
9432   actor1.Unparent();
9433   actor2.Unparent();
9434
9435   Actor actor3 = CreateRenderableActor();
9436   actor3.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9437   actor3.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
9438   application.GetScene().Add(actor3);
9439
9440   application.SendNotification();
9441
9442   // Started animation
9443   damagedRects.clear();
9444   application.PreRenderWithPartialUpdate(500, nullptr, damagedRects);
9445   DALI_TEST_EQUALS(damagedRects.size(), 3, TEST_LOCATION);
9446
9447   // One of dirty rect is actor3's.
9448   // We don't know the exact dirty rect of actor1 and actor2.
9449   DirtyRectChecker(damagedRects, {expectedRect1, expectedRect2, expectedRect2}, true, TEST_LOCATION);
9450
9451   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9452   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9453
9454   // Finished animation, but the actor was already unparented
9455   damagedRects.clear();
9456   application.PreRenderWithPartialUpdate(500, nullptr, damagedRects);
9457
9458   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9459
9460   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9461   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9462
9463   END_TEST;
9464 }
9465
9466 int utcDaliActorPartialUpdateChangeVisibility(void)
9467 {
9468   TestApplication application(
9469     TestApplication::DEFAULT_SURFACE_WIDTH,
9470     TestApplication::DEFAULT_SURFACE_HEIGHT,
9471     TestApplication::DEFAULT_HORIZONTAL_DPI,
9472     TestApplication::DEFAULT_VERTICAL_DPI,
9473     true,
9474     true);
9475
9476   tet_infoline("Check the damaged rect with partial update and visibility change");
9477
9478   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9479
9480   Actor actor = CreateRenderableActor();
9481   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9482   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
9483   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
9484   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9485   application.GetScene().Add(actor);
9486
9487   application.SendNotification();
9488
9489   std::vector<Rect<int>> damagedRects;
9490   Rect<int>              clippingRect;
9491
9492   // 1. Actor added, damaged rect is added size of actor
9493   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9494   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9495
9496   // Aligned by 16
9497   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
9498   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9499   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9500   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9501   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9502   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9503   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9504
9505   damagedRects.clear();
9506   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9507   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9508
9509   // Ensure the damaged rect is empty
9510   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9511
9512   // 2. Make the Actor invisible
9513   actor.SetProperty(Actor::Property::VISIBLE, false);
9514   application.SendNotification();
9515
9516   damagedRects.clear();
9517   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9518   DALI_TEST_CHECK(damagedRects.size() > 0);
9519   DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
9520
9521   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9522   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9523   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9524   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9525   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9526
9527   // 3. Make the Actor visible again
9528   actor.SetProperty(Actor::Property::VISIBLE, true);
9529   application.SendNotification();
9530
9531   damagedRects.clear();
9532   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9533   DALI_TEST_CHECK(damagedRects.size() > 0);
9534   DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
9535
9536   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9537   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9538   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9539   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9540   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9541
9542   END_TEST;
9543 }
9544
9545 int utcDaliActorPartialUpdateOnOffScene(void)
9546 {
9547   TestApplication application(
9548     TestApplication::DEFAULT_SURFACE_WIDTH,
9549     TestApplication::DEFAULT_SURFACE_HEIGHT,
9550     TestApplication::DEFAULT_HORIZONTAL_DPI,
9551     TestApplication::DEFAULT_VERTICAL_DPI,
9552     true,
9553     true);
9554
9555   tet_infoline("Check the damaged rect with partial update and on/off scene");
9556
9557   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9558
9559   Actor actor = CreateRenderableActor();
9560   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9561   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
9562   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
9563   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9564   application.GetScene().Add(actor);
9565
9566   application.SendNotification();
9567
9568   std::vector<Rect<int>> damagedRects;
9569   Rect<int>              clippingRect;
9570
9571   // 1. Actor added, damaged rect is added size of actor
9572   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9573   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9574
9575   // Aligned by 16
9576   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
9577   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9578   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9579   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9580   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9581   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9582   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9583
9584   damagedRects.clear();
9585   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9586   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9587
9588   damagedRects.clear();
9589   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9590   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9591
9592   // Ensure the damaged rect is empty
9593   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9594
9595   // 2. Remove the Actor from the Scene
9596   actor.Unparent();
9597   application.SendNotification();
9598
9599   damagedRects.clear();
9600   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9601   DALI_TEST_CHECK(damagedRects.size() > 0);
9602   DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
9603
9604   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9605   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9606   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9607   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9608   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9609
9610   // 3. Add the Actor to the Scene again
9611   application.GetScene().Add(actor);
9612   application.SendNotification();
9613
9614   damagedRects.clear();
9615   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9616   DALI_TEST_CHECK(damagedRects.size() > 0);
9617   DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
9618
9619   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9620   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9621   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9622   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9623   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9624
9625   END_TEST;
9626 }
9627
9628 int utcDaliActorPartialUpdateSkipRendering(void)
9629 {
9630   TestApplication application(
9631     TestApplication::DEFAULT_SURFACE_WIDTH,
9632     TestApplication::DEFAULT_SURFACE_HEIGHT,
9633     TestApplication::DEFAULT_HORIZONTAL_DPI,
9634     TestApplication::DEFAULT_VERTICAL_DPI,
9635     true,
9636     true);
9637
9638   tet_infoline("Check to skip rendering in case of the empty damaged rect");
9639
9640   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
9641   drawTrace.Enable(true);
9642   drawTrace.Reset();
9643
9644   Actor actor1 = CreateRenderableActor();
9645   actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9646   actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
9647   application.GetScene().Add(actor1);
9648
9649   std::vector<Rect<int>> damagedRects;
9650   Rect<int>              clippingRect;
9651   Rect<int>              expectedRect1;
9652
9653   application.SendNotification();
9654   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9655
9656   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9657
9658   // Aligned by 16
9659   expectedRect1 = Rect<int>(0, 720, 96, 96); // in screen coordinates
9660   DirtyRectChecker(damagedRects, {expectedRect1}, true, TEST_LOCATION);
9661
9662   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9663   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9664
9665   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9666
9667   damagedRects.clear();
9668   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9669   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9670   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9671
9672   // Remove the actor
9673   actor1.Unparent();
9674
9675   application.SendNotification();
9676
9677   damagedRects.clear();
9678   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9679
9680   DirtyRectChecker(damagedRects, {expectedRect1}, true, TEST_LOCATION);
9681
9682   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9683   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9684
9685   // Render again without any change
9686   damagedRects.clear();
9687   drawTrace.Reset();
9688   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9689
9690   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9691
9692   clippingRect = Rect<int>();
9693   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9694
9695   // Skip rendering
9696   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
9697
9698   // Add the actor again
9699   application.GetScene().Add(actor1);
9700
9701   application.SendNotification();
9702
9703   damagedRects.clear();
9704   drawTrace.Reset();
9705   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9706
9707   DirtyRectChecker(damagedRects, {expectedRect1}, true, TEST_LOCATION);
9708
9709   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9710   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9711
9712   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9713
9714   END_TEST;
9715 }
9716
9717 int utcDaliActorPartialUpdate3DNode(void)
9718 {
9719   TestApplication application(
9720     TestApplication::DEFAULT_SURFACE_WIDTH,
9721     TestApplication::DEFAULT_SURFACE_HEIGHT,
9722     TestApplication::DEFAULT_HORIZONTAL_DPI,
9723     TestApplication::DEFAULT_VERTICAL_DPI,
9724     true,
9725     true);
9726
9727   tet_infoline("Partial update should be ignored in case of 3d layer of 3d node");
9728
9729   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
9730   drawTrace.Enable(true);
9731   drawTrace.Reset();
9732
9733   Actor actor1 = CreateRenderableActor();
9734   actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9735   actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
9736   application.GetScene().Add(actor1);
9737
9738   std::vector<Rect<int>> damagedRects;
9739   Rect<int>              clippingRect;
9740
9741   application.SendNotification();
9742   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9743
9744   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9745
9746   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9747   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9748
9749   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9750
9751   // Change the layer to 3D
9752   application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D);
9753
9754   application.SendNotification();
9755
9756   damagedRects.clear();
9757   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9758
9759   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9760   DirtyRectChecker(damagedRects, {TestApplication::DEFAULT_SURFACE_RECT}, true, TEST_LOCATION);
9761
9762   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9763   drawTrace.Reset();
9764   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9765
9766   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9767
9768   // Change the layer to 2D
9769   application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_UI);
9770
9771   application.SendNotification();
9772
9773   damagedRects.clear();
9774   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9775
9776   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9777
9778   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9779   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9780
9781   // Make 3D transform
9782   actor1.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::YAXIS));
9783
9784   application.SendNotification();
9785
9786   damagedRects.clear();
9787   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9788
9789   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9790   DirtyRectChecker(damagedRects, {TestApplication::DEFAULT_SURFACE_RECT}, true, TEST_LOCATION);
9791
9792   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9793   drawTrace.Reset();
9794   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9795
9796   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9797
9798   END_TEST;
9799 }
9800
9801 int utcDaliActorPartialUpdateNotRenderableActor(void)
9802 {
9803   TestApplication application(
9804     TestApplication::DEFAULT_SURFACE_WIDTH,
9805     TestApplication::DEFAULT_SURFACE_HEIGHT,
9806     TestApplication::DEFAULT_HORIZONTAL_DPI,
9807     TestApplication::DEFAULT_VERTICAL_DPI,
9808     true,
9809     true);
9810
9811   tet_infoline("Check the damaged rect with not renderable parent actor");
9812
9813   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9814
9815   Actor parent                          = Actor::New();
9816   parent[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9817   parent[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
9818   parent[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
9819   parent.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9820   application.GetScene().Add(parent);
9821
9822   Actor child                          = CreateRenderableActor();
9823   child[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9824   child[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
9825   child.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9826   parent.Add(child);
9827
9828   application.SendNotification();
9829
9830   std::vector<Rect<int>> damagedRects;
9831
9832   // 1. Actor added, damaged rect is added size of actor
9833   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9834   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9835
9836   // Aligned by 16
9837   Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
9838   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9839
9840   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9841   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9842   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9843   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9844   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9845
9846   damagedRects.clear();
9847   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9848   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9849
9850   damagedRects.clear();
9851   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9852   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9853
9854   // Ensure the damaged rect is empty
9855   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9856
9857   END_TEST;
9858 }
9859
9860 int utcDaliActorPartialUpdateChangeTransparency(void)
9861 {
9862   TestApplication application(
9863     TestApplication::DEFAULT_SURFACE_WIDTH,
9864     TestApplication::DEFAULT_SURFACE_HEIGHT,
9865     TestApplication::DEFAULT_HORIZONTAL_DPI,
9866     TestApplication::DEFAULT_VERTICAL_DPI,
9867     true,
9868     true);
9869
9870   tet_infoline("Check the damaged rect with changing transparency");
9871
9872   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9873
9874   Actor actor                          = CreateRenderableActor();
9875   actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9876   actor[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
9877   actor[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
9878   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9879   application.GetScene().Add(actor);
9880
9881   application.SendNotification();
9882
9883   std::vector<Rect<int>> damagedRects;
9884
9885   // Actor added, damaged rect is added size of actor
9886   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9887   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9888
9889   // Aligned by 16
9890   Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
9891   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9892
9893   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9894   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9895   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9896   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9897   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9898
9899   damagedRects.clear();
9900   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9901   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9902
9903   // Ensure the damaged rect is empty
9904   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9905
9906   // Make the actor transparent by changing opacity of the Renderer
9907   // It changes a uniform value
9908   Renderer renderer                          = actor.GetRendererAt(0);
9909   renderer[DevelRenderer::Property::OPACITY] = 0.0f;
9910
9911   application.SendNotification();
9912
9913   // The damaged rect should be same
9914   damagedRects.clear();
9915   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9916   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9917   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9918   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9919
9920   damagedRects.clear();
9921   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9922   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9923
9924   // Ensure the damaged rect is empty
9925   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9926
9927   // Make the actor opaque again
9928   renderer[DevelRenderer::Property::OPACITY] = 1.0f;
9929
9930   application.SendNotification();
9931
9932   // The damaged rect should not be empty
9933   damagedRects.clear();
9934   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9935   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9936   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9937   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9938
9939   damagedRects.clear();
9940   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9941   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9942
9943   // Ensure the damaged rect is empty
9944   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9945
9946   // Make the actor translucent
9947   renderer[DevelRenderer::Property::OPACITY] = 0.5f;
9948
9949   application.SendNotification();
9950
9951   // The damaged rect should not be empty
9952   damagedRects.clear();
9953   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9954   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9955   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9956   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9957
9958   damagedRects.clear();
9959   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9960   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9961
9962   // Ensure the damaged rect is empty
9963   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9964
9965   // Change Renderer opacity - also translucent
9966   renderer[DevelRenderer::Property::OPACITY] = 0.2f;
9967
9968   application.SendNotification();
9969
9970   // The damaged rect should not be empty
9971   damagedRects.clear();
9972   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9973   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9974   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9975   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9976
9977   damagedRects.clear();
9978   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9979   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9980
9981   // Ensure the damaged rect is empty
9982   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9983
9984   // Make the actor culled
9985   actor[Actor::Property::SIZE] = Vector3(0.0f, 0.0f, 0.0f);
9986
9987   application.SendNotification();
9988
9989   // The damaged rect should be same
9990   damagedRects.clear();
9991   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9992   DALI_TEST_CHECK(damagedRects.size() > 0);
9993   DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
9994   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9995
9996   damagedRects.clear();
9997   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9998   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9999
10000   // Ensure the damaged rect is empty
10001   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10002
10003   // Make the actor not culled again
10004   actor[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 16.0f);
10005
10006   application.SendNotification();
10007
10008   // The damaged rect should not be empty
10009   damagedRects.clear();
10010   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10011   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10012   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10013   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10014
10015   END_TEST;
10016 }
10017
10018 int utcDaliActorPartialUpdateChangeParentOpacity(void)
10019 {
10020   TestApplication application(
10021     TestApplication::DEFAULT_SURFACE_WIDTH,
10022     TestApplication::DEFAULT_SURFACE_HEIGHT,
10023     TestApplication::DEFAULT_HORIZONTAL_DPI,
10024     TestApplication::DEFAULT_VERTICAL_DPI,
10025     true,
10026     true);
10027
10028   tet_infoline("Check the damaged rect with changing parent's opacity");
10029
10030   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
10031
10032   Actor parent                          = Actor::New();
10033   parent[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10034   parent[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
10035   parent[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
10036   parent.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10037   application.GetScene().Add(parent);
10038
10039   Texture texture                      = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
10040   Actor   child                        = CreateRenderableActor(texture);
10041   child[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10042   child[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
10043   child.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10044   parent.Add(child);
10045
10046   application.SendNotification();
10047
10048   std::vector<Rect<int>> damagedRects;
10049
10050   // Actor added, damaged rect is added size of actor
10051   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10052   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10053
10054   // Aligned by 16
10055   Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10056   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10057
10058   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10059   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
10060   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
10061   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
10062   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
10063
10064   damagedRects.clear();
10065   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10066   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10067
10068   damagedRects.clear();
10069   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10070   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10071
10072   // Ensure the damaged rect is empty
10073   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10074
10075   // Change the parent's opacity
10076   parent[Actor::Property::OPACITY] = 0.5f;
10077
10078   application.SendNotification();
10079
10080   // The damaged rect should be same
10081   damagedRects.clear();
10082   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10083   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10084   DALI_TEST_CHECK(damagedRects.size() > 0);
10085   DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
10086
10087   END_TEST;
10088 }
10089
10090 int utcDaliActorPartialUpdateAddRemoveRenderer(void)
10091 {
10092   TestApplication application(
10093     TestApplication::DEFAULT_SURFACE_WIDTH,
10094     TestApplication::DEFAULT_SURFACE_HEIGHT,
10095     TestApplication::DEFAULT_HORIZONTAL_DPI,
10096     TestApplication::DEFAULT_VERTICAL_DPI,
10097     true,
10098     true);
10099
10100   tet_infoline("Check the damaged rect with adding / removing renderer");
10101
10102   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
10103
10104   Actor actor                          = CreateRenderableActor();
10105   actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10106   actor[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
10107   actor[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
10108   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10109   application.GetScene().Add(actor);
10110
10111   application.SendNotification();
10112
10113   std::vector<Rect<int>> damagedRects;
10114
10115   // Actor added, damaged rect is added size of actor
10116   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10117   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10118
10119   // Aligned by 16
10120   Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10121   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10122
10123   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10124   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
10125   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
10126   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
10127   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
10128
10129   damagedRects.clear();
10130   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10131   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10132
10133   damagedRects.clear();
10134   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10135   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10136
10137   // Remove the Renderer
10138   Renderer renderer = actor.GetRendererAt(0);
10139   actor.RemoveRenderer(renderer);
10140
10141   application.SendNotification();
10142
10143   // The damaged rect should be the actor area
10144   damagedRects.clear();
10145   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10146   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10147   DALI_TEST_CHECK(damagedRects.size() > 0);
10148   DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
10149
10150   damagedRects.clear();
10151   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10152   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10153
10154   // Ensure the damaged rect is empty
10155   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10156
10157   // Add the Renderer again
10158   actor.AddRenderer(renderer);
10159
10160   application.SendNotification();
10161
10162   // The damaged rect should be the actor area
10163   damagedRects.clear();
10164   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10165   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10166   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10167   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10168
10169   END_TEST;
10170 }
10171
10172 int utcDaliActorPartialUpdate3DTransform(void)
10173 {
10174   TestApplication application(
10175     TestApplication::DEFAULT_SURFACE_WIDTH,
10176     TestApplication::DEFAULT_SURFACE_HEIGHT,
10177     TestApplication::DEFAULT_HORIZONTAL_DPI,
10178     TestApplication::DEFAULT_VERTICAL_DPI,
10179     true,
10180     true);
10181
10182   tet_infoline("Check the damaged rect with 3D transformed actors");
10183
10184   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
10185
10186   Actor actor1                          = CreateRenderableActor();
10187   actor1[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10188   actor1[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
10189   actor1[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
10190   actor1.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10191   application.GetScene().Add(actor1);
10192
10193   // Add a new actor
10194   Actor actor2                          = CreateRenderableActor();
10195   actor2[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10196   actor2[Actor::Property::POSITION]     = Vector3(160.0f, 160.0f, 0.0f);
10197   actor2[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
10198   actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10199   application.GetScene().Add(actor2);
10200
10201   application.SendNotification();
10202
10203   std::vector<Rect<int>> damagedRects;
10204
10205   // Actor added, damaged rect is added size of actor
10206   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10207   DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
10208
10209   // Aligned by 16
10210   Rect<int> clippingRect1 = Rect<int>(16, 768, 32, 32); // in screen coordinates
10211   Rect<int> clippingRect2 = Rect<int>(160, 624, 32, 32);
10212   DirtyRectChecker(damagedRects, {clippingRect1, clippingRect2}, true, TEST_LOCATION);
10213
10214   Rect<int> surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10215   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10216
10217   damagedRects.clear();
10218   surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10219   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10220   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10221
10222   damagedRects.clear();
10223   surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10224   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10225   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10226
10227   // Rotate actor1 on y axis
10228   actor1[Actor::Property::ORIENTATION] = Quaternion(Radian(Degree(90.0)), Vector3::YAXIS);
10229
10230   // Remove actor2
10231   actor2.Unparent();
10232
10233   application.SendNotification();
10234
10235   damagedRects.clear();
10236   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10237
10238   // Should update full area
10239   surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10240   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10241   DirtyRectChecker(damagedRects, {surfaceRect}, true, TEST_LOCATION);
10242   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10243
10244   // Add actor2 again
10245   application.GetScene().Add(actor2);
10246
10247   application.SendNotification();
10248
10249   damagedRects.clear();
10250   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10251
10252   // Should update full area
10253   surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10254   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10255   DirtyRectChecker(damagedRects, {surfaceRect}, true, TEST_LOCATION);
10256   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10257
10258   // Reset the orientation of actor1
10259   actor1[Actor::Property::ORIENTATION] = Quaternion::IDENTITY;
10260
10261   application.SendNotification();
10262
10263   damagedRects.clear();
10264   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10265
10266   // Should update full area
10267   surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10268   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10269   DirtyRectChecker(damagedRects, {surfaceRect}, true, TEST_LOCATION);
10270   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10271
10272   // Make actor2 dirty
10273   actor2[Actor::Property::SIZE] = Vector3(32.0f, 32.0f, 0.0f);
10274
10275   application.SendNotification();
10276
10277   damagedRects.clear();
10278   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10279
10280   clippingRect2 = Rect<int>(160, 608, 48, 48);
10281   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10282   DirtyRectChecker(damagedRects, {clippingRect2}, true, TEST_LOCATION);
10283
10284   application.RenderWithPartialUpdate(damagedRects, clippingRect2);
10285   DALI_TEST_EQUALS(clippingRect2.x, glScissorParams.x, TEST_LOCATION);
10286   DALI_TEST_EQUALS(clippingRect2.y, glScissorParams.y, TEST_LOCATION);
10287   DALI_TEST_EQUALS(clippingRect2.width, glScissorParams.width, TEST_LOCATION);
10288   DALI_TEST_EQUALS(clippingRect2.height, glScissorParams.height, TEST_LOCATION);
10289
10290   // Remove actor1
10291   actor1.Unparent();
10292
10293   application.SendNotification();
10294
10295   damagedRects.clear();
10296   surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10297   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10298   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10299
10300   // Rotate actor1 on y axis
10301   actor1[Actor::Property::ORIENTATION] = Quaternion(Radian(Degree(90.0)), Vector3::YAXIS);
10302
10303   // Add actor1 again
10304   application.GetScene().Add(actor1);
10305
10306   application.SendNotification();
10307
10308   damagedRects.clear();
10309   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10310
10311   // Should update full area
10312   surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10313   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10314   DirtyRectChecker(damagedRects, {surfaceRect}, true, TEST_LOCATION);
10315   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10316
10317   END_TEST;
10318 }
10319
10320 int utcDaliActorPartialUpdateOneActorMultipleRenderers(void)
10321 {
10322   TestApplication application(
10323     TestApplication::DEFAULT_SURFACE_WIDTH,
10324     TestApplication::DEFAULT_SURFACE_HEIGHT,
10325     TestApplication::DEFAULT_HORIZONTAL_DPI,
10326     TestApplication::DEFAULT_VERTICAL_DPI,
10327     true,
10328     true);
10329
10330   tet_infoline("Check the damaged rect with one actor which has multiple renderers");
10331
10332   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
10333
10334   Actor actor = CreateRenderableActor();
10335
10336   // Create another renderer
10337   Geometry geometry  = CreateQuadGeometry();
10338   Shader   shader    = CreateShader();
10339   Renderer renderer2 = Renderer::New(geometry, shader);
10340   actor.AddRenderer(renderer2);
10341
10342   actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10343   actor[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
10344   actor[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
10345   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10346   application.GetScene().Add(actor);
10347
10348   application.SendNotification();
10349
10350   DALI_TEST_EQUALS(actor.GetRendererCount(), 2u, TEST_LOCATION);
10351
10352   std::vector<Rect<int>> damagedRects;
10353
10354   // Actor added, damaged rect is added size of actor
10355   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10356   DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
10357
10358   // Aligned by 16
10359   Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10360   DirtyRectChecker(damagedRects, {clippingRect, clippingRect}, true, TEST_LOCATION);
10361
10362   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10363   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
10364   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
10365   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
10366   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
10367
10368   damagedRects.clear();
10369   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10370   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10371
10372   // Ensure the damaged rect is empty
10373   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10374
10375   // Make renderer2 dirty
10376   renderer2[DevelRenderer::Property::OPACITY] = 0.5f;
10377
10378   application.SendNotification();
10379
10380   // The damaged rect should be the actor area
10381   damagedRects.clear();
10382   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10383
10384   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10385   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10386   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10387
10388   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10389
10390   damagedRects.clear();
10391   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10392   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10393
10394   // Ensure the damaged rect is empty
10395   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10396
10397   // Make renderer2 dirty
10398   renderer2[Renderer::Property::FACE_CULLING_MODE] = FaceCullingMode::BACK;
10399
10400   application.SendNotification();
10401
10402   // The damaged rect should be the actor area
10403   damagedRects.clear();
10404   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10405
10406   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10407   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10408   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10409
10410   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10411
10412   damagedRects.clear();
10413   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10414   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10415
10416   // Ensure the damaged rect is empty
10417   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10418
10419   END_TEST;
10420 }
10421
10422 int utcDaliActorPartialUpdateMultipleActorsOneRenderer(void)
10423 {
10424   TestApplication application(
10425     TestApplication::DEFAULT_SURFACE_WIDTH,
10426     TestApplication::DEFAULT_SURFACE_HEIGHT,
10427     TestApplication::DEFAULT_HORIZONTAL_DPI,
10428     TestApplication::DEFAULT_VERTICAL_DPI,
10429     true,
10430     true);
10431
10432   tet_infoline("Check the damaged rect with multiple actors which share a same renderer");
10433
10434   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
10435
10436   Actor actor                          = CreateRenderableActor();
10437   actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10438   actor[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
10439   actor[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
10440   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10441   application.GetScene().Add(actor);
10442
10443   // Create another actor which has the same renderer with actor1
10444   Actor    actor2   = Actor::New();
10445   Renderer renderer = actor.GetRendererAt(0);
10446   actor2.AddRenderer(renderer);
10447   actor2[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10448   actor2[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
10449   actor2[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
10450   actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10451   application.GetScene().Add(actor2);
10452
10453   application.SendNotification();
10454
10455   std::vector<Rect<int>> damagedRects;
10456
10457   // Actor added, damaged rect is added size of actor
10458   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10459   DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
10460
10461   // Aligned by 16
10462   Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10463   DirtyRectChecker(damagedRects, {clippingRect, clippingRect}, true, TEST_LOCATION);
10464
10465   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10466   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
10467   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
10468   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
10469   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
10470
10471   damagedRects.clear();
10472   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10473   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10474
10475   // Ensure the damaged rect is empty
10476   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10477
10478   // Make renderer dirty
10479   renderer[DevelRenderer::Property::OPACITY] = 0.5f;
10480
10481   application.SendNotification();
10482
10483   // The damaged rect should be the actor area
10484   damagedRects.clear();
10485   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10486
10487   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10488   DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
10489   DirtyRectChecker(damagedRects, {clippingRect, clippingRect}, true, TEST_LOCATION);
10490
10491   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10492
10493   damagedRects.clear();
10494   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10495   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10496
10497   // Ensure the damaged rect is empty
10498   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10499
10500   END_TEST;
10501 }
10502
10503 int UtcDaliActorCaptureAllTouchAfterStartPropertyP(void)
10504 {
10505   TestApplication application;
10506
10507   Actor actor = Actor::New();
10508   DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), false, TEST_LOCATION);
10509   actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, true);
10510   DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), true, TEST_LOCATION);
10511   DALI_TEST_EQUALS(actor.GetPropertyType(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), Property::BOOLEAN, TEST_LOCATION);
10512   DALI_TEST_EQUALS(actor.IsPropertyWritable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), true, TEST_LOCATION);
10513   DALI_TEST_EQUALS(actor.IsPropertyAnimatable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
10514   DALI_TEST_EQUALS(actor.IsPropertyAConstraintInput(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
10515   DALI_TEST_EQUALS(actor.GetPropertyName(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), "captureAllTouchAfterStart", TEST_LOCATION);
10516   END_TEST;
10517 }
10518
10519 int UtcDaliActorCaptureAllTouchAfterStartPropertyN(void)
10520 {
10521   TestApplication application;
10522
10523   Actor actor = Actor::New();
10524
10525   // Make sure setting invalid types does not cause a crash
10526   try
10527   {
10528     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, 1.0f);
10529     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector2::ONE);
10530     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector3::ONE);
10531     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector4::ONE);
10532     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Map());
10533     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Array());
10534     tet_result(TET_PASS);
10535   }
10536   catch(...)
10537   {
10538     tet_result(TET_FAIL);
10539   }
10540   END_TEST;
10541 }
10542
10543 int UtcDaliActorTouchAreaOffsetPropertyP(void)
10544 {
10545   TestApplication application;
10546
10547   Actor     actor           = Actor::New();
10548   Rect<int> touchAreaOffset = actor.GetProperty(DevelActor::Property::TOUCH_AREA_OFFSET).Get<Rect<int>>();
10549   DALI_TEST_EQUALS(Rect<int>(0, 0, 0, 0), touchAreaOffset, TEST_LOCATION);
10550   actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Rect<int>(10, 20, 30, 40));
10551   touchAreaOffset = actor.GetProperty(DevelActor::Property::TOUCH_AREA_OFFSET).Get<Rect<int>>();
10552   DALI_TEST_EQUALS(Rect<int>(10, 20, 30, 40), touchAreaOffset, TEST_LOCATION);
10553   END_TEST;
10554 }
10555
10556 int UtcDaliActorTouchAreaOffsetPropertyN(void)
10557 {
10558   TestApplication application;
10559
10560   Actor actor = Actor::New();
10561
10562   // Make sure setting invalid types does not cause a crash
10563   try
10564   {
10565     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, 1.0f);
10566     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector2::ONE);
10567     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector3::ONE);
10568     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector4::ONE);
10569     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Property::Map());
10570     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Property::Array());
10571     tet_result(TET_PASS);
10572   }
10573   catch(...)
10574   {
10575     tet_result(TET_FAIL);
10576   }
10577   END_TEST;
10578 }
10579
10580 int UtcDaliActorLowerBelowNegative(void)
10581 {
10582   TestApplication application;
10583   Dali::Actor     instance;
10584   try
10585   {
10586     Dali::Actor arg1;
10587     instance.LowerBelow(arg1);
10588     DALI_TEST_CHECK(false); // Should not get here
10589   }
10590   catch(...)
10591   {
10592     DALI_TEST_CHECK(true); // We expect an assert
10593   }
10594   END_TEST;
10595 }
10596
10597 int UtcDaliActorRaiseAboveNegative(void)
10598 {
10599   TestApplication application;
10600   Dali::Actor     instance;
10601   try
10602   {
10603     Dali::Actor arg1;
10604     instance.RaiseAbove(arg1);
10605     DALI_TEST_CHECK(false); // Should not get here
10606   }
10607   catch(...)
10608   {
10609     DALI_TEST_CHECK(true); // We expect an assert
10610   }
10611   END_TEST;
10612 }
10613
10614 int UtcDaliActorRaiseToTopNegative(void)
10615 {
10616   TestApplication application;
10617   Dali::Actor     instance;
10618   try
10619   {
10620     instance.RaiseToTop();
10621     DALI_TEST_CHECK(false); // Should not get here
10622   }
10623   catch(...)
10624   {
10625     DALI_TEST_CHECK(true); // We expect an assert
10626   }
10627   END_TEST;
10628 }
10629
10630 int UtcDaliActorAddRendererNegative(void)
10631 {
10632   TestApplication application;
10633   Dali::Actor     instance;
10634   try
10635   {
10636     Dali::Renderer arg1;
10637     instance.AddRenderer(arg1);
10638     DALI_TEST_CHECK(false); // Should not get here
10639   }
10640   catch(...)
10641   {
10642     DALI_TEST_CHECK(true); // We expect an assert
10643   }
10644   END_TEST;
10645 }
10646
10647 int UtcDaliActorTouchedSignalNegative(void)
10648 {
10649   TestApplication application;
10650   Dali::Actor     instance;
10651   try
10652   {
10653     instance.TouchedSignal();
10654     DALI_TEST_CHECK(false); // Should not get here
10655   }
10656   catch(...)
10657   {
10658     DALI_TEST_CHECK(true); // We expect an assert
10659   }
10660   END_TEST;
10661 }
10662
10663 int UtcDaliActorTranslateByNegative(void)
10664 {
10665   TestApplication application;
10666   Dali::Actor     instance;
10667   try
10668   {
10669     Dali::Vector3 arg1;
10670     instance.TranslateBy(arg1);
10671     DALI_TEST_CHECK(false); // Should not get here
10672   }
10673   catch(...)
10674   {
10675     DALI_TEST_CHECK(true); // We expect an assert
10676   }
10677   END_TEST;
10678 }
10679
10680 int UtcDaliActorFindChildByIdNegative(void)
10681 {
10682   TestApplication application;
10683   Dali::Actor     instance;
10684   try
10685   {
10686     unsigned int arg1 = 0u;
10687     instance.FindChildById(arg1);
10688     DALI_TEST_CHECK(false); // Should not get here
10689   }
10690   catch(...)
10691   {
10692     DALI_TEST_CHECK(true); // We expect an assert
10693   }
10694   END_TEST;
10695 }
10696
10697 int UtcDaliActorGetRendererAtNegative(void)
10698 {
10699   TestApplication application;
10700   Dali::Actor     instance;
10701   try
10702   {
10703     unsigned int arg1 = 0u;
10704     instance.GetRendererAt(arg1);
10705     DALI_TEST_CHECK(false); // Should not get here
10706   }
10707   catch(...)
10708   {
10709     DALI_TEST_CHECK(true); // We expect an assert
10710   }
10711   END_TEST;
10712 }
10713
10714 int UtcDaliActorHoveredSignalNegative(void)
10715 {
10716   TestApplication application;
10717   Dali::Actor     instance;
10718   try
10719   {
10720     instance.HoveredSignal();
10721     DALI_TEST_CHECK(false); // Should not get here
10722   }
10723   catch(...)
10724   {
10725     DALI_TEST_CHECK(true); // We expect an assert
10726   }
10727   END_TEST;
10728 }
10729
10730 int UtcDaliActorLowerToBottomNegative(void)
10731 {
10732   TestApplication application;
10733   Dali::Actor     instance;
10734   try
10735   {
10736     instance.LowerToBottom();
10737     DALI_TEST_CHECK(false); // Should not get here
10738   }
10739   catch(...)
10740   {
10741     DALI_TEST_CHECK(true); // We expect an assert
10742   }
10743   END_TEST;
10744 }
10745
10746 int UtcDaliActorOnSceneSignalNegative(void)
10747 {
10748   TestApplication application;
10749   Dali::Actor     instance;
10750   try
10751   {
10752     instance.OnSceneSignal();
10753     DALI_TEST_CHECK(false); // Should not get here
10754   }
10755   catch(...)
10756   {
10757     DALI_TEST_CHECK(true); // We expect an assert
10758   }
10759   END_TEST;
10760 }
10761
10762 int UtcDaliActorOffSceneSignalNegative(void)
10763 {
10764   TestApplication application;
10765   Dali::Actor     instance;
10766   try
10767   {
10768     instance.OffSceneSignal();
10769     DALI_TEST_CHECK(false); // Should not get here
10770   }
10771   catch(...)
10772   {
10773     DALI_TEST_CHECK(true); // We expect an assert
10774   }
10775   END_TEST;
10776 }
10777
10778 int UtcDaliActorRemoveRendererNegative01(void)
10779 {
10780   TestApplication application;
10781   Dali::Actor     instance;
10782   try
10783   {
10784     unsigned int arg1 = 0u;
10785     instance.RemoveRenderer(arg1);
10786     DALI_TEST_CHECK(false); // Should not get here
10787   }
10788   catch(...)
10789   {
10790     DALI_TEST_CHECK(true); // We expect an assert
10791   }
10792   END_TEST;
10793 }
10794
10795 int UtcDaliActorRemoveRendererNegative02(void)
10796 {
10797   TestApplication application;
10798   Dali::Actor     instance;
10799   try
10800   {
10801     Dali::Renderer arg1;
10802     instance.RemoveRenderer(arg1);
10803     DALI_TEST_CHECK(false); // Should not get here
10804   }
10805   catch(...)
10806   {
10807     DALI_TEST_CHECK(true); // We expect an assert
10808   }
10809   END_TEST;
10810 }
10811
10812 int UtcDaliActorFindChildByNameNegative(void)
10813 {
10814   TestApplication application;
10815   Dali::Actor     instance;
10816   try
10817   {
10818     std::string arg1;
10819     instance.FindChildByName(arg1);
10820     DALI_TEST_CHECK(false); // Should not get here
10821   }
10822   catch(...)
10823   {
10824     DALI_TEST_CHECK(true); // We expect an assert
10825   }
10826   END_TEST;
10827 }
10828
10829 int UtcDaliActorSetResizePolicyNegative(void)
10830 {
10831   TestApplication application;
10832   Dali::Actor     instance;
10833   try
10834   {
10835     Dali::ResizePolicy::Type arg1 = ResizePolicy::USE_NATURAL_SIZE;
10836     Dali::Dimension::Type    arg2 = Dimension::ALL_DIMENSIONS;
10837     instance.SetResizePolicy(arg1, arg2);
10838     DALI_TEST_CHECK(false); // Should not get here
10839   }
10840   catch(...)
10841   {
10842     DALI_TEST_CHECK(true); // We expect an assert
10843   }
10844   END_TEST;
10845 }
10846
10847 int UtcDaliActorOnRelayoutSignalNegative(void)
10848 {
10849   TestApplication application;
10850   Dali::Actor     instance;
10851   try
10852   {
10853     instance.OnRelayoutSignal();
10854     DALI_TEST_CHECK(false); // Should not get here
10855   }
10856   catch(...)
10857   {
10858     DALI_TEST_CHECK(true); // We expect an assert
10859   }
10860   END_TEST;
10861 }
10862
10863 int UtcDaliActorWheelEventSignalNegative(void)
10864 {
10865   TestApplication application;
10866   Dali::Actor     instance;
10867   try
10868   {
10869     instance.WheelEventSignal();
10870     DALI_TEST_CHECK(false); // Should not get here
10871   }
10872   catch(...)
10873   {
10874     DALI_TEST_CHECK(true); // We expect an assert
10875   }
10876   END_TEST;
10877 }
10878
10879 int UtcDaliActorGetHeightForWidthNegative(void)
10880 {
10881   TestApplication application;
10882   Dali::Actor     instance;
10883   try
10884   {
10885     float arg1 = 0.0f;
10886     instance.GetHeightForWidth(arg1);
10887     DALI_TEST_CHECK(false); // Should not get here
10888   }
10889   catch(...)
10890   {
10891     DALI_TEST_CHECK(true); // We expect an assert
10892   }
10893   END_TEST;
10894 }
10895
10896 int UtcDaliActorGetWidthForHeightNegative(void)
10897 {
10898   TestApplication application;
10899   Dali::Actor     instance;
10900   try
10901   {
10902     float arg1 = 0.0f;
10903     instance.GetWidthForHeight(arg1);
10904     DALI_TEST_CHECK(false); // Should not get here
10905   }
10906   catch(...)
10907   {
10908     DALI_TEST_CHECK(true); // We expect an assert
10909   }
10910   END_TEST;
10911 }
10912
10913 int UtcDaliActorLayoutDirectionChangedSignalNegative(void)
10914 {
10915   TestApplication application;
10916   Dali::Actor     instance;
10917   try
10918   {
10919     instance.LayoutDirectionChangedSignal();
10920     DALI_TEST_CHECK(false); // Should not get here
10921   }
10922   catch(...)
10923   {
10924     DALI_TEST_CHECK(true); // We expect an assert
10925   }
10926   END_TEST;
10927 }
10928
10929 int UtcDaliActorAddNegative(void)
10930 {
10931   TestApplication application;
10932   Dali::Actor     instance;
10933   try
10934   {
10935     Dali::Actor arg1;
10936     instance.Add(arg1);
10937     DALI_TEST_CHECK(false); // Should not get here
10938   }
10939   catch(...)
10940   {
10941     DALI_TEST_CHECK(true); // We expect an assert
10942   }
10943   END_TEST;
10944 }
10945
10946 int UtcDaliActorLowerNegative(void)
10947 {
10948   TestApplication application;
10949   Dali::Actor     instance;
10950   try
10951   {
10952     instance.Lower();
10953     DALI_TEST_CHECK(false); // Should not get here
10954   }
10955   catch(...)
10956   {
10957     DALI_TEST_CHECK(true); // We expect an assert
10958   }
10959   END_TEST;
10960 }
10961
10962 int UtcDaliActorRaiseNegative(void)
10963 {
10964   TestApplication application;
10965   Dali::Actor     instance;
10966   try
10967   {
10968     instance.Raise();
10969     DALI_TEST_CHECK(false); // Should not get here
10970   }
10971   catch(...)
10972   {
10973     DALI_TEST_CHECK(true); // We expect an assert
10974   }
10975   END_TEST;
10976 }
10977
10978 int UtcDaliActorRemoveNegative(void)
10979 {
10980   TestApplication application;
10981   Dali::Actor     instance;
10982   try
10983   {
10984     Dali::Actor arg1;
10985     instance.Remove(arg1);
10986     DALI_TEST_CHECK(false); // Should not get here
10987   }
10988   catch(...)
10989   {
10990     DALI_TEST_CHECK(true); // We expect an assert
10991   }
10992   END_TEST;
10993 }
10994
10995 int UtcDaliActorScaleByNegative(void)
10996 {
10997   TestApplication application;
10998   Dali::Actor     instance;
10999   try
11000   {
11001     Dali::Vector3 arg1;
11002     instance.ScaleBy(arg1);
11003     DALI_TEST_CHECK(false); // Should not get here
11004   }
11005   catch(...)
11006   {
11007     DALI_TEST_CHECK(true); // We expect an assert
11008   }
11009   END_TEST;
11010 }
11011
11012 int UtcDaliActorGetLayerNegative(void)
11013 {
11014   TestApplication application;
11015   Dali::Actor     instance;
11016   try
11017   {
11018     instance.GetLayer();
11019     DALI_TEST_CHECK(false); // Should not get here
11020   }
11021   catch(...)
11022   {
11023     DALI_TEST_CHECK(true); // We expect an assert
11024   }
11025   END_TEST;
11026 }
11027
11028 int UtcDaliActorRotateByNegative01(void)
11029 {
11030   TestApplication application;
11031   Dali::Actor     instance;
11032   try
11033   {
11034     Dali::Quaternion arg1;
11035     instance.RotateBy(arg1);
11036     DALI_TEST_CHECK(false); // Should not get here
11037   }
11038   catch(...)
11039   {
11040     DALI_TEST_CHECK(true); // We expect an assert
11041   }
11042   END_TEST;
11043 }
11044
11045 int UtcDaliActorRotateByNegative02(void)
11046 {
11047   TestApplication application;
11048   Dali::Actor     instance;
11049   try
11050   {
11051     Dali::Radian  arg1;
11052     Dali::Vector3 arg2;
11053     instance.RotateBy(arg1, arg2);
11054     DALI_TEST_CHECK(false); // Should not get here
11055   }
11056   catch(...)
11057   {
11058     DALI_TEST_CHECK(true); // We expect an assert
11059   }
11060   END_TEST;
11061 }
11062
11063 int UtcDaliActorUnparentNegative(void)
11064 {
11065   TestApplication application;
11066   Dali::Actor     instance;
11067   try
11068   {
11069     instance.Unparent();
11070     DALI_TEST_CHECK(false); // Should not get here
11071   }
11072   catch(...)
11073   {
11074     DALI_TEST_CHECK(true); // We expect an assert
11075   }
11076   END_TEST;
11077 }
11078
11079 int UtcDaliActorGetChildAtNegative(void)
11080 {
11081   TestApplication application;
11082   Dali::Actor     instance;
11083   try
11084   {
11085     unsigned int arg1 = 0u;
11086     instance.GetChildAt(arg1);
11087     DALI_TEST_CHECK(false); // Should not get here
11088   }
11089   catch(...)
11090   {
11091     DALI_TEST_CHECK(true); // We expect an assert
11092   }
11093   END_TEST;
11094 }
11095
11096 int UtcDaliActorGetChildCountNegative(void)
11097 {
11098   TestApplication application;
11099   Dali::Actor     instance;
11100   try
11101   {
11102     instance.GetChildCount();
11103     DALI_TEST_CHECK(false); // Should not get here
11104   }
11105   catch(...)
11106   {
11107     DALI_TEST_CHECK(true); // We expect an assert
11108   }
11109   END_TEST;
11110 }
11111
11112 int UtcDaliActorGetTargetSizeNegative(void)
11113 {
11114   TestApplication application;
11115   Dali::Actor     instance;
11116   try
11117   {
11118     instance.GetTargetSize();
11119     DALI_TEST_CHECK(false); // Should not get here
11120   }
11121   catch(...)
11122   {
11123     DALI_TEST_CHECK(true); // We expect an assert
11124   }
11125   END_TEST;
11126 }
11127
11128 int UtcDaliActorScreenToLocalNegative(void)
11129 {
11130   TestApplication application;
11131   Dali::Actor     instance;
11132   try
11133   {
11134     float arg1 = 0.0f;
11135     float arg2 = 0.0f;
11136     float arg3 = 0.0f;
11137     float arg4 = 0.0f;
11138     instance.ScreenToLocal(arg1, arg2, arg3, arg4);
11139     DALI_TEST_CHECK(false); // Should not get here
11140   }
11141   catch(...)
11142   {
11143     DALI_TEST_CHECK(true); // We expect an assert
11144   }
11145   END_TEST;
11146 }
11147
11148 int UtcDaliActorGetNaturalSizeNegative(void)
11149 {
11150   TestApplication application;
11151   Dali::Actor     instance;
11152   try
11153   {
11154     instance.GetNaturalSize();
11155     DALI_TEST_CHECK(false); // Should not get here
11156   }
11157   catch(...)
11158   {
11159     DALI_TEST_CHECK(true); // We expect an assert
11160   }
11161   END_TEST;
11162 }
11163
11164 int UtcDaliActorGetRelayoutSizeNegative(void)
11165 {
11166   TestApplication application;
11167   Dali::Actor     instance;
11168   try
11169   {
11170     Dali::Dimension::Type arg1 = Dimension::HEIGHT;
11171     instance.GetRelayoutSize(arg1);
11172     DALI_TEST_CHECK(false); // Should not get here
11173   }
11174   catch(...)
11175   {
11176     DALI_TEST_CHECK(true); // We expect an assert
11177   }
11178   END_TEST;
11179 }
11180
11181 int UtcDaliActorGetResizePolicyNegative(void)
11182 {
11183   TestApplication application;
11184   Dali::Actor     instance;
11185   try
11186   {
11187     Dali::Dimension::Type arg1 = Dimension::ALL_DIMENSIONS;
11188     instance.GetResizePolicy(arg1);
11189     DALI_TEST_CHECK(false); // Should not get here
11190   }
11191   catch(...)
11192   {
11193     DALI_TEST_CHECK(true); // We expect an assert
11194   }
11195   END_TEST;
11196 }
11197
11198 int UtcDaliActorGetRendererCountNegative(void)
11199 {
11200   TestApplication application;
11201   Dali::Actor     instance;
11202   try
11203   {
11204     instance.GetRendererCount();
11205     DALI_TEST_CHECK(false); // Should not get here
11206   }
11207   catch(...)
11208   {
11209     DALI_TEST_CHECK(true); // We expect an assert
11210   }
11211   END_TEST;
11212 }
11213
11214 int UtcDaliActorGetParentNegative(void)
11215 {
11216   TestApplication application;
11217   Dali::Actor     instance;
11218   try
11219   {
11220     instance.GetParent();
11221     DALI_TEST_CHECK(false); // Should not get here
11222   }
11223   catch(...)
11224   {
11225     DALI_TEST_CHECK(true); // We expect an assert
11226   }
11227   END_TEST;
11228 }
11229
11230 int UtcDaliActorPropertyBlendEquation(void)
11231 {
11232   TestApplication application;
11233
11234   tet_infoline("Test SetProperty AdvancedBlendEquation");
11235
11236   Geometry geometry  = CreateQuadGeometry();
11237   Shader   shader    = CreateShader();
11238   Renderer renderer1 = Renderer::New(geometry, shader);
11239
11240   Actor actor = Actor::New();
11241   actor.SetProperty(Actor::Property::OPACITY, 0.1f);
11242
11243   actor.AddRenderer(renderer1);
11244   actor.SetProperty(Actor::Property::SIZE, Vector2(400, 400));
11245   application.GetScene().Add(actor);
11246
11247   if(!Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
11248   {
11249     actor.SetProperty(Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN);
11250     int equation = actor.GetProperty<int>(Dali::DevelActor::Property::BLEND_EQUATION);
11251     DALI_TEST_EQUALS((Dali::DevelBlendEquation::SCREEN == equation), false, TEST_LOCATION);
11252   }
11253
11254   if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
11255   {
11256     actor.SetProperty(Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN);
11257     int equation = actor.GetProperty<int>(Dali::DevelActor::Property::BLEND_EQUATION);
11258     DALI_TEST_EQUALS((Dali::DevelBlendEquation::SCREEN == equation), true, TEST_LOCATION);
11259   }
11260
11261   Renderer renderer2 = Renderer::New(geometry, shader);
11262   actor.AddRenderer(renderer2);
11263
11264   END_TEST;
11265 }
11266
11267 int UtcDaliActorRegisterProperty(void)
11268 {
11269   tet_infoline("Test property registration and uniform map update\n");
11270
11271   TestApplication application;
11272
11273   Geometry geometry  = CreateQuadGeometry();
11274   Shader   shader    = CreateShader();
11275   Renderer renderer1 = Renderer::New(geometry, shader);
11276   Renderer renderer2 = Renderer::New(geometry, shader);
11277
11278   Actor actor1 = Actor::New();
11279   actor1.AddRenderer(renderer1);
11280   actor1.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
11281   actor1.RegisterProperty("uCustom", 1);
11282   application.GetScene().Add(actor1);
11283
11284   Actor actor2 = Actor::New();
11285   actor2.AddRenderer(renderer2);
11286   actor2.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
11287   application.GetScene().Add(actor2);
11288
11289   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
11290   TraceCallStack&    callStack     = glAbstraction.GetSetUniformTrace();
11291   glAbstraction.EnableSetUniformCallTrace(true);
11292
11293   application.SendNotification();
11294   application.Render();
11295
11296   std::stringstream out;
11297   out.str("1");
11298   std::string params;
11299
11300   // Test uniform value of the custom property
11301   DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("uCustom", params));
11302   DALI_TEST_EQUALS(out.str(), params, TEST_LOCATION);
11303
11304   // Make invisible
11305   actor1[Actor::Property::VISIBLE] = false;
11306
11307   application.SendNotification();
11308   application.Render();
11309
11310   // Make visible again
11311   actor1[Actor::Property::VISIBLE] = true;
11312   actor1["uCustom"]                = 2;
11313
11314   glAbstraction.ResetSetUniformCallStack();
11315
11316   application.SendNotification();
11317   application.Render();
11318
11319   out.str("2");
11320
11321   // The uniform value should not be changed
11322   DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("uCustom", params));
11323   DALI_TEST_EQUALS(out.str(), params, TEST_LOCATION);
11324
11325   END_TEST;
11326 }
11327
11328 int UtcDaliActorDoesWantedHitTest(void)
11329 {
11330   struct HitTestData
11331   {
11332   public:
11333     HitTestData(const Vector3& scale, const Vector2& touchPoint, bool result)
11334     : mScale(scale),
11335       mTouchPoint(touchPoint),
11336       mResult(result)
11337     {
11338     }
11339
11340     Vector3 mScale;
11341     Vector2 mTouchPoint;
11342     bool    mResult;
11343   };
11344
11345   TestApplication application;
11346   tet_infoline(" UtcDaliActorDoesWantedHitTest");
11347
11348   // Fill a vector with different hit tests.
11349   struct HitTestData* hitTestData[] = {
11350     //                    scale                     touch point           result
11351     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(289.f, 400.f), true),  // touch point close to the right edge (inside)
11352     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(291.f, 400.f), false), // touch point close to the right edge (outside)
11353     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.
11354     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(200.f, 451.f), false), // touch point close to the down edge (outside)
11355     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.
11356     NULL,
11357   };
11358
11359   // get the root layer
11360   Actor actor = Actor::New();
11361   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
11362   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
11363
11364   Actor lowerActor = Actor::New();
11365   lowerActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
11366   lowerActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
11367
11368   // actor and lowerActor have no relationship.
11369   application.GetScene().Add(lowerActor);
11370   application.GetScene().Add(actor);
11371
11372   ResetTouchCallbacks();
11373   gHitTestTouchCallBackCalled = false;
11374
11375   unsigned int index = 0;
11376   while(NULL != hitTestData[index])
11377   {
11378     actor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f));
11379     actor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z));
11380
11381     lowerActor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f));
11382     lowerActor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z));
11383
11384     // flush the queue and render once
11385     application.SendNotification();
11386     application.Render();
11387
11388     DALI_TEST_CHECK(!gTouchCallBackCalled);
11389     DALI_TEST_CHECK(!gTouchCallBackCalled2);
11390     DALI_TEST_CHECK(!gHitTestTouchCallBackCalled);
11391
11392     // connect to its touch signal
11393     actor.TouchedSignal().Connect(TestTouchCallback);
11394     lowerActor.TouchedSignal().Connect(TestTouchCallback2);
11395
11396     // connect to its hit-test signal
11397     Dali::DevelActor::HitTestResultSignal(actor).Connect(TestHitTestTouchCallback);
11398
11399     Dali::Integration::Point point;
11400     point.SetState(PointState::DOWN);
11401     point.SetScreenPosition(Vector2(hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y));
11402     Dali::Integration::TouchEvent event;
11403     event.AddPoint(point);
11404
11405     // flush the queue and render once
11406     application.SendNotification();
11407     application.Render();
11408     application.ProcessEvent(event);
11409
11410     // check hit-test events
11411     DALI_TEST_CHECK(gHitTestTouchCallBackCalled == hitTestData[index]->mResult);
11412     // Passed all hit-tests of actor.
11413     DALI_TEST_CHECK(gTouchCallBackCalled == false);
11414     // The lowerActor was hit-tested.
11415     DALI_TEST_CHECK(gTouchCallBackCalled2 == hitTestData[index]->mResult);
11416
11417     if(gTouchCallBackCalled2 != hitTestData[index]->mResult)
11418       tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
11419                  hitTestData[index]->mScale.x,
11420                  hitTestData[index]->mScale.y,
11421                  hitTestData[index]->mScale.z,
11422                  hitTestData[index]->mTouchPoint.x,
11423                  hitTestData[index]->mTouchPoint.y,
11424                  hitTestData[index]->mResult);
11425
11426     ResetTouchCallbacks();
11427     gHitTestTouchCallBackCalled = false;
11428     ++index;
11429   }
11430   END_TEST;
11431 }
11432
11433 int UtcDaliActorAllowOnlyOwnTouchPropertyP(void)
11434 {
11435   TestApplication application;
11436
11437   Actor actor = Actor::New();
11438   DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH).Get<bool>(), false, TEST_LOCATION);
11439   actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, true);
11440   DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH).Get<bool>(), true, TEST_LOCATION);
11441   DALI_TEST_EQUALS(actor.GetPropertyType(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), Property::BOOLEAN, TEST_LOCATION);
11442   DALI_TEST_EQUALS(actor.IsPropertyWritable(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), true, TEST_LOCATION);
11443   DALI_TEST_EQUALS(actor.IsPropertyAnimatable(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), false, TEST_LOCATION);
11444   DALI_TEST_EQUALS(actor.IsPropertyAConstraintInput(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), false, TEST_LOCATION);
11445   DALI_TEST_EQUALS(actor.GetPropertyName(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), "allowOnlyOwnTouch", TEST_LOCATION);
11446   END_TEST;
11447 }
11448
11449 int UtcDaliActorAllowOnlyOwnTouchPropertyN(void)
11450 {
11451   TestApplication application;
11452
11453   Actor actor = Actor::New();
11454
11455   // Make sure setting invalid types does not cause a crash
11456   try
11457   {
11458     actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, 1.0f);
11459     actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Vector2::ONE);
11460     actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Vector3::ONE);
11461     actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Vector4::ONE);
11462     actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Property::Map());
11463     actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Property::Array());
11464     tet_result(TET_PASS);
11465   }
11466   catch(...)
11467   {
11468     tet_result(TET_FAIL);
11469   }
11470   END_TEST;
11471 }
11472
11473 int UtcDaliActorCalculateWorldTransform01(void)
11474 {
11475   TestApplication application;
11476
11477   tet_infoline("Test that actor position inheritance produces right transform matrix");
11478
11479   Actor rootActor   = Actor::New();
11480   Actor branchActor = Actor::New();
11481   Actor leafActor   = Actor::New();
11482
11483   rootActor[Actor::Property::POSITION]   = Vector3(0.0f, 0.0f, 0.0f);
11484   branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
11485   leafActor[Actor::Property::POSITION]   = Vector3(100.0f, 50.0f, 30.0f);
11486
11487   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11488   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11489   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11490
11491   // Set anchor point to the same value as parent origin
11492   rootActor[Actor::Property::PARENT_ORIGIN]   = ParentOrigin::TOP_LEFT;
11493   branchActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT;
11494   leafActor[Actor::Property::PARENT_ORIGIN]   = ParentOrigin::TOP_LEFT;
11495
11496   rootActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
11497   branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11498   leafActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
11499
11500   application.GetScene().Add(rootActor);
11501   rootActor.Add(branchActor);
11502   branchActor.Add(leafActor);
11503
11504   application.SendNotification();
11505   application.Render(0);
11506   application.SendNotification();
11507   application.Render(0);
11508
11509   Matrix m = DevelActor::GetWorldTransform(leafActor);
11510
11511   Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11512   DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11513
11514   Vector3    worldPos;
11515   Vector3    worldScale;
11516   Quaternion worldRotation;
11517   m.GetTransformComponents(worldPos, worldRotation, worldScale);
11518   DALI_TEST_EQUALS(worldPos, Vector3(200.0f, 150.0f, 30.0f), 0.0001f, TEST_LOCATION);
11519
11520   END_TEST;
11521 }
11522
11523 int UtcDaliActorCalculateWorldTransform02(void)
11524 {
11525   TestApplication application;
11526
11527   tet_infoline("Test that actor position produces right transform matrix");
11528
11529   Actor rootActor   = Actor::New();
11530   Actor branchActor = Actor::New();
11531   Actor leafActor   = Actor::New();
11532
11533   rootActor[Actor::Property::POSITION]   = Vector3(0.0f, 0.0f, 0.0f);
11534   branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
11535   leafActor[Actor::Property::POSITION]   = Vector3(100.0f, 50.0f, 30.0f);
11536
11537   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11538   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11539   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11540
11541   // Set anchor point to the same value as parent origin
11542   rootActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
11543   branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11544   leafActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
11545
11546   application.GetScene().Add(rootActor);
11547   rootActor.Add(branchActor);
11548   branchActor.Add(leafActor);
11549
11550   leafActor[Actor::Property::INHERIT_POSITION]    = false;
11551   leafActor[Actor::Property::INHERIT_ORIENTATION] = false;
11552   leafActor[Actor::Property::INHERIT_SCALE]       = false;
11553
11554   application.SendNotification();
11555   application.Render(0);
11556   application.SendNotification();
11557   application.Render(0);
11558
11559   Matrix m = DevelActor::GetWorldTransform(leafActor);
11560
11561   Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11562   DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11563
11564   END_TEST;
11565 }
11566
11567 int UtcDaliActorCalculateWorldTransform03(void)
11568 {
11569   TestApplication application;
11570
11571   tet_infoline("Test that actor position produces right transform matrix");
11572
11573   Actor rootActor   = Actor::New();
11574   Actor branchActor = Actor::New();
11575   Actor leafActor   = Actor::New();
11576
11577   rootActor[Actor::Property::POSITION]   = Vector3(0.0f, 0.0f, 0.0f);
11578   branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
11579   leafActor[Actor::Property::POSITION]   = Vector3(100.0f, 50.0f, 30.0f);
11580
11581   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11582   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11583   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11584
11585   // Set anchor point to the same value as parent origin
11586   rootActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
11587   branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11588   leafActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
11589
11590   application.GetScene().Add(rootActor);
11591   rootActor.Add(branchActor);
11592   branchActor.Add(leafActor);
11593
11594   leafActor[Actor::Property::INHERIT_POSITION]    = true;
11595   leafActor[Actor::Property::INHERIT_ORIENTATION] = false;
11596   leafActor[Actor::Property::INHERIT_SCALE]       = false;
11597
11598   application.SendNotification();
11599   application.Render(0);
11600   application.SendNotification();
11601   application.Render(0);
11602
11603   Matrix m = DevelActor::GetWorldTransform(leafActor);
11604
11605   Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11606   DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11607
11608   END_TEST;
11609 }
11610
11611 int UtcDaliActorCalculateWorldTransform04(void)
11612 {
11613   TestApplication application;
11614
11615   tet_infoline("Test that actor inheritance scale/orientation produces right transform matrix");
11616
11617   Actor rootActor   = Actor::New();
11618   Actor branchActor = Actor::New();
11619   Actor leafActor   = Actor::New();
11620
11621   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
11622   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
11623   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11624
11625   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11626   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11627   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11628
11629   // Set anchor point to the same value as parent origin
11630   rootActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::CENTER;
11631   rootActor[Actor::Property::PARENT_ORIGIN]  = ParentOrigin::CENTER;
11632   branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11633   leafActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
11634
11635   branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
11636   leafActor[Actor::Property::POSITION]   = Vector3(100.0f, 50.0f, 30.0f);
11637
11638   application.GetScene().Add(rootActor);
11639   rootActor.Add(branchActor);
11640   branchActor.Add(leafActor);
11641
11642   application.SendNotification();
11643   application.Render(0);
11644   application.SendNotification();
11645   application.Render(0);
11646
11647   Matrix m = DevelActor::GetWorldTransform(leafActor);
11648
11649   Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11650   DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11651
11652   END_TEST;
11653 }
11654
11655 int UtcDaliActorCalculateWorldTransform05(void)
11656 {
11657   TestApplication application;
11658
11659   tet_infoline("Test that actor inheritance of scale produces right transform matrix");
11660
11661   Actor rootActor   = Actor::New();
11662   Actor branchActor = Actor::New();
11663   Actor leafActor   = Actor::New();
11664
11665   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
11666   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
11667   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11668
11669   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11670   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11671   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11672
11673   // Set anchor point to the same value as parent origin
11674   rootActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::CENTER;
11675   rootActor[Actor::Property::PARENT_ORIGIN]  = ParentOrigin::CENTER;
11676   branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11677   leafActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
11678
11679   branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
11680   leafActor[Actor::Property::POSITION]   = Vector3(100.0f, 50.0f, 30.0f);
11681
11682   leafActor[Actor::Property::INHERIT_POSITION]    = false;
11683   leafActor[Actor::Property::INHERIT_ORIENTATION] = false;
11684
11685   application.GetScene().Add(rootActor);
11686   rootActor.Add(branchActor);
11687   branchActor.Add(leafActor);
11688
11689   application.SendNotification();
11690   application.Render(0);
11691   application.SendNotification();
11692   application.Render(0);
11693
11694   Matrix m = DevelActor::GetWorldTransform(leafActor);
11695
11696   Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11697   DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11698
11699   END_TEST;
11700 }
11701
11702 int UtcDaliActorCalculateWorldTransform06(void)
11703 {
11704   TestApplication application;
11705
11706   tet_infoline("Test that actor inheritance of scale produces right transform matrix");
11707
11708   Actor rootActor   = Actor::New();
11709   Actor branchActor = Actor::New();
11710   Actor leafActor   = Actor::New();
11711
11712   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
11713   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
11714   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11715
11716   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11717   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11718   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11719
11720   // Set anchor point to the same value as parent origin
11721   rootActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::CENTER;
11722   rootActor[Actor::Property::PARENT_ORIGIN]  = ParentOrigin::CENTER;
11723   branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11724   leafActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
11725
11726   branchActor[Actor::Property::POSITION]    = Vector3(100.0f, 30.0f, -50.0f);
11727   branchActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(45.0f), Vector3::XAXIS);
11728   leafActor[Actor::Property::POSITION]      = Vector3(100.0f, 50.0f, 30.0f);
11729
11730   leafActor[Actor::Property::INHERIT_POSITION] = false;
11731   leafActor[Actor::Property::INHERIT_SCALE]    = false;
11732
11733   application.GetScene().Add(rootActor);
11734   rootActor.Add(branchActor);
11735   branchActor.Add(leafActor);
11736
11737   application.SendNotification();
11738   application.Render(0);
11739   application.SendNotification();
11740   application.Render(0);
11741
11742   Matrix m = DevelActor::GetWorldTransform(leafActor);
11743
11744   Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11745   DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11746
11747   END_TEST;
11748 }
11749
11750 int UtcDaliActorCalculateWorldTransform07(void)
11751 {
11752   TestApplication application;
11753
11754   tet_infoline("Test that actor inheritance of scale produces right transform matrix");
11755
11756   Actor rootActor   = Actor::New();
11757   Actor branchActor = Actor::New();
11758   Actor leafActor   = Actor::New();
11759
11760   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
11761   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
11762   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11763
11764   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11765   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11766   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11767
11768   // Set anchor point to the same value as parent origin
11769   rootActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::CENTER;
11770   rootActor[Actor::Property::PARENT_ORIGIN]  = ParentOrigin::CENTER;
11771   branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11772
11773   // This should be ignored.
11774   leafActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
11775   leafActor[Actor::Property::ANCHOR_POINT]  = AnchorPoint::CENTER;
11776
11777   branchActor[Actor::Property::POSITION]    = Vector3(100.0f, 30.0f, -50.0f);
11778   branchActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(45.0f), Vector3::XAXIS);
11779   leafActor[Actor::Property::POSITION]      = Vector3(100.0f, 50.0f, 30.0f);
11780
11781   leafActor[Actor::Property::INHERIT_POSITION]           = false;
11782   leafActor[Actor::Property::INHERIT_SCALE]              = false;
11783   leafActor[Actor::Property::POSITION_USES_ANCHOR_POINT] = false;
11784
11785   application.GetScene().Add(rootActor);
11786   rootActor.Add(branchActor);
11787   branchActor.Add(leafActor);
11788
11789   application.SendNotification();
11790   application.Render(0);
11791   application.SendNotification();
11792   application.Render(0);
11793
11794   Matrix m = DevelActor::GetWorldTransform(leafActor);
11795
11796   Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11797   DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11798
11799   END_TEST;
11800 }
11801
11802 int UtcDaliActorCalculateWorldTransform08(void)
11803 {
11804   TestApplication application;
11805
11806   tet_infoline("Test that actor inheritance of scale produces right transform matrix");
11807
11808   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)};
11809
11810   struct TestCase
11811   {
11812     bool translation;
11813     bool rotation;
11814     bool scaling;
11815   };
11816   TestCase testCases[] = {
11817     {false, false, true},
11818     {false, true, false},
11819     {true, false, false},
11820     {false, true, true},
11821     {true, false, true},
11822     {true, true, false},
11823     {false, false, false},
11824     {true, true, true},
11825   };
11826
11827   Actor rootActor = Actor::New();
11828   Actor leafActor = Actor::New();
11829
11830   rootActor[Actor::Property::POSITION]      = Vector3(0.0f, 0.0f, 0.0f);
11831   rootActor[Actor::Property::SCALE]         = Vector3(1.0f, 2.0f, 1.0f);
11832   rootActor[Actor::Property::ORIENTATION]   = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11833   rootActor[Actor::Property::SIZE]          = Vector2(200, 400);
11834   rootActor[Actor::Property::ANCHOR_POINT]  = AnchorPoint::CENTER;
11835   rootActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
11836
11837   leafActor[Actor::Property::POSITION]                   = Vector3(0.0f, -50.0f, 0.0f);
11838   leafActor[Actor::Property::SCALE]                      = Vector3(1.0f, 1.0f, 1.0f);
11839   leafActor[Actor::Property::ORIENTATION]                = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11840   leafActor[Actor::Property::SIZE]                       = Vector2(200, 400);
11841   leafActor[Actor::Property::ANCHOR_POINT]               = AnchorPoint::BOTTOM_CENTER;
11842   leafActor[Actor::Property::PARENT_ORIGIN]              = ParentOrigin::TOP_CENTER;
11843   leafActor[Actor::Property::POSITION_USES_ANCHOR_POINT] = true;
11844
11845   application.GetScene().Add(rootActor);
11846   rootActor.Add(leafActor);
11847
11848   for(uint32_t i = 0; i < 8; ++i)
11849   {
11850     leafActor[Actor::Property::INHERIT_POSITION]    = testCases[i].translation;
11851     leafActor[Actor::Property::INHERIT_ORIENTATION] = testCases[i].rotation;
11852     leafActor[Actor::Property::INHERIT_SCALE]       = testCases[i].scaling;
11853
11854     application.SendNotification();
11855     application.Render(0);
11856     application.SendNotification();
11857     application.Render(0);
11858
11859     Matrix m            = DevelActor::GetWorldTransform(leafActor);
11860     Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11861
11862     Vector3 worldPosition1 = Vector3(m.GetTranslation());
11863     Vector3 worldPosition2 = Vector3(actualMatrix.GetTranslation());
11864
11865     DALI_TEST_EQUALS(solutions[i], worldPosition1, 0.001f, TEST_LOCATION);
11866     DALI_TEST_EQUALS(solutions[i], worldPosition2, 0.001f, TEST_LOCATION);
11867   }
11868
11869   END_TEST;
11870 }
11871
11872 int UtcDaliActorCalculateWorldColor01(void)
11873 {
11874   TestApplication application;
11875
11876   tet_infoline("Test that actor inheritance of color produces right final color");
11877
11878   Actor rootActor   = Actor::New();
11879   Actor branchActor = Actor::New();
11880   Actor leafActor   = Actor::New();
11881
11882   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
11883   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
11884   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11885
11886   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11887   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11888   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11889
11890   rootActor[Actor::Property::COLOR] = Color::WHITE;
11891   Vector4 testColor1(1.0f, 1.0f, 0.5f, 0.8f);
11892   branchActor[Actor::Property::COLOR] = testColor1;
11893   leafActor[Actor::Property::COLOR]   = Vector4(0.1f, 0.5f, 0.5f, 0.8f);
11894
11895   // Default is to inherit:
11896   leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_OWN_MULTIPLY_PARENT_ALPHA;
11897
11898   application.GetScene().Add(rootActor);
11899   rootActor.Add(branchActor);
11900   branchActor.Add(leafActor);
11901
11902   application.SendNotification();
11903   application.Render(16);
11904   Vector4 color = branchActor.GetCurrentProperty<Vector4>(Actor::Property::COLOR);
11905   DALI_TEST_EQUALS(color, testColor1, TEST_LOCATION);
11906
11907   application.SendNotification();
11908   application.Render(16);
11909   color = branchActor.GetCurrentProperty<Vector4>(Actor::Property::COLOR);
11910   DALI_TEST_EQUALS(color, testColor1, TEST_LOCATION);
11911
11912   application.SendNotification();
11913   application.Render(16);
11914   color = branchActor.GetCurrentProperty<Vector4>(Actor::Property::COLOR);
11915   DALI_TEST_EQUALS(color, testColor1, TEST_LOCATION);
11916
11917   color = DevelActor::GetWorldColor(leafActor);
11918
11919   Vector4 actualColor = leafActor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR);
11920   DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION);
11921
11922   END_TEST;
11923 }
11924
11925 int UtcDaliActorCalculateWorldColor02(void)
11926 {
11927   TestApplication application;
11928
11929   tet_infoline("Test that actor uses own color");
11930
11931   Actor rootActor   = Actor::New();
11932   Actor branchActor = Actor::New();
11933   Actor leafActor   = Actor::New();
11934
11935   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
11936   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
11937   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11938
11939   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11940   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11941   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11942
11943   rootActor[Actor::Property::COLOR]   = Color::WHITE;
11944   branchActor[Actor::Property::COLOR] = Vector4(1.0f, 1.0f, 0.5f, 0.8f);
11945   leafActor[Actor::Property::COLOR]   = Vector4(0.1f, 0.5f, 0.5f, 0.8f);
11946
11947   leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_OWN_COLOR;
11948
11949   application.GetScene().Add(rootActor);
11950   rootActor.Add(branchActor);
11951   branchActor.Add(leafActor);
11952
11953   application.SendNotification();
11954   application.Render(0);
11955
11956   Vector4 color = DevelActor::GetWorldColor(leafActor);
11957
11958   Vector4 actualColor = leafActor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR);
11959   DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION);
11960   DALI_TEST_EQUALS(color, Vector4(0.1f, 0.5f, 0.5f, 0.8f), 0.001f, TEST_LOCATION);
11961   END_TEST;
11962 }
11963
11964 int UtcDaliActorCalculateWorldColor03(void)
11965 {
11966   TestApplication application;
11967
11968   tet_infoline("Test that actor uses parent color");
11969
11970   Actor rootActor   = Actor::New();
11971   Actor branchActor = Actor::New();
11972   Actor leafActor   = Actor::New();
11973
11974   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
11975   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
11976   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11977
11978   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11979   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11980   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11981
11982   rootActor[Actor::Property::COLOR]   = Color::WHITE * 0.9f;
11983   branchActor[Actor::Property::COLOR] = Vector4(1.0f, 1.0f, 0.5f, 0.8f);
11984   leafActor[Actor::Property::COLOR]   = Vector4(0.1f, 0.5f, 0.5f, 0.8f);
11985
11986   leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_PARENT_COLOR;
11987
11988   application.GetScene().Add(rootActor);
11989   rootActor.Add(branchActor);
11990   branchActor.Add(leafActor);
11991
11992   application.SendNotification();
11993   application.Render(0);
11994
11995   Vector4 color = DevelActor::GetWorldColor(leafActor);
11996
11997   Vector4 actualColor = leafActor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR);
11998   DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION);
11999   DALI_TEST_EQUALS(color, Vector4(1.0f, 1.0f, 0.5f, 0.72f), 0.001f, TEST_LOCATION);
12000   END_TEST;
12001 }
12002
12003 int UtcDaliActorCalculateWorldColor04(void)
12004 {
12005   TestApplication application;
12006
12007   tet_infoline("Test that actor blends with parent color");
12008
12009   Actor rootActor   = Actor::New();
12010   Actor branchActor = Actor::New();
12011   Actor leafActor   = Actor::New();
12012
12013   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
12014   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
12015   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
12016
12017   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12018   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12019   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12020
12021   rootActor[Actor::Property::COLOR]   = Color::WHITE * 0.9f;
12022   branchActor[Actor::Property::COLOR] = Vector4(1.0f, 1.0f, 0.5f, 0.8f);
12023   leafActor[Actor::Property::COLOR]   = Vector4(0.1f, 0.5f, 0.5f, 0.8f);
12024
12025   leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_OWN_MULTIPLY_PARENT_COLOR;
12026
12027   application.GetScene().Add(rootActor);
12028   rootActor.Add(branchActor);
12029   branchActor.Add(leafActor);
12030
12031   application.SendNotification();
12032   application.Render(0);
12033
12034   Vector4 color = DevelActor::GetWorldColor(leafActor);
12035
12036   Vector4 actualColor = leafActor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR);
12037   DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION);
12038
12039   END_TEST;
12040 }