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/mouse-wheel-event-integ.h>
24 #include <dali/integration-api/events/key-event-integ.h>
26 #include "dali-test-suite-utils/dali-test-suite-utils.h"
31 void custom_actor_test_startup(void)
33 test_return_value = TET_UNDEF;
36 void custom_actor_test_cleanup(void)
38 test_return_value = TET_PASS;
44 std::vector< std::string > MasterCallStack;
48 // TypeRegistry needs custom actor Implementations to have the same name (namespaces are ignored so we use one here)
52 struct TestCustomActor : public CustomActorImpl
58 : CustomActorImpl( true ), // requires touch
59 mDaliProperty( Property::INVALID_INDEX ),
60 mSizeSet( Vector3::ZERO ),
61 mTargetSize( Vector3::ZERO )
63 SetRequiresMouseWheelEvents(true);
69 virtual ~TestCustomActor()
73 void Initialize( const char* name = NULL )
75 mDaliProperty = Self().RegisterProperty( "Dali", std::string("no"), Property::READ_WRITE);
80 virtual void OnInitialize( const char* name ) {}
83 * Resets the call stack
88 mTargetSize = Vector3();
89 mMethodsCalled.clear();
92 void AddToCallStacks( const char* method )
94 mMethodsCalled.push_back( method );
96 // Combine Actor name with method string
97 std::string nameAndMethod( Self().GetName() );
98 if ( 0 == nameAndMethod.size() )
100 nameAndMethod = "Unknown: ";
104 nameAndMethod += ": ";
106 nameAndMethod += method;
108 MasterCallStack.push_back( nameAndMethod );
111 // From CustomActorImpl
112 virtual void OnStageConnection()
114 AddToCallStacks("OnStageConnection");
116 virtual void OnStageDisconnection()
118 AddToCallStacks("OnStageDisconnection");
120 virtual void OnChildAdd(Actor& child)
122 AddToCallStacks("OnChildAdd");
124 virtual void OnChildRemove(Actor& child)
126 AddToCallStacks("OnChildRemove");
128 virtual void OnPropertySet( Property::Index index, Property::Value propertyValue )
130 AddToCallStacks("OnPropertySet");
132 virtual void OnSizeSet(const Vector3& targetSize)
134 mSizeSet = targetSize;
135 AddToCallStacks("OnSizeSet");
137 virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize)
139 mTargetSize = targetSize;
140 AddToCallStacks("OnSizeAnimation");
142 virtual bool OnTouchEvent(const TouchEvent& event)
144 AddToCallStacks("OnTouchEvent");
147 virtual bool OnMouseWheelEvent(const MouseWheelEvent& event)
149 AddToCallStacks("OnMouseWheelEvent");
152 virtual bool OnKeyEvent(const KeyEvent& event)
154 AddToCallStacks("OnKeyEvent");
157 virtual void OnKeyInputFocusGained()
159 AddToCallStacks("OnKeyInputFocusGained");
161 virtual void OnKeyInputFocusLost()
163 AddToCallStacks("OnKeyInputFocusLost");
165 virtual Actor GetChildByAlias(const std::string& actorAlias)
167 AddToCallStacks("GetChildByAlias");
169 if ("found" == actorAlias)
179 virtual Vector3 GetNaturalSize()
181 return Vector3( 0.0f, 0.0f, 0.0f );
184 void SetDaliProperty(std::string s)
186 Self().SetProperty(mDaliProperty, s) ;
189 Property::Index mDaliProperty;
190 std::vector< std::string > mMethodsCalled;
196 * Variant which adds a new child during OnStageConnection
198 struct TestCustomActorVariant1 : public TestCustomActor
203 TestCustomActorVariant1( Actor childToAdd )
204 : mChildToAdd( childToAdd )
208 // From CustomActorImpl
209 virtual void OnStageConnection()
212 TestCustomActor::OnStageConnection();
215 Self().Add( mChildToAdd );
222 * Variant which removes children during OnStageConnection
224 struct TestCustomActorVariant2 : public TestCustomActor
229 TestCustomActorVariant2()
233 // From CustomActorImpl
234 virtual void OnStageConnection()
237 TestCustomActor::OnStageConnection();
239 // Remove all the children
240 for( unsigned int i=0, num=Self().GetChildCount(); i<num; ++i )
242 Self().Remove( Self().GetChildAt(0) );
248 * Variant which adds a new child during OnStageDisconnection
250 struct TestCustomActorVariant3 : public TestCustomActor
255 TestCustomActorVariant3( Actor childToAdd )
256 : mChildToAdd( childToAdd )
260 // From CustomActorImpl
261 virtual void OnStageDisconnection()
264 TestCustomActor::OnStageDisconnection();
267 Self().Add( mChildToAdd );
274 * Variant which removes children during OnStageDisconnection
276 struct TestCustomActorVariant4 : public TestCustomActor
281 TestCustomActorVariant4()
285 // From CustomActorImpl
286 virtual void OnStageDisconnection()
289 TestCustomActor::OnStageDisconnection();
291 // Remove all the children
292 for( unsigned int i=0, num=Self().GetChildCount(); i<num; ++i )
294 Self().Remove( Self().GetChildAt(0) );
300 * Variant which removes its parent from Stage during OnStageConnection
302 struct TestCustomActorVariant5 : public TestCustomActor
307 TestCustomActorVariant5()
311 // From CustomActorImpl
312 virtual void OnStageConnection()
315 TestCustomActor::OnStageConnection();
317 // Take parent off-stage
318 Actor parent = Self().GetParent();
321 Stage::GetCurrent().Remove( parent );
327 * Variant which adds its parent to Stage during OnStageDisconnection
329 struct TestCustomActorVariant6 : public TestCustomActor
334 TestCustomActorVariant6()
338 // From CustomActorImpl
339 virtual void OnStageDisconnection()
342 TestCustomActor::OnStageDisconnection();
344 // Put parent on-stage
345 Actor parent = Self().GetParent();
348 Stage::GetCurrent().Add( parent );
354 * Variant which reparents its children into a separate container
356 struct TestCustomActorVariant7 : public TestCustomActor
361 TestCustomActorVariant7()
365 virtual void OnInitialize( const char* name )
367 // We need to do this early, before the OnChildAdd is recorded
368 Self().SetName( name );
370 mContainer = Actor::New();
371 mContainer.SetName( "Container" );
372 Self().Add( mContainer );
375 // From CustomActorImpl
376 virtual void OnChildAdd(Actor& child)
379 TestCustomActor::OnChildAdd(child);
382 if ( child != mContainer )
384 mContainer.Add( child );
392 * Variant which attempts to interfere with the reparenting of a child to another container
394 struct TestCustomActorVariant8 : public TestCustomActor
399 TestCustomActorVariant8( Actor rival )
400 : mRivalContainer( rival )
404 // From CustomActorImpl
405 virtual void OnChildRemove(Actor& child)
408 TestCustomActor::OnChildRemove(child);
410 mRivalContainer.Remove( child ); // attempt to block reparenting to rival (should be a NOOP)
413 Actor mRivalContainer;
416 // Need a class that doesn't override virtual methods
417 class SimpleTestCustomActor : public CustomActorImpl
424 SimpleTestCustomActor()
425 : CustomActorImpl( true ) // requires touch
432 virtual ~SimpleTestCustomActor()
436 // From CustomActorImpl
437 virtual void OnStageConnection()
440 virtual void OnStageDisconnection()
443 virtual void OnChildAdd(Actor& child)
446 virtual void OnChildRemove(Actor& child)
449 virtual void OnSizeSet(const Vector3& targetSize)
452 virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize)
455 virtual bool OnTouchEvent(const TouchEvent& event)
459 virtual bool OnMouseWheelEvent(const MouseWheelEvent& event)
463 virtual bool OnKeyEvent(const KeyEvent& event)
467 virtual void OnKeyInputFocusGained()
470 virtual void OnKeyInputFocusLost()
474 virtual Actor GetChildByAlias(const std::string& actorAlias)
479 virtual Vector3 GetNaturalSize()
481 return Vector3( 0.0f, 0.0f, 0.0f );
485 } ; // namespace Impl
492 * Test custom actor handle
494 class TestCustomActor : public CustomActor
498 static TestCustomActor New()
500 Impl::TestCustomActor* impl = new Impl::TestCustomActor;
501 TestCustomActor custom( *impl ); // takes ownership
508 static TestCustomActor NewVariant1( Actor childToAdd )
510 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant1( childToAdd );
511 TestCustomActor custom( *impl ); // takes ownership
518 static TestCustomActor NewVariant2()
520 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant2();
521 TestCustomActor custom( *impl ); // takes ownership
528 static TestCustomActor NewVariant3( Actor childToAdd )
530 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant3( childToAdd );
531 TestCustomActor custom( *impl ); // takes ownership
538 static TestCustomActor NewVariant4()
540 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant4();
541 TestCustomActor custom( *impl ); // takes ownership
548 static TestCustomActor NewVariant5()
550 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant5();
551 TestCustomActor custom( *impl ); // takes ownership
558 static TestCustomActor NewVariant6()
560 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant6();
561 TestCustomActor custom( *impl ); // takes ownership
568 static TestCustomActor NewVariant7( const char* name )
570 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant7();
571 TestCustomActor custom( *impl ); // takes ownership
573 impl->Initialize( name );
578 static TestCustomActor NewVariant8( Actor rival )
580 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant8( rival );
581 TestCustomActor custom( *impl ); // takes ownership
588 virtual ~TestCustomActor()
592 Impl::TestCustomActor& GetImpl()
594 return static_cast<Impl::TestCustomActor&>(GetImplementation());
597 std::vector< std::string >& GetMethodsCalled()
599 return GetImpl().mMethodsCalled;
602 void ResetCallStack()
604 GetImpl().ResetCallStack();
607 void SetDaliProperty(std::string s)
609 GetImpl().SetDaliProperty(s);
614 return GetImpl().mSizeSet;
617 Vector3 GetTargetSize()
619 return GetImpl().mTargetSize;
622 virtual Vector3 GetNaturalSize()
624 return Vector3( 0.0f, 0.0f, 0.0f );
629 TestCustomActor( Impl::TestCustomActor& impl ) : CustomActor( impl )
635 BaseHandle CreateActor()
637 return TestCustomActor::New();
643 int UtcDaliCustomActorDestructor(void)
645 TestApplication application;
647 CustomActor* actor = new CustomActor();
650 DALI_TEST_CHECK( true );
654 int UtcDaliCustomActorImplDestructor(void)
656 TestApplication application;
657 CustomActorImpl* actor = new Impl::TestCustomActor();
660 DALI_TEST_CHECK( true );
664 // Positive test case for a method
665 int UtcDaliCustomActorDownCast(void)
667 TestApplication application;
668 tet_infoline("Testing Dali::CustomActor::DownCast()");
670 TestCustomActor custom = TestCustomActor::New();
672 Actor anActor = Actor::New();
673 anActor.Add( custom );
675 Actor child = anActor.GetChildAt(0);
676 CustomActor customActor = CustomActor::DownCast( child );
677 DALI_TEST_CHECK( customActor );
680 DALI_TEST_CHECK( !customActor );
682 customActor = DownCast< CustomActor >( child );
683 DALI_TEST_CHECK( customActor );
687 // Negative test case for a method
688 int UtcDaliCustomActorDownCastNegative(void)
690 TestApplication application;
691 tet_infoline("Testing Dali::CustomActor::DownCast()");
693 Actor actor1 = Actor::New();
694 Actor anActor = Actor::New();
697 Actor child = anActor.GetChildAt(0);
698 CustomActor customActor = CustomActor::DownCast( child );
699 DALI_TEST_CHECK( !customActor );
701 Actor unInitialzedActor;
702 customActor = CustomActor::DownCast( unInitialzedActor );
703 DALI_TEST_CHECK( !customActor );
705 customActor = DownCast< CustomActor >( unInitialzedActor );
706 DALI_TEST_CHECK( !customActor );
710 int UtcDaliCustomActorOnStageConnectionDisconnection(void)
712 TestApplication application;
713 tet_infoline("Testing Dali::CustomActor::OnStageConnection() & OnStageDisconnection");
715 TestCustomActor custom = TestCustomActor::New();
716 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
718 // add the custom actor to stage
719 Stage::GetCurrent().Add( custom );
721 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
722 DALI_TEST_EQUALS( "OnStageConnection", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
724 Stage::GetCurrent().Remove( custom );
726 DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
727 DALI_TEST_EQUALS( "OnStageDisconnection", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
729 // Excercise the message passing to Update thread
731 application.SendNotification();
732 application.Render();
733 application.Render();
737 int UtcDaliCustomActorOnStageConnectionOrder(void)
739 TestApplication application;
740 tet_infoline("Testing Dali::CustomActor::OnStageConnection() order");
742 MasterCallStack.clear();
744 /* Build tree of actors:
752 * OnStageConnection should be received for A, B, D, E, C, and finally F
755 TestCustomActor actorA = TestCustomActor::New();
756 actorA.SetName( "ActorA" );
758 TestCustomActor actorB = TestCustomActor::New();
759 actorB.SetName( "ActorB" );
760 actorA.Add( actorB );
762 TestCustomActor actorC = TestCustomActor::New();
763 actorC.SetName( "ActorC" );
764 actorA.Add( actorC );
766 TestCustomActor actorD = TestCustomActor::New();
767 actorD.SetName( "ActorD" );
768 actorB.Add( actorD );
770 TestCustomActor actorE = TestCustomActor::New();
771 actorE.SetName( "ActorE" );
772 actorB.Add( actorE );
774 TestCustomActor actorF = TestCustomActor::New();
775 actorF.SetName( "ActorF" );
776 actorC.Add( actorF );
778 // add the custom actor to stage
779 Stage::GetCurrent().Add( actorA );
781 DALI_TEST_EQUALS( 3, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
782 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
783 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
784 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION );
786 DALI_TEST_EQUALS( 3, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
787 DALI_TEST_EQUALS( "OnChildAdd", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
788 DALI_TEST_EQUALS( "OnChildAdd", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
789 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 2 ], TEST_LOCATION );
791 DALI_TEST_EQUALS( 2, (int)(actorC.GetMethodsCalled().size()), TEST_LOCATION );
792 DALI_TEST_EQUALS( "OnChildAdd", actorC.GetMethodsCalled()[ 0 ], TEST_LOCATION );
793 DALI_TEST_EQUALS( "OnStageConnection", actorC.GetMethodsCalled()[ 1 ], TEST_LOCATION );
795 DALI_TEST_EQUALS( 1, (int)(actorD.GetMethodsCalled().size()), TEST_LOCATION );
796 DALI_TEST_EQUALS( "OnStageConnection", actorD.GetMethodsCalled()[ 0 ], TEST_LOCATION );
798 DALI_TEST_EQUALS( 1, (int)(actorE.GetMethodsCalled().size()), TEST_LOCATION );
799 DALI_TEST_EQUALS( "OnStageConnection", actorE.GetMethodsCalled()[ 0 ], TEST_LOCATION );
801 DALI_TEST_EQUALS( 1, (int)(actorF.GetMethodsCalled().size()), TEST_LOCATION );
802 DALI_TEST_EQUALS( "OnStageConnection", actorF.GetMethodsCalled()[ 0 ], TEST_LOCATION );
804 // Check sequence is correct in MasterCallStack
806 DALI_TEST_EQUALS( 3+3+2+1+1+1, (int)(MasterCallStack.size()), TEST_LOCATION );
808 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 0 ], TEST_LOCATION );
809 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 1 ], TEST_LOCATION );
810 DALI_TEST_EQUALS( "ActorB: OnChildAdd", MasterCallStack[ 2 ], TEST_LOCATION );
811 DALI_TEST_EQUALS( "ActorB: OnChildAdd", MasterCallStack[ 3 ], TEST_LOCATION );
812 DALI_TEST_EQUALS( "ActorC: OnChildAdd", MasterCallStack[ 4 ], TEST_LOCATION );
814 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 5 ], TEST_LOCATION );
815 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 6 ], TEST_LOCATION );
816 DALI_TEST_EQUALS( "ActorD: OnStageConnection", MasterCallStack[ 7 ], TEST_LOCATION );
817 DALI_TEST_EQUALS( "ActorE: OnStageConnection", MasterCallStack[ 8 ], TEST_LOCATION );
818 DALI_TEST_EQUALS( "ActorC: OnStageConnection", MasterCallStack[ 9 ], TEST_LOCATION );
819 DALI_TEST_EQUALS( "ActorF: OnStageConnection", MasterCallStack[ 10 ], TEST_LOCATION );
821 // Excercise the message passing to Update thread
823 application.SendNotification();
824 application.Render();
825 application.Render();
829 int UtcDaliCustomActorOnStageDisconnectionOrder(void)
831 TestApplication application;
832 tet_infoline("Testing Dali::CustomActor::OnStageDisconnection() order");
834 Stage stage = Stage::GetCurrent();
836 /* Build tree of actors:
844 * OnStageDisconnection should be received for D, E, B, F, C, and finally A.
847 TestCustomActor actorA = TestCustomActor::New();
848 actorA.SetName( "ActorA" );
851 TestCustomActor actorB = TestCustomActor::New();
852 actorB.SetName( "ActorB" );
853 actorA.Add( actorB );
855 TestCustomActor actorC = TestCustomActor::New();
856 actorC.SetName( "ActorC" );
857 actorA.Add( actorC );
859 TestCustomActor actorD = TestCustomActor::New();
860 actorD.SetName( "ActorD" );
861 actorB.Add( actorD );
863 TestCustomActor actorE = TestCustomActor::New();
864 actorE.SetName( "ActorE" );
865 actorB.Add( actorE );
867 TestCustomActor actorF = TestCustomActor::New();
868 actorF.SetName( "ActorF" );
869 actorC.Add( actorF );
871 // Excercise the message passing to Update thread
873 application.SendNotification();
874 application.Render();
875 application.Render();
877 // Clear call stacks before disconnection
878 actorA.ResetCallStack();
879 actorB.ResetCallStack();
880 actorC.ResetCallStack();
881 actorD.ResetCallStack();
882 actorE.ResetCallStack();
883 actorF.ResetCallStack();
884 MasterCallStack.clear();
886 stage.Remove( actorA );
888 DALI_TEST_EQUALS( 1, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
889 DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
891 DALI_TEST_EQUALS( 1, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
892 DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
894 DALI_TEST_EQUALS( 1, (int)(actorC.GetMethodsCalled().size()), TEST_LOCATION );
895 DALI_TEST_EQUALS( "OnStageDisconnection", actorC.GetMethodsCalled()[ 0 ], TEST_LOCATION );
897 DALI_TEST_EQUALS( 1, (int)(actorD.GetMethodsCalled().size()), TEST_LOCATION );
898 DALI_TEST_EQUALS( "OnStageDisconnection", actorD.GetMethodsCalled()[ 0 ], TEST_LOCATION );
900 DALI_TEST_EQUALS( 1, (int)(actorE.GetMethodsCalled().size()), TEST_LOCATION );
901 DALI_TEST_EQUALS( "OnStageDisconnection", actorE.GetMethodsCalled()[ 0 ], TEST_LOCATION );
903 DALI_TEST_EQUALS( 1, (int)(actorF.GetMethodsCalled().size()), TEST_LOCATION );
904 DALI_TEST_EQUALS( "OnStageDisconnection", actorF.GetMethodsCalled()[ 0 ], TEST_LOCATION );
906 // Check sequence is correct in MasterCallStack
908 DALI_TEST_EQUALS( 6, (int)(MasterCallStack.size()), TEST_LOCATION );
910 DALI_TEST_EQUALS( "ActorD: OnStageDisconnection", MasterCallStack[ 0 ], TEST_LOCATION );
911 DALI_TEST_EQUALS( "ActorE: OnStageDisconnection", MasterCallStack[ 1 ], TEST_LOCATION );
912 DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 2 ], TEST_LOCATION );
913 DALI_TEST_EQUALS( "ActorF: OnStageDisconnection", MasterCallStack[ 3 ], TEST_LOCATION );
914 DALI_TEST_EQUALS( "ActorC: OnStageDisconnection", MasterCallStack[ 4 ], TEST_LOCATION );
915 DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 5 ], TEST_LOCATION );
917 // Excercise the message passing to Update thread
919 application.SendNotification();
920 application.Render();
921 application.Render();
925 int UtcDaliCustomActorAddDuringOnStageConnection(void)
927 TestApplication application;
928 tet_infoline("Testing Actor::Add behaviour during Dali::CustomActor::OnStageConnection() callback");
930 Stage stage = Stage::GetCurrent();
932 MasterCallStack.clear();
934 /* The actorA is a special variant which adds a child to itself during OnStageConnection()
935 * The actorB is provided as the child
938 TestCustomActor actorB = TestCustomActor::New();
939 actorB.SetName( "ActorB" );
941 TestCustomActor actorA = TestCustomActor::NewVariant1( actorB );
942 actorA.SetName( "ActorA" );
945 // Check callback sequence
947 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
948 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
949 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION ); // Called from within OnStageConnection()
951 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
952 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
954 DALI_TEST_EQUALS( 3, (int)(MasterCallStack.size()), TEST_LOCATION );
956 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 0 ], TEST_LOCATION );
957 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION ); // Occurs during Actor::Add from within from within OnStageConnection()
958 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 2 ], TEST_LOCATION ); // Occurs after Actor::Add from within from within OnStageConnection()
960 // Excercise the message passing to Update thread
962 application.SendNotification();
963 application.Render();
964 application.Render();
966 // Check everything is ok after Actors are removed
968 stage.Remove( actorA );
969 application.SendNotification();
970 application.Render();
971 application.Render();
975 int UtcDaliCustomActorRemoveDuringOnStageConnection(void)
977 TestApplication application;
978 tet_infoline("Testing Actor::Remove behaviour during Dali::CustomActor::OnStageConnection() callback");
980 Stage stage = Stage::GetCurrent();
982 MasterCallStack.clear();
984 /* The actorA is a special variant which removes its children during OnStageConnection()
985 * Actors B & C are provided as the children
988 TestCustomActor actorA = TestCustomActor::NewVariant2();
989 actorA.SetName( "ActorA" );
991 TestCustomActor actorB = TestCustomActor::New();
992 actorB.SetName( "ActorB" );
993 actorA.Add( actorB );
995 TestCustomActor actorC = TestCustomActor::New();
996 actorC.SetName( "ActorC" );
997 actorA.Add( actorC );
1001 // Check callback sequence
1003 DALI_TEST_EQUALS( 5, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1004 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1005 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1006 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION );
1007 DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 3 ], TEST_LOCATION ); // Called from within OnStageConnection()
1008 DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 4 ], TEST_LOCATION ); // Called from within OnStageConnection()
1010 DALI_TEST_EQUALS( 5, (int)(MasterCallStack.size()), TEST_LOCATION );
1012 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 0 ], TEST_LOCATION );
1013 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 1 ], TEST_LOCATION );
1014 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 2 ], TEST_LOCATION );
1015 DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 3 ], TEST_LOCATION );
1016 DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 4 ], TEST_LOCATION );
1018 /* Actors B & C should be removed before the point where they could receive an OnStageConnection callback
1019 * Therefore they shouldn't receive either OnStageConnection or OnStageDisconnection
1021 DALI_TEST_EQUALS( 0, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1022 DALI_TEST_EQUALS( 0, (int)(actorC.GetMethodsCalled().size()), TEST_LOCATION );
1024 // Excercise the message passing to Update thread
1026 application.SendNotification();
1027 application.Render();
1028 application.Render();
1030 // Check everything is ok after last actor is removed
1032 stage.Remove( actorA );
1033 application.SendNotification();
1034 application.Render();
1035 application.Render();
1039 int UtcDaliCustomActorAddDuringOnStageDisconnection(void)
1041 TestApplication application;
1042 tet_infoline("Testing Actor::Add behaviour during Dali::CustomActor::OnStageDisonnection() callback");
1044 Stage stage = Stage::GetCurrent();
1046 /* The actorA is a special variant which adds a child to itself during OnStageDisconnection()
1047 * The actorB is provided as the child
1050 TestCustomActor actorB = TestCustomActor::New();
1051 actorB.SetName( "ActorB" );
1053 TestCustomActor actorA = TestCustomActor::NewVariant3( actorB );
1054 actorA.SetName( "ActorA" );
1055 stage.Add( actorA );
1057 // Excercise the message passing to Update thread
1059 application.SendNotification();
1060 application.Render();
1061 application.Render();
1063 // Clear call stacks before disconnection
1064 actorA.ResetCallStack();
1065 actorB.ResetCallStack();
1066 MasterCallStack.clear();
1068 stage.Remove( actorA );
1070 // Check callback sequence
1072 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1073 DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1074 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1076 // Child was added after parent disconnection, so should not receive OnStageConnection()
1077 DALI_TEST_EQUALS( 0, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1079 DALI_TEST_EQUALS( 2, (int)(MasterCallStack.size()), TEST_LOCATION );
1081 DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 0 ], TEST_LOCATION );
1082 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 1 ], TEST_LOCATION );
1084 // Excercise the message passing to Update thread
1086 application.SendNotification();
1087 application.Render();
1088 application.Render();
1092 int UtcDaliCustomActorRemoveDuringOnStageDisconnection(void)
1094 TestApplication application;
1095 tet_infoline("Testing Actor::Remove behaviour during Dali::CustomActor::OnStageDisconnection() callback");
1097 Stage stage = Stage::GetCurrent();
1099 /* The actorA is a special variant which removes its children during OnStageDisconnection()
1100 * The actorB is provided as the child
1103 TestCustomActor actorA = TestCustomActor::NewVariant4();
1104 actorA.SetName( "ActorA" );
1105 stage.Add( actorA );
1107 TestCustomActor actorB = TestCustomActor::New();
1108 actorB.SetName( "ActorB" );
1109 actorA.Add( actorB );
1111 // Excercise the message passing to Update thread
1113 application.SendNotification();
1114 application.Render();
1115 application.Render();
1117 // Clear call stacks before disconnection
1118 actorA.ResetCallStack();
1119 actorB.ResetCallStack();
1120 MasterCallStack.clear();
1122 stage.Remove( actorA );
1124 // Check callback sequence
1126 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1127 DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1128 DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1130 DALI_TEST_EQUALS( 1, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1131 DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1133 DALI_TEST_EQUALS( 3, (int)(MasterCallStack.size()), TEST_LOCATION );
1135 DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 0 ], TEST_LOCATION );
1136 DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 1 ], TEST_LOCATION );
1137 DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 2 ], TEST_LOCATION );
1139 // Excercise the message passing to Update thread
1141 application.SendNotification();
1142 application.Render();
1143 application.Render();
1147 int UtcDaliCustomActorRemoveParentDuringOnStageConnection(void)
1149 TestApplication application;
1150 tet_infoline("Weird test where child removes its own parent from Stage during Dali::CustomActor::OnStageConnection() callback");
1152 Stage stage = Stage::GetCurrent();
1154 MasterCallStack.clear();
1156 /* The actorA is the parent of actorB
1157 * The actorB is a special variant which removes its own parent during OnStageConnection()
1158 * The child actor is interrupting the parent's connection to stage, therefore the parent should not get an OnStageDisconnection()
1161 TestCustomActor actorA = TestCustomActor::New();
1162 actorA.SetName( "ActorA" );
1164 TestCustomActor actorB = TestCustomActor::NewVariant5();
1165 actorB.SetName( "ActorB" );
1166 actorA.Add( actorB );
1168 stage.Add( actorA );
1170 // Check callback sequence
1172 DALI_TEST_EQUALS( 3, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1173 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1174 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1175 DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION );
1177 DALI_TEST_EQUALS( 1, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1178 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1180 DALI_TEST_EQUALS( 4, (int)(MasterCallStack.size()), TEST_LOCATION );
1182 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 0 ], TEST_LOCATION );
1183 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION );
1184 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 2 ], TEST_LOCATION );
1185 DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 3 ], TEST_LOCATION );
1187 // Excercise the message passing to Update thread
1189 application.SendNotification();
1190 application.Render();
1191 application.Render();
1195 int UtcDaliCustomActorAddParentDuringOnStageDisconnection(void)
1197 TestApplication application;
1198 tet_infoline("Weird test where child adds its own parent to Stage during Dali::CustomActor::OnStageDisconnection() callback");
1200 Stage stage = Stage::GetCurrent();
1202 MasterCallStack.clear();
1204 /* The actorA is the parent of actorB
1205 * The actorB is a special variant which (weirdly) adds its own parent during OnStageDisconnection()
1206 * The child actor is interrupting the disconnection, such that parent should not get a OnStageDisconnection()
1209 TestCustomActor actorA = TestCustomActor::New();
1210 actorA.SetName( "ActorA" );
1211 stage.Add( actorA );
1213 TestCustomActor actorB = TestCustomActor::NewVariant6();
1214 actorB.SetName( "ActorB" );
1215 actorA.Add( actorB );
1217 stage.Remove( actorA );
1219 // Check callback sequence
1221 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1222 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1223 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1225 DALI_TEST_EQUALS( 2, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1226 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1227 DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1228 // Disconnect was interrupted, so we should only get one OnStageConnection() for actorB
1230 DALI_TEST_EQUALS( 4, (int)(MasterCallStack.size()), TEST_LOCATION );
1232 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 0 ], TEST_LOCATION );
1233 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION );
1234 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 2 ], TEST_LOCATION );
1235 DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 3 ], TEST_LOCATION );
1237 // Excercise the message passing to Update thread
1239 application.SendNotification();
1240 application.Render();
1241 application.Render();
1245 int UtcDaliCustomActorOnChildAddRemove(void)
1247 TestApplication application;
1248 tet_infoline("Testing Dali::CustomActor::OnChildAdd() & OnChildRemove()");
1250 TestCustomActor custom = TestCustomActor::New();
1251 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1253 Actor aChild = Actor::New();
1254 custom.Add( aChild );
1256 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1257 DALI_TEST_EQUALS( "OnChildAdd", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1259 custom.Remove( aChild );
1261 DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1262 DALI_TEST_EQUALS( "OnChildRemove", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1266 int UtcDaliCustomActorReparentDuringOnChildAdd(void)
1268 TestApplication application;
1269 tet_infoline("Testing Actor:Add (reparenting) behaviour during Dali::CustomActor::OnChildAdd() callback");
1271 Stage stage = Stage::GetCurrent();
1273 MasterCallStack.clear();
1275 /* The actorA is a special variant which reparents children added into a separate container child
1276 * The actorB is the child of actorA
1279 TestCustomActor actorA = TestCustomActor::NewVariant7( "ActorA" );
1280 stage.Add( actorA );
1282 TestCustomActor actorB = TestCustomActor::New();
1283 actorB.SetName( "ActorB" );
1284 actorA.Add( actorB );
1286 // Check hierarchy is as follows:
1293 DALI_TEST_EQUALS( 1, (int)(actorA.GetChildCount()), TEST_LOCATION );
1295 Actor container = actorA.GetChildAt(0);
1296 Actor containerChild;
1298 DALI_TEST_CHECK( container );
1301 DALI_TEST_EQUALS( "Container", container.GetName(), TEST_LOCATION );
1302 DALI_TEST_EQUALS( 1, (int)(container.GetChildCount()), TEST_LOCATION );
1303 containerChild = container.GetChildAt(0);
1306 DALI_TEST_CHECK( containerChild );
1307 if ( containerChild )
1309 DALI_TEST_EQUALS( "ActorB", containerChild.GetName(), TEST_LOCATION );
1310 DALI_TEST_EQUALS( 0, (int)(containerChild.GetChildCount()), TEST_LOCATION );
1313 // Check callback sequence
1315 DALI_TEST_EQUALS( 4, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1316 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION ); // The mContainer added to actorA
1317 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1318 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION ); // The actorB added to actorA
1319 DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 3 ], TEST_LOCATION );
1320 // mContainer will then receive OnChildAdd
1322 DALI_TEST_EQUALS( 3, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1323 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1324 DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1325 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 2 ], TEST_LOCATION );
1327 DALI_TEST_EQUALS( 7, (int)(MasterCallStack.size()), TEST_LOCATION );
1329 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 0 ], TEST_LOCATION );
1330 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION );
1331 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 2 ], TEST_LOCATION );
1332 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 3 ], TEST_LOCATION );
1333 DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 4 ], TEST_LOCATION );
1334 DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 5 ], TEST_LOCATION );
1335 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 6 ], TEST_LOCATION );
1337 // Excercise the message passing to Update thread
1339 application.SendNotification();
1340 application.Render();
1341 application.Render();
1346 * Test that Remove can be called (a NOOP) during the OnChildRemove
1347 * triggered when reparenting an actor
1349 int UtcDaliCustomActorRemoveDuringOnChildRemove(void)
1351 TestApplication application;
1352 tet_infoline("Testing Actor:Remove behaviour during OnChildRemove() callback triggered when reparenting");
1354 Stage stage = Stage::GetCurrent();
1356 MasterCallStack.clear();
1358 /* The childActor will be reparented from actorA to actorB
1359 * The actorA is a special variant which attempts to remove a child from actorB, during the OnChildRemove callback()
1360 * This should be a NOOP since the reparenting has not occured yet
1363 TestCustomActor actorB = TestCustomActor::New();
1364 actorB.SetName( "ActorB" );
1365 stage.Add( actorB );
1367 TestCustomActor actorA = TestCustomActor::NewVariant8( actorB );
1368 actorA.SetName( "ActorA" );
1369 stage.Add( actorA );
1371 Actor childActor = Actor::New();
1372 childActor.SetName( "Child" );
1373 // Reparent from actorA to actorB
1374 actorA.Add( childActor );
1375 actorB.Add( childActor );
1377 // Check hierarchy is as follows:
1382 DALI_TEST_EQUALS( 0, (int)(actorA.GetChildCount()), TEST_LOCATION );
1383 DALI_TEST_EQUALS( 1, (int)(actorB.GetChildCount()), TEST_LOCATION );
1384 DALI_TEST_EQUALS( 0, (int)(childActor.GetChildCount()), TEST_LOCATION );
1386 Actor child = actorB.GetChildAt(0);
1388 DALI_TEST_CHECK( child );
1391 DALI_TEST_EQUALS( "Child", child.GetName(), TEST_LOCATION );
1394 // Check callback sequence
1396 DALI_TEST_EQUALS( 3, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1397 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION ); // The mContainer added to actorA
1398 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1399 DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION ); // The actorB added to actorA
1400 // mContainer will then receive OnChildAdd
1402 DALI_TEST_EQUALS( 2, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1403 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1404 DALI_TEST_EQUALS( "OnChildAdd", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1406 DALI_TEST_EQUALS( 5, (int)(MasterCallStack.size()), TEST_LOCATION );
1408 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 0 ], TEST_LOCATION );
1409 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION );
1410 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 2 ], TEST_LOCATION );
1411 DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 3 ], TEST_LOCATION );
1412 DALI_TEST_EQUALS( "ActorB: OnChildAdd", MasterCallStack[ 4 ], TEST_LOCATION );
1414 // Excercise the message passing to Update thread
1416 application.SendNotification();
1417 application.Render();
1418 application.Render();
1422 int UtcDaliCustomActorOnPropertySet(void)
1424 TestApplication application;
1425 tet_infoline("Testing Dali::CustomActor::OnPropertySet()");
1427 TestCustomActor custom = TestCustomActor::New();
1428 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1430 custom.SetDaliProperty("yes") ;
1432 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1433 DALI_TEST_EQUALS( "OnPropertySet", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1437 int UtcDaliCustomActorOnSizeSet(void)
1439 TestApplication application;
1440 tet_infoline("Testing Dali::CustomActor::OnSizeSet()");
1442 TestCustomActor custom = TestCustomActor::New();
1443 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1445 custom.SetSize( Vector2( 9.0f, 10.0f ) );
1446 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1447 DALI_TEST_EQUALS( "OnSizeSet", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1448 DALI_TEST_EQUALS( 9.0f, custom.GetSize().width, TEST_LOCATION );
1449 DALI_TEST_EQUALS( 10.0f, custom.GetSize().height, TEST_LOCATION );
1451 custom.SetSize( Vector3( 4.0f, 5.0f, 6.0f ) );
1452 DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1453 DALI_TEST_EQUALS( "OnSizeSet", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1454 DALI_TEST_EQUALS( 4.0f, custom.GetSize().width, TEST_LOCATION );
1455 DALI_TEST_EQUALS( 5.0f, custom.GetSize().height, TEST_LOCATION );
1456 DALI_TEST_EQUALS( 6.0f, custom.GetSize().depth, TEST_LOCATION );
1460 int UtcDaliCustomActorOnSizeAnimation(void)
1462 TestApplication application;
1463 tet_infoline("Testing Dali::CustomActor::OnSizeAnimation()");
1465 TestCustomActor custom = TestCustomActor::New();
1466 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1468 Animation anim = Animation::New( 1.0f );
1469 anim.Resize( custom, Vector3( 8.0f, 9.0f, 10.0f ) );
1470 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1471 DALI_TEST_EQUALS( "OnSizeAnimation", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1472 DALI_TEST_EQUALS( 8.0f, custom.GetTargetSize().width, TEST_LOCATION );
1473 DALI_TEST_EQUALS( 9.0f, custom.GetTargetSize().height, TEST_LOCATION );
1474 DALI_TEST_EQUALS( 10.0f, custom.GetTargetSize().depth, TEST_LOCATION );
1476 anim.Resize( custom, 1.0f, 2.0f );
1477 DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1478 DALI_TEST_EQUALS( "OnSizeAnimation", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1479 DALI_TEST_EQUALS( 1.0f, custom.GetTargetSize().width, TEST_LOCATION );
1480 DALI_TEST_EQUALS( 2.0f, custom.GetTargetSize().height, TEST_LOCATION );
1484 int UtcDaliCustomActorOnTouchEvent(void)
1486 TestApplication application;
1487 tet_infoline("Testing Dali::CustomActor::OnTouchEvent()");
1489 TestCustomActor custom = TestCustomActor::New();
1490 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1492 // set size for custom actor
1493 custom.SetSize( 100, 100 );
1494 // add the custom actor to stage
1495 Stage::GetCurrent().Add( custom );
1496 custom.ResetCallStack();
1498 // Render and notify a couple of times
1499 application.SendNotification();
1500 application.Render();
1501 application.SendNotification();
1502 application.Render();
1504 // simulate a touch event
1505 Dali::TouchPoint point( 0, TouchPoint::Down, 1, 1 );
1506 Dali::Integration::TouchEvent event;
1507 event.AddPoint( point );
1508 application.ProcessEvent( event );
1510 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1511 DALI_TEST_EQUALS( "OnTouchEvent", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1515 int UtcDaliCustomActorOnMouseWheelEvent(void)
1517 TestApplication application;
1518 tet_infoline("Testing Dali::CustomActor::OnMouseWheelEvent()");
1520 TestCustomActor custom = TestCustomActor::New();
1521 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1523 // set size for custom actor
1524 custom.SetSize( 100, 100 );
1525 // add the custom actor to stage
1526 Stage::GetCurrent().Add( custom );
1527 custom.ResetCallStack();
1529 // Render and notify a couple of times
1530 application.SendNotification();
1531 application.Render();
1532 application.SendNotification();
1533 application.Render();
1535 // simulate a mouse wheel event
1536 Vector2 screenCoordinates( 10.0f, 10.0f );
1537 Integration::MouseWheelEvent event(0, 0u, screenCoordinates, 1, 1000u);
1538 application.ProcessEvent( event );
1540 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1541 DALI_TEST_EQUALS( "OnMouseWheelEvent", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1545 int UtcDaliCustomActorFindChildByAlias(void)
1547 TestApplication application;
1548 tet_infoline("Testing Dali::CustomActor::GetChildByAlias()");
1550 TestCustomActor custom = TestCustomActor::New();
1551 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1553 custom.Add(Actor::New());
1555 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1557 DALI_TEST_CHECK( !custom.FindChildByAlias("not-found") );
1559 DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1560 DALI_TEST_EQUALS( "GetChildByAlias", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1562 DALI_TEST_CHECK( custom.FindChildByAlias("found") );
1566 int UtcDaliCustomActorImplOnPropertySet(void)
1568 TestApplication application;
1569 CustomActorImpl* impl = new Impl::SimpleTestCustomActor();
1571 impl->OnPropertySet( 0, 0 );
1573 DALI_TEST_CHECK( true );
1579 int UtcDaliCustomActorGetImplementation(void)
1581 TestApplication application;
1583 TestCustomActor custom = TestCustomActor::New();
1584 CustomActorImpl& impl = custom.GetImplementation();
1585 impl.GetOwner(); // Test
1587 const TestCustomActor constCustom = TestCustomActor::New();
1588 const CustomActorImpl& constImpl = constCustom.GetImplementation();
1589 constImpl.GetOwner(); // Test
1591 DALI_TEST_CHECK( true );