[dali_1.1.28] Merge branch 'devel/master'
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-CustomActor.cpp
1 /*
2  * Copyright (c) 2014 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 #include <iostream>
19 #include <stdlib.h>
20 #include <dali/public-api/dali-core.h>
21
22 #include <dali/integration-api/events/touch-event-integ.h>
23 #include <dali/integration-api/events/hover-event-integ.h>
24 #include <dali/integration-api/events/wheel-event-integ.h>
25 #include <dali/integration-api/events/key-event-integ.h>
26
27 #include "dali-test-suite-utils/dali-test-suite-utils.h"
28
29 using namespace Dali;
30
31
32 void custom_actor_test_startup(void)
33 {
34   test_return_value = TET_UNDEF;
35 }
36
37 void custom_actor_test_cleanup(void)
38 {
39   test_return_value = TET_PASS;
40 }
41
42 namespace
43 {
44
45 std::vector< std::string > MasterCallStack;
46 bool gOnRelayout = false;
47
48 } // anon namespace
49
50 // TypeRegistry needs custom actor Implementations to have the same name (namespaces are ignored so we use one here)
51 namespace Impl
52 {
53
54 struct TestCustomActor : public CustomActorImpl
55 {
56   /**
57    * Constructor
58    */
59   TestCustomActor()
60   : CustomActorImpl( ActorFlags( REQUIRES_TOUCH_EVENTS | REQUIRES_WHEEL_EVENTS | REQUIRES_HOVER_EVENTS | DISABLE_SIZE_NEGOTIATION ) ),
61     mDaliProperty( Property::INVALID_INDEX ),
62     mSizeSet( Vector3::ZERO ),
63     mTargetSize( Vector3::ZERO ),
64     mNego( false ),
65     mDepth(0u)
66   {
67   }
68
69   TestCustomActor(bool nego)
70   : CustomActorImpl( ActorFlags( REQUIRES_TOUCH_EVENTS | REQUIRES_WHEEL_EVENTS | REQUIRES_HOVER_EVENTS ) ),
71     mDaliProperty( Property::INVALID_INDEX ),
72     mSizeSet( Vector3::ZERO ),
73     mTargetSize( Vector3::ZERO ),
74     mNego( nego )
75   {
76   }
77   /**
78    * Destructor
79    */
80   virtual ~TestCustomActor()
81   {
82   }
83
84   void Initialize( const char* name = NULL )
85   {
86     mDaliProperty = Self().RegisterProperty( "Dali", std::string("no"), Property::READ_WRITE);
87
88     OnInitialize( name );
89   }
90
91   virtual void OnInitialize( const char* name ) {}
92
93   /**
94    * Resets the call stack
95    */
96   void ResetCallStack()
97   {
98     mSizeSet = Vector3();
99     mTargetSize = Vector3();
100     mMethodsCalled.clear();
101   }
102
103   void AddToCallStacks( const char* method )
104   {
105     mMethodsCalled.push_back( method );
106
107     // Combine Actor name with method string
108     std::string nameAndMethod( Self().GetName() );
109     if ( 0 == nameAndMethod.size() )
110     {
111       nameAndMethod = "Unknown: ";
112     }
113     else
114     {
115       nameAndMethod += ": ";
116     }
117     nameAndMethod += method;
118
119     MasterCallStack.push_back( nameAndMethod );
120   }
121
122   // From CustomActorImpl
123   virtual void OnStageConnection( int depth )
124   {
125     AddToCallStacks("OnStageConnection");
126     mDepth = depth;
127   }
128   virtual void OnStageDisconnection()
129   {
130     AddToCallStacks("OnStageDisconnection");
131   }
132   virtual void OnChildAdd(Actor& child)
133   {
134     AddToCallStacks("OnChildAdd");
135   }
136   virtual void OnChildRemove(Actor& child)
137   {
138     AddToCallStacks("OnChildRemove");
139   }
140   virtual void OnPropertySet( Property::Index index, Property::Value propertyValue )
141   {
142     AddToCallStacks("OnPropertySet");
143   }
144   virtual void OnSizeSet(const Vector3& targetSize)
145   {
146     mSizeSet = targetSize;
147     AddToCallStacks("OnSizeSet");
148   }
149   virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize)
150   {
151     mTargetSize = targetSize;
152     AddToCallStacks("OnSizeAnimation");
153   }
154   virtual bool OnTouchEvent(const TouchEvent& event)
155   {
156     AddToCallStacks("OnTouchEvent");
157     return true;
158   }
159   virtual bool OnHoverEvent(const HoverEvent& event)
160   {
161     AddToCallStacks("OnHoverEvent");
162     return true;
163   }
164   virtual bool OnWheelEvent(const WheelEvent& event)
165   {
166     AddToCallStacks("OnWheelEvent");
167     return true;
168   }
169   virtual bool OnKeyEvent(const KeyEvent& event)
170   {
171     AddToCallStacks("OnKeyEvent");
172     return true;
173   }
174   virtual void OnKeyInputFocusGained()
175   {
176     AddToCallStacks("OnKeyInputFocusGained");
177   }
178   virtual void OnKeyInputFocusLost()
179   {
180     AddToCallStacks("OnKeyInputFocusLost");
181   }
182   virtual Vector3 GetNaturalSize()
183   {
184     return Vector3( 0.0f, 0.0f, 0.0f );
185   }
186
187   virtual float GetHeightForWidth( float width )
188   {
189     return 0.0f;
190   }
191
192   virtual float GetWidthForHeight( float height )
193   {
194     return 0.0f;
195   }
196
197   virtual void OnRelayout( const Vector2& size, RelayoutContainer& container )
198   {
199     gOnRelayout = true;
200   }
201
202   virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
203   {
204   }
205
206   virtual void OnCalculateRelayoutSize( Dimension::Type dimension )
207   {
208   }
209
210   virtual float CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension )
211   {
212     return 0.0f;
213   }
214
215   virtual void OnLayoutNegotiated( float size, Dimension::Type dimension )
216   {
217   }
218
219   virtual bool RelayoutDependentOnChildren( Dimension::Type dimension = Dimension::ALL_DIMENSIONS )
220   {
221     return false;
222   }
223
224   void SetDaliProperty(std::string s)
225   {
226     Self().SetProperty(mDaliProperty, s);
227   }
228   void TestRelayoutRequest()
229   {
230     RelayoutRequest();
231   }
232
233   float TestGetHeightForWidthBase( float width )
234   {
235     return GetHeightForWidthBase( width );
236   }
237
238   float TestGetWidthForHeightBase( float height )
239   {
240     return GetWidthForHeightBase( height );
241   }
242
243   float TestCalculateChildSizeBase( const Dali::Actor& child, Dimension::Type dimension )
244   {
245     return CalculateChildSizeBase( child, dimension );
246   }
247
248   bool TestRelayoutDependentOnChildrenBase( Dimension::Type dimension )
249   {
250     return RelayoutDependentOnChildrenBase( dimension );
251   }
252
253   Property::Index mDaliProperty;
254   std::vector< std::string > mMethodsCalled;
255   Vector3 mSizeSet;
256   Vector3 mTargetSize;
257   bool mNego;
258   unsigned int mDepth;
259 };
260
261 /**
262  * Variant which adds a new child during OnStageConnection
263  */
264 struct TestCustomActorVariant1 : public TestCustomActor
265 {
266   /**
267    * Constructor
268    */
269   TestCustomActorVariant1( Actor childToAdd )
270   : mChildToAdd( childToAdd )
271   {
272   }
273
274   // From CustomActorImpl
275   virtual void OnStageConnection( int depth )
276   {
277     // Chain up first
278     TestCustomActor::OnStageConnection( depth );
279
280     // Add the child
281     Self().Add( mChildToAdd );
282   }
283
284   Actor mChildToAdd;
285 };
286
287 /**
288  * Variant which removes children during OnStageConnection
289  */
290 struct TestCustomActorVariant2 : public TestCustomActor
291 {
292   /**
293    * Constructor
294    */
295   TestCustomActorVariant2()
296   {
297   }
298
299   // From CustomActorImpl
300   virtual void OnStageConnection( int depth )
301   {
302     // Chain up first
303     TestCustomActor::OnStageConnection( depth );
304
305     // Remove all the children
306     for( unsigned int i=0, num=Self().GetChildCount(); i<num; ++i )
307     {
308       Self().Remove( Self().GetChildAt(0) );
309     }
310   }
311 };
312
313 /**
314  * Variant which adds a new child during OnStageDisconnection
315  */
316 struct TestCustomActorVariant3 : public TestCustomActor
317 {
318   /**
319    * Constructor
320    */
321   TestCustomActorVariant3( Actor childToAdd )
322   : mChildToAdd( childToAdd )
323   {
324   }
325
326   // From CustomActorImpl
327   virtual void OnStageDisconnection()
328   {
329     // Chain up first
330     TestCustomActor::OnStageDisconnection();
331
332     // Add the child
333     Self().Add( mChildToAdd );
334   }
335
336   Actor mChildToAdd;
337 };
338
339 /**
340  * Variant which removes children during OnStageDisconnection
341  */
342 struct TestCustomActorVariant4 : public TestCustomActor
343 {
344   /**
345    * Constructor
346    */
347   TestCustomActorVariant4()
348   {
349   }
350
351   // From CustomActorImpl
352   virtual void OnStageDisconnection()
353   {
354     // Chain up first
355     TestCustomActor::OnStageDisconnection();
356
357     // Remove all the children
358     for( unsigned int i=0, num=Self().GetChildCount(); i<num; ++i )
359     {
360       Self().Remove( Self().GetChildAt(0) );
361     }
362   }
363 };
364
365 /**
366  * Variant which removes its parent from Stage during OnStageConnection
367  */
368 struct TestCustomActorVariant5 : public TestCustomActor
369 {
370   /**
371    * Constructor
372    */
373   TestCustomActorVariant5()
374   {
375   }
376
377   // From CustomActorImpl
378   virtual void OnStageConnection( int depth )
379   {
380     // Chain up first
381     TestCustomActor::OnStageConnection( depth );
382
383     // Take parent off-stage
384     Actor parent = Self().GetParent();
385     if ( parent )
386     {
387       Stage::GetCurrent().Remove( parent );
388     }
389   }
390 };
391
392 /**
393  * Variant which adds its parent to Stage during OnStageDisconnection
394  */
395 struct TestCustomActorVariant6 : public TestCustomActor
396 {
397   /**
398    * Constructor
399    */
400   TestCustomActorVariant6()
401   {
402   }
403
404   // From CustomActorImpl
405   virtual void OnStageDisconnection()
406   {
407     // Chain up first
408     TestCustomActor::OnStageDisconnection();
409
410     // Put parent on-stage
411     Actor parent = Self().GetParent();
412     if ( parent )
413     {
414       Stage::GetCurrent().Add( parent );
415     }
416   }
417 };
418
419 /**
420  * Variant which reparents its children into a separate container
421  */
422 struct TestCustomActorVariant7 : public TestCustomActor
423 {
424   /**
425    * Constructor
426    */
427   TestCustomActorVariant7()
428   {
429   }
430
431   virtual void OnInitialize( const char* name )
432   {
433     // We need to do this early, before the OnChildAdd is recorded
434     Self().SetName( name );
435
436     mContainer = Actor::New();
437     mContainer.SetName( "Container" );
438     Self().Add( mContainer );
439   }
440
441   // From CustomActorImpl
442   virtual void OnChildAdd(Actor& child)
443   {
444     // Chain up first
445     TestCustomActor::OnChildAdd(child);
446
447     // Reparent child
448     if ( child != mContainer )
449     {
450       mContainer.Add( child );
451     }
452   }
453
454   Actor mContainer;
455 };
456
457 /**
458  * Variant which attempts to interfere with the reparenting of a child to another container
459  */
460 struct TestCustomActorVariant8 : public TestCustomActor
461 {
462   /**
463    * Constructor
464    */
465   TestCustomActorVariant8( Actor rival )
466   : mRivalContainer( rival )
467   {
468   }
469
470   // From CustomActorImpl
471   virtual void OnChildRemove(Actor& child)
472   {
473     // Chain up first
474     TestCustomActor::OnChildRemove(child);
475
476     mRivalContainer.Remove( child ); // attempt to block reparenting to rival (should be a NOOP)
477   }
478
479   Actor mRivalContainer;
480 };
481
482 // Need a class that doesn't override virtual methods
483 class SimpleTestCustomActor : public CustomActorImpl
484 {
485 public:
486
487   /**
488    * Constructor
489    */
490   SimpleTestCustomActor()
491   : CustomActorImpl( ActorFlags( REQUIRES_TOUCH_EVENTS | DISABLE_SIZE_NEGOTIATION ) )
492   {
493   }
494
495   /**
496    * Destructor
497    */
498   virtual ~SimpleTestCustomActor()
499   {
500   }
501
502   // From CustomActorImpl
503   virtual void OnStageConnection( int depth )
504   {
505   }
506   virtual void OnStageDisconnection()
507   {
508   }
509   virtual void OnChildAdd(Actor& child)
510   {
511   }
512   virtual void OnChildRemove(Actor& child)
513   {
514   }
515   virtual void OnSizeSet(const Vector3& targetSize)
516   {
517   }
518   virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize)
519   {
520   }
521   virtual bool OnTouchEvent(const TouchEvent& event)
522   {
523     return true;
524   }
525   virtual bool OnHoverEvent(const HoverEvent& event)
526   {
527     return true;
528   }
529   virtual bool OnWheelEvent(const WheelEvent& event)
530   {
531     return true;
532   }
533   virtual bool OnKeyEvent(const KeyEvent& event)
534   {
535     return true;
536   }
537   virtual void OnKeyInputFocusGained()
538   {
539   }
540   virtual void OnKeyInputFocusLost()
541   {
542   }
543
544   virtual Vector3 GetNaturalSize()
545   {
546     return Vector3( 0.0f, 0.0f, 0.0f );
547   }
548
549   virtual float GetHeightForWidth( float width )
550   {
551     return 0.0f;
552   }
553
554   virtual float GetWidthForHeight( float height )
555   {
556     return 0.0f;
557   }
558
559   virtual void OnRelayout( const Vector2& size, RelayoutContainer& container )
560   {
561   }
562
563   virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
564   {
565   }
566
567   virtual void OnCalculateRelayoutSize( Dimension::Type dimension )
568   {
569   }
570
571   virtual float CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension )
572   {
573     return 0.0f;
574   }
575
576   virtual void OnLayoutNegotiated( float size, Dimension::Type dimension )
577   {
578   }
579
580   virtual bool RelayoutDependentOnChildren( Dimension::Type dimension = Dimension::ALL_DIMENSIONS )
581   {
582     return false;
583   }
584 };
585
586 } ; // namespace Impl
587
588
589 namespace
590 {
591
592 /**
593  * Test custom actor handle
594  */
595 class TestCustomActor : public CustomActor
596 {
597 public:
598
599   static TestCustomActor New()
600   {
601     Impl::TestCustomActor* impl = new Impl::TestCustomActor;
602     TestCustomActor custom( *impl ); // takes ownership
603
604     impl->Initialize();
605
606     return custom;
607   }
608
609   static TestCustomActor NewNegoSize()
610   {
611     Impl::TestCustomActor* impl = new Impl::TestCustomActor( true );
612     TestCustomActor custom( *impl ); // takes ownership
613     custom.SetName( "SizeNegotiationActor" );
614
615     impl->Initialize();
616
617     return custom;
618   }
619
620   static TestCustomActor NewVariant1( Actor childToAdd )
621   {
622     Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant1( childToAdd );
623     TestCustomActor custom( *impl ); // takes ownership
624
625     impl->Initialize();
626
627     return custom;
628   }
629
630   static TestCustomActor NewVariant2()
631   {
632     Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant2();
633     TestCustomActor custom( *impl ); // takes ownership
634
635     impl->Initialize();
636
637     return custom;
638   }
639
640   static TestCustomActor NewVariant3( Actor childToAdd )
641   {
642     Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant3( childToAdd );
643     TestCustomActor custom( *impl ); // takes ownership
644
645     impl->Initialize();
646
647     return custom;
648   }
649
650   static TestCustomActor NewVariant4()
651   {
652     Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant4();
653     TestCustomActor custom( *impl ); // takes ownership
654
655     impl->Initialize();
656
657     return custom;
658   }
659
660   static TestCustomActor NewVariant5()
661   {
662     Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant5();
663     TestCustomActor custom( *impl ); // takes ownership
664
665     impl->Initialize();
666
667     return custom;
668   }
669
670   static TestCustomActor NewVariant6()
671   {
672     Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant6();
673     TestCustomActor custom( *impl ); // takes ownership
674
675     impl->Initialize();
676
677     return custom;
678   }
679
680   static TestCustomActor NewVariant7( const char* name )
681   {
682     Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant7();
683     TestCustomActor custom( *impl ); // takes ownership
684
685     impl->Initialize( name );
686
687     return custom;
688   }
689
690   static TestCustomActor NewVariant8( Actor rival )
691   {
692     Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant8( rival );
693     TestCustomActor custom( *impl ); // takes ownership
694
695     impl->Initialize();
696
697     return custom;
698   }
699
700   virtual ~TestCustomActor()
701   {
702   }
703
704   Impl::TestCustomActor& GetImpl()
705   {
706     return static_cast<Impl::TestCustomActor&>(GetImplementation());
707   }
708
709   std::vector< std::string >& GetMethodsCalled()
710   {
711     return GetImpl().mMethodsCalled;
712   }
713
714   void ResetCallStack()
715   {
716     GetImpl().ResetCallStack();
717   }
718
719   void SetDaliProperty(std::string s)
720   {
721     GetImpl().SetDaliProperty(s);
722   }
723
724   Vector3 GetSize()
725   {
726     return GetImpl().mSizeSet;
727   }
728
729   Vector3 GetTargetSize()
730   {
731     return GetImpl().mTargetSize;
732   }
733
734   virtual Vector3 GetNaturalSize()
735   {
736     return Vector3( 0.0f, 0.0f, 0.0f );
737   }
738
739   virtual float GetHeightForWidth( float width )
740   {
741     return 0.0f;
742   }
743
744   virtual float GetWidthForHeight( float height )
745   {
746     return 0.0f;
747   }
748
749   virtual void OnRelayout( const Vector2& size, RelayoutContainer& container )
750   {
751   }
752
753   virtual void OnLayoutNegotiated( float size, Dimension::Type dimension )
754   {
755   }
756
757   virtual void OnCalculateRelayoutSize( Dimension::Type dimension )
758   {
759   }
760
761   void TestRelayoutRequest()
762   {
763     GetImpl().TestRelayoutRequest();
764   }
765
766   float TestGetHeightForWidthBase( float width )
767   {
768     return GetImpl().TestGetHeightForWidthBase( width );
769   }
770
771   float TestGetWidthForHeightBase( float height )
772   {
773     return GetImpl().TestGetWidthForHeightBase( height );
774   }
775
776   float TestCalculateChildSizeBase( const Dali::Actor& child, Dimension::Type dimension )
777   {
778     return GetImpl().TestCalculateChildSizeBase( child, dimension );
779   }
780
781   bool TestRelayoutDependentOnChildrenBase( Dimension::Type dimension )
782   {
783     return GetImpl().TestRelayoutDependentOnChildrenBase( dimension );
784   }
785
786   unsigned int GetDepth()
787   {
788     return GetImpl().mDepth;
789   }
790 private:
791
792   TestCustomActor( Impl::TestCustomActor& impl ) : CustomActor( impl )
793   {
794   }
795 };
796
797
798
799 using namespace Dali;
800
801 BaseHandle CreateActor()
802 {
803   return TestCustomActor::New();
804 }
805
806 Dali::TypeRegistration mType( typeid(TestCustomActor), typeid(Dali::CustomActor), CreateActor );
807
808 } // anon namespace
809
810
811 int UtcDaliCustomActorDestructor(void)
812 {
813   TestApplication application;
814
815   CustomActor* actor = new CustomActor();
816   delete actor;
817
818   DALI_TEST_CHECK( true );
819   END_TEST;
820 }
821
822 int UtcDaliCustomActorImplDestructor(void)
823 {
824   TestApplication application;
825   CustomActorImpl* actor = new Impl::TestCustomActor();
826   delete actor;
827
828   DALI_TEST_CHECK( true );
829   END_TEST;
830 }
831
832 // Positive test case for a method
833 int UtcDaliCustomActorDownCast(void)
834 {
835   TestApplication application;
836   tet_infoline("Testing Dali::CustomActor::DownCast()");
837
838   TestCustomActor custom = TestCustomActor::New();
839
840   Actor anActor = Actor::New();
841   anActor.Add( custom );
842
843   Actor child = anActor.GetChildAt(0);
844   CustomActor customActor = CustomActor::DownCast( child );
845   DALI_TEST_CHECK( customActor );
846
847   customActor = NULL;
848   DALI_TEST_CHECK( !customActor );
849
850   customActor = DownCast< CustomActor >( child );
851   DALI_TEST_CHECK( customActor );
852   END_TEST;
853 }
854
855 // Negative test case for a method
856 int UtcDaliCustomActorDownCastNegative(void)
857 {
858   TestApplication application;
859   tet_infoline("Testing Dali::CustomActor::DownCast()");
860
861   Actor actor1 = Actor::New();
862   Actor anActor = Actor::New();
863   anActor.Add(actor1);
864
865   Actor child = anActor.GetChildAt(0);
866   CustomActor customActor = CustomActor::DownCast( child );
867   DALI_TEST_CHECK( !customActor );
868
869   Actor unInitialzedActor;
870   customActor = CustomActor::DownCast( unInitialzedActor );
871   DALI_TEST_CHECK( !customActor );
872
873   customActor = DownCast< CustomActor >( unInitialzedActor );
874   DALI_TEST_CHECK( !customActor );
875   END_TEST;
876 }
877
878 int UtcDaliCustomActorOnStageConnectionDisconnection(void)
879 {
880   TestApplication application;
881   tet_infoline("Testing Dali::CustomActor::OnStageConnection() & OnStageDisconnection");
882
883   TestCustomActor custom = TestCustomActor::New();
884   DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
885
886   // add the custom actor to stage
887   Stage::GetCurrent().Add( custom );
888
889   DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
890   DALI_TEST_EQUALS( "OnStageConnection", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
891
892   Stage::GetCurrent().Remove( custom );
893
894   DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
895   DALI_TEST_EQUALS( "OnStageDisconnection", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
896
897   // Excercise the message passing to Update thread
898
899   application.SendNotification();
900   application.Render();
901   application.Render();
902   END_TEST;
903 }
904
905 int UtcDaliCustomActorOnStageConnectionOrder(void)
906 {
907   TestApplication application;
908   tet_infoline("Testing Dali::CustomActor::OnStageConnection() order");
909
910   MasterCallStack.clear();
911
912   /* Build tree of actors:
913    *
914    *       A (parent)
915    *      / \
916    *     B   C
917    *    / \   \
918    *   D   E   F
919    *
920    * OnStageConnection should be received for A, B, D, E, C, and finally F
921    */
922
923   TestCustomActor actorA = TestCustomActor::New();
924   actorA.SetName( "ActorA" );
925
926   TestCustomActor actorB = TestCustomActor::New();
927   actorB.SetName( "ActorB" );
928   actorA.Add( actorB );
929
930   TestCustomActor actorC = TestCustomActor::New();
931   actorC.SetName( "ActorC" );
932   actorA.Add( actorC );
933
934   TestCustomActor actorD = TestCustomActor::New();
935   actorD.SetName( "ActorD" );
936   actorB.Add( actorD );
937
938   TestCustomActor actorE = TestCustomActor::New();
939   actorE.SetName( "ActorE" );
940   actorB.Add( actorE );
941
942   TestCustomActor actorF = TestCustomActor::New();
943   actorF.SetName( "ActorF" );
944   actorC.Add( actorF );
945
946   // add the custom actor to stage
947   Stage::GetCurrent().Add( actorA );
948
949   DALI_TEST_EQUALS( 3, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
950   DALI_TEST_EQUALS( "OnChildAdd",        actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
951   DALI_TEST_EQUALS( "OnChildAdd",        actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
952   DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION );
953
954   DALI_TEST_EQUALS( 3, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
955   DALI_TEST_EQUALS( "OnChildAdd",        actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
956   DALI_TEST_EQUALS( "OnChildAdd",        actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
957   DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 2 ], TEST_LOCATION );
958
959   DALI_TEST_EQUALS( 2, (int)(actorC.GetMethodsCalled().size()), TEST_LOCATION );
960   DALI_TEST_EQUALS( "OnChildAdd",        actorC.GetMethodsCalled()[ 0 ], TEST_LOCATION );
961   DALI_TEST_EQUALS( "OnStageConnection", actorC.GetMethodsCalled()[ 1 ], TEST_LOCATION );
962
963   DALI_TEST_EQUALS( 1, (int)(actorD.GetMethodsCalled().size()), TEST_LOCATION );
964   DALI_TEST_EQUALS( "OnStageConnection", actorD.GetMethodsCalled()[ 0 ], TEST_LOCATION );
965
966   DALI_TEST_EQUALS( 1, (int)(actorE.GetMethodsCalled().size()), TEST_LOCATION );
967   DALI_TEST_EQUALS( "OnStageConnection", actorE.GetMethodsCalled()[ 0 ], TEST_LOCATION );
968
969   DALI_TEST_EQUALS( 1, (int)(actorF.GetMethodsCalled().size()), TEST_LOCATION );
970   DALI_TEST_EQUALS( "OnStageConnection", actorF.GetMethodsCalled()[ 0 ], TEST_LOCATION );
971
972   // Check sequence is correct in MasterCallStack
973
974   DALI_TEST_EQUALS( 3+3+2+1+1+1, (int)(MasterCallStack.size()), TEST_LOCATION );
975
976   DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 0 ], TEST_LOCATION );
977   DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 1 ], TEST_LOCATION );
978   DALI_TEST_EQUALS( "ActorB: OnChildAdd", MasterCallStack[ 2 ], TEST_LOCATION );
979   DALI_TEST_EQUALS( "ActorB: OnChildAdd", MasterCallStack[ 3 ], TEST_LOCATION );
980   DALI_TEST_EQUALS( "ActorC: OnChildAdd", MasterCallStack[ 4 ], TEST_LOCATION );
981
982   DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 5 ], TEST_LOCATION );
983   DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 6 ], TEST_LOCATION );
984   DALI_TEST_EQUALS( "ActorD: OnStageConnection", MasterCallStack[ 7 ], TEST_LOCATION );
985   DALI_TEST_EQUALS( "ActorE: OnStageConnection", MasterCallStack[ 8 ], TEST_LOCATION );
986   DALI_TEST_EQUALS( "ActorC: OnStageConnection", MasterCallStack[ 9 ], TEST_LOCATION );
987   DALI_TEST_EQUALS( "ActorF: OnStageConnection", MasterCallStack[ 10 ], TEST_LOCATION );
988
989   // Excercise the message passing to Update thread
990
991   application.SendNotification();
992   application.Render();
993   application.Render();
994   END_TEST;
995 }
996
997 int UtcDaliCustomActorOnStageDisconnectionOrder(void)
998 {
999   TestApplication application;
1000   tet_infoline("Testing Dali::CustomActor::OnStageDisconnection() order");
1001
1002   Stage stage = Stage::GetCurrent();
1003
1004   /* Build tree of actors:
1005    *
1006    *       A (parent)
1007    *      / \
1008    *     B   C
1009    *    / \   \
1010    *   D   E   F
1011    *
1012    * OnStageDisconnection should be received for D, E, B, F, C, and finally A.
1013    */
1014
1015   TestCustomActor actorA = TestCustomActor::New();
1016   actorA.SetName( "ActorA" );
1017   stage.Add( actorA );
1018
1019   TestCustomActor actorB = TestCustomActor::New();
1020   actorB.SetName( "ActorB" );
1021   actorA.Add( actorB );
1022
1023   TestCustomActor actorC = TestCustomActor::New();
1024   actorC.SetName( "ActorC" );
1025   actorA.Add( actorC );
1026
1027   TestCustomActor actorD = TestCustomActor::New();
1028   actorD.SetName( "ActorD" );
1029   actorB.Add( actorD );
1030
1031   TestCustomActor actorE = TestCustomActor::New();
1032   actorE.SetName( "ActorE" );
1033   actorB.Add( actorE );
1034
1035   TestCustomActor actorF = TestCustomActor::New();
1036   actorF.SetName( "ActorF" );
1037   actorC.Add( actorF );
1038
1039   // Excercise the message passing to Update thread
1040
1041   application.SendNotification();
1042   application.Render();
1043   application.Render();
1044
1045   // Clear call stacks before disconnection
1046   actorA.ResetCallStack();
1047   actorB.ResetCallStack();
1048   actorC.ResetCallStack();
1049   actorD.ResetCallStack();
1050   actorE.ResetCallStack();
1051   actorF.ResetCallStack();
1052   MasterCallStack.clear();
1053
1054   stage.Remove( actorA );
1055
1056   DALI_TEST_EQUALS( 1, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1057   DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1058
1059   DALI_TEST_EQUALS( 1, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1060   DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1061
1062   DALI_TEST_EQUALS( 1, (int)(actorC.GetMethodsCalled().size()), TEST_LOCATION );
1063   DALI_TEST_EQUALS( "OnStageDisconnection", actorC.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1064
1065   DALI_TEST_EQUALS( 1, (int)(actorD.GetMethodsCalled().size()), TEST_LOCATION );
1066   DALI_TEST_EQUALS( "OnStageDisconnection", actorD.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1067
1068   DALI_TEST_EQUALS( 1, (int)(actorE.GetMethodsCalled().size()), TEST_LOCATION );
1069   DALI_TEST_EQUALS( "OnStageDisconnection", actorE.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1070
1071   DALI_TEST_EQUALS( 1, (int)(actorF.GetMethodsCalled().size()), TEST_LOCATION );
1072   DALI_TEST_EQUALS( "OnStageDisconnection", actorF.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1073
1074   // Check sequence is correct in MasterCallStack
1075
1076   DALI_TEST_EQUALS( 6, (int)(MasterCallStack.size()), TEST_LOCATION );
1077
1078   DALI_TEST_EQUALS( "ActorD: OnStageDisconnection", MasterCallStack[ 0 ], TEST_LOCATION );
1079   DALI_TEST_EQUALS( "ActorE: OnStageDisconnection", MasterCallStack[ 1 ], TEST_LOCATION );
1080   DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 2 ], TEST_LOCATION );
1081   DALI_TEST_EQUALS( "ActorF: OnStageDisconnection", MasterCallStack[ 3 ], TEST_LOCATION );
1082   DALI_TEST_EQUALS( "ActorC: OnStageDisconnection", MasterCallStack[ 4 ], TEST_LOCATION );
1083   DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 5 ], TEST_LOCATION );
1084
1085   // Excercise the message passing to Update thread
1086
1087   application.SendNotification();
1088   application.Render();
1089   application.Render();
1090   END_TEST;
1091 }
1092
1093 int UtcDaliCustomActorAddDuringOnStageConnection(void)
1094 {
1095   TestApplication application;
1096   tet_infoline("Testing Actor::Add behaviour during Dali::CustomActor::OnStageConnection() callback");
1097
1098   Stage stage = Stage::GetCurrent();
1099
1100   MasterCallStack.clear();
1101
1102   /* The actorA is a special variant which adds a child to itself during OnStageConnection()
1103    * The actorB is provided as the child
1104    */
1105
1106   TestCustomActor actorB = TestCustomActor::New();
1107   actorB.SetName( "ActorB" );
1108
1109   TestCustomActor actorA = TestCustomActor::NewVariant1( actorB );
1110   actorA.SetName( "ActorA" );
1111   stage.Add( actorA );
1112
1113   // Check callback sequence
1114
1115   DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1116   DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1117   DALI_TEST_EQUALS( "OnChildAdd",        actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION ); // Called from within OnStageConnection()
1118
1119   DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1120   DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1121
1122   DALI_TEST_EQUALS( 3, (int)(MasterCallStack.size()), TEST_LOCATION );
1123
1124   DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 0 ], TEST_LOCATION );
1125   DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION ); // Occurs during Actor::Add from within from within OnStageConnection()
1126   DALI_TEST_EQUALS( "ActorA: OnChildAdd",        MasterCallStack[ 2 ], TEST_LOCATION ); // Occurs after Actor::Add from within from within OnStageConnection()
1127
1128   // Excercise the message passing to Update thread
1129
1130   application.SendNotification();
1131   application.Render();
1132   application.Render();
1133
1134   // Check everything is ok after Actors are removed
1135
1136   stage.Remove( actorA );
1137   application.SendNotification();
1138   application.Render();
1139   application.Render();
1140   END_TEST;
1141 }
1142
1143 int UtcDaliCustomActorRemoveDuringOnStageConnection(void)
1144 {
1145   TestApplication application;
1146   tet_infoline("Testing Actor::Remove behaviour during Dali::CustomActor::OnStageConnection() callback");
1147
1148   Stage stage = Stage::GetCurrent();
1149
1150   MasterCallStack.clear();
1151
1152   /* The actorA is a special variant which removes its children during OnStageConnection()
1153    * Actors B & C are provided as the children
1154    */
1155
1156   TestCustomActor actorA = TestCustomActor::NewVariant2();
1157   actorA.SetName( "ActorA" );
1158
1159   TestCustomActor actorB = TestCustomActor::New();
1160   actorB.SetName( "ActorB" );
1161   actorA.Add( actorB );
1162
1163   TestCustomActor actorC = TestCustomActor::New();
1164   actorC.SetName( "ActorC" );
1165   actorA.Add( actorC );
1166
1167   stage.Add( actorA );
1168
1169   // Check callback sequence
1170
1171   DALI_TEST_EQUALS( 5, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1172   DALI_TEST_EQUALS( "OnChildAdd",        actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1173   DALI_TEST_EQUALS( "OnChildAdd",        actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1174   DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION );
1175   DALI_TEST_EQUALS( "OnChildRemove",     actorA.GetMethodsCalled()[ 3 ], TEST_LOCATION ); // Called from within OnStageConnection()
1176   DALI_TEST_EQUALS( "OnChildRemove",     actorA.GetMethodsCalled()[ 4 ], TEST_LOCATION ); // Called from within OnStageConnection()
1177
1178   DALI_TEST_EQUALS( 5, (int)(MasterCallStack.size()), TEST_LOCATION );
1179
1180   DALI_TEST_EQUALS( "ActorA: OnChildAdd",        MasterCallStack[ 0 ], TEST_LOCATION );
1181   DALI_TEST_EQUALS( "ActorA: OnChildAdd",        MasterCallStack[ 1 ], TEST_LOCATION );
1182   DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 2 ], TEST_LOCATION );
1183   DALI_TEST_EQUALS( "ActorA: OnChildRemove",     MasterCallStack[ 3 ], TEST_LOCATION );
1184   DALI_TEST_EQUALS( "ActorA: OnChildRemove",     MasterCallStack[ 4 ], TEST_LOCATION );
1185
1186   /* Actors B & C should be removed before the point where they could receive an OnStageConnection callback
1187    * Therefore they shouldn't receive either OnStageConnection or OnStageDisconnection
1188    */
1189   DALI_TEST_EQUALS( 0, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1190   DALI_TEST_EQUALS( 0, (int)(actorC.GetMethodsCalled().size()), TEST_LOCATION );
1191
1192   // Excercise the message passing to Update thread
1193
1194   application.SendNotification();
1195   application.Render();
1196   application.Render();
1197
1198   // Check everything is ok after last actor is removed
1199
1200   stage.Remove( actorA );
1201   application.SendNotification();
1202   application.Render();
1203   application.Render();
1204   END_TEST;
1205 }
1206
1207 int UtcDaliCustomActorAddDuringOnStageDisconnection(void)
1208 {
1209   TestApplication application;
1210   tet_infoline("Testing Actor::Add behaviour during Dali::CustomActor::OnStageDisonnection() callback");
1211
1212   Stage stage = Stage::GetCurrent();
1213
1214   /* The actorA is a special variant which adds a child to itself during OnStageDisconnection()
1215    * The actorB is provided as the child
1216    */
1217
1218   TestCustomActor actorB = TestCustomActor::New();
1219   actorB.SetName( "ActorB" );
1220
1221   TestCustomActor actorA = TestCustomActor::NewVariant3( actorB );
1222   actorA.SetName( "ActorA" );
1223   stage.Add( actorA );
1224
1225   // Excercise the message passing to Update thread
1226
1227   application.SendNotification();
1228   application.Render();
1229   application.Render();
1230
1231   // Clear call stacks before disconnection
1232   actorA.ResetCallStack();
1233   actorB.ResetCallStack();
1234   MasterCallStack.clear();
1235
1236   stage.Remove( actorA );
1237
1238   // Check callback sequence
1239
1240   DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1241   DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1242   DALI_TEST_EQUALS( "OnChildAdd",           actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1243
1244   // Child was added after parent disconnection, so should not receive OnStageConnection()
1245   DALI_TEST_EQUALS( 0, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1246
1247   DALI_TEST_EQUALS( 2, (int)(MasterCallStack.size()), TEST_LOCATION );
1248
1249   DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 0 ], TEST_LOCATION );
1250   DALI_TEST_EQUALS( "ActorA: OnChildAdd",           MasterCallStack[ 1 ], TEST_LOCATION );
1251
1252   // Excercise the message passing to Update thread
1253
1254   application.SendNotification();
1255   application.Render();
1256   application.Render();
1257   END_TEST;
1258 }
1259
1260 int UtcDaliCustomActorRemoveDuringOnStageDisconnection(void)
1261 {
1262   TestApplication application;
1263   tet_infoline("Testing Actor::Remove behaviour during Dali::CustomActor::OnStageDisconnection() callback");
1264
1265   Stage stage = Stage::GetCurrent();
1266
1267   /* The actorA is a special variant which removes its children during OnStageDisconnection()
1268    * The actorB is provided as the child
1269    */
1270
1271   TestCustomActor actorA = TestCustomActor::NewVariant4();
1272   actorA.SetName( "ActorA" );
1273   stage.Add( actorA );
1274
1275   TestCustomActor actorB = TestCustomActor::New();
1276   actorB.SetName( "ActorB" );
1277   actorA.Add( actorB );
1278
1279   // Excercise the message passing to Update thread
1280
1281   application.SendNotification();
1282   application.Render();
1283   application.Render();
1284
1285   // Clear call stacks before disconnection
1286   actorA.ResetCallStack();
1287   actorB.ResetCallStack();
1288   MasterCallStack.clear();
1289
1290   stage.Remove( actorA );
1291
1292   // Check callback sequence
1293
1294   DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1295   DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1296   DALI_TEST_EQUALS( "OnChildRemove",        actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1297
1298   DALI_TEST_EQUALS( 1, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1299   DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1300
1301   DALI_TEST_EQUALS( 3, (int)(MasterCallStack.size()), TEST_LOCATION );
1302
1303   DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 0 ], TEST_LOCATION );
1304   DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 1 ], TEST_LOCATION );
1305   DALI_TEST_EQUALS( "ActorA: OnChildRemove",        MasterCallStack[ 2 ], TEST_LOCATION );
1306
1307   // Excercise the message passing to Update thread
1308
1309   application.SendNotification();
1310   application.Render();
1311   application.Render();
1312   END_TEST;
1313 }
1314
1315 int UtcDaliCustomActorRemoveParentDuringOnStageConnection(void)
1316 {
1317   TestApplication application;
1318   tet_infoline("Weird test where child removes its own parent from Stage during Dali::CustomActor::OnStageConnection() callback");
1319
1320   Stage stage = Stage::GetCurrent();
1321
1322   MasterCallStack.clear();
1323
1324   /* The actorA is the parent of actorB
1325    * The actorB is a special variant which removes its own parent during OnStageConnection()
1326    * The child actor is interrupting the parent's connection to stage, therefore the parent should not get an OnStageDisconnection()
1327    */
1328
1329   TestCustomActor actorA = TestCustomActor::New();
1330   actorA.SetName( "ActorA" );
1331
1332   TestCustomActor actorB = TestCustomActor::NewVariant5();
1333   actorB.SetName( "ActorB" );
1334   actorA.Add( actorB );
1335
1336   stage.Add( actorA );
1337
1338   // Check callback sequence
1339
1340   DALI_TEST_EQUALS( 3, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1341   DALI_TEST_EQUALS( "OnChildAdd",           actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1342   DALI_TEST_EQUALS( "OnStageConnection",    actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1343   DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION );
1344
1345   DALI_TEST_EQUALS( 1, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1346   DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1347
1348   DALI_TEST_EQUALS( 4, (int)(MasterCallStack.size()), TEST_LOCATION );
1349
1350   DALI_TEST_EQUALS( "ActorA: OnChildAdd",           MasterCallStack[ 0 ], TEST_LOCATION );
1351   DALI_TEST_EQUALS( "ActorA: OnStageConnection",    MasterCallStack[ 1 ], TEST_LOCATION );
1352   DALI_TEST_EQUALS( "ActorB: OnStageConnection",    MasterCallStack[ 2 ], TEST_LOCATION );
1353   DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 3 ], TEST_LOCATION );
1354
1355   // Excercise the message passing to Update thread
1356
1357   application.SendNotification();
1358   application.Render();
1359   application.Render();
1360   END_TEST;
1361 }
1362
1363 int UtcDaliCustomActorAddParentDuringOnStageDisconnection(void)
1364 {
1365   TestApplication application;
1366   tet_infoline("Weird test where child adds its own parent to Stage during Dali::CustomActor::OnStageDisconnection() callback");
1367
1368   Stage stage = Stage::GetCurrent();
1369
1370   MasterCallStack.clear();
1371
1372   /* The actorA is the parent of actorB
1373    * The actorB is a special variant which (weirdly) adds its own parent during OnStageDisconnection()
1374    * The child actor is interrupting the disconnection, such that parent should not get a OnStageDisconnection()
1375    */
1376
1377   TestCustomActor actorA = TestCustomActor::New();
1378   actorA.SetName( "ActorA" );
1379   stage.Add( actorA );
1380
1381   TestCustomActor actorB = TestCustomActor::NewVariant6();
1382   actorB.SetName( "ActorB" );
1383   actorA.Add( actorB );
1384
1385   stage.Remove( actorA );
1386
1387   // Check callback sequence
1388
1389   DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1390   DALI_TEST_EQUALS( "OnStageConnection",    actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1391   DALI_TEST_EQUALS( "OnChildAdd",           actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1392
1393   DALI_TEST_EQUALS( 2, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1394   DALI_TEST_EQUALS( "OnStageConnection",    actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1395   DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1396   // Disconnect was interrupted, so we should only get one OnStageConnection() for actorB
1397
1398   DALI_TEST_EQUALS( 4, (int)(MasterCallStack.size()), TEST_LOCATION );
1399
1400   DALI_TEST_EQUALS( "ActorA: OnStageConnection",    MasterCallStack[ 0 ], TEST_LOCATION );
1401   DALI_TEST_EQUALS( "ActorB: OnStageConnection",    MasterCallStack[ 1 ], TEST_LOCATION );
1402   DALI_TEST_EQUALS( "ActorA: OnChildAdd",           MasterCallStack[ 2 ], TEST_LOCATION );
1403   DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 3 ], TEST_LOCATION );
1404
1405   // Excercise the message passing to Update thread
1406
1407   application.SendNotification();
1408   application.Render();
1409   application.Render();
1410   END_TEST;
1411 }
1412
1413 int UtcDaliCustomActorOnChildAddRemove(void)
1414 {
1415   TestApplication application;
1416   tet_infoline("Testing Dali::CustomActor::OnChildAdd() & OnChildRemove()");
1417
1418   TestCustomActor custom = TestCustomActor::New();
1419   DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1420
1421   Actor aChild = Actor::New();
1422   custom.Add( aChild );
1423
1424   DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1425   DALI_TEST_EQUALS( "OnChildAdd", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1426
1427   custom.Remove( aChild );
1428
1429   DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1430   DALI_TEST_EQUALS( "OnChildRemove", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1431   END_TEST;
1432 }
1433
1434 int UtcDaliCustomActorReparentDuringOnChildAdd(void)
1435 {
1436   TestApplication application;
1437   tet_infoline("Testing Actor:Add (reparenting) behaviour during Dali::CustomActor::OnChildAdd() callback");
1438
1439   Stage stage = Stage::GetCurrent();
1440
1441   MasterCallStack.clear();
1442
1443   /* The actorA is a special variant which reparents children added into a separate container child
1444    * The actorB is the child of actorA
1445    */
1446
1447   TestCustomActor actorA = TestCustomActor::NewVariant7( "ActorA" );
1448   stage.Add( actorA );
1449
1450   TestCustomActor actorB = TestCustomActor::New();
1451   actorB.SetName( "ActorB" );
1452   actorA.Add( actorB );
1453
1454   // Check hierarchy is as follows:
1455   //  A
1456   //  |
1457   //  Container
1458   //  |
1459   //  B
1460
1461   DALI_TEST_EQUALS( 1, (int)(actorA.GetChildCount()), TEST_LOCATION );
1462
1463   Actor container = actorA.GetChildAt(0);
1464   Actor containerChild;
1465
1466   DALI_TEST_CHECK( container );
1467   if ( container )
1468   {
1469     DALI_TEST_EQUALS( "Container", container.GetName(), TEST_LOCATION );
1470     DALI_TEST_EQUALS( 1, (int)(container.GetChildCount()), TEST_LOCATION );
1471     containerChild = container.GetChildAt(0);
1472   }
1473
1474   DALI_TEST_CHECK( containerChild );
1475   if ( containerChild )
1476   {
1477     DALI_TEST_EQUALS( "ActorB", containerChild.GetName(), TEST_LOCATION );
1478     DALI_TEST_EQUALS( 0, (int)(containerChild.GetChildCount()), TEST_LOCATION );
1479   }
1480
1481   // Check callback sequence
1482
1483   DALI_TEST_EQUALS( 4, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1484   DALI_TEST_EQUALS( "OnChildAdd",           actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION ); // The mContainer added to actorA
1485   DALI_TEST_EQUALS( "OnStageConnection",    actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1486   DALI_TEST_EQUALS( "OnChildAdd",           actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION ); // The actorB added to actorA
1487   DALI_TEST_EQUALS( "OnChildRemove",        actorA.GetMethodsCalled()[ 3 ], TEST_LOCATION );
1488   // mContainer will then receive OnChildAdd
1489
1490   DALI_TEST_EQUALS( 3, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1491   DALI_TEST_EQUALS( "OnStageConnection",    actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1492   DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1493   DALI_TEST_EQUALS( "OnStageConnection",    actorB.GetMethodsCalled()[ 2 ], TEST_LOCATION );
1494
1495   DALI_TEST_EQUALS( 7, (int)(MasterCallStack.size()), TEST_LOCATION );
1496
1497   DALI_TEST_EQUALS( "ActorA: OnChildAdd",           MasterCallStack[ 0 ], TEST_LOCATION );
1498   DALI_TEST_EQUALS( "ActorA: OnStageConnection",    MasterCallStack[ 1 ], TEST_LOCATION );
1499   DALI_TEST_EQUALS( "ActorB: OnStageConnection",    MasterCallStack[ 2 ], TEST_LOCATION );
1500   DALI_TEST_EQUALS( "ActorA: OnChildAdd",           MasterCallStack[ 3 ], TEST_LOCATION );
1501   DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 4 ], TEST_LOCATION );
1502   DALI_TEST_EQUALS( "ActorA: OnChildRemove",        MasterCallStack[ 5 ], TEST_LOCATION );
1503   DALI_TEST_EQUALS( "ActorB: OnStageConnection",    MasterCallStack[ 6 ], TEST_LOCATION );
1504
1505   // Excercise the message passing to Update thread
1506
1507   application.SendNotification();
1508   application.Render();
1509   application.Render();
1510   END_TEST;
1511 }
1512
1513 /**
1514  * Test that Remove can be called (a NOOP) during the OnChildRemove
1515  * triggered when reparenting an actor
1516  */
1517 int UtcDaliCustomActorRemoveDuringOnChildRemove(void)
1518 {
1519   TestApplication application;
1520   tet_infoline("Testing Actor:Remove behaviour during OnChildRemove() callback triggered when reparenting");
1521
1522   Stage stage = Stage::GetCurrent();
1523
1524   MasterCallStack.clear();
1525
1526   /* The childActor will be reparented from actorA to actorB
1527    * The actorA is a special variant which attempts to remove a child from actorB, during the OnChildRemove callback()
1528    * This should be a NOOP since the reparenting has not occured yet
1529    */
1530
1531   TestCustomActor actorB = TestCustomActor::New();
1532   actorB.SetName( "ActorB" );
1533   stage.Add( actorB );
1534
1535   TestCustomActor actorA = TestCustomActor::NewVariant8( actorB );
1536   actorA.SetName( "ActorA" );
1537   stage.Add( actorA );
1538
1539   Actor childActor = Actor::New();
1540   childActor.SetName( "Child" );
1541   // Reparent from actorA to actorB
1542   actorA.Add( childActor );
1543   actorB.Add( childActor );
1544
1545   // Check hierarchy is as follows:
1546   //  A    B
1547   //       |
1548   //       Child
1549
1550   DALI_TEST_EQUALS( 0, (int)(actorA.GetChildCount()), TEST_LOCATION );
1551   DALI_TEST_EQUALS( 1, (int)(actorB.GetChildCount()), TEST_LOCATION );
1552   DALI_TEST_EQUALS( 0, (int)(childActor.GetChildCount()), TEST_LOCATION );
1553
1554   Actor child = actorB.GetChildAt(0);
1555
1556   DALI_TEST_CHECK( child );
1557   if ( child )
1558   {
1559     DALI_TEST_EQUALS( "Child", child.GetName(), TEST_LOCATION );
1560   }
1561
1562   // Check callback sequence
1563
1564   DALI_TEST_EQUALS( 3, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1565   DALI_TEST_EQUALS( "OnStageConnection",    actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION ); // The mContainer added to actorA
1566   DALI_TEST_EQUALS( "OnChildAdd",           actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1567   DALI_TEST_EQUALS( "OnChildRemove",        actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION ); // The actorB added to actorA
1568   // mContainer will then receive OnChildAdd
1569
1570   DALI_TEST_EQUALS( 3, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1571   DALI_TEST_EQUALS( "OnStageConnection",    actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1572   // The derived class are always notified, no matter the child is successfully removed or not
1573   DALI_TEST_EQUALS( "OnChildRemove",        actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1574   DALI_TEST_EQUALS( "OnChildAdd",           actorB.GetMethodsCalled()[ 2 ], TEST_LOCATION );
1575
1576   DALI_TEST_EQUALS( 6, (int)(MasterCallStack.size()), TEST_LOCATION );
1577
1578   DALI_TEST_EQUALS( "ActorB: OnStageConnection",    MasterCallStack[ 0 ], TEST_LOCATION );
1579   DALI_TEST_EQUALS( "ActorA: OnStageConnection",    MasterCallStack[ 1 ], TEST_LOCATION );
1580   DALI_TEST_EQUALS( "ActorA: OnChildAdd",           MasterCallStack[ 2 ], TEST_LOCATION );
1581   DALI_TEST_EQUALS( "ActorA: OnChildRemove",        MasterCallStack[ 3 ], TEST_LOCATION );
1582   // The derived class are always notified, no matter the child is successfully removed or not
1583   DALI_TEST_EQUALS( "ActorB: OnChildRemove",        MasterCallStack[ 4 ], TEST_LOCATION );
1584   DALI_TEST_EQUALS( "ActorB: OnChildAdd",           MasterCallStack[ 5 ], TEST_LOCATION );
1585
1586   // Excercise the message passing to Update thread
1587
1588   application.SendNotification();
1589   application.Render();
1590   application.Render();
1591   END_TEST;
1592 }
1593
1594 int UtcDaliCustomActorOnPropertySet(void)
1595 {
1596   TestApplication application;
1597   tet_infoline("Testing Dali::CustomActor::OnPropertySet()");
1598
1599   TestCustomActor custom = TestCustomActor::New();
1600   DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1601
1602   custom.SetDaliProperty("yes");
1603
1604   DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1605   DALI_TEST_EQUALS( "OnPropertySet", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1606   END_TEST;
1607 }
1608
1609 int UtcDaliCustomActorOnSizeSet(void)
1610 {
1611   TestApplication application;
1612   tet_infoline("Testing Dali::CustomActor::OnSizeSet()");
1613
1614   TestCustomActor custom = TestCustomActor::New();
1615   DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1616
1617   custom.SetSize( Vector2( 9.0f, 10.0f ) );
1618   DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1619   DALI_TEST_EQUALS( "OnSizeSet", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1620   DALI_TEST_EQUALS( 9.0f, custom.GetSize().width, TEST_LOCATION );
1621   DALI_TEST_EQUALS( 10.0f, custom.GetSize().height, TEST_LOCATION );
1622
1623   custom.SetSize( Vector3( 4.0f, 5.0f, 6.0f ) );
1624   DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1625   DALI_TEST_EQUALS( "OnSizeSet", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1626   DALI_TEST_EQUALS( 4.0f, custom.GetSize().width, TEST_LOCATION );
1627   DALI_TEST_EQUALS( 5.0f, custom.GetSize().height, TEST_LOCATION );
1628   DALI_TEST_EQUALS( 6.0f, custom.GetSize().depth, TEST_LOCATION );
1629   END_TEST;
1630 }
1631
1632 int UtcDaliCustomActorOnSizeAnimation(void)
1633 {
1634   TestApplication application;
1635   tet_infoline("Testing Dali::CustomActor::OnSizeAnimation()");
1636
1637   TestCustomActor custom = TestCustomActor::New();
1638   DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1639
1640   Animation anim = Animation::New( 1.0f );
1641   anim.AnimateTo( Property( custom, Actor::Property::SIZE ), Vector3( 8.0f, 9.0f, 10.0f ) );
1642   DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1643   DALI_TEST_EQUALS( "OnSizeAnimation", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1644   DALI_TEST_EQUALS( 8.0f, custom.GetTargetSize().width, TEST_LOCATION );
1645   DALI_TEST_EQUALS( 9.0f, custom.GetTargetSize().height, TEST_LOCATION );
1646   DALI_TEST_EQUALS( 10.0f, custom.GetTargetSize().depth, TEST_LOCATION );
1647   END_TEST;
1648 }
1649
1650 int UtcDaliCustomActorOnTouchEvent(void)
1651 {
1652   TestApplication application;
1653   tet_infoline("Testing Dali::CustomActor::OnTouchEvent()");
1654
1655   TestCustomActor custom = TestCustomActor::New();
1656   DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1657
1658   // set size for custom actor
1659   custom.SetSize( 100, 100 );
1660   // add the custom actor to stage
1661   Stage::GetCurrent().Add( custom );
1662   custom.ResetCallStack();
1663
1664   // Render and notify a couple of times
1665   application.SendNotification();
1666   application.Render();
1667   application.SendNotification();
1668   application.Render();
1669
1670   // simulate a touch event
1671   Dali::TouchPoint point( 0, TouchPoint::Down, 1, 1 );
1672   Dali::Integration::TouchEvent event;
1673   event.AddPoint( point );
1674   application.ProcessEvent( event );
1675
1676   DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1677   DALI_TEST_EQUALS( "OnTouchEvent", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1678   END_TEST;
1679 }
1680
1681 int UtcDaliCustomActorOnHoverEvent(void)
1682 {
1683   TestApplication application;
1684   tet_infoline("Testing Dali::CustomActor::OnHoverEvent()");
1685
1686   TestCustomActor custom = TestCustomActor::New();
1687   DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1688
1689   // set size for custom actor
1690   custom.SetSize( 100, 100 );
1691   // add the custom actor to stage
1692   Stage::GetCurrent().Add( custom );
1693   custom.ResetCallStack();
1694
1695   // Render and notify a couple of times
1696   application.SendNotification();
1697   application.Render();
1698   application.SendNotification();
1699   application.Render();
1700
1701   // simulate a hover event
1702   Dali::TouchPoint point( 0, TouchPoint::Motion, 1, 1 );
1703   Dali::Integration::HoverEvent event;
1704   event.AddPoint( point );
1705   application.ProcessEvent( event );
1706
1707   DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1708   DALI_TEST_EQUALS( "OnHoverEvent", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1709   END_TEST;
1710 }
1711
1712 int UtcDaliCustomActorOnWheelEvent(void)
1713 {
1714   TestApplication application;
1715   tet_infoline("Testing Dali::CustomActor::OnWheelEvent()");
1716
1717   TestCustomActor custom = TestCustomActor::New();
1718   DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1719
1720   // set size for custom actor
1721   custom.SetSize( 100, 100 );
1722   // add the custom actor to stage
1723   Stage::GetCurrent().Add( custom );
1724   custom.ResetCallStack();
1725
1726   // Render and notify a couple of times
1727   application.SendNotification();
1728   application.Render();
1729   application.SendNotification();
1730   application.Render();
1731
1732   // simulate a wheel event
1733   Vector2 screenCoordinates( 10.0f, 10.0f );
1734   Integration::WheelEvent event( Integration::WheelEvent::MOUSE_WHEEL, 0, 0u, screenCoordinates, 1, 1000u );
1735   application.ProcessEvent( event );
1736
1737   DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1738   DALI_TEST_EQUALS( "OnWheelEvent", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1739   END_TEST;
1740 }
1741
1742 int UtcDaliCustomActorImplOnPropertySet(void)
1743 {
1744   TestApplication application;
1745   CustomActorImpl* impl = new Impl::SimpleTestCustomActor();
1746
1747   impl->OnPropertySet( 0, 0 );
1748
1749   DALI_TEST_CHECK( true );
1750
1751   delete impl;
1752   END_TEST;
1753 }
1754
1755 int UtcDaliCustomActorGetImplementation(void)
1756 {
1757   TestApplication application;
1758
1759   TestCustomActor custom = TestCustomActor::New();
1760   CustomActorImpl& impl = custom.GetImplementation();
1761   impl.GetOwner();  // Test
1762
1763   const TestCustomActor constCustom = TestCustomActor::New();
1764   const CustomActorImpl& constImpl = constCustom.GetImplementation();
1765   constImpl.GetOwner();  // Test
1766
1767   DALI_TEST_CHECK( true );
1768   END_TEST;
1769 }
1770
1771 int UtcDaliCustomActorDoAction(void)
1772 {
1773   TestApplication application;
1774   tet_infoline("Testing Dali::CustomActor::DoAction()");
1775
1776   TestCustomActor custom = TestCustomActor::New();
1777
1778   BaseHandle customActorObject = custom;
1779
1780   DALI_TEST_CHECK(customActorObject);
1781
1782   Property::Map attributes;
1783
1784   // Check that an invalid command is not performed
1785   DALI_TEST_CHECK(customActorObject.DoAction("invalidCommand", attributes) == false);
1786
1787   // Check that the custom actor is visible
1788   custom.SetVisible(true);
1789   DALI_TEST_CHECK(custom.IsVisible() == true);
1790
1791   // Check the custom actor performed an action to hide itself
1792   DALI_TEST_CHECK(customActorObject.DoAction("hide", attributes) == true);
1793
1794   // flush the queue and render once
1795   application.SendNotification();
1796   application.Render();
1797
1798   // Check that the custom actor is now invisible
1799   DALI_TEST_CHECK(custom.IsVisible() == false);
1800
1801   // Check the custom actor performed an action to show itself
1802   DALI_TEST_CHECK(customActorObject.DoAction("show", attributes) == true);
1803
1804   // flush the queue and render once
1805   application.SendNotification();
1806   application.Render();
1807
1808   // Check that the custom actor is now visible
1809   DALI_TEST_CHECK(custom.IsVisible() == true);
1810   END_TEST;
1811 }
1812
1813 int UtcDaliCustomActorCustomActor(void)
1814 {
1815   Dali::CustomActor customA;
1816   Dali::CustomActor customB( customA );
1817
1818   DALI_TEST_CHECK( customA == customB );
1819
1820   END_TEST;
1821 }
1822
1823 int UtcDaliCustomActorImplRelayoutRequest(void)
1824 {
1825   TestApplication application;
1826
1827   DALI_TEST_CHECK( gOnRelayout == false );
1828
1829   TestCustomActor custom = TestCustomActor::NewNegoSize();
1830   Stage::GetCurrent().Add(custom);
1831
1832   application.SendNotification();
1833   application.Render();
1834
1835   DALI_TEST_CHECK( gOnRelayout == true );
1836   gOnRelayout = false;
1837
1838   custom.TestRelayoutRequest();
1839   application.SendNotification();
1840   application.Render();
1841
1842   DALI_TEST_CHECK( gOnRelayout == true );
1843
1844   END_TEST;
1845 }
1846
1847 int UtcDaliCustomActorImplGetHeightForWidthBase(void)
1848 {
1849   TestApplication application;
1850   TestCustomActor custom = TestCustomActor::NewNegoSize();
1851
1852   float width = 300.0f;
1853   float v = 0.0f;
1854
1855   application.SendNotification();
1856   application.Render();
1857
1858   v = custom.TestGetHeightForWidthBase( width );
1859
1860   DALI_TEST_CHECK( v == width );
1861
1862   END_TEST;
1863 }
1864
1865 int UtcDaliCustomActorImplGetWidthForHeightBase(void)
1866 {
1867   TestApplication application;
1868   TestCustomActor custom = TestCustomActor::NewNegoSize();
1869
1870   float height = 300.0f;
1871   float v = 0.0f;
1872
1873   application.SendNotification();
1874   application.Render();
1875
1876   v = custom.TestGetWidthForHeightBase( height );
1877
1878   DALI_TEST_CHECK( v == height );
1879
1880   END_TEST;
1881 }
1882
1883 int UtcDaliCustomActorImplCalculateChildSizeBase(void)
1884 {
1885   TestApplication application;
1886   TestCustomActor custom = TestCustomActor::NewNegoSize();
1887
1888   Actor child = Actor::New();
1889   child.SetResizePolicy(Dali::ResizePolicy::FIXED, Dali::Dimension::ALL_DIMENSIONS);
1890   child.SetSize(150, 150);
1891
1892   application.SendNotification();
1893   application.Render();
1894
1895   float v = 9.99f;
1896   v = custom.TestCalculateChildSizeBase( child, Dali::Dimension::ALL_DIMENSIONS );
1897   DALI_TEST_CHECK( v == 0.0f );
1898
1899   END_TEST;
1900 }
1901
1902 int UtcDaliCustomActorImplRelayoutDependentOnChildrenBase(void)
1903 {
1904   TestApplication application;
1905   TestCustomActor custom = TestCustomActor::NewNegoSize();
1906   custom.SetResizePolicy(Dali::ResizePolicy::FIT_TO_CHILDREN, Dali::Dimension::ALL_DIMENSIONS);
1907
1908   bool v = false;
1909
1910   v = custom.TestRelayoutDependentOnChildrenBase( Dali::Dimension::ALL_DIMENSIONS );
1911   application.SendNotification();
1912   application.Render();
1913
1914   DALI_TEST_CHECK( v == true );
1915
1916   custom.SetResizePolicy(Dali::ResizePolicy::FIXED, Dali::Dimension::ALL_DIMENSIONS);
1917   v = custom.TestRelayoutDependentOnChildrenBase( Dali::Dimension::WIDTH );
1918   application.SendNotification();
1919   application.Render();
1920   DALI_TEST_CHECK( v == false );
1921
1922   END_TEST;
1923 }
1924
1925 int UtcDaliCustomActorTypeRegistry(void)
1926 {
1927   TestApplication application;
1928
1929   // Register Type
1930   TypeInfo type;
1931   type = TypeRegistry::Get().GetTypeInfo( "CustomActor" );
1932   DALI_TEST_CHECK( type );
1933   BaseHandle handle = type.CreateInstance();
1934
1935   std::string name;
1936   std::string exception;
1937
1938   try
1939   {
1940     name = handle.GetTypeName();
1941     tet_result(TET_FAIL);
1942   }
1943   catch( DaliException& e )
1944   {
1945     exception = e.condition;
1946     DALI_TEST_EQUALS( exception, "handle && \"BaseObject handle is empty\"", TEST_LOCATION );
1947   }
1948
1949   END_TEST;
1950 }
1951
1952
1953 int UtcDaliCustomActorGetExtensionP(void)
1954 {
1955   TestApplication application;
1956
1957   TestCustomActor custom = TestCustomActor::NewVariant5();
1958
1959   DALI_TEST_CHECK( NULL == custom.GetImplementation().GetExtension() );
1960
1961   END_TEST;
1962 }
1963
1964 int UtcDaliCustomActorOnConnectionDepth(void)
1965 {
1966   TestApplication application;
1967   tet_infoline("Testing Dali::CustomActor::OnStageConnection() hierarchy depth");
1968
1969   Stage stage = Stage::GetCurrent();
1970
1971   /* Build tree of actors:
1972    *
1973    *                      Depth
1974    *
1975    *       A (parent)       1
1976    *      / \
1977    *     B   C              2
1978    *    / \   \
1979    *   D   E   F            3
1980    *
1981    * OnStageConnection should return 1 for A, 2 for B and C, and 3 for D, E and F.
1982    */
1983
1984   TestCustomActor actorA = TestCustomActor::New();
1985   stage.Add( actorA );
1986
1987   TestCustomActor actorB = TestCustomActor::New();
1988   actorA.Add( actorB );
1989
1990   TestCustomActor actorC = TestCustomActor::New();
1991   actorA.Add( actorC );
1992
1993   TestCustomActor actorD = TestCustomActor::New();
1994   actorB.Add( actorD );
1995
1996   TestCustomActor actorE = TestCustomActor::New();
1997   actorB.Add( actorE );
1998
1999   TestCustomActor actorF = TestCustomActor::New();
2000   actorC.Add( actorF );
2001
2002   // Excercise the message passing to Update thread
2003   application.SendNotification();
2004   application.Render();
2005   application.Render();
2006
2007   DALI_TEST_EQUALS( 1u, actorA.GetDepth(), TEST_LOCATION );
2008   DALI_TEST_EQUALS( 2u, actorB.GetDepth(), TEST_LOCATION );
2009   DALI_TEST_EQUALS( 2u, actorC.GetDepth(), TEST_LOCATION );
2010   DALI_TEST_EQUALS( 3u, actorD.GetDepth(), TEST_LOCATION );
2011   DALI_TEST_EQUALS( 3u, actorE.GetDepth(), TEST_LOCATION );
2012   DALI_TEST_EQUALS( 3u, actorF.GetDepth(), TEST_LOCATION );
2013
2014   END_TEST;
2015 }