2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 #include <dali/public-api/dali-core.h>
22 #include <dali/integration-api/events/touch-event-integ.h>
23 #include <dali/integration-api/events/hover-event-integ.h>
24 #include <dali/integration-api/events/mouse-wheel-event-integ.h>
25 #include <dali/integration-api/events/key-event-integ.h>
27 #include "dali-test-suite-utils/dali-test-suite-utils.h"
32 void custom_actor_test_startup(void)
34 test_return_value = TET_UNDEF;
37 void custom_actor_test_cleanup(void)
39 test_return_value = TET_PASS;
45 std::vector< std::string > MasterCallStack;
49 // TypeRegistry needs custom actor Implementations to have the same name (namespaces are ignored so we use one here)
53 struct TestCustomActor : public CustomActorImpl
59 : CustomActorImpl( true ), // requires touch
60 mDaliProperty( Property::INVALID_INDEX ),
61 mSizeSet( Vector3::ZERO ),
62 mTargetSize( Vector3::ZERO )
64 SetRequiresMouseWheelEvents(true);
65 SetRequiresHoverEvents(true);
71 virtual ~TestCustomActor()
75 void Initialize( const char* name = NULL )
77 mDaliProperty = Self().RegisterProperty( "Dali", std::string("no"), Property::READ_WRITE);
82 virtual void OnInitialize( const char* name ) {}
85 * Resets the call stack
90 mTargetSize = Vector3();
91 mMethodsCalled.clear();
94 void AddToCallStacks( const char* method )
96 mMethodsCalled.push_back( method );
98 // Combine Actor name with method string
99 std::string nameAndMethod( Self().GetName() );
100 if ( 0 == nameAndMethod.size() )
102 nameAndMethod = "Unknown: ";
106 nameAndMethod += ": ";
108 nameAndMethod += method;
110 MasterCallStack.push_back( nameAndMethod );
113 // From CustomActorImpl
114 virtual void OnStageConnection()
116 AddToCallStacks("OnStageConnection");
118 virtual void OnStageDisconnection()
120 AddToCallStacks("OnStageDisconnection");
122 virtual void OnChildAdd(Actor& child)
124 AddToCallStacks("OnChildAdd");
126 virtual void OnChildRemove(Actor& child)
128 AddToCallStacks("OnChildRemove");
130 virtual void OnPropertySet( Property::Index index, Property::Value propertyValue )
132 AddToCallStacks("OnPropertySet");
134 virtual void OnSizeSet(const Vector3& targetSize)
136 mSizeSet = targetSize;
137 AddToCallStacks("OnSizeSet");
139 virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize)
141 mTargetSize = targetSize;
142 AddToCallStacks("OnSizeAnimation");
144 virtual bool OnTouchEvent(const TouchEvent& event)
146 AddToCallStacks("OnTouchEvent");
149 virtual bool OnHoverEvent(const HoverEvent& event)
151 AddToCallStacks("OnHoverEvent");
154 virtual bool OnMouseWheelEvent(const MouseWheelEvent& event)
156 AddToCallStacks("OnMouseWheelEvent");
159 virtual bool OnKeyEvent(const KeyEvent& event)
161 AddToCallStacks("OnKeyEvent");
164 virtual void OnKeyInputFocusGained()
166 AddToCallStacks("OnKeyInputFocusGained");
168 virtual void OnKeyInputFocusLost()
170 AddToCallStacks("OnKeyInputFocusLost");
172 virtual Vector3 GetNaturalSize()
174 return Vector3( 0.0f, 0.0f, 0.0f );
177 void SetDaliProperty(std::string s)
179 Self().SetProperty(mDaliProperty, s) ;
182 Property::Index mDaliProperty;
183 std::vector< std::string > mMethodsCalled;
189 * Variant which adds a new child during OnStageConnection
191 struct TestCustomActorVariant1 : public TestCustomActor
196 TestCustomActorVariant1( Actor childToAdd )
197 : mChildToAdd( childToAdd )
201 // From CustomActorImpl
202 virtual void OnStageConnection()
205 TestCustomActor::OnStageConnection();
208 Self().Add( mChildToAdd );
215 * Variant which removes children during OnStageConnection
217 struct TestCustomActorVariant2 : public TestCustomActor
222 TestCustomActorVariant2()
226 // From CustomActorImpl
227 virtual void OnStageConnection()
230 TestCustomActor::OnStageConnection();
232 // Remove all the children
233 for( unsigned int i=0, num=Self().GetChildCount(); i<num; ++i )
235 Self().Remove( Self().GetChildAt(0) );
241 * Variant which adds a new child during OnStageDisconnection
243 struct TestCustomActorVariant3 : public TestCustomActor
248 TestCustomActorVariant3( Actor childToAdd )
249 : mChildToAdd( childToAdd )
253 // From CustomActorImpl
254 virtual void OnStageDisconnection()
257 TestCustomActor::OnStageDisconnection();
260 Self().Add( mChildToAdd );
267 * Variant which removes children during OnStageDisconnection
269 struct TestCustomActorVariant4 : public TestCustomActor
274 TestCustomActorVariant4()
278 // From CustomActorImpl
279 virtual void OnStageDisconnection()
282 TestCustomActor::OnStageDisconnection();
284 // Remove all the children
285 for( unsigned int i=0, num=Self().GetChildCount(); i<num; ++i )
287 Self().Remove( Self().GetChildAt(0) );
293 * Variant which removes its parent from Stage during OnStageConnection
295 struct TestCustomActorVariant5 : public TestCustomActor
300 TestCustomActorVariant5()
304 // From CustomActorImpl
305 virtual void OnStageConnection()
308 TestCustomActor::OnStageConnection();
310 // Take parent off-stage
311 Actor parent = Self().GetParent();
314 Stage::GetCurrent().Remove( parent );
320 * Variant which adds its parent to Stage during OnStageDisconnection
322 struct TestCustomActorVariant6 : public TestCustomActor
327 TestCustomActorVariant6()
331 // From CustomActorImpl
332 virtual void OnStageDisconnection()
335 TestCustomActor::OnStageDisconnection();
337 // Put parent on-stage
338 Actor parent = Self().GetParent();
341 Stage::GetCurrent().Add( parent );
347 * Variant which reparents its children into a separate container
349 struct TestCustomActorVariant7 : public TestCustomActor
354 TestCustomActorVariant7()
358 virtual void OnInitialize( const char* name )
360 // We need to do this early, before the OnChildAdd is recorded
361 Self().SetName( name );
363 mContainer = Actor::New();
364 mContainer.SetName( "Container" );
365 Self().Add( mContainer );
368 // From CustomActorImpl
369 virtual void OnChildAdd(Actor& child)
372 TestCustomActor::OnChildAdd(child);
375 if ( child != mContainer )
377 mContainer.Add( child );
385 * Variant which attempts to interfere with the reparenting of a child to another container
387 struct TestCustomActorVariant8 : public TestCustomActor
392 TestCustomActorVariant8( Actor rival )
393 : mRivalContainer( rival )
397 // From CustomActorImpl
398 virtual void OnChildRemove(Actor& child)
401 TestCustomActor::OnChildRemove(child);
403 mRivalContainer.Remove( child ); // attempt to block reparenting to rival (should be a NOOP)
406 Actor mRivalContainer;
409 // Need a class that doesn't override virtual methods
410 class SimpleTestCustomActor : public CustomActorImpl
417 SimpleTestCustomActor()
418 : CustomActorImpl( true ) // requires touch
425 virtual ~SimpleTestCustomActor()
429 // From CustomActorImpl
430 virtual void OnStageConnection()
433 virtual void OnStageDisconnection()
436 virtual void OnChildAdd(Actor& child)
439 virtual void OnChildRemove(Actor& child)
442 virtual void OnSizeSet(const Vector3& targetSize)
445 virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize)
448 virtual bool OnTouchEvent(const TouchEvent& event)
452 virtual bool OnHoverEvent(const HoverEvent& event)
456 virtual bool OnMouseWheelEvent(const MouseWheelEvent& event)
460 virtual bool OnKeyEvent(const KeyEvent& event)
464 virtual void OnKeyInputFocusGained()
467 virtual void OnKeyInputFocusLost()
471 virtual Vector3 GetNaturalSize()
473 return Vector3( 0.0f, 0.0f, 0.0f );
477 } ; // namespace Impl
484 * Test custom actor handle
486 class TestCustomActor : public CustomActor
490 static TestCustomActor New()
492 Impl::TestCustomActor* impl = new Impl::TestCustomActor;
493 TestCustomActor custom( *impl ); // takes ownership
500 static TestCustomActor NewVariant1( Actor childToAdd )
502 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant1( childToAdd );
503 TestCustomActor custom( *impl ); // takes ownership
510 static TestCustomActor NewVariant2()
512 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant2();
513 TestCustomActor custom( *impl ); // takes ownership
520 static TestCustomActor NewVariant3( Actor childToAdd )
522 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant3( childToAdd );
523 TestCustomActor custom( *impl ); // takes ownership
530 static TestCustomActor NewVariant4()
532 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant4();
533 TestCustomActor custom( *impl ); // takes ownership
540 static TestCustomActor NewVariant5()
542 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant5();
543 TestCustomActor custom( *impl ); // takes ownership
550 static TestCustomActor NewVariant6()
552 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant6();
553 TestCustomActor custom( *impl ); // takes ownership
560 static TestCustomActor NewVariant7( const char* name )
562 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant7();
563 TestCustomActor custom( *impl ); // takes ownership
565 impl->Initialize( name );
570 static TestCustomActor NewVariant8( Actor rival )
572 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant8( rival );
573 TestCustomActor custom( *impl ); // takes ownership
580 virtual ~TestCustomActor()
584 Impl::TestCustomActor& GetImpl()
586 return static_cast<Impl::TestCustomActor&>(GetImplementation());
589 std::vector< std::string >& GetMethodsCalled()
591 return GetImpl().mMethodsCalled;
594 void ResetCallStack()
596 GetImpl().ResetCallStack();
599 void SetDaliProperty(std::string s)
601 GetImpl().SetDaliProperty(s);
606 return GetImpl().mSizeSet;
609 Vector3 GetTargetSize()
611 return GetImpl().mTargetSize;
614 virtual Vector3 GetNaturalSize()
616 return Vector3( 0.0f, 0.0f, 0.0f );
621 TestCustomActor( Impl::TestCustomActor& impl ) : CustomActor( impl )
628 using namespace Dali;
630 BaseHandle CreateActor()
632 return TestCustomActor::New();
635 Dali::TypeRegistration mType( typeid(TestCustomActor), typeid(Dali::CustomActor), CreateActor );
640 int UtcDaliCustomActorDestructor(void)
642 TestApplication application;
644 CustomActor* actor = new CustomActor();
647 DALI_TEST_CHECK( true );
651 int UtcDaliCustomActorImplDestructor(void)
653 TestApplication application;
654 CustomActorImpl* actor = new Impl::TestCustomActor();
657 DALI_TEST_CHECK( true );
661 // Positive test case for a method
662 int UtcDaliCustomActorDownCast(void)
664 TestApplication application;
665 tet_infoline("Testing Dali::CustomActor::DownCast()");
667 TestCustomActor custom = TestCustomActor::New();
669 Actor anActor = Actor::New();
670 anActor.Add( custom );
672 Actor child = anActor.GetChildAt(0);
673 CustomActor customActor = CustomActor::DownCast( child );
674 DALI_TEST_CHECK( customActor );
677 DALI_TEST_CHECK( !customActor );
679 customActor = DownCast< CustomActor >( child );
680 DALI_TEST_CHECK( customActor );
684 // Negative test case for a method
685 int UtcDaliCustomActorDownCastNegative(void)
687 TestApplication application;
688 tet_infoline("Testing Dali::CustomActor::DownCast()");
690 Actor actor1 = Actor::New();
691 Actor anActor = Actor::New();
694 Actor child = anActor.GetChildAt(0);
695 CustomActor customActor = CustomActor::DownCast( child );
696 DALI_TEST_CHECK( !customActor );
698 Actor unInitialzedActor;
699 customActor = CustomActor::DownCast( unInitialzedActor );
700 DALI_TEST_CHECK( !customActor );
702 customActor = DownCast< CustomActor >( unInitialzedActor );
703 DALI_TEST_CHECK( !customActor );
707 int UtcDaliCustomActorOnStageConnectionDisconnection(void)
709 TestApplication application;
710 tet_infoline("Testing Dali::CustomActor::OnStageConnection() & OnStageDisconnection");
712 TestCustomActor custom = TestCustomActor::New();
713 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
715 // add the custom actor to stage
716 Stage::GetCurrent().Add( custom );
718 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
719 DALI_TEST_EQUALS( "OnStageConnection", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
721 Stage::GetCurrent().Remove( custom );
723 DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
724 DALI_TEST_EQUALS( "OnStageDisconnection", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
726 // Excercise the message passing to Update thread
728 application.SendNotification();
729 application.Render();
730 application.Render();
734 int UtcDaliCustomActorOnStageConnectionOrder(void)
736 TestApplication application;
737 tet_infoline("Testing Dali::CustomActor::OnStageConnection() order");
739 MasterCallStack.clear();
741 /* Build tree of actors:
749 * OnStageConnection should be received for A, B, D, E, C, and finally F
752 TestCustomActor actorA = TestCustomActor::New();
753 actorA.SetName( "ActorA" );
755 TestCustomActor actorB = TestCustomActor::New();
756 actorB.SetName( "ActorB" );
757 actorA.Add( actorB );
759 TestCustomActor actorC = TestCustomActor::New();
760 actorC.SetName( "ActorC" );
761 actorA.Add( actorC );
763 TestCustomActor actorD = TestCustomActor::New();
764 actorD.SetName( "ActorD" );
765 actorB.Add( actorD );
767 TestCustomActor actorE = TestCustomActor::New();
768 actorE.SetName( "ActorE" );
769 actorB.Add( actorE );
771 TestCustomActor actorF = TestCustomActor::New();
772 actorF.SetName( "ActorF" );
773 actorC.Add( actorF );
775 // add the custom actor to stage
776 Stage::GetCurrent().Add( actorA );
778 DALI_TEST_EQUALS( 3, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
779 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
780 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
781 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION );
783 DALI_TEST_EQUALS( 3, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
784 DALI_TEST_EQUALS( "OnChildAdd", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
785 DALI_TEST_EQUALS( "OnChildAdd", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
786 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 2 ], TEST_LOCATION );
788 DALI_TEST_EQUALS( 2, (int)(actorC.GetMethodsCalled().size()), TEST_LOCATION );
789 DALI_TEST_EQUALS( "OnChildAdd", actorC.GetMethodsCalled()[ 0 ], TEST_LOCATION );
790 DALI_TEST_EQUALS( "OnStageConnection", actorC.GetMethodsCalled()[ 1 ], TEST_LOCATION );
792 DALI_TEST_EQUALS( 1, (int)(actorD.GetMethodsCalled().size()), TEST_LOCATION );
793 DALI_TEST_EQUALS( "OnStageConnection", actorD.GetMethodsCalled()[ 0 ], TEST_LOCATION );
795 DALI_TEST_EQUALS( 1, (int)(actorE.GetMethodsCalled().size()), TEST_LOCATION );
796 DALI_TEST_EQUALS( "OnStageConnection", actorE.GetMethodsCalled()[ 0 ], TEST_LOCATION );
798 DALI_TEST_EQUALS( 1, (int)(actorF.GetMethodsCalled().size()), TEST_LOCATION );
799 DALI_TEST_EQUALS( "OnStageConnection", actorF.GetMethodsCalled()[ 0 ], TEST_LOCATION );
801 // Check sequence is correct in MasterCallStack
803 DALI_TEST_EQUALS( 3+3+2+1+1+1, (int)(MasterCallStack.size()), TEST_LOCATION );
805 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 0 ], TEST_LOCATION );
806 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 1 ], TEST_LOCATION );
807 DALI_TEST_EQUALS( "ActorB: OnChildAdd", MasterCallStack[ 2 ], TEST_LOCATION );
808 DALI_TEST_EQUALS( "ActorB: OnChildAdd", MasterCallStack[ 3 ], TEST_LOCATION );
809 DALI_TEST_EQUALS( "ActorC: OnChildAdd", MasterCallStack[ 4 ], TEST_LOCATION );
811 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 5 ], TEST_LOCATION );
812 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 6 ], TEST_LOCATION );
813 DALI_TEST_EQUALS( "ActorD: OnStageConnection", MasterCallStack[ 7 ], TEST_LOCATION );
814 DALI_TEST_EQUALS( "ActorE: OnStageConnection", MasterCallStack[ 8 ], TEST_LOCATION );
815 DALI_TEST_EQUALS( "ActorC: OnStageConnection", MasterCallStack[ 9 ], TEST_LOCATION );
816 DALI_TEST_EQUALS( "ActorF: OnStageConnection", MasterCallStack[ 10 ], TEST_LOCATION );
818 // Excercise the message passing to Update thread
820 application.SendNotification();
821 application.Render();
822 application.Render();
826 int UtcDaliCustomActorOnStageDisconnectionOrder(void)
828 TestApplication application;
829 tet_infoline("Testing Dali::CustomActor::OnStageDisconnection() order");
831 Stage stage = Stage::GetCurrent();
833 /* Build tree of actors:
841 * OnStageDisconnection should be received for D, E, B, F, C, and finally A.
844 TestCustomActor actorA = TestCustomActor::New();
845 actorA.SetName( "ActorA" );
848 TestCustomActor actorB = TestCustomActor::New();
849 actorB.SetName( "ActorB" );
850 actorA.Add( actorB );
852 TestCustomActor actorC = TestCustomActor::New();
853 actorC.SetName( "ActorC" );
854 actorA.Add( actorC );
856 TestCustomActor actorD = TestCustomActor::New();
857 actorD.SetName( "ActorD" );
858 actorB.Add( actorD );
860 TestCustomActor actorE = TestCustomActor::New();
861 actorE.SetName( "ActorE" );
862 actorB.Add( actorE );
864 TestCustomActor actorF = TestCustomActor::New();
865 actorF.SetName( "ActorF" );
866 actorC.Add( actorF );
868 // Excercise the message passing to Update thread
870 application.SendNotification();
871 application.Render();
872 application.Render();
874 // Clear call stacks before disconnection
875 actorA.ResetCallStack();
876 actorB.ResetCallStack();
877 actorC.ResetCallStack();
878 actorD.ResetCallStack();
879 actorE.ResetCallStack();
880 actorF.ResetCallStack();
881 MasterCallStack.clear();
883 stage.Remove( actorA );
885 DALI_TEST_EQUALS( 1, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
886 DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
888 DALI_TEST_EQUALS( 1, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
889 DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
891 DALI_TEST_EQUALS( 1, (int)(actorC.GetMethodsCalled().size()), TEST_LOCATION );
892 DALI_TEST_EQUALS( "OnStageDisconnection", actorC.GetMethodsCalled()[ 0 ], TEST_LOCATION );
894 DALI_TEST_EQUALS( 1, (int)(actorD.GetMethodsCalled().size()), TEST_LOCATION );
895 DALI_TEST_EQUALS( "OnStageDisconnection", actorD.GetMethodsCalled()[ 0 ], TEST_LOCATION );
897 DALI_TEST_EQUALS( 1, (int)(actorE.GetMethodsCalled().size()), TEST_LOCATION );
898 DALI_TEST_EQUALS( "OnStageDisconnection", actorE.GetMethodsCalled()[ 0 ], TEST_LOCATION );
900 DALI_TEST_EQUALS( 1, (int)(actorF.GetMethodsCalled().size()), TEST_LOCATION );
901 DALI_TEST_EQUALS( "OnStageDisconnection", actorF.GetMethodsCalled()[ 0 ], TEST_LOCATION );
903 // Check sequence is correct in MasterCallStack
905 DALI_TEST_EQUALS( 6, (int)(MasterCallStack.size()), TEST_LOCATION );
907 DALI_TEST_EQUALS( "ActorD: OnStageDisconnection", MasterCallStack[ 0 ], TEST_LOCATION );
908 DALI_TEST_EQUALS( "ActorE: OnStageDisconnection", MasterCallStack[ 1 ], TEST_LOCATION );
909 DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 2 ], TEST_LOCATION );
910 DALI_TEST_EQUALS( "ActorF: OnStageDisconnection", MasterCallStack[ 3 ], TEST_LOCATION );
911 DALI_TEST_EQUALS( "ActorC: OnStageDisconnection", MasterCallStack[ 4 ], TEST_LOCATION );
912 DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 5 ], TEST_LOCATION );
914 // Excercise the message passing to Update thread
916 application.SendNotification();
917 application.Render();
918 application.Render();
922 int UtcDaliCustomActorAddDuringOnStageConnection(void)
924 TestApplication application;
925 tet_infoline("Testing Actor::Add behaviour during Dali::CustomActor::OnStageConnection() callback");
927 Stage stage = Stage::GetCurrent();
929 MasterCallStack.clear();
931 /* The actorA is a special variant which adds a child to itself during OnStageConnection()
932 * The actorB is provided as the child
935 TestCustomActor actorB = TestCustomActor::New();
936 actorB.SetName( "ActorB" );
938 TestCustomActor actorA = TestCustomActor::NewVariant1( actorB );
939 actorA.SetName( "ActorA" );
942 // Check callback sequence
944 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
945 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
946 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION ); // Called from within OnStageConnection()
948 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
949 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
951 DALI_TEST_EQUALS( 3, (int)(MasterCallStack.size()), TEST_LOCATION );
953 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 0 ], TEST_LOCATION );
954 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION ); // Occurs during Actor::Add from within from within OnStageConnection()
955 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 2 ], TEST_LOCATION ); // Occurs after Actor::Add from within from within OnStageConnection()
957 // Excercise the message passing to Update thread
959 application.SendNotification();
960 application.Render();
961 application.Render();
963 // Check everything is ok after Actors are removed
965 stage.Remove( actorA );
966 application.SendNotification();
967 application.Render();
968 application.Render();
972 int UtcDaliCustomActorRemoveDuringOnStageConnection(void)
974 TestApplication application;
975 tet_infoline("Testing Actor::Remove behaviour during Dali::CustomActor::OnStageConnection() callback");
977 Stage stage = Stage::GetCurrent();
979 MasterCallStack.clear();
981 /* The actorA is a special variant which removes its children during OnStageConnection()
982 * Actors B & C are provided as the children
985 TestCustomActor actorA = TestCustomActor::NewVariant2();
986 actorA.SetName( "ActorA" );
988 TestCustomActor actorB = TestCustomActor::New();
989 actorB.SetName( "ActorB" );
990 actorA.Add( actorB );
992 TestCustomActor actorC = TestCustomActor::New();
993 actorC.SetName( "ActorC" );
994 actorA.Add( actorC );
998 // Check callback sequence
1000 DALI_TEST_EQUALS( 5, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1001 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1002 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1003 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION );
1004 DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 3 ], TEST_LOCATION ); // Called from within OnStageConnection()
1005 DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 4 ], TEST_LOCATION ); // Called from within OnStageConnection()
1007 DALI_TEST_EQUALS( 5, (int)(MasterCallStack.size()), TEST_LOCATION );
1009 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 0 ], TEST_LOCATION );
1010 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 1 ], TEST_LOCATION );
1011 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 2 ], TEST_LOCATION );
1012 DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 3 ], TEST_LOCATION );
1013 DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 4 ], TEST_LOCATION );
1015 /* Actors B & C should be removed before the point where they could receive an OnStageConnection callback
1016 * Therefore they shouldn't receive either OnStageConnection or OnStageDisconnection
1018 DALI_TEST_EQUALS( 0, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1019 DALI_TEST_EQUALS( 0, (int)(actorC.GetMethodsCalled().size()), TEST_LOCATION );
1021 // Excercise the message passing to Update thread
1023 application.SendNotification();
1024 application.Render();
1025 application.Render();
1027 // Check everything is ok after last actor is removed
1029 stage.Remove( actorA );
1030 application.SendNotification();
1031 application.Render();
1032 application.Render();
1036 int UtcDaliCustomActorAddDuringOnStageDisconnection(void)
1038 TestApplication application;
1039 tet_infoline("Testing Actor::Add behaviour during Dali::CustomActor::OnStageDisonnection() callback");
1041 Stage stage = Stage::GetCurrent();
1043 /* The actorA is a special variant which adds a child to itself during OnStageDisconnection()
1044 * The actorB is provided as the child
1047 TestCustomActor actorB = TestCustomActor::New();
1048 actorB.SetName( "ActorB" );
1050 TestCustomActor actorA = TestCustomActor::NewVariant3( actorB );
1051 actorA.SetName( "ActorA" );
1052 stage.Add( actorA );
1054 // Excercise the message passing to Update thread
1056 application.SendNotification();
1057 application.Render();
1058 application.Render();
1060 // Clear call stacks before disconnection
1061 actorA.ResetCallStack();
1062 actorB.ResetCallStack();
1063 MasterCallStack.clear();
1065 stage.Remove( actorA );
1067 // Check callback sequence
1069 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1070 DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1071 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1073 // Child was added after parent disconnection, so should not receive OnStageConnection()
1074 DALI_TEST_EQUALS( 0, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1076 DALI_TEST_EQUALS( 2, (int)(MasterCallStack.size()), TEST_LOCATION );
1078 DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 0 ], TEST_LOCATION );
1079 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 1 ], TEST_LOCATION );
1081 // Excercise the message passing to Update thread
1083 application.SendNotification();
1084 application.Render();
1085 application.Render();
1089 int UtcDaliCustomActorRemoveDuringOnStageDisconnection(void)
1091 TestApplication application;
1092 tet_infoline("Testing Actor::Remove behaviour during Dali::CustomActor::OnStageDisconnection() callback");
1094 Stage stage = Stage::GetCurrent();
1096 /* The actorA is a special variant which removes its children during OnStageDisconnection()
1097 * The actorB is provided as the child
1100 TestCustomActor actorA = TestCustomActor::NewVariant4();
1101 actorA.SetName( "ActorA" );
1102 stage.Add( actorA );
1104 TestCustomActor actorB = TestCustomActor::New();
1105 actorB.SetName( "ActorB" );
1106 actorA.Add( actorB );
1108 // Excercise the message passing to Update thread
1110 application.SendNotification();
1111 application.Render();
1112 application.Render();
1114 // Clear call stacks before disconnection
1115 actorA.ResetCallStack();
1116 actorB.ResetCallStack();
1117 MasterCallStack.clear();
1119 stage.Remove( actorA );
1121 // Check callback sequence
1123 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1124 DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1125 DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1127 DALI_TEST_EQUALS( 1, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1128 DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1130 DALI_TEST_EQUALS( 3, (int)(MasterCallStack.size()), TEST_LOCATION );
1132 DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 0 ], TEST_LOCATION );
1133 DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 1 ], TEST_LOCATION );
1134 DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 2 ], TEST_LOCATION );
1136 // Excercise the message passing to Update thread
1138 application.SendNotification();
1139 application.Render();
1140 application.Render();
1144 int UtcDaliCustomActorRemoveParentDuringOnStageConnection(void)
1146 TestApplication application;
1147 tet_infoline("Weird test where child removes its own parent from Stage during Dali::CustomActor::OnStageConnection() callback");
1149 Stage stage = Stage::GetCurrent();
1151 MasterCallStack.clear();
1153 /* The actorA is the parent of actorB
1154 * The actorB is a special variant which removes its own parent during OnStageConnection()
1155 * The child actor is interrupting the parent's connection to stage, therefore the parent should not get an OnStageDisconnection()
1158 TestCustomActor actorA = TestCustomActor::New();
1159 actorA.SetName( "ActorA" );
1161 TestCustomActor actorB = TestCustomActor::NewVariant5();
1162 actorB.SetName( "ActorB" );
1163 actorA.Add( actorB );
1165 stage.Add( actorA );
1167 // Check callback sequence
1169 DALI_TEST_EQUALS( 3, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1170 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1171 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1172 DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION );
1174 DALI_TEST_EQUALS( 1, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1175 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1177 DALI_TEST_EQUALS( 4, (int)(MasterCallStack.size()), TEST_LOCATION );
1179 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 0 ], TEST_LOCATION );
1180 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION );
1181 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 2 ], TEST_LOCATION );
1182 DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 3 ], TEST_LOCATION );
1184 // Excercise the message passing to Update thread
1186 application.SendNotification();
1187 application.Render();
1188 application.Render();
1192 int UtcDaliCustomActorAddParentDuringOnStageDisconnection(void)
1194 TestApplication application;
1195 tet_infoline("Weird test where child adds its own parent to Stage during Dali::CustomActor::OnStageDisconnection() callback");
1197 Stage stage = Stage::GetCurrent();
1199 MasterCallStack.clear();
1201 /* The actorA is the parent of actorB
1202 * The actorB is a special variant which (weirdly) adds its own parent during OnStageDisconnection()
1203 * The child actor is interrupting the disconnection, such that parent should not get a OnStageDisconnection()
1206 TestCustomActor actorA = TestCustomActor::New();
1207 actorA.SetName( "ActorA" );
1208 stage.Add( actorA );
1210 TestCustomActor actorB = TestCustomActor::NewVariant6();
1211 actorB.SetName( "ActorB" );
1212 actorA.Add( actorB );
1214 stage.Remove( actorA );
1216 // Check callback sequence
1218 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1219 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1220 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1222 DALI_TEST_EQUALS( 2, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1223 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1224 DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1225 // Disconnect was interrupted, so we should only get one OnStageConnection() for actorB
1227 DALI_TEST_EQUALS( 4, (int)(MasterCallStack.size()), TEST_LOCATION );
1229 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 0 ], TEST_LOCATION );
1230 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION );
1231 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 2 ], TEST_LOCATION );
1232 DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 3 ], TEST_LOCATION );
1234 // Excercise the message passing to Update thread
1236 application.SendNotification();
1237 application.Render();
1238 application.Render();
1242 int UtcDaliCustomActorOnChildAddRemove(void)
1244 TestApplication application;
1245 tet_infoline("Testing Dali::CustomActor::OnChildAdd() & OnChildRemove()");
1247 TestCustomActor custom = TestCustomActor::New();
1248 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1250 Actor aChild = Actor::New();
1251 custom.Add( aChild );
1253 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1254 DALI_TEST_EQUALS( "OnChildAdd", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1256 custom.Remove( aChild );
1258 DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1259 DALI_TEST_EQUALS( "OnChildRemove", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1263 int UtcDaliCustomActorReparentDuringOnChildAdd(void)
1265 TestApplication application;
1266 tet_infoline("Testing Actor:Add (reparenting) behaviour during Dali::CustomActor::OnChildAdd() callback");
1268 Stage stage = Stage::GetCurrent();
1270 MasterCallStack.clear();
1272 /* The actorA is a special variant which reparents children added into a separate container child
1273 * The actorB is the child of actorA
1276 TestCustomActor actorA = TestCustomActor::NewVariant7( "ActorA" );
1277 stage.Add( actorA );
1279 TestCustomActor actorB = TestCustomActor::New();
1280 actorB.SetName( "ActorB" );
1281 actorA.Add( actorB );
1283 // Check hierarchy is as follows:
1290 DALI_TEST_EQUALS( 1, (int)(actorA.GetChildCount()), TEST_LOCATION );
1292 Actor container = actorA.GetChildAt(0);
1293 Actor containerChild;
1295 DALI_TEST_CHECK( container );
1298 DALI_TEST_EQUALS( "Container", container.GetName(), TEST_LOCATION );
1299 DALI_TEST_EQUALS( 1, (int)(container.GetChildCount()), TEST_LOCATION );
1300 containerChild = container.GetChildAt(0);
1303 DALI_TEST_CHECK( containerChild );
1304 if ( containerChild )
1306 DALI_TEST_EQUALS( "ActorB", containerChild.GetName(), TEST_LOCATION );
1307 DALI_TEST_EQUALS( 0, (int)(containerChild.GetChildCount()), TEST_LOCATION );
1310 // Check callback sequence
1312 DALI_TEST_EQUALS( 4, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1313 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION ); // The mContainer added to actorA
1314 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1315 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION ); // The actorB added to actorA
1316 DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 3 ], TEST_LOCATION );
1317 // mContainer will then receive OnChildAdd
1319 DALI_TEST_EQUALS( 3, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1320 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1321 DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1322 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 2 ], TEST_LOCATION );
1324 DALI_TEST_EQUALS( 7, (int)(MasterCallStack.size()), TEST_LOCATION );
1326 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 0 ], TEST_LOCATION );
1327 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION );
1328 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 2 ], TEST_LOCATION );
1329 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 3 ], TEST_LOCATION );
1330 DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 4 ], TEST_LOCATION );
1331 DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 5 ], TEST_LOCATION );
1332 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 6 ], TEST_LOCATION );
1334 // Excercise the message passing to Update thread
1336 application.SendNotification();
1337 application.Render();
1338 application.Render();
1343 * Test that Remove can be called (a NOOP) during the OnChildRemove
1344 * triggered when reparenting an actor
1346 int UtcDaliCustomActorRemoveDuringOnChildRemove(void)
1348 TestApplication application;
1349 tet_infoline("Testing Actor:Remove behaviour during OnChildRemove() callback triggered when reparenting");
1351 Stage stage = Stage::GetCurrent();
1353 MasterCallStack.clear();
1355 /* The childActor will be reparented from actorA to actorB
1356 * The actorA is a special variant which attempts to remove a child from actorB, during the OnChildRemove callback()
1357 * This should be a NOOP since the reparenting has not occured yet
1360 TestCustomActor actorB = TestCustomActor::New();
1361 actorB.SetName( "ActorB" );
1362 stage.Add( actorB );
1364 TestCustomActor actorA = TestCustomActor::NewVariant8( actorB );
1365 actorA.SetName( "ActorA" );
1366 stage.Add( actorA );
1368 Actor childActor = Actor::New();
1369 childActor.SetName( "Child" );
1370 // Reparent from actorA to actorB
1371 actorA.Add( childActor );
1372 actorB.Add( childActor );
1374 // Check hierarchy is as follows:
1379 DALI_TEST_EQUALS( 0, (int)(actorA.GetChildCount()), TEST_LOCATION );
1380 DALI_TEST_EQUALS( 1, (int)(actorB.GetChildCount()), TEST_LOCATION );
1381 DALI_TEST_EQUALS( 0, (int)(childActor.GetChildCount()), TEST_LOCATION );
1383 Actor child = actorB.GetChildAt(0);
1385 DALI_TEST_CHECK( child );
1388 DALI_TEST_EQUALS( "Child", child.GetName(), TEST_LOCATION );
1391 // Check callback sequence
1393 DALI_TEST_EQUALS( 3, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1394 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION ); // The mContainer added to actorA
1395 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1396 DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION ); // The actorB added to actorA
1397 // mContainer will then receive OnChildAdd
1399 DALI_TEST_EQUALS( 2, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1400 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1401 DALI_TEST_EQUALS( "OnChildAdd", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1403 DALI_TEST_EQUALS( 5, (int)(MasterCallStack.size()), TEST_LOCATION );
1405 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 0 ], TEST_LOCATION );
1406 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION );
1407 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 2 ], TEST_LOCATION );
1408 DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 3 ], TEST_LOCATION );
1409 DALI_TEST_EQUALS( "ActorB: OnChildAdd", MasterCallStack[ 4 ], TEST_LOCATION );
1411 // Excercise the message passing to Update thread
1413 application.SendNotification();
1414 application.Render();
1415 application.Render();
1419 int UtcDaliCustomActorOnPropertySet(void)
1421 TestApplication application;
1422 tet_infoline("Testing Dali::CustomActor::OnPropertySet()");
1424 TestCustomActor custom = TestCustomActor::New();
1425 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1427 custom.SetDaliProperty("yes") ;
1429 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1430 DALI_TEST_EQUALS( "OnPropertySet", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1434 int UtcDaliCustomActorOnSizeSet(void)
1436 TestApplication application;
1437 tet_infoline("Testing Dali::CustomActor::OnSizeSet()");
1439 TestCustomActor custom = TestCustomActor::New();
1440 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1442 custom.SetSize( Vector2( 9.0f, 10.0f ) );
1443 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1444 DALI_TEST_EQUALS( "OnSizeSet", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1445 DALI_TEST_EQUALS( 9.0f, custom.GetSize().width, TEST_LOCATION );
1446 DALI_TEST_EQUALS( 10.0f, custom.GetSize().height, TEST_LOCATION );
1448 custom.SetSize( Vector3( 4.0f, 5.0f, 6.0f ) );
1449 DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1450 DALI_TEST_EQUALS( "OnSizeSet", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1451 DALI_TEST_EQUALS( 4.0f, custom.GetSize().width, TEST_LOCATION );
1452 DALI_TEST_EQUALS( 5.0f, custom.GetSize().height, TEST_LOCATION );
1453 DALI_TEST_EQUALS( 6.0f, custom.GetSize().depth, TEST_LOCATION );
1457 int UtcDaliCustomActorOnSizeAnimation(void)
1459 TestApplication application;
1460 tet_infoline("Testing Dali::CustomActor::OnSizeAnimation()");
1462 TestCustomActor custom = TestCustomActor::New();
1463 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1465 Animation anim = Animation::New( 1.0f );
1466 anim.Resize( custom, Vector3( 8.0f, 9.0f, 10.0f ) );
1467 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1468 DALI_TEST_EQUALS( "OnSizeAnimation", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1469 DALI_TEST_EQUALS( 8.0f, custom.GetTargetSize().width, TEST_LOCATION );
1470 DALI_TEST_EQUALS( 9.0f, custom.GetTargetSize().height, TEST_LOCATION );
1471 DALI_TEST_EQUALS( 10.0f, custom.GetTargetSize().depth, TEST_LOCATION );
1473 anim.Resize( custom, 1.0f, 2.0f );
1474 DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1475 DALI_TEST_EQUALS( "OnSizeAnimation", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1476 DALI_TEST_EQUALS( 1.0f, custom.GetTargetSize().width, TEST_LOCATION );
1477 DALI_TEST_EQUALS( 2.0f, custom.GetTargetSize().height, TEST_LOCATION );
1481 int UtcDaliCustomActorOnTouchEvent(void)
1483 TestApplication application;
1484 tet_infoline("Testing Dali::CustomActor::OnTouchEvent()");
1486 TestCustomActor custom = TestCustomActor::New();
1487 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1489 // set size for custom actor
1490 custom.SetSize( 100, 100 );
1491 // add the custom actor to stage
1492 Stage::GetCurrent().Add( custom );
1493 custom.ResetCallStack();
1495 // Render and notify a couple of times
1496 application.SendNotification();
1497 application.Render();
1498 application.SendNotification();
1499 application.Render();
1501 // simulate a touch event
1502 Dali::TouchPoint point( 0, TouchPoint::Down, 1, 1 );
1503 Dali::Integration::TouchEvent event;
1504 event.AddPoint( point );
1505 application.ProcessEvent( event );
1507 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1508 DALI_TEST_EQUALS( "OnTouchEvent", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1512 int UtcDaliCustomActorOnHoverEvent(void)
1514 TestApplication application;
1515 tet_infoline("Testing Dali::CustomActor::OnHoverEvent()");
1517 TestCustomActor custom = TestCustomActor::New();
1518 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1520 // set size for custom actor
1521 custom.SetSize( 100, 100 );
1522 // add the custom actor to stage
1523 Stage::GetCurrent().Add( custom );
1524 custom.ResetCallStack();
1526 // Render and notify a couple of times
1527 application.SendNotification();
1528 application.Render();
1529 application.SendNotification();
1530 application.Render();
1532 // simulate a hover event
1533 Dali::TouchPoint point( 0, TouchPoint::Motion, 1, 1 );
1534 Dali::Integration::HoverEvent event;
1535 event.AddPoint( point );
1536 application.ProcessEvent( event );
1538 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1539 DALI_TEST_EQUALS( "OnHoverEvent", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1543 int UtcDaliCustomActorOnMouseWheelEvent(void)
1545 TestApplication application;
1546 tet_infoline("Testing Dali::CustomActor::OnMouseWheelEvent()");
1548 TestCustomActor custom = TestCustomActor::New();
1549 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1551 // set size for custom actor
1552 custom.SetSize( 100, 100 );
1553 // add the custom actor to stage
1554 Stage::GetCurrent().Add( custom );
1555 custom.ResetCallStack();
1557 // Render and notify a couple of times
1558 application.SendNotification();
1559 application.Render();
1560 application.SendNotification();
1561 application.Render();
1563 // simulate a mouse wheel event
1564 Vector2 screenCoordinates( 10.0f, 10.0f );
1565 Integration::MouseWheelEvent event(0, 0u, screenCoordinates, 1, 1000u);
1566 application.ProcessEvent( event );
1568 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1569 DALI_TEST_EQUALS( "OnMouseWheelEvent", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1573 int UtcDaliCustomActorImplOnPropertySet(void)
1575 TestApplication application;
1576 CustomActorImpl* impl = new Impl::SimpleTestCustomActor();
1578 impl->OnPropertySet( 0, 0 );
1580 DALI_TEST_CHECK( true );
1586 int UtcDaliCustomActorGetImplementation(void)
1588 TestApplication application;
1590 TestCustomActor custom = TestCustomActor::New();
1591 CustomActorImpl& impl = custom.GetImplementation();
1592 impl.GetOwner(); // Test
1594 const TestCustomActor constCustom = TestCustomActor::New();
1595 const CustomActorImpl& constImpl = constCustom.GetImplementation();
1596 constImpl.GetOwner(); // Test
1598 DALI_TEST_CHECK( true );
1602 int UtcDaliCustomActorDoAction(void)
1604 TestApplication application;
1605 tet_infoline("Testing Dali::CustomActor::DoAction()");
1607 TestCustomActor custom = TestCustomActor::New();
1609 BaseHandle customActorObject = custom;
1611 DALI_TEST_CHECK(customActorObject);
1613 std::vector<Property::Value> attributes;
1615 // Check that an invalid command is not performed
1616 DALI_TEST_CHECK(customActorObject.DoAction("invalidCommand", attributes) == false);
1618 // Check that the custom actor is visible
1619 custom.SetVisible(true);
1620 DALI_TEST_CHECK(custom.IsVisible() == true);
1622 // Check the custom actor performed an action to hide itself
1623 DALI_TEST_CHECK(customActorObject.DoAction("hide", attributes) == true);
1625 // flush the queue and render once
1626 application.SendNotification();
1627 application.Render();
1629 // Check that the custom actor is now invisible
1630 DALI_TEST_CHECK(custom.IsVisible() == false);
1632 // Check the custom actor performed an action to show itself
1633 DALI_TEST_CHECK(customActorObject.DoAction("show", attributes) == true);
1635 // flush the queue and render once
1636 application.SendNotification();
1637 application.Render();
1639 // Check that the custom actor is now visible
1640 DALI_TEST_CHECK(custom.IsVisible() == true);