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 static MyTestCustomActor2 New()
365 return MyTestCustomActor2(); // takes ownership
368 virtual ~MyTestCustomActor2()
372 static MyTestCustomActor2 DownCast( BaseHandle handle )
374 MyTestCustomActor2 result;
376 CustomActor custom = Dali::CustomActor::DownCast( handle );
379 CustomActorImpl& customImpl = custom.GetImplementation();
381 Impl::MyTestCustomActor* impl = dynamic_cast<Impl::MyTestCustomActor*>(&customImpl);
385 result = MyTestCustomActor2(customImpl.GetOwner());
394 MyTestCustomActor2(Internal::CustomActor* internal)
395 : CustomActor(internal)
399 MyTestCustomActor2( Impl::MyTestCustomActor& impl )
400 : CustomActor( impl )
405 static TypeRegistration customTypeInit( typeid(MyTestCustomActor2), typeid(Dali::CustomActor), CreateCustomInit, true );
408 BaseHandle CreateCustom(void)
410 return MyTestCustomActor::New();
413 static std::string lastSignalConnectionCustom;
415 bool DoConnectSignalCustom( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
417 lastSignalConnectionCustom = signalName;
419 bool connected( true );
421 Dali::BaseHandle handle(object);
422 MyTestCustomActor customActor = MyTestCustomActor::DownCast(handle);
424 if( "sig1" == signalName )
426 customActor.GetCustomSignal().Connect( tracker, functor );
430 // signalName does not match any signal
437 bool DoConnectSignalCustomFailure( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
439 lastSignalConnectionCustom = "failed";
441 return false; // This is supposed to fail
444 struct CustomTestFunctor
448 ++mTotalInstanceCount;
449 ++mCurrentInstanceCount;
452 CustomTestFunctor( const CustomTestFunctor& copyMe )
454 ++mTotalInstanceCount;
455 ++mCurrentInstanceCount;
460 --mCurrentInstanceCount;
468 static int mTotalInstanceCount;
469 static int mCurrentInstanceCount;
470 static int mCallbackCount;
473 int CustomTestFunctor::mTotalInstanceCount = 0;
474 int CustomTestFunctor::mCurrentInstanceCount = 0;
475 int CustomTestFunctor::mCallbackCount = 0;
477 static void ResetFunctorCounts()
479 CustomTestFunctor::mTotalInstanceCount = 0;
480 CustomTestFunctor::mCurrentInstanceCount = 0;
481 CustomTestFunctor::mCallbackCount = 0;
484 static std::string lastActionCustom;
485 bool DoActionCustom(BaseObject* object, const std::string& actionName, const Property::Map& /*attributes*/)
487 lastActionCustom = actionName;
491 // Custom type registration
492 static TypeRegistration customType1( typeid(MyTestCustomActor), typeid(Dali::CustomActor), CreateCustom );
495 static SignalConnectorType customSignalConnector1( customType1, "sig1", DoConnectSignalCustom );
496 static SignalConnectorType customSignalConnector2( customType1, "sig2", DoConnectSignalCustomFailure );
497 static const int TEST_SIGNAL_COUNT = 2;
500 static TypeAction customAction1( customType1, "act1", DoActionCustom);
501 static const int TEST_ACTION_COUNT = 1;
503 class TestConnectionTracker : public ConnectionTracker
507 TestConnectionTracker()
512 BaseHandle CreateNamedActorType()
514 Actor actor = Actor::New();
515 actor.SetName( "NamedActor" );
519 TypeRegistration namedActorType( "MyNamedActor", typeid(Dali::Actor), CreateNamedActorType );
520 PropertyRegistration namedActorPropertyOne( namedActorType, "propName", PROPERTY_REGISTRATION_START_INDEX, Property::BOOLEAN, &SetProperty, &GetProperty );
522 } // Anonymous namespace
524 // Note: No negative test case for UtcDaliTypeRegistryGet can be implemented.
525 int UtcDaliTypeRegistryGetP(void)
527 TestApplication application;
529 TypeRegistry registry = TypeRegistry::Get();
530 DALI_TEST_CHECK( registry );
535 // Note: No negative test case for UtcDaliTypeRegistryConstructor can be implemented.
536 int UtcDaliTypeRegistryConstructorP(void)
538 TestApplication application;
540 TypeRegistry registry;
541 DALI_TEST_CHECK( !registry );
545 // Note: No negative test case for UtcDaliTypeRegistryCopyConstructor can be implemented.
546 int UtcDaliTypeRegistryCopyConstructorP(void)
548 TestApplication application;
550 TypeRegistry registry = TypeRegistry::Get();
551 DALI_TEST_CHECK( registry );
553 TypeRegistry copy( registry );
554 DALI_TEST_CHECK( copy );
556 DALI_TEST_CHECK( registry.GetTypeInfo( "Actor" ).GetName() == copy.GetTypeInfo( "Actor" ).GetName() );
561 // Note: No negative test case for UtcDaliTypeRegistryAssignmentOperator can be implemented.
562 int UtcDaliTypeRegistryAssignmentOperatorP(void)
564 TestApplication application;
566 TypeRegistry registry = TypeRegistry::Get();
567 DALI_TEST_CHECK( registry );
569 TypeRegistry copy = registry;
570 DALI_TEST_CHECK( copy );
571 DALI_TEST_CHECK( registry == copy );
573 DALI_TEST_CHECK( registry.GetTypeInfo( "Actor" ).GetName() == copy.GetTypeInfo( "Actor" ).GetName() );
578 int UtcDaliTypeRegistryAssignP(void)
580 TestApplication application;
582 TypeRegistry registry = TypeRegistry::Get();
583 TypeRegistry registry2;
584 registry2 = registry;
585 DALI_TEST_CHECK( registry2 );
587 DALI_TEST_CHECK( registry2.GetTypeInfo( "Actor" ).GetName() == registry2.GetTypeInfo( "Actor" ).GetName() );
592 int UtcDaliTypeRegistryGetTypeInfoFromTypeNameP(void)
594 TestApplication application;
596 TypeRegistry registry = TypeRegistry::Get();
601 type = registry.GetTypeInfo( "CameraActor" );
602 DALI_TEST_CHECK( type );
603 CameraActor ca = CameraActor::DownCast(type.CreateInstance());
604 DALI_TEST_CHECK( ca );
605 Stage::GetCurrent().Add( ca );
606 application.Render();
609 type = registry.GetTypeInfo( "Animation" );
610 DALI_TEST_CHECK( type );
611 Animation an = Animation::DownCast(type.CreateInstance());
612 DALI_TEST_CHECK( an );
614 application.Render();
619 int UtcDaliTypeRegistryGetTypeInfoFromTypeNameN(void)
621 TestApplication application;
623 TypeRegistry registry = TypeRegistry::Get();
627 type = registry.GetTypeInfo( "MyDummyActor" );
628 DALI_TEST_CHECK( !type );
633 int UtcDaliTypeRegistryGetTypeInfoFromTypeIdP(void)
635 TypeInfo named_type = TypeRegistry::Get().GetTypeInfo( "CameraActor" );
636 TypeInfo typeinfo_type = TypeRegistry::Get().GetTypeInfo( typeid(Dali::CameraActor) );
638 DALI_TEST_CHECK( named_type );
639 DALI_TEST_CHECK( typeinfo_type );
641 // Check named and typeid are equivalent
642 DALI_TEST_CHECK( named_type == typeinfo_type );
644 DALI_TEST_CHECK( named_type.GetName() == typeinfo_type.GetName() );
645 DALI_TEST_CHECK( named_type.GetBaseName() == typeinfo_type.GetBaseName() );
650 int UtcDaliTypeRegistryGetTypeInfoFromTypeIdN(void)
652 TestApplication application;
653 TypeRegistry typeRegistry = TypeRegistry::Get();
655 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(Vector2) );
656 DALI_TEST_CHECK( !typeInfo );
661 int UtcDaliTypeRegistryGetTypeNameCountP(void)
663 TestApplication application;
664 TypeRegistry typeRegistry = TypeRegistry::Get();
667 for(size_t i = 0; i < typeRegistry.GetTypeNameCount(); i++)
669 type = typeRegistry.GetTypeInfo( typeRegistry.GetTypeName(i) );
670 DALI_TEST_CHECK( type );
677 int UtcDaliTypeRegistryGetTypeNamesP(void)
679 TestApplication application;
680 TypeRegistry typeRegistry = TypeRegistry::Get();
683 for(size_t i = 0; i < typeRegistry.GetTypeNameCount(); i++)
685 type = typeRegistry.GetTypeInfo( typeRegistry.GetTypeName(i) );
686 DALI_TEST_CHECK( type );
693 // Note: No negative test case for UtcDaliTypeRegistryTypeRegistration can be implemented.
694 int UtcDaliTypeRegistryTypeRegistrationNotCallingCreateOnInitP(void)
696 ResetFunctorCounts();
698 TestApplication application;
700 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
701 DALI_TEST_CHECK( type );
703 TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( "CustomActor" );
704 DALI_TEST_CHECK( baseType );
706 BaseHandle handle = type.CreateInstance();
707 DALI_TEST_CHECK( handle );
709 MyTestCustomActor customHandle = MyTestCustomActor::DownCast( handle );
710 DALI_TEST_CHECK( customHandle );
712 DALI_TEST_EQUALS( type.GetActionCount(), TEST_ACTION_COUNT + baseType.GetActionCount(), TEST_LOCATION );
714 DALI_TEST_EQUALS( type.GetSignalCount(), TEST_SIGNAL_COUNT + baseType.GetSignalCount(), TEST_LOCATION );
717 TestConnectionTracker tracker;
719 bool connected = handle.ConnectSignal( &tracker, "sig1", CustomTestFunctor() );
720 DALI_TEST_EQUALS( connected, true, TEST_LOCATION );
721 DALI_TEST_CHECK( lastSignalConnectionCustom == "sig1" );
722 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
723 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION );
725 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
726 customHandle.GetCustomSignal().Emit();
727 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION );
728 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
729 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION );
731 // tracker should automatically disconnect here
732 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
733 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
735 // Test that functor is disconnected
736 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION );
737 customHandle.GetCustomSignal().Emit();
738 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1/*not incremented*/, TEST_LOCATION );
739 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
740 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
742 Property::Map attributes;
743 handle.DoAction("act1", attributes);
744 DALI_TEST_CHECK( lastActionCustom == "act1" );
748 // Note: No negative test case for UtcDaliTypeRegistryTypeRegistration can be implemented.
749 int UtcDaliTypeRegistryTypeRegistrationCallingCreateOnInitP(void)
751 TestApplication application;
753 DALI_TEST_CHECK( "MyTestCustomActor2" == customTypeInit.RegisteredName() );
755 DALI_TEST_CHECK( true == CreateCustomInitCalled );
756 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor2" );
757 DALI_TEST_CHECK( type );
761 // Note: No negative test case for UtcDaliTypeRegistryTypeRegistration can be implemented.
762 int UtcDaliTypeRegistryTypeRegistrationForNamedTypeP(void)
764 TestApplication application;
766 // Create Named Actor Type
767 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyNamedActor" );
768 DALI_TEST_CHECK( type );
770 BaseHandle namedHandle = type.CreateInstance();
771 DALI_TEST_CHECK( namedHandle );
772 Actor namedActor( Actor::DownCast( namedHandle ) );
773 DALI_TEST_CHECK( namedActor );
775 DALI_TEST_CHECK( namedActor.GetName() == "NamedActor" );
776 DALI_TEST_CHECK( type.GetName() == "MyNamedActor" );
777 DALI_TEST_CHECK( type.GetBaseName() == "Actor" );
782 // Note: No negative test case for UtcDaliTypeRegistryRegisteredName can be implemented.
783 int UtcDaliTypeRegistryRegisteredNameP(void)
785 TestApplication application;
787 DALI_TEST_CHECK( scriptedName == scriptedType.RegisteredName() );
789 TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( scriptedName );
790 DALI_TEST_CHECK( baseType );
792 BaseHandle handle = baseType.CreateInstance();
794 DALI_TEST_CHECK( true == CreateCustomNamedInitCalled );
795 TypeInfo type = TypeRegistry::Get().GetTypeInfo( scriptedName );
796 DALI_TEST_CHECK( type );
800 int UtcDaliTypeRegistrySignalConnectorTypeP(void)
802 ResetFunctorCounts();
804 TestApplication application;
806 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
807 DALI_TEST_CHECK( type );
809 BaseHandle handle = type.CreateInstance();
810 DALI_TEST_CHECK( handle );
812 MyTestCustomActor customHandle = MyTestCustomActor::DownCast( handle );
813 DALI_TEST_CHECK( customHandle );
816 TestConnectionTracker tracker;
818 bool connected = handle.ConnectSignal( &tracker, "sig1", CustomTestFunctor() );
819 DALI_TEST_EQUALS( connected, true, TEST_LOCATION );
820 DALI_TEST_CHECK( lastSignalConnectionCustom == "sig1" );
821 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
822 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION );
824 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
825 customHandle.GetCustomSignal().Emit();
826 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION );
827 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
828 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION );
830 // tracker should automatically disconnect here
831 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
832 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
834 // Test that functor is disconnected
835 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION );
836 customHandle.GetCustomSignal().Emit();
837 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1/*not incremented*/, TEST_LOCATION );
838 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
839 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
844 int UtcDaliTypeRegistrySignalConnectorTypeN(void)
846 // Test what happens when signal connnector (DoConnectSignalFailure method) returns false
848 ResetFunctorCounts();
850 TestApplication application;
852 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
853 DALI_TEST_CHECK( type );
855 TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( "CustomActor" );
856 DALI_TEST_CHECK( baseType );
858 BaseHandle handle = type.CreateInstance();
859 DALI_TEST_CHECK( handle );
861 MyTestCustomActor customHandle = MyTestCustomActor::DownCast( handle );
862 DALI_TEST_CHECK( customHandle );
864 DALI_TEST_EQUALS( type.GetActionCount(), TEST_ACTION_COUNT + baseType.GetActionCount(), TEST_LOCATION );
866 DALI_TEST_EQUALS( type.GetSignalCount(), TEST_SIGNAL_COUNT + baseType.GetSignalCount(), TEST_LOCATION );
869 TestConnectionTracker tracker;
871 bool connected = handle.ConnectSignal( &tracker, "sig2", CustomTestFunctor() );
872 DALI_TEST_EQUALS( connected, false/*This is supposed to fail*/, TEST_LOCATION );
873 DALI_TEST_CHECK( lastSignalConnectionCustom == "failed" );
874 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
875 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0/*deleted along with FunctorDelegate*/, TEST_LOCATION );
878 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
879 customHandle.GetCustomSignal().Emit();
880 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0/*never called*/, TEST_LOCATION );
882 // tracker should have nothing to disconnect here
885 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
886 customHandle.GetCustomSignal().Emit();
887 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0/*never called*/, TEST_LOCATION );
891 int UtcDaliTypeRegistryTypeActionP(void)
893 ResetFunctorCounts();
895 TestApplication application;
897 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
898 DALI_TEST_CHECK( type );
900 BaseHandle handle = type.CreateInstance();
901 DALI_TEST_CHECK( handle );
903 Property::Map attributes;
904 DALI_TEST_CHECK( handle.DoAction("act1", attributes) );
905 DALI_TEST_CHECK( lastActionCustom == "act1" );
910 int UtcDaliTypeRegistryTypeActionN(void)
912 ResetFunctorCounts();
914 TestApplication application;
916 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
917 DALI_TEST_CHECK( type );
919 BaseHandle handle = type.CreateInstance();
920 DALI_TEST_CHECK( handle );
922 Property::Map attributes;
923 DALI_TEST_CHECK( !handle.DoAction( "unknownAction", attributes ) );
928 int UtcDaliTypeRegistryPropertyRegistrationP(void)
930 TestApplication application;
931 TypeRegistry typeRegistry = TypeRegistry::Get();
933 // Check property count before property registration
934 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
935 DALI_TEST_CHECK( typeInfo );
936 BaseHandle handle = typeInfo.CreateInstance();
937 DALI_TEST_CHECK( handle );
938 Actor customActor = Actor::DownCast( handle );
939 DALI_TEST_CHECK( customActor );
940 unsigned int initialPropertyCount( customActor.GetPropertyCount() );
942 std::string propertyName( "prop1" );
943 int propertyIndex( PROPERTY_REGISTRATION_START_INDEX );
944 Property::Type propertyType( Property::BOOLEAN );
945 PropertyRegistration property1( customType1, propertyName, propertyIndex, propertyType, &SetProperty, &GetProperty );
947 // Check property count after registration
948 unsigned int postRegistrationPropertyCount( customActor.GetPropertyCount() );
949 DALI_TEST_EQUALS( initialPropertyCount + 1u, postRegistrationPropertyCount, TEST_LOCATION );
951 // Add custom property and check property count
952 customActor.RegisterProperty( "customProp1", true );
953 unsigned int customPropertyCount( customActor.GetPropertyCount() );
954 DALI_TEST_EQUALS( postRegistrationPropertyCount + 1u, customPropertyCount, TEST_LOCATION );
956 // Set the property, ensure SetProperty called
957 DALI_TEST_CHECK( !setPropertyCalled );
958 customActor.SetProperty( propertyIndex, false );
959 DALI_TEST_CHECK( setPropertyCalled );
961 // Get the property, ensure GetProperty called
962 DALI_TEST_CHECK( !getPropertyCalled );
963 (void)customActor.GetProperty< bool >( propertyIndex );
964 DALI_TEST_CHECK( getPropertyCalled );
966 // Check the property name
967 DALI_TEST_EQUALS( customActor.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
968 DALI_TEST_EQUALS( typeInfo.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
970 // Check the property index
971 DALI_TEST_EQUALS( customActor.GetPropertyIndex( propertyName ), propertyIndex, TEST_LOCATION );
973 // Check the property type
974 DALI_TEST_EQUALS( customActor.GetPropertyType( propertyIndex ), propertyType, TEST_LOCATION );
976 // Check property count of type-info is 1
977 Property::IndexContainer indices;
978 typeInfo.GetPropertyIndices( indices );
979 DALI_TEST_EQUALS( indices.Size(), 1u, TEST_LOCATION );
981 // Ensure indices returned from actor and customActor differ by two
982 Actor actor = Actor::New();
983 actor.GetPropertyIndices( indices );
984 unsigned int actorIndices = indices.Size();
985 customActor.GetPropertyIndices( indices );
986 unsigned int customActorIndices = indices.Size();
987 DALI_TEST_EQUALS( actorIndices + 2u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
991 int UtcDaliTypeRegistryPropertyRegistrationN(void)
993 TestApplication application;
994 TypeRegistry typeRegistry = TypeRegistry::Get();
996 // Attempt to register a property type out-of-bounds index (less than)
999 PropertyRegistration property1( customType1, "propName", PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN, &SetProperty, &GetProperty );
1000 tet_result( TET_FAIL );
1002 catch ( DaliException& e )
1004 DALI_TEST_ASSERT( e, "( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1007 // Attempt to register a property type out-of-bounds index (greater than)
1010 PropertyRegistration property1( customType1, "propName", PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN, &SetProperty, &GetProperty );
1011 tet_result( TET_FAIL );
1013 catch ( DaliException& e )
1015 DALI_TEST_ASSERT( e, "( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1021 int UtcDaliTypeRegistryAnimatablePropertyRegistrationP(void)
1023 TestApplication application;
1024 TypeRegistry typeRegistry = TypeRegistry::Get();
1026 // Check property count before property registration
1027 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1028 DALI_TEST_CHECK( typeInfo );
1029 BaseHandle handle = typeInfo.CreateInstance();
1030 DALI_TEST_CHECK( handle );
1031 Actor customActor = Actor::DownCast( handle );
1032 DALI_TEST_CHECK( customActor );
1033 Stage::GetCurrent().Add(customActor);
1035 unsigned int customPropertyCount( customActor.GetPropertyCount() );
1037 // Register animatable property
1038 std::string animatablePropertyName( "animatableProp1" );
1039 int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1040 Property::Type animatablePropertyType( Property::FLOAT );
1041 AnimatablePropertyRegistration animatableProperty( customType1, animatablePropertyName, animatablePropertyIndex, animatablePropertyType );
1043 // Check property count after registration
1044 DALI_TEST_EQUALS( customPropertyCount + 1u, customActor.GetPropertyCount(), TEST_LOCATION );
1046 // Set the animatable property value
1047 customActor.SetProperty( animatablePropertyIndex, 25.0f );
1049 // Render and notify
1050 application.SendNotification();
1051 application.Render();
1053 // Check the animatable property value
1054 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 25.f, TEST_LOCATION );
1056 // Check the animatable property name
1057 DALI_TEST_EQUALS( customActor.GetPropertyName( animatablePropertyIndex ), animatablePropertyName, TEST_LOCATION );
1059 // Check the animatable property index
1060 DALI_TEST_EQUALS( customActor.GetPropertyIndex( animatablePropertyName ), animatablePropertyIndex, TEST_LOCATION );
1062 // Check the animatable property type
1063 DALI_TEST_EQUALS( customActor.GetPropertyType( animatablePropertyIndex ), animatablePropertyType, TEST_LOCATION );
1065 // Check property count of type-info is 1
1066 Property::IndexContainer indices;
1067 typeInfo.GetPropertyIndices( indices );
1068 DALI_TEST_EQUALS( indices.Size(), 1u, TEST_LOCATION );
1070 // Ensure indices returned from actor and customActor differ by one
1071 Actor actor = Actor::New();
1072 actor.GetPropertyIndices( indices );
1073 unsigned int actorIndices = indices.Size();
1074 customActor.GetPropertyIndices( indices );
1075 unsigned int customActorIndices = indices.Size();
1076 DALI_TEST_EQUALS( actorIndices + 1u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1078 // check that the property is animatable
1079 Animation animation = Animation::New(0.2f);
1080 animation.AnimateTo( Property( customActor, animatablePropertyIndex ), 15.f, AlphaFunction::LINEAR );
1082 // Render and notify, animation play for 0.05 seconds
1083 application.SendNotification();
1084 application.Render(50);
1085 DALI_TEST_EQUALS( 0.25f, animation.GetCurrentProgress(), TEST_LOCATION );
1086 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 22.5f, TEST_LOCATION );
1087 // Render and notify, animation play for another 0.1 seconds
1088 application.SendNotification();
1089 application.Render(100);
1090 DALI_TEST_EQUALS( 0.75f, animation.GetCurrentProgress(), TEST_LOCATION );
1091 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 17.5f, TEST_LOCATION );
1096 int UtcDaliTypeRegistryAnimatablePropertyRegistrationN(void)
1098 TestApplication application;
1099 TypeRegistry typeRegistry = TypeRegistry::Get();
1101 // Attempt to register an animatable property type out-of-bounds index (less than)
1104 AnimatablePropertyRegistration property1( customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN );
1105 tet_result( TET_FAIL );
1107 catch ( DaliException& e )
1109 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1112 // Attempt to register an animatable property type out-of-bounds index (greater than)
1115 AnimatablePropertyRegistration property1( customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN );
1116 tet_result( TET_FAIL );
1118 catch ( DaliException& e )
1120 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1126 int UtcDaliTypeRegistryAnimatablePropertyRegistrationWithDefaultP(void)
1128 TestApplication application;
1129 TypeRegistry typeRegistry = TypeRegistry::Get();
1131 // Check property count before property registration
1132 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1133 DALI_TEST_CHECK( typeInfo );
1134 BaseHandle handle = typeInfo.CreateInstance();
1135 DALI_TEST_CHECK( handle );
1136 Actor customActor = Actor::DownCast( handle );
1137 DALI_TEST_CHECK( customActor );
1138 Stage::GetCurrent().Add(customActor);
1140 unsigned int customPropertyCount( customActor.GetPropertyCount() );
1142 // Register animatable property
1143 std::string animatablePropertyName( "animatableProp1" );
1144 int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1145 AnimatablePropertyRegistration animatableProperty1( customType1, animatablePropertyName, animatablePropertyIndex, 10.f );
1147 // Check property count after registration
1148 DALI_TEST_EQUALS( customPropertyCount + 1u, customActor.GetPropertyCount(), TEST_LOCATION );
1150 // Render and notify
1151 application.SendNotification();
1152 application.Render();
1154 // Check the animatable property value
1155 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 10.f, TEST_LOCATION );
1157 // Check the animatable property name
1158 DALI_TEST_EQUALS( customActor.GetPropertyName( animatablePropertyIndex ), animatablePropertyName, TEST_LOCATION );
1160 // Check the animatable property index
1161 DALI_TEST_EQUALS( customActor.GetPropertyIndex( animatablePropertyName ), animatablePropertyIndex, TEST_LOCATION );
1163 // Check the animatable property type
1164 DALI_TEST_EQUALS( customActor.GetPropertyType( animatablePropertyIndex ), Property::FLOAT, TEST_LOCATION );
1166 // Check property count of type-info is 1
1167 Property::IndexContainer indices;
1168 typeInfo.GetPropertyIndices( indices );
1169 DALI_TEST_EQUALS( indices.Size(), 1u, TEST_LOCATION );
1171 // Ensure indices returned from actor and customActor differ by one
1172 Actor actor = Actor::New();
1173 actor.GetPropertyIndices( indices );
1174 unsigned int actorIndices = indices.Size();
1175 customActor.GetPropertyIndices( indices );
1176 unsigned int customActorIndices = indices.Size();
1177 DALI_TEST_EQUALS( actorIndices + 1u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1179 // check that the property is animatable
1180 Animation animation = Animation::New(0.2f);
1181 animation.AnimateTo( Property( customActor, animatablePropertyIndex ), 20.f, AlphaFunction::LINEAR );
1183 // Render and notify, animation play for 0.05 seconds
1184 application.SendNotification();
1185 application.Render(50);
1186 DALI_TEST_EQUALS( 0.25f, animation.GetCurrentProgress(), TEST_LOCATION );
1187 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 12.5f, TEST_LOCATION );
1188 // Render and notify, animation play for another 0.1 seconds
1189 application.SendNotification();
1190 application.Render(100);
1191 DALI_TEST_EQUALS( 0.75f, animation.GetCurrentProgress(), TEST_LOCATION );
1192 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 17.5f, TEST_LOCATION );
1197 int UtcDaliTypeRegistryAnimatablePropertyRegistrationWithDefaultN(void)
1199 TestApplication application;
1200 TypeRegistry typeRegistry = TypeRegistry::Get();
1202 // Attempt to register an animatable property type out-of-bounds index (less than)
1205 AnimatablePropertyRegistration property1( customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX - 1, false );
1206 tet_result( TET_FAIL );
1208 catch ( DaliException& e )
1210 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1213 // Attempt to register an animatable property type out-of-bounds index (greater than)
1216 AnimatablePropertyRegistration property1( customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX + 1, true );
1217 tet_result( TET_FAIL );
1219 catch ( DaliException& e )
1221 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1227 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationP(void)
1229 TestApplication application;
1230 TypeRegistry typeRegistry = TypeRegistry::Get();
1232 // Check property count before property registration
1233 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1234 DALI_TEST_CHECK( typeInfo );
1235 BaseHandle handle = typeInfo.CreateInstance();
1236 DALI_TEST_CHECK( handle );
1237 Actor customActor = Actor::DownCast( handle );
1238 DALI_TEST_CHECK( customActor );
1240 unsigned int customPropertyCount( customActor.GetPropertyCount() );
1242 // Register animatable property
1243 std::string animatablePropertyName( "animatableProp1" );
1244 int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1245 Property::Type animatablePropertyType( Property::VECTOR2 );
1246 AnimatablePropertyRegistration animatableProperty1( customType1, animatablePropertyName, animatablePropertyIndex, animatablePropertyType );
1248 // Check property count after registration
1249 DALI_TEST_EQUALS( customPropertyCount + 1u, customActor.GetPropertyCount(), TEST_LOCATION );
1251 // Set the animatable property value
1252 customActor.SetProperty( animatablePropertyIndex, Vector2(25.0f, 50.0f) );
1254 // Render and notify
1255 application.SendNotification();
1256 application.Render();
1258 // Check the animatable property value
1259 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( animatablePropertyIndex ), Vector2(25.0f, 50.0f), TEST_LOCATION );
1261 // Check the animatable property name
1262 DALI_TEST_EQUALS( customActor.GetPropertyName( animatablePropertyIndex ), animatablePropertyName, TEST_LOCATION );
1264 // Check the animatable property index
1265 DALI_TEST_EQUALS( customActor.GetPropertyIndex( animatablePropertyName ), animatablePropertyIndex, TEST_LOCATION );
1267 // Check the animatable property type
1268 DALI_TEST_EQUALS( customActor.GetPropertyType( animatablePropertyIndex ), animatablePropertyType, TEST_LOCATION );
1270 // Check property count of type-info is 1
1271 Property::IndexContainer indices;
1272 typeInfo.GetPropertyIndices( indices );
1273 DALI_TEST_EQUALS( indices.Size(), 1u, TEST_LOCATION );
1275 // Register animatable property components
1276 std::string animatablePropertyComponentName1( "animatableProp1X" );
1277 int animatablePropertyComponentIndex1( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1 );
1278 AnimatablePropertyComponentRegistration animatablePropertyComponent1( customType1, animatablePropertyComponentName1, animatablePropertyComponentIndex1, animatablePropertyIndex, 0 );
1280 std::string animatablePropertyComponentName2( "animatableProp1Y" );
1281 int animatablePropertyComponentIndex2( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2 );
1282 AnimatablePropertyComponentRegistration animatablePropertyComponent2( customType1, animatablePropertyComponentName2, animatablePropertyComponentIndex2, animatablePropertyIndex, 1 );
1284 // Check property count after registration
1285 DALI_TEST_EQUALS( customPropertyCount + 3u, customActor.GetPropertyCount(), TEST_LOCATION );
1287 // Check the animatable property component value
1288 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex1 ), 25.0f, TEST_LOCATION );
1289 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex2 ), 50.0f, TEST_LOCATION );
1291 // Set the animatable property component value
1292 customActor.SetProperty( animatablePropertyComponentIndex1, 150.0f );
1294 // Render and notify
1295 application.SendNotification();
1296 application.Render();
1298 // Check the animatable property value
1299 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( animatablePropertyIndex ), Vector2(150.0f, 50.0f), TEST_LOCATION );
1300 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex1 ), 150.0f, TEST_LOCATION );
1301 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex2 ), 50.0f, TEST_LOCATION );
1303 // Set the animatable property component value
1304 customActor.SetProperty( animatablePropertyComponentIndex2, 225.0f );
1306 // Render and notify
1307 application.SendNotification();
1308 application.Render();
1310 // Check the animatable property value
1311 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( animatablePropertyIndex ), Vector2(150.0f, 225.0f), TEST_LOCATION );
1312 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex1 ), 150.0f, TEST_LOCATION );
1313 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex2 ), 225.0f, TEST_LOCATION );
1315 // Ensure indices returned from actor and customActor differ by three
1316 Actor actor = Actor::New();
1317 actor.GetPropertyIndices( indices );
1318 unsigned int actorIndices = indices.Size();
1319 customActor.GetPropertyIndices( indices );
1320 unsigned int customActorIndices = indices.Size();
1321 DALI_TEST_EQUALS( actorIndices + 3u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1326 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationN(void)
1328 TestApplication application;
1329 TypeRegistry typeRegistry = TypeRegistry::Get();
1331 // Register animatable property with the type of Vector2
1332 int animatablePropertyIndex1( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1333 AnimatablePropertyRegistration animatableProperty1( customType1, "animatableProp1", animatablePropertyIndex1, Property::VECTOR2 );
1335 // Attempt to register an animatable property component out-of-bounds index (less than)
1338 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp1X", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX - 1, animatablePropertyIndex1, 0 );
1339 tet_result( TET_FAIL );
1341 catch ( DaliException& e )
1343 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1346 // Attempt to register an animatable property component out-of-bounds index (greater than)
1349 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp1X", ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX + 1, animatablePropertyIndex1, 0 );
1350 tet_result( TET_FAIL );
1352 catch ( DaliException& e )
1354 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1357 // Register an animatable property component
1358 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp1X", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1, animatablePropertyIndex1, 0 );
1360 // Attempt to register another animatable property component with the same component index
1363 AnimatablePropertyComponentRegistration propertyComponent2( customType1, "animatableProp1Y", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2, animatablePropertyIndex1, 0 );
1364 tet_result( TET_FAIL );
1366 catch ( DaliException& e )
1368 DALI_TEST_ASSERT( e, "Property component already registered", TEST_LOCATION );
1371 // Register animatable property with the type of boolean
1372 int animatablePropertyIndex2( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2 );
1373 AnimatablePropertyRegistration animatableProperty2( customType1, "animatableProp2", animatablePropertyIndex2, Property::BOOLEAN );
1375 // Attempt to register an animatable property component for the above property with boolean type
1378 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp2X", animatablePropertyIndex2 + 1, animatablePropertyIndex2, 0 );
1379 tet_result( TET_FAIL );
1381 catch ( DaliException& e )
1383 DALI_TEST_ASSERT( e, "Base property does not support component", TEST_LOCATION );
1389 int UtcDaliTypeRegistryChildPropertyRegistrationP(void)
1391 TestApplication application;
1392 TypeRegistry typeRegistry = TypeRegistry::Get();
1394 // Check property count before property registration
1395 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1396 DALI_TEST_CHECK( typeInfo );
1397 BaseHandle handle = typeInfo.CreateInstance();
1398 DALI_TEST_CHECK( handle );
1399 Actor customActor = Actor::DownCast( handle );
1400 DALI_TEST_CHECK( customActor );
1401 unsigned int initialPropertyCount( customActor.GetPropertyCount() );
1403 // Register child properties to the parent
1404 std::string propertyName( "childProp1" );
1405 int propertyIndex( CHILD_PROPERTY_REGISTRATION_START_INDEX );
1406 Property::Type propertyType( Property::BOOLEAN );
1407 ChildPropertyRegistration childProperty1( customType1, propertyName, propertyIndex, propertyType );
1409 std::string propertyName2( "childProp2" );
1410 int propertyIndex2( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1 );
1411 Property::Type propertyType2( Property::INTEGER );
1412 ChildPropertyRegistration childProperty2( customType1, propertyName2, propertyIndex2, propertyType2 );
1414 std::string propertyName3( "childProp3" );
1415 int propertyIndex3( CHILD_PROPERTY_REGISTRATION_START_INDEX + 2 );
1416 Property::Type propertyType3( Property::FLOAT );
1417 ChildPropertyRegistration childProperty3( customType1, propertyName3, propertyIndex3, propertyType3 );
1419 std::string propertyName4( "childProp4" );
1420 int propertyIndex4( CHILD_PROPERTY_REGISTRATION_START_INDEX + 3 );
1421 Property::Type propertyType4( Property::INTEGER );
1422 ChildPropertyRegistration childProperty4( customType1, propertyName4, propertyIndex4, propertyType4 );
1424 // Check property count are not changed because the child properties will not be created for the parent
1425 DALI_TEST_EQUALS( initialPropertyCount, customActor.GetPropertyCount(), TEST_LOCATION );
1427 // Create a child actor
1428 Actor childActor = Actor::New();
1429 DALI_TEST_CHECK( childActor );
1430 unsigned int initialChildActorPropertyCount( childActor.GetPropertyCount() );
1432 // Set the value for the first child property when the child actor doesn't have a parent yet
1433 childActor.SetProperty(propertyIndex, true);
1435 // Check that the first child property is dynamically created
1436 DALI_TEST_EQUALS( initialChildActorPropertyCount + 1u, childActor.GetPropertyCount(), TEST_LOCATION );
1438 // Check the first child property value
1439 DALI_TEST_EQUALS( childActor.GetProperty< bool >( propertyIndex ), true, TEST_LOCATION );
1441 // Check the first child property type
1442 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex ), propertyType, TEST_LOCATION );
1444 // Check that the first child property have no name, as it doesn't have a parent yet.
1445 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex ), "", TEST_LOCATION );
1447 // Check that the first property can't be accessed through its name, as it doesn't have a parent yet.
1448 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName ), Property::INVALID_INDEX, TEST_LOCATION );
1450 // Create a custom property for the child with the same name as the second child property registered to the parent
1451 Property::Index customPropertyIndex = childActor.RegisterProperty(propertyName2, 100, Property::READ_WRITE);
1453 // Check that the custom property is created
1454 DALI_TEST_EQUALS( initialChildActorPropertyCount + 2u, childActor.GetPropertyCount(), TEST_LOCATION );
1456 // Check the property value
1457 DALI_TEST_EQUALS( childActor.GetProperty< int >( customPropertyIndex ), 100, TEST_LOCATION );
1459 // Check the property index
1460 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName2 ), customPropertyIndex, TEST_LOCATION );
1462 // Check the property type
1463 DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex ), propertyType2, TEST_LOCATION );
1465 // Check the property name
1466 DALI_TEST_EQUALS( childActor.GetPropertyName( customPropertyIndex ), propertyName2, TEST_LOCATION );
1468 // Now add the child actor to the parent
1469 customActor.Add( childActor );
1471 // Check that the first child property now has the correct name as previously registered to the parent
1472 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
1474 // Check that the child property index for the first child property can now be retrieved through its child property name
1475 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName ), propertyIndex, TEST_LOCATION );
1477 // Check that the second child property now has the correct index as previously registered to the parent
1478 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex2 ), propertyName2, TEST_LOCATION );
1480 // Check that the second child property can be accessed through both its custom property index and its child property index
1481 DALI_TEST_EQUALS( childActor.GetProperty< int >( customPropertyIndex ), 100, TEST_LOCATION );
1482 DALI_TEST_EQUALS( childActor.GetProperty< int >( propertyIndex2 ), 100, TEST_LOCATION );
1483 DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex ), propertyType2, TEST_LOCATION );
1484 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex2 ), propertyType2, TEST_LOCATION );
1486 // Check that the child property index for the second child property can now be retrieved through its child property name
1487 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName2 ), propertyIndex2, TEST_LOCATION );
1489 // Set the value for the third child property when the child actor is already added to the parent
1490 childActor.SetProperty(propertyIndex3, 0.15f);
1492 // Check that the third child property is dynamically created
1493 DALI_TEST_EQUALS( initialChildActorPropertyCount + 3u, childActor.GetPropertyCount(), TEST_LOCATION );
1495 // Check the third child property value
1496 DALI_TEST_EQUALS( childActor.GetProperty< float >( propertyIndex3 ), 0.15f, TEST_LOCATION );
1498 // Check the third child property type
1499 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex3 ), propertyType3, TEST_LOCATION );
1501 // Check the third child property name
1502 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex3 ), propertyName3, TEST_LOCATION );
1504 // Check the third child property index.
1505 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName3 ), propertyIndex3, TEST_LOCATION );
1507 // Create a custom property for the child with the same name as the fourth child property registered to the parent
1508 Property::Index customPropertyIndex2 = childActor.RegisterProperty(propertyName4, 20, Property::READ_WRITE);
1510 // Check that the custom property is created
1511 DALI_TEST_EQUALS( initialChildActorPropertyCount + 4u, childActor.GetPropertyCount(), TEST_LOCATION );
1513 // Check the fourth child property value
1514 DALI_TEST_EQUALS( childActor.GetProperty< int >( propertyIndex4 ), 20, TEST_LOCATION );
1515 DALI_TEST_EQUALS( childActor.GetProperty< int >( customPropertyIndex2 ), 20, TEST_LOCATION );
1517 // Check the fourth child property type
1518 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex4 ), propertyType4, TEST_LOCATION );
1519 DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex2 ), propertyType4, TEST_LOCATION );
1521 // Check the fourth child property name
1522 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex4 ), propertyName4, TEST_LOCATION );
1523 DALI_TEST_EQUALS( childActor.GetPropertyName( customPropertyIndex2 ), propertyName4, TEST_LOCATION );
1525 // Check the fourth child property index.
1526 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName4 ), propertyIndex4, TEST_LOCATION );
1528 // Now create another parent actor with different child properties registered
1529 TypeInfo typeInfo2 = typeRegistry.GetTypeInfo( "MyNamedActor" );
1530 DALI_TEST_CHECK( typeInfo2 );
1531 BaseHandle handle2 = typeInfo2.CreateInstance();
1532 DALI_TEST_CHECK( handle2 );
1533 Actor customActor2 = Actor::DownCast( handle2 );
1534 DALI_TEST_CHECK( customActor2 );
1536 // Register child properties to the new parent
1537 std::string newPropertyName( "newChildProp" );
1538 int newPropertyIndex( CHILD_PROPERTY_REGISTRATION_START_INDEX ); // The same index as the first child property "childProp1" in the old parent
1539 Property::Type newPropertyType( Property::VECTOR2 );
1540 ChildPropertyRegistration newChildProperty( namedActorType, newPropertyName, newPropertyIndex, newPropertyType );
1542 std::string newPropertyName2( "childProp3" ); // The same name as the third child property in the old parent
1543 int newPropertyIndex2( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1 ); // The same index as the second child property "childProp2" in the old parent
1544 Property::Type newPropertyType2( Property::FLOAT ); // The same type as the third child property in the old parent
1545 ChildPropertyRegistration newChildProperty2( namedActorType, newPropertyName2, newPropertyIndex2, newPropertyType2 );
1547 // Now move the child actor to the new parent
1548 customActor2.Add( childActor );
1550 // "childProp1" is not a valid child property supported by the new parent, so nothing changed
1551 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex ), propertyType, TEST_LOCATION );
1552 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
1553 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName ), propertyIndex, TEST_LOCATION );
1555 // "childProp3" is a valid child property supported by the new parent
1556 // So it should get its new child property index and should just work
1557 DALI_TEST_EQUALS( childActor.GetPropertyType( newPropertyIndex2 ), newPropertyType2, TEST_LOCATION );
1558 DALI_TEST_EQUALS( childActor.GetPropertyName( newPropertyIndex2 ), newPropertyName2, TEST_LOCATION );
1559 DALI_TEST_EQUALS( childActor.GetPropertyIndex( newPropertyName2 ), newPropertyIndex2, TEST_LOCATION );
1560 DALI_TEST_EQUALS( childActor.GetProperty< float >( newPropertyIndex2 ), 0.15f, TEST_LOCATION );
1562 // Now register a custom property called "newChildProp"
1563 Property::Index customPropertyIndex3 = childActor.RegisterProperty("newChildProp", Vector2( 10.0f, 10.0f ), Property::READ_WRITE);
1565 // Check that the custom property is created
1566 DALI_TEST_EQUALS( initialChildActorPropertyCount + 5u, childActor.GetPropertyCount(), TEST_LOCATION );
1568 // This is a valid child property registered to the new parent
1569 // So should be able to access it through both its custom property index and its registered child property index
1570 DALI_TEST_EQUALS( childActor.GetPropertyType( newPropertyIndex ), newPropertyType, TEST_LOCATION );
1571 DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex3 ), newPropertyType, TEST_LOCATION );
1572 DALI_TEST_EQUALS( childActor.GetPropertyName( newPropertyIndex ), newPropertyName, TEST_LOCATION ); // This should return the new name, although the child property index remains the same
1573 DALI_TEST_EQUALS( childActor.GetPropertyName( customPropertyIndex3 ), newPropertyName, TEST_LOCATION );
1574 DALI_TEST_EQUALS( childActor.GetProperty< Vector2 >( newPropertyIndex ), Vector2( 10.0f, 10.0f ), TEST_LOCATION );
1575 DALI_TEST_EQUALS( childActor.GetProperty< Vector2 >( customPropertyIndex3 ), Vector2( 10.0f, 10.0f ), TEST_LOCATION );
1577 // Should return the child property index by given its name
1578 DALI_TEST_EQUALS( childActor.GetPropertyIndex( newPropertyName ), newPropertyIndex, TEST_LOCATION );
1583 int UtcDaliTypeRegistryChildPropertyRegistrationN(void)
1585 TestApplication application;
1586 TypeRegistry typeRegistry = TypeRegistry::Get();
1588 // Attempt to register a child property type out-of-bounds index (less than)
1591 ChildPropertyRegistration property1( customType1, "propName", CHILD_PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN );
1592 tet_result( TET_FAIL );
1594 catch ( DaliException& e )
1596 DALI_TEST_ASSERT( e, "( index >= CHILD_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1599 // Attempt to register a child property type out-of-bounds index (greater than)
1602 ChildPropertyRegistration property1( customType1, "propName", CHILD_PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN );
1603 tet_result( TET_FAIL );
1605 catch ( DaliException& e )
1607 DALI_TEST_ASSERT( e, "( index >= CHILD_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1614 /*******************************************************************************
1616 * Action through the base handle
1618 ******************************************************************************/
1619 int UtcDaliTypeRegistryActionViaBaseHandle(void)
1621 TestApplication application;
1625 type = TypeRegistry::Get().GetTypeInfo( "Actor" );
1626 DALI_TEST_CHECK( type );
1628 BaseHandle hdl = type.CreateInstance();
1629 DALI_TEST_CHECK( hdl );
1631 Actor a = Actor::DownCast(hdl);
1632 DALI_TEST_CHECK( a );
1634 a.SetVisible(false);
1636 application.SendNotification();
1637 application.Render(0);
1638 DALI_TEST_CHECK(!a.IsVisible());
1640 Property::Map attributes;
1642 DALI_TEST_CHECK(hdl.DoAction("show", attributes));
1644 application.SendNotification();
1645 application.Render(0);
1646 DALI_TEST_CHECK(a.IsVisible());
1648 DALI_TEST_CHECK(!hdl.DoAction("unknownAction", attributes));
1652 int UtcDaliPropertyRegistrationFunctions(void)
1654 TestApplication application;
1655 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 10;
1657 // Attempt to register a property without a setter
1660 PropertyRegistration property1( customType1, "propName", propertyIndex++, Property::BOOLEAN, NULL, &GetProperty );
1661 tet_result( TET_PASS );
1663 catch ( DaliException& e )
1665 tet_result( TET_FAIL );
1668 // Attempt to register a property without a getter
1671 PropertyRegistration property1( customType1, "propName", propertyIndex++, Property::BOOLEAN, NULL, NULL );
1672 tet_result( TET_FAIL );
1674 catch ( DaliException& e )
1676 DALI_TEST_ASSERT( e, "! \"GetProperty", TEST_LOCATION );
1681 int UtcDaliPropertyRegistrationAddSameIndex(void)
1683 TestApplication application;
1684 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 100;
1686 // Add one property with a valid property index
1687 PropertyRegistration property1( customType1, "propName", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
1689 // Attempt to add another property with the same index
1692 PropertyRegistration property2( customType1, "propName2", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
1694 catch ( DaliException& e )
1696 DALI_TEST_ASSERT( e, "! \"Property index already added", TEST_LOCATION );
1699 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 100;
1701 // Add one property with a valid property index
1702 AnimatablePropertyRegistration property3( customType1, "animPropName", animatablePropertyIndex, Property::BOOLEAN );
1704 // Attempt to add another property with the same index
1707 AnimatablePropertyRegistration property4( customType1, "animPropName2", animatablePropertyIndex, Property::BOOLEAN );
1709 catch ( DaliException& e )
1711 DALI_TEST_ASSERT( e, "! \"Property index already added", TEST_LOCATION );
1716 int UtcDaliPropertyRegistrationPropertyWritable(void)
1718 TestApplication application;
1719 int propertyIndex1 = PROPERTY_REGISTRATION_START_INDEX + 200;
1720 int propertyIndex2 = PROPERTY_REGISTRATION_START_INDEX + 201;
1722 // Add two properties, one with SetProperty, one without
1723 PropertyRegistration property1( customType1, "propNameReadwrite", propertyIndex1, Property::BOOLEAN, &SetProperty, &GetProperty );
1724 PropertyRegistration property2( customType1, "propNameReadonly", propertyIndex2, Property::BOOLEAN, NULL, &GetProperty );
1726 // Create custom-actor
1727 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
1728 DALI_TEST_CHECK( typeInfo );
1729 BaseHandle handle = typeInfo.CreateInstance();
1730 DALI_TEST_CHECK( handle );
1731 Actor customActor = Actor::DownCast( handle );
1732 DALI_TEST_CHECK( customActor );
1734 // Check whether properties are writable
1735 DALI_TEST_CHECK( customActor.IsPropertyWritable( propertyIndex1 ) );
1736 DALI_TEST_CHECK( ! customActor.IsPropertyWritable( propertyIndex2 ) );
1740 int UtcDaliPropertyRegistrationPropertyAnimatable(void)
1742 TestApplication application;
1743 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 400;
1744 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 400;
1746 // These properties are not animatable
1747 PropertyRegistration property1( customType1, "propName", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
1749 // These properties are animatable
1750 AnimatablePropertyRegistration property2( customType1, "animPropName", animatablePropertyIndex, Property::BOOLEAN );
1752 // Create custom-actor
1753 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
1754 DALI_TEST_CHECK( typeInfo );
1755 BaseHandle handle = typeInfo.CreateInstance();
1756 DALI_TEST_CHECK( handle );
1757 Actor customActor = Actor::DownCast( handle );
1758 DALI_TEST_CHECK( customActor );
1760 // Check if animatable
1761 DALI_TEST_CHECK( ! customActor.IsPropertyAnimatable( propertyIndex ) );
1762 DALI_TEST_CHECK( customActor.IsPropertyAnimatable( animatablePropertyIndex ) );
1764 // Create another instance of custom-actor
1765 BaseHandle handle2 = typeInfo.CreateInstance();
1766 DALI_TEST_CHECK( handle2 );
1767 Actor customActor2 = Actor::DownCast( handle2 );
1768 DALI_TEST_CHECK( customActor2 );
1770 // Check if animatable
1771 DALI_TEST_CHECK( ! customActor2.IsPropertyAnimatable( propertyIndex ) );
1772 DALI_TEST_CHECK( customActor2.IsPropertyAnimatable( animatablePropertyIndex ) );
1776 int UtcDaliPropertyRegistrationInvalidGetAndSet(void)
1778 TestApplication application;
1779 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 2000;
1780 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2000;
1782 // Create custom-actor
1783 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
1784 DALI_TEST_CHECK( typeInfo );
1785 BaseHandle handle = typeInfo.CreateInstance();
1786 DALI_TEST_CHECK( handle );
1787 Actor customActor = Actor::DownCast( handle );
1788 DALI_TEST_CHECK( customActor );
1790 // Try to set an index that hasn't been added
1793 customActor.SetProperty( propertyIndex, true );
1794 tet_result( TET_FAIL );
1796 catch ( DaliException& e )
1798 DALI_TEST_ASSERT( e, "! \"Cannot find property index", TEST_LOCATION );
1803 customActor.SetProperty( animatablePropertyIndex, true );
1804 tet_result( TET_FAIL );
1806 catch ( DaliException& e )
1808 DALI_TEST_ASSERT( e, "! \"Cannot find property index", TEST_LOCATION );
1811 // Try to get an index that hasn't been added
1814 (void) customActor.GetProperty< bool >( propertyIndex );
1815 tet_result( TET_FAIL );
1817 catch ( DaliException& e )
1819 DALI_TEST_ASSERT( e, "! \"Cannot find property index", TEST_LOCATION );
1824 (void) customActor.GetProperty< bool >( animatablePropertyIndex );
1825 tet_result( TET_FAIL );
1827 catch ( DaliException& e )
1829 DALI_TEST_ASSERT( e, "! \"Cannot find property index", TEST_LOCATION );
1835 int UtcDaliLongPressGestureDetectorTypeRegistry(void)
1837 TestApplication application;
1839 Actor actor = Actor::New();
1840 actor.SetSize(100.0f, 100.0f);
1841 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1842 Stage::GetCurrent().Add(actor);
1846 type = TypeRegistry::Get().GetTypeInfo( "LongPressGestureDetector" );
1847 DALI_TEST_CHECK( type );
1848 BaseHandle handle = type.CreateInstance();
1849 DALI_TEST_CHECK( handle );
1850 LongPressGestureDetector detector = LongPressGestureDetector::DownCast( handle );
1851 DALI_TEST_CHECK( detector );
1853 // Attach actor to detector
1855 GestureReceivedFunctor functor( data );
1856 detector.Attach(actor);
1858 // Connect to signal through type
1859 handle.ConnectSignal( &application, "longPressDetected", functor );
1861 // Render and notify
1862 application.SendNotification();
1863 application.Render();
1866 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f)));
1867 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f)));
1868 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f)));
1869 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
1873 int UtcDaliPanGestureDetectorTypeRegistry(void)
1875 TestApplication application;
1877 Actor actor = Actor::New();
1878 actor.SetSize(100.0f, 100.0f);
1879 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1880 Stage::GetCurrent().Add(actor);
1884 type = TypeRegistry::Get().GetTypeInfo( "PanGestureDetector" );
1885 DALI_TEST_CHECK( type );
1886 BaseHandle handle = type.CreateInstance();
1887 DALI_TEST_CHECK( handle );
1888 PanGestureDetector detector = PanGestureDetector::DownCast( handle );
1889 DALI_TEST_CHECK( detector );
1891 // Attach actor to detector
1893 GestureReceivedFunctor functor( data );
1894 detector.Attach(actor);
1896 // Connect to signal through type
1897 handle.ConnectSignal( &application, "panDetected", functor );
1899 // Render and notify
1900 application.SendNotification();
1901 application.Render();
1904 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1905 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1906 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1907 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
1911 int UtcDaliPinchGestureDetectorTypeRegistry(void)
1913 TestApplication application;
1915 Actor actor = Actor::New();
1916 actor.SetSize(100.0f, 100.0f);
1917 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1918 Stage::GetCurrent().Add(actor);
1922 type = TypeRegistry::Get().GetTypeInfo( "PinchGestureDetector" );
1923 DALI_TEST_CHECK( type );
1924 BaseHandle handle = type.CreateInstance();
1925 DALI_TEST_CHECK( handle );
1926 PinchGestureDetector detector = PinchGestureDetector::DownCast( handle );
1927 DALI_TEST_CHECK( detector );
1929 // Attach actor to detector
1931 GestureReceivedFunctor functor( data );
1932 detector.Attach(actor);
1934 // Connect to signal through type
1935 handle.ConnectSignal( &application, "pinchDetected", functor );
1937 // Render and notify
1938 application.SendNotification();
1939 application.Render();
1942 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
1943 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
1947 int UtcDaliTapGestureDetectorTypeRegistry(void)
1949 TestApplication application;
1951 Actor actor = Actor::New();
1952 actor.SetSize(100.0f, 100.0f);
1953 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1954 Stage::GetCurrent().Add(actor);
1958 type = TypeRegistry::Get().GetTypeInfo( "TapGestureDetector" );
1959 DALI_TEST_CHECK( type );
1960 BaseHandle handle = type.CreateInstance();
1961 DALI_TEST_CHECK( handle );
1962 TapGestureDetector detector = TapGestureDetector::DownCast( handle );
1963 DALI_TEST_CHECK( detector );
1965 // Attach actor to detector
1967 GestureReceivedFunctor functor( data );
1968 detector.Attach(actor);
1970 // Connect to signal through type
1971 handle.ConnectSignal( &application, "tapDetected", functor );
1973 // Render and notify
1974 application.SendNotification();
1975 application.Render();
1978 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
1979 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
1980 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
1984 int UtcDaliTypeRegistryNamedType(void)
1986 TestApplication application;
1987 TypeRegistry typeRegistry = TypeRegistry::Get();
1989 // Create a normal actor
1990 BaseHandle actorHandle = typeRegistry.GetTypeInfo( "Actor" ).CreateInstance();
1991 DALI_TEST_CHECK( actorHandle );
1992 Actor actor( Actor::DownCast( actorHandle ) );
1993 DALI_TEST_CHECK( actor );
1994 unsigned int actorPropertyCount( actor.GetPropertyCount() );
1996 // Create Named Actor Type
1997 BaseHandle namedHandle = typeRegistry.GetTypeInfo( "MyNamedActor" ).CreateInstance();
1998 DALI_TEST_CHECK( namedHandle );
1999 Actor namedActor( Actor::DownCast( namedHandle ) );
2000 DALI_TEST_CHECK( namedActor );
2001 unsigned int namedActorPropertyCount( namedActor.GetPropertyCount() );
2003 DALI_TEST_CHECK( namedActorPropertyCount > actorPropertyCount );
2007 int UtcDaliTypeInfoGetActionNameP(void)
2009 TestApplication application;
2010 TypeRegistry typeRegistry = TypeRegistry::Get();
2012 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2013 DALI_TEST_CHECK( typeInfo );
2015 DALI_TEST_CHECK( 0 != typeInfo.GetActionCount() );
2017 std::string name = typeInfo.GetActionName(0);
2019 DALI_TEST_EQUALS( name, "show", TEST_LOCATION );
2024 int UtcDaliTypeInfoGetActionNameN(void)
2026 TestApplication application;
2027 TypeRegistry typeRegistry = TypeRegistry::Get();
2029 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2030 DALI_TEST_CHECK( typeInfo );
2032 DALI_TEST_CHECK( 0 != typeInfo.GetActionCount() );
2034 std::string name = typeInfo.GetActionName(std::numeric_limits<size_t>::max());
2036 DALI_TEST_EQUALS( 0u, name.size(), TEST_LOCATION );
2041 int UtcDaliTypeInfoGetSignalNameP(void)
2043 TestApplication application;
2044 TypeRegistry typeRegistry = TypeRegistry::Get();
2046 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2047 DALI_TEST_CHECK( typeInfo );
2049 DALI_TEST_CHECK( 0 != typeInfo.GetSignalCount() );
2051 std::string name = typeInfo.GetSignalName(0);
2053 DALI_TEST_EQUALS( name, "touched", TEST_LOCATION );
2058 int UtcDaliTypeInfoGetSignalNameN(void)
2060 TestApplication application;
2061 TypeRegistry typeRegistry = TypeRegistry::Get();
2063 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2064 DALI_TEST_CHECK( typeInfo );
2066 DALI_TEST_CHECK( 0 != typeInfo.GetSignalCount() );
2068 std::string name = typeInfo.GetSignalName(std::numeric_limits<size_t>::max());
2070 DALI_TEST_EQUALS( 0u, name.size(), TEST_LOCATION );