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 )
647 using namespace Dali;
649 BaseHandle CreateActor()
651 return TestCustomActor::New();
654 Dali::TypeRegistration mType( typeid(TestCustomActor), typeid(Dali::CustomActor), CreateActor );
659 int UtcDaliCustomActorDestructor(void)
661 TestApplication application;
663 CustomActor* actor = new CustomActor();
666 DALI_TEST_CHECK( true );
670 int UtcDaliCustomActorImplDestructor(void)
672 TestApplication application;
673 CustomActorImpl* actor = new Impl::TestCustomActor();
676 DALI_TEST_CHECK( true );
680 // Positive test case for a method
681 int UtcDaliCustomActorDownCast(void)
683 TestApplication application;
684 tet_infoline("Testing Dali::CustomActor::DownCast()");
686 TestCustomActor custom = TestCustomActor::New();
688 Actor anActor = Actor::New();
689 anActor.Add( custom );
691 Actor child = anActor.GetChildAt(0);
692 CustomActor customActor = CustomActor::DownCast( child );
693 DALI_TEST_CHECK( customActor );
696 DALI_TEST_CHECK( !customActor );
698 customActor = DownCast< CustomActor >( child );
699 DALI_TEST_CHECK( customActor );
703 // Negative test case for a method
704 int UtcDaliCustomActorDownCastNegative(void)
706 TestApplication application;
707 tet_infoline("Testing Dali::CustomActor::DownCast()");
709 Actor actor1 = Actor::New();
710 Actor anActor = Actor::New();
713 Actor child = anActor.GetChildAt(0);
714 CustomActor customActor = CustomActor::DownCast( child );
715 DALI_TEST_CHECK( !customActor );
717 Actor unInitialzedActor;
718 customActor = CustomActor::DownCast( unInitialzedActor );
719 DALI_TEST_CHECK( !customActor );
721 customActor = DownCast< CustomActor >( unInitialzedActor );
722 DALI_TEST_CHECK( !customActor );
726 int UtcDaliCustomActorOnStageConnectionDisconnection(void)
728 TestApplication application;
729 tet_infoline("Testing Dali::CustomActor::OnStageConnection() & OnStageDisconnection");
731 TestCustomActor custom = TestCustomActor::New();
732 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
734 // add the custom actor to stage
735 Stage::GetCurrent().Add( custom );
737 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
738 DALI_TEST_EQUALS( "OnStageConnection", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
740 Stage::GetCurrent().Remove( custom );
742 DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
743 DALI_TEST_EQUALS( "OnStageDisconnection", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
745 // Excercise the message passing to Update thread
747 application.SendNotification();
748 application.Render();
749 application.Render();
753 int UtcDaliCustomActorOnStageConnectionOrder(void)
755 TestApplication application;
756 tet_infoline("Testing Dali::CustomActor::OnStageConnection() order");
758 MasterCallStack.clear();
760 /* Build tree of actors:
768 * OnStageConnection should be received for A, B, D, E, C, and finally F
771 TestCustomActor actorA = TestCustomActor::New();
772 actorA.SetName( "ActorA" );
774 TestCustomActor actorB = TestCustomActor::New();
775 actorB.SetName( "ActorB" );
776 actorA.Add( actorB );
778 TestCustomActor actorC = TestCustomActor::New();
779 actorC.SetName( "ActorC" );
780 actorA.Add( actorC );
782 TestCustomActor actorD = TestCustomActor::New();
783 actorD.SetName( "ActorD" );
784 actorB.Add( actorD );
786 TestCustomActor actorE = TestCustomActor::New();
787 actorE.SetName( "ActorE" );
788 actorB.Add( actorE );
790 TestCustomActor actorF = TestCustomActor::New();
791 actorF.SetName( "ActorF" );
792 actorC.Add( actorF );
794 // add the custom actor to stage
795 Stage::GetCurrent().Add( actorA );
797 DALI_TEST_EQUALS( 3, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
798 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
799 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
800 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION );
802 DALI_TEST_EQUALS( 3, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
803 DALI_TEST_EQUALS( "OnChildAdd", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
804 DALI_TEST_EQUALS( "OnChildAdd", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
805 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 2 ], TEST_LOCATION );
807 DALI_TEST_EQUALS( 2, (int)(actorC.GetMethodsCalled().size()), TEST_LOCATION );
808 DALI_TEST_EQUALS( "OnChildAdd", actorC.GetMethodsCalled()[ 0 ], TEST_LOCATION );
809 DALI_TEST_EQUALS( "OnStageConnection", actorC.GetMethodsCalled()[ 1 ], TEST_LOCATION );
811 DALI_TEST_EQUALS( 1, (int)(actorD.GetMethodsCalled().size()), TEST_LOCATION );
812 DALI_TEST_EQUALS( "OnStageConnection", actorD.GetMethodsCalled()[ 0 ], TEST_LOCATION );
814 DALI_TEST_EQUALS( 1, (int)(actorE.GetMethodsCalled().size()), TEST_LOCATION );
815 DALI_TEST_EQUALS( "OnStageConnection", actorE.GetMethodsCalled()[ 0 ], TEST_LOCATION );
817 DALI_TEST_EQUALS( 1, (int)(actorF.GetMethodsCalled().size()), TEST_LOCATION );
818 DALI_TEST_EQUALS( "OnStageConnection", actorF.GetMethodsCalled()[ 0 ], TEST_LOCATION );
820 // Check sequence is correct in MasterCallStack
822 DALI_TEST_EQUALS( 3+3+2+1+1+1, (int)(MasterCallStack.size()), TEST_LOCATION );
824 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 0 ], TEST_LOCATION );
825 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 1 ], TEST_LOCATION );
826 DALI_TEST_EQUALS( "ActorB: OnChildAdd", MasterCallStack[ 2 ], TEST_LOCATION );
827 DALI_TEST_EQUALS( "ActorB: OnChildAdd", MasterCallStack[ 3 ], TEST_LOCATION );
828 DALI_TEST_EQUALS( "ActorC: OnChildAdd", MasterCallStack[ 4 ], TEST_LOCATION );
830 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 5 ], TEST_LOCATION );
831 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 6 ], TEST_LOCATION );
832 DALI_TEST_EQUALS( "ActorD: OnStageConnection", MasterCallStack[ 7 ], TEST_LOCATION );
833 DALI_TEST_EQUALS( "ActorE: OnStageConnection", MasterCallStack[ 8 ], TEST_LOCATION );
834 DALI_TEST_EQUALS( "ActorC: OnStageConnection", MasterCallStack[ 9 ], TEST_LOCATION );
835 DALI_TEST_EQUALS( "ActorF: OnStageConnection", MasterCallStack[ 10 ], TEST_LOCATION );
837 // Excercise the message passing to Update thread
839 application.SendNotification();
840 application.Render();
841 application.Render();
845 int UtcDaliCustomActorOnStageDisconnectionOrder(void)
847 TestApplication application;
848 tet_infoline("Testing Dali::CustomActor::OnStageDisconnection() order");
850 Stage stage = Stage::GetCurrent();
852 /* Build tree of actors:
860 * OnStageDisconnection should be received for D, E, B, F, C, and finally A.
863 TestCustomActor actorA = TestCustomActor::New();
864 actorA.SetName( "ActorA" );
867 TestCustomActor actorB = TestCustomActor::New();
868 actorB.SetName( "ActorB" );
869 actorA.Add( actorB );
871 TestCustomActor actorC = TestCustomActor::New();
872 actorC.SetName( "ActorC" );
873 actorA.Add( actorC );
875 TestCustomActor actorD = TestCustomActor::New();
876 actorD.SetName( "ActorD" );
877 actorB.Add( actorD );
879 TestCustomActor actorE = TestCustomActor::New();
880 actorE.SetName( "ActorE" );
881 actorB.Add( actorE );
883 TestCustomActor actorF = TestCustomActor::New();
884 actorF.SetName( "ActorF" );
885 actorC.Add( actorF );
887 // Excercise the message passing to Update thread
889 application.SendNotification();
890 application.Render();
891 application.Render();
893 // Clear call stacks before disconnection
894 actorA.ResetCallStack();
895 actorB.ResetCallStack();
896 actorC.ResetCallStack();
897 actorD.ResetCallStack();
898 actorE.ResetCallStack();
899 actorF.ResetCallStack();
900 MasterCallStack.clear();
902 stage.Remove( actorA );
904 DALI_TEST_EQUALS( 1, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
905 DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
907 DALI_TEST_EQUALS( 1, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
908 DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
910 DALI_TEST_EQUALS( 1, (int)(actorC.GetMethodsCalled().size()), TEST_LOCATION );
911 DALI_TEST_EQUALS( "OnStageDisconnection", actorC.GetMethodsCalled()[ 0 ], TEST_LOCATION );
913 DALI_TEST_EQUALS( 1, (int)(actorD.GetMethodsCalled().size()), TEST_LOCATION );
914 DALI_TEST_EQUALS( "OnStageDisconnection", actorD.GetMethodsCalled()[ 0 ], TEST_LOCATION );
916 DALI_TEST_EQUALS( 1, (int)(actorE.GetMethodsCalled().size()), TEST_LOCATION );
917 DALI_TEST_EQUALS( "OnStageDisconnection", actorE.GetMethodsCalled()[ 0 ], TEST_LOCATION );
919 DALI_TEST_EQUALS( 1, (int)(actorF.GetMethodsCalled().size()), TEST_LOCATION );
920 DALI_TEST_EQUALS( "OnStageDisconnection", actorF.GetMethodsCalled()[ 0 ], TEST_LOCATION );
922 // Check sequence is correct in MasterCallStack
924 DALI_TEST_EQUALS( 6, (int)(MasterCallStack.size()), TEST_LOCATION );
926 DALI_TEST_EQUALS( "ActorD: OnStageDisconnection", MasterCallStack[ 0 ], TEST_LOCATION );
927 DALI_TEST_EQUALS( "ActorE: OnStageDisconnection", MasterCallStack[ 1 ], TEST_LOCATION );
928 DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 2 ], TEST_LOCATION );
929 DALI_TEST_EQUALS( "ActorF: OnStageDisconnection", MasterCallStack[ 3 ], TEST_LOCATION );
930 DALI_TEST_EQUALS( "ActorC: OnStageDisconnection", MasterCallStack[ 4 ], TEST_LOCATION );
931 DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 5 ], TEST_LOCATION );
933 // Excercise the message passing to Update thread
935 application.SendNotification();
936 application.Render();
937 application.Render();
941 int UtcDaliCustomActorAddDuringOnStageConnection(void)
943 TestApplication application;
944 tet_infoline("Testing Actor::Add behaviour during Dali::CustomActor::OnStageConnection() callback");
946 Stage stage = Stage::GetCurrent();
948 MasterCallStack.clear();
950 /* The actorA is a special variant which adds a child to itself during OnStageConnection()
951 * The actorB is provided as the child
954 TestCustomActor actorB = TestCustomActor::New();
955 actorB.SetName( "ActorB" );
957 TestCustomActor actorA = TestCustomActor::NewVariant1( actorB );
958 actorA.SetName( "ActorA" );
961 // Check callback sequence
963 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
964 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
965 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION ); // Called from within OnStageConnection()
967 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
968 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
970 DALI_TEST_EQUALS( 3, (int)(MasterCallStack.size()), TEST_LOCATION );
972 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 0 ], TEST_LOCATION );
973 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION ); // Occurs during Actor::Add from within from within OnStageConnection()
974 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 2 ], TEST_LOCATION ); // Occurs after Actor::Add from within from within OnStageConnection()
976 // Excercise the message passing to Update thread
978 application.SendNotification();
979 application.Render();
980 application.Render();
982 // Check everything is ok after Actors are removed
984 stage.Remove( actorA );
985 application.SendNotification();
986 application.Render();
987 application.Render();
991 int UtcDaliCustomActorRemoveDuringOnStageConnection(void)
993 TestApplication application;
994 tet_infoline("Testing Actor::Remove behaviour during Dali::CustomActor::OnStageConnection() callback");
996 Stage stage = Stage::GetCurrent();
998 MasterCallStack.clear();
1000 /* The actorA is a special variant which removes its children during OnStageConnection()
1001 * Actors B & C are provided as the children
1004 TestCustomActor actorA = TestCustomActor::NewVariant2();
1005 actorA.SetName( "ActorA" );
1007 TestCustomActor actorB = TestCustomActor::New();
1008 actorB.SetName( "ActorB" );
1009 actorA.Add( actorB );
1011 TestCustomActor actorC = TestCustomActor::New();
1012 actorC.SetName( "ActorC" );
1013 actorA.Add( actorC );
1015 stage.Add( actorA );
1017 // Check callback sequence
1019 DALI_TEST_EQUALS( 5, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1020 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1021 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1022 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION );
1023 DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 3 ], TEST_LOCATION ); // Called from within OnStageConnection()
1024 DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 4 ], TEST_LOCATION ); // Called from within OnStageConnection()
1026 DALI_TEST_EQUALS( 5, (int)(MasterCallStack.size()), TEST_LOCATION );
1028 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 0 ], TEST_LOCATION );
1029 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 1 ], TEST_LOCATION );
1030 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 2 ], TEST_LOCATION );
1031 DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 3 ], TEST_LOCATION );
1032 DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 4 ], TEST_LOCATION );
1034 /* Actors B & C should be removed before the point where they could receive an OnStageConnection callback
1035 * Therefore they shouldn't receive either OnStageConnection or OnStageDisconnection
1037 DALI_TEST_EQUALS( 0, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1038 DALI_TEST_EQUALS( 0, (int)(actorC.GetMethodsCalled().size()), TEST_LOCATION );
1040 // Excercise the message passing to Update thread
1042 application.SendNotification();
1043 application.Render();
1044 application.Render();
1046 // Check everything is ok after last actor is removed
1048 stage.Remove( actorA );
1049 application.SendNotification();
1050 application.Render();
1051 application.Render();
1055 int UtcDaliCustomActorAddDuringOnStageDisconnection(void)
1057 TestApplication application;
1058 tet_infoline("Testing Actor::Add behaviour during Dali::CustomActor::OnStageDisonnection() callback");
1060 Stage stage = Stage::GetCurrent();
1062 /* The actorA is a special variant which adds a child to itself during OnStageDisconnection()
1063 * The actorB is provided as the child
1066 TestCustomActor actorB = TestCustomActor::New();
1067 actorB.SetName( "ActorB" );
1069 TestCustomActor actorA = TestCustomActor::NewVariant3( actorB );
1070 actorA.SetName( "ActorA" );
1071 stage.Add( actorA );
1073 // Excercise the message passing to Update thread
1075 application.SendNotification();
1076 application.Render();
1077 application.Render();
1079 // Clear call stacks before disconnection
1080 actorA.ResetCallStack();
1081 actorB.ResetCallStack();
1082 MasterCallStack.clear();
1084 stage.Remove( actorA );
1086 // Check callback sequence
1088 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1089 DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1090 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1092 // Child was added after parent disconnection, so should not receive OnStageConnection()
1093 DALI_TEST_EQUALS( 0, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1095 DALI_TEST_EQUALS( 2, (int)(MasterCallStack.size()), TEST_LOCATION );
1097 DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 0 ], TEST_LOCATION );
1098 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 1 ], TEST_LOCATION );
1100 // Excercise the message passing to Update thread
1102 application.SendNotification();
1103 application.Render();
1104 application.Render();
1108 int UtcDaliCustomActorRemoveDuringOnStageDisconnection(void)
1110 TestApplication application;
1111 tet_infoline("Testing Actor::Remove behaviour during Dali::CustomActor::OnStageDisconnection() callback");
1113 Stage stage = Stage::GetCurrent();
1115 /* The actorA is a special variant which removes its children during OnStageDisconnection()
1116 * The actorB is provided as the child
1119 TestCustomActor actorA = TestCustomActor::NewVariant4();
1120 actorA.SetName( "ActorA" );
1121 stage.Add( actorA );
1123 TestCustomActor actorB = TestCustomActor::New();
1124 actorB.SetName( "ActorB" );
1125 actorA.Add( actorB );
1127 // Excercise the message passing to Update thread
1129 application.SendNotification();
1130 application.Render();
1131 application.Render();
1133 // Clear call stacks before disconnection
1134 actorA.ResetCallStack();
1135 actorB.ResetCallStack();
1136 MasterCallStack.clear();
1138 stage.Remove( actorA );
1140 // Check callback sequence
1142 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1143 DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1144 DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1146 DALI_TEST_EQUALS( 1, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1147 DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1149 DALI_TEST_EQUALS( 3, (int)(MasterCallStack.size()), TEST_LOCATION );
1151 DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 0 ], TEST_LOCATION );
1152 DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 1 ], TEST_LOCATION );
1153 DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 2 ], TEST_LOCATION );
1155 // Excercise the message passing to Update thread
1157 application.SendNotification();
1158 application.Render();
1159 application.Render();
1163 int UtcDaliCustomActorRemoveParentDuringOnStageConnection(void)
1165 TestApplication application;
1166 tet_infoline("Weird test where child removes its own parent from Stage during Dali::CustomActor::OnStageConnection() callback");
1168 Stage stage = Stage::GetCurrent();
1170 MasterCallStack.clear();
1172 /* The actorA is the parent of actorB
1173 * The actorB is a special variant which removes its own parent during OnStageConnection()
1174 * The child actor is interrupting the parent's connection to stage, therefore the parent should not get an OnStageDisconnection()
1177 TestCustomActor actorA = TestCustomActor::New();
1178 actorA.SetName( "ActorA" );
1180 TestCustomActor actorB = TestCustomActor::NewVariant5();
1181 actorB.SetName( "ActorB" );
1182 actorA.Add( actorB );
1184 stage.Add( actorA );
1186 // Check callback sequence
1188 DALI_TEST_EQUALS( 3, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1189 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1190 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1191 DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION );
1193 DALI_TEST_EQUALS( 1, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1194 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1196 DALI_TEST_EQUALS( 4, (int)(MasterCallStack.size()), TEST_LOCATION );
1198 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 0 ], TEST_LOCATION );
1199 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION );
1200 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 2 ], TEST_LOCATION );
1201 DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 3 ], TEST_LOCATION );
1203 // Excercise the message passing to Update thread
1205 application.SendNotification();
1206 application.Render();
1207 application.Render();
1211 int UtcDaliCustomActorAddParentDuringOnStageDisconnection(void)
1213 TestApplication application;
1214 tet_infoline("Weird test where child adds its own parent to Stage during Dali::CustomActor::OnStageDisconnection() callback");
1216 Stage stage = Stage::GetCurrent();
1218 MasterCallStack.clear();
1220 /* The actorA is the parent of actorB
1221 * The actorB is a special variant which (weirdly) adds its own parent during OnStageDisconnection()
1222 * The child actor is interrupting the disconnection, such that parent should not get a OnStageDisconnection()
1225 TestCustomActor actorA = TestCustomActor::New();
1226 actorA.SetName( "ActorA" );
1227 stage.Add( actorA );
1229 TestCustomActor actorB = TestCustomActor::NewVariant6();
1230 actorB.SetName( "ActorB" );
1231 actorA.Add( actorB );
1233 stage.Remove( actorA );
1235 // Check callback sequence
1237 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1238 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1239 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1241 DALI_TEST_EQUALS( 2, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1242 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1243 DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1244 // Disconnect was interrupted, so we should only get one OnStageConnection() for actorB
1246 DALI_TEST_EQUALS( 4, (int)(MasterCallStack.size()), TEST_LOCATION );
1248 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 0 ], TEST_LOCATION );
1249 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION );
1250 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 2 ], TEST_LOCATION );
1251 DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 3 ], TEST_LOCATION );
1253 // Excercise the message passing to Update thread
1255 application.SendNotification();
1256 application.Render();
1257 application.Render();
1261 int UtcDaliCustomActorOnChildAddRemove(void)
1263 TestApplication application;
1264 tet_infoline("Testing Dali::CustomActor::OnChildAdd() & OnChildRemove()");
1266 TestCustomActor custom = TestCustomActor::New();
1267 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1269 Actor aChild = Actor::New();
1270 custom.Add( aChild );
1272 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1273 DALI_TEST_EQUALS( "OnChildAdd", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1275 custom.Remove( aChild );
1277 DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1278 DALI_TEST_EQUALS( "OnChildRemove", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1282 int UtcDaliCustomActorReparentDuringOnChildAdd(void)
1284 TestApplication application;
1285 tet_infoline("Testing Actor:Add (reparenting) behaviour during Dali::CustomActor::OnChildAdd() callback");
1287 Stage stage = Stage::GetCurrent();
1289 MasterCallStack.clear();
1291 /* The actorA is a special variant which reparents children added into a separate container child
1292 * The actorB is the child of actorA
1295 TestCustomActor actorA = TestCustomActor::NewVariant7( "ActorA" );
1296 stage.Add( actorA );
1298 TestCustomActor actorB = TestCustomActor::New();
1299 actorB.SetName( "ActorB" );
1300 actorA.Add( actorB );
1302 // Check hierarchy is as follows:
1309 DALI_TEST_EQUALS( 1, (int)(actorA.GetChildCount()), TEST_LOCATION );
1311 Actor container = actorA.GetChildAt(0);
1312 Actor containerChild;
1314 DALI_TEST_CHECK( container );
1317 DALI_TEST_EQUALS( "Container", container.GetName(), TEST_LOCATION );
1318 DALI_TEST_EQUALS( 1, (int)(container.GetChildCount()), TEST_LOCATION );
1319 containerChild = container.GetChildAt(0);
1322 DALI_TEST_CHECK( containerChild );
1323 if ( containerChild )
1325 DALI_TEST_EQUALS( "ActorB", containerChild.GetName(), TEST_LOCATION );
1326 DALI_TEST_EQUALS( 0, (int)(containerChild.GetChildCount()), TEST_LOCATION );
1329 // Check callback sequence
1331 DALI_TEST_EQUALS( 4, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1332 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION ); // The mContainer added to actorA
1333 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1334 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION ); // The actorB added to actorA
1335 DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 3 ], TEST_LOCATION );
1336 // mContainer will then receive OnChildAdd
1338 DALI_TEST_EQUALS( 3, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1339 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1340 DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1341 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 2 ], TEST_LOCATION );
1343 DALI_TEST_EQUALS( 7, (int)(MasterCallStack.size()), TEST_LOCATION );
1345 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 0 ], TEST_LOCATION );
1346 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION );
1347 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 2 ], TEST_LOCATION );
1348 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 3 ], TEST_LOCATION );
1349 DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 4 ], TEST_LOCATION );
1350 DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 5 ], TEST_LOCATION );
1351 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 6 ], TEST_LOCATION );
1353 // Excercise the message passing to Update thread
1355 application.SendNotification();
1356 application.Render();
1357 application.Render();
1362 * Test that Remove can be called (a NOOP) during the OnChildRemove
1363 * triggered when reparenting an actor
1365 int UtcDaliCustomActorRemoveDuringOnChildRemove(void)
1367 TestApplication application;
1368 tet_infoline("Testing Actor:Remove behaviour during OnChildRemove() callback triggered when reparenting");
1370 Stage stage = Stage::GetCurrent();
1372 MasterCallStack.clear();
1374 /* The childActor will be reparented from actorA to actorB
1375 * The actorA is a special variant which attempts to remove a child from actorB, during the OnChildRemove callback()
1376 * This should be a NOOP since the reparenting has not occured yet
1379 TestCustomActor actorB = TestCustomActor::New();
1380 actorB.SetName( "ActorB" );
1381 stage.Add( actorB );
1383 TestCustomActor actorA = TestCustomActor::NewVariant8( actorB );
1384 actorA.SetName( "ActorA" );
1385 stage.Add( actorA );
1387 Actor childActor = Actor::New();
1388 childActor.SetName( "Child" );
1389 // Reparent from actorA to actorB
1390 actorA.Add( childActor );
1391 actorB.Add( childActor );
1393 // Check hierarchy is as follows:
1398 DALI_TEST_EQUALS( 0, (int)(actorA.GetChildCount()), TEST_LOCATION );
1399 DALI_TEST_EQUALS( 1, (int)(actorB.GetChildCount()), TEST_LOCATION );
1400 DALI_TEST_EQUALS( 0, (int)(childActor.GetChildCount()), TEST_LOCATION );
1402 Actor child = actorB.GetChildAt(0);
1404 DALI_TEST_CHECK( child );
1407 DALI_TEST_EQUALS( "Child", child.GetName(), TEST_LOCATION );
1410 // Check callback sequence
1412 DALI_TEST_EQUALS( 3, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1413 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION ); // The mContainer added to actorA
1414 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1415 DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION ); // The actorB added to actorA
1416 // mContainer will then receive OnChildAdd
1418 DALI_TEST_EQUALS( 2, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1419 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1420 DALI_TEST_EQUALS( "OnChildAdd", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1422 DALI_TEST_EQUALS( 5, (int)(MasterCallStack.size()), TEST_LOCATION );
1424 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 0 ], TEST_LOCATION );
1425 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION );
1426 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 2 ], TEST_LOCATION );
1427 DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 3 ], TEST_LOCATION );
1428 DALI_TEST_EQUALS( "ActorB: OnChildAdd", MasterCallStack[ 4 ], TEST_LOCATION );
1430 // Excercise the message passing to Update thread
1432 application.SendNotification();
1433 application.Render();
1434 application.Render();
1438 int UtcDaliCustomActorOnPropertySet(void)
1440 TestApplication application;
1441 tet_infoline("Testing Dali::CustomActor::OnPropertySet()");
1443 TestCustomActor custom = TestCustomActor::New();
1444 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1446 custom.SetDaliProperty("yes") ;
1448 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1449 DALI_TEST_EQUALS( "OnPropertySet", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1453 int UtcDaliCustomActorOnSizeSet(void)
1455 TestApplication application;
1456 tet_infoline("Testing Dali::CustomActor::OnSizeSet()");
1458 TestCustomActor custom = TestCustomActor::New();
1459 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1461 custom.SetSize( Vector2( 9.0f, 10.0f ) );
1462 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1463 DALI_TEST_EQUALS( "OnSizeSet", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1464 DALI_TEST_EQUALS( 9.0f, custom.GetSize().width, TEST_LOCATION );
1465 DALI_TEST_EQUALS( 10.0f, custom.GetSize().height, TEST_LOCATION );
1467 custom.SetSize( Vector3( 4.0f, 5.0f, 6.0f ) );
1468 DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1469 DALI_TEST_EQUALS( "OnSizeSet", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1470 DALI_TEST_EQUALS( 4.0f, custom.GetSize().width, TEST_LOCATION );
1471 DALI_TEST_EQUALS( 5.0f, custom.GetSize().height, TEST_LOCATION );
1472 DALI_TEST_EQUALS( 6.0f, custom.GetSize().depth, TEST_LOCATION );
1476 int UtcDaliCustomActorOnSizeAnimation(void)
1478 TestApplication application;
1479 tet_infoline("Testing Dali::CustomActor::OnSizeAnimation()");
1481 TestCustomActor custom = TestCustomActor::New();
1482 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1484 Animation anim = Animation::New( 1.0f );
1485 anim.Resize( custom, Vector3( 8.0f, 9.0f, 10.0f ) );
1486 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1487 DALI_TEST_EQUALS( "OnSizeAnimation", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1488 DALI_TEST_EQUALS( 8.0f, custom.GetTargetSize().width, TEST_LOCATION );
1489 DALI_TEST_EQUALS( 9.0f, custom.GetTargetSize().height, TEST_LOCATION );
1490 DALI_TEST_EQUALS( 10.0f, custom.GetTargetSize().depth, TEST_LOCATION );
1492 anim.Resize( custom, 1.0f, 2.0f );
1493 DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1494 DALI_TEST_EQUALS( "OnSizeAnimation", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1495 DALI_TEST_EQUALS( 1.0f, custom.GetTargetSize().width, TEST_LOCATION );
1496 DALI_TEST_EQUALS( 2.0f, custom.GetTargetSize().height, TEST_LOCATION );
1500 int UtcDaliCustomActorOnTouchEvent(void)
1502 TestApplication application;
1503 tet_infoline("Testing Dali::CustomActor::OnTouchEvent()");
1505 TestCustomActor custom = TestCustomActor::New();
1506 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1508 // set size for custom actor
1509 custom.SetSize( 100, 100 );
1510 // add the custom actor to stage
1511 Stage::GetCurrent().Add( custom );
1512 custom.ResetCallStack();
1514 // Render and notify a couple of times
1515 application.SendNotification();
1516 application.Render();
1517 application.SendNotification();
1518 application.Render();
1520 // simulate a touch event
1521 Dali::TouchPoint point( 0, TouchPoint::Down, 1, 1 );
1522 Dali::Integration::TouchEvent event;
1523 event.AddPoint( point );
1524 application.ProcessEvent( event );
1526 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1527 DALI_TEST_EQUALS( "OnTouchEvent", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1531 int UtcDaliCustomActorOnHoverEvent(void)
1533 TestApplication application;
1534 tet_infoline("Testing Dali::CustomActor::OnHoverEvent()");
1536 TestCustomActor custom = TestCustomActor::New();
1537 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1539 // set size for custom actor
1540 custom.SetSize( 100, 100 );
1541 // add the custom actor to stage
1542 Stage::GetCurrent().Add( custom );
1543 custom.ResetCallStack();
1545 // Render and notify a couple of times
1546 application.SendNotification();
1547 application.Render();
1548 application.SendNotification();
1549 application.Render();
1551 // simulate a hover event
1552 Dali::TouchPoint point( 0, TouchPoint::Motion, 1, 1 );
1553 Dali::Integration::HoverEvent event;
1554 event.AddPoint( point );
1555 application.ProcessEvent( event );
1557 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1558 DALI_TEST_EQUALS( "OnHoverEvent", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1562 int UtcDaliCustomActorOnMouseWheelEvent(void)
1564 TestApplication application;
1565 tet_infoline("Testing Dali::CustomActor::OnMouseWheelEvent()");
1567 TestCustomActor custom = TestCustomActor::New();
1568 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1570 // set size for custom actor
1571 custom.SetSize( 100, 100 );
1572 // add the custom actor to stage
1573 Stage::GetCurrent().Add( custom );
1574 custom.ResetCallStack();
1576 // Render and notify a couple of times
1577 application.SendNotification();
1578 application.Render();
1579 application.SendNotification();
1580 application.Render();
1582 // simulate a mouse wheel event
1583 Vector2 screenCoordinates( 10.0f, 10.0f );
1584 Integration::MouseWheelEvent event(0, 0u, screenCoordinates, 1, 1000u);
1585 application.ProcessEvent( event );
1587 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1588 DALI_TEST_EQUALS( "OnMouseWheelEvent", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1592 int UtcDaliCustomActorFindChildByAlias(void)
1594 TestApplication application;
1595 tet_infoline("Testing Dali::CustomActor::GetChildByAlias()");
1597 TestCustomActor custom = TestCustomActor::New();
1598 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1600 custom.Add(Actor::New());
1602 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1604 DALI_TEST_CHECK( !custom.FindChildByAlias("not-found") );
1606 DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1607 DALI_TEST_EQUALS( "GetChildByAlias", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1609 DALI_TEST_CHECK( custom.FindChildByAlias("found") );
1613 int UtcDaliCustomActorImplOnPropertySet(void)
1615 TestApplication application;
1616 CustomActorImpl* impl = new Impl::SimpleTestCustomActor();
1618 impl->OnPropertySet( 0, 0 );
1620 DALI_TEST_CHECK( true );
1626 int UtcDaliCustomActorGetImplementation(void)
1628 TestApplication application;
1630 TestCustomActor custom = TestCustomActor::New();
1631 CustomActorImpl& impl = custom.GetImplementation();
1632 impl.GetOwner(); // Test
1634 const TestCustomActor constCustom = TestCustomActor::New();
1635 const CustomActorImpl& constImpl = constCustom.GetImplementation();
1636 constImpl.GetOwner(); // Test
1638 DALI_TEST_CHECK( true );
1642 int UtcDaliCustomActorDoAction(void)
1644 TestApplication application;
1645 tet_infoline("Testing Dali::CustomActor::DoAction()");
1647 TestCustomActor custom = TestCustomActor::New();
1649 BaseHandle customActorObject = custom;
1651 DALI_TEST_CHECK(customActorObject);
1653 std::vector<Property::Value> attributes;
1655 // Check that an invalid command is not performed
1656 DALI_TEST_CHECK(customActorObject.DoAction("invalidCommand", attributes) == false);
1658 // Check that the custom actor is visible
1659 custom.SetVisible(true);
1660 DALI_TEST_CHECK(custom.IsVisible() == true);
1662 // Check the custom actor performed an action to hide itself
1663 DALI_TEST_CHECK(customActorObject.DoAction("hide", attributes) == true);
1665 // flush the queue and render once
1666 application.SendNotification();
1667 application.Render();
1669 // Check that the custom actor is now invisible
1670 DALI_TEST_CHECK(custom.IsVisible() == false);
1672 // Check the custom actor performed an action to show itself
1673 DALI_TEST_CHECK(customActorObject.DoAction("show", attributes) == true);
1675 // flush the queue and render once
1676 application.SendNotification();
1677 application.Render();
1679 // Check that the custom actor is now visible
1680 DALI_TEST_CHECK(custom.IsVisible() == true);