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