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/mouse-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;
49 // TypeRegistry needs custom actor Implementations to have the same name (namespaces are ignored so we use one here)
53 struct TestCustomActor : public CustomActorImpl
59 : CustomActorImpl( true ), // requires touch
60 mDaliProperty( Property::INVALID_INDEX ),
61 mSizeSet( Vector3::ZERO ),
62 mTargetSize( Vector3::ZERO )
64 SetRequiresMouseWheelEvents(true);
65 SetRequiresHoverEvents(true);
71 virtual ~TestCustomActor()
75 void Initialize( const char* name = NULL )
77 mDaliProperty = Self().RegisterProperty( "Dali", std::string("no"), Property::READ_WRITE);
82 virtual void OnInitialize( const char* name ) {}
85 * Resets the call stack
90 mTargetSize = Vector3();
91 mMethodsCalled.clear();
94 void AddToCallStacks( const char* method )
96 mMethodsCalled.push_back( method );
98 // Combine Actor name with method string
99 std::string nameAndMethod( Self().GetName() );
100 if ( 0 == nameAndMethod.size() )
102 nameAndMethod = "Unknown: ";
106 nameAndMethod += ": ";
108 nameAndMethod += method;
110 MasterCallStack.push_back( nameAndMethod );
113 // From CustomActorImpl
114 virtual void OnStageConnection()
116 AddToCallStacks("OnStageConnection");
118 virtual void OnStageDisconnection()
120 AddToCallStacks("OnStageDisconnection");
122 virtual void OnChildAdd(Actor& child)
124 AddToCallStacks("OnChildAdd");
126 virtual void OnChildRemove(Actor& child)
128 AddToCallStacks("OnChildRemove");
130 virtual void OnPropertySet( Property::Index index, Property::Value propertyValue )
132 AddToCallStacks("OnPropertySet");
134 virtual void OnSizeSet(const Vector3& targetSize)
136 mSizeSet = targetSize;
137 AddToCallStacks("OnSizeSet");
139 virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize)
141 mTargetSize = targetSize;
142 AddToCallStacks("OnSizeAnimation");
144 virtual bool OnTouchEvent(const TouchEvent& event)
146 AddToCallStacks("OnTouchEvent");
149 virtual bool OnHoverEvent(const HoverEvent& event)
151 AddToCallStacks("OnHoverEvent");
154 virtual bool OnMouseWheelEvent(const MouseWheelEvent& event)
156 AddToCallStacks("OnMouseWheelEvent");
159 virtual bool OnKeyEvent(const KeyEvent& event)
161 AddToCallStacks("OnKeyEvent");
164 virtual void OnKeyInputFocusGained()
166 AddToCallStacks("OnKeyInputFocusGained");
168 virtual void OnKeyInputFocusLost()
170 AddToCallStacks("OnKeyInputFocusLost");
172 virtual Vector3 GetNaturalSize()
174 return Vector3( 0.0f, 0.0f, 0.0f );
177 virtual float GetHeightForWidth( float width )
182 virtual float GetWidthForHeight( float height )
187 virtual void OnRelayout( const Vector2& size, RelayoutContainer& container )
191 virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
195 virtual void OnCalculateRelayoutSize( Dimension::Type dimension )
199 virtual float CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension )
204 virtual void OnLayoutNegotiated( float size, Dimension::Type dimension )
208 virtual bool RelayoutDependentOnChildren( Dimension::Type dimension = Dimension::ALL_DIMENSIONS )
213 void SetDaliProperty(std::string s)
215 Self().SetProperty(mDaliProperty, s) ;
218 Property::Index mDaliProperty;
219 std::vector< std::string > mMethodsCalled;
225 * Variant which adds a new child during OnStageConnection
227 struct TestCustomActorVariant1 : public TestCustomActor
232 TestCustomActorVariant1( Actor childToAdd )
233 : mChildToAdd( childToAdd )
237 // From CustomActorImpl
238 virtual void OnStageConnection()
241 TestCustomActor::OnStageConnection();
244 Self().Add( mChildToAdd );
251 * Variant which removes children during OnStageConnection
253 struct TestCustomActorVariant2 : public TestCustomActor
258 TestCustomActorVariant2()
262 // From CustomActorImpl
263 virtual void OnStageConnection()
266 TestCustomActor::OnStageConnection();
268 // Remove all the children
269 for( unsigned int i=0, num=Self().GetChildCount(); i<num; ++i )
271 Self().Remove( Self().GetChildAt(0) );
277 * Variant which adds a new child during OnStageDisconnection
279 struct TestCustomActorVariant3 : public TestCustomActor
284 TestCustomActorVariant3( Actor childToAdd )
285 : mChildToAdd( childToAdd )
289 // From CustomActorImpl
290 virtual void OnStageDisconnection()
293 TestCustomActor::OnStageDisconnection();
296 Self().Add( mChildToAdd );
303 * Variant which removes children during OnStageDisconnection
305 struct TestCustomActorVariant4 : public TestCustomActor
310 TestCustomActorVariant4()
314 // From CustomActorImpl
315 virtual void OnStageDisconnection()
318 TestCustomActor::OnStageDisconnection();
320 // Remove all the children
321 for( unsigned int i=0, num=Self().GetChildCount(); i<num; ++i )
323 Self().Remove( Self().GetChildAt(0) );
329 * Variant which removes its parent from Stage during OnStageConnection
331 struct TestCustomActorVariant5 : public TestCustomActor
336 TestCustomActorVariant5()
340 // From CustomActorImpl
341 virtual void OnStageConnection()
344 TestCustomActor::OnStageConnection();
346 // Take parent off-stage
347 Actor parent = Self().GetParent();
350 Stage::GetCurrent().Remove( parent );
356 * Variant which adds its parent to Stage during OnStageDisconnection
358 struct TestCustomActorVariant6 : public TestCustomActor
363 TestCustomActorVariant6()
367 // From CustomActorImpl
368 virtual void OnStageDisconnection()
371 TestCustomActor::OnStageDisconnection();
373 // Put parent on-stage
374 Actor parent = Self().GetParent();
377 Stage::GetCurrent().Add( parent );
383 * Variant which reparents its children into a separate container
385 struct TestCustomActorVariant7 : public TestCustomActor
390 TestCustomActorVariant7()
394 virtual void OnInitialize( const char* name )
396 // We need to do this early, before the OnChildAdd is recorded
397 Self().SetName( name );
399 mContainer = Actor::New();
400 mContainer.SetName( "Container" );
401 Self().Add( mContainer );
404 // From CustomActorImpl
405 virtual void OnChildAdd(Actor& child)
408 TestCustomActor::OnChildAdd(child);
411 if ( child != mContainer )
413 mContainer.Add( child );
421 * Variant which attempts to interfere with the reparenting of a child to another container
423 struct TestCustomActorVariant8 : public TestCustomActor
428 TestCustomActorVariant8( Actor rival )
429 : mRivalContainer( rival )
433 // From CustomActorImpl
434 virtual void OnChildRemove(Actor& child)
437 TestCustomActor::OnChildRemove(child);
439 mRivalContainer.Remove( child ); // attempt to block reparenting to rival (should be a NOOP)
442 Actor mRivalContainer;
445 // Need a class that doesn't override virtual methods
446 class SimpleTestCustomActor : public CustomActorImpl
453 SimpleTestCustomActor()
454 : CustomActorImpl( true ) // requires touch
461 virtual ~SimpleTestCustomActor()
465 // From CustomActorImpl
466 virtual void OnStageConnection()
469 virtual void OnStageDisconnection()
472 virtual void OnChildAdd(Actor& child)
475 virtual void OnChildRemove(Actor& child)
478 virtual void OnSizeSet(const Vector3& targetSize)
481 virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize)
484 virtual bool OnTouchEvent(const TouchEvent& event)
488 virtual bool OnHoverEvent(const HoverEvent& event)
492 virtual bool OnMouseWheelEvent(const MouseWheelEvent& event)
496 virtual bool OnKeyEvent(const KeyEvent& event)
500 virtual void OnKeyInputFocusGained()
503 virtual void OnKeyInputFocusLost()
507 virtual Vector3 GetNaturalSize()
509 return Vector3( 0.0f, 0.0f, 0.0f );
512 virtual float GetHeightForWidth( float width )
517 virtual float GetWidthForHeight( float height )
522 virtual void OnRelayout( const Vector2& size, RelayoutContainer& container )
526 virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
530 virtual void OnCalculateRelayoutSize( Dimension::Type dimension )
534 virtual float CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension )
539 virtual void OnLayoutNegotiated( float size, Dimension::Type dimension )
543 virtual bool RelayoutDependentOnChildren( Dimension::Type dimension = Dimension::ALL_DIMENSIONS )
549 } ; // namespace Impl
556 * Test custom actor handle
558 class TestCustomActor : public CustomActor
562 static TestCustomActor New()
564 Impl::TestCustomActor* impl = new Impl::TestCustomActor;
565 TestCustomActor custom( *impl ); // takes ownership
572 static TestCustomActor NewVariant1( Actor childToAdd )
574 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant1( childToAdd );
575 TestCustomActor custom( *impl ); // takes ownership
582 static TestCustomActor NewVariant2()
584 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant2();
585 TestCustomActor custom( *impl ); // takes ownership
592 static TestCustomActor NewVariant3( Actor childToAdd )
594 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant3( childToAdd );
595 TestCustomActor custom( *impl ); // takes ownership
602 static TestCustomActor NewVariant4()
604 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant4();
605 TestCustomActor custom( *impl ); // takes ownership
612 static TestCustomActor NewVariant5()
614 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant5();
615 TestCustomActor custom( *impl ); // takes ownership
622 static TestCustomActor NewVariant6()
624 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant6();
625 TestCustomActor custom( *impl ); // takes ownership
632 static TestCustomActor NewVariant7( const char* name )
634 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant7();
635 TestCustomActor custom( *impl ); // takes ownership
637 impl->Initialize( name );
642 static TestCustomActor NewVariant8( Actor rival )
644 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant8( rival );
645 TestCustomActor custom( *impl ); // takes ownership
652 virtual ~TestCustomActor()
656 Impl::TestCustomActor& GetImpl()
658 return static_cast<Impl::TestCustomActor&>(GetImplementation());
661 std::vector< std::string >& GetMethodsCalled()
663 return GetImpl().mMethodsCalled;
666 void ResetCallStack()
668 GetImpl().ResetCallStack();
671 void SetDaliProperty(std::string s)
673 GetImpl().SetDaliProperty(s);
678 return GetImpl().mSizeSet;
681 Vector3 GetTargetSize()
683 return GetImpl().mTargetSize;
686 virtual Vector3 GetNaturalSize()
688 return Vector3( 0.0f, 0.0f, 0.0f );
691 virtual float GetHeightForWidth( float width )
696 virtual float GetWidthForHeight( float height )
701 virtual void OnRelayout( const Vector2& size, RelayoutContainer& container )
705 virtual void OnLayoutNegotiated( float size, Dimension::Type dimension )
709 virtual void OnCalculateRelayoutSize( Dimension::Type dimension )
715 TestCustomActor( Impl::TestCustomActor& impl ) : CustomActor( impl )
722 using namespace Dali;
724 BaseHandle CreateActor()
726 return TestCustomActor::New();
729 Dali::TypeRegistration mType( typeid(TestCustomActor), typeid(Dali::CustomActor), CreateActor );
734 int UtcDaliCustomActorDestructor(void)
736 TestApplication application;
738 CustomActor* actor = new CustomActor();
741 DALI_TEST_CHECK( true );
745 int UtcDaliCustomActorImplDestructor(void)
747 TestApplication application;
748 CustomActorImpl* actor = new Impl::TestCustomActor();
751 DALI_TEST_CHECK( true );
755 // Positive test case for a method
756 int UtcDaliCustomActorDownCast(void)
758 TestApplication application;
759 tet_infoline("Testing Dali::CustomActor::DownCast()");
761 TestCustomActor custom = TestCustomActor::New();
763 Actor anActor = Actor::New();
764 anActor.Add( custom );
766 Actor child = anActor.GetChildAt(0);
767 CustomActor customActor = CustomActor::DownCast( child );
768 DALI_TEST_CHECK( customActor );
771 DALI_TEST_CHECK( !customActor );
773 customActor = DownCast< CustomActor >( child );
774 DALI_TEST_CHECK( customActor );
778 // Negative test case for a method
779 int UtcDaliCustomActorDownCastNegative(void)
781 TestApplication application;
782 tet_infoline("Testing Dali::CustomActor::DownCast()");
784 Actor actor1 = Actor::New();
785 Actor anActor = Actor::New();
788 Actor child = anActor.GetChildAt(0);
789 CustomActor customActor = CustomActor::DownCast( child );
790 DALI_TEST_CHECK( !customActor );
792 Actor unInitialzedActor;
793 customActor = CustomActor::DownCast( unInitialzedActor );
794 DALI_TEST_CHECK( !customActor );
796 customActor = DownCast< CustomActor >( unInitialzedActor );
797 DALI_TEST_CHECK( !customActor );
801 int UtcDaliCustomActorOnStageConnectionDisconnection(void)
803 TestApplication application;
804 tet_infoline("Testing Dali::CustomActor::OnStageConnection() & OnStageDisconnection");
806 TestCustomActor custom = TestCustomActor::New();
807 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
809 // add the custom actor to stage
810 Stage::GetCurrent().Add( custom );
812 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
813 DALI_TEST_EQUALS( "OnStageConnection", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
815 Stage::GetCurrent().Remove( custom );
817 DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
818 DALI_TEST_EQUALS( "OnStageDisconnection", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
820 // Excercise the message passing to Update thread
822 application.SendNotification();
823 application.Render();
824 application.Render();
828 int UtcDaliCustomActorOnStageConnectionOrder(void)
830 TestApplication application;
831 tet_infoline("Testing Dali::CustomActor::OnStageConnection() order");
833 MasterCallStack.clear();
835 /* Build tree of actors:
843 * OnStageConnection should be received for A, B, D, E, C, and finally F
846 TestCustomActor actorA = TestCustomActor::New();
847 actorA.SetName( "ActorA" );
849 TestCustomActor actorB = TestCustomActor::New();
850 actorB.SetName( "ActorB" );
851 actorA.Add( actorB );
853 TestCustomActor actorC = TestCustomActor::New();
854 actorC.SetName( "ActorC" );
855 actorA.Add( actorC );
857 TestCustomActor actorD = TestCustomActor::New();
858 actorD.SetName( "ActorD" );
859 actorB.Add( actorD );
861 TestCustomActor actorE = TestCustomActor::New();
862 actorE.SetName( "ActorE" );
863 actorB.Add( actorE );
865 TestCustomActor actorF = TestCustomActor::New();
866 actorF.SetName( "ActorF" );
867 actorC.Add( actorF );
869 // add the custom actor to stage
870 Stage::GetCurrent().Add( actorA );
872 DALI_TEST_EQUALS( 3, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
873 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
874 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
875 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION );
877 DALI_TEST_EQUALS( 3, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
878 DALI_TEST_EQUALS( "OnChildAdd", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
879 DALI_TEST_EQUALS( "OnChildAdd", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
880 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 2 ], TEST_LOCATION );
882 DALI_TEST_EQUALS( 2, (int)(actorC.GetMethodsCalled().size()), TEST_LOCATION );
883 DALI_TEST_EQUALS( "OnChildAdd", actorC.GetMethodsCalled()[ 0 ], TEST_LOCATION );
884 DALI_TEST_EQUALS( "OnStageConnection", actorC.GetMethodsCalled()[ 1 ], TEST_LOCATION );
886 DALI_TEST_EQUALS( 1, (int)(actorD.GetMethodsCalled().size()), TEST_LOCATION );
887 DALI_TEST_EQUALS( "OnStageConnection", actorD.GetMethodsCalled()[ 0 ], TEST_LOCATION );
889 DALI_TEST_EQUALS( 1, (int)(actorE.GetMethodsCalled().size()), TEST_LOCATION );
890 DALI_TEST_EQUALS( "OnStageConnection", actorE.GetMethodsCalled()[ 0 ], TEST_LOCATION );
892 DALI_TEST_EQUALS( 1, (int)(actorF.GetMethodsCalled().size()), TEST_LOCATION );
893 DALI_TEST_EQUALS( "OnStageConnection", actorF.GetMethodsCalled()[ 0 ], TEST_LOCATION );
895 // Check sequence is correct in MasterCallStack
897 DALI_TEST_EQUALS( 3+3+2+1+1+1, (int)(MasterCallStack.size()), TEST_LOCATION );
899 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 0 ], TEST_LOCATION );
900 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 1 ], TEST_LOCATION );
901 DALI_TEST_EQUALS( "ActorB: OnChildAdd", MasterCallStack[ 2 ], TEST_LOCATION );
902 DALI_TEST_EQUALS( "ActorB: OnChildAdd", MasterCallStack[ 3 ], TEST_LOCATION );
903 DALI_TEST_EQUALS( "ActorC: OnChildAdd", MasterCallStack[ 4 ], TEST_LOCATION );
905 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 5 ], TEST_LOCATION );
906 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 6 ], TEST_LOCATION );
907 DALI_TEST_EQUALS( "ActorD: OnStageConnection", MasterCallStack[ 7 ], TEST_LOCATION );
908 DALI_TEST_EQUALS( "ActorE: OnStageConnection", MasterCallStack[ 8 ], TEST_LOCATION );
909 DALI_TEST_EQUALS( "ActorC: OnStageConnection", MasterCallStack[ 9 ], TEST_LOCATION );
910 DALI_TEST_EQUALS( "ActorF: OnStageConnection", MasterCallStack[ 10 ], TEST_LOCATION );
912 // Excercise the message passing to Update thread
914 application.SendNotification();
915 application.Render();
916 application.Render();
920 int UtcDaliCustomActorOnStageDisconnectionOrder(void)
922 TestApplication application;
923 tet_infoline("Testing Dali::CustomActor::OnStageDisconnection() order");
925 Stage stage = Stage::GetCurrent();
927 /* Build tree of actors:
935 * OnStageDisconnection should be received for D, E, B, F, C, and finally A.
938 TestCustomActor actorA = TestCustomActor::New();
939 actorA.SetName( "ActorA" );
942 TestCustomActor actorB = TestCustomActor::New();
943 actorB.SetName( "ActorB" );
944 actorA.Add( actorB );
946 TestCustomActor actorC = TestCustomActor::New();
947 actorC.SetName( "ActorC" );
948 actorA.Add( actorC );
950 TestCustomActor actorD = TestCustomActor::New();
951 actorD.SetName( "ActorD" );
952 actorB.Add( actorD );
954 TestCustomActor actorE = TestCustomActor::New();
955 actorE.SetName( "ActorE" );
956 actorB.Add( actorE );
958 TestCustomActor actorF = TestCustomActor::New();
959 actorF.SetName( "ActorF" );
960 actorC.Add( actorF );
962 // Excercise the message passing to Update thread
964 application.SendNotification();
965 application.Render();
966 application.Render();
968 // Clear call stacks before disconnection
969 actorA.ResetCallStack();
970 actorB.ResetCallStack();
971 actorC.ResetCallStack();
972 actorD.ResetCallStack();
973 actorE.ResetCallStack();
974 actorF.ResetCallStack();
975 MasterCallStack.clear();
977 stage.Remove( actorA );
979 DALI_TEST_EQUALS( 1, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
980 DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
982 DALI_TEST_EQUALS( 1, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
983 DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
985 DALI_TEST_EQUALS( 1, (int)(actorC.GetMethodsCalled().size()), TEST_LOCATION );
986 DALI_TEST_EQUALS( "OnStageDisconnection", actorC.GetMethodsCalled()[ 0 ], TEST_LOCATION );
988 DALI_TEST_EQUALS( 1, (int)(actorD.GetMethodsCalled().size()), TEST_LOCATION );
989 DALI_TEST_EQUALS( "OnStageDisconnection", actorD.GetMethodsCalled()[ 0 ], TEST_LOCATION );
991 DALI_TEST_EQUALS( 1, (int)(actorE.GetMethodsCalled().size()), TEST_LOCATION );
992 DALI_TEST_EQUALS( "OnStageDisconnection", actorE.GetMethodsCalled()[ 0 ], TEST_LOCATION );
994 DALI_TEST_EQUALS( 1, (int)(actorF.GetMethodsCalled().size()), TEST_LOCATION );
995 DALI_TEST_EQUALS( "OnStageDisconnection", actorF.GetMethodsCalled()[ 0 ], TEST_LOCATION );
997 // Check sequence is correct in MasterCallStack
999 DALI_TEST_EQUALS( 6, (int)(MasterCallStack.size()), TEST_LOCATION );
1001 DALI_TEST_EQUALS( "ActorD: OnStageDisconnection", MasterCallStack[ 0 ], TEST_LOCATION );
1002 DALI_TEST_EQUALS( "ActorE: OnStageDisconnection", MasterCallStack[ 1 ], TEST_LOCATION );
1003 DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 2 ], TEST_LOCATION );
1004 DALI_TEST_EQUALS( "ActorF: OnStageDisconnection", MasterCallStack[ 3 ], TEST_LOCATION );
1005 DALI_TEST_EQUALS( "ActorC: OnStageDisconnection", MasterCallStack[ 4 ], TEST_LOCATION );
1006 DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 5 ], TEST_LOCATION );
1008 // Excercise the message passing to Update thread
1010 application.SendNotification();
1011 application.Render();
1012 application.Render();
1016 int UtcDaliCustomActorAddDuringOnStageConnection(void)
1018 TestApplication application;
1019 tet_infoline("Testing Actor::Add behaviour during Dali::CustomActor::OnStageConnection() callback");
1021 Stage stage = Stage::GetCurrent();
1023 MasterCallStack.clear();
1025 /* The actorA is a special variant which adds a child to itself during OnStageConnection()
1026 * The actorB is provided as the child
1029 TestCustomActor actorB = TestCustomActor::New();
1030 actorB.SetName( "ActorB" );
1032 TestCustomActor actorA = TestCustomActor::NewVariant1( actorB );
1033 actorA.SetName( "ActorA" );
1034 stage.Add( actorA );
1036 // Check callback sequence
1038 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1039 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1040 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION ); // Called from within OnStageConnection()
1042 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1043 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1045 DALI_TEST_EQUALS( 3, (int)(MasterCallStack.size()), TEST_LOCATION );
1047 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 0 ], TEST_LOCATION );
1048 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION ); // Occurs during Actor::Add from within from within OnStageConnection()
1049 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 2 ], TEST_LOCATION ); // Occurs after Actor::Add from within from within OnStageConnection()
1051 // Excercise the message passing to Update thread
1053 application.SendNotification();
1054 application.Render();
1055 application.Render();
1057 // Check everything is ok after Actors are removed
1059 stage.Remove( actorA );
1060 application.SendNotification();
1061 application.Render();
1062 application.Render();
1066 int UtcDaliCustomActorRemoveDuringOnStageConnection(void)
1068 TestApplication application;
1069 tet_infoline("Testing Actor::Remove behaviour during Dali::CustomActor::OnStageConnection() callback");
1071 Stage stage = Stage::GetCurrent();
1073 MasterCallStack.clear();
1075 /* The actorA is a special variant which removes its children during OnStageConnection()
1076 * Actors B & C are provided as the children
1079 TestCustomActor actorA = TestCustomActor::NewVariant2();
1080 actorA.SetName( "ActorA" );
1082 TestCustomActor actorB = TestCustomActor::New();
1083 actorB.SetName( "ActorB" );
1084 actorA.Add( actorB );
1086 TestCustomActor actorC = TestCustomActor::New();
1087 actorC.SetName( "ActorC" );
1088 actorA.Add( actorC );
1090 stage.Add( actorA );
1092 // Check callback sequence
1094 DALI_TEST_EQUALS( 5, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1095 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1096 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1097 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION );
1098 DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 3 ], TEST_LOCATION ); // Called from within OnStageConnection()
1099 DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 4 ], TEST_LOCATION ); // Called from within OnStageConnection()
1101 DALI_TEST_EQUALS( 5, (int)(MasterCallStack.size()), TEST_LOCATION );
1103 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 0 ], TEST_LOCATION );
1104 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 1 ], TEST_LOCATION );
1105 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 2 ], TEST_LOCATION );
1106 DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 3 ], TEST_LOCATION );
1107 DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 4 ], TEST_LOCATION );
1109 /* Actors B & C should be removed before the point where they could receive an OnStageConnection callback
1110 * Therefore they shouldn't receive either OnStageConnection or OnStageDisconnection
1112 DALI_TEST_EQUALS( 0, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1113 DALI_TEST_EQUALS( 0, (int)(actorC.GetMethodsCalled().size()), TEST_LOCATION );
1115 // Excercise the message passing to Update thread
1117 application.SendNotification();
1118 application.Render();
1119 application.Render();
1121 // Check everything is ok after last actor is removed
1123 stage.Remove( actorA );
1124 application.SendNotification();
1125 application.Render();
1126 application.Render();
1130 int UtcDaliCustomActorAddDuringOnStageDisconnection(void)
1132 TestApplication application;
1133 tet_infoline("Testing Actor::Add behaviour during Dali::CustomActor::OnStageDisonnection() callback");
1135 Stage stage = Stage::GetCurrent();
1137 /* The actorA is a special variant which adds a child to itself during OnStageDisconnection()
1138 * The actorB is provided as the child
1141 TestCustomActor actorB = TestCustomActor::New();
1142 actorB.SetName( "ActorB" );
1144 TestCustomActor actorA = TestCustomActor::NewVariant3( actorB );
1145 actorA.SetName( "ActorA" );
1146 stage.Add( actorA );
1148 // Excercise the message passing to Update thread
1150 application.SendNotification();
1151 application.Render();
1152 application.Render();
1154 // Clear call stacks before disconnection
1155 actorA.ResetCallStack();
1156 actorB.ResetCallStack();
1157 MasterCallStack.clear();
1159 stage.Remove( actorA );
1161 // Check callback sequence
1163 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1164 DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1165 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1167 // Child was added after parent disconnection, so should not receive OnStageConnection()
1168 DALI_TEST_EQUALS( 0, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1170 DALI_TEST_EQUALS( 2, (int)(MasterCallStack.size()), TEST_LOCATION );
1172 DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 0 ], TEST_LOCATION );
1173 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 1 ], TEST_LOCATION );
1175 // Excercise the message passing to Update thread
1177 application.SendNotification();
1178 application.Render();
1179 application.Render();
1183 int UtcDaliCustomActorRemoveDuringOnStageDisconnection(void)
1185 TestApplication application;
1186 tet_infoline("Testing Actor::Remove behaviour during Dali::CustomActor::OnStageDisconnection() callback");
1188 Stage stage = Stage::GetCurrent();
1190 /* The actorA is a special variant which removes its children during OnStageDisconnection()
1191 * The actorB is provided as the child
1194 TestCustomActor actorA = TestCustomActor::NewVariant4();
1195 actorA.SetName( "ActorA" );
1196 stage.Add( actorA );
1198 TestCustomActor actorB = TestCustomActor::New();
1199 actorB.SetName( "ActorB" );
1200 actorA.Add( actorB );
1202 // Excercise the message passing to Update thread
1204 application.SendNotification();
1205 application.Render();
1206 application.Render();
1208 // Clear call stacks before disconnection
1209 actorA.ResetCallStack();
1210 actorB.ResetCallStack();
1211 MasterCallStack.clear();
1213 stage.Remove( actorA );
1215 // Check callback sequence
1217 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1218 DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1219 DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1221 DALI_TEST_EQUALS( 1, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1222 DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1224 DALI_TEST_EQUALS( 3, (int)(MasterCallStack.size()), TEST_LOCATION );
1226 DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 0 ], TEST_LOCATION );
1227 DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 1 ], TEST_LOCATION );
1228 DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 2 ], TEST_LOCATION );
1230 // Excercise the message passing to Update thread
1232 application.SendNotification();
1233 application.Render();
1234 application.Render();
1238 int UtcDaliCustomActorRemoveParentDuringOnStageConnection(void)
1240 TestApplication application;
1241 tet_infoline("Weird test where child removes its own parent from Stage during Dali::CustomActor::OnStageConnection() callback");
1243 Stage stage = Stage::GetCurrent();
1245 MasterCallStack.clear();
1247 /* The actorA is the parent of actorB
1248 * The actorB is a special variant which removes its own parent during OnStageConnection()
1249 * The child actor is interrupting the parent's connection to stage, therefore the parent should not get an OnStageDisconnection()
1252 TestCustomActor actorA = TestCustomActor::New();
1253 actorA.SetName( "ActorA" );
1255 TestCustomActor actorB = TestCustomActor::NewVariant5();
1256 actorB.SetName( "ActorB" );
1257 actorA.Add( actorB );
1259 stage.Add( actorA );
1261 // Check callback sequence
1263 DALI_TEST_EQUALS( 3, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1264 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1265 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1266 DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION );
1268 DALI_TEST_EQUALS( 1, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1269 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1271 DALI_TEST_EQUALS( 4, (int)(MasterCallStack.size()), TEST_LOCATION );
1273 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 0 ], TEST_LOCATION );
1274 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION );
1275 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 2 ], TEST_LOCATION );
1276 DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 3 ], TEST_LOCATION );
1278 // Excercise the message passing to Update thread
1280 application.SendNotification();
1281 application.Render();
1282 application.Render();
1286 int UtcDaliCustomActorAddParentDuringOnStageDisconnection(void)
1288 TestApplication application;
1289 tet_infoline("Weird test where child adds its own parent to Stage during Dali::CustomActor::OnStageDisconnection() callback");
1291 Stage stage = Stage::GetCurrent();
1293 MasterCallStack.clear();
1295 /* The actorA is the parent of actorB
1296 * The actorB is a special variant which (weirdly) adds its own parent during OnStageDisconnection()
1297 * The child actor is interrupting the disconnection, such that parent should not get a OnStageDisconnection()
1300 TestCustomActor actorA = TestCustomActor::New();
1301 actorA.SetName( "ActorA" );
1302 stage.Add( actorA );
1304 TestCustomActor actorB = TestCustomActor::NewVariant6();
1305 actorB.SetName( "ActorB" );
1306 actorA.Add( actorB );
1308 stage.Remove( actorA );
1310 // Check callback sequence
1312 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1313 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1314 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1316 DALI_TEST_EQUALS( 2, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1317 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1318 DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1319 // Disconnect was interrupted, so we should only get one OnStageConnection() for actorB
1321 DALI_TEST_EQUALS( 4, (int)(MasterCallStack.size()), TEST_LOCATION );
1323 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 0 ], TEST_LOCATION );
1324 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION );
1325 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 2 ], TEST_LOCATION );
1326 DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 3 ], TEST_LOCATION );
1328 // Excercise the message passing to Update thread
1330 application.SendNotification();
1331 application.Render();
1332 application.Render();
1336 int UtcDaliCustomActorOnChildAddRemove(void)
1338 TestApplication application;
1339 tet_infoline("Testing Dali::CustomActor::OnChildAdd() & OnChildRemove()");
1341 TestCustomActor custom = TestCustomActor::New();
1342 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1344 Actor aChild = Actor::New();
1345 custom.Add( aChild );
1347 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1348 DALI_TEST_EQUALS( "OnChildAdd", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1350 custom.Remove( aChild );
1352 DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1353 DALI_TEST_EQUALS( "OnChildRemove", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1357 int UtcDaliCustomActorReparentDuringOnChildAdd(void)
1359 TestApplication application;
1360 tet_infoline("Testing Actor:Add (reparenting) behaviour during Dali::CustomActor::OnChildAdd() callback");
1362 Stage stage = Stage::GetCurrent();
1364 MasterCallStack.clear();
1366 /* The actorA is a special variant which reparents children added into a separate container child
1367 * The actorB is the child of actorA
1370 TestCustomActor actorA = TestCustomActor::NewVariant7( "ActorA" );
1371 stage.Add( actorA );
1373 TestCustomActor actorB = TestCustomActor::New();
1374 actorB.SetName( "ActorB" );
1375 actorA.Add( actorB );
1377 // Check hierarchy is as follows:
1384 DALI_TEST_EQUALS( 1, (int)(actorA.GetChildCount()), TEST_LOCATION );
1386 Actor container = actorA.GetChildAt(0);
1387 Actor containerChild;
1389 DALI_TEST_CHECK( container );
1392 DALI_TEST_EQUALS( "Container", container.GetName(), TEST_LOCATION );
1393 DALI_TEST_EQUALS( 1, (int)(container.GetChildCount()), TEST_LOCATION );
1394 containerChild = container.GetChildAt(0);
1397 DALI_TEST_CHECK( containerChild );
1398 if ( containerChild )
1400 DALI_TEST_EQUALS( "ActorB", containerChild.GetName(), TEST_LOCATION );
1401 DALI_TEST_EQUALS( 0, (int)(containerChild.GetChildCount()), TEST_LOCATION );
1404 // Check callback sequence
1406 DALI_TEST_EQUALS( 4, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1407 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION ); // The mContainer added to actorA
1408 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1409 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION ); // The actorB added to actorA
1410 DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 3 ], TEST_LOCATION );
1411 // mContainer will then receive OnChildAdd
1413 DALI_TEST_EQUALS( 3, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1414 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1415 DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1416 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 2 ], TEST_LOCATION );
1418 DALI_TEST_EQUALS( 7, (int)(MasterCallStack.size()), TEST_LOCATION );
1420 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 0 ], TEST_LOCATION );
1421 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION );
1422 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 2 ], TEST_LOCATION );
1423 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 3 ], TEST_LOCATION );
1424 DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 4 ], TEST_LOCATION );
1425 DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 5 ], TEST_LOCATION );
1426 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 6 ], TEST_LOCATION );
1428 // Excercise the message passing to Update thread
1430 application.SendNotification();
1431 application.Render();
1432 application.Render();
1437 * Test that Remove can be called (a NOOP) during the OnChildRemove
1438 * triggered when reparenting an actor
1440 int UtcDaliCustomActorRemoveDuringOnChildRemove(void)
1442 TestApplication application;
1443 tet_infoline("Testing Actor:Remove behaviour during OnChildRemove() callback triggered when reparenting");
1445 Stage stage = Stage::GetCurrent();
1447 MasterCallStack.clear();
1449 /* The childActor will be reparented from actorA to actorB
1450 * The actorA is a special variant which attempts to remove a child from actorB, during the OnChildRemove callback()
1451 * This should be a NOOP since the reparenting has not occured yet
1454 TestCustomActor actorB = TestCustomActor::New();
1455 actorB.SetName( "ActorB" );
1456 stage.Add( actorB );
1458 TestCustomActor actorA = TestCustomActor::NewVariant8( actorB );
1459 actorA.SetName( "ActorA" );
1460 stage.Add( actorA );
1462 Actor childActor = Actor::New();
1463 childActor.SetName( "Child" );
1464 // Reparent from actorA to actorB
1465 actorA.Add( childActor );
1466 actorB.Add( childActor );
1468 // Check hierarchy is as follows:
1473 DALI_TEST_EQUALS( 0, (int)(actorA.GetChildCount()), TEST_LOCATION );
1474 DALI_TEST_EQUALS( 1, (int)(actorB.GetChildCount()), TEST_LOCATION );
1475 DALI_TEST_EQUALS( 0, (int)(childActor.GetChildCount()), TEST_LOCATION );
1477 Actor child = actorB.GetChildAt(0);
1479 DALI_TEST_CHECK( child );
1482 DALI_TEST_EQUALS( "Child", child.GetName(), TEST_LOCATION );
1485 // Check callback sequence
1487 DALI_TEST_EQUALS( 3, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1488 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION ); // The mContainer added to actorA
1489 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1490 DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION ); // The actorB added to actorA
1491 // mContainer will then receive OnChildAdd
1493 DALI_TEST_EQUALS( 2, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1494 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1495 DALI_TEST_EQUALS( "OnChildAdd", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1497 DALI_TEST_EQUALS( 5, (int)(MasterCallStack.size()), TEST_LOCATION );
1499 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 0 ], TEST_LOCATION );
1500 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION );
1501 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 2 ], TEST_LOCATION );
1502 DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 3 ], TEST_LOCATION );
1503 DALI_TEST_EQUALS( "ActorB: OnChildAdd", MasterCallStack[ 4 ], TEST_LOCATION );
1505 // Excercise the message passing to Update thread
1507 application.SendNotification();
1508 application.Render();
1509 application.Render();
1513 int UtcDaliCustomActorOnPropertySet(void)
1515 TestApplication application;
1516 tet_infoline("Testing Dali::CustomActor::OnPropertySet()");
1518 TestCustomActor custom = TestCustomActor::New();
1519 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1521 custom.SetDaliProperty("yes") ;
1523 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1524 DALI_TEST_EQUALS( "OnPropertySet", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1528 int UtcDaliCustomActorOnSizeSet(void)
1530 TestApplication application;
1531 tet_infoline("Testing Dali::CustomActor::OnSizeSet()");
1533 TestCustomActor custom = TestCustomActor::New();
1534 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1536 custom.SetSize( Vector2( 9.0f, 10.0f ) );
1537 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1538 DALI_TEST_EQUALS( "OnSizeSet", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1539 DALI_TEST_EQUALS( 9.0f, custom.GetSize().width, TEST_LOCATION );
1540 DALI_TEST_EQUALS( 10.0f, custom.GetSize().height, TEST_LOCATION );
1542 custom.SetSize( Vector3( 4.0f, 5.0f, 6.0f ) );
1543 DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1544 DALI_TEST_EQUALS( "OnSizeSet", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1545 DALI_TEST_EQUALS( 4.0f, custom.GetSize().width, TEST_LOCATION );
1546 DALI_TEST_EQUALS( 5.0f, custom.GetSize().height, TEST_LOCATION );
1547 DALI_TEST_EQUALS( 6.0f, custom.GetSize().depth, TEST_LOCATION );
1551 int UtcDaliCustomActorOnSizeAnimation(void)
1553 TestApplication application;
1554 tet_infoline("Testing Dali::CustomActor::OnSizeAnimation()");
1556 TestCustomActor custom = TestCustomActor::New();
1557 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1559 Animation anim = Animation::New( 1.0f );
1560 anim.AnimateTo( Property( custom, Actor::Property::SIZE ), Vector3( 8.0f, 9.0f, 10.0f ) );
1561 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1562 DALI_TEST_EQUALS( "OnSizeAnimation", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1563 DALI_TEST_EQUALS( 8.0f, custom.GetTargetSize().width, TEST_LOCATION );
1564 DALI_TEST_EQUALS( 9.0f, custom.GetTargetSize().height, TEST_LOCATION );
1565 DALI_TEST_EQUALS( 10.0f, custom.GetTargetSize().depth, TEST_LOCATION );
1569 int UtcDaliCustomActorOnTouchEvent(void)
1571 TestApplication application;
1572 tet_infoline("Testing Dali::CustomActor::OnTouchEvent()");
1574 TestCustomActor custom = TestCustomActor::New();
1575 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1577 // set size for custom actor
1578 custom.SetSize( 100, 100 );
1579 // add the custom actor to stage
1580 Stage::GetCurrent().Add( custom );
1581 custom.ResetCallStack();
1583 // Render and notify a couple of times
1584 application.SendNotification();
1585 application.Render();
1586 application.SendNotification();
1587 application.Render();
1589 // simulate a touch event
1590 Dali::TouchPoint point( 0, TouchPoint::Down, 1, 1 );
1591 Dali::Integration::TouchEvent event;
1592 event.AddPoint( point );
1593 application.ProcessEvent( event );
1595 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1596 DALI_TEST_EQUALS( "OnTouchEvent", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1600 int UtcDaliCustomActorOnHoverEvent(void)
1602 TestApplication application;
1603 tet_infoline("Testing Dali::CustomActor::OnHoverEvent()");
1605 TestCustomActor custom = TestCustomActor::New();
1606 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1608 // set size for custom actor
1609 custom.SetSize( 100, 100 );
1610 // add the custom actor to stage
1611 Stage::GetCurrent().Add( custom );
1612 custom.ResetCallStack();
1614 // Render and notify a couple of times
1615 application.SendNotification();
1616 application.Render();
1617 application.SendNotification();
1618 application.Render();
1620 // simulate a hover event
1621 Dali::TouchPoint point( 0, TouchPoint::Motion, 1, 1 );
1622 Dali::Integration::HoverEvent event;
1623 event.AddPoint( point );
1624 application.ProcessEvent( event );
1626 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1627 DALI_TEST_EQUALS( "OnHoverEvent", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1631 int UtcDaliCustomActorOnMouseWheelEvent(void)
1633 TestApplication application;
1634 tet_infoline("Testing Dali::CustomActor::OnMouseWheelEvent()");
1636 TestCustomActor custom = TestCustomActor::New();
1637 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1639 // set size for custom actor
1640 custom.SetSize( 100, 100 );
1641 // add the custom actor to stage
1642 Stage::GetCurrent().Add( custom );
1643 custom.ResetCallStack();
1645 // Render and notify a couple of times
1646 application.SendNotification();
1647 application.Render();
1648 application.SendNotification();
1649 application.Render();
1651 // simulate a mouse wheel event
1652 Vector2 screenCoordinates( 10.0f, 10.0f );
1653 Integration::MouseWheelEvent event(0, 0u, screenCoordinates, 1, 1000u);
1654 application.ProcessEvent( event );
1656 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1657 DALI_TEST_EQUALS( "OnMouseWheelEvent", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1661 int UtcDaliCustomActorImplOnPropertySet(void)
1663 TestApplication application;
1664 CustomActorImpl* impl = new Impl::SimpleTestCustomActor();
1666 impl->OnPropertySet( 0, 0 );
1668 DALI_TEST_CHECK( true );
1674 int UtcDaliCustomActorGetImplementation(void)
1676 TestApplication application;
1678 TestCustomActor custom = TestCustomActor::New();
1679 CustomActorImpl& impl = custom.GetImplementation();
1680 impl.GetOwner(); // Test
1682 const TestCustomActor constCustom = TestCustomActor::New();
1683 const CustomActorImpl& constImpl = constCustom.GetImplementation();
1684 constImpl.GetOwner(); // Test
1686 DALI_TEST_CHECK( true );
1690 int UtcDaliCustomActorDoAction(void)
1692 TestApplication application;
1693 tet_infoline("Testing Dali::CustomActor::DoAction()");
1695 TestCustomActor custom = TestCustomActor::New();
1697 BaseHandle customActorObject = custom;
1699 DALI_TEST_CHECK(customActorObject);
1701 std::vector<Property::Value> attributes;
1703 // Check that an invalid command is not performed
1704 DALI_TEST_CHECK(customActorObject.DoAction("invalidCommand", attributes) == false);
1706 // Check that the custom actor is visible
1707 custom.SetVisible(true);
1708 DALI_TEST_CHECK(custom.IsVisible() == true);
1710 // Check the custom actor performed an action to hide itself
1711 DALI_TEST_CHECK(customActorObject.DoAction("hide", attributes) == true);
1713 // flush the queue and render once
1714 application.SendNotification();
1715 application.Render();
1717 // Check that the custom actor is now invisible
1718 DALI_TEST_CHECK(custom.IsVisible() == false);
1720 // Check the custom actor performed an action to show itself
1721 DALI_TEST_CHECK(customActorObject.DoAction("show", attributes) == true);
1723 // flush the queue and render once
1724 application.SendNotification();
1725 application.Render();
1727 // Check that the custom actor is now visible
1728 DALI_TEST_CHECK(custom.IsVisible() == true);