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( ActorFlags( REQUIRES_TOUCH_EVENTS | REQUIRES_MOUSE_WHEEL_EVENTS | REQUIRES_HOVER_EVENTS | DISABLE_SIZE_NEGOTIATION ) ),
60 mDaliProperty( Property::INVALID_INDEX ),
61 mSizeSet( Vector3::ZERO ),
62 mTargetSize( Vector3::ZERO )
69 virtual ~TestCustomActor()
73 void Initialize( const char* name = NULL )
75 mDaliProperty = Self().RegisterProperty( "Dali", std::string("no"), Property::READ_WRITE);
80 virtual void OnInitialize( const char* name ) {}
83 * Resets the call stack
88 mTargetSize = Vector3();
89 mMethodsCalled.clear();
92 void AddToCallStacks( const char* method )
94 mMethodsCalled.push_back( method );
96 // Combine Actor name with method string
97 std::string nameAndMethod( Self().GetName() );
98 if ( 0 == nameAndMethod.size() )
100 nameAndMethod = "Unknown: ";
104 nameAndMethod += ": ";
106 nameAndMethod += method;
108 MasterCallStack.push_back( nameAndMethod );
111 // From CustomActorImpl
112 virtual void OnStageConnection()
114 AddToCallStacks("OnStageConnection");
116 virtual void OnStageDisconnection()
118 AddToCallStacks("OnStageDisconnection");
120 virtual void OnChildAdd(Actor& child)
122 AddToCallStacks("OnChildAdd");
124 virtual void OnChildRemove(Actor& child)
126 AddToCallStacks("OnChildRemove");
128 virtual void OnPropertySet( Property::Index index, Property::Value propertyValue )
130 AddToCallStacks("OnPropertySet");
132 virtual void OnSizeSet(const Vector3& targetSize)
134 mSizeSet = targetSize;
135 AddToCallStacks("OnSizeSet");
137 virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize)
139 mTargetSize = targetSize;
140 AddToCallStacks("OnSizeAnimation");
142 virtual bool OnTouchEvent(const TouchEvent& event)
144 AddToCallStacks("OnTouchEvent");
147 virtual bool OnHoverEvent(const HoverEvent& event)
149 AddToCallStacks("OnHoverEvent");
152 virtual bool OnMouseWheelEvent(const MouseWheelEvent& event)
154 AddToCallStacks("OnMouseWheelEvent");
157 virtual bool OnKeyEvent(const KeyEvent& event)
159 AddToCallStacks("OnKeyEvent");
162 virtual void OnKeyInputFocusGained()
164 AddToCallStacks("OnKeyInputFocusGained");
166 virtual void OnKeyInputFocusLost()
168 AddToCallStacks("OnKeyInputFocusLost");
170 virtual Vector3 GetNaturalSize()
172 return Vector3( 0.0f, 0.0f, 0.0f );
175 virtual float GetHeightForWidth( float width )
180 virtual float GetWidthForHeight( float height )
185 virtual void OnRelayout( const Vector2& size, RelayoutContainer& container )
189 virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
193 virtual void OnCalculateRelayoutSize( Dimension::Type dimension )
197 virtual float CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension )
202 virtual void OnLayoutNegotiated( float size, Dimension::Type dimension )
206 virtual bool RelayoutDependentOnChildren( Dimension::Type dimension = Dimension::ALL_DIMENSIONS )
211 void SetDaliProperty(std::string s)
213 Self().SetProperty(mDaliProperty, s) ;
216 Property::Index mDaliProperty;
217 std::vector< std::string > mMethodsCalled;
223 * Variant which adds a new child during OnStageConnection
225 struct TestCustomActorVariant1 : public TestCustomActor
230 TestCustomActorVariant1( Actor childToAdd )
231 : mChildToAdd( childToAdd )
235 // From CustomActorImpl
236 virtual void OnStageConnection()
239 TestCustomActor::OnStageConnection();
242 Self().Add( mChildToAdd );
249 * Variant which removes children during OnStageConnection
251 struct TestCustomActorVariant2 : public TestCustomActor
256 TestCustomActorVariant2()
260 // From CustomActorImpl
261 virtual void OnStageConnection()
264 TestCustomActor::OnStageConnection();
266 // Remove all the children
267 for( unsigned int i=0, num=Self().GetChildCount(); i<num; ++i )
269 Self().Remove( Self().GetChildAt(0) );
275 * Variant which adds a new child during OnStageDisconnection
277 struct TestCustomActorVariant3 : public TestCustomActor
282 TestCustomActorVariant3( Actor childToAdd )
283 : mChildToAdd( childToAdd )
287 // From CustomActorImpl
288 virtual void OnStageDisconnection()
291 TestCustomActor::OnStageDisconnection();
294 Self().Add( mChildToAdd );
301 * Variant which removes children during OnStageDisconnection
303 struct TestCustomActorVariant4 : public TestCustomActor
308 TestCustomActorVariant4()
312 // From CustomActorImpl
313 virtual void OnStageDisconnection()
316 TestCustomActor::OnStageDisconnection();
318 // Remove all the children
319 for( unsigned int i=0, num=Self().GetChildCount(); i<num; ++i )
321 Self().Remove( Self().GetChildAt(0) );
327 * Variant which removes its parent from Stage during OnStageConnection
329 struct TestCustomActorVariant5 : public TestCustomActor
334 TestCustomActorVariant5()
338 // From CustomActorImpl
339 virtual void OnStageConnection()
342 TestCustomActor::OnStageConnection();
344 // Take parent off-stage
345 Actor parent = Self().GetParent();
348 Stage::GetCurrent().Remove( parent );
354 * Variant which adds its parent to Stage during OnStageDisconnection
356 struct TestCustomActorVariant6 : public TestCustomActor
361 TestCustomActorVariant6()
365 // From CustomActorImpl
366 virtual void OnStageDisconnection()
369 TestCustomActor::OnStageDisconnection();
371 // Put parent on-stage
372 Actor parent = Self().GetParent();
375 Stage::GetCurrent().Add( parent );
381 * Variant which reparents its children into a separate container
383 struct TestCustomActorVariant7 : public TestCustomActor
388 TestCustomActorVariant7()
392 virtual void OnInitialize( const char* name )
394 // We need to do this early, before the OnChildAdd is recorded
395 Self().SetName( name );
397 mContainer = Actor::New();
398 mContainer.SetName( "Container" );
399 Self().Add( mContainer );
402 // From CustomActorImpl
403 virtual void OnChildAdd(Actor& child)
406 TestCustomActor::OnChildAdd(child);
409 if ( child != mContainer )
411 mContainer.Add( child );
419 * Variant which attempts to interfere with the reparenting of a child to another container
421 struct TestCustomActorVariant8 : public TestCustomActor
426 TestCustomActorVariant8( Actor rival )
427 : mRivalContainer( rival )
431 // From CustomActorImpl
432 virtual void OnChildRemove(Actor& child)
435 TestCustomActor::OnChildRemove(child);
437 mRivalContainer.Remove( child ); // attempt to block reparenting to rival (should be a NOOP)
440 Actor mRivalContainer;
443 // Need a class that doesn't override virtual methods
444 class SimpleTestCustomActor : public CustomActorImpl
451 SimpleTestCustomActor()
452 : CustomActorImpl( ActorFlags( REQUIRES_TOUCH_EVENTS | DISABLE_SIZE_NEGOTIATION ) )
459 virtual ~SimpleTestCustomActor()
463 // From CustomActorImpl
464 virtual void OnStageConnection()
467 virtual void OnStageDisconnection()
470 virtual void OnChildAdd(Actor& child)
473 virtual void OnChildRemove(Actor& child)
476 virtual void OnSizeSet(const Vector3& targetSize)
479 virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize)
482 virtual bool OnTouchEvent(const TouchEvent& event)
486 virtual bool OnHoverEvent(const HoverEvent& event)
490 virtual bool OnMouseWheelEvent(const MouseWheelEvent& event)
494 virtual bool OnKeyEvent(const KeyEvent& event)
498 virtual void OnKeyInputFocusGained()
501 virtual void OnKeyInputFocusLost()
505 virtual Vector3 GetNaturalSize()
507 return Vector3( 0.0f, 0.0f, 0.0f );
510 virtual float GetHeightForWidth( float width )
515 virtual float GetWidthForHeight( float height )
520 virtual void OnRelayout( const Vector2& size, RelayoutContainer& container )
524 virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
528 virtual void OnCalculateRelayoutSize( Dimension::Type dimension )
532 virtual float CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension )
537 virtual void OnLayoutNegotiated( float size, Dimension::Type dimension )
541 virtual bool RelayoutDependentOnChildren( Dimension::Type dimension = Dimension::ALL_DIMENSIONS )
547 } ; // namespace Impl
554 * Test custom actor handle
556 class TestCustomActor : public CustomActor
560 static TestCustomActor New()
562 Impl::TestCustomActor* impl = new Impl::TestCustomActor;
563 TestCustomActor custom( *impl ); // takes ownership
570 static TestCustomActor NewVariant1( Actor childToAdd )
572 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant1( childToAdd );
573 TestCustomActor custom( *impl ); // takes ownership
580 static TestCustomActor NewVariant2()
582 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant2();
583 TestCustomActor custom( *impl ); // takes ownership
590 static TestCustomActor NewVariant3( Actor childToAdd )
592 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant3( childToAdd );
593 TestCustomActor custom( *impl ); // takes ownership
600 static TestCustomActor NewVariant4()
602 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant4();
603 TestCustomActor custom( *impl ); // takes ownership
610 static TestCustomActor NewVariant5()
612 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant5();
613 TestCustomActor custom( *impl ); // takes ownership
620 static TestCustomActor NewVariant6()
622 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant6();
623 TestCustomActor custom( *impl ); // takes ownership
630 static TestCustomActor NewVariant7( const char* name )
632 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant7();
633 TestCustomActor custom( *impl ); // takes ownership
635 impl->Initialize( name );
640 static TestCustomActor NewVariant8( Actor rival )
642 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant8( rival );
643 TestCustomActor custom( *impl ); // takes ownership
650 virtual ~TestCustomActor()
654 Impl::TestCustomActor& GetImpl()
656 return static_cast<Impl::TestCustomActor&>(GetImplementation());
659 std::vector< std::string >& GetMethodsCalled()
661 return GetImpl().mMethodsCalled;
664 void ResetCallStack()
666 GetImpl().ResetCallStack();
669 void SetDaliProperty(std::string s)
671 GetImpl().SetDaliProperty(s);
676 return GetImpl().mSizeSet;
679 Vector3 GetTargetSize()
681 return GetImpl().mTargetSize;
684 virtual Vector3 GetNaturalSize()
686 return Vector3( 0.0f, 0.0f, 0.0f );
689 virtual float GetHeightForWidth( float width )
694 virtual float GetWidthForHeight( float height )
699 virtual void OnRelayout( const Vector2& size, RelayoutContainer& container )
703 virtual void OnLayoutNegotiated( float size, Dimension::Type dimension )
707 virtual void OnCalculateRelayoutSize( Dimension::Type dimension )
713 TestCustomActor( Impl::TestCustomActor& impl ) : CustomActor( impl )
720 using namespace Dali;
722 BaseHandle CreateActor()
724 return TestCustomActor::New();
727 Dali::TypeRegistration mType( typeid(TestCustomActor), typeid(Dali::CustomActor), CreateActor );
732 int UtcDaliCustomActorDestructor(void)
734 TestApplication application;
736 CustomActor* actor = new CustomActor();
739 DALI_TEST_CHECK( true );
743 int UtcDaliCustomActorImplDestructor(void)
745 TestApplication application;
746 CustomActorImpl* actor = new Impl::TestCustomActor();
749 DALI_TEST_CHECK( true );
753 // Positive test case for a method
754 int UtcDaliCustomActorDownCast(void)
756 TestApplication application;
757 tet_infoline("Testing Dali::CustomActor::DownCast()");
759 TestCustomActor custom = TestCustomActor::New();
761 Actor anActor = Actor::New();
762 anActor.Add( custom );
764 Actor child = anActor.GetChildAt(0);
765 CustomActor customActor = CustomActor::DownCast( child );
766 DALI_TEST_CHECK( customActor );
769 DALI_TEST_CHECK( !customActor );
771 customActor = DownCast< CustomActor >( child );
772 DALI_TEST_CHECK( customActor );
776 // Negative test case for a method
777 int UtcDaliCustomActorDownCastNegative(void)
779 TestApplication application;
780 tet_infoline("Testing Dali::CustomActor::DownCast()");
782 Actor actor1 = Actor::New();
783 Actor anActor = Actor::New();
786 Actor child = anActor.GetChildAt(0);
787 CustomActor customActor = CustomActor::DownCast( child );
788 DALI_TEST_CHECK( !customActor );
790 Actor unInitialzedActor;
791 customActor = CustomActor::DownCast( unInitialzedActor );
792 DALI_TEST_CHECK( !customActor );
794 customActor = DownCast< CustomActor >( unInitialzedActor );
795 DALI_TEST_CHECK( !customActor );
799 int UtcDaliCustomActorOnStageConnectionDisconnection(void)
801 TestApplication application;
802 tet_infoline("Testing Dali::CustomActor::OnStageConnection() & OnStageDisconnection");
804 TestCustomActor custom = TestCustomActor::New();
805 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
807 // add the custom actor to stage
808 Stage::GetCurrent().Add( custom );
810 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
811 DALI_TEST_EQUALS( "OnStageConnection", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
813 Stage::GetCurrent().Remove( custom );
815 DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
816 DALI_TEST_EQUALS( "OnStageDisconnection", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
818 // Excercise the message passing to Update thread
820 application.SendNotification();
821 application.Render();
822 application.Render();
826 int UtcDaliCustomActorOnStageConnectionOrder(void)
828 TestApplication application;
829 tet_infoline("Testing Dali::CustomActor::OnStageConnection() order");
831 MasterCallStack.clear();
833 /* Build tree of actors:
841 * OnStageConnection should be received for A, B, D, E, C, and finally F
844 TestCustomActor actorA = TestCustomActor::New();
845 actorA.SetName( "ActorA" );
847 TestCustomActor actorB = TestCustomActor::New();
848 actorB.SetName( "ActorB" );
849 actorA.Add( actorB );
851 TestCustomActor actorC = TestCustomActor::New();
852 actorC.SetName( "ActorC" );
853 actorA.Add( actorC );
855 TestCustomActor actorD = TestCustomActor::New();
856 actorD.SetName( "ActorD" );
857 actorB.Add( actorD );
859 TestCustomActor actorE = TestCustomActor::New();
860 actorE.SetName( "ActorE" );
861 actorB.Add( actorE );
863 TestCustomActor actorF = TestCustomActor::New();
864 actorF.SetName( "ActorF" );
865 actorC.Add( actorF );
867 // add the custom actor to stage
868 Stage::GetCurrent().Add( actorA );
870 DALI_TEST_EQUALS( 3, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
871 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
872 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
873 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION );
875 DALI_TEST_EQUALS( 3, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
876 DALI_TEST_EQUALS( "OnChildAdd", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
877 DALI_TEST_EQUALS( "OnChildAdd", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
878 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 2 ], TEST_LOCATION );
880 DALI_TEST_EQUALS( 2, (int)(actorC.GetMethodsCalled().size()), TEST_LOCATION );
881 DALI_TEST_EQUALS( "OnChildAdd", actorC.GetMethodsCalled()[ 0 ], TEST_LOCATION );
882 DALI_TEST_EQUALS( "OnStageConnection", actorC.GetMethodsCalled()[ 1 ], TEST_LOCATION );
884 DALI_TEST_EQUALS( 1, (int)(actorD.GetMethodsCalled().size()), TEST_LOCATION );
885 DALI_TEST_EQUALS( "OnStageConnection", actorD.GetMethodsCalled()[ 0 ], TEST_LOCATION );
887 DALI_TEST_EQUALS( 1, (int)(actorE.GetMethodsCalled().size()), TEST_LOCATION );
888 DALI_TEST_EQUALS( "OnStageConnection", actorE.GetMethodsCalled()[ 0 ], TEST_LOCATION );
890 DALI_TEST_EQUALS( 1, (int)(actorF.GetMethodsCalled().size()), TEST_LOCATION );
891 DALI_TEST_EQUALS( "OnStageConnection", actorF.GetMethodsCalled()[ 0 ], TEST_LOCATION );
893 // Check sequence is correct in MasterCallStack
895 DALI_TEST_EQUALS( 3+3+2+1+1+1, (int)(MasterCallStack.size()), TEST_LOCATION );
897 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 0 ], TEST_LOCATION );
898 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 1 ], TEST_LOCATION );
899 DALI_TEST_EQUALS( "ActorB: OnChildAdd", MasterCallStack[ 2 ], TEST_LOCATION );
900 DALI_TEST_EQUALS( "ActorB: OnChildAdd", MasterCallStack[ 3 ], TEST_LOCATION );
901 DALI_TEST_EQUALS( "ActorC: OnChildAdd", MasterCallStack[ 4 ], TEST_LOCATION );
903 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 5 ], TEST_LOCATION );
904 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 6 ], TEST_LOCATION );
905 DALI_TEST_EQUALS( "ActorD: OnStageConnection", MasterCallStack[ 7 ], TEST_LOCATION );
906 DALI_TEST_EQUALS( "ActorE: OnStageConnection", MasterCallStack[ 8 ], TEST_LOCATION );
907 DALI_TEST_EQUALS( "ActorC: OnStageConnection", MasterCallStack[ 9 ], TEST_LOCATION );
908 DALI_TEST_EQUALS( "ActorF: OnStageConnection", MasterCallStack[ 10 ], TEST_LOCATION );
910 // Excercise the message passing to Update thread
912 application.SendNotification();
913 application.Render();
914 application.Render();
918 int UtcDaliCustomActorOnStageDisconnectionOrder(void)
920 TestApplication application;
921 tet_infoline("Testing Dali::CustomActor::OnStageDisconnection() order");
923 Stage stage = Stage::GetCurrent();
925 /* Build tree of actors:
933 * OnStageDisconnection should be received for D, E, B, F, C, and finally A.
936 TestCustomActor actorA = TestCustomActor::New();
937 actorA.SetName( "ActorA" );
940 TestCustomActor actorB = TestCustomActor::New();
941 actorB.SetName( "ActorB" );
942 actorA.Add( actorB );
944 TestCustomActor actorC = TestCustomActor::New();
945 actorC.SetName( "ActorC" );
946 actorA.Add( actorC );
948 TestCustomActor actorD = TestCustomActor::New();
949 actorD.SetName( "ActorD" );
950 actorB.Add( actorD );
952 TestCustomActor actorE = TestCustomActor::New();
953 actorE.SetName( "ActorE" );
954 actorB.Add( actorE );
956 TestCustomActor actorF = TestCustomActor::New();
957 actorF.SetName( "ActorF" );
958 actorC.Add( actorF );
960 // Excercise the message passing to Update thread
962 application.SendNotification();
963 application.Render();
964 application.Render();
966 // Clear call stacks before disconnection
967 actorA.ResetCallStack();
968 actorB.ResetCallStack();
969 actorC.ResetCallStack();
970 actorD.ResetCallStack();
971 actorE.ResetCallStack();
972 actorF.ResetCallStack();
973 MasterCallStack.clear();
975 stage.Remove( actorA );
977 DALI_TEST_EQUALS( 1, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
978 DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
980 DALI_TEST_EQUALS( 1, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
981 DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
983 DALI_TEST_EQUALS( 1, (int)(actorC.GetMethodsCalled().size()), TEST_LOCATION );
984 DALI_TEST_EQUALS( "OnStageDisconnection", actorC.GetMethodsCalled()[ 0 ], TEST_LOCATION );
986 DALI_TEST_EQUALS( 1, (int)(actorD.GetMethodsCalled().size()), TEST_LOCATION );
987 DALI_TEST_EQUALS( "OnStageDisconnection", actorD.GetMethodsCalled()[ 0 ], TEST_LOCATION );
989 DALI_TEST_EQUALS( 1, (int)(actorE.GetMethodsCalled().size()), TEST_LOCATION );
990 DALI_TEST_EQUALS( "OnStageDisconnection", actorE.GetMethodsCalled()[ 0 ], TEST_LOCATION );
992 DALI_TEST_EQUALS( 1, (int)(actorF.GetMethodsCalled().size()), TEST_LOCATION );
993 DALI_TEST_EQUALS( "OnStageDisconnection", actorF.GetMethodsCalled()[ 0 ], TEST_LOCATION );
995 // Check sequence is correct in MasterCallStack
997 DALI_TEST_EQUALS( 6, (int)(MasterCallStack.size()), TEST_LOCATION );
999 DALI_TEST_EQUALS( "ActorD: OnStageDisconnection", MasterCallStack[ 0 ], TEST_LOCATION );
1000 DALI_TEST_EQUALS( "ActorE: OnStageDisconnection", MasterCallStack[ 1 ], TEST_LOCATION );
1001 DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 2 ], TEST_LOCATION );
1002 DALI_TEST_EQUALS( "ActorF: OnStageDisconnection", MasterCallStack[ 3 ], TEST_LOCATION );
1003 DALI_TEST_EQUALS( "ActorC: OnStageDisconnection", MasterCallStack[ 4 ], TEST_LOCATION );
1004 DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 5 ], TEST_LOCATION );
1006 // Excercise the message passing to Update thread
1008 application.SendNotification();
1009 application.Render();
1010 application.Render();
1014 int UtcDaliCustomActorAddDuringOnStageConnection(void)
1016 TestApplication application;
1017 tet_infoline("Testing Actor::Add behaviour during Dali::CustomActor::OnStageConnection() callback");
1019 Stage stage = Stage::GetCurrent();
1021 MasterCallStack.clear();
1023 /* The actorA is a special variant which adds a child to itself during OnStageConnection()
1024 * The actorB is provided as the child
1027 TestCustomActor actorB = TestCustomActor::New();
1028 actorB.SetName( "ActorB" );
1030 TestCustomActor actorA = TestCustomActor::NewVariant1( actorB );
1031 actorA.SetName( "ActorA" );
1032 stage.Add( actorA );
1034 // Check callback sequence
1036 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1037 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1038 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION ); // Called from within OnStageConnection()
1040 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1041 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1043 DALI_TEST_EQUALS( 3, (int)(MasterCallStack.size()), TEST_LOCATION );
1045 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 0 ], TEST_LOCATION );
1046 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION ); // Occurs during Actor::Add from within from within OnStageConnection()
1047 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 2 ], TEST_LOCATION ); // Occurs after Actor::Add from within from within OnStageConnection()
1049 // Excercise the message passing to Update thread
1051 application.SendNotification();
1052 application.Render();
1053 application.Render();
1055 // Check everything is ok after Actors are removed
1057 stage.Remove( actorA );
1058 application.SendNotification();
1059 application.Render();
1060 application.Render();
1064 int UtcDaliCustomActorRemoveDuringOnStageConnection(void)
1066 TestApplication application;
1067 tet_infoline("Testing Actor::Remove behaviour during Dali::CustomActor::OnStageConnection() callback");
1069 Stage stage = Stage::GetCurrent();
1071 MasterCallStack.clear();
1073 /* The actorA is a special variant which removes its children during OnStageConnection()
1074 * Actors B & C are provided as the children
1077 TestCustomActor actorA = TestCustomActor::NewVariant2();
1078 actorA.SetName( "ActorA" );
1080 TestCustomActor actorB = TestCustomActor::New();
1081 actorB.SetName( "ActorB" );
1082 actorA.Add( actorB );
1084 TestCustomActor actorC = TestCustomActor::New();
1085 actorC.SetName( "ActorC" );
1086 actorA.Add( actorC );
1088 stage.Add( actorA );
1090 // Check callback sequence
1092 DALI_TEST_EQUALS( 5, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1093 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1094 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1095 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION );
1096 DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 3 ], TEST_LOCATION ); // Called from within OnStageConnection()
1097 DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 4 ], TEST_LOCATION ); // Called from within OnStageConnection()
1099 DALI_TEST_EQUALS( 5, (int)(MasterCallStack.size()), TEST_LOCATION );
1101 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 0 ], TEST_LOCATION );
1102 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 1 ], TEST_LOCATION );
1103 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 2 ], TEST_LOCATION );
1104 DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 3 ], TEST_LOCATION );
1105 DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 4 ], TEST_LOCATION );
1107 /* Actors B & C should be removed before the point where they could receive an OnStageConnection callback
1108 * Therefore they shouldn't receive either OnStageConnection or OnStageDisconnection
1110 DALI_TEST_EQUALS( 0, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1111 DALI_TEST_EQUALS( 0, (int)(actorC.GetMethodsCalled().size()), TEST_LOCATION );
1113 // Excercise the message passing to Update thread
1115 application.SendNotification();
1116 application.Render();
1117 application.Render();
1119 // Check everything is ok after last actor is removed
1121 stage.Remove( actorA );
1122 application.SendNotification();
1123 application.Render();
1124 application.Render();
1128 int UtcDaliCustomActorAddDuringOnStageDisconnection(void)
1130 TestApplication application;
1131 tet_infoline("Testing Actor::Add behaviour during Dali::CustomActor::OnStageDisonnection() callback");
1133 Stage stage = Stage::GetCurrent();
1135 /* The actorA is a special variant which adds a child to itself during OnStageDisconnection()
1136 * The actorB is provided as the child
1139 TestCustomActor actorB = TestCustomActor::New();
1140 actorB.SetName( "ActorB" );
1142 TestCustomActor actorA = TestCustomActor::NewVariant3( actorB );
1143 actorA.SetName( "ActorA" );
1144 stage.Add( actorA );
1146 // Excercise the message passing to Update thread
1148 application.SendNotification();
1149 application.Render();
1150 application.Render();
1152 // Clear call stacks before disconnection
1153 actorA.ResetCallStack();
1154 actorB.ResetCallStack();
1155 MasterCallStack.clear();
1157 stage.Remove( actorA );
1159 // Check callback sequence
1161 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1162 DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1163 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1165 // Child was added after parent disconnection, so should not receive OnStageConnection()
1166 DALI_TEST_EQUALS( 0, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1168 DALI_TEST_EQUALS( 2, (int)(MasterCallStack.size()), TEST_LOCATION );
1170 DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 0 ], TEST_LOCATION );
1171 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 1 ], TEST_LOCATION );
1173 // Excercise the message passing to Update thread
1175 application.SendNotification();
1176 application.Render();
1177 application.Render();
1181 int UtcDaliCustomActorRemoveDuringOnStageDisconnection(void)
1183 TestApplication application;
1184 tet_infoline("Testing Actor::Remove behaviour during Dali::CustomActor::OnStageDisconnection() callback");
1186 Stage stage = Stage::GetCurrent();
1188 /* The actorA is a special variant which removes its children during OnStageDisconnection()
1189 * The actorB is provided as the child
1192 TestCustomActor actorA = TestCustomActor::NewVariant4();
1193 actorA.SetName( "ActorA" );
1194 stage.Add( actorA );
1196 TestCustomActor actorB = TestCustomActor::New();
1197 actorB.SetName( "ActorB" );
1198 actorA.Add( actorB );
1200 // Excercise the message passing to Update thread
1202 application.SendNotification();
1203 application.Render();
1204 application.Render();
1206 // Clear call stacks before disconnection
1207 actorA.ResetCallStack();
1208 actorB.ResetCallStack();
1209 MasterCallStack.clear();
1211 stage.Remove( actorA );
1213 // Check callback sequence
1215 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1216 DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1217 DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1219 DALI_TEST_EQUALS( 1, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1220 DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1222 DALI_TEST_EQUALS( 3, (int)(MasterCallStack.size()), TEST_LOCATION );
1224 DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 0 ], TEST_LOCATION );
1225 DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 1 ], TEST_LOCATION );
1226 DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 2 ], TEST_LOCATION );
1228 // Excercise the message passing to Update thread
1230 application.SendNotification();
1231 application.Render();
1232 application.Render();
1236 int UtcDaliCustomActorRemoveParentDuringOnStageConnection(void)
1238 TestApplication application;
1239 tet_infoline("Weird test where child removes its own parent from Stage during Dali::CustomActor::OnStageConnection() callback");
1241 Stage stage = Stage::GetCurrent();
1243 MasterCallStack.clear();
1245 /* The actorA is the parent of actorB
1246 * The actorB is a special variant which removes its own parent during OnStageConnection()
1247 * The child actor is interrupting the parent's connection to stage, therefore the parent should not get an OnStageDisconnection()
1250 TestCustomActor actorA = TestCustomActor::New();
1251 actorA.SetName( "ActorA" );
1253 TestCustomActor actorB = TestCustomActor::NewVariant5();
1254 actorB.SetName( "ActorB" );
1255 actorA.Add( actorB );
1257 stage.Add( actorA );
1259 // Check callback sequence
1261 DALI_TEST_EQUALS( 3, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1262 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1263 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1264 DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION );
1266 DALI_TEST_EQUALS( 1, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1267 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1269 DALI_TEST_EQUALS( 4, (int)(MasterCallStack.size()), TEST_LOCATION );
1271 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 0 ], TEST_LOCATION );
1272 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION );
1273 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 2 ], TEST_LOCATION );
1274 DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 3 ], TEST_LOCATION );
1276 // Excercise the message passing to Update thread
1278 application.SendNotification();
1279 application.Render();
1280 application.Render();
1284 int UtcDaliCustomActorAddParentDuringOnStageDisconnection(void)
1286 TestApplication application;
1287 tet_infoline("Weird test where child adds its own parent to Stage during Dali::CustomActor::OnStageDisconnection() callback");
1289 Stage stage = Stage::GetCurrent();
1291 MasterCallStack.clear();
1293 /* The actorA is the parent of actorB
1294 * The actorB is a special variant which (weirdly) adds its own parent during OnStageDisconnection()
1295 * The child actor is interrupting the disconnection, such that parent should not get a OnStageDisconnection()
1298 TestCustomActor actorA = TestCustomActor::New();
1299 actorA.SetName( "ActorA" );
1300 stage.Add( actorA );
1302 TestCustomActor actorB = TestCustomActor::NewVariant6();
1303 actorB.SetName( "ActorB" );
1304 actorA.Add( actorB );
1306 stage.Remove( actorA );
1308 // Check callback sequence
1310 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1311 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1312 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1314 DALI_TEST_EQUALS( 2, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1315 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1316 DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1317 // Disconnect was interrupted, so we should only get one OnStageConnection() for actorB
1319 DALI_TEST_EQUALS( 4, (int)(MasterCallStack.size()), TEST_LOCATION );
1321 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 0 ], TEST_LOCATION );
1322 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION );
1323 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 2 ], TEST_LOCATION );
1324 DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 3 ], TEST_LOCATION );
1326 // Excercise the message passing to Update thread
1328 application.SendNotification();
1329 application.Render();
1330 application.Render();
1334 int UtcDaliCustomActorOnChildAddRemove(void)
1336 TestApplication application;
1337 tet_infoline("Testing Dali::CustomActor::OnChildAdd() & OnChildRemove()");
1339 TestCustomActor custom = TestCustomActor::New();
1340 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1342 Actor aChild = Actor::New();
1343 custom.Add( aChild );
1345 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1346 DALI_TEST_EQUALS( "OnChildAdd", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1348 custom.Remove( aChild );
1350 DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1351 DALI_TEST_EQUALS( "OnChildRemove", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1355 int UtcDaliCustomActorReparentDuringOnChildAdd(void)
1357 TestApplication application;
1358 tet_infoline("Testing Actor:Add (reparenting) behaviour during Dali::CustomActor::OnChildAdd() callback");
1360 Stage stage = Stage::GetCurrent();
1362 MasterCallStack.clear();
1364 /* The actorA is a special variant which reparents children added into a separate container child
1365 * The actorB is the child of actorA
1368 TestCustomActor actorA = TestCustomActor::NewVariant7( "ActorA" );
1369 stage.Add( actorA );
1371 TestCustomActor actorB = TestCustomActor::New();
1372 actorB.SetName( "ActorB" );
1373 actorA.Add( actorB );
1375 // Check hierarchy is as follows:
1382 DALI_TEST_EQUALS( 1, (int)(actorA.GetChildCount()), TEST_LOCATION );
1384 Actor container = actorA.GetChildAt(0);
1385 Actor containerChild;
1387 DALI_TEST_CHECK( container );
1390 DALI_TEST_EQUALS( "Container", container.GetName(), TEST_LOCATION );
1391 DALI_TEST_EQUALS( 1, (int)(container.GetChildCount()), TEST_LOCATION );
1392 containerChild = container.GetChildAt(0);
1395 DALI_TEST_CHECK( containerChild );
1396 if ( containerChild )
1398 DALI_TEST_EQUALS( "ActorB", containerChild.GetName(), TEST_LOCATION );
1399 DALI_TEST_EQUALS( 0, (int)(containerChild.GetChildCount()), TEST_LOCATION );
1402 // Check callback sequence
1404 DALI_TEST_EQUALS( 4, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1405 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION ); // The mContainer added to actorA
1406 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1407 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION ); // The actorB added to actorA
1408 DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 3 ], TEST_LOCATION );
1409 // mContainer will then receive OnChildAdd
1411 DALI_TEST_EQUALS( 3, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1412 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1413 DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1414 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 2 ], TEST_LOCATION );
1416 DALI_TEST_EQUALS( 7, (int)(MasterCallStack.size()), TEST_LOCATION );
1418 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 0 ], TEST_LOCATION );
1419 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION );
1420 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 2 ], TEST_LOCATION );
1421 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 3 ], TEST_LOCATION );
1422 DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 4 ], TEST_LOCATION );
1423 DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 5 ], TEST_LOCATION );
1424 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 6 ], TEST_LOCATION );
1426 // Excercise the message passing to Update thread
1428 application.SendNotification();
1429 application.Render();
1430 application.Render();
1435 * Test that Remove can be called (a NOOP) during the OnChildRemove
1436 * triggered when reparenting an actor
1438 int UtcDaliCustomActorRemoveDuringOnChildRemove(void)
1440 TestApplication application;
1441 tet_infoline("Testing Actor:Remove behaviour during OnChildRemove() callback triggered when reparenting");
1443 Stage stage = Stage::GetCurrent();
1445 MasterCallStack.clear();
1447 /* The childActor will be reparented from actorA to actorB
1448 * The actorA is a special variant which attempts to remove a child from actorB, during the OnChildRemove callback()
1449 * This should be a NOOP since the reparenting has not occured yet
1452 TestCustomActor actorB = TestCustomActor::New();
1453 actorB.SetName( "ActorB" );
1454 stage.Add( actorB );
1456 TestCustomActor actorA = TestCustomActor::NewVariant8( actorB );
1457 actorA.SetName( "ActorA" );
1458 stage.Add( actorA );
1460 Actor childActor = Actor::New();
1461 childActor.SetName( "Child" );
1462 // Reparent from actorA to actorB
1463 actorA.Add( childActor );
1464 actorB.Add( childActor );
1466 // Check hierarchy is as follows:
1471 DALI_TEST_EQUALS( 0, (int)(actorA.GetChildCount()), TEST_LOCATION );
1472 DALI_TEST_EQUALS( 1, (int)(actorB.GetChildCount()), TEST_LOCATION );
1473 DALI_TEST_EQUALS( 0, (int)(childActor.GetChildCount()), TEST_LOCATION );
1475 Actor child = actorB.GetChildAt(0);
1477 DALI_TEST_CHECK( child );
1480 DALI_TEST_EQUALS( "Child", child.GetName(), TEST_LOCATION );
1483 // Check callback sequence
1485 DALI_TEST_EQUALS( 3, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
1486 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION ); // The mContainer added to actorA
1487 DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1488 DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION ); // The actorB added to actorA
1489 // mContainer will then receive OnChildAdd
1491 DALI_TEST_EQUALS( 2, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
1492 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1493 DALI_TEST_EQUALS( "OnChildAdd", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1495 DALI_TEST_EQUALS( 5, (int)(MasterCallStack.size()), TEST_LOCATION );
1497 DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 0 ], TEST_LOCATION );
1498 DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION );
1499 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 2 ], TEST_LOCATION );
1500 DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 3 ], TEST_LOCATION );
1501 DALI_TEST_EQUALS( "ActorB: OnChildAdd", MasterCallStack[ 4 ], TEST_LOCATION );
1503 // Excercise the message passing to Update thread
1505 application.SendNotification();
1506 application.Render();
1507 application.Render();
1511 int UtcDaliCustomActorOnPropertySet(void)
1513 TestApplication application;
1514 tet_infoline("Testing Dali::CustomActor::OnPropertySet()");
1516 TestCustomActor custom = TestCustomActor::New();
1517 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1519 custom.SetDaliProperty("yes") ;
1521 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1522 DALI_TEST_EQUALS( "OnPropertySet", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1526 int UtcDaliCustomActorOnSizeSet(void)
1528 TestApplication application;
1529 tet_infoline("Testing Dali::CustomActor::OnSizeSet()");
1531 TestCustomActor custom = TestCustomActor::New();
1532 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1534 custom.SetSize( Vector2( 9.0f, 10.0f ) );
1535 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1536 DALI_TEST_EQUALS( "OnSizeSet", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1537 DALI_TEST_EQUALS( 9.0f, custom.GetSize().width, TEST_LOCATION );
1538 DALI_TEST_EQUALS( 10.0f, custom.GetSize().height, TEST_LOCATION );
1540 custom.SetSize( Vector3( 4.0f, 5.0f, 6.0f ) );
1541 DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1542 DALI_TEST_EQUALS( "OnSizeSet", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
1543 DALI_TEST_EQUALS( 4.0f, custom.GetSize().width, TEST_LOCATION );
1544 DALI_TEST_EQUALS( 5.0f, custom.GetSize().height, TEST_LOCATION );
1545 DALI_TEST_EQUALS( 6.0f, custom.GetSize().depth, TEST_LOCATION );
1549 int UtcDaliCustomActorOnSizeAnimation(void)
1551 TestApplication application;
1552 tet_infoline("Testing Dali::CustomActor::OnSizeAnimation()");
1554 TestCustomActor custom = TestCustomActor::New();
1555 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1557 Animation anim = Animation::New( 1.0f );
1558 anim.AnimateTo( Property( custom, Actor::Property::SIZE ), Vector3( 8.0f, 9.0f, 10.0f ) );
1559 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1560 DALI_TEST_EQUALS( "OnSizeAnimation", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1561 DALI_TEST_EQUALS( 8.0f, custom.GetTargetSize().width, TEST_LOCATION );
1562 DALI_TEST_EQUALS( 9.0f, custom.GetTargetSize().height, TEST_LOCATION );
1563 DALI_TEST_EQUALS( 10.0f, custom.GetTargetSize().depth, TEST_LOCATION );
1567 int UtcDaliCustomActorOnTouchEvent(void)
1569 TestApplication application;
1570 tet_infoline("Testing Dali::CustomActor::OnTouchEvent()");
1572 TestCustomActor custom = TestCustomActor::New();
1573 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1575 // set size for custom actor
1576 custom.SetSize( 100, 100 );
1577 // add the custom actor to stage
1578 Stage::GetCurrent().Add( custom );
1579 custom.ResetCallStack();
1581 // Render and notify a couple of times
1582 application.SendNotification();
1583 application.Render();
1584 application.SendNotification();
1585 application.Render();
1587 // simulate a touch event
1588 Dali::TouchPoint point( 0, TouchPoint::Down, 1, 1 );
1589 Dali::Integration::TouchEvent event;
1590 event.AddPoint( point );
1591 application.ProcessEvent( event );
1593 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1594 DALI_TEST_EQUALS( "OnTouchEvent", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1598 int UtcDaliCustomActorOnHoverEvent(void)
1600 TestApplication application;
1601 tet_infoline("Testing Dali::CustomActor::OnHoverEvent()");
1603 TestCustomActor custom = TestCustomActor::New();
1604 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1606 // set size for custom actor
1607 custom.SetSize( 100, 100 );
1608 // add the custom actor to stage
1609 Stage::GetCurrent().Add( custom );
1610 custom.ResetCallStack();
1612 // Render and notify a couple of times
1613 application.SendNotification();
1614 application.Render();
1615 application.SendNotification();
1616 application.Render();
1618 // simulate a hover event
1619 Dali::TouchPoint point( 0, TouchPoint::Motion, 1, 1 );
1620 Dali::Integration::HoverEvent event;
1621 event.AddPoint( point );
1622 application.ProcessEvent( event );
1624 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1625 DALI_TEST_EQUALS( "OnHoverEvent", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1629 int UtcDaliCustomActorOnMouseWheelEvent(void)
1631 TestApplication application;
1632 tet_infoline("Testing Dali::CustomActor::OnMouseWheelEvent()");
1634 TestCustomActor custom = TestCustomActor::New();
1635 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1637 // set size for custom actor
1638 custom.SetSize( 100, 100 );
1639 // add the custom actor to stage
1640 Stage::GetCurrent().Add( custom );
1641 custom.ResetCallStack();
1643 // Render and notify a couple of times
1644 application.SendNotification();
1645 application.Render();
1646 application.SendNotification();
1647 application.Render();
1649 // simulate a mouse wheel event
1650 Vector2 screenCoordinates( 10.0f, 10.0f );
1651 Integration::MouseWheelEvent event(0, 0u, screenCoordinates, 1, 1000u);
1652 application.ProcessEvent( event );
1654 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1655 DALI_TEST_EQUALS( "OnMouseWheelEvent", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1659 int UtcDaliCustomActorImplOnPropertySet(void)
1661 TestApplication application;
1662 CustomActorImpl* impl = new Impl::SimpleTestCustomActor();
1664 impl->OnPropertySet( 0, 0 );
1666 DALI_TEST_CHECK( true );
1672 int UtcDaliCustomActorGetImplementation(void)
1674 TestApplication application;
1676 TestCustomActor custom = TestCustomActor::New();
1677 CustomActorImpl& impl = custom.GetImplementation();
1678 impl.GetOwner(); // Test
1680 const TestCustomActor constCustom = TestCustomActor::New();
1681 const CustomActorImpl& constImpl = constCustom.GetImplementation();
1682 constImpl.GetOwner(); // Test
1684 DALI_TEST_CHECK( true );
1688 int UtcDaliCustomActorDoAction(void)
1690 TestApplication application;
1691 tet_infoline("Testing Dali::CustomActor::DoAction()");
1693 TestCustomActor custom = TestCustomActor::New();
1695 BaseHandle customActorObject = custom;
1697 DALI_TEST_CHECK(customActorObject);
1699 std::vector<Property::Value> attributes;
1701 // Check that an invalid command is not performed
1702 DALI_TEST_CHECK(customActorObject.DoAction("invalidCommand", attributes) == false);
1704 // Check that the custom actor is visible
1705 custom.SetVisible(true);
1706 DALI_TEST_CHECK(custom.IsVisible() == true);
1708 // Check the custom actor performed an action to hide itself
1709 DALI_TEST_CHECK(customActorObject.DoAction("hide", attributes) == true);
1711 // flush the queue and render once
1712 application.SendNotification();
1713 application.Render();
1715 // Check that the custom actor is now invisible
1716 DALI_TEST_CHECK(custom.IsVisible() == false);
1718 // Check the custom actor performed an action to show itself
1719 DALI_TEST_CHECK(customActorObject.DoAction("show", attributes) == true);
1721 // flush the queue and render once
1722 application.SendNotification();
1723 application.Render();
1725 // Check that the custom actor is now visible
1726 DALI_TEST_CHECK(custom.IsVisible() == true);