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 // The type of child properties should be Property::None as the child hasn't registered any child property yet.
1433 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex ), Property::NONE, TEST_LOCATION );
1434 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex2 ), Property::NONE, TEST_LOCATION );
1435 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex3 ), Property::NONE, TEST_LOCATION );
1436 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex4 ), Property::NONE, TEST_LOCATION );
1438 // Set the value for the first child property when the child actor doesn't have a parent yet
1439 childActor.SetProperty(propertyIndex, true);
1441 // Check that the first child property is dynamically created
1442 DALI_TEST_EQUALS( initialChildActorPropertyCount + 1u, childActor.GetPropertyCount(), TEST_LOCATION );
1444 // Check the first child property value
1445 DALI_TEST_EQUALS( childActor.GetProperty< bool >( propertyIndex ), true, TEST_LOCATION );
1447 // Check the first child property type
1448 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex ), propertyType, TEST_LOCATION );
1450 // Check that the first child property have no name, as it doesn't have a parent yet.
1451 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex ), "", TEST_LOCATION );
1453 // Check that the first property can't be accessed through its name, as it doesn't have a parent yet.
1454 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName ), Property::INVALID_INDEX, TEST_LOCATION );
1456 // Create a custom property for the child with the same name as the second child property registered to the parent
1457 Property::Index customPropertyIndex = childActor.RegisterProperty(propertyName2, 100, Property::READ_WRITE);
1459 // Check that the custom property is created
1460 DALI_TEST_EQUALS( initialChildActorPropertyCount + 2u, childActor.GetPropertyCount(), TEST_LOCATION );
1462 // Check the property value
1463 DALI_TEST_EQUALS( childActor.GetProperty< int >( customPropertyIndex ), 100, TEST_LOCATION );
1465 // Check the property index
1466 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName2 ), customPropertyIndex, TEST_LOCATION );
1468 // Check the property type
1469 DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex ), propertyType2, TEST_LOCATION );
1471 // Check the property name
1472 DALI_TEST_EQUALS( childActor.GetPropertyName( customPropertyIndex ), propertyName2, TEST_LOCATION );
1474 // Now add the child actor to the parent
1475 customActor.Add( childActor );
1477 // Check that the first child property now has the correct name as previously registered to the parent
1478 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
1480 // Check that the child property index for the first child property can now be retrieved through its child property name
1481 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName ), propertyIndex, TEST_LOCATION );
1483 // Check that the second child property now has the correct index as previously registered to the parent
1484 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex2 ), propertyName2, TEST_LOCATION );
1486 // Check that the second child property can be accessed through both its custom property index and its child property index
1487 DALI_TEST_EQUALS( childActor.GetProperty< int >( customPropertyIndex ), 100, TEST_LOCATION );
1488 DALI_TEST_EQUALS( childActor.GetProperty< int >( propertyIndex2 ), 100, TEST_LOCATION );
1489 DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex ), propertyType2, TEST_LOCATION );
1490 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex2 ), propertyType2, TEST_LOCATION );
1492 // Check that the child property index for the second child property can now be retrieved through its child property name
1493 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName2 ), propertyIndex2, TEST_LOCATION );
1495 // Set the value for the third child property when the child actor is already added to the parent
1496 childActor.SetProperty(propertyIndex3, 0.15f);
1498 // Check that the third child property is dynamically created
1499 DALI_TEST_EQUALS( initialChildActorPropertyCount + 3u, childActor.GetPropertyCount(), TEST_LOCATION );
1501 // Check the third child property value
1502 DALI_TEST_EQUALS( childActor.GetProperty< float >( propertyIndex3 ), 0.15f, TEST_LOCATION );
1504 // Check the third child property type
1505 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex3 ), propertyType3, TEST_LOCATION );
1507 // Check the third child property name
1508 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex3 ), propertyName3, TEST_LOCATION );
1510 // Check the third child property index.
1511 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName3 ), propertyIndex3, TEST_LOCATION );
1513 // Create a custom property for the child with the same name as the fourth child property registered to the parent
1514 Property::Index customPropertyIndex2 = childActor.RegisterProperty(propertyName4, 20, Property::READ_WRITE);
1516 // Check that the custom property is created
1517 DALI_TEST_EQUALS( initialChildActorPropertyCount + 4u, childActor.GetPropertyCount(), TEST_LOCATION );
1519 // Check the fourth child property value
1520 DALI_TEST_EQUALS( childActor.GetProperty< int >( propertyIndex4 ), 20, TEST_LOCATION );
1521 DALI_TEST_EQUALS( childActor.GetProperty< int >( customPropertyIndex2 ), 20, TEST_LOCATION );
1523 // Check the fourth child property type
1524 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex4 ), propertyType4, TEST_LOCATION );
1525 DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex2 ), propertyType4, TEST_LOCATION );
1527 // Check the fourth child property name
1528 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex4 ), propertyName4, TEST_LOCATION );
1529 DALI_TEST_EQUALS( childActor.GetPropertyName( customPropertyIndex2 ), propertyName4, TEST_LOCATION );
1531 // Check the fourth child property index.
1532 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName4 ), propertyIndex4, TEST_LOCATION );
1534 // Now create another parent actor with different child properties registered
1535 TypeInfo typeInfo2 = typeRegistry.GetTypeInfo( "MyNamedActor" );
1536 DALI_TEST_CHECK( typeInfo2 );
1537 BaseHandle handle2 = typeInfo2.CreateInstance();
1538 DALI_TEST_CHECK( handle2 );
1539 Actor customActor2 = Actor::DownCast( handle2 );
1540 DALI_TEST_CHECK( customActor2 );
1542 // Register child properties to the new parent
1543 std::string newPropertyName( "newChildProp" );
1544 int newPropertyIndex( CHILD_PROPERTY_REGISTRATION_START_INDEX ); // The same index as the first child property "childProp1" in the old parent
1545 Property::Type newPropertyType( Property::VECTOR2 );
1546 ChildPropertyRegistration newChildProperty( namedActorType, newPropertyName, newPropertyIndex, newPropertyType );
1548 std::string newPropertyName2( "childProp3" ); // The same name as the third child property in the old parent
1549 int newPropertyIndex2( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1 ); // The same index as the second child property "childProp2" in the old parent
1550 Property::Type newPropertyType2( Property::FLOAT ); // The same type as the third child property in the old parent
1551 ChildPropertyRegistration newChildProperty2( namedActorType, newPropertyName2, newPropertyIndex2, newPropertyType2 );
1553 // Now move the child actor to the new parent
1554 customActor2.Add( childActor );
1556 // "childProp1" is not a valid child property supported by the new parent, so nothing changed
1557 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex ), propertyType, TEST_LOCATION );
1558 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
1559 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName ), propertyIndex, TEST_LOCATION );
1561 // "childProp3" is a valid child property supported by the new parent
1562 // So it should get its new child property index and should just work
1563 DALI_TEST_EQUALS( childActor.GetPropertyType( newPropertyIndex2 ), newPropertyType2, TEST_LOCATION );
1564 DALI_TEST_EQUALS( childActor.GetPropertyName( newPropertyIndex2 ), newPropertyName2, TEST_LOCATION );
1565 DALI_TEST_EQUALS( childActor.GetPropertyIndex( newPropertyName2 ), newPropertyIndex2, TEST_LOCATION );
1566 DALI_TEST_EQUALS( childActor.GetProperty< float >( newPropertyIndex2 ), 0.15f, TEST_LOCATION );
1568 // Now register a custom property called "newChildProp"
1569 Property::Index customPropertyIndex3 = childActor.RegisterProperty("newChildProp", Vector2( 10.0f, 10.0f ), Property::READ_WRITE);
1571 // Check that the custom property is created
1572 DALI_TEST_EQUALS( initialChildActorPropertyCount + 5u, childActor.GetPropertyCount(), TEST_LOCATION );
1574 // This is a valid child property registered to the new parent
1575 // So should be able to access it through both its custom property index and its registered child property index
1576 DALI_TEST_EQUALS( childActor.GetPropertyType( newPropertyIndex ), newPropertyType, TEST_LOCATION );
1577 DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex3 ), newPropertyType, TEST_LOCATION );
1578 DALI_TEST_EQUALS( childActor.GetPropertyName( newPropertyIndex ), newPropertyName, TEST_LOCATION ); // This should return the new name, although the child property index remains the same
1579 DALI_TEST_EQUALS( childActor.GetPropertyName( customPropertyIndex3 ), newPropertyName, TEST_LOCATION );
1580 DALI_TEST_EQUALS( childActor.GetProperty< Vector2 >( newPropertyIndex ), Vector2( 10.0f, 10.0f ), TEST_LOCATION );
1581 DALI_TEST_EQUALS( childActor.GetProperty< Vector2 >( customPropertyIndex3 ), Vector2( 10.0f, 10.0f ), TEST_LOCATION );
1583 // Should return the child property index by given its name
1584 DALI_TEST_EQUALS( childActor.GetPropertyIndex( newPropertyName ), newPropertyIndex, TEST_LOCATION );
1589 int UtcDaliTypeRegistryChildPropertyRegistrationN(void)
1591 TestApplication application;
1592 TypeRegistry typeRegistry = TypeRegistry::Get();
1594 // Attempt to register a child property type out-of-bounds index (less than)
1597 ChildPropertyRegistration property1( customType1, "propName", CHILD_PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN );
1598 tet_result( TET_FAIL );
1600 catch ( DaliException& e )
1602 DALI_TEST_ASSERT( e, "( index >= CHILD_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1605 // Attempt to register a child property type out-of-bounds index (greater than)
1608 ChildPropertyRegistration property1( customType1, "propName", CHILD_PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN );
1609 tet_result( TET_FAIL );
1611 catch ( DaliException& e )
1613 DALI_TEST_ASSERT( e, "( index >= CHILD_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1620 /*******************************************************************************
1622 * Action through the base handle
1624 ******************************************************************************/
1625 int UtcDaliTypeRegistryActionViaBaseHandle(void)
1627 TestApplication application;
1631 type = TypeRegistry::Get().GetTypeInfo( "Actor" );
1632 DALI_TEST_CHECK( type );
1634 BaseHandle hdl = type.CreateInstance();
1635 DALI_TEST_CHECK( hdl );
1637 Actor a = Actor::DownCast(hdl);
1638 DALI_TEST_CHECK( a );
1640 a.SetVisible(false);
1642 application.SendNotification();
1643 application.Render(0);
1644 DALI_TEST_CHECK(!a.IsVisible());
1646 Property::Map attributes;
1648 DALI_TEST_CHECK(hdl.DoAction("show", attributes));
1650 application.SendNotification();
1651 application.Render(0);
1652 DALI_TEST_CHECK(a.IsVisible());
1654 DALI_TEST_CHECK(!hdl.DoAction("unknownAction", attributes));
1658 int UtcDaliPropertyRegistrationFunctions(void)
1660 TestApplication application;
1661 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 10;
1663 // Attempt to register a property without a setter
1666 PropertyRegistration property1( customType1, "propName", propertyIndex++, Property::BOOLEAN, NULL, &GetProperty );
1667 tet_result( TET_PASS );
1669 catch ( DaliException& e )
1671 tet_result( TET_FAIL );
1674 // Attempt to register a property without a getter
1677 PropertyRegistration property1( customType1, "propName", propertyIndex++, Property::BOOLEAN, NULL, NULL );
1678 tet_result( TET_FAIL );
1680 catch ( DaliException& e )
1682 DALI_TEST_ASSERT( e, "! \"GetProperty", TEST_LOCATION );
1687 int UtcDaliPropertyRegistrationAddSameIndex(void)
1689 TestApplication application;
1690 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 100;
1692 // Add one property with a valid property index
1693 PropertyRegistration property1( customType1, "propName", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
1695 // Attempt to add another property with the same index
1698 PropertyRegistration property2( customType1, "propName2", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
1700 catch ( DaliException& e )
1702 DALI_TEST_ASSERT( e, "! \"Property index already added", TEST_LOCATION );
1705 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 100;
1707 // Add one property with a valid property index
1708 AnimatablePropertyRegistration property3( customType1, "animPropName", animatablePropertyIndex, Property::BOOLEAN );
1710 // Attempt to add another property with the same index
1713 AnimatablePropertyRegistration property4( customType1, "animPropName2", animatablePropertyIndex, Property::BOOLEAN );
1715 catch ( DaliException& e )
1717 DALI_TEST_ASSERT( e, "! \"Property index already added", TEST_LOCATION );
1722 int UtcDaliPropertyRegistrationPropertyWritable(void)
1724 TestApplication application;
1725 int propertyIndex1 = PROPERTY_REGISTRATION_START_INDEX + 200;
1726 int propertyIndex2 = PROPERTY_REGISTRATION_START_INDEX + 201;
1728 // Add two properties, one with SetProperty, one without
1729 PropertyRegistration property1( customType1, "propNameReadwrite", propertyIndex1, Property::BOOLEAN, &SetProperty, &GetProperty );
1730 PropertyRegistration property2( customType1, "propNameReadonly", propertyIndex2, Property::BOOLEAN, NULL, &GetProperty );
1732 // Create custom-actor
1733 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
1734 DALI_TEST_CHECK( typeInfo );
1735 BaseHandle handle = typeInfo.CreateInstance();
1736 DALI_TEST_CHECK( handle );
1737 Actor customActor = Actor::DownCast( handle );
1738 DALI_TEST_CHECK( customActor );
1740 // Check whether properties are writable
1741 DALI_TEST_CHECK( customActor.IsPropertyWritable( propertyIndex1 ) );
1742 DALI_TEST_CHECK( ! customActor.IsPropertyWritable( propertyIndex2 ) );
1746 int UtcDaliPropertyRegistrationPropertyAnimatable(void)
1748 TestApplication application;
1749 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 400;
1750 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 400;
1752 // These properties are not animatable
1753 PropertyRegistration property1( customType1, "propName", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
1755 // These properties are animatable
1756 AnimatablePropertyRegistration property2( customType1, "animPropName", animatablePropertyIndex, Property::BOOLEAN );
1758 // Create custom-actor
1759 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
1760 DALI_TEST_CHECK( typeInfo );
1761 BaseHandle handle = typeInfo.CreateInstance();
1762 DALI_TEST_CHECK( handle );
1763 Actor customActor = Actor::DownCast( handle );
1764 DALI_TEST_CHECK( customActor );
1766 // Check if animatable
1767 DALI_TEST_CHECK( ! customActor.IsPropertyAnimatable( propertyIndex ) );
1768 DALI_TEST_CHECK( customActor.IsPropertyAnimatable( animatablePropertyIndex ) );
1770 // Create another instance of custom-actor
1771 BaseHandle handle2 = typeInfo.CreateInstance();
1772 DALI_TEST_CHECK( handle2 );
1773 Actor customActor2 = Actor::DownCast( handle2 );
1774 DALI_TEST_CHECK( customActor2 );
1776 // Check if animatable
1777 DALI_TEST_CHECK( ! customActor2.IsPropertyAnimatable( propertyIndex ) );
1778 DALI_TEST_CHECK( customActor2.IsPropertyAnimatable( animatablePropertyIndex ) );
1782 int UtcDaliPropertyRegistrationInvalidGetAndSet(void)
1784 TestApplication application;
1785 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 2000;
1786 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2000;
1788 // Create custom-actor
1789 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
1790 DALI_TEST_CHECK( typeInfo );
1791 BaseHandle handle = typeInfo.CreateInstance();
1792 DALI_TEST_CHECK( handle );
1793 Actor customActor = Actor::DownCast( handle );
1794 DALI_TEST_CHECK( customActor );
1796 // Try to set an index that hasn't been added
1799 customActor.SetProperty( propertyIndex, true );
1800 tet_result( TET_FAIL );
1802 catch ( DaliException& e )
1804 DALI_TEST_ASSERT( e, "! \"Cannot find property index", TEST_LOCATION );
1809 customActor.SetProperty( animatablePropertyIndex, true );
1810 tet_result( TET_FAIL );
1812 catch ( DaliException& e )
1814 DALI_TEST_ASSERT( e, "! \"Cannot find property index", TEST_LOCATION );
1817 // Try to get an index that hasn't been added
1820 (void) customActor.GetProperty< bool >( propertyIndex );
1821 tet_result( TET_FAIL );
1823 catch ( DaliException& e )
1825 DALI_TEST_ASSERT( e, "! \"Cannot find property index", TEST_LOCATION );
1830 (void) customActor.GetProperty< bool >( animatablePropertyIndex );
1831 tet_result( TET_FAIL );
1833 catch ( DaliException& e )
1835 DALI_TEST_ASSERT( e, "! \"Cannot find property index", TEST_LOCATION );
1841 int UtcDaliLongPressGestureDetectorTypeRegistry(void)
1843 TestApplication application;
1845 Actor actor = Actor::New();
1846 actor.SetSize(100.0f, 100.0f);
1847 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1848 Stage::GetCurrent().Add(actor);
1852 type = TypeRegistry::Get().GetTypeInfo( "LongPressGestureDetector" );
1853 DALI_TEST_CHECK( type );
1854 BaseHandle handle = type.CreateInstance();
1855 DALI_TEST_CHECK( handle );
1856 LongPressGestureDetector detector = LongPressGestureDetector::DownCast( handle );
1857 DALI_TEST_CHECK( detector );
1859 // Attach actor to detector
1861 GestureReceivedFunctor functor( data );
1862 detector.Attach(actor);
1864 // Connect to signal through type
1865 handle.ConnectSignal( &application, "longPressDetected", functor );
1867 // Render and notify
1868 application.SendNotification();
1869 application.Render();
1872 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f)));
1873 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f)));
1874 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f)));
1875 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
1879 int UtcDaliPanGestureDetectorTypeRegistry(void)
1881 TestApplication application;
1883 Actor actor = Actor::New();
1884 actor.SetSize(100.0f, 100.0f);
1885 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1886 Stage::GetCurrent().Add(actor);
1890 type = TypeRegistry::Get().GetTypeInfo( "PanGestureDetector" );
1891 DALI_TEST_CHECK( type );
1892 BaseHandle handle = type.CreateInstance();
1893 DALI_TEST_CHECK( handle );
1894 PanGestureDetector detector = PanGestureDetector::DownCast( handle );
1895 DALI_TEST_CHECK( detector );
1897 // Attach actor to detector
1899 GestureReceivedFunctor functor( data );
1900 detector.Attach(actor);
1902 // Connect to signal through type
1903 handle.ConnectSignal( &application, "panDetected", functor );
1905 // Render and notify
1906 application.SendNotification();
1907 application.Render();
1910 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1911 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1912 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1913 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
1917 int UtcDaliPinchGestureDetectorTypeRegistry(void)
1919 TestApplication application;
1921 Actor actor = Actor::New();
1922 actor.SetSize(100.0f, 100.0f);
1923 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1924 Stage::GetCurrent().Add(actor);
1928 type = TypeRegistry::Get().GetTypeInfo( "PinchGestureDetector" );
1929 DALI_TEST_CHECK( type );
1930 BaseHandle handle = type.CreateInstance();
1931 DALI_TEST_CHECK( handle );
1932 PinchGestureDetector detector = PinchGestureDetector::DownCast( handle );
1933 DALI_TEST_CHECK( detector );
1935 // Attach actor to detector
1937 GestureReceivedFunctor functor( data );
1938 detector.Attach(actor);
1940 // Connect to signal through type
1941 handle.ConnectSignal( &application, "pinchDetected", functor );
1943 // Render and notify
1944 application.SendNotification();
1945 application.Render();
1948 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
1949 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
1953 int UtcDaliTapGestureDetectorTypeRegistry(void)
1955 TestApplication application;
1957 Actor actor = Actor::New();
1958 actor.SetSize(100.0f, 100.0f);
1959 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1960 Stage::GetCurrent().Add(actor);
1964 type = TypeRegistry::Get().GetTypeInfo( "TapGestureDetector" );
1965 DALI_TEST_CHECK( type );
1966 BaseHandle handle = type.CreateInstance();
1967 DALI_TEST_CHECK( handle );
1968 TapGestureDetector detector = TapGestureDetector::DownCast( handle );
1969 DALI_TEST_CHECK( detector );
1971 // Attach actor to detector
1973 GestureReceivedFunctor functor( data );
1974 detector.Attach(actor);
1976 // Connect to signal through type
1977 handle.ConnectSignal( &application, "tapDetected", functor );
1979 // Render and notify
1980 application.SendNotification();
1981 application.Render();
1984 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
1985 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
1986 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
1990 int UtcDaliTypeRegistryNamedType(void)
1992 TestApplication application;
1993 TypeRegistry typeRegistry = TypeRegistry::Get();
1995 // Create a normal actor
1996 BaseHandle actorHandle = typeRegistry.GetTypeInfo( "Actor" ).CreateInstance();
1997 DALI_TEST_CHECK( actorHandle );
1998 Actor actor( Actor::DownCast( actorHandle ) );
1999 DALI_TEST_CHECK( actor );
2000 unsigned int actorPropertyCount( actor.GetPropertyCount() );
2002 // Create Named Actor Type
2003 BaseHandle namedHandle = typeRegistry.GetTypeInfo( "MyNamedActor" ).CreateInstance();
2004 DALI_TEST_CHECK( namedHandle );
2005 Actor namedActor( Actor::DownCast( namedHandle ) );
2006 DALI_TEST_CHECK( namedActor );
2007 unsigned int namedActorPropertyCount( namedActor.GetPropertyCount() );
2009 DALI_TEST_CHECK( namedActorPropertyCount > actorPropertyCount );
2013 int UtcDaliTypeInfoGetActionNameP(void)
2015 TestApplication application;
2016 TypeRegistry typeRegistry = TypeRegistry::Get();
2018 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2019 DALI_TEST_CHECK( typeInfo );
2021 DALI_TEST_CHECK( 0 != typeInfo.GetActionCount() );
2023 std::string name = typeInfo.GetActionName(0);
2025 DALI_TEST_EQUALS( name, "show", TEST_LOCATION );
2030 int UtcDaliTypeInfoGetActionNameN(void)
2032 TestApplication application;
2033 TypeRegistry typeRegistry = TypeRegistry::Get();
2035 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2036 DALI_TEST_CHECK( typeInfo );
2038 DALI_TEST_CHECK( 0 != typeInfo.GetActionCount() );
2040 std::string name = typeInfo.GetActionName(std::numeric_limits<size_t>::max());
2042 DALI_TEST_EQUALS( 0u, name.size(), TEST_LOCATION );
2047 int UtcDaliTypeInfoGetSignalNameP(void)
2049 TestApplication application;
2050 TypeRegistry typeRegistry = TypeRegistry::Get();
2052 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2053 DALI_TEST_CHECK( typeInfo );
2055 DALI_TEST_CHECK( 0 != typeInfo.GetSignalCount() );
2057 std::string name = typeInfo.GetSignalName(0);
2059 DALI_TEST_EQUALS( name, "touched", TEST_LOCATION );
2064 int UtcDaliTypeInfoGetSignalNameN(void)
2066 TestApplication application;
2067 TypeRegistry typeRegistry = TypeRegistry::Get();
2069 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2070 DALI_TEST_CHECK( typeInfo );
2072 DALI_TEST_CHECK( 0 != typeInfo.GetSignalCount() );
2074 std::string name = typeInfo.GetSignalName(std::numeric_limits<size_t>::max());
2076 DALI_TEST_EQUALS( 0u, name.size(), TEST_LOCATION );