Removed old context test cases
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Actor.cpp
1 /*
2  * Copyright (c) 2022 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 <string>
33
34 #include "assert.h"
35
36 //& set: DaliActor
37
38 using std::string;
39 using namespace Dali;
40
41 void utc_dali_actor_startup(void)
42 {
43   test_return_value = TET_UNDEF;
44 }
45
46 void utc_dali_actor_cleanup(void)
47 {
48   test_return_value = TET_PASS;
49 }
50
51 namespace
52 {
53 bool gTouchCallBackCalled  = false;
54 bool gTouchCallBackCalled2 = false;
55 bool gTouchCallBackCalled3 = false;
56
57 bool gHoverCallBackCalled = false;
58
59 static bool gTestConstraintCalled;
60
61 LayoutDirection::Type gLayoutDirectionType;
62
63 struct TestConstraint
64 {
65   void operator()(Vector4& color, const PropertyInputContainer& /* inputs */)
66   {
67     gTestConstraintCalled = true;
68   }
69 };
70
71 /**
72  * TestConstraint reference.
73  * When constraint is called, the resultRef is updated
74  * with the value supplied.
75  */
76 template<typename T>
77 struct TestConstraintRef
78 {
79   TestConstraintRef(unsigned int& resultRef, unsigned int value)
80   : mResultRef(resultRef),
81     mValue(value)
82   {
83   }
84
85   void operator()(T& current, const PropertyInputContainer& /* inputs */)
86   {
87     mResultRef = mValue;
88   }
89
90   unsigned int& mResultRef;
91   unsigned int  mValue;
92 };
93
94 static bool TestTouchCallback(Actor, const TouchEvent&)
95 {
96   gTouchCallBackCalled = true;
97   return true;
98   END_TEST;
99 }
100
101 static bool TestTouchCallback2(Actor, const TouchEvent&)
102 {
103   gTouchCallBackCalled2 = true;
104   return true;
105   END_TEST;
106 }
107
108 static bool TestTouchCallback3(Actor, const TouchEvent&)
109 {
110   gTouchCallBackCalled3 = true;
111   return true;
112   END_TEST;
113 }
114
115 static void ResetTouchCallbacks()
116 {
117   gTouchCallBackCalled  = false;
118   gTouchCallBackCalled2 = false;
119   gTouchCallBackCalled3 = false;
120 }
121
122 static bool TestCallback3(Actor actor, const HoverEvent& event)
123 {
124   gHoverCallBackCalled = true;
125   return false;
126   END_TEST;
127 }
128
129 // validation stuff for onstage & offstage signals
130 static std::vector<std::string> gActorNamesOnOffScene;
131 static int                      gOnSceneCallBackCalled;
132 void                            OnSceneCallback(Actor actor)
133 {
134   ++gOnSceneCallBackCalled;
135   gActorNamesOnOffScene.push_back(actor.GetProperty<std::string>(Actor::Property::NAME));
136   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE) == true);
137 }
138 static int gOffSceneCallBackCalled;
139 void       OffSceneCallback(Actor actor)
140 {
141   ++gOffSceneCallBackCalled;
142   gActorNamesOnOffScene.push_back(actor.GetProperty<std::string>(Actor::Property::NAME));
143   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE) == false);
144 }
145
146 struct PositionComponentConstraint
147 {
148   PositionComponentConstraint()
149   {
150   }
151
152   void operator()(Vector3& pos, const PropertyInputContainer& inputs)
153   {
154     const Matrix& m = inputs[0]->GetMatrix();
155     Vector3       scale;
156     Quaternion    rot;
157     m.GetTransformComponents(pos, rot, scale);
158   }
159 };
160
161 struct OrientationComponentConstraint
162 {
163   OrientationComponentConstraint()
164   {
165   }
166
167   void operator()(Quaternion& orientation, const PropertyInputContainer& inputs)
168   {
169     const Quaternion& parentOrientation = inputs[0]->GetQuaternion();
170     Vector3           pos, scale;
171     Quaternion        rot;
172     orientation = parentOrientation;
173   }
174 };
175 // OnRelayout
176
177 static bool                     gOnRelayoutCallBackCalled = false;
178 static std::vector<std::string> gActorNamesRelayout;
179
180 void OnRelayoutCallback(Actor actor)
181 {
182   gOnRelayoutCallBackCalled = true;
183   gActorNamesRelayout.push_back(actor.GetProperty<std::string>(Actor::Property::NAME));
184 }
185
186 struct VisibilityChangedFunctorData
187 {
188   VisibilityChangedFunctorData()
189   : actor(),
190     visible(false),
191     type(DevelActor::VisibilityChange::SELF),
192     called(false)
193   {
194   }
195
196   void Reset()
197   {
198     actor.Reset();
199     visible = false;
200     type    = DevelActor::VisibilityChange::SELF;
201     called  = false;
202   }
203
204   void Check(bool compareCalled, Actor compareActor, bool compareVisible, DevelActor::VisibilityChange::Type compareType, const char* location)
205   {
206     DALI_TEST_EQUALS(called, compareCalled, TEST_INNER_LOCATION(location));
207     DALI_TEST_EQUALS(actor, compareActor, TEST_INNER_LOCATION(location));
208     DALI_TEST_EQUALS(visible, compareVisible, TEST_INNER_LOCATION(location));
209     DALI_TEST_EQUALS((int)type, (int)compareType, TEST_INNER_LOCATION(location));
210   }
211
212   void Check(bool compareCalled, const std::string& location)
213   {
214     DALI_TEST_EQUALS(called, compareCalled, TEST_INNER_LOCATION(location));
215   }
216
217   Actor                              actor;
218   bool                               visible;
219   DevelActor::VisibilityChange::Type type;
220   bool                               called;
221 };
222
223 struct VisibilityChangedFunctor
224 {
225   VisibilityChangedFunctor(VisibilityChangedFunctorData& dataVar)
226   : data(dataVar)
227   {
228   }
229
230   void operator()(Actor actor, bool visible, DevelActor::VisibilityChange::Type type)
231   {
232     data.actor   = actor;
233     data.visible = visible;
234     data.type    = type;
235     data.called  = true;
236   }
237
238   VisibilityChangedFunctorData& data;
239 };
240
241 struct VisibilityChangedVoidFunctor
242 {
243   VisibilityChangedVoidFunctor(bool& signalCalled)
244   : mSignalCalled(signalCalled)
245   {
246   }
247
248   void operator()()
249   {
250     mSignalCalled = true;
251   }
252
253   bool& mSignalCalled;
254 };
255
256 struct ChildOrderChangedFunctor
257 {
258   ChildOrderChangedFunctor(bool& signalCalled, Actor& actor)
259   : mSignalCalled(signalCalled),
260     mActor(actor)
261   {
262   }
263
264   void operator()(Actor actor)
265   {
266     mSignalCalled = true;
267     mActor        = actor;
268   }
269
270   bool&  mSignalCalled;
271   Actor& mActor;
272 };
273
274 struct CulledPropertyNotificationFunctor
275 {
276   CulledPropertyNotificationFunctor(bool& signalCalled, PropertyNotification& propertyNotification)
277   : mSignalCalled(signalCalled),
278     mPropertyNotification(propertyNotification)
279   {
280   }
281
282   void operator()(PropertyNotification& source)
283   {
284     mSignalCalled         = true;
285     mPropertyNotification = source;
286   }
287
288   bool&                 mSignalCalled;
289   PropertyNotification& mPropertyNotification;
290 };
291
292 } // anonymous namespace
293
294 //& purpose: Testing New API
295 int UtcDaliActorNew(void)
296 {
297   TestApplication application;
298
299   Actor actor = Actor::New();
300
301   DALI_TEST_CHECK(actor);
302   END_TEST;
303 }
304
305 //& purpose: Testing Dali::Actor::DownCast()
306 int UtcDaliActorDownCastP(void)
307 {
308   TestApplication application;
309   tet_infoline("Testing Dali::Actor::DownCast()");
310
311   Actor      actor = Actor::New();
312   BaseHandle object(actor);
313   Actor      actor2 = Actor::DownCast(object);
314   DALI_TEST_CHECK(actor2);
315   END_TEST;
316 }
317
318 //& purpose: Testing Dali::Actor::DownCast()
319 int UtcDaliActorDownCastN(void)
320 {
321   TestApplication application;
322   tet_infoline("Testing Dali::Actor::DownCast()");
323
324   BaseHandle unInitializedObject;
325   Actor      actor = Actor::DownCast(unInitializedObject);
326   DALI_TEST_CHECK(!actor);
327   END_TEST;
328 }
329
330 int UtcDaliActorMoveConstructor(void)
331 {
332   TestApplication application;
333
334   Actor actor = Actor::New();
335   DALI_TEST_CHECK(actor);
336
337   int id = actor.GetProperty<int>(Actor::Property::ID);
338
339   Actor moved = std::move(actor);
340   DALI_TEST_CHECK(moved);
341   DALI_TEST_EQUALS(id, moved.GetProperty<int>(Actor::Property::ID), TEST_LOCATION);
342   DALI_TEST_CHECK(!actor);
343
344   END_TEST;
345 }
346
347 int UtcDaliActorMoveAssignment(void)
348 {
349   TestApplication application;
350
351   Actor actor = Actor::New();
352   DALI_TEST_CHECK(actor);
353
354   int id = actor.GetProperty<int>(Actor::Property::ID);
355
356   Actor moved;
357   moved = std::move(actor);
358   DALI_TEST_CHECK(moved);
359   DALI_TEST_EQUALS(id, moved.GetProperty<int>(Actor::Property::ID), TEST_LOCATION);
360   DALI_TEST_CHECK(!actor);
361
362   END_TEST;
363 }
364
365 //& purpose: Testing Dali::Actor::GetName()
366 int UtcDaliActorGetName(void)
367 {
368   TestApplication application;
369
370   Actor actor = Actor::New();
371
372   DALI_TEST_CHECK(actor.GetProperty<std::string>(Actor::Property::NAME).empty());
373   END_TEST;
374 }
375
376 //& purpose: Testing Dali::Actor::SetName()
377 int UtcDaliActorSetName(void)
378 {
379   TestApplication application;
380
381   string str("ActorName");
382   Actor  actor = Actor::New();
383
384   actor.SetProperty(Actor::Property::NAME, str);
385   DALI_TEST_CHECK(actor.GetProperty<std::string>(Actor::Property::NAME) == str);
386   END_TEST;
387 }
388
389 int UtcDaliActorGetId(void)
390 {
391   tet_infoline("Testing Dali::Actor::UtcDaliActo.GetProperty< int >( Actor::Property::ID )");
392   TestApplication application;
393
394   Actor first  = Actor::New();
395   Actor second = Actor::New();
396   Actor third  = Actor::New();
397
398   DALI_TEST_CHECK(first.GetProperty<int>(Actor::Property::ID) != second.GetProperty<int>(Actor::Property::ID));
399   DALI_TEST_CHECK(second.GetProperty<int>(Actor::Property::ID) != third.GetProperty<int>(Actor::Property::ID));
400   END_TEST;
401 }
402
403 int UtcDaliActorIsRoot(void)
404 {
405   TestApplication application;
406
407   Actor actor = Actor::New();
408   DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::IS_ROOT));
409
410   // get the root layer
411   actor = application.GetScene().GetLayer(0);
412   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::IS_ROOT));
413   END_TEST;
414 }
415
416 int UtcDaliActorOnScene(void)
417 {
418   TestApplication application;
419
420   Actor actor = Actor::New();
421   DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
422
423   // get the root layer
424   actor = application.GetScene().GetLayer(0);
425   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
426   END_TEST;
427 }
428
429 int UtcDaliActorIsLayer(void)
430 {
431   TestApplication application;
432
433   Actor actor = Actor::New();
434   DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::IS_LAYER));
435
436   // get the root layer
437   actor = application.GetScene().GetLayer(0);
438   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::IS_LAYER));
439   END_TEST;
440 }
441
442 int UtcDaliActorGetLayer(void)
443 {
444   TestApplication application;
445
446   Actor actor = Actor::New();
447   application.GetScene().Add(actor);
448   Layer layer = actor.GetLayer();
449
450   DALI_TEST_CHECK(layer);
451
452   // get the root layers layer
453   actor = application.GetScene().GetLayer(0);
454   DALI_TEST_CHECK(actor.GetLayer());
455   END_TEST;
456 }
457
458 int UtcDaliActorAddP(void)
459 {
460   tet_infoline("Testing Actor::Add");
461   TestApplication application;
462
463   Actor parent = Actor::New();
464   Actor child  = Actor::New();
465
466   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
467
468   parent.Add(child);
469
470   DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
471
472   Actor parent2 = Actor::New();
473   parent2.Add(child);
474
475   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
476   DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
477
478   // try Adding to same parent again, works
479   parent2.Add(child);
480   DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
481
482   // try reparenting an orphaned child
483   {
484     Actor temporaryParent = Actor::New();
485     temporaryParent.Add(child);
486     DALI_TEST_EQUALS(parent2.GetChildCount(), 0u, TEST_LOCATION);
487   }
488   // temporaryParent has now died, reparent the orphaned child
489   parent2.Add(child);
490   DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
491
492   END_TEST;
493 }
494
495 int UtcDaliActorAddN(void)
496 {
497   tet_infoline("Testing Actor::Add");
498   TestApplication application;
499
500   Actor child = Actor::New();
501
502   Actor parent2 = Actor::New();
503   parent2.Add(child);
504
505   // try illegal Add
506   try
507   {
508     parent2.Add(parent2);
509     tet_printf("Assertion test failed - no Exception\n");
510     tet_result(TET_FAIL);
511   }
512   catch(Dali::DaliException& e)
513   {
514     DALI_TEST_PRINT_ASSERT(e);
515     DALI_TEST_ASSERT(e, "&mOwner != &child", TEST_LOCATION);
516     DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
517   }
518   catch(...)
519   {
520     tet_printf("Assertion test failed - wrong Exception\n");
521     tet_result(TET_FAIL);
522   }
523
524   // try reparenting root
525   try
526   {
527     parent2.Add(application.GetScene().GetLayer(0));
528     tet_printf("Assertion test failed - no Exception\n");
529     tet_result(TET_FAIL);
530   }
531   catch(Dali::DaliException& e)
532   {
533     DALI_TEST_PRINT_ASSERT(e);
534     DALI_TEST_ASSERT(e, "!child.IsRoot()", TEST_LOCATION);
535     DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
536   }
537   catch(...)
538   {
539     tet_printf("Assertion test failed - wrong Exception\n");
540     tet_result(TET_FAIL);
541   }
542
543   // try Add empty
544   try
545   {
546     Actor empty;
547     parent2.Add(empty);
548     tet_printf("Assertion test failed - no Exception\n");
549     tet_result(TET_FAIL);
550   }
551   catch(Dali::DaliException& e)
552   {
553     DALI_TEST_PRINT_ASSERT(e);
554     DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
555     DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
556   }
557   catch(...)
558   {
559     tet_printf("Assertion test failed - wrong Exception\n");
560     tet_result(TET_FAIL);
561   }
562
563   END_TEST;
564 }
565
566 int UtcDaliActorRemoveN(void)
567 {
568   tet_infoline("Testing Actor::Remove");
569   TestApplication application;
570
571   Actor parent = Actor::New();
572   Actor child  = Actor::New();
573   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
574
575   parent.Add(child);
576   DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
577
578   parent.Remove(child);
579   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
580
581   // remove again, no problem
582   parent.Remove(child);
583   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
584
585   // add child back
586   parent.Add(child);
587   DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
588   // try Remove self, its a no-op
589   parent.Remove(parent);
590   DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
591
592   // try Remove empty
593   try
594   {
595     Actor empty;
596     parent.Remove(empty);
597     tet_printf("Assertion test failed - no Exception\n");
598     tet_result(TET_FAIL);
599   }
600   catch(Dali::DaliException& e)
601   {
602     DALI_TEST_PRINT_ASSERT(e);
603     DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
604     DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
605   }
606   catch(...)
607   {
608     tet_printf("Assertion test failed - wrong Exception\n");
609     tet_result(TET_FAIL);
610   }
611   END_TEST;
612 }
613
614 int UtcDaliActorRemoveP(void)
615 {
616   TestApplication application;
617
618   Actor parent = Actor::New();
619   Actor child  = Actor::New();
620   Actor random = Actor::New();
621
622   application.GetScene().Add(parent);
623
624   DALI_TEST_CHECK(parent.GetChildCount() == 0);
625
626   parent.Add(child);
627
628   DALI_TEST_CHECK(parent.GetChildCount() == 1);
629
630   parent.Remove(random);
631
632   DALI_TEST_CHECK(parent.GetChildCount() == 1);
633
634   application.GetScene().Remove(parent);
635
636   DALI_TEST_CHECK(parent.GetChildCount() == 1);
637   END_TEST;
638 }
639
640 int UtcDaliActorSwitchParentN(void)
641 {
642   tet_infoline("Testing Actor::UtcDaliActorSwitchParentN");
643   TestApplication application;
644
645   Actor parent1 = Actor::New();
646   Actor child   = Actor::New();
647
648   DALI_TEST_EQUALS(parent1.GetChildCount(), 0u, TEST_LOCATION);
649
650   parent1.Add(child);
651
652   DALI_TEST_EQUALS(parent1.GetChildCount(), 1u, TEST_LOCATION);
653
654   Actor parent2 = Actor::New();
655
656   DALI_TEST_EQUALS(parent2.GetChildCount(), 0u, TEST_LOCATION);
657
658   // Try switch parent with that both of parent1 and parent2 are off scene.
659   DevelActor::SwitchParent(child, parent2);
660
661   DALI_TEST_EQUALS(parent1.GetChildCount(), 1u, TEST_LOCATION);
662   DALI_TEST_EQUALS(parent2.GetChildCount(), 0u, TEST_LOCATION);
663   END_TEST;
664 }
665
666 int UtcDaliActorGetChildCount(void)
667 {
668   TestApplication application;
669
670   Actor parent = Actor::New();
671   Actor child  = Actor::New();
672
673   DALI_TEST_CHECK(parent.GetChildCount() == 0);
674
675   parent.Add(child);
676
677   DALI_TEST_CHECK(parent.GetChildCount() == 1);
678   END_TEST;
679 }
680
681 int UtcDaliActorGetChildren01(void)
682 {
683   TestApplication application;
684
685   Actor parent = Actor::New();
686   Actor first  = Actor::New();
687   Actor second = Actor::New();
688   Actor third  = Actor::New();
689
690   parent.Add(first);
691   parent.Add(second);
692   parent.Add(third);
693
694   DALI_TEST_CHECK(parent.GetChildAt(0) == first);
695   DALI_TEST_CHECK(parent.GetChildAt(1) == second);
696   DALI_TEST_CHECK(parent.GetChildAt(2) == third);
697   END_TEST;
698 }
699
700 int UtcDaliActorGetChildren02(void)
701 {
702   TestApplication application;
703
704   Actor parent = Actor::New();
705   Actor first  = Actor::New();
706   Actor second = Actor::New();
707   Actor third  = Actor::New();
708
709   parent.Add(first);
710   parent.Add(second);
711   parent.Add(third);
712
713   const Actor& constParent = parent;
714
715   DALI_TEST_CHECK(constParent.GetChildAt(0) == first);
716   DALI_TEST_CHECK(constParent.GetChildAt(1) == second);
717   DALI_TEST_CHECK(constParent.GetChildAt(2) == third);
718   END_TEST;
719 }
720
721 int UtcDaliActorGetParent01(void)
722 {
723   TestApplication application;
724
725   Actor parent = Actor::New();
726   Actor child  = Actor::New();
727
728   parent.Add(child);
729
730   DALI_TEST_CHECK(child.GetParent() == parent);
731   END_TEST;
732 }
733
734 int UtcDaliActorGetParent02(void)
735 {
736   TestApplication application;
737
738   Actor actor = Actor::New();
739
740   DALI_TEST_CHECK(!actor.GetParent());
741   END_TEST;
742 }
743
744 int UtcDaliActorCustomProperty(void)
745 {
746   TestApplication application;
747
748   Actor actor = Actor::New();
749   application.GetScene().Add(actor);
750
751   float           startValue(1.0f);
752   Property::Index index = actor.RegisterProperty("testProperty", startValue);
753   DALI_TEST_CHECK(actor.GetProperty<float>(index) == startValue);
754
755   application.SendNotification();
756   application.Render(0);
757   DALI_TEST_CHECK(actor.GetProperty<float>(index) == startValue);
758
759   actor.SetProperty(index, 5.0f);
760
761   application.SendNotification();
762   application.Render(0);
763   DALI_TEST_CHECK(actor.GetProperty<float>(index) == 5.0f);
764   END_TEST;
765 }
766
767 int UtcDaliActorCustomPropertyIntToFloat(void)
768 {
769   TestApplication application;
770
771   Actor actor = Actor::New();
772   application.GetScene().Add(actor);
773
774   float           startValue(5.0f);
775   Property::Index index = actor.RegisterProperty("testProperty", startValue);
776   DALI_TEST_CHECK(actor.GetProperty<float>(index) == startValue);
777
778   application.SendNotification();
779   application.Render(0);
780   DALI_TEST_CHECK(actor.GetProperty<float>(index) == startValue);
781
782   actor.SetProperty(index, int(1));
783
784   application.SendNotification();
785   application.Render(0);
786   DALI_TEST_CHECK(actor.GetProperty<float>(index) == 1.0f);
787   END_TEST;
788 }
789
790 int UtcDaliActorCustomPropertyFloatToInt(void)
791 {
792   TestApplication application;
793
794   Actor actor = Actor::New();
795   application.GetScene().Add(actor);
796
797   int             startValue(5);
798   Property::Index index = actor.RegisterProperty("testProperty", startValue);
799   DALI_TEST_CHECK(actor.GetProperty<int>(index) == startValue);
800
801   application.SendNotification();
802   application.Render(0);
803   DALI_TEST_CHECK(actor.GetProperty<int>(index) == startValue);
804
805   actor.SetProperty(index, float(1.5));
806
807   application.SendNotification();
808   application.Render(0);
809   DALI_TEST_CHECK(actor.GetProperty<int>(index) == 1);
810   END_TEST;
811 }
812
813 int UtcDaliActorSetParentOrigin(void)
814 {
815   TestApplication application;
816
817   Actor actor = Actor::New();
818
819   Vector3 vector(0.7f, 0.8f, 0.9f);
820   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
821
822   actor.SetProperty(Actor::Property::PARENT_ORIGIN, vector);
823
824   // flush the queue and render once
825   application.SendNotification();
826   application.Render();
827
828   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
829
830   application.GetScene().Add(actor);
831
832   actor.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0.1f, 0.2f, 0.3f));
833
834   // flush the queue and render once
835   application.SendNotification();
836   application.Render();
837
838   DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), TEST_LOCATION);
839
840   application.GetScene().Remove(actor);
841   END_TEST;
842 }
843
844 int UtcDaliActorSetParentOriginIndividual(void)
845 {
846   TestApplication application;
847
848   Actor actor = Actor::New();
849
850   Vector3 vector(0.7f, 0.8f, 0.9f);
851   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
852
853   actor.SetProperty(Actor::Property::PARENT_ORIGIN_X, vector.x);
854
855   // flush the queue and render once
856   application.SendNotification();
857   application.Render();
858
859   DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN).x, TEST_LOCATION);
860
861   actor.SetProperty(Actor::Property::PARENT_ORIGIN_Y, vector.y);
862
863   // flush the queue and render once
864   application.SendNotification();
865   application.Render();
866
867   DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN).y, TEST_LOCATION);
868
869   actor.SetProperty(Actor::Property::PARENT_ORIGIN_Z, vector.z);
870
871   // flush the queue and render once
872   application.SendNotification();
873   application.Render();
874
875   DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN).z, TEST_LOCATION);
876
877   END_TEST;
878 }
879
880 int UtcDaliActorGetCurrentParentOrigin(void)
881 {
882   TestApplication application;
883
884   Actor actor = Actor::New();
885
886   Vector3 vector(0.7f, 0.8f, 0.9f);
887   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
888
889   actor.SetProperty(Actor::Property::PARENT_ORIGIN, vector);
890
891   // flush the queue and render once
892   application.SendNotification();
893   application.Render();
894
895   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
896   END_TEST;
897 }
898
899 int UtcDaliActorSetAnchorPoint(void)
900 {
901   TestApplication application;
902
903   Actor actor = Actor::New();
904
905   Vector3 vector(0.7f, 0.8f, 0.9f);
906   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
907
908   actor.SetProperty(Actor::Property::ANCHOR_POINT, vector);
909
910   // flush the queue and render once
911   application.SendNotification();
912   application.Render();
913
914   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
915
916   application.GetScene().Add(actor);
917
918   actor.SetProperty(Actor::Property::ANCHOR_POINT, Vector3(0.1f, 0.2f, 0.3f));
919   // flush the queue and render once
920   application.SendNotification();
921   application.Render();
922
923   DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), TEST_LOCATION);
924
925   application.GetScene().Remove(actor);
926   END_TEST;
927 }
928
929 int UtcDaliActorSetAnchorPointIndividual(void)
930 {
931   TestApplication application;
932
933   Actor actor = Actor::New();
934
935   Vector3 vector(0.7f, 0.8f, 0.9f);
936   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
937
938   actor.SetProperty(Actor::Property::ANCHOR_POINT_X, vector.x);
939
940   // flush the queue and render once
941   application.SendNotification();
942   application.Render();
943
944   DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT).x, TEST_LOCATION);
945
946   actor.SetProperty(Actor::Property::ANCHOR_POINT_Y, vector.y);
947
948   // flush the queue and render once
949   application.SendNotification();
950   application.Render();
951
952   DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT).y, TEST_LOCATION);
953
954   actor.SetProperty(Actor::Property::ANCHOR_POINT_Z, vector.z);
955
956   // flush the queue and render once
957   application.SendNotification();
958   application.Render();
959
960   DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT).z, TEST_LOCATION);
961
962   END_TEST;
963 }
964
965 int UtcDaliActorGetCurrentAnchorPoint(void)
966 {
967   TestApplication application;
968
969   Actor actor = Actor::New();
970
971   Vector3 vector(0.7f, 0.8f, 0.9f);
972   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
973
974   actor.SetProperty(Actor::Property::ANCHOR_POINT, vector);
975
976   // flush the queue and render once
977   application.SendNotification();
978   application.Render();
979
980   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
981   END_TEST;
982 }
983
984 int UtcDaliActorSetSize01(void)
985 {
986   TestApplication application;
987
988   Actor   actor = Actor::New();
989   Vector3 vector(100.0f, 100.0f, 0.0f);
990
991   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
992
993   actor.SetProperty(Actor::Property::SIZE, Vector2(vector.x, vector.y));
994
995   // Immediately retrieve the size after setting
996   Vector3 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
997   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
998   DALI_TEST_EQUALS(vector.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
999   DALI_TEST_EQUALS(vector.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
1000   DALI_TEST_EQUALS(vector.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
1001
1002   // Flush the queue and render once
1003   application.SendNotification();
1004   application.Render();
1005
1006   // Check the size in the new frame
1007   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1008
1009   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1010   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1011   DALI_TEST_EQUALS(vector.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
1012   DALI_TEST_EQUALS(vector.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
1013   DALI_TEST_EQUALS(vector.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
1014
1015   // Check async behaviour
1016   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
1017   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1018   DALI_TEST_EQUALS(vector.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
1019   DALI_TEST_EQUALS(vector.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
1020   DALI_TEST_EQUALS(vector.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
1021
1022   // Change the resize policy and check whether the size stays the same
1023   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
1024
1025   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1026   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1027
1028   // Set a new size after resize policy is changed and check the new size
1029   actor.SetProperty(Actor::Property::SIZE, Vector3(0.1f, 0.2f, 0.0f));
1030
1031   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1032   DALI_TEST_EQUALS(currentSize, Vector3(0.1f, 0.2f, 0.0f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1033
1034   // Change the resize policy again and check whether the new size stays the same
1035   actor.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
1036
1037   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1038   DALI_TEST_EQUALS(currentSize, Vector3(0.1f, 0.2f, 0.0f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1039
1040   // Set another new size after resize policy is changed and check the new size
1041   actor.SetProperty(Actor::Property::SIZE, Vector3(50.0f, 60.0f, 0.0f));
1042
1043   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1044   DALI_TEST_EQUALS(currentSize, Vector3(50.0f, 60.0f, 0.0f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1045
1046   END_TEST;
1047 }
1048
1049 int UtcDaliActorSetSize02(void)
1050 {
1051   TestApplication application;
1052
1053   Actor   actor = Actor::New();
1054   Vector3 vector(100.0f, 100.0f, 100.0f);
1055
1056   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1057
1058   actor.SetProperty(Actor::Property::SIZE, Vector3(vector.x, vector.y, vector.z));
1059
1060   // Immediately check the size after setting
1061   Vector3 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1062   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1063
1064   // flush the queue and render once
1065   application.SendNotification();
1066   application.Render();
1067
1068   // Check the size in the new frame
1069   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1070
1071   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1072   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1073
1074   END_TEST;
1075 }
1076
1077 // SetSize(Vector2 size)
1078 int UtcDaliActorSetSize03(void)
1079 {
1080   TestApplication application;
1081
1082   Actor   actor = Actor::New();
1083   Vector3 vector(100.0f, 100.0f, 0.0f);
1084
1085   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1086
1087   actor.SetProperty(Actor::Property::SIZE, Vector2(vector.x, vector.y));
1088
1089   // Immediately check the size after setting
1090   Vector3 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1091   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1092
1093   // flush the queue and render once
1094   application.SendNotification();
1095   application.Render();
1096
1097   // Check the size in the new frame
1098   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1099
1100   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1101   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1102
1103   END_TEST;
1104 }
1105
1106 // SetSize(Vector3 size)
1107 int UtcDaliActorSetSize04(void)
1108 {
1109   TestApplication application;
1110
1111   Actor   actor = Actor::New();
1112   Vector3 vector(100.0f, 100.0f, 100.0f);
1113
1114   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1115
1116   actor.SetProperty(Actor::Property::SIZE, vector);
1117
1118   // Immediately check the size after setting
1119   Vector3 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1120   DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1121
1122   // flush the queue and render once
1123   application.SendNotification();
1124   application.Render();
1125
1126   // Check the size in the new frame
1127   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1128
1129   application.GetScene().Add(actor);
1130   actor.SetProperty(Actor::Property::SIZE, Vector3(0.1f, 0.2f, 0.3f));
1131
1132   // Immediately check the size after setting
1133   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1134   DALI_TEST_EQUALS(currentSize, Vector3(0.1f, 0.2f, 0.3f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1135
1136   // flush the queue and render once
1137   application.SendNotification();
1138   application.Render();
1139
1140   // Check the size in the new frame
1141   DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE), TEST_LOCATION);
1142
1143   currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1144   DALI_TEST_EQUALS(currentSize, Vector3(0.1f, 0.2f, 0.3f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1145
1146   application.GetScene().Remove(actor);
1147   END_TEST;
1148 }
1149
1150 int UtcDaliActorSetSizeIndividual(void)
1151 {
1152   TestApplication application;
1153
1154   Actor actor = Actor::New();
1155
1156   Vector3 vector(0.7f, 0.8f, 0.9f);
1157   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1158
1159   actor.SetProperty(Actor::Property::SIZE_WIDTH, vector.width);
1160
1161   // Immediately check the width after setting
1162   float sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1163   DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1164
1165   // flush the queue and render once
1166   application.SendNotification();
1167   application.Render();
1168
1169   // Check the width in the new frame
1170   DALI_TEST_EQUALS(vector.width, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, TEST_LOCATION);
1171
1172   sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1173   DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1174
1175   actor.SetProperty(Actor::Property::SIZE_HEIGHT, vector.height);
1176
1177   // Immediately check the height after setting
1178   float sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1179   DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1180
1181   // flush the queue and render once
1182   application.SendNotification();
1183   application.Render();
1184
1185   // Check the height in the new frame
1186   DALI_TEST_EQUALS(vector.height, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, TEST_LOCATION);
1187
1188   sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1189   DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1190
1191   actor.SetProperty(Actor::Property::SIZE_DEPTH, vector.depth);
1192
1193   // Immediately check the depth after setting
1194   float sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1195   DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1196
1197   // flush the queue and render once
1198   application.SendNotification();
1199   application.Render();
1200
1201   // Check the depth in the new frame
1202   DALI_TEST_EQUALS(vector.depth, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).depth, TEST_LOCATION);
1203
1204   sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1205   DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1206
1207   // Change the resize policy and check whether the size stays the same
1208   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
1209
1210   sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1211   DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1212
1213   sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1214   DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1215
1216   sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1217   DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1218
1219   // Change the resize policy again and check whether the size stays the same
1220   actor.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
1221
1222   sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1223   DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1224
1225   sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1226   DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1227
1228   sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1229   DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1230
1231   END_TEST;
1232 }
1233
1234 int UtcDaliActorSetSizeIndividual02(void)
1235 {
1236   TestApplication application;
1237
1238   Actor actor = Actor::New();
1239   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
1240   application.GetScene().Add(actor);
1241
1242   Vector3 vector(100.0f, 200.0f, 400.0f);
1243   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1244
1245   actor.SetProperty(Actor::Property::SIZE_WIDTH, vector.width);
1246   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>(), vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1247
1248   actor.SetProperty(Actor::Property::SIZE_HEIGHT, vector.height);
1249   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>(), vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1250
1251   actor.SetProperty(Actor::Property::SIZE_DEPTH, vector.depth);
1252   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>(), vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1253
1254   // flush the queue and render once
1255   application.SendNotification();
1256   application.Render();
1257
1258   // Check the width in the new frame
1259   DALI_TEST_EQUALS(vector.width, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, TEST_LOCATION);
1260   DALI_TEST_EQUALS(vector.height, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, TEST_LOCATION);
1261
1262   END_TEST;
1263 }
1264
1265 int UtcDaliActorGetCurrentSize(void)
1266 {
1267   TestApplication application;
1268
1269   Actor   actor = Actor::New();
1270   Vector3 vector(100.0f, 100.0f, 20.0f);
1271
1272   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1273
1274   actor.SetProperty(Actor::Property::SIZE, vector);
1275
1276   // flush the queue and render once
1277   application.SendNotification();
1278   application.Render();
1279
1280   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1281   END_TEST;
1282 }
1283
1284 int UtcDaliActorGetNaturalSize(void)
1285 {
1286   TestApplication application;
1287
1288   Actor   actor = Actor::New();
1289   Vector3 vector(0.0f, 0.0f, 0.0f);
1290
1291   DALI_TEST_CHECK(actor.GetNaturalSize() == vector);
1292
1293   END_TEST;
1294 }
1295
1296 int UtcDaliActorGetCurrentSizeImmediate(void)
1297 {
1298   TestApplication application;
1299
1300   Actor   actor = Actor::New();
1301   Vector3 vector(100.0f, 100.0f, 20.0f);
1302
1303   DALI_TEST_CHECK(vector != actor.GetTargetSize());
1304   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1305
1306   actor.SetProperty(Actor::Property::SIZE, vector);
1307
1308   DALI_TEST_CHECK(vector == actor.GetTargetSize());
1309   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1310
1311   // flush the queue and render once
1312   application.SendNotification();
1313   application.Render();
1314
1315   DALI_TEST_CHECK(vector == actor.GetTargetSize());
1316   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1317
1318   // Animation
1319   // Build the animation
1320   const float   durationSeconds = 2.0f;
1321   Animation     animation       = Animation::New(durationSeconds);
1322   const Vector3 targetValue(10.0f, 20.0f, 30.0f);
1323   animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
1324
1325   DALI_TEST_CHECK(actor.GetTargetSize() == vector);
1326
1327   application.GetScene().Add(actor);
1328
1329   // Start the animation
1330   animation.Play();
1331
1332   application.SendNotification();
1333   application.Render(static_cast<unsigned int>(durationSeconds * 1000.0f));
1334
1335   DALI_TEST_CHECK(actor.GetTargetSize() == targetValue);
1336
1337   END_TEST;
1338 }
1339
1340 int UtcDaliActorCalculateScreenExtents(void)
1341 {
1342   TestApplication application;
1343
1344   Actor actor = Actor::New();
1345
1346   actor.SetProperty(Actor::Property::POSITION, Vector3(2.0f, 2.0f, 16.0f));
1347   actor.SetProperty(Actor::Property::SIZE, Vector3{1.0f, 1.0f, 1.0f});
1348
1349   application.SendNotification();
1350   application.Render();
1351
1352   auto expectedExtent = Rect<>{-0.5f, -0.5f, 1.0f, 1.0f};
1353   auto actualExtent   = DevelActor::CalculateScreenExtents(actor);
1354   DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1355   DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1356   DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1357   DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1358
1359   application.GetScene().Remove(actor);
1360   END_TEST;
1361 }
1362
1363 // SetPosition(float x, float y)
1364 int UtcDaliActorSetPosition01(void)
1365 {
1366   TestApplication application;
1367
1368   Actor actor = Actor::New();
1369
1370   // Set to random to start off with
1371   actor.SetProperty(Actor::Property::POSITION, Vector3(120.0f, 120.0f, 0.0f));
1372
1373   Vector3 vector(100.0f, 100.0f, 0.0f);
1374
1375   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1376
1377   actor.SetProperty(Actor::Property::POSITION, Vector2(vector.x, vector.y));
1378   // flush the queue and render once
1379   application.SendNotification();
1380   application.Render();
1381   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1382
1383   application.GetScene().Add(actor);
1384   actor.SetProperty(Actor::Property::POSITION, Vector3(0.1f, 0.2f, 0.3f));
1385   // flush the queue and render once
1386   application.SendNotification();
1387   application.Render();
1388   DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
1389
1390   actor.SetProperty(Actor::Property::POSITION_X, 1.0f);
1391   actor.SetProperty(Actor::Property::POSITION_Y, 1.1f);
1392   actor.SetProperty(Actor::Property::POSITION_Z, 1.2f);
1393   // flush the queue and render once
1394   application.SendNotification();
1395   application.Render();
1396   DALI_TEST_EQUALS(Vector3(1.0f, 1.1f, 1.2f), actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
1397
1398   actor.TranslateBy(Vector3(0.1f, 0.1f, 0.1f));
1399   // flush the queue and render once
1400   application.SendNotification();
1401   application.Render();
1402   DALI_TEST_EQUALS(Vector3(1.1f, 1.2f, 1.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1403
1404   application.GetScene().Remove(actor);
1405   END_TEST;
1406 }
1407
1408 // SetPosition(float x, float y, float z)
1409 int UtcDaliActorSetPosition02(void)
1410 {
1411   TestApplication application;
1412
1413   Actor actor = Actor::New();
1414
1415   // Set to random to start off with
1416   actor.SetProperty(Actor::Property::POSITION, Vector3(120.0f, 120.0f, 120.0f));
1417
1418   Vector3 vector(100.0f, 100.0f, 100.0f);
1419
1420   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1421
1422   actor.SetProperty(Actor::Property::POSITION, Vector3(vector.x, vector.y, vector.z));
1423
1424   // flush the queue and render once
1425   application.SendNotification();
1426   application.Render();
1427
1428   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1429   END_TEST;
1430 }
1431
1432 // SetPosition(Vector3 position)
1433 int UtcDaliActorSetPosition03(void)
1434 {
1435   TestApplication application;
1436
1437   Actor actor = Actor::New();
1438
1439   // Set to random to start off with
1440   actor.SetProperty(Actor::Property::POSITION, Vector3(120.0f, 120.0f, 120.0f));
1441
1442   Vector3 vector(100.0f, 100.0f, 100.0f);
1443
1444   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1445
1446   actor.SetProperty(Actor::Property::POSITION, vector);
1447
1448   // flush the queue and render once
1449   application.SendNotification();
1450   application.Render();
1451
1452   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1453   END_TEST;
1454 }
1455
1456 int UtcDaliActorSetX(void)
1457 {
1458   TestApplication application;
1459
1460   Actor actor = Actor::New();
1461
1462   Vector3 vector(100.0f, 0.0f, 0.0f);
1463
1464   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1465
1466   actor.SetProperty(Actor::Property::POSITION_X, 100.0f);
1467
1468   // flush the queue and render once
1469   application.SendNotification();
1470   application.Render();
1471
1472   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1473   END_TEST;
1474 }
1475
1476 int UtcDaliActorSetY(void)
1477 {
1478   TestApplication application;
1479
1480   Actor actor = Actor::New();
1481
1482   Vector3 vector(0.0f, 100.0f, 0.0f);
1483
1484   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1485
1486   actor.SetProperty(Actor::Property::POSITION_Y, 100.0f);
1487
1488   // flush the queue and render once
1489   application.SendNotification();
1490   application.Render();
1491
1492   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1493   END_TEST;
1494 }
1495
1496 int UtcDaliActorSetZ(void)
1497 {
1498   TestApplication application;
1499
1500   Actor actor = Actor::New();
1501
1502   Vector3 vector(0.0f, 0.0f, 100.0f);
1503
1504   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1505
1506   actor.SetProperty(Actor::Property::POSITION_Z, 100.0f);
1507
1508   // flush the queue and render once
1509   application.SendNotification();
1510   application.Render();
1511
1512   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1513   END_TEST;
1514 }
1515
1516 int UtcDaliActorSetPositionProperties(void)
1517 {
1518   TestApplication application;
1519
1520   Actor actor = Actor::New();
1521
1522   Vector3 vector(0.7f, 0.8f, 0.9f);
1523   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1524
1525   actor.SetProperty(Actor::Property::POSITION_X, vector.x);
1526   DALI_TEST_EQUALS(vector.x, actor.GetProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1527   DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::POSITION_X), TEST_LOCATION);
1528
1529   // flush the queue and render once
1530   application.SendNotification();
1531   application.Render();
1532
1533   DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1534   DALI_TEST_EQUALS(vector.x, actor.GetProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1535   DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::POSITION_X), TEST_LOCATION);
1536   DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1537   DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<float>(Actor::Property::POSITION_X), TEST_LOCATION);
1538
1539   actor.SetProperty(Actor::Property::POSITION_Y, vector.y);
1540   DALI_TEST_EQUALS(vector.y, actor.GetProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1541   DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::POSITION_Y), TEST_LOCATION);
1542
1543   // flush the queue and render once
1544   application.SendNotification();
1545   application.Render();
1546
1547   DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1548   DALI_TEST_EQUALS(vector.y, actor.GetProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1549   DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::POSITION_Y), TEST_LOCATION);
1550   DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1551   DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<float>(Actor::Property::POSITION_Y), TEST_LOCATION);
1552
1553   actor.SetProperty(Actor::Property::POSITION_Z, vector.z);
1554   DALI_TEST_EQUALS(vector.z, actor.GetProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1555   DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::POSITION_Z), TEST_LOCATION);
1556
1557   // flush the queue and render once
1558   application.SendNotification();
1559   application.Render();
1560
1561   DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1562   DALI_TEST_EQUALS(vector.z, actor.GetProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1563   DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::POSITION_Z), TEST_LOCATION);
1564   DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1565   DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<float>(Actor::Property::POSITION_Z), TEST_LOCATION);
1566
1567   END_TEST;
1568 }
1569
1570 int UtcDaliActorTranslateBy(void)
1571 {
1572   TestApplication application;
1573
1574   Actor   actor = Actor::New();
1575   Vector3 vector(100.0f, 100.0f, 100.0f);
1576
1577   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1578
1579   actor.SetProperty(Actor::Property::POSITION, vector);
1580
1581   // flush the queue and render once
1582   application.SendNotification();
1583   application.Render();
1584
1585   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1586
1587   actor.TranslateBy(vector);
1588
1589   // flush the queue and render once
1590   application.SendNotification();
1591   application.Render();
1592
1593   DALI_TEST_CHECK(vector * 2.0f == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1594   END_TEST;
1595 }
1596
1597 int UtcDaliActorGetCurrentPosition(void)
1598 {
1599   TestApplication application;
1600
1601   Actor   actor = Actor::New();
1602   Vector3 setVector(100.0f, 100.0f, 0.0f);
1603   actor.SetProperty(Actor::Property::POSITION, setVector);
1604
1605   // flush the queue and render once
1606   application.SendNotification();
1607   application.Render();
1608
1609   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION) == setVector);
1610   END_TEST;
1611 }
1612
1613 int UtcDaliActorGetCurrentWorldPosition(void)
1614 {
1615   TestApplication application;
1616
1617   Actor   parent = Actor::New();
1618   Vector3 parentPosition(1.0f, 2.0f, 3.0f);
1619   parent.SetProperty(Actor::Property::POSITION, parentPosition);
1620   parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1621   parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1622   application.GetScene().Add(parent);
1623
1624   Actor child = Actor::New();
1625   child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1626   child.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1627   Vector3 childPosition(6.0f, 6.0f, 6.0f);
1628   child.SetProperty(Actor::Property::POSITION, childPosition);
1629   parent.Add(child);
1630
1631   // The actors should not have a world position yet
1632   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1633   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1634
1635   application.SendNotification();
1636   application.Render(0);
1637
1638   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
1639   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childPosition, TEST_LOCATION);
1640
1641   // The actors should have a world position now
1642   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
1643   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition + childPosition, TEST_LOCATION);
1644   END_TEST;
1645 }
1646
1647 int UtcDaliActorSetInheritPosition(void)
1648 {
1649   tet_infoline("Testing Actor::SetInheritPosition");
1650   TestApplication application;
1651
1652   Actor   parent = Actor::New();
1653   Vector3 parentPosition(1.0f, 2.0f, 3.0f);
1654   parent.SetProperty(Actor::Property::POSITION, parentPosition);
1655   parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1656   parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1657   application.GetScene().Add(parent);
1658
1659   Actor child = Actor::New();
1660   child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1661   child.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1662   Vector3 childPosition(10.0f, 11.0f, 12.0f);
1663   child.SetProperty(Actor::Property::POSITION, childPosition);
1664   parent.Add(child);
1665
1666   // The actors should not have a world position yet
1667   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1668   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1669
1670   // first test default, which is to inherit position
1671   DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_POSITION), true, TEST_LOCATION);
1672   application.SendNotification();
1673   application.Render(0); // should only really call Update as Render is not required to update scene
1674   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
1675   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childPosition, TEST_LOCATION);
1676   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
1677   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition + childPosition, TEST_LOCATION);
1678
1679   //Change child position
1680   Vector3 childOffset(-1.0f, 1.0f, 0.0f);
1681   child.SetProperty(Actor::Property::POSITION, childOffset);
1682
1683   // Use local position as world postion
1684   child.SetProperty(Actor::Property::INHERIT_POSITION, false);
1685   DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_POSITION), false, TEST_LOCATION);
1686   application.SendNotification();
1687   application.Render(0); // should only really call Update as Render is not required to update scene
1688   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
1689   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childOffset, TEST_LOCATION);
1690   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
1691   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), childOffset, TEST_LOCATION);
1692
1693   //Change back to inherit position from parent
1694   child.SetProperty(Actor::Property::INHERIT_POSITION, true);
1695   DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_POSITION), true, TEST_LOCATION);
1696   application.SendNotification();
1697   application.Render(0); // should only really call Update as Render is not required to update scene
1698   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
1699   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childOffset, TEST_LOCATION);
1700   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
1701   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition + childOffset, TEST_LOCATION);
1702   END_TEST;
1703 }
1704
1705 int UtcDaliActorInheritOpacity(void)
1706 {
1707   tet_infoline("Testing Actor::Inherit Opacity");
1708   TestApplication application;
1709
1710   Actor parent = Actor::New();
1711   Actor child  = Actor::New();
1712   parent.Add(child);
1713   application.GetScene().Add(parent);
1714
1715   DALI_TEST_EQUALS(parent.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION);
1716   DALI_TEST_EQUALS(child.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION);
1717
1718   // flush the queue and render once
1719   application.SendNotification();
1720   application.Render();
1721
1722   parent.SetProperty(Actor::Property::OPACITY, 0.1f);
1723
1724   DALI_TEST_EQUALS(parent.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION);
1725   DALI_TEST_EQUALS(child.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION);
1726
1727   application.SendNotification();
1728   application.Render();
1729
1730   DALI_TEST_EQUALS(parent.GetProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
1731   DALI_TEST_EQUALS(parent.GetCurrentProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION);
1732   DALI_TEST_EQUALS(parent.GetCurrentProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
1733   DALI_TEST_EQUALS(child.GetProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
1734   DALI_TEST_EQUALS(child.GetCurrentProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
1735   DALI_TEST_EQUALS(child.GetCurrentProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.f, 0.0001f, TEST_LOCATION);
1736
1737   END_TEST;
1738 }
1739
1740 // SetOrientation(float angleRadians, Vector3 axis)
1741 int UtcDaliActorSetOrientation01(void)
1742 {
1743   TestApplication application;
1744
1745   Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1746   Actor      actor = Actor::New();
1747
1748   actor.SetProperty(Actor::Property::ORIENTATION, rotation);
1749
1750   // flush the queue and render once
1751   application.SendNotification();
1752   application.Render();
1753
1754   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1755   END_TEST;
1756 }
1757
1758 int UtcDaliActorSetOrientation02(void)
1759 {
1760   TestApplication application;
1761
1762   Actor actor = Actor::New();
1763
1764   Radian  angle(0.785f);
1765   Vector3 axis(1.0f, 1.0f, 0.0f);
1766
1767   actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(angle, axis));
1768   Quaternion rotation(angle, axis);
1769   // flush the queue and render once
1770   application.SendNotification();
1771   application.Render();
1772   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1773
1774   application.GetScene().Add(actor);
1775   actor.RotateBy(Degree(360), axis);
1776   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1777
1778   actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(0), Vector3(1.0f, 0.0f, 0.0f)));
1779   Quaternion result(Radian(0), Vector3(1.0f, 0.0f, 0.0f));
1780   // flush the queue and render once
1781   application.SendNotification();
1782   application.Render();
1783   DALI_TEST_EQUALS(result, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1784
1785   actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(angle, axis));
1786   // flush the queue and render once
1787   application.SendNotification();
1788   application.Render();
1789   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1790
1791   application.GetScene().Remove(actor);
1792   END_TEST;
1793 }
1794
1795 // SetOrientation(float angleRadians, Vector3 axis)
1796 int UtcDaliActorSetOrientationProperty(void)
1797 {
1798   TestApplication application;
1799
1800   Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1801   Actor      actor = Actor::New();
1802
1803   actor.SetProperty(Actor::Property::ORIENTATION, rotation);
1804   DALI_TEST_EQUALS(rotation, actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1805
1806   // flush the queue and render once
1807   application.SendNotification();
1808   application.Render();
1809
1810   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1811   DALI_TEST_EQUALS(rotation, actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1812   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1813   END_TEST;
1814 }
1815
1816 // RotateBy(float angleRadians, Vector3 axis)
1817 int UtcDaliActorRotateBy01(void)
1818 {
1819   TestApplication application;
1820
1821   Actor actor = Actor::New();
1822
1823   Radian angle(M_PI * 0.25f);
1824   actor.RotateBy((angle), Vector3::ZAXIS);
1825   // flush the queue and render once
1826   application.SendNotification();
1827   application.Render();
1828   DALI_TEST_EQUALS(Quaternion(angle, Vector3::ZAXIS), actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1829
1830   application.GetScene().Add(actor);
1831
1832   actor.RotateBy(angle, Vector3::ZAXIS);
1833   // flush the queue and render once
1834   application.SendNotification();
1835   application.Render();
1836   DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1837
1838   application.GetScene().Remove(actor);
1839   END_TEST;
1840 }
1841
1842 // RotateBy(Quaternion relativeRotation)
1843 int UtcDaliActorRotateBy02(void)
1844 {
1845   TestApplication application;
1846
1847   Actor actor = Actor::New();
1848
1849   Radian     angle(M_PI * 0.25f);
1850   Quaternion rotation(angle, Vector3::ZAXIS);
1851   actor.RotateBy(rotation);
1852   // flush the queue and render once
1853   application.SendNotification();
1854   application.Render();
1855   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1856
1857   actor.RotateBy(rotation);
1858   // flush the queue and render once
1859   application.SendNotification();
1860   application.Render();
1861   DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1862   END_TEST;
1863 }
1864
1865 int UtcDaliActorGetCurrentOrientation(void)
1866 {
1867   TestApplication application;
1868   Actor           actor = Actor::New();
1869
1870   Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1871   actor.SetProperty(Actor::Property::ORIENTATION, rotation);
1872   // flush the queue and render once
1873   application.SendNotification();
1874   application.Render();
1875   DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1876   END_TEST;
1877 }
1878
1879 int UtcDaliActorGetCurrentWorldOrientation(void)
1880 {
1881   tet_infoline("Testing Actor::GetCurrentWorldRotation");
1882   TestApplication application;
1883
1884   Actor      parent = Actor::New();
1885   Radian     rotationAngle(Degree(90.0f));
1886   Quaternion rotation(rotationAngle, Vector3::YAXIS);
1887   parent.SetProperty(Actor::Property::ORIENTATION, rotation);
1888   application.GetScene().Add(parent);
1889
1890   Actor child = Actor::New();
1891   child.SetProperty(Actor::Property::ORIENTATION, rotation);
1892   parent.Add(child);
1893
1894   // The actors should not have a world rotation yet
1895   DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION);
1896   DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION);
1897
1898   application.SendNotification();
1899   application.Render(0);
1900
1901   DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), rotation, 0.001, TEST_LOCATION);
1902   DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), rotation, 0.001, TEST_LOCATION);
1903
1904   // The actors should have a world rotation now
1905   DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(rotationAngle, Vector3::YAXIS), 0.001, TEST_LOCATION);
1906   DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(rotationAngle * 2.0f, Vector3::YAXIS), 0.001, TEST_LOCATION);
1907
1908   // turn off child rotation inheritance
1909   child.SetProperty(Actor::Property::INHERIT_ORIENTATION, false);
1910   DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_ORIENTATION), false, TEST_LOCATION);
1911   application.SendNotification();
1912   application.Render(0);
1913
1914   // The actors should have a world rotation now
1915   DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(rotationAngle, Vector3::YAXIS), 0.001, TEST_LOCATION);
1916   DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), rotation, 0.001, TEST_LOCATION);
1917   END_TEST;
1918 }
1919
1920 // SetScale(float scale)
1921 int UtcDaliActorSetScale01(void)
1922 {
1923   TestApplication application;
1924
1925   Actor actor = Actor::New();
1926
1927   // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
1928   actor.SetProperty(Actor::Property::SCALE, 0.25f);
1929
1930   Vector3 scale(10.0f, 10.0f, 10.0f);
1931   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) != scale);
1932
1933   actor.SetProperty(Actor::Property::SCALE, scale.x);
1934
1935   // flush the queue and render once
1936   application.SendNotification();
1937   application.Render();
1938
1939   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
1940   END_TEST;
1941 }
1942
1943 // SetScale(float scaleX, float scaleY, float scaleZ)
1944 int UtcDaliActorSetScale02(void)
1945 {
1946   TestApplication application;
1947   Vector3         scale(10.0f, 10.0f, 10.0f);
1948
1949   Actor actor = Actor::New();
1950
1951   // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
1952   actor.SetProperty(Actor::Property::SCALE, Vector3(12.0f, 1.0f, 2.0f));
1953
1954   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) != scale);
1955
1956   actor.SetProperty(Actor::Property::SCALE, Vector3(scale.x, scale.y, scale.z));
1957   // flush the queue and render once
1958   application.SendNotification();
1959   application.Render();
1960   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
1961
1962   // add to stage and test
1963   application.GetScene().Add(actor);
1964   actor.SetProperty(Actor::Property::SCALE, Vector3(2.0f, 2.0f, 2.0f));
1965   // flush the queue and render once
1966   application.SendNotification();
1967   application.Render();
1968   DALI_TEST_EQUALS(Vector3(2.0f, 2.0f, 2.0f), actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE), 0.001, TEST_LOCATION);
1969
1970   application.GetScene().Remove(actor);
1971
1972   END_TEST;
1973 }
1974
1975 // SetScale(Vector3 scale)
1976 int UtcDaliActorSetScale03(void)
1977 {
1978   TestApplication application;
1979   Vector3         scale(10.0f, 10.0f, 10.0f);
1980
1981   Actor actor = Actor::New();
1982
1983   // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
1984   actor.SetProperty(Actor::Property::SCALE, Vector3(12.0f, 1.0f, 2.0f));
1985
1986   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) != scale);
1987
1988   actor.SetProperty(Actor::Property::SCALE, scale);
1989
1990   // flush the queue and render once
1991   application.SendNotification();
1992   application.Render();
1993
1994   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
1995   END_TEST;
1996 }
1997
1998 int UtcDaliActorSetScaleIndividual(void)
1999 {
2000   TestApplication application;
2001
2002   Actor actor = Actor::New();
2003
2004   Vector3 vector(0.7f, 0.8f, 0.9f);
2005   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2006
2007   actor.SetProperty(Actor::Property::SCALE_X, vector.x);
2008   DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::SCALE_X), TEST_LOCATION);
2009
2010   // flush the queue and render once
2011   application.SendNotification();
2012   application.Render();
2013
2014   DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE).x, TEST_LOCATION);
2015   DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::SCALE_X), TEST_LOCATION);
2016   DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<float>(Actor::Property::SCALE_X), TEST_LOCATION);
2017
2018   actor.SetProperty(Actor::Property::SCALE_Y, vector.y);
2019   DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::SCALE_Y), TEST_LOCATION);
2020
2021   // flush the queue and render once
2022   application.SendNotification();
2023   application.Render();
2024
2025   DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE).y, TEST_LOCATION);
2026   DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::SCALE_Y), TEST_LOCATION);
2027   DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<float>(Actor::Property::SCALE_Y), TEST_LOCATION);
2028
2029   actor.SetProperty(Actor::Property::SCALE_Z, vector.z);
2030   DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::SCALE_Z), TEST_LOCATION);
2031
2032   // flush the queue and render once
2033   application.SendNotification();
2034   application.Render();
2035
2036   DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE).z, TEST_LOCATION);
2037   DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::SCALE_Z), TEST_LOCATION);
2038   DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<float>(Actor::Property::SCALE_Z), TEST_LOCATION);
2039
2040   DALI_TEST_EQUALS(vector, actor.GetProperty<Vector3>(Actor::Property::SCALE), TEST_LOCATION);
2041   DALI_TEST_EQUALS(vector, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE), TEST_LOCATION);
2042
2043   END_TEST;
2044 }
2045
2046 int UtcDaliActorScaleBy(void)
2047 {
2048   TestApplication application;
2049   Actor           actor = Actor::New();
2050   Vector3         vector(100.0f, 100.0f, 100.0f);
2051
2052   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2053
2054   actor.SetProperty(Actor::Property::SCALE, vector);
2055
2056   // flush the queue and render once
2057   application.SendNotification();
2058   application.Render();
2059
2060   DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2061
2062   actor.ScaleBy(vector);
2063
2064   // flush the queue and render once
2065   application.SendNotification();
2066   application.Render();
2067
2068   DALI_TEST_CHECK(vector * 100.0f == actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2069   END_TEST;
2070 }
2071
2072 int UtcDaliActorGetCurrentScale(void)
2073 {
2074   TestApplication application;
2075   Vector3         scale(12.0f, 1.0f, 2.0f);
2076
2077   Actor actor = Actor::New();
2078
2079   actor.SetProperty(Actor::Property::SCALE, scale);
2080
2081   // flush the queue and render once
2082   application.SendNotification();
2083   application.Render();
2084
2085   DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
2086   END_TEST;
2087 }
2088
2089 int UtcDaliActorGetCurrentWorldScale(void)
2090 {
2091   TestApplication application;
2092
2093   Actor   parent = Actor::New();
2094   Vector3 parentScale(1.0f, 2.0f, 3.0f);
2095   parent.SetProperty(Actor::Property::SCALE, parentScale);
2096   application.GetScene().Add(parent);
2097
2098   Actor   child = Actor::New();
2099   Vector3 childScale(2.0f, 2.0f, 2.0f);
2100   child.SetProperty(Actor::Property::SCALE, childScale);
2101   parent.Add(child);
2102
2103   // The actors should not have a scale yet
2104   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::SCALE), Vector3::ONE, TEST_LOCATION);
2105   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::SCALE), Vector3::ONE, TEST_LOCATION);
2106
2107   // The actors should not have a world scale yet
2108   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), Vector3::ONE, TEST_LOCATION);
2109   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), Vector3::ONE, TEST_LOCATION);
2110
2111   application.SendNotification();
2112   application.Render(0);
2113
2114   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::SCALE), parentScale, TEST_LOCATION);
2115   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::SCALE), childScale, TEST_LOCATION);
2116
2117   // The actors should have a world scale now
2118   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), parentScale, TEST_LOCATION);
2119   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), parentScale * childScale, TEST_LOCATION);
2120   END_TEST;
2121 }
2122
2123 int UtcDaliActorInheritScale(void)
2124 {
2125   tet_infoline("Testing Actor::SetInheritScale");
2126   TestApplication application;
2127
2128   Actor   parent = Actor::New();
2129   Vector3 parentScale(1.0f, 2.0f, 3.0f);
2130   parent.SetProperty(Actor::Property::SCALE, parentScale);
2131   application.GetScene().Add(parent);
2132
2133   Actor   child = Actor::New();
2134   Vector3 childScale(2.0f, 2.0f, 2.0f);
2135   child.SetProperty(Actor::Property::SCALE, childScale);
2136   parent.Add(child);
2137
2138   application.SendNotification();
2139   application.Render(0);
2140
2141   DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_SCALE), true, TEST_LOCATION);
2142   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), parentScale * childScale, TEST_LOCATION);
2143
2144   child.SetProperty(Actor::Property::INHERIT_SCALE, false);
2145   DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_SCALE), false, TEST_LOCATION);
2146
2147   application.SendNotification();
2148   application.Render(0);
2149
2150   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), childScale, TEST_LOCATION);
2151   END_TEST;
2152 }
2153
2154 int UtcDaliActorSetVisible(void)
2155 {
2156   TestApplication application;
2157
2158   Actor actor = Actor::New();
2159   actor.SetProperty(Actor::Property::VISIBLE, false);
2160   // flush the queue and render once
2161   application.SendNotification();
2162   application.Render();
2163   DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == false);
2164
2165   actor.SetProperty(Actor::Property::VISIBLE, true);
2166   // flush the queue and render once
2167   application.SendNotification();
2168   application.Render();
2169   DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == true);
2170
2171   // put actor on stage
2172   application.GetScene().Add(actor);
2173   actor.SetProperty(Actor::Property::VISIBLE, false);
2174   // flush the queue and render once
2175   application.SendNotification();
2176   application.Render();
2177   DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == false);
2178   END_TEST;
2179 }
2180
2181 int UtcDaliActorIsVisible(void)
2182 {
2183   TestApplication application;
2184
2185   Actor actor = Actor::New();
2186
2187   DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == true);
2188   END_TEST;
2189 }
2190
2191 int UtcDaliActorSetOpacity(void)
2192 {
2193   TestApplication application;
2194
2195   Actor actor = Actor::New();
2196   // initial opacity is 1
2197   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, TEST_LOCATION);
2198
2199   actor.SetProperty(Actor::Property::OPACITY, 0.4f);
2200   // flush the queue and render once
2201   application.SendNotification();
2202   application.Render();
2203   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.4f, TEST_LOCATION);
2204
2205   // change opacity, actor is on stage to change is not immediate
2206   actor.SetProperty(Actor::Property::OPACITY, actor.GetCurrentProperty<float>(Actor::Property::OPACITY) + 0.1f);
2207   // flush the queue and render once
2208   application.SendNotification();
2209   application.Render();
2210   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.5f, TEST_LOCATION);
2211
2212   // put actor on stage
2213   application.GetScene().Add(actor);
2214
2215   // change opacity, actor is on stage to change is not immediate
2216   actor.SetProperty(Actor::Property::OPACITY, 0.9f);
2217   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.5f, TEST_LOCATION);
2218   // flush the queue and render once
2219   application.SendNotification();
2220   application.Render();
2221   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.9f, TEST_LOCATION);
2222
2223   // change opacity, actor is on stage to change is not immediate
2224   actor.SetProperty(Actor::Property::OPACITY, actor.GetCurrentProperty<float>(Actor::Property::OPACITY) - 0.9f);
2225   // flush the queue and render once
2226   application.SendNotification();
2227   application.Render();
2228   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, TEST_LOCATION);
2229   END_TEST;
2230 }
2231
2232 int UtcDaliActorGetCurrentOpacity(void)
2233 {
2234   TestApplication application;
2235
2236   Actor actor = Actor::New();
2237   DALI_TEST_CHECK(actor.GetCurrentProperty<float>(Actor::Property::OPACITY) != 0.5f);
2238
2239   actor.SetProperty(Actor::Property::OPACITY, 0.5f);
2240   // flush the queue and render once
2241   application.SendNotification();
2242   application.Render();
2243   DALI_TEST_CHECK(actor.GetCurrentProperty<float>(Actor::Property::OPACITY) == 0.5f);
2244   END_TEST;
2245 }
2246
2247 int UtcDaliActorSetSensitive(void)
2248 {
2249   TestApplication application;
2250   Actor           actor = Actor::New();
2251
2252   bool sensitive = !actor.GetProperty<bool>(Actor::Property::SENSITIVE);
2253
2254   actor.SetProperty(Actor::Property::SENSITIVE, sensitive);
2255
2256   DALI_TEST_CHECK(sensitive == actor.GetProperty<bool>(Actor::Property::SENSITIVE));
2257   END_TEST;
2258 }
2259
2260 int UtcDaliActorIsSensitive(void)
2261 {
2262   TestApplication application;
2263   Actor           actor = Actor::New();
2264   actor.SetProperty(Actor::Property::SENSITIVE, false);
2265
2266   DALI_TEST_CHECK(false == actor.GetProperty<bool>(Actor::Property::SENSITIVE));
2267   END_TEST;
2268 }
2269
2270 int UtcDaliActorSetColor(void)
2271 {
2272   TestApplication application;
2273   Actor           actor = Actor::New();
2274   Vector4         color(1.0f, 1.0f, 1.0f, 0.5f);
2275
2276   DALI_TEST_CHECK(color != actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2277
2278   actor.SetProperty(Actor::Property::COLOR, color);
2279   // flush the queue and render once
2280   application.SendNotification();
2281   application.Render();
2282   DALI_TEST_CHECK(color == actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2283
2284   actor.SetProperty(Actor::Property::COLOR, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR) + Vector4(-0.4f, -0.5f, -0.6f, -0.4f));
2285   // flush the queue and render once
2286   application.SendNotification();
2287   application.Render();
2288   DALI_TEST_EQUALS(Vector4(0.6f, 0.5f, 0.4f, 0.1f), actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2289
2290   application.GetScene().Add(actor);
2291   actor.SetProperty(Actor::Property::COLOR, color);
2292   // flush the queue and render once
2293   application.SendNotification();
2294   application.Render();
2295   DALI_TEST_EQUALS(color, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2296
2297   actor.SetProperty(Actor::Property::COLOR, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR) + Vector4(1.1f, 1.1f, 1.1f, 1.1f));
2298   // flush the queue and render once
2299   application.SendNotification();
2300   application.Render();
2301   // Actor color is not clamped
2302   DALI_TEST_EQUALS(Vector4(2.1f, 2.1f, 2.1f, 1.6f), actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2303   // world color is clamped
2304   DALI_TEST_EQUALS(Vector4(1.0f, 1.0f, 1.0f, 1.0f), actor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), TEST_LOCATION);
2305
2306   actor.SetProperty(Actor::Property::COLOR, color);
2307   DALI_TEST_EQUALS(color, actor.GetProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2308
2309   Vector3 newColor(1.0f, 0.0f, 0.0f);
2310   actor.SetProperty(Actor::Property::COLOR, newColor);
2311   DALI_TEST_EQUALS(Vector4(newColor.r, newColor.g, newColor.b, 1.0f), actor.GetProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2312
2313   application.GetScene().Remove(actor);
2314   END_TEST;
2315 }
2316
2317 int UtcDaliActorSetColorIndividual(void)
2318 {
2319   TestApplication application;
2320
2321   Actor actor = Actor::New();
2322
2323   Vector4 vector(0.7f, 0.8f, 0.9f, 0.6f);
2324   DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2325
2326   actor.SetProperty(Actor::Property::COLOR_RED, vector.r);
2327   DALI_TEST_EQUALS(vector.r, actor.GetProperty<float>(Actor::Property::COLOR_RED), TEST_LOCATION);
2328
2329   // flush the queue and render once
2330   application.SendNotification();
2331   application.Render();
2332
2333   DALI_TEST_EQUALS(vector.r, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).r, TEST_LOCATION);
2334   DALI_TEST_EQUALS(vector.r, actor.GetProperty<float>(Actor::Property::COLOR_RED), TEST_LOCATION);
2335   DALI_TEST_EQUALS(vector.r, actor.GetCurrentProperty<float>(Actor::Property::COLOR_RED), TEST_LOCATION);
2336
2337   actor.SetProperty(Actor::Property::COLOR_GREEN, vector.g);
2338   DALI_TEST_EQUALS(vector.g, actor.GetProperty<float>(Actor::Property::COLOR_GREEN), TEST_LOCATION);
2339
2340   // flush the queue and render once
2341   application.SendNotification();
2342   application.Render();
2343
2344   DALI_TEST_EQUALS(vector.g, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).g, TEST_LOCATION);
2345   DALI_TEST_EQUALS(vector.g, actor.GetProperty<float>(Actor::Property::COLOR_GREEN), TEST_LOCATION);
2346   DALI_TEST_EQUALS(vector.g, actor.GetCurrentProperty<float>(Actor::Property::COLOR_GREEN), TEST_LOCATION);
2347
2348   actor.SetProperty(Actor::Property::COLOR_BLUE, vector.b);
2349   DALI_TEST_EQUALS(vector.b, actor.GetProperty<float>(Actor::Property::COLOR_BLUE), TEST_LOCATION);
2350
2351   // flush the queue and render once
2352   application.SendNotification();
2353   application.Render();
2354
2355   DALI_TEST_EQUALS(vector.b, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).b, TEST_LOCATION);
2356   DALI_TEST_EQUALS(vector.b, actor.GetProperty<float>(Actor::Property::COLOR_BLUE), TEST_LOCATION);
2357   DALI_TEST_EQUALS(vector.b, actor.GetCurrentProperty<float>(Actor::Property::COLOR_BLUE), TEST_LOCATION);
2358
2359   actor.SetProperty(Actor::Property::COLOR_ALPHA, vector.a);
2360   DALI_TEST_EQUALS(vector.a, actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), TEST_LOCATION);
2361
2362   // flush the queue and render once
2363   application.SendNotification();
2364   application.Render();
2365
2366   DALI_TEST_EQUALS(vector.a, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).a, TEST_LOCATION);
2367   DALI_TEST_EQUALS(vector.a, actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), TEST_LOCATION);
2368   DALI_TEST_EQUALS(vector.a, actor.GetCurrentProperty<float>(Actor::Property::COLOR_ALPHA), TEST_LOCATION);
2369
2370   DALI_TEST_EQUALS(vector, actor.GetProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2371   DALI_TEST_EQUALS(vector, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2372
2373   actor.SetProperty(Actor::Property::OPACITY, 0.2f);
2374
2375   // flush the queue and render once
2376   application.SendNotification();
2377   application.Render();
2378
2379   DALI_TEST_EQUALS(0.2f, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).a, TEST_LOCATION);
2380
2381   END_TEST;
2382 }
2383
2384 int UtcDaliActorGetCurrentColor(void)
2385 {
2386   TestApplication application;
2387   Actor           actor = Actor::New();
2388   Vector4         color(1.0f, 1.0f, 1.0f, 0.5f);
2389
2390   actor.SetProperty(Actor::Property::COLOR, color);
2391   // flush the queue and render once
2392   application.SendNotification();
2393   application.Render();
2394   DALI_TEST_CHECK(color == actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2395   END_TEST;
2396 }
2397
2398 int UtcDaliActorGetCurrentWorldColor(void)
2399 {
2400   tet_infoline("Actor::GetCurrentWorldColor");
2401   TestApplication application;
2402
2403   Actor   parent = Actor::New();
2404   Vector4 parentColor(1.0f, 0.5f, 0.0f, 0.8f);
2405   parent.SetProperty(Actor::Property::COLOR, parentColor);
2406   application.GetScene().Add(parent);
2407
2408   Actor   child = Actor::New();
2409   Vector4 childColor(0.5f, 0.6f, 0.5f, 1.0f);
2410   child.SetProperty(Actor::Property::COLOR, childColor);
2411   parent.Add(child);
2412
2413   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::COLOR), Color::WHITE, TEST_LOCATION);
2414   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), Color::WHITE, TEST_LOCATION);
2415
2416   // verify the default color mode
2417   DALI_TEST_EQUALS(USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2418
2419   // The actors should not have a world color yet
2420   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), Color::WHITE, TEST_LOCATION);
2421   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), Color::WHITE, TEST_LOCATION);
2422
2423   application.SendNotification();
2424   application.Render(0);
2425
2426   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::COLOR), parentColor, TEST_LOCATION);
2427   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), childColor, TEST_LOCATION);
2428
2429   // The actors should have a world color now
2430   DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), parentColor, TEST_LOCATION);
2431   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), Vector4(childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION);
2432
2433   // use own color
2434   child.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
2435   application.SendNotification();
2436   application.Render(0);
2437   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), childColor, TEST_LOCATION);
2438
2439   // use parent color
2440   child.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
2441   application.SendNotification();
2442   application.Render(0);
2443   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), childColor, TEST_LOCATION);
2444   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), parentColor, TEST_LOCATION);
2445
2446   // use parent alpha
2447   child.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
2448   application.SendNotification();
2449   application.Render(0);
2450   Vector4 expectedColor(childColor);
2451   expectedColor.a *= parentColor.a;
2452   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), childColor, TEST_LOCATION);
2453   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), expectedColor, TEST_LOCATION);
2454   END_TEST;
2455 }
2456
2457 int UtcDaliActorSetColorMode(void)
2458 {
2459   tet_infoline("Actor::SetColorMode");
2460   TestApplication application;
2461   Actor           actor = Actor::New();
2462   Actor           child = Actor::New();
2463   actor.Add(child);
2464
2465   actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
2466   DALI_TEST_EQUALS(USE_OWN_COLOR, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2467
2468   actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR);
2469   DALI_TEST_EQUALS(USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2470
2471   actor.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
2472   DALI_TEST_EQUALS(USE_PARENT_COLOR, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2473
2474   actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
2475   DALI_TEST_EQUALS(USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2476   END_TEST;
2477 }
2478
2479 int UtcDaliActorScreenToLocal(void)
2480 {
2481   TestApplication application;
2482   Actor           actor = Actor::New();
2483   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2484   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2485   actor.SetProperty(Actor::Property::POSITION, Vector2(10.0f, 10.0f));
2486   application.GetScene().Add(actor);
2487
2488   // flush the queue and render once
2489   application.SendNotification();
2490   application.Render();
2491
2492   float localX;
2493   float localY;
2494
2495   application.SendNotification();
2496   application.Render();
2497
2498   DALI_TEST_CHECK(actor.ScreenToLocal(localX, localY, 50.0f, 50.0f));
2499
2500   DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
2501   DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
2502   END_TEST;
2503 }
2504
2505 int UtcDaliActorSetLeaveRequired(void)
2506 {
2507   TestApplication application;
2508
2509   Actor actor = Actor::New();
2510
2511   actor.SetProperty(Actor::Property::LEAVE_REQUIRED, false);
2512   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::LEAVE_REQUIRED) == false);
2513
2514   actor.SetProperty(Actor::Property::LEAVE_REQUIRED, true);
2515   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::LEAVE_REQUIRED) == true);
2516   END_TEST;
2517 }
2518
2519 int UtcDaliActorGetLeaveRequired(void)
2520 {
2521   TestApplication application;
2522
2523   Actor actor = Actor::New();
2524
2525   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::LEAVE_REQUIRED) == false);
2526   END_TEST;
2527 }
2528
2529 int UtcDaliActorSetKeyboardFocusable(void)
2530 {
2531   TestApplication application;
2532
2533   Actor actor = Actor::New();
2534
2535   actor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
2536   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) == true);
2537
2538   actor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, false);
2539   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) == false);
2540   END_TEST;
2541 }
2542
2543 int UtcDaliActorIsKeyboardFocusable(void)
2544 {
2545   TestApplication application;
2546
2547   Actor actor = Actor::New();
2548
2549   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) == false);
2550   END_TEST;
2551 }
2552
2553 int UtcDaliActorSetKeyboardFocusableChildren(void)
2554 {
2555   TestApplication application;
2556
2557   Actor actor = Actor::New();
2558
2559   actor.SetProperty(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN, true);
2560   DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN) == true);
2561
2562   actor.SetProperty(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN, false);
2563   DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN) == false);
2564   END_TEST;
2565 }
2566
2567 int UtcDaliActorAreChildrenKeyBoardFocusable(void)
2568 {
2569   TestApplication application;
2570
2571   Actor actor = Actor::New();
2572
2573   DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN) == true);
2574   END_TEST;
2575 }
2576
2577 int UtcDaliActorSetTouchFocusable(void)
2578 {
2579   TestApplication application;
2580
2581   Actor actor = Actor::New();
2582
2583   actor.SetProperty(DevelActor::Property::TOUCH_FOCUSABLE, true);
2584   DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::TOUCH_FOCUSABLE) == true);
2585
2586   actor.SetProperty(DevelActor::Property::TOUCH_FOCUSABLE, false);
2587   DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::TOUCH_FOCUSABLE) == false);
2588   END_TEST;
2589 }
2590
2591 int UtcDaliActorIsTouchFocusable(void)
2592 {
2593   TestApplication application;
2594
2595   Actor actor = Actor::New();
2596
2597   DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::TOUCH_FOCUSABLE) == false);
2598   END_TEST;
2599 }
2600
2601 int UtcDaliActorRemoveConstraints(void)
2602 {
2603   tet_infoline(" UtcDaliActorRemoveConstraints");
2604   TestApplication application;
2605
2606   gTestConstraintCalled = false;
2607
2608   Actor actor = Actor::New();
2609
2610   Constraint constraint = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraint());
2611   constraint.Apply();
2612   actor.RemoveConstraints();
2613
2614   DALI_TEST_CHECK(gTestConstraintCalled == false);
2615
2616   application.GetScene().Add(actor);
2617   constraint.Apply();
2618
2619   // flush the queue and render once
2620   application.SendNotification();
2621   application.Render();
2622
2623   actor.RemoveConstraints();
2624
2625   DALI_TEST_CHECK(gTestConstraintCalled == true);
2626   END_TEST;
2627 }
2628
2629 int UtcDaliActorRemoveConstraintTag(void)
2630 {
2631   tet_infoline(" UtcDaliActorRemoveConstraintTag");
2632   TestApplication application;
2633
2634   Actor actor = Actor::New();
2635
2636   // 1. Apply Constraint1 and Constraint2, and test...
2637   unsigned int result1 = 0u;
2638   unsigned int result2 = 0u;
2639
2640   unsigned   constraint1Tag = 1u;
2641   Constraint constraint1    = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1));
2642   constraint1.SetTag(constraint1Tag);
2643   constraint1.Apply();
2644
2645   unsigned   constraint2Tag = 2u;
2646   Constraint constraint2    = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2));
2647   constraint2.SetTag(constraint2Tag);
2648   constraint2.Apply();
2649
2650   application.GetScene().Add(actor);
2651   // flush the queue and render once
2652   application.SendNotification();
2653   application.Render();
2654
2655   DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
2656   DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
2657
2658   // 2. Remove Constraint1 and test...
2659   result1 = 0;
2660   result2 = 0;
2661   actor.RemoveConstraints(constraint1Tag);
2662   // make color property dirty, which will trigger constraints to be reapplied.
2663   actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2664   // flush the queue and render once
2665   application.SendNotification();
2666   application.Render();
2667
2668   DALI_TEST_EQUALS(result1, 0u, TEST_LOCATION); ///< constraint 1 should not apply now.
2669   DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
2670
2671   // 3. Re-Apply Constraint1 and test...
2672   result1 = 0;
2673   result2 = 0;
2674   constraint1.Apply();
2675   // make color property dirty, which will trigger constraints to be reapplied.
2676   actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2677   // flush the queue and render once
2678   application.SendNotification();
2679   application.Render();
2680
2681   DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
2682   DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
2683
2684   // 2. Remove Constraint2 and test...
2685   result1 = 0;
2686   result2 = 0;
2687   actor.RemoveConstraints(constraint2Tag);
2688   // make color property dirty, which will trigger constraints to be reapplied.
2689   actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2690   // flush the queue and render once
2691   application.SendNotification();
2692   application.Render();
2693
2694   DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
2695   DALI_TEST_EQUALS(result2, 0u, TEST_LOCATION); ///< constraint 2 should not apply now.
2696
2697   // 2. Remove Constraint1 as well and test...
2698   result1 = 0;
2699   result2 = 0;
2700   actor.RemoveConstraints(constraint1Tag);
2701   // make color property dirty, which will trigger constraints to be reapplied.
2702   actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2703   // flush the queue and render once
2704   application.SendNotification();
2705   application.Render();
2706
2707   DALI_TEST_EQUALS(result1, 0u, TEST_LOCATION); ///< constraint 1 should not apply now.
2708   DALI_TEST_EQUALS(result2, 0u, TEST_LOCATION); ///< constraint 2 should not apply now.
2709   END_TEST;
2710 }
2711
2712 int UtcDaliActorTouchedSignal(void)
2713 {
2714   TestApplication application;
2715
2716   ResetTouchCallbacks();
2717
2718   // get the root layer
2719   Actor actor = application.GetScene().GetRootLayer();
2720   DALI_TEST_CHECK(gTouchCallBackCalled == false);
2721
2722   application.SendNotification();
2723   application.Render();
2724
2725   // connect to its touch signal
2726   actor.TouchedSignal().Connect(TestTouchCallback);
2727
2728   // simulate a touch event in the middle of the screen
2729   Vector2                  touchPoint(application.GetScene().GetSize() * 0.5);
2730   Dali::Integration::Point point;
2731   point.SetDeviceId(1);
2732   point.SetState(PointState::DOWN);
2733   point.SetScreenPosition(Vector2(touchPoint.x, touchPoint.y));
2734   Dali::Integration::TouchEvent touchEvent;
2735   touchEvent.AddPoint(point);
2736   application.ProcessEvent(touchEvent);
2737
2738   DALI_TEST_CHECK(gTouchCallBackCalled == true);
2739   END_TEST;
2740 }
2741
2742 int UtcDaliActorHoveredSignal(void)
2743 {
2744   TestApplication application;
2745
2746   gHoverCallBackCalled = false;
2747
2748   // get the root layer
2749   Actor actor = application.GetScene().GetRootLayer();
2750   DALI_TEST_CHECK(gHoverCallBackCalled == false);
2751
2752   application.SendNotification();
2753   application.Render();
2754
2755   // connect to its hover signal
2756   actor.HoveredSignal().Connect(TestCallback3);
2757
2758   // simulate a hover event in the middle of the screen
2759   Vector2                  touchPoint(application.GetScene().GetSize() * 0.5);
2760   Dali::Integration::Point point;
2761   point.SetDeviceId(1);
2762   point.SetState(PointState::MOTION);
2763   point.SetScreenPosition(Vector2(touchPoint.x, touchPoint.y));
2764   Dali::Integration::HoverEvent hoverEvent;
2765   hoverEvent.AddPoint(point);
2766   application.ProcessEvent(hoverEvent);
2767
2768   DALI_TEST_CHECK(gHoverCallBackCalled == true);
2769   END_TEST;
2770 }
2771
2772 int UtcDaliActorOnOffSceneSignal(void)
2773 {
2774   tet_infoline("Testing Dali::Actor::OnSceneSignal() and OffSceneSignal()");
2775
2776   TestApplication application;
2777
2778   // clean test data
2779   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2780   gActorNamesOnOffScene.clear();
2781
2782   Actor parent = Actor::New();
2783   parent.SetProperty(Actor::Property::NAME, "parent");
2784   parent.OnSceneSignal().Connect(OnSceneCallback);
2785   parent.OffSceneSignal().Connect(OffSceneCallback);
2786   // sanity check
2787   DALI_TEST_CHECK(gOnSceneCallBackCalled == 0);
2788   DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
2789
2790   // add parent to the scene
2791   application.GetScene().Add(parent);
2792   // onstage emitted, offstage not
2793   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 1, TEST_LOCATION);
2794   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
2795   DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
2796
2797   // test adding a child, should get onstage emitted
2798   // clean test data
2799   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2800   gActorNamesOnOffScene.clear();
2801
2802   Actor child = Actor::New();
2803   child.SetProperty(Actor::Property::NAME, "child");
2804   child.OnSceneSignal().Connect(OnSceneCallback);
2805   child.OffSceneSignal().Connect(OffSceneCallback);
2806   parent.Add(child); // add child
2807   // onscene emitted, offscene not
2808   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 1, TEST_LOCATION);
2809   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
2810   DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
2811
2812   // test removing parent from the scene
2813   // clean test data
2814   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2815   gActorNamesOnOffScene.clear();
2816
2817   application.GetScene().Remove(parent);
2818   // onscene not emitted, offscene is
2819   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
2820   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 2, TEST_LOCATION);
2821   DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
2822   DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[1], TEST_LOCATION);
2823
2824   // test adding parent back to the scene
2825   // clean test data
2826   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2827   gActorNamesOnOffScene.clear();
2828
2829   application.GetScene().Add(parent);
2830   // onscene emitted, offscene not
2831   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 2, TEST_LOCATION);
2832   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
2833   DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
2834   DALI_TEST_EQUALS("child", gActorNamesOnOffScene[1], TEST_LOCATION);
2835
2836   // test removing child
2837   // clean test data
2838   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2839   gActorNamesOnOffScene.clear();
2840
2841   parent.Remove(child);
2842   // onscene not emitted, offscene is
2843   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
2844   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 1, TEST_LOCATION);
2845   DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
2846
2847   // test removing parent
2848   // clean test data
2849   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2850   gActorNamesOnOffScene.clear();
2851
2852   application.GetScene().Remove(parent);
2853   // onscene not emitted, offscene is
2854   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
2855   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 1, TEST_LOCATION);
2856   DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
2857   END_TEST;
2858 }
2859
2860 int UtcDaliActorFindChildByName(void)
2861 {
2862   tet_infoline("Testing Dali::Actor::FindChildByName()");
2863   TestApplication application;
2864
2865   Actor parent = Actor::New();
2866   parent.SetProperty(Actor::Property::NAME, "parent");
2867   Actor first = Actor::New();
2868   first.SetProperty(Actor::Property::NAME, "first");
2869   Actor second = Actor::New();
2870   second.SetProperty(Actor::Property::NAME, "second");
2871
2872   parent.Add(first);
2873   first.Add(second);
2874
2875   Actor found = parent.FindChildByName("foo");
2876   DALI_TEST_CHECK(!found);
2877
2878   found = parent.FindChildByName("parent");
2879   DALI_TEST_CHECK(found == parent);
2880
2881   found = parent.FindChildByName("first");
2882   DALI_TEST_CHECK(found == first);
2883
2884   found = parent.FindChildByName("second");
2885   DALI_TEST_CHECK(found == second);
2886   END_TEST;
2887 }
2888
2889 int UtcDaliActorFindChildById(void)
2890 {
2891   tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2892   TestApplication application;
2893
2894   Actor parent = Actor::New();
2895   Actor first  = Actor::New();
2896   Actor second = Actor::New();
2897
2898   parent.Add(first);
2899   first.Add(second);
2900
2901   Actor found = parent.FindChildById(100000);
2902   DALI_TEST_CHECK(!found);
2903
2904   found = parent.FindChildById(parent.GetProperty<int>(Actor::Property::ID));
2905   DALI_TEST_CHECK(found == parent);
2906
2907   found = parent.FindChildById(first.GetProperty<int>(Actor::Property::ID));
2908   DALI_TEST_CHECK(found == first);
2909
2910   found = parent.FindChildById(second.GetProperty<int>(Actor::Property::ID));
2911   DALI_TEST_CHECK(found == second);
2912   END_TEST;
2913 }
2914
2915 int UtcDaliActorHitTest(void)
2916 {
2917   struct HitTestData
2918   {
2919   public:
2920     HitTestData(const Vector3& scale, const Vector2& touchPoint, bool result)
2921     : mScale(scale),
2922       mTouchPoint(touchPoint),
2923       mResult(result)
2924     {
2925     }
2926
2927     Vector3 mScale;
2928     Vector2 mTouchPoint;
2929     bool    mResult;
2930   };
2931
2932   TestApplication application;
2933   tet_infoline(" UtcDaliActorHitTest");
2934
2935   // Fill a vector with different hit tests.
2936   struct HitTestData* hitTestData[] = {
2937     //                    scale                     touch point           result
2938     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(289.f, 400.f), true),  // touch point close to the right edge (inside)
2939     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(291.f, 400.f), false), // touch point close to the right edge (outside)
2940     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.
2941     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(200.f, 451.f), false), // touch point close to the down edge (outside)
2942     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.
2943     NULL,
2944   };
2945
2946   // get the root layer
2947   Actor actor = Actor::New();
2948   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
2949   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
2950
2951   application.GetScene().Add(actor);
2952
2953   ResetTouchCallbacks();
2954
2955   unsigned int index = 0;
2956   while(NULL != hitTestData[index])
2957   {
2958     actor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f));
2959     actor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z));
2960
2961     // flush the queue and render once
2962     application.SendNotification();
2963     application.Render();
2964
2965     DALI_TEST_CHECK(!gTouchCallBackCalled);
2966
2967     // connect to its touch signal
2968     actor.TouchedSignal().Connect(TestTouchCallback);
2969
2970     Dali::Integration::Point point;
2971     point.SetState(PointState::DOWN);
2972     point.SetScreenPosition(Vector2(hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y));
2973     Dali::Integration::TouchEvent event;
2974     event.AddPoint(point);
2975
2976     // flush the queue and render once
2977     application.SendNotification();
2978     application.Render();
2979     application.ProcessEvent(event);
2980
2981     DALI_TEST_CHECK(gTouchCallBackCalled == hitTestData[index]->mResult);
2982
2983     if(gTouchCallBackCalled != hitTestData[index]->mResult)
2984       tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2985                  hitTestData[index]->mScale.x,
2986                  hitTestData[index]->mScale.y,
2987                  hitTestData[index]->mScale.z,
2988                  hitTestData[index]->mTouchPoint.x,
2989                  hitTestData[index]->mTouchPoint.y,
2990                  hitTestData[index]->mResult);
2991
2992     ResetTouchCallbacks();
2993     ++index;
2994   }
2995   END_TEST;
2996 }
2997
2998 int UtcDaliActorSetDrawMode(void)
2999 {
3000   TestApplication application;
3001   tet_infoline(" UtcDaliActorSetDrawModeOverlay");
3002
3003   Actor a = Actor::New();
3004
3005   application.GetScene().Add(a);
3006   application.SendNotification();
3007   application.Render(0);
3008   application.SendNotification();
3009   application.Render(1);
3010
3011   DALI_TEST_CHECK(DrawMode::NORMAL == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Ensure overlay is off by default
3012
3013   a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3014   application.SendNotification();
3015   application.Render(1);
3016
3017   DALI_TEST_CHECK(DrawMode::OVERLAY_2D == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Check Actor is overlay
3018
3019   a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::NORMAL);
3020   application.SendNotification();
3021   application.Render(1);
3022
3023   DALI_TEST_CHECK(DrawMode::NORMAL == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Check Actor is normal
3024   END_TEST;
3025 }
3026
3027 int UtcDaliActorSetDrawModeOverlayRender(void)
3028 {
3029   TestApplication application;
3030   tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
3031
3032   application.SendNotification();
3033   application.Render(1);
3034
3035   std::vector<GLuint> ids;
3036   ids.push_back(8);  // first rendered actor
3037   ids.push_back(9);  // second rendered actor
3038   ids.push_back(10); // third rendered actor
3039   application.GetGlAbstraction().SetNextTextureIds(ids);
3040
3041   Texture imageA = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
3042   Texture imageB = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
3043   Texture imageC = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
3044   Actor   a      = CreateRenderableActor(imageA);
3045   Actor   b      = CreateRenderableActor(imageB);
3046   Actor   c      = CreateRenderableActor(imageC);
3047
3048   application.SendNotification();
3049   application.Render(1);
3050
3051   //Textures are bound when first created. Clear bound textures vector
3052   application.GetGlAbstraction().ClearBoundTextures();
3053
3054   // Render a,b,c as regular non-overlays. so order will be:
3055   // a (8)
3056   // b (9)
3057   // c (10)
3058   application.GetScene().Add(a);
3059   application.GetScene().Add(b);
3060   application.GetScene().Add(c);
3061
3062   application.SendNotification();
3063   application.Render(1);
3064
3065   // Should be 3 textures changes.
3066   const std::vector<GLuint>&             boundTextures = application.GetGlAbstraction().GetBoundTextures(GL_TEXTURE0);
3067   typedef std::vector<GLuint>::size_type TextureSize;
3068   DALI_TEST_EQUALS(boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION);
3069   if(boundTextures.size() == 3)
3070   {
3071     DALI_TEST_CHECK(boundTextures[0] == 8u);
3072     DALI_TEST_CHECK(boundTextures[1] == 9u);
3073     DALI_TEST_CHECK(boundTextures[2] == 10u);
3074   }
3075
3076   // Now texture ids have been set, we can monitor their render order.
3077   // render a as an overlay (last), so order will be:
3078   // b (9)
3079   // c (10)
3080   // a (8)
3081   a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3082   application.GetGlAbstraction().ClearBoundTextures();
3083
3084   application.SendNotification();
3085   application.Render(1);
3086
3087   // Should be 3 texture changes.
3088   DALI_TEST_EQUALS(boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION);
3089   if(boundTextures.size() == 3)
3090   {
3091     DALI_TEST_CHECK(boundTextures[0] == 9u);
3092     DALI_TEST_CHECK(boundTextures[1] == 10u);
3093     DALI_TEST_CHECK(boundTextures[2] == 8u);
3094   }
3095   END_TEST;
3096 }
3097
3098 int UtcDaliActorGetCurrentWorldMatrix(void)
3099 {
3100   TestApplication application;
3101   tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
3102
3103   Actor parent = Actor::New();
3104   parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3105   parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3106   Vector3    parentPosition(10.0f, 20.0f, 30.0f);
3107   Radian     rotationAngle(Degree(85.0f));
3108   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3109   Vector3    parentScale(1.0f, 2.0f, 3.0f);
3110   parent.SetProperty(Actor::Property::POSITION, parentPosition);
3111   parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3112   parent.SetProperty(Actor::Property::SCALE, parentScale);
3113   application.GetScene().Add(parent);
3114
3115   Actor child = Actor::New();
3116   child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3117   Vector3    childPosition(0.0f, 0.0f, 100.0f);
3118   Radian     childRotationAngle(Degree(23.0f));
3119   Quaternion childRotation(childRotationAngle, Vector3::YAXIS);
3120   Vector3    childScale(2.0f, 2.0f, 2.0f);
3121   child.SetProperty(Actor::Property::POSITION, childPosition);
3122   child.SetProperty(Actor::Property::ORIENTATION, childRotation);
3123   child.SetProperty(Actor::Property::SCALE, childScale);
3124   parent.Add(child);
3125
3126   application.SendNotification();
3127   application.Render(0);
3128   application.Render();
3129   application.SendNotification();
3130
3131   Matrix parentMatrix(false);
3132   parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3133
3134   Matrix childMatrix(false);
3135   childMatrix.SetTransformComponents(childScale, childRotation, childPosition);
3136
3137   //Child matrix should be the composition of child and parent
3138   Matrix childWorldMatrix(false);
3139   Matrix::Multiply(childWorldMatrix, childMatrix, parentMatrix);
3140
3141   DALI_TEST_EQUALS(parent.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), parentMatrix, 0.001, TEST_LOCATION);
3142   DALI_TEST_EQUALS(child.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), childWorldMatrix, 0.001, TEST_LOCATION);
3143   END_TEST;
3144 }
3145
3146 int UtcDaliActorConstrainedToWorldMatrix(void)
3147 {
3148   TestApplication application;
3149   tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
3150
3151   Actor parent = Actor::New();
3152   parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3153   parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3154   Vector3    parentPosition(10.0f, 20.0f, 30.0f);
3155   Radian     rotationAngle(Degree(85.0f));
3156   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3157   Vector3    parentScale(1.0f, 2.0f, 3.0f);
3158   parent.SetProperty(Actor::Property::POSITION, parentPosition);
3159   parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3160   parent.SetProperty(Actor::Property::SCALE, parentScale);
3161   application.GetScene().Add(parent);
3162
3163   Actor child = Actor::New();
3164   child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3165   Constraint posConstraint = Constraint::New<Vector3>(child, Actor::Property::POSITION, PositionComponentConstraint());
3166   posConstraint.AddSource(Source(parent, Actor::Property::WORLD_MATRIX));
3167   posConstraint.Apply();
3168
3169   application.GetScene().Add(child);
3170
3171   application.SendNotification();
3172   application.Render(0);
3173   application.Render();
3174   application.SendNotification();
3175
3176   Matrix parentMatrix(false);
3177   parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3178
3179   DALI_TEST_EQUALS(parent.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), parentMatrix, 0.001, TEST_LOCATION);
3180   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), 0.001, TEST_LOCATION);
3181   END_TEST;
3182 }
3183
3184 int UtcDaliActorConstrainedToOrientation(void)
3185 {
3186   TestApplication application;
3187   tet_infoline(" UtcDaliActorConstrainedToOrientation");
3188
3189   Actor parent = Actor::New();
3190   parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3191   parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3192   Vector3    parentPosition(10.0f, 20.0f, 30.0f);
3193   Radian     rotationAngle(Degree(85.0f));
3194   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3195   Vector3    parentScale(1.0f, 2.0f, 3.0f);
3196   parent.SetProperty(Actor::Property::POSITION, parentPosition);
3197   parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3198   parent.SetProperty(Actor::Property::SCALE, parentScale);
3199   application.GetScene().Add(parent);
3200
3201   Actor child = Actor::New();
3202   child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3203   Constraint posConstraint = Constraint::New<Quaternion>(child, Actor::Property::ORIENTATION, OrientationComponentConstraint());
3204   posConstraint.AddSource(Source(parent, Actor::Property::ORIENTATION));
3205   posConstraint.Apply();
3206
3207   application.GetScene().Add(child);
3208
3209   application.SendNotification();
3210   application.Render(0);
3211   application.Render();
3212   application.SendNotification();
3213
3214   DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), parent.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
3215   END_TEST;
3216 }
3217
3218 int UtcDaliActorConstrainedToOpacity(void)
3219 {
3220   TestApplication application;
3221   tet_infoline(" UtcDaliActorConstrainedToOpacity");
3222
3223   Actor parent = Actor::New();
3224   parent.SetProperty(Actor::Property::OPACITY, 0.7f);
3225   application.GetScene().Add(parent);
3226
3227   Actor      child             = Actor::New();
3228   Constraint opacityConstraint = Constraint::New<float>(child, Actor::Property::OPACITY, EqualToConstraint());
3229   opacityConstraint.AddSource(Source(parent, Actor::Property::OPACITY));
3230   opacityConstraint.Apply();
3231
3232   application.GetScene().Add(child);
3233
3234   application.SendNotification();
3235   application.Render(0);
3236   application.Render();
3237   application.SendNotification();
3238
3239   DALI_TEST_EQUALS(child.GetCurrentProperty<float>(Actor::Property::OPACITY), parent.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.001f, TEST_LOCATION);
3240
3241   parent.SetProperty(Actor::Property::OPACITY, 0.3f);
3242
3243   application.SendNotification();
3244   application.Render(0);
3245   application.Render();
3246   application.SendNotification();
3247
3248   DALI_TEST_EQUALS(child.GetCurrentProperty<float>(Actor::Property::OPACITY), parent.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.001f, TEST_LOCATION);
3249
3250   END_TEST;
3251 }
3252
3253 int UtcDaliActorUnparent(void)
3254 {
3255   TestApplication application;
3256   tet_infoline(" UtcDaliActorUnparent");
3257
3258   Actor parent = Actor::New();
3259   application.GetScene().Add(parent);
3260
3261   Actor child = Actor::New();
3262
3263   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3264   DALI_TEST_CHECK(!child.GetParent());
3265
3266   // Test that calling Unparent with no parent is a NOOP
3267   child.Unparent();
3268
3269   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3270   DALI_TEST_CHECK(!child.GetParent());
3271
3272   // Test that Unparent works
3273   parent.Add(child);
3274
3275   DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
3276   DALI_TEST_CHECK(parent == child.GetParent());
3277
3278   child.Unparent();
3279
3280   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3281   DALI_TEST_CHECK(!child.GetParent());
3282
3283   // Test that UnparentAndReset works
3284   parent.Add(child);
3285
3286   DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
3287   DALI_TEST_CHECK(parent == child.GetParent());
3288
3289   UnparentAndReset(child);
3290
3291   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3292   DALI_TEST_CHECK(!child);
3293
3294   // Test that UnparentAndReset is a NOOP with empty handle
3295   UnparentAndReset(child);
3296
3297   DALI_TEST_CHECK(!child);
3298   END_TEST;
3299 }
3300
3301 int UtcDaliActorGetChildAt(void)
3302 {
3303   TestApplication application;
3304   tet_infoline(" UtcDaliActorGetChildAt");
3305
3306   Actor parent = Actor::New();
3307   application.GetScene().Add(parent);
3308
3309   Actor child0 = Actor::New();
3310   parent.Add(child0);
3311
3312   Actor child1 = Actor::New();
3313   parent.Add(child1);
3314
3315   Actor child2 = Actor::New();
3316   parent.Add(child2);
3317
3318   DALI_TEST_EQUALS(parent.GetChildAt(0), child0, TEST_LOCATION);
3319   DALI_TEST_EQUALS(parent.GetChildAt(1), child1, TEST_LOCATION);
3320   DALI_TEST_EQUALS(parent.GetChildAt(2), child2, TEST_LOCATION);
3321   END_TEST;
3322 }
3323
3324 int UtcDaliActorSetGetOverlay(void)
3325 {
3326   TestApplication application;
3327   tet_infoline(" UtcDaliActorSetGetOverlay");
3328
3329   Actor parent = Actor::New();
3330   parent.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3331   DALI_TEST_CHECK(parent.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE) == DrawMode::OVERLAY_2D);
3332   END_TEST;
3333 }
3334
3335 int UtcDaliActorCreateDestroy(void)
3336 {
3337   Actor* actor = new Actor;
3338   DALI_TEST_CHECK(actor);
3339   delete actor;
3340   END_TEST;
3341 }
3342
3343 namespace
3344 {
3345 struct PropertyStringIndex
3346 {
3347   const char* const     name;
3348   const Property::Index index;
3349   const Property::Type  type;
3350 };
3351
3352 const PropertyStringIndex PROPERTY_TABLE[] =
3353   {
3354     {"parentOrigin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3},
3355     {"parentOriginX", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT},
3356     {"parentOriginY", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT},
3357     {"parentOriginZ", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT},
3358     {"anchorPoint", Actor::Property::ANCHOR_POINT, Property::VECTOR3},
3359     {"anchorPointX", Actor::Property::ANCHOR_POINT_X, Property::FLOAT},
3360     {"anchorPointY", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT},
3361     {"anchorPointZ", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT},
3362     {"size", Actor::Property::SIZE, Property::VECTOR3},
3363     {"sizeWidth", Actor::Property::SIZE_WIDTH, Property::FLOAT},
3364     {"sizeHeight", Actor::Property::SIZE_HEIGHT, Property::FLOAT},
3365     {"sizeDepth", Actor::Property::SIZE_DEPTH, Property::FLOAT},
3366     {"position", Actor::Property::POSITION, Property::VECTOR3},
3367     {"positionX", Actor::Property::POSITION_X, Property::FLOAT},
3368     {"positionY", Actor::Property::POSITION_Y, Property::FLOAT},
3369     {"positionZ", Actor::Property::POSITION_Z, Property::FLOAT},
3370     {"worldPosition", Actor::Property::WORLD_POSITION, Property::VECTOR3},
3371     {"worldPositionX", Actor::Property::WORLD_POSITION_X, Property::FLOAT},
3372     {"worldPositionY", Actor::Property::WORLD_POSITION_Y, Property::FLOAT},
3373     {"worldPositionZ", Actor::Property::WORLD_POSITION_Z, Property::FLOAT},
3374     {"orientation", Actor::Property::ORIENTATION, Property::ROTATION},
3375     {"worldOrientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION},
3376     {"scale", Actor::Property::SCALE, Property::VECTOR3},
3377     {"scaleX", Actor::Property::SCALE_X, Property::FLOAT},
3378     {"scaleY", Actor::Property::SCALE_Y, Property::FLOAT},
3379     {"scaleZ", Actor::Property::SCALE_Z, Property::FLOAT},
3380     {"worldScale", Actor::Property::WORLD_SCALE, Property::VECTOR3},
3381     {"visible", Actor::Property::VISIBLE, Property::BOOLEAN},
3382     {"color", Actor::Property::COLOR, Property::VECTOR4},
3383     {"colorRed", Actor::Property::COLOR_RED, Property::FLOAT},
3384     {"colorGreen", Actor::Property::COLOR_GREEN, Property::FLOAT},
3385     {"colorBlue", Actor::Property::COLOR_BLUE, Property::FLOAT},
3386     {"colorAlpha", Actor::Property::COLOR_ALPHA, Property::FLOAT},
3387     {"worldColor", Actor::Property::WORLD_COLOR, Property::VECTOR4},
3388     {"worldMatrix", Actor::Property::WORLD_MATRIX, Property::MATRIX},
3389     {"name", Actor::Property::NAME, Property::STRING},
3390     {"sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN},
3391     {"leaveRequired", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN},
3392     {"inheritOrientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN},
3393     {"inheritScale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN},
3394     {"colorMode", Actor::Property::COLOR_MODE, Property::INTEGER},
3395     {"drawMode", Actor::Property::DRAW_MODE, Property::INTEGER},
3396     {"sizeModeFactor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3},
3397     {"widthResizePolicy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING},
3398     {"heightResizePolicy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING},
3399     {"sizeScalePolicy", Actor::Property::SIZE_SCALE_POLICY, Property::INTEGER},
3400     {"widthForHeight", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN},
3401     {"heightForWidth", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN},
3402     {"padding", Actor::Property::PADDING, Property::VECTOR4},
3403     {"minimumSize", Actor::Property::MINIMUM_SIZE, Property::VECTOR2},
3404     {"maximumSize", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2},
3405     {"inheritPosition", Actor::Property::INHERIT_POSITION, Property::BOOLEAN},
3406     {"clippingMode", Actor::Property::CLIPPING_MODE, Property::STRING},
3407     {"opacity", Actor::Property::OPACITY, Property::FLOAT},
3408 };
3409 const unsigned int PROPERTY_TABLE_COUNT = sizeof(PROPERTY_TABLE) / sizeof(PROPERTY_TABLE[0]);
3410 } // unnamed namespace
3411
3412 int UtcDaliActorProperties(void)
3413 {
3414   TestApplication application;
3415
3416   Actor actor = Actor::New();
3417
3418   for(unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i)
3419   {
3420     tet_printf("Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index);
3421     DALI_TEST_EQUALS(actor.GetPropertyName(PROPERTY_TABLE[i].index), PROPERTY_TABLE[i].name, TEST_LOCATION);
3422     DALI_TEST_EQUALS(actor.GetPropertyIndex(PROPERTY_TABLE[i].name), PROPERTY_TABLE[i].index, TEST_LOCATION);
3423     DALI_TEST_EQUALS(actor.GetPropertyType(PROPERTY_TABLE[i].index), PROPERTY_TABLE[i].type, TEST_LOCATION);
3424   }
3425   END_TEST;
3426 }
3427
3428 int UtcDaliRelayoutProperties_ResizePolicies(void)
3429 {
3430   TestApplication application;
3431
3432   Actor actor = Actor::New();
3433
3434   // Defaults
3435   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_RESIZE_POLICY).Get<std::string>(), "USE_NATURAL_SIZE", TEST_LOCATION);
3436   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_RESIZE_POLICY).Get<std::string>(), "USE_NATURAL_SIZE", TEST_LOCATION);
3437
3438   // Set resize policy for all dimensions
3439   actor.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
3440   for(unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
3441   {
3442     DALI_TEST_EQUALS(actor.GetResizePolicy(static_cast<Dimension::Type>(1 << i)), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION);
3443   }
3444
3445   // Set individual dimensions
3446   const char* const widthPolicy  = "FILL_TO_PARENT";
3447   const char* const heightPolicy = "FIXED";
3448
3449   actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy);
3450   actor.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy);
3451
3452   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_RESIZE_POLICY).Get<std::string>(), widthPolicy, TEST_LOCATION);
3453   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_RESIZE_POLICY).Get<std::string>(), heightPolicy, TEST_LOCATION);
3454
3455   // Set individual dimensions using enums
3456   ResizePolicy::Type widthPolicyEnum  = ResizePolicy::USE_ASSIGNED_SIZE;
3457   ResizePolicy::Type heightPolicyEnum = ResizePolicy::SIZE_RELATIVE_TO_PARENT;
3458
3459   actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, widthPolicyEnum);
3460   actor.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicyEnum);
3461
3462   DALI_TEST_EQUALS(static_cast<int>(actor.GetResizePolicy(Dimension::WIDTH)), static_cast<int>(widthPolicyEnum), TEST_LOCATION);
3463   DALI_TEST_EQUALS(static_cast<int>(actor.GetResizePolicy(Dimension::HEIGHT)), static_cast<int>(heightPolicyEnum), TEST_LOCATION);
3464
3465   END_TEST;
3466 }
3467
3468 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
3469 {
3470   TestApplication application;
3471
3472   Actor actor = Actor::New();
3473
3474   // Defaults
3475   DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION);
3476
3477   SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3478   actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy);
3479   DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy, TEST_LOCATION);
3480
3481   // Set
3482   const SizeScalePolicy::Type policy1 = SizeScalePolicy::FIT_WITH_ASPECT_RATIO;
3483   const SizeScalePolicy::Type policy2 = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3484
3485   actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy1);
3486   DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy1, TEST_LOCATION);
3487
3488   actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy2);
3489   DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy2, TEST_LOCATION);
3490
3491   END_TEST;
3492 }
3493
3494 int UtcDaliRelayoutProperties_SizeModeFactor(void)
3495 {
3496   TestApplication application;
3497
3498   Actor actor = Actor::New();
3499
3500   // Defaults
3501   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_MODE_FACTOR).Get<Vector3>(), Vector3(1.0f, 1.0f, 1.0f), TEST_LOCATION);
3502   DALI_TEST_EQUALS(actor.GetProperty<Vector3>(Actor::Property::SIZE_MODE_FACTOR), Vector3(1.0f, 1.0f, 1.0f), TEST_LOCATION);
3503
3504   Vector3 sizeMode(1.0f, 2.0f, 3.0f);
3505   actor.SetProperty(Actor::Property::SIZE_MODE_FACTOR, sizeMode);
3506   DALI_TEST_EQUALS(actor.GetProperty<Vector3>(Actor::Property::SIZE_MODE_FACTOR), sizeMode, TEST_LOCATION);
3507
3508   // Set
3509   Vector3 sizeMode1(2.0f, 3.0f, 4.0f);
3510
3511   actor.SetProperty(Actor::Property::SIZE_MODE_FACTOR, sizeMode1);
3512   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_MODE_FACTOR).Get<Vector3>(), sizeMode1, TEST_LOCATION);
3513
3514   END_TEST;
3515 }
3516
3517 int UtcDaliRelayoutProperties_DimensionDependency(void)
3518 {
3519   TestApplication application;
3520
3521   Actor actor = Actor::New();
3522
3523   // Defaults
3524   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), false, TEST_LOCATION);
3525   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_FOR_WIDTH).Get<bool>(), false, TEST_LOCATION);
3526
3527   // Set
3528   actor.SetProperty(Actor::Property::WIDTH_FOR_HEIGHT, true);
3529   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), true, TEST_LOCATION);
3530
3531   actor.SetProperty(Actor::Property::HEIGHT_FOR_WIDTH, true);
3532   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_FOR_WIDTH).Get<bool>(), true, TEST_LOCATION);
3533
3534   // Test setting another resize policy
3535   actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FIXED");
3536   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), false, TEST_LOCATION);
3537
3538   END_TEST;
3539 }
3540
3541 int UtcDaliRelayoutProperties_Padding(void)
3542 {
3543   TestApplication application;
3544
3545   Actor actor = Actor::New();
3546
3547   // Data
3548   Vector4 padding(1.0f, 2.0f, 3.0f, 4.0f);
3549
3550   // PADDING
3551   actor.SetProperty(Actor::Property::PADDING, padding);
3552   Vector4 paddingResult = actor.GetProperty(Actor::Property::PADDING).Get<Vector4>();
3553
3554   DALI_TEST_EQUALS(paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION);
3555
3556   END_TEST;
3557 }
3558
3559 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
3560 {
3561   TestApplication application;
3562
3563   Actor actor = Actor::New();
3564
3565   // Data
3566   Vector2 minSize(1.0f, 2.0f);
3567
3568   actor.SetProperty(Actor::Property::MINIMUM_SIZE, minSize);
3569   Vector2 resultMin = actor.GetProperty(Actor::Property::MINIMUM_SIZE).Get<Vector2>();
3570
3571   DALI_TEST_EQUALS(resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
3572
3573   Vector2 maxSize(3.0f, 4.0f);
3574
3575   actor.SetProperty(Actor::Property::MAXIMUM_SIZE, maxSize);
3576   Vector2 resultMax = actor.GetProperty(Actor::Property::MAXIMUM_SIZE).Get<Vector2>();
3577
3578   DALI_TEST_EQUALS(resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
3579
3580   END_TEST;
3581 }
3582
3583 int UtcDaliActorGetHeightForWidth(void)
3584 {
3585   TestApplication application;
3586
3587   Actor actor = Actor::New();
3588
3589   DALI_TEST_EQUALS(actor.GetHeightForWidth(1.0f), 1.0f, TEST_LOCATION);
3590
3591   END_TEST;
3592 }
3593
3594 int UtcDaliActorGetWidthForHeight(void)
3595 {
3596   TestApplication application;
3597
3598   Actor actor = Actor::New();
3599
3600   DALI_TEST_EQUALS(actor.GetWidthForHeight(1.0f), 1.0f, TEST_LOCATION);
3601
3602   END_TEST;
3603 }
3604
3605 int UtcDaliActorGetRelayoutSize(void)
3606 {
3607   TestApplication application;
3608
3609   Actor actor = Actor::New();
3610
3611   // Add actor to stage
3612   application.GetScene().Add(actor);
3613
3614   DALI_TEST_EQUALS(actor.GetRelayoutSize(Dimension::WIDTH), 0.0f, TEST_LOCATION);
3615
3616   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::WIDTH);
3617   actor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 0.0f));
3618
3619   // Flush the queue and render once
3620   application.SendNotification();
3621   application.Render();
3622
3623   DALI_TEST_EQUALS(actor.GetRelayoutSize(Dimension::WIDTH), 1.0f, TEST_LOCATION);
3624
3625   END_TEST;
3626 }
3627
3628 int UtcDaliActorSetPadding(void)
3629 {
3630   TestApplication application;
3631
3632   Actor actor = Actor::New();
3633
3634   Padding padding;
3635   padding = actor.GetProperty<Vector4>(Actor::Property::PADDING);
3636
3637   DALI_TEST_EQUALS(padding.left, 0.0f, TEST_LOCATION);
3638   DALI_TEST_EQUALS(padding.right, 0.0f, TEST_LOCATION);
3639   DALI_TEST_EQUALS(padding.bottom, 0.0f, TEST_LOCATION);
3640   DALI_TEST_EQUALS(padding.top, 0.0f, TEST_LOCATION);
3641
3642   Padding padding2(1.0f, 2.0f, 3.0f, 4.0f);
3643   actor.SetProperty(Actor::Property::PADDING, padding2);
3644
3645   padding = actor.GetProperty<Vector4>(Actor::Property::PADDING);
3646
3647   DALI_TEST_EQUALS(padding.left, padding2.left, TEST_LOCATION);
3648   DALI_TEST_EQUALS(padding.right, padding2.right, TEST_LOCATION);
3649   DALI_TEST_EQUALS(padding.bottom, padding2.bottom, TEST_LOCATION);
3650   DALI_TEST_EQUALS(padding.top, padding2.top, TEST_LOCATION);
3651
3652   END_TEST;
3653 }
3654
3655 int UtcDaliActorSetMinimumSize(void)
3656 {
3657   TestApplication application;
3658
3659   Actor actor = Actor::New();
3660
3661   Vector2 size = actor.GetProperty<Vector2>(Actor::Property::MINIMUM_SIZE);
3662
3663   DALI_TEST_EQUALS(size.width, 0.0f, TEST_LOCATION);
3664   DALI_TEST_EQUALS(size.height, 0.0f, TEST_LOCATION);
3665
3666   Vector2 size2(1.0f, 2.0f);
3667   actor.SetProperty(Actor::Property::MINIMUM_SIZE, size2);
3668
3669   size = actor.GetProperty<Vector2>(Actor::Property::MINIMUM_SIZE);
3670
3671   DALI_TEST_EQUALS(size.width, size2.width, TEST_LOCATION);
3672   DALI_TEST_EQUALS(size.height, size2.height, TEST_LOCATION);
3673
3674   END_TEST;
3675 }
3676
3677 int UtcDaliActorSetMaximumSize(void)
3678 {
3679   TestApplication application;
3680
3681   Actor actor = Actor::New();
3682
3683   Vector2 size = actor.GetProperty<Vector2>(Actor::Property::MAXIMUM_SIZE);
3684
3685   DALI_TEST_EQUALS(size.width, FLT_MAX, TEST_LOCATION);
3686   DALI_TEST_EQUALS(size.height, FLT_MAX, TEST_LOCATION);
3687
3688   Vector2 size2(1.0f, 2.0f);
3689   actor.SetProperty(Actor::Property::MAXIMUM_SIZE, size2);
3690
3691   size = actor.GetProperty<Vector2>(Actor::Property::MAXIMUM_SIZE);
3692
3693   DALI_TEST_EQUALS(size.width, size2.width, TEST_LOCATION);
3694   DALI_TEST_EQUALS(size.height, size2.height, TEST_LOCATION);
3695
3696   END_TEST;
3697 }
3698
3699 int UtcDaliActorOnRelayoutSignal(void)
3700 {
3701   tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
3702
3703   TestApplication application;
3704
3705   // Clean test data
3706   gOnRelayoutCallBackCalled = false;
3707   gActorNamesRelayout.clear();
3708
3709   Actor actor = Actor::New();
3710   actor.SetProperty(Actor::Property::NAME, "actor");
3711   actor.OnRelayoutSignal().Connect(OnRelayoutCallback);
3712
3713   // Sanity check
3714   DALI_TEST_CHECK(!gOnRelayoutCallBackCalled);
3715
3716   // Add actor to stage
3717   application.GetScene().Add(actor);
3718
3719   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
3720   actor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 2.0));
3721
3722   // Flush the queue and render once
3723   application.SendNotification();
3724   application.Render();
3725
3726   // OnRelayout emitted
3727   DALI_TEST_EQUALS(gOnRelayoutCallBackCalled, true, TEST_LOCATION);
3728   DALI_TEST_EQUALS("actor", gActorNamesRelayout[0], TEST_LOCATION);
3729
3730   END_TEST;
3731 }
3732
3733 int UtcDaliActorGetHierachyDepth(void)
3734 {
3735   TestApplication application;
3736   tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
3737
3738   /* Build tree of actors:
3739    *
3740    *                      Depth
3741    *
3742    *       A (parent)       1
3743    *      / \
3744    *     B   C              2`
3745    *    / \   \
3746    *   D   E   F            3
3747    *
3748    * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
3749    */
3750   Integration::Scene stage(application.GetScene());
3751
3752   Actor actorA = Actor::New();
3753   Actor actorB = Actor::New();
3754   Actor actorC = Actor::New();
3755   Actor actorD = Actor::New();
3756   Actor actorE = Actor::New();
3757   Actor actorF = Actor::New();
3758
3759   //Test that root actor has depth equal 0
3760   DALI_TEST_EQUALS(0, stage.GetRootLayer().GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3761
3762   //Test actors return depth -1 when not connected to the tree
3763   DALI_TEST_EQUALS(-1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3764   DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3765   DALI_TEST_EQUALS(-1, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3766   DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3767   DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3768   DALI_TEST_EQUALS(-1, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3769
3770   //Create the hierarchy
3771   stage.Add(actorA);
3772   actorA.Add(actorB);
3773   actorA.Add(actorC);
3774   actorB.Add(actorD);
3775   actorB.Add(actorE);
3776   actorC.Add(actorF);
3777
3778   //Test actors return correct depth
3779   DALI_TEST_EQUALS(1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3780   DALI_TEST_EQUALS(2, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3781   DALI_TEST_EQUALS(2, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3782   DALI_TEST_EQUALS(3, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3783   DALI_TEST_EQUALS(3, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3784   DALI_TEST_EQUALS(3, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3785
3786   //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
3787   actorA.Remove(actorB);
3788
3789   DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3790   DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3791   DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3792
3793   //Removing actorA from the stage. All actors should have depth equal -1
3794   stage.Remove(actorA);
3795
3796   DALI_TEST_EQUALS(-1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3797   DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3798   DALI_TEST_EQUALS(-1, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3799   DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3800   DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3801   DALI_TEST_EQUALS(-1, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3802
3803   END_TEST;
3804 }
3805
3806 int UtcDaliActorAnchorPointPropertyAsString(void)
3807 {
3808   TestApplication application;
3809
3810   Actor actor = Actor::New();
3811
3812   actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_LEFT");
3813   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_LEFT, TEST_LOCATION);
3814
3815   actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_CENTER");
3816   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_CENTER, TEST_LOCATION);
3817
3818   actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_RIGHT");
3819   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_RIGHT, TEST_LOCATION);
3820
3821   actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER_LEFT");
3822   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER_LEFT, TEST_LOCATION);
3823
3824   actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER");
3825   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER, TEST_LOCATION);
3826
3827   actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER_RIGHT");
3828   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER_RIGHT, TEST_LOCATION);
3829
3830   actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT");
3831   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION);
3832
3833   actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER");
3834   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION);
3835
3836   actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT");
3837   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
3838
3839   // Invalid should not change anything
3840   actor.SetProperty(Actor::Property::ANCHOR_POINT, "INVALID_ARG");
3841   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
3842
3843   END_TEST;
3844 }
3845
3846 int UtcDaliActorParentOriginPropertyAsString(void)
3847 {
3848   TestApplication application;
3849
3850   Actor actor = Actor::New();
3851
3852   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_LEFT");
3853   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_LEFT, TEST_LOCATION);
3854
3855   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_CENTER");
3856   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_CENTER, TEST_LOCATION);
3857
3858   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_RIGHT");
3859   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_RIGHT, TEST_LOCATION);
3860
3861   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER_LEFT");
3862   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER_LEFT, TEST_LOCATION);
3863
3864   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER");
3865   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER, TEST_LOCATION);
3866
3867   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT");
3868   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER_RIGHT, TEST_LOCATION);
3869
3870   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT");
3871   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION);
3872
3873   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER");
3874   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION);
3875
3876   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT");
3877   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
3878
3879   // Invalid should not change anything
3880   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "INVALID_ARG");
3881   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
3882
3883   END_TEST;
3884 }
3885
3886 int UtcDaliActorColorModePropertyAsString(void)
3887 {
3888   TestApplication application;
3889
3890   Actor actor = Actor::New();
3891
3892   actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_COLOR");
3893   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_COLOR, TEST_LOCATION);
3894
3895   actor.SetProperty(Actor::Property::COLOR_MODE, "USE_PARENT_COLOR");
3896   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_PARENT_COLOR, TEST_LOCATION);
3897
3898   actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR");
3899   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION);
3900
3901   actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA");
3902   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
3903
3904   // Invalid should not change anything
3905   actor.SetProperty(Actor::Property::COLOR_MODE, "INVALID_ARG");
3906   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
3907
3908   END_TEST;
3909 }
3910
3911 int UtcDaliActorDrawModePropertyAsString(void)
3912 {
3913   TestApplication application;
3914
3915   Actor actor = Actor::New();
3916
3917   actor.SetProperty(Actor::Property::DRAW_MODE, "NORMAL");
3918   DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::NORMAL, TEST_LOCATION);
3919
3920   actor.SetProperty(Actor::Property::DRAW_MODE, "OVERLAY_2D");
3921   DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
3922
3923   // Invalid should not change anything
3924   actor.SetProperty(Actor::Property::DRAW_MODE, "INVALID_ARG");
3925   DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
3926
3927   END_TEST;
3928 }
3929
3930 int UtcDaliActorColorModePropertyAsEnum(void)
3931 {
3932   TestApplication application;
3933
3934   Actor actor = Actor::New();
3935
3936   actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
3937   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_COLOR, TEST_LOCATION);
3938
3939   actor.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
3940   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_PARENT_COLOR, TEST_LOCATION);
3941
3942   actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR);
3943   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION);
3944
3945   actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
3946   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
3947
3948   END_TEST;
3949 }
3950
3951 int UtcDaliActorDrawModePropertyAsEnum(void)
3952 {
3953   TestApplication application;
3954
3955   Actor actor = Actor::New();
3956
3957   actor.SetProperty(Actor::Property::DRAW_MODE, DrawMode::NORMAL);
3958   DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::NORMAL, TEST_LOCATION);
3959
3960   actor.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3961   DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
3962
3963   END_TEST;
3964 }
3965
3966 int UtcDaliActorAddRendererP(void)
3967 {
3968   tet_infoline("Testing Actor::AddRenderer");
3969   TestApplication application;
3970
3971   Actor actor = Actor::New();
3972
3973   DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
3974
3975   Geometry geometry = CreateQuadGeometry();
3976   Shader   shader   = CreateShader();
3977   Renderer renderer = Renderer::New(geometry, shader);
3978
3979   actor.AddRenderer(renderer);
3980   DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
3981   DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
3982
3983   END_TEST;
3984 }
3985
3986 int UtcDaliActorAddRendererN01(void)
3987 {
3988   tet_infoline("Testing Actor::AddRenderer");
3989   TestApplication application;
3990
3991   Actor    actor = Actor::New();
3992   Renderer renderer;
3993
3994   // try illegal Add
3995   try
3996   {
3997     actor.AddRenderer(renderer);
3998     tet_printf("Assertion test failed - no Exception\n");
3999     tet_result(TET_FAIL);
4000   }
4001   catch(Dali::DaliException& e)
4002   {
4003     DALI_TEST_PRINT_ASSERT(e);
4004     DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
4005     DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4006   }
4007   catch(...)
4008   {
4009     tet_printf("Assertion test failed - wrong Exception\n");
4010     tet_result(TET_FAIL);
4011   }
4012
4013   END_TEST;
4014 }
4015
4016 int UtcDaliActorAddRendererN02(void)
4017 {
4018   tet_infoline("UtcDaliActorAddRendererN02");
4019
4020   Actor    actor;
4021   Renderer renderer;
4022
4023   {
4024     TestApplication application;
4025
4026     Geometry geometry = CreateQuadGeometry();
4027     Shader   shader   = CreateShader();
4028     renderer          = Renderer::New(geometry, shader);
4029
4030     actor = Actor::New();
4031   }
4032
4033   // try illegal AddRenderer
4034   try
4035   {
4036     actor.AddRenderer(renderer);
4037     tet_printf("Assertion test failed - no Exception\n");
4038     tet_result(TET_FAIL);
4039   }
4040   catch(Dali::DaliException& e)
4041   {
4042     DALI_TEST_PRINT_ASSERT(e);
4043     DALI_TEST_ASSERT(e, "EventThreadServices::IsCoreRunning()", TEST_LOCATION);
4044   }
4045   catch(...)
4046   {
4047     tet_printf("Assertion test failed - wrong Exception\n");
4048     tet_result(TET_FAIL);
4049   }
4050
4051   END_TEST;
4052 }
4053
4054 int UtcDaliActorAddRendererOnScene(void)
4055 {
4056   tet_infoline("Testing Actor::AddRenderer");
4057   TestApplication application;
4058
4059   Actor actor = Actor::New();
4060   application.GetScene().Add(actor);
4061
4062   application.SendNotification();
4063   application.Render(0);
4064
4065   Geometry geometry = CreateQuadGeometry();
4066   Shader   shader   = CreateShader();
4067   Renderer renderer = Renderer::New(geometry, shader);
4068
4069   application.SendNotification();
4070   application.Render(0);
4071
4072   try
4073   {
4074     actor.AddRenderer(renderer);
4075     tet_result(TET_PASS);
4076   }
4077   catch(...)
4078   {
4079     tet_result(TET_FAIL);
4080   }
4081
4082   END_TEST;
4083 }
4084
4085 int UtcDaliActorRemoveRendererP1(void)
4086 {
4087   tet_infoline("Testing Actor::RemoveRenderer");
4088   TestApplication application;
4089
4090   Actor actor = Actor::New();
4091
4092   DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4093
4094   {
4095     Geometry geometry = CreateQuadGeometry();
4096     Shader   shader   = CreateShader();
4097     Renderer renderer = Renderer::New(geometry, shader);
4098
4099     actor.AddRenderer(renderer);
4100     DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4101     DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4102
4103     application.SendNotification();
4104     application.Render();
4105   }
4106
4107   {
4108     Renderer renderer = actor.GetRendererAt(0);
4109     actor.RemoveRenderer(renderer);
4110     DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4111
4112     application.SendNotification();
4113     application.Render();
4114   }
4115
4116   // Call one final time to ensure that the renderer is actually removed after
4117   // the handle goes out of scope, and excercises the deletion code path in
4118   // scene graph and render.
4119   application.SendNotification();
4120   application.Render();
4121
4122   END_TEST;
4123 }
4124
4125 int UtcDaliActorRemoveRendererP2(void)
4126 {
4127   tet_infoline("Testing Actor::RemoveRenderer");
4128   TestApplication application;
4129
4130   Actor actor = Actor::New();
4131
4132   DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4133
4134   Geometry geometry = CreateQuadGeometry();
4135   Shader   shader   = CreateShader();
4136   Renderer renderer = Renderer::New(geometry, shader);
4137
4138   actor.AddRenderer(renderer);
4139   application.SendNotification();
4140   application.Render();
4141
4142   DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4143   DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4144
4145   actor.RemoveRenderer(0);
4146   application.SendNotification();
4147   application.Render();
4148
4149   DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4150
4151   // Shut down whilst holding onto the renderer handle.
4152   END_TEST;
4153 }
4154
4155 int UtcDaliActorRemoveRendererN(void)
4156 {
4157   tet_infoline("Testing Actor::RemoveRenderer");
4158   TestApplication application;
4159
4160   Actor actor = Actor::New();
4161
4162   DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4163
4164   Geometry geometry = CreateQuadGeometry();
4165   Shader   shader   = CreateShader();
4166   Renderer renderer = Renderer::New(geometry, shader);
4167
4168   actor.AddRenderer(renderer);
4169   DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4170   DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4171
4172   actor.RemoveRenderer(10);
4173   DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4174   DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4175
4176   END_TEST;
4177 }
4178
4179 // Clipping test helper functions:
4180 Actor CreateActorWithContent(uint32_t width, uint32_t height)
4181 {
4182   Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
4183   Actor   actor = CreateRenderableActor(image);
4184
4185   // Setup dimensions and position so actor is not skipped by culling.
4186   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
4187   actor.SetProperty(Actor::Property::SIZE, Vector2(width, height));
4188   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4189   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4190
4191   return actor;
4192 }
4193
4194 Actor CreateActorWithContent16x16()
4195 {
4196   return CreateActorWithContent(16, 16);
4197 }
4198
4199 void GenerateTrace(TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace)
4200 {
4201   enabledDisableTrace.Reset();
4202   stencilTrace.Reset();
4203   enabledDisableTrace.Enable(true);
4204   stencilTrace.Enable(true);
4205
4206   application.SendNotification();
4207   application.Render();
4208
4209   enabledDisableTrace.Enable(false);
4210   stencilTrace.Enable(false);
4211 }
4212
4213 void CheckColorMask(TestGlAbstraction& glAbstraction, bool maskValue)
4214 {
4215   const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
4216
4217   DALI_TEST_EQUALS<bool>(colorMaskParams.red, maskValue, TEST_LOCATION);
4218   DALI_TEST_EQUALS<bool>(colorMaskParams.green, maskValue, TEST_LOCATION);
4219   DALI_TEST_EQUALS<bool>(colorMaskParams.blue, maskValue, TEST_LOCATION);
4220
4221   // @todo only test alpha if the framebuffer has an alpha channel
4222   //DALI_TEST_EQUALS<bool>(colorMaskParams.alpha, maskValue, TEST_LOCATION);
4223 }
4224
4225 int UtcDaliActorPropertyClippingP(void)
4226 {
4227   // This test checks the clippingMode property.
4228   tet_infoline("Testing Actor::Property::ClippingMode: P");
4229   TestApplication application;
4230
4231   Actor actor = Actor::New();
4232
4233   // Check default clippingEnabled value.
4234   Property::Value getValue(actor.GetProperty(Actor::Property::CLIPPING_MODE));
4235
4236   int  value          = 0;
4237   bool getValueResult = getValue.Get(value);
4238   DALI_TEST_CHECK(getValueResult);
4239
4240   if(getValueResult)
4241   {
4242     DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4243   }
4244
4245   // Check setting the property to the stencil mode.
4246   actor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4247
4248   // Check the new value was set.
4249   getValue       = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4250   getValueResult = getValue.Get(value);
4251   DALI_TEST_CHECK(getValueResult);
4252
4253   if(getValueResult)
4254   {
4255     DALI_TEST_EQUALS<int>(value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION);
4256   }
4257
4258   // Check setting the property to the scissor mode.
4259   actor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4260
4261   // Check the new value was set.
4262   getValue       = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4263   getValueResult = getValue.Get(value);
4264   DALI_TEST_CHECK(getValueResult);
4265
4266   if(getValueResult)
4267   {
4268     DALI_TEST_EQUALS<int>(value, ClippingMode::CLIP_TO_BOUNDING_BOX, TEST_LOCATION);
4269   }
4270   END_TEST;
4271 }
4272
4273 int UtcDaliActorPropertyClippingN(void)
4274 {
4275   // Negative test case for Clipping.
4276   tet_infoline("Testing Actor::Property::ClippingMode: N");
4277   TestApplication application;
4278
4279   Actor actor = Actor::New();
4280
4281   // Check default clippingEnabled value.
4282   Property::Value getValue(actor.GetProperty(Actor::Property::CLIPPING_MODE));
4283
4284   int  value          = 0;
4285   bool getValueResult = getValue.Get(value);
4286   DALI_TEST_CHECK(getValueResult);
4287
4288   if(getValueResult)
4289   {
4290     DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4291   }
4292
4293   // Check setting an invalid property value won't change the current property value.
4294   actor.SetProperty(Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY");
4295
4296   getValue       = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4297   getValueResult = getValue.Get(value);
4298   DALI_TEST_CHECK(getValueResult);
4299
4300   if(getValueResult)
4301   {
4302     DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4303   }
4304
4305   END_TEST;
4306 }
4307
4308 int UtcDaliActorPropertyClippingActor(void)
4309 {
4310   // This test checks that an actor is correctly setup for clipping.
4311   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor");
4312   TestApplication application;
4313
4314   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4315   TraceCallStack&    stencilTrace        = glAbstraction.GetStencilFunctionTrace();
4316   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4317   size_t             startIndex          = 0u;
4318
4319   // Create a clipping actor.
4320   Actor actorDepth1Clip = CreateActorWithContent16x16();
4321   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4322   application.GetScene().Add(actorDepth1Clip);
4323
4324   // Gather the call trace.
4325   GenerateTrace(application, enabledDisableTrace, stencilTrace);
4326
4327   // Check we are writing to the color buffer.
4328   CheckColorMask(glAbstraction, true);
4329
4330   // Check the stencil buffer was enabled.
4331   std::ostringstream oss;
4332   oss << std::hex << GL_STENCIL_TEST;
4333   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
4334
4335   // Check the stencil buffer was cleared.
4336   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4337
4338   // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4339   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4340   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));
4341   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4342
4343   END_TEST;
4344 }
4345
4346 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
4347 {
4348   // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
4349   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor enable and then disable");
4350   TestApplication application;
4351
4352   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4353   TraceCallStack&    stencilTrace        = glAbstraction.GetStencilFunctionTrace();
4354   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4355   size_t             startIndex          = 0u;
4356
4357   // Create a clipping actor.
4358   Actor actorDepth1Clip = CreateActorWithContent16x16();
4359   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4360   application.GetScene().Add(actorDepth1Clip);
4361
4362   // Gather the call trace.
4363   GenerateTrace(application, enabledDisableTrace, stencilTrace);
4364
4365   // Check we are writing to the color buffer.
4366   CheckColorMask(glAbstraction, true);
4367
4368   // Check the stencil buffer was enabled.
4369   std::ostringstream oss;
4370   oss << std::hex << GL_STENCIL_TEST;
4371   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
4372
4373   // Check the stencil buffer was cleared.
4374   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4375
4376   // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4377   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4378   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));
4379   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4380
4381   // Now disable the clipping
4382   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED);
4383
4384   // Gather the call trace.
4385   GenerateTrace(application, enabledDisableTrace, stencilTrace);
4386
4387   // Check the stencil buffer was disabled.
4388   std::ostringstream stencil;
4389   stencil << std::hex << GL_STENCIL_TEST;
4390   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Disable", stencil.str()));
4391
4392   // Ensure all values in stencil-mask are set to 1.
4393   startIndex = 0u;
4394   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "255", startIndex));
4395
4396   END_TEST;
4397 }
4398
4399 int UtcDaliActorPropertyClippingNestedChildren(void)
4400 {
4401   // This test checks that a hierarchy of actors are clipped correctly by
4402   // writing to and reading from the correct bit-planes of the stencil buffer.
4403   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN nested children");
4404   TestApplication    application;
4405   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4406   TraceCallStack&    stencilTrace        = glAbstraction.GetStencilFunctionTrace();
4407   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4408
4409   // Create a clipping actor.
4410   Actor actorDepth1Clip = CreateActorWithContent16x16();
4411   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4412   application.GetScene().Add(actorDepth1Clip);
4413
4414   // Create a child actor.
4415   Actor childDepth2 = CreateActorWithContent16x16();
4416   actorDepth1Clip.Add(childDepth2);
4417
4418   // Create another clipping actor.
4419   Actor childDepth2Clip = CreateActorWithContent16x16();
4420   childDepth2Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4421   childDepth2.Add(childDepth2Clip);
4422
4423   // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
4424   // This tests the sort algorithm.
4425   Actor childDepth3 = CreateActorWithContent16x16();
4426   childDepth2Clip.Add(childDepth3);
4427   Actor childDepth4 = CreateActorWithContent16x16();
4428   childDepth3.Add(childDepth4);
4429
4430   // Gather the call trace.
4431   GenerateTrace(application, enabledDisableTrace, stencilTrace);
4432
4433   // Check we are writing to the color buffer.
4434   CheckColorMask(glAbstraction, true);
4435
4436   // Check the stencil buffer was enabled.
4437   std::ostringstream oss;
4438   oss << std::hex << GL_STENCIL_TEST;
4439   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
4440
4441   // Perform the test twice, once for 2D layer, and once for 3D.
4442   for(unsigned int i = 0u; i < 2u; ++i)
4443   {
4444     size_t startIndex = 0u;
4445
4446     // Check the stencil buffer was cleared.
4447     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4448
4449     // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4450     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex));      // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4451     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));              // Write to the first bit-plane
4452     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4453
4454     // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
4455     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 1", startIndex));      // 514 is GL_EQUAL
4456     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7680, 7680", startIndex)); // GL_KEEP, GL_KEEP, GL_KEEP
4457
4458     // Check we are set up to write to the second bitplane of the stencil buffer (only).
4459     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 3, 1", startIndex));      // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4460     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "3", startIndex));              // Write to second (and previous) bit-planes
4461     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4462
4463     // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4464     // (Both must be set to pass the check).
4465     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 3, 3", startIndex));      // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4466     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7680, 7680", startIndex)); // GL_KEEP, GL_KEEP, GL_KEEP
4467
4468     // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4469     if(i == 0u)
4470     {
4471       application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D);
4472       GenerateTrace(application, enabledDisableTrace, stencilTrace);
4473     }
4474   }
4475
4476   END_TEST;
4477 }
4478
4479 int UtcDaliActorPropertyClippingActorDrawOrder(void)
4480 {
4481   // This test checks that a hierarchy of actors are drawn in the correct order when clipping is enabled.
4482   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN draw order");
4483   TestApplication    application;
4484   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4485   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4486
4487   /* We create a small tree of actors as follows:
4488
4489                            A
4490                           / \
4491      Clipping enabled -> B   D
4492                          |   |
4493                          C   E
4494
4495      The correct draw order is "ABCDE" (the same as if clipping was not enabled).
4496   */
4497   Actor actors[5];
4498   for(int i = 0; i < 5; ++i)
4499   {
4500     Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
4501     Actor   actor = CreateRenderableActor(image);
4502
4503     // Setup dimensions and position so actor is not skipped by culling.
4504     actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
4505     actor.SetProperty(Actor::Property::SIZE, Vector2(16.0f, 16.0f));
4506
4507     if(i == 0)
4508     {
4509       actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4510     }
4511     else
4512     {
4513       float b = i > 2 ? 1.0f : -1.0f;
4514       actor.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0.5 + (0.2f * b), 0.8f, 0.8f));
4515     }
4516
4517     actors[i] = actor;
4518   }
4519
4520   // Enable clipping on the actor at the top of the left branch.
4521   actors[1].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4522
4523   // Build the scene graph.
4524   application.GetScene().Add(actors[0]);
4525
4526   // Left branch:
4527   actors[0].Add(actors[1]);
4528   actors[1].Add(actors[2]);
4529
4530   // Right branch:
4531   actors[0].Add(actors[3]);
4532   actors[3].Add(actors[4]);
4533
4534   // Gather the call trace.
4535   enabledDisableTrace.Reset();
4536   enabledDisableTrace.Enable(true);
4537   application.SendNotification();
4538   application.Render();
4539   enabledDisableTrace.Enable(false);
4540
4541   /* Check stencil is enabled and disabled again (as right-hand branch of tree is drawn).
4542
4543      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
4544            Incorrect enable call trace:  StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960
4545   */
4546   size_t             startIndex = 0u;
4547   std::ostringstream blend;
4548   blend << std::hex << GL_BLEND;
4549   std::ostringstream stencil;
4550   stencil << std::hex << GL_STENCIL_TEST;
4551
4552   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", blend.str(), startIndex));
4553   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", stencil.str(), startIndex));
4554   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", stencil.str(), startIndex));
4555
4556   // Swap the clipping actor from top of left branch to top of right branch.
4557   actors[1].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED);
4558   actors[3].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4559
4560   // Gather the call trace.
4561   enabledDisableTrace.Reset();
4562   enabledDisableTrace.Enable(true);
4563   application.SendNotification();
4564   application.Render();
4565   enabledDisableTrace.Enable(false);
4566
4567   // Check stencil is enabled but NOT disabled again (as right-hand branch of tree is drawn).
4568   // This proves the draw order has remained the same.
4569   startIndex = 0u;
4570   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", stencil.str(), startIndex));
4571   DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", stencil.str(), startIndex));
4572
4573   END_TEST;
4574 }
4575
4576 int UtcDaliActorPropertyScissorClippingActor01(void)
4577 {
4578   // This test checks that an actor is correctly setup for clipping.
4579   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor");
4580   TestApplication application;
4581
4582   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4583   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
4584   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4585
4586   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4587   const Vector2 imageSize(16.0f, 16.0f);
4588
4589   // Create a clipping actor.
4590   Actor clippingActorA = CreateActorWithContent16x16();
4591   // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4592   // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4593   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
4594   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
4595   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4596   application.GetScene().Add(clippingActorA);
4597
4598   // Gather the call trace.
4599   GenerateTrace(application, enabledDisableTrace, scissorTrace);
4600
4601   // Check we are writing to the color buffer.
4602   CheckColorMask(glAbstraction, true);
4603
4604   // Check scissor test was enabled.
4605
4606   std::ostringstream scissor;
4607   scissor << std::hex << GL_SCISSOR_TEST;
4608   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
4609
4610   // Check the scissor was set, and the coordinates are correct.
4611   std::stringstream compareParametersString;
4612   compareParametersString << "0, 0, " << imageSize.x << ", " << imageSize.y;
4613   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
4614
4615   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
4616   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_RIGHT);
4617
4618   // Gather the call trace.
4619   GenerateTrace(application, enabledDisableTrace, scissorTrace);
4620
4621   // Check the scissor was set, and the coordinates are correct.
4622   compareParametersString.str(std::string());
4623   compareParametersString.clear();
4624   compareParametersString << (stageSize.x - imageSize.x) << ", " << (stageSize.y - imageSize.y) << ", " << imageSize.x << ", " << imageSize.y;
4625   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 464, 784, 16, 16
4626
4627   END_TEST;
4628 }
4629
4630 int UtcDaliActorPropertyScissorClippingActor02(void)
4631 {
4632   // This test checks that an actor is correctly setup for clipping.
4633   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor with a transparent renderer");
4634   TestApplication application;
4635
4636   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4637   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
4638   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4639
4640   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4641   const Vector2 actorSize(16.0f, 16.0f);
4642
4643   // Create a clipping actor.
4644   Actor clippingActorA                  = CreateRenderableActor();
4645   clippingActorA[Actor::Property::SIZE] = actorSize;
4646
4647   Renderer renderer = clippingActorA.GetRendererAt(0);
4648   DALI_TEST_CHECK(renderer);
4649
4650   // Make Renderer opacity 0.
4651   renderer[DevelRenderer::Property::OPACITY] = 0.0f;
4652
4653   // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4654   // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4655   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
4656   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
4657   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4658   application.GetScene().Add(clippingActorA);
4659
4660   // Gather the call trace.
4661   GenerateTrace(application, enabledDisableTrace, scissorTrace);
4662
4663   // Check we are writing to the color buffer.
4664   CheckColorMask(glAbstraction, true);
4665
4666   // Check scissor test was enabled.
4667
4668   std::ostringstream scissor;
4669   scissor << std::hex << GL_SCISSOR_TEST;
4670   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
4671
4672   // Check the scissor was set, and the coordinates are correct.
4673   std::stringstream compareParametersString;
4674   compareParametersString << "0, 0, " << actorSize.x << ", " << actorSize.y;
4675   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
4676
4677   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
4678   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_RIGHT);
4679
4680   // Gather the call trace.
4681   GenerateTrace(application, enabledDisableTrace, scissorTrace);
4682
4683   // Check the scissor was set, and the coordinates are correct.
4684   compareParametersString.str(std::string());
4685   compareParametersString.clear();
4686   compareParametersString << (stageSize.x - actorSize.x) << ", " << (stageSize.y - actorSize.y) << ", " << actorSize.x << ", " << actorSize.y;
4687   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 464, 784, 16, 16
4688
4689   END_TEST;
4690 }
4691
4692 int UtcDaliActorPropertyScissorClippingActorSiblings(void)
4693 {
4694   // This test checks that an actor is correctly setup for clipping.
4695   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actors which are siblings");
4696   TestApplication application;
4697
4698   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4699   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
4700   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4701
4702   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4703   const Vector2 sizeA{stageSize.width, stageSize.height * 0.25f};
4704   const Vector2 sizeB{stageSize.width, stageSize.height * 0.05f};
4705
4706   // Create a clipping actors.
4707   Actor clippingActorA = CreateActorWithContent(sizeA.width, sizeA.height);
4708   Actor clippingActorB = CreateActorWithContent(sizeB.width, sizeB.height);
4709
4710   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4711   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4712   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4713
4714   clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4715   clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4716   clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4717
4718   clippingActorA.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -200.0f, 0.0f));
4719   clippingActorB.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
4720
4721   application.GetScene().Add(clippingActorA);
4722   application.GetScene().Add(clippingActorB);
4723
4724   // Gather the call trace.
4725   GenerateTrace(application, enabledDisableTrace, scissorTrace);
4726
4727   // Check we are writing to the color buffer.
4728   CheckColorMask(glAbstraction, true);
4729
4730   // Check scissor test was enabled.
4731   std::ostringstream scissor;
4732   scissor << std::hex << GL_SCISSOR_TEST;
4733   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
4734
4735   // Check the scissor was set, and the coordinates are correct.
4736   std::stringstream compareParametersString;
4737
4738   std::string clipA("0, 500, 480, 200");
4739   std::string clipB("0, 380, 480, 40");
4740
4741   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipA));
4742   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipB));
4743
4744   END_TEST;
4745 }
4746
4747 int UtcDaliActorPropertyScissorClippingActorNested01(void)
4748 {
4749   // This test checks that an actor is correctly setup for clipping.
4750   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested");
4751   TestApplication application;
4752
4753   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4754   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
4755   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4756
4757   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4758   const Vector2 imageSize(16.0f, 16.0f);
4759
4760   /* Create a nest of 2 scissors to test nesting (intersecting clips).
4761
4762      A is drawn first - with scissor clipping on
4763      B is drawn second - also with scissor clipping on
4764      C is the generated clipping region, the intersection ( A ∩ B )
4765
4766            ┏━━━━━━━┓                   ┌───────┐
4767            ┃     B ┃                   │     B │
4768        ┌───╂┄┄┄┐   ┃               ┌┄┄┄╆━━━┓   │
4769        │   ┃   ┊   ┃     ━━━━━>    ┊   ┃ C ┃   │
4770        │   ┗━━━┿━━━┛               ┊   ┗━━━╃───┘
4771        │ A     │                   ┊ A     ┊
4772        └───────┘                   └┄┄┄┄┄┄┄┘
4773
4774      We then reposition B around each corner of A to test the 4 overlap combinations (thus testing intersecting works correctly).
4775   */
4776
4777   // Create a clipping actor.
4778   Actor clippingActorA = CreateActorWithContent16x16();
4779   // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4780   // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4781   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4782   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4783   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4784   application.GetScene().Add(clippingActorA);
4785
4786   // Create a child clipping actor.
4787   Actor clippingActorB = CreateActorWithContent16x16();
4788   clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4789   clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4790   clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4791   clippingActorA.Add(clippingActorB);
4792
4793   // positionModifiers is an array of positions to position B around.
4794   // expect is an array of expected scissor clip coordinate results.
4795   const Vector2 positionModifiers[4] = {Vector2(1.0f, 1.0f), Vector2(-1.0f, 1.0f), Vector2(-1.0f, -1.0f), Vector2(1.0f, -1.0f)};
4796   const Vector4 expect[4]            = {Vector4(240, 392, 8, 8), Vector4(232, 392, 8, 8), Vector4(232, 400, 8, 8), Vector4(240, 400, 8, 8)};
4797
4798   // Loop through each overlap combination.
4799   for(unsigned int test = 0u; test < 4u; ++test)
4800   {
4801     // Position the child clipping actor so it intersects with the 1st clipping actor. This changes each loop.
4802     const Vector2 position = (imageSize / 2.0f) * positionModifiers[test];
4803     clippingActorB.SetProperty(Actor::Property::POSITION, Vector2(position.x, position.y));
4804
4805     // Gather the call trace.
4806     GenerateTrace(application, enabledDisableTrace, scissorTrace);
4807
4808     // Check we are writing to the color buffer.
4809     CheckColorMask(glAbstraction, true);
4810
4811     // Check scissor test was enabled.
4812     std::ostringstream scissor;
4813     scissor << std::hex << GL_SCISSOR_TEST;
4814     DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
4815
4816     // Check the scissor was set, and the coordinates are correct.
4817     const Vector4&    expectResults(expect[test]);
4818     std::stringstream compareParametersString;
4819     compareParametersString << expectResults.x << ", " << expectResults.y << ", " << expectResults.z << ", " << expectResults.w;
4820     DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with the expected result
4821   }
4822
4823   END_TEST;
4824 }
4825
4826 int UtcDaliActorPropertyScissorClippingActorNested02(void)
4827 {
4828   // This test checks that an actor is correctly setup for clipping.
4829   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested");
4830   TestApplication application;
4831
4832   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4833   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
4834   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4835
4836   /* Create a nest of 2 scissors and siblings of the parent.
4837
4838             stage
4839               |
4840         ┌─────┐─────┐
4841         A     C     D
4842         |           |
4843         B           E
4844   */
4845
4846   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4847   const Vector2 sizeA{stageSize.width, stageSize.height * 0.25f};
4848   const Vector2 sizeB{stageSize.width, stageSize.height * 0.05f};
4849   const Vector2 sizeC{stageSize.width, stageSize.height * 0.25f};
4850   const Vector2 sizeD{stageSize.width, stageSize.height * 0.25f};
4851   const Vector2 sizeE{stageSize.width, stageSize.height * 0.05f};
4852
4853   // Create a clipping actors.
4854   Actor clippingActorA = CreateActorWithContent(sizeA.width, sizeA.height);
4855   Actor clippingActorB = CreateActorWithContent(sizeB.width, sizeB.height);
4856   Actor clippingActorC = CreateActorWithContent(sizeC.width, sizeC.height);
4857   Actor clippingActorD = CreateActorWithContent(sizeD.width, sizeD.height);
4858   Actor clippingActorE = CreateActorWithContent(sizeE.width, sizeE.height);
4859
4860   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4861   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4862   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4863
4864   clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4865   clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4866   clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4867
4868   clippingActorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4869   clippingActorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4870   clippingActorC.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4871
4872   clippingActorD.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4873   clippingActorD.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4874   clippingActorD.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4875
4876   clippingActorE.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4877   clippingActorE.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4878
4879   clippingActorA.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -200.0f, 0.0f));
4880   clippingActorB.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
4881   clippingActorC.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 100.0f, 0.0f));
4882   clippingActorD.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
4883   clippingActorE.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
4884
4885   application.GetScene().Add(clippingActorA);
4886   clippingActorA.Add(clippingActorB);
4887   application.GetScene().Add(clippingActorC);
4888   application.GetScene().Add(clippingActorD);
4889   clippingActorD.Add(clippingActorE);
4890
4891   // Gather the call trace.
4892   GenerateTrace(application, enabledDisableTrace, scissorTrace);
4893
4894   // Check we are writing to the color buffer.
4895   CheckColorMask(glAbstraction, true);
4896
4897   // Check scissor test was enabled.
4898   std::ostringstream scissor;
4899   scissor << std::hex << GL_SCISSOR_TEST;
4900   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
4901
4902   // Check the scissor was set, and the coordinates are correct.
4903   std::string clipA("0, 500, 480, 200");
4904   std::string clipB("0, 580, 480, 40");
4905   std::string clipC("0, 200, 480, 200");
4906   std::string clipD("0, 300, 480, 200");
4907
4908   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipA));
4909   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipB));
4910   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipC));
4911   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipD));
4912   DALI_TEST_EQUALS(scissorTrace.CountMethod("Scissor"), 4, TEST_LOCATION); // Scissor rect should not be changed in clippingActorE case. So count should be 4.
4913
4914   END_TEST;
4915 }
4916
4917 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
4918 {
4919   // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
4920   tet_infoline("Testing Actor::Property::CLIPPING_MODE actor with renderer override");
4921   TestApplication application;
4922
4923   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4924   TraceCallStack&    stencilTrace        = glAbstraction.GetStencilFunctionTrace();
4925   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4926
4927   // Create a clipping actor.
4928   Actor actorDepth1Clip = CreateActorWithContent16x16();
4929   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4930   application.GetScene().Add(actorDepth1Clip);
4931
4932   // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
4933   actorDepth1Clip.GetRendererAt(0).SetProperty(Renderer::Property::RENDER_MODE, RenderMode::COLOR);
4934
4935   // Gather the call trace.
4936   GenerateTrace(application, enabledDisableTrace, stencilTrace);
4937
4938   // Check we are writing to the color buffer.
4939   CheckColorMask(glAbstraction, true);
4940
4941   // Check the stencil buffer was not enabled.
4942   std::ostringstream stencil;
4943   stencil << std::hex << GL_STENCIL_TEST;
4944   DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", stencil.str()));
4945
4946   // Check stencil functions are not called.
4947   DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilFunc"));
4948   DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilOp"));
4949
4950   // Check that scissor clipping is overriden by the renderer properties.
4951   TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4952
4953   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4954
4955   // Gather the call trace.
4956   GenerateTrace(application, enabledDisableTrace, scissorTrace);
4957
4958   // Check the stencil buffer was not enabled.
4959   std::ostringstream scissor;
4960   scissor << std::hex << GL_SCISSOR_TEST;
4961   DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
4962
4963   DALI_TEST_CHECK(!scissorTrace.FindMethod("StencilFunc"));
4964
4965   END_TEST;
4966 }
4967
4968 int UtcDaliActorPropertyClippingActorCulled(void)
4969 {
4970   // This test checks that child actors are clipped by an culled parent actor.
4971   tet_infoline("Testing child actors are clipped by an culled parent actor");
4972   TestApplication application;
4973
4974   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4975   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
4976   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4977
4978   const Vector2 actorSize(160.0f, 160.0f);
4979
4980   // Create a clipping actor.
4981   Actor clippingActorA                  = CreateRenderableActor();
4982   clippingActorA[Actor::Property::SIZE] = actorSize;
4983
4984   // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4985   // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4986   clippingActorA[Actor::Property::PARENT_ORIGIN] = ParentOrigin::BOTTOM_LEFT;
4987   clippingActorA[Actor::Property::ANCHOR_POINT]  = AnchorPoint::BOTTOM_LEFT;
4988   clippingActorA[Actor::Property::CLIPPING_MODE] = ClippingMode::CLIP_TO_BOUNDING_BOX;
4989   application.GetScene().Add(clippingActorA);
4990
4991   // Create a child actor
4992   Actor childActor                              = CreateRenderableActor();
4993   childActor[Actor::Property::PARENT_ORIGIN]    = ParentOrigin::BOTTOM_LEFT;
4994   childActor[Actor::Property::ANCHOR_POINT]     = AnchorPoint::BOTTOM_LEFT;
4995   childActor[Actor::Property::SIZE]             = Vector2(50.0f, 50.0f);
4996   childActor[Actor::Property::INHERIT_POSITION] = false;
4997
4998   // Gather the call trace.
4999   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5000
5001   // Check scissor test was enabled.
5002   std::ostringstream scissor;
5003   scissor << std::hex << GL_SCISSOR_TEST;
5004   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5005
5006   // Check the scissor was set, and the coordinates are correct.
5007   std::stringstream compareParametersString;
5008   compareParametersString << "0, 0, " << actorSize.x << ", " << actorSize.y;
5009   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
5010
5011   // Move the clipping actor out of screen
5012   clippingActorA[Actor::Property::POSITION] = Vector2(2000.0f, 2000.0f);
5013
5014   // Gather the call trace.
5015   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5016
5017   // Check the scissor was set, and the coordinates are correct.
5018   compareParametersString.str(std::string());
5019   compareParametersString.clear();
5020   compareParametersString << 2000 << ", " << 0 << ", " << 0 << ", " << 0;
5021   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Clipping area should be empty.
5022
5023   END_TEST;
5024 }
5025
5026 int UtcDaliGetPropertyN(void)
5027 {
5028   tet_infoline("Testing Actor::GetProperty returns a non valid value if property index is out of range");
5029   TestApplication application;
5030
5031   Actor actor = Actor::New();
5032
5033   unsigned int propertyCount = actor.GetPropertyCount();
5034   DALI_TEST_EQUALS(actor.GetProperty(Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION);
5035   END_TEST;
5036 }
5037
5038 int UtcDaliActorRaiseLower(void)
5039 {
5040   tet_infoline("UtcDaliActor Raise and Lower test\n");
5041
5042   TestApplication application;
5043
5044   Debug::Filter::SetGlobalLogLevel(Debug::Verbose);
5045
5046   Integration::Scene stage(application.GetScene());
5047
5048   Actor actorA = Actor::New();
5049   Actor actorB = Actor::New();
5050   Actor actorC = Actor::New();
5051
5052   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5053   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5054
5055   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5056   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5057
5058   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5059   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5060
5061   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5062   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5063
5064   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5065   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5066
5067   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5068   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5069
5070   stage.Add(actorA);
5071   stage.Add(actorB);
5072   stage.Add(actorC);
5073
5074   ResetTouchCallbacks();
5075
5076   application.SendNotification();
5077   application.Render();
5078
5079   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5080   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5081   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5082
5083   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5084   // Only top actor will get touched.
5085   actorA.TouchedSignal().Connect(TestTouchCallback);
5086   actorB.TouchedSignal().Connect(TestTouchCallback2);
5087   actorC.TouchedSignal().Connect(TestTouchCallback3);
5088
5089   // Connect ChildOrderChangedSignal
5090   bool                     orderChangedSignal(false);
5091   Actor                    orderChangedActor;
5092   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5093   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5094
5095   Dali::Integration::Point point;
5096   point.SetDeviceId(1);
5097   point.SetState(PointState::DOWN);
5098   point.SetScreenPosition(Vector2(10.f, 10.f));
5099   Dali::Integration::TouchEvent touchEvent;
5100   touchEvent.AddPoint(point);
5101
5102   application.ProcessEvent(touchEvent);
5103
5104   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5105   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5106   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5107
5108   ResetTouchCallbacks();
5109
5110   tet_printf("Testing Raising of Actor\n");
5111
5112   int preActorOrder(0);
5113   int postActorOrder(0);
5114
5115   Property::Value value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5116   value.Get(preActorOrder);
5117
5118   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5119   actorB.Raise();
5120   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5121   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5122
5123   // Ensure sort order is calculated before next touch event
5124   application.SendNotification();
5125
5126   value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5127   value.Get(postActorOrder);
5128
5129   tet_printf("Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder);
5130
5131   application.ProcessEvent(touchEvent);
5132
5133   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5134   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5135   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5136
5137   ResetTouchCallbacks();
5138
5139   tet_printf("Testing Lowering of Actor\n");
5140
5141   value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5142   value.Get(preActorOrder);
5143
5144   orderChangedSignal = false;
5145
5146   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5147   actorB.Lower();
5148   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5149   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5150
5151   application.SendNotification(); // ensure sort order calculated before next touch event
5152
5153   value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5154   value.Get(postActorOrder);
5155
5156   tet_printf("Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder);
5157
5158   application.ProcessEvent(touchEvent);
5159
5160   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5161   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5162   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5163
5164   ResetTouchCallbacks();
5165
5166   Debug::Filter::SetGlobalLogLevel(Debug::NoLogging);
5167
5168   END_TEST;
5169 }
5170
5171 int UtcDaliActorRaiseToTopLowerToBottom(void)
5172 {
5173   tet_infoline("UtcDaliActorRaiseToTop and LowerToBottom test \n");
5174
5175   TestApplication application;
5176
5177   Integration::Scene stage(application.GetScene());
5178
5179   Actor actorA = Actor::New();
5180   Actor actorB = Actor::New();
5181   Actor actorC = Actor::New();
5182
5183   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5184   // enables checking of which actor the uniform is assigned too
5185   Shader shaderA = CreateShader();
5186   shaderA.RegisterProperty("uRendererColor", 1.f);
5187
5188   Shader shaderB = CreateShader();
5189   shaderB.RegisterProperty("uRendererColor", 2.f);
5190
5191   Shader shaderC = CreateShader();
5192   shaderC.RegisterProperty("uRendererColor", 3.f);
5193
5194   Geometry geometry = CreateQuadGeometry();
5195
5196   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5197   Renderer rendererA = Renderer::New(geometry, shaderA);
5198   actorA.AddRenderer(rendererA);
5199
5200   Renderer rendererB = Renderer::New(geometry, shaderB);
5201   actorB.AddRenderer(rendererB);
5202
5203   Renderer rendererC = Renderer::New(geometry, shaderC);
5204   actorC.AddRenderer(rendererC);
5205
5206   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5207   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5208
5209   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5210   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5211
5212   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5213   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5214
5215   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5216   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5217
5218   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5219   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5220
5221   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5222   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5223
5224   stage.Add(actorA);
5225   stage.Add(actorB);
5226   stage.Add(actorC);
5227
5228   ResetTouchCallbacks();
5229
5230   // Connect ChildOrderChangedSignal
5231   bool                     orderChangedSignal(false);
5232   Actor                    orderChangedActor;
5233   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5234   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5235
5236   // Set up gl abstraction trace so can query the set uniform order
5237   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5238   glAbstraction.EnableSetUniformCallTrace(true);
5239   glAbstraction.ResetSetUniformCallStack();
5240
5241   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5242
5243   application.SendNotification();
5244   application.Render();
5245
5246   tet_printf("Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str());
5247
5248   // Test order of uniforms in stack
5249   int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5250   int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5251   int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5252
5253   bool CBA = (indexC > indexB) && (indexB > indexA);
5254
5255   DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
5256
5257   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5258   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5259   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5260
5261   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5262   // Only top actor will get touched.
5263   actorA.TouchedSignal().Connect(TestTouchCallback);
5264   actorB.TouchedSignal().Connect(TestTouchCallback2);
5265   actorC.TouchedSignal().Connect(TestTouchCallback3);
5266
5267   Dali::Integration::Point point;
5268   point.SetDeviceId(1);
5269   point.SetState(PointState::DOWN);
5270   point.SetScreenPosition(Vector2(10.f, 10.f));
5271   Dali::Integration::TouchEvent touchEvent;
5272   touchEvent.AddPoint(point);
5273
5274   application.ProcessEvent(touchEvent);
5275
5276   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5277   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5278   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5279
5280   ResetTouchCallbacks();
5281
5282   tet_printf("RaiseToTop ActorA\n");
5283
5284   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5285   actorA.RaiseToTop();
5286   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5287   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5288
5289   application.SendNotification(); // ensure sorting order is calculated before next touch event
5290
5291   application.ProcessEvent(touchEvent);
5292
5293   glSetUniformStack.Reset();
5294
5295   application.SendNotification();
5296   application.Render();
5297
5298   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5299
5300   // Test order of uniforms in stack
5301   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5302   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5303   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5304
5305   tet_infoline("Testing A above C and B at bottom\n");
5306   bool ACB = (indexA > indexC) && (indexC > indexB);
5307
5308   DALI_TEST_EQUALS(ACB, true, TEST_LOCATION);
5309
5310   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5311   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5312   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5313
5314   ResetTouchCallbacks();
5315
5316   tet_printf("RaiseToTop ActorB\n");
5317
5318   orderChangedSignal = false;
5319
5320   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5321   actorB.RaiseToTop();
5322   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5323   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5324
5325   application.SendNotification(); // Ensure sort order is calculated before next touch event
5326
5327   application.ProcessEvent(touchEvent);
5328
5329   glSetUniformStack.Reset();
5330
5331   application.SendNotification();
5332   application.Render();
5333
5334   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5335
5336   // Test order of uniforms in stack
5337   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5338   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5339   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5340
5341   tet_infoline("Testing B above A and C at bottom\n");
5342   bool BAC = (indexB > indexA) && (indexA > indexC);
5343
5344   DALI_TEST_EQUALS(BAC, true, TEST_LOCATION);
5345
5346   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5347   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5348   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5349
5350   ResetTouchCallbacks();
5351
5352   tet_printf("LowerToBottom ActorA then ActorB leaving Actor C at Top\n");
5353
5354   orderChangedSignal = false;
5355
5356   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5357   actorA.LowerToBottom();
5358   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5359   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5360
5361   application.SendNotification();
5362   application.Render();
5363
5364   orderChangedSignal = false;
5365
5366   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5367   actorB.LowerToBottom();
5368   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5369   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5370
5371   application.SendNotification();
5372   application.Render();
5373
5374   application.ProcessEvent(touchEvent);
5375
5376   glSetUniformStack.Reset();
5377
5378   application.SendNotification();
5379   application.Render();
5380
5381   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5382
5383   // Test order of uniforms in stack
5384   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5385   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5386   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5387
5388   tet_infoline("Testing C above A and B at bottom\n");
5389   bool CAB = (indexC > indexA) && (indexA > indexB);
5390
5391   DALI_TEST_EQUALS(CAB, true, TEST_LOCATION);
5392
5393   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5394   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5395   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5396
5397   ResetTouchCallbacks();
5398
5399   END_TEST;
5400 }
5401
5402 int UtcDaliActorRaiseAbove(void)
5403 {
5404   tet_infoline("UtcDaliActor RaiseToAbove test \n");
5405
5406   TestApplication application;
5407
5408   Integration::Scene stage(application.GetScene());
5409
5410   Actor actorA = Actor::New();
5411   Actor actorB = Actor::New();
5412   Actor actorC = Actor::New();
5413
5414   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5415   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5416
5417   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5418   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5419
5420   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5421   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5422
5423   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5424   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5425
5426   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5427   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5428
5429   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5430   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5431
5432   stage.Add(actorA);
5433   stage.Add(actorB);
5434   stage.Add(actorC);
5435
5436   ResetTouchCallbacks();
5437
5438   application.SendNotification();
5439   application.Render();
5440
5441   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5442   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5443   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5444
5445   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5446   // Only top actor will get touched.
5447   actorA.TouchedSignal().Connect(TestTouchCallback);
5448   actorB.TouchedSignal().Connect(TestTouchCallback2);
5449   actorC.TouchedSignal().Connect(TestTouchCallback3);
5450
5451   bool                     orderChangedSignal(false);
5452   Actor                    orderChangedActor;
5453   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5454   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5455
5456   Dali::Integration::Point point;
5457   point.SetDeviceId(1);
5458   point.SetState(PointState::DOWN);
5459   point.SetScreenPosition(Vector2(10.f, 10.f));
5460   Dali::Integration::TouchEvent touchEvent;
5461   touchEvent.AddPoint(point);
5462
5463   application.ProcessEvent(touchEvent);
5464
5465   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5466   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5467   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5468
5469   ResetTouchCallbacks();
5470
5471   tet_printf("Raise actor B Above Actor C\n");
5472
5473   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5474   actorB.RaiseAbove(actorC);
5475   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5476   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5477
5478   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5479   application.SendNotification();
5480   application.ProcessEvent(touchEvent);
5481
5482   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5483   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5484   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5485
5486   ResetTouchCallbacks();
5487
5488   tet_printf("Raise actor A Above Actor B\n");
5489
5490   orderChangedSignal = false;
5491
5492   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5493   actorA.RaiseAbove(actorB);
5494   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5495   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5496
5497   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5498   application.SendNotification();
5499
5500   application.ProcessEvent(touchEvent); // process a touch event on ordered actors.
5501
5502   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5503   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5504   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5505
5506   ResetTouchCallbacks();
5507
5508   END_TEST;
5509 }
5510
5511 int UtcDaliActorRaiseAbove2(void)
5512 {
5513   tet_infoline("UtcDaliActor RaiseToAbove test using SIBLING_ORDER property\n");
5514
5515   TestApplication application;
5516
5517   Integration::Scene stage(application.GetScene());
5518
5519   Actor actorA = Actor::New();
5520   Actor actorB = Actor::New();
5521   Actor actorC = Actor::New();
5522
5523   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5524   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5525
5526   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5527   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5528
5529   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5530   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5531
5532   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5533   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5534
5535   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5536   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5537
5538   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5539   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5540
5541   stage.Add(actorA);
5542   stage.Add(actorB);
5543   stage.Add(actorC);
5544
5545   ResetTouchCallbacks();
5546
5547   application.SendNotification();
5548   application.Render();
5549
5550   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5551   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5552   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5553
5554   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5555   // Only top actor will get touched.
5556   actorA.TouchedSignal().Connect(TestTouchCallback);
5557   actorB.TouchedSignal().Connect(TestTouchCallback2);
5558   actorC.TouchedSignal().Connect(TestTouchCallback3);
5559
5560   bool                     orderChangedSignal(false);
5561   Actor                    orderChangedActor;
5562   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5563   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5564
5565   Dali::Integration::Point point;
5566   point.SetDeviceId(1);
5567   point.SetState(PointState::DOWN);
5568   point.SetScreenPosition(Vector2(10.f, 10.f));
5569   Dali::Integration::TouchEvent touchEvent;
5570   touchEvent.AddPoint(point);
5571
5572   application.ProcessEvent(touchEvent);
5573
5574   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5575   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5576   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5577
5578   ResetTouchCallbacks();
5579
5580   tet_printf("Raise actor B Above Actor C\n");
5581
5582   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5583   int newOrder                                = actorC[DevelActor::Property::SIBLING_ORDER];
5584   actorB[DevelActor::Property::SIBLING_ORDER] = newOrder;
5585   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5586   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5587
5588   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5589   application.SendNotification();
5590   application.ProcessEvent(touchEvent);
5591
5592   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5593   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5594   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5595
5596   ResetTouchCallbacks();
5597
5598   tet_printf("Raise actor A Above Actor B\n");
5599
5600   orderChangedSignal = false;
5601
5602   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5603   newOrder                                    = actorB[DevelActor::Property::SIBLING_ORDER];
5604   actorA[DevelActor::Property::SIBLING_ORDER] = newOrder;
5605   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5606   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5607
5608   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5609   application.SendNotification();
5610
5611   application.ProcessEvent(touchEvent); // process a touch event on ordered actors.
5612
5613   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5614   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5615   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5616
5617   ResetTouchCallbacks();
5618
5619   END_TEST;
5620 }
5621
5622 int UtcDaliActorLowerBelow(void)
5623 {
5624   tet_infoline("UtcDaliActor LowerBelow test \n");
5625
5626   TestApplication application;
5627
5628   Integration::Scene stage(application.GetScene());
5629
5630   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5631   // enables checking of which actor the uniform is assigned too
5632   Shader shaderA = CreateShader();
5633   shaderA.RegisterProperty("uRendererColor", 1.f);
5634
5635   Shader shaderB = CreateShader();
5636   shaderB.RegisterProperty("uRendererColor", 2.f);
5637
5638   Shader shaderC = CreateShader();
5639   shaderC.RegisterProperty("uRendererColor", 3.f);
5640
5641   Actor actorA = Actor::New();
5642   Actor actorB = Actor::New();
5643   Actor actorC = Actor::New();
5644
5645   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5646   Geometry geometry = CreateQuadGeometry();
5647
5648   Renderer rendererA = Renderer::New(geometry, shaderA);
5649   actorA.AddRenderer(rendererA);
5650
5651   Renderer rendererB = Renderer::New(geometry, shaderB);
5652   actorB.AddRenderer(rendererB);
5653
5654   Renderer rendererC = Renderer::New(geometry, shaderC);
5655   actorC.AddRenderer(rendererC);
5656
5657   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5658   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5659
5660   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5661   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5662
5663   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5664   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5665
5666   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5667   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5668
5669   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5670   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5671
5672   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5673   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5674
5675   Actor container = Actor::New();
5676   container.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5677   container.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
5678   stage.Add(container);
5679
5680   container.Add(actorA);
5681   container.Add(actorB);
5682   container.Add(actorC);
5683
5684   ResetTouchCallbacks();
5685
5686   // Connect ChildOrderChangedSignal
5687   bool                     orderChangedSignal(false);
5688   Actor                    orderChangedActor;
5689   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5690   DevelActor::ChildOrderChangedSignal(container).Connect(&application, f);
5691
5692   // Set up gl abstraction trace so can query the set uniform order
5693   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5694   glAbstraction.EnableSetUniformCallTrace(true);
5695   glAbstraction.ResetSetUniformCallStack();
5696   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5697
5698   glAbstraction.ResetSetUniformCallStack();
5699
5700   application.SendNotification();
5701   application.Render();
5702
5703   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5704
5705   // Test order of uniforms in stack
5706   int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5707   int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5708   int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5709
5710   tet_infoline("Testing C above B and A at bottom\n");
5711   bool CBA = (indexC > indexB) && (indexB > indexA);
5712
5713   DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
5714
5715   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5716   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5717   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5718
5719   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5720   // Only top actor will get touched.
5721   actorA.TouchedSignal().Connect(TestTouchCallback);
5722   actorB.TouchedSignal().Connect(TestTouchCallback2);
5723   actorC.TouchedSignal().Connect(TestTouchCallback3);
5724
5725   Dali::Integration::Point point;
5726   point.SetDeviceId(1);
5727   point.SetState(PointState::DOWN);
5728   point.SetScreenPosition(Vector2(10.f, 10.f));
5729   Dali::Integration::TouchEvent touchEvent;
5730   touchEvent.AddPoint(point);
5731
5732   tet_infoline("UtcDaliActor Test Set up completed \n");
5733
5734   application.ProcessEvent(touchEvent);
5735
5736   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5737   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5738   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5739
5740   ResetTouchCallbacks();
5741
5742   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");
5743
5744   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5745   actorC.LowerBelow(actorB);
5746   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5747   DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
5748
5749   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5750   application.SendNotification();
5751   application.Render();
5752
5753   application.ProcessEvent(touchEvent); // touch event
5754
5755   glSetUniformStack.Reset();
5756
5757   application.SendNotification();
5758   application.Render();
5759
5760   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5761
5762   // Test order of uniforms in stack
5763   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5764   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5765   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5766
5767   tet_infoline("Testing render order is A, C, B");
5768   DALI_TEST_EQUALS(indexC > indexA, true, TEST_LOCATION);
5769   DALI_TEST_EQUALS(indexB > indexC, true, TEST_LOCATION);
5770
5771   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5772   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5773   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5774
5775   ResetTouchCallbacks();
5776
5777   tet_printf("Lower actor C below Actor A leaving B on top\n");
5778
5779   orderChangedSignal = false;
5780
5781   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5782   actorC.LowerBelow(actorA);
5783   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5784   DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
5785
5786   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5787   application.SendNotification();
5788   application.Render();
5789
5790   application.ProcessEvent(touchEvent);
5791
5792   glSetUniformStack.Reset();
5793
5794   application.Render();
5795   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5796
5797   // Test order of uniforms in stack
5798   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5799   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5800   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5801
5802   DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
5803   DALI_TEST_EQUALS(indexB > indexA, true, TEST_LOCATION);
5804
5805   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5806   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5807   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5808
5809   ResetTouchCallbacks();
5810
5811   tet_printf("Lower actor B below Actor C leaving A on top\n");
5812
5813   orderChangedSignal = false;
5814
5815   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5816   actorB.LowerBelow(actorC);
5817   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5818   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5819
5820   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5821   application.SendNotification();
5822   application.Render();
5823
5824   application.ProcessEvent(touchEvent);
5825
5826   glSetUniformStack.Reset();
5827
5828   application.Render();
5829   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5830
5831   // Test order of uniforms in stack
5832   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5833   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5834   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5835
5836   DALI_TEST_EQUALS(indexC > indexB, true, TEST_LOCATION);
5837   DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
5838
5839   END_TEST;
5840 }
5841
5842 int UtcDaliActorLowerBelow2(void)
5843 {
5844   tet_infoline("UtcDaliActor LowerBelow test using SIBLING_ORDER property\n");
5845
5846   TestApplication application;
5847
5848   Integration::Scene stage(application.GetScene());
5849
5850   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5851   // enables checking of which actor the uniform is assigned too
5852   Shader shaderA = CreateShader();
5853   shaderA.RegisterProperty("uRendererColor", 1.f);
5854
5855   Shader shaderB = CreateShader();
5856   shaderB.RegisterProperty("uRendererColor", 2.f);
5857
5858   Shader shaderC = CreateShader();
5859   shaderC.RegisterProperty("uRendererColor", 3.f);
5860
5861   Actor actorA = Actor::New();
5862   Actor actorB = Actor::New();
5863   Actor actorC = Actor::New();
5864
5865   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5866   Geometry geometry = CreateQuadGeometry();
5867
5868   Renderer rendererA = Renderer::New(geometry, shaderA);
5869   actorA.AddRenderer(rendererA);
5870
5871   Renderer rendererB = Renderer::New(geometry, shaderB);
5872   actorB.AddRenderer(rendererB);
5873
5874   Renderer rendererC = Renderer::New(geometry, shaderC);
5875   actorC.AddRenderer(rendererC);
5876
5877   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5878   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5879
5880   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5881   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5882
5883   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5884   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5885
5886   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5887   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5888
5889   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5890   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5891
5892   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5893   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5894
5895   Actor container = Actor::New();
5896   container.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5897   container.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
5898   stage.Add(container);
5899
5900   container.Add(actorA);
5901   container.Add(actorB);
5902   container.Add(actorC);
5903
5904   ResetTouchCallbacks();
5905
5906   // Connect ChildOrderChangedSignal
5907   bool                     orderChangedSignal(false);
5908   Actor                    orderChangedActor;
5909   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5910   DevelActor::ChildOrderChangedSignal(container).Connect(&application, f);
5911
5912   // Set up gl abstraction trace so can query the set uniform order
5913   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5914   glAbstraction.EnableSetUniformCallTrace(true);
5915   glAbstraction.ResetSetUniformCallStack();
5916   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5917
5918   glAbstraction.ResetSetUniformCallStack();
5919
5920   application.SendNotification();
5921   application.Render();
5922
5923   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5924
5925   // Test order of uniforms in stack
5926   int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5927   int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5928   int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5929
5930   tet_infoline("Testing C above B and A at bottom\n");
5931   bool CBA = (indexC > indexB) && (indexB > indexA);
5932
5933   DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
5934
5935   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5936   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5937   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5938
5939   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5940   // Only top actor will get touched.
5941   actorA.TouchedSignal().Connect(TestTouchCallback);
5942   actorB.TouchedSignal().Connect(TestTouchCallback2);
5943   actorC.TouchedSignal().Connect(TestTouchCallback3);
5944
5945   Dali::Integration::Point point;
5946   point.SetDeviceId(1);
5947   point.SetState(PointState::DOWN);
5948   point.SetScreenPosition(Vector2(10.f, 10.f));
5949   Dali::Integration::TouchEvent touchEvent;
5950   touchEvent.AddPoint(point);
5951
5952   tet_infoline("UtcDaliActor Test Set up completed \n");
5953
5954   application.ProcessEvent(touchEvent);
5955
5956   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5957   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5958   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5959
5960   ResetTouchCallbacks();
5961
5962   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");
5963
5964   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5965   actorC[DevelActor::Property::SIBLING_ORDER] = 1;
5966   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5967   DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
5968
5969   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5970   application.SendNotification();
5971   application.Render();
5972
5973   application.ProcessEvent(touchEvent); // touch event
5974
5975   glSetUniformStack.Reset();
5976
5977   application.SendNotification();
5978   application.Render();
5979
5980   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5981
5982   // Test order of uniforms in stack
5983   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5984   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5985   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5986
5987   tet_infoline("Testing render order is A, C, B");
5988   DALI_TEST_EQUALS(indexC > indexA, true, TEST_LOCATION);
5989   DALI_TEST_EQUALS(indexB > indexC, true, TEST_LOCATION);
5990
5991   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5992   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5993   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5994
5995   ResetTouchCallbacks();
5996
5997   tet_printf("Lower actor C below Actor A leaving B on top\n");
5998
5999   orderChangedSignal = false;
6000
6001   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6002   actorC[DevelActor::Property::SIBLING_ORDER] = 0;
6003   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6004   DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
6005
6006   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6007   application.SendNotification();
6008   application.Render();
6009
6010   application.ProcessEvent(touchEvent);
6011
6012   glSetUniformStack.Reset();
6013
6014   application.Render();
6015   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6016
6017   // Test order of uniforms in stack
6018   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6019   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6020   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6021
6022   DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
6023   DALI_TEST_EQUALS(indexB > indexA, true, TEST_LOCATION);
6024
6025   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6026   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6027   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6028
6029   ResetTouchCallbacks();
6030
6031   tet_printf("Lower actor B below Actor C leaving A on top\n");
6032
6033   orderChangedSignal = false;
6034
6035   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6036   actorB[DevelActor::Property::SIBLING_ORDER] = 0;
6037   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6038   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
6039
6040   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6041   application.SendNotification();
6042   application.Render();
6043
6044   application.ProcessEvent(touchEvent);
6045
6046   glSetUniformStack.Reset();
6047
6048   application.Render();
6049   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6050
6051   // Test order of uniforms in stack
6052   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6053   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6054   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6055
6056   DALI_TEST_EQUALS(indexC > indexB, true, TEST_LOCATION);
6057   DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
6058
6059   END_TEST;
6060 }
6061
6062 int UtcDaliActorRaiseAboveDifferentParentsN(void)
6063 {
6064   tet_infoline("UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n");
6065
6066   TestApplication application;
6067
6068   Integration::Scene stage(application.GetScene());
6069
6070   Actor parentA = Actor::New();
6071   Actor parentB = Actor::New();
6072   parentA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6073   parentA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6074   parentB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6075   parentB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6076
6077   parentA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6078   parentA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6079
6080   parentB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6081   parentB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6082
6083   stage.Add(parentA);
6084   stage.Add(parentB);
6085
6086   Actor actorA = Actor::New();
6087   Actor actorB = Actor::New();
6088   Actor actorC = Actor::New();
6089
6090   parentA.Add(actorA);
6091   parentA.Add(actorB);
6092
6093   tet_printf("Actor C added to different parent from A and B \n");
6094   parentB.Add(actorC);
6095
6096   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6097   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6098
6099   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6100   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6101
6102   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6103   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6104
6105   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6106   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6107
6108   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6109   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6110
6111   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6112   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6113
6114   ResetTouchCallbacks();
6115
6116   // Connect ChildOrderChangedSignal
6117   bool                     orderChangedSignal(false);
6118   Actor                    orderChangedActor;
6119   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6120   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6121
6122   application.SendNotification();
6123   application.Render();
6124
6125   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6126   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6127   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6128
6129   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6130   // Only top actor will get touched.
6131   actorA.TouchedSignal().Connect(TestTouchCallback);
6132   actorB.TouchedSignal().Connect(TestTouchCallback2);
6133   actorC.TouchedSignal().Connect(TestTouchCallback3);
6134
6135   Dali::Integration::Point point;
6136   point.SetDeviceId(1);
6137   point.SetState(PointState::DOWN);
6138   point.SetScreenPosition(Vector2(10.f, 10.f));
6139   Dali::Integration::TouchEvent touchEvent;
6140   touchEvent.AddPoint(point);
6141
6142   application.ProcessEvent(touchEvent);
6143
6144   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6145   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6146   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6147
6148   ResetTouchCallbacks();
6149
6150   tet_printf("Raise actor A Above Actor C which have different parents\n");
6151
6152   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6153   actorA.RaiseAbove(actorC);
6154   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6155
6156   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6157   application.SendNotification();
6158
6159   application.ProcessEvent(touchEvent); // touch event
6160
6161   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6162   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6163   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6164
6165   ResetTouchCallbacks();
6166
6167   END_TEST;
6168 }
6169
6170 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
6171 {
6172   tet_infoline("UtcDaliActor Test  raiseAbove and lowerBelow api when target Actor has no parent \n");
6173
6174   TestApplication application;
6175
6176   Integration::Scene stage(application.GetScene());
6177
6178   Actor actorA = Actor::New();
6179   Actor actorB = Actor::New();
6180   Actor actorC = Actor::New();
6181
6182   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6183   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6184
6185   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6186   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6187
6188   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6189   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6190
6191   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6192   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6193
6194   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6195   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6196
6197   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6198   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6199
6200   ResetTouchCallbacks();
6201
6202   // Connect ChildOrderChangedSignal
6203   bool                     orderChangedSignal(false);
6204   Actor                    orderChangedActor;
6205   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6206   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6207
6208   application.SendNotification();
6209   application.Render();
6210
6211   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6212   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6213   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6214
6215   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6216   // Only top actor will get touched.
6217   actorA.TouchedSignal().Connect(TestTouchCallback);
6218   actorB.TouchedSignal().Connect(TestTouchCallback2);
6219   actorC.TouchedSignal().Connect(TestTouchCallback3);
6220
6221   Dali::Integration::Point point;
6222   point.SetDeviceId(1);
6223   point.SetState(PointState::DOWN);
6224   point.SetScreenPosition(Vector2(10.f, 10.f));
6225   Dali::Integration::TouchEvent touchEvent;
6226   touchEvent.AddPoint(point);
6227
6228   tet_printf("Raise actor A Above Actor C which have no parents\n");
6229
6230   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6231   actorA.RaiseAbove(actorC);
6232   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6233
6234   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6235   application.SendNotification();
6236
6237   application.ProcessEvent(touchEvent);
6238
6239   tet_printf("Not parented so RaiseAbove should show no effect\n");
6240
6241   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6242   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6243   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6244
6245   ResetTouchCallbacks();
6246
6247   orderChangedSignal = false;
6248
6249   stage.Add(actorB);
6250   tet_printf("Lower actor A below Actor C when only A is not on stage \n");
6251
6252   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6253   actorA.LowerBelow(actorC);
6254   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6255
6256   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6257   application.SendNotification();
6258   application.Render();
6259
6260   application.ProcessEvent(touchEvent);
6261
6262   tet_printf("Actor A not parented so LowerBelow should show no effect\n");
6263   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6264   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6265   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6266
6267   ResetTouchCallbacks();
6268
6269   orderChangedSignal = false;
6270
6271   tet_printf("Adding Actor A to stage, will be on top\n");
6272
6273   stage.Add(actorA);
6274   application.SendNotification();
6275   application.Render();
6276
6277   tet_printf("Raise actor B Above Actor C when only B has a parent\n");
6278
6279   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6280   actorB.RaiseAbove(actorC);
6281   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6282
6283   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6284   application.SendNotification();
6285
6286   application.ProcessEvent(touchEvent);
6287
6288   tet_printf("C not parented so RaiseAbove should show no effect\n");
6289   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6290   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6291   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6292
6293   ResetTouchCallbacks();
6294
6295   orderChangedSignal = false;
6296
6297   tet_printf("Lower actor A below Actor C when only A has a parent\n");
6298
6299   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6300   actorA.LowerBelow(actorC);
6301   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6302
6303   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6304   application.SendNotification();
6305
6306   application.ProcessEvent(touchEvent);
6307
6308   tet_printf("C not parented so LowerBelow should show no effect\n");
6309   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6310   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6311   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6312
6313   ResetTouchCallbacks();
6314
6315   orderChangedSignal = false;
6316
6317   stage.Add(actorC);
6318
6319   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6320   actorA.RaiseAbove(actorC);
6321   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6322   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6323
6324   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6325   application.SendNotification();
6326   application.Render();
6327
6328   application.ProcessEvent(touchEvent);
6329
6330   tet_printf("Raise actor A Above Actor C, now both have same parent \n");
6331   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6332   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6333   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6334
6335   END_TEST;
6336 }
6337
6338 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
6339 {
6340   tet_infoline("UtcDaliActor Test all raise/lower api when actor has no parent \n");
6341
6342   TestApplication application;
6343
6344   Integration::Scene stage(application.GetScene());
6345
6346   Actor actorA = Actor::New();
6347   Actor actorB = Actor::New();
6348   Actor actorC = Actor::New();
6349
6350   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6351   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6352
6353   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6354   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6355
6356   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6357   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6358
6359   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6360   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6361
6362   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6363   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6364
6365   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6366   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6367
6368   ResetTouchCallbacks();
6369
6370   // Connect ChildOrderChangedSignal
6371   bool                     orderChangedSignal(false);
6372   Actor                    orderChangedActor;
6373   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6374   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6375
6376   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6377   // Only top actor will get touched.
6378   actorA.TouchedSignal().Connect(TestTouchCallback);
6379   actorB.TouchedSignal().Connect(TestTouchCallback2);
6380   actorC.TouchedSignal().Connect(TestTouchCallback3);
6381
6382   Dali::Integration::Point point;
6383   point.SetDeviceId(1);
6384   point.SetState(PointState::DOWN);
6385   point.SetScreenPosition(Vector2(10.f, 10.f));
6386   Dali::Integration::TouchEvent touchEvent;
6387   touchEvent.AddPoint(point);
6388
6389   stage.Add(actorA);
6390   tet_printf("Raise actor B Above Actor C but B not parented\n");
6391
6392   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6393   actorB.Raise();
6394   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6395
6396   application.SendNotification();
6397   application.Render();
6398
6399   application.ProcessEvent(touchEvent);
6400
6401   tet_printf("Not parented so RaiseAbove should show no effect\n");
6402
6403   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6404   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6405   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6406
6407   tet_printf("Raise actor B Above Actor C but B not parented\n");
6408   ResetTouchCallbacks();
6409
6410   orderChangedSignal = false;
6411
6412   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6413   actorC.Lower();
6414   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6415
6416   // Sort actor tree before next touch event
6417   application.SendNotification();
6418   application.Render();
6419
6420   application.ProcessEvent(touchEvent);
6421
6422   tet_printf("Not parented so RaiseAbove should show no effect\n");
6423
6424   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6425   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6426   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6427   ResetTouchCallbacks();
6428
6429   orderChangedSignal = false;
6430
6431   tet_printf("Lower actor C below B but C not parented\n");
6432
6433   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6434   actorB.Lower();
6435   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6436
6437   // Sort actor tree before next touch event
6438   application.SendNotification();
6439   application.Render();
6440
6441   application.ProcessEvent(touchEvent);
6442
6443   tet_printf("Not parented so Lower should show no effect\n");
6444
6445   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6446   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6447   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6448   ResetTouchCallbacks();
6449
6450   orderChangedSignal = false;
6451
6452   tet_printf("Raise actor B to top\n");
6453
6454   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6455   actorB.RaiseToTop();
6456   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6457
6458   // Sort actor tree before next touch event
6459   application.SendNotification();
6460   application.Render();
6461
6462   application.ProcessEvent(touchEvent);
6463
6464   tet_printf("Not parented so RaiseToTop should show no effect\n");
6465
6466   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6467   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6468   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6469   ResetTouchCallbacks();
6470
6471   orderChangedSignal = false;
6472
6473   tet_printf("Add ActorB to stage so only Actor C not parented\n");
6474
6475   stage.Add(actorB);
6476
6477   tet_printf("Lower actor C to Bottom, B stays at top\n");
6478
6479   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6480   actorC.LowerToBottom();
6481   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6482
6483   application.SendNotification();
6484   application.Render();
6485
6486   application.ProcessEvent(touchEvent);
6487
6488   tet_printf("Not parented so LowerToBottom should show no effect\n");
6489
6490   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6491   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6492   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6493   ResetTouchCallbacks();
6494
6495   END_TEST;
6496 }
6497
6498 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
6499 {
6500   tet_infoline("UtcDaliActor RaiseToAbove and  test with actor provided as target resulting in a no operation \n");
6501
6502   TestApplication application;
6503
6504   Integration::Scene stage(application.GetScene());
6505
6506   Actor actorA = Actor::New();
6507   Actor actorB = Actor::New();
6508   Actor actorC = Actor::New();
6509
6510   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6511   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6512
6513   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6514   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6515
6516   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6517   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6518
6519   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6520   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6521
6522   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6523   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6524
6525   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6526   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6527
6528   stage.Add(actorA);
6529   stage.Add(actorB);
6530   stage.Add(actorC);
6531
6532   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6533   // Only top actor will get touched.
6534   actorA.TouchedSignal().Connect(TestTouchCallback);
6535   actorB.TouchedSignal().Connect(TestTouchCallback2);
6536   actorC.TouchedSignal().Connect(TestTouchCallback3);
6537
6538   ResetTouchCallbacks();
6539
6540   // Connect ChildOrderChangedSignal
6541   bool                     orderChangedSignal(false);
6542   Actor                    orderChangedActor;
6543   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6544   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6545
6546   application.SendNotification();
6547   application.Render();
6548
6549   Dali::Integration::Point point;
6550   point.SetDeviceId(1);
6551   point.SetState(PointState::DOWN);
6552   point.SetScreenPosition(Vector2(10.f, 10.f));
6553   Dali::Integration::TouchEvent touchEvent;
6554   touchEvent.AddPoint(point);
6555
6556   application.ProcessEvent(touchEvent);
6557
6558   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6559   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6560   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6561
6562   ResetTouchCallbacks();
6563
6564   tet_infoline("Raise actor A Above Actor A which is the same actor!!\n");
6565
6566   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6567   actorA.RaiseAbove(actorA);
6568   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6569   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6570
6571   application.SendNotification();
6572   application.Render();
6573
6574   application.ProcessEvent(touchEvent);
6575
6576   tet_infoline("No target is source Actor so RaiseAbove should show no effect\n");
6577
6578   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6579   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6580   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6581
6582   ResetTouchCallbacks();
6583
6584   orderChangedSignal = false;
6585
6586   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6587   actorA.RaiseAbove(actorC);
6588   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6589   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6590
6591   application.SendNotification();
6592   application.Render();
6593
6594   application.ProcessEvent(touchEvent);
6595
6596   tet_infoline("Raise actor A Above Actor C which will now be successful \n");
6597   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6598   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6599   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6600
6601   END_TEST;
6602 }
6603
6604 int UtcDaliActorGetScreenPosition(void)
6605 {
6606   tet_infoline("UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n");
6607
6608   TestApplication application;
6609
6610   Integration::Scene stage(application.GetScene());
6611
6612   Actor actorA = Actor::New();
6613   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6614
6615   Vector2 size2(10.0f, 20.0f);
6616   actorA.SetProperty(Actor::Property::SIZE, size2);
6617
6618   actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6619
6620   tet_infoline("UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n");
6621
6622   stage.Add(actorA);
6623
6624   application.SendNotification();
6625   application.Render();
6626
6627   Vector3 actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6628   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6629
6630   tet_printf("Actor World Position ( %f %f ) AnchorPoint::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
6631   tet_printf("Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y);
6632
6633   DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6634   DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6635
6636   tet_infoline("UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n");
6637
6638   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6639
6640   application.SendNotification();
6641   application.Render();
6642
6643   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6644   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6645
6646   tet_printf("Actor World Position  ( %f %f ) AnchorPoint::TOP_LEFT  \n", actorWorldPosition.x, actorWorldPosition.y);
6647   tet_printf("Actor Screen Position  ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y);
6648
6649   DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6650   DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6651
6652   tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n");
6653
6654   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6655
6656   application.SendNotification();
6657   application.Render();
6658
6659   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6660   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6661
6662   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT   \n", actorWorldPosition.x, actorWorldPosition.y);
6663   tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT  \n", actorScreenPosition.x, actorScreenPosition.y);
6664
6665   DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6666   DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6667
6668   tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n");
6669
6670   actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 0.0));
6671
6672   application.SendNotification();
6673   application.Render();
6674
6675   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6676   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6677
6678   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorWorldPosition.x, actorWorldPosition.y);
6679   tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0   \n", actorScreenPosition.x, actorScreenPosition.y);
6680
6681   DALI_TEST_EQUALS(actorScreenPosition.x, 30lu, TEST_LOCATION);
6682   DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6683
6684   tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n");
6685
6686   actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 420.0));
6687
6688   application.SendNotification();
6689   application.Render();
6690
6691   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6692   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6693
6694   DALI_TEST_EQUALS(actorScreenPosition.x, 30lu, TEST_LOCATION);
6695   DALI_TEST_EQUALS(actorScreenPosition.y, 420lu, TEST_LOCATION);
6696
6697   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n", actorWorldPosition.x, actorWorldPosition.y);
6698   tet_printf("Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y);
6699
6700   tet_infoline("UtcDaliActorGetScreenPosition Scale parent and check child's screen position \n");
6701
6702   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6703   actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 30.0));
6704
6705   Actor actorB = Actor::New();
6706   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6707   actorB.SetProperty(Actor::Property::SIZE, size2);
6708   actorB.SetProperty(Actor::Property::POSITION, Vector2(10.f, 10.f));
6709   actorA.Add(actorB);
6710
6711   actorA.SetProperty(Actor::Property::SCALE, 2.0f);
6712
6713   application.SendNotification();
6714   application.Render();
6715
6716   actorScreenPosition = actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6717
6718   DALI_TEST_EQUALS(actorScreenPosition.x, 50lu, TEST_LOCATION);
6719   DALI_TEST_EQUALS(actorScreenPosition.y, 50lu, TEST_LOCATION);
6720
6721   END_TEST;
6722 }
6723
6724 int UtcDaliActorGetScreenPositionAfterScaling(void)
6725 {
6726   tet_infoline("UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n");
6727
6728   TestApplication application;
6729
6730   Integration::Scene stage(application.GetScene());
6731
6732   Actor actorA = Actor::New();
6733   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6734
6735   Vector2 size2(10.0f, 20.0f);
6736   actorA.SetProperty(Actor::Property::SIZE, size2);
6737   actorA.SetProperty(Actor::Property::SCALE, 1.5f);
6738   actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6739
6740   tet_infoline("UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n");
6741
6742   stage.Add(actorA);
6743
6744   application.SendNotification();
6745   application.Render();
6746
6747   Vector3 actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6748   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6749
6750   tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y);
6751   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6752
6753   DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6754   DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6755
6756   tet_infoline("UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n");
6757
6758   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6759
6760   application.SendNotification();
6761   application.Render();
6762
6763   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6764   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6765
6766   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
6767   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6768
6769   DALI_TEST_EQUALS(actorScreenPosition.x, 0.0f, TEST_LOCATION);
6770   DALI_TEST_EQUALS(actorScreenPosition.y, 0.0f, TEST_LOCATION);
6771
6772   END_TEST;
6773 }
6774
6775 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
6776 {
6777   tet_infoline("UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n");
6778
6779   TestApplication application;
6780
6781   Integration::Scene stage(application.GetScene());
6782
6783   Actor actorA = Actor::New();
6784   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6785   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6786   Vector2 size2(10.0f, 20.0f);
6787   actorA.SetProperty(Actor::Property::SIZE, size2);
6788   actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6789
6790   tet_infoline(" TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6791
6792   stage.Add(actorA);
6793
6794   application.SendNotification();
6795   application.Render();
6796
6797   Vector3 actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6798   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6799
6800   tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n", actorWorldPosition.x, actorWorldPosition.y);
6801   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6802
6803   DALI_TEST_EQUALS(actorScreenPosition.x, 240.0f, TEST_LOCATION);
6804   DALI_TEST_EQUALS(actorScreenPosition.y, 400.0f, TEST_LOCATION);
6805
6806   tet_infoline(" BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n");
6807
6808   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
6809   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6810
6811   application.SendNotification();
6812   application.Render();
6813
6814   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6815   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6816
6817   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
6818   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6819
6820   DALI_TEST_EQUALS(actorScreenPosition.x, 480.0f, TEST_LOCATION);
6821   DALI_TEST_EQUALS(actorScreenPosition.y, 0.0f, TEST_LOCATION);
6822
6823   END_TEST;
6824   END_TEST;
6825 }
6826
6827 int UtcDaliActorGetScreenPositionWithChildActors(void)
6828 {
6829   tet_infoline("UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n");
6830
6831   TestApplication application;
6832
6833   Integration::Scene stage(application.GetScene());
6834
6835   tet_infoline("Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6836
6837   Actor actorA = Actor::New();
6838   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6839   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6840   Vector2 size1(10.0f, 20.0f);
6841   actorA.SetProperty(Actor::Property::SIZE, size1);
6842   actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6843
6844   tet_infoline("Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6845
6846   Actor parentActorA = Actor::New();
6847   parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6848   parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6849   Vector2 size2(30.0f, 60.0f);
6850   parentActorA.SetProperty(Actor::Property::SIZE, size2);
6851   parentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6852
6853   tet_infoline("Add child 1 to Parent 1 and check screen position \n");
6854
6855   stage.Add(parentActorA);
6856   parentActorA.Add(actorA);
6857
6858   application.SendNotification();
6859   application.Render();
6860
6861   Vector3 actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6862   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6863
6864   tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n", actorWorldPosition.x, actorWorldPosition.y);
6865   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6866
6867   DALI_TEST_EQUALS(actorScreenPosition.x, 255.0f, TEST_LOCATION);
6868   DALI_TEST_EQUALS(actorScreenPosition.y, 430.0f, TEST_LOCATION);
6869
6870   tet_infoline("Test 2\n");
6871
6872   tet_infoline("change parent anchor point and parent origin then check screen position \n");
6873
6874   parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
6875   parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6876
6877   application.SendNotification();
6878   application.Render();
6879
6880   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6881   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6882
6883   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT  \n", actorWorldPosition.x, actorWorldPosition.y);
6884   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6885
6886   DALI_TEST_EQUALS(actorScreenPosition.x, 15.0f, TEST_LOCATION);
6887   DALI_TEST_EQUALS(actorScreenPosition.y, -30.0f, TEST_LOCATION);
6888
6889   END_TEST;
6890 }
6891
6892 int UtcDaliActorGetScreenPositionWithChildActors02(void)
6893 {
6894   tet_infoline("UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n");
6895
6896   TestApplication application;
6897
6898   Integration::Scene stage(application.GetScene());
6899
6900   tet_infoline("Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6901
6902   Actor actorA = Actor::New();
6903   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6904   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6905   Vector2 size1(10.0f, 20.0f);
6906   actorA.SetProperty(Actor::Property::SIZE, size1);
6907   actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6908
6909   tet_infoline("Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6910
6911   Actor parentActorA = Actor::New();
6912   parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6913   parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6914   Vector2 size2(30.0f, 60.0f);
6915   parentActorA.SetProperty(Actor::Property::SIZE, size2);
6916   parentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6917
6918   tet_infoline("Create Grand Parent Actor 1 BOTTOM_LEFT Anchor Point, ParentOrigin::BOTTOM_LEFT and 0,0 position \n");
6919
6920   Actor grandParentActorA = Actor::New();
6921   grandParentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
6922   grandParentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
6923   Vector2 size3(60.0f, 120.0f);
6924   grandParentActorA.SetProperty(Actor::Property::SIZE, size3);
6925   grandParentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6926
6927   tet_infoline("Add Parent 1 to Grand Parent 1 \n");
6928
6929   stage.Add(grandParentActorA);
6930   grandParentActorA.Add(parentActorA);
6931
6932   tet_infoline("Add child 1 to Parent 1 and check screen position \n");
6933
6934   parentActorA.Add(actorA);
6935
6936   application.SendNotification();
6937   application.Render();
6938
6939   Vector3 actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6940   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6941
6942   tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n", actorWorldPosition.x, actorWorldPosition.y);
6943   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6944
6945   DALI_TEST_EQUALS(actorScreenPosition.x, 45.0f, TEST_LOCATION);
6946   DALI_TEST_EQUALS(actorScreenPosition.y, 770.0f, TEST_LOCATION);
6947
6948   END_TEST;
6949 }
6950
6951 int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void)
6952 {
6953   tet_infoline("UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse Check screen position where the position does not use the anchor point");
6954
6955   TestApplication application;
6956
6957   Integration::Scene stage(application.GetScene());
6958
6959   tet_infoline("Create an actor with AnchorPoint::TOP_LEFT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
6960
6961   Actor actorA = Actor::New();
6962   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6963   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6964   actorA.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6965   actorA.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 20.0f));
6966   stage.Add(actorA);
6967
6968   tet_infoline("Create an Actor with AnchorPoint::BOTTOM_RIGHT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
6969
6970   Actor actorB = Actor::New();
6971   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6972   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6973   actorB.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6974   Vector2 actorBSize(30.0f, 60.0f);
6975   actorB.SetProperty(Actor::Property::SIZE, actorBSize);
6976   stage.Add(actorB);
6977
6978   tet_infoline("Create an actor with AnchorPoint::CENTER, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
6979
6980   Actor actorC = Actor::New();
6981   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6982   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6983   actorC.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6984   Vector2 actorCSize(60.0f, 120.0f);
6985   actorC.SetProperty(Actor::Property::SIZE, actorCSize);
6986   stage.Add(actorC);
6987
6988   application.SendNotification();
6989   application.Render();
6990
6991   tet_infoline("Despite differing sizes and anchor-points, the screen position for all actors is the same");
6992
6993   Vector2 center(stage.GetSize() * 0.5f);
6994
6995   DALI_TEST_EQUALS(actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
6996   DALI_TEST_EQUALS(actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
6997   DALI_TEST_EQUALS(actorC.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
6998
6999   tet_infoline("Add scale to all actors");
7000
7001   actorA.SetProperty(Actor::Property::SCALE, 2.0f);
7002   actorB.SetProperty(Actor::Property::SCALE, 2.0f);
7003   actorC.SetProperty(Actor::Property::SCALE, 2.0f);
7004
7005   application.SendNotification();
7006   application.Render();
7007
7008   DALI_TEST_EQUALS(actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center /* TOP_LEFT Anchor */, TEST_LOCATION);
7009   DALI_TEST_EQUALS(actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center - actorBSize /* BOTTOM_RIGHT Anchor */, TEST_LOCATION);
7010   DALI_TEST_EQUALS(actorC.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center - actorCSize * 0.5f /* CENTER Anchor*/, TEST_LOCATION);
7011
7012   END_TEST;
7013 }
7014
7015 int utcDaliActorPositionUsesAnchorPoint(void)
7016 {
7017   TestApplication application;
7018   tet_infoline("Check default behaviour\n");
7019
7020   Actor actor = Actor::New();
7021   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7022   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7023   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7024   application.GetScene().Add(actor);
7025
7026   application.SendNotification();
7027   application.Render();
7028
7029   tet_infoline("Check that the world position is in the center\n");
7030   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
7031
7032   tet_infoline("Set the position uses anchor point property to false\n");
7033   actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7034
7035   application.SendNotification();
7036   application.Render();
7037
7038   tet_infoline("Check that the world position has changed appropriately\n");
7039   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7040
7041   END_TEST;
7042 }
7043
7044 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
7045 {
7046   TestApplication application;
7047   tet_infoline("Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7048
7049   Actor actor = Actor::New();
7050   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7051   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7052   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7053   actor.SetProperty(Actor::Property::SCALE, 2.0f);
7054   actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7055   application.GetScene().Add(actor);
7056
7057   application.SendNotification();
7058   application.Render();
7059
7060   tet_infoline("Check the world position is the same as it would be without a scale\n");
7061   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7062
7063   tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
7064   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7065   application.SendNotification();
7066   application.Render();
7067   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(100.0f, 100.0f, 0.0f), TEST_LOCATION);
7068
7069   tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
7070   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7071   application.SendNotification();
7072   application.Render();
7073   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
7074
7075   END_TEST;
7076 }
7077
7078 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
7079 {
7080   TestApplication application;
7081   tet_infoline("Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7082
7083   Actor actor = Actor::New();
7084   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7085   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7086   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7087   actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::ZAXIS));
7088   actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7089   application.GetScene().Add(actor);
7090
7091   application.SendNotification();
7092   application.Render();
7093
7094   tet_infoline("Check the world position is the same as it would be without a rotation\n");
7095   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7096
7097   tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
7098   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7099   application.SendNotification();
7100   application.Render();
7101   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(-50.0f, 50.0f, 0.0f), TEST_LOCATION);
7102
7103   tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
7104   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7105   application.SendNotification();
7106   application.Render();
7107   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(150.0f, 50.0f, 0.0f), TEST_LOCATION);
7108
7109   END_TEST;
7110 }
7111
7112 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
7113 {
7114   TestApplication application;
7115   tet_infoline("Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7116
7117   Actor actor = Actor::New();
7118   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7119   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7120   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7121   actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::ZAXIS));
7122   actor.SetProperty(Actor::Property::SCALE, 2.0f);
7123   actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7124   application.GetScene().Add(actor);
7125
7126   application.SendNotification();
7127   application.Render();
7128
7129   tet_infoline("Check the world position is the same as it would be without a scale and rotation\n");
7130   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7131
7132   tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
7133   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7134   application.SendNotification();
7135   application.Render();
7136   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(-100.0f, 100.0f, 0.0f), TEST_LOCATION);
7137
7138   tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
7139   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7140   application.SendNotification();
7141   application.Render();
7142   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(200.0f, 0.0f, 0.0f), TEST_LOCATION);
7143
7144   END_TEST;
7145 }
7146
7147 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
7148 {
7149   TestApplication application;
7150   tet_infoline("Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7151
7152   Actor parent = Actor::New();
7153
7154   application.GetScene().Add(parent);
7155   Vector2 stageSize(application.GetScene().GetSize());
7156
7157   Actor actor = Actor::New();
7158   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7159   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7160   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7161   actor.SetProperty(Actor::Property::INHERIT_SCALE, false);
7162   actor.SetProperty(Actor::Property::INHERIT_ORIENTATION, false);
7163   actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7164   parent.Add(actor);
7165
7166   application.SendNotification();
7167   application.Render();
7168
7169   const Vector3 expectedWorldPosition(-stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f);
7170
7171   tet_infoline("Check the world position is in the right place\n");
7172   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
7173
7174   tet_infoline("Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed");
7175   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7176   application.SendNotification();
7177   application.Render();
7178   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
7179
7180   tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed");
7181   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7182   application.SendNotification();
7183   application.Render();
7184   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
7185
7186   END_TEST;
7187 }
7188
7189 int utcDaliActorVisibilityChangeSignalSelf(void)
7190 {
7191   TestApplication application;
7192   tet_infoline("Check that the visibility change signal is called when the visibility changes for the actor itself");
7193
7194   Actor actor = Actor::New();
7195
7196   VisibilityChangedFunctorData data;
7197   DevelActor::VisibilityChangedSignal(actor).Connect(&application, VisibilityChangedFunctor(data));
7198
7199   actor.SetProperty(Actor::Property::VISIBLE, false);
7200
7201   data.Check(true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7202
7203   tet_infoline("Ensure functor is not called if we attempt to change the visibility to what it already is at");
7204   data.Reset();
7205
7206   actor.SetProperty(Actor::Property::VISIBLE, false);
7207   data.Check(false /* not called */, TEST_LOCATION);
7208
7209   tet_infoline("Change the visibility using properties, ensure called");
7210   data.Reset();
7211
7212   actor.SetProperty(Actor::Property::VISIBLE, true);
7213   data.Check(true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7214
7215   tet_infoline("Set the visibility to current using properties, ensure not called");
7216   data.Reset();
7217
7218   actor.SetProperty(Actor::Property::VISIBLE, true);
7219   data.Check(false /* not called */, TEST_LOCATION);
7220
7221   END_TEST;
7222 }
7223
7224 int utcDaliActorVisibilityChangeSignalChildren(void)
7225 {
7226   TestApplication application;
7227   tet_infoline("Check that the visibility change signal is called for the children when the visibility changes for the parent");
7228
7229   Actor parent = Actor::New();
7230   Actor child  = Actor::New();
7231   parent.Add(child);
7232
7233   Actor grandChild = Actor::New();
7234   child.Add(grandChild);
7235
7236   VisibilityChangedFunctorData parentData;
7237   VisibilityChangedFunctorData childData;
7238   VisibilityChangedFunctorData grandChildData;
7239
7240   tet_infoline("Only connect the child and grandchild, ensure they are called and not the parent");
7241   DevelActor::VisibilityChangedSignal(child).Connect(&application, VisibilityChangedFunctor(childData));
7242   DevelActor::VisibilityChangedSignal(grandChild).Connect(&application, VisibilityChangedFunctor(grandChildData));
7243
7244   parent.SetProperty(Actor::Property::VISIBLE, false);
7245   parentData.Check(false /* not called */, TEST_LOCATION);
7246   childData.Check(true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7247   grandChildData.Check(true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7248
7249   tet_infoline("Connect to the parent's signal as well and ensure all three are called");
7250   parentData.Reset();
7251   childData.Reset();
7252   grandChildData.Reset();
7253
7254   DevelActor::VisibilityChangedSignal(parent).Connect(&application, VisibilityChangedFunctor(parentData));
7255
7256   parent.SetProperty(Actor::Property::VISIBLE, true);
7257   parentData.Check(true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7258   childData.Check(true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7259   grandChildData.Check(true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7260
7261   tet_infoline("Ensure none of the functors are called if we attempt to change the visibility to what it already is at");
7262   parentData.Reset();
7263   childData.Reset();
7264   grandChildData.Reset();
7265
7266   parent.SetProperty(Actor::Property::VISIBLE, true);
7267   parentData.Check(false /* not called */, TEST_LOCATION);
7268   childData.Check(false /* not called */, TEST_LOCATION);
7269   grandChildData.Check(false /* not called */, TEST_LOCATION);
7270
7271   END_TEST;
7272 }
7273
7274 int utcDaliActorVisibilityChangeSignalAfterAnimation(void)
7275 {
7276   TestApplication application;
7277   tet_infoline("Check that the visibility change signal is emitted when the visibility changes when an animation starts");
7278
7279   Actor actor = Actor::New();
7280   application.GetScene().Add(actor);
7281
7282   application.SendNotification();
7283   application.Render();
7284
7285   VisibilityChangedFunctorData data;
7286   DevelActor::VisibilityChangedSignal(actor).Connect(&application, VisibilityChangedFunctor(data));
7287
7288   Animation animation = Animation::New(1.0f);
7289   animation.AnimateTo(Property(actor, Actor::Property::VISIBLE), false);
7290
7291   data.Check(false, TEST_LOCATION);
7292   DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7293   DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7294
7295   tet_infoline("Play the animation and check the property value");
7296   animation.Play();
7297
7298   data.Check(true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7299   DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::VISIBLE), false, TEST_LOCATION);
7300
7301   tet_infoline("Animation not currently finished, so the current visibility should still be true");
7302   DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7303
7304   application.SendNotification();
7305   application.Render(1100); // After the animation
7306
7307   DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), false, TEST_LOCATION);
7308
7309   END_TEST;
7310 }
7311
7312 int utcDaliActorVisibilityChangeSignalByName(void)
7313 {
7314   TestApplication application;
7315   tet_infoline("Check that the visibility change signal is called when the visibility changes for the actor itself");
7316
7317   Actor actor = Actor::New();
7318
7319   bool signalCalled = false;
7320   actor.ConnectSignal(&application, "visibilityChanged", VisibilityChangedVoidFunctor(signalCalled));
7321   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7322   actor.SetProperty(Actor::Property::VISIBLE, false);
7323   DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7324
7325   tet_infoline("Ensure functor is not called if we attempt to change the visibility to what it already is at");
7326   signalCalled = false;
7327   actor.SetProperty(Actor::Property::VISIBLE, false);
7328   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7329
7330   tet_infoline("Change the visibility using properties, ensure called");
7331   actor.SetProperty(Actor::Property::VISIBLE, true);
7332   DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7333
7334   tet_infoline("Set the visibility to current using properties, ensure not called");
7335   signalCalled = false;
7336
7337   actor.SetProperty(Actor::Property::VISIBLE, true);
7338   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7339
7340   END_TEST;
7341 }
7342
7343 static void LayoutDirectionChanged(Actor actor, LayoutDirection::Type type)
7344 {
7345   gLayoutDirectionType = type;
7346 }
7347
7348 int UtcDaliActorLayoutDirectionProperty(void)
7349 {
7350   TestApplication application;
7351   tet_infoline("Check layout direction property");
7352
7353   Actor actor0 = Actor::New();
7354   DALI_TEST_EQUALS(actor0.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7355   application.GetScene().Add(actor0);
7356
7357   application.SendNotification();
7358   application.Render();
7359
7360   Actor actor1 = Actor::New();
7361   DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7362   Actor actor2 = Actor::New();
7363   DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7364   Actor actor3 = Actor::New();
7365   DALI_TEST_EQUALS(actor3.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7366   Actor actor4 = Actor::New();
7367   DALI_TEST_EQUALS(actor4.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7368   Actor actor5 = Actor::New();
7369   DALI_TEST_EQUALS(actor5.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7370   Actor actor6 = Actor::New();
7371   DALI_TEST_EQUALS(actor6.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7372   Actor actor7 = Actor::New();
7373   DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7374   Actor actor8 = Actor::New();
7375   DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7376   Actor actor9 = Actor::New();
7377   DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7378
7379   actor1.Add(actor2);
7380   gLayoutDirectionType = LayoutDirection::LEFT_TO_RIGHT;
7381   actor2.LayoutDirectionChangedSignal().Connect(LayoutDirectionChanged);
7382
7383   DALI_TEST_EQUALS(actor1.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), true, TEST_LOCATION);
7384   actor1.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
7385   DALI_TEST_EQUALS(actor1.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), false, TEST_LOCATION);
7386
7387   DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7388   DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7389   DALI_TEST_EQUALS(gLayoutDirectionType, LayoutDirection::RIGHT_TO_LEFT, TEST_LOCATION);
7390
7391   actor1.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, true);
7392   actor0.Add(actor1);
7393   DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7394   DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7395
7396   application.GetScene().Add(actor3);
7397   actor3.Add(actor4);
7398   actor4.Add(actor5);
7399   actor5.Add(actor6);
7400   actor5.Add(actor7);
7401   actor7.Add(actor8);
7402   actor8.Add(actor9);
7403   actor3.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7404   actor5.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7405
7406   DALI_TEST_EQUALS(actor8.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), true, TEST_LOCATION);
7407   actor8.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, false);
7408   DALI_TEST_EQUALS(actor8.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), false, TEST_LOCATION);
7409
7410   actor7.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7411
7412   DALI_TEST_EQUALS(actor3.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7413   DALI_TEST_EQUALS(actor4.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7414   DALI_TEST_EQUALS(actor5.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7415   DALI_TEST_EQUALS(actor6.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7416   DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7417   DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7418   DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7419
7420   actor8.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7421   DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7422   DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7423
7424   actor7.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7425   DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7426   DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7427   DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7428
7429   actor8.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, true);
7430   DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7431   DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7432
7433   END_TEST;
7434 }
7435
7436 struct LayoutDirectionFunctor
7437 {
7438   LayoutDirectionFunctor(bool& signalCalled)
7439   : mSignalCalled(signalCalled)
7440   {
7441   }
7442
7443   LayoutDirectionFunctor(const LayoutDirectionFunctor& rhs)
7444   : mSignalCalled(rhs.mSignalCalled)
7445   {
7446   }
7447
7448   void operator()()
7449   {
7450     mSignalCalled = true;
7451   }
7452
7453   bool& mSignalCalled;
7454 };
7455
7456 int UtcDaliActorLayoutDirectionSignal(void)
7457 {
7458   TestApplication application;
7459   tet_infoline("Check changing layout direction property sends a signal");
7460
7461   Actor actor = Actor::New();
7462   DALI_TEST_EQUALS(actor.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7463   application.GetScene().Add(actor);
7464   bool                   signalCalled = false;
7465   LayoutDirectionFunctor layoutDirectionFunctor(signalCalled);
7466
7467   actor.ConnectSignal(&application, "layoutDirectionChanged", layoutDirectionFunctor);
7468   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7469
7470   // Test that writing the same value doesn't send a signal
7471   actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7472   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7473
7474   // Test that writing a different value sends the signal
7475   signalCalled = false;
7476   actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
7477   DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7478
7479   signalCalled = false;
7480   actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
7481   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7482
7483   END_TEST;
7484 }
7485
7486 struct ChildAddedSignalCheck
7487 {
7488   ChildAddedSignalCheck(bool& signalReceived, Actor& childHandle)
7489   : mSignalReceived(signalReceived),
7490     mChildHandle(childHandle)
7491   {
7492   }
7493
7494   void operator()(Actor childHandle)
7495   {
7496     mSignalReceived = true;
7497     mChildHandle    = childHandle;
7498   }
7499   void operator()()
7500   {
7501     mSignalReceived = true;
7502     mChildHandle    = Actor();
7503   }
7504
7505   bool&  mSignalReceived;
7506   Actor& mChildHandle;
7507 };
7508
7509 int UtcDaliChildAddedSignalP1(void)
7510 {
7511   TestApplication application;
7512   auto            stage = application.GetScene();
7513
7514   bool  signalReceived = false;
7515   Actor childActor;
7516
7517   ChildAddedSignalCheck signal(signalReceived, childActor);
7518   DevelActor::ChildAddedSignal(stage.GetRootLayer()).Connect(&application, signal);
7519   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7520
7521   auto actorA = Actor::New();
7522   stage.Add(actorA);
7523   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7524   DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
7525   signalReceived = false;
7526
7527   auto actorB = Actor::New();
7528   stage.Add(actorB);
7529   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7530   DALI_TEST_EQUALS(childActor, actorB, TEST_LOCATION);
7531
7532   END_TEST;
7533 }
7534
7535 int UtcDaliChildAddedSignalP2(void)
7536 {
7537   TestApplication application;
7538   auto            stage = application.GetScene();
7539
7540   bool  signalReceived = false;
7541   Actor childActor;
7542
7543   ChildAddedSignalCheck signal(signalReceived, childActor);
7544   tet_infoline("Connect to childAdded signal by name");
7545
7546   stage.GetRootLayer().ConnectSignal(&application, "childAdded", signal);
7547   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7548
7549   auto actorA = Actor::New();
7550   stage.Add(actorA);
7551   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7552
7553   // Can't test which actor was added; signal signature is void() when connecting via name.
7554   signalReceived = false;
7555
7556   auto actorB = Actor::New();
7557   stage.Add(actorB);
7558   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7559
7560   END_TEST;
7561 }
7562
7563 int UtcDaliChildAddedSignalN(void)
7564 {
7565   TestApplication application;
7566   auto            stage = application.GetScene();
7567
7568   bool  signalReceived = false;
7569   Actor childActor;
7570
7571   ChildAddedSignalCheck signal(signalReceived, childActor);
7572   DevelActor::ChildAddedSignal(stage.GetRootLayer()).Connect(&application, signal);
7573   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7574
7575   auto actorA = Actor::New();
7576   stage.Add(actorA);
7577   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7578   DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
7579   signalReceived = false;
7580
7581   auto actorB = Actor::New();
7582   actorA.Add(actorB);
7583   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7584   END_TEST;
7585 }
7586
7587 struct ChildRemovedSignalCheck
7588 {
7589   ChildRemovedSignalCheck(bool& signalReceived, Actor& childHandle)
7590   : mSignalReceived(signalReceived),
7591     mChildHandle(childHandle)
7592   {
7593   }
7594
7595   void operator()(Actor childHandle)
7596   {
7597     mSignalReceived = true;
7598     mChildHandle    = childHandle;
7599   }
7600
7601   void operator()()
7602   {
7603     mSignalReceived = true;
7604   }
7605
7606   bool&  mSignalReceived;
7607   Actor& mChildHandle;
7608 };
7609
7610 int UtcDaliChildRemovedSignalP1(void)
7611 {
7612   TestApplication application;
7613   auto            stage = application.GetScene();
7614
7615   bool  signalReceived = false;
7616   Actor childActor;
7617
7618   ChildRemovedSignalCheck signal(signalReceived, childActor);
7619   DevelActor::ChildRemovedSignal(stage.GetRootLayer()).Connect(&application, signal);
7620   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7621
7622   auto actorA = Actor::New();
7623   stage.Add(actorA);
7624   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7625   DALI_TEST_CHECK(!childActor);
7626
7627   stage.Remove(actorA);
7628   DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
7629   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7630
7631   signalReceived = false;
7632   auto actorB    = Actor::New();
7633   stage.Add(actorB);
7634   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7635
7636   stage.Remove(actorB);
7637   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7638   DALI_TEST_EQUALS(childActor, actorB, TEST_LOCATION);
7639
7640   END_TEST;
7641 }
7642
7643 int UtcDaliChildRemovedSignalP2(void)
7644 {
7645   TestApplication application;
7646   auto            stage = application.GetScene();
7647
7648   bool  signalReceived = false;
7649   Actor childActor;
7650
7651   ChildAddedSignalCheck signal(signalReceived, childActor);
7652   tet_infoline("Connect to childRemoved signal by name");
7653
7654   stage.GetRootLayer().ConnectSignal(&application, "childRemoved", signal);
7655   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7656
7657   auto actorA = Actor::New();
7658   stage.Add(actorA);
7659   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7660
7661   stage.Remove(actorA);
7662   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7663
7664   signalReceived = false;
7665   auto actorB    = Actor::New();
7666   stage.Add(actorB);
7667   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7668
7669   stage.Remove(actorB);
7670   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7671
7672   END_TEST;
7673 }
7674
7675 int UtcDaliChildRemovedSignalN(void)
7676 {
7677   TestApplication application;
7678   auto            stage = application.GetScene();
7679
7680   bool  signalReceived = false;
7681   Actor childActor;
7682
7683   ChildRemovedSignalCheck signal(signalReceived, childActor);
7684   DevelActor::ChildRemovedSignal(stage.GetRootLayer()).Connect(&application, signal);
7685   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7686
7687   auto actorA = Actor::New();
7688   stage.Add(actorA);
7689
7690   auto actorB = Actor::New();
7691   actorA.Add(actorB);
7692
7693   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7694   DALI_TEST_CHECK(!childActor);
7695
7696   actorA.Remove(actorB);
7697   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7698   END_TEST;
7699 }
7700
7701 int UtcDaliChildMovedSignalP(void)
7702 {
7703   TestApplication application;
7704   auto            stage = application.GetScene();
7705
7706   bool  addedASignalReceived   = false;
7707   bool  removedASignalReceived = false;
7708   bool  addedBSignalReceived   = false;
7709   bool  removedBSignalReceived = false;
7710   Actor childActor;
7711
7712   auto actorA = Actor::New();
7713   auto actorB = Actor::New();
7714   stage.Add(actorA);
7715   stage.Add(actorB);
7716
7717   ChildAddedSignalCheck   addedSignalA(addedASignalReceived, childActor);
7718   ChildRemovedSignalCheck removedSignalA(removedASignalReceived, childActor);
7719   ChildAddedSignalCheck   addedSignalB(addedBSignalReceived, childActor);
7720   ChildRemovedSignalCheck removedSignalB(removedBSignalReceived, childActor);
7721
7722   DevelActor::ChildAddedSignal(actorA).Connect(&application, addedSignalA);
7723   DevelActor::ChildRemovedSignal(actorA).Connect(&application, removedSignalA);
7724   DevelActor::ChildAddedSignal(actorB).Connect(&application, addedSignalB);
7725   DevelActor::ChildRemovedSignal(actorB).Connect(&application, removedSignalB);
7726
7727   DALI_TEST_EQUALS(addedASignalReceived, false, TEST_LOCATION);
7728   DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
7729   DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
7730   DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
7731
7732   // Create a child of A
7733
7734   auto child = Actor::New();
7735   actorA.Add(child);
7736
7737   DALI_TEST_EQUALS(addedASignalReceived, true, TEST_LOCATION);
7738   DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
7739   DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
7740   DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
7741   DALI_TEST_EQUALS(childActor, child, TEST_LOCATION);
7742
7743   // Move child to B:
7744   addedASignalReceived   = false;
7745   addedBSignalReceived   = false;
7746   removedASignalReceived = false;
7747   removedBSignalReceived = false;
7748
7749   actorB.Add(child); // Expect this child to be re-parented
7750   DALI_TEST_EQUALS(addedASignalReceived, false, TEST_LOCATION);
7751   DALI_TEST_EQUALS(removedASignalReceived, true, TEST_LOCATION);
7752   DALI_TEST_EQUALS(addedBSignalReceived, true, TEST_LOCATION);
7753   DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
7754
7755   // Move child back to A:
7756   addedASignalReceived   = false;
7757   addedBSignalReceived   = false;
7758   removedASignalReceived = false;
7759   removedBSignalReceived = false;
7760
7761   actorA.Add(child); // Expect this child to be re-parented
7762   DALI_TEST_EQUALS(addedASignalReceived, true, TEST_LOCATION);
7763   DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
7764   DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
7765   DALI_TEST_EQUALS(removedBSignalReceived, true, TEST_LOCATION);
7766
7767   END_TEST;
7768 }
7769
7770 int UtcDaliActorSwitchParentP(void)
7771 {
7772   tet_infoline("Testing Actor::UtcDaliActorSwitchParentP");
7773   TestApplication application;
7774
7775   Actor parent1 = Actor::New();
7776   Actor child   = Actor::New();
7777
7778   application.GetScene().Add(parent1);
7779
7780   DALI_TEST_EQUALS(parent1.GetChildCount(), 0u, TEST_LOCATION);
7781
7782   child.OnSceneSignal().Connect(OnSceneCallback);
7783   child.OffSceneSignal().Connect(OffSceneCallback);
7784
7785   // sanity check
7786   DALI_TEST_CHECK(gOnSceneCallBackCalled == 0);
7787   DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
7788
7789   parent1.Add(child);
7790
7791   DALI_TEST_EQUALS(parent1.GetChildCount(), 1u, TEST_LOCATION);
7792
7793   DALI_TEST_CHECK(gOnSceneCallBackCalled == 1);
7794   DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
7795
7796   Actor parent2 = Actor::New();
7797   application.GetScene().Add(parent2);
7798
7799   bool                  addSignalReceived = false;
7800   ChildAddedSignalCheck addedSignal(addSignalReceived, child);
7801   DevelActor::ChildAddedSignal(application.GetScene().GetRootLayer()).Connect(&application, addedSignal);
7802   DALI_TEST_EQUALS(addSignalReceived, false, TEST_LOCATION);
7803
7804   bool                    removedSignalReceived = false;
7805   ChildRemovedSignalCheck removedSignal(removedSignalReceived, child);
7806   DevelActor::ChildRemovedSignal(application.GetScene().GetRootLayer()).Connect(&application, removedSignal);
7807   DALI_TEST_EQUALS(removedSignalReceived, false, TEST_LOCATION);
7808
7809   DevelActor::SwitchParent(child, parent2);
7810
7811   DALI_TEST_EQUALS(addSignalReceived, false, TEST_LOCATION);
7812   DALI_TEST_EQUALS(removedSignalReceived, false, TEST_LOCATION);
7813
7814   DALI_TEST_EQUALS(parent1.GetChildCount(), 0u, TEST_LOCATION);
7815   DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
7816
7817   DALI_TEST_CHECK(gOnSceneCallBackCalled == 1);
7818   DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
7819   DALI_TEST_CHECK(child.GetProperty<bool>(Dali::Actor::Property::CONNECTED_TO_SCENE));
7820   DALI_TEST_CHECK(child.GetParent() == parent2);
7821
7822   END_TEST;
7823 }
7824
7825 int utcDaliActorCulled(void)
7826 {
7827   TestApplication application;
7828   auto            stage = application.GetScene();
7829
7830   tet_infoline("Check that the actor is culled if the actor is out of the screen");
7831
7832   Actor actor = Actor::New();
7833   actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
7834
7835   Geometry geometry = CreateQuadGeometry();
7836   Shader   shader   = CreateShader();
7837   Renderer renderer = Renderer::New(geometry, shader);
7838   actor.AddRenderer(renderer);
7839
7840   stage.Add(actor);
7841
7842   application.SendNotification();
7843   application.Render(0);
7844
7845   DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::CULLED), false, TEST_LOCATION);
7846
7847   PropertyNotification notification = actor.AddPropertyNotification(Actor::Property::CULLED, LessThanCondition(0.5f));
7848   notification.SetNotifyMode(PropertyNotification::NOTIFY_ON_CHANGED);
7849
7850   // Connect NotifySignal
7851   bool                              propertyNotificationSignal(false);
7852   PropertyNotification              source;
7853   CulledPropertyNotificationFunctor f(propertyNotificationSignal, source);
7854   notification.NotifySignal().Connect(&application, f);
7855
7856   actor.SetProperty(Actor::Property::POSITION, Vector2(1000.0f, 1000.0f));
7857
7858   application.SendNotification();
7859   application.Render();
7860
7861   application.SendNotification();
7862
7863   DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::CULLED), true, TEST_LOCATION);
7864
7865   DALI_TEST_EQUALS(propertyNotificationSignal, true, TEST_LOCATION);
7866   DALI_TEST_EQUALS(source.GetTargetProperty(), static_cast<int>(Actor::Property::CULLED), TEST_LOCATION);
7867   DALI_TEST_EQUALS(source.GetTarget().GetProperty<bool>(source.GetTargetProperty()), true, TEST_LOCATION);
7868
7869   END_TEST;
7870 }
7871
7872 int utcDaliEnsureRenderWhenRemovingLastRenderableActor(void)
7873 {
7874   TestApplication application;
7875   auto            stage = application.GetScene();
7876
7877   tet_infoline("Ensure we clear the screen when the last actor is removed");
7878
7879   Actor actor = CreateRenderableActor();
7880   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7881   stage.Add(actor);
7882
7883   application.SendNotification();
7884   application.Render();
7885
7886   auto&      glAbstraction    = application.GetGlAbstraction();
7887   const auto clearCountBefore = glAbstraction.GetClearCountCalled();
7888
7889   actor.Unparent();
7890
7891   application.SendNotification();
7892   application.Render();
7893
7894   DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION);
7895
7896   END_TEST;
7897 }
7898
7899 int utcDaliEnsureRenderWhenMakingLastActorInvisible(void)
7900 {
7901   TestApplication application;
7902   auto            stage = application.GetScene();
7903
7904   tet_infoline("Ensure we clear the screen when the last actor is made invisible");
7905
7906   Actor actor = CreateRenderableActor();
7907   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7908   stage.Add(actor);
7909
7910   application.SendNotification();
7911   application.Render();
7912
7913   auto&      glAbstraction    = application.GetGlAbstraction();
7914   const auto clearCountBefore = glAbstraction.GetClearCountCalled();
7915
7916   actor.SetProperty(Actor::Property::VISIBLE, false);
7917
7918   application.SendNotification();
7919   application.Render();
7920
7921   DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION);
7922
7923   END_TEST;
7924 }
7925
7926 int utcDaliActorGetSizeAfterAnimation(void)
7927 {
7928   TestApplication application;
7929   tet_infoline("Check the actor size before / after an animation is finished");
7930
7931   Vector3 actorSize(100.0f, 100.0f, 0.0f);
7932
7933   Actor actor = Actor::New();
7934   actor.SetProperty(Actor::Property::SIZE, actorSize);
7935   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7936   application.GetScene().Add(actor);
7937
7938   // Size should be updated without rendering.
7939   Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7940   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7941
7942   application.SendNotification();
7943   application.Render();
7944
7945   // Size and current size should be updated.
7946   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7947   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7948   DALI_TEST_EQUALS(actorSize.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7949   DALI_TEST_EQUALS(actorSize.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7950   DALI_TEST_EQUALS(actorSize.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7951
7952   Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7953   DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7954   DALI_TEST_EQUALS(actorSize.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7955   DALI_TEST_EQUALS(actorSize.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7956   DALI_TEST_EQUALS(actorSize.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7957
7958   // Set size again
7959   actorSize = Vector3(200.0f, 200.0f, 0.0f);
7960   actor.SetProperty(Actor::Property::SIZE, actorSize);
7961
7962   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7963   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7964
7965   Vector3 targetValue(10.0f, 20.0f, 0.0f);
7966
7967   Animation animation = Animation::New(1.0f);
7968   animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
7969   animation.Play();
7970
7971   // Size should be updated without rendering.
7972   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7973   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7974
7975   application.SendNotification();
7976   application.Render(1100); // After the animation
7977
7978   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7979   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7980   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7981   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7982   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7983
7984   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7985   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7986   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7987   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7988   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7989
7990   targetValue.width = 50.0f;
7991
7992   animation.Clear();
7993   animation.AnimateTo(Property(actor, Actor::Property::SIZE_WIDTH), targetValue.width);
7994   animation.Play();
7995
7996   application.SendNotification();
7997   application.Render(1100); // After the animation
7998
7999   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8000   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8001   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8002   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8003   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8004
8005   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8006   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8007   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8008   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8009   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8010
8011   targetValue.height = 70.0f;
8012
8013   animation.Clear();
8014   animation.AnimateTo(Property(actor, Actor::Property::SIZE_HEIGHT), targetValue.height);
8015   animation.Play();
8016
8017   application.SendNotification();
8018   application.Render(1100); // After the animation
8019
8020   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8021   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8022   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8023   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8024   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8025
8026   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8027   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8028   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8029   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8030   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8031
8032   Vector3 offset(10.0f, 20.0f, 0.0f);
8033
8034   animation.Clear();
8035   animation.AnimateBy(Property(actor, Actor::Property::SIZE), offset);
8036   animation.Play();
8037
8038   application.SendNotification();
8039   application.Render(1100); // After the animation
8040
8041   targetValue += offset;
8042
8043   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8044   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8045   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8046   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8047   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8048
8049   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8050   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8051   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8052   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8053   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8054
8055   offset.width = 20.0f;
8056
8057   animation.Clear();
8058   animation.AnimateBy(Property(actor, Actor::Property::SIZE_WIDTH), offset.width);
8059   animation.Play();
8060
8061   application.SendNotification();
8062   application.Render(1100); // After the animation
8063
8064   targetValue.width += offset.width;
8065
8066   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8067   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8068   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8069   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8070   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8071
8072   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8073   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8074   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8075   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8076   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8077
8078   offset.height = 10.0f;
8079
8080   animation.Clear();
8081   animation.AnimateBy(Property(actor, Actor::Property::SIZE_HEIGHT), offset.height);
8082   animation.Play();
8083
8084   application.SendNotification();
8085   application.Render(1100); // After the animation
8086
8087   targetValue.height += offset.height;
8088
8089   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8090   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8091   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8092   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8093   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8094
8095   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8096   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8097   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8098   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8099   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8100
8101   // Set size again
8102   actorSize = Vector3(300.0f, 300.0f, 0.0f);
8103
8104   actor.SetProperty(Actor::Property::SIZE, actorSize);
8105
8106   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8107   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8108
8109   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8110   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8111
8112   application.SendNotification();
8113   application.Render();
8114
8115   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8116   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8117
8118   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8119   DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8120
8121   END_TEST;
8122 }
8123
8124 int utcDaliActorRelayoutAndAnimation(void)
8125 {
8126   TestApplication application;
8127   tet_infoline("Check the actor size when relayoutting and playing animation");
8128
8129   Vector3 parentSize(300.0f, 300.0f, 0.0f);
8130   Vector3 actorSize(100.0f, 100.0f, 0.0f);
8131
8132   {
8133     Actor parentA = Actor::New();
8134     parentA.SetProperty(Actor::Property::SIZE, parentSize);
8135     parentA.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8136     application.GetScene().Add(parentA);
8137
8138     Actor parentB = Actor::New();
8139     parentB.SetProperty(Actor::Property::SIZE, parentSize);
8140     parentB.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8141     application.GetScene().Add(parentB);
8142
8143     Actor actor = Actor::New();
8144     actor.SetProperty(Actor::Property::SIZE, actorSize);
8145     actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8146     parentA.Add(actor);
8147
8148     Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8149     DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8150
8151     Vector3 targetValue(200.0f, 200.0f, 0.0f);
8152
8153     Animation animation = Animation::New(1.0f);
8154     animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
8155     animation.Play();
8156
8157     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8158     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8159
8160     application.SendNotification();
8161     application.Render(1100); // After the animation
8162
8163     // Size and current size should be updated.
8164     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8165     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8166
8167     Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8168     DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8169
8170     // Trigger relayout
8171     parentB.Add(actor);
8172
8173     application.SendNotification();
8174     application.Render();
8175
8176     // Size and current size should be same.
8177     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8178     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8179
8180     currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8181     DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8182
8183     actor.Unparent();
8184     parentA.Unparent();
8185     parentB.Unparent();
8186   }
8187
8188   {
8189     Actor parentA = Actor::New();
8190     parentA.SetProperty(Actor::Property::SIZE, parentSize);
8191     parentA.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8192     application.GetScene().Add(parentA);
8193
8194     Actor parentB = Actor::New();
8195     parentB.SetProperty(Actor::Property::SIZE, parentSize);
8196     parentB.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8197     application.GetScene().Add(parentB);
8198
8199     Actor actor = Actor::New();
8200     actor.SetProperty(Actor::Property::SIZE, actorSize);
8201     actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8202     parentA.Add(actor);
8203
8204     Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8205     DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8206
8207     application.SendNotification();
8208     application.Render();
8209
8210     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8211     DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8212
8213     Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8214     DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8215
8216     Vector3 targetValue(200.0f, 200.0f, 0.0f);
8217
8218     // Make an animation
8219     Animation animation = Animation::New(1.0f);
8220     animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
8221     animation.Play();
8222
8223     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8224     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8225
8226     application.SendNotification();
8227     application.Render(1100); // After the animation
8228
8229     // Size and current size should be updated.
8230     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8231     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8232
8233     currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8234     DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8235
8236     // Trigger relayout
8237     parentB.Add(actor);
8238
8239     application.SendNotification();
8240     application.Render();
8241
8242     // Size and current size should be same.
8243     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8244     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8245
8246     currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8247     DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8248
8249     actor.Unparent();
8250     parentA.Unparent();
8251     parentB.Unparent();
8252   }
8253
8254   END_TEST;
8255 }
8256
8257 int utcDaliActorPartialUpdate(void)
8258 {
8259   TestApplication application(
8260     TestApplication::DEFAULT_SURFACE_WIDTH,
8261     TestApplication::DEFAULT_SURFACE_HEIGHT,
8262     TestApplication::DEFAULT_HORIZONTAL_DPI,
8263     TestApplication::DEFAULT_VERTICAL_DPI,
8264     true,
8265     true);
8266
8267   tet_infoline("Check the damaged area");
8268
8269   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8270
8271   std::vector<Rect<int>> damagedRects;
8272   Rect<int>              clippingRect;
8273   application.SendNotification();
8274   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8275
8276   // First render pass, nothing to render, adaptor would just do swap buffer.
8277   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8278
8279   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8280   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8281
8282   Actor actor = CreateRenderableActor();
8283   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8284   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8285   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8286   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8287   application.GetScene().Add(actor);
8288
8289   application.SendNotification();
8290
8291   // 1. Actor added, damaged rect is added size of actor
8292   damagedRects.clear();
8293   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8294   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8295
8296   // Aligned by 16
8297   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8298   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8299   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8300   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8301   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8302   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8303   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8304
8305   // 2. Set new size
8306   actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0));
8307   application.SendNotification();
8308
8309   damagedRects.clear();
8310   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8311   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8312
8313   // Aligned by 16
8314   clippingRect = Rect<int>(16, 752, 48, 48); // in screen coordinates, includes 3 last frames updates
8315   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8316   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8317   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8318   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8319   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8320   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8321
8322   // 3. Set new position
8323   actor.SetProperty(Actor::Property::POSITION, Vector3(32.0f, 32.0f, 0));
8324   application.SendNotification();
8325
8326   damagedRects.clear();
8327   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8328   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8329
8330   // Aligned by 16
8331   clippingRect = Rect<int>(16, 736, 64, 64); // in screen coordinates, includes 3 last frames updates
8332   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8333   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8334   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8335   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8336   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8337   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8338
8339   application.GetScene().Remove(actor);
8340   application.SendNotification();
8341
8342   // Actor removed, last 3 dirty rects are reported. Adaptor would merge them together.
8343   damagedRects.clear();
8344   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8345   DALI_TEST_EQUALS(damagedRects.size(), 3, TEST_LOCATION);
8346
8347   clippingRect = damagedRects[0];
8348   clippingRect.Merge(damagedRects[1]);
8349   clippingRect.Merge(damagedRects[2]);
8350
8351   DALI_TEST_EQUALS(clippingRect.IsEmpty(), false, TEST_LOCATION);
8352   DALI_TEST_EQUALS(clippingRect.IsValid(), true, TEST_LOCATION);
8353   DALI_TEST_EQUALS<Rect<int>>(clippingRect, Rect<int>(16, 736, 64, 64), TEST_LOCATION);
8354
8355   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8356   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8357   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8358   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8359   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8360
8361   END_TEST;
8362 }
8363
8364 int utcDaliActorPartialUpdateSetColor(void)
8365 {
8366   TestApplication application(
8367     TestApplication::DEFAULT_SURFACE_WIDTH,
8368     TestApplication::DEFAULT_SURFACE_HEIGHT,
8369     TestApplication::DEFAULT_HORIZONTAL_DPI,
8370     TestApplication::DEFAULT_VERTICAL_DPI,
8371     true,
8372     true);
8373
8374   tet_infoline("Check uniform update");
8375
8376   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8377
8378   std::vector<Rect<int>> damagedRects;
8379   Rect<int>              clippingRect;
8380   application.SendNotification();
8381   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8382
8383   // First render pass, nothing to render, adaptor would just do swap buffer.
8384   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8385
8386   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8387   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8388
8389   Actor actor = CreateRenderableActor();
8390   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8391   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8392   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8393   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8394   application.GetScene().Add(actor);
8395
8396   application.SendNotification();
8397
8398   // 1. Actor added, damaged rect is added size of actor
8399   damagedRects.clear();
8400   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8401   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8402
8403   // Aligned by 16
8404   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8405   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8406   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8407   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8408   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8409   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8410   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8411
8412   damagedRects.clear();
8413   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8414
8415   damagedRects.clear();
8416   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8417
8418   // 2. Set new color
8419   actor.SetProperty(Actor::Property::COLOR, Vector3(1.0f, 0.0f, 0.0f));
8420   application.SendNotification();
8421
8422   damagedRects.clear();
8423   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8424   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8425
8426   // Aligned by 16
8427   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8428   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8429   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8430   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8431   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8432   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8433   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8434
8435   END_TEST;
8436 }
8437
8438 const std::string SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME("uLightCameraProjectionMatrix");
8439 const std::string SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME("uLightCameraViewMatrix");
8440 const std::string SHADER_SHADOW_COLOR_PROPERTY_NAME("uShadowColor");
8441 const char* const RENDER_SHADOW_VERTEX_SOURCE =
8442   " uniform mediump mat4 uLightCameraProjectionMatrix;\n"
8443   " uniform mediump mat4 uLightCameraViewMatrix;\n"
8444   "\n"
8445   "void main()\n"
8446   "{\n"
8447   "  gl_Position = uProjection * uModelView * vec4(aPosition,1.0);\n"
8448   "  vec4 textureCoords = uLightCameraProjectionMatrix * uLightCameraViewMatrix * uModelMatrix  * vec4(aPosition,1.0);\n"
8449   "  vTexCoord = 0.5 + 0.5 * (textureCoords.xy/textureCoords.w);\n"
8450   "}\n";
8451
8452 const char* const RENDER_SHADOW_FRAGMENT_SOURCE =
8453   "uniform lowp vec4 uShadowColor;\n"
8454   "void main()\n"
8455   "{\n"
8456   "  lowp float alpha;\n"
8457   "  alpha = texture2D(sTexture, vec2(vTexCoord.x, vTexCoord.y)).a;\n"
8458   "  gl_FragColor = vec4(uShadowColor.rgb, uShadowColor.a * alpha);\n"
8459   "}\n";
8460
8461 int utcDaliActorPartialUpdateSetProperty(void)
8462 {
8463   TestApplication application(
8464     TestApplication::DEFAULT_SURFACE_WIDTH,
8465     TestApplication::DEFAULT_SURFACE_HEIGHT,
8466     TestApplication::DEFAULT_HORIZONTAL_DPI,
8467     TestApplication::DEFAULT_VERTICAL_DPI,
8468     true,
8469     true);
8470
8471   tet_infoline("Set/Update property with partial update");
8472
8473   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8474
8475   std::vector<Rect<int>> damagedRects;
8476   Rect<int>              clippingRect;
8477   application.SendNotification();
8478   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8479
8480   // First render pass, nothing to render, adaptor would just do swap buffer.
8481   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8482
8483   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8484   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8485
8486   Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 4u, 4u);
8487   Actor   actor = CreateRenderableActor(image, RENDER_SHADOW_VERTEX_SOURCE, RENDER_SHADOW_FRAGMENT_SOURCE);
8488   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8489   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8490   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8491   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8492   application.GetScene().Add(actor);
8493
8494   actor.RegisterProperty(SHADER_SHADOW_COLOR_PROPERTY_NAME, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
8495
8496   damagedRects.clear();
8497   application.SendNotification();
8498   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8499   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8500
8501   // Aligned by 16
8502   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8503   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8504   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8505   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8506   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8507   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8508   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8509
8510   Property::Index shadowColorPropertyIndex = actor.GetPropertyIndex(SHADER_SHADOW_COLOR_PROPERTY_NAME);
8511   actor.SetProperty(shadowColorPropertyIndex, Vector4(1.0f, 1.0f, 0.0f, 1.0f));
8512
8513   damagedRects.clear();
8514   application.SendNotification();
8515   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8516   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8517
8518   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8519   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8520   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8521   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8522   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8523   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8524
8525   // Should be no damage rects, nothing changed
8526   damagedRects.clear();
8527   application.SendNotification();
8528   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8529   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8530
8531   // Should be 1 damage rect due to change in size
8532   damagedRects.clear();
8533   actor.SetProperty(Actor::Property::SIZE, Vector3(26.0f, 26.0f, 0.0f));
8534   application.SendNotification();
8535   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8536   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8537
8538   clippingRect = Rect<int>(16, 752, 32, 48); // new clipping rect size increased due to change in actor size
8539   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8540   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8541   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8542   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8543   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8544   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8545
8546   damagedRects.clear();
8547   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8548   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8549
8550   END_TEST;
8551 }
8552
8553 int utcDaliActorPartialUpdateTwoActors(void)
8554 {
8555   TestApplication application(
8556     TestApplication::DEFAULT_SURFACE_WIDTH,
8557     TestApplication::DEFAULT_SURFACE_HEIGHT,
8558     TestApplication::DEFAULT_HORIZONTAL_DPI,
8559     TestApplication::DEFAULT_VERTICAL_DPI,
8560     true,
8561     true);
8562
8563   tet_infoline("Check the damaged rects with partial update and two actors");
8564
8565   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8566
8567   Actor actor = CreateRenderableActor();
8568   actor.SetProperty(Actor::Property::POSITION, Vector3(100.0f, 100.0f, 0.0f));
8569   actor.SetProperty(Actor::Property::SIZE, Vector3(50.0f, 50.0f, 0.0f));
8570   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8571   application.GetScene().Add(actor);
8572
8573   Actor actor2 = CreateRenderableActor();
8574   actor2.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
8575   actor2.SetProperty(Actor::Property::SIZE, Vector3(100.0f, 100.0f, 0.0f));
8576   actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8577   application.GetScene().Add(actor2);
8578
8579   application.SendNotification();
8580   std::vector<Rect<int>> damagedRects;
8581   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
8582
8583   DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
8584   DALI_TEST_EQUALS<Rect<int>>(Rect<int>(64, 672, 64, 64), damagedRects[0], TEST_LOCATION);
8585   DALI_TEST_EQUALS<Rect<int>>(Rect<int>(96, 592, 112, 112), damagedRects[1], TEST_LOCATION);
8586
8587   // in screen coordinates, adaptor would calculate it using previous frames information
8588   Rect<int> clippingRect = Rect<int>(64, 592, 144, 192);
8589   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8590
8591   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8592   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8593   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8594   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8595
8596   // Change a Renderer of actor1
8597   Geometry geometry    = CreateQuadGeometry();
8598   Shader   shader      = CreateShader();
8599   Renderer newRenderer = Renderer::New(geometry, shader);
8600   Renderer renderer    = actor.GetRendererAt(0);
8601
8602   actor.RemoveRenderer(renderer);
8603   actor.AddRenderer(newRenderer);
8604
8605   damagedRects.clear();
8606
8607   application.SendNotification();
8608   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
8609
8610   DALI_TEST_CHECK(damagedRects.size() > 0);
8611   DALI_TEST_EQUALS<Rect<int>>(Rect<int>(64, 672, 64, 64), damagedRects[0], TEST_LOCATION);
8612
8613   // in screen coordinates, adaptor would calculate it using previous frames information
8614   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8615
8616   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8617   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8618   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8619   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8620
8621   END_TEST;
8622 }
8623
8624 int utcDaliActorPartialUpdateActorsWithSizeHint(void)
8625 {
8626   TestApplication application(
8627     TestApplication::DEFAULT_SURFACE_WIDTH,
8628     TestApplication::DEFAULT_SURFACE_HEIGHT,
8629     TestApplication::DEFAULT_HORIZONTAL_DPI,
8630     TestApplication::DEFAULT_VERTICAL_DPI,
8631     true,
8632     true);
8633
8634   tet_infoline("Check the damaged rect with partial update and actor size hint");
8635
8636   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8637
8638   Actor actor = CreateRenderableActor();
8639   actor.SetProperty(Actor::Property::POSITION, Vector3(64.0f, 64.0f, 0.0f));
8640   actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0.0f));
8641   actor.SetProperty(DevelActor::Property::UPDATE_SIZE_HINT, Vector3(64.0f, 64.0f, 0.0f));
8642   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8643   application.GetScene().Add(actor);
8644
8645   application.SendNotification();
8646   std::vector<Rect<int>> damagedRects;
8647   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
8648
8649   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8650
8651   Rect<int> clippingRect = Rect<int>(32, 704, 80, 80);
8652   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8653
8654   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8655
8656   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8657   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8658   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8659   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8660
8661   END_TEST;
8662 }
8663
8664 int utcDaliActorPartialUpdateAnimation(void)
8665 {
8666   TestApplication application(
8667     TestApplication::DEFAULT_SURFACE_WIDTH,
8668     TestApplication::DEFAULT_SURFACE_HEIGHT,
8669     TestApplication::DEFAULT_HORIZONTAL_DPI,
8670     TestApplication::DEFAULT_VERTICAL_DPI,
8671     true,
8672     true);
8673
8674   tet_infoline("Check the damaged area with partial update and animation");
8675
8676   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
8677   drawTrace.Enable(true);
8678   drawTrace.Reset();
8679
8680   Actor actor1 = CreateRenderableActor();
8681   actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8682   actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
8683   application.GetScene().Add(actor1);
8684
8685   Actor actor2 = CreateRenderableActor();
8686   actor2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8687   actor2.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8688   application.GetScene().Add(actor2);
8689
8690   std::vector<Rect<int>> damagedRects;
8691   Rect<int>              clippingRect;
8692   Rect<int>              expectedRect1, expectedRect2;
8693
8694   application.SendNotification();
8695   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8696
8697   DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
8698
8699   // Aligned by 16
8700   expectedRect1 = Rect<int>(0, 720, 96, 96); // in screen coordinates, includes 3 last frames updates
8701   expectedRect2 = Rect<int>(0, 784, 32, 32); // in screen coordinates, includes 3 last frames updates
8702   DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[0], TEST_LOCATION);
8703   DALI_TEST_EQUALS<Rect<int>>(expectedRect2, damagedRects[1], TEST_LOCATION);
8704
8705   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8706   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8707
8708   damagedRects.clear();
8709   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8710   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8711   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8712
8713   // Make an animation
8714   Animation animation = Animation::New(1.0f);
8715   animation.AnimateTo(Property(actor2, Actor::Property::POSITION_X), 160.0f, TimePeriod(0.5f, 0.5f));
8716   animation.Play();
8717
8718   application.SendNotification();
8719
8720   damagedRects.clear();
8721   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8722   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8723   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8724
8725   drawTrace.Reset();
8726   damagedRects.clear();
8727
8728   // In animation deley time
8729   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8730   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8731   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8732
8733   // Skip rendering
8734   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
8735
8736   drawTrace.Reset();
8737   damagedRects.clear();
8738
8739   // Also in animation deley time
8740   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8741   application.PreRenderWithPartialUpdate(100, nullptr, damagedRects);
8742   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8743
8744   // Skip rendering
8745   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
8746
8747   // Unparent 2 actors and make a new actor
8748   actor1.Unparent();
8749   actor2.Unparent();
8750
8751   Actor actor3 = CreateRenderableActor();
8752   actor3.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8753   actor3.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8754   application.GetScene().Add(actor3);
8755
8756   application.SendNotification();
8757
8758   // Started animation
8759   damagedRects.clear();
8760   application.PreRenderWithPartialUpdate(500, nullptr, damagedRects);
8761   DALI_TEST_EQUALS(damagedRects.size(), 5, TEST_LOCATION);
8762
8763   // The first dirty rect is actor3's.
8764   // We don't know the exact dirty rect of actor2
8765   DALI_TEST_EQUALS<Rect<int>>(expectedRect2, damagedRects[0], TEST_LOCATION);
8766   DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[1], TEST_LOCATION);
8767
8768   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8769   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8770
8771   // Finished animation, but the actor was already unparented
8772   damagedRects.clear();
8773   application.PreRenderWithPartialUpdate(500, nullptr, damagedRects);
8774
8775   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8776   DALI_TEST_EQUALS<Rect<int>>(expectedRect2, damagedRects[0], TEST_LOCATION);
8777
8778   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8779   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8780
8781   END_TEST;
8782 }
8783
8784 int utcDaliActorPartialUpdateChangeVisibility(void)
8785 {
8786   TestApplication application(
8787     TestApplication::DEFAULT_SURFACE_WIDTH,
8788     TestApplication::DEFAULT_SURFACE_HEIGHT,
8789     TestApplication::DEFAULT_HORIZONTAL_DPI,
8790     TestApplication::DEFAULT_VERTICAL_DPI,
8791     true,
8792     true);
8793
8794   tet_infoline("Check the damaged rect with partial update and visibility change");
8795
8796   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8797
8798   Actor actor = CreateRenderableActor();
8799   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8800   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8801   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8802   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8803   application.GetScene().Add(actor);
8804
8805   application.SendNotification();
8806
8807   std::vector<Rect<int>> damagedRects;
8808   Rect<int>              clippingRect;
8809
8810   // 1. Actor added, damaged rect is added size of actor
8811   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8812   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8813
8814   // Aligned by 16
8815   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8816   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8817   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8818   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8819   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8820   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8821   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8822
8823   damagedRects.clear();
8824   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8825   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8826
8827   damagedRects.clear();
8828   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8829   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8830
8831   // Ensure the damaged rect is empty
8832   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8833
8834   // 2. Make the Actor invisible
8835   actor.SetProperty(Actor::Property::VISIBLE, false);
8836   application.SendNotification();
8837
8838   damagedRects.clear();
8839   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8840   DALI_TEST_CHECK(damagedRects.size() > 0);
8841   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8842
8843   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8844   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8845   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8846   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8847   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8848
8849   // 3. Make the Actor visible again
8850   actor.SetProperty(Actor::Property::VISIBLE, true);
8851   application.SendNotification();
8852
8853   damagedRects.clear();
8854   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8855   DALI_TEST_CHECK(damagedRects.size() > 0);
8856   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8857
8858   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8859   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8860   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8861   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8862   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8863
8864   END_TEST;
8865 }
8866
8867 int utcDaliActorPartialUpdateOnOffScene(void)
8868 {
8869   TestApplication application(
8870     TestApplication::DEFAULT_SURFACE_WIDTH,
8871     TestApplication::DEFAULT_SURFACE_HEIGHT,
8872     TestApplication::DEFAULT_HORIZONTAL_DPI,
8873     TestApplication::DEFAULT_VERTICAL_DPI,
8874     true,
8875     true);
8876
8877   tet_infoline("Check the damaged rect with partial update and on/off scene");
8878
8879   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8880
8881   Actor actor = CreateRenderableActor();
8882   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8883   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8884   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8885   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8886   application.GetScene().Add(actor);
8887
8888   application.SendNotification();
8889
8890   std::vector<Rect<int>> damagedRects;
8891   Rect<int>              clippingRect;
8892
8893   // 1. Actor added, damaged rect is added size of actor
8894   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8895   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8896
8897   // Aligned by 16
8898   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8899   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8900   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8901   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8902   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8903   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8904   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8905
8906   damagedRects.clear();
8907   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8908   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8909
8910   damagedRects.clear();
8911   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8912   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8913
8914   // Ensure the damaged rect is empty
8915   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8916
8917   // 2. Remove the Actor from the Scene
8918   actor.Unparent();
8919   application.SendNotification();
8920
8921   damagedRects.clear();
8922   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8923   DALI_TEST_CHECK(damagedRects.size() > 0);
8924   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8925
8926   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8927   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8928   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8929   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8930   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8931
8932   // 3. Add the Actor to the Scene again
8933   application.GetScene().Add(actor);
8934   application.SendNotification();
8935
8936   damagedRects.clear();
8937   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8938   DALI_TEST_CHECK(damagedRects.size() > 0);
8939   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8940
8941   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8942   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8943   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8944   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8945   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8946
8947   END_TEST;
8948 }
8949
8950 int utcDaliActorPartialUpdateSkipRendering(void)
8951 {
8952   TestApplication application(
8953     TestApplication::DEFAULT_SURFACE_WIDTH,
8954     TestApplication::DEFAULT_SURFACE_HEIGHT,
8955     TestApplication::DEFAULT_HORIZONTAL_DPI,
8956     TestApplication::DEFAULT_VERTICAL_DPI,
8957     true,
8958     true);
8959
8960   tet_infoline("Check to skip rendering in case of the empty damaged rect");
8961
8962   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
8963   drawTrace.Enable(true);
8964   drawTrace.Reset();
8965
8966   Actor actor1 = CreateRenderableActor();
8967   actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8968   actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
8969   application.GetScene().Add(actor1);
8970
8971   std::vector<Rect<int>> damagedRects;
8972   Rect<int>              clippingRect;
8973   Rect<int>              expectedRect1;
8974
8975   application.SendNotification();
8976   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8977
8978   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8979
8980   // Aligned by 16
8981   expectedRect1 = Rect<int>(0, 720, 96, 96); // in screen coordinates, includes 3 last frames updates
8982   DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[0], TEST_LOCATION);
8983
8984   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8985   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8986
8987   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
8988
8989   damagedRects.clear();
8990   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8991   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8992   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8993
8994   // Remove the actor
8995   actor1.Unparent();
8996
8997   application.SendNotification();
8998
8999   damagedRects.clear();
9000   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9001
9002   DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[0], TEST_LOCATION);
9003
9004   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9005   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9006
9007   // Render again without any change
9008   damagedRects.clear();
9009   drawTrace.Reset();
9010   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9011
9012   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9013
9014   clippingRect = Rect<int>();
9015   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9016
9017   // Skip rendering
9018   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
9019
9020   // Add the actor again
9021   application.GetScene().Add(actor1);
9022
9023   application.SendNotification();
9024
9025   damagedRects.clear();
9026   drawTrace.Reset();
9027   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9028
9029   DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[0], TEST_LOCATION);
9030
9031   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9032   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9033
9034   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9035
9036   END_TEST;
9037 }
9038
9039 int utcDaliActorPartialUpdate3DNode(void)
9040 {
9041   TestApplication application(
9042     TestApplication::DEFAULT_SURFACE_WIDTH,
9043     TestApplication::DEFAULT_SURFACE_HEIGHT,
9044     TestApplication::DEFAULT_HORIZONTAL_DPI,
9045     TestApplication::DEFAULT_VERTICAL_DPI,
9046     true,
9047     true);
9048
9049   tet_infoline("Partial update should be ignored in case of 3d layer of 3d node");
9050
9051   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
9052   drawTrace.Enable(true);
9053   drawTrace.Reset();
9054
9055   Actor actor1 = CreateRenderableActor();
9056   actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9057   actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
9058   application.GetScene().Add(actor1);
9059
9060   std::vector<Rect<int>> damagedRects;
9061   Rect<int>              clippingRect;
9062
9063   application.SendNotification();
9064   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9065
9066   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9067
9068   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9069   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9070
9071   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9072
9073   // Change the layer to 3D
9074   application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D);
9075
9076   application.SendNotification();
9077
9078   damagedRects.clear();
9079   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9080
9081   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9082   DALI_TEST_EQUALS<Rect<int>>(TestApplication::DEFAULT_SURFACE_RECT, damagedRects[0], TEST_LOCATION);
9083
9084   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9085   drawTrace.Reset();
9086   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9087
9088   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9089
9090   // Change the layer to 2D
9091   application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_UI);
9092
9093   application.SendNotification();
9094
9095   damagedRects.clear();
9096   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9097
9098   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9099
9100   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9101   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9102
9103   // Make 3D transform
9104   actor1.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::YAXIS));
9105
9106   application.SendNotification();
9107
9108   damagedRects.clear();
9109   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9110
9111   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9112   DALI_TEST_EQUALS<Rect<int>>(TestApplication::DEFAULT_SURFACE_RECT, damagedRects[0], TEST_LOCATION);
9113
9114   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9115   drawTrace.Reset();
9116   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9117
9118   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9119
9120   END_TEST;
9121 }
9122
9123 int utcDaliActorPartialUpdateNotRenderableActor(void)
9124 {
9125   TestApplication application(
9126     TestApplication::DEFAULT_SURFACE_WIDTH,
9127     TestApplication::DEFAULT_SURFACE_HEIGHT,
9128     TestApplication::DEFAULT_HORIZONTAL_DPI,
9129     TestApplication::DEFAULT_VERTICAL_DPI,
9130     true,
9131     true);
9132
9133   tet_infoline("Check the damaged rect with not renderable parent actor");
9134
9135   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9136
9137   Actor parent                          = Actor::New();
9138   parent[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9139   parent[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
9140   parent[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
9141   parent.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9142   application.GetScene().Add(parent);
9143
9144   Actor child                          = CreateRenderableActor();
9145   child[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9146   child[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
9147   child.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9148   parent.Add(child);
9149
9150   application.SendNotification();
9151
9152   std::vector<Rect<int>> damagedRects;
9153
9154   // 1. Actor added, damaged rect is added size of actor
9155   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9156   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9157
9158   // Aligned by 16
9159   Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
9160   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9161
9162   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9163   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9164   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9165   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9166   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9167
9168   damagedRects.clear();
9169   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9170   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9171
9172   damagedRects.clear();
9173   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9174   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9175
9176   // Ensure the damaged rect is empty
9177   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9178
9179   END_TEST;
9180 }
9181
9182 int utcDaliActorPartialUpdateChangeTransparency(void)
9183 {
9184   TestApplication application(
9185     TestApplication::DEFAULT_SURFACE_WIDTH,
9186     TestApplication::DEFAULT_SURFACE_HEIGHT,
9187     TestApplication::DEFAULT_HORIZONTAL_DPI,
9188     TestApplication::DEFAULT_VERTICAL_DPI,
9189     true,
9190     true);
9191
9192   tet_infoline("Check the damaged rect with changing transparency");
9193
9194   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9195
9196   Actor actor                          = CreateRenderableActor();
9197   actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9198   actor[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
9199   actor[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
9200   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9201   application.GetScene().Add(actor);
9202
9203   application.SendNotification();
9204
9205   std::vector<Rect<int>> damagedRects;
9206
9207   // Actor added, damaged rect is added size of actor
9208   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9209   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9210
9211   // Aligned by 16
9212   Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
9213   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9214
9215   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9216   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9217   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9218   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9219   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9220
9221   damagedRects.clear();
9222   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9223   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9224
9225   damagedRects.clear();
9226   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9227   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9228
9229   // Make the actor transparent by changing opacity of the Renderer
9230   // It changes a uniform value
9231   Renderer renderer                          = actor.GetRendererAt(0);
9232   renderer[DevelRenderer::Property::OPACITY] = 0.0f;
9233
9234   application.SendNotification();
9235
9236   // The damaged rect should be same
9237   damagedRects.clear();
9238   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9239   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9240   DALI_TEST_CHECK(damagedRects.size() > 0);
9241   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9242
9243   damagedRects.clear();
9244   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9245   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9246
9247   // Ensure the damaged rect is empty
9248   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9249
9250   // Make the actor opaque again
9251   renderer[DevelRenderer::Property::OPACITY] = 1.0f;
9252
9253   application.SendNotification();
9254
9255   // The damaged rect should not be empty
9256   damagedRects.clear();
9257   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9258   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9259   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9260   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9261
9262   damagedRects.clear();
9263   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9264   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9265
9266   damagedRects.clear();
9267   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9268   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9269
9270   // Make the actor culled
9271   actor[Actor::Property::SIZE] = Vector3(0.0f, 0.0f, 0.0f);
9272
9273   application.SendNotification();
9274
9275   // The damaged rect should be same
9276   damagedRects.clear();
9277   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9278   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9279   DALI_TEST_CHECK(damagedRects.size() > 0);
9280   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9281
9282   damagedRects.clear();
9283   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9284   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9285
9286   // Ensure the damaged rect is empty
9287   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9288
9289   // Make the actor not culled again
9290   actor[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 16.0f);
9291
9292   application.SendNotification();
9293
9294   // The damaged rect should not be empty
9295   damagedRects.clear();
9296   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9297   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9298   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9299   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9300
9301   END_TEST;
9302 }
9303
9304 int utcDaliActorPartialUpdateChangeParentOpacity(void)
9305 {
9306   TestApplication application(
9307     TestApplication::DEFAULT_SURFACE_WIDTH,
9308     TestApplication::DEFAULT_SURFACE_HEIGHT,
9309     TestApplication::DEFAULT_HORIZONTAL_DPI,
9310     TestApplication::DEFAULT_VERTICAL_DPI,
9311     true,
9312     true);
9313
9314   tet_infoline("Check the damaged rect with changing parent's opacity");
9315
9316   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9317
9318   Actor parent                          = Actor::New();
9319   parent[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9320   parent[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
9321   parent[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
9322   parent.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9323   application.GetScene().Add(parent);
9324
9325   Texture texture                      = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
9326   Actor   child                        = CreateRenderableActor(texture);
9327   child[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9328   child[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
9329   child.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9330   parent.Add(child);
9331
9332   application.SendNotification();
9333
9334   std::vector<Rect<int>> damagedRects;
9335
9336   // Actor added, damaged rect is added size of actor
9337   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9338   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9339
9340   // Aligned by 16
9341   Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
9342   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9343
9344   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9345   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9346   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9347   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9348   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9349
9350   damagedRects.clear();
9351   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9352   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9353
9354   damagedRects.clear();
9355   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9356   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9357
9358   // Ensure the damaged rect is empty
9359   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9360
9361   // Change the parent's opacity
9362   parent[Actor::Property::OPACITY] = 0.5f;
9363
9364   application.SendNotification();
9365
9366   // The damaged rect should be same
9367   damagedRects.clear();
9368   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9369   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9370   DALI_TEST_CHECK(damagedRects.size() > 0);
9371   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9372
9373   END_TEST;
9374 }
9375
9376 int utcDaliActorPartialAddRemoveRenderer(void)
9377 {
9378   TestApplication application(
9379     TestApplication::DEFAULT_SURFACE_WIDTH,
9380     TestApplication::DEFAULT_SURFACE_HEIGHT,
9381     TestApplication::DEFAULT_HORIZONTAL_DPI,
9382     TestApplication::DEFAULT_VERTICAL_DPI,
9383     true,
9384     true);
9385
9386   tet_infoline("Check the damaged rect with adding / removing renderer");
9387
9388   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9389
9390   Actor actor                          = CreateRenderableActor();
9391   actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9392   actor[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
9393   actor[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
9394   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9395   application.GetScene().Add(actor);
9396
9397   application.SendNotification();
9398
9399   std::vector<Rect<int>> damagedRects;
9400
9401   // Actor added, damaged rect is added size of actor
9402   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9403   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9404
9405   // Aligned by 16
9406   Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
9407   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9408
9409   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9410   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9411   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9412   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9413   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9414
9415   damagedRects.clear();
9416   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9417   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9418
9419   damagedRects.clear();
9420   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9421   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9422
9423   // Remove the Renderer
9424   Renderer renderer = actor.GetRendererAt(0);
9425   actor.RemoveRenderer(renderer);
9426
9427   application.SendNotification();
9428
9429   // The damaged rect should be the actor area
9430   damagedRects.clear();
9431   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9432   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9433   DALI_TEST_CHECK(damagedRects.size() > 0);
9434   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9435
9436   damagedRects.clear();
9437   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9438   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9439
9440   // Ensure the damaged rect is empty
9441   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9442
9443   // Add the Renderer again
9444   actor.AddRenderer(renderer);
9445
9446   application.SendNotification();
9447
9448   // The damaged rect should be the actor area
9449   damagedRects.clear();
9450   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9451   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9452   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9453   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9454
9455   END_TEST;
9456 }
9457
9458 int UtcDaliActorCaptureAllTouchAfterStartPropertyP(void)
9459 {
9460   TestApplication application;
9461
9462   Actor actor = Actor::New();
9463   DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), false, TEST_LOCATION);
9464   actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, true);
9465   DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), true, TEST_LOCATION);
9466   DALI_TEST_EQUALS(actor.GetPropertyType(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), Property::BOOLEAN, TEST_LOCATION);
9467   DALI_TEST_EQUALS(actor.IsPropertyWritable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), true, TEST_LOCATION);
9468   DALI_TEST_EQUALS(actor.IsPropertyAnimatable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
9469   DALI_TEST_EQUALS(actor.IsPropertyAConstraintInput(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
9470   DALI_TEST_EQUALS(actor.GetPropertyName(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), "captureAllTouchAfterStart", TEST_LOCATION);
9471   END_TEST;
9472 }
9473
9474 int UtcDaliActorCaptureAllTouchAfterStartPropertyN(void)
9475 {
9476   TestApplication application;
9477
9478   Actor actor = Actor::New();
9479
9480   // Make sure setting invalid types does not cause a crash
9481   try
9482   {
9483     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, 1.0f);
9484     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector2::ONE);
9485     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector3::ONE);
9486     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector4::ONE);
9487     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Map());
9488     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Array());
9489     tet_result(TET_PASS);
9490   }
9491   catch(...)
9492   {
9493     tet_result(TET_FAIL);
9494   }
9495   END_TEST;
9496 }
9497
9498 int UtcDaliActorTouchAreaOffsetPropertyP(void)
9499 {
9500   TestApplication application;
9501
9502   Actor     actor           = Actor::New();
9503   Rect<int> touchAreaOffset = actor.GetProperty(DevelActor::Property::TOUCH_AREA_OFFSET).Get<Rect<int>>();
9504   DALI_TEST_EQUALS(Rect<int>(0, 0, 0, 0), touchAreaOffset, TEST_LOCATION);
9505   actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Rect<int>(10, 20, 30, 40));
9506   touchAreaOffset = actor.GetProperty(DevelActor::Property::TOUCH_AREA_OFFSET).Get<Rect<int>>();
9507   DALI_TEST_EQUALS(Rect<int>(10, 20, 30, 40), touchAreaOffset, TEST_LOCATION);
9508   END_TEST;
9509 }
9510
9511 int UtcDaliActorTouchAreaOffsetPropertyN(void)
9512 {
9513   TestApplication application;
9514
9515   Actor actor = Actor::New();
9516
9517   // Make sure setting invalid types does not cause a crash
9518   try
9519   {
9520     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, 1.0f);
9521     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector2::ONE);
9522     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector3::ONE);
9523     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector4::ONE);
9524     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Property::Map());
9525     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Property::Array());
9526     tet_result(TET_PASS);
9527   }
9528   catch(...)
9529   {
9530     tet_result(TET_FAIL);
9531   }
9532   END_TEST;
9533 }
9534
9535 int UtcDaliActorLowerBelowNegative(void)
9536 {
9537   TestApplication application;
9538   Dali::Actor     instance;
9539   try
9540   {
9541     Dali::Actor arg1;
9542     instance.LowerBelow(arg1);
9543     DALI_TEST_CHECK(false); // Should not get here
9544   }
9545   catch(...)
9546   {
9547     DALI_TEST_CHECK(true); // We expect an assert
9548   }
9549   END_TEST;
9550 }
9551
9552 int UtcDaliActorRaiseAboveNegative(void)
9553 {
9554   TestApplication application;
9555   Dali::Actor     instance;
9556   try
9557   {
9558     Dali::Actor arg1;
9559     instance.RaiseAbove(arg1);
9560     DALI_TEST_CHECK(false); // Should not get here
9561   }
9562   catch(...)
9563   {
9564     DALI_TEST_CHECK(true); // We expect an assert
9565   }
9566   END_TEST;
9567 }
9568
9569 int UtcDaliActorRaiseToTopNegative(void)
9570 {
9571   TestApplication application;
9572   Dali::Actor     instance;
9573   try
9574   {
9575     instance.RaiseToTop();
9576     DALI_TEST_CHECK(false); // Should not get here
9577   }
9578   catch(...)
9579   {
9580     DALI_TEST_CHECK(true); // We expect an assert
9581   }
9582   END_TEST;
9583 }
9584
9585 int UtcDaliActorAddRendererNegative(void)
9586 {
9587   TestApplication application;
9588   Dali::Actor     instance;
9589   try
9590   {
9591     Dali::Renderer arg1;
9592     instance.AddRenderer(arg1);
9593     DALI_TEST_CHECK(false); // Should not get here
9594   }
9595   catch(...)
9596   {
9597     DALI_TEST_CHECK(true); // We expect an assert
9598   }
9599   END_TEST;
9600 }
9601
9602 int UtcDaliActorTouchedSignalNegative(void)
9603 {
9604   TestApplication application;
9605   Dali::Actor     instance;
9606   try
9607   {
9608     instance.TouchedSignal();
9609     DALI_TEST_CHECK(false); // Should not get here
9610   }
9611   catch(...)
9612   {
9613     DALI_TEST_CHECK(true); // We expect an assert
9614   }
9615   END_TEST;
9616 }
9617
9618 int UtcDaliActorTranslateByNegative(void)
9619 {
9620   TestApplication application;
9621   Dali::Actor     instance;
9622   try
9623   {
9624     Dali::Vector3 arg1;
9625     instance.TranslateBy(arg1);
9626     DALI_TEST_CHECK(false); // Should not get here
9627   }
9628   catch(...)
9629   {
9630     DALI_TEST_CHECK(true); // We expect an assert
9631   }
9632   END_TEST;
9633 }
9634
9635 int UtcDaliActorFindChildByIdNegative(void)
9636 {
9637   TestApplication application;
9638   Dali::Actor     instance;
9639   try
9640   {
9641     unsigned int arg1 = 0u;
9642     instance.FindChildById(arg1);
9643     DALI_TEST_CHECK(false); // Should not get here
9644   }
9645   catch(...)
9646   {
9647     DALI_TEST_CHECK(true); // We expect an assert
9648   }
9649   END_TEST;
9650 }
9651
9652 int UtcDaliActorGetRendererAtNegative(void)
9653 {
9654   TestApplication application;
9655   Dali::Actor     instance;
9656   try
9657   {
9658     unsigned int arg1 = 0u;
9659     instance.GetRendererAt(arg1);
9660     DALI_TEST_CHECK(false); // Should not get here
9661   }
9662   catch(...)
9663   {
9664     DALI_TEST_CHECK(true); // We expect an assert
9665   }
9666   END_TEST;
9667 }
9668
9669 int UtcDaliActorHoveredSignalNegative(void)
9670 {
9671   TestApplication application;
9672   Dali::Actor     instance;
9673   try
9674   {
9675     instance.HoveredSignal();
9676     DALI_TEST_CHECK(false); // Should not get here
9677   }
9678   catch(...)
9679   {
9680     DALI_TEST_CHECK(true); // We expect an assert
9681   }
9682   END_TEST;
9683 }
9684
9685 int UtcDaliActorLowerToBottomNegative(void)
9686 {
9687   TestApplication application;
9688   Dali::Actor     instance;
9689   try
9690   {
9691     instance.LowerToBottom();
9692     DALI_TEST_CHECK(false); // Should not get here
9693   }
9694   catch(...)
9695   {
9696     DALI_TEST_CHECK(true); // We expect an assert
9697   }
9698   END_TEST;
9699 }
9700
9701 int UtcDaliActorOnSceneSignalNegative(void)
9702 {
9703   TestApplication application;
9704   Dali::Actor     instance;
9705   try
9706   {
9707     instance.OnSceneSignal();
9708     DALI_TEST_CHECK(false); // Should not get here
9709   }
9710   catch(...)
9711   {
9712     DALI_TEST_CHECK(true); // We expect an assert
9713   }
9714   END_TEST;
9715 }
9716
9717 int UtcDaliActorOffSceneSignalNegative(void)
9718 {
9719   TestApplication application;
9720   Dali::Actor     instance;
9721   try
9722   {
9723     instance.OffSceneSignal();
9724     DALI_TEST_CHECK(false); // Should not get here
9725   }
9726   catch(...)
9727   {
9728     DALI_TEST_CHECK(true); // We expect an assert
9729   }
9730   END_TEST;
9731 }
9732
9733 int UtcDaliActorRemoveRendererNegative01(void)
9734 {
9735   TestApplication application;
9736   Dali::Actor     instance;
9737   try
9738   {
9739     unsigned int arg1 = 0u;
9740     instance.RemoveRenderer(arg1);
9741     DALI_TEST_CHECK(false); // Should not get here
9742   }
9743   catch(...)
9744   {
9745     DALI_TEST_CHECK(true); // We expect an assert
9746   }
9747   END_TEST;
9748 }
9749
9750 int UtcDaliActorRemoveRendererNegative02(void)
9751 {
9752   TestApplication application;
9753   Dali::Actor     instance;
9754   try
9755   {
9756     Dali::Renderer arg1;
9757     instance.RemoveRenderer(arg1);
9758     DALI_TEST_CHECK(false); // Should not get here
9759   }
9760   catch(...)
9761   {
9762     DALI_TEST_CHECK(true); // We expect an assert
9763   }
9764   END_TEST;
9765 }
9766
9767 int UtcDaliActorFindChildByNameNegative(void)
9768 {
9769   TestApplication application;
9770   Dali::Actor     instance;
9771   try
9772   {
9773     std::string arg1;
9774     instance.FindChildByName(arg1);
9775     DALI_TEST_CHECK(false); // Should not get here
9776   }
9777   catch(...)
9778   {
9779     DALI_TEST_CHECK(true); // We expect an assert
9780   }
9781   END_TEST;
9782 }
9783
9784 int UtcDaliActorSetResizePolicyNegative(void)
9785 {
9786   TestApplication application;
9787   Dali::Actor     instance;
9788   try
9789   {
9790     Dali::ResizePolicy::Type arg1 = ResizePolicy::USE_NATURAL_SIZE;
9791     Dali::Dimension::Type    arg2 = Dimension::ALL_DIMENSIONS;
9792     instance.SetResizePolicy(arg1, arg2);
9793     DALI_TEST_CHECK(false); // Should not get here
9794   }
9795   catch(...)
9796   {
9797     DALI_TEST_CHECK(true); // We expect an assert
9798   }
9799   END_TEST;
9800 }
9801
9802 int UtcDaliActorOnRelayoutSignalNegative(void)
9803 {
9804   TestApplication application;
9805   Dali::Actor     instance;
9806   try
9807   {
9808     instance.OnRelayoutSignal();
9809     DALI_TEST_CHECK(false); // Should not get here
9810   }
9811   catch(...)
9812   {
9813     DALI_TEST_CHECK(true); // We expect an assert
9814   }
9815   END_TEST;
9816 }
9817
9818 int UtcDaliActorWheelEventSignalNegative(void)
9819 {
9820   TestApplication application;
9821   Dali::Actor     instance;
9822   try
9823   {
9824     instance.WheelEventSignal();
9825     DALI_TEST_CHECK(false); // Should not get here
9826   }
9827   catch(...)
9828   {
9829     DALI_TEST_CHECK(true); // We expect an assert
9830   }
9831   END_TEST;
9832 }
9833
9834 int UtcDaliActorGetHeightForWidthNegative(void)
9835 {
9836   TestApplication application;
9837   Dali::Actor     instance;
9838   try
9839   {
9840     float arg1 = 0.0f;
9841     instance.GetHeightForWidth(arg1);
9842     DALI_TEST_CHECK(false); // Should not get here
9843   }
9844   catch(...)
9845   {
9846     DALI_TEST_CHECK(true); // We expect an assert
9847   }
9848   END_TEST;
9849 }
9850
9851 int UtcDaliActorGetWidthForHeightNegative(void)
9852 {
9853   TestApplication application;
9854   Dali::Actor     instance;
9855   try
9856   {
9857     float arg1 = 0.0f;
9858     instance.GetWidthForHeight(arg1);
9859     DALI_TEST_CHECK(false); // Should not get here
9860   }
9861   catch(...)
9862   {
9863     DALI_TEST_CHECK(true); // We expect an assert
9864   }
9865   END_TEST;
9866 }
9867
9868 int UtcDaliActorLayoutDirectionChangedSignalNegative(void)
9869 {
9870   TestApplication application;
9871   Dali::Actor     instance;
9872   try
9873   {
9874     instance.LayoutDirectionChangedSignal();
9875     DALI_TEST_CHECK(false); // Should not get here
9876   }
9877   catch(...)
9878   {
9879     DALI_TEST_CHECK(true); // We expect an assert
9880   }
9881   END_TEST;
9882 }
9883
9884 int UtcDaliActorAddNegative(void)
9885 {
9886   TestApplication application;
9887   Dali::Actor     instance;
9888   try
9889   {
9890     Dali::Actor arg1;
9891     instance.Add(arg1);
9892     DALI_TEST_CHECK(false); // Should not get here
9893   }
9894   catch(...)
9895   {
9896     DALI_TEST_CHECK(true); // We expect an assert
9897   }
9898   END_TEST;
9899 }
9900
9901 int UtcDaliActorLowerNegative(void)
9902 {
9903   TestApplication application;
9904   Dali::Actor     instance;
9905   try
9906   {
9907     instance.Lower();
9908     DALI_TEST_CHECK(false); // Should not get here
9909   }
9910   catch(...)
9911   {
9912     DALI_TEST_CHECK(true); // We expect an assert
9913   }
9914   END_TEST;
9915 }
9916
9917 int UtcDaliActorRaiseNegative(void)
9918 {
9919   TestApplication application;
9920   Dali::Actor     instance;
9921   try
9922   {
9923     instance.Raise();
9924     DALI_TEST_CHECK(false); // Should not get here
9925   }
9926   catch(...)
9927   {
9928     DALI_TEST_CHECK(true); // We expect an assert
9929   }
9930   END_TEST;
9931 }
9932
9933 int UtcDaliActorRemoveNegative(void)
9934 {
9935   TestApplication application;
9936   Dali::Actor     instance;
9937   try
9938   {
9939     Dali::Actor arg1;
9940     instance.Remove(arg1);
9941     DALI_TEST_CHECK(false); // Should not get here
9942   }
9943   catch(...)
9944   {
9945     DALI_TEST_CHECK(true); // We expect an assert
9946   }
9947   END_TEST;
9948 }
9949
9950 int UtcDaliActorScaleByNegative(void)
9951 {
9952   TestApplication application;
9953   Dali::Actor     instance;
9954   try
9955   {
9956     Dali::Vector3 arg1;
9957     instance.ScaleBy(arg1);
9958     DALI_TEST_CHECK(false); // Should not get here
9959   }
9960   catch(...)
9961   {
9962     DALI_TEST_CHECK(true); // We expect an assert
9963   }
9964   END_TEST;
9965 }
9966
9967 int UtcDaliActorGetLayerNegative(void)
9968 {
9969   TestApplication application;
9970   Dali::Actor     instance;
9971   try
9972   {
9973     instance.GetLayer();
9974     DALI_TEST_CHECK(false); // Should not get here
9975   }
9976   catch(...)
9977   {
9978     DALI_TEST_CHECK(true); // We expect an assert
9979   }
9980   END_TEST;
9981 }
9982
9983 int UtcDaliActorRotateByNegative01(void)
9984 {
9985   TestApplication application;
9986   Dali::Actor     instance;
9987   try
9988   {
9989     Dali::Quaternion arg1;
9990     instance.RotateBy(arg1);
9991     DALI_TEST_CHECK(false); // Should not get here
9992   }
9993   catch(...)
9994   {
9995     DALI_TEST_CHECK(true); // We expect an assert
9996   }
9997   END_TEST;
9998 }
9999
10000 int UtcDaliActorRotateByNegative02(void)
10001 {
10002   TestApplication application;
10003   Dali::Actor     instance;
10004   try
10005   {
10006     Dali::Radian  arg1;
10007     Dali::Vector3 arg2;
10008     instance.RotateBy(arg1, arg2);
10009     DALI_TEST_CHECK(false); // Should not get here
10010   }
10011   catch(...)
10012   {
10013     DALI_TEST_CHECK(true); // We expect an assert
10014   }
10015   END_TEST;
10016 }
10017
10018 int UtcDaliActorUnparentNegative(void)
10019 {
10020   TestApplication application;
10021   Dali::Actor     instance;
10022   try
10023   {
10024     instance.Unparent();
10025     DALI_TEST_CHECK(false); // Should not get here
10026   }
10027   catch(...)
10028   {
10029     DALI_TEST_CHECK(true); // We expect an assert
10030   }
10031   END_TEST;
10032 }
10033
10034 int UtcDaliActorGetChildAtNegative(void)
10035 {
10036   TestApplication application;
10037   Dali::Actor     instance;
10038   try
10039   {
10040     unsigned int arg1 = 0u;
10041     instance.GetChildAt(arg1);
10042     DALI_TEST_CHECK(false); // Should not get here
10043   }
10044   catch(...)
10045   {
10046     DALI_TEST_CHECK(true); // We expect an assert
10047   }
10048   END_TEST;
10049 }
10050
10051 int UtcDaliActorGetChildCountNegative(void)
10052 {
10053   TestApplication application;
10054   Dali::Actor     instance;
10055   try
10056   {
10057     instance.GetChildCount();
10058     DALI_TEST_CHECK(false); // Should not get here
10059   }
10060   catch(...)
10061   {
10062     DALI_TEST_CHECK(true); // We expect an assert
10063   }
10064   END_TEST;
10065 }
10066
10067 int UtcDaliActorGetTargetSizeNegative(void)
10068 {
10069   TestApplication application;
10070   Dali::Actor     instance;
10071   try
10072   {
10073     instance.GetTargetSize();
10074     DALI_TEST_CHECK(false); // Should not get here
10075   }
10076   catch(...)
10077   {
10078     DALI_TEST_CHECK(true); // We expect an assert
10079   }
10080   END_TEST;
10081 }
10082
10083 int UtcDaliActorScreenToLocalNegative(void)
10084 {
10085   TestApplication application;
10086   Dali::Actor     instance;
10087   try
10088   {
10089     float arg1 = 0.0f;
10090     float arg2 = 0.0f;
10091     float arg3 = 0.0f;
10092     float arg4 = 0.0f;
10093     instance.ScreenToLocal(arg1, arg2, arg3, arg4);
10094     DALI_TEST_CHECK(false); // Should not get here
10095   }
10096   catch(...)
10097   {
10098     DALI_TEST_CHECK(true); // We expect an assert
10099   }
10100   END_TEST;
10101 }
10102
10103 int UtcDaliActorGetNaturalSizeNegative(void)
10104 {
10105   TestApplication application;
10106   Dali::Actor     instance;
10107   try
10108   {
10109     instance.GetNaturalSize();
10110     DALI_TEST_CHECK(false); // Should not get here
10111   }
10112   catch(...)
10113   {
10114     DALI_TEST_CHECK(true); // We expect an assert
10115   }
10116   END_TEST;
10117 }
10118
10119 int UtcDaliActorGetRelayoutSizeNegative(void)
10120 {
10121   TestApplication application;
10122   Dali::Actor     instance;
10123   try
10124   {
10125     Dali::Dimension::Type arg1 = Dimension::HEIGHT;
10126     instance.GetRelayoutSize(arg1);
10127     DALI_TEST_CHECK(false); // Should not get here
10128   }
10129   catch(...)
10130   {
10131     DALI_TEST_CHECK(true); // We expect an assert
10132   }
10133   END_TEST;
10134 }
10135
10136 int UtcDaliActorGetResizePolicyNegative(void)
10137 {
10138   TestApplication application;
10139   Dali::Actor     instance;
10140   try
10141   {
10142     Dali::Dimension::Type arg1 = Dimension::ALL_DIMENSIONS;
10143     instance.GetResizePolicy(arg1);
10144     DALI_TEST_CHECK(false); // Should not get here
10145   }
10146   catch(...)
10147   {
10148     DALI_TEST_CHECK(true); // We expect an assert
10149   }
10150   END_TEST;
10151 }
10152
10153 int UtcDaliActorGetRendererCountNegative(void)
10154 {
10155   TestApplication application;
10156   Dali::Actor     instance;
10157   try
10158   {
10159     instance.GetRendererCount();
10160     DALI_TEST_CHECK(false); // Should not get here
10161   }
10162   catch(...)
10163   {
10164     DALI_TEST_CHECK(true); // We expect an assert
10165   }
10166   END_TEST;
10167 }
10168
10169 int UtcDaliActorGetParentNegative(void)
10170 {
10171   TestApplication application;
10172   Dali::Actor     instance;
10173   try
10174   {
10175     instance.GetParent();
10176     DALI_TEST_CHECK(false); // Should not get here
10177   }
10178   catch(...)
10179   {
10180     DALI_TEST_CHECK(true); // We expect an assert
10181   }
10182   END_TEST;
10183 }
10184
10185 int UtcDaliActorPropertyBlendEquation(void)
10186 {
10187   TestApplication application;
10188
10189   tet_infoline("Test SetProperty AdvancedBlendEquation");
10190
10191   Geometry geometry  = CreateQuadGeometry();
10192   Shader   shader    = CreateShader();
10193   Renderer renderer1 = Renderer::New(geometry, shader);
10194
10195   Actor actor = Actor::New();
10196   actor.SetProperty(Actor::Property::OPACITY, 0.1f);
10197
10198   actor.AddRenderer(renderer1);
10199   actor.SetProperty(Actor::Property::SIZE, Vector2(400, 400));
10200   application.GetScene().Add(actor);
10201
10202   if(!Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
10203   {
10204     actor.SetProperty(Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN);
10205     int equation = actor.GetProperty<int>(Dali::DevelActor::Property::BLEND_EQUATION);
10206     DALI_TEST_EQUALS((Dali::DevelBlendEquation::SCREEN == equation), false, TEST_LOCATION);
10207   }
10208
10209   if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
10210   {
10211     actor.SetProperty(Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN);
10212     int equation = actor.GetProperty<int>(Dali::DevelActor::Property::BLEND_EQUATION);
10213     DALI_TEST_EQUALS((Dali::DevelBlendEquation::SCREEN == equation), true, TEST_LOCATION);
10214   }
10215
10216   Renderer renderer2 = Renderer::New(geometry, shader);
10217   actor.AddRenderer(renderer2);
10218
10219   END_TEST;
10220 }
10221
10222 int UtcDaliActorRegisterProperty(void)
10223 {
10224   tet_infoline("Test property registration and uniform map update\n");
10225
10226   TestApplication application;
10227
10228   Geometry geometry  = CreateQuadGeometry();
10229   Shader   shader    = CreateShader();
10230   Renderer renderer1 = Renderer::New(geometry, shader);
10231   Renderer renderer2 = Renderer::New(geometry, shader);
10232
10233   Actor actor1 = Actor::New();
10234   actor1.AddRenderer(renderer1);
10235   actor1.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
10236   actor1.RegisterProperty("uCustom", 1);
10237   application.GetScene().Add(actor1);
10238
10239   Actor actor2 = Actor::New();
10240   actor2.AddRenderer(renderer2);
10241   actor2.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
10242   application.GetScene().Add(actor2);
10243
10244   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
10245   TraceCallStack&    callStack     = glAbstraction.GetSetUniformTrace();
10246   glAbstraction.EnableSetUniformCallTrace(true);
10247
10248   application.SendNotification();
10249   application.Render();
10250
10251   std::stringstream out;
10252   out.str("1");
10253   std::string params;
10254
10255   // Test uniform value of the custom property
10256   DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("uCustom", params));
10257   DALI_TEST_EQUALS(out.str(), params, TEST_LOCATION);
10258
10259   // Make invisible
10260   actor1[Actor::Property::VISIBLE] = false;
10261
10262   application.SendNotification();
10263   application.Render();
10264
10265   // Make visible again
10266   actor1[Actor::Property::VISIBLE] = true;
10267   actor1["uCustom"]                = 2;
10268
10269   glAbstraction.ResetSetUniformCallStack();
10270
10271   application.SendNotification();
10272   application.Render();
10273
10274   out.str("2");
10275
10276   // The uniform value should not be changed
10277   DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("uCustom", params));
10278   DALI_TEST_EQUALS(out.str(), params, TEST_LOCATION);
10279
10280   END_TEST;
10281 }