19e6de3f0a9d7098205338dd7f861dc640c88783
[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 UtcDaliActorRemoveRendererP3(void)
4498 {
4499   tet_infoline("Testing Actor::RemoveRenderer");
4500   TestApplication application;
4501
4502   Actor actor1 = Actor::New();
4503   Actor actor2 = Actor::New();
4504   Actor actor3 = Actor::New();
4505
4506   application.GetScene().Add(actor1);
4507   application.GetScene().Add(actor2);
4508   application.GetScene().Add(actor3);
4509
4510   // Make each actors size bigger than zero, so we can assuem that actor is rendered
4511   actor1.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
4512   actor2.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
4513   actor3.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
4514
4515   // Register some dummy property to seperate actor1 and actor2 in Render::Renderer
4516   actor1.RegisterProperty("dummy1", 1);
4517   actor2.RegisterProperty("dummy2", 2.0f);
4518   actor3.RegisterProperty("dummy3", Vector2(3.0f, 4.0f));
4519
4520   DALI_TEST_EQUALS(actor1.GetRendererCount(), 0u, TEST_LOCATION);
4521   DALI_TEST_EQUALS(actor2.GetRendererCount(), 0u, TEST_LOCATION);
4522   DALI_TEST_EQUALS(actor3.GetRendererCount(), 0u, TEST_LOCATION);
4523
4524   Geometry geometry = CreateQuadGeometry();
4525   Shader   shader   = CreateShader();
4526   Renderer renderer1 = Renderer::New(geometry, shader);
4527   Renderer renderer2 = Renderer::New(geometry, shader);
4528
4529   actor1.AddRenderer(renderer1);
4530   actor1.AddRenderer(renderer2);
4531   actor2.AddRenderer(renderer1);
4532   actor2.AddRenderer(renderer2);
4533   actor3.AddRenderer(renderer1);
4534   actor3.AddRenderer(renderer2);
4535   application.SendNotification();
4536   application.Render();
4537
4538   DALI_TEST_EQUALS(actor1.GetRendererCount(), 2u, TEST_LOCATION);
4539   DALI_TEST_EQUALS(actor1.GetRendererAt(0), renderer1, TEST_LOCATION);
4540   DALI_TEST_EQUALS(actor1.GetRendererAt(1), renderer2, TEST_LOCATION);
4541
4542   DALI_TEST_EQUALS(actor2.GetRendererCount(), 2u, TEST_LOCATION);
4543   DALI_TEST_EQUALS(actor2.GetRendererAt(0), renderer1, TEST_LOCATION);
4544   DALI_TEST_EQUALS(actor2.GetRendererAt(1), renderer2, TEST_LOCATION);
4545
4546   DALI_TEST_EQUALS(actor3.GetRendererCount(), 2u, TEST_LOCATION);
4547   DALI_TEST_EQUALS(actor3.GetRendererAt(0), renderer1, TEST_LOCATION);
4548   DALI_TEST_EQUALS(actor3.GetRendererAt(1), renderer2, TEST_LOCATION);
4549
4550   actor1.RemoveRenderer(0);
4551   actor2.RemoveRenderer(1);
4552   actor3.RemoveRenderer(0);
4553   application.SendNotification();
4554   application.Render();
4555
4556   DALI_TEST_EQUALS(actor1.GetRendererCount(), 1u, TEST_LOCATION);
4557   DALI_TEST_EQUALS(actor1.GetRendererAt(0), renderer2, TEST_LOCATION);
4558   DALI_TEST_EQUALS(actor2.GetRendererCount(), 1u, TEST_LOCATION);
4559   DALI_TEST_EQUALS(actor2.GetRendererAt(0), renderer1, TEST_LOCATION);
4560   DALI_TEST_EQUALS(actor3.GetRendererCount(), 1u, TEST_LOCATION);
4561   DALI_TEST_EQUALS(actor3.GetRendererAt(0), renderer2, TEST_LOCATION);
4562
4563   // Shut down whilst holding onto the renderer handle.
4564   END_TEST;
4565 }
4566
4567 int UtcDaliActorRemoveRendererN(void)
4568 {
4569   tet_infoline("Testing Actor::RemoveRenderer");
4570   TestApplication application;
4571
4572   Actor actor = Actor::New();
4573
4574   DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4575
4576   Geometry geometry = CreateQuadGeometry();
4577   Shader   shader   = CreateShader();
4578   Renderer renderer = Renderer::New(geometry, shader);
4579
4580   actor.AddRenderer(renderer);
4581   DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4582   DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4583
4584   actor.RemoveRenderer(10);
4585   DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4586   DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4587
4588   END_TEST;
4589 }
4590
4591 // Clipping test helper functions:
4592 Actor CreateActorWithContent(uint32_t width, uint32_t height)
4593 {
4594   Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
4595   Actor   actor = CreateRenderableActor(image);
4596
4597   // Setup dimensions and position so actor is not skipped by culling.
4598   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
4599   actor.SetProperty(Actor::Property::SIZE, Vector2(width, height));
4600   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4601   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4602
4603   return actor;
4604 }
4605
4606 Actor CreateActorWithContent16x16()
4607 {
4608   return CreateActorWithContent(16, 16);
4609 }
4610
4611 void GenerateTrace(TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace)
4612 {
4613   enabledDisableTrace.Reset();
4614   stencilTrace.Reset();
4615   enabledDisableTrace.Enable(true);
4616   stencilTrace.Enable(true);
4617
4618   application.SendNotification();
4619   application.Render();
4620
4621   enabledDisableTrace.Enable(false);
4622   stencilTrace.Enable(false);
4623 }
4624
4625 void CheckColorMask(TestGlAbstraction& glAbstraction, bool maskValue)
4626 {
4627   const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
4628
4629   DALI_TEST_EQUALS<bool>(colorMaskParams.red, maskValue, TEST_LOCATION);
4630   DALI_TEST_EQUALS<bool>(colorMaskParams.green, maskValue, TEST_LOCATION);
4631   DALI_TEST_EQUALS<bool>(colorMaskParams.blue, maskValue, TEST_LOCATION);
4632
4633   // @todo only test alpha if the framebuffer has an alpha channel
4634   //DALI_TEST_EQUALS<bool>(colorMaskParams.alpha, maskValue, TEST_LOCATION);
4635 }
4636
4637 int UtcDaliActorPropertyClippingP(void)
4638 {
4639   // This test checks the clippingMode property.
4640   tet_infoline("Testing Actor::Property::ClippingMode: P");
4641   TestApplication application;
4642
4643   Actor actor = Actor::New();
4644
4645   // Check default clippingEnabled value.
4646   Property::Value getValue(actor.GetProperty(Actor::Property::CLIPPING_MODE));
4647
4648   int  value          = 0;
4649   bool getValueResult = getValue.Get(value);
4650   DALI_TEST_CHECK(getValueResult);
4651
4652   if(getValueResult)
4653   {
4654     DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4655   }
4656
4657   // Check setting the property to the stencil mode.
4658   actor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4659
4660   // Check the new value was set.
4661   getValue       = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4662   getValueResult = getValue.Get(value);
4663   DALI_TEST_CHECK(getValueResult);
4664
4665   if(getValueResult)
4666   {
4667     DALI_TEST_EQUALS<int>(value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION);
4668   }
4669
4670   // Check setting the property to the scissor mode.
4671   actor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4672
4673   // Check the new value was set.
4674   getValue       = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4675   getValueResult = getValue.Get(value);
4676   DALI_TEST_CHECK(getValueResult);
4677
4678   if(getValueResult)
4679   {
4680     DALI_TEST_EQUALS<int>(value, ClippingMode::CLIP_TO_BOUNDING_BOX, TEST_LOCATION);
4681   }
4682   END_TEST;
4683 }
4684
4685 int UtcDaliActorPropertyClippingN(void)
4686 {
4687   // Negative test case for Clipping.
4688   tet_infoline("Testing Actor::Property::ClippingMode: N");
4689   TestApplication application;
4690
4691   Actor actor = Actor::New();
4692
4693   // Check default clippingEnabled value.
4694   Property::Value getValue(actor.GetProperty(Actor::Property::CLIPPING_MODE));
4695
4696   int  value          = 0;
4697   bool getValueResult = getValue.Get(value);
4698   DALI_TEST_CHECK(getValueResult);
4699
4700   if(getValueResult)
4701   {
4702     DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4703   }
4704
4705   // Check setting an invalid property value won't change the current property value.
4706   actor.SetProperty(Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY");
4707
4708   getValue       = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4709   getValueResult = getValue.Get(value);
4710   DALI_TEST_CHECK(getValueResult);
4711
4712   if(getValueResult)
4713   {
4714     DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4715   }
4716
4717   END_TEST;
4718 }
4719
4720 int UtcDaliActorPropertyClippingActor(void)
4721 {
4722   // This test checks that an actor is correctly setup for clipping.
4723   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor");
4724   TestApplication application;
4725
4726   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4727   TraceCallStack&    stencilTrace        = glAbstraction.GetStencilFunctionTrace();
4728   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4729   size_t             startIndex          = 0u;
4730
4731   // Create a clipping actor.
4732   Actor actorDepth1Clip = CreateActorWithContent16x16();
4733   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4734   application.GetScene().Add(actorDepth1Clip);
4735
4736   // Gather the call trace.
4737   GenerateTrace(application, enabledDisableTrace, stencilTrace);
4738
4739   // Check we are writing to the color buffer.
4740   CheckColorMask(glAbstraction, true);
4741
4742   // Check the stencil buffer was enabled.
4743   std::ostringstream oss;
4744   oss << std::hex << GL_STENCIL_TEST;
4745   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
4746
4747   // Check the stencil buffer was cleared.
4748   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4749
4750   // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4751   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4752   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));
4753   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4754
4755   END_TEST;
4756 }
4757
4758 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
4759 {
4760   // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
4761   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor enable and then disable");
4762   TestApplication application;
4763
4764   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4765   TraceCallStack&    stencilTrace        = glAbstraction.GetStencilFunctionTrace();
4766   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4767   size_t             startIndex          = 0u;
4768
4769   // Create a clipping actor.
4770   Actor actorDepth1Clip = CreateActorWithContent16x16();
4771   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4772   application.GetScene().Add(actorDepth1Clip);
4773
4774   // Gather the call trace.
4775   GenerateTrace(application, enabledDisableTrace, stencilTrace);
4776
4777   // Check we are writing to the color buffer.
4778   CheckColorMask(glAbstraction, true);
4779
4780   // Check the stencil buffer was enabled.
4781   std::ostringstream oss;
4782   oss << std::hex << GL_STENCIL_TEST;
4783   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
4784
4785   // Check the stencil buffer was cleared.
4786   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4787
4788   // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4789   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4790   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));
4791   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4792
4793   // Now disable the clipping
4794   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED);
4795
4796   // Gather the call trace.
4797   GenerateTrace(application, enabledDisableTrace, stencilTrace);
4798
4799   // Check the stencil buffer was disabled.
4800   std::ostringstream stencil;
4801   stencil << std::hex << GL_STENCIL_TEST;
4802   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Disable", stencil.str()));
4803
4804   // Ensure all values in stencil-mask are set to 1.
4805   startIndex = 0u;
4806   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "255", startIndex));
4807
4808   END_TEST;
4809 }
4810
4811 int UtcDaliActorPropertyClippingNestedChildren(void)
4812 {
4813   // This test checks that a hierarchy of actors are clipped correctly by
4814   // writing to and reading from the correct bit-planes of the stencil buffer.
4815   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN nested children");
4816   TestApplication    application;
4817   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4818   TraceCallStack&    stencilTrace        = glAbstraction.GetStencilFunctionTrace();
4819   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4820
4821   // Create a clipping actor.
4822   Actor actorDepth1Clip = CreateActorWithContent16x16();
4823   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4824   application.GetScene().Add(actorDepth1Clip);
4825
4826   // Create a child actor.
4827   Actor childDepth2 = CreateActorWithContent16x16();
4828   actorDepth1Clip.Add(childDepth2);
4829
4830   // Create another clipping actor.
4831   Actor childDepth2Clip = CreateActorWithContent16x16();
4832   childDepth2Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4833   childDepth2.Add(childDepth2Clip);
4834
4835   // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
4836   // This tests the sort algorithm.
4837   Actor childDepth3 = CreateActorWithContent16x16();
4838   childDepth2Clip.Add(childDepth3);
4839   Actor childDepth4 = CreateActorWithContent16x16();
4840   childDepth3.Add(childDepth4);
4841
4842   // Gather the call trace.
4843   GenerateTrace(application, enabledDisableTrace, stencilTrace);
4844
4845   // Check we are writing to the color buffer.
4846   CheckColorMask(glAbstraction, true);
4847
4848   // Check the stencil buffer was enabled.
4849   std::ostringstream oss;
4850   oss << std::hex << GL_STENCIL_TEST;
4851   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
4852
4853   // Perform the test twice, once for 2D layer, and once for 3D.
4854   for(unsigned int i = 0u; i < 2u; ++i)
4855   {
4856     size_t startIndex = 0u;
4857
4858     // Check the stencil buffer was cleared.
4859     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4860
4861     // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4862     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex));      // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4863     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));              // Write to the first bit-plane
4864     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4865
4866     // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
4867     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 1", startIndex));      // 514 is GL_EQUAL
4868     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7680, 7680", startIndex)); // GL_KEEP, GL_KEEP, GL_KEEP
4869
4870     // Check we are set up to write to the second bitplane of the stencil buffer (only).
4871     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 3, 1", startIndex));      // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4872     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "3", startIndex));              // Write to second (and previous) bit-planes
4873     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4874
4875     // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4876     // (Both must be set to pass the check).
4877     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 3, 3", startIndex));      // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4878     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7680, 7680", startIndex)); // GL_KEEP, GL_KEEP, GL_KEEP
4879
4880     // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4881     if(i == 0u)
4882     {
4883       application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D);
4884       GenerateTrace(application, enabledDisableTrace, stencilTrace);
4885     }
4886   }
4887
4888   END_TEST;
4889 }
4890
4891 int UtcDaliActorPropertyClippingActorDrawOrder(void)
4892 {
4893   // This test checks that a hierarchy of actors are drawn in the correct order when clipping is enabled.
4894   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN draw order");
4895   TestApplication    application;
4896   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4897   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4898
4899   /* We create a small tree of actors as follows:
4900
4901                            A
4902                           / \
4903      Clipping enabled -> B   D
4904                          |   |
4905                          C   E
4906
4907      The correct draw order is "ABCDE" (the same as if clipping was not enabled).
4908   */
4909   Actor actors[5];
4910   for(int i = 0; i < 5; ++i)
4911   {
4912     Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
4913     Actor   actor = CreateRenderableActor(image);
4914
4915     // Setup dimensions and position so actor is not skipped by culling.
4916     actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
4917     actor.SetProperty(Actor::Property::SIZE, Vector2(16.0f, 16.0f));
4918
4919     if(i == 0)
4920     {
4921       actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4922     }
4923     else
4924     {
4925       float b = i > 2 ? 1.0f : -1.0f;
4926       actor.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0.5 + (0.2f * b), 0.8f, 0.8f));
4927     }
4928
4929     actors[i] = actor;
4930   }
4931
4932   // Enable clipping on the actor at the top of the left branch.
4933   actors[1].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4934
4935   // Build the scene graph.
4936   application.GetScene().Add(actors[0]);
4937
4938   // Left branch:
4939   actors[0].Add(actors[1]);
4940   actors[1].Add(actors[2]);
4941
4942   // Right branch:
4943   actors[0].Add(actors[3]);
4944   actors[3].Add(actors[4]);
4945
4946   // Gather the call trace.
4947   enabledDisableTrace.Reset();
4948   enabledDisableTrace.Enable(true);
4949   application.SendNotification();
4950   application.Render();
4951   enabledDisableTrace.Enable(false);
4952
4953   /* Check stencil is enabled and disabled again (as right-hand branch of tree is drawn).
4954
4955      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
4956            Incorrect enable call trace:  StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960
4957   */
4958   size_t             startIndex = 0u;
4959   std::ostringstream blend;
4960   blend << std::hex << GL_BLEND;
4961   std::ostringstream stencil;
4962   stencil << std::hex << GL_STENCIL_TEST;
4963
4964   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", blend.str(), startIndex));
4965   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", stencil.str(), startIndex));
4966   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", stencil.str(), startIndex));
4967
4968   // Swap the clipping actor from top of left branch to top of right branch.
4969   actors[1].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED);
4970   actors[3].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4971
4972   // Gather the call trace.
4973   enabledDisableTrace.Reset();
4974   enabledDisableTrace.Enable(true);
4975   application.SendNotification();
4976   application.Render();
4977   enabledDisableTrace.Enable(false);
4978
4979   // Check stencil is enabled but NOT disabled again (as right-hand branch of tree is drawn).
4980   // This proves the draw order has remained the same.
4981   startIndex = 0u;
4982   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", stencil.str(), startIndex));
4983   DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", stencil.str(), startIndex));
4984
4985   END_TEST;
4986 }
4987
4988 int UtcDaliActorPropertyScissorClippingActor01(void)
4989 {
4990   // This test checks that an actor is correctly setup for clipping.
4991   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor");
4992   TestApplication application;
4993
4994   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4995   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
4996   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4997
4998   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4999   const Vector2 imageSize(16.0f, 16.0f);
5000
5001   // Create a clipping actor.
5002   Actor clippingActorA = CreateActorWithContent16x16();
5003   // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
5004   // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
5005   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
5006   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
5007   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5008   application.GetScene().Add(clippingActorA);
5009
5010   // Gather the call trace.
5011   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5012
5013   // Check we are writing to the color buffer.
5014   CheckColorMask(glAbstraction, true);
5015
5016   // Check scissor test was enabled.
5017
5018   std::ostringstream scissor;
5019   scissor << std::hex << GL_SCISSOR_TEST;
5020   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5021
5022   // Check the scissor was set, and the coordinates are correct.
5023   std::stringstream compareParametersString;
5024   compareParametersString << "0, 0, " << imageSize.x << ", " << imageSize.y;
5025   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
5026
5027   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
5028   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_RIGHT);
5029
5030   // Gather the call trace.
5031   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5032
5033   // Check the scissor was set, and the coordinates are correct.
5034   compareParametersString.str(std::string());
5035   compareParametersString.clear();
5036   compareParametersString << (stageSize.x - imageSize.x) << ", " << (stageSize.y - imageSize.y) << ", " << imageSize.x << ", " << imageSize.y;
5037   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 464, 784, 16, 16
5038
5039   END_TEST;
5040 }
5041
5042 int UtcDaliActorPropertyScissorClippingActor02(void)
5043 {
5044   // This test checks that an actor is correctly setup for clipping.
5045   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor with a transparent renderer");
5046   TestApplication application;
5047
5048   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
5049   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
5050   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5051
5052   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
5053   const Vector2 actorSize(16.0f, 16.0f);
5054
5055   // Create a clipping actor.
5056   Actor clippingActorA                  = CreateRenderableActor();
5057   clippingActorA[Actor::Property::SIZE] = actorSize;
5058
5059   Renderer renderer = clippingActorA.GetRendererAt(0);
5060   DALI_TEST_CHECK(renderer);
5061
5062   // Make Renderer opacity 0.
5063   renderer[DevelRenderer::Property::OPACITY] = 0.0f;
5064
5065   // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
5066   // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
5067   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
5068   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
5069   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5070   application.GetScene().Add(clippingActorA);
5071
5072   // Gather the call trace.
5073   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5074
5075   // Check we are writing to the color buffer.
5076   CheckColorMask(glAbstraction, true);
5077
5078   // Check scissor test was enabled.
5079
5080   std::ostringstream scissor;
5081   scissor << std::hex << GL_SCISSOR_TEST;
5082   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5083
5084   // Check the scissor was set, and the coordinates are correct.
5085   std::stringstream compareParametersString;
5086   compareParametersString << "0, 0, " << actorSize.x << ", " << actorSize.y;
5087   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
5088
5089   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
5090   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_RIGHT);
5091
5092   // Gather the call trace.
5093   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5094
5095   // Check the scissor was set, and the coordinates are correct.
5096   compareParametersString.str(std::string());
5097   compareParametersString.clear();
5098   compareParametersString << (stageSize.x - actorSize.x) << ", " << (stageSize.y - actorSize.y) << ", " << actorSize.x << ", " << actorSize.y;
5099   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 464, 784, 16, 16
5100
5101   END_TEST;
5102 }
5103
5104 int UtcDaliActorPropertyScissorClippingActorSiblings(void)
5105 {
5106   // This test checks that an actor is correctly setup for clipping.
5107   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actors which are siblings");
5108   TestApplication application;
5109
5110   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
5111   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
5112   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5113
5114   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
5115   const Vector2 sizeA{stageSize.width, stageSize.height * 0.25f};
5116   const Vector2 sizeB{stageSize.width, stageSize.height * 0.05f};
5117
5118   // Create a clipping actors.
5119   Actor clippingActorA = CreateActorWithContent(sizeA.width, sizeA.height);
5120   Actor clippingActorB = CreateActorWithContent(sizeB.width, sizeB.height);
5121
5122   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5123   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5124   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5125
5126   clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5127   clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5128   clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5129
5130   clippingActorA.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -200.0f, 0.0f));
5131   clippingActorB.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
5132
5133   application.GetScene().Add(clippingActorA);
5134   application.GetScene().Add(clippingActorB);
5135
5136   // Gather the call trace.
5137   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5138
5139   // Check we are writing to the color buffer.
5140   CheckColorMask(glAbstraction, true);
5141
5142   // Check scissor test was enabled.
5143   std::ostringstream scissor;
5144   scissor << std::hex << GL_SCISSOR_TEST;
5145   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5146
5147   // Check the scissor was set, and the coordinates are correct.
5148   std::stringstream compareParametersString;
5149
5150   std::string clipA("0, 500, 480, 200");
5151   std::string clipB("0, 380, 480, 40");
5152
5153   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipA));
5154   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipB));
5155
5156   END_TEST;
5157 }
5158
5159 int UtcDaliActorPropertyScissorClippingActorNested01(void)
5160 {
5161   // This test checks that an actor is correctly setup for clipping.
5162   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested");
5163   TestApplication application;
5164
5165   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
5166   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
5167   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5168
5169   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
5170   const Vector2 imageSize(16.0f, 16.0f);
5171
5172   /* Create a nest of 2 scissors to test nesting (intersecting clips).
5173
5174      A is drawn first - with scissor clipping on
5175      B is drawn second - also with scissor clipping on
5176      C is the generated clipping region, the intersection ( A ∩ B )
5177
5178            ┏━━━━━━━┓                   ┌───────┐
5179            ┃     B ┃                   │     B │
5180        ┌───╂┄┄┄┐   ┃               ┌┄┄┄╆━━━┓   │
5181        │   ┃   ┊   ┃     ━━━━━>    ┊   ┃ C ┃   │
5182        │   ┗━━━┿━━━┛               ┊   ┗━━━╃───┘
5183        │ A     │                   ┊ A     ┊
5184        └───────┘                   └┄┄┄┄┄┄┄┘
5185
5186      We then reposition B around each corner of A to test the 4 overlap combinations (thus testing intersecting works correctly).
5187   */
5188
5189   // Create a clipping actor.
5190   Actor clippingActorA = CreateActorWithContent16x16();
5191   // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
5192   // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
5193   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5194   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5195   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5196   application.GetScene().Add(clippingActorA);
5197
5198   // Create a child clipping actor.
5199   Actor clippingActorB = CreateActorWithContent16x16();
5200   clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5201   clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5202   clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5203   clippingActorA.Add(clippingActorB);
5204
5205   // positionModifiers is an array of positions to position B around.
5206   // expect is an array of expected scissor clip coordinate results.
5207   const Vector2 positionModifiers[4] = {Vector2(1.0f, 1.0f), Vector2(-1.0f, 1.0f), Vector2(-1.0f, -1.0f), Vector2(1.0f, -1.0f)};
5208   const Vector4 expect[4]            = {Vector4(240, 392, 8, 8), Vector4(232, 392, 8, 8), Vector4(232, 400, 8, 8), Vector4(240, 400, 8, 8)};
5209
5210   // Loop through each overlap combination.
5211   for(unsigned int test = 0u; test < 4u; ++test)
5212   {
5213     // Position the child clipping actor so it intersects with the 1st clipping actor. This changes each loop.
5214     const Vector2 position = (imageSize / 2.0f) * positionModifiers[test];
5215     clippingActorB.SetProperty(Actor::Property::POSITION, Vector2(position.x, position.y));
5216
5217     // Gather the call trace.
5218     GenerateTrace(application, enabledDisableTrace, scissorTrace);
5219
5220     // Check we are writing to the color buffer.
5221     CheckColorMask(glAbstraction, true);
5222
5223     // Check scissor test was enabled.
5224     std::ostringstream scissor;
5225     scissor << std::hex << GL_SCISSOR_TEST;
5226     DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5227
5228     // Check the scissor was set, and the coordinates are correct.
5229     const Vector4&    expectResults(expect[test]);
5230     std::stringstream compareParametersString;
5231     compareParametersString << expectResults.x << ", " << expectResults.y << ", " << expectResults.z << ", " << expectResults.w;
5232     DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with the expected result
5233   }
5234
5235   END_TEST;
5236 }
5237
5238 int UtcDaliActorPropertyScissorClippingActorNested02(void)
5239 {
5240   // This test checks that an actor is correctly setup for clipping.
5241   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested");
5242   TestApplication application;
5243
5244   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
5245   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
5246   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5247
5248   /* Create a nest of 2 scissors and siblings of the parent.
5249
5250             stage
5251               |
5252         ┌─────┐─────┐
5253         A     C     D
5254         |           |
5255         B           E
5256   */
5257
5258   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
5259   const Vector2 sizeA{stageSize.width, stageSize.height * 0.25f};
5260   const Vector2 sizeB{stageSize.width, stageSize.height * 0.05f};
5261   const Vector2 sizeC{stageSize.width, stageSize.height * 0.25f};
5262   const Vector2 sizeD{stageSize.width, stageSize.height * 0.25f};
5263   const Vector2 sizeE{stageSize.width, stageSize.height * 0.05f};
5264
5265   // Create a clipping actors.
5266   Actor clippingActorA = CreateActorWithContent(sizeA.width, sizeA.height);
5267   Actor clippingActorB = CreateActorWithContent(sizeB.width, sizeB.height);
5268   Actor clippingActorC = CreateActorWithContent(sizeC.width, sizeC.height);
5269   Actor clippingActorD = CreateActorWithContent(sizeD.width, sizeD.height);
5270   Actor clippingActorE = CreateActorWithContent(sizeE.width, sizeE.height);
5271
5272   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5273   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5274   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5275
5276   clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5277   clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5278   clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5279
5280   clippingActorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5281   clippingActorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5282   clippingActorC.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5283
5284   clippingActorD.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5285   clippingActorD.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5286   clippingActorD.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5287
5288   clippingActorE.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5289   clippingActorE.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5290
5291   clippingActorA.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -200.0f, 0.0f));
5292   clippingActorB.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
5293   clippingActorC.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 100.0f, 0.0f));
5294   clippingActorD.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
5295   clippingActorE.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
5296
5297   application.GetScene().Add(clippingActorA);
5298   clippingActorA.Add(clippingActorB);
5299   application.GetScene().Add(clippingActorC);
5300   application.GetScene().Add(clippingActorD);
5301   clippingActorD.Add(clippingActorE);
5302
5303   // Gather the call trace.
5304   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5305
5306   // Check we are writing to the color buffer.
5307   CheckColorMask(glAbstraction, true);
5308
5309   // Check scissor test was enabled.
5310   std::ostringstream scissor;
5311   scissor << std::hex << GL_SCISSOR_TEST;
5312   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5313
5314   // Check the scissor was set, and the coordinates are correct.
5315   std::string clipA("0, 500, 480, 200");
5316   std::string clipB("0, 580, 480, 40");
5317   std::string clipC("0, 200, 480, 200");
5318   std::string clipD("0, 300, 480, 200");
5319
5320   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipA));
5321   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipB));
5322   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipC));
5323   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipD));
5324   DALI_TEST_EQUALS(scissorTrace.CountMethod("Scissor"), 4, TEST_LOCATION); // Scissor rect should not be changed in clippingActorE case. So count should be 4.
5325
5326   END_TEST;
5327 }
5328
5329 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
5330 {
5331   // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
5332   tet_infoline("Testing Actor::Property::CLIPPING_MODE actor with renderer override");
5333   TestApplication application;
5334
5335   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
5336   TraceCallStack&    stencilTrace        = glAbstraction.GetStencilFunctionTrace();
5337   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5338
5339   // Create a clipping actor.
5340   Actor actorDepth1Clip = CreateActorWithContent16x16();
5341   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
5342   application.GetScene().Add(actorDepth1Clip);
5343
5344   // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
5345   actorDepth1Clip.GetRendererAt(0).SetProperty(Renderer::Property::RENDER_MODE, RenderMode::COLOR);
5346
5347   // Gather the call trace.
5348   GenerateTrace(application, enabledDisableTrace, stencilTrace);
5349
5350   // Check we are writing to the color buffer.
5351   CheckColorMask(glAbstraction, true);
5352
5353   // Check the stencil buffer was not enabled.
5354   std::ostringstream stencil;
5355   stencil << std::hex << GL_STENCIL_TEST;
5356   DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", stencil.str()));
5357
5358   // Check stencil functions are not called.
5359   DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilFunc"));
5360   DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilOp"));
5361
5362   // Check that scissor clipping is overriden by the renderer properties.
5363   TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
5364
5365   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5366
5367   // Gather the call trace.
5368   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5369
5370   // Check the stencil buffer was not enabled.
5371   std::ostringstream scissor;
5372   scissor << std::hex << GL_SCISSOR_TEST;
5373   DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5374
5375   DALI_TEST_CHECK(!scissorTrace.FindMethod("StencilFunc"));
5376
5377   END_TEST;
5378 }
5379
5380 int UtcDaliActorPropertyClippingActorCulled(void)
5381 {
5382   // This test checks that child actors are clipped by an culled parent actor.
5383   tet_infoline("Testing child actors are clipped by an culled parent actor");
5384   TestApplication application;
5385
5386   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
5387   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
5388   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5389
5390   const Vector2 actorSize(160.0f, 160.0f);
5391
5392   // Create a clipping actor.
5393   Actor clippingActorA                  = CreateRenderableActor();
5394   clippingActorA[Actor::Property::SIZE] = actorSize;
5395
5396   // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
5397   // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
5398   clippingActorA[Actor::Property::PARENT_ORIGIN] = ParentOrigin::BOTTOM_LEFT;
5399   clippingActorA[Actor::Property::ANCHOR_POINT]  = AnchorPoint::BOTTOM_LEFT;
5400   clippingActorA[Actor::Property::CLIPPING_MODE] = ClippingMode::CLIP_TO_BOUNDING_BOX;
5401   application.GetScene().Add(clippingActorA);
5402
5403   // Create a child actor
5404   Actor childActor                              = CreateRenderableActor();
5405   childActor[Actor::Property::PARENT_ORIGIN]    = ParentOrigin::BOTTOM_LEFT;
5406   childActor[Actor::Property::ANCHOR_POINT]     = AnchorPoint::BOTTOM_LEFT;
5407   childActor[Actor::Property::SIZE]             = Vector2(50.0f, 50.0f);
5408   childActor[Actor::Property::INHERIT_POSITION] = false;
5409
5410   // Gather the call trace.
5411   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5412
5413   // Check scissor test was enabled.
5414   std::ostringstream scissor;
5415   scissor << std::hex << GL_SCISSOR_TEST;
5416   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5417
5418   // Check the scissor was set, and the coordinates are correct.
5419   std::stringstream compareParametersString;
5420   compareParametersString << "0, 0, " << actorSize.x << ", " << actorSize.y;
5421   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
5422
5423   // Move the clipping actor out of screen
5424   clippingActorA[Actor::Property::POSITION] = Vector2(2000.0f, 2000.0f);
5425
5426   // Gather the call trace.
5427   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5428
5429   // Check the scissor was set, and the coordinates are correct.
5430   compareParametersString.str(std::string());
5431   compareParametersString.clear();
5432   compareParametersString << 2000 << ", " << 0 << ", " << 0 << ", " << 0;
5433   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Clipping area should be empty.
5434
5435   END_TEST;
5436 }
5437
5438 int UtcDaliGetPropertyN(void)
5439 {
5440   tet_infoline("Testing Actor::GetProperty returns a non valid value if property index is out of range");
5441   TestApplication application;
5442
5443   Actor actor = Actor::New();
5444
5445   unsigned int propertyCount = actor.GetPropertyCount();
5446   DALI_TEST_EQUALS(actor.GetProperty(Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION);
5447   END_TEST;
5448 }
5449
5450 int UtcDaliActorRaiseLower(void)
5451 {
5452   tet_infoline("UtcDaliActor Raise and Lower test\n");
5453
5454   TestApplication application;
5455
5456   Debug::Filter::SetGlobalLogLevel(Debug::Verbose);
5457
5458   Integration::Scene stage(application.GetScene());
5459
5460   Actor actorA = Actor::New();
5461   Actor actorB = Actor::New();
5462   Actor actorC = Actor::New();
5463
5464   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5465   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5466
5467   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5468   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5469
5470   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5471   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5472
5473   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5474   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5475
5476   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5477   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5478
5479   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5480   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5481
5482   stage.Add(actorA);
5483   stage.Add(actorB);
5484   stage.Add(actorC);
5485
5486   ResetTouchCallbacks();
5487
5488   application.SendNotification();
5489   application.Render();
5490
5491   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5492   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5493   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5494
5495   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5496   // Only top actor will get touched.
5497   actorA.TouchedSignal().Connect(TestTouchCallback);
5498   actorB.TouchedSignal().Connect(TestTouchCallback2);
5499   actorC.TouchedSignal().Connect(TestTouchCallback3);
5500
5501   // Connect ChildOrderChangedSignal
5502   bool                     orderChangedSignal(false);
5503   Actor                    orderChangedActor;
5504   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5505   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5506
5507   Dali::Integration::Point point;
5508   point.SetDeviceId(1);
5509   point.SetState(PointState::DOWN);
5510   point.SetScreenPosition(Vector2(10.f, 10.f));
5511   Dali::Integration::TouchEvent touchEvent;
5512   touchEvent.AddPoint(point);
5513
5514   application.ProcessEvent(touchEvent);
5515
5516   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5517   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5518   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5519
5520   ResetTouchCallbacks();
5521
5522   tet_printf("Testing Raising of Actor\n");
5523
5524   int preActorOrder(0);
5525   int postActorOrder(0);
5526
5527   Property::Value value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5528   value.Get(preActorOrder);
5529
5530   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5531   actorB.Raise();
5532   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5533   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5534
5535   // Ensure sort order is calculated before next touch event
5536   application.SendNotification();
5537
5538   value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5539   value.Get(postActorOrder);
5540
5541   tet_printf("Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder);
5542
5543   application.ProcessEvent(touchEvent);
5544
5545   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5546   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5547   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5548
5549   ResetTouchCallbacks();
5550
5551   tet_printf("Testing Lowering of Actor\n");
5552
5553   value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5554   value.Get(preActorOrder);
5555
5556   orderChangedSignal = false;
5557
5558   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5559   actorB.Lower();
5560   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5561   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5562
5563   application.SendNotification(); // ensure sort order calculated before next touch event
5564
5565   value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5566   value.Get(postActorOrder);
5567
5568   tet_printf("Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder);
5569
5570   application.ProcessEvent(touchEvent);
5571
5572   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5573   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5574   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5575
5576   ResetTouchCallbacks();
5577
5578   Debug::Filter::SetGlobalLogLevel(Debug::NoLogging);
5579
5580   END_TEST;
5581 }
5582
5583 int UtcDaliActorRaiseToTopLowerToBottom(void)
5584 {
5585   tet_infoline("UtcDaliActorRaiseToTop and LowerToBottom test \n");
5586
5587   TestApplication application;
5588
5589   Integration::Scene stage(application.GetScene());
5590
5591   Actor actorA = Actor::New();
5592   Actor actorB = Actor::New();
5593   Actor actorC = Actor::New();
5594
5595   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5596   // enables checking of which actor the uniform is assigned too
5597   Shader shaderA = CreateShader();
5598   shaderA.RegisterProperty("uRendererColor", 1.f);
5599
5600   Shader shaderB = CreateShader();
5601   shaderB.RegisterProperty("uRendererColor", 2.f);
5602
5603   Shader shaderC = CreateShader();
5604   shaderC.RegisterProperty("uRendererColor", 3.f);
5605
5606   Geometry geometry = CreateQuadGeometry();
5607
5608   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5609   Renderer rendererA = Renderer::New(geometry, shaderA);
5610   actorA.AddRenderer(rendererA);
5611
5612   Renderer rendererB = Renderer::New(geometry, shaderB);
5613   actorB.AddRenderer(rendererB);
5614
5615   Renderer rendererC = Renderer::New(geometry, shaderC);
5616   actorC.AddRenderer(rendererC);
5617
5618   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5619   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5620
5621   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5622   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5623
5624   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5625   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5626
5627   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5628   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5629
5630   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5631   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5632
5633   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5634   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5635
5636   stage.Add(actorA);
5637   stage.Add(actorB);
5638   stage.Add(actorC);
5639
5640   ResetTouchCallbacks();
5641
5642   // Connect ChildOrderChangedSignal
5643   bool                     orderChangedSignal(false);
5644   Actor                    orderChangedActor;
5645   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5646   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5647
5648   // Set up gl abstraction trace so can query the set uniform order
5649   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5650   glAbstraction.EnableSetUniformCallTrace(true);
5651   glAbstraction.ResetSetUniformCallStack();
5652
5653   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5654
5655   application.SendNotification();
5656   application.Render();
5657
5658   tet_printf("Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str());
5659
5660   // Test order of uniforms in stack
5661   int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5662   int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5663   int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5664
5665   bool CBA = (indexC > indexB) && (indexB > indexA);
5666
5667   DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
5668
5669   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5670   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5671   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5672
5673   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5674   // Only top actor will get touched.
5675   actorA.TouchedSignal().Connect(TestTouchCallback);
5676   actorB.TouchedSignal().Connect(TestTouchCallback2);
5677   actorC.TouchedSignal().Connect(TestTouchCallback3);
5678
5679   Dali::Integration::Point point;
5680   point.SetDeviceId(1);
5681   point.SetState(PointState::DOWN);
5682   point.SetScreenPosition(Vector2(10.f, 10.f));
5683   Dali::Integration::TouchEvent touchEvent;
5684   touchEvent.AddPoint(point);
5685
5686   application.ProcessEvent(touchEvent);
5687
5688   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5689   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5690   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5691
5692   ResetTouchCallbacks();
5693
5694   tet_printf("RaiseToTop ActorA\n");
5695
5696   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5697   actorA.RaiseToTop();
5698   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5699   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5700
5701   application.SendNotification(); // ensure sorting order is calculated before next touch event
5702
5703   application.ProcessEvent(touchEvent);
5704
5705   glSetUniformStack.Reset();
5706
5707   application.SendNotification();
5708   application.Render();
5709
5710   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5711
5712   // Test order of uniforms in stack
5713   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5714   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5715   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5716
5717   tet_infoline("Testing A above C and B at bottom\n");
5718   bool ACB = (indexA > indexC) && (indexC > indexB);
5719
5720   DALI_TEST_EQUALS(ACB, true, TEST_LOCATION);
5721
5722   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5723   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5724   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5725
5726   ResetTouchCallbacks();
5727
5728   tet_printf("RaiseToTop ActorB\n");
5729
5730   orderChangedSignal = false;
5731
5732   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5733   actorB.RaiseToTop();
5734   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5735   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5736
5737   application.SendNotification(); // Ensure sort order is calculated before next touch event
5738
5739   application.ProcessEvent(touchEvent);
5740
5741   glSetUniformStack.Reset();
5742
5743   application.SendNotification();
5744   application.Render();
5745
5746   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5747
5748   // Test order of uniforms in stack
5749   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5750   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5751   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5752
5753   tet_infoline("Testing B above A and C at bottom\n");
5754   bool BAC = (indexB > indexA) && (indexA > indexC);
5755
5756   DALI_TEST_EQUALS(BAC, true, TEST_LOCATION);
5757
5758   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5759   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5760   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5761
5762   ResetTouchCallbacks();
5763
5764   tet_printf("LowerToBottom ActorA then ActorB leaving Actor C at Top\n");
5765
5766   orderChangedSignal = false;
5767
5768   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5769   actorA.LowerToBottom();
5770   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5771   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5772
5773   application.SendNotification();
5774   application.Render();
5775
5776   orderChangedSignal = false;
5777
5778   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5779   actorB.LowerToBottom();
5780   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5781   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5782
5783   application.SendNotification();
5784   application.Render();
5785
5786   application.ProcessEvent(touchEvent);
5787
5788   glSetUniformStack.Reset();
5789
5790   application.SendNotification();
5791   application.Render();
5792
5793   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5794
5795   // Test order of uniforms in stack
5796   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5797   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5798   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5799
5800   tet_infoline("Testing C above A and B at bottom\n");
5801   bool CAB = (indexC > indexA) && (indexA > indexB);
5802
5803   DALI_TEST_EQUALS(CAB, true, TEST_LOCATION);
5804
5805   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5806   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5807   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5808
5809   ResetTouchCallbacks();
5810
5811   END_TEST;
5812 }
5813
5814 int UtcDaliActorRaiseAbove(void)
5815 {
5816   tet_infoline("UtcDaliActor RaiseToAbove test \n");
5817
5818   TestApplication application;
5819
5820   Integration::Scene stage(application.GetScene());
5821
5822   Actor actorA = Actor::New();
5823   Actor actorB = Actor::New();
5824   Actor actorC = Actor::New();
5825
5826   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5827   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5828
5829   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5830   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5831
5832   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5833   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5834
5835   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5836   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5837
5838   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5839   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5840
5841   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5842   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5843
5844   stage.Add(actorA);
5845   stage.Add(actorB);
5846   stage.Add(actorC);
5847
5848   ResetTouchCallbacks();
5849
5850   application.SendNotification();
5851   application.Render();
5852
5853   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5854   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5855   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5856
5857   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5858   // Only top actor will get touched.
5859   actorA.TouchedSignal().Connect(TestTouchCallback);
5860   actorB.TouchedSignal().Connect(TestTouchCallback2);
5861   actorC.TouchedSignal().Connect(TestTouchCallback3);
5862
5863   bool                     orderChangedSignal(false);
5864   Actor                    orderChangedActor;
5865   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5866   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5867
5868   Dali::Integration::Point point;
5869   point.SetDeviceId(1);
5870   point.SetState(PointState::DOWN);
5871   point.SetScreenPosition(Vector2(10.f, 10.f));
5872   Dali::Integration::TouchEvent touchEvent;
5873   touchEvent.AddPoint(point);
5874
5875   application.ProcessEvent(touchEvent);
5876
5877   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5878   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5879   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5880
5881   ResetTouchCallbacks();
5882
5883   tet_printf("Raise actor B Above Actor C\n");
5884
5885   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5886   actorB.RaiseAbove(actorC);
5887   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5888   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5889
5890   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5891   application.SendNotification();
5892   application.ProcessEvent(touchEvent);
5893
5894   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5895   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5896   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5897
5898   ResetTouchCallbacks();
5899
5900   tet_printf("Raise actor A Above Actor B\n");
5901
5902   orderChangedSignal = false;
5903
5904   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5905   actorA.RaiseAbove(actorB);
5906   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5907   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5908
5909   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5910   application.SendNotification();
5911
5912   application.ProcessEvent(touchEvent); // process a touch event on ordered actors.
5913
5914   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5915   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5916   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5917
5918   ResetTouchCallbacks();
5919
5920   END_TEST;
5921 }
5922
5923 int UtcDaliActorRaiseAbove2(void)
5924 {
5925   tet_infoline("UtcDaliActor RaiseToAbove test using SIBLING_ORDER property\n");
5926
5927   TestApplication application;
5928
5929   Integration::Scene stage(application.GetScene());
5930
5931   Actor actorA = Actor::New();
5932   Actor actorB = Actor::New();
5933   Actor actorC = Actor::New();
5934
5935   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5936   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5937
5938   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5939   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5940
5941   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5942   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5943
5944   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5945   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5946
5947   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5948   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5949
5950   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5951   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5952
5953   stage.Add(actorA);
5954   stage.Add(actorB);
5955   stage.Add(actorC);
5956
5957   ResetTouchCallbacks();
5958
5959   application.SendNotification();
5960   application.Render();
5961
5962   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5963   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5964   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5965
5966   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5967   // Only top actor will get touched.
5968   actorA.TouchedSignal().Connect(TestTouchCallback);
5969   actorB.TouchedSignal().Connect(TestTouchCallback2);
5970   actorC.TouchedSignal().Connect(TestTouchCallback3);
5971
5972   bool                     orderChangedSignal(false);
5973   Actor                    orderChangedActor;
5974   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5975   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5976
5977   Dali::Integration::Point point;
5978   point.SetDeviceId(1);
5979   point.SetState(PointState::DOWN);
5980   point.SetScreenPosition(Vector2(10.f, 10.f));
5981   Dali::Integration::TouchEvent touchEvent;
5982   touchEvent.AddPoint(point);
5983
5984   application.ProcessEvent(touchEvent);
5985
5986   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5987   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5988   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5989
5990   ResetTouchCallbacks();
5991
5992   tet_printf("Raise actor B Above Actor C\n");
5993
5994   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5995   int newOrder                                = actorC[DevelActor::Property::SIBLING_ORDER];
5996   actorB[DevelActor::Property::SIBLING_ORDER] = newOrder;
5997   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5998   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5999
6000   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6001   application.SendNotification();
6002   application.ProcessEvent(touchEvent);
6003
6004   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6005   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6006   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6007
6008   ResetTouchCallbacks();
6009
6010   tet_printf("Raise actor A Above Actor B\n");
6011
6012   orderChangedSignal = false;
6013
6014   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6015   newOrder                                    = actorB[DevelActor::Property::SIBLING_ORDER];
6016   actorA[DevelActor::Property::SIBLING_ORDER] = newOrder;
6017   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6018   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6019
6020   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6021   application.SendNotification();
6022
6023   application.ProcessEvent(touchEvent); // process a touch event on ordered actors.
6024
6025   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6026   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6027   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6028
6029   ResetTouchCallbacks();
6030
6031   END_TEST;
6032 }
6033
6034 int UtcDaliActorLowerBelow(void)
6035 {
6036   tet_infoline("UtcDaliActor LowerBelow test \n");
6037
6038   TestApplication application;
6039
6040   Integration::Scene stage(application.GetScene());
6041
6042   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
6043   // enables checking of which actor the uniform is assigned too
6044   Shader shaderA = CreateShader();
6045   shaderA.RegisterProperty("uRendererColor", 1.f);
6046
6047   Shader shaderB = CreateShader();
6048   shaderB.RegisterProperty("uRendererColor", 2.f);
6049
6050   Shader shaderC = CreateShader();
6051   shaderC.RegisterProperty("uRendererColor", 3.f);
6052
6053   Actor actorA = Actor::New();
6054   Actor actorB = Actor::New();
6055   Actor actorC = Actor::New();
6056
6057   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
6058   Geometry geometry = CreateQuadGeometry();
6059
6060   Renderer rendererA = Renderer::New(geometry, shaderA);
6061   actorA.AddRenderer(rendererA);
6062
6063   Renderer rendererB = Renderer::New(geometry, shaderB);
6064   actorB.AddRenderer(rendererB);
6065
6066   Renderer rendererC = Renderer::New(geometry, shaderC);
6067   actorC.AddRenderer(rendererC);
6068
6069   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6070   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6071
6072   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6073   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6074
6075   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6076   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6077
6078   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6079   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6080
6081   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6082   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6083
6084   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6085   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6086
6087   Actor container = Actor::New();
6088   container.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6089   container.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
6090   stage.Add(container);
6091
6092   container.Add(actorA);
6093   container.Add(actorB);
6094   container.Add(actorC);
6095
6096   ResetTouchCallbacks();
6097
6098   // Connect ChildOrderChangedSignal
6099   bool                     orderChangedSignal(false);
6100   Actor                    orderChangedActor;
6101   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6102   DevelActor::ChildOrderChangedSignal(container).Connect(&application, f);
6103
6104   // Set up gl abstraction trace so can query the set uniform order
6105   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
6106   glAbstraction.EnableSetUniformCallTrace(true);
6107   glAbstraction.ResetSetUniformCallStack();
6108   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
6109
6110   glAbstraction.ResetSetUniformCallStack();
6111
6112   application.SendNotification();
6113   application.Render();
6114
6115   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6116
6117   // Test order of uniforms in stack
6118   int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6119   int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6120   int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6121
6122   tet_infoline("Testing C above B and A at bottom\n");
6123   bool CBA = (indexC > indexB) && (indexB > indexA);
6124
6125   DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
6126
6127   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6128   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6129   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6130
6131   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6132   // Only top actor will get touched.
6133   actorA.TouchedSignal().Connect(TestTouchCallback);
6134   actorB.TouchedSignal().Connect(TestTouchCallback2);
6135   actorC.TouchedSignal().Connect(TestTouchCallback3);
6136
6137   Dali::Integration::Point point;
6138   point.SetDeviceId(1);
6139   point.SetState(PointState::DOWN);
6140   point.SetScreenPosition(Vector2(10.f, 10.f));
6141   Dali::Integration::TouchEvent touchEvent;
6142   touchEvent.AddPoint(point);
6143
6144   tet_infoline("UtcDaliActor Test Set up completed \n");
6145
6146   application.ProcessEvent(touchEvent);
6147
6148   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6149   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6150   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6151
6152   ResetTouchCallbacks();
6153
6154   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");
6155
6156   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6157   actorC.LowerBelow(actorB);
6158   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6159   DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
6160
6161   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6162   application.SendNotification();
6163   application.Render();
6164
6165   application.ProcessEvent(touchEvent); // touch event
6166
6167   glSetUniformStack.Reset();
6168
6169   application.SendNotification();
6170   application.Render();
6171
6172   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6173
6174   // Test order of uniforms in stack
6175   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6176   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6177   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6178
6179   tet_infoline("Testing render order is A, C, B");
6180   DALI_TEST_EQUALS(indexC > indexA, true, TEST_LOCATION);
6181   DALI_TEST_EQUALS(indexB > indexC, true, TEST_LOCATION);
6182
6183   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6184   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6185   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6186
6187   ResetTouchCallbacks();
6188
6189   tet_printf("Lower actor C below Actor A leaving B on top\n");
6190
6191   orderChangedSignal = false;
6192
6193   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6194   actorC.LowerBelow(actorA);
6195   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6196   DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
6197
6198   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6199   application.SendNotification();
6200   application.Render();
6201
6202   application.ProcessEvent(touchEvent);
6203
6204   glSetUniformStack.Reset();
6205
6206   application.Render();
6207   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6208
6209   // Test order of uniforms in stack
6210   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6211   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6212   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6213
6214   DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
6215   DALI_TEST_EQUALS(indexB > indexA, true, TEST_LOCATION);
6216
6217   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6218   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6219   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6220
6221   ResetTouchCallbacks();
6222
6223   tet_printf("Lower actor B below Actor C leaving A on top\n");
6224
6225   orderChangedSignal = false;
6226
6227   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6228   actorB.LowerBelow(actorC);
6229   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6230   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
6231
6232   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6233   application.SendNotification();
6234   application.Render();
6235
6236   application.ProcessEvent(touchEvent);
6237
6238   glSetUniformStack.Reset();
6239
6240   application.Render();
6241   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6242
6243   // Test order of uniforms in stack
6244   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6245   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6246   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6247
6248   DALI_TEST_EQUALS(indexC > indexB, true, TEST_LOCATION);
6249   DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
6250
6251   END_TEST;
6252 }
6253
6254 int UtcDaliActorLowerBelow2(void)
6255 {
6256   tet_infoline("UtcDaliActor LowerBelow test using SIBLING_ORDER property\n");
6257
6258   TestApplication application;
6259
6260   Integration::Scene stage(application.GetScene());
6261
6262   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
6263   // enables checking of which actor the uniform is assigned too
6264   Shader shaderA = CreateShader();
6265   shaderA.RegisterProperty("uRendererColor", 1.f);
6266
6267   Shader shaderB = CreateShader();
6268   shaderB.RegisterProperty("uRendererColor", 2.f);
6269
6270   Shader shaderC = CreateShader();
6271   shaderC.RegisterProperty("uRendererColor", 3.f);
6272
6273   Actor actorA = Actor::New();
6274   Actor actorB = Actor::New();
6275   Actor actorC = Actor::New();
6276
6277   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
6278   Geometry geometry = CreateQuadGeometry();
6279
6280   Renderer rendererA = Renderer::New(geometry, shaderA);
6281   actorA.AddRenderer(rendererA);
6282
6283   Renderer rendererB = Renderer::New(geometry, shaderB);
6284   actorB.AddRenderer(rendererB);
6285
6286   Renderer rendererC = Renderer::New(geometry, shaderC);
6287   actorC.AddRenderer(rendererC);
6288
6289   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6290   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6291
6292   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6293   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6294
6295   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6296   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6297
6298   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6299   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6300
6301   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6302   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6303
6304   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6305   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6306
6307   Actor container = Actor::New();
6308   container.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6309   container.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
6310   stage.Add(container);
6311
6312   container.Add(actorA);
6313   container.Add(actorB);
6314   container.Add(actorC);
6315
6316   ResetTouchCallbacks();
6317
6318   // Connect ChildOrderChangedSignal
6319   bool                     orderChangedSignal(false);
6320   Actor                    orderChangedActor;
6321   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6322   DevelActor::ChildOrderChangedSignal(container).Connect(&application, f);
6323
6324   // Set up gl abstraction trace so can query the set uniform order
6325   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
6326   glAbstraction.EnableSetUniformCallTrace(true);
6327   glAbstraction.ResetSetUniformCallStack();
6328   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
6329
6330   glAbstraction.ResetSetUniformCallStack();
6331
6332   application.SendNotification();
6333   application.Render();
6334
6335   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6336
6337   // Test order of uniforms in stack
6338   int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6339   int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6340   int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6341
6342   tet_infoline("Testing C above B and A at bottom\n");
6343   bool CBA = (indexC > indexB) && (indexB > indexA);
6344
6345   DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
6346
6347   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6348   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6349   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6350
6351   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6352   // Only top actor will get touched.
6353   actorA.TouchedSignal().Connect(TestTouchCallback);
6354   actorB.TouchedSignal().Connect(TestTouchCallback2);
6355   actorC.TouchedSignal().Connect(TestTouchCallback3);
6356
6357   Dali::Integration::Point point;
6358   point.SetDeviceId(1);
6359   point.SetState(PointState::DOWN);
6360   point.SetScreenPosition(Vector2(10.f, 10.f));
6361   Dali::Integration::TouchEvent touchEvent;
6362   touchEvent.AddPoint(point);
6363
6364   tet_infoline("UtcDaliActor Test Set up completed \n");
6365
6366   application.ProcessEvent(touchEvent);
6367
6368   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6369   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6370   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6371
6372   ResetTouchCallbacks();
6373
6374   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");
6375
6376   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6377   actorC[DevelActor::Property::SIBLING_ORDER] = 1;
6378   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6379   DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
6380
6381   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6382   application.SendNotification();
6383   application.Render();
6384
6385   application.ProcessEvent(touchEvent); // touch event
6386
6387   glSetUniformStack.Reset();
6388
6389   application.SendNotification();
6390   application.Render();
6391
6392   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6393
6394   // Test order of uniforms in stack
6395   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6396   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6397   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6398
6399   tet_infoline("Testing render order is A, C, B");
6400   DALI_TEST_EQUALS(indexC > indexA, true, TEST_LOCATION);
6401   DALI_TEST_EQUALS(indexB > indexC, true, TEST_LOCATION);
6402
6403   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6404   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6405   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6406
6407   ResetTouchCallbacks();
6408
6409   tet_printf("Lower actor C below Actor A leaving B on top\n");
6410
6411   orderChangedSignal = false;
6412
6413   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6414   actorC[DevelActor::Property::SIBLING_ORDER] = 0;
6415   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6416   DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
6417
6418   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6419   application.SendNotification();
6420   application.Render();
6421
6422   application.ProcessEvent(touchEvent);
6423
6424   glSetUniformStack.Reset();
6425
6426   application.Render();
6427   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6428
6429   // Test order of uniforms in stack
6430   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6431   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6432   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6433
6434   DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
6435   DALI_TEST_EQUALS(indexB > indexA, true, TEST_LOCATION);
6436
6437   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6438   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6439   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6440
6441   ResetTouchCallbacks();
6442
6443   tet_printf("Lower actor B below Actor C leaving A on top\n");
6444
6445   orderChangedSignal = false;
6446
6447   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6448   actorB[DevelActor::Property::SIBLING_ORDER] = 0;
6449   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6450   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
6451
6452   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6453   application.SendNotification();
6454   application.Render();
6455
6456   application.ProcessEvent(touchEvent);
6457
6458   glSetUniformStack.Reset();
6459
6460   application.Render();
6461   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6462
6463   // Test order of uniforms in stack
6464   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6465   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6466   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6467
6468   DALI_TEST_EQUALS(indexC > indexB, true, TEST_LOCATION);
6469   DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
6470
6471   END_TEST;
6472 }
6473
6474 int UtcDaliActorRaiseAboveDifferentParentsN(void)
6475 {
6476   tet_infoline("UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n");
6477
6478   TestApplication application;
6479
6480   Integration::Scene stage(application.GetScene());
6481
6482   Actor parentA = Actor::New();
6483   Actor parentB = Actor::New();
6484   parentA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6485   parentA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6486   parentB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6487   parentB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6488
6489   parentA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6490   parentA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6491
6492   parentB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6493   parentB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6494
6495   stage.Add(parentA);
6496   stage.Add(parentB);
6497
6498   Actor actorA = Actor::New();
6499   Actor actorB = Actor::New();
6500   Actor actorC = Actor::New();
6501
6502   parentA.Add(actorA);
6503   parentA.Add(actorB);
6504
6505   tet_printf("Actor C added to different parent from A and B \n");
6506   parentB.Add(actorC);
6507
6508   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6509   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6510
6511   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6512   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6513
6514   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6515   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6516
6517   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6518   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6519
6520   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6521   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6522
6523   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6524   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6525
6526   ResetTouchCallbacks();
6527
6528   // Connect ChildOrderChangedSignal
6529   bool                     orderChangedSignal(false);
6530   Actor                    orderChangedActor;
6531   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6532   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6533
6534   application.SendNotification();
6535   application.Render();
6536
6537   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6538   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6539   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6540
6541   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6542   // Only top actor will get touched.
6543   actorA.TouchedSignal().Connect(TestTouchCallback);
6544   actorB.TouchedSignal().Connect(TestTouchCallback2);
6545   actorC.TouchedSignal().Connect(TestTouchCallback3);
6546
6547   Dali::Integration::Point point;
6548   point.SetDeviceId(1);
6549   point.SetState(PointState::DOWN);
6550   point.SetScreenPosition(Vector2(10.f, 10.f));
6551   Dali::Integration::TouchEvent touchEvent;
6552   touchEvent.AddPoint(point);
6553
6554   application.ProcessEvent(touchEvent);
6555
6556   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6557   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6558   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6559
6560   ResetTouchCallbacks();
6561
6562   tet_printf("Raise actor A Above Actor C which have different parents\n");
6563
6564   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6565   actorA.RaiseAbove(actorC);
6566   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6567
6568   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6569   application.SendNotification();
6570
6571   application.ProcessEvent(touchEvent); // touch event
6572
6573   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6574   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6575   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6576
6577   ResetTouchCallbacks();
6578
6579   END_TEST;
6580 }
6581
6582 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
6583 {
6584   tet_infoline("UtcDaliActor Test  raiseAbove and lowerBelow api when target Actor has no parent \n");
6585
6586   TestApplication application;
6587
6588   Integration::Scene stage(application.GetScene());
6589
6590   Actor actorA = Actor::New();
6591   Actor actorB = Actor::New();
6592   Actor actorC = Actor::New();
6593
6594   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6595   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6596
6597   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6598   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6599
6600   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6601   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6602
6603   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6604   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6605
6606   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6607   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6608
6609   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6610   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6611
6612   ResetTouchCallbacks();
6613
6614   // Connect ChildOrderChangedSignal
6615   bool                     orderChangedSignal(false);
6616   Actor                    orderChangedActor;
6617   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6618   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6619
6620   application.SendNotification();
6621   application.Render();
6622
6623   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6624   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6625   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6626
6627   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6628   // Only top actor will get touched.
6629   actorA.TouchedSignal().Connect(TestTouchCallback);
6630   actorB.TouchedSignal().Connect(TestTouchCallback2);
6631   actorC.TouchedSignal().Connect(TestTouchCallback3);
6632
6633   Dali::Integration::Point point;
6634   point.SetDeviceId(1);
6635   point.SetState(PointState::DOWN);
6636   point.SetScreenPosition(Vector2(10.f, 10.f));
6637   Dali::Integration::TouchEvent touchEvent;
6638   touchEvent.AddPoint(point);
6639
6640   tet_printf("Raise actor A Above Actor C which have no parents\n");
6641
6642   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6643   actorA.RaiseAbove(actorC);
6644   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6645
6646   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6647   application.SendNotification();
6648
6649   application.ProcessEvent(touchEvent);
6650
6651   tet_printf("Not parented so RaiseAbove should show no effect\n");
6652
6653   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6654   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6655   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6656
6657   ResetTouchCallbacks();
6658
6659   orderChangedSignal = false;
6660
6661   stage.Add(actorB);
6662   tet_printf("Lower actor A below Actor C when only A is not on stage \n");
6663
6664   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6665   actorA.LowerBelow(actorC);
6666   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6667
6668   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6669   application.SendNotification();
6670   application.Render();
6671
6672   application.ProcessEvent(touchEvent);
6673
6674   tet_printf("Actor A not parented so LowerBelow should show no effect\n");
6675   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6676   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6677   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6678
6679   ResetTouchCallbacks();
6680
6681   orderChangedSignal = false;
6682
6683   tet_printf("Adding Actor A to stage, will be on top\n");
6684
6685   stage.Add(actorA);
6686   application.SendNotification();
6687   application.Render();
6688
6689   tet_printf("Raise actor B Above Actor C when only B has a parent\n");
6690
6691   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6692   actorB.RaiseAbove(actorC);
6693   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6694
6695   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6696   application.SendNotification();
6697
6698   application.ProcessEvent(touchEvent);
6699
6700   tet_printf("C not parented so RaiseAbove should show no effect\n");
6701   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6702   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6703   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6704
6705   ResetTouchCallbacks();
6706
6707   orderChangedSignal = false;
6708
6709   tet_printf("Lower actor A below Actor C when only A has a parent\n");
6710
6711   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6712   actorA.LowerBelow(actorC);
6713   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6714
6715   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6716   application.SendNotification();
6717
6718   application.ProcessEvent(touchEvent);
6719
6720   tet_printf("C not parented so LowerBelow should show no effect\n");
6721   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6722   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6723   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6724
6725   ResetTouchCallbacks();
6726
6727   orderChangedSignal = false;
6728
6729   stage.Add(actorC);
6730
6731   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6732   actorA.RaiseAbove(actorC);
6733   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6734   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6735
6736   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6737   application.SendNotification();
6738   application.Render();
6739
6740   application.ProcessEvent(touchEvent);
6741
6742   tet_printf("Raise actor A Above Actor C, now both have same parent \n");
6743   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6744   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6745   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6746
6747   END_TEST;
6748 }
6749
6750 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
6751 {
6752   tet_infoline("UtcDaliActor Test all raise/lower api when actor has no parent \n");
6753
6754   TestApplication application;
6755
6756   Integration::Scene stage(application.GetScene());
6757
6758   Actor actorA = Actor::New();
6759   Actor actorB = Actor::New();
6760   Actor actorC = Actor::New();
6761
6762   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6763   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6764
6765   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6766   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6767
6768   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6769   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6770
6771   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6772   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6773
6774   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6775   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6776
6777   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6778   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6779
6780   ResetTouchCallbacks();
6781
6782   // Connect ChildOrderChangedSignal
6783   bool                     orderChangedSignal(false);
6784   Actor                    orderChangedActor;
6785   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6786   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6787
6788   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6789   // Only top actor will get touched.
6790   actorA.TouchedSignal().Connect(TestTouchCallback);
6791   actorB.TouchedSignal().Connect(TestTouchCallback2);
6792   actorC.TouchedSignal().Connect(TestTouchCallback3);
6793
6794   Dali::Integration::Point point;
6795   point.SetDeviceId(1);
6796   point.SetState(PointState::DOWN);
6797   point.SetScreenPosition(Vector2(10.f, 10.f));
6798   Dali::Integration::TouchEvent touchEvent;
6799   touchEvent.AddPoint(point);
6800
6801   stage.Add(actorA);
6802   tet_printf("Raise actor B Above Actor C but B not parented\n");
6803
6804   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6805   actorB.Raise();
6806   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6807
6808   application.SendNotification();
6809   application.Render();
6810
6811   application.ProcessEvent(touchEvent);
6812
6813   tet_printf("Not parented so RaiseAbove should show no effect\n");
6814
6815   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6816   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6817   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6818
6819   tet_printf("Raise actor B Above Actor C but B not parented\n");
6820   ResetTouchCallbacks();
6821
6822   orderChangedSignal = false;
6823
6824   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6825   actorC.Lower();
6826   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6827
6828   // Sort actor tree before next touch event
6829   application.SendNotification();
6830   application.Render();
6831
6832   application.ProcessEvent(touchEvent);
6833
6834   tet_printf("Not parented so RaiseAbove should show no effect\n");
6835
6836   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6837   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6838   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6839   ResetTouchCallbacks();
6840
6841   orderChangedSignal = false;
6842
6843   tet_printf("Lower actor C below B but C not parented\n");
6844
6845   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6846   actorB.Lower();
6847   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6848
6849   // Sort actor tree before next touch event
6850   application.SendNotification();
6851   application.Render();
6852
6853   application.ProcessEvent(touchEvent);
6854
6855   tet_printf("Not parented so Lower should show no effect\n");
6856
6857   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6858   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6859   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6860   ResetTouchCallbacks();
6861
6862   orderChangedSignal = false;
6863
6864   tet_printf("Raise actor B to top\n");
6865
6866   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6867   actorB.RaiseToTop();
6868   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6869
6870   // Sort actor tree before next touch event
6871   application.SendNotification();
6872   application.Render();
6873
6874   application.ProcessEvent(touchEvent);
6875
6876   tet_printf("Not parented so RaiseToTop should show no effect\n");
6877
6878   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6879   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6880   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6881   ResetTouchCallbacks();
6882
6883   orderChangedSignal = false;
6884
6885   tet_printf("Add ActorB to stage so only Actor C not parented\n");
6886
6887   stage.Add(actorB);
6888
6889   tet_printf("Lower actor C to Bottom, B stays at top\n");
6890
6891   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6892   actorC.LowerToBottom();
6893   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6894
6895   application.SendNotification();
6896   application.Render();
6897
6898   application.ProcessEvent(touchEvent);
6899
6900   tet_printf("Not parented so LowerToBottom should show no effect\n");
6901
6902   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6903   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6904   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6905   ResetTouchCallbacks();
6906
6907   END_TEST;
6908 }
6909
6910 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
6911 {
6912   tet_infoline("UtcDaliActor RaiseToAbove and  test with actor provided as target resulting in a no operation \n");
6913
6914   TestApplication application;
6915
6916   Integration::Scene stage(application.GetScene());
6917
6918   Actor actorA = Actor::New();
6919   Actor actorB = Actor::New();
6920   Actor actorC = Actor::New();
6921
6922   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6923   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6924
6925   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6926   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6927
6928   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6929   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6930
6931   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6932   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6933
6934   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6935   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6936
6937   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6938   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6939
6940   stage.Add(actorA);
6941   stage.Add(actorB);
6942   stage.Add(actorC);
6943
6944   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6945   // Only top actor will get touched.
6946   actorA.TouchedSignal().Connect(TestTouchCallback);
6947   actorB.TouchedSignal().Connect(TestTouchCallback2);
6948   actorC.TouchedSignal().Connect(TestTouchCallback3);
6949
6950   ResetTouchCallbacks();
6951
6952   // Connect ChildOrderChangedSignal
6953   bool                     orderChangedSignal(false);
6954   Actor                    orderChangedActor;
6955   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6956   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6957
6958   application.SendNotification();
6959   application.Render();
6960
6961   Dali::Integration::Point point;
6962   point.SetDeviceId(1);
6963   point.SetState(PointState::DOWN);
6964   point.SetScreenPosition(Vector2(10.f, 10.f));
6965   Dali::Integration::TouchEvent touchEvent;
6966   touchEvent.AddPoint(point);
6967
6968   application.ProcessEvent(touchEvent);
6969
6970   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6971   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6972   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6973
6974   ResetTouchCallbacks();
6975
6976   tet_infoline("Raise actor A Above Actor A which is the same actor!!\n");
6977
6978   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6979   actorA.RaiseAbove(actorA);
6980   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6981   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6982
6983   application.SendNotification();
6984   application.Render();
6985
6986   application.ProcessEvent(touchEvent);
6987
6988   tet_infoline("No target is source Actor so RaiseAbove should show no effect\n");
6989
6990   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6991   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6992   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6993
6994   ResetTouchCallbacks();
6995
6996   orderChangedSignal = false;
6997
6998   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6999   actorA.RaiseAbove(actorC);
7000   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
7001   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
7002
7003   application.SendNotification();
7004   application.Render();
7005
7006   application.ProcessEvent(touchEvent);
7007
7008   tet_infoline("Raise actor A Above Actor C which will now be successful \n");
7009   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
7010   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
7011   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
7012
7013   END_TEST;
7014 }
7015
7016 int UtcDaliActorGetScreenPosition(void)
7017 {
7018   tet_infoline("UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n");
7019
7020   TestApplication application;
7021
7022   Integration::Scene stage(application.GetScene());
7023
7024   Actor actorA = Actor::New();
7025   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7026
7027   Vector2 size2(10.0f, 20.0f);
7028   actorA.SetProperty(Actor::Property::SIZE, size2);
7029
7030   actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7031
7032   tet_infoline("UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n");
7033
7034   stage.Add(actorA);
7035
7036   application.SendNotification();
7037   application.Render();
7038
7039   Vector3 actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7040   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7041
7042   tet_printf("Actor World Position ( %f %f ) AnchorPoint::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
7043   tet_printf("Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y);
7044
7045   DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
7046   DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
7047
7048   tet_infoline("UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n");
7049
7050   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7051
7052   application.SendNotification();
7053   application.Render();
7054
7055   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7056   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7057
7058   tet_printf("Actor World Position  ( %f %f ) AnchorPoint::TOP_LEFT  \n", actorWorldPosition.x, actorWorldPosition.y);
7059   tet_printf("Actor Screen Position  ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y);
7060
7061   DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
7062   DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
7063
7064   tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n");
7065
7066   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7067
7068   application.SendNotification();
7069   application.Render();
7070
7071   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7072   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7073
7074   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT   \n", actorWorldPosition.x, actorWorldPosition.y);
7075   tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT  \n", actorScreenPosition.x, actorScreenPosition.y);
7076
7077   DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
7078   DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
7079
7080   tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n");
7081
7082   actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 0.0));
7083
7084   application.SendNotification();
7085   application.Render();
7086
7087   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7088   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7089
7090   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorWorldPosition.x, actorWorldPosition.y);
7091   tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0   \n", actorScreenPosition.x, actorScreenPosition.y);
7092
7093   DALI_TEST_EQUALS(actorScreenPosition.x, 30lu, TEST_LOCATION);
7094   DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
7095
7096   tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n");
7097
7098   actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 420.0));
7099
7100   application.SendNotification();
7101   application.Render();
7102
7103   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7104   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7105
7106   DALI_TEST_EQUALS(actorScreenPosition.x, 30lu, TEST_LOCATION);
7107   DALI_TEST_EQUALS(actorScreenPosition.y, 420lu, TEST_LOCATION);
7108
7109   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n", actorWorldPosition.x, actorWorldPosition.y);
7110   tet_printf("Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y);
7111
7112   tet_infoline("UtcDaliActorGetScreenPosition Scale parent and check child's screen position \n");
7113
7114   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7115   actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 30.0));
7116
7117   Actor actorB = Actor::New();
7118   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7119   actorB.SetProperty(Actor::Property::SIZE, size2);
7120   actorB.SetProperty(Actor::Property::POSITION, Vector2(10.f, 10.f));
7121   actorA.Add(actorB);
7122
7123   actorA.SetProperty(Actor::Property::SCALE, 2.0f);
7124
7125   application.SendNotification();
7126   application.Render();
7127
7128   actorScreenPosition = actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7129
7130   DALI_TEST_EQUALS(actorScreenPosition.x, 50lu, TEST_LOCATION);
7131   DALI_TEST_EQUALS(actorScreenPosition.y, 50lu, TEST_LOCATION);
7132
7133   END_TEST;
7134 }
7135
7136 int UtcDaliActorGetScreenPositionAfterScaling(void)
7137 {
7138   tet_infoline("UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n");
7139
7140   TestApplication application;
7141
7142   Integration::Scene stage(application.GetScene());
7143
7144   Actor actorA = Actor::New();
7145   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7146
7147   Vector2 size2(10.0f, 20.0f);
7148   actorA.SetProperty(Actor::Property::SIZE, size2);
7149   actorA.SetProperty(Actor::Property::SCALE, 1.5f);
7150   actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7151
7152   tet_infoline("UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n");
7153
7154   stage.Add(actorA);
7155
7156   application.SendNotification();
7157   application.Render();
7158
7159   Vector3 actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7160   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7161
7162   tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y);
7163   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7164
7165   DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
7166   DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
7167
7168   tet_infoline("UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n");
7169
7170   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7171
7172   application.SendNotification();
7173   application.Render();
7174
7175   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7176   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7177
7178   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
7179   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7180
7181   DALI_TEST_EQUALS(actorScreenPosition.x, 0.0f, TEST_LOCATION);
7182   DALI_TEST_EQUALS(actorScreenPosition.y, 0.0f, TEST_LOCATION);
7183
7184   END_TEST;
7185 }
7186
7187 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
7188 {
7189   tet_infoline("UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n");
7190
7191   TestApplication application;
7192
7193   Integration::Scene stage(application.GetScene());
7194
7195   Actor actorA = Actor::New();
7196   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7197   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7198   Vector2 size2(10.0f, 20.0f);
7199   actorA.SetProperty(Actor::Property::SIZE, size2);
7200   actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7201
7202   tet_infoline(" TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
7203
7204   stage.Add(actorA);
7205
7206   application.SendNotification();
7207   application.Render();
7208
7209   Vector3 actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7210   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7211
7212   tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n", actorWorldPosition.x, actorWorldPosition.y);
7213   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7214
7215   DALI_TEST_EQUALS(actorScreenPosition.x, 240.0f, TEST_LOCATION);
7216   DALI_TEST_EQUALS(actorScreenPosition.y, 400.0f, TEST_LOCATION);
7217
7218   tet_infoline(" BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n");
7219
7220   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
7221   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7222
7223   application.SendNotification();
7224   application.Render();
7225
7226   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7227   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7228
7229   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
7230   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7231
7232   DALI_TEST_EQUALS(actorScreenPosition.x, 480.0f, TEST_LOCATION);
7233   DALI_TEST_EQUALS(actorScreenPosition.y, 0.0f, TEST_LOCATION);
7234
7235   END_TEST;
7236   END_TEST;
7237 }
7238
7239 int UtcDaliActorGetScreenPositionWithChildActors(void)
7240 {
7241   tet_infoline("UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n");
7242
7243   TestApplication application;
7244
7245   Integration::Scene stage(application.GetScene());
7246
7247   tet_infoline("Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
7248
7249   Actor actorA = Actor::New();
7250   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7251   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7252   Vector2 size1(10.0f, 20.0f);
7253   actorA.SetProperty(Actor::Property::SIZE, size1);
7254   actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7255
7256   tet_infoline("Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
7257
7258   Actor parentActorA = Actor::New();
7259   parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7260   parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7261   Vector2 size2(30.0f, 60.0f);
7262   parentActorA.SetProperty(Actor::Property::SIZE, size2);
7263   parentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7264
7265   tet_infoline("Add child 1 to Parent 1 and check screen position \n");
7266
7267   stage.Add(parentActorA);
7268   parentActorA.Add(actorA);
7269
7270   application.SendNotification();
7271   application.Render();
7272
7273   Vector3 actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7274   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7275
7276   tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n", actorWorldPosition.x, actorWorldPosition.y);
7277   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7278
7279   DALI_TEST_EQUALS(actorScreenPosition.x, 255.0f, TEST_LOCATION);
7280   DALI_TEST_EQUALS(actorScreenPosition.y, 430.0f, TEST_LOCATION);
7281
7282   tet_infoline("Test 2\n");
7283
7284   tet_infoline("change parent anchor point and parent origin then check screen position \n");
7285
7286   parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
7287   parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
7288
7289   application.SendNotification();
7290   application.Render();
7291
7292   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7293   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7294
7295   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT  \n", actorWorldPosition.x, actorWorldPosition.y);
7296   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7297
7298   DALI_TEST_EQUALS(actorScreenPosition.x, 15.0f, TEST_LOCATION);
7299   DALI_TEST_EQUALS(actorScreenPosition.y, -30.0f, TEST_LOCATION);
7300
7301   END_TEST;
7302 }
7303
7304 int UtcDaliActorGetScreenPositionWithChildActors02(void)
7305 {
7306   tet_infoline("UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n");
7307
7308   TestApplication application;
7309
7310   Integration::Scene stage(application.GetScene());
7311
7312   tet_infoline("Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
7313
7314   Actor actorA = Actor::New();
7315   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7316   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7317   Vector2 size1(10.0f, 20.0f);
7318   actorA.SetProperty(Actor::Property::SIZE, size1);
7319   actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7320
7321   tet_infoline("Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
7322
7323   Actor parentActorA = Actor::New();
7324   parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7325   parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7326   Vector2 size2(30.0f, 60.0f);
7327   parentActorA.SetProperty(Actor::Property::SIZE, size2);
7328   parentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7329
7330   tet_infoline("Create Grand Parent Actor 1 BOTTOM_LEFT Anchor Point, ParentOrigin::BOTTOM_LEFT and 0,0 position \n");
7331
7332   Actor grandParentActorA = Actor::New();
7333   grandParentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
7334   grandParentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
7335   Vector2 size3(60.0f, 120.0f);
7336   grandParentActorA.SetProperty(Actor::Property::SIZE, size3);
7337   grandParentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7338
7339   tet_infoline("Add Parent 1 to Grand Parent 1 \n");
7340
7341   stage.Add(grandParentActorA);
7342   grandParentActorA.Add(parentActorA);
7343
7344   tet_infoline("Add child 1 to Parent 1 and check screen position \n");
7345
7346   parentActorA.Add(actorA);
7347
7348   application.SendNotification();
7349   application.Render();
7350
7351   Vector3 actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7352   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7353
7354   tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n", actorWorldPosition.x, actorWorldPosition.y);
7355   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7356
7357   DALI_TEST_EQUALS(actorScreenPosition.x, 45.0f, TEST_LOCATION);
7358   DALI_TEST_EQUALS(actorScreenPosition.y, 770.0f, TEST_LOCATION);
7359
7360   END_TEST;
7361 }
7362
7363 int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void)
7364 {
7365   tet_infoline("UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse Check screen position where the position does not use the anchor point");
7366
7367   TestApplication application;
7368
7369   Integration::Scene stage(application.GetScene());
7370
7371   tet_infoline("Create an actor with AnchorPoint::TOP_LEFT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
7372
7373   Actor actorA = Actor::New();
7374   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7375   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7376   actorA.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7377   actorA.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 20.0f));
7378   stage.Add(actorA);
7379
7380   tet_infoline("Create an Actor with AnchorPoint::BOTTOM_RIGHT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
7381
7382   Actor actorB = Actor::New();
7383   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7384   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7385   actorB.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7386   Vector2 actorBSize(30.0f, 60.0f);
7387   actorB.SetProperty(Actor::Property::SIZE, actorBSize);
7388   stage.Add(actorB);
7389
7390   tet_infoline("Create an actor with AnchorPoint::CENTER, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
7391
7392   Actor actorC = Actor::New();
7393   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7394   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7395   actorC.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7396   Vector2 actorCSize(60.0f, 120.0f);
7397   actorC.SetProperty(Actor::Property::SIZE, actorCSize);
7398   stage.Add(actorC);
7399
7400   application.SendNotification();
7401   application.Render();
7402
7403   tet_infoline("Despite differing sizes and anchor-points, the screen position for all actors is the same");
7404
7405   Vector2 center(stage.GetSize() * 0.5f);
7406
7407   DALI_TEST_EQUALS(actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
7408   DALI_TEST_EQUALS(actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
7409   DALI_TEST_EQUALS(actorC.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
7410
7411   tet_infoline("Add scale to all actors");
7412
7413   actorA.SetProperty(Actor::Property::SCALE, 2.0f);
7414   actorB.SetProperty(Actor::Property::SCALE, 2.0f);
7415   actorC.SetProperty(Actor::Property::SCALE, 2.0f);
7416
7417   application.SendNotification();
7418   application.Render();
7419
7420   DALI_TEST_EQUALS(actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center /* TOP_LEFT Anchor */, TEST_LOCATION);
7421   DALI_TEST_EQUALS(actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center - actorBSize /* BOTTOM_RIGHT Anchor */, TEST_LOCATION);
7422   DALI_TEST_EQUALS(actorC.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center - actorCSize * 0.5f /* CENTER Anchor*/, TEST_LOCATION);
7423
7424   END_TEST;
7425 }
7426
7427 int UtcDaliActorGetScreenPositionResizeScene(void)
7428 {
7429   tet_infoline("UtcDaliActorGetScreenPositionResizeScene Check screen position after resizing the scene size");
7430
7431   TestApplication    application;
7432   Integration::Scene scene = application.GetScene();
7433
7434   Actor actorA = Actor::New();
7435   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7436   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7437   actorA.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
7438
7439   scene.Add(actorA);
7440
7441   application.SendNotification();
7442   application.Render();
7443
7444   Vector2 sceneSize           = scene.GetSize();
7445   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7446
7447   DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2, TEST_LOCATION);
7448
7449   // Resize the scene
7450   Vector2 newSize(1000.0f, 2000.0f);
7451   DALI_TEST_CHECK(scene.GetSize() != newSize);
7452
7453   scene.SurfaceResized(newSize.width, newSize.height);
7454
7455   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7456
7457   // The screen position should not be updated yet
7458   DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2, TEST_LOCATION);
7459
7460   application.SendNotification();
7461   application.Render();
7462
7463   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7464
7465   // The screen position should be updated
7466   sceneSize = scene.GetSize();
7467   DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2, TEST_LOCATION);
7468
7469   END_TEST;
7470 }
7471
7472 int UtcDaliActorGetScreenPositionInCustomCameraAndLayer3D(void)
7473 {
7474   tet_infoline("UtcDaliActorGetScreenPositionInCustomCameraAndLayer3D Check screen position under LAYER_3D and custom camera");
7475
7476   TestApplication    application;
7477   Integration::Scene scene = application.GetScene();
7478
7479   // Make 3D Layer
7480   Layer layer = scene.GetRootLayer();
7481   layer.SetProperty(Layer::Property::BEHAVIOR, Layer::Behavior::LAYER_3D);
7482
7483   // Build custom camera with top-view
7484   CameraActor cameraActor = scene.GetRenderTaskList().GetTask(0).GetCameraActor();
7485   {
7486     // Default camera position at +z and looking -z axis. (orientation is [ Axis: [0, 1, 0], Angle: 180 degrees ])
7487     Vector3    cameraPos    = cameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
7488     Quaternion cameraOrient = cameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
7489
7490     {
7491       std::ostringstream oss;
7492       oss << cameraPos << "\n";
7493       oss << cameraOrient << "\n";
7494       tet_printf("%s\n", oss.str().c_str());
7495     }
7496
7497     cameraActor.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -cameraPos.z, 0.0f));
7498     cameraActor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::XAXIS) * cameraOrient);
7499
7500     // Now, upside : -Z, leftside : -X, foward : +Y
7501
7502     cameraPos    = cameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
7503     cameraOrient = cameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
7504     {
7505       std::ostringstream oss;
7506       oss << cameraPos << "\n";
7507       oss << cameraOrient << "\n";
7508       tet_printf("%s\n", oss.str().c_str());
7509     }
7510   }
7511
7512   Actor actorA = Actor::New();
7513   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7514   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7515   actorA.SetProperty(Actor::Property::SIZE, Vector3(10.0f, 10.0f, 10.0f));
7516   actorA.SetProperty(Actor::Property::POSITION, Vector3(20.0f, 0.0f, 10.0f));
7517
7518   Actor actorB = Actor::New();
7519   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7520   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7521   actorB.SetProperty(Actor::Property::SIZE, Vector3(10.0f, 10.0f, 10.0f));
7522   actorB.SetProperty(Actor::Property::POSITION, Vector3(-20.0f, 0.0f, -10.0f));
7523
7524   scene.Add(actorA);
7525   scene.Add(actorB);
7526
7527   application.SendNotification();
7528   application.Render();
7529
7530   Vector2 sceneSize           = scene.GetSize();
7531   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7532
7533   DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2 + Vector2(20.0f, 10.0f), TEST_LOCATION);
7534
7535   actorScreenPosition = actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7536
7537   DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2 - Vector2(20.0f, 10.0f), TEST_LOCATION);
7538
7539   END_TEST;
7540 }
7541
7542 int utcDaliActorPositionUsesAnchorPoint(void)
7543 {
7544   TestApplication application;
7545   tet_infoline("Check default behaviour\n");
7546
7547   Actor actor = Actor::New();
7548   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7549   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7550   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7551   application.GetScene().Add(actor);
7552
7553   application.SendNotification();
7554   application.Render();
7555
7556   tet_infoline("Check that the world position is in the center\n");
7557   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
7558
7559   tet_infoline("Set the position uses anchor point property to false\n");
7560   actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7561
7562   application.SendNotification();
7563   application.Render();
7564
7565   tet_infoline("Check that the world position has changed appropriately\n");
7566   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7567
7568   END_TEST;
7569 }
7570
7571 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
7572 {
7573   TestApplication application;
7574   tet_infoline("Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7575
7576   Actor actor = Actor::New();
7577   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7578   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7579   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7580   actor.SetProperty(Actor::Property::SCALE, 2.0f);
7581   actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7582   application.GetScene().Add(actor);
7583
7584   application.SendNotification();
7585   application.Render();
7586
7587   tet_infoline("Check the world position is the same as it would be without a scale\n");
7588   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7589
7590   tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
7591   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7592   application.SendNotification();
7593   application.Render();
7594   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(100.0f, 100.0f, 0.0f), TEST_LOCATION);
7595
7596   tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
7597   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7598   application.SendNotification();
7599   application.Render();
7600   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
7601
7602   END_TEST;
7603 }
7604
7605 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
7606 {
7607   TestApplication application;
7608   tet_infoline("Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7609
7610   Actor actor = Actor::New();
7611   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7612   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7613   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7614   actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::ZAXIS));
7615   actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7616   application.GetScene().Add(actor);
7617
7618   application.SendNotification();
7619   application.Render();
7620
7621   tet_infoline("Check the world position is the same as it would be without a rotation\n");
7622   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7623
7624   tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
7625   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7626   application.SendNotification();
7627   application.Render();
7628   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(-50.0f, 50.0f, 0.0f), TEST_LOCATION);
7629
7630   tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
7631   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7632   application.SendNotification();
7633   application.Render();
7634   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(150.0f, 50.0f, 0.0f), TEST_LOCATION);
7635
7636   END_TEST;
7637 }
7638
7639 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
7640 {
7641   TestApplication application;
7642   tet_infoline("Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7643
7644   Actor actor = Actor::New();
7645   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7646   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7647   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7648   actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::ZAXIS));
7649   actor.SetProperty(Actor::Property::SCALE, 2.0f);
7650   actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7651   application.GetScene().Add(actor);
7652
7653   application.SendNotification();
7654   application.Render();
7655
7656   tet_infoline("Check the world position is the same as it would be without a scale and rotation\n");
7657   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7658
7659   tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
7660   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7661   application.SendNotification();
7662   application.Render();
7663   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(-100.0f, 100.0f, 0.0f), TEST_LOCATION);
7664
7665   tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
7666   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7667   application.SendNotification();
7668   application.Render();
7669   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(200.0f, 0.0f, 0.0f), TEST_LOCATION);
7670
7671   END_TEST;
7672 }
7673
7674 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
7675 {
7676   TestApplication application;
7677   tet_infoline("Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7678
7679   Actor parent = Actor::New();
7680
7681   application.GetScene().Add(parent);
7682   Vector2 stageSize(application.GetScene().GetSize());
7683
7684   Actor actor = Actor::New();
7685   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7686   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7687   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7688   actor.SetProperty(Actor::Property::INHERIT_SCALE, false);
7689   actor.SetProperty(Actor::Property::INHERIT_ORIENTATION, false);
7690   actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7691   parent.Add(actor);
7692
7693   application.SendNotification();
7694   application.Render();
7695
7696   const Vector3 expectedWorldPosition(-stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f);
7697
7698   tet_infoline("Check the world position is in the right place\n");
7699   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
7700
7701   tet_infoline("Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed");
7702   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7703   application.SendNotification();
7704   application.Render();
7705   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
7706
7707   tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed");
7708   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7709   application.SendNotification();
7710   application.Render();
7711   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
7712
7713   END_TEST;
7714 }
7715
7716 int utcDaliActorVisibilityChangeSignalSelf(void)
7717 {
7718   TestApplication application;
7719   tet_infoline("Check that the visibility change signal is called when the visibility changes for the actor itself");
7720
7721   Actor actor = Actor::New();
7722
7723   VisibilityChangedFunctorData data;
7724   DevelActor::VisibilityChangedSignal(actor).Connect(&application, VisibilityChangedFunctor(data));
7725
7726   actor.SetProperty(Actor::Property::VISIBLE, false);
7727
7728   data.Check(true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7729
7730   tet_infoline("Ensure functor is not called if we attempt to change the visibility to what it already is at");
7731   data.Reset();
7732
7733   actor.SetProperty(Actor::Property::VISIBLE, false);
7734   data.Check(false /* not called */, TEST_LOCATION);
7735
7736   tet_infoline("Change the visibility using properties, ensure called");
7737   data.Reset();
7738
7739   actor.SetProperty(Actor::Property::VISIBLE, true);
7740   data.Check(true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7741
7742   tet_infoline("Set the visibility to current using properties, ensure not called");
7743   data.Reset();
7744
7745   actor.SetProperty(Actor::Property::VISIBLE, true);
7746   data.Check(false /* not called */, TEST_LOCATION);
7747
7748   END_TEST;
7749 }
7750
7751 int utcDaliActorVisibilityChangeSignalChildren(void)
7752 {
7753   TestApplication application;
7754   tet_infoline("Check that the visibility change signal is called for the children when the visibility changes for the parent");
7755
7756   Actor parent = Actor::New();
7757   Actor child  = Actor::New();
7758   parent.Add(child);
7759
7760   Actor grandChild = Actor::New();
7761   child.Add(grandChild);
7762
7763   VisibilityChangedFunctorData parentData;
7764   VisibilityChangedFunctorData childData;
7765   VisibilityChangedFunctorData grandChildData;
7766
7767   tet_infoline("Only connect the child and grandchild, ensure they are called and not the parent");
7768   DevelActor::VisibilityChangedSignal(child).Connect(&application, VisibilityChangedFunctor(childData));
7769   DevelActor::VisibilityChangedSignal(grandChild).Connect(&application, VisibilityChangedFunctor(grandChildData));
7770
7771   parent.SetProperty(Actor::Property::VISIBLE, false);
7772   parentData.Check(false /* not called */, TEST_LOCATION);
7773   childData.Check(true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7774   grandChildData.Check(true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7775
7776   tet_infoline("Connect to the parent's signal as well and ensure all three are called");
7777   parentData.Reset();
7778   childData.Reset();
7779   grandChildData.Reset();
7780
7781   DevelActor::VisibilityChangedSignal(parent).Connect(&application, VisibilityChangedFunctor(parentData));
7782
7783   parent.SetProperty(Actor::Property::VISIBLE, true);
7784   parentData.Check(true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7785   childData.Check(true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7786   grandChildData.Check(true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7787
7788   tet_infoline("Ensure none of the functors are called if we attempt to change the visibility to what it already is at");
7789   parentData.Reset();
7790   childData.Reset();
7791   grandChildData.Reset();
7792
7793   parent.SetProperty(Actor::Property::VISIBLE, true);
7794   parentData.Check(false /* not called */, TEST_LOCATION);
7795   childData.Check(false /* not called */, TEST_LOCATION);
7796   grandChildData.Check(false /* not called */, TEST_LOCATION);
7797
7798   END_TEST;
7799 }
7800
7801 int utcDaliActorVisibilityChangeSignalAfterAnimation(void)
7802 {
7803   TestApplication application;
7804   tet_infoline("Check that the visibility change signal is emitted when the visibility changes when an animation starts");
7805
7806   Actor actor = Actor::New();
7807   application.GetScene().Add(actor);
7808
7809   application.SendNotification();
7810   application.Render();
7811
7812   VisibilityChangedFunctorData data;
7813   DevelActor::VisibilityChangedSignal(actor).Connect(&application, VisibilityChangedFunctor(data));
7814
7815   Animation animation = Animation::New(1.0f);
7816   animation.AnimateTo(Property(actor, Actor::Property::VISIBLE), false);
7817
7818   data.Check(false, TEST_LOCATION);
7819   DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7820   DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7821
7822   tet_infoline("Play the animation and check the property value");
7823   animation.Play();
7824
7825   data.Check(true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7826   DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::VISIBLE), false, TEST_LOCATION);
7827
7828   tet_infoline("Animation not currently finished, so the current visibility should still be true");
7829   DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7830
7831   application.SendNotification();
7832   application.Render(1100); // After the animation
7833
7834   DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), false, TEST_LOCATION);
7835
7836   END_TEST;
7837 }
7838
7839 int utcDaliActorVisibilityChangeSignalByName(void)
7840 {
7841   TestApplication application;
7842   tet_infoline("Check that the visibility change signal is called when the visibility changes for the actor itself");
7843
7844   Actor actor = Actor::New();
7845
7846   bool signalCalled = false;
7847   actor.ConnectSignal(&application, "visibilityChanged", VisibilityChangedVoidFunctor(signalCalled));
7848   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7849   actor.SetProperty(Actor::Property::VISIBLE, false);
7850   DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7851
7852   tet_infoline("Ensure functor is not called if we attempt to change the visibility to what it already is at");
7853   signalCalled = false;
7854   actor.SetProperty(Actor::Property::VISIBLE, false);
7855   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7856
7857   tet_infoline("Change the visibility using properties, ensure called");
7858   actor.SetProperty(Actor::Property::VISIBLE, true);
7859   DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7860
7861   tet_infoline("Set the visibility to current using properties, ensure not called");
7862   signalCalled = false;
7863
7864   actor.SetProperty(Actor::Property::VISIBLE, true);
7865   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7866
7867   END_TEST;
7868 }
7869
7870 static void LayoutDirectionChanged(Actor actor, LayoutDirection::Type type)
7871 {
7872   gLayoutDirectionType = type;
7873 }
7874
7875 int UtcDaliActorLayoutDirectionProperty(void)
7876 {
7877   TestApplication application;
7878   tet_infoline("Check layout direction property");
7879
7880   Actor actor0 = Actor::New();
7881   DALI_TEST_EQUALS(actor0.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7882   application.GetScene().Add(actor0);
7883
7884   application.SendNotification();
7885   application.Render();
7886
7887   Actor actor1 = Actor::New();
7888   DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7889   Actor actor2 = Actor::New();
7890   DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7891   Actor actor3 = Actor::New();
7892   DALI_TEST_EQUALS(actor3.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7893   Actor actor4 = Actor::New();
7894   DALI_TEST_EQUALS(actor4.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7895   Actor actor5 = Actor::New();
7896   DALI_TEST_EQUALS(actor5.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7897   Actor actor6 = Actor::New();
7898   DALI_TEST_EQUALS(actor6.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7899   Actor actor7 = Actor::New();
7900   DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7901   Actor actor8 = Actor::New();
7902   DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7903   Actor actor9 = Actor::New();
7904   DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7905
7906   actor1.Add(actor2);
7907   gLayoutDirectionType = LayoutDirection::LEFT_TO_RIGHT;
7908   actor2.LayoutDirectionChangedSignal().Connect(LayoutDirectionChanged);
7909
7910   DALI_TEST_EQUALS(actor1.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), true, TEST_LOCATION);
7911   actor1.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
7912   DALI_TEST_EQUALS(actor1.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), false, TEST_LOCATION);
7913
7914   DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7915   DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7916   DALI_TEST_EQUALS(gLayoutDirectionType, LayoutDirection::RIGHT_TO_LEFT, TEST_LOCATION);
7917
7918   actor1.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, true);
7919   actor0.Add(actor1);
7920   DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7921   DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7922
7923   application.GetScene().Add(actor3);
7924   actor3.Add(actor4);
7925   actor4.Add(actor5);
7926   actor5.Add(actor6);
7927   actor5.Add(actor7);
7928   actor7.Add(actor8);
7929   actor8.Add(actor9);
7930   actor3.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7931   actor5.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7932
7933   DALI_TEST_EQUALS(actor8.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), true, TEST_LOCATION);
7934   actor8.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, false);
7935   DALI_TEST_EQUALS(actor8.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), false, TEST_LOCATION);
7936
7937   actor7.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7938
7939   DALI_TEST_EQUALS(actor3.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7940   DALI_TEST_EQUALS(actor4.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7941   DALI_TEST_EQUALS(actor5.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7942   DALI_TEST_EQUALS(actor6.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7943   DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7944   DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7945   DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7946
7947   actor8.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7948   DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7949   DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7950
7951   actor7.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7952   DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7953   DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7954   DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7955
7956   actor8.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, true);
7957   DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7958   DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7959
7960   END_TEST;
7961 }
7962
7963 struct LayoutDirectionFunctor
7964 {
7965   LayoutDirectionFunctor(bool& signalCalled)
7966   : mSignalCalled(signalCalled)
7967   {
7968   }
7969
7970   LayoutDirectionFunctor(const LayoutDirectionFunctor& rhs)
7971   : mSignalCalled(rhs.mSignalCalled)
7972   {
7973   }
7974
7975   void operator()()
7976   {
7977     mSignalCalled = true;
7978   }
7979
7980   bool& mSignalCalled;
7981 };
7982
7983 int UtcDaliActorLayoutDirectionSignal(void)
7984 {
7985   TestApplication application;
7986   tet_infoline("Check changing layout direction property sends a signal");
7987
7988   Actor actor = Actor::New();
7989   DALI_TEST_EQUALS(actor.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7990   application.GetScene().Add(actor);
7991   bool                   signalCalled = false;
7992   LayoutDirectionFunctor layoutDirectionFunctor(signalCalled);
7993
7994   actor.ConnectSignal(&application, "layoutDirectionChanged", layoutDirectionFunctor);
7995   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7996
7997   // Test that writing the same value doesn't send a signal
7998   actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7999   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
8000
8001   // Test that writing a different value sends the signal
8002   signalCalled = false;
8003   actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
8004   DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
8005
8006   signalCalled = false;
8007   actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
8008   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
8009
8010   END_TEST;
8011 }
8012
8013 struct ChildAddedSignalCheck
8014 {
8015   ChildAddedSignalCheck(bool& signalReceived, Actor& childHandle)
8016   : mSignalReceived(signalReceived),
8017     mChildHandle(childHandle)
8018   {
8019   }
8020
8021   void operator()(Actor childHandle)
8022   {
8023     mSignalReceived = true;
8024     mChildHandle    = childHandle;
8025   }
8026   void operator()()
8027   {
8028     mSignalReceived = true;
8029     mChildHandle    = Actor();
8030   }
8031
8032   bool&  mSignalReceived;
8033   Actor& mChildHandle;
8034 };
8035
8036 int UtcDaliChildAddedSignalP1(void)
8037 {
8038   TestApplication application;
8039   auto            stage = application.GetScene();
8040
8041   bool  signalReceived = false;
8042   Actor childActor;
8043
8044   ChildAddedSignalCheck signal(signalReceived, childActor);
8045   DevelActor::ChildAddedSignal(stage.GetRootLayer()).Connect(&application, signal);
8046   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8047
8048   auto actorA = Actor::New();
8049   stage.Add(actorA);
8050   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8051   DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
8052   signalReceived = false;
8053
8054   auto actorB = Actor::New();
8055   stage.Add(actorB);
8056   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8057   DALI_TEST_EQUALS(childActor, actorB, TEST_LOCATION);
8058
8059   END_TEST;
8060 }
8061
8062 int UtcDaliChildAddedSignalP2(void)
8063 {
8064   TestApplication application;
8065   auto            stage = application.GetScene();
8066
8067   bool  signalReceived = false;
8068   Actor childActor;
8069
8070   ChildAddedSignalCheck signal(signalReceived, childActor);
8071   tet_infoline("Connect to childAdded signal by name");
8072
8073   stage.GetRootLayer().ConnectSignal(&application, "childAdded", signal);
8074   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8075
8076   auto actorA = Actor::New();
8077   stage.Add(actorA);
8078   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8079
8080   // Can't test which actor was added; signal signature is void() when connecting via name.
8081   signalReceived = false;
8082
8083   auto actorB = Actor::New();
8084   stage.Add(actorB);
8085   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8086
8087   END_TEST;
8088 }
8089
8090 int UtcDaliChildAddedSignalN(void)
8091 {
8092   TestApplication application;
8093   auto            stage = application.GetScene();
8094
8095   bool  signalReceived = false;
8096   Actor childActor;
8097
8098   ChildAddedSignalCheck signal(signalReceived, childActor);
8099   DevelActor::ChildAddedSignal(stage.GetRootLayer()).Connect(&application, signal);
8100   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8101
8102   auto actorA = Actor::New();
8103   stage.Add(actorA);
8104   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8105   DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
8106   signalReceived = false;
8107
8108   auto actorB = Actor::New();
8109   actorA.Add(actorB);
8110   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8111   END_TEST;
8112 }
8113
8114 struct ChildRemovedSignalCheck
8115 {
8116   ChildRemovedSignalCheck(bool& signalReceived, Actor& childHandle)
8117   : mSignalReceived(signalReceived),
8118     mChildHandle(childHandle)
8119   {
8120   }
8121
8122   void operator()(Actor childHandle)
8123   {
8124     mSignalReceived = true;
8125     mChildHandle    = childHandle;
8126   }
8127
8128   void operator()()
8129   {
8130     mSignalReceived = true;
8131   }
8132
8133   bool&  mSignalReceived;
8134   Actor& mChildHandle;
8135 };
8136
8137 int UtcDaliChildRemovedSignalP1(void)
8138 {
8139   TestApplication application;
8140   auto            stage = application.GetScene();
8141
8142   bool  signalReceived = false;
8143   Actor childActor;
8144
8145   ChildRemovedSignalCheck signal(signalReceived, childActor);
8146   DevelActor::ChildRemovedSignal(stage.GetRootLayer()).Connect(&application, signal);
8147   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8148
8149   auto actorA = Actor::New();
8150   stage.Add(actorA);
8151   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8152   DALI_TEST_CHECK(!childActor);
8153
8154   stage.Remove(actorA);
8155   DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
8156   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8157
8158   signalReceived = false;
8159   auto actorB    = Actor::New();
8160   stage.Add(actorB);
8161   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8162
8163   stage.Remove(actorB);
8164   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8165   DALI_TEST_EQUALS(childActor, actorB, TEST_LOCATION);
8166
8167   END_TEST;
8168 }
8169
8170 int UtcDaliChildRemovedSignalP2(void)
8171 {
8172   TestApplication application;
8173   auto            stage = application.GetScene();
8174
8175   bool  signalReceived = false;
8176   Actor childActor;
8177
8178   ChildAddedSignalCheck signal(signalReceived, childActor);
8179   tet_infoline("Connect to childRemoved signal by name");
8180
8181   stage.GetRootLayer().ConnectSignal(&application, "childRemoved", signal);
8182   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8183
8184   auto actorA = Actor::New();
8185   stage.Add(actorA);
8186   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8187
8188   stage.Remove(actorA);
8189   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8190
8191   signalReceived = false;
8192   auto actorB    = Actor::New();
8193   stage.Add(actorB);
8194   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8195
8196   stage.Remove(actorB);
8197   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8198
8199   END_TEST;
8200 }
8201
8202 int UtcDaliChildRemovedSignalN(void)
8203 {
8204   TestApplication application;
8205   auto            stage = application.GetScene();
8206
8207   bool  signalReceived = false;
8208   Actor childActor;
8209
8210   ChildRemovedSignalCheck signal(signalReceived, childActor);
8211   DevelActor::ChildRemovedSignal(stage.GetRootLayer()).Connect(&application, signal);
8212   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8213
8214   auto actorA = Actor::New();
8215   stage.Add(actorA);
8216
8217   auto actorB = Actor::New();
8218   actorA.Add(actorB);
8219
8220   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8221   DALI_TEST_CHECK(!childActor);
8222
8223   actorA.Remove(actorB);
8224   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8225   END_TEST;
8226 }
8227
8228 int UtcDaliChildMovedSignalP(void)
8229 {
8230   TestApplication application;
8231   auto            stage = application.GetScene();
8232
8233   bool  addedASignalReceived   = false;
8234   bool  removedASignalReceived = false;
8235   bool  addedBSignalReceived   = false;
8236   bool  removedBSignalReceived = false;
8237   Actor childActor;
8238
8239   auto actorA = Actor::New();
8240   auto actorB = Actor::New();
8241   stage.Add(actorA);
8242   stage.Add(actorB);
8243
8244   ChildAddedSignalCheck   addedSignalA(addedASignalReceived, childActor);
8245   ChildRemovedSignalCheck removedSignalA(removedASignalReceived, childActor);
8246   ChildAddedSignalCheck   addedSignalB(addedBSignalReceived, childActor);
8247   ChildRemovedSignalCheck removedSignalB(removedBSignalReceived, childActor);
8248
8249   DevelActor::ChildAddedSignal(actorA).Connect(&application, addedSignalA);
8250   DevelActor::ChildRemovedSignal(actorA).Connect(&application, removedSignalA);
8251   DevelActor::ChildAddedSignal(actorB).Connect(&application, addedSignalB);
8252   DevelActor::ChildRemovedSignal(actorB).Connect(&application, removedSignalB);
8253
8254   DALI_TEST_EQUALS(addedASignalReceived, false, TEST_LOCATION);
8255   DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
8256   DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
8257   DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
8258
8259   // Create a child of A
8260
8261   auto child = Actor::New();
8262   actorA.Add(child);
8263
8264   DALI_TEST_EQUALS(addedASignalReceived, true, TEST_LOCATION);
8265   DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
8266   DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
8267   DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
8268   DALI_TEST_EQUALS(childActor, child, TEST_LOCATION);
8269
8270   // Move child to B:
8271   addedASignalReceived   = false;
8272   addedBSignalReceived   = false;
8273   removedASignalReceived = false;
8274   removedBSignalReceived = false;
8275
8276   actorB.Add(child); // Expect this child to be re-parented
8277   DALI_TEST_EQUALS(addedASignalReceived, false, TEST_LOCATION);
8278   DALI_TEST_EQUALS(removedASignalReceived, true, TEST_LOCATION);
8279   DALI_TEST_EQUALS(addedBSignalReceived, true, TEST_LOCATION);
8280   DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
8281
8282   // Move child back to A:
8283   addedASignalReceived   = false;
8284   addedBSignalReceived   = false;
8285   removedASignalReceived = false;
8286   removedBSignalReceived = false;
8287
8288   actorA.Add(child); // Expect this child to be re-parented
8289   DALI_TEST_EQUALS(addedASignalReceived, true, TEST_LOCATION);
8290   DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
8291   DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
8292   DALI_TEST_EQUALS(removedBSignalReceived, true, TEST_LOCATION);
8293
8294   END_TEST;
8295 }
8296
8297 int UtcDaliActorSwitchParentP(void)
8298 {
8299   tet_infoline("Testing Actor::UtcDaliActorSwitchParentP");
8300   TestApplication application;
8301
8302   Actor parent1 = Actor::New();
8303   Actor child   = Actor::New();
8304
8305   application.GetScene().Add(parent1);
8306
8307   DALI_TEST_EQUALS(parent1.GetChildCount(), 0u, TEST_LOCATION);
8308
8309   child.OnSceneSignal().Connect(OnSceneCallback);
8310   child.OffSceneSignal().Connect(OffSceneCallback);
8311
8312   // sanity check
8313   DALI_TEST_CHECK(gOnSceneCallBackCalled == 0);
8314   DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
8315
8316   parent1.Add(child);
8317
8318   DALI_TEST_EQUALS(parent1.GetChildCount(), 1u, TEST_LOCATION);
8319
8320   DALI_TEST_CHECK(gOnSceneCallBackCalled == 1);
8321   DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
8322
8323   Actor parent2 = Actor::New();
8324   application.GetScene().Add(parent2);
8325
8326   bool                  addSignalReceived = false;
8327   ChildAddedSignalCheck addedSignal(addSignalReceived, child);
8328   DevelActor::ChildAddedSignal(application.GetScene().GetRootLayer()).Connect(&application, addedSignal);
8329   DALI_TEST_EQUALS(addSignalReceived, false, TEST_LOCATION);
8330
8331   bool                    removedSignalReceived = false;
8332   ChildRemovedSignalCheck removedSignal(removedSignalReceived, child);
8333   DevelActor::ChildRemovedSignal(application.GetScene().GetRootLayer()).Connect(&application, removedSignal);
8334   DALI_TEST_EQUALS(removedSignalReceived, false, TEST_LOCATION);
8335
8336   DevelActor::SwitchParent(child, parent2);
8337
8338   DALI_TEST_EQUALS(addSignalReceived, false, TEST_LOCATION);
8339   DALI_TEST_EQUALS(removedSignalReceived, false, TEST_LOCATION);
8340
8341   DALI_TEST_EQUALS(parent1.GetChildCount(), 0u, TEST_LOCATION);
8342   DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
8343
8344   DALI_TEST_CHECK(gOnSceneCallBackCalled == 1);
8345   DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
8346   DALI_TEST_CHECK(child.GetProperty<bool>(Dali::Actor::Property::CONNECTED_TO_SCENE));
8347   DALI_TEST_CHECK(child.GetParent() == parent2);
8348
8349   END_TEST;
8350 }
8351
8352 int utcDaliActorCulled(void)
8353 {
8354   TestApplication application;
8355   auto            stage = application.GetScene();
8356
8357   tet_infoline("Check that the actor is culled if the actor is out of the screen");
8358
8359   Actor actor = Actor::New();
8360   actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
8361
8362   Geometry geometry = CreateQuadGeometry();
8363   Shader   shader   = CreateShader();
8364   Renderer renderer = Renderer::New(geometry, shader);
8365   actor.AddRenderer(renderer);
8366
8367   stage.Add(actor);
8368
8369   application.SendNotification();
8370   application.Render(0);
8371
8372   DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::CULLED), false, TEST_LOCATION);
8373
8374   PropertyNotification notification = actor.AddPropertyNotification(Actor::Property::CULLED, LessThanCondition(0.5f));
8375   notification.SetNotifyMode(PropertyNotification::NOTIFY_ON_CHANGED);
8376
8377   // Connect NotifySignal
8378   bool                              propertyNotificationSignal(false);
8379   PropertyNotification              source;
8380   CulledPropertyNotificationFunctor f(propertyNotificationSignal, source);
8381   notification.NotifySignal().Connect(&application, f);
8382
8383   actor.SetProperty(Actor::Property::POSITION, Vector2(1000.0f, 1000.0f));
8384
8385   application.SendNotification();
8386   application.Render();
8387
8388   application.SendNotification();
8389
8390   DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::CULLED), true, TEST_LOCATION);
8391
8392   DALI_TEST_EQUALS(propertyNotificationSignal, true, TEST_LOCATION);
8393   DALI_TEST_EQUALS(source.GetTargetProperty(), static_cast<int>(Actor::Property::CULLED), TEST_LOCATION);
8394   DALI_TEST_EQUALS(source.GetTarget().GetProperty<bool>(source.GetTargetProperty()), true, TEST_LOCATION);
8395
8396   END_TEST;
8397 }
8398
8399 int utcDaliEnsureRenderWhenRemovingLastRenderableActor(void)
8400 {
8401   TestApplication application;
8402   auto            stage = application.GetScene();
8403
8404   tet_infoline("Ensure we clear the screen when the last actor is removed");
8405
8406   Actor actor = CreateRenderableActor();
8407   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
8408   stage.Add(actor);
8409
8410   application.SendNotification();
8411   application.Render();
8412
8413   auto&      glAbstraction    = application.GetGlAbstraction();
8414   const auto clearCountBefore = glAbstraction.GetClearCountCalled();
8415
8416   actor.Unparent();
8417
8418   application.SendNotification();
8419   application.Render();
8420
8421   DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION);
8422
8423   END_TEST;
8424 }
8425
8426 int utcDaliEnsureRenderWhenMakingLastActorInvisible(void)
8427 {
8428   TestApplication application;
8429   auto            stage = application.GetScene();
8430
8431   tet_infoline("Ensure we clear the screen when the last actor is made invisible");
8432
8433   Actor actor = CreateRenderableActor();
8434   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
8435   stage.Add(actor);
8436
8437   application.SendNotification();
8438   application.Render();
8439
8440   auto&      glAbstraction    = application.GetGlAbstraction();
8441   const auto clearCountBefore = glAbstraction.GetClearCountCalled();
8442
8443   actor.SetProperty(Actor::Property::VISIBLE, false);
8444
8445   application.SendNotification();
8446   application.Render();
8447
8448   DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION);
8449
8450   END_TEST;
8451 }
8452
8453 int utcDaliActorGetSizeAfterAnimation(void)
8454 {
8455   TestApplication application;
8456   tet_infoline("Check the actor size before / after an animation is finished");
8457
8458   Vector3 actorSize(100.0f, 100.0f, 0.0f);
8459
8460   Actor actor = Actor::New();
8461   actor.SetProperty(Actor::Property::SIZE, actorSize);
8462   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8463   application.GetScene().Add(actor);
8464
8465   // Size should be updated without rendering.
8466   Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8467   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8468
8469   application.SendNotification();
8470   application.Render();
8471
8472   // Size and current size should be updated.
8473   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8474   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8475   DALI_TEST_EQUALS(actorSize.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8476   DALI_TEST_EQUALS(actorSize.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8477   DALI_TEST_EQUALS(actorSize.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8478
8479   Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8480   DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8481   DALI_TEST_EQUALS(actorSize.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8482   DALI_TEST_EQUALS(actorSize.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8483   DALI_TEST_EQUALS(actorSize.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8484
8485   // Set size again
8486   actorSize = Vector3(200.0f, 200.0f, 0.0f);
8487   actor.SetProperty(Actor::Property::SIZE, actorSize);
8488
8489   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8490   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8491
8492   Vector3 targetValue(10.0f, 20.0f, 0.0f);
8493
8494   Animation animation = Animation::New(1.0f);
8495   animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
8496   animation.Play();
8497
8498   // Size should be updated without rendering.
8499   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8500   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8501
8502   application.SendNotification();
8503   application.Render(1100); // After the animation
8504
8505   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8506   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8507   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8508   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8509   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8510
8511   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8512   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8513   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8514   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8515   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8516
8517   targetValue.width = 50.0f;
8518
8519   animation.Clear();
8520   animation.AnimateTo(Property(actor, Actor::Property::SIZE_WIDTH), targetValue.width);
8521   animation.Play();
8522
8523   application.SendNotification();
8524   application.Render(1100); // After the animation
8525
8526   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8527   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8528   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8529   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8530   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8531
8532   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8533   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8534   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8535   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8536   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8537
8538   targetValue.height = 70.0f;
8539
8540   animation.Clear();
8541   animation.AnimateTo(Property(actor, Actor::Property::SIZE_HEIGHT), targetValue.height);
8542   animation.Play();
8543
8544   application.SendNotification();
8545   application.Render(1100); // After the animation
8546
8547   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8548   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8549   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8550   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8551   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8552
8553   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8554   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8555   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8556   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8557   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8558
8559   Vector3 offset(10.0f, 20.0f, 0.0f);
8560
8561   animation.Clear();
8562   animation.AnimateBy(Property(actor, Actor::Property::SIZE), offset);
8563   animation.Play();
8564
8565   application.SendNotification();
8566   application.Render(1100); // After the animation
8567
8568   targetValue += offset;
8569
8570   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8571   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8572   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8573   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8574   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8575
8576   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8577   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8578   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8579   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8580   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8581
8582   offset.width = 20.0f;
8583
8584   animation.Clear();
8585   animation.AnimateBy(Property(actor, Actor::Property::SIZE_WIDTH), offset.width);
8586   animation.Play();
8587
8588   application.SendNotification();
8589   application.Render(1100); // After the animation
8590
8591   targetValue.width += offset.width;
8592
8593   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8594   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8595   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8596   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8597   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8598
8599   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8600   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8601   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8602   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8603   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8604
8605   offset.height = 10.0f;
8606
8607   animation.Clear();
8608   animation.AnimateBy(Property(actor, Actor::Property::SIZE_HEIGHT), offset.height);
8609   animation.Play();
8610
8611   application.SendNotification();
8612   application.Render(1100); // After the animation
8613
8614   targetValue.height += offset.height;
8615
8616   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8617   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8618   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8619   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8620   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8621
8622   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8623   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8624   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8625   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8626   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8627
8628   // Set size again
8629   actorSize = Vector3(300.0f, 300.0f, 0.0f);
8630
8631   actor.SetProperty(Actor::Property::SIZE, actorSize);
8632
8633   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8634   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8635
8636   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8637   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8638
8639   application.SendNotification();
8640   application.Render();
8641
8642   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8643   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8644
8645   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8646   DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8647
8648   END_TEST;
8649 }
8650
8651 int utcDaliActorGetSizeAfterAnimation2(void)
8652 {
8653   TestApplication application;
8654   tet_infoline("Check the actor size before / after an animation is finished if before size is equal to animation target size");
8655
8656   Vector3 actorSize(100.0f, 100.0f, 0.0f);
8657
8658   Actor actor = Actor::New();
8659   actor.SetProperty(Actor::Property::SIZE, actorSize);
8660   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8661   application.GetScene().Add(actor);
8662
8663   // Size should be updated without rendering.
8664   Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8665   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8666
8667   application.SendNotification();
8668   application.Render();
8669
8670   // Size and current size should be updated.
8671   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8672   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8673   DALI_TEST_EQUALS(actorSize.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8674   DALI_TEST_EQUALS(actorSize.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8675   DALI_TEST_EQUALS(actorSize.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8676
8677   Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8678   DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8679   DALI_TEST_EQUALS(actorSize.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8680   DALI_TEST_EQUALS(actorSize.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8681   DALI_TEST_EQUALS(actorSize.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8682
8683   // Set size again
8684   actorSize = Vector3(200.0f, 200.0f, 0.0f);
8685   actor.SetProperty(Actor::Property::SIZE, actorSize);
8686
8687   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8688   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8689
8690   Vector3 targetValue(actorSize);
8691
8692   Animation animation = Animation::New(1.0f);
8693   animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
8694   animation.Play();
8695
8696   // Size should be updated without rendering.
8697   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8698   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8699
8700   application.SendNotification();
8701   application.Render(100); // During the animation
8702
8703   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8704   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8705   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8706   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8707   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8708
8709   // We should get target value because targetValue is equal to current actor size.
8710   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8711   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8712   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8713   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8714   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8715
8716   application.SendNotification();
8717   application.Render(1000); // After animation finished
8718
8719   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8720   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8721
8722   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8723   DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8724
8725   END_TEST;
8726 }
8727
8728 int utcDaliActorRelayoutAndAnimation(void)
8729 {
8730   TestApplication application;
8731   tet_infoline("Check the actor size when relayoutting and playing animation");
8732
8733   Vector3 parentSize(300.0f, 300.0f, 0.0f);
8734   Vector3 actorSize(100.0f, 100.0f, 0.0f);
8735
8736   {
8737     Actor parentA = Actor::New();
8738     parentA.SetProperty(Actor::Property::SIZE, parentSize);
8739     parentA.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8740     application.GetScene().Add(parentA);
8741
8742     Actor parentB = Actor::New();
8743     parentB.SetProperty(Actor::Property::SIZE, parentSize);
8744     parentB.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8745     application.GetScene().Add(parentB);
8746
8747     Actor actor = Actor::New();
8748     actor.SetProperty(Actor::Property::SIZE, actorSize);
8749     actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8750     parentA.Add(actor);
8751
8752     Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8753     DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8754
8755     Vector3 targetValue(200.0f, 200.0f, 0.0f);
8756
8757     Animation animation = Animation::New(1.0f);
8758     animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
8759     animation.Play();
8760
8761     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8762     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8763
8764     application.SendNotification();
8765     application.Render(1100); // After the animation
8766
8767     // Size and current size should be updated.
8768     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8769     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8770
8771     Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8772     DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8773
8774     // Trigger relayout
8775     parentB.Add(actor);
8776
8777     application.SendNotification();
8778     application.Render();
8779
8780     // Size and current size should be same.
8781     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8782     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8783
8784     currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8785     DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8786
8787     actor.Unparent();
8788     parentA.Unparent();
8789     parentB.Unparent();
8790   }
8791
8792   {
8793     Actor parentA = Actor::New();
8794     parentA.SetProperty(Actor::Property::SIZE, parentSize);
8795     parentA.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8796     application.GetScene().Add(parentA);
8797
8798     Actor parentB = Actor::New();
8799     parentB.SetProperty(Actor::Property::SIZE, parentSize);
8800     parentB.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8801     application.GetScene().Add(parentB);
8802
8803     Actor actor = Actor::New();
8804     actor.SetProperty(Actor::Property::SIZE, actorSize);
8805     actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8806     parentA.Add(actor);
8807
8808     Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8809     DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8810
8811     application.SendNotification();
8812     application.Render();
8813
8814     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8815     DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8816
8817     Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8818     DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8819
8820     Vector3 targetValue(200.0f, 200.0f, 0.0f);
8821
8822     // Make an animation
8823     Animation animation = Animation::New(1.0f);
8824     animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
8825     animation.Play();
8826
8827     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8828     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8829
8830     application.SendNotification();
8831     application.Render(1100); // After the animation
8832
8833     // Size and current size should be updated.
8834     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8835     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8836
8837     currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8838     DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8839
8840     // Trigger relayout
8841     parentB.Add(actor);
8842
8843     application.SendNotification();
8844     application.Render();
8845
8846     // Size and current size should be same.
8847     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8848     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8849
8850     currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8851     DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8852
8853     actor.Unparent();
8854     parentA.Unparent();
8855     parentB.Unparent();
8856   }
8857
8858   END_TEST;
8859 }
8860
8861 int utcDaliActorPartialUpdate(void)
8862 {
8863   TestApplication application(
8864     TestApplication::DEFAULT_SURFACE_WIDTH,
8865     TestApplication::DEFAULT_SURFACE_HEIGHT,
8866     TestApplication::DEFAULT_HORIZONTAL_DPI,
8867     TestApplication::DEFAULT_VERTICAL_DPI,
8868     true,
8869     true);
8870
8871   tet_infoline("Check the damaged area");
8872
8873   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8874
8875   std::vector<Rect<int>> damagedRects;
8876   Rect<int>              clippingRect;
8877   application.SendNotification();
8878   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8879
8880   // First render pass, nothing to render, adaptor would just do swap buffer.
8881   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8882
8883   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8884   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8885
8886   Actor actor = CreateRenderableActor();
8887   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8888   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8889   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8890   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8891   application.GetScene().Add(actor);
8892
8893   application.SendNotification();
8894
8895   // 1. Actor added, damaged rect is added size of actor
8896   damagedRects.clear();
8897   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8898   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8899
8900   // Aligned by 16
8901   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
8902   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
8903   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8904   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8905   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8906   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8907   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8908
8909   // 2. Set new size
8910   actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0));
8911   application.SendNotification();
8912
8913   damagedRects.clear();
8914   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8915   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8916
8917   // Aligned by 16
8918   clippingRect = Rect<int>(16, 752, 48, 48); // in screen coordinates
8919   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
8920   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8921   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8922   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8923   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8924   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8925
8926   // 3. Set new position
8927   actor.SetProperty(Actor::Property::POSITION, Vector3(32.0f, 32.0f, 0));
8928   application.SendNotification();
8929
8930   damagedRects.clear();
8931   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8932   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8933
8934   // Aligned by 16
8935   clippingRect = Rect<int>(16, 736, 64, 64); // in screen coordinates
8936   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
8937   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8938   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8939   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8940   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8941   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8942
8943   application.GetScene().Remove(actor);
8944   application.SendNotification();
8945
8946   // Actor removed, last a dirty rect is reported.
8947   damagedRects.clear();
8948   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8949   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8950
8951   clippingRect = damagedRects[0];
8952
8953   DALI_TEST_EQUALS(clippingRect.IsValid(), true, TEST_LOCATION);
8954   DALI_TEST_EQUALS<Rect<int>>(clippingRect, Rect<int>(32, 736, 48, 48), TEST_LOCATION);
8955
8956   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8957   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8958   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8959   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8960   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8961
8962   END_TEST;
8963 }
8964
8965 int utcDaliActorPartialUpdateSetColor(void)
8966 {
8967   TestApplication application(
8968     TestApplication::DEFAULT_SURFACE_WIDTH,
8969     TestApplication::DEFAULT_SURFACE_HEIGHT,
8970     TestApplication::DEFAULT_HORIZONTAL_DPI,
8971     TestApplication::DEFAULT_VERTICAL_DPI,
8972     true,
8973     true);
8974
8975   tet_infoline("Check uniform update");
8976
8977   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8978
8979   std::vector<Rect<int>> damagedRects;
8980   Rect<int>              clippingRect;
8981   application.SendNotification();
8982   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8983
8984   // First render pass, nothing to render, adaptor would just do swap buffer.
8985   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8986
8987   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8988   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8989
8990   Actor actor = CreateRenderableActor();
8991   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8992   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8993   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8994   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8995   application.GetScene().Add(actor);
8996
8997   application.SendNotification();
8998
8999   // 1. Actor added, damaged rect is added size of actor
9000   damagedRects.clear();
9001   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9002   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9003
9004   // Aligned by 16
9005   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
9006   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9007   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9008   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9009   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9010   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9011   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9012
9013   damagedRects.clear();
9014   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9015   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9016
9017   damagedRects.clear();
9018   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9019   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9020
9021   // 2. Set new color
9022   actor.SetProperty(Actor::Property::COLOR, Vector3(1.0f, 0.0f, 0.0f));
9023   application.SendNotification();
9024
9025   damagedRects.clear();
9026   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9027   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9028
9029   // Aligned by 16
9030   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
9031   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9032   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9033   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9034   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9035   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9036   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9037
9038   END_TEST;
9039 }
9040
9041 const std::string SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME("uLightCameraProjectionMatrix");
9042 const std::string SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME("uLightCameraViewMatrix");
9043 const std::string SHADER_SHADOW_COLOR_PROPERTY_NAME("uShadowColor");
9044 const char* const RENDER_SHADOW_VERTEX_SOURCE =
9045   " uniform mediump mat4 uLightCameraProjectionMatrix;\n"
9046   " uniform mediump mat4 uLightCameraViewMatrix;\n"
9047   "\n"
9048   "void main()\n"
9049   "{\n"
9050   "  gl_Position = uProjection * uModelView * vec4(aPosition,1.0);\n"
9051   "  vec4 textureCoords = uLightCameraProjectionMatrix * uLightCameraViewMatrix * uModelMatrix  * vec4(aPosition,1.0);\n"
9052   "  vTexCoord = 0.5 + 0.5 * (textureCoords.xy/textureCoords.w);\n"
9053   "}\n";
9054
9055 const char* const RENDER_SHADOW_FRAGMENT_SOURCE =
9056   "uniform lowp vec4 uShadowColor;\n"
9057   "void main()\n"
9058   "{\n"
9059   "  lowp float alpha;\n"
9060   "  alpha = texture2D(sTexture, vec2(vTexCoord.x, vTexCoord.y)).a;\n"
9061   "  gl_FragColor = vec4(uShadowColor.rgb, uShadowColor.a * alpha);\n"
9062   "}\n";
9063
9064 int utcDaliActorPartialUpdateSetProperty(void)
9065 {
9066   TestApplication application(
9067     TestApplication::DEFAULT_SURFACE_WIDTH,
9068     TestApplication::DEFAULT_SURFACE_HEIGHT,
9069     TestApplication::DEFAULT_HORIZONTAL_DPI,
9070     TestApplication::DEFAULT_VERTICAL_DPI,
9071     true,
9072     true);
9073
9074   tet_infoline("Set/Update property with partial update");
9075
9076   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9077
9078   std::vector<Rect<int>> damagedRects;
9079   Rect<int>              clippingRect;
9080   application.SendNotification();
9081   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9082
9083   // First render pass, nothing to render, adaptor would just do swap buffer.
9084   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9085
9086   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9087   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9088
9089   Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 4u, 4u);
9090   Actor   actor = CreateRenderableActor(image, RENDER_SHADOW_VERTEX_SOURCE, RENDER_SHADOW_FRAGMENT_SOURCE);
9091   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9092   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
9093   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
9094   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9095   application.GetScene().Add(actor);
9096
9097   actor.RegisterProperty(SHADER_SHADOW_COLOR_PROPERTY_NAME, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
9098
9099   damagedRects.clear();
9100   application.SendNotification();
9101   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9102   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9103
9104   // Aligned by 16
9105   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
9106   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9107   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9108   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9109   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9110   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9111   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9112
9113   Property::Index shadowColorPropertyIndex = actor.GetPropertyIndex(SHADER_SHADOW_COLOR_PROPERTY_NAME);
9114   actor.SetProperty(shadowColorPropertyIndex, Vector4(1.0f, 1.0f, 0.0f, 1.0f));
9115
9116   damagedRects.clear();
9117   application.SendNotification();
9118   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9119   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9120
9121   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9122   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9123   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9124   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9125   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9126   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9127
9128   // Should be no damage rects, nothing changed
9129   damagedRects.clear();
9130   application.SendNotification();
9131   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9132   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9133
9134   // Should be 1 damage rect due to change in size
9135   damagedRects.clear();
9136   actor.SetProperty(Actor::Property::SIZE, Vector3(26.0f, 26.0f, 0.0f));
9137   application.SendNotification();
9138   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9139   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9140
9141   clippingRect = Rect<int>(16, 752, 32, 48); // new clipping rect size increased due to change in actor size
9142   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9143   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9144   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9145   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9146   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9147   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9148
9149   damagedRects.clear();
9150   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9151   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9152
9153   END_TEST;
9154 }
9155
9156 int utcDaliActorPartialUpdateTwoActors(void)
9157 {
9158   TestApplication application(
9159     TestApplication::DEFAULT_SURFACE_WIDTH,
9160     TestApplication::DEFAULT_SURFACE_HEIGHT,
9161     TestApplication::DEFAULT_HORIZONTAL_DPI,
9162     TestApplication::DEFAULT_VERTICAL_DPI,
9163     true,
9164     true);
9165
9166   tet_infoline("Check the damaged rects with partial update and two actors");
9167
9168   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9169
9170   Actor actor = CreateRenderableActor();
9171   actor.SetProperty(Actor::Property::POSITION, Vector3(100.0f, 100.0f, 0.0f));
9172   actor.SetProperty(Actor::Property::SIZE, Vector3(50.0f, 50.0f, 0.0f));
9173   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9174   application.GetScene().Add(actor);
9175
9176   Actor actor2 = CreateRenderableActor();
9177   actor2.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
9178   actor2.SetProperty(Actor::Property::SIZE, Vector3(100.0f, 100.0f, 0.0f));
9179   actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9180   application.GetScene().Add(actor2);
9181
9182   application.SendNotification();
9183   std::vector<Rect<int>> damagedRects;
9184   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9185
9186   DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
9187   DirtyRectChecker(damagedRects, {Rect<int>(64, 672, 64, 64), Rect<int>(96, 592, 112, 112)}, true, TEST_LOCATION);
9188
9189   // in screen coordinates, adaptor would calculate it using previous frames information
9190   Rect<int> clippingRect = Rect<int>(64, 592, 144, 192);
9191   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9192
9193   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9194   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9195   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9196   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9197
9198   // Change a Renderer of actor1
9199   Geometry geometry    = CreateQuadGeometry();
9200   Shader   shader      = CreateShader();
9201   Renderer newRenderer = Renderer::New(geometry, shader);
9202   Renderer renderer    = actor.GetRendererAt(0);
9203
9204   actor.RemoveRenderer(renderer);
9205   actor.AddRenderer(newRenderer);
9206
9207   damagedRects.clear();
9208
9209   application.SendNotification();
9210   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9211
9212   DALI_TEST_CHECK(damagedRects.size() > 0);
9213   DirtyRectChecker(damagedRects, {Rect<int>(64, 672, 64, 64)}, false, TEST_LOCATION);
9214
9215   // in screen coordinates, adaptor would calculate it using previous frames information
9216   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9217
9218   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9219   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9220   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9221   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9222
9223   END_TEST;
9224 }
9225
9226 int utcDaliActorPartialUpdateActorsWithSizeHint01(void)
9227 {
9228   TestApplication application(
9229     TestApplication::DEFAULT_SURFACE_WIDTH,
9230     TestApplication::DEFAULT_SURFACE_HEIGHT,
9231     TestApplication::DEFAULT_HORIZONTAL_DPI,
9232     TestApplication::DEFAULT_VERTICAL_DPI,
9233     true,
9234     true);
9235
9236   tet_infoline("Check the damaged rect with partial update and update area hint");
9237
9238   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9239
9240   Actor actor = CreateRenderableActor();
9241   actor.SetProperty(Actor::Property::POSITION, Vector3(64.0f, 64.0f, 0.0f));
9242   actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0.0f));
9243   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(0.0f, 0.0f, 64.0f, 64.0f));
9244   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9245   application.GetScene().Add(actor);
9246
9247   application.SendNotification();
9248   std::vector<Rect<int>> damagedRects;
9249   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9250
9251   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9252
9253   Rect<int> clippingRect = Rect<int>(32, 704, 80, 80);
9254   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9255
9256   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9257
9258   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9259   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9260   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9261   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9262
9263   // Reset
9264   actor.Unparent();
9265
9266   damagedRects.clear();
9267   application.SendNotification();
9268   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9269
9270   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9271   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9272
9273   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9274
9275   damagedRects.clear();
9276   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9277   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9278
9279   // Ensure the damaged rect is empty
9280   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9281
9282   // Chnage UPDATE_AREA_HINT
9283   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(16.0f, 16.0f, 32.0f, 32.0f));
9284   application.GetScene().Add(actor);
9285
9286   application.SendNotification();
9287   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9288
9289   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9290
9291   clippingRect = Rect<int>(64, 704, 48, 48);
9292   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9293
9294   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9295
9296   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9297   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9298   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9299   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9300
9301   // Reset
9302   actor.Unparent();
9303
9304   damagedRects.clear();
9305   application.SendNotification();
9306   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9307
9308   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9309   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9310
9311   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9312
9313   damagedRects.clear();
9314   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9315   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9316
9317   // Ensure the damaged rect is empty
9318   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9319
9320   // Chnage UPDATE_AREA_HINT
9321   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(-32.0f, -16.0f, 64.0f, 64.0f));
9322   application.GetScene().Add(actor);
9323
9324   application.SendNotification();
9325   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9326
9327   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9328
9329   clippingRect = Rect<int>(0, 720, 80, 80);
9330   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9331
9332   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9333
9334   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9335   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9336   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9337   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9338
9339   END_TEST;
9340 }
9341
9342 int utcDaliActorPartialUpdateActorsWithSizeHint02(void)
9343 {
9344   TestApplication application(
9345     TestApplication::DEFAULT_SURFACE_WIDTH,
9346     TestApplication::DEFAULT_SURFACE_HEIGHT,
9347     TestApplication::DEFAULT_HORIZONTAL_DPI,
9348     TestApplication::DEFAULT_VERTICAL_DPI,
9349     true,
9350     true);
9351
9352   tet_infoline("Check the damaged rect with partial update and update area hint");
9353
9354   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9355
9356   Actor actor = CreateRenderableActor();
9357   actor.SetProperty(Actor::Property::POSITION, Vector3(64.0f, 64.0f, 0.0f));
9358   actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0.0f));
9359   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9360   application.GetScene().Add(actor);
9361
9362   application.SendNotification();
9363   std::vector<Rect<int>> damagedRects;
9364   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9365
9366   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9367
9368   Rect<int> clippingRect = Rect<int>(48, 720, 48, 48);
9369   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9370
9371   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9372
9373   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9374   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9375   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9376   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9377
9378   damagedRects.clear();
9379   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9380   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9381
9382   // Ensure the damaged rect is empty
9383   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9384
9385   // Change UPDATE_AREA_HINT
9386   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(0.0f, 0.0f, 64.0f, 64.0f));
9387
9388   application.SendNotification();
9389   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9390
9391   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9392
9393   clippingRect = Rect<int>(32, 704, 80, 80);
9394   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9395
9396   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9397
9398   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9399   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9400   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9401   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9402
9403   damagedRects.clear();
9404   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9405   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9406
9407   // Ensure the damaged rect is empty
9408   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9409
9410   // Chnage UPDATE_AREA_HINT
9411   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(16.0f, 16.0f, 64.0f, 64.0f));
9412   application.GetScene().Add(actor);
9413
9414   application.SendNotification();
9415   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9416
9417   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9418
9419   clippingRect = Rect<int>(32, 688, 96, 96);
9420   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9421
9422   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9423
9424   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9425   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9426   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9427   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9428
9429   END_TEST;
9430 }
9431
9432 int utcDaliActorPartialUpdateActorsWithSizeHint03(void)
9433 {
9434   TestApplication application(
9435     TestApplication::DEFAULT_SURFACE_WIDTH,
9436     TestApplication::DEFAULT_SURFACE_HEIGHT,
9437     TestApplication::DEFAULT_HORIZONTAL_DPI,
9438     TestApplication::DEFAULT_VERTICAL_DPI,
9439     true,
9440     true);
9441
9442   tet_infoline("Check the damaged rect with partial update and update area hint");
9443
9444   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9445
9446   Actor actor = CreateRenderableActor();
9447   actor.SetProperty(Actor::Property::POSITION, Vector3(64.0f, 64.0f, 0.0f));
9448   actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0.0f));
9449   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(0.0f, 0.0f, 64.0f, 64.0f));
9450   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9451   application.GetScene().Add(actor);
9452
9453   application.SendNotification();
9454   std::vector<Rect<int>> damagedRects;
9455   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9456
9457   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9458
9459   Rect<int> clippingRect = Rect<int>(32, 704, 80, 80);
9460   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9461
9462   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9463
9464   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9465   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9466   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9467   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9468
9469   damagedRects.clear();
9470   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9471   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9472
9473   // Ensure the damaged rect is empty
9474   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9475
9476   // Set UPDATE_AREA_HINT twice before rendering
9477   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(0.0f, 0.0f, 32.0f, 32.0f));
9478   application.SendNotification();
9479
9480   actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(32.0f, -32.0f, 32.0f, 32.0f));
9481   application.SendNotification();
9482
9483   damagedRects.clear();
9484   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9485
9486   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9487
9488   clippingRect = Rect<int>(32, 704, 96, 96);
9489   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9490
9491   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9492
9493   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9494   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9495   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9496   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9497
9498   END_TEST;
9499 }
9500
9501 int utcDaliActorPartialUpdateAnimation(void)
9502 {
9503   TestApplication application(
9504     TestApplication::DEFAULT_SURFACE_WIDTH,
9505     TestApplication::DEFAULT_SURFACE_HEIGHT,
9506     TestApplication::DEFAULT_HORIZONTAL_DPI,
9507     TestApplication::DEFAULT_VERTICAL_DPI,
9508     true,
9509     true);
9510
9511   tet_infoline("Check the damaged area with partial update and animation");
9512
9513   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
9514   drawTrace.Enable(true);
9515   drawTrace.Reset();
9516
9517   Actor actor1 = CreateRenderableActor();
9518   actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9519   actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
9520   application.GetScene().Add(actor1);
9521
9522   Actor actor2 = CreateRenderableActor();
9523   actor2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9524   actor2.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
9525   application.GetScene().Add(actor2);
9526
9527   std::vector<Rect<int>> damagedRects;
9528   Rect<int>              clippingRect;
9529   Rect<int>              expectedRect1, expectedRect2;
9530
9531   application.SendNotification();
9532   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9533
9534   DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
9535
9536   // Aligned by 16
9537   expectedRect1 = Rect<int>(0, 720, 96, 96); // in screen coordinates, includes 1 last frames updates
9538   expectedRect2 = Rect<int>(0, 784, 32, 32); // in screen coordinates, includes 1 last frames updates
9539   DirtyRectChecker(damagedRects, {expectedRect1, expectedRect2}, true, TEST_LOCATION);
9540
9541   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9542   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9543
9544   // Make an animation
9545   Animation animation = Animation::New(1.0f);
9546   animation.AnimateTo(Property(actor2, Actor::Property::POSITION_X), 160.0f, TimePeriod(0.5f, 0.5f));
9547   animation.Play();
9548
9549   application.SendNotification();
9550
9551   damagedRects.clear();
9552   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9553   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9554   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9555
9556   drawTrace.Reset();
9557   damagedRects.clear();
9558
9559   // In animation deley time
9560   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9561   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9562   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9563
9564   // Skip rendering
9565   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
9566
9567   drawTrace.Reset();
9568   damagedRects.clear();
9569
9570   // Also in animation deley time
9571   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9572   application.PreRenderWithPartialUpdate(100, nullptr, damagedRects);
9573   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9574
9575   // Skip rendering
9576   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
9577
9578   // Unparent 2 actors and make a new actor
9579   actor1.Unparent();
9580   actor2.Unparent();
9581
9582   Actor actor3 = CreateRenderableActor();
9583   actor3.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9584   actor3.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
9585   application.GetScene().Add(actor3);
9586
9587   application.SendNotification();
9588
9589   // Started animation
9590   damagedRects.clear();
9591   application.PreRenderWithPartialUpdate(500, nullptr, damagedRects);
9592   DALI_TEST_EQUALS(damagedRects.size(), 3, TEST_LOCATION);
9593
9594   // One of dirty rect is actor3's.
9595   // We don't know the exact dirty rect of actor1 and actor2.
9596   DirtyRectChecker(damagedRects, {expectedRect1, expectedRect2, expectedRect2}, true, TEST_LOCATION);
9597
9598   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9599   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9600
9601   // Finished animation, but the actor was already unparented
9602   damagedRects.clear();
9603   application.PreRenderWithPartialUpdate(500, nullptr, damagedRects);
9604
9605   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9606
9607   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9608   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9609
9610   END_TEST;
9611 }
9612
9613 int utcDaliActorPartialUpdateChangeVisibility(void)
9614 {
9615   TestApplication application(
9616     TestApplication::DEFAULT_SURFACE_WIDTH,
9617     TestApplication::DEFAULT_SURFACE_HEIGHT,
9618     TestApplication::DEFAULT_HORIZONTAL_DPI,
9619     TestApplication::DEFAULT_VERTICAL_DPI,
9620     true,
9621     true);
9622
9623   tet_infoline("Check the damaged rect with partial update and visibility change");
9624
9625   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9626
9627   Actor actor = CreateRenderableActor();
9628   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9629   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
9630   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
9631   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9632   application.GetScene().Add(actor);
9633
9634   application.SendNotification();
9635
9636   std::vector<Rect<int>> damagedRects;
9637   Rect<int>              clippingRect;
9638
9639   // 1. Actor added, damaged rect is added size of actor
9640   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9641   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9642
9643   // Aligned by 16
9644   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
9645   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9646   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9647   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9648   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9649   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9650   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9651
9652   damagedRects.clear();
9653   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9654   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9655
9656   // Ensure the damaged rect is empty
9657   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9658
9659   // 2. Make the Actor invisible
9660   actor.SetProperty(Actor::Property::VISIBLE, false);
9661   application.SendNotification();
9662
9663   damagedRects.clear();
9664   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9665   DALI_TEST_CHECK(damagedRects.size() > 0);
9666   DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
9667
9668   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9669   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9670   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9671   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9672   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9673
9674   // 3. Make the Actor visible again
9675   actor.SetProperty(Actor::Property::VISIBLE, true);
9676   application.SendNotification();
9677
9678   damagedRects.clear();
9679   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9680   DALI_TEST_CHECK(damagedRects.size() > 0);
9681   DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
9682
9683   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9684   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9685   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9686   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9687   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9688
9689   END_TEST;
9690 }
9691
9692 int utcDaliActorPartialUpdateOnOffScene(void)
9693 {
9694   TestApplication application(
9695     TestApplication::DEFAULT_SURFACE_WIDTH,
9696     TestApplication::DEFAULT_SURFACE_HEIGHT,
9697     TestApplication::DEFAULT_HORIZONTAL_DPI,
9698     TestApplication::DEFAULT_VERTICAL_DPI,
9699     true,
9700     true);
9701
9702   tet_infoline("Check the damaged rect with partial update and on/off scene");
9703
9704   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9705
9706   Actor actor = CreateRenderableActor();
9707   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9708   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
9709   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
9710   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9711   application.GetScene().Add(actor);
9712
9713   application.SendNotification();
9714
9715   std::vector<Rect<int>> damagedRects;
9716   Rect<int>              clippingRect;
9717
9718   // 1. Actor added, damaged rect is added size of actor
9719   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9720   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9721
9722   // Aligned by 16
9723   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
9724   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9725   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9726   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9727   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9728   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9729   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9730
9731   damagedRects.clear();
9732   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9733   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9734
9735   damagedRects.clear();
9736   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9737   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9738
9739   // Ensure the damaged rect is empty
9740   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9741
9742   // 2. Remove the Actor from the Scene
9743   actor.Unparent();
9744   application.SendNotification();
9745
9746   damagedRects.clear();
9747   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9748   DALI_TEST_CHECK(damagedRects.size() > 0);
9749   DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
9750
9751   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9752   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9753   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9754   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9755   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9756
9757   // 3. Add the Actor to the Scene again
9758   application.GetScene().Add(actor);
9759   application.SendNotification();
9760
9761   damagedRects.clear();
9762   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9763   DALI_TEST_CHECK(damagedRects.size() > 0);
9764   DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
9765
9766   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9767   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9768   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9769   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9770   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9771
9772   END_TEST;
9773 }
9774
9775 int utcDaliActorPartialUpdateSkipRendering(void)
9776 {
9777   TestApplication application(
9778     TestApplication::DEFAULT_SURFACE_WIDTH,
9779     TestApplication::DEFAULT_SURFACE_HEIGHT,
9780     TestApplication::DEFAULT_HORIZONTAL_DPI,
9781     TestApplication::DEFAULT_VERTICAL_DPI,
9782     true,
9783     true);
9784
9785   tet_infoline("Check to skip rendering in case of the empty damaged rect");
9786
9787   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
9788   drawTrace.Enable(true);
9789   drawTrace.Reset();
9790
9791   Actor actor1 = CreateRenderableActor();
9792   actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9793   actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
9794   application.GetScene().Add(actor1);
9795
9796   std::vector<Rect<int>> damagedRects;
9797   Rect<int>              clippingRect;
9798   Rect<int>              expectedRect1;
9799
9800   application.SendNotification();
9801   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9802
9803   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9804
9805   // Aligned by 16
9806   expectedRect1 = Rect<int>(0, 720, 96, 96); // in screen coordinates
9807   DirtyRectChecker(damagedRects, {expectedRect1}, true, TEST_LOCATION);
9808
9809   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9810   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9811
9812   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9813
9814   damagedRects.clear();
9815   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9816   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9817   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9818
9819   // Remove the actor
9820   actor1.Unparent();
9821
9822   application.SendNotification();
9823
9824   damagedRects.clear();
9825   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9826
9827   DirtyRectChecker(damagedRects, {expectedRect1}, true, TEST_LOCATION);
9828
9829   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9830   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9831
9832   // Render again without any change
9833   damagedRects.clear();
9834   drawTrace.Reset();
9835   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9836
9837   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9838
9839   clippingRect = Rect<int>();
9840   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9841
9842   // Skip rendering
9843   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
9844
9845   // Add the actor again
9846   application.GetScene().Add(actor1);
9847
9848   application.SendNotification();
9849
9850   damagedRects.clear();
9851   drawTrace.Reset();
9852   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9853
9854   DirtyRectChecker(damagedRects, {expectedRect1}, true, TEST_LOCATION);
9855
9856   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9857   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9858
9859   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9860
9861   END_TEST;
9862 }
9863
9864 int utcDaliActorPartialUpdate3DNode(void)
9865 {
9866   TestApplication application(
9867     TestApplication::DEFAULT_SURFACE_WIDTH,
9868     TestApplication::DEFAULT_SURFACE_HEIGHT,
9869     TestApplication::DEFAULT_HORIZONTAL_DPI,
9870     TestApplication::DEFAULT_VERTICAL_DPI,
9871     true,
9872     true);
9873
9874   tet_infoline("Partial update should be ignored in case of 3d layer of 3d node");
9875
9876   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
9877   drawTrace.Enable(true);
9878   drawTrace.Reset();
9879
9880   Actor actor1 = CreateRenderableActor();
9881   actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9882   actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
9883   application.GetScene().Add(actor1);
9884
9885   std::vector<Rect<int>> damagedRects;
9886   Rect<int>              clippingRect;
9887
9888   application.SendNotification();
9889   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9890
9891   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9892
9893   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9894   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9895
9896   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9897
9898   // Change the layer to 3D
9899   application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D);
9900
9901   application.SendNotification();
9902
9903   damagedRects.clear();
9904   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9905
9906   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9907   DirtyRectChecker(damagedRects, {TestApplication::DEFAULT_SURFACE_RECT}, true, TEST_LOCATION);
9908
9909   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9910   drawTrace.Reset();
9911   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9912
9913   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9914
9915   // Change the layer to 2D
9916   application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_UI);
9917
9918   application.SendNotification();
9919
9920   damagedRects.clear();
9921   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9922
9923   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9924
9925   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9926   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9927
9928   // Make 3D transform
9929   actor1.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::YAXIS));
9930
9931   application.SendNotification();
9932
9933   damagedRects.clear();
9934   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9935
9936   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9937   DirtyRectChecker(damagedRects, {TestApplication::DEFAULT_SURFACE_RECT}, true, TEST_LOCATION);
9938
9939   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9940   drawTrace.Reset();
9941   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9942
9943   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9944
9945   END_TEST;
9946 }
9947
9948 int utcDaliActorPartialUpdateNotRenderableActor(void)
9949 {
9950   TestApplication application(
9951     TestApplication::DEFAULT_SURFACE_WIDTH,
9952     TestApplication::DEFAULT_SURFACE_HEIGHT,
9953     TestApplication::DEFAULT_HORIZONTAL_DPI,
9954     TestApplication::DEFAULT_VERTICAL_DPI,
9955     true,
9956     true);
9957
9958   tet_infoline("Check the damaged rect with not renderable parent actor");
9959
9960   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9961
9962   Actor parent                          = Actor::New();
9963   parent[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9964   parent[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
9965   parent[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
9966   parent.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9967   application.GetScene().Add(parent);
9968
9969   Actor child                          = CreateRenderableActor();
9970   child[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9971   child[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
9972   child.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9973   parent.Add(child);
9974
9975   application.SendNotification();
9976
9977   std::vector<Rect<int>> damagedRects;
9978
9979   // 1. Actor added, damaged rect is added size of actor
9980   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9981   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9982
9983   // Aligned by 16
9984   Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
9985   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9986
9987   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9988   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9989   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9990   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9991   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9992
9993   damagedRects.clear();
9994   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9995   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9996
9997   damagedRects.clear();
9998   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9999   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10000
10001   // Ensure the damaged rect is empty
10002   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10003
10004   END_TEST;
10005 }
10006
10007 int utcDaliActorPartialUpdateChangeTransparency(void)
10008 {
10009   TestApplication application(
10010     TestApplication::DEFAULT_SURFACE_WIDTH,
10011     TestApplication::DEFAULT_SURFACE_HEIGHT,
10012     TestApplication::DEFAULT_HORIZONTAL_DPI,
10013     TestApplication::DEFAULT_VERTICAL_DPI,
10014     true,
10015     true);
10016
10017   tet_infoline("Check the damaged rect with changing transparency");
10018
10019   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
10020
10021   Actor actor                          = CreateRenderableActor();
10022   actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10023   actor[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
10024   actor[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
10025   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10026   application.GetScene().Add(actor);
10027
10028   application.SendNotification();
10029
10030   std::vector<Rect<int>> damagedRects;
10031
10032   // Actor added, damaged rect is added size of actor
10033   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10034   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10035
10036   // Aligned by 16
10037   Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10038   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10039
10040   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10041   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
10042   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
10043   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
10044   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
10045
10046   damagedRects.clear();
10047   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10048   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10049
10050   // Ensure the damaged rect is empty
10051   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10052
10053   // Make the actor transparent by changing opacity of the Renderer
10054   // It changes a uniform value
10055   Renderer renderer                          = actor.GetRendererAt(0);
10056   renderer[DevelRenderer::Property::OPACITY] = 0.0f;
10057
10058   application.SendNotification();
10059
10060   // The damaged rect should be same
10061   damagedRects.clear();
10062   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10063   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10064   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10065   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10066
10067   damagedRects.clear();
10068   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10069   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10070
10071   // Ensure the damaged rect is empty
10072   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10073
10074   // Make the actor opaque again
10075   renderer[DevelRenderer::Property::OPACITY] = 1.0f;
10076
10077   application.SendNotification();
10078
10079   // The damaged rect should not be empty
10080   damagedRects.clear();
10081   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10082   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10083   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10084   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10085
10086   damagedRects.clear();
10087   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10088   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10089
10090   // Ensure the damaged rect is empty
10091   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10092
10093   // Make the actor translucent
10094   renderer[DevelRenderer::Property::OPACITY] = 0.5f;
10095
10096   application.SendNotification();
10097
10098   // The damaged rect should not be empty
10099   damagedRects.clear();
10100   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10101   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10102   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10103   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10104
10105   damagedRects.clear();
10106   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10107   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10108
10109   // Ensure the damaged rect is empty
10110   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10111
10112   // Change Renderer opacity - also translucent
10113   renderer[DevelRenderer::Property::OPACITY] = 0.2f;
10114
10115   application.SendNotification();
10116
10117   // The damaged rect should not be empty
10118   damagedRects.clear();
10119   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10120   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10121   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10122   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10123
10124   damagedRects.clear();
10125   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10126   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10127
10128   // Ensure the damaged rect is empty
10129   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10130
10131   // Make the actor culled
10132   actor[Actor::Property::SIZE] = Vector3(0.0f, 0.0f, 0.0f);
10133
10134   application.SendNotification();
10135
10136   // The damaged rect should be same
10137   damagedRects.clear();
10138   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10139   DALI_TEST_CHECK(damagedRects.size() > 0);
10140   DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
10141   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10142
10143   damagedRects.clear();
10144   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10145   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10146
10147   // Ensure the damaged rect is empty
10148   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10149
10150   // Make the actor not culled again
10151   actor[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 16.0f);
10152
10153   application.SendNotification();
10154
10155   // The damaged rect should not be empty
10156   damagedRects.clear();
10157   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10158   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10159   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10160   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10161
10162   END_TEST;
10163 }
10164
10165 int utcDaliActorPartialUpdateChangeParentOpacity(void)
10166 {
10167   TestApplication application(
10168     TestApplication::DEFAULT_SURFACE_WIDTH,
10169     TestApplication::DEFAULT_SURFACE_HEIGHT,
10170     TestApplication::DEFAULT_HORIZONTAL_DPI,
10171     TestApplication::DEFAULT_VERTICAL_DPI,
10172     true,
10173     true);
10174
10175   tet_infoline("Check the damaged rect with changing parent's opacity");
10176
10177   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
10178
10179   Actor parent                          = Actor::New();
10180   parent[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10181   parent[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
10182   parent[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
10183   parent.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10184   application.GetScene().Add(parent);
10185
10186   Texture texture                      = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
10187   Actor   child                        = CreateRenderableActor(texture);
10188   child[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10189   child[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
10190   child.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10191   parent.Add(child);
10192
10193   application.SendNotification();
10194
10195   std::vector<Rect<int>> damagedRects;
10196
10197   // Actor added, damaged rect is added size of actor
10198   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10199   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10200
10201   // Aligned by 16
10202   Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10203   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10204
10205   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10206   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
10207   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
10208   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
10209   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
10210
10211   damagedRects.clear();
10212   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10213   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10214
10215   damagedRects.clear();
10216   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10217   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10218
10219   // Ensure the damaged rect is empty
10220   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10221
10222   // Change the parent's opacity
10223   parent[Actor::Property::OPACITY] = 0.5f;
10224
10225   application.SendNotification();
10226
10227   // The damaged rect should be same
10228   damagedRects.clear();
10229   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10230   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10231   DALI_TEST_CHECK(damagedRects.size() > 0);
10232   DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
10233
10234   END_TEST;
10235 }
10236
10237 int utcDaliActorPartialUpdateAddRemoveRenderer(void)
10238 {
10239   TestApplication application(
10240     TestApplication::DEFAULT_SURFACE_WIDTH,
10241     TestApplication::DEFAULT_SURFACE_HEIGHT,
10242     TestApplication::DEFAULT_HORIZONTAL_DPI,
10243     TestApplication::DEFAULT_VERTICAL_DPI,
10244     true,
10245     true);
10246
10247   tet_infoline("Check the damaged rect with adding / removing renderer");
10248
10249   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
10250
10251   Actor actor                          = CreateRenderableActor();
10252   actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10253   actor[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
10254   actor[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
10255   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10256   application.GetScene().Add(actor);
10257
10258   application.SendNotification();
10259
10260   std::vector<Rect<int>> damagedRects;
10261
10262   // Actor added, damaged rect is added size of actor
10263   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10264   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10265
10266   // Aligned by 16
10267   Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10268   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10269
10270   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10271   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
10272   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
10273   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
10274   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
10275
10276   damagedRects.clear();
10277   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10278   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10279
10280   damagedRects.clear();
10281   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10282   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10283
10284   // Remove the Renderer
10285   Renderer renderer = actor.GetRendererAt(0);
10286   actor.RemoveRenderer(renderer);
10287
10288   application.SendNotification();
10289
10290   // The damaged rect should be the actor area
10291   damagedRects.clear();
10292   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10293   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10294   DALI_TEST_CHECK(damagedRects.size() > 0);
10295   DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
10296
10297   damagedRects.clear();
10298   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10299   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10300
10301   // Ensure the damaged rect is empty
10302   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10303
10304   // Add the Renderer again
10305   actor.AddRenderer(renderer);
10306
10307   application.SendNotification();
10308
10309   // The damaged rect should be the actor area
10310   damagedRects.clear();
10311   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10312   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10313   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10314   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10315
10316   END_TEST;
10317 }
10318
10319 int utcDaliActorPartialUpdate3DTransform(void)
10320 {
10321   TestApplication application(
10322     TestApplication::DEFAULT_SURFACE_WIDTH,
10323     TestApplication::DEFAULT_SURFACE_HEIGHT,
10324     TestApplication::DEFAULT_HORIZONTAL_DPI,
10325     TestApplication::DEFAULT_VERTICAL_DPI,
10326     true,
10327     true);
10328
10329   tet_infoline("Check the damaged rect with 3D transformed actors");
10330
10331   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
10332
10333   Actor actor1                          = CreateRenderableActor();
10334   actor1[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10335   actor1[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
10336   actor1[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
10337   actor1.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10338   application.GetScene().Add(actor1);
10339
10340   // Add a new actor
10341   Actor actor2                          = CreateRenderableActor();
10342   actor2[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10343   actor2[Actor::Property::POSITION]     = Vector3(160.0f, 160.0f, 0.0f);
10344   actor2[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
10345   actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10346   application.GetScene().Add(actor2);
10347
10348   application.SendNotification();
10349
10350   std::vector<Rect<int>> damagedRects;
10351
10352   // Actor added, damaged rect is added size of actor
10353   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10354   DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
10355
10356   // Aligned by 16
10357   Rect<int> clippingRect1 = Rect<int>(16, 768, 32, 32); // in screen coordinates
10358   Rect<int> clippingRect2 = Rect<int>(160, 624, 32, 32);
10359   DirtyRectChecker(damagedRects, {clippingRect1, clippingRect2}, true, TEST_LOCATION);
10360
10361   Rect<int> surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10362   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10363
10364   damagedRects.clear();
10365   surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10366   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10367   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10368
10369   damagedRects.clear();
10370   surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10371   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10372   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10373
10374   // Rotate actor1 on y axis
10375   actor1[Actor::Property::ORIENTATION] = Quaternion(Radian(Degree(90.0)), Vector3::YAXIS);
10376
10377   // Remove actor2
10378   actor2.Unparent();
10379
10380   application.SendNotification();
10381
10382   damagedRects.clear();
10383   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10384
10385   // Should update full area
10386   surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10387   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10388   DirtyRectChecker(damagedRects, {surfaceRect}, true, TEST_LOCATION);
10389   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10390
10391   // Add actor2 again
10392   application.GetScene().Add(actor2);
10393
10394   application.SendNotification();
10395
10396   damagedRects.clear();
10397   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10398
10399   // Should update full area
10400   surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10401   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10402   DirtyRectChecker(damagedRects, {surfaceRect}, true, TEST_LOCATION);
10403   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10404
10405   // Reset the orientation of actor1
10406   actor1[Actor::Property::ORIENTATION] = Quaternion::IDENTITY;
10407
10408   application.SendNotification();
10409
10410   damagedRects.clear();
10411   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10412
10413   // Should update full area
10414   surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10415   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10416   DirtyRectChecker(damagedRects, {surfaceRect}, true, TEST_LOCATION);
10417   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10418
10419   // Make actor2 dirty
10420   actor2[Actor::Property::SIZE] = Vector3(32.0f, 32.0f, 0.0f);
10421
10422   application.SendNotification();
10423
10424   damagedRects.clear();
10425   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10426
10427   clippingRect2 = Rect<int>(160, 608, 48, 48);
10428   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10429   DirtyRectChecker(damagedRects, {clippingRect2}, true, TEST_LOCATION);
10430
10431   application.RenderWithPartialUpdate(damagedRects, clippingRect2);
10432   DALI_TEST_EQUALS(clippingRect2.x, glScissorParams.x, TEST_LOCATION);
10433   DALI_TEST_EQUALS(clippingRect2.y, glScissorParams.y, TEST_LOCATION);
10434   DALI_TEST_EQUALS(clippingRect2.width, glScissorParams.width, TEST_LOCATION);
10435   DALI_TEST_EQUALS(clippingRect2.height, glScissorParams.height, TEST_LOCATION);
10436
10437   // Remove actor1
10438   actor1.Unparent();
10439
10440   application.SendNotification();
10441
10442   damagedRects.clear();
10443   surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10444   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10445   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10446
10447   // Rotate actor1 on y axis
10448   actor1[Actor::Property::ORIENTATION] = Quaternion(Radian(Degree(90.0)), Vector3::YAXIS);
10449
10450   // Add actor1 again
10451   application.GetScene().Add(actor1);
10452
10453   application.SendNotification();
10454
10455   damagedRects.clear();
10456   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10457
10458   // Should update full area
10459   surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10460   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10461   DirtyRectChecker(damagedRects, {surfaceRect}, true, TEST_LOCATION);
10462   application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10463
10464   END_TEST;
10465 }
10466
10467 int utcDaliActorPartialUpdateOneActorMultipleRenderers(void)
10468 {
10469   TestApplication application(
10470     TestApplication::DEFAULT_SURFACE_WIDTH,
10471     TestApplication::DEFAULT_SURFACE_HEIGHT,
10472     TestApplication::DEFAULT_HORIZONTAL_DPI,
10473     TestApplication::DEFAULT_VERTICAL_DPI,
10474     true,
10475     true);
10476
10477   tet_infoline("Check the damaged rect with one actor which has multiple renderers");
10478
10479   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
10480
10481   Actor actor = CreateRenderableActor();
10482
10483   // Create another renderer
10484   Geometry geometry  = CreateQuadGeometry();
10485   Shader   shader    = CreateShader();
10486   Renderer renderer2 = Renderer::New(geometry, shader);
10487   actor.AddRenderer(renderer2);
10488
10489   actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10490   actor[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
10491   actor[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
10492   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10493   application.GetScene().Add(actor);
10494
10495   application.SendNotification();
10496
10497   DALI_TEST_EQUALS(actor.GetRendererCount(), 2u, TEST_LOCATION);
10498
10499   std::vector<Rect<int>> damagedRects;
10500
10501   // Actor added, damaged rect is added size of actor
10502   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10503   DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
10504
10505   // Aligned by 16
10506   Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10507   DirtyRectChecker(damagedRects, {clippingRect, clippingRect}, true, TEST_LOCATION);
10508
10509   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10510   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
10511   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
10512   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
10513   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
10514
10515   damagedRects.clear();
10516   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10517   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10518
10519   // Ensure the damaged rect is empty
10520   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10521
10522   // Make renderer2 dirty
10523   renderer2[DevelRenderer::Property::OPACITY] = 0.5f;
10524
10525   application.SendNotification();
10526
10527   // The damaged rect should be the actor area
10528   damagedRects.clear();
10529   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10530
10531   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10532   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10533   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10534
10535   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10536
10537   damagedRects.clear();
10538   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10539   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10540
10541   // Ensure the damaged rect is empty
10542   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10543
10544   // Make renderer2 dirty
10545   renderer2[Renderer::Property::FACE_CULLING_MODE] = FaceCullingMode::BACK;
10546
10547   application.SendNotification();
10548
10549   // The damaged rect should be the actor area
10550   damagedRects.clear();
10551   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10552
10553   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10554   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10555   DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10556
10557   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10558
10559   damagedRects.clear();
10560   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10561   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10562
10563   // Ensure the damaged rect is empty
10564   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10565
10566   END_TEST;
10567 }
10568
10569 int utcDaliActorPartialUpdateMultipleActorsOneRenderer(void)
10570 {
10571   TestApplication application(
10572     TestApplication::DEFAULT_SURFACE_WIDTH,
10573     TestApplication::DEFAULT_SURFACE_HEIGHT,
10574     TestApplication::DEFAULT_HORIZONTAL_DPI,
10575     TestApplication::DEFAULT_VERTICAL_DPI,
10576     true,
10577     true);
10578
10579   tet_infoline("Check the damaged rect with multiple actors which share a same renderer");
10580
10581   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
10582
10583   Actor actor                          = CreateRenderableActor();
10584   actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10585   actor[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
10586   actor[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
10587   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10588   application.GetScene().Add(actor);
10589
10590   // Create another actor which has the same renderer with actor1
10591   Actor    actor2   = Actor::New();
10592   Renderer renderer = actor.GetRendererAt(0);
10593   actor2.AddRenderer(renderer);
10594   actor2[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10595   actor2[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
10596   actor2[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
10597   actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10598   application.GetScene().Add(actor2);
10599
10600   application.SendNotification();
10601
10602   std::vector<Rect<int>> damagedRects;
10603
10604   // Actor added, damaged rect is added size of actor
10605   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10606   DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
10607
10608   // Aligned by 16
10609   Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10610   DirtyRectChecker(damagedRects, {clippingRect, clippingRect}, true, TEST_LOCATION);
10611
10612   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10613   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
10614   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
10615   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
10616   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
10617
10618   damagedRects.clear();
10619   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10620   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10621
10622   // Ensure the damaged rect is empty
10623   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10624
10625   // Make renderer dirty
10626   renderer[DevelRenderer::Property::OPACITY] = 0.5f;
10627
10628   application.SendNotification();
10629
10630   // The damaged rect should be the actor area
10631   damagedRects.clear();
10632   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10633
10634   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10635   DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
10636   DirtyRectChecker(damagedRects, {clippingRect, clippingRect}, true, TEST_LOCATION);
10637
10638   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10639
10640   damagedRects.clear();
10641   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10642   application.RenderWithPartialUpdate(damagedRects, clippingRect);
10643
10644   // Ensure the damaged rect is empty
10645   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10646
10647   END_TEST;
10648 }
10649
10650 int UtcDaliActorCaptureAllTouchAfterStartPropertyP(void)
10651 {
10652   TestApplication application;
10653
10654   Actor actor = Actor::New();
10655   DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), false, TEST_LOCATION);
10656   actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, true);
10657   DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), true, TEST_LOCATION);
10658   DALI_TEST_EQUALS(actor.GetPropertyType(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), Property::BOOLEAN, TEST_LOCATION);
10659   DALI_TEST_EQUALS(actor.IsPropertyWritable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), true, TEST_LOCATION);
10660   DALI_TEST_EQUALS(actor.IsPropertyAnimatable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
10661   DALI_TEST_EQUALS(actor.IsPropertyAConstraintInput(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
10662   DALI_TEST_EQUALS(actor.GetPropertyName(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), "captureAllTouchAfterStart", TEST_LOCATION);
10663   END_TEST;
10664 }
10665
10666 int UtcDaliActorCaptureAllTouchAfterStartPropertyN(void)
10667 {
10668   TestApplication application;
10669
10670   Actor actor = Actor::New();
10671
10672   // Make sure setting invalid types does not cause a crash
10673   try
10674   {
10675     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, 1.0f);
10676     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector2::ONE);
10677     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector3::ONE);
10678     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector4::ONE);
10679     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Map());
10680     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Array());
10681     tet_result(TET_PASS);
10682   }
10683   catch(...)
10684   {
10685     tet_result(TET_FAIL);
10686   }
10687   END_TEST;
10688 }
10689
10690 int UtcDaliActorTouchAreaOffsetPropertyP(void)
10691 {
10692   TestApplication application;
10693
10694   Actor     actor           = Actor::New();
10695   Rect<int> touchAreaOffset = actor.GetProperty(DevelActor::Property::TOUCH_AREA_OFFSET).Get<Rect<int>>();
10696   DALI_TEST_EQUALS(Rect<int>(0, 0, 0, 0), touchAreaOffset, TEST_LOCATION);
10697   actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Rect<int>(10, 20, 30, 40));
10698   touchAreaOffset = actor.GetProperty(DevelActor::Property::TOUCH_AREA_OFFSET).Get<Rect<int>>();
10699   DALI_TEST_EQUALS(Rect<int>(10, 20, 30, 40), touchAreaOffset, TEST_LOCATION);
10700   END_TEST;
10701 }
10702
10703 int UtcDaliActorTouchAreaOffsetPropertyN(void)
10704 {
10705   TestApplication application;
10706
10707   Actor actor = Actor::New();
10708
10709   // Make sure setting invalid types does not cause a crash
10710   try
10711   {
10712     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, 1.0f);
10713     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector2::ONE);
10714     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector3::ONE);
10715     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector4::ONE);
10716     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Property::Map());
10717     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Property::Array());
10718     tet_result(TET_PASS);
10719   }
10720   catch(...)
10721   {
10722     tet_result(TET_FAIL);
10723   }
10724   END_TEST;
10725 }
10726
10727 int UtcDaliActorLowerBelowNegative(void)
10728 {
10729   TestApplication application;
10730   Dali::Actor     instance;
10731   try
10732   {
10733     Dali::Actor arg1;
10734     instance.LowerBelow(arg1);
10735     DALI_TEST_CHECK(false); // Should not get here
10736   }
10737   catch(...)
10738   {
10739     DALI_TEST_CHECK(true); // We expect an assert
10740   }
10741   END_TEST;
10742 }
10743
10744 int UtcDaliActorRaiseAboveNegative(void)
10745 {
10746   TestApplication application;
10747   Dali::Actor     instance;
10748   try
10749   {
10750     Dali::Actor arg1;
10751     instance.RaiseAbove(arg1);
10752     DALI_TEST_CHECK(false); // Should not get here
10753   }
10754   catch(...)
10755   {
10756     DALI_TEST_CHECK(true); // We expect an assert
10757   }
10758   END_TEST;
10759 }
10760
10761 int UtcDaliActorRaiseToTopNegative(void)
10762 {
10763   TestApplication application;
10764   Dali::Actor     instance;
10765   try
10766   {
10767     instance.RaiseToTop();
10768     DALI_TEST_CHECK(false); // Should not get here
10769   }
10770   catch(...)
10771   {
10772     DALI_TEST_CHECK(true); // We expect an assert
10773   }
10774   END_TEST;
10775 }
10776
10777 int UtcDaliActorAddRendererNegative(void)
10778 {
10779   TestApplication application;
10780   Dali::Actor     instance;
10781   try
10782   {
10783     Dali::Renderer arg1;
10784     instance.AddRenderer(arg1);
10785     DALI_TEST_CHECK(false); // Should not get here
10786   }
10787   catch(...)
10788   {
10789     DALI_TEST_CHECK(true); // We expect an assert
10790   }
10791   END_TEST;
10792 }
10793
10794 int UtcDaliActorTouchedSignalNegative(void)
10795 {
10796   TestApplication application;
10797   Dali::Actor     instance;
10798   try
10799   {
10800     instance.TouchedSignal();
10801     DALI_TEST_CHECK(false); // Should not get here
10802   }
10803   catch(...)
10804   {
10805     DALI_TEST_CHECK(true); // We expect an assert
10806   }
10807   END_TEST;
10808 }
10809
10810 int UtcDaliActorTranslateByNegative(void)
10811 {
10812   TestApplication application;
10813   Dali::Actor     instance;
10814   try
10815   {
10816     Dali::Vector3 arg1;
10817     instance.TranslateBy(arg1);
10818     DALI_TEST_CHECK(false); // Should not get here
10819   }
10820   catch(...)
10821   {
10822     DALI_TEST_CHECK(true); // We expect an assert
10823   }
10824   END_TEST;
10825 }
10826
10827 int UtcDaliActorFindChildByIdNegative(void)
10828 {
10829   TestApplication application;
10830   Dali::Actor     instance;
10831   try
10832   {
10833     unsigned int arg1 = 0u;
10834     instance.FindChildById(arg1);
10835     DALI_TEST_CHECK(false); // Should not get here
10836   }
10837   catch(...)
10838   {
10839     DALI_TEST_CHECK(true); // We expect an assert
10840   }
10841   END_TEST;
10842 }
10843
10844 int UtcDaliActorGetRendererAtNegative(void)
10845 {
10846   TestApplication application;
10847   Dali::Actor     instance;
10848   try
10849   {
10850     unsigned int arg1 = 0u;
10851     instance.GetRendererAt(arg1);
10852     DALI_TEST_CHECK(false); // Should not get here
10853   }
10854   catch(...)
10855   {
10856     DALI_TEST_CHECK(true); // We expect an assert
10857   }
10858   END_TEST;
10859 }
10860
10861 int UtcDaliActorHoveredSignalNegative(void)
10862 {
10863   TestApplication application;
10864   Dali::Actor     instance;
10865   try
10866   {
10867     instance.HoveredSignal();
10868     DALI_TEST_CHECK(false); // Should not get here
10869   }
10870   catch(...)
10871   {
10872     DALI_TEST_CHECK(true); // We expect an assert
10873   }
10874   END_TEST;
10875 }
10876
10877 int UtcDaliActorLowerToBottomNegative(void)
10878 {
10879   TestApplication application;
10880   Dali::Actor     instance;
10881   try
10882   {
10883     instance.LowerToBottom();
10884     DALI_TEST_CHECK(false); // Should not get here
10885   }
10886   catch(...)
10887   {
10888     DALI_TEST_CHECK(true); // We expect an assert
10889   }
10890   END_TEST;
10891 }
10892
10893 int UtcDaliActorOnSceneSignalNegative(void)
10894 {
10895   TestApplication application;
10896   Dali::Actor     instance;
10897   try
10898   {
10899     instance.OnSceneSignal();
10900     DALI_TEST_CHECK(false); // Should not get here
10901   }
10902   catch(...)
10903   {
10904     DALI_TEST_CHECK(true); // We expect an assert
10905   }
10906   END_TEST;
10907 }
10908
10909 int UtcDaliActorOffSceneSignalNegative(void)
10910 {
10911   TestApplication application;
10912   Dali::Actor     instance;
10913   try
10914   {
10915     instance.OffSceneSignal();
10916     DALI_TEST_CHECK(false); // Should not get here
10917   }
10918   catch(...)
10919   {
10920     DALI_TEST_CHECK(true); // We expect an assert
10921   }
10922   END_TEST;
10923 }
10924
10925 int UtcDaliActorRemoveRendererNegative01(void)
10926 {
10927   TestApplication application;
10928   Dali::Actor     instance;
10929   try
10930   {
10931     unsigned int arg1 = 0u;
10932     instance.RemoveRenderer(arg1);
10933     DALI_TEST_CHECK(false); // Should not get here
10934   }
10935   catch(...)
10936   {
10937     DALI_TEST_CHECK(true); // We expect an assert
10938   }
10939   END_TEST;
10940 }
10941
10942 int UtcDaliActorRemoveRendererNegative02(void)
10943 {
10944   TestApplication application;
10945   Dali::Actor     instance;
10946   try
10947   {
10948     Dali::Renderer arg1;
10949     instance.RemoveRenderer(arg1);
10950     DALI_TEST_CHECK(false); // Should not get here
10951   }
10952   catch(...)
10953   {
10954     DALI_TEST_CHECK(true); // We expect an assert
10955   }
10956   END_TEST;
10957 }
10958
10959 int UtcDaliActorFindChildByNameNegative(void)
10960 {
10961   TestApplication application;
10962   Dali::Actor     instance;
10963   try
10964   {
10965     std::string arg1;
10966     instance.FindChildByName(arg1);
10967     DALI_TEST_CHECK(false); // Should not get here
10968   }
10969   catch(...)
10970   {
10971     DALI_TEST_CHECK(true); // We expect an assert
10972   }
10973   END_TEST;
10974 }
10975
10976 int UtcDaliActorSetResizePolicyNegative(void)
10977 {
10978   TestApplication application;
10979   Dali::Actor     instance;
10980   try
10981   {
10982     Dali::ResizePolicy::Type arg1 = ResizePolicy::USE_NATURAL_SIZE;
10983     Dali::Dimension::Type    arg2 = Dimension::ALL_DIMENSIONS;
10984     instance.SetResizePolicy(arg1, arg2);
10985     DALI_TEST_CHECK(false); // Should not get here
10986   }
10987   catch(...)
10988   {
10989     DALI_TEST_CHECK(true); // We expect an assert
10990   }
10991   END_TEST;
10992 }
10993
10994 int UtcDaliActorOnRelayoutSignalNegative(void)
10995 {
10996   TestApplication application;
10997   Dali::Actor     instance;
10998   try
10999   {
11000     instance.OnRelayoutSignal();
11001     DALI_TEST_CHECK(false); // Should not get here
11002   }
11003   catch(...)
11004   {
11005     DALI_TEST_CHECK(true); // We expect an assert
11006   }
11007   END_TEST;
11008 }
11009
11010 int UtcDaliActorWheelEventSignalNegative(void)
11011 {
11012   TestApplication application;
11013   Dali::Actor     instance;
11014   try
11015   {
11016     instance.WheelEventSignal();
11017     DALI_TEST_CHECK(false); // Should not get here
11018   }
11019   catch(...)
11020   {
11021     DALI_TEST_CHECK(true); // We expect an assert
11022   }
11023   END_TEST;
11024 }
11025
11026 int UtcDaliActorGetHeightForWidthNegative(void)
11027 {
11028   TestApplication application;
11029   Dali::Actor     instance;
11030   try
11031   {
11032     float arg1 = 0.0f;
11033     instance.GetHeightForWidth(arg1);
11034     DALI_TEST_CHECK(false); // Should not get here
11035   }
11036   catch(...)
11037   {
11038     DALI_TEST_CHECK(true); // We expect an assert
11039   }
11040   END_TEST;
11041 }
11042
11043 int UtcDaliActorGetWidthForHeightNegative(void)
11044 {
11045   TestApplication application;
11046   Dali::Actor     instance;
11047   try
11048   {
11049     float arg1 = 0.0f;
11050     instance.GetWidthForHeight(arg1);
11051     DALI_TEST_CHECK(false); // Should not get here
11052   }
11053   catch(...)
11054   {
11055     DALI_TEST_CHECK(true); // We expect an assert
11056   }
11057   END_TEST;
11058 }
11059
11060 int UtcDaliActorLayoutDirectionChangedSignalNegative(void)
11061 {
11062   TestApplication application;
11063   Dali::Actor     instance;
11064   try
11065   {
11066     instance.LayoutDirectionChangedSignal();
11067     DALI_TEST_CHECK(false); // Should not get here
11068   }
11069   catch(...)
11070   {
11071     DALI_TEST_CHECK(true); // We expect an assert
11072   }
11073   END_TEST;
11074 }
11075
11076 int UtcDaliActorAddNegative(void)
11077 {
11078   TestApplication application;
11079   Dali::Actor     instance;
11080   try
11081   {
11082     Dali::Actor arg1;
11083     instance.Add(arg1);
11084     DALI_TEST_CHECK(false); // Should not get here
11085   }
11086   catch(...)
11087   {
11088     DALI_TEST_CHECK(true); // We expect an assert
11089   }
11090   END_TEST;
11091 }
11092
11093 int UtcDaliActorLowerNegative(void)
11094 {
11095   TestApplication application;
11096   Dali::Actor     instance;
11097   try
11098   {
11099     instance.Lower();
11100     DALI_TEST_CHECK(false); // Should not get here
11101   }
11102   catch(...)
11103   {
11104     DALI_TEST_CHECK(true); // We expect an assert
11105   }
11106   END_TEST;
11107 }
11108
11109 int UtcDaliActorRaiseNegative(void)
11110 {
11111   TestApplication application;
11112   Dali::Actor     instance;
11113   try
11114   {
11115     instance.Raise();
11116     DALI_TEST_CHECK(false); // Should not get here
11117   }
11118   catch(...)
11119   {
11120     DALI_TEST_CHECK(true); // We expect an assert
11121   }
11122   END_TEST;
11123 }
11124
11125 int UtcDaliActorRemoveNegative(void)
11126 {
11127   TestApplication application;
11128   Dali::Actor     instance;
11129   try
11130   {
11131     Dali::Actor arg1;
11132     instance.Remove(arg1);
11133     DALI_TEST_CHECK(false); // Should not get here
11134   }
11135   catch(...)
11136   {
11137     DALI_TEST_CHECK(true); // We expect an assert
11138   }
11139   END_TEST;
11140 }
11141
11142 int UtcDaliActorScaleByNegative(void)
11143 {
11144   TestApplication application;
11145   Dali::Actor     instance;
11146   try
11147   {
11148     Dali::Vector3 arg1;
11149     instance.ScaleBy(arg1);
11150     DALI_TEST_CHECK(false); // Should not get here
11151   }
11152   catch(...)
11153   {
11154     DALI_TEST_CHECK(true); // We expect an assert
11155   }
11156   END_TEST;
11157 }
11158
11159 int UtcDaliActorGetLayerNegative(void)
11160 {
11161   TestApplication application;
11162   Dali::Actor     instance;
11163   try
11164   {
11165     instance.GetLayer();
11166     DALI_TEST_CHECK(false); // Should not get here
11167   }
11168   catch(...)
11169   {
11170     DALI_TEST_CHECK(true); // We expect an assert
11171   }
11172   END_TEST;
11173 }
11174
11175 int UtcDaliActorRotateByNegative01(void)
11176 {
11177   TestApplication application;
11178   Dali::Actor     instance;
11179   try
11180   {
11181     Dali::Quaternion arg1;
11182     instance.RotateBy(arg1);
11183     DALI_TEST_CHECK(false); // Should not get here
11184   }
11185   catch(...)
11186   {
11187     DALI_TEST_CHECK(true); // We expect an assert
11188   }
11189   END_TEST;
11190 }
11191
11192 int UtcDaliActorRotateByNegative02(void)
11193 {
11194   TestApplication application;
11195   Dali::Actor     instance;
11196   try
11197   {
11198     Dali::Radian  arg1;
11199     Dali::Vector3 arg2;
11200     instance.RotateBy(arg1, arg2);
11201     DALI_TEST_CHECK(false); // Should not get here
11202   }
11203   catch(...)
11204   {
11205     DALI_TEST_CHECK(true); // We expect an assert
11206   }
11207   END_TEST;
11208 }
11209
11210 int UtcDaliActorUnparentNegative(void)
11211 {
11212   TestApplication application;
11213   Dali::Actor     instance;
11214   try
11215   {
11216     instance.Unparent();
11217     DALI_TEST_CHECK(false); // Should not get here
11218   }
11219   catch(...)
11220   {
11221     DALI_TEST_CHECK(true); // We expect an assert
11222   }
11223   END_TEST;
11224 }
11225
11226 int UtcDaliActorGetChildAtNegative(void)
11227 {
11228   TestApplication application;
11229   Dali::Actor     instance;
11230   try
11231   {
11232     unsigned int arg1 = 0u;
11233     instance.GetChildAt(arg1);
11234     DALI_TEST_CHECK(false); // Should not get here
11235   }
11236   catch(...)
11237   {
11238     DALI_TEST_CHECK(true); // We expect an assert
11239   }
11240   END_TEST;
11241 }
11242
11243 int UtcDaliActorGetChildCountNegative(void)
11244 {
11245   TestApplication application;
11246   Dali::Actor     instance;
11247   try
11248   {
11249     instance.GetChildCount();
11250     DALI_TEST_CHECK(false); // Should not get here
11251   }
11252   catch(...)
11253   {
11254     DALI_TEST_CHECK(true); // We expect an assert
11255   }
11256   END_TEST;
11257 }
11258
11259 int UtcDaliActorGetTargetSizeNegative(void)
11260 {
11261   TestApplication application;
11262   Dali::Actor     instance;
11263   try
11264   {
11265     instance.GetTargetSize();
11266     DALI_TEST_CHECK(false); // Should not get here
11267   }
11268   catch(...)
11269   {
11270     DALI_TEST_CHECK(true); // We expect an assert
11271   }
11272   END_TEST;
11273 }
11274
11275 int UtcDaliActorScreenToLocalNegative(void)
11276 {
11277   TestApplication application;
11278   Dali::Actor     instance;
11279   try
11280   {
11281     float arg1 = 0.0f;
11282     float arg2 = 0.0f;
11283     float arg3 = 0.0f;
11284     float arg4 = 0.0f;
11285     instance.ScreenToLocal(arg1, arg2, arg3, arg4);
11286     DALI_TEST_CHECK(false); // Should not get here
11287   }
11288   catch(...)
11289   {
11290     DALI_TEST_CHECK(true); // We expect an assert
11291   }
11292   END_TEST;
11293 }
11294
11295 int UtcDaliActorGetNaturalSizeNegative(void)
11296 {
11297   TestApplication application;
11298   Dali::Actor     instance;
11299   try
11300   {
11301     instance.GetNaturalSize();
11302     DALI_TEST_CHECK(false); // Should not get here
11303   }
11304   catch(...)
11305   {
11306     DALI_TEST_CHECK(true); // We expect an assert
11307   }
11308   END_TEST;
11309 }
11310
11311 int UtcDaliActorGetRelayoutSizeNegative(void)
11312 {
11313   TestApplication application;
11314   Dali::Actor     instance;
11315   try
11316   {
11317     Dali::Dimension::Type arg1 = Dimension::HEIGHT;
11318     instance.GetRelayoutSize(arg1);
11319     DALI_TEST_CHECK(false); // Should not get here
11320   }
11321   catch(...)
11322   {
11323     DALI_TEST_CHECK(true); // We expect an assert
11324   }
11325   END_TEST;
11326 }
11327
11328 int UtcDaliActorGetResizePolicyNegative(void)
11329 {
11330   TestApplication application;
11331   Dali::Actor     instance;
11332   try
11333   {
11334     Dali::Dimension::Type arg1 = Dimension::ALL_DIMENSIONS;
11335     instance.GetResizePolicy(arg1);
11336     DALI_TEST_CHECK(false); // Should not get here
11337   }
11338   catch(...)
11339   {
11340     DALI_TEST_CHECK(true); // We expect an assert
11341   }
11342   END_TEST;
11343 }
11344
11345 int UtcDaliActorGetRendererCountNegative(void)
11346 {
11347   TestApplication application;
11348   Dali::Actor     instance;
11349   try
11350   {
11351     instance.GetRendererCount();
11352     DALI_TEST_CHECK(false); // Should not get here
11353   }
11354   catch(...)
11355   {
11356     DALI_TEST_CHECK(true); // We expect an assert
11357   }
11358   END_TEST;
11359 }
11360
11361 int UtcDaliActorGetParentNegative(void)
11362 {
11363   TestApplication application;
11364   Dali::Actor     instance;
11365   try
11366   {
11367     instance.GetParent();
11368     DALI_TEST_CHECK(false); // Should not get here
11369   }
11370   catch(...)
11371   {
11372     DALI_TEST_CHECK(true); // We expect an assert
11373   }
11374   END_TEST;
11375 }
11376
11377 int UtcDaliActorPropertyBlendEquation(void)
11378 {
11379   TestApplication application;
11380
11381   tet_infoline("Test SetProperty AdvancedBlendEquation");
11382
11383   Geometry geometry  = CreateQuadGeometry();
11384   Shader   shader    = CreateShader();
11385   Renderer renderer1 = Renderer::New(geometry, shader);
11386
11387   Actor actor = Actor::New();
11388   actor.SetProperty(Actor::Property::OPACITY, 0.1f);
11389
11390   actor.AddRenderer(renderer1);
11391   actor.SetProperty(Actor::Property::SIZE, Vector2(400, 400));
11392   application.GetScene().Add(actor);
11393
11394   if(!Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
11395   {
11396     actor.SetProperty(Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN);
11397     int equation = actor.GetProperty<int>(Dali::DevelActor::Property::BLEND_EQUATION);
11398     DALI_TEST_EQUALS((Dali::DevelBlendEquation::SCREEN == equation), false, TEST_LOCATION);
11399   }
11400
11401   if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
11402   {
11403     actor.SetProperty(Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN);
11404     int equation = actor.GetProperty<int>(Dali::DevelActor::Property::BLEND_EQUATION);
11405     DALI_TEST_EQUALS((Dali::DevelBlendEquation::SCREEN == equation), true, TEST_LOCATION);
11406   }
11407
11408   Renderer renderer2 = Renderer::New(geometry, shader);
11409   actor.AddRenderer(renderer2);
11410
11411   END_TEST;
11412 }
11413
11414 int UtcDaliActorRegisterProperty(void)
11415 {
11416   tet_infoline("Test property registration and uniform map update\n");
11417
11418   TestApplication application;
11419
11420   Geometry geometry  = CreateQuadGeometry();
11421   Shader   shader    = CreateShader();
11422   Renderer renderer1 = Renderer::New(geometry, shader);
11423   Renderer renderer2 = Renderer::New(geometry, shader);
11424
11425   Actor actor1 = Actor::New();
11426   actor1.AddRenderer(renderer1);
11427   actor1.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
11428   actor1.RegisterProperty("uCustom", 1);
11429   application.GetScene().Add(actor1);
11430
11431   Actor actor2 = Actor::New();
11432   actor2.AddRenderer(renderer2);
11433   actor2.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
11434   application.GetScene().Add(actor2);
11435
11436   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
11437   TraceCallStack&    callStack     = glAbstraction.GetSetUniformTrace();
11438   glAbstraction.EnableSetUniformCallTrace(true);
11439
11440   application.SendNotification();
11441   application.Render();
11442
11443   std::stringstream out;
11444   out.str("1");
11445   std::string params;
11446
11447   // Test uniform value of the custom property
11448   DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("uCustom", params));
11449   DALI_TEST_EQUALS(out.str(), params, TEST_LOCATION);
11450
11451   // Make invisible
11452   actor1[Actor::Property::VISIBLE] = false;
11453
11454   application.SendNotification();
11455   application.Render();
11456
11457   // Make visible again
11458   actor1[Actor::Property::VISIBLE] = true;
11459   actor1["uCustom"]                = 2;
11460
11461   glAbstraction.ResetSetUniformCallStack();
11462
11463   application.SendNotification();
11464   application.Render();
11465
11466   out.str("2");
11467
11468   // The uniform value should not be changed
11469   DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("uCustom", params));
11470   DALI_TEST_EQUALS(out.str(), params, TEST_LOCATION);
11471
11472   END_TEST;
11473 }
11474
11475 int UtcDaliActorDoesWantedHitTest(void)
11476 {
11477   struct HitTestData
11478   {
11479   public:
11480     HitTestData(const Vector3& scale, const Vector2& touchPoint, bool result)
11481     : mScale(scale),
11482       mTouchPoint(touchPoint),
11483       mResult(result)
11484     {
11485     }
11486
11487     Vector3 mScale;
11488     Vector2 mTouchPoint;
11489     bool    mResult;
11490   };
11491
11492   TestApplication application;
11493   tet_infoline(" UtcDaliActorDoesWantedHitTest");
11494
11495   // Fill a vector with different hit tests.
11496   struct HitTestData* hitTestData[] = {
11497     //                    scale                     touch point           result
11498     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(289.f, 400.f), true),  // touch point close to the right edge (inside)
11499     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(291.f, 400.f), false), // touch point close to the right edge (outside)
11500     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.
11501     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(200.f, 451.f), false), // touch point close to the down edge (outside)
11502     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.
11503     NULL,
11504   };
11505
11506   // get the root layer
11507   Actor actor = Actor::New();
11508   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
11509   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
11510
11511   Actor lowerActor = Actor::New();
11512   lowerActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
11513   lowerActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
11514
11515   // actor and lowerActor have no relationship.
11516   application.GetScene().Add(lowerActor);
11517   application.GetScene().Add(actor);
11518
11519   ResetTouchCallbacks();
11520   gHitTestTouchCallBackCalled = false;
11521
11522   unsigned int index = 0;
11523   while(NULL != hitTestData[index])
11524   {
11525     actor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f));
11526     actor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z));
11527
11528     lowerActor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f));
11529     lowerActor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z));
11530
11531     // flush the queue and render once
11532     application.SendNotification();
11533     application.Render();
11534
11535     DALI_TEST_CHECK(!gTouchCallBackCalled);
11536     DALI_TEST_CHECK(!gTouchCallBackCalled2);
11537     DALI_TEST_CHECK(!gHitTestTouchCallBackCalled);
11538
11539     // connect to its touch signal
11540     actor.TouchedSignal().Connect(TestTouchCallback);
11541     lowerActor.TouchedSignal().Connect(TestTouchCallback2);
11542
11543     // connect to its hit-test signal
11544     Dali::DevelActor::HitTestResultSignal(actor).Connect(TestHitTestTouchCallback);
11545
11546     Dali::Integration::Point point;
11547     point.SetState(PointState::DOWN);
11548     point.SetScreenPosition(Vector2(hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y));
11549     Dali::Integration::TouchEvent event;
11550     event.AddPoint(point);
11551
11552     // flush the queue and render once
11553     application.SendNotification();
11554     application.Render();
11555     application.ProcessEvent(event);
11556
11557     // check hit-test events
11558     DALI_TEST_CHECK(gHitTestTouchCallBackCalled == hitTestData[index]->mResult);
11559     // Passed all hit-tests of actor.
11560     DALI_TEST_CHECK(gTouchCallBackCalled == false);
11561     // The lowerActor was hit-tested.
11562     DALI_TEST_CHECK(gTouchCallBackCalled2 == hitTestData[index]->mResult);
11563
11564     if(gTouchCallBackCalled2 != hitTestData[index]->mResult)
11565       tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
11566                  hitTestData[index]->mScale.x,
11567                  hitTestData[index]->mScale.y,
11568                  hitTestData[index]->mScale.z,
11569                  hitTestData[index]->mTouchPoint.x,
11570                  hitTestData[index]->mTouchPoint.y,
11571                  hitTestData[index]->mResult);
11572
11573     ResetTouchCallbacks();
11574     gHitTestTouchCallBackCalled = false;
11575     ++index;
11576   }
11577   END_TEST;
11578 }
11579
11580 int UtcDaliActorAllowOnlyOwnTouchPropertyP(void)
11581 {
11582   TestApplication application;
11583
11584   Actor actor = Actor::New();
11585   DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH).Get<bool>(), false, TEST_LOCATION);
11586   actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, true);
11587   DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH).Get<bool>(), true, TEST_LOCATION);
11588   DALI_TEST_EQUALS(actor.GetPropertyType(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), Property::BOOLEAN, TEST_LOCATION);
11589   DALI_TEST_EQUALS(actor.IsPropertyWritable(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), true, TEST_LOCATION);
11590   DALI_TEST_EQUALS(actor.IsPropertyAnimatable(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), false, TEST_LOCATION);
11591   DALI_TEST_EQUALS(actor.IsPropertyAConstraintInput(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), false, TEST_LOCATION);
11592   DALI_TEST_EQUALS(actor.GetPropertyName(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), "allowOnlyOwnTouch", TEST_LOCATION);
11593   END_TEST;
11594 }
11595
11596 int UtcDaliActorAllowOnlyOwnTouchPropertyN(void)
11597 {
11598   TestApplication application;
11599
11600   Actor actor = Actor::New();
11601
11602   // Make sure setting invalid types does not cause a crash
11603   try
11604   {
11605     actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, 1.0f);
11606     actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Vector2::ONE);
11607     actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Vector3::ONE);
11608     actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Vector4::ONE);
11609     actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Property::Map());
11610     actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Property::Array());
11611     tet_result(TET_PASS);
11612   }
11613   catch(...)
11614   {
11615     tet_result(TET_FAIL);
11616   }
11617   END_TEST;
11618 }
11619
11620 int UtcDaliActorCalculateWorldTransform01(void)
11621 {
11622   TestApplication application;
11623
11624   tet_infoline("Test that actor position inheritance produces right transform matrix");
11625
11626   Actor rootActor   = Actor::New();
11627   Actor branchActor = Actor::New();
11628   Actor leafActor   = Actor::New();
11629
11630   rootActor[Actor::Property::POSITION]   = Vector3(0.0f, 0.0f, 0.0f);
11631   branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
11632   leafActor[Actor::Property::POSITION]   = Vector3(100.0f, 50.0f, 30.0f);
11633
11634   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11635   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11636   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11637
11638   // Set anchor point to the same value as parent origin
11639   rootActor[Actor::Property::PARENT_ORIGIN]   = ParentOrigin::TOP_LEFT;
11640   branchActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT;
11641   leafActor[Actor::Property::PARENT_ORIGIN]   = ParentOrigin::TOP_LEFT;
11642
11643   rootActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
11644   branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11645   leafActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
11646
11647   application.GetScene().Add(rootActor);
11648   rootActor.Add(branchActor);
11649   branchActor.Add(leafActor);
11650
11651   application.SendNotification();
11652   application.Render(0);
11653   application.SendNotification();
11654   application.Render(0);
11655
11656   Matrix m = DevelActor::GetWorldTransform(leafActor);
11657
11658   Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11659   DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11660
11661   Vector3    worldPos;
11662   Vector3    worldScale;
11663   Quaternion worldRotation;
11664   m.GetTransformComponents(worldPos, worldRotation, worldScale);
11665   DALI_TEST_EQUALS(worldPos, Vector3(200.0f, 150.0f, 30.0f), 0.0001f, TEST_LOCATION);
11666
11667   END_TEST;
11668 }
11669
11670 int UtcDaliActorCalculateWorldTransform02(void)
11671 {
11672   TestApplication application;
11673
11674   tet_infoline("Test that actor position produces right transform matrix");
11675
11676   Actor rootActor   = Actor::New();
11677   Actor branchActor = Actor::New();
11678   Actor leafActor   = Actor::New();
11679
11680   rootActor[Actor::Property::POSITION]   = Vector3(0.0f, 0.0f, 0.0f);
11681   branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
11682   leafActor[Actor::Property::POSITION]   = Vector3(100.0f, 50.0f, 30.0f);
11683
11684   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11685   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11686   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11687
11688   // Set anchor point to the same value as parent origin
11689   rootActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
11690   branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11691   leafActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
11692
11693   application.GetScene().Add(rootActor);
11694   rootActor.Add(branchActor);
11695   branchActor.Add(leafActor);
11696
11697   leafActor[Actor::Property::INHERIT_POSITION]    = false;
11698   leafActor[Actor::Property::INHERIT_ORIENTATION] = false;
11699   leafActor[Actor::Property::INHERIT_SCALE]       = false;
11700
11701   application.SendNotification();
11702   application.Render(0);
11703   application.SendNotification();
11704   application.Render(0);
11705
11706   Matrix m = DevelActor::GetWorldTransform(leafActor);
11707
11708   Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11709   DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11710
11711   END_TEST;
11712 }
11713
11714 int UtcDaliActorCalculateWorldTransform03(void)
11715 {
11716   TestApplication application;
11717
11718   tet_infoline("Test that actor position produces right transform matrix");
11719
11720   Actor rootActor   = Actor::New();
11721   Actor branchActor = Actor::New();
11722   Actor leafActor   = Actor::New();
11723
11724   rootActor[Actor::Property::POSITION]   = Vector3(0.0f, 0.0f, 0.0f);
11725   branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
11726   leafActor[Actor::Property::POSITION]   = Vector3(100.0f, 50.0f, 30.0f);
11727
11728   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11729   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11730   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11731
11732   // Set anchor point to the same value as parent origin
11733   rootActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
11734   branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11735   leafActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
11736
11737   application.GetScene().Add(rootActor);
11738   rootActor.Add(branchActor);
11739   branchActor.Add(leafActor);
11740
11741   leafActor[Actor::Property::INHERIT_POSITION]    = true;
11742   leafActor[Actor::Property::INHERIT_ORIENTATION] = false;
11743   leafActor[Actor::Property::INHERIT_SCALE]       = false;
11744
11745   application.SendNotification();
11746   application.Render(0);
11747   application.SendNotification();
11748   application.Render(0);
11749
11750   Matrix m = DevelActor::GetWorldTransform(leafActor);
11751
11752   Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11753   DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11754
11755   END_TEST;
11756 }
11757
11758 int UtcDaliActorCalculateWorldTransform04(void)
11759 {
11760   TestApplication application;
11761
11762   tet_infoline("Test that actor inheritance scale/orientation produces right transform matrix");
11763
11764   Actor rootActor   = Actor::New();
11765   Actor branchActor = Actor::New();
11766   Actor leafActor   = Actor::New();
11767
11768   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
11769   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
11770   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11771
11772   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11773   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11774   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11775
11776   // Set anchor point to the same value as parent origin
11777   rootActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::CENTER;
11778   rootActor[Actor::Property::PARENT_ORIGIN]  = ParentOrigin::CENTER;
11779   branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11780   leafActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
11781
11782   branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
11783   leafActor[Actor::Property::POSITION]   = Vector3(100.0f, 50.0f, 30.0f);
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 UtcDaliActorCalculateWorldTransform05(void)
11803 {
11804   TestApplication application;
11805
11806   tet_infoline("Test that actor inheritance of scale produces right transform matrix");
11807
11808   Actor rootActor   = Actor::New();
11809   Actor branchActor = Actor::New();
11810   Actor leafActor   = Actor::New();
11811
11812   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
11813   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
11814   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11815
11816   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11817   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11818   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11819
11820   // Set anchor point to the same value as parent origin
11821   rootActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::CENTER;
11822   rootActor[Actor::Property::PARENT_ORIGIN]  = ParentOrigin::CENTER;
11823   branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11824   leafActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
11825
11826   branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
11827   leafActor[Actor::Property::POSITION]   = Vector3(100.0f, 50.0f, 30.0f);
11828
11829   leafActor[Actor::Property::INHERIT_POSITION]    = false;
11830   leafActor[Actor::Property::INHERIT_ORIENTATION] = false;
11831
11832   application.GetScene().Add(rootActor);
11833   rootActor.Add(branchActor);
11834   branchActor.Add(leafActor);
11835
11836   application.SendNotification();
11837   application.Render(0);
11838   application.SendNotification();
11839   application.Render(0);
11840
11841   Matrix m = DevelActor::GetWorldTransform(leafActor);
11842
11843   Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11844   DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11845
11846   END_TEST;
11847 }
11848
11849 int UtcDaliActorCalculateWorldTransform06(void)
11850 {
11851   TestApplication application;
11852
11853   tet_infoline("Test that actor inheritance of scale produces right transform matrix");
11854
11855   Actor rootActor   = Actor::New();
11856   Actor branchActor = Actor::New();
11857   Actor leafActor   = Actor::New();
11858
11859   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
11860   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
11861   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11862
11863   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11864   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11865   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11866
11867   // Set anchor point to the same value as parent origin
11868   rootActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::CENTER;
11869   rootActor[Actor::Property::PARENT_ORIGIN]  = ParentOrigin::CENTER;
11870   branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11871   leafActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::TOP_LEFT;
11872
11873   branchActor[Actor::Property::POSITION]    = Vector3(100.0f, 30.0f, -50.0f);
11874   branchActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(45.0f), Vector3::XAXIS);
11875   leafActor[Actor::Property::POSITION]      = Vector3(100.0f, 50.0f, 30.0f);
11876
11877   leafActor[Actor::Property::INHERIT_POSITION] = false;
11878   leafActor[Actor::Property::INHERIT_SCALE]    = false;
11879
11880   application.GetScene().Add(rootActor);
11881   rootActor.Add(branchActor);
11882   branchActor.Add(leafActor);
11883
11884   application.SendNotification();
11885   application.Render(0);
11886   application.SendNotification();
11887   application.Render(0);
11888
11889   Matrix m = DevelActor::GetWorldTransform(leafActor);
11890
11891   Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11892   DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11893
11894   END_TEST;
11895 }
11896
11897 int UtcDaliActorCalculateWorldTransform07(void)
11898 {
11899   TestApplication application;
11900
11901   tet_infoline("Test that actor inheritance of scale produces right transform matrix");
11902
11903   Actor rootActor   = Actor::New();
11904   Actor branchActor = Actor::New();
11905   Actor leafActor   = Actor::New();
11906
11907   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
11908   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
11909   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11910
11911   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11912   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11913   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11914
11915   // Set anchor point to the same value as parent origin
11916   rootActor[Actor::Property::ANCHOR_POINT]   = AnchorPoint::CENTER;
11917   rootActor[Actor::Property::PARENT_ORIGIN]  = ParentOrigin::CENTER;
11918   branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11919
11920   // This should be ignored.
11921   leafActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
11922   leafActor[Actor::Property::ANCHOR_POINT]  = AnchorPoint::CENTER;
11923
11924   branchActor[Actor::Property::POSITION]    = Vector3(100.0f, 30.0f, -50.0f);
11925   branchActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(45.0f), Vector3::XAXIS);
11926   leafActor[Actor::Property::POSITION]      = Vector3(100.0f, 50.0f, 30.0f);
11927
11928   leafActor[Actor::Property::INHERIT_POSITION]           = false;
11929   leafActor[Actor::Property::INHERIT_SCALE]              = false;
11930   leafActor[Actor::Property::POSITION_USES_ANCHOR_POINT] = false;
11931
11932   application.GetScene().Add(rootActor);
11933   rootActor.Add(branchActor);
11934   branchActor.Add(leafActor);
11935
11936   application.SendNotification();
11937   application.Render(0);
11938   application.SendNotification();
11939   application.Render(0);
11940
11941   Matrix m = DevelActor::GetWorldTransform(leafActor);
11942
11943   Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11944   DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11945
11946   END_TEST;
11947 }
11948
11949 int UtcDaliActorCalculateWorldTransform08(void)
11950 {
11951   TestApplication application;
11952
11953   tet_infoline("Test that actor inheritance of scale produces right transform matrix");
11954
11955   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)};
11956
11957   struct TestCase
11958   {
11959     bool translation;
11960     bool rotation;
11961     bool scaling;
11962   };
11963   TestCase testCases[] = {
11964     {false, false, true},
11965     {false, true, false},
11966     {true, false, false},
11967     {false, true, true},
11968     {true, false, true},
11969     {true, true, false},
11970     {false, false, false},
11971     {true, true, true},
11972   };
11973
11974   Actor rootActor = Actor::New();
11975   Actor leafActor = Actor::New();
11976
11977   rootActor[Actor::Property::POSITION]      = Vector3(0.0f, 0.0f, 0.0f);
11978   rootActor[Actor::Property::SCALE]         = Vector3(1.0f, 2.0f, 1.0f);
11979   rootActor[Actor::Property::ORIENTATION]   = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11980   rootActor[Actor::Property::SIZE]          = Vector2(200, 400);
11981   rootActor[Actor::Property::ANCHOR_POINT]  = AnchorPoint::CENTER;
11982   rootActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
11983
11984   leafActor[Actor::Property::POSITION]                   = Vector3(0.0f, -50.0f, 0.0f);
11985   leafActor[Actor::Property::SCALE]                      = Vector3(1.0f, 1.0f, 1.0f);
11986   leafActor[Actor::Property::ORIENTATION]                = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11987   leafActor[Actor::Property::SIZE]                       = Vector2(200, 400);
11988   leafActor[Actor::Property::ANCHOR_POINT]               = AnchorPoint::BOTTOM_CENTER;
11989   leafActor[Actor::Property::PARENT_ORIGIN]              = ParentOrigin::TOP_CENTER;
11990   leafActor[Actor::Property::POSITION_USES_ANCHOR_POINT] = true;
11991
11992   application.GetScene().Add(rootActor);
11993   rootActor.Add(leafActor);
11994
11995   for(uint32_t i = 0; i < 8; ++i)
11996   {
11997     leafActor[Actor::Property::INHERIT_POSITION]    = testCases[i].translation;
11998     leafActor[Actor::Property::INHERIT_ORIENTATION] = testCases[i].rotation;
11999     leafActor[Actor::Property::INHERIT_SCALE]       = testCases[i].scaling;
12000
12001     application.SendNotification();
12002     application.Render(0);
12003     application.SendNotification();
12004     application.Render(0);
12005
12006     Matrix m            = DevelActor::GetWorldTransform(leafActor);
12007     Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
12008
12009     Vector3 worldPosition1 = Vector3(m.GetTranslation());
12010     Vector3 worldPosition2 = Vector3(actualMatrix.GetTranslation());
12011
12012     DALI_TEST_EQUALS(solutions[i], worldPosition1, 0.001f, TEST_LOCATION);
12013     DALI_TEST_EQUALS(solutions[i], worldPosition2, 0.001f, TEST_LOCATION);
12014   }
12015
12016   END_TEST;
12017 }
12018
12019 int UtcDaliActorCalculateWorldColor01(void)
12020 {
12021   TestApplication application;
12022
12023   tet_infoline("Test that actor inheritance of color produces right final color");
12024
12025   Actor rootActor   = Actor::New();
12026   Actor branchActor = Actor::New();
12027   Actor leafActor   = Actor::New();
12028
12029   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
12030   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
12031   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
12032
12033   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12034   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12035   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12036
12037   rootActor[Actor::Property::COLOR] = Color::WHITE;
12038   Vector4 testColor1(1.0f, 1.0f, 0.5f, 0.8f);
12039   branchActor[Actor::Property::COLOR] = testColor1;
12040   leafActor[Actor::Property::COLOR]   = Vector4(0.1f, 0.5f, 0.5f, 0.8f);
12041
12042   // Default is to inherit:
12043   leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_OWN_MULTIPLY_PARENT_ALPHA;
12044
12045   application.GetScene().Add(rootActor);
12046   rootActor.Add(branchActor);
12047   branchActor.Add(leafActor);
12048
12049   application.SendNotification();
12050   application.Render(16);
12051   Vector4 color = branchActor.GetCurrentProperty<Vector4>(Actor::Property::COLOR);
12052   DALI_TEST_EQUALS(color, testColor1, TEST_LOCATION);
12053
12054   application.SendNotification();
12055   application.Render(16);
12056   color = branchActor.GetCurrentProperty<Vector4>(Actor::Property::COLOR);
12057   DALI_TEST_EQUALS(color, testColor1, TEST_LOCATION);
12058
12059   application.SendNotification();
12060   application.Render(16);
12061   color = branchActor.GetCurrentProperty<Vector4>(Actor::Property::COLOR);
12062   DALI_TEST_EQUALS(color, testColor1, TEST_LOCATION);
12063
12064   color = DevelActor::GetWorldColor(leafActor);
12065
12066   Vector4 actualColor = leafActor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR);
12067   DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION);
12068
12069   END_TEST;
12070 }
12071
12072 int UtcDaliActorCalculateWorldColor02(void)
12073 {
12074   TestApplication application;
12075
12076   tet_infoline("Test that actor uses own color");
12077
12078   Actor rootActor   = Actor::New();
12079   Actor branchActor = Actor::New();
12080   Actor leafActor   = Actor::New();
12081
12082   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
12083   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
12084   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
12085
12086   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12087   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12088   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12089
12090   rootActor[Actor::Property::COLOR]   = Color::WHITE;
12091   branchActor[Actor::Property::COLOR] = Vector4(1.0f, 1.0f, 0.5f, 0.8f);
12092   leafActor[Actor::Property::COLOR]   = Vector4(0.1f, 0.5f, 0.5f, 0.8f);
12093
12094   leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_OWN_COLOR;
12095
12096   application.GetScene().Add(rootActor);
12097   rootActor.Add(branchActor);
12098   branchActor.Add(leafActor);
12099
12100   application.SendNotification();
12101   application.Render(0);
12102
12103   Vector4 color = DevelActor::GetWorldColor(leafActor);
12104
12105   Vector4 actualColor = leafActor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR);
12106   DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION);
12107   DALI_TEST_EQUALS(color, Vector4(0.1f, 0.5f, 0.5f, 0.8f), 0.001f, TEST_LOCATION);
12108   END_TEST;
12109 }
12110
12111 int UtcDaliActorCalculateWorldColor03(void)
12112 {
12113   TestApplication application;
12114
12115   tet_infoline("Test that actor uses parent color");
12116
12117   Actor rootActor   = Actor::New();
12118   Actor branchActor = Actor::New();
12119   Actor leafActor   = Actor::New();
12120
12121   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
12122   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
12123   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
12124
12125   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12126   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12127   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12128
12129   rootActor[Actor::Property::COLOR]   = Color::WHITE * 0.9f;
12130   branchActor[Actor::Property::COLOR] = Vector4(1.0f, 1.0f, 0.5f, 0.8f);
12131   leafActor[Actor::Property::COLOR]   = Vector4(0.1f, 0.5f, 0.5f, 0.8f);
12132
12133   leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_PARENT_COLOR;
12134
12135   application.GetScene().Add(rootActor);
12136   rootActor.Add(branchActor);
12137   branchActor.Add(leafActor);
12138
12139   application.SendNotification();
12140   application.Render(0);
12141
12142   Vector4 color = DevelActor::GetWorldColor(leafActor);
12143
12144   Vector4 actualColor = leafActor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR);
12145   DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION);
12146   DALI_TEST_EQUALS(color, Vector4(1.0f, 1.0f, 0.5f, 0.72f), 0.001f, TEST_LOCATION);
12147   END_TEST;
12148 }
12149
12150 int UtcDaliActorCalculateWorldColor04(void)
12151 {
12152   TestApplication application;
12153
12154   tet_infoline("Test that actor blends with parent color");
12155
12156   Actor rootActor   = Actor::New();
12157   Actor branchActor = Actor::New();
12158   Actor leafActor   = Actor::New();
12159
12160   rootActor[Actor::Property::POSITION]    = Vector3(100.0f, 0.0f, 0.0f);
12161   rootActor[Actor::Property::SCALE]       = Vector3(2.0f, 2.0f, 2.0f);
12162   rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
12163
12164   rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12165   branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12166   leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12167
12168   rootActor[Actor::Property::COLOR]   = Color::WHITE * 0.9f;
12169   branchActor[Actor::Property::COLOR] = Vector4(1.0f, 1.0f, 0.5f, 0.8f);
12170   leafActor[Actor::Property::COLOR]   = Vector4(0.1f, 0.5f, 0.5f, 0.8f);
12171
12172   leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_OWN_MULTIPLY_PARENT_COLOR;
12173
12174   application.GetScene().Add(rootActor);
12175   rootActor.Add(branchActor);
12176   branchActor.Add(leafActor);
12177
12178   application.SendNotification();
12179   application.Render(0);
12180
12181   Vector4 color = DevelActor::GetWorldColor(leafActor);
12182
12183   Vector4 actualColor = leafActor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR);
12184   DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION);
12185
12186   END_TEST;
12187 }
12188
12189 int UtcDaliActorCalculateLookAt(void)
12190 {
12191   TestApplication application;
12192
12193   tet_infoline("Test that actor rotate right value of orientation");
12194
12195   Actor actor = Actor::New();
12196
12197   actor[Actor::Property::POSITION]      = Vector3(100.0f, 0.0f, 0.0f);
12198   actor[Actor::Property::ANCHOR_POINT]  = AnchorPoint::CENTER;
12199   actor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
12200
12201   application.GetScene().Add(actor);
12202
12203   application.SendNotification();
12204   application.Render(0);
12205
12206   Quaternion actorQuaternion;
12207
12208   tet_printf("Test with target only\n");
12209   Dali::DevelActor::LookAt(actor, Vector3::ZERO);
12210   actorQuaternion = actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
12211   DALI_TEST_EQUALS(actorQuaternion, Quaternion(Radian(Degree(90.0f)), Vector3::NEGATIVE_YAXIS), TEST_LOCATION);
12212
12213   tet_printf("Test with target + up\n");
12214   Dali::DevelActor::LookAt(actor, Vector3::ZERO, Vector3::ZAXIS);
12215   actorQuaternion = actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
12216   DALI_TEST_EQUALS(actorQuaternion, Quaternion(Radian(Degree(90.0f)), Vector3::XAXIS) * Quaternion(Radian(Degree(90.0f)), Vector3::NEGATIVE_YAXIS), TEST_LOCATION);
12217
12218   tet_printf("Test with target + up + localForward\n");
12219   Dali::DevelActor::LookAt(actor, Vector3::ZERO, Vector3::NEGATIVE_YAXIS, Vector3::NEGATIVE_XAXIS);
12220   actorQuaternion = actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
12221   DALI_TEST_EQUALS(actorQuaternion, Quaternion(Radian(Degree(180.0f)), Vector3::XAXIS), TEST_LOCATION);
12222
12223   tet_printf("Test with target + up + localForward + localUp\n");
12224   Dali::DevelActor::LookAt(actor, Vector3::ZERO, Vector3::NEGATIVE_YAXIS, Vector3::NEGATIVE_YAXIS, Vector3::XAXIS);
12225   actorQuaternion = actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
12226   DALI_TEST_EQUALS(actorQuaternion, Quaternion(Radian(Degree(90.0f)), Vector3::NEGATIVE_ZAXIS), TEST_LOCATION);
12227
12228   // Reset quaternion
12229   actor[Actor::Property::ORIENTATION] = Quaternion();
12230
12231   Actor actor2                           = Actor::New();
12232   actor2[Actor::Property::POSITION]      = Vector3(0.0f, 50.0f, -10.0f);
12233   actor2[Actor::Property::ANCHOR_POINT]  = AnchorPoint::CENTER;
12234   actor2[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
12235   actor.Add(actor2);
12236
12237   tet_printf("Test whether lookat calculate well by using event side values only\n");
12238   Dali::DevelActor::LookAt(actor2, Vector3(100.0f, 50.0f, 1.0f));
12239   actorQuaternion = actor2.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
12240   DALI_TEST_EQUALS(actorQuaternion, Quaternion(), TEST_LOCATION);
12241
12242   actor[Actor::Property::ORIENTATION] = Quaternion(Radian(Degree(90.0f)), Vector3::ZAXIS);
12243
12244   DALI_TEST_EQUALS(Dali::DevelActor::GetWorldTransform(actor2).GetTranslation3(), Vector3(50.0f, 0.0f, -10.0f), TEST_LOCATION);
12245
12246   tet_printf("Test whether lookat calculate well inherit by parent orientation\n");
12247   Dali::DevelActor::LookAt(actor2, Vector3(50.0f, 0.0f, 1.0f), Vector3::NEGATIVE_XAXIS);
12248   actorQuaternion = actor2.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
12249   DALI_TEST_EQUALS(actorQuaternion, Quaternion(), TEST_LOCATION);
12250
12251   END_TEST;
12252 }