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/dali.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 void SetDaliProperty(std::string s)
181 Self().SetProperty(mDaliProperty, s) ;
184 Property::Index mDaliProperty;
185 std::vector< std::string > mMethodsCalled;
191 * Variant which adds a new child during OnStageConnection
193 struct TestCustomActorVariant1 : public TestCustomActor
198 TestCustomActorVariant1( Actor childToAdd )
199 : mChildToAdd( childToAdd )
203 // From CustomActorImpl
204 virtual void OnStageConnection()
207 TestCustomActor::OnStageConnection();
210 Self().Add( mChildToAdd );
217 * Variant which removes children during OnStageConnection
219 struct TestCustomActorVariant2 : public TestCustomActor
224 TestCustomActorVariant2()
228 // From CustomActorImpl
229 virtual void OnStageConnection()
232 TestCustomActor::OnStageConnection();
234 // Remove all the children
235 for( unsigned int i=0, num=Self().GetChildCount(); i<num; ++i )
237 Self().Remove( Self().GetChildAt(0) );
243 * Variant which adds a new child during OnStageDisconnection
245 struct TestCustomActorVariant3 : public TestCustomActor
250 TestCustomActorVariant3( Actor childToAdd )
251 : mChildToAdd( childToAdd )
255 // From CustomActorImpl
256 virtual void OnStageDisconnection()
259 TestCustomActor::OnStageDisconnection();
262 Self().Add( mChildToAdd );
269 * Variant which removes children during OnStageDisconnection
271 struct TestCustomActorVariant4 : public TestCustomActor
276 TestCustomActorVariant4()
280 // From CustomActorImpl
281 virtual void OnStageDisconnection()
284 TestCustomActor::OnStageDisconnection();
286 // Remove all the children
287 for( unsigned int i=0, num=Self().GetChildCount(); i<num; ++i )
289 Self().Remove( Self().GetChildAt(0) );
295 * Variant which removes its parent from Stage during OnStageConnection
297 struct TestCustomActorVariant5 : public TestCustomActor
302 TestCustomActorVariant5()
306 // From CustomActorImpl
307 virtual void OnStageConnection()
310 TestCustomActor::OnStageConnection();
312 // Take parent off-stage
313 Actor parent = Self().GetParent();
316 Stage::GetCurrent().Remove( parent );
322 * Variant which adds its parent to Stage during OnStageDisconnection
324 struct TestCustomActorVariant6 : public TestCustomActor
329 TestCustomActorVariant6()
333 // From CustomActorImpl
334 virtual void OnStageDisconnection()
337 TestCustomActor::OnStageDisconnection();
339 // Put parent on-stage
340 Actor parent = Self().GetParent();
343 Stage::GetCurrent().Add( parent );
349 * Variant which reparents its children into a separate container
351 struct TestCustomActorVariant7 : public TestCustomActor
356 TestCustomActorVariant7()
360 virtual void OnInitialize( const char* name )
362 // We need to do this early, before the OnChildAdd is recorded
363 Self().SetName( name );
365 mContainer = Actor::New();
366 mContainer.SetName( "Container" );
367 Self().Add( mContainer );
370 // From CustomActorImpl
371 virtual void OnChildAdd(Actor& child)
374 TestCustomActor::OnChildAdd(child);
377 if ( child != mContainer )
379 mContainer.Add( child );
387 * Variant which attempts to interfere with the reparenting of a child to another container
389 struct TestCustomActorVariant8 : public TestCustomActor
394 TestCustomActorVariant8( Actor rival )
395 : mRivalContainer( rival )
399 // From CustomActorImpl
400 virtual void OnChildRemove(Actor& child)
403 TestCustomActor::OnChildRemove(child);
405 mRivalContainer.Remove( child ); // attempt to block reparenting to rival (should be a NOOP)
408 Actor mRivalContainer;
411 // Need a class that doesn't override virtual methods
412 class SimpleTestCustomActor : public CustomActorImpl
419 SimpleTestCustomActor()
420 : CustomActorImpl( true ) // requires touch
427 virtual ~SimpleTestCustomActor()
431 // From CustomActorImpl
432 virtual void OnStageConnection()
435 virtual void OnStageDisconnection()
438 virtual void OnChildAdd(Actor& child)
441 virtual void OnChildRemove(Actor& child)
444 virtual void OnSizeSet(const Vector3& targetSize)
447 virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize)
450 virtual bool OnTouchEvent(const TouchEvent& event)
454 virtual bool OnMouseWheelEvent(const MouseWheelEvent& event)
458 virtual bool OnKeyEvent(const KeyEvent& event)
462 virtual void OnKeyInputFocusGained()
465 virtual void OnKeyInputFocusLost()
469 virtual Actor GetChildByAlias(const std::string& actorAlias)
475 } ; // namespace Impl
482 * Test custom actor handle
484 class TestCustomActor : public CustomActor
488 static TestCustomActor New()
490 Impl::TestCustomActor* impl = new Impl::TestCustomActor;
491 TestCustomActor custom( *impl ); // takes ownership
498 static TestCustomActor NewVariant1( Actor childToAdd )
500 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant1( childToAdd );
501 TestCustomActor custom( *impl ); // takes ownership
508 static TestCustomActor NewVariant2()
510 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant2();
511 TestCustomActor custom( *impl ); // takes ownership
518 static TestCustomActor NewVariant3( Actor childToAdd )
520 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant3( childToAdd );
521 TestCustomActor custom( *impl ); // takes ownership
528 static TestCustomActor NewVariant4()
530 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant4();
531 TestCustomActor custom( *impl ); // takes ownership
538 static TestCustomActor NewVariant5()
540 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant5();
541 TestCustomActor custom( *impl ); // takes ownership
548 static TestCustomActor NewVariant6()
550 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant6();
551 TestCustomActor custom( *impl ); // takes ownership
558 static TestCustomActor NewVariant7( const char* name )
560 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant7();
561 TestCustomActor custom( *impl ); // takes ownership
563 impl->Initialize( name );
568 static TestCustomActor NewVariant8( Actor rival )
570 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant8( rival );
571 TestCustomActor custom( *impl ); // takes ownership
578 virtual ~TestCustomActor()
582 Impl::TestCustomActor& GetImpl()
584 return static_cast<Impl::TestCustomActor&>(GetImplementation());
587 std::vector< std::string >& GetMethodsCalled()
589 return GetImpl().mMethodsCalled;
592 void ResetCallStack()
594 GetImpl().ResetCallStack();
597 void SetDaliProperty(std::string s)
599 GetImpl().SetDaliProperty(s);
604 return GetImpl().mSizeSet;
607 Vector3 GetTargetSize()
609 return GetImpl().mTargetSize;
614 TestCustomActor( Impl::TestCustomActor& impl ) : CustomActor( impl )
620 BaseHandle CreateActor()
622 return TestCustomActor::New();
628 int UtcDaliCustomActorDestructor(void)
630 TestApplication application;
632 CustomActor* actor = new CustomActor();
635 DALI_TEST_CHECK( true );
639 int UtcDaliCustomActorImplDestructor(void)
641 TestApplication application;
642 CustomActorImpl* actor = new Impl::TestCustomActor();
645 DALI_TEST_CHECK( true );
649 // Positive test case for a method
650 int UtcDaliCustomActorDownCast(void)
652 TestApplication application;
653 tet_infoline("Testing Dali::CustomActor::DownCast()");
655 TestCustomActor custom = TestCustomActor::New();
657 Actor anActor = Actor::New();
658 anActor.Add( custom );
660 Actor child = anActor.GetChildAt(0);
661 CustomActor customActor = CustomActor::DownCast( child );
662 DALI_TEST_CHECK( customActor );
665 DALI_TEST_CHECK( !customActor );
667 customActor = DownCast< CustomActor >( child );
668 DALI_TEST_CHECK( customActor );
672 // Negative test case for a method
673 int UtcDaliCustomActorDownCastNegative(void)
675 TestApplication application;
676 tet_infoline("Testing Dali::CustomActor::DownCast()");
678 Actor actor1 = Actor::New();
679 Actor anActor = Actor::New();
682 Actor child = anActor.GetChildAt(0);
683 CustomActor customActor = CustomActor::DownCast( child );
684 DALI_TEST_CHECK( !customActor );
686 Actor unInitialzedActor;
687 customActor = CustomActor::DownCast( unInitialzedActor );
688 DALI_TEST_CHECK( !customActor );
690 customActor = DownCast< CustomActor >( unInitialzedActor );
691 DALI_TEST_CHECK( !customActor );
695 int UtcDaliCustomActorOnStageConnectionDisconnection(void)
697 TestApplication application;
698 tet_infoline("Testing Dali::CustomActor::OnStageConnection() & OnStageDisconnection");
700 TestCustomActor custom = TestCustomActor::New();
701 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
703 // add the custom actor to stage
704 Stage::GetCurrent().Add( custom );
706 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
707 DALI_TEST_EQUALS( "OnStageConnection", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
709 Stage::GetCurrent().Remove( custom );
711 DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
712 DALI_TEST_EQUALS( "OnStageDisconnection", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
714 // Excercise the message passing to Update thread
716 application.SendNotification();
717 application.Render();
718 application.Render();
722 int UtcDaliCustomActorOnStageConnectionOrder(void)
724 TestApplication application;
725 tet_infoline("Testing Dali::CustomActor::OnStageConnection() order");
727 MasterCallStack.clear();
729 /* Build tree of actors:
737 * OnStageConnection should be received for A, B, D, E, C, and finally F
740 TestCustomActor actorA = TestCustomActor::New();
741 actorA.SetName( "ActorA" );
743 TestCustomActor actorB = TestCustomActor::New();
744 actorB.SetName( "ActorB" );
745 actorA.Add( actorB );
747 TestCustomActor actorC = TestCustomActor::New();
748 actorC.SetName( "ActorC" );
749 actorA.Add( actorC );
751 TestCustomActor actorD = TestCustomActor::New();
752 actorD.SetName( "ActorD" );
753 actorB.Add( actorD );
755 TestCustomActor actorE = TestCustomActor::New();
756 actorE.SetName( "ActorE" );
757 actorB.Add( actorE );
759 TestCustomActor actorF = TestCustomActor::New();
760 actorF.SetName( "ActorF" );
761 actorC.Add( actorF );
763 // add the custom actor to stage
764 Stage::GetCurrent().Add( actorA );
766 DALI_TEST_EQUALS( 3, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
767 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
768 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
769 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION );
771 DALI_TEST_EQUALS( 3, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
772 DALI_TEST_EQUALS( "OnChildAdd", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
773 DALI_TEST_EQUALS( "OnChildAdd", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
774 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 2 ], TEST_LOCATION );
776 DALI_TEST_EQUALS( 2, (int)(actorC.GetMethodsCalled().size()), TEST_LOCATION );
777 DALI_TEST_EQUALS( "OnChildAdd", actorC.GetMethodsCalled()[ 0 ], TEST_LOCATION );
778 DALI_TEST_EQUALS( "OnStageConnection", actorC.GetMethodsCalled()[ 1 ], TEST_LOCATION );
780 DALI_TEST_EQUALS( 1, (int)(actorD.GetMethodsCalled().size()), TEST_LOCATION );
781 DALI_TEST_EQUALS( "OnStageConnection", actorD.GetMethodsCalled()[ 0 ], TEST_LOCATION );
783 DALI_TEST_EQUALS( 1, (int)(actorE.GetMethodsCalled().size()), TEST_LOCATION );
784 DALI_TEST_EQUALS( "OnStageConnection", actorE.GetMethodsCalled()[ 0 ], TEST_LOCATION );
786 DALI_TEST_EQUALS( 1, (int)(actorF.GetMethodsCalled().size()), TEST_LOCATION );
787 DALI_TEST_EQUALS( "OnStageConnection", actorF.GetMethodsCalled()[ 0 ], TEST_LOCATION );
789 // Check sequence is correct in MasterCallStack
791 DALI_TEST_EQUALS( 3+3+2+1+1+1, (int)(MasterCallStack.size()), TEST_LOCATION );
793 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 0 ], TEST_LOCATION );
794 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 1 ], TEST_LOCATION );
795 DALI_TEST_EQUALS( "ActorB: OnChildAdd", MasterCallStack[ 2 ], TEST_LOCATION );
796 DALI_TEST_EQUALS( "ActorB: OnChildAdd", MasterCallStack[ 3 ], TEST_LOCATION );
797 DALI_TEST_EQUALS( "ActorC: OnChildAdd", MasterCallStack[ 4 ], TEST_LOCATION );
799 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 5 ], TEST_LOCATION );
800 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 6 ], TEST_LOCATION );
801 DALI_TEST_EQUALS( "ActorD: OnStageConnection", MasterCallStack[ 7 ], TEST_LOCATION );
802 DALI_TEST_EQUALS( "ActorE: OnStageConnection", MasterCallStack[ 8 ], TEST_LOCATION );
803 DALI_TEST_EQUALS( "ActorC: OnStageConnection", MasterCallStack[ 9 ], TEST_LOCATION );
804 DALI_TEST_EQUALS( "ActorF: OnStageConnection", MasterCallStack[ 10 ], TEST_LOCATION );
806 // Excercise the message passing to Update thread
808 application.SendNotification();
809 application.Render();
810 application.Render();
814 int UtcDaliCustomActorOnStageDisconnectionOrder(void)
816 TestApplication application;
817 tet_infoline("Testing Dali::CustomActor::OnStageDisconnection() order");
819 Stage stage = Stage::GetCurrent();
821 /* Build tree of actors:
829 * OnStageDisconnection should be received for D, E, B, F, C, and finally A.
832 TestCustomActor actorA = TestCustomActor::New();
833 actorA.SetName( "ActorA" );
836 TestCustomActor actorB = TestCustomActor::New();
837 actorB.SetName( "ActorB" );
838 actorA.Add( actorB );
840 TestCustomActor actorC = TestCustomActor::New();
841 actorC.SetName( "ActorC" );
842 actorA.Add( actorC );
844 TestCustomActor actorD = TestCustomActor::New();
845 actorD.SetName( "ActorD" );
846 actorB.Add( actorD );
848 TestCustomActor actorE = TestCustomActor::New();
849 actorE.SetName( "ActorE" );
850 actorB.Add( actorE );
852 TestCustomActor actorF = TestCustomActor::New();
853 actorF.SetName( "ActorF" );
854 actorC.Add( actorF );
856 // Excercise the message passing to Update thread
858 application.SendNotification();
859 application.Render();
860 application.Render();
862 // Clear call stacks before disconnection
863 actorA.ResetCallStack();
864 actorB.ResetCallStack();
865 actorC.ResetCallStack();
866 actorD.ResetCallStack();
867 actorE.ResetCallStack();
868 actorF.ResetCallStack();
869 MasterCallStack.clear();
871 stage.Remove( actorA );
873 DALI_TEST_EQUALS( 1, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
874 DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
876 DALI_TEST_EQUALS( 1, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
877 DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
879 DALI_TEST_EQUALS( 1, (int)(actorC.GetMethodsCalled().size()), TEST_LOCATION );
880 DALI_TEST_EQUALS( "OnStageDisconnection", actorC.GetMethodsCalled()[ 0 ], TEST_LOCATION );
882 DALI_TEST_EQUALS( 1, (int)(actorD.GetMethodsCalled().size()), TEST_LOCATION );
883 DALI_TEST_EQUALS( "OnStageDisconnection", actorD.GetMethodsCalled()[ 0 ], TEST_LOCATION );
885 DALI_TEST_EQUALS( 1, (int)(actorE.GetMethodsCalled().size()), TEST_LOCATION );
886 DALI_TEST_EQUALS( "OnStageDisconnection", actorE.GetMethodsCalled()[ 0 ], TEST_LOCATION );
888 DALI_TEST_EQUALS( 1, (int)(actorF.GetMethodsCalled().size()), TEST_LOCATION );
889 DALI_TEST_EQUALS( "OnStageDisconnection", actorF.GetMethodsCalled()[ 0 ], TEST_LOCATION );
891 // Check sequence is correct in MasterCallStack
893 DALI_TEST_EQUALS( 6, (int)(MasterCallStack.size()), TEST_LOCATION );
895 DALI_TEST_EQUALS( "ActorD: OnStageDisconnection", MasterCallStack[ 0 ], TEST_LOCATION );
896 DALI_TEST_EQUALS( "ActorE: OnStageDisconnection", MasterCallStack[ 1 ], TEST_LOCATION );
897 DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 2 ], TEST_LOCATION );
898 DALI_TEST_EQUALS( "ActorF: OnStageDisconnection", MasterCallStack[ 3 ], TEST_LOCATION );
899 DALI_TEST_EQUALS( "ActorC: OnStageDisconnection", MasterCallStack[ 4 ], TEST_LOCATION );
900 DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 5 ], TEST_LOCATION );
902 // Excercise the message passing to Update thread
904 application.SendNotification();
905 application.Render();
906 application.Render();
910 int UtcDaliCustomActorAddDuringOnStageConnection(void)
912 TestApplication application;
913 tet_infoline("Testing Actor::Add behaviour during Dali::CustomActor::OnStageConnection() callback");
915 Stage stage = Stage::GetCurrent();
917 MasterCallStack.clear();
919 /* The actorA is a special variant which adds a child to itself during OnStageConnection()
920 * The actorB is provided as the child
923 TestCustomActor actorB = TestCustomActor::New();
924 actorB.SetName( "ActorB" );
926 TestCustomActor actorA = TestCustomActor::NewVariant1( actorB );
927 actorA.SetName( "ActorA" );
930 // Check callback sequence
932 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
933 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
934 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION ); // Called from within OnStageConnection()
936 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
937 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
939 DALI_TEST_EQUALS( 3, (int)(MasterCallStack.size()), TEST_LOCATION );
941 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 0 ], TEST_LOCATION );
942 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION ); // Occurs during Actor::Add from within from within OnStageConnection()
943 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 2 ], TEST_LOCATION ); // Occurs after Actor::Add from within from within OnStageConnection()
945 // Excercise the message passing to Update thread
947 application.SendNotification();
948 application.Render();
949 application.Render();
951 // Check everything is ok after Actors are removed
953 stage.Remove( actorA );
954 application.SendNotification();
955 application.Render();
956 application.Render();
960 int UtcDaliCustomActorRemoveDuringOnStageConnection(void)
962 TestApplication application;
963 tet_infoline("Testing Actor::Remove behaviour during Dali::CustomActor::OnStageConnection() callback");
965 Stage stage = Stage::GetCurrent();
967 MasterCallStack.clear();
969 /* The actorA is a special variant which removes its children during OnStageConnection()
970 * Actors B & C are provided as the children
973 TestCustomActor actorA = TestCustomActor::NewVariant2();
974 actorA.SetName( "ActorA" );
976 TestCustomActor actorB = TestCustomActor::New();
977 actorB.SetName( "ActorB" );
978 actorA.Add( actorB );
980 TestCustomActor actorC = TestCustomActor::New();
981 actorC.SetName( "ActorC" );
982 actorA.Add( actorC );
986 // Check callback sequence
988 DALI_TEST_EQUALS( 5, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
989 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
990 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
991 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION );
992 DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 3 ], TEST_LOCATION ); // Called from within OnStageConnection()
993 DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 4 ], TEST_LOCATION ); // Called from within OnStageConnection()
995 DALI_TEST_EQUALS( 5, (int)(MasterCallStack.size()), TEST_LOCATION );
997 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 0 ], TEST_LOCATION );
998 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 1 ], TEST_LOCATION );
999 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 2 ], TEST_LOCATION );
1000 DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 3 ], TEST_LOCATION );
1001 DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 4 ], TEST_LOCATION );
1003 /* Actors B & C should be removed before the point where they could receive an OnStageConnection callback
1004 * Therefore they shouldn't receive either OnStageConnection or OnStageDisconnection
1006 DALI_TEST_EQUALS( 0, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1007 DALI_TEST_EQUALS( 0, (int)(actorC.GetMethodsCalled().size()), TEST_LOCATION );
1009 // Excercise the message passing to Update thread
1011 application.SendNotification();
1012 application.Render();
1013 application.Render();
1015 // Check everything is ok after last actor is removed
1017 stage.Remove( actorA );
1018 application.SendNotification();
1019 application.Render();
1020 application.Render();
1024 int UtcDaliCustomActorAddDuringOnStageDisconnection(void)
1026 TestApplication application;
1027 tet_infoline("Testing Actor::Add behaviour during Dali::CustomActor::OnStageDisonnection() callback");
1029 Stage stage = Stage::GetCurrent();
1031 /* The actorA is a special variant which adds a child to itself during OnStageDisconnection()
1032 * The actorB is provided as the child
1035 TestCustomActor actorB = TestCustomActor::New();
1036 actorB.SetName( "ActorB" );
1038 TestCustomActor actorA = TestCustomActor::NewVariant3( actorB );
1039 actorA.SetName( "ActorA" );
1040 stage.Add( actorA );
1042 // Excercise the message passing to Update thread
1044 application.SendNotification();
1045 application.Render();
1046 application.Render();
1048 // Clear call stacks before disconnection
1049 actorA.ResetCallStack();
1050 actorB.ResetCallStack();
1051 MasterCallStack.clear();
1053 stage.Remove( actorA );
1055 // Check callback sequence
1057 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1058 DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1059 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1061 // Child was added after parent disconnection, so should not receive OnStageConnection()
1062 DALI_TEST_EQUALS( 0, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1064 DALI_TEST_EQUALS( 2, (int)(MasterCallStack.size()), TEST_LOCATION );
1066 DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 0 ], TEST_LOCATION );
1067 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 1 ], TEST_LOCATION );
1069 // Excercise the message passing to Update thread
1071 application.SendNotification();
1072 application.Render();
1073 application.Render();
1077 int UtcDaliCustomActorRemoveDuringOnStageDisconnection(void)
1079 TestApplication application;
1080 tet_infoline("Testing Actor::Remove behaviour during Dali::CustomActor::OnStageDisconnection() callback");
1082 Stage stage = Stage::GetCurrent();
1084 /* The actorA is a special variant which removes its children during OnStageDisconnection()
1085 * The actorB is provided as the child
1088 TestCustomActor actorA = TestCustomActor::NewVariant4();
1089 actorA.SetName( "ActorA" );
1090 stage.Add( actorA );
1092 TestCustomActor actorB = TestCustomActor::New();
1093 actorB.SetName( "ActorB" );
1094 actorA.Add( actorB );
1096 // Excercise the message passing to Update thread
1098 application.SendNotification();
1099 application.Render();
1100 application.Render();
1102 // Clear call stacks before disconnection
1103 actorA.ResetCallStack();
1104 actorB.ResetCallStack();
1105 MasterCallStack.clear();
1107 stage.Remove( actorA );
1109 // Check callback sequence
1111 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1112 DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1113 DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1115 DALI_TEST_EQUALS( 1, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1116 DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1118 DALI_TEST_EQUALS( 3, (int)(MasterCallStack.size()), TEST_LOCATION );
1120 DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 0 ], TEST_LOCATION );
1121 DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 1 ], TEST_LOCATION );
1122 DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 2 ], TEST_LOCATION );
1124 // Excercise the message passing to Update thread
1126 application.SendNotification();
1127 application.Render();
1128 application.Render();
1132 int UtcDaliCustomActorRemoveParentDuringOnStageConnection(void)
1134 TestApplication application;
1135 tet_infoline("Weird test where child removes its own parent from Stage during Dali::CustomActor::OnStageConnection() callback");
1137 Stage stage = Stage::GetCurrent();
1139 MasterCallStack.clear();
1141 /* The actorA is the parent of actorB
1142 * The actorB is a special variant which removes its own parent during OnStageConnection()
1143 * The child actor is interrupting the parent's connection to stage, therefore the parent should not get an OnStageDisconnection()
1146 TestCustomActor actorA = TestCustomActor::New();
1147 actorA.SetName( "ActorA" );
1149 TestCustomActor actorB = TestCustomActor::NewVariant5();
1150 actorB.SetName( "ActorB" );
1151 actorA.Add( actorB );
1153 stage.Add( actorA );
1155 // Check callback sequence
1157 DALI_TEST_EQUALS( 3, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1158 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1159 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1160 DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION );
1162 DALI_TEST_EQUALS( 1, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1163 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1165 DALI_TEST_EQUALS( 4, (int)(MasterCallStack.size()), TEST_LOCATION );
1167 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 0 ], TEST_LOCATION );
1168 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION );
1169 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 2 ], TEST_LOCATION );
1170 DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 3 ], TEST_LOCATION );
1172 // Excercise the message passing to Update thread
1174 application.SendNotification();
1175 application.Render();
1176 application.Render();
1180 int UtcDaliCustomActorAddParentDuringOnStageDisconnection(void)
1182 TestApplication application;
1183 tet_infoline("Weird test where child adds its own parent to Stage during Dali::CustomActor::OnStageDisconnection() callback");
1185 Stage stage = Stage::GetCurrent();
1187 MasterCallStack.clear();
1189 /* The actorA is the parent of actorB
1190 * The actorB is a special variant which (weirdly) adds its own parent during OnStageDisconnection()
1191 * The child actor is interrupting the disconnection, such that parent should not get a OnStageDisconnection()
1194 TestCustomActor actorA = TestCustomActor::New();
1195 actorA.SetName( "ActorA" );
1196 stage.Add( actorA );
1198 TestCustomActor actorB = TestCustomActor::NewVariant6();
1199 actorB.SetName( "ActorB" );
1200 actorA.Add( actorB );
1202 stage.Remove( actorA );
1204 // Check callback sequence
1206 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1207 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1208 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1210 DALI_TEST_EQUALS( 2, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1211 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1212 DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1213 // Disconnect was interrupted, so we should only get one OnStageConnection() for actorB
1215 DALI_TEST_EQUALS( 4, (int)(MasterCallStack.size()), TEST_LOCATION );
1217 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 0 ], TEST_LOCATION );
1218 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION );
1219 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 2 ], TEST_LOCATION );
1220 DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 3 ], TEST_LOCATION );
1222 // Excercise the message passing to Update thread
1224 application.SendNotification();
1225 application.Render();
1226 application.Render();
1230 int UtcDaliCustomActorOnChildAddRemove(void)
1232 TestApplication application;
1233 tet_infoline("Testing Dali::CustomActor::OnChildAdd() & OnChildRemove()");
1235 TestCustomActor custom = TestCustomActor::New();
1236 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1238 Actor aChild = Actor::New();
1239 custom.Add( aChild );
1241 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1242 DALI_TEST_EQUALS( "OnChildAdd", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1244 custom.Remove( aChild );
1246 DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1247 DALI_TEST_EQUALS( "OnChildRemove", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1251 int UtcDaliCustomActorReparentDuringOnChildAdd(void)
1253 TestApplication application;
1254 tet_infoline("Testing Actor:Add (reparenting) behaviour during Dali::CustomActor::OnChildAdd() callback");
1256 Stage stage = Stage::GetCurrent();
1258 MasterCallStack.clear();
1260 /* The actorA is a special variant which reparents children added into a separate container child
1261 * The actorB is the child of actorA
1264 TestCustomActor actorA = TestCustomActor::NewVariant7( "ActorA" );
1265 stage.Add( actorA );
1267 TestCustomActor actorB = TestCustomActor::New();
1268 actorB.SetName( "ActorB" );
1269 actorA.Add( actorB );
1271 // Check hierarchy is as follows:
1278 DALI_TEST_EQUALS( 1, (int)(actorA.GetChildCount()), TEST_LOCATION );
1280 Actor container = actorA.GetChildAt(0);
1281 Actor containerChild;
1283 DALI_TEST_CHECK( container );
1286 DALI_TEST_EQUALS( "Container", container.GetName(), TEST_LOCATION );
1287 DALI_TEST_EQUALS( 1, (int)(container.GetChildCount()), TEST_LOCATION );
1288 containerChild = container.GetChildAt(0);
1291 DALI_TEST_CHECK( containerChild );
1292 if ( containerChild )
1294 DALI_TEST_EQUALS( "ActorB", containerChild.GetName(), TEST_LOCATION );
1295 DALI_TEST_EQUALS( 0, (int)(containerChild.GetChildCount()), TEST_LOCATION );
1298 // Check callback sequence
1300 DALI_TEST_EQUALS( 4, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1301 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION ); // The mContainer added to actorA
1302 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1303 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION ); // The actorB added to actorA
1304 DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 3 ], TEST_LOCATION );
1305 // mContainer will then receive OnChildAdd
1307 DALI_TEST_EQUALS( 3, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1308 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1309 DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1310 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 2 ], TEST_LOCATION );
1312 DALI_TEST_EQUALS( 7, (int)(MasterCallStack.size()), TEST_LOCATION );
1314 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 0 ], TEST_LOCATION );
1315 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION );
1316 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 2 ], TEST_LOCATION );
1317 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 3 ], TEST_LOCATION );
1318 DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 4 ], TEST_LOCATION );
1319 DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 5 ], TEST_LOCATION );
1320 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 6 ], TEST_LOCATION );
1322 // Excercise the message passing to Update thread
1324 application.SendNotification();
1325 application.Render();
1326 application.Render();
1331 * Test that Remove can be called (a NOOP) during the OnChildRemove
1332 * triggered when reparenting an actor
1334 int UtcDaliCustomActorRemoveDuringOnChildRemove(void)
1336 TestApplication application;
1337 tet_infoline("Testing Actor:Remove behaviour during OnChildRemove() callback triggered when reparenting");
1339 Stage stage = Stage::GetCurrent();
1341 MasterCallStack.clear();
1343 /* The childActor will be reparented from actorA to actorB
1344 * The actorA is a special variant which attempts to remove a child from actorB, during the OnChildRemove callback()
1345 * This should be a NOOP since the reparenting has not occured yet
1348 TestCustomActor actorB = TestCustomActor::New();
1349 actorB.SetName( "ActorB" );
1350 stage.Add( actorB );
1352 TestCustomActor actorA = TestCustomActor::NewVariant8( actorB );
1353 actorA.SetName( "ActorA" );
1354 stage.Add( actorA );
1356 Actor childActor = Actor::New();
1357 childActor.SetName( "Child" );
1358 // Reparent from actorA to actorB
1359 actorA.Add( childActor );
1360 actorB.Add( childActor );
1362 // Check hierarchy is as follows:
1367 DALI_TEST_EQUALS( 0, (int)(actorA.GetChildCount()), TEST_LOCATION );
1368 DALI_TEST_EQUALS( 1, (int)(actorB.GetChildCount()), TEST_LOCATION );
1369 DALI_TEST_EQUALS( 0, (int)(childActor.GetChildCount()), TEST_LOCATION );
1371 Actor child = actorB.GetChildAt(0);
1373 DALI_TEST_CHECK( child );
1376 DALI_TEST_EQUALS( "Child", child.GetName(), TEST_LOCATION );
1379 // Check callback sequence
1381 DALI_TEST_EQUALS( 3, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1382 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION ); // The mContainer added to actorA
1383 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1384 DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION ); // The actorB added to actorA
1385 // mContainer will then receive OnChildAdd
1387 DALI_TEST_EQUALS( 2, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1388 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1389 DALI_TEST_EQUALS( "OnChildAdd", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1391 DALI_TEST_EQUALS( 5, (int)(MasterCallStack.size()), TEST_LOCATION );
1393 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 0 ], TEST_LOCATION );
1394 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION );
1395 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 2 ], TEST_LOCATION );
1396 DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 3 ], TEST_LOCATION );
1397 DALI_TEST_EQUALS( "ActorB: OnChildAdd", MasterCallStack[ 4 ], TEST_LOCATION );
1399 // Excercise the message passing to Update thread
1401 application.SendNotification();
1402 application.Render();
1403 application.Render();
1407 int UtcDaliCustomActorOnPropertySet(void)
1409 TestApplication application;
1410 tet_infoline("Testing Dali::CustomActor::OnPropertySet()");
1412 TestCustomActor custom = TestCustomActor::New();
1413 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1415 custom.SetDaliProperty("yes") ;
1417 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1418 DALI_TEST_EQUALS( "OnPropertySet", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1422 int UtcDaliCustomActorOnSizeSet(void)
1424 TestApplication application;
1425 tet_infoline("Testing Dali::CustomActor::OnSizeSet()");
1427 TestCustomActor custom = TestCustomActor::New();
1428 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1430 custom.SetSize( Vector2( 9.0f, 10.0f ) );
1431 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1432 DALI_TEST_EQUALS( "OnSizeSet", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1433 DALI_TEST_EQUALS( 9.0f, custom.GetSize().width, TEST_LOCATION );
1434 DALI_TEST_EQUALS( 10.0f, custom.GetSize().height, TEST_LOCATION );
1436 custom.SetSize( Vector3( 4.0f, 5.0f, 6.0f ) );
1437 DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1438 DALI_TEST_EQUALS( "OnSizeSet", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1439 DALI_TEST_EQUALS( 4.0f, custom.GetSize().width, TEST_LOCATION );
1440 DALI_TEST_EQUALS( 5.0f, custom.GetSize().height, TEST_LOCATION );
1441 DALI_TEST_EQUALS( 6.0f, custom.GetSize().depth, TEST_LOCATION );
1445 int UtcDaliCustomActorOnSizeAnimation(void)
1447 TestApplication application;
1448 tet_infoline("Testing Dali::CustomActor::OnSizeAnimation()");
1450 TestCustomActor custom = TestCustomActor::New();
1451 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1453 Animation anim = Animation::New( 1.0f );
1454 anim.Resize( custom, Vector3( 8.0f, 9.0f, 10.0f ) );
1455 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1456 DALI_TEST_EQUALS( "OnSizeAnimation", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1457 DALI_TEST_EQUALS( 8.0f, custom.GetTargetSize().width, TEST_LOCATION );
1458 DALI_TEST_EQUALS( 9.0f, custom.GetTargetSize().height, TEST_LOCATION );
1459 DALI_TEST_EQUALS( 10.0f, custom.GetTargetSize().depth, TEST_LOCATION );
1461 anim.Resize( custom, 1.0f, 2.0f );
1462 DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1463 DALI_TEST_EQUALS( "OnSizeAnimation", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1464 DALI_TEST_EQUALS( 1.0f, custom.GetTargetSize().width, TEST_LOCATION );
1465 DALI_TEST_EQUALS( 2.0f, custom.GetTargetSize().height, TEST_LOCATION );
1469 int UtcDaliCustomActorOnTouchEvent(void)
1471 TestApplication application;
1472 tet_infoline("Testing Dali::CustomActor::OnTouchEvent()");
1474 TestCustomActor custom = TestCustomActor::New();
1475 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1477 // set size for custom actor
1478 custom.SetSize( 100, 100 );
1479 // add the custom actor to stage
1480 Stage::GetCurrent().Add( custom );
1481 custom.ResetCallStack();
1483 // Render and notify a couple of times
1484 application.SendNotification();
1485 application.Render();
1486 application.SendNotification();
1487 application.Render();
1489 // simulate a touch event
1490 Dali::TouchPoint point( 0, TouchPoint::Down, 1, 1 );
1491 Dali::Integration::TouchEvent event;
1492 event.AddPoint( point );
1493 application.ProcessEvent( event );
1495 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1496 DALI_TEST_EQUALS( "OnTouchEvent", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1500 int UtcDaliCustomActorOnMouseWheelEvent(void)
1502 TestApplication application;
1503 tet_infoline("Testing Dali::CustomActor::OnMouseWheelEvent()");
1505 TestCustomActor custom = TestCustomActor::New();
1506 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1508 // set size for custom actor
1509 custom.SetSize( 100, 100 );
1510 // add the custom actor to stage
1511 Stage::GetCurrent().Add( custom );
1512 custom.ResetCallStack();
1514 // Render and notify a couple of times
1515 application.SendNotification();
1516 application.Render();
1517 application.SendNotification();
1518 application.Render();
1520 // simulate a mouse wheel event
1521 Vector2 screenCoordinates( 10.0f, 10.0f );
1522 Integration::MouseWheelEvent event(0, 0u, screenCoordinates, 1, 1000u);
1523 application.ProcessEvent( event );
1525 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1526 DALI_TEST_EQUALS( "OnMouseWheelEvent", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1530 int UtcDaliCustomActorFindChildByAlias(void)
1532 TestApplication application;
1533 tet_infoline("Testing Dali::CustomActor::GetChildByAlias()");
1535 TestCustomActor custom = TestCustomActor::New();
1536 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1538 custom.Add(Actor::New());
1540 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1542 DALI_TEST_CHECK( !custom.FindChildByAlias("not-found") );
1544 DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1545 DALI_TEST_EQUALS( "GetChildByAlias", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1547 DALI_TEST_CHECK( custom.FindChildByAlias("found") );
1551 int UtcDaliCustomActorImplOnPropertySet(void)
1553 TestApplication application;
1554 CustomActorImpl* impl = new Impl::SimpleTestCustomActor();
1556 impl->OnPropertySet( 0, 0 );
1558 DALI_TEST_CHECK( true );
1564 int UtcDaliCustomActorGetImplementation(void)
1566 TestApplication application;
1568 TestCustomActor custom = TestCustomActor::New();
1569 CustomActorImpl& impl = custom.GetImplementation();
1570 impl.GetOwner(); // Test
1572 const TestCustomActor constCustom = TestCustomActor::New();
1573 const CustomActorImpl& constImpl = constCustom.GetImplementation();
1574 constImpl.GetOwner(); // Test
1576 DALI_TEST_CHECK( true );