2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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.
19 #include <dali/dali.h>
21 #include <dali/integration-api/events/touch-event-integ.h>
22 #include <dali/integration-api/events/mouse-wheel-event-integ.h>
23 #include <dali/integration-api/events/key-event-integ.h>
25 #include "dali-test-suite-utils/dali-test-suite-utils.h"
30 void custom_actor_test_startup(void)
32 test_return_value = TET_UNDEF;
35 void custom_actor_test_cleanup(void)
37 test_return_value = TET_PASS;
43 std::vector< std::string > MasterCallStack;
47 // TypeRegistry needs custom actor Implementations to have the same name (namespaces are ignored so we use one here)
51 struct TestCustomActor : public CustomActorImpl
57 : CustomActorImpl( true ), // requires touch
58 mDaliProperty( Property::INVALID_INDEX ),
59 mSizeSet( Vector3::ZERO ),
60 mTargetSize( Vector3::ZERO )
62 SetRequiresMouseWheelEvents(true);
68 virtual ~TestCustomActor()
72 void Initialize( const char* name = NULL )
74 mDaliProperty = Self().RegisterProperty( "Dali", std::string("no"), Property::READ_WRITE);
79 virtual void OnInitialize( const char* name ) {}
82 * Resets the call stack
87 mTargetSize = Vector3();
88 mMethodsCalled.clear();
91 void AddToCallStacks( const char* method )
93 mMethodsCalled.push_back( method );
95 // Combine Actor name with method string
96 std::string nameAndMethod( Self().GetName() );
97 if ( 0 == nameAndMethod.size() )
99 nameAndMethod = "Unknown: ";
103 nameAndMethod += ": ";
105 nameAndMethod += method;
107 MasterCallStack.push_back( nameAndMethod );
110 // From CustomActorImpl
111 virtual void OnStageConnection()
113 AddToCallStacks("OnStageConnection");
115 virtual void OnStageDisconnection()
117 AddToCallStacks("OnStageDisconnection");
119 virtual void OnChildAdd(Actor& child)
121 AddToCallStacks("OnChildAdd");
123 virtual void OnChildRemove(Actor& child)
125 AddToCallStacks("OnChildRemove");
127 virtual void OnPropertySet( Property::Index index, Property::Value propertyValue )
129 AddToCallStacks("OnPropertySet");
131 virtual void OnSizeSet(const Vector3& targetSize)
133 mSizeSet = targetSize;
134 AddToCallStacks("OnSizeSet");
136 virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize)
138 mTargetSize = targetSize;
139 AddToCallStacks("OnSizeAnimation");
141 virtual bool OnTouchEvent(const TouchEvent& event)
143 AddToCallStacks("OnTouchEvent");
146 virtual bool OnMouseWheelEvent(const MouseWheelEvent& event)
148 AddToCallStacks("OnMouseWheelEvent");
151 virtual bool OnKeyEvent(const KeyEvent& event)
153 AddToCallStacks("OnKeyEvent");
156 virtual void OnKeyInputFocusGained()
158 AddToCallStacks("OnKeyInputFocusGained");
160 virtual void OnKeyInputFocusLost()
162 AddToCallStacks("OnKeyInputFocusLost");
164 virtual Actor GetChildByAlias(const std::string& actorAlias)
166 AddToCallStacks("GetChildByAlias");
168 if ("found" == actorAlias)
178 void SetDaliProperty(std::string s)
180 Self().SetProperty(mDaliProperty, s) ;
183 Property::Index mDaliProperty;
184 std::vector< std::string > mMethodsCalled;
190 * Variant which adds a new child during OnStageConnection
192 struct TestCustomActorVariant1 : public TestCustomActor
197 TestCustomActorVariant1( Actor childToAdd )
198 : mChildToAdd( childToAdd )
202 // From CustomActorImpl
203 virtual void OnStageConnection()
206 TestCustomActor::OnStageConnection();
209 Self().Add( mChildToAdd );
216 * Variant which removes children during OnStageConnection
218 struct TestCustomActorVariant2 : public TestCustomActor
223 TestCustomActorVariant2()
227 // From CustomActorImpl
228 virtual void OnStageConnection()
231 TestCustomActor::OnStageConnection();
233 // Remove all the children
234 for( unsigned int i=0, num=Self().GetChildCount(); i<num; ++i )
236 Self().Remove( Self().GetChildAt(0) );
242 * Variant which adds a new child during OnStageDisconnection
244 struct TestCustomActorVariant3 : public TestCustomActor
249 TestCustomActorVariant3( Actor childToAdd )
250 : mChildToAdd( childToAdd )
254 // From CustomActorImpl
255 virtual void OnStageDisconnection()
258 TestCustomActor::OnStageDisconnection();
261 Self().Add( mChildToAdd );
268 * Variant which removes children during OnStageDisconnection
270 struct TestCustomActorVariant4 : public TestCustomActor
275 TestCustomActorVariant4()
279 // From CustomActorImpl
280 virtual void OnStageDisconnection()
283 TestCustomActor::OnStageDisconnection();
285 // Remove all the children
286 for( unsigned int i=0, num=Self().GetChildCount(); i<num; ++i )
288 Self().Remove( Self().GetChildAt(0) );
294 * Variant which removes its parent from Stage during OnStageConnection
296 struct TestCustomActorVariant5 : public TestCustomActor
301 TestCustomActorVariant5()
305 // From CustomActorImpl
306 virtual void OnStageConnection()
309 TestCustomActor::OnStageConnection();
311 // Take parent off-stage
312 Actor parent = Self().GetParent();
315 Stage::GetCurrent().Remove( parent );
321 * Variant which adds its parent to Stage during OnStageDisconnection
323 struct TestCustomActorVariant6 : public TestCustomActor
328 TestCustomActorVariant6()
332 // From CustomActorImpl
333 virtual void OnStageDisconnection()
336 TestCustomActor::OnStageDisconnection();
338 // Put parent on-stage
339 Actor parent = Self().GetParent();
342 Stage::GetCurrent().Add( parent );
348 * Variant which reparents its children into a separate container
350 struct TestCustomActorVariant7 : public TestCustomActor
355 TestCustomActorVariant7()
359 virtual void OnInitialize( const char* name )
361 // We need to do this early, before the OnChildAdd is recorded
362 Self().SetName( name );
364 mContainer = Actor::New();
365 mContainer.SetName( "Container" );
366 Self().Add( mContainer );
369 // From CustomActorImpl
370 virtual void OnChildAdd(Actor& child)
373 TestCustomActor::OnChildAdd(child);
376 if ( child != mContainer )
378 mContainer.Add( child );
386 * Variant which attempts to interfere with the reparenting of a child to another container
388 struct TestCustomActorVariant8 : public TestCustomActor
393 TestCustomActorVariant8( Actor rival )
394 : mRivalContainer( rival )
398 // From CustomActorImpl
399 virtual void OnChildRemove(Actor& child)
402 TestCustomActor::OnChildRemove(child);
404 mRivalContainer.Remove( child ); // attempt to block reparenting to rival (should be a NOOP)
407 Actor mRivalContainer;
410 // Need a class that doesn't override virtual methods
411 class SimpleTestCustomActor : public CustomActorImpl
418 SimpleTestCustomActor()
419 : CustomActorImpl( true ) // requires touch
426 virtual ~SimpleTestCustomActor()
430 // From CustomActorImpl
431 virtual void OnStageConnection()
434 virtual void OnStageDisconnection()
437 virtual void OnChildAdd(Actor& child)
440 virtual void OnChildRemove(Actor& child)
443 virtual void OnSizeSet(const Vector3& targetSize)
446 virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize)
449 virtual bool OnTouchEvent(const TouchEvent& event)
453 virtual bool OnMouseWheelEvent(const MouseWheelEvent& event)
457 virtual bool OnKeyEvent(const KeyEvent& event)
461 virtual void OnKeyInputFocusGained()
464 virtual void OnKeyInputFocusLost()
468 virtual Actor GetChildByAlias(const std::string& actorAlias)
474 } ; // namespace Impl
481 * Test custom actor handle
483 class TestCustomActor : public CustomActor
487 static TestCustomActor New()
489 Impl::TestCustomActor* impl = new Impl::TestCustomActor;
490 TestCustomActor custom( *impl ); // takes ownership
497 static TestCustomActor NewVariant1( Actor childToAdd )
499 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant1( childToAdd );
500 TestCustomActor custom( *impl ); // takes ownership
507 static TestCustomActor NewVariant2()
509 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant2();
510 TestCustomActor custom( *impl ); // takes ownership
517 static TestCustomActor NewVariant3( Actor childToAdd )
519 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant3( childToAdd );
520 TestCustomActor custom( *impl ); // takes ownership
527 static TestCustomActor NewVariant4()
529 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant4();
530 TestCustomActor custom( *impl ); // takes ownership
537 static TestCustomActor NewVariant5()
539 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant5();
540 TestCustomActor custom( *impl ); // takes ownership
547 static TestCustomActor NewVariant6()
549 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant6();
550 TestCustomActor custom( *impl ); // takes ownership
557 static TestCustomActor NewVariant7( const char* name )
559 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant7();
560 TestCustomActor custom( *impl ); // takes ownership
562 impl->Initialize( name );
567 static TestCustomActor NewVariant8( Actor rival )
569 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant8( rival );
570 TestCustomActor custom( *impl ); // takes ownership
577 virtual ~TestCustomActor()
581 Impl::TestCustomActor& GetImpl()
583 return static_cast<Impl::TestCustomActor&>(GetImplementation());
586 std::vector< std::string >& GetMethodsCalled()
588 return GetImpl().mMethodsCalled;
591 void ResetCallStack()
593 GetImpl().ResetCallStack();
596 void SetDaliProperty(std::string s)
598 GetImpl().SetDaliProperty(s);
603 return GetImpl().mSizeSet;
606 Vector3 GetTargetSize()
608 return GetImpl().mTargetSize;
613 TestCustomActor( Impl::TestCustomActor& impl ) : CustomActor( impl )
619 BaseHandle CreateActor()
621 return TestCustomActor::New();
627 int UtcDaliCustomActorDestructor(void)
629 TestApplication application;
631 CustomActor* actor = new CustomActor();
634 DALI_TEST_CHECK( true );
638 int UtcDaliCustomActorImplDestructor(void)
640 TestApplication application;
641 CustomActorImpl* actor = new Impl::TestCustomActor();
644 DALI_TEST_CHECK( true );
648 // Positive test case for a method
649 int UtcDaliCustomActorDownCast(void)
651 TestApplication application;
652 tet_infoline("Testing Dali::CustomActor::DownCast()");
654 TestCustomActor custom = TestCustomActor::New();
656 Actor anActor = Actor::New();
657 anActor.Add( custom );
659 Actor child = anActor.GetChildAt(0);
660 CustomActor customActor = CustomActor::DownCast( child );
661 DALI_TEST_CHECK( customActor );
664 DALI_TEST_CHECK( !customActor );
666 customActor = DownCast< CustomActor >( child );
667 DALI_TEST_CHECK( customActor );
671 // Negative test case for a method
672 int UtcDaliCustomActorDownCastNegative(void)
674 TestApplication application;
675 tet_infoline("Testing Dali::CustomActor::DownCast()");
677 Actor actor1 = Actor::New();
678 Actor anActor = Actor::New();
681 Actor child = anActor.GetChildAt(0);
682 CustomActor customActor = CustomActor::DownCast( child );
683 DALI_TEST_CHECK( !customActor );
685 Actor unInitialzedActor;
686 customActor = CustomActor::DownCast( unInitialzedActor );
687 DALI_TEST_CHECK( !customActor );
689 customActor = DownCast< CustomActor >( unInitialzedActor );
690 DALI_TEST_CHECK( !customActor );
694 int UtcDaliCustomActorOnStageConnectionDisconnection(void)
696 TestApplication application;
697 tet_infoline("Testing Dali::CustomActor::OnStageConnection() & OnStageDisconnection");
699 TestCustomActor custom = TestCustomActor::New();
700 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
702 // add the custom actor to stage
703 Stage::GetCurrent().Add( custom );
705 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
706 DALI_TEST_EQUALS( "OnStageConnection", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
708 Stage::GetCurrent().Remove( custom );
710 DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
711 DALI_TEST_EQUALS( "OnStageDisconnection", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
713 // Excercise the message passing to Update thread
715 application.SendNotification();
716 application.Render();
717 application.Render();
721 int UtcDaliCustomActorOnStageConnectionOrder(void)
723 TestApplication application;
724 tet_infoline("Testing Dali::CustomActor::OnStageConnection() order");
726 MasterCallStack.clear();
728 /* Build tree of actors:
736 * OnStageConnection should be received for A, B, D, E, C, and finally F
739 TestCustomActor actorA = TestCustomActor::New();
740 actorA.SetName( "ActorA" );
742 TestCustomActor actorB = TestCustomActor::New();
743 actorB.SetName( "ActorB" );
744 actorA.Add( actorB );
746 TestCustomActor actorC = TestCustomActor::New();
747 actorC.SetName( "ActorC" );
748 actorA.Add( actorC );
750 TestCustomActor actorD = TestCustomActor::New();
751 actorD.SetName( "ActorD" );
752 actorB.Add( actorD );
754 TestCustomActor actorE = TestCustomActor::New();
755 actorE.SetName( "ActorE" );
756 actorB.Add( actorE );
758 TestCustomActor actorF = TestCustomActor::New();
759 actorF.SetName( "ActorF" );
760 actorC.Add( actorF );
762 // add the custom actor to stage
763 Stage::GetCurrent().Add( actorA );
765 DALI_TEST_EQUALS( 3, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
766 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
767 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
768 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION );
770 DALI_TEST_EQUALS( 3, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
771 DALI_TEST_EQUALS( "OnChildAdd", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
772 DALI_TEST_EQUALS( "OnChildAdd", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
773 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 2 ], TEST_LOCATION );
775 DALI_TEST_EQUALS( 2, (int)(actorC.GetMethodsCalled().size()), TEST_LOCATION );
776 DALI_TEST_EQUALS( "OnChildAdd", actorC.GetMethodsCalled()[ 0 ], TEST_LOCATION );
777 DALI_TEST_EQUALS( "OnStageConnection", actorC.GetMethodsCalled()[ 1 ], TEST_LOCATION );
779 DALI_TEST_EQUALS( 1, (int)(actorD.GetMethodsCalled().size()), TEST_LOCATION );
780 DALI_TEST_EQUALS( "OnStageConnection", actorD.GetMethodsCalled()[ 0 ], TEST_LOCATION );
782 DALI_TEST_EQUALS( 1, (int)(actorE.GetMethodsCalled().size()), TEST_LOCATION );
783 DALI_TEST_EQUALS( "OnStageConnection", actorE.GetMethodsCalled()[ 0 ], TEST_LOCATION );
785 DALI_TEST_EQUALS( 1, (int)(actorF.GetMethodsCalled().size()), TEST_LOCATION );
786 DALI_TEST_EQUALS( "OnStageConnection", actorF.GetMethodsCalled()[ 0 ], TEST_LOCATION );
788 // Check sequence is correct in MasterCallStack
790 DALI_TEST_EQUALS( 3+3+2+1+1+1, (int)(MasterCallStack.size()), TEST_LOCATION );
792 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 0 ], TEST_LOCATION );
793 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 1 ], TEST_LOCATION );
794 DALI_TEST_EQUALS( "ActorB: OnChildAdd", MasterCallStack[ 2 ], TEST_LOCATION );
795 DALI_TEST_EQUALS( "ActorB: OnChildAdd", MasterCallStack[ 3 ], TEST_LOCATION );
796 DALI_TEST_EQUALS( "ActorC: OnChildAdd", MasterCallStack[ 4 ], TEST_LOCATION );
798 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 5 ], TEST_LOCATION );
799 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 6 ], TEST_LOCATION );
800 DALI_TEST_EQUALS( "ActorD: OnStageConnection", MasterCallStack[ 7 ], TEST_LOCATION );
801 DALI_TEST_EQUALS( "ActorE: OnStageConnection", MasterCallStack[ 8 ], TEST_LOCATION );
802 DALI_TEST_EQUALS( "ActorC: OnStageConnection", MasterCallStack[ 9 ], TEST_LOCATION );
803 DALI_TEST_EQUALS( "ActorF: OnStageConnection", MasterCallStack[ 10 ], TEST_LOCATION );
805 // Excercise the message passing to Update thread
807 application.SendNotification();
808 application.Render();
809 application.Render();
813 int UtcDaliCustomActorOnStageDisconnectionOrder(void)
815 TestApplication application;
816 tet_infoline("Testing Dali::CustomActor::OnStageDisconnection() order");
818 Stage stage = Stage::GetCurrent();
820 /* Build tree of actors:
828 * OnStageDisconnection should be received for D, E, B, F, C, and finally A.
831 TestCustomActor actorA = TestCustomActor::New();
832 actorA.SetName( "ActorA" );
835 TestCustomActor actorB = TestCustomActor::New();
836 actorB.SetName( "ActorB" );
837 actorA.Add( actorB );
839 TestCustomActor actorC = TestCustomActor::New();
840 actorC.SetName( "ActorC" );
841 actorA.Add( actorC );
843 TestCustomActor actorD = TestCustomActor::New();
844 actorD.SetName( "ActorD" );
845 actorB.Add( actorD );
847 TestCustomActor actorE = TestCustomActor::New();
848 actorE.SetName( "ActorE" );
849 actorB.Add( actorE );
851 TestCustomActor actorF = TestCustomActor::New();
852 actorF.SetName( "ActorF" );
853 actorC.Add( actorF );
855 // Excercise the message passing to Update thread
857 application.SendNotification();
858 application.Render();
859 application.Render();
861 // Clear call stacks before disconnection
862 actorA.ResetCallStack();
863 actorB.ResetCallStack();
864 actorC.ResetCallStack();
865 actorD.ResetCallStack();
866 actorE.ResetCallStack();
867 actorF.ResetCallStack();
868 MasterCallStack.clear();
870 stage.Remove( actorA );
872 DALI_TEST_EQUALS( 1, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
873 DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
875 DALI_TEST_EQUALS( 1, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
876 DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
878 DALI_TEST_EQUALS( 1, (int)(actorC.GetMethodsCalled().size()), TEST_LOCATION );
879 DALI_TEST_EQUALS( "OnStageDisconnection", actorC.GetMethodsCalled()[ 0 ], TEST_LOCATION );
881 DALI_TEST_EQUALS( 1, (int)(actorD.GetMethodsCalled().size()), TEST_LOCATION );
882 DALI_TEST_EQUALS( "OnStageDisconnection", actorD.GetMethodsCalled()[ 0 ], TEST_LOCATION );
884 DALI_TEST_EQUALS( 1, (int)(actorE.GetMethodsCalled().size()), TEST_LOCATION );
885 DALI_TEST_EQUALS( "OnStageDisconnection", actorE.GetMethodsCalled()[ 0 ], TEST_LOCATION );
887 DALI_TEST_EQUALS( 1, (int)(actorF.GetMethodsCalled().size()), TEST_LOCATION );
888 DALI_TEST_EQUALS( "OnStageDisconnection", actorF.GetMethodsCalled()[ 0 ], TEST_LOCATION );
890 // Check sequence is correct in MasterCallStack
892 DALI_TEST_EQUALS( 6, (int)(MasterCallStack.size()), TEST_LOCATION );
894 DALI_TEST_EQUALS( "ActorD: OnStageDisconnection", MasterCallStack[ 0 ], TEST_LOCATION );
895 DALI_TEST_EQUALS( "ActorE: OnStageDisconnection", MasterCallStack[ 1 ], TEST_LOCATION );
896 DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 2 ], TEST_LOCATION );
897 DALI_TEST_EQUALS( "ActorF: OnStageDisconnection", MasterCallStack[ 3 ], TEST_LOCATION );
898 DALI_TEST_EQUALS( "ActorC: OnStageDisconnection", MasterCallStack[ 4 ], TEST_LOCATION );
899 DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 5 ], TEST_LOCATION );
901 // Excercise the message passing to Update thread
903 application.SendNotification();
904 application.Render();
905 application.Render();
909 int UtcDaliCustomActorAddDuringOnStageConnection(void)
911 TestApplication application;
912 tet_infoline("Testing Actor::Add behaviour during Dali::CustomActor::OnStageConnection() callback");
914 Stage stage = Stage::GetCurrent();
916 MasterCallStack.clear();
918 /* The actorA is a special variant which adds a child to itself during OnStageConnection()
919 * The actorB is provided as the child
922 TestCustomActor actorB = TestCustomActor::New();
923 actorB.SetName( "ActorB" );
925 TestCustomActor actorA = TestCustomActor::NewVariant1( actorB );
926 actorA.SetName( "ActorA" );
929 // Check callback sequence
931 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
932 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
933 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION ); // Called from within OnStageConnection()
935 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
936 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
938 DALI_TEST_EQUALS( 3, (int)(MasterCallStack.size()), TEST_LOCATION );
940 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 0 ], TEST_LOCATION );
941 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION ); // Occurs during Actor::Add from within from within OnStageConnection()
942 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 2 ], TEST_LOCATION ); // Occurs after Actor::Add from within from within OnStageConnection()
944 // Excercise the message passing to Update thread
946 application.SendNotification();
947 application.Render();
948 application.Render();
950 // Check everything is ok after Actors are removed
952 stage.Remove( actorA );
953 application.SendNotification();
954 application.Render();
955 application.Render();
959 int UtcDaliCustomActorRemoveDuringOnStageConnection(void)
961 TestApplication application;
962 tet_infoline("Testing Actor::Remove behaviour during Dali::CustomActor::OnStageConnection() callback");
964 Stage stage = Stage::GetCurrent();
966 MasterCallStack.clear();
968 /* The actorA is a special variant which removes its children during OnStageConnection()
969 * Actors B & C are provided as the children
972 TestCustomActor actorA = TestCustomActor::NewVariant2();
973 actorA.SetName( "ActorA" );
975 TestCustomActor actorB = TestCustomActor::New();
976 actorB.SetName( "ActorB" );
977 actorA.Add( actorB );
979 TestCustomActor actorC = TestCustomActor::New();
980 actorC.SetName( "ActorC" );
981 actorA.Add( actorC );
985 // Check callback sequence
987 DALI_TEST_EQUALS( 5, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
988 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
989 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
990 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION );
991 DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 3 ], TEST_LOCATION ); // Called from within OnStageConnection()
992 DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 4 ], TEST_LOCATION ); // Called from within OnStageConnection()
994 DALI_TEST_EQUALS( 5, (int)(MasterCallStack.size()), TEST_LOCATION );
996 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 0 ], TEST_LOCATION );
997 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 1 ], TEST_LOCATION );
998 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 2 ], TEST_LOCATION );
999 DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 3 ], TEST_LOCATION );
1000 DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 4 ], TEST_LOCATION );
1002 /* Actors B & C should be removed before the point where they could receive an OnStageConnection callback
1003 * Therefore they shouldn't receive either OnStageConnection or OnStageDisconnection
1005 DALI_TEST_EQUALS( 0, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1006 DALI_TEST_EQUALS( 0, (int)(actorC.GetMethodsCalled().size()), TEST_LOCATION );
1008 // Excercise the message passing to Update thread
1010 application.SendNotification();
1011 application.Render();
1012 application.Render();
1014 // Check everything is ok after last actor is removed
1016 stage.Remove( actorA );
1017 application.SendNotification();
1018 application.Render();
1019 application.Render();
1023 int UtcDaliCustomActorAddDuringOnStageDisconnection(void)
1025 TestApplication application;
1026 tet_infoline("Testing Actor::Add behaviour during Dali::CustomActor::OnStageDisonnection() callback");
1028 Stage stage = Stage::GetCurrent();
1030 /* The actorA is a special variant which adds a child to itself during OnStageDisconnection()
1031 * The actorB is provided as the child
1034 TestCustomActor actorB = TestCustomActor::New();
1035 actorB.SetName( "ActorB" );
1037 TestCustomActor actorA = TestCustomActor::NewVariant3( actorB );
1038 actorA.SetName( "ActorA" );
1039 stage.Add( actorA );
1041 // Excercise the message passing to Update thread
1043 application.SendNotification();
1044 application.Render();
1045 application.Render();
1047 // Clear call stacks before disconnection
1048 actorA.ResetCallStack();
1049 actorB.ResetCallStack();
1050 MasterCallStack.clear();
1052 stage.Remove( actorA );
1054 // Check callback sequence
1056 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1057 DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1058 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1060 // Child was added after parent disconnection, so should not receive OnStageConnection()
1061 DALI_TEST_EQUALS( 0, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1063 DALI_TEST_EQUALS( 2, (int)(MasterCallStack.size()), TEST_LOCATION );
1065 DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 0 ], TEST_LOCATION );
1066 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 1 ], TEST_LOCATION );
1068 // Excercise the message passing to Update thread
1070 application.SendNotification();
1071 application.Render();
1072 application.Render();
1076 int UtcDaliCustomActorRemoveDuringOnStageDisconnection(void)
1078 TestApplication application;
1079 tet_infoline("Testing Actor::Remove behaviour during Dali::CustomActor::OnStageDisconnection() callback");
1081 Stage stage = Stage::GetCurrent();
1083 /* The actorA is a special variant which removes its children during OnStageDisconnection()
1084 * The actorB is provided as the child
1087 TestCustomActor actorA = TestCustomActor::NewVariant4();
1088 actorA.SetName( "ActorA" );
1089 stage.Add( actorA );
1091 TestCustomActor actorB = TestCustomActor::New();
1092 actorB.SetName( "ActorB" );
1093 actorA.Add( actorB );
1095 // Excercise the message passing to Update thread
1097 application.SendNotification();
1098 application.Render();
1099 application.Render();
1101 // Clear call stacks before disconnection
1102 actorA.ResetCallStack();
1103 actorB.ResetCallStack();
1104 MasterCallStack.clear();
1106 stage.Remove( actorA );
1108 // Check callback sequence
1110 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1111 DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1112 DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1114 DALI_TEST_EQUALS( 1, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1115 DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1117 DALI_TEST_EQUALS( 3, (int)(MasterCallStack.size()), TEST_LOCATION );
1119 DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 0 ], TEST_LOCATION );
1120 DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 1 ], TEST_LOCATION );
1121 DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 2 ], TEST_LOCATION );
1123 // Excercise the message passing to Update thread
1125 application.SendNotification();
1126 application.Render();
1127 application.Render();
1131 int UtcDaliCustomActorRemoveParentDuringOnStageConnection(void)
1133 TestApplication application;
1134 tet_infoline("Weird test where child removes its own parent from Stage during Dali::CustomActor::OnStageConnection() callback");
1136 Stage stage = Stage::GetCurrent();
1138 MasterCallStack.clear();
1140 /* The actorA is the parent of actorB
1141 * The actorB is a special variant which removes its own parent during OnStageConnection()
1142 * The child actor is interrupting the parent's connection to stage, therefore the parent should not get an OnStageDisconnection()
1145 TestCustomActor actorA = TestCustomActor::New();
1146 actorA.SetName( "ActorA" );
1148 TestCustomActor actorB = TestCustomActor::NewVariant5();
1149 actorB.SetName( "ActorB" );
1150 actorA.Add( actorB );
1152 stage.Add( actorA );
1154 // Check callback sequence
1156 DALI_TEST_EQUALS( 3, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1157 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1158 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1159 DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION );
1161 DALI_TEST_EQUALS( 1, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1162 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1164 DALI_TEST_EQUALS( 4, (int)(MasterCallStack.size()), TEST_LOCATION );
1166 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 0 ], TEST_LOCATION );
1167 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION );
1168 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 2 ], TEST_LOCATION );
1169 DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 3 ], TEST_LOCATION );
1171 // Excercise the message passing to Update thread
1173 application.SendNotification();
1174 application.Render();
1175 application.Render();
1179 int UtcDaliCustomActorAddParentDuringOnStageDisconnection(void)
1181 TestApplication application;
1182 tet_infoline("Weird test where child adds its own parent to Stage during Dali::CustomActor::OnStageDisconnection() callback");
1184 Stage stage = Stage::GetCurrent();
1186 MasterCallStack.clear();
1188 /* The actorA is the parent of actorB
1189 * The actorB is a special variant which (weirdly) adds its own parent during OnStageDisconnection()
1190 * The child actor is interrupting the disconnection, such that parent should not get a OnStageDisconnection()
1193 TestCustomActor actorA = TestCustomActor::New();
1194 actorA.SetName( "ActorA" );
1195 stage.Add( actorA );
1197 TestCustomActor actorB = TestCustomActor::NewVariant6();
1198 actorB.SetName( "ActorB" );
1199 actorA.Add( actorB );
1201 stage.Remove( actorA );
1203 // Check callback sequence
1205 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1206 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1207 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1209 DALI_TEST_EQUALS( 2, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1210 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1211 DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1212 // Disconnect was interrupted, so we should only get one OnStageConnection() for actorB
1214 DALI_TEST_EQUALS( 4, (int)(MasterCallStack.size()), TEST_LOCATION );
1216 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 0 ], TEST_LOCATION );
1217 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION );
1218 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 2 ], TEST_LOCATION );
1219 DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 3 ], TEST_LOCATION );
1221 // Excercise the message passing to Update thread
1223 application.SendNotification();
1224 application.Render();
1225 application.Render();
1229 int UtcDaliCustomActorOnChildAddRemove(void)
1231 TestApplication application;
1232 tet_infoline("Testing Dali::CustomActor::OnChildAdd() & OnChildRemove()");
1234 TestCustomActor custom = TestCustomActor::New();
1235 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1237 Actor aChild = Actor::New();
1238 custom.Add( aChild );
1240 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1241 DALI_TEST_EQUALS( "OnChildAdd", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1243 custom.Remove( aChild );
1245 DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1246 DALI_TEST_EQUALS( "OnChildRemove", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1250 int UtcDaliCustomActorReparentDuringOnChildAdd(void)
1252 TestApplication application;
1253 tet_infoline("Testing Actor:Add (reparenting) behaviour during Dali::CustomActor::OnChildAdd() callback");
1255 Stage stage = Stage::GetCurrent();
1257 MasterCallStack.clear();
1259 /* The actorA is a special variant which reparents children added into a separate container child
1260 * The actorB is the child of actorA
1263 TestCustomActor actorA = TestCustomActor::NewVariant7( "ActorA" );
1264 stage.Add( actorA );
1266 TestCustomActor actorB = TestCustomActor::New();
1267 actorB.SetName( "ActorB" );
1268 actorA.Add( actorB );
1270 // Check hierarchy is as follows:
1277 DALI_TEST_EQUALS( 1, (int)(actorA.GetChildCount()), TEST_LOCATION );
1279 Actor container = actorA.GetChildAt(0);
1280 Actor containerChild;
1282 DALI_TEST_CHECK( container );
1285 DALI_TEST_EQUALS( "Container", container.GetName(), TEST_LOCATION );
1286 DALI_TEST_EQUALS( 1, (int)(container.GetChildCount()), TEST_LOCATION );
1287 containerChild = container.GetChildAt(0);
1290 DALI_TEST_CHECK( containerChild );
1291 if ( containerChild )
1293 DALI_TEST_EQUALS( "ActorB", containerChild.GetName(), TEST_LOCATION );
1294 DALI_TEST_EQUALS( 0, (int)(containerChild.GetChildCount()), TEST_LOCATION );
1297 // Check callback sequence
1299 DALI_TEST_EQUALS( 4, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1300 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION ); // The mContainer added to actorA
1301 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1302 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION ); // The actorB added to actorA
1303 DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 3 ], TEST_LOCATION );
1304 // mContainer will then receive OnChildAdd
1306 DALI_TEST_EQUALS( 3, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1307 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1308 DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1309 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 2 ], TEST_LOCATION );
1311 DALI_TEST_EQUALS( 7, (int)(MasterCallStack.size()), TEST_LOCATION );
1313 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 0 ], TEST_LOCATION );
1314 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION );
1315 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 2 ], TEST_LOCATION );
1316 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 3 ], TEST_LOCATION );
1317 DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 4 ], TEST_LOCATION );
1318 DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 5 ], TEST_LOCATION );
1319 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 6 ], TEST_LOCATION );
1321 // Excercise the message passing to Update thread
1323 application.SendNotification();
1324 application.Render();
1325 application.Render();
1330 * Test that Remove can be called (a NOOP) during the OnChildRemove
1331 * triggered when reparenting an actor
1333 int UtcDaliCustomActorRemoveDuringOnChildRemove(void)
1335 TestApplication application;
1336 tet_infoline("Testing Actor:Remove behaviour during OnChildRemove() callback triggered when reparenting");
1338 Stage stage = Stage::GetCurrent();
1340 MasterCallStack.clear();
1342 /* The childActor will be reparented from actorA to actorB
1343 * The actorA is a special variant which attempts to remove a child from actorB, during the OnChildRemove callback()
1344 * This should be a NOOP since the reparenting has not occured yet
1347 TestCustomActor actorB = TestCustomActor::New();
1348 actorB.SetName( "ActorB" );
1349 stage.Add( actorB );
1351 TestCustomActor actorA = TestCustomActor::NewVariant8( actorB );
1352 actorA.SetName( "ActorA" );
1353 stage.Add( actorA );
1355 Actor childActor = Actor::New();
1356 childActor.SetName( "Child" );
1357 // Reparent from actorA to actorB
1358 actorA.Add( childActor );
1359 actorB.Add( childActor );
1361 // Check hierarchy is as follows:
1366 DALI_TEST_EQUALS( 0, (int)(actorA.GetChildCount()), TEST_LOCATION );
1367 DALI_TEST_EQUALS( 1, (int)(actorB.GetChildCount()), TEST_LOCATION );
1368 DALI_TEST_EQUALS( 0, (int)(childActor.GetChildCount()), TEST_LOCATION );
1370 Actor child = actorB.GetChildAt(0);
1372 DALI_TEST_CHECK( child );
1375 DALI_TEST_EQUALS( "Child", child.GetName(), TEST_LOCATION );
1378 // Check callback sequence
1380 DALI_TEST_EQUALS( 3, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1381 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION ); // The mContainer added to actorA
1382 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1383 DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION ); // The actorB added to actorA
1384 // mContainer will then receive OnChildAdd
1386 DALI_TEST_EQUALS( 2, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1387 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1388 DALI_TEST_EQUALS( "OnChildAdd", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1390 DALI_TEST_EQUALS( 5, (int)(MasterCallStack.size()), TEST_LOCATION );
1392 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 0 ], TEST_LOCATION );
1393 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION );
1394 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 2 ], TEST_LOCATION );
1395 DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 3 ], TEST_LOCATION );
1396 DALI_TEST_EQUALS( "ActorB: OnChildAdd", MasterCallStack[ 4 ], TEST_LOCATION );
1398 // Excercise the message passing to Update thread
1400 application.SendNotification();
1401 application.Render();
1402 application.Render();
1406 int UtcDaliCustomActorOnPropertySet(void)
1408 TestApplication application;
1409 tet_infoline("Testing Dali::CustomActor::OnPropertySet()");
1411 TestCustomActor custom = TestCustomActor::New();
1412 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1414 custom.SetDaliProperty("yes") ;
1416 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1417 DALI_TEST_EQUALS( "OnPropertySet", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1421 int UtcDaliCustomActorOnSizeSet(void)
1423 TestApplication application;
1424 tet_infoline("Testing Dali::CustomActor::OnSizeSet()");
1426 TestCustomActor custom = TestCustomActor::New();
1427 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1429 custom.SetSize( Vector2( 9.0f, 10.0f ) );
1430 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1431 DALI_TEST_EQUALS( "OnSizeSet", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1432 DALI_TEST_EQUALS( 9.0f, custom.GetSize().width, TEST_LOCATION );
1433 DALI_TEST_EQUALS( 10.0f, custom.GetSize().height, TEST_LOCATION );
1435 custom.SetSize( Vector3( 4.0f, 5.0f, 6.0f ) );
1436 DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1437 DALI_TEST_EQUALS( "OnSizeSet", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1438 DALI_TEST_EQUALS( 4.0f, custom.GetSize().width, TEST_LOCATION );
1439 DALI_TEST_EQUALS( 5.0f, custom.GetSize().height, TEST_LOCATION );
1440 DALI_TEST_EQUALS( 6.0f, custom.GetSize().depth, TEST_LOCATION );
1444 int UtcDaliCustomActorOnSizeAnimation(void)
1446 TestApplication application;
1447 tet_infoline("Testing Dali::CustomActor::OnSizeAnimation()");
1449 TestCustomActor custom = TestCustomActor::New();
1450 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1452 Animation anim = Animation::New( 1.0f );
1453 anim.Resize( custom, Vector3( 8.0f, 9.0f, 10.0f ) );
1454 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1455 DALI_TEST_EQUALS( "OnSizeAnimation", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1456 DALI_TEST_EQUALS( 8.0f, custom.GetTargetSize().width, TEST_LOCATION );
1457 DALI_TEST_EQUALS( 9.0f, custom.GetTargetSize().height, TEST_LOCATION );
1458 DALI_TEST_EQUALS( 10.0f, custom.GetTargetSize().depth, TEST_LOCATION );
1460 anim.Resize( custom, 1.0f, 2.0f );
1461 DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1462 DALI_TEST_EQUALS( "OnSizeAnimation", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1463 DALI_TEST_EQUALS( 1.0f, custom.GetTargetSize().width, TEST_LOCATION );
1464 DALI_TEST_EQUALS( 2.0f, custom.GetTargetSize().height, TEST_LOCATION );
1468 int UtcDaliCustomActorOnTouchEvent(void)
1470 TestApplication application;
1471 tet_infoline("Testing Dali::CustomActor::OnTouchEvent()");
1473 TestCustomActor custom = TestCustomActor::New();
1474 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1476 // set size for custom actor
1477 custom.SetSize( 100, 100 );
1478 // add the custom actor to stage
1479 Stage::GetCurrent().Add( custom );
1480 custom.ResetCallStack();
1482 // Render and notify a couple of times
1483 application.SendNotification();
1484 application.Render();
1485 application.SendNotification();
1486 application.Render();
1488 // simulate a touch event
1489 Dali::TouchPoint point( 0, TouchPoint::Down, 1, 1 );
1490 Dali::Integration::TouchEvent event;
1491 event.AddPoint( point );
1492 application.ProcessEvent( event );
1494 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1495 DALI_TEST_EQUALS( "OnTouchEvent", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1499 int UtcDaliCustomActorOnMouseWheelEvent(void)
1501 TestApplication application;
1502 tet_infoline("Testing Dali::CustomActor::OnMouseWheelEvent()");
1504 TestCustomActor custom = TestCustomActor::New();
1505 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1507 // set size for custom actor
1508 custom.SetSize( 100, 100 );
1509 // add the custom actor to stage
1510 Stage::GetCurrent().Add( custom );
1511 custom.ResetCallStack();
1513 // Render and notify a couple of times
1514 application.SendNotification();
1515 application.Render();
1516 application.SendNotification();
1517 application.Render();
1519 // simulate a mouse wheel event
1520 Vector2 screenCoordinates( 10.0f, 10.0f );
1521 Integration::MouseWheelEvent event(0, 0u, screenCoordinates, 1, 1000u);
1522 application.ProcessEvent( event );
1524 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1525 DALI_TEST_EQUALS( "OnMouseWheelEvent", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1529 int UtcDaliCustomActorFindChildByAlias(void)
1531 TestApplication application;
1532 tet_infoline("Testing Dali::CustomActor::GetChildByAlias()");
1534 TestCustomActor custom = TestCustomActor::New();
1535 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1537 custom.Add(Actor::New());
1539 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1541 DALI_TEST_CHECK( !custom.FindChildByAlias("not-found") );
1543 DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1544 DALI_TEST_EQUALS( "GetChildByAlias", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1546 DALI_TEST_CHECK( custom.FindChildByAlias("found") );
1550 int UtcDaliCustomActorImplOnPropertySet(void)
1552 TestApplication application;
1553 CustomActorImpl* impl = new Impl::SimpleTestCustomActor();
1555 impl->OnPropertySet( 0, 0 );
1557 DALI_TEST_CHECK( true );
1563 int UtcDaliCustomActorGetImplementation(void)
1565 TestApplication application;
1567 TestCustomActor custom = TestCustomActor::New();
1568 CustomActorImpl& impl = custom.GetImplementation();
1569 impl.GetOwner(); // Test
1571 const TestCustomActor constCustom = TestCustomActor::New();
1572 const CustomActorImpl& constImpl = constCustom.GetImplementation();
1573 constImpl.GetOwner(); // Test
1575 DALI_TEST_CHECK( true );