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 Actor GetChildByAlias(const std::string& actorAlias)
174 AddToCallStacks("GetChildByAlias");
176 if ("found" == actorAlias)
186 virtual Vector3 GetNaturalSize()
188 return Vector3( 0.0f, 0.0f, 0.0f );
191 void SetDaliProperty(std::string s)
193 Self().SetProperty(mDaliProperty, s) ;
196 Property::Index mDaliProperty;
197 std::vector< std::string > mMethodsCalled;
203 * Variant which adds a new child during OnStageConnection
205 struct TestCustomActorVariant1 : public TestCustomActor
210 TestCustomActorVariant1( Actor childToAdd )
211 : mChildToAdd( childToAdd )
215 // From CustomActorImpl
216 virtual void OnStageConnection()
219 TestCustomActor::OnStageConnection();
222 Self().Add( mChildToAdd );
229 * Variant which removes children during OnStageConnection
231 struct TestCustomActorVariant2 : public TestCustomActor
236 TestCustomActorVariant2()
240 // From CustomActorImpl
241 virtual void OnStageConnection()
244 TestCustomActor::OnStageConnection();
246 // Remove all the children
247 for( unsigned int i=0, num=Self().GetChildCount(); i<num; ++i )
249 Self().Remove( Self().GetChildAt(0) );
255 * Variant which adds a new child during OnStageDisconnection
257 struct TestCustomActorVariant3 : public TestCustomActor
262 TestCustomActorVariant3( Actor childToAdd )
263 : mChildToAdd( childToAdd )
267 // From CustomActorImpl
268 virtual void OnStageDisconnection()
271 TestCustomActor::OnStageDisconnection();
274 Self().Add( mChildToAdd );
281 * Variant which removes children during OnStageDisconnection
283 struct TestCustomActorVariant4 : public TestCustomActor
288 TestCustomActorVariant4()
292 // From CustomActorImpl
293 virtual void OnStageDisconnection()
296 TestCustomActor::OnStageDisconnection();
298 // Remove all the children
299 for( unsigned int i=0, num=Self().GetChildCount(); i<num; ++i )
301 Self().Remove( Self().GetChildAt(0) );
307 * Variant which removes its parent from Stage during OnStageConnection
309 struct TestCustomActorVariant5 : public TestCustomActor
314 TestCustomActorVariant5()
318 // From CustomActorImpl
319 virtual void OnStageConnection()
322 TestCustomActor::OnStageConnection();
324 // Take parent off-stage
325 Actor parent = Self().GetParent();
328 Stage::GetCurrent().Remove( parent );
334 * Variant which adds its parent to Stage during OnStageDisconnection
336 struct TestCustomActorVariant6 : public TestCustomActor
341 TestCustomActorVariant6()
345 // From CustomActorImpl
346 virtual void OnStageDisconnection()
349 TestCustomActor::OnStageDisconnection();
351 // Put parent on-stage
352 Actor parent = Self().GetParent();
355 Stage::GetCurrent().Add( parent );
361 * Variant which reparents its children into a separate container
363 struct TestCustomActorVariant7 : public TestCustomActor
368 TestCustomActorVariant7()
372 virtual void OnInitialize( const char* name )
374 // We need to do this early, before the OnChildAdd is recorded
375 Self().SetName( name );
377 mContainer = Actor::New();
378 mContainer.SetName( "Container" );
379 Self().Add( mContainer );
382 // From CustomActorImpl
383 virtual void OnChildAdd(Actor& child)
386 TestCustomActor::OnChildAdd(child);
389 if ( child != mContainer )
391 mContainer.Add( child );
399 * Variant which attempts to interfere with the reparenting of a child to another container
401 struct TestCustomActorVariant8 : public TestCustomActor
406 TestCustomActorVariant8( Actor rival )
407 : mRivalContainer( rival )
411 // From CustomActorImpl
412 virtual void OnChildRemove(Actor& child)
415 TestCustomActor::OnChildRemove(child);
417 mRivalContainer.Remove( child ); // attempt to block reparenting to rival (should be a NOOP)
420 Actor mRivalContainer;
423 // Need a class that doesn't override virtual methods
424 class SimpleTestCustomActor : public CustomActorImpl
431 SimpleTestCustomActor()
432 : CustomActorImpl( true ) // requires touch
439 virtual ~SimpleTestCustomActor()
443 // From CustomActorImpl
444 virtual void OnStageConnection()
447 virtual void OnStageDisconnection()
450 virtual void OnChildAdd(Actor& child)
453 virtual void OnChildRemove(Actor& child)
456 virtual void OnSizeSet(const Vector3& targetSize)
459 virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize)
462 virtual bool OnTouchEvent(const TouchEvent& event)
466 virtual bool OnHoverEvent(const HoverEvent& event)
470 virtual bool OnMouseWheelEvent(const MouseWheelEvent& event)
474 virtual bool OnKeyEvent(const KeyEvent& event)
478 virtual void OnKeyInputFocusGained()
481 virtual void OnKeyInputFocusLost()
485 virtual Actor GetChildByAlias(const std::string& actorAlias)
490 virtual Vector3 GetNaturalSize()
492 return Vector3( 0.0f, 0.0f, 0.0f );
496 } ; // namespace Impl
503 * Test custom actor handle
505 class TestCustomActor : public CustomActor
509 static TestCustomActor New()
511 Impl::TestCustomActor* impl = new Impl::TestCustomActor;
512 TestCustomActor custom( *impl ); // takes ownership
519 static TestCustomActor NewVariant1( Actor childToAdd )
521 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant1( childToAdd );
522 TestCustomActor custom( *impl ); // takes ownership
529 static TestCustomActor NewVariant2()
531 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant2();
532 TestCustomActor custom( *impl ); // takes ownership
539 static TestCustomActor NewVariant3( Actor childToAdd )
541 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant3( childToAdd );
542 TestCustomActor custom( *impl ); // takes ownership
549 static TestCustomActor NewVariant4()
551 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant4();
552 TestCustomActor custom( *impl ); // takes ownership
559 static TestCustomActor NewVariant5()
561 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant5();
562 TestCustomActor custom( *impl ); // takes ownership
569 static TestCustomActor NewVariant6()
571 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant6();
572 TestCustomActor custom( *impl ); // takes ownership
579 static TestCustomActor NewVariant7( const char* name )
581 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant7();
582 TestCustomActor custom( *impl ); // takes ownership
584 impl->Initialize( name );
589 static TestCustomActor NewVariant8( Actor rival )
591 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant8( rival );
592 TestCustomActor custom( *impl ); // takes ownership
599 virtual ~TestCustomActor()
603 Impl::TestCustomActor& GetImpl()
605 return static_cast<Impl::TestCustomActor&>(GetImplementation());
608 std::vector< std::string >& GetMethodsCalled()
610 return GetImpl().mMethodsCalled;
613 void ResetCallStack()
615 GetImpl().ResetCallStack();
618 void SetDaliProperty(std::string s)
620 GetImpl().SetDaliProperty(s);
625 return GetImpl().mSizeSet;
628 Vector3 GetTargetSize()
630 return GetImpl().mTargetSize;
633 virtual Vector3 GetNaturalSize()
635 return Vector3( 0.0f, 0.0f, 0.0f );
640 TestCustomActor( Impl::TestCustomActor& impl ) : CustomActor( impl )
646 BaseHandle CreateActor()
648 return TestCustomActor::New();
654 int UtcDaliCustomActorDestructor(void)
656 TestApplication application;
658 CustomActor* actor = new CustomActor();
661 DALI_TEST_CHECK( true );
665 int UtcDaliCustomActorImplDestructor(void)
667 TestApplication application;
668 CustomActorImpl* actor = new Impl::TestCustomActor();
671 DALI_TEST_CHECK( true );
675 // Positive test case for a method
676 int UtcDaliCustomActorDownCast(void)
678 TestApplication application;
679 tet_infoline("Testing Dali::CustomActor::DownCast()");
681 TestCustomActor custom = TestCustomActor::New();
683 Actor anActor = Actor::New();
684 anActor.Add( custom );
686 Actor child = anActor.GetChildAt(0);
687 CustomActor customActor = CustomActor::DownCast( child );
688 DALI_TEST_CHECK( customActor );
691 DALI_TEST_CHECK( !customActor );
693 customActor = DownCast< CustomActor >( child );
694 DALI_TEST_CHECK( customActor );
698 // Negative test case for a method
699 int UtcDaliCustomActorDownCastNegative(void)
701 TestApplication application;
702 tet_infoline("Testing Dali::CustomActor::DownCast()");
704 Actor actor1 = Actor::New();
705 Actor anActor = Actor::New();
708 Actor child = anActor.GetChildAt(0);
709 CustomActor customActor = CustomActor::DownCast( child );
710 DALI_TEST_CHECK( !customActor );
712 Actor unInitialzedActor;
713 customActor = CustomActor::DownCast( unInitialzedActor );
714 DALI_TEST_CHECK( !customActor );
716 customActor = DownCast< CustomActor >( unInitialzedActor );
717 DALI_TEST_CHECK( !customActor );
721 int UtcDaliCustomActorOnStageConnectionDisconnection(void)
723 TestApplication application;
724 tet_infoline("Testing Dali::CustomActor::OnStageConnection() & OnStageDisconnection");
726 TestCustomActor custom = TestCustomActor::New();
727 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
729 // add the custom actor to stage
730 Stage::GetCurrent().Add( custom );
732 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
733 DALI_TEST_EQUALS( "OnStageConnection", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
735 Stage::GetCurrent().Remove( custom );
737 DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
738 DALI_TEST_EQUALS( "OnStageDisconnection", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
740 // Excercise the message passing to Update thread
742 application.SendNotification();
743 application.Render();
744 application.Render();
748 int UtcDaliCustomActorOnStageConnectionOrder(void)
750 TestApplication application;
751 tet_infoline("Testing Dali::CustomActor::OnStageConnection() order");
753 MasterCallStack.clear();
755 /* Build tree of actors:
763 * OnStageConnection should be received for A, B, D, E, C, and finally F
766 TestCustomActor actorA = TestCustomActor::New();
767 actorA.SetName( "ActorA" );
769 TestCustomActor actorB = TestCustomActor::New();
770 actorB.SetName( "ActorB" );
771 actorA.Add( actorB );
773 TestCustomActor actorC = TestCustomActor::New();
774 actorC.SetName( "ActorC" );
775 actorA.Add( actorC );
777 TestCustomActor actorD = TestCustomActor::New();
778 actorD.SetName( "ActorD" );
779 actorB.Add( actorD );
781 TestCustomActor actorE = TestCustomActor::New();
782 actorE.SetName( "ActorE" );
783 actorB.Add( actorE );
785 TestCustomActor actorF = TestCustomActor::New();
786 actorF.SetName( "ActorF" );
787 actorC.Add( actorF );
789 // add the custom actor to stage
790 Stage::GetCurrent().Add( actorA );
792 DALI_TEST_EQUALS( 3, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
793 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
794 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
795 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION );
797 DALI_TEST_EQUALS( 3, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
798 DALI_TEST_EQUALS( "OnChildAdd", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
799 DALI_TEST_EQUALS( "OnChildAdd", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
800 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 2 ], TEST_LOCATION );
802 DALI_TEST_EQUALS( 2, (int)(actorC.GetMethodsCalled().size()), TEST_LOCATION );
803 DALI_TEST_EQUALS( "OnChildAdd", actorC.GetMethodsCalled()[ 0 ], TEST_LOCATION );
804 DALI_TEST_EQUALS( "OnStageConnection", actorC.GetMethodsCalled()[ 1 ], TEST_LOCATION );
806 DALI_TEST_EQUALS( 1, (int)(actorD.GetMethodsCalled().size()), TEST_LOCATION );
807 DALI_TEST_EQUALS( "OnStageConnection", actorD.GetMethodsCalled()[ 0 ], TEST_LOCATION );
809 DALI_TEST_EQUALS( 1, (int)(actorE.GetMethodsCalled().size()), TEST_LOCATION );
810 DALI_TEST_EQUALS( "OnStageConnection", actorE.GetMethodsCalled()[ 0 ], TEST_LOCATION );
812 DALI_TEST_EQUALS( 1, (int)(actorF.GetMethodsCalled().size()), TEST_LOCATION );
813 DALI_TEST_EQUALS( "OnStageConnection", actorF.GetMethodsCalled()[ 0 ], TEST_LOCATION );
815 // Check sequence is correct in MasterCallStack
817 DALI_TEST_EQUALS( 3+3+2+1+1+1, (int)(MasterCallStack.size()), TEST_LOCATION );
819 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 0 ], TEST_LOCATION );
820 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 1 ], TEST_LOCATION );
821 DALI_TEST_EQUALS( "ActorB: OnChildAdd", MasterCallStack[ 2 ], TEST_LOCATION );
822 DALI_TEST_EQUALS( "ActorB: OnChildAdd", MasterCallStack[ 3 ], TEST_LOCATION );
823 DALI_TEST_EQUALS( "ActorC: OnChildAdd", MasterCallStack[ 4 ], TEST_LOCATION );
825 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 5 ], TEST_LOCATION );
826 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 6 ], TEST_LOCATION );
827 DALI_TEST_EQUALS( "ActorD: OnStageConnection", MasterCallStack[ 7 ], TEST_LOCATION );
828 DALI_TEST_EQUALS( "ActorE: OnStageConnection", MasterCallStack[ 8 ], TEST_LOCATION );
829 DALI_TEST_EQUALS( "ActorC: OnStageConnection", MasterCallStack[ 9 ], TEST_LOCATION );
830 DALI_TEST_EQUALS( "ActorF: OnStageConnection", MasterCallStack[ 10 ], TEST_LOCATION );
832 // Excercise the message passing to Update thread
834 application.SendNotification();
835 application.Render();
836 application.Render();
840 int UtcDaliCustomActorOnStageDisconnectionOrder(void)
842 TestApplication application;
843 tet_infoline("Testing Dali::CustomActor::OnStageDisconnection() order");
845 Stage stage = Stage::GetCurrent();
847 /* Build tree of actors:
855 * OnStageDisconnection should be received for D, E, B, F, C, and finally A.
858 TestCustomActor actorA = TestCustomActor::New();
859 actorA.SetName( "ActorA" );
862 TestCustomActor actorB = TestCustomActor::New();
863 actorB.SetName( "ActorB" );
864 actorA.Add( actorB );
866 TestCustomActor actorC = TestCustomActor::New();
867 actorC.SetName( "ActorC" );
868 actorA.Add( actorC );
870 TestCustomActor actorD = TestCustomActor::New();
871 actorD.SetName( "ActorD" );
872 actorB.Add( actorD );
874 TestCustomActor actorE = TestCustomActor::New();
875 actorE.SetName( "ActorE" );
876 actorB.Add( actorE );
878 TestCustomActor actorF = TestCustomActor::New();
879 actorF.SetName( "ActorF" );
880 actorC.Add( actorF );
882 // Excercise the message passing to Update thread
884 application.SendNotification();
885 application.Render();
886 application.Render();
888 // Clear call stacks before disconnection
889 actorA.ResetCallStack();
890 actorB.ResetCallStack();
891 actorC.ResetCallStack();
892 actorD.ResetCallStack();
893 actorE.ResetCallStack();
894 actorF.ResetCallStack();
895 MasterCallStack.clear();
897 stage.Remove( actorA );
899 DALI_TEST_EQUALS( 1, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
900 DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
902 DALI_TEST_EQUALS( 1, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
903 DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
905 DALI_TEST_EQUALS( 1, (int)(actorC.GetMethodsCalled().size()), TEST_LOCATION );
906 DALI_TEST_EQUALS( "OnStageDisconnection", actorC.GetMethodsCalled()[ 0 ], TEST_LOCATION );
908 DALI_TEST_EQUALS( 1, (int)(actorD.GetMethodsCalled().size()), TEST_LOCATION );
909 DALI_TEST_EQUALS( "OnStageDisconnection", actorD.GetMethodsCalled()[ 0 ], TEST_LOCATION );
911 DALI_TEST_EQUALS( 1, (int)(actorE.GetMethodsCalled().size()), TEST_LOCATION );
912 DALI_TEST_EQUALS( "OnStageDisconnection", actorE.GetMethodsCalled()[ 0 ], TEST_LOCATION );
914 DALI_TEST_EQUALS( 1, (int)(actorF.GetMethodsCalled().size()), TEST_LOCATION );
915 DALI_TEST_EQUALS( "OnStageDisconnection", actorF.GetMethodsCalled()[ 0 ], TEST_LOCATION );
917 // Check sequence is correct in MasterCallStack
919 DALI_TEST_EQUALS( 6, (int)(MasterCallStack.size()), TEST_LOCATION );
921 DALI_TEST_EQUALS( "ActorD: OnStageDisconnection", MasterCallStack[ 0 ], TEST_LOCATION );
922 DALI_TEST_EQUALS( "ActorE: OnStageDisconnection", MasterCallStack[ 1 ], TEST_LOCATION );
923 DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 2 ], TEST_LOCATION );
924 DALI_TEST_EQUALS( "ActorF: OnStageDisconnection", MasterCallStack[ 3 ], TEST_LOCATION );
925 DALI_TEST_EQUALS( "ActorC: OnStageDisconnection", MasterCallStack[ 4 ], TEST_LOCATION );
926 DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 5 ], TEST_LOCATION );
928 // Excercise the message passing to Update thread
930 application.SendNotification();
931 application.Render();
932 application.Render();
936 int UtcDaliCustomActorAddDuringOnStageConnection(void)
938 TestApplication application;
939 tet_infoline("Testing Actor::Add behaviour during Dali::CustomActor::OnStageConnection() callback");
941 Stage stage = Stage::GetCurrent();
943 MasterCallStack.clear();
945 /* The actorA is a special variant which adds a child to itself during OnStageConnection()
946 * The actorB is provided as the child
949 TestCustomActor actorB = TestCustomActor::New();
950 actorB.SetName( "ActorB" );
952 TestCustomActor actorA = TestCustomActor::NewVariant1( actorB );
953 actorA.SetName( "ActorA" );
956 // Check callback sequence
958 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
959 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
960 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION ); // Called from within OnStageConnection()
962 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
963 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
965 DALI_TEST_EQUALS( 3, (int)(MasterCallStack.size()), TEST_LOCATION );
967 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 0 ], TEST_LOCATION );
968 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION ); // Occurs during Actor::Add from within from within OnStageConnection()
969 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 2 ], TEST_LOCATION ); // Occurs after Actor::Add from within from within OnStageConnection()
971 // Excercise the message passing to Update thread
973 application.SendNotification();
974 application.Render();
975 application.Render();
977 // Check everything is ok after Actors are removed
979 stage.Remove( actorA );
980 application.SendNotification();
981 application.Render();
982 application.Render();
986 int UtcDaliCustomActorRemoveDuringOnStageConnection(void)
988 TestApplication application;
989 tet_infoline("Testing Actor::Remove behaviour during Dali::CustomActor::OnStageConnection() callback");
991 Stage stage = Stage::GetCurrent();
993 MasterCallStack.clear();
995 /* The actorA is a special variant which removes its children during OnStageConnection()
996 * Actors B & C are provided as the children
999 TestCustomActor actorA = TestCustomActor::NewVariant2();
1000 actorA.SetName( "ActorA" );
1002 TestCustomActor actorB = TestCustomActor::New();
1003 actorB.SetName( "ActorB" );
1004 actorA.Add( actorB );
1006 TestCustomActor actorC = TestCustomActor::New();
1007 actorC.SetName( "ActorC" );
1008 actorA.Add( actorC );
1010 stage.Add( actorA );
1012 // Check callback sequence
1014 DALI_TEST_EQUALS( 5, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1015 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1016 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1017 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION );
1018 DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 3 ], TEST_LOCATION ); // Called from within OnStageConnection()
1019 DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 4 ], TEST_LOCATION ); // Called from within OnStageConnection()
1021 DALI_TEST_EQUALS( 5, (int)(MasterCallStack.size()), TEST_LOCATION );
1023 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 0 ], TEST_LOCATION );
1024 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 1 ], TEST_LOCATION );
1025 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 2 ], TEST_LOCATION );
1026 DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 3 ], TEST_LOCATION );
1027 DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 4 ], TEST_LOCATION );
1029 /* Actors B & C should be removed before the point where they could receive an OnStageConnection callback
1030 * Therefore they shouldn't receive either OnStageConnection or OnStageDisconnection
1032 DALI_TEST_EQUALS( 0, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1033 DALI_TEST_EQUALS( 0, (int)(actorC.GetMethodsCalled().size()), TEST_LOCATION );
1035 // Excercise the message passing to Update thread
1037 application.SendNotification();
1038 application.Render();
1039 application.Render();
1041 // Check everything is ok after last actor is removed
1043 stage.Remove( actorA );
1044 application.SendNotification();
1045 application.Render();
1046 application.Render();
1050 int UtcDaliCustomActorAddDuringOnStageDisconnection(void)
1052 TestApplication application;
1053 tet_infoline("Testing Actor::Add behaviour during Dali::CustomActor::OnStageDisonnection() callback");
1055 Stage stage = Stage::GetCurrent();
1057 /* The actorA is a special variant which adds a child to itself during OnStageDisconnection()
1058 * The actorB is provided as the child
1061 TestCustomActor actorB = TestCustomActor::New();
1062 actorB.SetName( "ActorB" );
1064 TestCustomActor actorA = TestCustomActor::NewVariant3( actorB );
1065 actorA.SetName( "ActorA" );
1066 stage.Add( actorA );
1068 // Excercise the message passing to Update thread
1070 application.SendNotification();
1071 application.Render();
1072 application.Render();
1074 // Clear call stacks before disconnection
1075 actorA.ResetCallStack();
1076 actorB.ResetCallStack();
1077 MasterCallStack.clear();
1079 stage.Remove( actorA );
1081 // Check callback sequence
1083 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1084 DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1085 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1087 // Child was added after parent disconnection, so should not receive OnStageConnection()
1088 DALI_TEST_EQUALS( 0, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1090 DALI_TEST_EQUALS( 2, (int)(MasterCallStack.size()), TEST_LOCATION );
1092 DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 0 ], TEST_LOCATION );
1093 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 1 ], TEST_LOCATION );
1095 // Excercise the message passing to Update thread
1097 application.SendNotification();
1098 application.Render();
1099 application.Render();
1103 int UtcDaliCustomActorRemoveDuringOnStageDisconnection(void)
1105 TestApplication application;
1106 tet_infoline("Testing Actor::Remove behaviour during Dali::CustomActor::OnStageDisconnection() callback");
1108 Stage stage = Stage::GetCurrent();
1110 /* The actorA is a special variant which removes its children during OnStageDisconnection()
1111 * The actorB is provided as the child
1114 TestCustomActor actorA = TestCustomActor::NewVariant4();
1115 actorA.SetName( "ActorA" );
1116 stage.Add( actorA );
1118 TestCustomActor actorB = TestCustomActor::New();
1119 actorB.SetName( "ActorB" );
1120 actorA.Add( actorB );
1122 // Excercise the message passing to Update thread
1124 application.SendNotification();
1125 application.Render();
1126 application.Render();
1128 // Clear call stacks before disconnection
1129 actorA.ResetCallStack();
1130 actorB.ResetCallStack();
1131 MasterCallStack.clear();
1133 stage.Remove( actorA );
1135 // Check callback sequence
1137 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1138 DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1139 DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1141 DALI_TEST_EQUALS( 1, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1142 DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1144 DALI_TEST_EQUALS( 3, (int)(MasterCallStack.size()), TEST_LOCATION );
1146 DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 0 ], TEST_LOCATION );
1147 DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 1 ], TEST_LOCATION );
1148 DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 2 ], TEST_LOCATION );
1150 // Excercise the message passing to Update thread
1152 application.SendNotification();
1153 application.Render();
1154 application.Render();
1158 int UtcDaliCustomActorRemoveParentDuringOnStageConnection(void)
1160 TestApplication application;
1161 tet_infoline("Weird test where child removes its own parent from Stage during Dali::CustomActor::OnStageConnection() callback");
1163 Stage stage = Stage::GetCurrent();
1165 MasterCallStack.clear();
1167 /* The actorA is the parent of actorB
1168 * The actorB is a special variant which removes its own parent during OnStageConnection()
1169 * The child actor is interrupting the parent's connection to stage, therefore the parent should not get an OnStageDisconnection()
1172 TestCustomActor actorA = TestCustomActor::New();
1173 actorA.SetName( "ActorA" );
1175 TestCustomActor actorB = TestCustomActor::NewVariant5();
1176 actorB.SetName( "ActorB" );
1177 actorA.Add( actorB );
1179 stage.Add( actorA );
1181 // Check callback sequence
1183 DALI_TEST_EQUALS( 3, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1184 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1185 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1186 DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION );
1188 DALI_TEST_EQUALS( 1, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1189 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1191 DALI_TEST_EQUALS( 4, (int)(MasterCallStack.size()), TEST_LOCATION );
1193 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 0 ], TEST_LOCATION );
1194 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION );
1195 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 2 ], TEST_LOCATION );
1196 DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 3 ], TEST_LOCATION );
1198 // Excercise the message passing to Update thread
1200 application.SendNotification();
1201 application.Render();
1202 application.Render();
1206 int UtcDaliCustomActorAddParentDuringOnStageDisconnection(void)
1208 TestApplication application;
1209 tet_infoline("Weird test where child adds its own parent to Stage during Dali::CustomActor::OnStageDisconnection() callback");
1211 Stage stage = Stage::GetCurrent();
1213 MasterCallStack.clear();
1215 /* The actorA is the parent of actorB
1216 * The actorB is a special variant which (weirdly) adds its own parent during OnStageDisconnection()
1217 * The child actor is interrupting the disconnection, such that parent should not get a OnStageDisconnection()
1220 TestCustomActor actorA = TestCustomActor::New();
1221 actorA.SetName( "ActorA" );
1222 stage.Add( actorA );
1224 TestCustomActor actorB = TestCustomActor::NewVariant6();
1225 actorB.SetName( "ActorB" );
1226 actorA.Add( actorB );
1228 stage.Remove( actorA );
1230 // Check callback sequence
1232 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1233 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1234 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1236 DALI_TEST_EQUALS( 2, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1237 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1238 DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1239 // Disconnect was interrupted, so we should only get one OnStageConnection() for actorB
1241 DALI_TEST_EQUALS( 4, (int)(MasterCallStack.size()), TEST_LOCATION );
1243 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 0 ], TEST_LOCATION );
1244 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION );
1245 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 2 ], TEST_LOCATION );
1246 DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 3 ], TEST_LOCATION );
1248 // Excercise the message passing to Update thread
1250 application.SendNotification();
1251 application.Render();
1252 application.Render();
1256 int UtcDaliCustomActorOnChildAddRemove(void)
1258 TestApplication application;
1259 tet_infoline("Testing Dali::CustomActor::OnChildAdd() & OnChildRemove()");
1261 TestCustomActor custom = TestCustomActor::New();
1262 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1264 Actor aChild = Actor::New();
1265 custom.Add( aChild );
1267 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1268 DALI_TEST_EQUALS( "OnChildAdd", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1270 custom.Remove( aChild );
1272 DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1273 DALI_TEST_EQUALS( "OnChildRemove", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1277 int UtcDaliCustomActorReparentDuringOnChildAdd(void)
1279 TestApplication application;
1280 tet_infoline("Testing Actor:Add (reparenting) behaviour during Dali::CustomActor::OnChildAdd() callback");
1282 Stage stage = Stage::GetCurrent();
1284 MasterCallStack.clear();
1286 /* The actorA is a special variant which reparents children added into a separate container child
1287 * The actorB is the child of actorA
1290 TestCustomActor actorA = TestCustomActor::NewVariant7( "ActorA" );
1291 stage.Add( actorA );
1293 TestCustomActor actorB = TestCustomActor::New();
1294 actorB.SetName( "ActorB" );
1295 actorA.Add( actorB );
1297 // Check hierarchy is as follows:
1304 DALI_TEST_EQUALS( 1, (int)(actorA.GetChildCount()), TEST_LOCATION );
1306 Actor container = actorA.GetChildAt(0);
1307 Actor containerChild;
1309 DALI_TEST_CHECK( container );
1312 DALI_TEST_EQUALS( "Container", container.GetName(), TEST_LOCATION );
1313 DALI_TEST_EQUALS( 1, (int)(container.GetChildCount()), TEST_LOCATION );
1314 containerChild = container.GetChildAt(0);
1317 DALI_TEST_CHECK( containerChild );
1318 if ( containerChild )
1320 DALI_TEST_EQUALS( "ActorB", containerChild.GetName(), TEST_LOCATION );
1321 DALI_TEST_EQUALS( 0, (int)(containerChild.GetChildCount()), TEST_LOCATION );
1324 // Check callback sequence
1326 DALI_TEST_EQUALS( 4, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1327 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION ); // The mContainer added to actorA
1328 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1329 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION ); // The actorB added to actorA
1330 DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 3 ], TEST_LOCATION );
1331 // mContainer will then receive OnChildAdd
1333 DALI_TEST_EQUALS( 3, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1334 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1335 DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1336 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 2 ], TEST_LOCATION );
1338 DALI_TEST_EQUALS( 7, (int)(MasterCallStack.size()), TEST_LOCATION );
1340 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 0 ], TEST_LOCATION );
1341 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION );
1342 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 2 ], TEST_LOCATION );
1343 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 3 ], TEST_LOCATION );
1344 DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 4 ], TEST_LOCATION );
1345 DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 5 ], TEST_LOCATION );
1346 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 6 ], TEST_LOCATION );
1348 // Excercise the message passing to Update thread
1350 application.SendNotification();
1351 application.Render();
1352 application.Render();
1357 * Test that Remove can be called (a NOOP) during the OnChildRemove
1358 * triggered when reparenting an actor
1360 int UtcDaliCustomActorRemoveDuringOnChildRemove(void)
1362 TestApplication application;
1363 tet_infoline("Testing Actor:Remove behaviour during OnChildRemove() callback triggered when reparenting");
1365 Stage stage = Stage::GetCurrent();
1367 MasterCallStack.clear();
1369 /* The childActor will be reparented from actorA to actorB
1370 * The actorA is a special variant which attempts to remove a child from actorB, during the OnChildRemove callback()
1371 * This should be a NOOP since the reparenting has not occured yet
1374 TestCustomActor actorB = TestCustomActor::New();
1375 actorB.SetName( "ActorB" );
1376 stage.Add( actorB );
1378 TestCustomActor actorA = TestCustomActor::NewVariant8( actorB );
1379 actorA.SetName( "ActorA" );
1380 stage.Add( actorA );
1382 Actor childActor = Actor::New();
1383 childActor.SetName( "Child" );
1384 // Reparent from actorA to actorB
1385 actorA.Add( childActor );
1386 actorB.Add( childActor );
1388 // Check hierarchy is as follows:
1393 DALI_TEST_EQUALS( 0, (int)(actorA.GetChildCount()), TEST_LOCATION );
1394 DALI_TEST_EQUALS( 1, (int)(actorB.GetChildCount()), TEST_LOCATION );
1395 DALI_TEST_EQUALS( 0, (int)(childActor.GetChildCount()), TEST_LOCATION );
1397 Actor child = actorB.GetChildAt(0);
1399 DALI_TEST_CHECK( child );
1402 DALI_TEST_EQUALS( "Child", child.GetName(), TEST_LOCATION );
1405 // Check callback sequence
1407 DALI_TEST_EQUALS( 3, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1408 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION ); // The mContainer added to actorA
1409 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1410 DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION ); // The actorB added to actorA
1411 // mContainer will then receive OnChildAdd
1413 DALI_TEST_EQUALS( 2, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1414 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1415 DALI_TEST_EQUALS( "OnChildAdd", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1417 DALI_TEST_EQUALS( 5, (int)(MasterCallStack.size()), TEST_LOCATION );
1419 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 0 ], TEST_LOCATION );
1420 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION );
1421 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 2 ], TEST_LOCATION );
1422 DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 3 ], TEST_LOCATION );
1423 DALI_TEST_EQUALS( "ActorB: OnChildAdd", MasterCallStack[ 4 ], TEST_LOCATION );
1425 // Excercise the message passing to Update thread
1427 application.SendNotification();
1428 application.Render();
1429 application.Render();
1433 int UtcDaliCustomActorOnPropertySet(void)
1435 TestApplication application;
1436 tet_infoline("Testing Dali::CustomActor::OnPropertySet()");
1438 TestCustomActor custom = TestCustomActor::New();
1439 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1441 custom.SetDaliProperty("yes") ;
1443 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1444 DALI_TEST_EQUALS( "OnPropertySet", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1448 int UtcDaliCustomActorOnSizeSet(void)
1450 TestApplication application;
1451 tet_infoline("Testing Dali::CustomActor::OnSizeSet()");
1453 TestCustomActor custom = TestCustomActor::New();
1454 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1456 custom.SetSize( Vector2( 9.0f, 10.0f ) );
1457 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1458 DALI_TEST_EQUALS( "OnSizeSet", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1459 DALI_TEST_EQUALS( 9.0f, custom.GetSize().width, TEST_LOCATION );
1460 DALI_TEST_EQUALS( 10.0f, custom.GetSize().height, TEST_LOCATION );
1462 custom.SetSize( Vector3( 4.0f, 5.0f, 6.0f ) );
1463 DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1464 DALI_TEST_EQUALS( "OnSizeSet", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1465 DALI_TEST_EQUALS( 4.0f, custom.GetSize().width, TEST_LOCATION );
1466 DALI_TEST_EQUALS( 5.0f, custom.GetSize().height, TEST_LOCATION );
1467 DALI_TEST_EQUALS( 6.0f, custom.GetSize().depth, TEST_LOCATION );
1471 int UtcDaliCustomActorOnSizeAnimation(void)
1473 TestApplication application;
1474 tet_infoline("Testing Dali::CustomActor::OnSizeAnimation()");
1476 TestCustomActor custom = TestCustomActor::New();
1477 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1479 Animation anim = Animation::New( 1.0f );
1480 anim.Resize( custom, Vector3( 8.0f, 9.0f, 10.0f ) );
1481 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1482 DALI_TEST_EQUALS( "OnSizeAnimation", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1483 DALI_TEST_EQUALS( 8.0f, custom.GetTargetSize().width, TEST_LOCATION );
1484 DALI_TEST_EQUALS( 9.0f, custom.GetTargetSize().height, TEST_LOCATION );
1485 DALI_TEST_EQUALS( 10.0f, custom.GetTargetSize().depth, TEST_LOCATION );
1487 anim.Resize( custom, 1.0f, 2.0f );
1488 DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1489 DALI_TEST_EQUALS( "OnSizeAnimation", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1490 DALI_TEST_EQUALS( 1.0f, custom.GetTargetSize().width, TEST_LOCATION );
1491 DALI_TEST_EQUALS( 2.0f, custom.GetTargetSize().height, TEST_LOCATION );
1495 int UtcDaliCustomActorOnTouchEvent(void)
1497 TestApplication application;
1498 tet_infoline("Testing Dali::CustomActor::OnTouchEvent()");
1500 TestCustomActor custom = TestCustomActor::New();
1501 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1503 // set size for custom actor
1504 custom.SetSize( 100, 100 );
1505 // add the custom actor to stage
1506 Stage::GetCurrent().Add( custom );
1507 custom.ResetCallStack();
1509 // Render and notify a couple of times
1510 application.SendNotification();
1511 application.Render();
1512 application.SendNotification();
1513 application.Render();
1515 // simulate a touch event
1516 Dali::TouchPoint point( 0, TouchPoint::Down, 1, 1 );
1517 Dali::Integration::TouchEvent event;
1518 event.AddPoint( point );
1519 application.ProcessEvent( event );
1521 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1522 DALI_TEST_EQUALS( "OnTouchEvent", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1526 int UtcDaliCustomActorOnHoverEvent(void)
1528 TestApplication application;
1529 tet_infoline("Testing Dali::CustomActor::OnHoverEvent()");
1531 TestCustomActor custom = TestCustomActor::New();
1532 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1534 // set size for custom actor
1535 custom.SetSize( 100, 100 );
1536 // add the custom actor to stage
1537 Stage::GetCurrent().Add( custom );
1538 custom.ResetCallStack();
1540 // Render and notify a couple of times
1541 application.SendNotification();
1542 application.Render();
1543 application.SendNotification();
1544 application.Render();
1546 // simulate a hover event
1547 Dali::TouchPoint point( 0, TouchPoint::Motion, 1, 1 );
1548 Dali::Integration::HoverEvent event;
1549 event.AddPoint( point );
1550 application.ProcessEvent( event );
1552 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1553 DALI_TEST_EQUALS( "OnHoverEvent", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1557 int UtcDaliCustomActorOnMouseWheelEvent(void)
1559 TestApplication application;
1560 tet_infoline("Testing Dali::CustomActor::OnMouseWheelEvent()");
1562 TestCustomActor custom = TestCustomActor::New();
1563 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1565 // set size for custom actor
1566 custom.SetSize( 100, 100 );
1567 // add the custom actor to stage
1568 Stage::GetCurrent().Add( custom );
1569 custom.ResetCallStack();
1571 // Render and notify a couple of times
1572 application.SendNotification();
1573 application.Render();
1574 application.SendNotification();
1575 application.Render();
1577 // simulate a mouse wheel event
1578 Vector2 screenCoordinates( 10.0f, 10.0f );
1579 Integration::MouseWheelEvent event(0, 0u, screenCoordinates, 1, 1000u);
1580 application.ProcessEvent( event );
1582 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1583 DALI_TEST_EQUALS( "OnMouseWheelEvent", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1587 int UtcDaliCustomActorFindChildByAlias(void)
1589 TestApplication application;
1590 tet_infoline("Testing Dali::CustomActor::GetChildByAlias()");
1592 TestCustomActor custom = TestCustomActor::New();
1593 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1595 custom.Add(Actor::New());
1597 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1599 DALI_TEST_CHECK( !custom.FindChildByAlias("not-found") );
1601 DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1602 DALI_TEST_EQUALS( "GetChildByAlias", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1604 DALI_TEST_CHECK( custom.FindChildByAlias("found") );
1608 int UtcDaliCustomActorImplOnPropertySet(void)
1610 TestApplication application;
1611 CustomActorImpl* impl = new Impl::SimpleTestCustomActor();
1613 impl->OnPropertySet( 0, 0 );
1615 DALI_TEST_CHECK( true );
1621 int UtcDaliCustomActorGetImplementation(void)
1623 TestApplication application;
1625 TestCustomActor custom = TestCustomActor::New();
1626 CustomActorImpl& impl = custom.GetImplementation();
1627 impl.GetOwner(); // Test
1629 const TestCustomActor constCustom = TestCustomActor::New();
1630 const CustomActorImpl& constImpl = constCustom.GetImplementation();
1631 constImpl.GetOwner(); // Test
1633 DALI_TEST_CHECK( true );