2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 #include <dali/public-api/dali-core.h>
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>
27 #include "dali-test-suite-utils/dali-test-suite-utils.h"
32 void custom_actor_test_startup(void)
34 test_return_value = TET_UNDEF;
37 void custom_actor_test_cleanup(void)
39 test_return_value = TET_PASS;
45 std::vector< std::string > MasterCallStack;
46 bool gOnRelayout = false;
50 // TypeRegistry needs custom actor Implementations to have the same name (namespaces are ignored so we use one here)
54 struct TestCustomActor : public CustomActorImpl
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 ),
68 TestCustomActor(bool nego)
69 : CustomActorImpl( ActorFlags( REQUIRES_TOUCH_EVENTS | REQUIRES_WHEEL_EVENTS | REQUIRES_HOVER_EVENTS ) ),
70 mDaliProperty( Property::INVALID_INDEX ),
71 mSizeSet( Vector3::ZERO ),
72 mTargetSize( Vector3::ZERO ),
79 virtual ~TestCustomActor()
83 void Initialize( const char* name = NULL )
85 mDaliProperty = Self().RegisterProperty( "Dali", std::string("no"), Property::READ_WRITE);
90 virtual void OnInitialize( const char* name ) {}
93 * Resets the call stack
98 mTargetSize = Vector3();
99 mMethodsCalled.clear();
102 void AddToCallStacks( const char* method )
104 mMethodsCalled.push_back( method );
106 // Combine Actor name with method string
107 std::string nameAndMethod( Self().GetName() );
108 if ( 0 == nameAndMethod.size() )
110 nameAndMethod = "Unknown: ";
114 nameAndMethod += ": ";
116 nameAndMethod += method;
118 MasterCallStack.push_back( nameAndMethod );
121 // From CustomActorImpl
122 virtual void OnStageConnection()
124 AddToCallStacks("OnStageConnection");
126 virtual void OnStageDisconnection()
128 AddToCallStacks("OnStageDisconnection");
130 virtual void OnChildAdd(Actor& child)
132 AddToCallStacks("OnChildAdd");
134 virtual void OnChildRemove(Actor& child)
136 AddToCallStacks("OnChildRemove");
138 virtual void OnPropertySet( Property::Index index, Property::Value propertyValue )
140 AddToCallStacks("OnPropertySet");
142 virtual void OnSizeSet(const Vector3& targetSize)
144 mSizeSet = targetSize;
145 AddToCallStacks("OnSizeSet");
147 virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize)
149 mTargetSize = targetSize;
150 AddToCallStacks("OnSizeAnimation");
152 virtual bool OnTouchEvent(const TouchEvent& event)
154 AddToCallStacks("OnTouchEvent");
157 virtual bool OnHoverEvent(const HoverEvent& event)
159 AddToCallStacks("OnHoverEvent");
162 virtual bool OnWheelEvent(const WheelEvent& event)
164 AddToCallStacks("OnWheelEvent");
167 virtual bool OnKeyEvent(const KeyEvent& event)
169 AddToCallStacks("OnKeyEvent");
172 virtual void OnKeyInputFocusGained()
174 AddToCallStacks("OnKeyInputFocusGained");
176 virtual void OnKeyInputFocusLost()
178 AddToCallStacks("OnKeyInputFocusLost");
180 virtual Vector3 GetNaturalSize()
182 return Vector3( 0.0f, 0.0f, 0.0f );
185 virtual float GetHeightForWidth( float width )
190 virtual float GetWidthForHeight( float height )
195 virtual void OnRelayout( const Vector2& size, RelayoutContainer& container )
200 virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
204 virtual void OnCalculateRelayoutSize( Dimension::Type dimension )
208 virtual float CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension )
213 virtual void OnLayoutNegotiated( float size, Dimension::Type dimension )
217 virtual bool RelayoutDependentOnChildren( Dimension::Type dimension = Dimension::ALL_DIMENSIONS )
222 void SetDaliProperty(std::string s)
224 Self().SetProperty(mDaliProperty, s) ;
226 void TestRelayoutRequest()
231 float TestGetHeightForWidthBase( float width )
233 return GetHeightForWidthBase( width );
236 float TestGetWidthForHeightBase( float height )
238 return GetWidthForHeightBase( height );
241 float TestCalculateChildSizeBase( const Dali::Actor& child, Dimension::Type dimension )
243 return CalculateChildSizeBase( child, dimension );
246 bool TestRelayoutDependentOnChildrenBase( Dimension::Type dimension )
248 return RelayoutDependentOnChildrenBase( dimension );
251 Property::Index mDaliProperty;
252 std::vector< std::string > mMethodsCalled;
259 * Variant which adds a new child during OnStageConnection
261 struct TestCustomActorVariant1 : public TestCustomActor
266 TestCustomActorVariant1( Actor childToAdd )
267 : mChildToAdd( childToAdd )
271 // From CustomActorImpl
272 virtual void OnStageConnection()
275 TestCustomActor::OnStageConnection();
278 Self().Add( mChildToAdd );
285 * Variant which removes children during OnStageConnection
287 struct TestCustomActorVariant2 : public TestCustomActor
292 TestCustomActorVariant2()
296 // From CustomActorImpl
297 virtual void OnStageConnection()
300 TestCustomActor::OnStageConnection();
302 // Remove all the children
303 for( unsigned int i=0, num=Self().GetChildCount(); i<num; ++i )
305 Self().Remove( Self().GetChildAt(0) );
311 * Variant which adds a new child during OnStageDisconnection
313 struct TestCustomActorVariant3 : public TestCustomActor
318 TestCustomActorVariant3( Actor childToAdd )
319 : mChildToAdd( childToAdd )
323 // From CustomActorImpl
324 virtual void OnStageDisconnection()
327 TestCustomActor::OnStageDisconnection();
330 Self().Add( mChildToAdd );
337 * Variant which removes children during OnStageDisconnection
339 struct TestCustomActorVariant4 : public TestCustomActor
344 TestCustomActorVariant4()
348 // From CustomActorImpl
349 virtual void OnStageDisconnection()
352 TestCustomActor::OnStageDisconnection();
354 // Remove all the children
355 for( unsigned int i=0, num=Self().GetChildCount(); i<num; ++i )
357 Self().Remove( Self().GetChildAt(0) );
363 * Variant which removes its parent from Stage during OnStageConnection
365 struct TestCustomActorVariant5 : public TestCustomActor
370 TestCustomActorVariant5()
374 // From CustomActorImpl
375 virtual void OnStageConnection()
378 TestCustomActor::OnStageConnection();
380 // Take parent off-stage
381 Actor parent = Self().GetParent();
384 Stage::GetCurrent().Remove( parent );
390 * Variant which adds its parent to Stage during OnStageDisconnection
392 struct TestCustomActorVariant6 : public TestCustomActor
397 TestCustomActorVariant6()
401 // From CustomActorImpl
402 virtual void OnStageDisconnection()
405 TestCustomActor::OnStageDisconnection();
407 // Put parent on-stage
408 Actor parent = Self().GetParent();
411 Stage::GetCurrent().Add( parent );
417 * Variant which reparents its children into a separate container
419 struct TestCustomActorVariant7 : public TestCustomActor
424 TestCustomActorVariant7()
428 virtual void OnInitialize( const char* name )
430 // We need to do this early, before the OnChildAdd is recorded
431 Self().SetName( name );
433 mContainer = Actor::New();
434 mContainer.SetName( "Container" );
435 Self().Add( mContainer );
438 // From CustomActorImpl
439 virtual void OnChildAdd(Actor& child)
442 TestCustomActor::OnChildAdd(child);
445 if ( child != mContainer )
447 mContainer.Add( child );
455 * Variant which attempts to interfere with the reparenting of a child to another container
457 struct TestCustomActorVariant8 : public TestCustomActor
462 TestCustomActorVariant8( Actor rival )
463 : mRivalContainer( rival )
467 // From CustomActorImpl
468 virtual void OnChildRemove(Actor& child)
471 TestCustomActor::OnChildRemove(child);
473 mRivalContainer.Remove( child ); // attempt to block reparenting to rival (should be a NOOP)
476 Actor mRivalContainer;
479 // Need a class that doesn't override virtual methods
480 class SimpleTestCustomActor : public CustomActorImpl
487 SimpleTestCustomActor()
488 : CustomActorImpl( ActorFlags( REQUIRES_TOUCH_EVENTS | DISABLE_SIZE_NEGOTIATION ) )
495 virtual ~SimpleTestCustomActor()
499 // From CustomActorImpl
500 virtual void OnStageConnection()
503 virtual void OnStageDisconnection()
506 virtual void OnChildAdd(Actor& child)
509 virtual void OnChildRemove(Actor& child)
512 virtual void OnSizeSet(const Vector3& targetSize)
515 virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize)
518 virtual bool OnTouchEvent(const TouchEvent& event)
522 virtual bool OnHoverEvent(const HoverEvent& event)
526 virtual bool OnWheelEvent(const WheelEvent& event)
530 virtual bool OnKeyEvent(const KeyEvent& event)
534 virtual void OnKeyInputFocusGained()
537 virtual void OnKeyInputFocusLost()
541 virtual Vector3 GetNaturalSize()
543 return Vector3( 0.0f, 0.0f, 0.0f );
546 virtual float GetHeightForWidth( float width )
551 virtual float GetWidthForHeight( float height )
556 virtual void OnRelayout( const Vector2& size, RelayoutContainer& container )
560 virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
564 virtual void OnCalculateRelayoutSize( Dimension::Type dimension )
568 virtual float CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension )
573 virtual void OnLayoutNegotiated( float size, Dimension::Type dimension )
577 virtual bool RelayoutDependentOnChildren( Dimension::Type dimension = Dimension::ALL_DIMENSIONS )
583 } ; // namespace Impl
590 * Test custom actor handle
592 class TestCustomActor : public CustomActor
596 static TestCustomActor New()
598 Impl::TestCustomActor* impl = new Impl::TestCustomActor;
599 TestCustomActor custom( *impl ); // takes ownership
606 static TestCustomActor NewNegoSize()
608 Impl::TestCustomActor* impl = new Impl::TestCustomActor( true );
609 TestCustomActor custom( *impl ); // takes ownership
616 static TestCustomActor NewVariant1( Actor childToAdd )
618 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant1( childToAdd );
619 TestCustomActor custom( *impl ); // takes ownership
626 static TestCustomActor NewVariant2()
628 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant2();
629 TestCustomActor custom( *impl ); // takes ownership
636 static TestCustomActor NewVariant3( Actor childToAdd )
638 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant3( childToAdd );
639 TestCustomActor custom( *impl ); // takes ownership
646 static TestCustomActor NewVariant4()
648 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant4();
649 TestCustomActor custom( *impl ); // takes ownership
656 static TestCustomActor NewVariant5()
658 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant5();
659 TestCustomActor custom( *impl ); // takes ownership
666 static TestCustomActor NewVariant6()
668 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant6();
669 TestCustomActor custom( *impl ); // takes ownership
676 static TestCustomActor NewVariant7( const char* name )
678 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant7();
679 TestCustomActor custom( *impl ); // takes ownership
681 impl->Initialize( name );
686 static TestCustomActor NewVariant8( Actor rival )
688 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant8( rival );
689 TestCustomActor custom( *impl ); // takes ownership
696 virtual ~TestCustomActor()
700 Impl::TestCustomActor& GetImpl()
702 return static_cast<Impl::TestCustomActor&>(GetImplementation());
705 std::vector< std::string >& GetMethodsCalled()
707 return GetImpl().mMethodsCalled;
710 void ResetCallStack()
712 GetImpl().ResetCallStack();
715 void SetDaliProperty(std::string s)
717 GetImpl().SetDaliProperty(s);
722 return GetImpl().mSizeSet;
725 Vector3 GetTargetSize()
727 return GetImpl().mTargetSize;
730 virtual Vector3 GetNaturalSize()
732 return Vector3( 0.0f, 0.0f, 0.0f );
735 virtual float GetHeightForWidth( float width )
740 virtual float GetWidthForHeight( float height )
745 virtual void OnRelayout( const Vector2& size, RelayoutContainer& container )
749 virtual void OnLayoutNegotiated( float size, Dimension::Type dimension )
753 virtual void OnCalculateRelayoutSize( Dimension::Type dimension )
757 void TestRelayoutRequest()
759 GetImpl().TestRelayoutRequest();
762 float TestGetHeightForWidthBase( float width )
764 return GetImpl().TestGetHeightForWidthBase( width );
767 float TestGetWidthForHeightBase( float height )
769 return GetImpl().TestGetWidthForHeightBase( height );
772 float TestCalculateChildSizeBase( const Dali::Actor& child, Dimension::Type dimension )
774 return GetImpl().TestCalculateChildSizeBase( child, dimension );
777 bool TestRelayoutDependentOnChildrenBase( Dimension::Type dimension )
779 return GetImpl().TestRelayoutDependentOnChildrenBase( dimension );
784 TestCustomActor( Impl::TestCustomActor& impl ) : CustomActor( impl )
791 using namespace Dali;
793 BaseHandle CreateActor()
795 return TestCustomActor::New();
798 Dali::TypeRegistration mType( typeid(TestCustomActor), typeid(Dali::CustomActor), CreateActor );
803 int UtcDaliCustomActorDestructor(void)
805 TestApplication application;
807 CustomActor* actor = new CustomActor();
810 DALI_TEST_CHECK( true );
814 int UtcDaliCustomActorImplDestructor(void)
816 TestApplication application;
817 CustomActorImpl* actor = new Impl::TestCustomActor();
820 DALI_TEST_CHECK( true );
824 // Positive test case for a method
825 int UtcDaliCustomActorDownCast(void)
827 TestApplication application;
828 tet_infoline("Testing Dali::CustomActor::DownCast()");
830 TestCustomActor custom = TestCustomActor::New();
832 Actor anActor = Actor::New();
833 anActor.Add( custom );
835 Actor child = anActor.GetChildAt(0);
836 CustomActor customActor = CustomActor::DownCast( child );
837 DALI_TEST_CHECK( customActor );
840 DALI_TEST_CHECK( !customActor );
842 customActor = DownCast< CustomActor >( child );
843 DALI_TEST_CHECK( customActor );
847 // Negative test case for a method
848 int UtcDaliCustomActorDownCastNegative(void)
850 TestApplication application;
851 tet_infoline("Testing Dali::CustomActor::DownCast()");
853 Actor actor1 = Actor::New();
854 Actor anActor = Actor::New();
857 Actor child = anActor.GetChildAt(0);
858 CustomActor customActor = CustomActor::DownCast( child );
859 DALI_TEST_CHECK( !customActor );
861 Actor unInitialzedActor;
862 customActor = CustomActor::DownCast( unInitialzedActor );
863 DALI_TEST_CHECK( !customActor );
865 customActor = DownCast< CustomActor >( unInitialzedActor );
866 DALI_TEST_CHECK( !customActor );
870 int UtcDaliCustomActorOnStageConnectionDisconnection(void)
872 TestApplication application;
873 tet_infoline("Testing Dali::CustomActor::OnStageConnection() & OnStageDisconnection");
875 TestCustomActor custom = TestCustomActor::New();
876 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
878 // add the custom actor to stage
879 Stage::GetCurrent().Add( custom );
881 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
882 DALI_TEST_EQUALS( "OnStageConnection", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
884 Stage::GetCurrent().Remove( custom );
886 DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
887 DALI_TEST_EQUALS( "OnStageDisconnection", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
889 // Excercise the message passing to Update thread
891 application.SendNotification();
892 application.Render();
893 application.Render();
897 int UtcDaliCustomActorOnStageConnectionOrder(void)
899 TestApplication application;
900 tet_infoline("Testing Dali::CustomActor::OnStageConnection() order");
902 MasterCallStack.clear();
904 /* Build tree of actors:
912 * OnStageConnection should be received for A, B, D, E, C, and finally F
915 TestCustomActor actorA = TestCustomActor::New();
916 actorA.SetName( "ActorA" );
918 TestCustomActor actorB = TestCustomActor::New();
919 actorB.SetName( "ActorB" );
920 actorA.Add( actorB );
922 TestCustomActor actorC = TestCustomActor::New();
923 actorC.SetName( "ActorC" );
924 actorA.Add( actorC );
926 TestCustomActor actorD = TestCustomActor::New();
927 actorD.SetName( "ActorD" );
928 actorB.Add( actorD );
930 TestCustomActor actorE = TestCustomActor::New();
931 actorE.SetName( "ActorE" );
932 actorB.Add( actorE );
934 TestCustomActor actorF = TestCustomActor::New();
935 actorF.SetName( "ActorF" );
936 actorC.Add( actorF );
938 // add the custom actor to stage
939 Stage::GetCurrent().Add( actorA );
941 DALI_TEST_EQUALS( 3, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
942 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
943 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
944 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION );
946 DALI_TEST_EQUALS( 3, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
947 DALI_TEST_EQUALS( "OnChildAdd", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
948 DALI_TEST_EQUALS( "OnChildAdd", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
949 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 2 ], TEST_LOCATION );
951 DALI_TEST_EQUALS( 2, (int)(actorC.GetMethodsCalled().size()), TEST_LOCATION );
952 DALI_TEST_EQUALS( "OnChildAdd", actorC.GetMethodsCalled()[ 0 ], TEST_LOCATION );
953 DALI_TEST_EQUALS( "OnStageConnection", actorC.GetMethodsCalled()[ 1 ], TEST_LOCATION );
955 DALI_TEST_EQUALS( 1, (int)(actorD.GetMethodsCalled().size()), TEST_LOCATION );
956 DALI_TEST_EQUALS( "OnStageConnection", actorD.GetMethodsCalled()[ 0 ], TEST_LOCATION );
958 DALI_TEST_EQUALS( 1, (int)(actorE.GetMethodsCalled().size()), TEST_LOCATION );
959 DALI_TEST_EQUALS( "OnStageConnection", actorE.GetMethodsCalled()[ 0 ], TEST_LOCATION );
961 DALI_TEST_EQUALS( 1, (int)(actorF.GetMethodsCalled().size()), TEST_LOCATION );
962 DALI_TEST_EQUALS( "OnStageConnection", actorF.GetMethodsCalled()[ 0 ], TEST_LOCATION );
964 // Check sequence is correct in MasterCallStack
966 DALI_TEST_EQUALS( 3+3+2+1+1+1, (int)(MasterCallStack.size()), TEST_LOCATION );
968 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 0 ], TEST_LOCATION );
969 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 1 ], TEST_LOCATION );
970 DALI_TEST_EQUALS( "ActorB: OnChildAdd", MasterCallStack[ 2 ], TEST_LOCATION );
971 DALI_TEST_EQUALS( "ActorB: OnChildAdd", MasterCallStack[ 3 ], TEST_LOCATION );
972 DALI_TEST_EQUALS( "ActorC: OnChildAdd", MasterCallStack[ 4 ], TEST_LOCATION );
974 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 5 ], TEST_LOCATION );
975 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 6 ], TEST_LOCATION );
976 DALI_TEST_EQUALS( "ActorD: OnStageConnection", MasterCallStack[ 7 ], TEST_LOCATION );
977 DALI_TEST_EQUALS( "ActorE: OnStageConnection", MasterCallStack[ 8 ], TEST_LOCATION );
978 DALI_TEST_EQUALS( "ActorC: OnStageConnection", MasterCallStack[ 9 ], TEST_LOCATION );
979 DALI_TEST_EQUALS( "ActorF: OnStageConnection", MasterCallStack[ 10 ], TEST_LOCATION );
981 // Excercise the message passing to Update thread
983 application.SendNotification();
984 application.Render();
985 application.Render();
989 int UtcDaliCustomActorOnStageDisconnectionOrder(void)
991 TestApplication application;
992 tet_infoline("Testing Dali::CustomActor::OnStageDisconnection() order");
994 Stage stage = Stage::GetCurrent();
996 /* Build tree of actors:
1004 * OnStageDisconnection should be received for D, E, B, F, C, and finally A.
1007 TestCustomActor actorA = TestCustomActor::New();
1008 actorA.SetName( "ActorA" );
1009 stage.Add( actorA );
1011 TestCustomActor actorB = TestCustomActor::New();
1012 actorB.SetName( "ActorB" );
1013 actorA.Add( actorB );
1015 TestCustomActor actorC = TestCustomActor::New();
1016 actorC.SetName( "ActorC" );
1017 actorA.Add( actorC );
1019 TestCustomActor actorD = TestCustomActor::New();
1020 actorD.SetName( "ActorD" );
1021 actorB.Add( actorD );
1023 TestCustomActor actorE = TestCustomActor::New();
1024 actorE.SetName( "ActorE" );
1025 actorB.Add( actorE );
1027 TestCustomActor actorF = TestCustomActor::New();
1028 actorF.SetName( "ActorF" );
1029 actorC.Add( actorF );
1031 // Excercise the message passing to Update thread
1033 application.SendNotification();
1034 application.Render();
1035 application.Render();
1037 // Clear call stacks before disconnection
1038 actorA.ResetCallStack();
1039 actorB.ResetCallStack();
1040 actorC.ResetCallStack();
1041 actorD.ResetCallStack();
1042 actorE.ResetCallStack();
1043 actorF.ResetCallStack();
1044 MasterCallStack.clear();
1046 stage.Remove( actorA );
1048 DALI_TEST_EQUALS( 1, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1049 DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1051 DALI_TEST_EQUALS( 1, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1052 DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1054 DALI_TEST_EQUALS( 1, (int)(actorC.GetMethodsCalled().size()), TEST_LOCATION );
1055 DALI_TEST_EQUALS( "OnStageDisconnection", actorC.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1057 DALI_TEST_EQUALS( 1, (int)(actorD.GetMethodsCalled().size()), TEST_LOCATION );
1058 DALI_TEST_EQUALS( "OnStageDisconnection", actorD.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1060 DALI_TEST_EQUALS( 1, (int)(actorE.GetMethodsCalled().size()), TEST_LOCATION );
1061 DALI_TEST_EQUALS( "OnStageDisconnection", actorE.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1063 DALI_TEST_EQUALS( 1, (int)(actorF.GetMethodsCalled().size()), TEST_LOCATION );
1064 DALI_TEST_EQUALS( "OnStageDisconnection", actorF.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1066 // Check sequence is correct in MasterCallStack
1068 DALI_TEST_EQUALS( 6, (int)(MasterCallStack.size()), TEST_LOCATION );
1070 DALI_TEST_EQUALS( "ActorD: OnStageDisconnection", MasterCallStack[ 0 ], TEST_LOCATION );
1071 DALI_TEST_EQUALS( "ActorE: OnStageDisconnection", MasterCallStack[ 1 ], TEST_LOCATION );
1072 DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 2 ], TEST_LOCATION );
1073 DALI_TEST_EQUALS( "ActorF: OnStageDisconnection", MasterCallStack[ 3 ], TEST_LOCATION );
1074 DALI_TEST_EQUALS( "ActorC: OnStageDisconnection", MasterCallStack[ 4 ], TEST_LOCATION );
1075 DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 5 ], TEST_LOCATION );
1077 // Excercise the message passing to Update thread
1079 application.SendNotification();
1080 application.Render();
1081 application.Render();
1085 int UtcDaliCustomActorAddDuringOnStageConnection(void)
1087 TestApplication application;
1088 tet_infoline("Testing Actor::Add behaviour during Dali::CustomActor::OnStageConnection() callback");
1090 Stage stage = Stage::GetCurrent();
1092 MasterCallStack.clear();
1094 /* The actorA is a special variant which adds a child to itself during OnStageConnection()
1095 * The actorB is provided as the child
1098 TestCustomActor actorB = TestCustomActor::New();
1099 actorB.SetName( "ActorB" );
1101 TestCustomActor actorA = TestCustomActor::NewVariant1( actorB );
1102 actorA.SetName( "ActorA" );
1103 stage.Add( actorA );
1105 // Check callback sequence
1107 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1108 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1109 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION ); // Called from within OnStageConnection()
1111 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1112 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1114 DALI_TEST_EQUALS( 3, (int)(MasterCallStack.size()), TEST_LOCATION );
1116 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 0 ], TEST_LOCATION );
1117 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION ); // Occurs during Actor::Add from within from within OnStageConnection()
1118 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 2 ], TEST_LOCATION ); // Occurs after Actor::Add from within from within OnStageConnection()
1120 // Excercise the message passing to Update thread
1122 application.SendNotification();
1123 application.Render();
1124 application.Render();
1126 // Check everything is ok after Actors are removed
1128 stage.Remove( actorA );
1129 application.SendNotification();
1130 application.Render();
1131 application.Render();
1135 int UtcDaliCustomActorRemoveDuringOnStageConnection(void)
1137 TestApplication application;
1138 tet_infoline("Testing Actor::Remove behaviour during Dali::CustomActor::OnStageConnection() callback");
1140 Stage stage = Stage::GetCurrent();
1142 MasterCallStack.clear();
1144 /* The actorA is a special variant which removes its children during OnStageConnection()
1145 * Actors B & C are provided as the children
1148 TestCustomActor actorA = TestCustomActor::NewVariant2();
1149 actorA.SetName( "ActorA" );
1151 TestCustomActor actorB = TestCustomActor::New();
1152 actorB.SetName( "ActorB" );
1153 actorA.Add( actorB );
1155 TestCustomActor actorC = TestCustomActor::New();
1156 actorC.SetName( "ActorC" );
1157 actorA.Add( actorC );
1159 stage.Add( actorA );
1161 // Check callback sequence
1163 DALI_TEST_EQUALS( 5, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1164 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1165 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1166 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION );
1167 DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 3 ], TEST_LOCATION ); // Called from within OnStageConnection()
1168 DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 4 ], TEST_LOCATION ); // Called from within OnStageConnection()
1170 DALI_TEST_EQUALS( 5, (int)(MasterCallStack.size()), TEST_LOCATION );
1172 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 0 ], TEST_LOCATION );
1173 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 1 ], TEST_LOCATION );
1174 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 2 ], TEST_LOCATION );
1175 DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 3 ], TEST_LOCATION );
1176 DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 4 ], TEST_LOCATION );
1178 /* Actors B & C should be removed before the point where they could receive an OnStageConnection callback
1179 * Therefore they shouldn't receive either OnStageConnection or OnStageDisconnection
1181 DALI_TEST_EQUALS( 0, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1182 DALI_TEST_EQUALS( 0, (int)(actorC.GetMethodsCalled().size()), TEST_LOCATION );
1184 // Excercise the message passing to Update thread
1186 application.SendNotification();
1187 application.Render();
1188 application.Render();
1190 // Check everything is ok after last actor is removed
1192 stage.Remove( actorA );
1193 application.SendNotification();
1194 application.Render();
1195 application.Render();
1199 int UtcDaliCustomActorAddDuringOnStageDisconnection(void)
1201 TestApplication application;
1202 tet_infoline("Testing Actor::Add behaviour during Dali::CustomActor::OnStageDisonnection() callback");
1204 Stage stage = Stage::GetCurrent();
1206 /* The actorA is a special variant which adds a child to itself during OnStageDisconnection()
1207 * The actorB is provided as the child
1210 TestCustomActor actorB = TestCustomActor::New();
1211 actorB.SetName( "ActorB" );
1213 TestCustomActor actorA = TestCustomActor::NewVariant3( actorB );
1214 actorA.SetName( "ActorA" );
1215 stage.Add( actorA );
1217 // Excercise the message passing to Update thread
1219 application.SendNotification();
1220 application.Render();
1221 application.Render();
1223 // Clear call stacks before disconnection
1224 actorA.ResetCallStack();
1225 actorB.ResetCallStack();
1226 MasterCallStack.clear();
1228 stage.Remove( actorA );
1230 // Check callback sequence
1232 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1233 DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1234 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1236 // Child was added after parent disconnection, so should not receive OnStageConnection()
1237 DALI_TEST_EQUALS( 0, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1239 DALI_TEST_EQUALS( 2, (int)(MasterCallStack.size()), TEST_LOCATION );
1241 DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 0 ], TEST_LOCATION );
1242 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 1 ], TEST_LOCATION );
1244 // Excercise the message passing to Update thread
1246 application.SendNotification();
1247 application.Render();
1248 application.Render();
1252 int UtcDaliCustomActorRemoveDuringOnStageDisconnection(void)
1254 TestApplication application;
1255 tet_infoline("Testing Actor::Remove behaviour during Dali::CustomActor::OnStageDisconnection() callback");
1257 Stage stage = Stage::GetCurrent();
1259 /* The actorA is a special variant which removes its children during OnStageDisconnection()
1260 * The actorB is provided as the child
1263 TestCustomActor actorA = TestCustomActor::NewVariant4();
1264 actorA.SetName( "ActorA" );
1265 stage.Add( actorA );
1267 TestCustomActor actorB = TestCustomActor::New();
1268 actorB.SetName( "ActorB" );
1269 actorA.Add( actorB );
1271 // Excercise the message passing to Update thread
1273 application.SendNotification();
1274 application.Render();
1275 application.Render();
1277 // Clear call stacks before disconnection
1278 actorA.ResetCallStack();
1279 actorB.ResetCallStack();
1280 MasterCallStack.clear();
1282 stage.Remove( actorA );
1284 // Check callback sequence
1286 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1287 DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1288 DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1290 DALI_TEST_EQUALS( 1, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1291 DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1293 DALI_TEST_EQUALS( 3, (int)(MasterCallStack.size()), TEST_LOCATION );
1295 DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 0 ], TEST_LOCATION );
1296 DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 1 ], TEST_LOCATION );
1297 DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 2 ], TEST_LOCATION );
1299 // Excercise the message passing to Update thread
1301 application.SendNotification();
1302 application.Render();
1303 application.Render();
1307 int UtcDaliCustomActorRemoveParentDuringOnStageConnection(void)
1309 TestApplication application;
1310 tet_infoline("Weird test where child removes its own parent from Stage during Dali::CustomActor::OnStageConnection() callback");
1312 Stage stage = Stage::GetCurrent();
1314 MasterCallStack.clear();
1316 /* The actorA is the parent of actorB
1317 * The actorB is a special variant which removes its own parent during OnStageConnection()
1318 * The child actor is interrupting the parent's connection to stage, therefore the parent should not get an OnStageDisconnection()
1321 TestCustomActor actorA = TestCustomActor::New();
1322 actorA.SetName( "ActorA" );
1324 TestCustomActor actorB = TestCustomActor::NewVariant5();
1325 actorB.SetName( "ActorB" );
1326 actorA.Add( actorB );
1328 stage.Add( actorA );
1330 // Check callback sequence
1332 DALI_TEST_EQUALS( 3, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1333 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1334 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1335 DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION );
1337 DALI_TEST_EQUALS( 1, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1338 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1340 DALI_TEST_EQUALS( 4, (int)(MasterCallStack.size()), TEST_LOCATION );
1342 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 0 ], TEST_LOCATION );
1343 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION );
1344 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 2 ], TEST_LOCATION );
1345 DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 3 ], TEST_LOCATION );
1347 // Excercise the message passing to Update thread
1349 application.SendNotification();
1350 application.Render();
1351 application.Render();
1355 int UtcDaliCustomActorAddParentDuringOnStageDisconnection(void)
1357 TestApplication application;
1358 tet_infoline("Weird test where child adds its own parent to Stage during Dali::CustomActor::OnStageDisconnection() callback");
1360 Stage stage = Stage::GetCurrent();
1362 MasterCallStack.clear();
1364 /* The actorA is the parent of actorB
1365 * The actorB is a special variant which (weirdly) adds its own parent during OnStageDisconnection()
1366 * The child actor is interrupting the disconnection, such that parent should not get a OnStageDisconnection()
1369 TestCustomActor actorA = TestCustomActor::New();
1370 actorA.SetName( "ActorA" );
1371 stage.Add( actorA );
1373 TestCustomActor actorB = TestCustomActor::NewVariant6();
1374 actorB.SetName( "ActorB" );
1375 actorA.Add( actorB );
1377 stage.Remove( actorA );
1379 // Check callback sequence
1381 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1382 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1383 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1385 DALI_TEST_EQUALS( 2, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1386 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1387 DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1388 // Disconnect was interrupted, so we should only get one OnStageConnection() for actorB
1390 DALI_TEST_EQUALS( 4, (int)(MasterCallStack.size()), TEST_LOCATION );
1392 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 0 ], TEST_LOCATION );
1393 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION );
1394 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 2 ], TEST_LOCATION );
1395 DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 3 ], TEST_LOCATION );
1397 // Excercise the message passing to Update thread
1399 application.SendNotification();
1400 application.Render();
1401 application.Render();
1405 int UtcDaliCustomActorOnChildAddRemove(void)
1407 TestApplication application;
1408 tet_infoline("Testing Dali::CustomActor::OnChildAdd() & OnChildRemove()");
1410 TestCustomActor custom = TestCustomActor::New();
1411 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1413 Actor aChild = Actor::New();
1414 custom.Add( aChild );
1416 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1417 DALI_TEST_EQUALS( "OnChildAdd", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1419 custom.Remove( aChild );
1421 DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1422 DALI_TEST_EQUALS( "OnChildRemove", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1426 int UtcDaliCustomActorReparentDuringOnChildAdd(void)
1428 TestApplication application;
1429 tet_infoline("Testing Actor:Add (reparenting) behaviour during Dali::CustomActor::OnChildAdd() callback");
1431 Stage stage = Stage::GetCurrent();
1433 MasterCallStack.clear();
1435 /* The actorA is a special variant which reparents children added into a separate container child
1436 * The actorB is the child of actorA
1439 TestCustomActor actorA = TestCustomActor::NewVariant7( "ActorA" );
1440 stage.Add( actorA );
1442 TestCustomActor actorB = TestCustomActor::New();
1443 actorB.SetName( "ActorB" );
1444 actorA.Add( actorB );
1446 // Check hierarchy is as follows:
1453 DALI_TEST_EQUALS( 1, (int)(actorA.GetChildCount()), TEST_LOCATION );
1455 Actor container = actorA.GetChildAt(0);
1456 Actor containerChild;
1458 DALI_TEST_CHECK( container );
1461 DALI_TEST_EQUALS( "Container", container.GetName(), TEST_LOCATION );
1462 DALI_TEST_EQUALS( 1, (int)(container.GetChildCount()), TEST_LOCATION );
1463 containerChild = container.GetChildAt(0);
1466 DALI_TEST_CHECK( containerChild );
1467 if ( containerChild )
1469 DALI_TEST_EQUALS( "ActorB", containerChild.GetName(), TEST_LOCATION );
1470 DALI_TEST_EQUALS( 0, (int)(containerChild.GetChildCount()), TEST_LOCATION );
1473 // Check callback sequence
1475 DALI_TEST_EQUALS( 4, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1476 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION ); // The mContainer added to actorA
1477 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1478 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION ); // The actorB added to actorA
1479 DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 3 ], TEST_LOCATION );
1480 // mContainer will then receive OnChildAdd
1482 DALI_TEST_EQUALS( 3, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1483 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1484 DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1485 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 2 ], TEST_LOCATION );
1487 DALI_TEST_EQUALS( 7, (int)(MasterCallStack.size()), TEST_LOCATION );
1489 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 0 ], TEST_LOCATION );
1490 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION );
1491 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 2 ], TEST_LOCATION );
1492 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 3 ], TEST_LOCATION );
1493 DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 4 ], TEST_LOCATION );
1494 DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 5 ], TEST_LOCATION );
1495 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 6 ], TEST_LOCATION );
1497 // Excercise the message passing to Update thread
1499 application.SendNotification();
1500 application.Render();
1501 application.Render();
1506 * Test that Remove can be called (a NOOP) during the OnChildRemove
1507 * triggered when reparenting an actor
1509 int UtcDaliCustomActorRemoveDuringOnChildRemove(void)
1511 TestApplication application;
1512 tet_infoline("Testing Actor:Remove behaviour during OnChildRemove() callback triggered when reparenting");
1514 Stage stage = Stage::GetCurrent();
1516 MasterCallStack.clear();
1518 /* The childActor will be reparented from actorA to actorB
1519 * The actorA is a special variant which attempts to remove a child from actorB, during the OnChildRemove callback()
1520 * This should be a NOOP since the reparenting has not occured yet
1523 TestCustomActor actorB = TestCustomActor::New();
1524 actorB.SetName( "ActorB" );
1525 stage.Add( actorB );
1527 TestCustomActor actorA = TestCustomActor::NewVariant8( actorB );
1528 actorA.SetName( "ActorA" );
1529 stage.Add( actorA );
1531 Actor childActor = Actor::New();
1532 childActor.SetName( "Child" );
1533 // Reparent from actorA to actorB
1534 actorA.Add( childActor );
1535 actorB.Add( childActor );
1537 // Check hierarchy is as follows:
1542 DALI_TEST_EQUALS( 0, (int)(actorA.GetChildCount()), TEST_LOCATION );
1543 DALI_TEST_EQUALS( 1, (int)(actorB.GetChildCount()), TEST_LOCATION );
1544 DALI_TEST_EQUALS( 0, (int)(childActor.GetChildCount()), TEST_LOCATION );
1546 Actor child = actorB.GetChildAt(0);
1548 DALI_TEST_CHECK( child );
1551 DALI_TEST_EQUALS( "Child", child.GetName(), TEST_LOCATION );
1554 // Check callback sequence
1556 DALI_TEST_EQUALS( 3, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1557 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION ); // The mContainer added to actorA
1558 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1559 DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION ); // The actorB added to actorA
1560 // mContainer will then receive OnChildAdd
1562 DALI_TEST_EQUALS( 2, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1563 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1564 DALI_TEST_EQUALS( "OnChildAdd", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1566 DALI_TEST_EQUALS( 5, (int)(MasterCallStack.size()), TEST_LOCATION );
1568 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 0 ], TEST_LOCATION );
1569 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION );
1570 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 2 ], TEST_LOCATION );
1571 DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 3 ], TEST_LOCATION );
1572 DALI_TEST_EQUALS( "ActorB: OnChildAdd", MasterCallStack[ 4 ], TEST_LOCATION );
1574 // Excercise the message passing to Update thread
1576 application.SendNotification();
1577 application.Render();
1578 application.Render();
1582 int UtcDaliCustomActorOnPropertySet(void)
1584 TestApplication application;
1585 tet_infoline("Testing Dali::CustomActor::OnPropertySet()");
1587 TestCustomActor custom = TestCustomActor::New();
1588 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1590 custom.SetDaliProperty("yes") ;
1592 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1593 DALI_TEST_EQUALS( "OnPropertySet", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1597 int UtcDaliCustomActorOnSizeSet(void)
1599 TestApplication application;
1600 tet_infoline("Testing Dali::CustomActor::OnSizeSet()");
1602 TestCustomActor custom = TestCustomActor::New();
1603 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1605 custom.SetSize( Vector2( 9.0f, 10.0f ) );
1606 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1607 DALI_TEST_EQUALS( "OnSizeSet", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1608 DALI_TEST_EQUALS( 9.0f, custom.GetSize().width, TEST_LOCATION );
1609 DALI_TEST_EQUALS( 10.0f, custom.GetSize().height, TEST_LOCATION );
1611 custom.SetSize( Vector3( 4.0f, 5.0f, 6.0f ) );
1612 DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1613 DALI_TEST_EQUALS( "OnSizeSet", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1614 DALI_TEST_EQUALS( 4.0f, custom.GetSize().width, TEST_LOCATION );
1615 DALI_TEST_EQUALS( 5.0f, custom.GetSize().height, TEST_LOCATION );
1616 DALI_TEST_EQUALS( 6.0f, custom.GetSize().depth, TEST_LOCATION );
1620 int UtcDaliCustomActorOnSizeAnimation(void)
1622 TestApplication application;
1623 tet_infoline("Testing Dali::CustomActor::OnSizeAnimation()");
1625 TestCustomActor custom = TestCustomActor::New();
1626 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1628 Animation anim = Animation::New( 1.0f );
1629 anim.AnimateTo( Property( custom, Actor::Property::SIZE ), Vector3( 8.0f, 9.0f, 10.0f ) );
1630 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1631 DALI_TEST_EQUALS( "OnSizeAnimation", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1632 DALI_TEST_EQUALS( 8.0f, custom.GetTargetSize().width, TEST_LOCATION );
1633 DALI_TEST_EQUALS( 9.0f, custom.GetTargetSize().height, TEST_LOCATION );
1634 DALI_TEST_EQUALS( 10.0f, custom.GetTargetSize().depth, TEST_LOCATION );
1638 int UtcDaliCustomActorOnTouchEvent(void)
1640 TestApplication application;
1641 tet_infoline("Testing Dali::CustomActor::OnTouchEvent()");
1643 TestCustomActor custom = TestCustomActor::New();
1644 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1646 // set size for custom actor
1647 custom.SetSize( 100, 100 );
1648 // add the custom actor to stage
1649 Stage::GetCurrent().Add( custom );
1650 custom.ResetCallStack();
1652 // Render and notify a couple of times
1653 application.SendNotification();
1654 application.Render();
1655 application.SendNotification();
1656 application.Render();
1658 // simulate a touch event
1659 Dali::TouchPoint point( 0, TouchPoint::Down, 1, 1 );
1660 Dali::Integration::TouchEvent event;
1661 event.AddPoint( point );
1662 application.ProcessEvent( event );
1664 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1665 DALI_TEST_EQUALS( "OnTouchEvent", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1669 int UtcDaliCustomActorOnHoverEvent(void)
1671 TestApplication application;
1672 tet_infoline("Testing Dali::CustomActor::OnHoverEvent()");
1674 TestCustomActor custom = TestCustomActor::New();
1675 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1677 // set size for custom actor
1678 custom.SetSize( 100, 100 );
1679 // add the custom actor to stage
1680 Stage::GetCurrent().Add( custom );
1681 custom.ResetCallStack();
1683 // Render and notify a couple of times
1684 application.SendNotification();
1685 application.Render();
1686 application.SendNotification();
1687 application.Render();
1689 // simulate a hover event
1690 Dali::TouchPoint point( 0, TouchPoint::Motion, 1, 1 );
1691 Dali::Integration::HoverEvent event;
1692 event.AddPoint( point );
1693 application.ProcessEvent( event );
1695 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1696 DALI_TEST_EQUALS( "OnHoverEvent", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1700 int UtcDaliCustomActorOnWheelEvent(void)
1702 TestApplication application;
1703 tet_infoline("Testing Dali::CustomActor::OnWheelEvent()");
1705 TestCustomActor custom = TestCustomActor::New();
1706 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1708 // set size for custom actor
1709 custom.SetSize( 100, 100 );
1710 // add the custom actor to stage
1711 Stage::GetCurrent().Add( custom );
1712 custom.ResetCallStack();
1714 // Render and notify a couple of times
1715 application.SendNotification();
1716 application.Render();
1717 application.SendNotification();
1718 application.Render();
1720 // simulate a wheel event
1721 Vector2 screenCoordinates( 10.0f, 10.0f );
1722 Integration::WheelEvent event( Integration::WheelEvent::MOUSE_WHEEL, 0, 0u, screenCoordinates, 1, 1000u );
1723 application.ProcessEvent( event );
1725 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1726 DALI_TEST_EQUALS( "OnWheelEvent", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1730 int UtcDaliCustomActorImplOnPropertySet(void)
1732 TestApplication application;
1733 CustomActorImpl* impl = new Impl::SimpleTestCustomActor();
1735 impl->OnPropertySet( 0, 0 );
1737 DALI_TEST_CHECK( true );
1743 int UtcDaliCustomActorGetImplementation(void)
1745 TestApplication application;
1747 TestCustomActor custom = TestCustomActor::New();
1748 CustomActorImpl& impl = custom.GetImplementation();
1749 impl.GetOwner(); // Test
1751 const TestCustomActor constCustom = TestCustomActor::New();
1752 const CustomActorImpl& constImpl = constCustom.GetImplementation();
1753 constImpl.GetOwner(); // Test
1755 DALI_TEST_CHECK( true );
1759 int UtcDaliCustomActorDoAction(void)
1761 TestApplication application;
1762 tet_infoline("Testing Dali::CustomActor::DoAction()");
1764 TestCustomActor custom = TestCustomActor::New();
1766 BaseHandle customActorObject = custom;
1768 DALI_TEST_CHECK(customActorObject);
1770 std::vector<Property::Value> attributes;
1772 // Check that an invalid command is not performed
1773 DALI_TEST_CHECK(customActorObject.DoAction("invalidCommand", attributes) == false);
1775 // Check that the custom actor is visible
1776 custom.SetVisible(true);
1777 DALI_TEST_CHECK(custom.IsVisible() == true);
1779 // Check the custom actor performed an action to hide itself
1780 DALI_TEST_CHECK(customActorObject.DoAction("hide", attributes) == true);
1782 // flush the queue and render once
1783 application.SendNotification();
1784 application.Render();
1786 // Check that the custom actor is now invisible
1787 DALI_TEST_CHECK(custom.IsVisible() == false);
1789 // Check the custom actor performed an action to show itself
1790 DALI_TEST_CHECK(customActorObject.DoAction("show", attributes) == true);
1792 // flush the queue and render once
1793 application.SendNotification();
1794 application.Render();
1796 // Check that the custom actor is now visible
1797 DALI_TEST_CHECK(custom.IsVisible() == true);
1801 int UtcDaliCustomActorCustomActor(void)
1803 Dali::CustomActor customA;
1804 Dali::CustomActor customB( customA );
1806 DALI_TEST_CHECK( customA == customB );
1811 int UtcDaliCustomActorImplRelayoutRequest(void)
1813 TestApplication application;
1815 DALI_TEST_CHECK( gOnRelayout == false );
1817 TestCustomActor custom = TestCustomActor::NewNegoSize();
1818 Stage::GetCurrent().Add(custom);
1820 application.SendNotification();
1821 application.Render();
1823 DALI_TEST_CHECK( gOnRelayout == true );
1824 gOnRelayout = false;
1826 custom.TestRelayoutRequest();
1827 application.SendNotification();
1828 application.Render();
1830 DALI_TEST_CHECK( gOnRelayout == true );
1835 int UtcDaliCustomActorImplGetHeightForWidthBase(void)
1837 TestApplication application;
1838 TestCustomActor custom = TestCustomActor::NewNegoSize();
1840 float width = 300.0f;
1843 application.SendNotification();
1844 application.Render();
1846 v = custom.TestGetHeightForWidthBase( width );
1848 DALI_TEST_CHECK( v == width );
1853 int UtcDaliCustomActorImplGetWidthForHeightBase(void)
1855 TestApplication application;
1856 TestCustomActor custom = TestCustomActor::NewNegoSize();
1858 float height = 300.0f;
1861 application.SendNotification();
1862 application.Render();
1864 v = custom.TestGetWidthForHeightBase( height );
1866 DALI_TEST_CHECK( v == height );
1871 int UtcDaliCustomActorImplCalculateChildSizeBase(void)
1873 TestApplication application;
1874 TestCustomActor custom = TestCustomActor::NewNegoSize();
1876 Actor child = Actor::New();
1877 child.SetResizePolicy(Dali::ResizePolicy::FIXED, Dali::Dimension::ALL_DIMENSIONS);
1878 child.SetSize(150, 150);
1880 application.SendNotification();
1881 application.Render();
1884 v = custom.TestCalculateChildSizeBase( child, Dali::Dimension::ALL_DIMENSIONS );
1885 DALI_TEST_CHECK( v == 0.0f );
1890 int UtcDaliCustomActorImplRelayoutDependentOnChildrenBase(void)
1892 TestApplication application;
1893 TestCustomActor custom = TestCustomActor::NewNegoSize();
1894 custom.SetResizePolicy(Dali::ResizePolicy::FIT_TO_CHILDREN, Dali::Dimension::ALL_DIMENSIONS);
1898 v = custom.TestRelayoutDependentOnChildrenBase( Dali::Dimension::ALL_DIMENSIONS );
1899 application.SendNotification();
1900 application.Render();
1902 DALI_TEST_CHECK( v == true );
1904 custom.SetResizePolicy(Dali::ResizePolicy::FIXED, Dali::Dimension::ALL_DIMENSIONS);
1905 v = custom.TestRelayoutDependentOnChildrenBase( Dali::Dimension::WIDTH );
1906 application.SendNotification();
1907 application.Render();
1908 DALI_TEST_CHECK( v == false );
1913 int UtcDaliCustomActorTypeRegistry(void)
1915 TestApplication application;
1919 type = TypeRegistry::Get().GetTypeInfo( "CustomActor" );
1920 DALI_TEST_CHECK( type );
1921 BaseHandle handle = type.CreateInstance();
1924 std::string exception;
1928 name = handle.GetTypeName();
1929 tet_result(TET_FAIL);
1931 catch( DaliException& e )
1933 exception = e.condition;
1934 DALI_TEST_EQUALS( exception, "handle && \"BaseObject handle is empty\"", TEST_LOCATION );
1941 int UtcDaliCustomActorGetExtensionP(void)
1943 TestApplication application;
1945 TestCustomActor custom = TestCustomActor::NewVariant5();
1947 DALI_TEST_CHECK( NULL == custom.GetImplementation().GetExtension() );