2 * Copyright (c) 2016 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.
21 #include <dali/public-api/dali-core.h>
22 #include <dali-test-suite-utils.h>
23 #include <dali/integration-api/events/long-press-gesture-event.h>
24 #include <dali/integration-api/events/pan-gesture-event.h>
25 #include <dali/integration-api/events/pinch-gesture-event.h>
26 #include <dali/integration-api/events/tap-gesture-event.h>
27 #include <dali/integration-api/events/touch-event-integ.h>
28 #include <dali/integration-api/events/hover-event-integ.h>
36 // Stores data that is populated in the callback and will be read by the Test cases
40 : functorCalled( false ),
41 voidFunctorCalled( false ),
42 receivedGesture( Gesture::Clear ),
48 functorCalled = false;
49 voidFunctorCalled = false;
51 receivedGesture.numberOfTouches = 0u;
52 receivedGesture.screenPoint = Vector2(0.0f, 0.0f);
53 receivedGesture.localPoint = Vector2(0.0f, 0.0f);
59 bool voidFunctorCalled;
60 LongPressGesture receivedGesture;
64 // Functor that sets the data when called
65 struct GestureReceivedFunctor
67 GestureReceivedFunctor(SignalData& data) : signalData(data) { }
69 void operator()(Actor actor, LongPressGesture longPress)
71 signalData.functorCalled = true;
72 signalData.receivedGesture = longPress;
73 signalData.pressedActor = actor;
78 signalData.voidFunctorCalled = true;
81 SignalData& signalData;
84 // Generate a LongPressGestureEvent to send to Core
85 Integration::LongPressGestureEvent GenerateLongPress(
87 unsigned int numberOfTouches,
90 Integration::LongPressGestureEvent longPress( state );
92 longPress.numberOfTouches = numberOfTouches;
93 longPress.point = point;
98 // Generate a PanGestureEvent to send to Core
99 Integration::PanGestureEvent GeneratePan(
100 Gesture::State state,
101 Vector2 previousPosition,
102 Vector2 currentPosition,
103 unsigned long timeDelta,
104 unsigned int numberOfTouches = 1,
105 unsigned int time = 1u)
107 Integration::PanGestureEvent pan(state);
109 pan.previousPosition = previousPosition;
110 pan.currentPosition = currentPosition;
111 pan.timeDelta = timeDelta;
112 pan.numberOfTouches = numberOfTouches;
117 // Generate a PinchGestureEvent to send to Core
118 Integration::PinchGestureEvent GeneratePinch(
119 Gesture::State state,
124 Integration::PinchGestureEvent pinch(state);
128 pinch.centerPoint = centerpoint;
132 // Generate a TapGestureEvent to send to Core
133 Integration::TapGestureEvent GenerateTap(
134 Gesture::State state,
135 unsigned int numberOfTaps,
136 unsigned int numberOfTouches,
139 Integration::TapGestureEvent tap( state );
141 tap.numberOfTaps = numberOfTaps;
142 tap.numberOfTouches = numberOfTouches;
149 // Create function as Init function called
151 static bool CreateCustomInitCalled = false;
152 BaseHandle CreateCustomInit(void)
154 CreateCustomInitCalled = true;
158 static bool CreateCustomNamedInitCalled = false;
159 BaseHandle CreateCustomNamedInit(void)
161 CreateCustomNamedInitCalled = true;
165 const std::string scriptedName("PopupStyle");
166 static TypeRegistration scriptedType( scriptedName, typeid(Dali::CustomActor), CreateCustomNamedInit );
168 // Property Registration
169 bool setPropertyCalled = false;
170 bool getPropertyCalled = false;
171 void SetProperty( BaseObject* object, Property::Index propertyIndex, const Property::Value& value )
173 setPropertyCalled = true;
175 Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex )
177 getPropertyCalled = true;
178 return Property::Value( true );
183 /*******************************************************************************
187 ******************************************************************************/
190 struct MyTestCustomActor : public CustomActorImpl
192 typedef Signal< void ()> SignalType;
193 typedef Signal< void (float)> SignalTypeFloat;
195 MyTestCustomActor() : CustomActorImpl( ActorFlags( REQUIRES_TOUCH_EVENTS ) )
198 virtual ~MyTestCustomActor()
201 void ResetCallStack()
205 // From CustomActorImpl
206 virtual void OnStageConnection( int depth )
209 virtual void OnStageDisconnection()
212 virtual void OnChildAdd(Actor& child)
215 virtual void OnChildRemove(Actor& child)
218 virtual void OnSizeSet(const Vector3& targetSize)
221 virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize)
224 virtual bool OnTouchEvent(const TouchEvent& event)
228 virtual bool OnHoverEvent(const HoverEvent& event)
232 virtual bool OnWheelEvent(const WheelEvent& event)
236 virtual bool OnKeyEvent(const KeyEvent& event)
240 virtual void OnKeyInputFocusGained()
243 virtual void OnKeyInputFocusLost()
246 virtual Vector3 GetNaturalSize()
248 return Vector3( 0.0f, 0.0f, 0.0f );
251 virtual float GetHeightForWidth( float width )
256 virtual float GetWidthForHeight( float height )
261 virtual void OnRelayout( const Vector2& size, RelayoutContainer& container )
265 virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
269 virtual void OnCalculateRelayoutSize( Dimension::Type dimension )
273 virtual float CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension )
278 virtual void OnLayoutNegotiated( float size, Dimension::Type dimension )
282 virtual bool RelayoutDependentOnChildren( Dimension::Type dimension = Dimension::ALL_DIMENSIONS )
294 class MyTestCustomActor : public CustomActor
298 typedef Signal< void ()> SignalType;
299 typedef Signal< void (float)> SignalTypeFloat;
305 static MyTestCustomActor New()
307 Impl::MyTestCustomActor* p = new Impl::MyTestCustomActor;
308 return MyTestCustomActor( *p ); // takes ownership
311 virtual ~MyTestCustomActor()
315 static MyTestCustomActor DownCast( BaseHandle handle )
317 MyTestCustomActor result;
319 CustomActor custom = Dali::CustomActor::DownCast( handle );
322 CustomActorImpl& customImpl = custom.GetImplementation();
324 Impl::MyTestCustomActor* impl = dynamic_cast<Impl::MyTestCustomActor*>(&customImpl);
328 result = MyTestCustomActor(customImpl.GetOwner());
335 SignalType& GetCustomSignal()
337 Dali::RefObject& obj = GetImplementation();
338 return static_cast<Impl::MyTestCustomActor&>( obj ).mSignal;
343 MyTestCustomActor(Internal::CustomActor* internal)
344 : CustomActor(internal)
348 MyTestCustomActor( Impl::MyTestCustomActor& impl )
349 : CustomActor( impl )
355 class MyTestCustomActor2 : public CustomActor
363 P1=Dali::PROPERTY_REGISTRATION_START_INDEX,
373 static MyTestCustomActor2 New()
375 return MyTestCustomActor2(); // takes ownership
378 virtual ~MyTestCustomActor2()
382 static MyTestCustomActor2 DownCast( BaseHandle handle )
384 MyTestCustomActor2 result;
386 CustomActor custom = Dali::CustomActor::DownCast( handle );
389 CustomActorImpl& customImpl = custom.GetImplementation();
391 Impl::MyTestCustomActor* impl = dynamic_cast<Impl::MyTestCustomActor*>(&customImpl);
395 result = MyTestCustomActor2(customImpl.GetOwner());
404 MyTestCustomActor2(Internal::CustomActor* internal)
405 : CustomActor(internal)
409 MyTestCustomActor2( Impl::MyTestCustomActor& impl )
410 : CustomActor( impl )
415 static TypeRegistration customTypeInit( typeid(MyTestCustomActor2), typeid(Dali::CustomActor), CreateCustomInit, true );
417 PropertyRegistration P1( customTypeInit, "propertyOne", MyTestCustomActor2::Property::P1, Property::INTEGER, &SetProperty, &GetProperty );
418 PropertyRegistration P2( customTypeInit, "propertyTwo", MyTestCustomActor2::Property::P2, Property::STRING, &SetProperty, &GetProperty );
421 class MyTestCustomActor3 : public CustomActor
428 static MyTestCustomActor3 New()
430 return MyTestCustomActor3(); // takes ownership
433 virtual ~MyTestCustomActor3()
437 static MyTestCustomActor3 DownCast( BaseHandle handle )
439 MyTestCustomActor3 result;
441 CustomActor custom = Dali::CustomActor::DownCast( handle );
444 CustomActorImpl& customImpl = custom.GetImplementation();
446 Impl::MyTestCustomActor* impl = dynamic_cast<Impl::MyTestCustomActor*>(&customImpl);
450 result = MyTestCustomActor3(customImpl.GetOwner());
459 MyTestCustomActor3(Internal::CustomActor* internal)
460 : CustomActor(internal)
464 MyTestCustomActor3( Impl::MyTestCustomActor& impl )
465 : CustomActor( impl )
470 static TypeRegistration customTypeBadInit( typeid(MyTestCustomActor3), typeid(Dali::CustomActor), NULL, false );
472 BaseHandle CreateCustom(void)
474 return MyTestCustomActor::New();
477 static std::string lastSignalConnectionCustom;
479 bool DoConnectSignalCustom( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
481 lastSignalConnectionCustom = signalName;
483 bool connected( true );
485 Dali::BaseHandle handle(object);
486 MyTestCustomActor customActor = MyTestCustomActor::DownCast(handle);
488 if( "sig1" == signalName )
490 customActor.GetCustomSignal().Connect( tracker, functor );
494 // signalName does not match any signal
501 bool DoConnectSignalCustomFailure( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
503 lastSignalConnectionCustom = "failed";
505 return false; // This is supposed to fail
508 struct CustomTestFunctor
512 ++mTotalInstanceCount;
513 ++mCurrentInstanceCount;
516 CustomTestFunctor( const CustomTestFunctor& copyMe )
518 ++mTotalInstanceCount;
519 ++mCurrentInstanceCount;
524 --mCurrentInstanceCount;
532 static int mTotalInstanceCount;
533 static int mCurrentInstanceCount;
534 static int mCallbackCount;
537 int CustomTestFunctor::mTotalInstanceCount = 0;
538 int CustomTestFunctor::mCurrentInstanceCount = 0;
539 int CustomTestFunctor::mCallbackCount = 0;
541 static void ResetFunctorCounts()
543 CustomTestFunctor::mTotalInstanceCount = 0;
544 CustomTestFunctor::mCurrentInstanceCount = 0;
545 CustomTestFunctor::mCallbackCount = 0;
548 static std::string lastActionCustom;
549 bool DoActionCustom(BaseObject* object, const std::string& actionName, const Property::Map& /*attributes*/)
551 lastActionCustom = actionName;
555 // Custom type registration
556 static TypeRegistration customType1( typeid(MyTestCustomActor), typeid(Dali::CustomActor), CreateCustom );
559 static SignalConnectorType customSignalConnector1( customType1, "sig1", DoConnectSignalCustom );
560 static SignalConnectorType customSignalConnector2( customType1, "sig2", DoConnectSignalCustomFailure );
561 static const int TEST_SIGNAL_COUNT = 2;
564 static TypeAction customAction1( customType1, "act1", DoActionCustom);
565 static const int TEST_ACTION_COUNT = 1;
567 class TestConnectionTracker : public ConnectionTracker
571 TestConnectionTracker()
576 BaseHandle CreateNamedActorType()
578 Actor actor = Actor::New();
579 actor.SetName( "NamedActor" );
583 TypeRegistration namedActorType( "MyNamedActor", typeid(Dali::Actor), CreateNamedActorType );
584 PropertyRegistration namedActorPropertyOne( namedActorType, "propName", PROPERTY_REGISTRATION_START_INDEX, Property::BOOLEAN, &SetProperty, &GetProperty );
586 } // Anonymous namespace
588 // Note: No negative test case for UtcDaliTypeRegistryGet can be implemented.
589 int UtcDaliTypeRegistryGetP(void)
591 TestApplication application;
593 TypeRegistry registry = TypeRegistry::Get();
594 DALI_TEST_CHECK( registry );
599 // Note: No negative test case for UtcDaliTypeRegistryConstructor can be implemented.
600 int UtcDaliTypeRegistryConstructorP(void)
602 TestApplication application;
604 TypeRegistry registry;
605 DALI_TEST_CHECK( !registry );
609 // Note: No negative test case for UtcDaliTypeRegistryCopyConstructor can be implemented.
610 int UtcDaliTypeRegistryCopyConstructorP(void)
612 TestApplication application;
614 TypeRegistry registry = TypeRegistry::Get();
615 DALI_TEST_CHECK( registry );
617 TypeRegistry copy( registry );
618 DALI_TEST_CHECK( copy );
620 DALI_TEST_CHECK( registry.GetTypeInfo( "Actor" ).GetName() == copy.GetTypeInfo( "Actor" ).GetName() );
625 // Note: No negative test case for UtcDaliTypeRegistryAssignmentOperator can be implemented.
626 int UtcDaliTypeRegistryAssignmentOperatorP(void)
628 TestApplication application;
630 TypeRegistry registry = TypeRegistry::Get();
631 DALI_TEST_CHECK( registry );
633 TypeRegistry copy = registry;
634 DALI_TEST_CHECK( copy );
635 DALI_TEST_CHECK( registry == copy );
637 DALI_TEST_CHECK( registry.GetTypeInfo( "Actor" ).GetName() == copy.GetTypeInfo( "Actor" ).GetName() );
642 int UtcDaliTypeRegistryAssignP(void)
644 TestApplication application;
646 TypeRegistry registry = TypeRegistry::Get();
647 TypeRegistry registry2;
648 registry2 = registry;
649 DALI_TEST_CHECK( registry2 );
651 DALI_TEST_CHECK( registry2.GetTypeInfo( "Actor" ).GetName() == registry2.GetTypeInfo( "Actor" ).GetName() );
656 int UtcDaliTypeRegistryGetTypeInfoFromTypeNameP(void)
658 TestApplication application;
660 TypeRegistry registry = TypeRegistry::Get();
665 type = registry.GetTypeInfo( "CameraActor" );
666 DALI_TEST_CHECK( type );
667 CameraActor ca = CameraActor::DownCast(type.CreateInstance());
668 DALI_TEST_CHECK( ca );
669 Stage::GetCurrent().Add( ca );
670 application.Render();
673 type = registry.GetTypeInfo( "Animation" );
674 DALI_TEST_CHECK( type );
675 Animation an = Animation::DownCast(type.CreateInstance());
676 DALI_TEST_CHECK( an );
678 application.Render();
683 int UtcDaliTypeRegistryGetTypeInfoFromTypeNameN(void)
685 TestApplication application;
687 TypeRegistry registry = TypeRegistry::Get();
691 type = registry.GetTypeInfo( "MyDummyActor" );
692 DALI_TEST_CHECK( !type );
697 int UtcDaliTypeRegistryGetTypeInfoFromTypeIdP(void)
699 TypeInfo named_type = TypeRegistry::Get().GetTypeInfo( "CameraActor" );
700 TypeInfo typeinfo_type = TypeRegistry::Get().GetTypeInfo( typeid(Dali::CameraActor) );
702 DALI_TEST_CHECK( named_type );
703 DALI_TEST_CHECK( typeinfo_type );
705 // Check named and typeid are equivalent
706 DALI_TEST_CHECK( named_type == typeinfo_type );
708 DALI_TEST_CHECK( named_type.GetName() == typeinfo_type.GetName() );
709 DALI_TEST_CHECK( named_type.GetBaseName() == typeinfo_type.GetBaseName() );
714 int UtcDaliTypeRegistryGetTypeInfoFromTypeIdN(void)
716 TestApplication application;
717 TypeRegistry typeRegistry = TypeRegistry::Get();
719 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(Vector2) );
720 DALI_TEST_CHECK( !typeInfo );
725 int UtcDaliTypeRegistryGetTypeNameCountP(void)
727 TestApplication application;
728 TypeRegistry typeRegistry = TypeRegistry::Get();
731 for(size_t i = 0; i < typeRegistry.GetTypeNameCount(); i++)
733 type = typeRegistry.GetTypeInfo( typeRegistry.GetTypeName(i) );
734 DALI_TEST_CHECK( type );
741 int UtcDaliTypeRegistryGetTypeNamesP(void)
743 TestApplication application;
744 TypeRegistry typeRegistry = TypeRegistry::Get();
747 for(size_t i = 0; i < typeRegistry.GetTypeNameCount(); i++)
749 type = typeRegistry.GetTypeInfo( typeRegistry.GetTypeName(i) );
750 DALI_TEST_CHECK( type );
757 // Note: No negative test case for UtcDaliTypeRegistryTypeRegistration can be implemented.
758 int UtcDaliTypeRegistryTypeRegistrationNotCallingCreateOnInitP(void)
760 ResetFunctorCounts();
762 TestApplication application;
764 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
765 DALI_TEST_CHECK( type );
767 TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( "CustomActor" );
768 DALI_TEST_CHECK( baseType );
770 BaseHandle handle = type.CreateInstance();
771 DALI_TEST_CHECK( handle );
773 MyTestCustomActor customHandle = MyTestCustomActor::DownCast( handle );
774 DALI_TEST_CHECK( customHandle );
776 DALI_TEST_EQUALS( type.GetActionCount(), TEST_ACTION_COUNT + baseType.GetActionCount(), TEST_LOCATION );
778 DALI_TEST_EQUALS( type.GetSignalCount(), TEST_SIGNAL_COUNT + baseType.GetSignalCount(), TEST_LOCATION );
781 TestConnectionTracker tracker;
783 bool connected = handle.ConnectSignal( &tracker, "sig1", CustomTestFunctor() );
784 DALI_TEST_EQUALS( connected, true, TEST_LOCATION );
785 DALI_TEST_CHECK( lastSignalConnectionCustom == "sig1" );
786 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
787 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION );
789 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
790 customHandle.GetCustomSignal().Emit();
791 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION );
792 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
793 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION );
795 // tracker should automatically disconnect here
796 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
797 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
799 // Test that functor is disconnected
800 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION );
801 customHandle.GetCustomSignal().Emit();
802 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1/*not incremented*/, TEST_LOCATION );
803 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
804 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
806 Property::Map attributes;
807 handle.DoAction("act1", attributes);
808 DALI_TEST_CHECK( lastActionCustom == "act1" );
812 // Note: No negative test case for UtcDaliTypeRegistryTypeRegistration can be implemented.
813 int UtcDaliTypeRegistryTypeRegistrationCallingCreateOnInitP(void)
815 TestApplication application;
817 DALI_TEST_CHECK( "MyTestCustomActor2" == customTypeInit.RegisteredName() );
819 DALI_TEST_CHECK( true == CreateCustomInitCalled );
820 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor2" );
821 DALI_TEST_CHECK( type );
825 // Note: No negative test case for UtcDaliTypeRegistryTypeRegistration can be implemented.
826 int UtcDaliTypeRegistryTypeRegistrationForNamedTypeP(void)
828 TestApplication application;
830 // Create Named Actor Type
831 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyNamedActor" );
832 DALI_TEST_CHECK( type );
834 BaseHandle namedHandle = type.CreateInstance();
835 DALI_TEST_CHECK( namedHandle );
836 Actor namedActor( Actor::DownCast( namedHandle ) );
837 DALI_TEST_CHECK( namedActor );
839 DALI_TEST_CHECK( namedActor.GetName() == "NamedActor" );
840 DALI_TEST_CHECK( type.GetName() == "MyNamedActor" );
841 DALI_TEST_CHECK( type.GetBaseName() == "Actor" );
846 // Note: No negative test case for UtcDaliTypeRegistryRegisteredName can be implemented.
847 int UtcDaliTypeRegistryRegisteredNameP(void)
849 TestApplication application;
851 DALI_TEST_CHECK( scriptedName == scriptedType.RegisteredName() );
853 TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( scriptedName );
854 DALI_TEST_CHECK( baseType );
856 BaseHandle handle = baseType.CreateInstance();
858 DALI_TEST_CHECK( true == CreateCustomNamedInitCalled );
859 TypeInfo type = TypeRegistry::Get().GetTypeInfo( scriptedName );
860 DALI_TEST_CHECK( type );
864 int UtcDaliTypeRegistrySignalConnectorTypeP(void)
866 ResetFunctorCounts();
868 TestApplication application;
870 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
871 DALI_TEST_CHECK( type );
873 BaseHandle handle = type.CreateInstance();
874 DALI_TEST_CHECK( handle );
876 MyTestCustomActor customHandle = MyTestCustomActor::DownCast( handle );
877 DALI_TEST_CHECK( customHandle );
880 TestConnectionTracker tracker;
882 bool connected = handle.ConnectSignal( &tracker, "sig1", CustomTestFunctor() );
883 DALI_TEST_EQUALS( connected, true, TEST_LOCATION );
884 DALI_TEST_CHECK( lastSignalConnectionCustom == "sig1" );
885 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
886 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION );
888 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
889 customHandle.GetCustomSignal().Emit();
890 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION );
891 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
892 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION );
894 // tracker should automatically disconnect here
895 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
896 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
898 // Test that functor is disconnected
899 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION );
900 customHandle.GetCustomSignal().Emit();
901 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1/*not incremented*/, TEST_LOCATION );
902 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
903 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
908 int UtcDaliTypeRegistrySignalConnectorTypeN(void)
910 // Test what happens when signal connnector (DoConnectSignalFailure method) returns false
912 ResetFunctorCounts();
914 TestApplication application;
916 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
917 DALI_TEST_CHECK( type );
919 TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( "CustomActor" );
920 DALI_TEST_CHECK( baseType );
922 BaseHandle handle = type.CreateInstance();
923 DALI_TEST_CHECK( handle );
925 MyTestCustomActor customHandle = MyTestCustomActor::DownCast( handle );
926 DALI_TEST_CHECK( customHandle );
928 DALI_TEST_EQUALS( type.GetActionCount(), TEST_ACTION_COUNT + baseType.GetActionCount(), TEST_LOCATION );
930 DALI_TEST_EQUALS( type.GetSignalCount(), TEST_SIGNAL_COUNT + baseType.GetSignalCount(), TEST_LOCATION );
933 TestConnectionTracker tracker;
935 bool connected = handle.ConnectSignal( &tracker, "sig2", CustomTestFunctor() );
936 DALI_TEST_EQUALS( connected, false/*This is supposed to fail*/, TEST_LOCATION );
937 DALI_TEST_CHECK( lastSignalConnectionCustom == "failed" );
938 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
939 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0/*deleted along with FunctorDelegate*/, TEST_LOCATION );
942 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
943 customHandle.GetCustomSignal().Emit();
944 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0/*never called*/, TEST_LOCATION );
946 // tracker should have nothing to disconnect here
949 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
950 customHandle.GetCustomSignal().Emit();
951 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0/*never called*/, TEST_LOCATION );
955 int UtcDaliTypeRegistryTypeActionP(void)
957 ResetFunctorCounts();
959 TestApplication application;
961 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
962 DALI_TEST_CHECK( type );
964 BaseHandle handle = type.CreateInstance();
965 DALI_TEST_CHECK( handle );
967 Property::Map attributes;
968 DALI_TEST_CHECK( handle.DoAction("act1", attributes) );
969 DALI_TEST_CHECK( lastActionCustom == "act1" );
974 int UtcDaliTypeRegistryTypeActionN(void)
976 ResetFunctorCounts();
978 TestApplication application;
980 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
981 DALI_TEST_CHECK( type );
983 BaseHandle handle = type.CreateInstance();
984 DALI_TEST_CHECK( handle );
986 Property::Map attributes;
987 DALI_TEST_CHECK( !handle.DoAction( "unknownAction", attributes ) );
992 int UtcDaliTypeRegistryPropertyRegistrationP(void)
994 TestApplication application;
995 TypeRegistry typeRegistry = TypeRegistry::Get();
997 // Check property count before property registration
998 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
999 DALI_TEST_CHECK( typeInfo );
1000 BaseHandle handle = typeInfo.CreateInstance();
1001 DALI_TEST_CHECK( handle );
1002 Actor customActor = Actor::DownCast( handle );
1003 DALI_TEST_CHECK( customActor );
1004 unsigned int initialPropertyCount( customActor.GetPropertyCount() );
1006 std::string propertyName( "prop1" );
1007 int propertyIndex( PROPERTY_REGISTRATION_START_INDEX );
1008 Property::Type propertyType( Property::BOOLEAN );
1009 PropertyRegistration property1( customType1, propertyName, propertyIndex, propertyType, &SetProperty, &GetProperty );
1011 // Check property count after registration
1012 unsigned int postRegistrationPropertyCount( customActor.GetPropertyCount() );
1013 DALI_TEST_EQUALS( initialPropertyCount + 1u, postRegistrationPropertyCount, TEST_LOCATION );
1015 // Add custom property and check property count
1016 customActor.RegisterProperty( "customProp1", true );
1017 unsigned int customPropertyCount( customActor.GetPropertyCount() );
1018 DALI_TEST_EQUALS( postRegistrationPropertyCount + 1u, customPropertyCount, TEST_LOCATION );
1020 // Set the property, ensure SetProperty called
1021 DALI_TEST_CHECK( !setPropertyCalled );
1022 customActor.SetProperty( propertyIndex, false );
1023 DALI_TEST_CHECK( setPropertyCalled );
1025 // Get the property, ensure GetProperty called
1026 DALI_TEST_CHECK( !getPropertyCalled );
1027 (void)customActor.GetProperty< bool >( propertyIndex );
1028 DALI_TEST_CHECK( getPropertyCalled );
1030 // Check the property name
1031 DALI_TEST_EQUALS( customActor.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
1032 DALI_TEST_EQUALS( typeInfo.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
1034 // Check the property index
1035 DALI_TEST_EQUALS( customActor.GetPropertyIndex( propertyName ), propertyIndex, TEST_LOCATION );
1037 // Check the property type
1038 DALI_TEST_EQUALS( customActor.GetPropertyType( propertyIndex ), propertyType, TEST_LOCATION );
1040 // Check property count of type-info is 1
1041 Property::IndexContainer indices;
1042 typeInfo.GetPropertyIndices( indices );
1044 size_t typePropertyCount = typeInfo.GetPropertyCount();
1045 DALI_TEST_EQUALS( indices.Size(), 1u, TEST_LOCATION );
1046 DALI_TEST_EQUALS( indices.Size(), typePropertyCount, TEST_LOCATION );
1048 // Ensure indices returned from actor and customActor differ by two
1049 Actor actor = Actor::New();
1050 actor.GetPropertyIndices( indices );
1051 unsigned int actorIndices = indices.Size();
1052 customActor.GetPropertyIndices( indices );
1053 unsigned int customActorIndices = indices.Size();
1054 DALI_TEST_EQUALS( actorIndices + 2u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1058 int UtcDaliTypeRegistryPropertyRegistrationN(void)
1060 TestApplication application;
1061 TypeRegistry typeRegistry = TypeRegistry::Get();
1063 // Attempt to register a property type out-of-bounds index (less than)
1066 PropertyRegistration property1( customType1, "propName", PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN, &SetProperty, &GetProperty );
1067 tet_result( TET_FAIL );
1069 catch ( DaliException& e )
1071 DALI_TEST_ASSERT( e, "( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1074 // Attempt to register a property type out-of-bounds index (greater than)
1077 PropertyRegistration property1( customType1, "propName", PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN, &SetProperty, &GetProperty );
1078 tet_result( TET_FAIL );
1080 catch ( DaliException& e )
1082 DALI_TEST_ASSERT( e, "( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1088 int UtcDaliTypeRegistryAnimatablePropertyRegistrationP(void)
1090 TestApplication application;
1091 TypeRegistry typeRegistry = TypeRegistry::Get();
1093 // Check property count before property registration
1094 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1095 DALI_TEST_CHECK( typeInfo );
1096 BaseHandle handle = typeInfo.CreateInstance();
1097 DALI_TEST_CHECK( handle );
1098 Actor customActor = Actor::DownCast( handle );
1099 DALI_TEST_CHECK( customActor );
1100 Stage::GetCurrent().Add(customActor);
1102 unsigned int customPropertyCount( customActor.GetPropertyCount() );
1104 // Register animatable property
1105 std::string animatablePropertyName( "animatableProp1" );
1106 int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1107 Property::Type animatablePropertyType( Property::FLOAT );
1108 AnimatablePropertyRegistration animatableProperty( customType1, animatablePropertyName, animatablePropertyIndex, animatablePropertyType );
1110 // Check property count after registration
1111 DALI_TEST_EQUALS( customPropertyCount + 1u, customActor.GetPropertyCount(), TEST_LOCATION );
1113 // Set the animatable property value
1114 customActor.SetProperty( animatablePropertyIndex, 25.0f );
1116 // Render and notify
1117 application.SendNotification();
1118 application.Render();
1120 // Check the animatable property value
1121 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 25.f, TEST_LOCATION );
1123 // Check the animatable property name
1124 DALI_TEST_EQUALS( customActor.GetPropertyName( animatablePropertyIndex ), animatablePropertyName, TEST_LOCATION );
1126 // Check the animatable property index
1127 DALI_TEST_EQUALS( customActor.GetPropertyIndex( animatablePropertyName ), animatablePropertyIndex, TEST_LOCATION );
1129 // Check the animatable property type
1130 DALI_TEST_EQUALS( customActor.GetPropertyType( animatablePropertyIndex ), animatablePropertyType, TEST_LOCATION );
1132 // Check property count of type-info is 1
1133 Property::IndexContainer indices;
1134 typeInfo.GetPropertyIndices( indices );
1135 DALI_TEST_EQUALS( indices.Size(), 1u, TEST_LOCATION );
1137 // Ensure indices returned from actor and customActor differ by one
1138 Actor actor = Actor::New();
1139 actor.GetPropertyIndices( indices );
1140 unsigned int actorIndices = indices.Size();
1141 customActor.GetPropertyIndices( indices );
1142 unsigned int customActorIndices = indices.Size();
1143 DALI_TEST_EQUALS( actorIndices + 1u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1145 // check that the property is animatable
1146 Animation animation = Animation::New(0.2f);
1147 animation.AnimateTo( Property( customActor, animatablePropertyIndex ), 15.f, AlphaFunction::LINEAR );
1149 // Render and notify, animation play for 0.05 seconds
1150 application.SendNotification();
1151 application.Render(50);
1152 DALI_TEST_EQUALS( 0.25f, animation.GetCurrentProgress(), TEST_LOCATION );
1153 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 22.5f, TEST_LOCATION );
1154 // Render and notify, animation play for another 0.1 seconds
1155 application.SendNotification();
1156 application.Render(100);
1157 DALI_TEST_EQUALS( 0.75f, animation.GetCurrentProgress(), TEST_LOCATION );
1158 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 17.5f, TEST_LOCATION );
1163 int UtcDaliTypeRegistryAnimatablePropertyRegistrationN(void)
1165 TestApplication application;
1166 TypeRegistry typeRegistry = TypeRegistry::Get();
1168 // Attempt to register an animatable property type out-of-bounds index (less than)
1171 AnimatablePropertyRegistration property1( customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN );
1172 tet_result( TET_FAIL );
1174 catch ( DaliException& e )
1176 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1179 // Attempt to register an animatable property type out-of-bounds index (greater than)
1182 AnimatablePropertyRegistration property1( customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN );
1183 tet_result( TET_FAIL );
1185 catch ( DaliException& e )
1187 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1193 int UtcDaliTypeRegistryAnimatablePropertyRegistrationWithDefaultP(void)
1195 TestApplication application;
1196 TypeRegistry typeRegistry = TypeRegistry::Get();
1198 // Check property count before property registration
1199 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1200 DALI_TEST_CHECK( typeInfo );
1201 BaseHandle handle = typeInfo.CreateInstance();
1202 DALI_TEST_CHECK( handle );
1203 Actor customActor = Actor::DownCast( handle );
1204 DALI_TEST_CHECK( customActor );
1205 Stage::GetCurrent().Add(customActor);
1207 unsigned int customPropertyCount( customActor.GetPropertyCount() );
1209 // Register animatable property
1210 std::string animatablePropertyName( "animatableProp1" );
1211 int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1212 AnimatablePropertyRegistration animatableProperty1( customType1, animatablePropertyName, animatablePropertyIndex, 10.f );
1214 // Check property count after registration
1215 DALI_TEST_EQUALS( customPropertyCount + 1u, customActor.GetPropertyCount(), TEST_LOCATION );
1217 // Render and notify
1218 application.SendNotification();
1219 application.Render();
1221 // Check the animatable property value
1222 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 10.f, TEST_LOCATION );
1224 // Check the animatable property name
1225 DALI_TEST_EQUALS( customActor.GetPropertyName( animatablePropertyIndex ), animatablePropertyName, TEST_LOCATION );
1227 // Check the animatable property index
1228 DALI_TEST_EQUALS( customActor.GetPropertyIndex( animatablePropertyName ), animatablePropertyIndex, TEST_LOCATION );
1230 // Check the animatable property type
1231 DALI_TEST_EQUALS( customActor.GetPropertyType( animatablePropertyIndex ), Property::FLOAT, TEST_LOCATION );
1233 // Check property count of type-info is 1
1234 Property::IndexContainer indices;
1235 typeInfo.GetPropertyIndices( indices );
1236 DALI_TEST_EQUALS( indices.Size(), 1u, TEST_LOCATION );
1238 // Ensure indices returned from actor and customActor differ by one
1239 Actor actor = Actor::New();
1240 actor.GetPropertyIndices( indices );
1241 unsigned int actorIndices = indices.Size();
1242 customActor.GetPropertyIndices( indices );
1243 unsigned int customActorIndices = indices.Size();
1244 DALI_TEST_EQUALS( actorIndices + 1u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1246 // check that the property is animatable
1247 Animation animation = Animation::New(0.2f);
1248 animation.AnimateTo( Property( customActor, animatablePropertyIndex ), 20.f, AlphaFunction::LINEAR );
1250 // Render and notify, animation play for 0.05 seconds
1251 application.SendNotification();
1252 application.Render(50);
1253 DALI_TEST_EQUALS( 0.25f, animation.GetCurrentProgress(), TEST_LOCATION );
1254 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 12.5f, TEST_LOCATION );
1255 // Render and notify, animation play for another 0.1 seconds
1256 application.SendNotification();
1257 application.Render(100);
1258 DALI_TEST_EQUALS( 0.75f, animation.GetCurrentProgress(), TEST_LOCATION );
1259 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 17.5f, TEST_LOCATION );
1264 int UtcDaliTypeRegistryAnimatablePropertyRegistrationWithDefaultN(void)
1266 TestApplication application;
1267 TypeRegistry typeRegistry = TypeRegistry::Get();
1269 // Attempt to register an animatable property type out-of-bounds index (less than)
1272 AnimatablePropertyRegistration property1( customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX - 1, false );
1273 tet_result( TET_FAIL );
1275 catch ( DaliException& e )
1277 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1280 // Attempt to register an animatable property type out-of-bounds index (greater than)
1283 AnimatablePropertyRegistration property1( customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX + 1, true );
1284 tet_result( TET_FAIL );
1286 catch ( DaliException& e )
1288 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1294 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationP(void)
1296 TestApplication application;
1297 TypeRegistry typeRegistry = TypeRegistry::Get();
1299 // Check property count before property registration
1300 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1301 DALI_TEST_CHECK( typeInfo );
1302 BaseHandle handle = typeInfo.CreateInstance();
1303 DALI_TEST_CHECK( handle );
1304 Actor customActor = Actor::DownCast( handle );
1305 DALI_TEST_CHECK( customActor );
1307 unsigned int customPropertyCount( customActor.GetPropertyCount() );
1309 // Register animatable property
1310 std::string animatablePropertyName( "animatableProp1" );
1311 int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1312 Property::Type animatablePropertyType( Property::VECTOR2 );
1313 AnimatablePropertyRegistration animatableProperty1( customType1, animatablePropertyName, animatablePropertyIndex, animatablePropertyType );
1315 // Check property count after registration
1316 DALI_TEST_EQUALS( customPropertyCount + 1u, customActor.GetPropertyCount(), TEST_LOCATION );
1318 // Set the animatable property value
1319 customActor.SetProperty( animatablePropertyIndex, Vector2(25.0f, 50.0f) );
1321 // Render and notify
1322 application.SendNotification();
1323 application.Render();
1325 // Check the animatable property value
1326 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( animatablePropertyIndex ), Vector2(25.0f, 50.0f), TEST_LOCATION );
1328 // Check the animatable property name
1329 DALI_TEST_EQUALS( customActor.GetPropertyName( animatablePropertyIndex ), animatablePropertyName, TEST_LOCATION );
1331 // Check the animatable property index
1332 DALI_TEST_EQUALS( customActor.GetPropertyIndex( animatablePropertyName ), animatablePropertyIndex, TEST_LOCATION );
1334 // Check the animatable property type
1335 DALI_TEST_EQUALS( customActor.GetPropertyType( animatablePropertyIndex ), animatablePropertyType, TEST_LOCATION );
1337 // Check property count of type-info is 1
1338 Property::IndexContainer indices;
1339 typeInfo.GetPropertyIndices( indices );
1340 DALI_TEST_EQUALS( indices.Size(), 1u, TEST_LOCATION );
1342 // Register animatable property components
1343 std::string animatablePropertyComponentName1( "animatableProp1X" );
1344 int animatablePropertyComponentIndex1( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1 );
1345 AnimatablePropertyComponentRegistration animatablePropertyComponent1( customType1, animatablePropertyComponentName1, animatablePropertyComponentIndex1, animatablePropertyIndex, 0 );
1347 std::string animatablePropertyComponentName2( "animatableProp1Y" );
1348 int animatablePropertyComponentIndex2( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2 );
1349 AnimatablePropertyComponentRegistration animatablePropertyComponent2( customType1, animatablePropertyComponentName2, animatablePropertyComponentIndex2, animatablePropertyIndex, 1 );
1351 // Check property count after registration
1352 DALI_TEST_EQUALS( customPropertyCount + 3u, customActor.GetPropertyCount(), TEST_LOCATION );
1354 // Check the animatable property component value
1355 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex1 ), 25.0f, TEST_LOCATION );
1356 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex2 ), 50.0f, TEST_LOCATION );
1358 // Set the animatable property component value
1359 customActor.SetProperty( animatablePropertyComponentIndex1, 150.0f );
1361 // Render and notify
1362 application.SendNotification();
1363 application.Render();
1365 // Check the animatable property value
1366 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( animatablePropertyIndex ), Vector2(150.0f, 50.0f), TEST_LOCATION );
1367 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex1 ), 150.0f, TEST_LOCATION );
1368 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex2 ), 50.0f, TEST_LOCATION );
1370 // Set the animatable property component value
1371 customActor.SetProperty( animatablePropertyComponentIndex2, 225.0f );
1373 // Render and notify
1374 application.SendNotification();
1375 application.Render();
1377 // Check the animatable property value
1378 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( animatablePropertyIndex ), Vector2(150.0f, 225.0f), TEST_LOCATION );
1379 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex1 ), 150.0f, TEST_LOCATION );
1380 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex2 ), 225.0f, TEST_LOCATION );
1382 // Ensure indices returned from actor and customActor differ by three
1383 Actor actor = Actor::New();
1384 actor.GetPropertyIndices( indices );
1385 unsigned int actorIndices = indices.Size();
1386 customActor.GetPropertyIndices( indices );
1387 unsigned int customActorIndices = indices.Size();
1388 DALI_TEST_EQUALS( actorIndices + 3u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1393 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationN(void)
1395 TestApplication application;
1396 TypeRegistry typeRegistry = TypeRegistry::Get();
1398 // Register animatable property with the type of Vector2
1399 int animatablePropertyIndex1( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1400 AnimatablePropertyRegistration animatableProperty1( customType1, "animatableProp1", animatablePropertyIndex1, Property::VECTOR2 );
1402 // Attempt to register an animatable property component out-of-bounds index (less than)
1405 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp1X", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX - 1, animatablePropertyIndex1, 0 );
1406 tet_result( TET_FAIL );
1408 catch ( DaliException& e )
1410 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1413 // Attempt to register an animatable property component out-of-bounds index (greater than)
1416 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp1X", ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX + 1, animatablePropertyIndex1, 0 );
1417 tet_result( TET_FAIL );
1419 catch ( DaliException& e )
1421 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1424 // Register an animatable property component
1425 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp1X", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1, animatablePropertyIndex1, 0 );
1427 // Attempt to register another animatable property component with the same component index
1430 AnimatablePropertyComponentRegistration propertyComponent2( customType1, "animatableProp1Y", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2, animatablePropertyIndex1, 0 );
1431 tet_result( TET_FAIL );
1433 catch ( DaliException& e )
1435 DALI_TEST_ASSERT( e, "Property component already registered", TEST_LOCATION );
1438 // Register animatable property with the type of boolean
1439 int animatablePropertyIndex2( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2 );
1440 AnimatablePropertyRegistration animatableProperty2( customType1, "animatableProp2", animatablePropertyIndex2, Property::BOOLEAN );
1442 // Attempt to register an animatable property component for the above property with boolean type
1445 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp2X", animatablePropertyIndex2 + 1, animatablePropertyIndex2, 0 );
1446 tet_result( TET_FAIL );
1448 catch ( DaliException& e )
1450 DALI_TEST_ASSERT( e, "Base property does not support component", TEST_LOCATION );
1456 int UtcDaliTypeRegistryChildPropertyRegistrationP(void)
1458 TestApplication application;
1459 TypeRegistry typeRegistry = TypeRegistry::Get();
1461 // Check property count before property registration
1462 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1463 DALI_TEST_CHECK( typeInfo );
1464 BaseHandle handle = typeInfo.CreateInstance();
1465 DALI_TEST_CHECK( handle );
1466 Actor customActor = Actor::DownCast( handle );
1467 DALI_TEST_CHECK( customActor );
1468 unsigned int initialPropertyCount( customActor.GetPropertyCount() );
1470 // Register child properties to the parent
1471 std::string propertyName( "childProp1" );
1472 int propertyIndex( CHILD_PROPERTY_REGISTRATION_START_INDEX );
1473 Property::Type propertyType( Property::BOOLEAN );
1474 ChildPropertyRegistration childProperty1( customType1, propertyName, propertyIndex, propertyType );
1476 std::string propertyName2( "childProp2" );
1477 int propertyIndex2( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1 );
1478 Property::Type propertyType2( Property::INTEGER );
1479 ChildPropertyRegistration childProperty2( customType1, propertyName2, propertyIndex2, propertyType2 );
1481 std::string propertyName3( "childProp3" );
1482 int propertyIndex3( CHILD_PROPERTY_REGISTRATION_START_INDEX + 2 );
1483 Property::Type propertyType3( Property::FLOAT );
1484 ChildPropertyRegistration childProperty3( customType1, propertyName3, propertyIndex3, propertyType3 );
1486 std::string propertyName4( "childProp4" );
1487 int propertyIndex4( CHILD_PROPERTY_REGISTRATION_START_INDEX + 3 );
1488 Property::Type propertyType4( Property::INTEGER );
1489 ChildPropertyRegistration childProperty4( customType1, propertyName4, propertyIndex4, propertyType4 );
1491 // Check property count are not changed because the child properties will not be created for the parent
1492 DALI_TEST_EQUALS( initialPropertyCount, customActor.GetPropertyCount(), TEST_LOCATION );
1494 // Create a child actor
1495 Actor childActor = Actor::New();
1496 DALI_TEST_CHECK( childActor );
1497 unsigned int initialChildActorPropertyCount( childActor.GetPropertyCount() );
1499 // The type of child properties should be Property::None as the child hasn't registered any child property yet.
1500 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex ), Property::NONE, TEST_LOCATION );
1501 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex2 ), Property::NONE, TEST_LOCATION );
1502 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex3 ), Property::NONE, TEST_LOCATION );
1503 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex4 ), Property::NONE, TEST_LOCATION );
1505 // Set the value for the first child property when the child actor doesn't have a parent yet
1506 childActor.SetProperty(propertyIndex, true);
1508 // Check that the first child property is dynamically created
1509 DALI_TEST_EQUALS( initialChildActorPropertyCount + 1u, childActor.GetPropertyCount(), TEST_LOCATION );
1511 // Check the first child property value
1512 DALI_TEST_EQUALS( childActor.GetProperty< bool >( propertyIndex ), true, TEST_LOCATION );
1514 // Check the first child property type
1515 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex ), propertyType, TEST_LOCATION );
1517 // Check that the first child property have no name, as it doesn't have a parent yet.
1518 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex ), "", TEST_LOCATION );
1520 // Check that the first property can't be accessed through its name, as it doesn't have a parent yet.
1521 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName ), Property::INVALID_INDEX, TEST_LOCATION );
1523 // Create a custom property for the child with the same name as the second child property registered to the parent
1524 Property::Index customPropertyIndex = childActor.RegisterProperty(propertyName2, 100, Property::READ_WRITE);
1526 // Check that the custom property is created
1527 DALI_TEST_EQUALS( initialChildActorPropertyCount + 2u, childActor.GetPropertyCount(), TEST_LOCATION );
1529 // Check the property value
1530 DALI_TEST_EQUALS( childActor.GetProperty< int >( customPropertyIndex ), 100, TEST_LOCATION );
1532 // Check the property index
1533 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName2 ), customPropertyIndex, TEST_LOCATION );
1535 // Check the property type
1536 DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex ), propertyType2, TEST_LOCATION );
1538 // Check the property name
1539 DALI_TEST_EQUALS( childActor.GetPropertyName( customPropertyIndex ), propertyName2, TEST_LOCATION );
1541 // Now add the child actor to the parent
1542 customActor.Add( childActor );
1544 // Check that the first child property now has the correct name as previously registered to the parent
1545 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
1547 // Check that the child property index for the first child property can now be retrieved through its child property name
1548 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName ), propertyIndex, TEST_LOCATION );
1550 // Check that the second child property now has the correct index as previously registered to the parent
1551 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex2 ), propertyName2, TEST_LOCATION );
1553 // Check that the second child property can be accessed through both its custom property index and its child property index
1554 DALI_TEST_EQUALS( childActor.GetProperty< int >( customPropertyIndex ), 100, TEST_LOCATION );
1555 DALI_TEST_EQUALS( childActor.GetProperty< int >( propertyIndex2 ), 100, TEST_LOCATION );
1556 DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex ), propertyType2, TEST_LOCATION );
1557 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex2 ), propertyType2, TEST_LOCATION );
1559 // Check that the child property index for the second child property can now be retrieved through its child property name
1560 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName2 ), propertyIndex2, TEST_LOCATION );
1562 // Set the value for the third child property when the child actor is already added to the parent
1563 childActor.SetProperty(propertyIndex3, 0.15f);
1565 // Check that the third child property is dynamically created
1566 DALI_TEST_EQUALS( initialChildActorPropertyCount + 3u, childActor.GetPropertyCount(), TEST_LOCATION );
1568 // Check the third child property value
1569 DALI_TEST_EQUALS( childActor.GetProperty< float >( propertyIndex3 ), 0.15f, TEST_LOCATION );
1571 // Check the third child property type
1572 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex3 ), propertyType3, TEST_LOCATION );
1574 // Check the third child property name
1575 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex3 ), propertyName3, TEST_LOCATION );
1577 // Check the third child property index.
1578 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName3 ), propertyIndex3, TEST_LOCATION );
1580 // Create a custom property for the child with the same name as the fourth child property registered to the parent
1581 Property::Index customPropertyIndex2 = childActor.RegisterProperty(propertyName4, 20, Property::READ_WRITE);
1583 // Check that the custom property is created
1584 DALI_TEST_EQUALS( initialChildActorPropertyCount + 4u, childActor.GetPropertyCount(), TEST_LOCATION );
1586 // Check the fourth child property value
1587 DALI_TEST_EQUALS( childActor.GetProperty< int >( propertyIndex4 ), 20, TEST_LOCATION );
1588 DALI_TEST_EQUALS( childActor.GetProperty< int >( customPropertyIndex2 ), 20, TEST_LOCATION );
1590 // Check the fourth child property type
1591 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex4 ), propertyType4, TEST_LOCATION );
1592 DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex2 ), propertyType4, TEST_LOCATION );
1594 // Check the fourth child property name
1595 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex4 ), propertyName4, TEST_LOCATION );
1596 DALI_TEST_EQUALS( childActor.GetPropertyName( customPropertyIndex2 ), propertyName4, TEST_LOCATION );
1598 // Check the fourth child property index.
1599 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName4 ), propertyIndex4, TEST_LOCATION );
1601 // Now create another parent actor with different child properties registered
1602 TypeInfo typeInfo2 = typeRegistry.GetTypeInfo( "MyNamedActor" );
1603 DALI_TEST_CHECK( typeInfo2 );
1604 BaseHandle handle2 = typeInfo2.CreateInstance();
1605 DALI_TEST_CHECK( handle2 );
1606 Actor customActor2 = Actor::DownCast( handle2 );
1607 DALI_TEST_CHECK( customActor2 );
1609 // Register child properties to the new parent
1610 std::string newPropertyName( "newChildProp" );
1611 int newPropertyIndex( CHILD_PROPERTY_REGISTRATION_START_INDEX ); // The same index as the first child property "childProp1" in the old parent
1612 Property::Type newPropertyType( Property::VECTOR2 );
1613 ChildPropertyRegistration newChildProperty( namedActorType, newPropertyName, newPropertyIndex, newPropertyType );
1615 std::string newPropertyName2( "childProp3" ); // The same name as the third child property in the old parent
1616 int newPropertyIndex2( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1 ); // The same index as the second child property "childProp2" in the old parent
1617 Property::Type newPropertyType2( Property::FLOAT ); // The same type as the third child property in the old parent
1618 ChildPropertyRegistration newChildProperty2( namedActorType, newPropertyName2, newPropertyIndex2, newPropertyType2 );
1620 // Now move the child actor to the new parent
1621 customActor2.Add( childActor );
1623 // "childProp1" is not a valid child property supported by the new parent, so nothing changed
1624 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex ), propertyType, TEST_LOCATION );
1625 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
1626 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName ), propertyIndex, TEST_LOCATION );
1628 // "childProp3" is a valid child property supported by the new parent
1629 // So it should get its new child property index and should just work
1630 DALI_TEST_EQUALS( childActor.GetPropertyType( newPropertyIndex2 ), newPropertyType2, TEST_LOCATION );
1631 DALI_TEST_EQUALS( childActor.GetPropertyName( newPropertyIndex2 ), newPropertyName2, TEST_LOCATION );
1632 DALI_TEST_EQUALS( childActor.GetPropertyIndex( newPropertyName2 ), newPropertyIndex2, TEST_LOCATION );
1633 DALI_TEST_EQUALS( childActor.GetProperty< float >( newPropertyIndex2 ), 0.15f, TEST_LOCATION );
1635 // Now register a custom property called "newChildProp"
1636 Property::Index customPropertyIndex3 = childActor.RegisterProperty("newChildProp", Vector2( 10.0f, 10.0f ), Property::READ_WRITE);
1638 // Check that the custom property is created
1639 DALI_TEST_EQUALS( initialChildActorPropertyCount + 5u, childActor.GetPropertyCount(), TEST_LOCATION );
1641 // This is a valid child property registered to the new parent
1642 // So should be able to access it through both its custom property index and its registered child property index
1643 DALI_TEST_EQUALS( childActor.GetPropertyType( newPropertyIndex ), newPropertyType, TEST_LOCATION );
1644 DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex3 ), newPropertyType, TEST_LOCATION );
1645 DALI_TEST_EQUALS( childActor.GetPropertyName( newPropertyIndex ), newPropertyName, TEST_LOCATION ); // This should return the new name, although the child property index remains the same
1646 DALI_TEST_EQUALS( childActor.GetPropertyName( customPropertyIndex3 ), newPropertyName, TEST_LOCATION );
1647 DALI_TEST_EQUALS( childActor.GetProperty< Vector2 >( newPropertyIndex ), Vector2( 10.0f, 10.0f ), TEST_LOCATION );
1648 DALI_TEST_EQUALS( childActor.GetProperty< Vector2 >( customPropertyIndex3 ), Vector2( 10.0f, 10.0f ), TEST_LOCATION );
1650 // Should return the child property index by given its name
1651 DALI_TEST_EQUALS( childActor.GetPropertyIndex( newPropertyName ), newPropertyIndex, TEST_LOCATION );
1656 int UtcDaliTypeRegistryChildPropertyRegistrationN(void)
1658 TestApplication application;
1659 TypeRegistry typeRegistry = TypeRegistry::Get();
1661 // Attempt to register a child property type out-of-bounds index (less than)
1664 ChildPropertyRegistration property1( customType1, "propName", CHILD_PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN );
1665 tet_result( TET_FAIL );
1667 catch ( DaliException& e )
1669 DALI_TEST_ASSERT( e, "( index >= CHILD_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1672 // Attempt to register a child property type out-of-bounds index (greater than)
1675 ChildPropertyRegistration property1( customType1, "propName", CHILD_PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN );
1676 tet_result( TET_FAIL );
1678 catch ( DaliException& e )
1680 DALI_TEST_ASSERT( e, "( index >= CHILD_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1687 /*******************************************************************************
1689 * Action through the base handle
1691 ******************************************************************************/
1692 int UtcDaliTypeRegistryActionViaBaseHandle(void)
1694 TestApplication application;
1698 type = TypeRegistry::Get().GetTypeInfo( "Actor" );
1699 DALI_TEST_CHECK( type );
1701 BaseHandle hdl = type.CreateInstance();
1702 DALI_TEST_CHECK( hdl );
1704 Actor a = Actor::DownCast(hdl);
1705 DALI_TEST_CHECK( a );
1707 a.SetVisible(false);
1709 application.SendNotification();
1710 application.Render(0);
1711 DALI_TEST_CHECK(!a.IsVisible());
1713 Property::Map attributes;
1715 DALI_TEST_CHECK(hdl.DoAction("show", attributes));
1717 application.SendNotification();
1718 application.Render(0);
1719 DALI_TEST_CHECK(a.IsVisible());
1721 DALI_TEST_CHECK(!hdl.DoAction("unknownAction", attributes));
1725 int UtcDaliPropertyRegistrationFunctions(void)
1727 TestApplication application;
1728 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 10;
1730 // Attempt to register a property without a setter
1733 PropertyRegistration property1( customType1, "propName", propertyIndex++, Property::BOOLEAN, NULL, &GetProperty );
1734 tet_result( TET_PASS );
1736 catch ( DaliException& e )
1738 tet_result( TET_FAIL );
1741 // Attempt to register a property without a getter
1744 PropertyRegistration property1( customType1, "propName", propertyIndex++, Property::BOOLEAN, NULL, NULL );
1745 tet_result( TET_FAIL );
1747 catch ( DaliException& e )
1749 DALI_TEST_ASSERT( e, "! \"GetProperty", TEST_LOCATION );
1754 int UtcDaliPropertyRegistrationAddSameIndex(void)
1756 TestApplication application;
1757 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 100;
1759 // Add one property with a valid property index
1760 PropertyRegistration property1( customType1, "propName", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
1762 // Attempt to add another property with the same index
1765 PropertyRegistration property2( customType1, "propName2", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
1767 catch ( DaliException& e )
1769 DALI_TEST_ASSERT( e, "! \"Property index already added", TEST_LOCATION );
1772 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 100;
1774 // Add one property with a valid property index
1775 AnimatablePropertyRegistration property3( customType1, "animPropName", animatablePropertyIndex, Property::BOOLEAN );
1777 // Attempt to add another property with the same index
1780 AnimatablePropertyRegistration property4( customType1, "animPropName2", animatablePropertyIndex, Property::BOOLEAN );
1782 catch ( DaliException& e )
1784 DALI_TEST_ASSERT( e, "! \"Property index already added", TEST_LOCATION );
1789 int UtcDaliPropertyRegistrationPropertyWritable(void)
1791 TestApplication application;
1792 int propertyIndex1 = PROPERTY_REGISTRATION_START_INDEX + 200;
1793 int propertyIndex2 = PROPERTY_REGISTRATION_START_INDEX + 201;
1795 // Add two properties, one with SetProperty, one without
1796 PropertyRegistration property1( customType1, "propNameReadwrite", propertyIndex1, Property::BOOLEAN, &SetProperty, &GetProperty );
1797 PropertyRegistration property2( customType1, "propNameReadonly", propertyIndex2, Property::BOOLEAN, NULL, &GetProperty );
1799 // Create custom-actor
1800 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
1801 DALI_TEST_CHECK( typeInfo );
1802 BaseHandle handle = typeInfo.CreateInstance();
1803 DALI_TEST_CHECK( handle );
1804 Actor customActor = Actor::DownCast( handle );
1805 DALI_TEST_CHECK( customActor );
1807 // Check whether properties are writable
1808 DALI_TEST_CHECK( customActor.IsPropertyWritable( propertyIndex1 ) );
1809 DALI_TEST_CHECK( ! customActor.IsPropertyWritable( propertyIndex2 ) );
1813 int UtcDaliPropertyRegistrationPropertyAnimatable(void)
1815 TestApplication application;
1816 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 400;
1817 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 400;
1819 // These properties are not animatable
1820 PropertyRegistration property1( customType1, "propName", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
1822 // These properties are animatable
1823 AnimatablePropertyRegistration property2( customType1, "animPropName", animatablePropertyIndex, Property::BOOLEAN );
1825 // Create custom-actor
1826 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
1827 DALI_TEST_CHECK( typeInfo );
1828 BaseHandle handle = typeInfo.CreateInstance();
1829 DALI_TEST_CHECK( handle );
1830 Actor customActor = Actor::DownCast( handle );
1831 DALI_TEST_CHECK( customActor );
1833 // Check if animatable
1834 DALI_TEST_CHECK( ! customActor.IsPropertyAnimatable( propertyIndex ) );
1835 DALI_TEST_CHECK( customActor.IsPropertyAnimatable( animatablePropertyIndex ) );
1837 // Create another instance of custom-actor
1838 BaseHandle handle2 = typeInfo.CreateInstance();
1839 DALI_TEST_CHECK( handle2 );
1840 Actor customActor2 = Actor::DownCast( handle2 );
1841 DALI_TEST_CHECK( customActor2 );
1843 // Check if animatable
1844 DALI_TEST_CHECK( ! customActor2.IsPropertyAnimatable( propertyIndex ) );
1845 DALI_TEST_CHECK( customActor2.IsPropertyAnimatable( animatablePropertyIndex ) );
1849 int UtcDaliPropertyRegistrationInvalidGetAndSet(void)
1851 TestApplication application;
1852 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 2000;
1853 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2000;
1855 // Create custom-actor
1856 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
1857 DALI_TEST_CHECK( typeInfo );
1858 BaseHandle handle = typeInfo.CreateInstance();
1859 DALI_TEST_CHECK( handle );
1860 Actor customActor = Actor::DownCast( handle );
1861 DALI_TEST_CHECK( customActor );
1863 // Try to set an index that hasn't been added
1866 customActor.SetProperty( propertyIndex, true );
1867 tet_result( TET_FAIL );
1869 catch ( DaliException& e )
1871 DALI_TEST_ASSERT( e, "! \"Cannot find property index", TEST_LOCATION );
1876 customActor.SetProperty( animatablePropertyIndex, true );
1877 tet_result( TET_FAIL );
1879 catch ( DaliException& e )
1881 DALI_TEST_ASSERT( e, "! \"Cannot find property index", TEST_LOCATION );
1884 // Try to get an index that hasn't been added
1887 (void) customActor.GetProperty< bool >( propertyIndex );
1888 tet_result( TET_FAIL );
1890 catch ( DaliException& e )
1892 DALI_TEST_ASSERT( e, "! \"Cannot find property index", TEST_LOCATION );
1897 (void) customActor.GetProperty< bool >( animatablePropertyIndex );
1898 tet_result( TET_FAIL );
1900 catch ( DaliException& e )
1902 DALI_TEST_ASSERT( e, "! \"Cannot find property index", TEST_LOCATION );
1908 int UtcDaliLongPressGestureDetectorTypeRegistry(void)
1910 TestApplication application;
1912 Actor actor = Actor::New();
1913 actor.SetSize(100.0f, 100.0f);
1914 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1915 Stage::GetCurrent().Add(actor);
1919 type = TypeRegistry::Get().GetTypeInfo( "LongPressGestureDetector" );
1920 DALI_TEST_CHECK( type );
1921 BaseHandle handle = type.CreateInstance();
1922 DALI_TEST_CHECK( handle );
1923 LongPressGestureDetector detector = LongPressGestureDetector::DownCast( handle );
1924 DALI_TEST_CHECK( detector );
1926 // Attach actor to detector
1928 GestureReceivedFunctor functor( data );
1929 detector.Attach(actor);
1931 // Connect to signal through type
1932 handle.ConnectSignal( &application, "longPressDetected", functor );
1934 // Render and notify
1935 application.SendNotification();
1936 application.Render();
1939 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f)));
1940 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f)));
1941 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f)));
1942 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
1946 int UtcDaliPanGestureDetectorTypeRegistry(void)
1948 TestApplication application;
1950 Actor actor = Actor::New();
1951 actor.SetSize(100.0f, 100.0f);
1952 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1953 Stage::GetCurrent().Add(actor);
1957 type = TypeRegistry::Get().GetTypeInfo( "PanGestureDetector" );
1958 DALI_TEST_CHECK( type );
1959 BaseHandle handle = type.CreateInstance();
1960 DALI_TEST_CHECK( handle );
1961 PanGestureDetector detector = PanGestureDetector::DownCast( handle );
1962 DALI_TEST_CHECK( detector );
1964 // Attach actor to detector
1966 GestureReceivedFunctor functor( data );
1967 detector.Attach(actor);
1969 // Connect to signal through type
1970 handle.ConnectSignal( &application, "panDetected", functor );
1972 // Render and notify
1973 application.SendNotification();
1974 application.Render();
1977 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1978 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1979 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1980 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
1984 int UtcDaliPinchGestureDetectorTypeRegistry(void)
1986 TestApplication application;
1988 Actor actor = Actor::New();
1989 actor.SetSize(100.0f, 100.0f);
1990 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1991 Stage::GetCurrent().Add(actor);
1995 type = TypeRegistry::Get().GetTypeInfo( "PinchGestureDetector" );
1996 DALI_TEST_CHECK( type );
1997 BaseHandle handle = type.CreateInstance();
1998 DALI_TEST_CHECK( handle );
1999 PinchGestureDetector detector = PinchGestureDetector::DownCast( handle );
2000 DALI_TEST_CHECK( detector );
2002 // Attach actor to detector
2004 GestureReceivedFunctor functor( data );
2005 detector.Attach(actor);
2007 // Connect to signal through type
2008 handle.ConnectSignal( &application, "pinchDetected", functor );
2010 // Render and notify
2011 application.SendNotification();
2012 application.Render();
2015 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
2016 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2020 int UtcDaliTapGestureDetectorTypeRegistry(void)
2022 TestApplication application;
2024 Actor actor = Actor::New();
2025 actor.SetSize(100.0f, 100.0f);
2026 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2027 Stage::GetCurrent().Add(actor);
2031 type = TypeRegistry::Get().GetTypeInfo( "TapGestureDetector" );
2032 DALI_TEST_CHECK( type );
2033 BaseHandle handle = type.CreateInstance();
2034 DALI_TEST_CHECK( handle );
2035 TapGestureDetector detector = TapGestureDetector::DownCast( handle );
2036 DALI_TEST_CHECK( detector );
2038 // Attach actor to detector
2040 GestureReceivedFunctor functor( data );
2041 detector.Attach(actor);
2043 // Connect to signal through type
2044 handle.ConnectSignal( &application, "tapDetected", functor );
2046 // Render and notify
2047 application.SendNotification();
2048 application.Render();
2051 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
2052 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
2053 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2057 int UtcDaliTypeRegistryNamedType(void)
2059 TestApplication application;
2060 TypeRegistry typeRegistry = TypeRegistry::Get();
2062 // Create a normal actor
2063 BaseHandle actorHandle = typeRegistry.GetTypeInfo( "Actor" ).CreateInstance();
2064 DALI_TEST_CHECK( actorHandle );
2065 Actor actor( Actor::DownCast( actorHandle ) );
2066 DALI_TEST_CHECK( actor );
2067 unsigned int actorPropertyCount( actor.GetPropertyCount() );
2069 // Create Named Actor Type
2070 BaseHandle namedHandle = typeRegistry.GetTypeInfo( "MyNamedActor" ).CreateInstance();
2071 DALI_TEST_CHECK( namedHandle );
2072 Actor namedActor( Actor::DownCast( namedHandle ) );
2073 DALI_TEST_CHECK( namedActor );
2074 unsigned int namedActorPropertyCount( namedActor.GetPropertyCount() );
2076 DALI_TEST_CHECK( namedActorPropertyCount > actorPropertyCount );
2080 int UtcDaliTypeInfoGetActionNameP(void)
2082 TestApplication application;
2083 TypeRegistry typeRegistry = TypeRegistry::Get();
2085 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2086 DALI_TEST_CHECK( typeInfo );
2088 DALI_TEST_CHECK( 0 != typeInfo.GetActionCount() );
2090 std::string name = typeInfo.GetActionName(0);
2092 DALI_TEST_EQUALS( name, "show", TEST_LOCATION );
2097 int UtcDaliTypeInfoGetActionNameN(void)
2099 TestApplication application;
2100 TypeRegistry typeRegistry = TypeRegistry::Get();
2102 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2103 DALI_TEST_CHECK( typeInfo );
2105 DALI_TEST_CHECK( 0 != typeInfo.GetActionCount() );
2107 std::string name = typeInfo.GetActionName(std::numeric_limits<size_t>::max());
2109 DALI_TEST_EQUALS( 0u, name.size(), TEST_LOCATION );
2114 int UtcDaliTypeInfoGetSignalNameP(void)
2116 TestApplication application;
2117 TypeRegistry typeRegistry = TypeRegistry::Get();
2119 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2120 DALI_TEST_CHECK( typeInfo );
2122 DALI_TEST_CHECK( 0 != typeInfo.GetSignalCount() );
2124 std::string name = typeInfo.GetSignalName(0);
2126 DALI_TEST_EQUALS( name, "touched", TEST_LOCATION );
2131 int UtcDaliTypeInfoGetSignalNameN(void)
2133 TestApplication application;
2134 TypeRegistry typeRegistry = TypeRegistry::Get();
2136 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2137 DALI_TEST_CHECK( typeInfo );
2139 DALI_TEST_CHECK( 0 != typeInfo.GetSignalCount() );
2141 std::string name = typeInfo.GetSignalName(std::numeric_limits<size_t>::max());
2143 DALI_TEST_EQUALS( 0u, name.size(), TEST_LOCATION );
2149 int UtcDaliTypeInfoGetCreatorP(void)
2151 TestApplication application;
2152 TypeRegistry typeRegistry = TypeRegistry::Get();
2154 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2155 DALI_TEST_CHECK( typeInfo );
2157 TypeInfo::CreateFunction createFn = typeInfo.GetCreator();
2158 DALI_TEST_EQUALS( createFn != NULL, true, TEST_LOCATION );
2162 BaseHandle handle = createFn();
2163 DALI_TEST_EQUALS( (bool)handle, true, TEST_LOCATION );
2169 int UtcDaliTypeInfoGetCreatorN(void)
2171 TestApplication application;
2172 TypeRegistry typeRegistry = TypeRegistry::Get();
2174 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "MyTestCustomActor3" );
2175 DALI_TEST_CHECK( typeInfo );
2177 TypeInfo::CreateFunction createFn = typeInfo.GetCreator();
2178 DALI_TEST_EQUALS( createFn == NULL, true, TEST_LOCATION );
2183 int UtcDaliTypeInfoGetPropertyCountP1(void)
2185 TestApplication application;
2186 TypeRegistry typeRegistry = TypeRegistry::Get();
2188 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2189 DALI_TEST_CHECK( typeInfo );
2190 size_t actorPropertyCount = typeInfo.GetPropertyCount();
2192 DALI_TEST_EQUALS( actorPropertyCount == 0 , true, TEST_LOCATION ); // No event only props
2196 int UtcDaliTypeInfoGetPropertyCountP2(void)
2198 TestApplication application;
2199 TypeRegistry typeRegistry = TypeRegistry::Get();
2201 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "MyTestCustomActor2" );
2202 DALI_TEST_CHECK( typeInfo );
2203 size_t propertyCount = typeInfo.GetPropertyCount();
2204 Property::IndexContainer indices;
2205 typeInfo.GetPropertyIndices( indices );
2207 DALI_TEST_EQUALS( propertyCount > 0 && propertyCount <= indices.Size(), true, TEST_LOCATION );
2208 DALI_TEST_EQUALS( propertyCount == 2, true, TEST_LOCATION );