Add UserInteractionEnabled property on actor for controlling user interaction.
[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 UtcDaliActorSetUserInteractionEnabled(void)
2602 {
2603   TestApplication application;
2604   Actor           actor = Actor::New();
2605
2606   bool enabled = !actor.GetProperty<bool>(DevelActor::Property::USER_INTERACTION_ENABLED);
2607
2608   actor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, enabled);
2609
2610   DALI_TEST_CHECK(enabled == actor.GetProperty<bool>(DevelActor::Property::USER_INTERACTION_ENABLED));
2611   END_TEST;
2612 }
2613
2614 int UtcDaliActorIsUserInteractionEnabled(void)
2615 {
2616   TestApplication application;
2617   Actor           actor = Actor::New();
2618   actor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, true);
2619
2620   DALI_TEST_CHECK(true == actor.GetProperty<bool>(DevelActor::Property::USER_INTERACTION_ENABLED));
2621   END_TEST;
2622 }
2623
2624 int UtcDaliActorRemoveConstraints(void)
2625 {
2626   tet_infoline(" UtcDaliActorRemoveConstraints");
2627   TestApplication application;
2628
2629   gTestConstraintCalled = false;
2630
2631   Actor actor = Actor::New();
2632
2633   Constraint constraint = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraint());
2634   constraint.Apply();
2635   actor.RemoveConstraints();
2636
2637   DALI_TEST_CHECK(gTestConstraintCalled == false);
2638
2639   application.GetScene().Add(actor);
2640   constraint.Apply();
2641
2642   // flush the queue and render once
2643   application.SendNotification();
2644   application.Render();
2645
2646   actor.RemoveConstraints();
2647
2648   DALI_TEST_CHECK(gTestConstraintCalled == true);
2649   END_TEST;
2650 }
2651
2652 int UtcDaliActorRemoveConstraintTag(void)
2653 {
2654   tet_infoline(" UtcDaliActorRemoveConstraintTag");
2655   TestApplication application;
2656
2657   Actor actor = Actor::New();
2658
2659   // 1. Apply Constraint1 and Constraint2, and test...
2660   unsigned int result1 = 0u;
2661   unsigned int result2 = 0u;
2662
2663   unsigned   constraint1Tag = 1u;
2664   Constraint constraint1    = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1));
2665   constraint1.SetTag(constraint1Tag);
2666   constraint1.Apply();
2667
2668   unsigned   constraint2Tag = 2u;
2669   Constraint constraint2    = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2));
2670   constraint2.SetTag(constraint2Tag);
2671   constraint2.Apply();
2672
2673   application.GetScene().Add(actor);
2674   // flush the queue and render once
2675   application.SendNotification();
2676   application.Render();
2677
2678   DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
2679   DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
2680
2681   // 2. Remove Constraint1 and test...
2682   result1 = 0;
2683   result2 = 0;
2684   actor.RemoveConstraints(constraint1Tag);
2685   // make color property dirty, which will trigger constraints to be reapplied.
2686   actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2687   // flush the queue and render once
2688   application.SendNotification();
2689   application.Render();
2690
2691   DALI_TEST_EQUALS(result1, 0u, TEST_LOCATION); ///< constraint 1 should not apply now.
2692   DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
2693
2694   // 3. Re-Apply Constraint1 and test...
2695   result1 = 0;
2696   result2 = 0;
2697   constraint1.Apply();
2698   // make color property dirty, which will trigger constraints to be reapplied.
2699   actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2700   // flush the queue and render once
2701   application.SendNotification();
2702   application.Render();
2703
2704   DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
2705   DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
2706
2707   // 2. Remove Constraint2 and test...
2708   result1 = 0;
2709   result2 = 0;
2710   actor.RemoveConstraints(constraint2Tag);
2711   // make color property dirty, which will trigger constraints to be reapplied.
2712   actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2713   // flush the queue and render once
2714   application.SendNotification();
2715   application.Render();
2716
2717   DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
2718   DALI_TEST_EQUALS(result2, 0u, TEST_LOCATION); ///< constraint 2 should not apply now.
2719
2720   // 2. Remove Constraint1 as well and test...
2721   result1 = 0;
2722   result2 = 0;
2723   actor.RemoveConstraints(constraint1Tag);
2724   // make color property dirty, which will trigger constraints to be reapplied.
2725   actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2726   // flush the queue and render once
2727   application.SendNotification();
2728   application.Render();
2729
2730   DALI_TEST_EQUALS(result1, 0u, TEST_LOCATION); ///< constraint 1 should not apply now.
2731   DALI_TEST_EQUALS(result2, 0u, TEST_LOCATION); ///< constraint 2 should not apply now.
2732   END_TEST;
2733 }
2734
2735 int UtcDaliActorTouchedSignal(void)
2736 {
2737   TestApplication application;
2738
2739   ResetTouchCallbacks();
2740
2741   // get the root layer
2742   Actor actor = application.GetScene().GetRootLayer();
2743   DALI_TEST_CHECK(gTouchCallBackCalled == false);
2744
2745   application.SendNotification();
2746   application.Render();
2747
2748   // connect to its touch signal
2749   actor.TouchedSignal().Connect(TestTouchCallback);
2750
2751   // simulate a touch event in the middle of the screen
2752   Vector2                  touchPoint(application.GetScene().GetSize() * 0.5);
2753   Dali::Integration::Point point;
2754   point.SetDeviceId(1);
2755   point.SetState(PointState::DOWN);
2756   point.SetScreenPosition(Vector2(touchPoint.x, touchPoint.y));
2757   Dali::Integration::TouchEvent touchEvent;
2758   touchEvent.AddPoint(point);
2759   application.ProcessEvent(touchEvent);
2760
2761   DALI_TEST_CHECK(gTouchCallBackCalled == true);
2762   END_TEST;
2763 }
2764
2765 int UtcDaliActorHoveredSignal(void)
2766 {
2767   TestApplication application;
2768
2769   gHoverCallBackCalled = false;
2770
2771   // get the root layer
2772   Actor actor = application.GetScene().GetRootLayer();
2773   DALI_TEST_CHECK(gHoverCallBackCalled == false);
2774
2775   application.SendNotification();
2776   application.Render();
2777
2778   // connect to its hover signal
2779   actor.HoveredSignal().Connect(TestCallback3);
2780
2781   // simulate a hover event in the middle of the screen
2782   Vector2                  touchPoint(application.GetScene().GetSize() * 0.5);
2783   Dali::Integration::Point point;
2784   point.SetDeviceId(1);
2785   point.SetState(PointState::MOTION);
2786   point.SetScreenPosition(Vector2(touchPoint.x, touchPoint.y));
2787   Dali::Integration::HoverEvent hoverEvent;
2788   hoverEvent.AddPoint(point);
2789   application.ProcessEvent(hoverEvent);
2790
2791   DALI_TEST_CHECK(gHoverCallBackCalled == true);
2792   END_TEST;
2793 }
2794
2795 int UtcDaliActorOnOffSceneSignal(void)
2796 {
2797   tet_infoline("Testing Dali::Actor::OnSceneSignal() and OffSceneSignal()");
2798
2799   TestApplication application;
2800
2801   // clean test data
2802   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2803   gActorNamesOnOffScene.clear();
2804
2805   Actor parent = Actor::New();
2806   parent.SetProperty(Actor::Property::NAME, "parent");
2807   parent.OnSceneSignal().Connect(OnSceneCallback);
2808   parent.OffSceneSignal().Connect(OffSceneCallback);
2809   // sanity check
2810   DALI_TEST_CHECK(gOnSceneCallBackCalled == 0);
2811   DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
2812
2813   // add parent to the scene
2814   application.GetScene().Add(parent);
2815   // onstage emitted, offstage not
2816   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 1, TEST_LOCATION);
2817   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
2818   DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
2819
2820   // test adding a child, should get onstage emitted
2821   // clean test data
2822   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2823   gActorNamesOnOffScene.clear();
2824
2825   Actor child = Actor::New();
2826   child.SetProperty(Actor::Property::NAME, "child");
2827   child.OnSceneSignal().Connect(OnSceneCallback);
2828   child.OffSceneSignal().Connect(OffSceneCallback);
2829   parent.Add(child); // add child
2830   // onscene emitted, offscene not
2831   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 1, TEST_LOCATION);
2832   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
2833   DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
2834
2835   // test removing parent from the scene
2836   // clean test data
2837   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2838   gActorNamesOnOffScene.clear();
2839
2840   application.GetScene().Remove(parent);
2841   // onscene not emitted, offscene is
2842   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
2843   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 2, TEST_LOCATION);
2844   DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
2845   DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[1], TEST_LOCATION);
2846
2847   // test adding parent back to the scene
2848   // clean test data
2849   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2850   gActorNamesOnOffScene.clear();
2851
2852   application.GetScene().Add(parent);
2853   // onscene emitted, offscene not
2854   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 2, TEST_LOCATION);
2855   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
2856   DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
2857   DALI_TEST_EQUALS("child", gActorNamesOnOffScene[1], TEST_LOCATION);
2858
2859   // test removing child
2860   // clean test data
2861   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2862   gActorNamesOnOffScene.clear();
2863
2864   parent.Remove(child);
2865   // onscene not emitted, offscene is
2866   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
2867   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 1, TEST_LOCATION);
2868   DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
2869
2870   // test removing parent
2871   // clean test data
2872   gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2873   gActorNamesOnOffScene.clear();
2874
2875   application.GetScene().Remove(parent);
2876   // onscene not emitted, offscene is
2877   DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
2878   DALI_TEST_EQUALS(gOffSceneCallBackCalled, 1, TEST_LOCATION);
2879   DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
2880   END_TEST;
2881 }
2882
2883 int UtcDaliActorFindChildByName(void)
2884 {
2885   tet_infoline("Testing Dali::Actor::FindChildByName()");
2886   TestApplication application;
2887
2888   Actor parent = Actor::New();
2889   parent.SetProperty(Actor::Property::NAME, "parent");
2890   Actor first = Actor::New();
2891   first.SetProperty(Actor::Property::NAME, "first");
2892   Actor second = Actor::New();
2893   second.SetProperty(Actor::Property::NAME, "second");
2894
2895   parent.Add(first);
2896   first.Add(second);
2897
2898   Actor found = parent.FindChildByName("foo");
2899   DALI_TEST_CHECK(!found);
2900
2901   found = parent.FindChildByName("parent");
2902   DALI_TEST_CHECK(found == parent);
2903
2904   found = parent.FindChildByName("first");
2905   DALI_TEST_CHECK(found == first);
2906
2907   found = parent.FindChildByName("second");
2908   DALI_TEST_CHECK(found == second);
2909   END_TEST;
2910 }
2911
2912 int UtcDaliActorFindChildById(void)
2913 {
2914   tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2915   TestApplication application;
2916
2917   Actor parent = Actor::New();
2918   Actor first  = Actor::New();
2919   Actor second = Actor::New();
2920
2921   parent.Add(first);
2922   first.Add(second);
2923
2924   Actor found = parent.FindChildById(100000);
2925   DALI_TEST_CHECK(!found);
2926
2927   found = parent.FindChildById(parent.GetProperty<int>(Actor::Property::ID));
2928   DALI_TEST_CHECK(found == parent);
2929
2930   found = parent.FindChildById(first.GetProperty<int>(Actor::Property::ID));
2931   DALI_TEST_CHECK(found == first);
2932
2933   found = parent.FindChildById(second.GetProperty<int>(Actor::Property::ID));
2934   DALI_TEST_CHECK(found == second);
2935   END_TEST;
2936 }
2937
2938 int UtcDaliActorHitTest(void)
2939 {
2940   struct HitTestData
2941   {
2942   public:
2943     HitTestData(const Vector3& scale, const Vector2& touchPoint, bool result)
2944     : mScale(scale),
2945       mTouchPoint(touchPoint),
2946       mResult(result)
2947     {
2948     }
2949
2950     Vector3 mScale;
2951     Vector2 mTouchPoint;
2952     bool    mResult;
2953   };
2954
2955   TestApplication application;
2956   tet_infoline(" UtcDaliActorHitTest");
2957
2958   // Fill a vector with different hit tests.
2959   struct HitTestData* hitTestData[] = {
2960     //                    scale                     touch point           result
2961     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(289.f, 400.f), true),  // touch point close to the right edge (inside)
2962     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(291.f, 400.f), false), // touch point close to the right edge (outside)
2963     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.
2964     new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(200.f, 451.f), false), // touch point close to the down edge (outside)
2965     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.
2966     NULL,
2967   };
2968
2969   // get the root layer
2970   Actor actor = Actor::New();
2971   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
2972   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
2973
2974   application.GetScene().Add(actor);
2975
2976   ResetTouchCallbacks();
2977
2978   unsigned int index = 0;
2979   while(NULL != hitTestData[index])
2980   {
2981     actor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f));
2982     actor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z));
2983
2984     // flush the queue and render once
2985     application.SendNotification();
2986     application.Render();
2987
2988     DALI_TEST_CHECK(!gTouchCallBackCalled);
2989
2990     // connect to its touch signal
2991     actor.TouchedSignal().Connect(TestTouchCallback);
2992
2993     Dali::Integration::Point point;
2994     point.SetState(PointState::DOWN);
2995     point.SetScreenPosition(Vector2(hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y));
2996     Dali::Integration::TouchEvent event;
2997     event.AddPoint(point);
2998
2999     // flush the queue and render once
3000     application.SendNotification();
3001     application.Render();
3002     application.ProcessEvent(event);
3003
3004     DALI_TEST_CHECK(gTouchCallBackCalled == hitTestData[index]->mResult);
3005
3006     if(gTouchCallBackCalled != hitTestData[index]->mResult)
3007       tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
3008                  hitTestData[index]->mScale.x,
3009                  hitTestData[index]->mScale.y,
3010                  hitTestData[index]->mScale.z,
3011                  hitTestData[index]->mTouchPoint.x,
3012                  hitTestData[index]->mTouchPoint.y,
3013                  hitTestData[index]->mResult);
3014
3015     ResetTouchCallbacks();
3016     ++index;
3017   }
3018   END_TEST;
3019 }
3020
3021 int UtcDaliActorSetDrawMode(void)
3022 {
3023   TestApplication application;
3024   tet_infoline(" UtcDaliActorSetDrawModeOverlay");
3025
3026   Actor a = Actor::New();
3027
3028   application.GetScene().Add(a);
3029   application.SendNotification();
3030   application.Render(0);
3031   application.SendNotification();
3032   application.Render(1);
3033
3034   DALI_TEST_CHECK(DrawMode::NORMAL == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Ensure overlay is off by default
3035
3036   a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3037   application.SendNotification();
3038   application.Render(1);
3039
3040   DALI_TEST_CHECK(DrawMode::OVERLAY_2D == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Check Actor is overlay
3041
3042   a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::NORMAL);
3043   application.SendNotification();
3044   application.Render(1);
3045
3046   DALI_TEST_CHECK(DrawMode::NORMAL == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Check Actor is normal
3047   END_TEST;
3048 }
3049
3050 int UtcDaliActorSetDrawModeOverlayRender(void)
3051 {
3052   TestApplication application;
3053   tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
3054
3055   application.SendNotification();
3056   application.Render(1);
3057
3058   std::vector<GLuint> ids;
3059   ids.push_back(8);  // first rendered actor
3060   ids.push_back(9);  // second rendered actor
3061   ids.push_back(10); // third rendered actor
3062   application.GetGlAbstraction().SetNextTextureIds(ids);
3063
3064   Texture imageA = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
3065   Texture imageB = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
3066   Texture imageC = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
3067   Actor   a      = CreateRenderableActor(imageA);
3068   Actor   b      = CreateRenderableActor(imageB);
3069   Actor   c      = CreateRenderableActor(imageC);
3070
3071   application.SendNotification();
3072   application.Render(1);
3073
3074   //Textures are bound when first created. Clear bound textures vector
3075   application.GetGlAbstraction().ClearBoundTextures();
3076
3077   // Render a,b,c as regular non-overlays. so order will be:
3078   // a (8)
3079   // b (9)
3080   // c (10)
3081   application.GetScene().Add(a);
3082   application.GetScene().Add(b);
3083   application.GetScene().Add(c);
3084
3085   application.SendNotification();
3086   application.Render(1);
3087
3088   // Should be 3 textures changes.
3089   const std::vector<GLuint>&             boundTextures = application.GetGlAbstraction().GetBoundTextures(GL_TEXTURE0);
3090   typedef std::vector<GLuint>::size_type TextureSize;
3091   DALI_TEST_EQUALS(boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION);
3092   if(boundTextures.size() == 3)
3093   {
3094     DALI_TEST_CHECK(boundTextures[0] == 8u);
3095     DALI_TEST_CHECK(boundTextures[1] == 9u);
3096     DALI_TEST_CHECK(boundTextures[2] == 10u);
3097   }
3098
3099   // Now texture ids have been set, we can monitor their render order.
3100   // render a as an overlay (last), so order will be:
3101   // b (9)
3102   // c (10)
3103   // a (8)
3104   a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3105   application.GetGlAbstraction().ClearBoundTextures();
3106
3107   application.SendNotification();
3108   application.Render(1);
3109
3110   // Should be 3 texture changes.
3111   DALI_TEST_EQUALS(boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION);
3112   if(boundTextures.size() == 3)
3113   {
3114     DALI_TEST_CHECK(boundTextures[0] == 9u);
3115     DALI_TEST_CHECK(boundTextures[1] == 10u);
3116     DALI_TEST_CHECK(boundTextures[2] == 8u);
3117   }
3118   END_TEST;
3119 }
3120
3121 int UtcDaliActorGetCurrentWorldMatrix(void)
3122 {
3123   TestApplication application;
3124   tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
3125
3126   Actor parent = Actor::New();
3127   parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3128   parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3129   Vector3    parentPosition(10.0f, 20.0f, 30.0f);
3130   Radian     rotationAngle(Degree(85.0f));
3131   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3132   Vector3    parentScale(1.0f, 2.0f, 3.0f);
3133   parent.SetProperty(Actor::Property::POSITION, parentPosition);
3134   parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3135   parent.SetProperty(Actor::Property::SCALE, parentScale);
3136   application.GetScene().Add(parent);
3137
3138   Actor child = Actor::New();
3139   child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3140   Vector3    childPosition(0.0f, 0.0f, 100.0f);
3141   Radian     childRotationAngle(Degree(23.0f));
3142   Quaternion childRotation(childRotationAngle, Vector3::YAXIS);
3143   Vector3    childScale(2.0f, 2.0f, 2.0f);
3144   child.SetProperty(Actor::Property::POSITION, childPosition);
3145   child.SetProperty(Actor::Property::ORIENTATION, childRotation);
3146   child.SetProperty(Actor::Property::SCALE, childScale);
3147   parent.Add(child);
3148
3149   application.SendNotification();
3150   application.Render(0);
3151   application.Render();
3152   application.SendNotification();
3153
3154   Matrix parentMatrix(false);
3155   parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3156
3157   Matrix childMatrix(false);
3158   childMatrix.SetTransformComponents(childScale, childRotation, childPosition);
3159
3160   //Child matrix should be the composition of child and parent
3161   Matrix childWorldMatrix(false);
3162   Matrix::Multiply(childWorldMatrix, childMatrix, parentMatrix);
3163
3164   DALI_TEST_EQUALS(parent.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), parentMatrix, 0.001, TEST_LOCATION);
3165   DALI_TEST_EQUALS(child.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), childWorldMatrix, 0.001, TEST_LOCATION);
3166   END_TEST;
3167 }
3168
3169 int UtcDaliActorConstrainedToWorldMatrix(void)
3170 {
3171   TestApplication application;
3172   tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
3173
3174   Actor parent = Actor::New();
3175   parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3176   parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3177   Vector3    parentPosition(10.0f, 20.0f, 30.0f);
3178   Radian     rotationAngle(Degree(85.0f));
3179   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3180   Vector3    parentScale(1.0f, 2.0f, 3.0f);
3181   parent.SetProperty(Actor::Property::POSITION, parentPosition);
3182   parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3183   parent.SetProperty(Actor::Property::SCALE, parentScale);
3184   application.GetScene().Add(parent);
3185
3186   Actor child = Actor::New();
3187   child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3188   Constraint posConstraint = Constraint::New<Vector3>(child, Actor::Property::POSITION, PositionComponentConstraint());
3189   posConstraint.AddSource(Source(parent, Actor::Property::WORLD_MATRIX));
3190   posConstraint.Apply();
3191
3192   application.GetScene().Add(child);
3193
3194   application.SendNotification();
3195   application.Render(0);
3196   application.Render();
3197   application.SendNotification();
3198
3199   Matrix parentMatrix(false);
3200   parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3201
3202   DALI_TEST_EQUALS(parent.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), parentMatrix, 0.001, TEST_LOCATION);
3203   DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), 0.001, TEST_LOCATION);
3204   END_TEST;
3205 }
3206
3207 int UtcDaliActorConstrainedToOrientation(void)
3208 {
3209   TestApplication application;
3210   tet_infoline(" UtcDaliActorConstrainedToOrientation");
3211
3212   Actor parent = Actor::New();
3213   parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3214   parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3215   Vector3    parentPosition(10.0f, 20.0f, 30.0f);
3216   Radian     rotationAngle(Degree(85.0f));
3217   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3218   Vector3    parentScale(1.0f, 2.0f, 3.0f);
3219   parent.SetProperty(Actor::Property::POSITION, parentPosition);
3220   parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3221   parent.SetProperty(Actor::Property::SCALE, parentScale);
3222   application.GetScene().Add(parent);
3223
3224   Actor child = Actor::New();
3225   child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3226   Constraint posConstraint = Constraint::New<Quaternion>(child, Actor::Property::ORIENTATION, OrientationComponentConstraint());
3227   posConstraint.AddSource(Source(parent, Actor::Property::ORIENTATION));
3228   posConstraint.Apply();
3229
3230   application.GetScene().Add(child);
3231
3232   application.SendNotification();
3233   application.Render(0);
3234   application.Render();
3235   application.SendNotification();
3236
3237   DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), parent.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
3238   END_TEST;
3239 }
3240
3241 int UtcDaliActorConstrainedToOpacity(void)
3242 {
3243   TestApplication application;
3244   tet_infoline(" UtcDaliActorConstrainedToOpacity");
3245
3246   Actor parent = Actor::New();
3247   parent.SetProperty(Actor::Property::OPACITY, 0.7f);
3248   application.GetScene().Add(parent);
3249
3250   Actor      child             = Actor::New();
3251   Constraint opacityConstraint = Constraint::New<float>(child, Actor::Property::OPACITY, EqualToConstraint());
3252   opacityConstraint.AddSource(Source(parent, Actor::Property::OPACITY));
3253   opacityConstraint.Apply();
3254
3255   application.GetScene().Add(child);
3256
3257   application.SendNotification();
3258   application.Render(0);
3259   application.Render();
3260   application.SendNotification();
3261
3262   DALI_TEST_EQUALS(child.GetCurrentProperty<float>(Actor::Property::OPACITY), parent.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.001f, TEST_LOCATION);
3263
3264   parent.SetProperty(Actor::Property::OPACITY, 0.3f);
3265
3266   application.SendNotification();
3267   application.Render(0);
3268   application.Render();
3269   application.SendNotification();
3270
3271   DALI_TEST_EQUALS(child.GetCurrentProperty<float>(Actor::Property::OPACITY), parent.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.001f, TEST_LOCATION);
3272
3273   END_TEST;
3274 }
3275
3276 int UtcDaliActorUnparent(void)
3277 {
3278   TestApplication application;
3279   tet_infoline(" UtcDaliActorUnparent");
3280
3281   Actor parent = Actor::New();
3282   application.GetScene().Add(parent);
3283
3284   Actor child = Actor::New();
3285
3286   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3287   DALI_TEST_CHECK(!child.GetParent());
3288
3289   // Test that calling Unparent with no parent is a NOOP
3290   child.Unparent();
3291
3292   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3293   DALI_TEST_CHECK(!child.GetParent());
3294
3295   // Test that Unparent works
3296   parent.Add(child);
3297
3298   DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
3299   DALI_TEST_CHECK(parent == child.GetParent());
3300
3301   child.Unparent();
3302
3303   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3304   DALI_TEST_CHECK(!child.GetParent());
3305
3306   // Test that UnparentAndReset works
3307   parent.Add(child);
3308
3309   DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
3310   DALI_TEST_CHECK(parent == child.GetParent());
3311
3312   UnparentAndReset(child);
3313
3314   DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3315   DALI_TEST_CHECK(!child);
3316
3317   // Test that UnparentAndReset is a NOOP with empty handle
3318   UnparentAndReset(child);
3319
3320   DALI_TEST_CHECK(!child);
3321   END_TEST;
3322 }
3323
3324 int UtcDaliActorGetChildAt(void)
3325 {
3326   TestApplication application;
3327   tet_infoline(" UtcDaliActorGetChildAt");
3328
3329   Actor parent = Actor::New();
3330   application.GetScene().Add(parent);
3331
3332   Actor child0 = Actor::New();
3333   parent.Add(child0);
3334
3335   Actor child1 = Actor::New();
3336   parent.Add(child1);
3337
3338   Actor child2 = Actor::New();
3339   parent.Add(child2);
3340
3341   DALI_TEST_EQUALS(parent.GetChildAt(0), child0, TEST_LOCATION);
3342   DALI_TEST_EQUALS(parent.GetChildAt(1), child1, TEST_LOCATION);
3343   DALI_TEST_EQUALS(parent.GetChildAt(2), child2, TEST_LOCATION);
3344   END_TEST;
3345 }
3346
3347 int UtcDaliActorSetGetOverlay(void)
3348 {
3349   TestApplication application;
3350   tet_infoline(" UtcDaliActorSetGetOverlay");
3351
3352   Actor parent = Actor::New();
3353   parent.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3354   DALI_TEST_CHECK(parent.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE) == DrawMode::OVERLAY_2D);
3355   END_TEST;
3356 }
3357
3358 int UtcDaliActorCreateDestroy(void)
3359 {
3360   Actor* actor = new Actor;
3361   DALI_TEST_CHECK(actor);
3362   delete actor;
3363   END_TEST;
3364 }
3365
3366 namespace
3367 {
3368 struct PropertyStringIndex
3369 {
3370   const char* const     name;
3371   const Property::Index index;
3372   const Property::Type  type;
3373 };
3374
3375 const PropertyStringIndex PROPERTY_TABLE[] =
3376   {
3377     {"parentOrigin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3},
3378     {"parentOriginX", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT},
3379     {"parentOriginY", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT},
3380     {"parentOriginZ", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT},
3381     {"anchorPoint", Actor::Property::ANCHOR_POINT, Property::VECTOR3},
3382     {"anchorPointX", Actor::Property::ANCHOR_POINT_X, Property::FLOAT},
3383     {"anchorPointY", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT},
3384     {"anchorPointZ", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT},
3385     {"size", Actor::Property::SIZE, Property::VECTOR3},
3386     {"sizeWidth", Actor::Property::SIZE_WIDTH, Property::FLOAT},
3387     {"sizeHeight", Actor::Property::SIZE_HEIGHT, Property::FLOAT},
3388     {"sizeDepth", Actor::Property::SIZE_DEPTH, Property::FLOAT},
3389     {"position", Actor::Property::POSITION, Property::VECTOR3},
3390     {"positionX", Actor::Property::POSITION_X, Property::FLOAT},
3391     {"positionY", Actor::Property::POSITION_Y, Property::FLOAT},
3392     {"positionZ", Actor::Property::POSITION_Z, Property::FLOAT},
3393     {"worldPosition", Actor::Property::WORLD_POSITION, Property::VECTOR3},
3394     {"worldPositionX", Actor::Property::WORLD_POSITION_X, Property::FLOAT},
3395     {"worldPositionY", Actor::Property::WORLD_POSITION_Y, Property::FLOAT},
3396     {"worldPositionZ", Actor::Property::WORLD_POSITION_Z, Property::FLOAT},
3397     {"orientation", Actor::Property::ORIENTATION, Property::ROTATION},
3398     {"worldOrientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION},
3399     {"scale", Actor::Property::SCALE, Property::VECTOR3},
3400     {"scaleX", Actor::Property::SCALE_X, Property::FLOAT},
3401     {"scaleY", Actor::Property::SCALE_Y, Property::FLOAT},
3402     {"scaleZ", Actor::Property::SCALE_Z, Property::FLOAT},
3403     {"worldScale", Actor::Property::WORLD_SCALE, Property::VECTOR3},
3404     {"visible", Actor::Property::VISIBLE, Property::BOOLEAN},
3405     {"color", Actor::Property::COLOR, Property::VECTOR4},
3406     {"colorRed", Actor::Property::COLOR_RED, Property::FLOAT},
3407     {"colorGreen", Actor::Property::COLOR_GREEN, Property::FLOAT},
3408     {"colorBlue", Actor::Property::COLOR_BLUE, Property::FLOAT},
3409     {"colorAlpha", Actor::Property::COLOR_ALPHA, Property::FLOAT},
3410     {"worldColor", Actor::Property::WORLD_COLOR, Property::VECTOR4},
3411     {"worldMatrix", Actor::Property::WORLD_MATRIX, Property::MATRIX},
3412     {"name", Actor::Property::NAME, Property::STRING},
3413     {"sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN},
3414     {"leaveRequired", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN},
3415     {"inheritOrientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN},
3416     {"inheritScale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN},
3417     {"colorMode", Actor::Property::COLOR_MODE, Property::INTEGER},
3418     {"drawMode", Actor::Property::DRAW_MODE, Property::INTEGER},
3419     {"sizeModeFactor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3},
3420     {"widthResizePolicy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING},
3421     {"heightResizePolicy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING},
3422     {"sizeScalePolicy", Actor::Property::SIZE_SCALE_POLICY, Property::INTEGER},
3423     {"widthForHeight", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN},
3424     {"heightForWidth", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN},
3425     {"padding", Actor::Property::PADDING, Property::VECTOR4},
3426     {"minimumSize", Actor::Property::MINIMUM_SIZE, Property::VECTOR2},
3427     {"maximumSize", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2},
3428     {"inheritPosition", Actor::Property::INHERIT_POSITION, Property::BOOLEAN},
3429     {"clippingMode", Actor::Property::CLIPPING_MODE, Property::STRING},
3430     {"opacity", Actor::Property::OPACITY, Property::FLOAT},
3431 };
3432 const unsigned int PROPERTY_TABLE_COUNT = sizeof(PROPERTY_TABLE) / sizeof(PROPERTY_TABLE[0]);
3433 } // unnamed namespace
3434
3435 int UtcDaliActorProperties(void)
3436 {
3437   TestApplication application;
3438
3439   Actor actor = Actor::New();
3440
3441   for(unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i)
3442   {
3443     tet_printf("Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index);
3444     DALI_TEST_EQUALS(actor.GetPropertyName(PROPERTY_TABLE[i].index), PROPERTY_TABLE[i].name, TEST_LOCATION);
3445     DALI_TEST_EQUALS(actor.GetPropertyIndex(PROPERTY_TABLE[i].name), PROPERTY_TABLE[i].index, TEST_LOCATION);
3446     DALI_TEST_EQUALS(actor.GetPropertyType(PROPERTY_TABLE[i].index), PROPERTY_TABLE[i].type, TEST_LOCATION);
3447   }
3448   END_TEST;
3449 }
3450
3451 int UtcDaliRelayoutProperties_ResizePolicies(void)
3452 {
3453   TestApplication application;
3454
3455   Actor actor = Actor::New();
3456
3457   // Defaults
3458   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_RESIZE_POLICY).Get<std::string>(), "USE_NATURAL_SIZE", TEST_LOCATION);
3459   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_RESIZE_POLICY).Get<std::string>(), "USE_NATURAL_SIZE", TEST_LOCATION);
3460
3461   // Set resize policy for all dimensions
3462   actor.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
3463   for(unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
3464   {
3465     DALI_TEST_EQUALS(actor.GetResizePolicy(static_cast<Dimension::Type>(1 << i)), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION);
3466   }
3467
3468   // Set individual dimensions
3469   const char* const widthPolicy  = "FILL_TO_PARENT";
3470   const char* const heightPolicy = "FIXED";
3471
3472   actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy);
3473   actor.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy);
3474
3475   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_RESIZE_POLICY).Get<std::string>(), widthPolicy, TEST_LOCATION);
3476   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_RESIZE_POLICY).Get<std::string>(), heightPolicy, TEST_LOCATION);
3477
3478   // Set individual dimensions using enums
3479   ResizePolicy::Type widthPolicyEnum  = ResizePolicy::USE_ASSIGNED_SIZE;
3480   ResizePolicy::Type heightPolicyEnum = ResizePolicy::SIZE_RELATIVE_TO_PARENT;
3481
3482   actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, widthPolicyEnum);
3483   actor.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicyEnum);
3484
3485   DALI_TEST_EQUALS(static_cast<int>(actor.GetResizePolicy(Dimension::WIDTH)), static_cast<int>(widthPolicyEnum), TEST_LOCATION);
3486   DALI_TEST_EQUALS(static_cast<int>(actor.GetResizePolicy(Dimension::HEIGHT)), static_cast<int>(heightPolicyEnum), TEST_LOCATION);
3487
3488   END_TEST;
3489 }
3490
3491 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
3492 {
3493   TestApplication application;
3494
3495   Actor actor = Actor::New();
3496
3497   // Defaults
3498   DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION);
3499
3500   SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3501   actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy);
3502   DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy, TEST_LOCATION);
3503
3504   // Set
3505   const SizeScalePolicy::Type policy1 = SizeScalePolicy::FIT_WITH_ASPECT_RATIO;
3506   const SizeScalePolicy::Type policy2 = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3507
3508   actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy1);
3509   DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy1, TEST_LOCATION);
3510
3511   actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy2);
3512   DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy2, TEST_LOCATION);
3513
3514   END_TEST;
3515 }
3516
3517 int UtcDaliRelayoutProperties_SizeModeFactor(void)
3518 {
3519   TestApplication application;
3520
3521   Actor actor = Actor::New();
3522
3523   // Defaults
3524   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_MODE_FACTOR).Get<Vector3>(), Vector3(1.0f, 1.0f, 1.0f), TEST_LOCATION);
3525   DALI_TEST_EQUALS(actor.GetProperty<Vector3>(Actor::Property::SIZE_MODE_FACTOR), Vector3(1.0f, 1.0f, 1.0f), TEST_LOCATION);
3526
3527   Vector3 sizeMode(1.0f, 2.0f, 3.0f);
3528   actor.SetProperty(Actor::Property::SIZE_MODE_FACTOR, sizeMode);
3529   DALI_TEST_EQUALS(actor.GetProperty<Vector3>(Actor::Property::SIZE_MODE_FACTOR), sizeMode, TEST_LOCATION);
3530
3531   // Set
3532   Vector3 sizeMode1(2.0f, 3.0f, 4.0f);
3533
3534   actor.SetProperty(Actor::Property::SIZE_MODE_FACTOR, sizeMode1);
3535   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_MODE_FACTOR).Get<Vector3>(), sizeMode1, TEST_LOCATION);
3536
3537   END_TEST;
3538 }
3539
3540 int UtcDaliRelayoutProperties_DimensionDependency(void)
3541 {
3542   TestApplication application;
3543
3544   Actor actor = Actor::New();
3545
3546   // Defaults
3547   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), false, TEST_LOCATION);
3548   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_FOR_WIDTH).Get<bool>(), false, TEST_LOCATION);
3549
3550   // Set
3551   actor.SetProperty(Actor::Property::WIDTH_FOR_HEIGHT, true);
3552   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), true, TEST_LOCATION);
3553
3554   actor.SetProperty(Actor::Property::HEIGHT_FOR_WIDTH, true);
3555   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_FOR_WIDTH).Get<bool>(), true, TEST_LOCATION);
3556
3557   // Test setting another resize policy
3558   actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FIXED");
3559   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), false, TEST_LOCATION);
3560
3561   END_TEST;
3562 }
3563
3564 int UtcDaliRelayoutProperties_Padding(void)
3565 {
3566   TestApplication application;
3567
3568   Actor actor = Actor::New();
3569
3570   // Data
3571   Vector4 padding(1.0f, 2.0f, 3.0f, 4.0f);
3572
3573   // PADDING
3574   actor.SetProperty(Actor::Property::PADDING, padding);
3575   Vector4 paddingResult = actor.GetProperty(Actor::Property::PADDING).Get<Vector4>();
3576
3577   DALI_TEST_EQUALS(paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION);
3578
3579   END_TEST;
3580 }
3581
3582 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
3583 {
3584   TestApplication application;
3585
3586   Actor actor = Actor::New();
3587
3588   // Data
3589   Vector2 minSize(1.0f, 2.0f);
3590
3591   actor.SetProperty(Actor::Property::MINIMUM_SIZE, minSize);
3592   Vector2 resultMin = actor.GetProperty(Actor::Property::MINIMUM_SIZE).Get<Vector2>();
3593
3594   DALI_TEST_EQUALS(resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
3595
3596   Vector2 maxSize(3.0f, 4.0f);
3597
3598   actor.SetProperty(Actor::Property::MAXIMUM_SIZE, maxSize);
3599   Vector2 resultMax = actor.GetProperty(Actor::Property::MAXIMUM_SIZE).Get<Vector2>();
3600
3601   DALI_TEST_EQUALS(resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
3602
3603   END_TEST;
3604 }
3605
3606 int UtcDaliActorGetHeightForWidth(void)
3607 {
3608   TestApplication application;
3609
3610   Actor actor = Actor::New();
3611
3612   DALI_TEST_EQUALS(actor.GetHeightForWidth(1.0f), 1.0f, TEST_LOCATION);
3613
3614   END_TEST;
3615 }
3616
3617 int UtcDaliActorGetWidthForHeight(void)
3618 {
3619   TestApplication application;
3620
3621   Actor actor = Actor::New();
3622
3623   DALI_TEST_EQUALS(actor.GetWidthForHeight(1.0f), 1.0f, TEST_LOCATION);
3624
3625   END_TEST;
3626 }
3627
3628 int UtcDaliActorGetRelayoutSize(void)
3629 {
3630   TestApplication application;
3631
3632   Actor actor = Actor::New();
3633
3634   // Add actor to stage
3635   application.GetScene().Add(actor);
3636
3637   DALI_TEST_EQUALS(actor.GetRelayoutSize(Dimension::WIDTH), 0.0f, TEST_LOCATION);
3638
3639   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::WIDTH);
3640   actor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 0.0f));
3641
3642   // Flush the queue and render once
3643   application.SendNotification();
3644   application.Render();
3645
3646   DALI_TEST_EQUALS(actor.GetRelayoutSize(Dimension::WIDTH), 1.0f, TEST_LOCATION);
3647
3648   END_TEST;
3649 }
3650
3651 int UtcDaliActorSetPadding(void)
3652 {
3653   TestApplication application;
3654
3655   Actor actor = Actor::New();
3656
3657   Padding padding;
3658   padding = actor.GetProperty<Vector4>(Actor::Property::PADDING);
3659
3660   DALI_TEST_EQUALS(padding.left, 0.0f, TEST_LOCATION);
3661   DALI_TEST_EQUALS(padding.right, 0.0f, TEST_LOCATION);
3662   DALI_TEST_EQUALS(padding.bottom, 0.0f, TEST_LOCATION);
3663   DALI_TEST_EQUALS(padding.top, 0.0f, TEST_LOCATION);
3664
3665   Padding padding2(1.0f, 2.0f, 3.0f, 4.0f);
3666   actor.SetProperty(Actor::Property::PADDING, padding2);
3667
3668   padding = actor.GetProperty<Vector4>(Actor::Property::PADDING);
3669
3670   DALI_TEST_EQUALS(padding.left, padding2.left, TEST_LOCATION);
3671   DALI_TEST_EQUALS(padding.right, padding2.right, TEST_LOCATION);
3672   DALI_TEST_EQUALS(padding.bottom, padding2.bottom, TEST_LOCATION);
3673   DALI_TEST_EQUALS(padding.top, padding2.top, TEST_LOCATION);
3674
3675   END_TEST;
3676 }
3677
3678 int UtcDaliActorSetMinimumSize(void)
3679 {
3680   TestApplication application;
3681
3682   Actor actor = Actor::New();
3683
3684   Vector2 size = actor.GetProperty<Vector2>(Actor::Property::MINIMUM_SIZE);
3685
3686   DALI_TEST_EQUALS(size.width, 0.0f, TEST_LOCATION);
3687   DALI_TEST_EQUALS(size.height, 0.0f, TEST_LOCATION);
3688
3689   Vector2 size2(1.0f, 2.0f);
3690   actor.SetProperty(Actor::Property::MINIMUM_SIZE, size2);
3691
3692   size = actor.GetProperty<Vector2>(Actor::Property::MINIMUM_SIZE);
3693
3694   DALI_TEST_EQUALS(size.width, size2.width, TEST_LOCATION);
3695   DALI_TEST_EQUALS(size.height, size2.height, TEST_LOCATION);
3696
3697   END_TEST;
3698 }
3699
3700 int UtcDaliActorSetMaximumSize(void)
3701 {
3702   TestApplication application;
3703
3704   Actor actor = Actor::New();
3705
3706   Vector2 size = actor.GetProperty<Vector2>(Actor::Property::MAXIMUM_SIZE);
3707
3708   DALI_TEST_EQUALS(size.width, FLT_MAX, TEST_LOCATION);
3709   DALI_TEST_EQUALS(size.height, FLT_MAX, TEST_LOCATION);
3710
3711   Vector2 size2(1.0f, 2.0f);
3712   actor.SetProperty(Actor::Property::MAXIMUM_SIZE, size2);
3713
3714   size = actor.GetProperty<Vector2>(Actor::Property::MAXIMUM_SIZE);
3715
3716   DALI_TEST_EQUALS(size.width, size2.width, TEST_LOCATION);
3717   DALI_TEST_EQUALS(size.height, size2.height, TEST_LOCATION);
3718
3719   END_TEST;
3720 }
3721
3722 int UtcDaliActorOnRelayoutSignal(void)
3723 {
3724   tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
3725
3726   TestApplication application;
3727
3728   // Clean test data
3729   gOnRelayoutCallBackCalled = false;
3730   gActorNamesRelayout.clear();
3731
3732   Actor actor = Actor::New();
3733   actor.SetProperty(Actor::Property::NAME, "actor");
3734   actor.OnRelayoutSignal().Connect(OnRelayoutCallback);
3735
3736   // Sanity check
3737   DALI_TEST_CHECK(!gOnRelayoutCallBackCalled);
3738
3739   // Add actor to stage
3740   application.GetScene().Add(actor);
3741
3742   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
3743   actor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 2.0));
3744
3745   // Flush the queue and render once
3746   application.SendNotification();
3747   application.Render();
3748
3749   // OnRelayout emitted
3750   DALI_TEST_EQUALS(gOnRelayoutCallBackCalled, true, TEST_LOCATION);
3751   DALI_TEST_EQUALS("actor", gActorNamesRelayout[0], TEST_LOCATION);
3752
3753   END_TEST;
3754 }
3755
3756 int UtcDaliActorGetHierachyDepth(void)
3757 {
3758   TestApplication application;
3759   tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
3760
3761   /* Build tree of actors:
3762    *
3763    *                      Depth
3764    *
3765    *       A (parent)       1
3766    *      / \
3767    *     B   C              2`
3768    *    / \   \
3769    *   D   E   F            3
3770    *
3771    * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
3772    */
3773   Integration::Scene stage(application.GetScene());
3774
3775   Actor actorA = Actor::New();
3776   Actor actorB = Actor::New();
3777   Actor actorC = Actor::New();
3778   Actor actorD = Actor::New();
3779   Actor actorE = Actor::New();
3780   Actor actorF = Actor::New();
3781
3782   //Test that root actor has depth equal 0
3783   DALI_TEST_EQUALS(0, stage.GetRootLayer().GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3784
3785   //Test actors return depth -1 when not connected to the tree
3786   DALI_TEST_EQUALS(-1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3787   DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3788   DALI_TEST_EQUALS(-1, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3789   DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3790   DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3791   DALI_TEST_EQUALS(-1, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3792
3793   //Create the hierarchy
3794   stage.Add(actorA);
3795   actorA.Add(actorB);
3796   actorA.Add(actorC);
3797   actorB.Add(actorD);
3798   actorB.Add(actorE);
3799   actorC.Add(actorF);
3800
3801   //Test actors return correct depth
3802   DALI_TEST_EQUALS(1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3803   DALI_TEST_EQUALS(2, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3804   DALI_TEST_EQUALS(2, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3805   DALI_TEST_EQUALS(3, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3806   DALI_TEST_EQUALS(3, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3807   DALI_TEST_EQUALS(3, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3808
3809   //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
3810   actorA.Remove(actorB);
3811
3812   DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3813   DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3814   DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3815
3816   //Removing actorA from the stage. All actors should have depth equal -1
3817   stage.Remove(actorA);
3818
3819   DALI_TEST_EQUALS(-1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3820   DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3821   DALI_TEST_EQUALS(-1, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3822   DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3823   DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3824   DALI_TEST_EQUALS(-1, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3825
3826   END_TEST;
3827 }
3828
3829 int UtcDaliActorAnchorPointPropertyAsString(void)
3830 {
3831   TestApplication application;
3832
3833   Actor actor = Actor::New();
3834
3835   actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_LEFT");
3836   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_LEFT, TEST_LOCATION);
3837
3838   actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_CENTER");
3839   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_CENTER, TEST_LOCATION);
3840
3841   actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_RIGHT");
3842   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_RIGHT, TEST_LOCATION);
3843
3844   actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER_LEFT");
3845   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER_LEFT, TEST_LOCATION);
3846
3847   actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER");
3848   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER, TEST_LOCATION);
3849
3850   actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER_RIGHT");
3851   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER_RIGHT, TEST_LOCATION);
3852
3853   actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT");
3854   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION);
3855
3856   actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER");
3857   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION);
3858
3859   actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT");
3860   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
3861
3862   // Invalid should not change anything
3863   actor.SetProperty(Actor::Property::ANCHOR_POINT, "INVALID_ARG");
3864   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
3865
3866   END_TEST;
3867 }
3868
3869 int UtcDaliActorParentOriginPropertyAsString(void)
3870 {
3871   TestApplication application;
3872
3873   Actor actor = Actor::New();
3874
3875   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_LEFT");
3876   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_LEFT, TEST_LOCATION);
3877
3878   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_CENTER");
3879   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_CENTER, TEST_LOCATION);
3880
3881   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_RIGHT");
3882   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_RIGHT, TEST_LOCATION);
3883
3884   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER_LEFT");
3885   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER_LEFT, TEST_LOCATION);
3886
3887   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER");
3888   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER, TEST_LOCATION);
3889
3890   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT");
3891   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER_RIGHT, TEST_LOCATION);
3892
3893   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT");
3894   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION);
3895
3896   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER");
3897   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION);
3898
3899   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT");
3900   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
3901
3902   // Invalid should not change anything
3903   actor.SetProperty(Actor::Property::PARENT_ORIGIN, "INVALID_ARG");
3904   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
3905
3906   END_TEST;
3907 }
3908
3909 int UtcDaliActorColorModePropertyAsString(void)
3910 {
3911   TestApplication application;
3912
3913   Actor actor = Actor::New();
3914
3915   actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_COLOR");
3916   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_COLOR, TEST_LOCATION);
3917
3918   actor.SetProperty(Actor::Property::COLOR_MODE, "USE_PARENT_COLOR");
3919   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_PARENT_COLOR, TEST_LOCATION);
3920
3921   actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR");
3922   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION);
3923
3924   actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA");
3925   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
3926
3927   // Invalid should not change anything
3928   actor.SetProperty(Actor::Property::COLOR_MODE, "INVALID_ARG");
3929   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
3930
3931   END_TEST;
3932 }
3933
3934 int UtcDaliActorDrawModePropertyAsString(void)
3935 {
3936   TestApplication application;
3937
3938   Actor actor = Actor::New();
3939
3940   actor.SetProperty(Actor::Property::DRAW_MODE, "NORMAL");
3941   DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::NORMAL, TEST_LOCATION);
3942
3943   actor.SetProperty(Actor::Property::DRAW_MODE, "OVERLAY_2D");
3944   DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
3945
3946   // Invalid should not change anything
3947   actor.SetProperty(Actor::Property::DRAW_MODE, "INVALID_ARG");
3948   DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
3949
3950   END_TEST;
3951 }
3952
3953 int UtcDaliActorColorModePropertyAsEnum(void)
3954 {
3955   TestApplication application;
3956
3957   Actor actor = Actor::New();
3958
3959   actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
3960   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_COLOR, TEST_LOCATION);
3961
3962   actor.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
3963   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_PARENT_COLOR, TEST_LOCATION);
3964
3965   actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR);
3966   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION);
3967
3968   actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
3969   DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
3970
3971   END_TEST;
3972 }
3973
3974 int UtcDaliActorDrawModePropertyAsEnum(void)
3975 {
3976   TestApplication application;
3977
3978   Actor actor = Actor::New();
3979
3980   actor.SetProperty(Actor::Property::DRAW_MODE, DrawMode::NORMAL);
3981   DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::NORMAL, TEST_LOCATION);
3982
3983   actor.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3984   DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
3985
3986   END_TEST;
3987 }
3988
3989 int UtcDaliActorAddRendererP(void)
3990 {
3991   tet_infoline("Testing Actor::AddRenderer");
3992   TestApplication application;
3993
3994   Actor actor = Actor::New();
3995
3996   DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
3997
3998   Geometry geometry = CreateQuadGeometry();
3999   Shader   shader   = CreateShader();
4000   Renderer renderer = Renderer::New(geometry, shader);
4001
4002   actor.AddRenderer(renderer);
4003   DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4004   DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4005
4006   END_TEST;
4007 }
4008
4009 int UtcDaliActorAddRendererN01(void)
4010 {
4011   tet_infoline("Testing Actor::AddRenderer");
4012   TestApplication application;
4013
4014   Actor    actor = Actor::New();
4015   Renderer renderer;
4016
4017   // try illegal Add
4018   try
4019   {
4020     actor.AddRenderer(renderer);
4021     tet_printf("Assertion test failed - no Exception\n");
4022     tet_result(TET_FAIL);
4023   }
4024   catch(Dali::DaliException& e)
4025   {
4026     DALI_TEST_PRINT_ASSERT(e);
4027     DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
4028     DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4029   }
4030   catch(...)
4031   {
4032     tet_printf("Assertion test failed - wrong Exception\n");
4033     tet_result(TET_FAIL);
4034   }
4035
4036   END_TEST;
4037 }
4038
4039 int UtcDaliActorAddRendererN02(void)
4040 {
4041   tet_infoline("UtcDaliActorAddRendererN02");
4042
4043   Actor    actor;
4044   Renderer renderer;
4045
4046   {
4047     TestApplication application;
4048
4049     Geometry geometry = CreateQuadGeometry();
4050     Shader   shader   = CreateShader();
4051     renderer          = Renderer::New(geometry, shader);
4052
4053     actor = Actor::New();
4054   }
4055
4056   // try illegal AddRenderer
4057   try
4058   {
4059     actor.AddRenderer(renderer);
4060     tet_printf("Assertion test failed - no Exception\n");
4061     tet_result(TET_FAIL);
4062   }
4063   catch(Dali::DaliException& e)
4064   {
4065     DALI_TEST_PRINT_ASSERT(e);
4066     DALI_TEST_ASSERT(e, "EventThreadServices::IsCoreRunning()", TEST_LOCATION);
4067   }
4068   catch(...)
4069   {
4070     tet_printf("Assertion test failed - wrong Exception\n");
4071     tet_result(TET_FAIL);
4072   }
4073
4074   END_TEST;
4075 }
4076
4077 int UtcDaliActorAddRendererOnScene(void)
4078 {
4079   tet_infoline("Testing Actor::AddRenderer");
4080   TestApplication application;
4081
4082   Actor actor = Actor::New();
4083   application.GetScene().Add(actor);
4084
4085   application.SendNotification();
4086   application.Render(0);
4087
4088   Geometry geometry = CreateQuadGeometry();
4089   Shader   shader   = CreateShader();
4090   Renderer renderer = Renderer::New(geometry, shader);
4091
4092   application.SendNotification();
4093   application.Render(0);
4094
4095   try
4096   {
4097     actor.AddRenderer(renderer);
4098     tet_result(TET_PASS);
4099   }
4100   catch(...)
4101   {
4102     tet_result(TET_FAIL);
4103   }
4104
4105   END_TEST;
4106 }
4107
4108 int UtcDaliActorRemoveRendererP1(void)
4109 {
4110   tet_infoline("Testing Actor::RemoveRenderer");
4111   TestApplication application;
4112
4113   Actor actor = Actor::New();
4114
4115   DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4116
4117   {
4118     Geometry geometry = CreateQuadGeometry();
4119     Shader   shader   = CreateShader();
4120     Renderer renderer = Renderer::New(geometry, shader);
4121
4122     actor.AddRenderer(renderer);
4123     DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4124     DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4125
4126     application.SendNotification();
4127     application.Render();
4128   }
4129
4130   {
4131     Renderer renderer = actor.GetRendererAt(0);
4132     actor.RemoveRenderer(renderer);
4133     DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4134
4135     application.SendNotification();
4136     application.Render();
4137   }
4138
4139   // Call one final time to ensure that the renderer is actually removed after
4140   // the handle goes out of scope, and excercises the deletion code path in
4141   // scene graph and render.
4142   application.SendNotification();
4143   application.Render();
4144
4145   END_TEST;
4146 }
4147
4148 int UtcDaliActorRemoveRendererP2(void)
4149 {
4150   tet_infoline("Testing Actor::RemoveRenderer");
4151   TestApplication application;
4152
4153   Actor actor = Actor::New();
4154
4155   DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4156
4157   Geometry geometry = CreateQuadGeometry();
4158   Shader   shader   = CreateShader();
4159   Renderer renderer = Renderer::New(geometry, shader);
4160
4161   actor.AddRenderer(renderer);
4162   application.SendNotification();
4163   application.Render();
4164
4165   DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4166   DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4167
4168   actor.RemoveRenderer(0);
4169   application.SendNotification();
4170   application.Render();
4171
4172   DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4173
4174   // Shut down whilst holding onto the renderer handle.
4175   END_TEST;
4176 }
4177
4178 int UtcDaliActorRemoveRendererN(void)
4179 {
4180   tet_infoline("Testing Actor::RemoveRenderer");
4181   TestApplication application;
4182
4183   Actor actor = Actor::New();
4184
4185   DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4186
4187   Geometry geometry = CreateQuadGeometry();
4188   Shader   shader   = CreateShader();
4189   Renderer renderer = Renderer::New(geometry, shader);
4190
4191   actor.AddRenderer(renderer);
4192   DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4193   DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4194
4195   actor.RemoveRenderer(10);
4196   DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4197   DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4198
4199   END_TEST;
4200 }
4201
4202 // Clipping test helper functions:
4203 Actor CreateActorWithContent(uint32_t width, uint32_t height)
4204 {
4205   Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
4206   Actor   actor = CreateRenderableActor(image);
4207
4208   // Setup dimensions and position so actor is not skipped by culling.
4209   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
4210   actor.SetProperty(Actor::Property::SIZE, Vector2(width, height));
4211   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4212   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4213
4214   return actor;
4215 }
4216
4217 Actor CreateActorWithContent16x16()
4218 {
4219   return CreateActorWithContent(16, 16);
4220 }
4221
4222 void GenerateTrace(TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace)
4223 {
4224   enabledDisableTrace.Reset();
4225   stencilTrace.Reset();
4226   enabledDisableTrace.Enable(true);
4227   stencilTrace.Enable(true);
4228
4229   application.SendNotification();
4230   application.Render();
4231
4232   enabledDisableTrace.Enable(false);
4233   stencilTrace.Enable(false);
4234 }
4235
4236 void CheckColorMask(TestGlAbstraction& glAbstraction, bool maskValue)
4237 {
4238   const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
4239
4240   DALI_TEST_EQUALS<bool>(colorMaskParams.red, maskValue, TEST_LOCATION);
4241   DALI_TEST_EQUALS<bool>(colorMaskParams.green, maskValue, TEST_LOCATION);
4242   DALI_TEST_EQUALS<bool>(colorMaskParams.blue, maskValue, TEST_LOCATION);
4243
4244   // @todo only test alpha if the framebuffer has an alpha channel
4245   //DALI_TEST_EQUALS<bool>(colorMaskParams.alpha, maskValue, TEST_LOCATION);
4246 }
4247
4248 int UtcDaliActorPropertyClippingP(void)
4249 {
4250   // This test checks the clippingMode property.
4251   tet_infoline("Testing Actor::Property::ClippingMode: P");
4252   TestApplication application;
4253
4254   Actor actor = Actor::New();
4255
4256   // Check default clippingEnabled value.
4257   Property::Value getValue(actor.GetProperty(Actor::Property::CLIPPING_MODE));
4258
4259   int  value          = 0;
4260   bool getValueResult = getValue.Get(value);
4261   DALI_TEST_CHECK(getValueResult);
4262
4263   if(getValueResult)
4264   {
4265     DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4266   }
4267
4268   // Check setting the property to the stencil mode.
4269   actor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4270
4271   // Check the new value was set.
4272   getValue       = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4273   getValueResult = getValue.Get(value);
4274   DALI_TEST_CHECK(getValueResult);
4275
4276   if(getValueResult)
4277   {
4278     DALI_TEST_EQUALS<int>(value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION);
4279   }
4280
4281   // Check setting the property to the scissor mode.
4282   actor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4283
4284   // Check the new value was set.
4285   getValue       = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4286   getValueResult = getValue.Get(value);
4287   DALI_TEST_CHECK(getValueResult);
4288
4289   if(getValueResult)
4290   {
4291     DALI_TEST_EQUALS<int>(value, ClippingMode::CLIP_TO_BOUNDING_BOX, TEST_LOCATION);
4292   }
4293   END_TEST;
4294 }
4295
4296 int UtcDaliActorPropertyClippingN(void)
4297 {
4298   // Negative test case for Clipping.
4299   tet_infoline("Testing Actor::Property::ClippingMode: N");
4300   TestApplication application;
4301
4302   Actor actor = Actor::New();
4303
4304   // Check default clippingEnabled value.
4305   Property::Value getValue(actor.GetProperty(Actor::Property::CLIPPING_MODE));
4306
4307   int  value          = 0;
4308   bool getValueResult = getValue.Get(value);
4309   DALI_TEST_CHECK(getValueResult);
4310
4311   if(getValueResult)
4312   {
4313     DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4314   }
4315
4316   // Check setting an invalid property value won't change the current property value.
4317   actor.SetProperty(Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY");
4318
4319   getValue       = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4320   getValueResult = getValue.Get(value);
4321   DALI_TEST_CHECK(getValueResult);
4322
4323   if(getValueResult)
4324   {
4325     DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4326   }
4327
4328   END_TEST;
4329 }
4330
4331 int UtcDaliActorPropertyClippingActor(void)
4332 {
4333   // This test checks that an actor is correctly setup for clipping.
4334   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor");
4335   TestApplication application;
4336
4337   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4338   TraceCallStack&    stencilTrace        = glAbstraction.GetStencilFunctionTrace();
4339   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4340   size_t             startIndex          = 0u;
4341
4342   // Create a clipping actor.
4343   Actor actorDepth1Clip = CreateActorWithContent16x16();
4344   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4345   application.GetScene().Add(actorDepth1Clip);
4346
4347   // Gather the call trace.
4348   GenerateTrace(application, enabledDisableTrace, stencilTrace);
4349
4350   // Check we are writing to the color buffer.
4351   CheckColorMask(glAbstraction, true);
4352
4353   // Check the stencil buffer was enabled.
4354   std::ostringstream oss;
4355   oss << std::hex << GL_STENCIL_TEST;
4356   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
4357
4358   // Check the stencil buffer was cleared.
4359   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4360
4361   // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4362   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4363   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));
4364   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4365
4366   END_TEST;
4367 }
4368
4369 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
4370 {
4371   // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
4372   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor enable and then disable");
4373   TestApplication application;
4374
4375   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4376   TraceCallStack&    stencilTrace        = glAbstraction.GetStencilFunctionTrace();
4377   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4378   size_t             startIndex          = 0u;
4379
4380   // Create a clipping actor.
4381   Actor actorDepth1Clip = CreateActorWithContent16x16();
4382   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4383   application.GetScene().Add(actorDepth1Clip);
4384
4385   // Gather the call trace.
4386   GenerateTrace(application, enabledDisableTrace, stencilTrace);
4387
4388   // Check we are writing to the color buffer.
4389   CheckColorMask(glAbstraction, true);
4390
4391   // Check the stencil buffer was enabled.
4392   std::ostringstream oss;
4393   oss << std::hex << GL_STENCIL_TEST;
4394   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
4395
4396   // Check the stencil buffer was cleared.
4397   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4398
4399   // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4400   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4401   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));
4402   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4403
4404   // Now disable the clipping
4405   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED);
4406
4407   // Gather the call trace.
4408   GenerateTrace(application, enabledDisableTrace, stencilTrace);
4409
4410   // Check the stencil buffer was disabled.
4411   std::ostringstream stencil;
4412   stencil << std::hex << GL_STENCIL_TEST;
4413   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Disable", stencil.str()));
4414
4415   // Ensure all values in stencil-mask are set to 1.
4416   startIndex = 0u;
4417   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "255", startIndex));
4418
4419   END_TEST;
4420 }
4421
4422 int UtcDaliActorPropertyClippingNestedChildren(void)
4423 {
4424   // This test checks that a hierarchy of actors are clipped correctly by
4425   // writing to and reading from the correct bit-planes of the stencil buffer.
4426   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN nested children");
4427   TestApplication    application;
4428   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4429   TraceCallStack&    stencilTrace        = glAbstraction.GetStencilFunctionTrace();
4430   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4431
4432   // Create a clipping actor.
4433   Actor actorDepth1Clip = CreateActorWithContent16x16();
4434   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4435   application.GetScene().Add(actorDepth1Clip);
4436
4437   // Create a child actor.
4438   Actor childDepth2 = CreateActorWithContent16x16();
4439   actorDepth1Clip.Add(childDepth2);
4440
4441   // Create another clipping actor.
4442   Actor childDepth2Clip = CreateActorWithContent16x16();
4443   childDepth2Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4444   childDepth2.Add(childDepth2Clip);
4445
4446   // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
4447   // This tests the sort algorithm.
4448   Actor childDepth3 = CreateActorWithContent16x16();
4449   childDepth2Clip.Add(childDepth3);
4450   Actor childDepth4 = CreateActorWithContent16x16();
4451   childDepth3.Add(childDepth4);
4452
4453   // Gather the call trace.
4454   GenerateTrace(application, enabledDisableTrace, stencilTrace);
4455
4456   // Check we are writing to the color buffer.
4457   CheckColorMask(glAbstraction, true);
4458
4459   // Check the stencil buffer was enabled.
4460   std::ostringstream oss;
4461   oss << std::hex << GL_STENCIL_TEST;
4462   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
4463
4464   // Perform the test twice, once for 2D layer, and once for 3D.
4465   for(unsigned int i = 0u; i < 2u; ++i)
4466   {
4467     size_t startIndex = 0u;
4468
4469     // Check the stencil buffer was cleared.
4470     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4471
4472     // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4473     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex));      // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4474     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));              // Write to the first bit-plane
4475     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4476
4477     // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
4478     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 1", startIndex));      // 514 is GL_EQUAL
4479     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7680, 7680", startIndex)); // GL_KEEP, GL_KEEP, GL_KEEP
4480
4481     // Check we are set up to write to the second bitplane of the stencil buffer (only).
4482     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 3, 1", startIndex));      // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4483     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "3", startIndex));              // Write to second (and previous) bit-planes
4484     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4485
4486     // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4487     // (Both must be set to pass the check).
4488     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 3, 3", startIndex));      // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4489     DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7680, 7680", startIndex)); // GL_KEEP, GL_KEEP, GL_KEEP
4490
4491     // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4492     if(i == 0u)
4493     {
4494       application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D);
4495       GenerateTrace(application, enabledDisableTrace, stencilTrace);
4496     }
4497   }
4498
4499   END_TEST;
4500 }
4501
4502 int UtcDaliActorPropertyClippingActorDrawOrder(void)
4503 {
4504   // This test checks that a hierarchy of actors are drawn in the correct order when clipping is enabled.
4505   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN draw order");
4506   TestApplication    application;
4507   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4508   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4509
4510   /* We create a small tree of actors as follows:
4511
4512                            A
4513                           / \
4514      Clipping enabled -> B   D
4515                          |   |
4516                          C   E
4517
4518      The correct draw order is "ABCDE" (the same as if clipping was not enabled).
4519   */
4520   Actor actors[5];
4521   for(int i = 0; i < 5; ++i)
4522   {
4523     Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
4524     Actor   actor = CreateRenderableActor(image);
4525
4526     // Setup dimensions and position so actor is not skipped by culling.
4527     actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
4528     actor.SetProperty(Actor::Property::SIZE, Vector2(16.0f, 16.0f));
4529
4530     if(i == 0)
4531     {
4532       actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4533     }
4534     else
4535     {
4536       float b = i > 2 ? 1.0f : -1.0f;
4537       actor.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0.5 + (0.2f * b), 0.8f, 0.8f));
4538     }
4539
4540     actors[i] = actor;
4541   }
4542
4543   // Enable clipping on the actor at the top of the left branch.
4544   actors[1].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4545
4546   // Build the scene graph.
4547   application.GetScene().Add(actors[0]);
4548
4549   // Left branch:
4550   actors[0].Add(actors[1]);
4551   actors[1].Add(actors[2]);
4552
4553   // Right branch:
4554   actors[0].Add(actors[3]);
4555   actors[3].Add(actors[4]);
4556
4557   // Gather the call trace.
4558   enabledDisableTrace.Reset();
4559   enabledDisableTrace.Enable(true);
4560   application.SendNotification();
4561   application.Render();
4562   enabledDisableTrace.Enable(false);
4563
4564   /* Check stencil is enabled and disabled again (as right-hand branch of tree is drawn).
4565
4566      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
4567            Incorrect enable call trace:  StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960
4568   */
4569   size_t             startIndex = 0u;
4570   std::ostringstream blend;
4571   blend << std::hex << GL_BLEND;
4572   std::ostringstream stencil;
4573   stencil << std::hex << GL_STENCIL_TEST;
4574
4575   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", blend.str(), startIndex));
4576   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", stencil.str(), startIndex));
4577   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", stencil.str(), startIndex));
4578
4579   // Swap the clipping actor from top of left branch to top of right branch.
4580   actors[1].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED);
4581   actors[3].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4582
4583   // Gather the call trace.
4584   enabledDisableTrace.Reset();
4585   enabledDisableTrace.Enable(true);
4586   application.SendNotification();
4587   application.Render();
4588   enabledDisableTrace.Enable(false);
4589
4590   // Check stencil is enabled but NOT disabled again (as right-hand branch of tree is drawn).
4591   // This proves the draw order has remained the same.
4592   startIndex = 0u;
4593   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", stencil.str(), startIndex));
4594   DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", stencil.str(), startIndex));
4595
4596   END_TEST;
4597 }
4598
4599 int UtcDaliActorPropertyScissorClippingActor01(void)
4600 {
4601   // This test checks that an actor is correctly setup for clipping.
4602   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor");
4603   TestApplication application;
4604
4605   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4606   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
4607   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4608
4609   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4610   const Vector2 imageSize(16.0f, 16.0f);
4611
4612   // Create a clipping actor.
4613   Actor clippingActorA = CreateActorWithContent16x16();
4614   // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4615   // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4616   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
4617   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
4618   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4619   application.GetScene().Add(clippingActorA);
4620
4621   // Gather the call trace.
4622   GenerateTrace(application, enabledDisableTrace, scissorTrace);
4623
4624   // Check we are writing to the color buffer.
4625   CheckColorMask(glAbstraction, true);
4626
4627   // Check scissor test was enabled.
4628
4629   std::ostringstream scissor;
4630   scissor << std::hex << GL_SCISSOR_TEST;
4631   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
4632
4633   // Check the scissor was set, and the coordinates are correct.
4634   std::stringstream compareParametersString;
4635   compareParametersString << "0, 0, " << imageSize.x << ", " << imageSize.y;
4636   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
4637
4638   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
4639   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_RIGHT);
4640
4641   // Gather the call trace.
4642   GenerateTrace(application, enabledDisableTrace, scissorTrace);
4643
4644   // Check the scissor was set, and the coordinates are correct.
4645   compareParametersString.str(std::string());
4646   compareParametersString.clear();
4647   compareParametersString << (stageSize.x - imageSize.x) << ", " << (stageSize.y - imageSize.y) << ", " << imageSize.x << ", " << imageSize.y;
4648   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 464, 784, 16, 16
4649
4650   END_TEST;
4651 }
4652
4653 int UtcDaliActorPropertyScissorClippingActor02(void)
4654 {
4655   // This test checks that an actor is correctly setup for clipping.
4656   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor with a transparent renderer");
4657   TestApplication application;
4658
4659   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4660   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
4661   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4662
4663   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4664   const Vector2 actorSize(16.0f, 16.0f);
4665
4666   // Create a clipping actor.
4667   Actor clippingActorA                  = CreateRenderableActor();
4668   clippingActorA[Actor::Property::SIZE] = actorSize;
4669
4670   Renderer renderer = clippingActorA.GetRendererAt(0);
4671   DALI_TEST_CHECK(renderer);
4672
4673   // Make Renderer opacity 0.
4674   renderer[DevelRenderer::Property::OPACITY] = 0.0f;
4675
4676   // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4677   // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4678   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
4679   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
4680   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4681   application.GetScene().Add(clippingActorA);
4682
4683   // Gather the call trace.
4684   GenerateTrace(application, enabledDisableTrace, scissorTrace);
4685
4686   // Check we are writing to the color buffer.
4687   CheckColorMask(glAbstraction, true);
4688
4689   // Check scissor test was enabled.
4690
4691   std::ostringstream scissor;
4692   scissor << std::hex << GL_SCISSOR_TEST;
4693   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
4694
4695   // Check the scissor was set, and the coordinates are correct.
4696   std::stringstream compareParametersString;
4697   compareParametersString << "0, 0, " << actorSize.x << ", " << actorSize.y;
4698   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
4699
4700   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
4701   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_RIGHT);
4702
4703   // Gather the call trace.
4704   GenerateTrace(application, enabledDisableTrace, scissorTrace);
4705
4706   // Check the scissor was set, and the coordinates are correct.
4707   compareParametersString.str(std::string());
4708   compareParametersString.clear();
4709   compareParametersString << (stageSize.x - actorSize.x) << ", " << (stageSize.y - actorSize.y) << ", " << actorSize.x << ", " << actorSize.y;
4710   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 464, 784, 16, 16
4711
4712   END_TEST;
4713 }
4714
4715 int UtcDaliActorPropertyScissorClippingActorSiblings(void)
4716 {
4717   // This test checks that an actor is correctly setup for clipping.
4718   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actors which are siblings");
4719   TestApplication application;
4720
4721   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4722   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
4723   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4724
4725   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4726   const Vector2 sizeA{stageSize.width, stageSize.height * 0.25f};
4727   const Vector2 sizeB{stageSize.width, stageSize.height * 0.05f};
4728
4729   // Create a clipping actors.
4730   Actor clippingActorA = CreateActorWithContent(sizeA.width, sizeA.height);
4731   Actor clippingActorB = CreateActorWithContent(sizeB.width, sizeB.height);
4732
4733   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4734   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4735   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4736
4737   clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4738   clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4739   clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4740
4741   clippingActorA.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -200.0f, 0.0f));
4742   clippingActorB.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
4743
4744   application.GetScene().Add(clippingActorA);
4745   application.GetScene().Add(clippingActorB);
4746
4747   // Gather the call trace.
4748   GenerateTrace(application, enabledDisableTrace, scissorTrace);
4749
4750   // Check we are writing to the color buffer.
4751   CheckColorMask(glAbstraction, true);
4752
4753   // Check scissor test was enabled.
4754   std::ostringstream scissor;
4755   scissor << std::hex << GL_SCISSOR_TEST;
4756   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
4757
4758   // Check the scissor was set, and the coordinates are correct.
4759   std::stringstream compareParametersString;
4760
4761   std::string clipA("0, 500, 480, 200");
4762   std::string clipB("0, 380, 480, 40");
4763
4764   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipA));
4765   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipB));
4766
4767   END_TEST;
4768 }
4769
4770 int UtcDaliActorPropertyScissorClippingActorNested01(void)
4771 {
4772   // This test checks that an actor is correctly setup for clipping.
4773   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested");
4774   TestApplication application;
4775
4776   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4777   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
4778   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4779
4780   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4781   const Vector2 imageSize(16.0f, 16.0f);
4782
4783   /* Create a nest of 2 scissors to test nesting (intersecting clips).
4784
4785      A is drawn first - with scissor clipping on
4786      B is drawn second - also with scissor clipping on
4787      C is the generated clipping region, the intersection ( A ∩ B )
4788
4789            ┏━━━━━━━┓                   ┌───────┐
4790            ┃     B ┃                   │     B │
4791        ┌───╂┄┄┄┐   ┃               ┌┄┄┄╆━━━┓   │
4792        │   ┃   ┊   ┃     ━━━━━>    ┊   ┃ C ┃   │
4793        │   ┗━━━┿━━━┛               ┊   ┗━━━╃───┘
4794        │ A     │                   ┊ A     ┊
4795        └───────┘                   └┄┄┄┄┄┄┄┘
4796
4797      We then reposition B around each corner of A to test the 4 overlap combinations (thus testing intersecting works correctly).
4798   */
4799
4800   // Create a clipping actor.
4801   Actor clippingActorA = CreateActorWithContent16x16();
4802   // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4803   // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4804   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4805   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4806   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4807   application.GetScene().Add(clippingActorA);
4808
4809   // Create a child clipping actor.
4810   Actor clippingActorB = CreateActorWithContent16x16();
4811   clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4812   clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4813   clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4814   clippingActorA.Add(clippingActorB);
4815
4816   // positionModifiers is an array of positions to position B around.
4817   // expect is an array of expected scissor clip coordinate results.
4818   const Vector2 positionModifiers[4] = {Vector2(1.0f, 1.0f), Vector2(-1.0f, 1.0f), Vector2(-1.0f, -1.0f), Vector2(1.0f, -1.0f)};
4819   const Vector4 expect[4]            = {Vector4(240, 392, 8, 8), Vector4(232, 392, 8, 8), Vector4(232, 400, 8, 8), Vector4(240, 400, 8, 8)};
4820
4821   // Loop through each overlap combination.
4822   for(unsigned int test = 0u; test < 4u; ++test)
4823   {
4824     // Position the child clipping actor so it intersects with the 1st clipping actor. This changes each loop.
4825     const Vector2 position = (imageSize / 2.0f) * positionModifiers[test];
4826     clippingActorB.SetProperty(Actor::Property::POSITION, Vector2(position.x, position.y));
4827
4828     // Gather the call trace.
4829     GenerateTrace(application, enabledDisableTrace, scissorTrace);
4830
4831     // Check we are writing to the color buffer.
4832     CheckColorMask(glAbstraction, true);
4833
4834     // Check scissor test was enabled.
4835     std::ostringstream scissor;
4836     scissor << std::hex << GL_SCISSOR_TEST;
4837     DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
4838
4839     // Check the scissor was set, and the coordinates are correct.
4840     const Vector4&    expectResults(expect[test]);
4841     std::stringstream compareParametersString;
4842     compareParametersString << expectResults.x << ", " << expectResults.y << ", " << expectResults.z << ", " << expectResults.w;
4843     DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with the expected result
4844   }
4845
4846   END_TEST;
4847 }
4848
4849 int UtcDaliActorPropertyScissorClippingActorNested02(void)
4850 {
4851   // This test checks that an actor is correctly setup for clipping.
4852   tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested");
4853   TestApplication application;
4854
4855   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4856   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
4857   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4858
4859   /* Create a nest of 2 scissors and siblings of the parent.
4860
4861             stage
4862               |
4863         ┌─────┐─────┐
4864         A     C     D
4865         |           |
4866         B           E
4867   */
4868
4869   const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4870   const Vector2 sizeA{stageSize.width, stageSize.height * 0.25f};
4871   const Vector2 sizeB{stageSize.width, stageSize.height * 0.05f};
4872   const Vector2 sizeC{stageSize.width, stageSize.height * 0.25f};
4873   const Vector2 sizeD{stageSize.width, stageSize.height * 0.25f};
4874   const Vector2 sizeE{stageSize.width, stageSize.height * 0.05f};
4875
4876   // Create a clipping actors.
4877   Actor clippingActorA = CreateActorWithContent(sizeA.width, sizeA.height);
4878   Actor clippingActorB = CreateActorWithContent(sizeB.width, sizeB.height);
4879   Actor clippingActorC = CreateActorWithContent(sizeC.width, sizeC.height);
4880   Actor clippingActorD = CreateActorWithContent(sizeD.width, sizeD.height);
4881   Actor clippingActorE = CreateActorWithContent(sizeE.width, sizeE.height);
4882
4883   clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4884   clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4885   clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4886
4887   clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4888   clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4889   clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4890
4891   clippingActorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4892   clippingActorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4893   clippingActorC.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4894
4895   clippingActorD.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4896   clippingActorD.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4897   clippingActorD.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4898
4899   clippingActorE.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4900   clippingActorE.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4901
4902   clippingActorA.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -200.0f, 0.0f));
4903   clippingActorB.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
4904   clippingActorC.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 100.0f, 0.0f));
4905   clippingActorD.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
4906   clippingActorE.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
4907
4908   application.GetScene().Add(clippingActorA);
4909   clippingActorA.Add(clippingActorB);
4910   application.GetScene().Add(clippingActorC);
4911   application.GetScene().Add(clippingActorD);
4912   clippingActorD.Add(clippingActorE);
4913
4914   // Gather the call trace.
4915   GenerateTrace(application, enabledDisableTrace, scissorTrace);
4916
4917   // Check we are writing to the color buffer.
4918   CheckColorMask(glAbstraction, true);
4919
4920   // Check scissor test was enabled.
4921   std::ostringstream scissor;
4922   scissor << std::hex << GL_SCISSOR_TEST;
4923   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
4924
4925   // Check the scissor was set, and the coordinates are correct.
4926   std::string clipA("0, 500, 480, 200");
4927   std::string clipB("0, 580, 480, 40");
4928   std::string clipC("0, 200, 480, 200");
4929   std::string clipD("0, 300, 480, 200");
4930
4931   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipA));
4932   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipB));
4933   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipC));
4934   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipD));
4935   DALI_TEST_EQUALS(scissorTrace.CountMethod("Scissor"), 4, TEST_LOCATION); // Scissor rect should not be changed in clippingActorE case. So count should be 4.
4936
4937   END_TEST;
4938 }
4939
4940 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
4941 {
4942   // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
4943   tet_infoline("Testing Actor::Property::CLIPPING_MODE actor with renderer override");
4944   TestApplication application;
4945
4946   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
4947   TraceCallStack&    stencilTrace        = glAbstraction.GetStencilFunctionTrace();
4948   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4949
4950   // Create a clipping actor.
4951   Actor actorDepth1Clip = CreateActorWithContent16x16();
4952   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4953   application.GetScene().Add(actorDepth1Clip);
4954
4955   // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
4956   actorDepth1Clip.GetRendererAt(0).SetProperty(Renderer::Property::RENDER_MODE, RenderMode::COLOR);
4957
4958   // Gather the call trace.
4959   GenerateTrace(application, enabledDisableTrace, stencilTrace);
4960
4961   // Check we are writing to the color buffer.
4962   CheckColorMask(glAbstraction, true);
4963
4964   // Check the stencil buffer was not enabled.
4965   std::ostringstream stencil;
4966   stencil << std::hex << GL_STENCIL_TEST;
4967   DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", stencil.str()));
4968
4969   // Check stencil functions are not called.
4970   DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilFunc"));
4971   // TODO: Temporarily commented out the line below when caching is disabled. Will need to add it back.
4972   //  DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilMask"));
4973   DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilOp"));
4974
4975   // Check that scissor clipping is overriden by the renderer properties.
4976   TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4977
4978   actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4979
4980   // Gather the call trace.
4981   GenerateTrace(application, enabledDisableTrace, scissorTrace);
4982
4983   // Check the stencil buffer was not enabled.
4984   std::ostringstream scissor;
4985   scissor << std::hex << GL_SCISSOR_TEST;
4986   DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
4987
4988   DALI_TEST_CHECK(!scissorTrace.FindMethod("StencilFunc"));
4989
4990   END_TEST;
4991 }
4992
4993 int UtcDaliActorPropertyClippingActorCulled(void)
4994 {
4995   // This test checks that child actors are clipped by an culled parent actor.
4996   tet_infoline("Testing child actors are clipped by an culled parent actor");
4997   TestApplication application;
4998
4999   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
5000   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
5001   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5002
5003   const Vector2 actorSize(160.0f, 160.0f);
5004
5005   // Create a clipping actor.
5006   Actor clippingActorA                  = CreateRenderableActor();
5007   clippingActorA[Actor::Property::SIZE] = actorSize;
5008
5009   // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
5010   // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
5011   clippingActorA[Actor::Property::PARENT_ORIGIN] = ParentOrigin::BOTTOM_LEFT;
5012   clippingActorA[Actor::Property::ANCHOR_POINT]  = AnchorPoint::BOTTOM_LEFT;
5013   clippingActorA[Actor::Property::CLIPPING_MODE] = ClippingMode::CLIP_TO_BOUNDING_BOX;
5014   application.GetScene().Add(clippingActorA);
5015
5016   // Create a child actor
5017   Actor childActor                              = CreateRenderableActor();
5018   childActor[Actor::Property::PARENT_ORIGIN]    = ParentOrigin::BOTTOM_LEFT;
5019   childActor[Actor::Property::ANCHOR_POINT]     = AnchorPoint::BOTTOM_LEFT;
5020   childActor[Actor::Property::SIZE]             = Vector2(50.0f, 50.0f);
5021   childActor[Actor::Property::INHERIT_POSITION] = false;
5022
5023   // Gather the call trace.
5024   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5025
5026   // Check scissor test was enabled.
5027   std::ostringstream scissor;
5028   scissor << std::hex << GL_SCISSOR_TEST;
5029   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5030
5031   // Check the scissor was set, and the coordinates are correct.
5032   std::stringstream compareParametersString;
5033   compareParametersString << "0, 0, " << actorSize.x << ", " << actorSize.y;
5034   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
5035
5036   // Move the clipping actor out of screen
5037   clippingActorA[Actor::Property::POSITION] = Vector2(2000.0f, 2000.0f);
5038
5039   // Gather the call trace.
5040   GenerateTrace(application, enabledDisableTrace, scissorTrace);
5041
5042   // Check the scissor was set, and the coordinates are correct.
5043   compareParametersString.str(std::string());
5044   compareParametersString.clear();
5045   compareParametersString << 2000 << ", " << 0 << ", " << 0 << ", " << 0;
5046   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Clipping area should be empty.
5047
5048   END_TEST;
5049 }
5050
5051 int UtcDaliGetPropertyN(void)
5052 {
5053   tet_infoline("Testing Actor::GetProperty returns a non valid value if property index is out of range");
5054   TestApplication application;
5055
5056   Actor actor = Actor::New();
5057
5058   unsigned int propertyCount = actor.GetPropertyCount();
5059   DALI_TEST_EQUALS(actor.GetProperty(Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION);
5060   END_TEST;
5061 }
5062
5063 int UtcDaliActorRaiseLower(void)
5064 {
5065   tet_infoline("UtcDaliActor Raise and Lower test\n");
5066
5067   TestApplication application;
5068
5069   Debug::Filter::SetGlobalLogLevel(Debug::Verbose);
5070
5071   Integration::Scene stage(application.GetScene());
5072
5073   Actor actorA = Actor::New();
5074   Actor actorB = Actor::New();
5075   Actor actorC = Actor::New();
5076
5077   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5078   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5079
5080   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5081   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5082
5083   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5084   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5085
5086   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5087   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5088
5089   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5090   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5091
5092   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5093   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5094
5095   stage.Add(actorA);
5096   stage.Add(actorB);
5097   stage.Add(actorC);
5098
5099   ResetTouchCallbacks();
5100
5101   application.SendNotification();
5102   application.Render();
5103
5104   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5105   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5106   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5107
5108   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5109   // Only top actor will get touched.
5110   actorA.TouchedSignal().Connect(TestTouchCallback);
5111   actorB.TouchedSignal().Connect(TestTouchCallback2);
5112   actorC.TouchedSignal().Connect(TestTouchCallback3);
5113
5114   // Connect ChildOrderChangedSignal
5115   bool                     orderChangedSignal(false);
5116   Actor                    orderChangedActor;
5117   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5118   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5119
5120   Dali::Integration::Point point;
5121   point.SetDeviceId(1);
5122   point.SetState(PointState::DOWN);
5123   point.SetScreenPosition(Vector2(10.f, 10.f));
5124   Dali::Integration::TouchEvent touchEvent;
5125   touchEvent.AddPoint(point);
5126
5127   application.ProcessEvent(touchEvent);
5128
5129   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5130   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5131   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5132
5133   ResetTouchCallbacks();
5134
5135   tet_printf("Testing Raising of Actor\n");
5136
5137   int preActorOrder(0);
5138   int postActorOrder(0);
5139
5140   Property::Value value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5141   value.Get(preActorOrder);
5142
5143   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5144   actorB.Raise();
5145   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5146   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5147
5148   // Ensure sort order is calculated before next touch event
5149   application.SendNotification();
5150
5151   value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5152   value.Get(postActorOrder);
5153
5154   tet_printf("Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder);
5155
5156   application.ProcessEvent(touchEvent);
5157
5158   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5159   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5160   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5161
5162   ResetTouchCallbacks();
5163
5164   tet_printf("Testing Lowering of Actor\n");
5165
5166   value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5167   value.Get(preActorOrder);
5168
5169   orderChangedSignal = false;
5170
5171   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5172   actorB.Lower();
5173   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5174   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5175
5176   application.SendNotification(); // ensure sort order calculated before next touch event
5177
5178   value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5179   value.Get(postActorOrder);
5180
5181   tet_printf("Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder);
5182
5183   application.ProcessEvent(touchEvent);
5184
5185   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5186   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5187   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5188
5189   ResetTouchCallbacks();
5190
5191   Debug::Filter::SetGlobalLogLevel(Debug::NoLogging);
5192
5193   END_TEST;
5194 }
5195
5196 int UtcDaliActorRaiseToTopLowerToBottom(void)
5197 {
5198   tet_infoline("UtcDaliActorRaiseToTop and LowerToBottom test \n");
5199
5200   TestApplication application;
5201
5202   Integration::Scene stage(application.GetScene());
5203
5204   Actor actorA = Actor::New();
5205   Actor actorB = Actor::New();
5206   Actor actorC = Actor::New();
5207
5208   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5209   // enables checking of which actor the uniform is assigned too
5210   Shader shaderA = CreateShader();
5211   shaderA.RegisterProperty("uRendererColor", 1.f);
5212
5213   Shader shaderB = CreateShader();
5214   shaderB.RegisterProperty("uRendererColor", 2.f);
5215
5216   Shader shaderC = CreateShader();
5217   shaderC.RegisterProperty("uRendererColor", 3.f);
5218
5219   Geometry geometry = CreateQuadGeometry();
5220
5221   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5222   Renderer rendererA = Renderer::New(geometry, shaderA);
5223   actorA.AddRenderer(rendererA);
5224
5225   Renderer rendererB = Renderer::New(geometry, shaderB);
5226   actorB.AddRenderer(rendererB);
5227
5228   Renderer rendererC = Renderer::New(geometry, shaderC);
5229   actorC.AddRenderer(rendererC);
5230
5231   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5232   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5233
5234   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5235   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5236
5237   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5238   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5239
5240   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5241   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5242
5243   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5244   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5245
5246   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5247   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5248
5249   stage.Add(actorA);
5250   stage.Add(actorB);
5251   stage.Add(actorC);
5252
5253   ResetTouchCallbacks();
5254
5255   // Connect ChildOrderChangedSignal
5256   bool                     orderChangedSignal(false);
5257   Actor                    orderChangedActor;
5258   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5259   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5260
5261   // Set up gl abstraction trace so can query the set uniform order
5262   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5263   glAbstraction.EnableSetUniformCallTrace(true);
5264   glAbstraction.ResetSetUniformCallStack();
5265
5266   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5267
5268   application.SendNotification();
5269   application.Render();
5270
5271   tet_printf("Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str());
5272
5273   // Test order of uniforms in stack
5274   int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5275   int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5276   int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5277
5278   bool CBA = (indexC > indexB) && (indexB > indexA);
5279
5280   DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
5281
5282   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5283   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5284   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5285
5286   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5287   // Only top actor will get touched.
5288   actorA.TouchedSignal().Connect(TestTouchCallback);
5289   actorB.TouchedSignal().Connect(TestTouchCallback2);
5290   actorC.TouchedSignal().Connect(TestTouchCallback3);
5291
5292   Dali::Integration::Point point;
5293   point.SetDeviceId(1);
5294   point.SetState(PointState::DOWN);
5295   point.SetScreenPosition(Vector2(10.f, 10.f));
5296   Dali::Integration::TouchEvent touchEvent;
5297   touchEvent.AddPoint(point);
5298
5299   application.ProcessEvent(touchEvent);
5300
5301   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5302   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5303   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5304
5305   ResetTouchCallbacks();
5306
5307   tet_printf("RaiseToTop ActorA\n");
5308
5309   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5310   actorA.RaiseToTop();
5311   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5312   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5313
5314   application.SendNotification(); // ensure sorting order is calculated before next touch event
5315
5316   application.ProcessEvent(touchEvent);
5317
5318   glSetUniformStack.Reset();
5319
5320   application.SendNotification();
5321   application.Render();
5322
5323   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5324
5325   // Test order of uniforms in stack
5326   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5327   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5328   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5329
5330   tet_infoline("Testing A above C and B at bottom\n");
5331   bool ACB = (indexA > indexC) && (indexC > indexB);
5332
5333   DALI_TEST_EQUALS(ACB, true, TEST_LOCATION);
5334
5335   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5336   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5337   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5338
5339   ResetTouchCallbacks();
5340
5341   tet_printf("RaiseToTop ActorB\n");
5342
5343   orderChangedSignal = false;
5344
5345   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5346   actorB.RaiseToTop();
5347   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5348   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5349
5350   application.SendNotification(); // Ensure sort order is calculated before next touch event
5351
5352   application.ProcessEvent(touchEvent);
5353
5354   glSetUniformStack.Reset();
5355
5356   application.SendNotification();
5357   application.Render();
5358
5359   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5360
5361   // Test order of uniforms in stack
5362   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5363   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5364   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5365
5366   tet_infoline("Testing B above A and C at bottom\n");
5367   bool BAC = (indexB > indexA) && (indexA > indexC);
5368
5369   DALI_TEST_EQUALS(BAC, true, TEST_LOCATION);
5370
5371   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5372   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5373   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5374
5375   ResetTouchCallbacks();
5376
5377   tet_printf("LowerToBottom ActorA then ActorB leaving Actor C at Top\n");
5378
5379   orderChangedSignal = false;
5380
5381   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5382   actorA.LowerToBottom();
5383   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5384   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5385
5386   application.SendNotification();
5387   application.Render();
5388
5389   orderChangedSignal = false;
5390
5391   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5392   actorB.LowerToBottom();
5393   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5394   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5395
5396   application.SendNotification();
5397   application.Render();
5398
5399   application.ProcessEvent(touchEvent);
5400
5401   glSetUniformStack.Reset();
5402
5403   application.SendNotification();
5404   application.Render();
5405
5406   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5407
5408   // Test order of uniforms in stack
5409   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5410   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5411   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5412
5413   tet_infoline("Testing C above A and B at bottom\n");
5414   bool CAB = (indexC > indexA) && (indexA > indexB);
5415
5416   DALI_TEST_EQUALS(CAB, true, TEST_LOCATION);
5417
5418   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5419   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5420   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5421
5422   ResetTouchCallbacks();
5423
5424   END_TEST;
5425 }
5426
5427 int UtcDaliActorRaiseAbove(void)
5428 {
5429   tet_infoline("UtcDaliActor RaiseToAbove test \n");
5430
5431   TestApplication application;
5432
5433   Integration::Scene stage(application.GetScene());
5434
5435   Actor actorA = Actor::New();
5436   Actor actorB = Actor::New();
5437   Actor actorC = Actor::New();
5438
5439   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5440   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5441
5442   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5443   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5444
5445   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5446   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5447
5448   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5449   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5450
5451   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5452   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5453
5454   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5455   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5456
5457   stage.Add(actorA);
5458   stage.Add(actorB);
5459   stage.Add(actorC);
5460
5461   ResetTouchCallbacks();
5462
5463   application.SendNotification();
5464   application.Render();
5465
5466   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5467   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5468   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5469
5470   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5471   // Only top actor will get touched.
5472   actorA.TouchedSignal().Connect(TestTouchCallback);
5473   actorB.TouchedSignal().Connect(TestTouchCallback2);
5474   actorC.TouchedSignal().Connect(TestTouchCallback3);
5475
5476   bool                     orderChangedSignal(false);
5477   Actor                    orderChangedActor;
5478   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5479   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5480
5481   Dali::Integration::Point point;
5482   point.SetDeviceId(1);
5483   point.SetState(PointState::DOWN);
5484   point.SetScreenPosition(Vector2(10.f, 10.f));
5485   Dali::Integration::TouchEvent touchEvent;
5486   touchEvent.AddPoint(point);
5487
5488   application.ProcessEvent(touchEvent);
5489
5490   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5491   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5492   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5493
5494   ResetTouchCallbacks();
5495
5496   tet_printf("Raise actor B Above Actor C\n");
5497
5498   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5499   actorB.RaiseAbove(actorC);
5500   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5501   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5502
5503   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5504   application.SendNotification();
5505   application.ProcessEvent(touchEvent);
5506
5507   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5508   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5509   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5510
5511   ResetTouchCallbacks();
5512
5513   tet_printf("Raise actor A Above Actor B\n");
5514
5515   orderChangedSignal = false;
5516
5517   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5518   actorA.RaiseAbove(actorB);
5519   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5520   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5521
5522   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5523   application.SendNotification();
5524
5525   application.ProcessEvent(touchEvent); // process a touch event on ordered actors.
5526
5527   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5528   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5529   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5530
5531   ResetTouchCallbacks();
5532
5533   END_TEST;
5534 }
5535
5536 int UtcDaliActorRaiseAbove2(void)
5537 {
5538   tet_infoline("UtcDaliActor RaiseToAbove test using SIBLING_ORDER property\n");
5539
5540   TestApplication application;
5541
5542   Integration::Scene stage(application.GetScene());
5543
5544   Actor actorA = Actor::New();
5545   Actor actorB = Actor::New();
5546   Actor actorC = Actor::New();
5547
5548   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5549   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5550
5551   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5552   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5553
5554   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5555   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5556
5557   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5558   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5559
5560   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5561   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5562
5563   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5564   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5565
5566   stage.Add(actorA);
5567   stage.Add(actorB);
5568   stage.Add(actorC);
5569
5570   ResetTouchCallbacks();
5571
5572   application.SendNotification();
5573   application.Render();
5574
5575   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5576   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5577   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5578
5579   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5580   // Only top actor will get touched.
5581   actorA.TouchedSignal().Connect(TestTouchCallback);
5582   actorB.TouchedSignal().Connect(TestTouchCallback2);
5583   actorC.TouchedSignal().Connect(TestTouchCallback3);
5584
5585   bool                     orderChangedSignal(false);
5586   Actor                    orderChangedActor;
5587   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5588   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5589
5590   Dali::Integration::Point point;
5591   point.SetDeviceId(1);
5592   point.SetState(PointState::DOWN);
5593   point.SetScreenPosition(Vector2(10.f, 10.f));
5594   Dali::Integration::TouchEvent touchEvent;
5595   touchEvent.AddPoint(point);
5596
5597   application.ProcessEvent(touchEvent);
5598
5599   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5600   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5601   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5602
5603   ResetTouchCallbacks();
5604
5605   tet_printf("Raise actor B Above Actor C\n");
5606
5607   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5608   int newOrder                                = actorC[DevelActor::Property::SIBLING_ORDER];
5609   actorB[DevelActor::Property::SIBLING_ORDER] = newOrder;
5610   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5611   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5612
5613   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5614   application.SendNotification();
5615   application.ProcessEvent(touchEvent);
5616
5617   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5618   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5619   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5620
5621   ResetTouchCallbacks();
5622
5623   tet_printf("Raise actor A Above Actor B\n");
5624
5625   orderChangedSignal = false;
5626
5627   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5628   newOrder                                    = actorB[DevelActor::Property::SIBLING_ORDER];
5629   actorA[DevelActor::Property::SIBLING_ORDER] = newOrder;
5630   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5631   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5632
5633   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5634   application.SendNotification();
5635
5636   application.ProcessEvent(touchEvent); // process a touch event on ordered actors.
5637
5638   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5639   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5640   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5641
5642   ResetTouchCallbacks();
5643
5644   END_TEST;
5645 }
5646
5647 int UtcDaliActorLowerBelow(void)
5648 {
5649   tet_infoline("UtcDaliActor LowerBelow test \n");
5650
5651   TestApplication application;
5652
5653   Integration::Scene stage(application.GetScene());
5654
5655   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5656   // enables checking of which actor the uniform is assigned too
5657   Shader shaderA = CreateShader();
5658   shaderA.RegisterProperty("uRendererColor", 1.f);
5659
5660   Shader shaderB = CreateShader();
5661   shaderB.RegisterProperty("uRendererColor", 2.f);
5662
5663   Shader shaderC = CreateShader();
5664   shaderC.RegisterProperty("uRendererColor", 3.f);
5665
5666   Actor actorA = Actor::New();
5667   Actor actorB = Actor::New();
5668   Actor actorC = Actor::New();
5669
5670   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5671   Geometry geometry = CreateQuadGeometry();
5672
5673   Renderer rendererA = Renderer::New(geometry, shaderA);
5674   actorA.AddRenderer(rendererA);
5675
5676   Renderer rendererB = Renderer::New(geometry, shaderB);
5677   actorB.AddRenderer(rendererB);
5678
5679   Renderer rendererC = Renderer::New(geometry, shaderC);
5680   actorC.AddRenderer(rendererC);
5681
5682   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5683   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5684
5685   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5686   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5687
5688   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5689   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5690
5691   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5692   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5693
5694   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5695   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5696
5697   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5698   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5699
5700   Actor container = Actor::New();
5701   container.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5702   container.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
5703   stage.Add(container);
5704
5705   container.Add(actorA);
5706   container.Add(actorB);
5707   container.Add(actorC);
5708
5709   ResetTouchCallbacks();
5710
5711   // Connect ChildOrderChangedSignal
5712   bool                     orderChangedSignal(false);
5713   Actor                    orderChangedActor;
5714   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5715   DevelActor::ChildOrderChangedSignal(container).Connect(&application, f);
5716
5717   // Set up gl abstraction trace so can query the set uniform order
5718   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5719   glAbstraction.EnableSetUniformCallTrace(true);
5720   glAbstraction.ResetSetUniformCallStack();
5721   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5722
5723   glAbstraction.ResetSetUniformCallStack();
5724
5725   application.SendNotification();
5726   application.Render();
5727
5728   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5729
5730   // Test order of uniforms in stack
5731   int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5732   int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5733   int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5734
5735   tet_infoline("Testing C above B and A at bottom\n");
5736   bool CBA = (indexC > indexB) && (indexB > indexA);
5737
5738   DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
5739
5740   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5741   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5742   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5743
5744   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5745   // Only top actor will get touched.
5746   actorA.TouchedSignal().Connect(TestTouchCallback);
5747   actorB.TouchedSignal().Connect(TestTouchCallback2);
5748   actorC.TouchedSignal().Connect(TestTouchCallback3);
5749
5750   Dali::Integration::Point point;
5751   point.SetDeviceId(1);
5752   point.SetState(PointState::DOWN);
5753   point.SetScreenPosition(Vector2(10.f, 10.f));
5754   Dali::Integration::TouchEvent touchEvent;
5755   touchEvent.AddPoint(point);
5756
5757   tet_infoline("UtcDaliActor Test Set up completed \n");
5758
5759   application.ProcessEvent(touchEvent);
5760
5761   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5762   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5763   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5764
5765   ResetTouchCallbacks();
5766
5767   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");
5768
5769   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5770   actorC.LowerBelow(actorB);
5771   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5772   DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
5773
5774   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5775   application.SendNotification();
5776   application.Render();
5777
5778   application.ProcessEvent(touchEvent); // touch event
5779
5780   glSetUniformStack.Reset();
5781
5782   application.SendNotification();
5783   application.Render();
5784
5785   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5786
5787   // Test order of uniforms in stack
5788   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5789   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5790   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5791
5792   tet_infoline("Testing render order is A, C, B");
5793   DALI_TEST_EQUALS(indexC > indexA, true, TEST_LOCATION);
5794   DALI_TEST_EQUALS(indexB > indexC, true, TEST_LOCATION);
5795
5796   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5797   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5798   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5799
5800   ResetTouchCallbacks();
5801
5802   tet_printf("Lower actor C below Actor A leaving B on top\n");
5803
5804   orderChangedSignal = false;
5805
5806   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5807   actorC.LowerBelow(actorA);
5808   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5809   DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
5810
5811   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5812   application.SendNotification();
5813   application.Render();
5814
5815   application.ProcessEvent(touchEvent);
5816
5817   glSetUniformStack.Reset();
5818
5819   application.Render();
5820   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5821
5822   // Test order of uniforms in stack
5823   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5824   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5825   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5826
5827   DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
5828   DALI_TEST_EQUALS(indexB > indexA, true, TEST_LOCATION);
5829
5830   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5831   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5832   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5833
5834   ResetTouchCallbacks();
5835
5836   tet_printf("Lower actor B below Actor C leaving A on top\n");
5837
5838   orderChangedSignal = false;
5839
5840   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5841   actorB.LowerBelow(actorC);
5842   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5843   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5844
5845   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5846   application.SendNotification();
5847   application.Render();
5848
5849   application.ProcessEvent(touchEvent);
5850
5851   glSetUniformStack.Reset();
5852
5853   application.Render();
5854   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5855
5856   // Test order of uniforms in stack
5857   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5858   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5859   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5860
5861   DALI_TEST_EQUALS(indexC > indexB, true, TEST_LOCATION);
5862   DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
5863
5864   END_TEST;
5865 }
5866
5867 int UtcDaliActorLowerBelow2(void)
5868 {
5869   tet_infoline("UtcDaliActor LowerBelow test using SIBLING_ORDER property\n");
5870
5871   TestApplication application;
5872
5873   Integration::Scene stage(application.GetScene());
5874
5875   // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5876   // enables checking of which actor the uniform is assigned too
5877   Shader shaderA = CreateShader();
5878   shaderA.RegisterProperty("uRendererColor", 1.f);
5879
5880   Shader shaderB = CreateShader();
5881   shaderB.RegisterProperty("uRendererColor", 2.f);
5882
5883   Shader shaderC = CreateShader();
5884   shaderC.RegisterProperty("uRendererColor", 3.f);
5885
5886   Actor actorA = Actor::New();
5887   Actor actorB = Actor::New();
5888   Actor actorC = Actor::New();
5889
5890   // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5891   Geometry geometry = CreateQuadGeometry();
5892
5893   Renderer rendererA = Renderer::New(geometry, shaderA);
5894   actorA.AddRenderer(rendererA);
5895
5896   Renderer rendererB = Renderer::New(geometry, shaderB);
5897   actorB.AddRenderer(rendererB);
5898
5899   Renderer rendererC = Renderer::New(geometry, shaderC);
5900   actorC.AddRenderer(rendererC);
5901
5902   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5903   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5904
5905   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5906   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5907
5908   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5909   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5910
5911   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5912   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5913
5914   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5915   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5916
5917   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5918   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5919
5920   Actor container = Actor::New();
5921   container.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5922   container.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
5923   stage.Add(container);
5924
5925   container.Add(actorA);
5926   container.Add(actorB);
5927   container.Add(actorC);
5928
5929   ResetTouchCallbacks();
5930
5931   // Connect ChildOrderChangedSignal
5932   bool                     orderChangedSignal(false);
5933   Actor                    orderChangedActor;
5934   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5935   DevelActor::ChildOrderChangedSignal(container).Connect(&application, f);
5936
5937   // Set up gl abstraction trace so can query the set uniform order
5938   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5939   glAbstraction.EnableSetUniformCallTrace(true);
5940   glAbstraction.ResetSetUniformCallStack();
5941   TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5942
5943   glAbstraction.ResetSetUniformCallStack();
5944
5945   application.SendNotification();
5946   application.Render();
5947
5948   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5949
5950   // Test order of uniforms in stack
5951   int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5952   int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5953   int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5954
5955   tet_infoline("Testing C above B and A at bottom\n");
5956   bool CBA = (indexC > indexB) && (indexB > indexA);
5957
5958   DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
5959
5960   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5961   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5962   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5963
5964   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5965   // Only top actor will get touched.
5966   actorA.TouchedSignal().Connect(TestTouchCallback);
5967   actorB.TouchedSignal().Connect(TestTouchCallback2);
5968   actorC.TouchedSignal().Connect(TestTouchCallback3);
5969
5970   Dali::Integration::Point point;
5971   point.SetDeviceId(1);
5972   point.SetState(PointState::DOWN);
5973   point.SetScreenPosition(Vector2(10.f, 10.f));
5974   Dali::Integration::TouchEvent touchEvent;
5975   touchEvent.AddPoint(point);
5976
5977   tet_infoline("UtcDaliActor Test Set up completed \n");
5978
5979   application.ProcessEvent(touchEvent);
5980
5981   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5982   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5983   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5984
5985   ResetTouchCallbacks();
5986
5987   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");
5988
5989   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5990   actorC[DevelActor::Property::SIBLING_ORDER] = 1;
5991   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5992   DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
5993
5994   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5995   application.SendNotification();
5996   application.Render();
5997
5998   application.ProcessEvent(touchEvent); // touch event
5999
6000   glSetUniformStack.Reset();
6001
6002   application.SendNotification();
6003   application.Render();
6004
6005   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6006
6007   // Test order of uniforms in stack
6008   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6009   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6010   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6011
6012   tet_infoline("Testing render order is A, C, B");
6013   DALI_TEST_EQUALS(indexC > indexA, true, TEST_LOCATION);
6014   DALI_TEST_EQUALS(indexB > indexC, true, TEST_LOCATION);
6015
6016   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6017   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6018   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6019
6020   ResetTouchCallbacks();
6021
6022   tet_printf("Lower actor C below Actor A leaving B on top\n");
6023
6024   orderChangedSignal = false;
6025
6026   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6027   actorC[DevelActor::Property::SIBLING_ORDER] = 0;
6028   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6029   DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
6030
6031   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6032   application.SendNotification();
6033   application.Render();
6034
6035   application.ProcessEvent(touchEvent);
6036
6037   glSetUniformStack.Reset();
6038
6039   application.Render();
6040   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6041
6042   // Test order of uniforms in stack
6043   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6044   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6045   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6046
6047   DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
6048   DALI_TEST_EQUALS(indexB > indexA, true, TEST_LOCATION);
6049
6050   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6051   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6052   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6053
6054   ResetTouchCallbacks();
6055
6056   tet_printf("Lower actor B below Actor C leaving A on top\n");
6057
6058   orderChangedSignal = false;
6059
6060   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6061   actorB[DevelActor::Property::SIBLING_ORDER] = 0;
6062   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6063   DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
6064
6065   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6066   application.SendNotification();
6067   application.Render();
6068
6069   application.ProcessEvent(touchEvent);
6070
6071   glSetUniformStack.Reset();
6072
6073   application.Render();
6074   tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6075
6076   // Test order of uniforms in stack
6077   indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6078   indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6079   indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6080
6081   DALI_TEST_EQUALS(indexC > indexB, true, TEST_LOCATION);
6082   DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
6083
6084   END_TEST;
6085 }
6086
6087 int UtcDaliActorRaiseAboveDifferentParentsN(void)
6088 {
6089   tet_infoline("UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n");
6090
6091   TestApplication application;
6092
6093   Integration::Scene stage(application.GetScene());
6094
6095   Actor parentA = Actor::New();
6096   Actor parentB = Actor::New();
6097   parentA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6098   parentA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6099   parentB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6100   parentB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6101
6102   parentA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6103   parentA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6104
6105   parentB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6106   parentB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6107
6108   stage.Add(parentA);
6109   stage.Add(parentB);
6110
6111   Actor actorA = Actor::New();
6112   Actor actorB = Actor::New();
6113   Actor actorC = Actor::New();
6114
6115   parentA.Add(actorA);
6116   parentA.Add(actorB);
6117
6118   tet_printf("Actor C added to different parent from A and B \n");
6119   parentB.Add(actorC);
6120
6121   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6122   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6123
6124   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6125   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6126
6127   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6128   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6129
6130   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6131   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6132
6133   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6134   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6135
6136   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6137   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6138
6139   ResetTouchCallbacks();
6140
6141   // Connect ChildOrderChangedSignal
6142   bool                     orderChangedSignal(false);
6143   Actor                    orderChangedActor;
6144   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6145   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6146
6147   application.SendNotification();
6148   application.Render();
6149
6150   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6151   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6152   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6153
6154   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6155   // Only top actor will get touched.
6156   actorA.TouchedSignal().Connect(TestTouchCallback);
6157   actorB.TouchedSignal().Connect(TestTouchCallback2);
6158   actorC.TouchedSignal().Connect(TestTouchCallback3);
6159
6160   Dali::Integration::Point point;
6161   point.SetDeviceId(1);
6162   point.SetState(PointState::DOWN);
6163   point.SetScreenPosition(Vector2(10.f, 10.f));
6164   Dali::Integration::TouchEvent touchEvent;
6165   touchEvent.AddPoint(point);
6166
6167   application.ProcessEvent(touchEvent);
6168
6169   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6170   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6171   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6172
6173   ResetTouchCallbacks();
6174
6175   tet_printf("Raise actor A Above Actor C which have different parents\n");
6176
6177   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6178   actorA.RaiseAbove(actorC);
6179   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6180
6181   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6182   application.SendNotification();
6183
6184   application.ProcessEvent(touchEvent); // touch event
6185
6186   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6187   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6188   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6189
6190   ResetTouchCallbacks();
6191
6192   END_TEST;
6193 }
6194
6195 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
6196 {
6197   tet_infoline("UtcDaliActor Test  raiseAbove and lowerBelow api when target Actor has no parent \n");
6198
6199   TestApplication application;
6200
6201   Integration::Scene stage(application.GetScene());
6202
6203   Actor actorA = Actor::New();
6204   Actor actorB = Actor::New();
6205   Actor actorC = Actor::New();
6206
6207   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6208   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6209
6210   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6211   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6212
6213   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6214   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6215
6216   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6217   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6218
6219   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6220   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6221
6222   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6223   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6224
6225   ResetTouchCallbacks();
6226
6227   // Connect ChildOrderChangedSignal
6228   bool                     orderChangedSignal(false);
6229   Actor                    orderChangedActor;
6230   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6231   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6232
6233   application.SendNotification();
6234   application.Render();
6235
6236   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6237   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6238   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6239
6240   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6241   // Only top actor will get touched.
6242   actorA.TouchedSignal().Connect(TestTouchCallback);
6243   actorB.TouchedSignal().Connect(TestTouchCallback2);
6244   actorC.TouchedSignal().Connect(TestTouchCallback3);
6245
6246   Dali::Integration::Point point;
6247   point.SetDeviceId(1);
6248   point.SetState(PointState::DOWN);
6249   point.SetScreenPosition(Vector2(10.f, 10.f));
6250   Dali::Integration::TouchEvent touchEvent;
6251   touchEvent.AddPoint(point);
6252
6253   tet_printf("Raise actor A Above Actor C which have no parents\n");
6254
6255   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6256   actorA.RaiseAbove(actorC);
6257   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6258
6259   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6260   application.SendNotification();
6261
6262   application.ProcessEvent(touchEvent);
6263
6264   tet_printf("Not parented so RaiseAbove should show no effect\n");
6265
6266   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6267   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6268   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6269
6270   ResetTouchCallbacks();
6271
6272   orderChangedSignal = false;
6273
6274   stage.Add(actorB);
6275   tet_printf("Lower actor A below Actor C when only A is not on stage \n");
6276
6277   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6278   actorA.LowerBelow(actorC);
6279   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6280
6281   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6282   application.SendNotification();
6283   application.Render();
6284
6285   application.ProcessEvent(touchEvent);
6286
6287   tet_printf("Actor A not parented so LowerBelow should show no effect\n");
6288   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6289   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6290   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6291
6292   ResetTouchCallbacks();
6293
6294   orderChangedSignal = false;
6295
6296   tet_printf("Adding Actor A to stage, will be on top\n");
6297
6298   stage.Add(actorA);
6299   application.SendNotification();
6300   application.Render();
6301
6302   tet_printf("Raise actor B Above Actor C when only B has a parent\n");
6303
6304   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6305   actorB.RaiseAbove(actorC);
6306   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6307
6308   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6309   application.SendNotification();
6310
6311   application.ProcessEvent(touchEvent);
6312
6313   tet_printf("C not parented so RaiseAbove should show no effect\n");
6314   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6315   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6316   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6317
6318   ResetTouchCallbacks();
6319
6320   orderChangedSignal = false;
6321
6322   tet_printf("Lower actor A below Actor C when only A has a parent\n");
6323
6324   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6325   actorA.LowerBelow(actorC);
6326   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6327
6328   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6329   application.SendNotification();
6330
6331   application.ProcessEvent(touchEvent);
6332
6333   tet_printf("C not parented so LowerBelow should show no effect\n");
6334   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6335   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6336   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6337
6338   ResetTouchCallbacks();
6339
6340   orderChangedSignal = false;
6341
6342   stage.Add(actorC);
6343
6344   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6345   actorA.RaiseAbove(actorC);
6346   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6347   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6348
6349   // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6350   application.SendNotification();
6351   application.Render();
6352
6353   application.ProcessEvent(touchEvent);
6354
6355   tet_printf("Raise actor A Above Actor C, now both have same parent \n");
6356   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6357   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6358   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6359
6360   END_TEST;
6361 }
6362
6363 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
6364 {
6365   tet_infoline("UtcDaliActor Test all raise/lower api when actor has no parent \n");
6366
6367   TestApplication application;
6368
6369   Integration::Scene stage(application.GetScene());
6370
6371   Actor actorA = Actor::New();
6372   Actor actorB = Actor::New();
6373   Actor actorC = Actor::New();
6374
6375   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6376   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6377
6378   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6379   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6380
6381   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6382   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6383
6384   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6385   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6386
6387   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6388   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6389
6390   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6391   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6392
6393   ResetTouchCallbacks();
6394
6395   // Connect ChildOrderChangedSignal
6396   bool                     orderChangedSignal(false);
6397   Actor                    orderChangedActor;
6398   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6399   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6400
6401   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6402   // Only top actor will get touched.
6403   actorA.TouchedSignal().Connect(TestTouchCallback);
6404   actorB.TouchedSignal().Connect(TestTouchCallback2);
6405   actorC.TouchedSignal().Connect(TestTouchCallback3);
6406
6407   Dali::Integration::Point point;
6408   point.SetDeviceId(1);
6409   point.SetState(PointState::DOWN);
6410   point.SetScreenPosition(Vector2(10.f, 10.f));
6411   Dali::Integration::TouchEvent touchEvent;
6412   touchEvent.AddPoint(point);
6413
6414   stage.Add(actorA);
6415   tet_printf("Raise actor B Above Actor C but B not parented\n");
6416
6417   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6418   actorB.Raise();
6419   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6420
6421   application.SendNotification();
6422   application.Render();
6423
6424   application.ProcessEvent(touchEvent);
6425
6426   tet_printf("Not parented so RaiseAbove should show no effect\n");
6427
6428   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6429   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6430   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6431
6432   tet_printf("Raise actor B Above Actor C but B not parented\n");
6433   ResetTouchCallbacks();
6434
6435   orderChangedSignal = false;
6436
6437   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6438   actorC.Lower();
6439   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6440
6441   // Sort actor tree before next touch event
6442   application.SendNotification();
6443   application.Render();
6444
6445   application.ProcessEvent(touchEvent);
6446
6447   tet_printf("Not parented so RaiseAbove should show no effect\n");
6448
6449   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6450   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6451   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6452   ResetTouchCallbacks();
6453
6454   orderChangedSignal = false;
6455
6456   tet_printf("Lower actor C below B but C not parented\n");
6457
6458   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6459   actorB.Lower();
6460   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6461
6462   // Sort actor tree before next touch event
6463   application.SendNotification();
6464   application.Render();
6465
6466   application.ProcessEvent(touchEvent);
6467
6468   tet_printf("Not parented so Lower should show no effect\n");
6469
6470   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6471   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6472   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6473   ResetTouchCallbacks();
6474
6475   orderChangedSignal = false;
6476
6477   tet_printf("Raise actor B to top\n");
6478
6479   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6480   actorB.RaiseToTop();
6481   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6482
6483   // Sort actor tree before next touch event
6484   application.SendNotification();
6485   application.Render();
6486
6487   application.ProcessEvent(touchEvent);
6488
6489   tet_printf("Not parented so RaiseToTop should show no effect\n");
6490
6491   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6492   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6493   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6494   ResetTouchCallbacks();
6495
6496   orderChangedSignal = false;
6497
6498   tet_printf("Add ActorB to stage so only Actor C not parented\n");
6499
6500   stage.Add(actorB);
6501
6502   tet_printf("Lower actor C to Bottom, B stays at top\n");
6503
6504   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6505   actorC.LowerToBottom();
6506   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6507
6508   application.SendNotification();
6509   application.Render();
6510
6511   application.ProcessEvent(touchEvent);
6512
6513   tet_printf("Not parented so LowerToBottom should show no effect\n");
6514
6515   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6516   DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6517   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6518   ResetTouchCallbacks();
6519
6520   END_TEST;
6521 }
6522
6523 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
6524 {
6525   tet_infoline("UtcDaliActor RaiseToAbove and  test with actor provided as target resulting in a no operation \n");
6526
6527   TestApplication application;
6528
6529   Integration::Scene stage(application.GetScene());
6530
6531   Actor actorA = Actor::New();
6532   Actor actorB = Actor::New();
6533   Actor actorC = Actor::New();
6534
6535   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6536   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6537
6538   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6539   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6540
6541   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6542   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6543
6544   actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6545   actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6546
6547   actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6548   actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6549
6550   actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6551   actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6552
6553   stage.Add(actorA);
6554   stage.Add(actorB);
6555   stage.Add(actorC);
6556
6557   // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6558   // Only top actor will get touched.
6559   actorA.TouchedSignal().Connect(TestTouchCallback);
6560   actorB.TouchedSignal().Connect(TestTouchCallback2);
6561   actorC.TouchedSignal().Connect(TestTouchCallback3);
6562
6563   ResetTouchCallbacks();
6564
6565   // Connect ChildOrderChangedSignal
6566   bool                     orderChangedSignal(false);
6567   Actor                    orderChangedActor;
6568   ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6569   DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6570
6571   application.SendNotification();
6572   application.Render();
6573
6574   Dali::Integration::Point point;
6575   point.SetDeviceId(1);
6576   point.SetState(PointState::DOWN);
6577   point.SetScreenPosition(Vector2(10.f, 10.f));
6578   Dali::Integration::TouchEvent touchEvent;
6579   touchEvent.AddPoint(point);
6580
6581   application.ProcessEvent(touchEvent);
6582
6583   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6584   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6585   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6586
6587   ResetTouchCallbacks();
6588
6589   tet_infoline("Raise actor A Above Actor A which is the same actor!!\n");
6590
6591   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6592   actorA.RaiseAbove(actorA);
6593   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6594   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6595
6596   application.SendNotification();
6597   application.Render();
6598
6599   application.ProcessEvent(touchEvent);
6600
6601   tet_infoline("No target is source Actor so RaiseAbove should show no effect\n");
6602
6603   DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6604   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6605   DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6606
6607   ResetTouchCallbacks();
6608
6609   orderChangedSignal = false;
6610
6611   DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6612   actorA.RaiseAbove(actorC);
6613   DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6614   DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6615
6616   application.SendNotification();
6617   application.Render();
6618
6619   application.ProcessEvent(touchEvent);
6620
6621   tet_infoline("Raise actor A Above Actor C which will now be successful \n");
6622   DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6623   DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6624   DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6625
6626   END_TEST;
6627 }
6628
6629 int UtcDaliActorGetScreenPosition(void)
6630 {
6631   tet_infoline("UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n");
6632
6633   TestApplication application;
6634
6635   Integration::Scene stage(application.GetScene());
6636
6637   Actor actorA = Actor::New();
6638   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6639
6640   Vector2 size2(10.0f, 20.0f);
6641   actorA.SetProperty(Actor::Property::SIZE, size2);
6642
6643   actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6644
6645   tet_infoline("UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n");
6646
6647   stage.Add(actorA);
6648
6649   application.SendNotification();
6650   application.Render();
6651
6652   Vector3 actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6653   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6654
6655   tet_printf("Actor World Position ( %f %f ) AnchorPoint::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
6656   tet_printf("Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y);
6657
6658   DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6659   DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6660
6661   tet_infoline("UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n");
6662
6663   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6664
6665   application.SendNotification();
6666   application.Render();
6667
6668   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6669   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6670
6671   tet_printf("Actor World Position  ( %f %f ) AnchorPoint::TOP_LEFT  \n", actorWorldPosition.x, actorWorldPosition.y);
6672   tet_printf("Actor Screen Position  ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y);
6673
6674   DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6675   DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6676
6677   tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n");
6678
6679   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6680
6681   application.SendNotification();
6682   application.Render();
6683
6684   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6685   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6686
6687   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT   \n", actorWorldPosition.x, actorWorldPosition.y);
6688   tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT  \n", actorScreenPosition.x, actorScreenPosition.y);
6689
6690   DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6691   DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6692
6693   tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n");
6694
6695   actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 0.0));
6696
6697   application.SendNotification();
6698   application.Render();
6699
6700   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6701   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6702
6703   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorWorldPosition.x, actorWorldPosition.y);
6704   tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0   \n", actorScreenPosition.x, actorScreenPosition.y);
6705
6706   DALI_TEST_EQUALS(actorScreenPosition.x, 30lu, TEST_LOCATION);
6707   DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6708
6709   tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n");
6710
6711   actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 420.0));
6712
6713   application.SendNotification();
6714   application.Render();
6715
6716   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6717   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6718
6719   DALI_TEST_EQUALS(actorScreenPosition.x, 30lu, TEST_LOCATION);
6720   DALI_TEST_EQUALS(actorScreenPosition.y, 420lu, TEST_LOCATION);
6721
6722   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n", actorWorldPosition.x, actorWorldPosition.y);
6723   tet_printf("Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y);
6724
6725   tet_infoline("UtcDaliActorGetScreenPosition Scale parent and check child's screen position \n");
6726
6727   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6728   actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 30.0));
6729
6730   Actor actorB = Actor::New();
6731   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6732   actorB.SetProperty(Actor::Property::SIZE, size2);
6733   actorB.SetProperty(Actor::Property::POSITION, Vector2(10.f, 10.f));
6734   actorA.Add(actorB);
6735
6736   actorA.SetProperty(Actor::Property::SCALE, 2.0f);
6737
6738   application.SendNotification();
6739   application.Render();
6740
6741   actorScreenPosition = actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6742
6743   DALI_TEST_EQUALS(actorScreenPosition.x, 50lu, TEST_LOCATION);
6744   DALI_TEST_EQUALS(actorScreenPosition.y, 50lu, TEST_LOCATION);
6745
6746   END_TEST;
6747 }
6748
6749 int UtcDaliActorGetScreenPositionAfterScaling(void)
6750 {
6751   tet_infoline("UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n");
6752
6753   TestApplication application;
6754
6755   Integration::Scene stage(application.GetScene());
6756
6757   Actor actorA = Actor::New();
6758   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6759
6760   Vector2 size2(10.0f, 20.0f);
6761   actorA.SetProperty(Actor::Property::SIZE, size2);
6762   actorA.SetProperty(Actor::Property::SCALE, 1.5f);
6763   actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6764
6765   tet_infoline("UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n");
6766
6767   stage.Add(actorA);
6768
6769   application.SendNotification();
6770   application.Render();
6771
6772   Vector3 actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6773   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6774
6775   tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y);
6776   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6777
6778   DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6779   DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6780
6781   tet_infoline("UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n");
6782
6783   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6784
6785   application.SendNotification();
6786   application.Render();
6787
6788   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6789   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6790
6791   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
6792   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6793
6794   DALI_TEST_EQUALS(actorScreenPosition.x, 0.0f, TEST_LOCATION);
6795   DALI_TEST_EQUALS(actorScreenPosition.y, 0.0f, TEST_LOCATION);
6796
6797   END_TEST;
6798 }
6799
6800 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
6801 {
6802   tet_infoline("UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n");
6803
6804   TestApplication application;
6805
6806   Integration::Scene stage(application.GetScene());
6807
6808   Actor actorA = Actor::New();
6809   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6810   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6811   Vector2 size2(10.0f, 20.0f);
6812   actorA.SetProperty(Actor::Property::SIZE, size2);
6813   actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6814
6815   tet_infoline(" TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6816
6817   stage.Add(actorA);
6818
6819   application.SendNotification();
6820   application.Render();
6821
6822   Vector3 actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6823   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6824
6825   tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n", actorWorldPosition.x, actorWorldPosition.y);
6826   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6827
6828   DALI_TEST_EQUALS(actorScreenPosition.x, 240.0f, TEST_LOCATION);
6829   DALI_TEST_EQUALS(actorScreenPosition.y, 400.0f, TEST_LOCATION);
6830
6831   tet_infoline(" BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n");
6832
6833   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
6834   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6835
6836   application.SendNotification();
6837   application.Render();
6838
6839   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6840   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6841
6842   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
6843   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6844
6845   DALI_TEST_EQUALS(actorScreenPosition.x, 480.0f, TEST_LOCATION);
6846   DALI_TEST_EQUALS(actorScreenPosition.y, 0.0f, TEST_LOCATION);
6847
6848   END_TEST;
6849   END_TEST;
6850 }
6851
6852 int UtcDaliActorGetScreenPositionWithChildActors(void)
6853 {
6854   tet_infoline("UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n");
6855
6856   TestApplication application;
6857
6858   Integration::Scene stage(application.GetScene());
6859
6860   tet_infoline("Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6861
6862   Actor actorA = Actor::New();
6863   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6864   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6865   Vector2 size1(10.0f, 20.0f);
6866   actorA.SetProperty(Actor::Property::SIZE, size1);
6867   actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6868
6869   tet_infoline("Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6870
6871   Actor parentActorA = Actor::New();
6872   parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6873   parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6874   Vector2 size2(30.0f, 60.0f);
6875   parentActorA.SetProperty(Actor::Property::SIZE, size2);
6876   parentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6877
6878   tet_infoline("Add child 1 to Parent 1 and check screen position \n");
6879
6880   stage.Add(parentActorA);
6881   parentActorA.Add(actorA);
6882
6883   application.SendNotification();
6884   application.Render();
6885
6886   Vector3 actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6887   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6888
6889   tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n", actorWorldPosition.x, actorWorldPosition.y);
6890   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6891
6892   DALI_TEST_EQUALS(actorScreenPosition.x, 255.0f, TEST_LOCATION);
6893   DALI_TEST_EQUALS(actorScreenPosition.y, 430.0f, TEST_LOCATION);
6894
6895   tet_infoline("Test 2\n");
6896
6897   tet_infoline("change parent anchor point and parent origin then check screen position \n");
6898
6899   parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
6900   parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6901
6902   application.SendNotification();
6903   application.Render();
6904
6905   actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6906   actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6907
6908   tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT  \n", actorWorldPosition.x, actorWorldPosition.y);
6909   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6910
6911   DALI_TEST_EQUALS(actorScreenPosition.x, 15.0f, TEST_LOCATION);
6912   DALI_TEST_EQUALS(actorScreenPosition.y, -30.0f, TEST_LOCATION);
6913
6914   END_TEST;
6915 }
6916
6917 int UtcDaliActorGetScreenPositionWithChildActors02(void)
6918 {
6919   tet_infoline("UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n");
6920
6921   TestApplication application;
6922
6923   Integration::Scene stage(application.GetScene());
6924
6925   tet_infoline("Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6926
6927   Actor actorA = Actor::New();
6928   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6929   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6930   Vector2 size1(10.0f, 20.0f);
6931   actorA.SetProperty(Actor::Property::SIZE, size1);
6932   actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6933
6934   tet_infoline("Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6935
6936   Actor parentActorA = Actor::New();
6937   parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6938   parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6939   Vector2 size2(30.0f, 60.0f);
6940   parentActorA.SetProperty(Actor::Property::SIZE, size2);
6941   parentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6942
6943   tet_infoline("Create Grand Parent Actor 1 BOTTOM_LEFT Anchor Point, ParentOrigin::BOTTOM_LEFT and 0,0 position \n");
6944
6945   Actor grandParentActorA = Actor::New();
6946   grandParentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
6947   grandParentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
6948   Vector2 size3(60.0f, 120.0f);
6949   grandParentActorA.SetProperty(Actor::Property::SIZE, size3);
6950   grandParentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6951
6952   tet_infoline("Add Parent 1 to Grand Parent 1 \n");
6953
6954   stage.Add(grandParentActorA);
6955   grandParentActorA.Add(parentActorA);
6956
6957   tet_infoline("Add child 1 to Parent 1 and check screen position \n");
6958
6959   parentActorA.Add(actorA);
6960
6961   application.SendNotification();
6962   application.Render();
6963
6964   Vector3 actorWorldPosition  = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6965   Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6966
6967   tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER  \n", actorWorldPosition.x, actorWorldPosition.y);
6968   tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6969
6970   DALI_TEST_EQUALS(actorScreenPosition.x, 45.0f, TEST_LOCATION);
6971   DALI_TEST_EQUALS(actorScreenPosition.y, 770.0f, TEST_LOCATION);
6972
6973   END_TEST;
6974 }
6975
6976 int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void)
6977 {
6978   tet_infoline("UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse Check screen position where the position does not use the anchor point");
6979
6980   TestApplication application;
6981
6982   Integration::Scene stage(application.GetScene());
6983
6984   tet_infoline("Create an actor with AnchorPoint::TOP_LEFT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
6985
6986   Actor actorA = Actor::New();
6987   actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6988   actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6989   actorA.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6990   actorA.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 20.0f));
6991   stage.Add(actorA);
6992
6993   tet_infoline("Create an Actor with AnchorPoint::BOTTOM_RIGHT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
6994
6995   Actor actorB = Actor::New();
6996   actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6997   actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6998   actorB.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6999   Vector2 actorBSize(30.0f, 60.0f);
7000   actorB.SetProperty(Actor::Property::SIZE, actorBSize);
7001   stage.Add(actorB);
7002
7003   tet_infoline("Create an actor with AnchorPoint::CENTER, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
7004
7005   Actor actorC = Actor::New();
7006   actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7007   actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7008   actorC.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7009   Vector2 actorCSize(60.0f, 120.0f);
7010   actorC.SetProperty(Actor::Property::SIZE, actorCSize);
7011   stage.Add(actorC);
7012
7013   application.SendNotification();
7014   application.Render();
7015
7016   tet_infoline("Despite differing sizes and anchor-points, the screen position for all actors is the same");
7017
7018   Vector2 center(stage.GetSize() * 0.5f);
7019
7020   DALI_TEST_EQUALS(actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
7021   DALI_TEST_EQUALS(actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
7022   DALI_TEST_EQUALS(actorC.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
7023
7024   tet_infoline("Add scale to all actors");
7025
7026   actorA.SetProperty(Actor::Property::SCALE, 2.0f);
7027   actorB.SetProperty(Actor::Property::SCALE, 2.0f);
7028   actorC.SetProperty(Actor::Property::SCALE, 2.0f);
7029
7030   application.SendNotification();
7031   application.Render();
7032
7033   DALI_TEST_EQUALS(actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center /* TOP_LEFT Anchor */, TEST_LOCATION);
7034   DALI_TEST_EQUALS(actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center - actorBSize /* BOTTOM_RIGHT Anchor */, TEST_LOCATION);
7035   DALI_TEST_EQUALS(actorC.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center - actorCSize * 0.5f /* CENTER Anchor*/, TEST_LOCATION);
7036
7037   END_TEST;
7038 }
7039
7040 int utcDaliActorPositionUsesAnchorPoint(void)
7041 {
7042   TestApplication application;
7043   tet_infoline("Check default behaviour\n");
7044
7045   Actor actor = Actor::New();
7046   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7047   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7048   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7049   application.GetScene().Add(actor);
7050
7051   application.SendNotification();
7052   application.Render();
7053
7054   tet_infoline("Check that the world position is in the center\n");
7055   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
7056
7057   tet_infoline("Set the position uses anchor point property to false\n");
7058   actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7059
7060   application.SendNotification();
7061   application.Render();
7062
7063   tet_infoline("Check that the world position has changed appropriately\n");
7064   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7065
7066   END_TEST;
7067 }
7068
7069 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
7070 {
7071   TestApplication application;
7072   tet_infoline("Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7073
7074   Actor actor = Actor::New();
7075   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7076   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7077   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7078   actor.SetProperty(Actor::Property::SCALE, 2.0f);
7079   actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7080   application.GetScene().Add(actor);
7081
7082   application.SendNotification();
7083   application.Render();
7084
7085   tet_infoline("Check the world position is the same as it would be without a scale\n");
7086   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7087
7088   tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
7089   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7090   application.SendNotification();
7091   application.Render();
7092   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(100.0f, 100.0f, 0.0f), TEST_LOCATION);
7093
7094   tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
7095   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7096   application.SendNotification();
7097   application.Render();
7098   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
7099
7100   END_TEST;
7101 }
7102
7103 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
7104 {
7105   TestApplication application;
7106   tet_infoline("Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7107
7108   Actor actor = Actor::New();
7109   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7110   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7111   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7112   actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::ZAXIS));
7113   actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7114   application.GetScene().Add(actor);
7115
7116   application.SendNotification();
7117   application.Render();
7118
7119   tet_infoline("Check the world position is the same as it would be without a rotation\n");
7120   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7121
7122   tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
7123   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7124   application.SendNotification();
7125   application.Render();
7126   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(-50.0f, 50.0f, 0.0f), TEST_LOCATION);
7127
7128   tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
7129   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7130   application.SendNotification();
7131   application.Render();
7132   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(150.0f, 50.0f, 0.0f), TEST_LOCATION);
7133
7134   END_TEST;
7135 }
7136
7137 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
7138 {
7139   TestApplication application;
7140   tet_infoline("Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7141
7142   Actor actor = Actor::New();
7143   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7144   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7145   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7146   actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::ZAXIS));
7147   actor.SetProperty(Actor::Property::SCALE, 2.0f);
7148   actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7149   application.GetScene().Add(actor);
7150
7151   application.SendNotification();
7152   application.Render();
7153
7154   tet_infoline("Check the world position is the same as it would be without a scale and rotation\n");
7155   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7156
7157   tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
7158   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7159   application.SendNotification();
7160   application.Render();
7161   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(-100.0f, 100.0f, 0.0f), TEST_LOCATION);
7162
7163   tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
7164   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7165   application.SendNotification();
7166   application.Render();
7167   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(200.0f, 0.0f, 0.0f), TEST_LOCATION);
7168
7169   END_TEST;
7170 }
7171
7172 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
7173 {
7174   TestApplication application;
7175   tet_infoline("Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7176
7177   Actor parent = Actor::New();
7178
7179   application.GetScene().Add(parent);
7180   Vector2 stageSize(application.GetScene().GetSize());
7181
7182   Actor actor = Actor::New();
7183   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7184   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7185   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7186   actor.SetProperty(Actor::Property::INHERIT_SCALE, false);
7187   actor.SetProperty(Actor::Property::INHERIT_ORIENTATION, false);
7188   actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7189   parent.Add(actor);
7190
7191   application.SendNotification();
7192   application.Render();
7193
7194   const Vector3 expectedWorldPosition(-stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f);
7195
7196   tet_infoline("Check the world position is in the right place\n");
7197   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
7198
7199   tet_infoline("Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed");
7200   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7201   application.SendNotification();
7202   application.Render();
7203   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
7204
7205   tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed");
7206   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7207   application.SendNotification();
7208   application.Render();
7209   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
7210
7211   END_TEST;
7212 }
7213
7214 int utcDaliActorVisibilityChangeSignalSelf(void)
7215 {
7216   TestApplication application;
7217   tet_infoline("Check that the visibility change signal is called when the visibility changes for the actor itself");
7218
7219   Actor actor = Actor::New();
7220
7221   VisibilityChangedFunctorData data;
7222   DevelActor::VisibilityChangedSignal(actor).Connect(&application, VisibilityChangedFunctor(data));
7223
7224   actor.SetProperty(Actor::Property::VISIBLE, false);
7225
7226   data.Check(true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7227
7228   tet_infoline("Ensure functor is not called if we attempt to change the visibility to what it already is at");
7229   data.Reset();
7230
7231   actor.SetProperty(Actor::Property::VISIBLE, false);
7232   data.Check(false /* not called */, TEST_LOCATION);
7233
7234   tet_infoline("Change the visibility using properties, ensure called");
7235   data.Reset();
7236
7237   actor.SetProperty(Actor::Property::VISIBLE, true);
7238   data.Check(true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7239
7240   tet_infoline("Set the visibility to current using properties, ensure not called");
7241   data.Reset();
7242
7243   actor.SetProperty(Actor::Property::VISIBLE, true);
7244   data.Check(false /* not called */, TEST_LOCATION);
7245
7246   END_TEST;
7247 }
7248
7249 int utcDaliActorVisibilityChangeSignalChildren(void)
7250 {
7251   TestApplication application;
7252   tet_infoline("Check that the visibility change signal is called for the children when the visibility changes for the parent");
7253
7254   Actor parent = Actor::New();
7255   Actor child  = Actor::New();
7256   parent.Add(child);
7257
7258   Actor grandChild = Actor::New();
7259   child.Add(grandChild);
7260
7261   VisibilityChangedFunctorData parentData;
7262   VisibilityChangedFunctorData childData;
7263   VisibilityChangedFunctorData grandChildData;
7264
7265   tet_infoline("Only connect the child and grandchild, ensure they are called and not the parent");
7266   DevelActor::VisibilityChangedSignal(child).Connect(&application, VisibilityChangedFunctor(childData));
7267   DevelActor::VisibilityChangedSignal(grandChild).Connect(&application, VisibilityChangedFunctor(grandChildData));
7268
7269   parent.SetProperty(Actor::Property::VISIBLE, false);
7270   parentData.Check(false /* not called */, TEST_LOCATION);
7271   childData.Check(true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7272   grandChildData.Check(true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7273
7274   tet_infoline("Connect to the parent's signal as well and ensure all three are called");
7275   parentData.Reset();
7276   childData.Reset();
7277   grandChildData.Reset();
7278
7279   DevelActor::VisibilityChangedSignal(parent).Connect(&application, VisibilityChangedFunctor(parentData));
7280
7281   parent.SetProperty(Actor::Property::VISIBLE, true);
7282   parentData.Check(true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7283   childData.Check(true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7284   grandChildData.Check(true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7285
7286   tet_infoline("Ensure none of the functors are called if we attempt to change the visibility to what it already is at");
7287   parentData.Reset();
7288   childData.Reset();
7289   grandChildData.Reset();
7290
7291   parent.SetProperty(Actor::Property::VISIBLE, true);
7292   parentData.Check(false /* not called */, TEST_LOCATION);
7293   childData.Check(false /* not called */, TEST_LOCATION);
7294   grandChildData.Check(false /* not called */, TEST_LOCATION);
7295
7296   END_TEST;
7297 }
7298
7299 int utcDaliActorVisibilityChangeSignalAfterAnimation(void)
7300 {
7301   TestApplication application;
7302   tet_infoline("Check that the visibility change signal is emitted when the visibility changes when an animation starts");
7303
7304   Actor actor = Actor::New();
7305   application.GetScene().Add(actor);
7306
7307   application.SendNotification();
7308   application.Render();
7309
7310   VisibilityChangedFunctorData data;
7311   DevelActor::VisibilityChangedSignal(actor).Connect(&application, VisibilityChangedFunctor(data));
7312
7313   Animation animation = Animation::New(1.0f);
7314   animation.AnimateTo(Property(actor, Actor::Property::VISIBLE), false);
7315
7316   data.Check(false, TEST_LOCATION);
7317   DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7318   DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7319
7320   tet_infoline("Play the animation and check the property value");
7321   animation.Play();
7322
7323   data.Check(true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7324   DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::VISIBLE), false, TEST_LOCATION);
7325
7326   tet_infoline("Animation not currently finished, so the current visibility should still be true");
7327   DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7328
7329   application.SendNotification();
7330   application.Render(1100); // After the animation
7331
7332   DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), false, TEST_LOCATION);
7333
7334   END_TEST;
7335 }
7336
7337 int utcDaliActorVisibilityChangeSignalByName(void)
7338 {
7339   TestApplication application;
7340   tet_infoline("Check that the visibility change signal is called when the visibility changes for the actor itself");
7341
7342   Actor actor = Actor::New();
7343
7344   bool signalCalled = false;
7345   actor.ConnectSignal(&application, "visibilityChanged", VisibilityChangedVoidFunctor(signalCalled));
7346   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7347   actor.SetProperty(Actor::Property::VISIBLE, false);
7348   DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7349
7350   tet_infoline("Ensure functor is not called if we attempt to change the visibility to what it already is at");
7351   signalCalled = false;
7352   actor.SetProperty(Actor::Property::VISIBLE, false);
7353   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7354
7355   tet_infoline("Change the visibility using properties, ensure called");
7356   actor.SetProperty(Actor::Property::VISIBLE, true);
7357   DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7358
7359   tet_infoline("Set the visibility to current using properties, ensure not called");
7360   signalCalled = false;
7361
7362   actor.SetProperty(Actor::Property::VISIBLE, true);
7363   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7364
7365   END_TEST;
7366 }
7367
7368 static void LayoutDirectionChanged(Actor actor, LayoutDirection::Type type)
7369 {
7370   gLayoutDirectionType = type;
7371 }
7372
7373 int UtcDaliActorLayoutDirectionProperty(void)
7374 {
7375   TestApplication application;
7376   tet_infoline("Check layout direction property");
7377
7378   Actor actor0 = Actor::New();
7379   DALI_TEST_EQUALS(actor0.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7380   application.GetScene().Add(actor0);
7381
7382   application.SendNotification();
7383   application.Render();
7384
7385   Actor actor1 = Actor::New();
7386   DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7387   Actor actor2 = Actor::New();
7388   DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7389   Actor actor3 = Actor::New();
7390   DALI_TEST_EQUALS(actor3.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7391   Actor actor4 = Actor::New();
7392   DALI_TEST_EQUALS(actor4.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7393   Actor actor5 = Actor::New();
7394   DALI_TEST_EQUALS(actor5.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7395   Actor actor6 = Actor::New();
7396   DALI_TEST_EQUALS(actor6.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7397   Actor actor7 = Actor::New();
7398   DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7399   Actor actor8 = Actor::New();
7400   DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7401   Actor actor9 = Actor::New();
7402   DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7403
7404   actor1.Add(actor2);
7405   gLayoutDirectionType = LayoutDirection::LEFT_TO_RIGHT;
7406   actor2.LayoutDirectionChangedSignal().Connect(LayoutDirectionChanged);
7407
7408   DALI_TEST_EQUALS(actor1.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), true, TEST_LOCATION);
7409   actor1.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
7410   DALI_TEST_EQUALS(actor1.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), false, TEST_LOCATION);
7411
7412   DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7413   DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7414   DALI_TEST_EQUALS(gLayoutDirectionType, LayoutDirection::RIGHT_TO_LEFT, TEST_LOCATION);
7415
7416   actor1.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, true);
7417   actor0.Add(actor1);
7418   DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7419   DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7420
7421   application.GetScene().Add(actor3);
7422   actor3.Add(actor4);
7423   actor4.Add(actor5);
7424   actor5.Add(actor6);
7425   actor5.Add(actor7);
7426   actor7.Add(actor8);
7427   actor8.Add(actor9);
7428   actor3.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7429   actor5.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7430
7431   DALI_TEST_EQUALS(actor8.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), true, TEST_LOCATION);
7432   actor8.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, false);
7433   DALI_TEST_EQUALS(actor8.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), false, TEST_LOCATION);
7434
7435   actor7.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7436
7437   DALI_TEST_EQUALS(actor3.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7438   DALI_TEST_EQUALS(actor4.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7439   DALI_TEST_EQUALS(actor5.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7440   DALI_TEST_EQUALS(actor6.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7441   DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7442   DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7443   DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7444
7445   actor8.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7446   DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7447   DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7448
7449   actor7.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7450   DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7451   DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7452   DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7453
7454   actor8.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, true);
7455   DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7456   DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7457
7458   END_TEST;
7459 }
7460
7461 struct LayoutDirectionFunctor
7462 {
7463   LayoutDirectionFunctor(bool& signalCalled)
7464   : mSignalCalled(signalCalled)
7465   {
7466   }
7467
7468   LayoutDirectionFunctor(const LayoutDirectionFunctor& rhs)
7469   : mSignalCalled(rhs.mSignalCalled)
7470   {
7471   }
7472
7473   void operator()()
7474   {
7475     mSignalCalled = true;
7476   }
7477
7478   bool& mSignalCalled;
7479 };
7480
7481 int UtcDaliActorLayoutDirectionSignal(void)
7482 {
7483   TestApplication application;
7484   tet_infoline("Check changing layout direction property sends a signal");
7485
7486   Actor actor = Actor::New();
7487   DALI_TEST_EQUALS(actor.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7488   application.GetScene().Add(actor);
7489   bool                   signalCalled = false;
7490   LayoutDirectionFunctor layoutDirectionFunctor(signalCalled);
7491
7492   actor.ConnectSignal(&application, "layoutDirectionChanged", layoutDirectionFunctor);
7493   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7494
7495   // Test that writing the same value doesn't send a signal
7496   actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7497   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7498
7499   // Test that writing a different value sends the signal
7500   signalCalled = false;
7501   actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
7502   DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7503
7504   signalCalled = false;
7505   actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
7506   DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7507
7508   END_TEST;
7509 }
7510
7511 struct ChildAddedSignalCheck
7512 {
7513   ChildAddedSignalCheck(bool& signalReceived, Actor& childHandle)
7514   : mSignalReceived(signalReceived),
7515     mChildHandle(childHandle)
7516   {
7517   }
7518
7519   void operator()(Actor childHandle)
7520   {
7521     mSignalReceived = true;
7522     mChildHandle    = childHandle;
7523   }
7524   void operator()()
7525   {
7526     mSignalReceived = true;
7527     mChildHandle    = Actor();
7528   }
7529
7530   bool&  mSignalReceived;
7531   Actor& mChildHandle;
7532 };
7533
7534 int UtcDaliChildAddedSignalP1(void)
7535 {
7536   TestApplication application;
7537   auto            stage = application.GetScene();
7538
7539   bool  signalReceived = false;
7540   Actor childActor;
7541
7542   ChildAddedSignalCheck signal(signalReceived, childActor);
7543   DevelActor::ChildAddedSignal(stage.GetRootLayer()).Connect(&application, signal);
7544   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7545
7546   auto actorA = Actor::New();
7547   stage.Add(actorA);
7548   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7549   DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
7550   signalReceived = false;
7551
7552   auto actorB = Actor::New();
7553   stage.Add(actorB);
7554   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7555   DALI_TEST_EQUALS(childActor, actorB, TEST_LOCATION);
7556
7557   END_TEST;
7558 }
7559
7560 int UtcDaliChildAddedSignalP2(void)
7561 {
7562   TestApplication application;
7563   auto            stage = application.GetScene();
7564
7565   bool  signalReceived = false;
7566   Actor childActor;
7567
7568   ChildAddedSignalCheck signal(signalReceived, childActor);
7569   tet_infoline("Connect to childAdded signal by name");
7570
7571   stage.GetRootLayer().ConnectSignal(&application, "childAdded", signal);
7572   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7573
7574   auto actorA = Actor::New();
7575   stage.Add(actorA);
7576   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7577
7578   // Can't test which actor was added; signal signature is void() when connecting via name.
7579   signalReceived = false;
7580
7581   auto actorB = Actor::New();
7582   stage.Add(actorB);
7583   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7584
7585   END_TEST;
7586 }
7587
7588 int UtcDaliChildAddedSignalN(void)
7589 {
7590   TestApplication application;
7591   auto            stage = application.GetScene();
7592
7593   bool  signalReceived = false;
7594   Actor childActor;
7595
7596   ChildAddedSignalCheck signal(signalReceived, childActor);
7597   DevelActor::ChildAddedSignal(stage.GetRootLayer()).Connect(&application, signal);
7598   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7599
7600   auto actorA = Actor::New();
7601   stage.Add(actorA);
7602   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7603   DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
7604   signalReceived = false;
7605
7606   auto actorB = Actor::New();
7607   actorA.Add(actorB);
7608   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7609   END_TEST;
7610 }
7611
7612 struct ChildRemovedSignalCheck
7613 {
7614   ChildRemovedSignalCheck(bool& signalReceived, Actor& childHandle)
7615   : mSignalReceived(signalReceived),
7616     mChildHandle(childHandle)
7617   {
7618   }
7619
7620   void operator()(Actor childHandle)
7621   {
7622     mSignalReceived = true;
7623     mChildHandle    = childHandle;
7624   }
7625
7626   void operator()()
7627   {
7628     mSignalReceived = true;
7629   }
7630
7631   bool&  mSignalReceived;
7632   Actor& mChildHandle;
7633 };
7634
7635 int UtcDaliChildRemovedSignalP1(void)
7636 {
7637   TestApplication application;
7638   auto            stage = application.GetScene();
7639
7640   bool  signalReceived = false;
7641   Actor childActor;
7642
7643   ChildRemovedSignalCheck signal(signalReceived, childActor);
7644   DevelActor::ChildRemovedSignal(stage.GetRootLayer()).Connect(&application, signal);
7645   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7646
7647   auto actorA = Actor::New();
7648   stage.Add(actorA);
7649   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7650   DALI_TEST_CHECK(!childActor);
7651
7652   stage.Remove(actorA);
7653   DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
7654   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7655
7656   signalReceived = false;
7657   auto actorB    = Actor::New();
7658   stage.Add(actorB);
7659   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7660
7661   stage.Remove(actorB);
7662   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7663   DALI_TEST_EQUALS(childActor, actorB, TEST_LOCATION);
7664
7665   END_TEST;
7666 }
7667
7668 int UtcDaliChildRemovedSignalP2(void)
7669 {
7670   TestApplication application;
7671   auto            stage = application.GetScene();
7672
7673   bool  signalReceived = false;
7674   Actor childActor;
7675
7676   ChildAddedSignalCheck signal(signalReceived, childActor);
7677   tet_infoline("Connect to childRemoved signal by name");
7678
7679   stage.GetRootLayer().ConnectSignal(&application, "childRemoved", signal);
7680   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7681
7682   auto actorA = Actor::New();
7683   stage.Add(actorA);
7684   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7685
7686   stage.Remove(actorA);
7687   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7688
7689   signalReceived = false;
7690   auto actorB    = Actor::New();
7691   stage.Add(actorB);
7692   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7693
7694   stage.Remove(actorB);
7695   DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7696
7697   END_TEST;
7698 }
7699
7700 int UtcDaliChildRemovedSignalN(void)
7701 {
7702   TestApplication application;
7703   auto            stage = application.GetScene();
7704
7705   bool  signalReceived = false;
7706   Actor childActor;
7707
7708   ChildRemovedSignalCheck signal(signalReceived, childActor);
7709   DevelActor::ChildRemovedSignal(stage.GetRootLayer()).Connect(&application, signal);
7710   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7711
7712   auto actorA = Actor::New();
7713   stage.Add(actorA);
7714
7715   auto actorB = Actor::New();
7716   actorA.Add(actorB);
7717
7718   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7719   DALI_TEST_CHECK(!childActor);
7720
7721   actorA.Remove(actorB);
7722   DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7723   END_TEST;
7724 }
7725
7726 int UtcDaliChildMovedSignalP(void)
7727 {
7728   TestApplication application;
7729   auto            stage = application.GetScene();
7730
7731   bool  addedASignalReceived   = false;
7732   bool  removedASignalReceived = false;
7733   bool  addedBSignalReceived   = false;
7734   bool  removedBSignalReceived = false;
7735   Actor childActor;
7736
7737   auto actorA = Actor::New();
7738   auto actorB = Actor::New();
7739   stage.Add(actorA);
7740   stage.Add(actorB);
7741
7742   ChildAddedSignalCheck   addedSignalA(addedASignalReceived, childActor);
7743   ChildRemovedSignalCheck removedSignalA(removedASignalReceived, childActor);
7744   ChildAddedSignalCheck   addedSignalB(addedBSignalReceived, childActor);
7745   ChildRemovedSignalCheck removedSignalB(removedBSignalReceived, childActor);
7746
7747   DevelActor::ChildAddedSignal(actorA).Connect(&application, addedSignalA);
7748   DevelActor::ChildRemovedSignal(actorA).Connect(&application, removedSignalA);
7749   DevelActor::ChildAddedSignal(actorB).Connect(&application, addedSignalB);
7750   DevelActor::ChildRemovedSignal(actorB).Connect(&application, removedSignalB);
7751
7752   DALI_TEST_EQUALS(addedASignalReceived, false, TEST_LOCATION);
7753   DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
7754   DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
7755   DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
7756
7757   // Create a child of A
7758
7759   auto child = Actor::New();
7760   actorA.Add(child);
7761
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, false, TEST_LOCATION);
7766   DALI_TEST_EQUALS(childActor, child, TEST_LOCATION);
7767
7768   // Move child to B:
7769   addedASignalReceived   = false;
7770   addedBSignalReceived   = false;
7771   removedASignalReceived = false;
7772   removedBSignalReceived = false;
7773
7774   actorB.Add(child); // Expect this child to be re-parented
7775   DALI_TEST_EQUALS(addedASignalReceived, false, TEST_LOCATION);
7776   DALI_TEST_EQUALS(removedASignalReceived, true, TEST_LOCATION);
7777   DALI_TEST_EQUALS(addedBSignalReceived, true, TEST_LOCATION);
7778   DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
7779
7780   // Move child back to A:
7781   addedASignalReceived   = false;
7782   addedBSignalReceived   = false;
7783   removedASignalReceived = false;
7784   removedBSignalReceived = false;
7785
7786   actorA.Add(child); // Expect this child to be re-parented
7787   DALI_TEST_EQUALS(addedASignalReceived, true, TEST_LOCATION);
7788   DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
7789   DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
7790   DALI_TEST_EQUALS(removedBSignalReceived, true, TEST_LOCATION);
7791
7792   END_TEST;
7793 }
7794
7795 int UtcDaliActorSwitchParentP(void)
7796 {
7797   tet_infoline("Testing Actor::UtcDaliActorSwitchParentP");
7798   TestApplication application;
7799
7800   Actor parent1 = Actor::New();
7801   Actor child   = Actor::New();
7802
7803   application.GetScene().Add(parent1);
7804
7805   DALI_TEST_EQUALS(parent1.GetChildCount(), 0u, TEST_LOCATION);
7806
7807   child.OnSceneSignal().Connect(OnSceneCallback);
7808   child.OffSceneSignal().Connect(OffSceneCallback);
7809
7810   // sanity check
7811   DALI_TEST_CHECK(gOnSceneCallBackCalled == 0);
7812   DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
7813
7814   parent1.Add(child);
7815
7816   DALI_TEST_EQUALS(parent1.GetChildCount(), 1u, TEST_LOCATION);
7817
7818   DALI_TEST_CHECK(gOnSceneCallBackCalled == 1);
7819   DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
7820
7821   Actor parent2 = Actor::New();
7822   application.GetScene().Add(parent2);
7823
7824   bool                  addSignalReceived = false;
7825   ChildAddedSignalCheck addedSignal(addSignalReceived, child);
7826   DevelActor::ChildAddedSignal(application.GetScene().GetRootLayer()).Connect(&application, addedSignal);
7827   DALI_TEST_EQUALS(addSignalReceived, false, TEST_LOCATION);
7828
7829   bool                    removedSignalReceived = false;
7830   ChildRemovedSignalCheck removedSignal(removedSignalReceived, child);
7831   DevelActor::ChildRemovedSignal(application.GetScene().GetRootLayer()).Connect(&application, removedSignal);
7832   DALI_TEST_EQUALS(removedSignalReceived, false, TEST_LOCATION);
7833
7834   DevelActor::SwitchParent(child, parent2);
7835
7836   DALI_TEST_EQUALS(addSignalReceived, false, TEST_LOCATION);
7837   DALI_TEST_EQUALS(removedSignalReceived, false, TEST_LOCATION);
7838
7839   DALI_TEST_EQUALS(parent1.GetChildCount(), 0u, TEST_LOCATION);
7840   DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
7841
7842   DALI_TEST_CHECK(gOnSceneCallBackCalled == 1);
7843   DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
7844   DALI_TEST_CHECK(child.GetProperty<bool>(Dali::Actor::Property::CONNECTED_TO_SCENE));
7845   DALI_TEST_CHECK(child.GetParent() == parent2);
7846
7847   END_TEST;
7848 }
7849
7850 int utcDaliActorCulled(void)
7851 {
7852   TestApplication application;
7853   auto            stage = application.GetScene();
7854
7855   tet_infoline("Check that the actor is culled if the actor is out of the screen");
7856
7857   Actor actor = Actor::New();
7858   actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
7859
7860   Geometry geometry = CreateQuadGeometry();
7861   Shader   shader   = CreateShader();
7862   Renderer renderer = Renderer::New(geometry, shader);
7863   actor.AddRenderer(renderer);
7864
7865   stage.Add(actor);
7866
7867   application.SendNotification();
7868   application.Render(0);
7869
7870   DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::CULLED), false, TEST_LOCATION);
7871
7872   PropertyNotification notification = actor.AddPropertyNotification(Actor::Property::CULLED, LessThanCondition(0.5f));
7873   notification.SetNotifyMode(PropertyNotification::NOTIFY_ON_CHANGED);
7874
7875   // Connect NotifySignal
7876   bool                              propertyNotificationSignal(false);
7877   PropertyNotification              source;
7878   CulledPropertyNotificationFunctor f(propertyNotificationSignal, source);
7879   notification.NotifySignal().Connect(&application, f);
7880
7881   actor.SetProperty(Actor::Property::POSITION, Vector2(1000.0f, 1000.0f));
7882
7883   application.SendNotification();
7884   application.Render();
7885
7886   application.SendNotification();
7887
7888   DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::CULLED), true, TEST_LOCATION);
7889
7890   DALI_TEST_EQUALS(propertyNotificationSignal, true, TEST_LOCATION);
7891   DALI_TEST_EQUALS(source.GetTargetProperty(), static_cast<int>(Actor::Property::CULLED), TEST_LOCATION);
7892   DALI_TEST_EQUALS(source.GetTarget().GetProperty<bool>(source.GetTargetProperty()), true, TEST_LOCATION);
7893
7894   END_TEST;
7895 }
7896
7897 int utcDaliEnsureRenderWhenRemovingLastRenderableActor(void)
7898 {
7899   TestApplication application;
7900   auto            stage = application.GetScene();
7901
7902   tet_infoline("Ensure we clear the screen when the last actor is removed");
7903
7904   Actor actor = CreateRenderableActor();
7905   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7906   stage.Add(actor);
7907
7908   application.SendNotification();
7909   application.Render();
7910
7911   auto&      glAbstraction    = application.GetGlAbstraction();
7912   const auto clearCountBefore = glAbstraction.GetClearCountCalled();
7913
7914   actor.Unparent();
7915
7916   application.SendNotification();
7917   application.Render();
7918
7919   DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION);
7920
7921   END_TEST;
7922 }
7923
7924 int utcDaliEnsureRenderWhenMakingLastActorInvisible(void)
7925 {
7926   TestApplication application;
7927   auto            stage = application.GetScene();
7928
7929   tet_infoline("Ensure we clear the screen when the last actor is made invisible");
7930
7931   Actor actor = CreateRenderableActor();
7932   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7933   stage.Add(actor);
7934
7935   application.SendNotification();
7936   application.Render();
7937
7938   auto&      glAbstraction    = application.GetGlAbstraction();
7939   const auto clearCountBefore = glAbstraction.GetClearCountCalled();
7940
7941   actor.SetProperty(Actor::Property::VISIBLE, false);
7942
7943   application.SendNotification();
7944   application.Render();
7945
7946   DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION);
7947
7948   END_TEST;
7949 }
7950
7951 int utcDaliActorGetSizeAfterAnimation(void)
7952 {
7953   TestApplication application;
7954   tet_infoline("Check the actor size before / after an animation is finished");
7955
7956   Vector3 actorSize(100.0f, 100.0f, 0.0f);
7957
7958   Actor actor = Actor::New();
7959   actor.SetProperty(Actor::Property::SIZE, actorSize);
7960   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7961   application.GetScene().Add(actor);
7962
7963   // Size should be updated without rendering.
7964   Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7965   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7966
7967   application.SendNotification();
7968   application.Render();
7969
7970   // Size and current size should be updated.
7971   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7972   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7973   DALI_TEST_EQUALS(actorSize.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7974   DALI_TEST_EQUALS(actorSize.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7975   DALI_TEST_EQUALS(actorSize.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7976
7977   Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7978   DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7979   DALI_TEST_EQUALS(actorSize.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7980   DALI_TEST_EQUALS(actorSize.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7981   DALI_TEST_EQUALS(actorSize.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7982
7983   // Set size again
7984   actorSize = Vector3(200.0f, 200.0f, 0.0f);
7985   actor.SetProperty(Actor::Property::SIZE, actorSize);
7986
7987   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7988   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7989
7990   Vector3 targetValue(10.0f, 20.0f, 0.0f);
7991
7992   Animation animation = Animation::New(1.0f);
7993   animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
7994   animation.Play();
7995
7996   // Size should be updated without rendering.
7997   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7998   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7999
8000   application.SendNotification();
8001   application.Render(1100); // After the animation
8002
8003   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8004   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8005   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8006   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8007   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8008
8009   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8010   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8011   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8012   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8013   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8014
8015   targetValue.width = 50.0f;
8016
8017   animation.Clear();
8018   animation.AnimateTo(Property(actor, Actor::Property::SIZE_WIDTH), targetValue.width);
8019   animation.Play();
8020
8021   application.SendNotification();
8022   application.Render(1100); // After the animation
8023
8024   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8025   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8026   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8027   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8028   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8029
8030   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8031   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8032   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8033   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8034   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8035
8036   targetValue.height = 70.0f;
8037
8038   animation.Clear();
8039   animation.AnimateTo(Property(actor, Actor::Property::SIZE_HEIGHT), targetValue.height);
8040   animation.Play();
8041
8042   application.SendNotification();
8043   application.Render(1100); // After the animation
8044
8045   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8046   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8047   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8048   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8049   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8050
8051   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8052   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8053   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8054   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8055   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8056
8057   Vector3 offset(10.0f, 20.0f, 0.0f);
8058
8059   animation.Clear();
8060   animation.AnimateBy(Property(actor, Actor::Property::SIZE), offset);
8061   animation.Play();
8062
8063   application.SendNotification();
8064   application.Render(1100); // After the animation
8065
8066   targetValue += offset;
8067
8068   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8069   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8070   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8071   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8072   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8073
8074   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8075   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8076   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8077   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8078   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8079
8080   offset.width = 20.0f;
8081
8082   animation.Clear();
8083   animation.AnimateBy(Property(actor, Actor::Property::SIZE_WIDTH), offset.width);
8084   animation.Play();
8085
8086   application.SendNotification();
8087   application.Render(1100); // After the animation
8088
8089   targetValue.width += offset.width;
8090
8091   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8092   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8093   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8094   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8095   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8096
8097   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8098   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8099   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8100   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8101   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8102
8103   offset.height = 10.0f;
8104
8105   animation.Clear();
8106   animation.AnimateBy(Property(actor, Actor::Property::SIZE_HEIGHT), offset.height);
8107   animation.Play();
8108
8109   application.SendNotification();
8110   application.Render(1100); // After the animation
8111
8112   targetValue.height += offset.height;
8113
8114   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8115   DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8116   DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8117   DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8118   DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8119
8120   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8121   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8122   DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8123   DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8124   DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8125
8126   // Set size again
8127   actorSize = Vector3(300.0f, 300.0f, 0.0f);
8128
8129   actor.SetProperty(Actor::Property::SIZE, actorSize);
8130
8131   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8132   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8133
8134   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8135   DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8136
8137   application.SendNotification();
8138   application.Render();
8139
8140   size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8141   DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8142
8143   currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8144   DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8145
8146   END_TEST;
8147 }
8148
8149 int utcDaliActorRelayoutAndAnimation(void)
8150 {
8151   TestApplication application;
8152   tet_infoline("Check the actor size when relayoutting and playing animation");
8153
8154   Vector3 parentSize(300.0f, 300.0f, 0.0f);
8155   Vector3 actorSize(100.0f, 100.0f, 0.0f);
8156
8157   {
8158     Actor parentA = Actor::New();
8159     parentA.SetProperty(Actor::Property::SIZE, parentSize);
8160     parentA.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8161     application.GetScene().Add(parentA);
8162
8163     Actor parentB = Actor::New();
8164     parentB.SetProperty(Actor::Property::SIZE, parentSize);
8165     parentB.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8166     application.GetScene().Add(parentB);
8167
8168     Actor actor = Actor::New();
8169     actor.SetProperty(Actor::Property::SIZE, actorSize);
8170     actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8171     parentA.Add(actor);
8172
8173     Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8174     DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8175
8176     Vector3 targetValue(200.0f, 200.0f, 0.0f);
8177
8178     Animation animation = Animation::New(1.0f);
8179     animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
8180     animation.Play();
8181
8182     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8183     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8184
8185     application.SendNotification();
8186     application.Render(1100); // After the animation
8187
8188     // Size and current size should be updated.
8189     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8190     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8191
8192     Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8193     DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8194
8195     // Trigger relayout
8196     parentB.Add(actor);
8197
8198     application.SendNotification();
8199     application.Render();
8200
8201     // Size and current size should be same.
8202     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8203     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8204
8205     currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8206     DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8207
8208     actor.Unparent();
8209     parentA.Unparent();
8210     parentB.Unparent();
8211   }
8212
8213   {
8214     Actor parentA = Actor::New();
8215     parentA.SetProperty(Actor::Property::SIZE, parentSize);
8216     parentA.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8217     application.GetScene().Add(parentA);
8218
8219     Actor parentB = Actor::New();
8220     parentB.SetProperty(Actor::Property::SIZE, parentSize);
8221     parentB.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8222     application.GetScene().Add(parentB);
8223
8224     Actor actor = Actor::New();
8225     actor.SetProperty(Actor::Property::SIZE, actorSize);
8226     actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8227     parentA.Add(actor);
8228
8229     Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8230     DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8231
8232     application.SendNotification();
8233     application.Render();
8234
8235     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8236     DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8237
8238     Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8239     DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8240
8241     Vector3 targetValue(200.0f, 200.0f, 0.0f);
8242
8243     // Make an animation
8244     Animation animation = Animation::New(1.0f);
8245     animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
8246     animation.Play();
8247
8248     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8249     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8250
8251     application.SendNotification();
8252     application.Render(1100); // After the animation
8253
8254     // Size and current size should be updated.
8255     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8256     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8257
8258     currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8259     DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8260
8261     // Trigger relayout
8262     parentB.Add(actor);
8263
8264     application.SendNotification();
8265     application.Render();
8266
8267     // Size and current size should be same.
8268     size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8269     DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8270
8271     currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8272     DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8273
8274     actor.Unparent();
8275     parentA.Unparent();
8276     parentB.Unparent();
8277   }
8278
8279   END_TEST;
8280 }
8281
8282 int utcDaliActorPartialUpdate(void)
8283 {
8284   TestApplication application(
8285     TestApplication::DEFAULT_SURFACE_WIDTH,
8286     TestApplication::DEFAULT_SURFACE_HEIGHT,
8287     TestApplication::DEFAULT_HORIZONTAL_DPI,
8288     TestApplication::DEFAULT_VERTICAL_DPI,
8289     true,
8290     true);
8291
8292   tet_infoline("Check the damaged area");
8293
8294   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8295
8296   std::vector<Rect<int>> damagedRects;
8297   Rect<int>              clippingRect;
8298   application.SendNotification();
8299   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8300
8301   // First render pass, nothing to render, adaptor would just do swap buffer.
8302   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8303
8304   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8305   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8306
8307   Actor actor = CreateRenderableActor();
8308   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8309   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8310   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8311   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8312   application.GetScene().Add(actor);
8313
8314   application.SendNotification();
8315
8316   // 1. Actor added, damaged rect is added size of actor
8317   damagedRects.clear();
8318   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8319   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8320
8321   // Aligned by 16
8322   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8323   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8324   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8325   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8326   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8327   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8328   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8329
8330   // 2. Set new size
8331   actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0));
8332   application.SendNotification();
8333
8334   damagedRects.clear();
8335   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8336   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8337
8338   // Aligned by 16
8339   clippingRect = Rect<int>(16, 752, 48, 48); // in screen coordinates, includes 3 last frames updates
8340   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8341   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8342   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8343   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8344   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8345   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8346
8347   // 3. Set new position
8348   actor.SetProperty(Actor::Property::POSITION, Vector3(32.0f, 32.0f, 0));
8349   application.SendNotification();
8350
8351   damagedRects.clear();
8352   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8353   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8354
8355   // Aligned by 16
8356   clippingRect = Rect<int>(16, 736, 64, 64); // in screen coordinates, includes 3 last frames updates
8357   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8358   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8359   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8360   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8361   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8362   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8363
8364   application.GetScene().Remove(actor);
8365   application.SendNotification();
8366
8367   // Actor removed, last 3 dirty rects are reported. Adaptor would merge them together.
8368   damagedRects.clear();
8369   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8370   DALI_TEST_EQUALS(damagedRects.size(), 3, TEST_LOCATION);
8371
8372   clippingRect = damagedRects[0];
8373   clippingRect.Merge(damagedRects[1]);
8374   clippingRect.Merge(damagedRects[2]);
8375
8376   DALI_TEST_EQUALS(clippingRect.IsEmpty(), false, TEST_LOCATION);
8377   DALI_TEST_EQUALS(clippingRect.IsValid(), true, TEST_LOCATION);
8378   DALI_TEST_EQUALS<Rect<int>>(clippingRect, Rect<int>(16, 736, 64, 64), TEST_LOCATION);
8379
8380   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8381   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8382   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8383   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8384   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8385
8386   END_TEST;
8387 }
8388
8389 int utcDaliActorPartialUpdateSetColor(void)
8390 {
8391   TestApplication application(
8392     TestApplication::DEFAULT_SURFACE_WIDTH,
8393     TestApplication::DEFAULT_SURFACE_HEIGHT,
8394     TestApplication::DEFAULT_HORIZONTAL_DPI,
8395     TestApplication::DEFAULT_VERTICAL_DPI,
8396     true,
8397     true);
8398
8399   tet_infoline("Check uniform update");
8400
8401   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8402
8403   std::vector<Rect<int>> damagedRects;
8404   Rect<int>              clippingRect;
8405   application.SendNotification();
8406   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8407
8408   // First render pass, nothing to render, adaptor would just do swap buffer.
8409   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8410
8411   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8412   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8413
8414   Actor actor = CreateRenderableActor();
8415   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8416   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8417   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8418   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8419   application.GetScene().Add(actor);
8420
8421   application.SendNotification();
8422
8423   // 1. Actor added, damaged rect is added size of actor
8424   damagedRects.clear();
8425   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8426   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8427
8428   // Aligned by 16
8429   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8430   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8431   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8432   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8433   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8434   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8435   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8436
8437   damagedRects.clear();
8438   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8439
8440   damagedRects.clear();
8441   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8442
8443   // 2. Set new color
8444   actor.SetProperty(Actor::Property::COLOR, Vector3(1.0f, 0.0f, 0.0f));
8445   application.SendNotification();
8446
8447   damagedRects.clear();
8448   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8449   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8450
8451   // Aligned by 16
8452   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8453   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8454   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8455   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8456   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8457   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8458   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8459
8460   END_TEST;
8461 }
8462
8463 const std::string SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME("uLightCameraProjectionMatrix");
8464 const std::string SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME("uLightCameraViewMatrix");
8465 const std::string SHADER_SHADOW_COLOR_PROPERTY_NAME("uShadowColor");
8466 const char* const RENDER_SHADOW_VERTEX_SOURCE =
8467   " uniform mediump mat4 uLightCameraProjectionMatrix;\n"
8468   " uniform mediump mat4 uLightCameraViewMatrix;\n"
8469   "\n"
8470   "void main()\n"
8471   "{\n"
8472   "  gl_Position = uProjection * uModelView * vec4(aPosition,1.0);\n"
8473   "  vec4 textureCoords = uLightCameraProjectionMatrix * uLightCameraViewMatrix * uModelMatrix  * vec4(aPosition,1.0);\n"
8474   "  vTexCoord = 0.5 + 0.5 * (textureCoords.xy/textureCoords.w);\n"
8475   "}\n";
8476
8477 const char* const RENDER_SHADOW_FRAGMENT_SOURCE =
8478   "uniform lowp vec4 uShadowColor;\n"
8479   "void main()\n"
8480   "{\n"
8481   "  lowp float alpha;\n"
8482   "  alpha = texture2D(sTexture, vec2(vTexCoord.x, vTexCoord.y)).a;\n"
8483   "  gl_FragColor = vec4(uShadowColor.rgb, uShadowColor.a * alpha);\n"
8484   "}\n";
8485
8486 int utcDaliActorPartialUpdateSetProperty(void)
8487 {
8488   TestApplication application(
8489     TestApplication::DEFAULT_SURFACE_WIDTH,
8490     TestApplication::DEFAULT_SURFACE_HEIGHT,
8491     TestApplication::DEFAULT_HORIZONTAL_DPI,
8492     TestApplication::DEFAULT_VERTICAL_DPI,
8493     true,
8494     true);
8495
8496   tet_infoline("Set/Update property with partial update");
8497
8498   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8499
8500   std::vector<Rect<int>> damagedRects;
8501   Rect<int>              clippingRect;
8502   application.SendNotification();
8503   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8504
8505   // First render pass, nothing to render, adaptor would just do swap buffer.
8506   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8507
8508   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8509   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8510
8511   Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 4u, 4u);
8512   Actor   actor = CreateRenderableActor(image, RENDER_SHADOW_VERTEX_SOURCE, RENDER_SHADOW_FRAGMENT_SOURCE);
8513   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8514   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8515   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8516   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8517   application.GetScene().Add(actor);
8518
8519   actor.RegisterProperty(SHADER_SHADOW_COLOR_PROPERTY_NAME, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
8520
8521   damagedRects.clear();
8522   application.SendNotification();
8523   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8524   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8525
8526   // Aligned by 16
8527   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8528   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8529   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8530   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8531   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8532   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8533   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8534
8535   Property::Index shadowColorPropertyIndex = actor.GetPropertyIndex(SHADER_SHADOW_COLOR_PROPERTY_NAME);
8536   actor.SetProperty(shadowColorPropertyIndex, Vector4(1.0f, 1.0f, 0.0f, 1.0f));
8537
8538   damagedRects.clear();
8539   application.SendNotification();
8540   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8541   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8542
8543   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8544   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8545   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8546   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8547   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8548   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8549
8550   // Should be no damage rects, nothing changed
8551   damagedRects.clear();
8552   application.SendNotification();
8553   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8554   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8555
8556   // Should be 1 damage rect due to change in size
8557   damagedRects.clear();
8558   actor.SetProperty(Actor::Property::SIZE, Vector3(26.0f, 26.0f, 0.0f));
8559   application.SendNotification();
8560   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8561   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8562
8563   clippingRect = Rect<int>(16, 752, 32, 48); // new clipping rect size increased due to change in actor size
8564   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8565   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8566   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8567   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8568   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8569   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8570
8571   damagedRects.clear();
8572   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8573   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8574
8575   END_TEST;
8576 }
8577
8578 int utcDaliActorPartialUpdateTwoActors(void)
8579 {
8580   TestApplication application(
8581     TestApplication::DEFAULT_SURFACE_WIDTH,
8582     TestApplication::DEFAULT_SURFACE_HEIGHT,
8583     TestApplication::DEFAULT_HORIZONTAL_DPI,
8584     TestApplication::DEFAULT_VERTICAL_DPI,
8585     true,
8586     true);
8587
8588   tet_infoline("Check the damaged rects with partial update and two actors");
8589
8590   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8591
8592   Actor actor = CreateRenderableActor();
8593   actor.SetProperty(Actor::Property::POSITION, Vector3(100.0f, 100.0f, 0.0f));
8594   actor.SetProperty(Actor::Property::SIZE, Vector3(50.0f, 50.0f, 0.0f));
8595   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8596   application.GetScene().Add(actor);
8597
8598   Actor actor2 = CreateRenderableActor();
8599   actor2.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
8600   actor2.SetProperty(Actor::Property::SIZE, Vector3(100.0f, 100.0f, 0.0f));
8601   actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8602   application.GetScene().Add(actor2);
8603
8604   application.SendNotification();
8605   std::vector<Rect<int>> damagedRects;
8606   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
8607
8608   DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
8609   DALI_TEST_EQUALS<Rect<int>>(Rect<int>(64, 672, 64, 64), damagedRects[0], TEST_LOCATION);
8610   DALI_TEST_EQUALS<Rect<int>>(Rect<int>(96, 592, 112, 112), damagedRects[1], TEST_LOCATION);
8611
8612   // in screen coordinates, adaptor would calculate it using previous frames information
8613   Rect<int> clippingRect = Rect<int>(64, 592, 144, 192);
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   // Change a Renderer of actor1
8622   Geometry geometry    = CreateQuadGeometry();
8623   Shader   shader      = CreateShader();
8624   Renderer newRenderer = Renderer::New(geometry, shader);
8625   Renderer renderer    = actor.GetRendererAt(0);
8626
8627   actor.RemoveRenderer(renderer);
8628   actor.AddRenderer(newRenderer);
8629
8630   damagedRects.clear();
8631
8632   application.SendNotification();
8633   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
8634
8635   DALI_TEST_CHECK(damagedRects.size() > 0);
8636   DALI_TEST_EQUALS<Rect<int>>(Rect<int>(64, 672, 64, 64), damagedRects[0], TEST_LOCATION);
8637
8638   // in screen coordinates, adaptor would calculate it using previous frames information
8639   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8640
8641   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8642   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8643   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8644   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8645
8646   END_TEST;
8647 }
8648
8649 int utcDaliActorPartialUpdateActorsWithSizeHint(void)
8650 {
8651   TestApplication application(
8652     TestApplication::DEFAULT_SURFACE_WIDTH,
8653     TestApplication::DEFAULT_SURFACE_HEIGHT,
8654     TestApplication::DEFAULT_HORIZONTAL_DPI,
8655     TestApplication::DEFAULT_VERTICAL_DPI,
8656     true,
8657     true);
8658
8659   tet_infoline("Check the damaged rect with partial update and actor size hint");
8660
8661   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8662
8663   Actor actor = CreateRenderableActor();
8664   actor.SetProperty(Actor::Property::POSITION, Vector3(64.0f, 64.0f, 0.0f));
8665   actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0.0f));
8666   actor.SetProperty(DevelActor::Property::UPDATE_SIZE_HINT, Vector3(64.0f, 64.0f, 0.0f));
8667   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8668   application.GetScene().Add(actor);
8669
8670   application.SendNotification();
8671   std::vector<Rect<int>> damagedRects;
8672   application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
8673
8674   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8675
8676   Rect<int> clippingRect = Rect<int>(32, 704, 80, 80);
8677   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8678
8679   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8680
8681   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8682   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8683   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8684   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8685
8686   END_TEST;
8687 }
8688
8689 int utcDaliActorPartialUpdateAnimation(void)
8690 {
8691   TestApplication application(
8692     TestApplication::DEFAULT_SURFACE_WIDTH,
8693     TestApplication::DEFAULT_SURFACE_HEIGHT,
8694     TestApplication::DEFAULT_HORIZONTAL_DPI,
8695     TestApplication::DEFAULT_VERTICAL_DPI,
8696     true,
8697     true);
8698
8699   tet_infoline("Check the damaged area with partial update and animation");
8700
8701   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
8702   drawTrace.Enable(true);
8703   drawTrace.Reset();
8704
8705   Actor actor1 = CreateRenderableActor();
8706   actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8707   actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
8708   application.GetScene().Add(actor1);
8709
8710   Actor actor2 = CreateRenderableActor();
8711   actor2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8712   actor2.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8713   application.GetScene().Add(actor2);
8714
8715   std::vector<Rect<int>> damagedRects;
8716   Rect<int>              clippingRect;
8717   Rect<int>              expectedRect1, expectedRect2;
8718
8719   application.SendNotification();
8720   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8721
8722   DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
8723
8724   // Aligned by 16
8725   expectedRect1 = Rect<int>(0, 720, 96, 96); // in screen coordinates, includes 3 last frames updates
8726   expectedRect2 = Rect<int>(0, 784, 32, 32); // in screen coordinates, includes 3 last frames updates
8727   DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[0], TEST_LOCATION);
8728   DALI_TEST_EQUALS<Rect<int>>(expectedRect2, damagedRects[1], TEST_LOCATION);
8729
8730   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8731   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8732
8733   damagedRects.clear();
8734   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8735   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8736   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8737
8738   // Make an animation
8739   Animation animation = Animation::New(1.0f);
8740   animation.AnimateTo(Property(actor2, Actor::Property::POSITION_X), 160.0f, TimePeriod(0.5f, 0.5f));
8741   animation.Play();
8742
8743   application.SendNotification();
8744
8745   damagedRects.clear();
8746   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8747   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8748   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8749
8750   drawTrace.Reset();
8751   damagedRects.clear();
8752
8753   // In animation deley time
8754   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8755   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8756   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8757
8758   // Skip rendering
8759   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
8760
8761   drawTrace.Reset();
8762   damagedRects.clear();
8763
8764   // Also in animation deley time
8765   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8766   application.PreRenderWithPartialUpdate(100, nullptr, damagedRects);
8767   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8768
8769   // Skip rendering
8770   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
8771
8772   // Unparent 2 actors and make a new actor
8773   actor1.Unparent();
8774   actor2.Unparent();
8775
8776   Actor actor3 = CreateRenderableActor();
8777   actor3.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8778   actor3.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8779   application.GetScene().Add(actor3);
8780
8781   application.SendNotification();
8782
8783   // Started animation
8784   damagedRects.clear();
8785   application.PreRenderWithPartialUpdate(500, nullptr, damagedRects);
8786   DALI_TEST_EQUALS(damagedRects.size(), 5, TEST_LOCATION);
8787
8788   // The first dirty rect is actor3's.
8789   // We don't know the exact dirty rect of actor2
8790   DALI_TEST_EQUALS<Rect<int>>(expectedRect2, damagedRects[0], TEST_LOCATION);
8791   DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[1], TEST_LOCATION);
8792
8793   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8794   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8795
8796   // Finished animation, but the actor was already unparented
8797   damagedRects.clear();
8798   application.PreRenderWithPartialUpdate(500, nullptr, damagedRects);
8799
8800   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8801   DALI_TEST_EQUALS<Rect<int>>(expectedRect2, damagedRects[0], TEST_LOCATION);
8802
8803   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8804   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8805
8806   END_TEST;
8807 }
8808
8809 int utcDaliActorPartialUpdateChangeVisibility(void)
8810 {
8811   TestApplication application(
8812     TestApplication::DEFAULT_SURFACE_WIDTH,
8813     TestApplication::DEFAULT_SURFACE_HEIGHT,
8814     TestApplication::DEFAULT_HORIZONTAL_DPI,
8815     TestApplication::DEFAULT_VERTICAL_DPI,
8816     true,
8817     true);
8818
8819   tet_infoline("Check the damaged rect with partial update and visibility change");
8820
8821   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8822
8823   Actor actor = CreateRenderableActor();
8824   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8825   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8826   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8827   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8828   application.GetScene().Add(actor);
8829
8830   application.SendNotification();
8831
8832   std::vector<Rect<int>> damagedRects;
8833   Rect<int>              clippingRect;
8834
8835   // 1. Actor added, damaged rect is added size of actor
8836   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8837   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8838
8839   // Aligned by 16
8840   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8841   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8842   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8843   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8844   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8845   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8846   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8847
8848   damagedRects.clear();
8849   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8850   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8851
8852   damagedRects.clear();
8853   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8854   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8855
8856   // Ensure the damaged rect is empty
8857   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8858
8859   // 2. Make the Actor invisible
8860   actor.SetProperty(Actor::Property::VISIBLE, false);
8861   application.SendNotification();
8862
8863   damagedRects.clear();
8864   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8865   DALI_TEST_CHECK(damagedRects.size() > 0);
8866   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8867
8868   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8869   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8870   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8871   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8872   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8873
8874   // 3. Make the Actor visible again
8875   actor.SetProperty(Actor::Property::VISIBLE, true);
8876   application.SendNotification();
8877
8878   damagedRects.clear();
8879   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8880   DALI_TEST_CHECK(damagedRects.size() > 0);
8881   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8882
8883   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8884   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8885   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8886   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8887   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8888
8889   END_TEST;
8890 }
8891
8892 int utcDaliActorPartialUpdateOnOffScene(void)
8893 {
8894   TestApplication application(
8895     TestApplication::DEFAULT_SURFACE_WIDTH,
8896     TestApplication::DEFAULT_SURFACE_HEIGHT,
8897     TestApplication::DEFAULT_HORIZONTAL_DPI,
8898     TestApplication::DEFAULT_VERTICAL_DPI,
8899     true,
8900     true);
8901
8902   tet_infoline("Check the damaged rect with partial update and on/off scene");
8903
8904   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8905
8906   Actor actor = CreateRenderableActor();
8907   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8908   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8909   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8910   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8911   application.GetScene().Add(actor);
8912
8913   application.SendNotification();
8914
8915   std::vector<Rect<int>> damagedRects;
8916   Rect<int>              clippingRect;
8917
8918   // 1. Actor added, damaged rect is added size of actor
8919   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8920   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8921
8922   // Aligned by 16
8923   clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8924   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8925   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8926   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8927   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8928   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8929   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8930
8931   damagedRects.clear();
8932   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8933   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8934
8935   damagedRects.clear();
8936   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8937   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8938
8939   // Ensure the damaged rect is empty
8940   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8941
8942   // 2. Remove the Actor from the Scene
8943   actor.Unparent();
8944   application.SendNotification();
8945
8946   damagedRects.clear();
8947   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8948   DALI_TEST_CHECK(damagedRects.size() > 0);
8949   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8950
8951   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8952   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8953   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8954   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8955   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8956
8957   // 3. Add the Actor to the Scene again
8958   application.GetScene().Add(actor);
8959   application.SendNotification();
8960
8961   damagedRects.clear();
8962   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8963   DALI_TEST_CHECK(damagedRects.size() > 0);
8964   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8965
8966   application.RenderWithPartialUpdate(damagedRects, clippingRect);
8967   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8968   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8969   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8970   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8971
8972   END_TEST;
8973 }
8974
8975 int utcDaliActorPartialUpdateSkipRendering(void)
8976 {
8977   TestApplication application(
8978     TestApplication::DEFAULT_SURFACE_WIDTH,
8979     TestApplication::DEFAULT_SURFACE_HEIGHT,
8980     TestApplication::DEFAULT_HORIZONTAL_DPI,
8981     TestApplication::DEFAULT_VERTICAL_DPI,
8982     true,
8983     true);
8984
8985   tet_infoline("Check to skip rendering in case of the empty damaged rect");
8986
8987   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
8988   drawTrace.Enable(true);
8989   drawTrace.Reset();
8990
8991   Actor actor1 = CreateRenderableActor();
8992   actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8993   actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
8994   application.GetScene().Add(actor1);
8995
8996   std::vector<Rect<int>> damagedRects;
8997   Rect<int>              clippingRect;
8998   Rect<int>              expectedRect1;
8999
9000   application.SendNotification();
9001   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9002
9003   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9004
9005   // Aligned by 16
9006   expectedRect1 = Rect<int>(0, 720, 96, 96); // in screen coordinates, includes 3 last frames updates
9007   DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[0], TEST_LOCATION);
9008
9009   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9010   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9011
9012   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9013
9014   damagedRects.clear();
9015   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9016   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9017   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9018
9019   // Remove the actor
9020   actor1.Unparent();
9021
9022   application.SendNotification();
9023
9024   damagedRects.clear();
9025   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9026
9027   DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[0], TEST_LOCATION);
9028
9029   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9030   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9031
9032   // Render again without any change
9033   damagedRects.clear();
9034   drawTrace.Reset();
9035   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9036
9037   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9038
9039   clippingRect = Rect<int>();
9040   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9041
9042   // Skip rendering
9043   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
9044
9045   // Add the actor again
9046   application.GetScene().Add(actor1);
9047
9048   application.SendNotification();
9049
9050   damagedRects.clear();
9051   drawTrace.Reset();
9052   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9053
9054   DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[0], TEST_LOCATION);
9055
9056   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9057   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9058
9059   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9060
9061   END_TEST;
9062 }
9063
9064 int utcDaliActorPartialUpdate3DNode(void)
9065 {
9066   TestApplication application(
9067     TestApplication::DEFAULT_SURFACE_WIDTH,
9068     TestApplication::DEFAULT_SURFACE_HEIGHT,
9069     TestApplication::DEFAULT_HORIZONTAL_DPI,
9070     TestApplication::DEFAULT_VERTICAL_DPI,
9071     true,
9072     true);
9073
9074   tet_infoline("Partial update should be ignored in case of 3d layer of 3d node");
9075
9076   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
9077   drawTrace.Enable(true);
9078   drawTrace.Reset();
9079
9080   Actor actor1 = CreateRenderableActor();
9081   actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9082   actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
9083   application.GetScene().Add(actor1);
9084
9085   std::vector<Rect<int>> damagedRects;
9086   Rect<int>              clippingRect;
9087
9088   application.SendNotification();
9089   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9090
9091   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9092
9093   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9094   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9095
9096   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9097
9098   // Change the layer to 3D
9099   application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D);
9100
9101   application.SendNotification();
9102
9103   damagedRects.clear();
9104   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9105
9106   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9107   DALI_TEST_EQUALS<Rect<int>>(TestApplication::DEFAULT_SURFACE_RECT, damagedRects[0], TEST_LOCATION);
9108
9109   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9110   drawTrace.Reset();
9111   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9112
9113   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9114
9115   // Change the layer to 2D
9116   application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_UI);
9117
9118   application.SendNotification();
9119
9120   damagedRects.clear();
9121   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9122
9123   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9124
9125   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9126   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9127
9128   // Make 3D transform
9129   actor1.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::YAXIS));
9130
9131   application.SendNotification();
9132
9133   damagedRects.clear();
9134   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9135
9136   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9137   DALI_TEST_EQUALS<Rect<int>>(TestApplication::DEFAULT_SURFACE_RECT, damagedRects[0], TEST_LOCATION);
9138
9139   clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9140   drawTrace.Reset();
9141   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9142
9143   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9144
9145   END_TEST;
9146 }
9147
9148 int utcDaliActorPartialUpdateNotRenderableActor(void)
9149 {
9150   TestApplication application(
9151     TestApplication::DEFAULT_SURFACE_WIDTH,
9152     TestApplication::DEFAULT_SURFACE_HEIGHT,
9153     TestApplication::DEFAULT_HORIZONTAL_DPI,
9154     TestApplication::DEFAULT_VERTICAL_DPI,
9155     true,
9156     true);
9157
9158   tet_infoline("Check the damaged rect with not renderable parent actor");
9159
9160   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9161
9162   Actor parent                          = Actor::New();
9163   parent[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9164   parent[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
9165   parent[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
9166   parent.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9167   application.GetScene().Add(parent);
9168
9169   Actor child                          = CreateRenderableActor();
9170   child[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9171   child[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
9172   child.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9173   parent.Add(child);
9174
9175   application.SendNotification();
9176
9177   std::vector<Rect<int>> damagedRects;
9178
9179   // 1. Actor added, damaged rect is added size of actor
9180   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9181   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9182
9183   // Aligned by 16
9184   Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
9185   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9186
9187   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9188   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9189   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9190   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9191   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9192
9193   damagedRects.clear();
9194   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9195   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9196
9197   damagedRects.clear();
9198   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9199   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9200
9201   // Ensure the damaged rect is empty
9202   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9203
9204   END_TEST;
9205 }
9206
9207 int utcDaliActorPartialUpdateChangeTransparency(void)
9208 {
9209   TestApplication application(
9210     TestApplication::DEFAULT_SURFACE_WIDTH,
9211     TestApplication::DEFAULT_SURFACE_HEIGHT,
9212     TestApplication::DEFAULT_HORIZONTAL_DPI,
9213     TestApplication::DEFAULT_VERTICAL_DPI,
9214     true,
9215     true);
9216
9217   tet_infoline("Check the damaged rect with changing transparency");
9218
9219   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9220
9221   Actor actor                          = CreateRenderableActor();
9222   actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9223   actor[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
9224   actor[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
9225   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9226   application.GetScene().Add(actor);
9227
9228   application.SendNotification();
9229
9230   std::vector<Rect<int>> damagedRects;
9231
9232   // Actor added, damaged rect is added size of actor
9233   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9234   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9235
9236   // Aligned by 16
9237   Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
9238   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9239
9240   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9241   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9242   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9243   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9244   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9245
9246   damagedRects.clear();
9247   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9248   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9249
9250   damagedRects.clear();
9251   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9252   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9253
9254   // Make the actor transparent by changing opacity of the Renderer
9255   // It changes a uniform value
9256   Renderer renderer                          = actor.GetRendererAt(0);
9257   renderer[DevelRenderer::Property::OPACITY] = 0.0f;
9258
9259   application.SendNotification();
9260
9261   // The damaged rect should be same
9262   damagedRects.clear();
9263   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9264   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9265   DALI_TEST_CHECK(damagedRects.size() > 0);
9266   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9267
9268   damagedRects.clear();
9269   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9270   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9271
9272   // Ensure the damaged rect is empty
9273   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9274
9275   // Make the actor opaque again
9276   renderer[DevelRenderer::Property::OPACITY] = 1.0f;
9277
9278   application.SendNotification();
9279
9280   // The damaged rect should not be empty
9281   damagedRects.clear();
9282   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9283   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9284   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9285   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9286
9287   damagedRects.clear();
9288   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9289   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9290
9291   damagedRects.clear();
9292   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9293   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9294
9295   // Make the actor culled
9296   actor[Actor::Property::SIZE] = Vector3(0.0f, 0.0f, 0.0f);
9297
9298   application.SendNotification();
9299
9300   // The damaged rect should be same
9301   damagedRects.clear();
9302   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9303   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9304   DALI_TEST_CHECK(damagedRects.size() > 0);
9305   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9306
9307   damagedRects.clear();
9308   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9309   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9310
9311   // Ensure the damaged rect is empty
9312   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9313
9314   // Make the actor not culled again
9315   actor[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 16.0f);
9316
9317   application.SendNotification();
9318
9319   // The damaged rect should not be empty
9320   damagedRects.clear();
9321   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9322   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9323   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9324   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9325
9326   END_TEST;
9327 }
9328
9329 int utcDaliActorPartialUpdateChangeParentOpacity(void)
9330 {
9331   TestApplication application(
9332     TestApplication::DEFAULT_SURFACE_WIDTH,
9333     TestApplication::DEFAULT_SURFACE_HEIGHT,
9334     TestApplication::DEFAULT_HORIZONTAL_DPI,
9335     TestApplication::DEFAULT_VERTICAL_DPI,
9336     true,
9337     true);
9338
9339   tet_infoline("Check the damaged rect with changing parent's opacity");
9340
9341   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9342
9343   Actor parent                          = Actor::New();
9344   parent[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9345   parent[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
9346   parent[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
9347   parent.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9348   application.GetScene().Add(parent);
9349
9350   Texture texture                      = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
9351   Actor   child                        = CreateRenderableActor(texture);
9352   child[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9353   child[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
9354   child.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9355   parent.Add(child);
9356
9357   application.SendNotification();
9358
9359   std::vector<Rect<int>> damagedRects;
9360
9361   // Actor added, damaged rect is added size of actor
9362   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9363   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9364
9365   // Aligned by 16
9366   Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
9367   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9368
9369   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9370   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9371   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9372   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9373   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9374
9375   damagedRects.clear();
9376   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9377   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9378
9379   damagedRects.clear();
9380   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9381   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9382
9383   // Ensure the damaged rect is empty
9384   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9385
9386   // Change the parent's opacity
9387   parent[Actor::Property::OPACITY] = 0.5f;
9388
9389   application.SendNotification();
9390
9391   // The damaged rect should be same
9392   damagedRects.clear();
9393   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9394   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9395   DALI_TEST_CHECK(damagedRects.size() > 0);
9396   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9397
9398   END_TEST;
9399 }
9400
9401 int utcDaliActorPartialAddRemoveRenderer(void)
9402 {
9403   TestApplication application(
9404     TestApplication::DEFAULT_SURFACE_WIDTH,
9405     TestApplication::DEFAULT_SURFACE_HEIGHT,
9406     TestApplication::DEFAULT_HORIZONTAL_DPI,
9407     TestApplication::DEFAULT_VERTICAL_DPI,
9408     true,
9409     true);
9410
9411   tet_infoline("Check the damaged rect with adding / removing renderer");
9412
9413   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9414
9415   Actor actor                          = CreateRenderableActor();
9416   actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9417   actor[Actor::Property::POSITION]     = Vector3(16.0f, 16.0f, 0.0f);
9418   actor[Actor::Property::SIZE]         = Vector3(16.0f, 16.0f, 0.0f);
9419   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9420   application.GetScene().Add(actor);
9421
9422   application.SendNotification();
9423
9424   std::vector<Rect<int>> damagedRects;
9425
9426   // Actor added, damaged rect is added size of actor
9427   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9428   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9429
9430   // Aligned by 16
9431   Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
9432   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9433
9434   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9435   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9436   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9437   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9438   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9439
9440   damagedRects.clear();
9441   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9442   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9443
9444   damagedRects.clear();
9445   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9446   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9447
9448   // Remove the Renderer
9449   Renderer renderer = actor.GetRendererAt(0);
9450   actor.RemoveRenderer(renderer);
9451
9452   application.SendNotification();
9453
9454   // The damaged rect should be the actor area
9455   damagedRects.clear();
9456   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9457   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9458   DALI_TEST_CHECK(damagedRects.size() > 0);
9459   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9460
9461   damagedRects.clear();
9462   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9463   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9464
9465   // Ensure the damaged rect is empty
9466   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9467
9468   // Add the Renderer again
9469   actor.AddRenderer(renderer);
9470
9471   application.SendNotification();
9472
9473   // The damaged rect should be the actor area
9474   damagedRects.clear();
9475   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9476   application.RenderWithPartialUpdate(damagedRects, clippingRect);
9477   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9478   DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9479
9480   END_TEST;
9481 }
9482
9483 int UtcDaliActorCaptureAllTouchAfterStartPropertyP(void)
9484 {
9485   TestApplication application;
9486
9487   Actor actor = Actor::New();
9488   DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), false, TEST_LOCATION);
9489   actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, true);
9490   DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), true, TEST_LOCATION);
9491   DALI_TEST_EQUALS(actor.GetPropertyType(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), Property::BOOLEAN, TEST_LOCATION);
9492   DALI_TEST_EQUALS(actor.IsPropertyWritable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), true, TEST_LOCATION);
9493   DALI_TEST_EQUALS(actor.IsPropertyAnimatable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
9494   DALI_TEST_EQUALS(actor.IsPropertyAConstraintInput(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
9495   DALI_TEST_EQUALS(actor.GetPropertyName(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), "captureAllTouchAfterStart", TEST_LOCATION);
9496   END_TEST;
9497 }
9498
9499 int UtcDaliActorCaptureAllTouchAfterStartPropertyN(void)
9500 {
9501   TestApplication application;
9502
9503   Actor actor = Actor::New();
9504
9505   // Make sure setting invalid types does not cause a crash
9506   try
9507   {
9508     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, 1.0f);
9509     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector2::ONE);
9510     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector3::ONE);
9511     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector4::ONE);
9512     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Map());
9513     actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Array());
9514     tet_result(TET_PASS);
9515   }
9516   catch(...)
9517   {
9518     tet_result(TET_FAIL);
9519   }
9520   END_TEST;
9521 }
9522
9523 int UtcDaliActorTouchAreaOffsetPropertyP(void)
9524 {
9525   TestApplication application;
9526
9527   Actor     actor           = Actor::New();
9528   Rect<int> touchAreaOffset = actor.GetProperty(DevelActor::Property::TOUCH_AREA_OFFSET).Get<Rect<int>>();
9529   DALI_TEST_EQUALS(Rect<int>(0, 0, 0, 0), touchAreaOffset, TEST_LOCATION);
9530   actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Rect<int>(10, 20, 30, 40));
9531   touchAreaOffset = actor.GetProperty(DevelActor::Property::TOUCH_AREA_OFFSET).Get<Rect<int>>();
9532   DALI_TEST_EQUALS(Rect<int>(10, 20, 30, 40), touchAreaOffset, TEST_LOCATION);
9533   END_TEST;
9534 }
9535
9536 int UtcDaliActorTouchAreaOffsetPropertyN(void)
9537 {
9538   TestApplication application;
9539
9540   Actor actor = Actor::New();
9541
9542   // Make sure setting invalid types does not cause a crash
9543   try
9544   {
9545     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, 1.0f);
9546     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector2::ONE);
9547     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector3::ONE);
9548     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector4::ONE);
9549     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Property::Map());
9550     actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Property::Array());
9551     tet_result(TET_PASS);
9552   }
9553   catch(...)
9554   {
9555     tet_result(TET_FAIL);
9556   }
9557   END_TEST;
9558 }
9559
9560 int UtcDaliActorLowerBelowNegative(void)
9561 {
9562   TestApplication application;
9563   Dali::Actor     instance;
9564   try
9565   {
9566     Dali::Actor arg1;
9567     instance.LowerBelow(arg1);
9568     DALI_TEST_CHECK(false); // Should not get here
9569   }
9570   catch(...)
9571   {
9572     DALI_TEST_CHECK(true); // We expect an assert
9573   }
9574   END_TEST;
9575 }
9576
9577 int UtcDaliActorRaiseAboveNegative(void)
9578 {
9579   TestApplication application;
9580   Dali::Actor     instance;
9581   try
9582   {
9583     Dali::Actor arg1;
9584     instance.RaiseAbove(arg1);
9585     DALI_TEST_CHECK(false); // Should not get here
9586   }
9587   catch(...)
9588   {
9589     DALI_TEST_CHECK(true); // We expect an assert
9590   }
9591   END_TEST;
9592 }
9593
9594 int UtcDaliActorRaiseToTopNegative(void)
9595 {
9596   TestApplication application;
9597   Dali::Actor     instance;
9598   try
9599   {
9600     instance.RaiseToTop();
9601     DALI_TEST_CHECK(false); // Should not get here
9602   }
9603   catch(...)
9604   {
9605     DALI_TEST_CHECK(true); // We expect an assert
9606   }
9607   END_TEST;
9608 }
9609
9610 int UtcDaliActorAddRendererNegative(void)
9611 {
9612   TestApplication application;
9613   Dali::Actor     instance;
9614   try
9615   {
9616     Dali::Renderer arg1;
9617     instance.AddRenderer(arg1);
9618     DALI_TEST_CHECK(false); // Should not get here
9619   }
9620   catch(...)
9621   {
9622     DALI_TEST_CHECK(true); // We expect an assert
9623   }
9624   END_TEST;
9625 }
9626
9627 int UtcDaliActorTouchedSignalNegative(void)
9628 {
9629   TestApplication application;
9630   Dali::Actor     instance;
9631   try
9632   {
9633     instance.TouchedSignal();
9634     DALI_TEST_CHECK(false); // Should not get here
9635   }
9636   catch(...)
9637   {
9638     DALI_TEST_CHECK(true); // We expect an assert
9639   }
9640   END_TEST;
9641 }
9642
9643 int UtcDaliActorTranslateByNegative(void)
9644 {
9645   TestApplication application;
9646   Dali::Actor     instance;
9647   try
9648   {
9649     Dali::Vector3 arg1;
9650     instance.TranslateBy(arg1);
9651     DALI_TEST_CHECK(false); // Should not get here
9652   }
9653   catch(...)
9654   {
9655     DALI_TEST_CHECK(true); // We expect an assert
9656   }
9657   END_TEST;
9658 }
9659
9660 int UtcDaliActorFindChildByIdNegative(void)
9661 {
9662   TestApplication application;
9663   Dali::Actor     instance;
9664   try
9665   {
9666     unsigned int arg1 = 0u;
9667     instance.FindChildById(arg1);
9668     DALI_TEST_CHECK(false); // Should not get here
9669   }
9670   catch(...)
9671   {
9672     DALI_TEST_CHECK(true); // We expect an assert
9673   }
9674   END_TEST;
9675 }
9676
9677 int UtcDaliActorGetRendererAtNegative(void)
9678 {
9679   TestApplication application;
9680   Dali::Actor     instance;
9681   try
9682   {
9683     unsigned int arg1 = 0u;
9684     instance.GetRendererAt(arg1);
9685     DALI_TEST_CHECK(false); // Should not get here
9686   }
9687   catch(...)
9688   {
9689     DALI_TEST_CHECK(true); // We expect an assert
9690   }
9691   END_TEST;
9692 }
9693
9694 int UtcDaliActorHoveredSignalNegative(void)
9695 {
9696   TestApplication application;
9697   Dali::Actor     instance;
9698   try
9699   {
9700     instance.HoveredSignal();
9701     DALI_TEST_CHECK(false); // Should not get here
9702   }
9703   catch(...)
9704   {
9705     DALI_TEST_CHECK(true); // We expect an assert
9706   }
9707   END_TEST;
9708 }
9709
9710 int UtcDaliActorLowerToBottomNegative(void)
9711 {
9712   TestApplication application;
9713   Dali::Actor     instance;
9714   try
9715   {
9716     instance.LowerToBottom();
9717     DALI_TEST_CHECK(false); // Should not get here
9718   }
9719   catch(...)
9720   {
9721     DALI_TEST_CHECK(true); // We expect an assert
9722   }
9723   END_TEST;
9724 }
9725
9726 int UtcDaliActorOnSceneSignalNegative(void)
9727 {
9728   TestApplication application;
9729   Dali::Actor     instance;
9730   try
9731   {
9732     instance.OnSceneSignal();
9733     DALI_TEST_CHECK(false); // Should not get here
9734   }
9735   catch(...)
9736   {
9737     DALI_TEST_CHECK(true); // We expect an assert
9738   }
9739   END_TEST;
9740 }
9741
9742 int UtcDaliActorOffSceneSignalNegative(void)
9743 {
9744   TestApplication application;
9745   Dali::Actor     instance;
9746   try
9747   {
9748     instance.OffSceneSignal();
9749     DALI_TEST_CHECK(false); // Should not get here
9750   }
9751   catch(...)
9752   {
9753     DALI_TEST_CHECK(true); // We expect an assert
9754   }
9755   END_TEST;
9756 }
9757
9758 int UtcDaliActorRemoveRendererNegative01(void)
9759 {
9760   TestApplication application;
9761   Dali::Actor     instance;
9762   try
9763   {
9764     unsigned int arg1 = 0u;
9765     instance.RemoveRenderer(arg1);
9766     DALI_TEST_CHECK(false); // Should not get here
9767   }
9768   catch(...)
9769   {
9770     DALI_TEST_CHECK(true); // We expect an assert
9771   }
9772   END_TEST;
9773 }
9774
9775 int UtcDaliActorRemoveRendererNegative02(void)
9776 {
9777   TestApplication application;
9778   Dali::Actor     instance;
9779   try
9780   {
9781     Dali::Renderer arg1;
9782     instance.RemoveRenderer(arg1);
9783     DALI_TEST_CHECK(false); // Should not get here
9784   }
9785   catch(...)
9786   {
9787     DALI_TEST_CHECK(true); // We expect an assert
9788   }
9789   END_TEST;
9790 }
9791
9792 int UtcDaliActorFindChildByNameNegative(void)
9793 {
9794   TestApplication application;
9795   Dali::Actor     instance;
9796   try
9797   {
9798     std::string arg1;
9799     instance.FindChildByName(arg1);
9800     DALI_TEST_CHECK(false); // Should not get here
9801   }
9802   catch(...)
9803   {
9804     DALI_TEST_CHECK(true); // We expect an assert
9805   }
9806   END_TEST;
9807 }
9808
9809 int UtcDaliActorSetResizePolicyNegative(void)
9810 {
9811   TestApplication application;
9812   Dali::Actor     instance;
9813   try
9814   {
9815     Dali::ResizePolicy::Type arg1 = ResizePolicy::USE_NATURAL_SIZE;
9816     Dali::Dimension::Type    arg2 = Dimension::ALL_DIMENSIONS;
9817     instance.SetResizePolicy(arg1, arg2);
9818     DALI_TEST_CHECK(false); // Should not get here
9819   }
9820   catch(...)
9821   {
9822     DALI_TEST_CHECK(true); // We expect an assert
9823   }
9824   END_TEST;
9825 }
9826
9827 int UtcDaliActorOnRelayoutSignalNegative(void)
9828 {
9829   TestApplication application;
9830   Dali::Actor     instance;
9831   try
9832   {
9833     instance.OnRelayoutSignal();
9834     DALI_TEST_CHECK(false); // Should not get here
9835   }
9836   catch(...)
9837   {
9838     DALI_TEST_CHECK(true); // We expect an assert
9839   }
9840   END_TEST;
9841 }
9842
9843 int UtcDaliActorWheelEventSignalNegative(void)
9844 {
9845   TestApplication application;
9846   Dali::Actor     instance;
9847   try
9848   {
9849     instance.WheelEventSignal();
9850     DALI_TEST_CHECK(false); // Should not get here
9851   }
9852   catch(...)
9853   {
9854     DALI_TEST_CHECK(true); // We expect an assert
9855   }
9856   END_TEST;
9857 }
9858
9859 int UtcDaliActorGetHeightForWidthNegative(void)
9860 {
9861   TestApplication application;
9862   Dali::Actor     instance;
9863   try
9864   {
9865     float arg1 = 0.0f;
9866     instance.GetHeightForWidth(arg1);
9867     DALI_TEST_CHECK(false); // Should not get here
9868   }
9869   catch(...)
9870   {
9871     DALI_TEST_CHECK(true); // We expect an assert
9872   }
9873   END_TEST;
9874 }
9875
9876 int UtcDaliActorGetWidthForHeightNegative(void)
9877 {
9878   TestApplication application;
9879   Dali::Actor     instance;
9880   try
9881   {
9882     float arg1 = 0.0f;
9883     instance.GetWidthForHeight(arg1);
9884     DALI_TEST_CHECK(false); // Should not get here
9885   }
9886   catch(...)
9887   {
9888     DALI_TEST_CHECK(true); // We expect an assert
9889   }
9890   END_TEST;
9891 }
9892
9893 int UtcDaliActorLayoutDirectionChangedSignalNegative(void)
9894 {
9895   TestApplication application;
9896   Dali::Actor     instance;
9897   try
9898   {
9899     instance.LayoutDirectionChangedSignal();
9900     DALI_TEST_CHECK(false); // Should not get here
9901   }
9902   catch(...)
9903   {
9904     DALI_TEST_CHECK(true); // We expect an assert
9905   }
9906   END_TEST;
9907 }
9908
9909 int UtcDaliActorAddNegative(void)
9910 {
9911   TestApplication application;
9912   Dali::Actor     instance;
9913   try
9914   {
9915     Dali::Actor arg1;
9916     instance.Add(arg1);
9917     DALI_TEST_CHECK(false); // Should not get here
9918   }
9919   catch(...)
9920   {
9921     DALI_TEST_CHECK(true); // We expect an assert
9922   }
9923   END_TEST;
9924 }
9925
9926 int UtcDaliActorLowerNegative(void)
9927 {
9928   TestApplication application;
9929   Dali::Actor     instance;
9930   try
9931   {
9932     instance.Lower();
9933     DALI_TEST_CHECK(false); // Should not get here
9934   }
9935   catch(...)
9936   {
9937     DALI_TEST_CHECK(true); // We expect an assert
9938   }
9939   END_TEST;
9940 }
9941
9942 int UtcDaliActorRaiseNegative(void)
9943 {
9944   TestApplication application;
9945   Dali::Actor     instance;
9946   try
9947   {
9948     instance.Raise();
9949     DALI_TEST_CHECK(false); // Should not get here
9950   }
9951   catch(...)
9952   {
9953     DALI_TEST_CHECK(true); // We expect an assert
9954   }
9955   END_TEST;
9956 }
9957
9958 int UtcDaliActorRemoveNegative(void)
9959 {
9960   TestApplication application;
9961   Dali::Actor     instance;
9962   try
9963   {
9964     Dali::Actor arg1;
9965     instance.Remove(arg1);
9966     DALI_TEST_CHECK(false); // Should not get here
9967   }
9968   catch(...)
9969   {
9970     DALI_TEST_CHECK(true); // We expect an assert
9971   }
9972   END_TEST;
9973 }
9974
9975 int UtcDaliActorScaleByNegative(void)
9976 {
9977   TestApplication application;
9978   Dali::Actor     instance;
9979   try
9980   {
9981     Dali::Vector3 arg1;
9982     instance.ScaleBy(arg1);
9983     DALI_TEST_CHECK(false); // Should not get here
9984   }
9985   catch(...)
9986   {
9987     DALI_TEST_CHECK(true); // We expect an assert
9988   }
9989   END_TEST;
9990 }
9991
9992 int UtcDaliActorGetLayerNegative(void)
9993 {
9994   TestApplication application;
9995   Dali::Actor     instance;
9996   try
9997   {
9998     instance.GetLayer();
9999     DALI_TEST_CHECK(false); // Should not get here
10000   }
10001   catch(...)
10002   {
10003     DALI_TEST_CHECK(true); // We expect an assert
10004   }
10005   END_TEST;
10006 }
10007
10008 int UtcDaliActorRotateByNegative01(void)
10009 {
10010   TestApplication application;
10011   Dali::Actor     instance;
10012   try
10013   {
10014     Dali::Quaternion arg1;
10015     instance.RotateBy(arg1);
10016     DALI_TEST_CHECK(false); // Should not get here
10017   }
10018   catch(...)
10019   {
10020     DALI_TEST_CHECK(true); // We expect an assert
10021   }
10022   END_TEST;
10023 }
10024
10025 int UtcDaliActorRotateByNegative02(void)
10026 {
10027   TestApplication application;
10028   Dali::Actor     instance;
10029   try
10030   {
10031     Dali::Radian  arg1;
10032     Dali::Vector3 arg2;
10033     instance.RotateBy(arg1, arg2);
10034     DALI_TEST_CHECK(false); // Should not get here
10035   }
10036   catch(...)
10037   {
10038     DALI_TEST_CHECK(true); // We expect an assert
10039   }
10040   END_TEST;
10041 }
10042
10043 int UtcDaliActorUnparentNegative(void)
10044 {
10045   TestApplication application;
10046   Dali::Actor     instance;
10047   try
10048   {
10049     instance.Unparent();
10050     DALI_TEST_CHECK(false); // Should not get here
10051   }
10052   catch(...)
10053   {
10054     DALI_TEST_CHECK(true); // We expect an assert
10055   }
10056   END_TEST;
10057 }
10058
10059 int UtcDaliActorGetChildAtNegative(void)
10060 {
10061   TestApplication application;
10062   Dali::Actor     instance;
10063   try
10064   {
10065     unsigned int arg1 = 0u;
10066     instance.GetChildAt(arg1);
10067     DALI_TEST_CHECK(false); // Should not get here
10068   }
10069   catch(...)
10070   {
10071     DALI_TEST_CHECK(true); // We expect an assert
10072   }
10073   END_TEST;
10074 }
10075
10076 int UtcDaliActorGetChildCountNegative(void)
10077 {
10078   TestApplication application;
10079   Dali::Actor     instance;
10080   try
10081   {
10082     instance.GetChildCount();
10083     DALI_TEST_CHECK(false); // Should not get here
10084   }
10085   catch(...)
10086   {
10087     DALI_TEST_CHECK(true); // We expect an assert
10088   }
10089   END_TEST;
10090 }
10091
10092 int UtcDaliActorGetTargetSizeNegative(void)
10093 {
10094   TestApplication application;
10095   Dali::Actor     instance;
10096   try
10097   {
10098     instance.GetTargetSize();
10099     DALI_TEST_CHECK(false); // Should not get here
10100   }
10101   catch(...)
10102   {
10103     DALI_TEST_CHECK(true); // We expect an assert
10104   }
10105   END_TEST;
10106 }
10107
10108 int UtcDaliActorScreenToLocalNegative(void)
10109 {
10110   TestApplication application;
10111   Dali::Actor     instance;
10112   try
10113   {
10114     float arg1 = 0.0f;
10115     float arg2 = 0.0f;
10116     float arg3 = 0.0f;
10117     float arg4 = 0.0f;
10118     instance.ScreenToLocal(arg1, arg2, arg3, arg4);
10119     DALI_TEST_CHECK(false); // Should not get here
10120   }
10121   catch(...)
10122   {
10123     DALI_TEST_CHECK(true); // We expect an assert
10124   }
10125   END_TEST;
10126 }
10127
10128 int UtcDaliActorGetNaturalSizeNegative(void)
10129 {
10130   TestApplication application;
10131   Dali::Actor     instance;
10132   try
10133   {
10134     instance.GetNaturalSize();
10135     DALI_TEST_CHECK(false); // Should not get here
10136   }
10137   catch(...)
10138   {
10139     DALI_TEST_CHECK(true); // We expect an assert
10140   }
10141   END_TEST;
10142 }
10143
10144 int UtcDaliActorGetRelayoutSizeNegative(void)
10145 {
10146   TestApplication application;
10147   Dali::Actor     instance;
10148   try
10149   {
10150     Dali::Dimension::Type arg1 = Dimension::HEIGHT;
10151     instance.GetRelayoutSize(arg1);
10152     DALI_TEST_CHECK(false); // Should not get here
10153   }
10154   catch(...)
10155   {
10156     DALI_TEST_CHECK(true); // We expect an assert
10157   }
10158   END_TEST;
10159 }
10160
10161 int UtcDaliActorGetResizePolicyNegative(void)
10162 {
10163   TestApplication application;
10164   Dali::Actor     instance;
10165   try
10166   {
10167     Dali::Dimension::Type arg1 = Dimension::ALL_DIMENSIONS;
10168     instance.GetResizePolicy(arg1);
10169     DALI_TEST_CHECK(false); // Should not get here
10170   }
10171   catch(...)
10172   {
10173     DALI_TEST_CHECK(true); // We expect an assert
10174   }
10175   END_TEST;
10176 }
10177
10178 int UtcDaliActorGetRendererCountNegative(void)
10179 {
10180   TestApplication application;
10181   Dali::Actor     instance;
10182   try
10183   {
10184     instance.GetRendererCount();
10185     DALI_TEST_CHECK(false); // Should not get here
10186   }
10187   catch(...)
10188   {
10189     DALI_TEST_CHECK(true); // We expect an assert
10190   }
10191   END_TEST;
10192 }
10193
10194 int UtcDaliActorGetParentNegative(void)
10195 {
10196   TestApplication application;
10197   Dali::Actor     instance;
10198   try
10199   {
10200     instance.GetParent();
10201     DALI_TEST_CHECK(false); // Should not get here
10202   }
10203   catch(...)
10204   {
10205     DALI_TEST_CHECK(true); // We expect an assert
10206   }
10207   END_TEST;
10208 }
10209
10210 int UtcDaliActorPropertyBlendEquation(void)
10211 {
10212   TestApplication application;
10213
10214   tet_infoline("Test SetProperty AdvancedBlendEquation");
10215
10216   Geometry geometry  = CreateQuadGeometry();
10217   Shader   shader    = CreateShader();
10218   Renderer renderer1 = Renderer::New(geometry, shader);
10219
10220   Actor actor = Actor::New();
10221   actor.SetProperty(Actor::Property::OPACITY, 0.1f);
10222
10223   actor.AddRenderer(renderer1);
10224   actor.SetProperty(Actor::Property::SIZE, Vector2(400, 400));
10225   application.GetScene().Add(actor);
10226
10227   if(!Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
10228   {
10229     actor.SetProperty(Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN);
10230     int equation = actor.GetProperty<int>(Dali::DevelActor::Property::BLEND_EQUATION);
10231     DALI_TEST_EQUALS((Dali::DevelBlendEquation::SCREEN == equation), false, TEST_LOCATION);
10232   }
10233
10234   if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
10235   {
10236     actor.SetProperty(Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN);
10237     int equation = actor.GetProperty<int>(Dali::DevelActor::Property::BLEND_EQUATION);
10238     DALI_TEST_EQUALS((Dali::DevelBlendEquation::SCREEN == equation), true, TEST_LOCATION);
10239   }
10240
10241   Renderer renderer2 = Renderer::New(geometry, shader);
10242   actor.AddRenderer(renderer2);
10243
10244   END_TEST;
10245 }
10246
10247 int UtcDaliActorRegisterProperty(void)
10248 {
10249   tet_infoline("Test property registration and uniform map update\n");
10250
10251   TestApplication application;
10252
10253   Geometry geometry  = CreateQuadGeometry();
10254   Shader   shader    = CreateShader();
10255   Renderer renderer1 = Renderer::New(geometry, shader);
10256   Renderer renderer2 = Renderer::New(geometry, shader);
10257
10258   Actor actor1 = Actor::New();
10259   actor1.AddRenderer(renderer1);
10260   actor1.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
10261   actor1.RegisterProperty("uCustom", 1);
10262   application.GetScene().Add(actor1);
10263
10264   Actor actor2 = Actor::New();
10265   actor2.AddRenderer(renderer2);
10266   actor2.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
10267   application.GetScene().Add(actor2);
10268
10269   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
10270   TraceCallStack&    callStack     = glAbstraction.GetSetUniformTrace();
10271   glAbstraction.EnableSetUniformCallTrace(true);
10272
10273   application.SendNotification();
10274   application.Render();
10275
10276   std::stringstream out;
10277   out.str("1");
10278   std::string params;
10279
10280   // Test uniform value of the custom property
10281   DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("uCustom", params));
10282   DALI_TEST_EQUALS(out.str(), params, TEST_LOCATION);
10283
10284   // Make invisible
10285   actor1[Actor::Property::VISIBLE] = false;
10286
10287   application.SendNotification();
10288   application.Render();
10289
10290   // Make visible again
10291   actor1[Actor::Property::VISIBLE] = true;
10292   actor1["uCustom"]                = 2;
10293
10294   glAbstraction.ResetSetUniformCallStack();
10295
10296   application.SendNotification();
10297   application.Render();
10298
10299   out.str("2");
10300
10301   // The uniform value should not be changed
10302   DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("uCustom", params));
10303   DALI_TEST_EQUALS(out.str(), params, TEST_LOCATION);
10304
10305   END_TEST;
10306 }