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
610 custom.SetName( "SizeNegotiationActor" );
617 static TestCustomActor NewVariant1( Actor childToAdd )
619 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant1( childToAdd );
620 TestCustomActor custom( *impl ); // takes ownership
627 static TestCustomActor NewVariant2()
629 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant2();
630 TestCustomActor custom( *impl ); // takes ownership
637 static TestCustomActor NewVariant3( Actor childToAdd )
639 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant3( childToAdd );
640 TestCustomActor custom( *impl ); // takes ownership
647 static TestCustomActor NewVariant4()
649 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant4();
650 TestCustomActor custom( *impl ); // takes ownership
657 static TestCustomActor NewVariant5()
659 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant5();
660 TestCustomActor custom( *impl ); // takes ownership
667 static TestCustomActor NewVariant6()
669 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant6();
670 TestCustomActor custom( *impl ); // takes ownership
677 static TestCustomActor NewVariant7( const char* name )
679 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant7();
680 TestCustomActor custom( *impl ); // takes ownership
682 impl->Initialize( name );
687 static TestCustomActor NewVariant8( Actor rival )
689 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant8( rival );
690 TestCustomActor custom( *impl ); // takes ownership
697 virtual ~TestCustomActor()
701 Impl::TestCustomActor& GetImpl()
703 return static_cast<Impl::TestCustomActor&>(GetImplementation());
706 std::vector< std::string >& GetMethodsCalled()
708 return GetImpl().mMethodsCalled;
711 void ResetCallStack()
713 GetImpl().ResetCallStack();
716 void SetDaliProperty(std::string s)
718 GetImpl().SetDaliProperty(s);
723 return GetImpl().mSizeSet;
726 Vector3 GetTargetSize()
728 return GetImpl().mTargetSize;
731 virtual Vector3 GetNaturalSize()
733 return Vector3( 0.0f, 0.0f, 0.0f );
736 virtual float GetHeightForWidth( float width )
741 virtual float GetWidthForHeight( float height )
746 virtual void OnRelayout( const Vector2& size, RelayoutContainer& container )
750 virtual void OnLayoutNegotiated( float size, Dimension::Type dimension )
754 virtual void OnCalculateRelayoutSize( Dimension::Type dimension )
758 void TestRelayoutRequest()
760 GetImpl().TestRelayoutRequest();
763 float TestGetHeightForWidthBase( float width )
765 return GetImpl().TestGetHeightForWidthBase( width );
768 float TestGetWidthForHeightBase( float height )
770 return GetImpl().TestGetWidthForHeightBase( height );
773 float TestCalculateChildSizeBase( const Dali::Actor& child, Dimension::Type dimension )
775 return GetImpl().TestCalculateChildSizeBase( child, dimension );
778 bool TestRelayoutDependentOnChildrenBase( Dimension::Type dimension )
780 return GetImpl().TestRelayoutDependentOnChildrenBase( dimension );
785 TestCustomActor( Impl::TestCustomActor& impl ) : CustomActor( impl )
792 using namespace Dali;
794 BaseHandle CreateActor()
796 return TestCustomActor::New();
799 Dali::TypeRegistration mType( typeid(TestCustomActor), typeid(Dali::CustomActor), CreateActor );
804 int UtcDaliCustomActorDestructor(void)
806 TestApplication application;
808 CustomActor* actor = new CustomActor();
811 DALI_TEST_CHECK( true );
815 int UtcDaliCustomActorImplDestructor(void)
817 TestApplication application;
818 CustomActorImpl* actor = new Impl::TestCustomActor();
821 DALI_TEST_CHECK( true );
825 // Positive test case for a method
826 int UtcDaliCustomActorDownCast(void)
828 TestApplication application;
829 tet_infoline("Testing Dali::CustomActor::DownCast()");
831 TestCustomActor custom = TestCustomActor::New();
833 Actor anActor = Actor::New();
834 anActor.Add( custom );
836 Actor child = anActor.GetChildAt(0);
837 CustomActor customActor = CustomActor::DownCast( child );
838 DALI_TEST_CHECK( customActor );
841 DALI_TEST_CHECK( !customActor );
843 customActor = DownCast< CustomActor >( child );
844 DALI_TEST_CHECK( customActor );
848 // Negative test case for a method
849 int UtcDaliCustomActorDownCastNegative(void)
851 TestApplication application;
852 tet_infoline("Testing Dali::CustomActor::DownCast()");
854 Actor actor1 = Actor::New();
855 Actor anActor = Actor::New();
858 Actor child = anActor.GetChildAt(0);
859 CustomActor customActor = CustomActor::DownCast( child );
860 DALI_TEST_CHECK( !customActor );
862 Actor unInitialzedActor;
863 customActor = CustomActor::DownCast( unInitialzedActor );
864 DALI_TEST_CHECK( !customActor );
866 customActor = DownCast< CustomActor >( unInitialzedActor );
867 DALI_TEST_CHECK( !customActor );
871 int UtcDaliCustomActorOnStageConnectionDisconnection(void)
873 TestApplication application;
874 tet_infoline("Testing Dali::CustomActor::OnStageConnection() & OnStageDisconnection");
876 TestCustomActor custom = TestCustomActor::New();
877 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
879 // add the custom actor to stage
880 Stage::GetCurrent().Add( custom );
882 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
883 DALI_TEST_EQUALS( "OnStageConnection", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
885 Stage::GetCurrent().Remove( custom );
887 DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
888 DALI_TEST_EQUALS( "OnStageDisconnection", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
890 // Excercise the message passing to Update thread
892 application.SendNotification();
893 application.Render();
894 application.Render();
898 int UtcDaliCustomActorOnStageConnectionOrder(void)
900 TestApplication application;
901 tet_infoline("Testing Dali::CustomActor::OnStageConnection() order");
903 MasterCallStack.clear();
905 /* Build tree of actors:
913 * OnStageConnection should be received for A, B, D, E, C, and finally F
916 TestCustomActor actorA = TestCustomActor::New();
917 actorA.SetName( "ActorA" );
919 TestCustomActor actorB = TestCustomActor::New();
920 actorB.SetName( "ActorB" );
921 actorA.Add( actorB );
923 TestCustomActor actorC = TestCustomActor::New();
924 actorC.SetName( "ActorC" );
925 actorA.Add( actorC );
927 TestCustomActor actorD = TestCustomActor::New();
928 actorD.SetName( "ActorD" );
929 actorB.Add( actorD );
931 TestCustomActor actorE = TestCustomActor::New();
932 actorE.SetName( "ActorE" );
933 actorB.Add( actorE );
935 TestCustomActor actorF = TestCustomActor::New();
936 actorF.SetName( "ActorF" );
937 actorC.Add( actorF );
939 // add the custom actor to stage
940 Stage::GetCurrent().Add( actorA );
942 DALI_TEST_EQUALS( 3, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
943 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
944 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
945 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION );
947 DALI_TEST_EQUALS( 3, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
948 DALI_TEST_EQUALS( "OnChildAdd", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
949 DALI_TEST_EQUALS( "OnChildAdd", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
950 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 2 ], TEST_LOCATION );
952 DALI_TEST_EQUALS( 2, (int)(actorC.GetMethodsCalled().size()), TEST_LOCATION );
953 DALI_TEST_EQUALS( "OnChildAdd", actorC.GetMethodsCalled()[ 0 ], TEST_LOCATION );
954 DALI_TEST_EQUALS( "OnStageConnection", actorC.GetMethodsCalled()[ 1 ], TEST_LOCATION );
956 DALI_TEST_EQUALS( 1, (int)(actorD.GetMethodsCalled().size()), TEST_LOCATION );
957 DALI_TEST_EQUALS( "OnStageConnection", actorD.GetMethodsCalled()[ 0 ], TEST_LOCATION );
959 DALI_TEST_EQUALS( 1, (int)(actorE.GetMethodsCalled().size()), TEST_LOCATION );
960 DALI_TEST_EQUALS( "OnStageConnection", actorE.GetMethodsCalled()[ 0 ], TEST_LOCATION );
962 DALI_TEST_EQUALS( 1, (int)(actorF.GetMethodsCalled().size()), TEST_LOCATION );
963 DALI_TEST_EQUALS( "OnStageConnection", actorF.GetMethodsCalled()[ 0 ], TEST_LOCATION );
965 // Check sequence is correct in MasterCallStack
967 DALI_TEST_EQUALS( 3+3+2+1+1+1, (int)(MasterCallStack.size()), TEST_LOCATION );
969 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 0 ], TEST_LOCATION );
970 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 1 ], TEST_LOCATION );
971 DALI_TEST_EQUALS( "ActorB: OnChildAdd", MasterCallStack[ 2 ], TEST_LOCATION );
972 DALI_TEST_EQUALS( "ActorB: OnChildAdd", MasterCallStack[ 3 ], TEST_LOCATION );
973 DALI_TEST_EQUALS( "ActorC: OnChildAdd", MasterCallStack[ 4 ], TEST_LOCATION );
975 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 5 ], TEST_LOCATION );
976 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 6 ], TEST_LOCATION );
977 DALI_TEST_EQUALS( "ActorD: OnStageConnection", MasterCallStack[ 7 ], TEST_LOCATION );
978 DALI_TEST_EQUALS( "ActorE: OnStageConnection", MasterCallStack[ 8 ], TEST_LOCATION );
979 DALI_TEST_EQUALS( "ActorC: OnStageConnection", MasterCallStack[ 9 ], TEST_LOCATION );
980 DALI_TEST_EQUALS( "ActorF: OnStageConnection", MasterCallStack[ 10 ], TEST_LOCATION );
982 // Excercise the message passing to Update thread
984 application.SendNotification();
985 application.Render();
986 application.Render();
990 int UtcDaliCustomActorOnStageDisconnectionOrder(void)
992 TestApplication application;
993 tet_infoline("Testing Dali::CustomActor::OnStageDisconnection() order");
995 Stage stage = Stage::GetCurrent();
997 /* Build tree of actors:
1005 * OnStageDisconnection should be received for D, E, B, F, C, and finally A.
1008 TestCustomActor actorA = TestCustomActor::New();
1009 actorA.SetName( "ActorA" );
1010 stage.Add( actorA );
1012 TestCustomActor actorB = TestCustomActor::New();
1013 actorB.SetName( "ActorB" );
1014 actorA.Add( actorB );
1016 TestCustomActor actorC = TestCustomActor::New();
1017 actorC.SetName( "ActorC" );
1018 actorA.Add( actorC );
1020 TestCustomActor actorD = TestCustomActor::New();
1021 actorD.SetName( "ActorD" );
1022 actorB.Add( actorD );
1024 TestCustomActor actorE = TestCustomActor::New();
1025 actorE.SetName( "ActorE" );
1026 actorB.Add( actorE );
1028 TestCustomActor actorF = TestCustomActor::New();
1029 actorF.SetName( "ActorF" );
1030 actorC.Add( actorF );
1032 // Excercise the message passing to Update thread
1034 application.SendNotification();
1035 application.Render();
1036 application.Render();
1038 // Clear call stacks before disconnection
1039 actorA.ResetCallStack();
1040 actorB.ResetCallStack();
1041 actorC.ResetCallStack();
1042 actorD.ResetCallStack();
1043 actorE.ResetCallStack();
1044 actorF.ResetCallStack();
1045 MasterCallStack.clear();
1047 stage.Remove( actorA );
1049 DALI_TEST_EQUALS( 1, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1050 DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1052 DALI_TEST_EQUALS( 1, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1053 DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1055 DALI_TEST_EQUALS( 1, (int)(actorC.GetMethodsCalled().size()), TEST_LOCATION );
1056 DALI_TEST_EQUALS( "OnStageDisconnection", actorC.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1058 DALI_TEST_EQUALS( 1, (int)(actorD.GetMethodsCalled().size()), TEST_LOCATION );
1059 DALI_TEST_EQUALS( "OnStageDisconnection", actorD.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1061 DALI_TEST_EQUALS( 1, (int)(actorE.GetMethodsCalled().size()), TEST_LOCATION );
1062 DALI_TEST_EQUALS( "OnStageDisconnection", actorE.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1064 DALI_TEST_EQUALS( 1, (int)(actorF.GetMethodsCalled().size()), TEST_LOCATION );
1065 DALI_TEST_EQUALS( "OnStageDisconnection", actorF.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1067 // Check sequence is correct in MasterCallStack
1069 DALI_TEST_EQUALS( 6, (int)(MasterCallStack.size()), TEST_LOCATION );
1071 DALI_TEST_EQUALS( "ActorD: OnStageDisconnection", MasterCallStack[ 0 ], TEST_LOCATION );
1072 DALI_TEST_EQUALS( "ActorE: OnStageDisconnection", MasterCallStack[ 1 ], TEST_LOCATION );
1073 DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 2 ], TEST_LOCATION );
1074 DALI_TEST_EQUALS( "ActorF: OnStageDisconnection", MasterCallStack[ 3 ], TEST_LOCATION );
1075 DALI_TEST_EQUALS( "ActorC: OnStageDisconnection", MasterCallStack[ 4 ], TEST_LOCATION );
1076 DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 5 ], TEST_LOCATION );
1078 // Excercise the message passing to Update thread
1080 application.SendNotification();
1081 application.Render();
1082 application.Render();
1086 int UtcDaliCustomActorAddDuringOnStageConnection(void)
1088 TestApplication application;
1089 tet_infoline("Testing Actor::Add behaviour during Dali::CustomActor::OnStageConnection() callback");
1091 Stage stage = Stage::GetCurrent();
1093 MasterCallStack.clear();
1095 /* The actorA is a special variant which adds a child to itself during OnStageConnection()
1096 * The actorB is provided as the child
1099 TestCustomActor actorB = TestCustomActor::New();
1100 actorB.SetName( "ActorB" );
1102 TestCustomActor actorA = TestCustomActor::NewVariant1( actorB );
1103 actorA.SetName( "ActorA" );
1104 stage.Add( actorA );
1106 // Check callback sequence
1108 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1109 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1110 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION ); // Called from within OnStageConnection()
1112 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1113 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1115 DALI_TEST_EQUALS( 3, (int)(MasterCallStack.size()), TEST_LOCATION );
1117 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 0 ], TEST_LOCATION );
1118 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION ); // Occurs during Actor::Add from within from within OnStageConnection()
1119 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 2 ], TEST_LOCATION ); // Occurs after Actor::Add from within from within OnStageConnection()
1121 // Excercise the message passing to Update thread
1123 application.SendNotification();
1124 application.Render();
1125 application.Render();
1127 // Check everything is ok after Actors are removed
1129 stage.Remove( actorA );
1130 application.SendNotification();
1131 application.Render();
1132 application.Render();
1136 int UtcDaliCustomActorRemoveDuringOnStageConnection(void)
1138 TestApplication application;
1139 tet_infoline("Testing Actor::Remove behaviour during Dali::CustomActor::OnStageConnection() callback");
1141 Stage stage = Stage::GetCurrent();
1143 MasterCallStack.clear();
1145 /* The actorA is a special variant which removes its children during OnStageConnection()
1146 * Actors B & C are provided as the children
1149 TestCustomActor actorA = TestCustomActor::NewVariant2();
1150 actorA.SetName( "ActorA" );
1152 TestCustomActor actorB = TestCustomActor::New();
1153 actorB.SetName( "ActorB" );
1154 actorA.Add( actorB );
1156 TestCustomActor actorC = TestCustomActor::New();
1157 actorC.SetName( "ActorC" );
1158 actorA.Add( actorC );
1160 stage.Add( actorA );
1162 // Check callback sequence
1164 DALI_TEST_EQUALS( 5, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1165 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1166 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1167 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION );
1168 DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 3 ], TEST_LOCATION ); // Called from within OnStageConnection()
1169 DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 4 ], TEST_LOCATION ); // Called from within OnStageConnection()
1171 DALI_TEST_EQUALS( 5, (int)(MasterCallStack.size()), TEST_LOCATION );
1173 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 0 ], TEST_LOCATION );
1174 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 1 ], TEST_LOCATION );
1175 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 2 ], TEST_LOCATION );
1176 DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 3 ], TEST_LOCATION );
1177 DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 4 ], TEST_LOCATION );
1179 /* Actors B & C should be removed before the point where they could receive an OnStageConnection callback
1180 * Therefore they shouldn't receive either OnStageConnection or OnStageDisconnection
1182 DALI_TEST_EQUALS( 0, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1183 DALI_TEST_EQUALS( 0, (int)(actorC.GetMethodsCalled().size()), TEST_LOCATION );
1185 // Excercise the message passing to Update thread
1187 application.SendNotification();
1188 application.Render();
1189 application.Render();
1191 // Check everything is ok after last actor is removed
1193 stage.Remove( actorA );
1194 application.SendNotification();
1195 application.Render();
1196 application.Render();
1200 int UtcDaliCustomActorAddDuringOnStageDisconnection(void)
1202 TestApplication application;
1203 tet_infoline("Testing Actor::Add behaviour during Dali::CustomActor::OnStageDisonnection() callback");
1205 Stage stage = Stage::GetCurrent();
1207 /* The actorA is a special variant which adds a child to itself during OnStageDisconnection()
1208 * The actorB is provided as the child
1211 TestCustomActor actorB = TestCustomActor::New();
1212 actorB.SetName( "ActorB" );
1214 TestCustomActor actorA = TestCustomActor::NewVariant3( actorB );
1215 actorA.SetName( "ActorA" );
1216 stage.Add( actorA );
1218 // Excercise the message passing to Update thread
1220 application.SendNotification();
1221 application.Render();
1222 application.Render();
1224 // Clear call stacks before disconnection
1225 actorA.ResetCallStack();
1226 actorB.ResetCallStack();
1227 MasterCallStack.clear();
1229 stage.Remove( actorA );
1231 // Check callback sequence
1233 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1234 DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1235 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1237 // Child was added after parent disconnection, so should not receive OnStageConnection()
1238 DALI_TEST_EQUALS( 0, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1240 DALI_TEST_EQUALS( 2, (int)(MasterCallStack.size()), TEST_LOCATION );
1242 DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 0 ], TEST_LOCATION );
1243 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 1 ], TEST_LOCATION );
1245 // Excercise the message passing to Update thread
1247 application.SendNotification();
1248 application.Render();
1249 application.Render();
1253 int UtcDaliCustomActorRemoveDuringOnStageDisconnection(void)
1255 TestApplication application;
1256 tet_infoline("Testing Actor::Remove behaviour during Dali::CustomActor::OnStageDisconnection() callback");
1258 Stage stage = Stage::GetCurrent();
1260 /* The actorA is a special variant which removes its children during OnStageDisconnection()
1261 * The actorB is provided as the child
1264 TestCustomActor actorA = TestCustomActor::NewVariant4();
1265 actorA.SetName( "ActorA" );
1266 stage.Add( actorA );
1268 TestCustomActor actorB = TestCustomActor::New();
1269 actorB.SetName( "ActorB" );
1270 actorA.Add( actorB );
1272 // Excercise the message passing to Update thread
1274 application.SendNotification();
1275 application.Render();
1276 application.Render();
1278 // Clear call stacks before disconnection
1279 actorA.ResetCallStack();
1280 actorB.ResetCallStack();
1281 MasterCallStack.clear();
1283 stage.Remove( actorA );
1285 // Check callback sequence
1287 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1288 DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1289 DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1291 DALI_TEST_EQUALS( 1, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1292 DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1294 DALI_TEST_EQUALS( 3, (int)(MasterCallStack.size()), TEST_LOCATION );
1296 DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 0 ], TEST_LOCATION );
1297 DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 1 ], TEST_LOCATION );
1298 DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 2 ], TEST_LOCATION );
1300 // Excercise the message passing to Update thread
1302 application.SendNotification();
1303 application.Render();
1304 application.Render();
1308 int UtcDaliCustomActorRemoveParentDuringOnStageConnection(void)
1310 TestApplication application;
1311 tet_infoline("Weird test where child removes its own parent from Stage during Dali::CustomActor::OnStageConnection() callback");
1313 Stage stage = Stage::GetCurrent();
1315 MasterCallStack.clear();
1317 /* The actorA is the parent of actorB
1318 * The actorB is a special variant which removes its own parent during OnStageConnection()
1319 * The child actor is interrupting the parent's connection to stage, therefore the parent should not get an OnStageDisconnection()
1322 TestCustomActor actorA = TestCustomActor::New();
1323 actorA.SetName( "ActorA" );
1325 TestCustomActor actorB = TestCustomActor::NewVariant5();
1326 actorB.SetName( "ActorB" );
1327 actorA.Add( actorB );
1329 stage.Add( actorA );
1331 // Check callback sequence
1333 DALI_TEST_EQUALS( 3, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1334 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1335 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1336 DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION );
1338 DALI_TEST_EQUALS( 1, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1339 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1341 DALI_TEST_EQUALS( 4, (int)(MasterCallStack.size()), TEST_LOCATION );
1343 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 0 ], TEST_LOCATION );
1344 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION );
1345 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 2 ], TEST_LOCATION );
1346 DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 3 ], TEST_LOCATION );
1348 // Excercise the message passing to Update thread
1350 application.SendNotification();
1351 application.Render();
1352 application.Render();
1356 int UtcDaliCustomActorAddParentDuringOnStageDisconnection(void)
1358 TestApplication application;
1359 tet_infoline("Weird test where child adds its own parent to Stage during Dali::CustomActor::OnStageDisconnection() callback");
1361 Stage stage = Stage::GetCurrent();
1363 MasterCallStack.clear();
1365 /* The actorA is the parent of actorB
1366 * The actorB is a special variant which (weirdly) adds its own parent during OnStageDisconnection()
1367 * The child actor is interrupting the disconnection, such that parent should not get a OnStageDisconnection()
1370 TestCustomActor actorA = TestCustomActor::New();
1371 actorA.SetName( "ActorA" );
1372 stage.Add( actorA );
1374 TestCustomActor actorB = TestCustomActor::NewVariant6();
1375 actorB.SetName( "ActorB" );
1376 actorA.Add( actorB );
1378 stage.Remove( actorA );
1380 // Check callback sequence
1382 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1383 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1384 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1386 DALI_TEST_EQUALS( 2, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1387 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1388 DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1389 // Disconnect was interrupted, so we should only get one OnStageConnection() for actorB
1391 DALI_TEST_EQUALS( 4, (int)(MasterCallStack.size()), TEST_LOCATION );
1393 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 0 ], TEST_LOCATION );
1394 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION );
1395 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 2 ], TEST_LOCATION );
1396 DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 3 ], TEST_LOCATION );
1398 // Excercise the message passing to Update thread
1400 application.SendNotification();
1401 application.Render();
1402 application.Render();
1406 int UtcDaliCustomActorOnChildAddRemove(void)
1408 TestApplication application;
1409 tet_infoline("Testing Dali::CustomActor::OnChildAdd() & OnChildRemove()");
1411 TestCustomActor custom = TestCustomActor::New();
1412 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1414 Actor aChild = Actor::New();
1415 custom.Add( aChild );
1417 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1418 DALI_TEST_EQUALS( "OnChildAdd", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1420 custom.Remove( aChild );
1422 DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1423 DALI_TEST_EQUALS( "OnChildRemove", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1427 int UtcDaliCustomActorReparentDuringOnChildAdd(void)
1429 TestApplication application;
1430 tet_infoline("Testing Actor:Add (reparenting) behaviour during Dali::CustomActor::OnChildAdd() callback");
1432 Stage stage = Stage::GetCurrent();
1434 MasterCallStack.clear();
1436 /* The actorA is a special variant which reparents children added into a separate container child
1437 * The actorB is the child of actorA
1440 TestCustomActor actorA = TestCustomActor::NewVariant7( "ActorA" );
1441 stage.Add( actorA );
1443 TestCustomActor actorB = TestCustomActor::New();
1444 actorB.SetName( "ActorB" );
1445 actorA.Add( actorB );
1447 // Check hierarchy is as follows:
1454 DALI_TEST_EQUALS( 1, (int)(actorA.GetChildCount()), TEST_LOCATION );
1456 Actor container = actorA.GetChildAt(0);
1457 Actor containerChild;
1459 DALI_TEST_CHECK( container );
1462 DALI_TEST_EQUALS( "Container", container.GetName(), TEST_LOCATION );
1463 DALI_TEST_EQUALS( 1, (int)(container.GetChildCount()), TEST_LOCATION );
1464 containerChild = container.GetChildAt(0);
1467 DALI_TEST_CHECK( containerChild );
1468 if ( containerChild )
1470 DALI_TEST_EQUALS( "ActorB", containerChild.GetName(), TEST_LOCATION );
1471 DALI_TEST_EQUALS( 0, (int)(containerChild.GetChildCount()), TEST_LOCATION );
1474 // Check callback sequence
1476 DALI_TEST_EQUALS( 4, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1477 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION ); // The mContainer added to actorA
1478 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1479 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION ); // The actorB added to actorA
1480 DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 3 ], TEST_LOCATION );
1481 // mContainer will then receive OnChildAdd
1483 DALI_TEST_EQUALS( 3, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1484 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1485 DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1486 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 2 ], TEST_LOCATION );
1488 DALI_TEST_EQUALS( 7, (int)(MasterCallStack.size()), TEST_LOCATION );
1490 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 0 ], TEST_LOCATION );
1491 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION );
1492 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 2 ], TEST_LOCATION );
1493 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 3 ], TEST_LOCATION );
1494 DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 4 ], TEST_LOCATION );
1495 DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 5 ], TEST_LOCATION );
1496 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 6 ], TEST_LOCATION );
1498 // Excercise the message passing to Update thread
1500 application.SendNotification();
1501 application.Render();
1502 application.Render();
1507 * Test that Remove can be called (a NOOP) during the OnChildRemove
1508 * triggered when reparenting an actor
1510 int UtcDaliCustomActorRemoveDuringOnChildRemove(void)
1512 TestApplication application;
1513 tet_infoline("Testing Actor:Remove behaviour during OnChildRemove() callback triggered when reparenting");
1515 Stage stage = Stage::GetCurrent();
1517 MasterCallStack.clear();
1519 /* The childActor will be reparented from actorA to actorB
1520 * The actorA is a special variant which attempts to remove a child from actorB, during the OnChildRemove callback()
1521 * This should be a NOOP since the reparenting has not occured yet
1524 TestCustomActor actorB = TestCustomActor::New();
1525 actorB.SetName( "ActorB" );
1526 stage.Add( actorB );
1528 TestCustomActor actorA = TestCustomActor::NewVariant8( actorB );
1529 actorA.SetName( "ActorA" );
1530 stage.Add( actorA );
1532 Actor childActor = Actor::New();
1533 childActor.SetName( "Child" );
1534 // Reparent from actorA to actorB
1535 actorA.Add( childActor );
1536 actorB.Add( childActor );
1538 // Check hierarchy is as follows:
1543 DALI_TEST_EQUALS( 0, (int)(actorA.GetChildCount()), TEST_LOCATION );
1544 DALI_TEST_EQUALS( 1, (int)(actorB.GetChildCount()), TEST_LOCATION );
1545 DALI_TEST_EQUALS( 0, (int)(childActor.GetChildCount()), TEST_LOCATION );
1547 Actor child = actorB.GetChildAt(0);
1549 DALI_TEST_CHECK( child );
1552 DALI_TEST_EQUALS( "Child", child.GetName(), TEST_LOCATION );
1555 // Check callback sequence
1557 DALI_TEST_EQUALS( 3, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1558 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION ); // The mContainer added to actorA
1559 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1560 DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION ); // The actorB added to actorA
1561 // mContainer will then receive OnChildAdd
1563 DALI_TEST_EQUALS( 2, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1564 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1565 DALI_TEST_EQUALS( "OnChildAdd", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1567 DALI_TEST_EQUALS( 5, (int)(MasterCallStack.size()), TEST_LOCATION );
1569 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 0 ], TEST_LOCATION );
1570 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION );
1571 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 2 ], TEST_LOCATION );
1572 DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 3 ], TEST_LOCATION );
1573 DALI_TEST_EQUALS( "ActorB: OnChildAdd", MasterCallStack[ 4 ], TEST_LOCATION );
1575 // Excercise the message passing to Update thread
1577 application.SendNotification();
1578 application.Render();
1579 application.Render();
1583 int UtcDaliCustomActorOnPropertySet(void)
1585 TestApplication application;
1586 tet_infoline("Testing Dali::CustomActor::OnPropertySet()");
1588 TestCustomActor custom = TestCustomActor::New();
1589 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1591 custom.SetDaliProperty("yes");
1593 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1594 DALI_TEST_EQUALS( "OnPropertySet", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1598 int UtcDaliCustomActorOnSizeSet(void)
1600 TestApplication application;
1601 tet_infoline("Testing Dali::CustomActor::OnSizeSet()");
1603 TestCustomActor custom = TestCustomActor::New();
1604 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1606 custom.SetSize( Vector2( 9.0f, 10.0f ) );
1607 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1608 DALI_TEST_EQUALS( "OnSizeSet", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1609 DALI_TEST_EQUALS( 9.0f, custom.GetSize().width, TEST_LOCATION );
1610 DALI_TEST_EQUALS( 10.0f, custom.GetSize().height, TEST_LOCATION );
1612 custom.SetSize( Vector3( 4.0f, 5.0f, 6.0f ) );
1613 DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1614 DALI_TEST_EQUALS( "OnSizeSet", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1615 DALI_TEST_EQUALS( 4.0f, custom.GetSize().width, TEST_LOCATION );
1616 DALI_TEST_EQUALS( 5.0f, custom.GetSize().height, TEST_LOCATION );
1617 DALI_TEST_EQUALS( 6.0f, custom.GetSize().depth, TEST_LOCATION );
1621 int UtcDaliCustomActorOnSizeAnimation(void)
1623 TestApplication application;
1624 tet_infoline("Testing Dali::CustomActor::OnSizeAnimation()");
1626 TestCustomActor custom = TestCustomActor::New();
1627 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1629 Animation anim = Animation::New( 1.0f );
1630 anim.AnimateTo( Property( custom, Actor::Property::SIZE ), Vector3( 8.0f, 9.0f, 10.0f ) );
1631 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1632 DALI_TEST_EQUALS( "OnSizeAnimation", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1633 DALI_TEST_EQUALS( 8.0f, custom.GetTargetSize().width, TEST_LOCATION );
1634 DALI_TEST_EQUALS( 9.0f, custom.GetTargetSize().height, TEST_LOCATION );
1635 DALI_TEST_EQUALS( 10.0f, custom.GetTargetSize().depth, TEST_LOCATION );
1639 int UtcDaliCustomActorOnTouchEvent(void)
1641 TestApplication application;
1642 tet_infoline("Testing Dali::CustomActor::OnTouchEvent()");
1644 TestCustomActor custom = TestCustomActor::New();
1645 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1647 // set size for custom actor
1648 custom.SetSize( 100, 100 );
1649 // add the custom actor to stage
1650 Stage::GetCurrent().Add( custom );
1651 custom.ResetCallStack();
1653 // Render and notify a couple of times
1654 application.SendNotification();
1655 application.Render();
1656 application.SendNotification();
1657 application.Render();
1659 // simulate a touch event
1660 Dali::TouchPoint point( 0, TouchPoint::Down, 1, 1 );
1661 Dali::Integration::TouchEvent event;
1662 event.AddPoint( point );
1663 application.ProcessEvent( event );
1665 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1666 DALI_TEST_EQUALS( "OnTouchEvent", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1670 int UtcDaliCustomActorOnHoverEvent(void)
1672 TestApplication application;
1673 tet_infoline("Testing Dali::CustomActor::OnHoverEvent()");
1675 TestCustomActor custom = TestCustomActor::New();
1676 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1678 // set size for custom actor
1679 custom.SetSize( 100, 100 );
1680 // add the custom actor to stage
1681 Stage::GetCurrent().Add( custom );
1682 custom.ResetCallStack();
1684 // Render and notify a couple of times
1685 application.SendNotification();
1686 application.Render();
1687 application.SendNotification();
1688 application.Render();
1690 // simulate a hover event
1691 Dali::TouchPoint point( 0, TouchPoint::Motion, 1, 1 );
1692 Dali::Integration::HoverEvent event;
1693 event.AddPoint( point );
1694 application.ProcessEvent( event );
1696 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1697 DALI_TEST_EQUALS( "OnHoverEvent", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1701 int UtcDaliCustomActorOnWheelEvent(void)
1703 TestApplication application;
1704 tet_infoline("Testing Dali::CustomActor::OnWheelEvent()");
1706 TestCustomActor custom = TestCustomActor::New();
1707 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1709 // set size for custom actor
1710 custom.SetSize( 100, 100 );
1711 // add the custom actor to stage
1712 Stage::GetCurrent().Add( custom );
1713 custom.ResetCallStack();
1715 // Render and notify a couple of times
1716 application.SendNotification();
1717 application.Render();
1718 application.SendNotification();
1719 application.Render();
1721 // simulate a wheel event
1722 Vector2 screenCoordinates( 10.0f, 10.0f );
1723 Integration::WheelEvent event( Integration::WheelEvent::MOUSE_WHEEL, 0, 0u, screenCoordinates, 1, 1000u );
1724 application.ProcessEvent( event );
1726 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1727 DALI_TEST_EQUALS( "OnWheelEvent", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1731 int UtcDaliCustomActorImplOnPropertySet(void)
1733 TestApplication application;
1734 CustomActorImpl* impl = new Impl::SimpleTestCustomActor();
1736 impl->OnPropertySet( 0, 0 );
1738 DALI_TEST_CHECK( true );
1744 int UtcDaliCustomActorGetImplementation(void)
1746 TestApplication application;
1748 TestCustomActor custom = TestCustomActor::New();
1749 CustomActorImpl& impl = custom.GetImplementation();
1750 impl.GetOwner(); // Test
1752 const TestCustomActor constCustom = TestCustomActor::New();
1753 const CustomActorImpl& constImpl = constCustom.GetImplementation();
1754 constImpl.GetOwner(); // Test
1756 DALI_TEST_CHECK( true );
1760 int UtcDaliCustomActorDoAction(void)
1762 TestApplication application;
1763 tet_infoline("Testing Dali::CustomActor::DoAction()");
1765 TestCustomActor custom = TestCustomActor::New();
1767 BaseHandle customActorObject = custom;
1769 DALI_TEST_CHECK(customActorObject);
1771 Property::Map attributes;
1773 // Check that an invalid command is not performed
1774 DALI_TEST_CHECK(customActorObject.DoAction("invalidCommand", attributes) == false);
1776 // Check that the custom actor is visible
1777 custom.SetVisible(true);
1778 DALI_TEST_CHECK(custom.IsVisible() == true);
1780 // Check the custom actor performed an action to hide itself
1781 DALI_TEST_CHECK(customActorObject.DoAction("hide", attributes) == true);
1783 // flush the queue and render once
1784 application.SendNotification();
1785 application.Render();
1787 // Check that the custom actor is now invisible
1788 DALI_TEST_CHECK(custom.IsVisible() == false);
1790 // Check the custom actor performed an action to show itself
1791 DALI_TEST_CHECK(customActorObject.DoAction("show", attributes) == true);
1793 // flush the queue and render once
1794 application.SendNotification();
1795 application.Render();
1797 // Check that the custom actor is now visible
1798 DALI_TEST_CHECK(custom.IsVisible() == true);
1802 int UtcDaliCustomActorCustomActor(void)
1804 Dali::CustomActor customA;
1805 Dali::CustomActor customB( customA );
1807 DALI_TEST_CHECK( customA == customB );
1812 int UtcDaliCustomActorImplRelayoutRequest(void)
1814 TestApplication application;
1816 DALI_TEST_CHECK( gOnRelayout == false );
1818 TestCustomActor custom = TestCustomActor::NewNegoSize();
1819 Stage::GetCurrent().Add(custom);
1821 application.SendNotification();
1822 application.Render();
1824 DALI_TEST_CHECK( gOnRelayout == true );
1825 gOnRelayout = false;
1827 custom.TestRelayoutRequest();
1828 application.SendNotification();
1829 application.Render();
1831 DALI_TEST_CHECK( gOnRelayout == true );
1836 int UtcDaliCustomActorImplGetHeightForWidthBase(void)
1838 TestApplication application;
1839 TestCustomActor custom = TestCustomActor::NewNegoSize();
1841 float width = 300.0f;
1844 application.SendNotification();
1845 application.Render();
1847 v = custom.TestGetHeightForWidthBase( width );
1849 DALI_TEST_CHECK( v == width );
1854 int UtcDaliCustomActorImplGetWidthForHeightBase(void)
1856 TestApplication application;
1857 TestCustomActor custom = TestCustomActor::NewNegoSize();
1859 float height = 300.0f;
1862 application.SendNotification();
1863 application.Render();
1865 v = custom.TestGetWidthForHeightBase( height );
1867 DALI_TEST_CHECK( v == height );
1872 int UtcDaliCustomActorImplCalculateChildSizeBase(void)
1874 TestApplication application;
1875 TestCustomActor custom = TestCustomActor::NewNegoSize();
1877 Actor child = Actor::New();
1878 child.SetResizePolicy(Dali::ResizePolicy::FIXED, Dali::Dimension::ALL_DIMENSIONS);
1879 child.SetSize(150, 150);
1881 application.SendNotification();
1882 application.Render();
1885 v = custom.TestCalculateChildSizeBase( child, Dali::Dimension::ALL_DIMENSIONS );
1886 DALI_TEST_CHECK( v == 0.0f );
1891 int UtcDaliCustomActorImplRelayoutDependentOnChildrenBase(void)
1893 TestApplication application;
1894 TestCustomActor custom = TestCustomActor::NewNegoSize();
1895 custom.SetResizePolicy(Dali::ResizePolicy::FIT_TO_CHILDREN, Dali::Dimension::ALL_DIMENSIONS);
1899 v = custom.TestRelayoutDependentOnChildrenBase( Dali::Dimension::ALL_DIMENSIONS );
1900 application.SendNotification();
1901 application.Render();
1903 DALI_TEST_CHECK( v == true );
1905 custom.SetResizePolicy(Dali::ResizePolicy::FIXED, Dali::Dimension::ALL_DIMENSIONS);
1906 v = custom.TestRelayoutDependentOnChildrenBase( Dali::Dimension::WIDTH );
1907 application.SendNotification();
1908 application.Render();
1909 DALI_TEST_CHECK( v == false );
1914 int UtcDaliCustomActorTypeRegistry(void)
1916 TestApplication application;
1920 type = TypeRegistry::Get().GetTypeInfo( "CustomActor" );
1921 DALI_TEST_CHECK( type );
1922 BaseHandle handle = type.CreateInstance();
1925 std::string exception;
1929 name = handle.GetTypeName();
1930 tet_result(TET_FAIL);
1932 catch( DaliException& e )
1934 exception = e.condition;
1935 DALI_TEST_EQUALS( exception, "handle && \"BaseObject handle is empty\"", TEST_LOCATION );
1942 int UtcDaliCustomActorGetExtensionP(void)
1944 TestApplication application;
1946 TestCustomActor custom = TestCustomActor::NewVariant5();
1948 DALI_TEST_CHECK( NULL == custom.GetImplementation().GetExtension() );