2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 #include <dali/public-api/dali-core.h>
21 #include <dali-test-suite-utils.h>
22 #include <dali/integration-api/events/long-press-gesture-event.h>
23 #include <dali/integration-api/events/pan-gesture-event.h>
24 #include <dali/integration-api/events/pinch-gesture-event.h>
25 #include <dali/integration-api/events/tap-gesture-event.h>
26 #include <dali/integration-api/events/touch-event-integ.h>
27 #include <dali/integration-api/events/hover-event-integ.h>
35 // Stores data that is populated in the callback and will be read by the Test cases
39 : functorCalled( false ),
40 voidFunctorCalled( false ),
41 receivedGesture( Gesture::Clear ),
47 functorCalled = false;
48 voidFunctorCalled = false;
50 receivedGesture.numberOfTouches = 0u;
51 receivedGesture.screenPoint = Vector2(0.0f, 0.0f);
52 receivedGesture.localPoint = Vector2(0.0f, 0.0f);
58 bool voidFunctorCalled;
59 LongPressGesture receivedGesture;
63 // Functor that sets the data when called
64 struct GestureReceivedFunctor
66 GestureReceivedFunctor(SignalData& data) : signalData(data) { }
68 void operator()(Actor actor, LongPressGesture longPress)
70 signalData.functorCalled = true;
71 signalData.receivedGesture = longPress;
72 signalData.pressedActor = actor;
77 signalData.voidFunctorCalled = true;
80 SignalData& signalData;
83 // Generate a LongPressGestureEvent to send to Core
84 Integration::LongPressGestureEvent GenerateLongPress(
86 unsigned int numberOfTouches,
89 Integration::LongPressGestureEvent longPress( state );
91 longPress.numberOfTouches = numberOfTouches;
92 longPress.point = point;
97 // Generate a PanGestureEvent to send to Core
98 Integration::PanGestureEvent GeneratePan(
100 Vector2 previousPosition,
101 Vector2 currentPosition,
102 unsigned long timeDelta,
103 unsigned int numberOfTouches = 1,
104 unsigned int time = 1u)
106 Integration::PanGestureEvent pan(state);
108 pan.previousPosition = previousPosition;
109 pan.currentPosition = currentPosition;
110 pan.timeDelta = timeDelta;
111 pan.numberOfTouches = numberOfTouches;
116 // Generate a PinchGestureEvent to send to Core
117 Integration::PinchGestureEvent GeneratePinch(
118 Gesture::State state,
123 Integration::PinchGestureEvent pinch(state);
127 pinch.centerPoint = centerpoint;
131 // Generate a TapGestureEvent to send to Core
132 Integration::TapGestureEvent GenerateTap(
133 Gesture::State state,
134 unsigned int numberOfTaps,
135 unsigned int numberOfTouches,
138 Integration::TapGestureEvent tap( state );
140 tap.numberOfTaps = numberOfTaps;
141 tap.numberOfTouches = numberOfTouches;
148 // Create function as Init function called
150 static bool CreateCustomInitCalled = false;
151 BaseHandle CreateCustomInit(void)
153 CreateCustomInitCalled = true;
157 static bool CreateCustomNamedInitCalled = false;
158 BaseHandle CreateCustomNamedInit(void)
160 CreateCustomNamedInitCalled = true;
164 const std::string scriptedName("PopupStyle");
165 static TypeRegistration scriptedType( scriptedName, typeid(Dali::CustomActor), CreateCustomNamedInit );
167 // Property Registration
168 bool setPropertyCalled = false;
169 bool getPropertyCalled = false;
170 void SetProperty( BaseObject* object, Property::Index propertyIndex, const Property::Value& value )
172 setPropertyCalled = true;
174 Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex )
176 getPropertyCalled = true;
177 return Property::Value( true );
182 /*******************************************************************************
186 ******************************************************************************/
189 struct MyTestCustomActor : public CustomActorImpl
191 typedef Signal< void ()> SignalType;
192 typedef Signal< void (float)> SignalTypeFloat;
194 MyTestCustomActor() : CustomActorImpl( ActorFlags( REQUIRES_TOUCH_EVENTS ) )
197 virtual ~MyTestCustomActor()
200 void ResetCallStack()
204 // From CustomActorImpl
205 virtual void OnStageConnection()
208 virtual void OnStageDisconnection()
211 virtual void OnChildAdd(Actor& child)
214 virtual void OnChildRemove(Actor& child)
217 virtual void OnSizeSet(const Vector3& targetSize)
220 virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize)
223 virtual bool OnTouchEvent(const TouchEvent& event)
227 virtual bool OnHoverEvent(const HoverEvent& event)
231 virtual bool OnWheelEvent(const WheelEvent& event)
235 virtual bool OnKeyEvent(const KeyEvent& event)
239 virtual void OnKeyInputFocusGained()
242 virtual void OnKeyInputFocusLost()
245 virtual Vector3 GetNaturalSize()
247 return Vector3( 0.0f, 0.0f, 0.0f );
250 virtual float GetHeightForWidth( float width )
255 virtual float GetWidthForHeight( float height )
260 virtual void OnRelayout( const Vector2& size, RelayoutContainer& container )
264 virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
268 virtual void OnCalculateRelayoutSize( Dimension::Type dimension )
272 virtual float CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension )
277 virtual void OnLayoutNegotiated( float size, Dimension::Type dimension )
281 virtual bool RelayoutDependentOnChildren( Dimension::Type dimension = Dimension::ALL_DIMENSIONS )
293 class MyTestCustomActor : public CustomActor
297 typedef Signal< void ()> SignalType;
298 typedef Signal< void (float)> SignalTypeFloat;
304 static MyTestCustomActor New()
306 Impl::MyTestCustomActor* p = new Impl::MyTestCustomActor;
307 return MyTestCustomActor( *p ); // takes ownership
310 virtual ~MyTestCustomActor()
314 static MyTestCustomActor DownCast( BaseHandle handle )
316 MyTestCustomActor result;
318 CustomActor custom = Dali::CustomActor::DownCast( handle );
321 CustomActorImpl& customImpl = custom.GetImplementation();
323 Impl::MyTestCustomActor* impl = dynamic_cast<Impl::MyTestCustomActor*>(&customImpl);
327 result = MyTestCustomActor(customImpl.GetOwner());
334 SignalType& GetCustomSignal()
336 Dali::RefObject& obj = GetImplementation();
337 return static_cast<Impl::MyTestCustomActor&>( obj ).mSignal;
342 MyTestCustomActor(Internal::CustomActor* internal)
343 : CustomActor(internal)
347 MyTestCustomActor( Impl::MyTestCustomActor& impl )
348 : CustomActor( impl )
354 class MyTestCustomActor2 : public CustomActor
362 static MyTestCustomActor2 New()
364 return MyTestCustomActor2(); // takes ownership
367 virtual ~MyTestCustomActor2()
371 static MyTestCustomActor2 DownCast( BaseHandle handle )
373 MyTestCustomActor2 result;
375 CustomActor custom = Dali::CustomActor::DownCast( handle );
378 CustomActorImpl& customImpl = custom.GetImplementation();
380 Impl::MyTestCustomActor* impl = dynamic_cast<Impl::MyTestCustomActor*>(&customImpl);
384 result = MyTestCustomActor2(customImpl.GetOwner());
393 MyTestCustomActor2(Internal::CustomActor* internal)
394 : CustomActor(internal)
398 MyTestCustomActor2( Impl::MyTestCustomActor& impl )
399 : CustomActor( impl )
404 static TypeRegistration customTypeInit( typeid(MyTestCustomActor2), typeid(Dali::CustomActor), CreateCustomInit, true );
407 BaseHandle CreateCustom(void)
409 return MyTestCustomActor::New();
412 static std::string lastSignalConnectionCustom;
414 bool DoConnectSignalCustom( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
416 lastSignalConnectionCustom = signalName;
418 bool connected( true );
420 Dali::BaseHandle handle(object);
421 MyTestCustomActor customActor = MyTestCustomActor::DownCast(handle);
423 if( "sig1" == signalName )
425 customActor.GetCustomSignal().Connect( tracker, functor );
429 // signalName does not match any signal
436 bool DoConnectSignalCustomFailure( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
438 lastSignalConnectionCustom = "failed";
440 return false; // This is supposed to fail
443 struct CustomTestFunctor
447 ++mTotalInstanceCount;
448 ++mCurrentInstanceCount;
451 CustomTestFunctor( const CustomTestFunctor& copyMe )
453 ++mTotalInstanceCount;
454 ++mCurrentInstanceCount;
459 --mCurrentInstanceCount;
467 static int mTotalInstanceCount;
468 static int mCurrentInstanceCount;
469 static int mCallbackCount;
472 int CustomTestFunctor::mTotalInstanceCount = 0;
473 int CustomTestFunctor::mCurrentInstanceCount = 0;
474 int CustomTestFunctor::mCallbackCount = 0;
476 static void ResetFunctorCounts()
478 CustomTestFunctor::mTotalInstanceCount = 0;
479 CustomTestFunctor::mCurrentInstanceCount = 0;
480 CustomTestFunctor::mCallbackCount = 0;
483 static std::string lastActionCustom;
484 bool DoActionCustom(BaseObject* object, const std::string& actionName, const Property::Map& /*attributes*/)
486 lastActionCustom = actionName;
490 // Custom type registration
491 static TypeRegistration customType1( typeid(MyTestCustomActor), typeid(Dali::CustomActor), CreateCustom );
494 static SignalConnectorType customSignalConnector1( customType1, "sig1", DoConnectSignalCustom );
495 static SignalConnectorType customSignalConnector2( customType1, "sig2", DoConnectSignalCustomFailure );
496 static const int TEST_SIGNAL_COUNT = 2;
499 static TypeAction customAction1( customType1, "act1", DoActionCustom);
500 static const int TEST_ACTION_COUNT = 1;
502 class TestConnectionTracker : public ConnectionTracker
506 TestConnectionTracker()
511 BaseHandle CreateNamedActorType()
513 Actor actor = Actor::New();
514 actor.SetName( "NamedActor" );
518 TypeRegistration namedActorType( "MyNamedActor", typeid(Dali::Actor), CreateNamedActorType );
519 PropertyRegistration namedActorPropertyOne( namedActorType, "prop-name", PROPERTY_REGISTRATION_START_INDEX, Property::BOOLEAN, &SetProperty, &GetProperty );
521 } // Anonymous namespace
523 // Note: No negative test case for UtcDaliTypeRegistryGet can be implemented.
524 int UtcDaliTypeRegistryGetP(void)
526 TestApplication application;
528 TypeRegistry registry = TypeRegistry::Get();
529 DALI_TEST_CHECK( registry );
534 // Note: No negative test case for UtcDaliTypeRegistryConstructor can be implemented.
535 int UtcDaliTypeRegistryConstructorP(void)
537 TestApplication application;
539 TypeRegistry registry;
540 DALI_TEST_CHECK( !registry );
544 // Note: No negative test case for UtcDaliTypeRegistryCopyConstructor can be implemented.
545 int UtcDaliTypeRegistryCopyConstructorP(void)
547 TestApplication application;
549 TypeRegistry registry = TypeRegistry::Get();
550 DALI_TEST_CHECK( registry );
552 TypeRegistry copy( registry );
553 DALI_TEST_CHECK( copy );
555 DALI_TEST_CHECK( registry.GetTypeInfo( "Actor" ).GetName() == copy.GetTypeInfo( "Actor" ).GetName() );
560 // Note: No negative test case for UtcDaliTypeRegistryAssignmentOperator can be implemented.
561 int UtcDaliTypeRegistryAssignmentOperatorP(void)
563 TestApplication application;
565 TypeRegistry registry = TypeRegistry::Get();
566 DALI_TEST_CHECK( registry );
568 TypeRegistry copy = registry;
569 DALI_TEST_CHECK( copy );
570 DALI_TEST_CHECK( registry == copy );
572 DALI_TEST_CHECK( registry.GetTypeInfo( "Actor" ).GetName() == copy.GetTypeInfo( "Actor" ).GetName() );
577 int UtcDaliTypeRegistryAssignP(void)
579 TestApplication application;
581 TypeRegistry registry = TypeRegistry::Get();
582 TypeRegistry registry2;
583 registry2 = registry;
584 DALI_TEST_CHECK( registry2 );
586 DALI_TEST_CHECK( registry2.GetTypeInfo( "Actor" ).GetName() == registry2.GetTypeInfo( "Actor" ).GetName() );
591 int UtcDaliTypeRegistryGetTypeInfoFromTypeNameP(void)
593 TestApplication application;
595 TypeRegistry registry = TypeRegistry::Get();
600 type = registry.GetTypeInfo( "ImageActor" );
601 DALI_TEST_CHECK( type );
602 DALI_TEST_CHECK( type.GetCreator() );
603 DALI_TEST_CHECK( ImageActor::DownCast( type.GetCreator()() ) );
604 ImageActor ia = ImageActor::DownCast(type.CreateInstance());
605 DALI_TEST_CHECK( ia );
606 Stage::GetCurrent().Add( ia );
607 application.Render();
610 type = registry.GetTypeInfo( "CameraActor" );
611 DALI_TEST_CHECK( type );
612 CameraActor ca = CameraActor::DownCast(type.CreateInstance());
613 DALI_TEST_CHECK( ca );
614 Stage::GetCurrent().Add( ca );
615 application.Render();
618 type = registry.GetTypeInfo( "Animation" );
619 DALI_TEST_CHECK( type );
620 Animation an = Animation::DownCast(type.CreateInstance());
621 DALI_TEST_CHECK( an );
623 application.Render();
626 type = registry.GetTypeInfo( "ShaderEffect" );
627 DALI_TEST_CHECK( type );
628 ShaderEffect ef = ShaderEffect::DownCast(type.CreateInstance());
629 DALI_TEST_CHECK( ef );
630 application.Render();
635 int UtcDaliTypeRegistryGetTypeInfoFromTypeNameN(void)
637 TestApplication application;
639 TypeRegistry registry = TypeRegistry::Get();
643 type = registry.GetTypeInfo( "MyDummyActor" );
644 DALI_TEST_CHECK( !type );
649 int UtcDaliTypeRegistryGetTypeInfoFromTypeIdP(void)
651 TypeInfo named_type = TypeRegistry::Get().GetTypeInfo( "ImageActor" );
652 TypeInfo typeinfo_type = TypeRegistry::Get().GetTypeInfo( typeid(Dali::ImageActor) );
654 DALI_TEST_CHECK( named_type );
655 DALI_TEST_CHECK( typeinfo_type );
657 // Check named and typeid are equivalent
658 DALI_TEST_CHECK( named_type == typeinfo_type );
660 DALI_TEST_CHECK( named_type.GetName() == typeinfo_type.GetName() );
661 DALI_TEST_CHECK( named_type.GetBaseName() == typeinfo_type.GetBaseName() );
666 int UtcDaliTypeRegistryGetTypeInfoFromTypeIdN(void)
668 TestApplication application;
669 TypeRegistry typeRegistry = TypeRegistry::Get();
671 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(Vector2) );
672 DALI_TEST_CHECK( !typeInfo );
677 int UtcDaliTypeRegistryGetTypeNameCountP(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 int UtcDaliTypeRegistryGetTypeNamesP(void)
695 TestApplication application;
696 TypeRegistry typeRegistry = TypeRegistry::Get();
699 for(size_t i = 0; i < typeRegistry.GetTypeNameCount(); i++)
701 type = typeRegistry.GetTypeInfo( typeRegistry.GetTypeName(i) );
702 DALI_TEST_CHECK( type );
709 // Note: No negative test case for UtcDaliTypeRegistryTypeRegistration can be implemented.
710 int UtcDaliTypeRegistryTypeRegistrationNotCallingCreateOnInitP(void)
712 ResetFunctorCounts();
714 TestApplication application;
716 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
717 DALI_TEST_CHECK( type );
719 TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( "CustomActor" );
720 DALI_TEST_CHECK( baseType );
722 BaseHandle handle = type.CreateInstance();
723 DALI_TEST_CHECK( handle );
725 MyTestCustomActor customHandle = MyTestCustomActor::DownCast( handle );
726 DALI_TEST_CHECK( customHandle );
728 DALI_TEST_EQUALS( type.GetActionCount(), TEST_ACTION_COUNT + baseType.GetActionCount(), TEST_LOCATION );
730 DALI_TEST_EQUALS( type.GetSignalCount(), TEST_SIGNAL_COUNT + baseType.GetSignalCount(), TEST_LOCATION );
733 TestConnectionTracker tracker;
735 bool connected = handle.ConnectSignal( &tracker, "sig1", CustomTestFunctor() );
736 DALI_TEST_EQUALS( connected, true, TEST_LOCATION );
737 DALI_TEST_CHECK( lastSignalConnectionCustom == "sig1" );
738 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
739 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION );
741 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
742 customHandle.GetCustomSignal().Emit();
743 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION );
744 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
745 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION );
747 // tracker should automatically disconnect here
748 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
749 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
751 // Test that functor is disconnected
752 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION );
753 customHandle.GetCustomSignal().Emit();
754 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1/*not incremented*/, TEST_LOCATION );
755 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
756 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
758 Property::Map attributes;
759 handle.DoAction("act1", attributes);
760 DALI_TEST_CHECK( lastActionCustom == "act1" );
764 // Note: No negative test case for UtcDaliTypeRegistryTypeRegistration can be implemented.
765 int UtcDaliTypeRegistryTypeRegistrationCallingCreateOnInitP(void)
767 TestApplication application;
769 DALI_TEST_CHECK( "MyTestCustomActor2" == customTypeInit.RegisteredName() );
771 DALI_TEST_CHECK( true == CreateCustomInitCalled );
772 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor2" );
773 DALI_TEST_CHECK( type );
777 // Note: No negative test case for UtcDaliTypeRegistryTypeRegistration can be implemented.
778 int UtcDaliTypeRegistryTypeRegistrationForNamedTypeP(void)
780 TestApplication application;
782 // Create Named Actor Type
783 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyNamedActor" );
784 DALI_TEST_CHECK( type );
786 BaseHandle namedHandle = type.CreateInstance();
787 DALI_TEST_CHECK( namedHandle );
788 Actor namedActor( Actor::DownCast( namedHandle ) );
789 DALI_TEST_CHECK( namedActor );
791 DALI_TEST_CHECK( namedActor.GetName() == "NamedActor" );
792 DALI_TEST_CHECK( type.GetName() == "MyNamedActor" );
793 DALI_TEST_CHECK( type.GetBaseName() == "Actor" );
798 // Note: No negative test case for UtcDaliTypeRegistryRegisteredName can be implemented.
799 int UtcDaliTypeRegistryRegisteredNameP(void)
801 TestApplication application;
803 DALI_TEST_CHECK( scriptedName == scriptedType.RegisteredName() );
805 TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( scriptedName );
806 DALI_TEST_CHECK( baseType );
808 BaseHandle handle = baseType.CreateInstance();
810 DALI_TEST_CHECK( true == CreateCustomNamedInitCalled );
811 TypeInfo type = TypeRegistry::Get().GetTypeInfo( scriptedName );
812 DALI_TEST_CHECK( type );
816 int UtcDaliTypeRegistrySignalConnectorTypeP(void)
818 ResetFunctorCounts();
820 TestApplication application;
822 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
823 DALI_TEST_CHECK( type );
825 BaseHandle handle = type.CreateInstance();
826 DALI_TEST_CHECK( handle );
828 MyTestCustomActor customHandle = MyTestCustomActor::DownCast( handle );
829 DALI_TEST_CHECK( customHandle );
832 TestConnectionTracker tracker;
834 bool connected = handle.ConnectSignal( &tracker, "sig1", CustomTestFunctor() );
835 DALI_TEST_EQUALS( connected, true, TEST_LOCATION );
836 DALI_TEST_CHECK( lastSignalConnectionCustom == "sig1" );
837 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
838 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION );
840 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
841 customHandle.GetCustomSignal().Emit();
842 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION );
843 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
844 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION );
846 // tracker should automatically disconnect here
847 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
848 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
850 // Test that functor is disconnected
851 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION );
852 customHandle.GetCustomSignal().Emit();
853 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1/*not incremented*/, TEST_LOCATION );
854 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
855 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
860 int UtcDaliTypeRegistrySignalConnectorTypeN(void)
862 // Test what happens when signal connnector (DoConnectSignalFailure method) returns false
864 ResetFunctorCounts();
866 TestApplication application;
868 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
869 DALI_TEST_CHECK( type );
871 TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( "CustomActor" );
872 DALI_TEST_CHECK( baseType );
874 BaseHandle handle = type.CreateInstance();
875 DALI_TEST_CHECK( handle );
877 MyTestCustomActor customHandle = MyTestCustomActor::DownCast( handle );
878 DALI_TEST_CHECK( customHandle );
880 DALI_TEST_EQUALS( type.GetActionCount(), TEST_ACTION_COUNT + baseType.GetActionCount(), TEST_LOCATION );
882 DALI_TEST_EQUALS( type.GetSignalCount(), TEST_SIGNAL_COUNT + baseType.GetSignalCount(), TEST_LOCATION );
885 TestConnectionTracker tracker;
887 bool connected = handle.ConnectSignal( &tracker, "sig2", CustomTestFunctor() );
888 DALI_TEST_EQUALS( connected, false/*This is supposed to fail*/, TEST_LOCATION );
889 DALI_TEST_CHECK( lastSignalConnectionCustom == "failed" );
890 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
891 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0/*deleted along with FunctorDelegate*/, TEST_LOCATION );
894 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
895 customHandle.GetCustomSignal().Emit();
896 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0/*never called*/, TEST_LOCATION );
898 // tracker should have nothing to disconnect here
901 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
902 customHandle.GetCustomSignal().Emit();
903 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0/*never called*/, TEST_LOCATION );
907 int UtcDaliTypeRegistryTypeActionP(void)
909 ResetFunctorCounts();
911 TestApplication application;
913 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
914 DALI_TEST_CHECK( type );
916 BaseHandle handle = type.CreateInstance();
917 DALI_TEST_CHECK( handle );
919 Property::Map attributes;
920 DALI_TEST_CHECK( handle.DoAction("act1", attributes) );
921 DALI_TEST_CHECK( lastActionCustom == "act1" );
926 int UtcDaliTypeRegistryTypeActionN(void)
928 ResetFunctorCounts();
930 TestApplication application;
932 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
933 DALI_TEST_CHECK( type );
935 BaseHandle handle = type.CreateInstance();
936 DALI_TEST_CHECK( handle );
938 Property::Map attributes;
939 DALI_TEST_CHECK( !handle.DoAction( "unknown-action", attributes ) );
944 int UtcDaliTypeRegistryPropertyRegistrationP(void)
946 TestApplication application;
947 TypeRegistry typeRegistry = TypeRegistry::Get();
949 // Check property count before property registration
950 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
951 DALI_TEST_CHECK( typeInfo );
952 BaseHandle handle = typeInfo.CreateInstance();
953 DALI_TEST_CHECK( handle );
954 Actor customActor = Actor::DownCast( handle );
955 DALI_TEST_CHECK( customActor );
956 unsigned int initialPropertyCount( customActor.GetPropertyCount() );
958 std::string propertyName( "prop-1" );
959 int propertyIndex( PROPERTY_REGISTRATION_START_INDEX );
960 Property::Type propertyType( Property::BOOLEAN );
961 PropertyRegistration property1( customType1, propertyName, propertyIndex, propertyType, &SetProperty, &GetProperty );
963 // Check property count after registration
964 unsigned int postRegistrationPropertyCount( customActor.GetPropertyCount() );
965 DALI_TEST_EQUALS( initialPropertyCount + 1u, postRegistrationPropertyCount, TEST_LOCATION );
967 // Add custom property and check property count
968 customActor.RegisterProperty( "custom-prop-1", true );
969 unsigned int customPropertyCount( customActor.GetPropertyCount() );
970 DALI_TEST_EQUALS( postRegistrationPropertyCount + 1u, customPropertyCount, TEST_LOCATION );
972 // Set the property, ensure SetProperty called
973 DALI_TEST_CHECK( !setPropertyCalled );
974 customActor.SetProperty( propertyIndex, false );
975 DALI_TEST_CHECK( setPropertyCalled );
977 // Get the property, ensure GetProperty called
978 DALI_TEST_CHECK( !getPropertyCalled );
979 (void)customActor.GetProperty< bool >( propertyIndex );
980 DALI_TEST_CHECK( getPropertyCalled );
982 // Check the property name
983 DALI_TEST_EQUALS( customActor.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
984 DALI_TEST_EQUALS( typeInfo.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
986 // Check the property index
987 DALI_TEST_EQUALS( customActor.GetPropertyIndex( propertyName ), propertyIndex, TEST_LOCATION );
989 // Check the property type
990 DALI_TEST_EQUALS( customActor.GetPropertyType( propertyIndex ), propertyType, TEST_LOCATION );
992 // Check property count of type-info is 1
993 Property::IndexContainer indices;
994 typeInfo.GetPropertyIndices( indices );
995 DALI_TEST_EQUALS( indices.Size(), 1u, TEST_LOCATION );
997 // check property name count
998 DALI_TEST_CHECK( 1 == typeInfo.GetPropertyCount() );
1000 // Ensure indices returned from actor and customActor differ by two
1001 Actor actor = Actor::New();
1002 actor.GetPropertyIndices( indices );
1003 unsigned int actorIndices = indices.Size();
1004 customActor.GetPropertyIndices( indices );
1005 unsigned int customActorIndices = indices.Size();
1006 DALI_TEST_EQUALS( actorIndices + 2u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1010 int UtcDaliTypeRegistryPropertyRegistrationN(void)
1012 TestApplication application;
1013 TypeRegistry typeRegistry = TypeRegistry::Get();
1015 // Attempt to register a property type out-of-bounds index (less than)
1018 PropertyRegistration property1( customType1, "prop-name", PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN, &SetProperty, &GetProperty );
1019 tet_result( TET_FAIL );
1021 catch ( DaliException& e )
1023 DALI_TEST_ASSERT( e, "( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1026 // Attempt to register a property type out-of-bounds index (greater than)
1029 PropertyRegistration property1( customType1, "prop-name", PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN, &SetProperty, &GetProperty );
1030 tet_result( TET_FAIL );
1032 catch ( DaliException& e )
1034 DALI_TEST_ASSERT( e, "( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1040 int UtcDaliTypeRegistryAnimatablePropertyRegistrationP(void)
1042 TestApplication application;
1043 TypeRegistry typeRegistry = TypeRegistry::Get();
1045 // Check property count before property registration
1046 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1047 DALI_TEST_CHECK( typeInfo );
1048 BaseHandle handle = typeInfo.CreateInstance();
1049 DALI_TEST_CHECK( handle );
1050 Actor customActor = Actor::DownCast( handle );
1051 DALI_TEST_CHECK( customActor );
1053 unsigned int customPropertyCount( customActor.GetPropertyCount() );
1055 // Register animatable property
1056 std::string animatablePropertyName( "animatable-prop-1" );
1057 int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1058 Property::Type animatablePropertyType( Property::FLOAT );
1059 AnimatablePropertyRegistration animatableProperty1( customType1, animatablePropertyName, animatablePropertyIndex, animatablePropertyType );
1061 // Check property count after registration
1062 DALI_TEST_EQUALS( customPropertyCount + 1u, customActor.GetPropertyCount(), TEST_LOCATION );
1064 // Set the animatable property value
1065 customActor.SetProperty( animatablePropertyIndex, 25.0f );
1067 // Render and notify
1068 application.SendNotification();
1069 application.Render();
1071 // Check the animatable property value
1072 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 25.0f, TEST_LOCATION );
1074 // Check the animatable property name
1075 DALI_TEST_EQUALS( customActor.GetPropertyName( animatablePropertyIndex ), animatablePropertyName, TEST_LOCATION );
1077 // Check the animatable property index
1078 DALI_TEST_EQUALS( customActor.GetPropertyIndex( animatablePropertyName ), animatablePropertyIndex, TEST_LOCATION );
1080 // Check the animatable property type
1081 DALI_TEST_EQUALS( customActor.GetPropertyType( animatablePropertyIndex ), animatablePropertyType, TEST_LOCATION );
1083 // Check property count of type-info is 1
1084 Property::IndexContainer indices;
1085 typeInfo.GetPropertyIndices( indices );
1086 DALI_TEST_EQUALS( indices.Size(), 1u, TEST_LOCATION );
1088 // Ensure indices returned from actor and customActor differ by one
1089 Actor actor = Actor::New();
1090 actor.GetPropertyIndices( indices );
1091 unsigned int actorIndices = indices.Size();
1092 customActor.GetPropertyIndices( indices );
1093 unsigned int customActorIndices = indices.Size();
1094 DALI_TEST_EQUALS( actorIndices + 1u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1099 int UtcDaliTypeRegistryAnimatablePropertyRegistrationN(void)
1101 TestApplication application;
1102 TypeRegistry typeRegistry = TypeRegistry::Get();
1104 // Attempt to register an animatable property type out-of-bounds index (less than)
1107 AnimatablePropertyRegistration property1( customType1, "anim-prop-name", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN );
1108 tet_result( TET_FAIL );
1110 catch ( DaliException& e )
1112 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1115 // Attempt to register an animatable property type out-of-bounds index (greater than)
1118 AnimatablePropertyRegistration property1( customType1, "anim-prop-name", ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN );
1119 tet_result( TET_FAIL );
1121 catch ( DaliException& e )
1123 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1129 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationP(void)
1131 TestApplication application;
1132 TypeRegistry typeRegistry = TypeRegistry::Get();
1134 // Check property count before property registration
1135 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1136 DALI_TEST_CHECK( typeInfo );
1137 BaseHandle handle = typeInfo.CreateInstance();
1138 DALI_TEST_CHECK( handle );
1139 Actor customActor = Actor::DownCast( handle );
1140 DALI_TEST_CHECK( customActor );
1142 unsigned int customPropertyCount( customActor.GetPropertyCount() );
1144 // Register animatable property
1145 std::string animatablePropertyName( "animatable-prop-1" );
1146 int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1147 Property::Type animatablePropertyType( Property::VECTOR2 );
1148 AnimatablePropertyRegistration animatableProperty1( customType1, animatablePropertyName, animatablePropertyIndex, animatablePropertyType );
1150 // Check property count after registration
1151 DALI_TEST_EQUALS( customPropertyCount + 1u, customActor.GetPropertyCount(), TEST_LOCATION );
1153 // Set the animatable property value
1154 customActor.SetProperty( animatablePropertyIndex, Vector2(25.0f, 50.0f) );
1156 // Render and notify
1157 application.SendNotification();
1158 application.Render();
1160 // Check the animatable property value
1161 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( animatablePropertyIndex ), Vector2(25.0f, 50.0f), TEST_LOCATION );
1163 // Check the animatable property name
1164 DALI_TEST_EQUALS( customActor.GetPropertyName( animatablePropertyIndex ), animatablePropertyName, TEST_LOCATION );
1166 // Check the animatable property index
1167 DALI_TEST_EQUALS( customActor.GetPropertyIndex( animatablePropertyName ), animatablePropertyIndex, TEST_LOCATION );
1169 // Check the animatable property type
1170 DALI_TEST_EQUALS( customActor.GetPropertyType( animatablePropertyIndex ), animatablePropertyType, TEST_LOCATION );
1172 // Check property count of type-info is 1
1173 Property::IndexContainer indices;
1174 typeInfo.GetPropertyIndices( indices );
1175 DALI_TEST_EQUALS( indices.Size(), 1u, TEST_LOCATION );
1177 // Register animatable property components
1178 std::string animatablePropertyComponentName1( "animatable-prop-1-x" );
1179 int animatablePropertyComponentIndex1( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1 );
1180 AnimatablePropertyComponentRegistration animatablePropertyComponent1( customType1, animatablePropertyComponentName1, animatablePropertyComponentIndex1, animatablePropertyIndex, 0 );
1182 std::string animatablePropertyComponentName2( "animatable-prop-1-y" );
1183 int animatablePropertyComponentIndex2( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2 );
1184 AnimatablePropertyComponentRegistration animatablePropertyComponent2( customType1, animatablePropertyComponentName2, animatablePropertyComponentIndex2, animatablePropertyIndex, 1 );
1186 // Check property count after registration
1187 DALI_TEST_EQUALS( customPropertyCount + 3u, customActor.GetPropertyCount(), TEST_LOCATION );
1189 // Check the animatable property component value
1190 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex1 ), 25.0f, TEST_LOCATION );
1191 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex2 ), 50.0f, TEST_LOCATION );
1193 // Set the animatable property component value
1194 customActor.SetProperty( animatablePropertyComponentIndex1, 150.0f );
1196 // Render and notify
1197 application.SendNotification();
1198 application.Render();
1200 // Check the animatable property value
1201 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( animatablePropertyIndex ), Vector2(150.0f, 50.0f), TEST_LOCATION );
1202 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex1 ), 150.0f, TEST_LOCATION );
1203 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex2 ), 50.0f, TEST_LOCATION );
1205 // Set the animatable property component value
1206 customActor.SetProperty( animatablePropertyComponentIndex2, 225.0f );
1208 // Render and notify
1209 application.SendNotification();
1210 application.Render();
1212 // Check the animatable property value
1213 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( animatablePropertyIndex ), Vector2(150.0f, 225.0f), TEST_LOCATION );
1214 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex1 ), 150.0f, TEST_LOCATION );
1215 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex2 ), 225.0f, TEST_LOCATION );
1217 // Ensure indices returned from actor and customActor differ by three
1218 Actor actor = Actor::New();
1219 actor.GetPropertyIndices( indices );
1220 unsigned int actorIndices = indices.Size();
1221 customActor.GetPropertyIndices( indices );
1222 unsigned int customActorIndices = indices.Size();
1223 DALI_TEST_EQUALS( actorIndices + 3u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1228 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationN(void)
1230 TestApplication application;
1231 TypeRegistry typeRegistry = TypeRegistry::Get();
1233 // Register animatable property with the type of Vector2
1234 int animatablePropertyIndex1( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1235 AnimatablePropertyRegistration animatableProperty1( customType1, "animatable-prop-1", animatablePropertyIndex1, Property::VECTOR2 );
1237 // Attempt to register an animatable property component out-of-bounds index (less than)
1240 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatable-prop-1-x", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX - 1, animatablePropertyIndex1, 0 );
1241 tet_result( TET_FAIL );
1243 catch ( DaliException& e )
1245 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1248 // Attempt to register an animatable property component out-of-bounds index (greater than)
1251 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatable-prop-1-x", ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX + 1, animatablePropertyIndex1, 0 );
1252 tet_result( TET_FAIL );
1254 catch ( DaliException& e )
1256 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1259 // Register an animatable property component
1260 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatable-prop-1-x", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1, animatablePropertyIndex1, 0 );
1262 // Attempt to register another animatable property component with the same component index
1265 AnimatablePropertyComponentRegistration propertyComponent2( customType1, "animatable-prop-1-y", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2, animatablePropertyIndex1, 0 );
1266 tet_result( TET_FAIL );
1268 catch ( DaliException& e )
1270 DALI_TEST_ASSERT( e, "Property component already registered", TEST_LOCATION );
1273 // Register animatable property with the type of boolean
1274 int animatablePropertyIndex2( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2 );
1275 AnimatablePropertyRegistration animatableProperty2( customType1, "animatable-prop-2", animatablePropertyIndex2, Property::BOOLEAN );
1277 // Attempt to register an animatable property component for the above property with boolean type
1280 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatable-prop-2-x", animatablePropertyIndex2 + 1, animatablePropertyIndex2, 0 );
1281 tet_result( TET_FAIL );
1283 catch ( DaliException& e )
1285 DALI_TEST_ASSERT( e, "Base property does not support component", TEST_LOCATION );
1292 /*******************************************************************************
1294 * Action through the base handle
1296 ******************************************************************************/
1297 int UtcDaliTypeRegistryActionViaBaseHandle(void)
1299 TestApplication application;
1303 type = TypeRegistry::Get().GetTypeInfo( "Actor" );
1304 DALI_TEST_CHECK( type );
1306 BaseHandle hdl = type.CreateInstance();
1307 DALI_TEST_CHECK( hdl );
1309 Actor a = Actor::DownCast(hdl);
1310 DALI_TEST_CHECK( a );
1312 a.SetVisible(false);
1314 application.SendNotification();
1315 application.Render(0);
1316 DALI_TEST_CHECK(!a.IsVisible());
1318 Property::Map attributes;
1320 DALI_TEST_CHECK(hdl.DoAction("show", attributes));
1322 application.SendNotification();
1323 application.Render(0);
1324 DALI_TEST_CHECK(a.IsVisible());
1326 DALI_TEST_CHECK(!hdl.DoAction("unknown-action", attributes));
1330 int UtcDaliPropertyRegistrationFunctions(void)
1332 TestApplication application;
1333 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 10;
1335 // Attempt to register a property without a setter
1338 PropertyRegistration property1( customType1, "prop-name", propertyIndex++, Property::BOOLEAN, NULL, &GetProperty );
1339 tet_result( TET_PASS );
1341 catch ( DaliException& e )
1343 tet_result( TET_FAIL );
1346 // Attempt to register a property without a getter
1349 PropertyRegistration property1( customType1, "prop-name", propertyIndex++, Property::BOOLEAN, NULL, NULL );
1350 tet_result( TET_FAIL );
1352 catch ( DaliException& e )
1354 DALI_TEST_ASSERT( e, "! \"GetProperty", TEST_LOCATION );
1359 int UtcDaliPropertyRegistrationAddSameIndex(void)
1361 TestApplication application;
1362 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 100;
1364 // Add one property with a valid property index
1365 PropertyRegistration property1( customType1, "prop-name", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
1367 // Attempt to add another property with the same index
1370 PropertyRegistration property2( customType1, "prop-name-2", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
1372 catch ( DaliException& e )
1374 DALI_TEST_ASSERT( e, "! \"Property index already added", TEST_LOCATION );
1377 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 100;
1379 // Add one property with a valid property index
1380 AnimatablePropertyRegistration property3( customType1, "anim-prop-name", animatablePropertyIndex, Property::BOOLEAN );
1382 // Attempt to add another property with the same index
1385 AnimatablePropertyRegistration property4( customType1, "anim-prop-name-2", animatablePropertyIndex, Property::BOOLEAN );
1387 catch ( DaliException& e )
1389 DALI_TEST_ASSERT( e, "! \"Property index already added", TEST_LOCATION );
1394 int UtcDaliPropertyRegistrationPropertyWritable(void)
1396 TestApplication application;
1397 int propertyIndex1 = PROPERTY_REGISTRATION_START_INDEX + 200;
1398 int propertyIndex2 = PROPERTY_REGISTRATION_START_INDEX + 201;
1400 // Add two properties, one with SetProperty, one without
1401 PropertyRegistration property1( customType1, "prop-name-readwrite", propertyIndex1, Property::BOOLEAN, &SetProperty, &GetProperty );
1402 PropertyRegistration property2( customType1, "prop-name-readonly", propertyIndex2, Property::BOOLEAN, NULL, &GetProperty );
1404 // Create custom-actor
1405 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
1406 DALI_TEST_CHECK( typeInfo );
1407 BaseHandle handle = typeInfo.CreateInstance();
1408 DALI_TEST_CHECK( handle );
1409 Actor customActor = Actor::DownCast( handle );
1410 DALI_TEST_CHECK( customActor );
1412 // Check whether properties are writable
1413 DALI_TEST_CHECK( customActor.IsPropertyWritable( propertyIndex1 ) );
1414 DALI_TEST_CHECK( ! customActor.IsPropertyWritable( propertyIndex2 ) );
1418 int UtcDaliPropertyRegistrationPropertyAnimatable(void)
1420 TestApplication application;
1421 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 400;
1422 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 400;
1424 // These properties are not animatable
1425 PropertyRegistration property1( customType1, "prop-name", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
1427 // These properties are animatable
1428 AnimatablePropertyRegistration property2( customType1, "anim-prop-name", animatablePropertyIndex, Property::BOOLEAN );
1430 // Create custom-actor
1431 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
1432 DALI_TEST_CHECK( typeInfo );
1433 BaseHandle handle = typeInfo.CreateInstance();
1434 DALI_TEST_CHECK( handle );
1435 Actor customActor = Actor::DownCast( handle );
1436 DALI_TEST_CHECK( customActor );
1438 // Check if animatable
1439 DALI_TEST_CHECK( ! customActor.IsPropertyAnimatable( propertyIndex ) );
1440 DALI_TEST_CHECK( customActor.IsPropertyAnimatable( animatablePropertyIndex ) );
1442 // Create another instance of custom-actor
1443 BaseHandle handle2 = typeInfo.CreateInstance();
1444 DALI_TEST_CHECK( handle2 );
1445 Actor customActor2 = Actor::DownCast( handle2 );
1446 DALI_TEST_CHECK( customActor2 );
1448 // Check if animatable
1449 DALI_TEST_CHECK( ! customActor2.IsPropertyAnimatable( propertyIndex ) );
1450 DALI_TEST_CHECK( customActor2.IsPropertyAnimatable( animatablePropertyIndex ) );
1454 int UtcDaliPropertyRegistrationInvalidGetAndSet(void)
1456 TestApplication application;
1457 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 2000;
1458 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2000;
1460 // Create custom-actor
1461 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
1462 DALI_TEST_CHECK( typeInfo );
1463 BaseHandle handle = typeInfo.CreateInstance();
1464 DALI_TEST_CHECK( handle );
1465 Actor customActor = Actor::DownCast( handle );
1466 DALI_TEST_CHECK( customActor );
1468 // Try to set an index that hasn't been added
1471 customActor.SetProperty( propertyIndex, true );
1472 tet_result( TET_FAIL );
1474 catch ( DaliException& e )
1476 DALI_TEST_ASSERT( e, "! \"Cannot find property index", TEST_LOCATION );
1481 customActor.SetProperty( animatablePropertyIndex, true );
1482 tet_result( TET_FAIL );
1484 catch ( DaliException& e )
1486 DALI_TEST_ASSERT( e, "! \"Cannot find property index", TEST_LOCATION );
1489 // Try to get an index that hasn't been added
1492 (void) customActor.GetProperty< bool >( propertyIndex );
1493 tet_result( TET_FAIL );
1495 catch ( DaliException& e )
1497 DALI_TEST_ASSERT( e, "! \"Cannot find property index", TEST_LOCATION );
1502 (void) customActor.GetProperty< bool >( animatablePropertyIndex );
1503 tet_result( TET_FAIL );
1505 catch ( DaliException& e )
1507 DALI_TEST_ASSERT( e, "! \"Cannot find property index", TEST_LOCATION );
1513 int UtcDaliLongPressGestureDetectorTypeRegistry(void)
1515 TestApplication application;
1517 Actor actor = Actor::New();
1518 actor.SetSize(100.0f, 100.0f);
1519 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1520 Stage::GetCurrent().Add(actor);
1524 type = TypeRegistry::Get().GetTypeInfo( "LongPressGestureDetector" );
1525 DALI_TEST_CHECK( type );
1526 BaseHandle handle = type.CreateInstance();
1527 DALI_TEST_CHECK( handle );
1528 LongPressGestureDetector detector = LongPressGestureDetector::DownCast( handle );
1529 DALI_TEST_CHECK( detector );
1531 // Attach actor to detector
1533 GestureReceivedFunctor functor( data );
1534 detector.Attach(actor);
1536 // Connect to signal through type
1537 handle.ConnectSignal( &application, "long-press-detected", functor );
1539 // Render and notify
1540 application.SendNotification();
1541 application.Render();
1544 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f)));
1545 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f)));
1546 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f)));
1547 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
1551 int UtcDaliPanGestureDetectorTypeRegistry(void)
1553 TestApplication application;
1555 Actor actor = Actor::New();
1556 actor.SetSize(100.0f, 100.0f);
1557 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1558 Stage::GetCurrent().Add(actor);
1562 type = TypeRegistry::Get().GetTypeInfo( "PanGestureDetector" );
1563 DALI_TEST_CHECK( type );
1564 BaseHandle handle = type.CreateInstance();
1565 DALI_TEST_CHECK( handle );
1566 PanGestureDetector detector = PanGestureDetector::DownCast( handle );
1567 DALI_TEST_CHECK( detector );
1569 // Attach actor to detector
1571 GestureReceivedFunctor functor( data );
1572 detector.Attach(actor);
1574 // Connect to signal through type
1575 handle.ConnectSignal( &application, "pan-detected", functor );
1577 // Render and notify
1578 application.SendNotification();
1579 application.Render();
1582 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1583 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1584 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1585 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
1589 int UtcDaliPinchGestureDetectorTypeRegistry(void)
1591 TestApplication application;
1593 Actor actor = Actor::New();
1594 actor.SetSize(100.0f, 100.0f);
1595 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1596 Stage::GetCurrent().Add(actor);
1600 type = TypeRegistry::Get().GetTypeInfo( "PinchGestureDetector" );
1601 DALI_TEST_CHECK( type );
1602 BaseHandle handle = type.CreateInstance();
1603 DALI_TEST_CHECK( handle );
1604 PinchGestureDetector detector = PinchGestureDetector::DownCast( handle );
1605 DALI_TEST_CHECK( detector );
1607 // Attach actor to detector
1609 GestureReceivedFunctor functor( data );
1610 detector.Attach(actor);
1612 // Connect to signal through type
1613 handle.ConnectSignal( &application, "pinch-detected", functor );
1615 // Render and notify
1616 application.SendNotification();
1617 application.Render();
1620 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
1621 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
1625 int UtcDaliTapGestureDetectorTypeRegistry(void)
1627 TestApplication application;
1629 Actor actor = Actor::New();
1630 actor.SetSize(100.0f, 100.0f);
1631 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1632 Stage::GetCurrent().Add(actor);
1636 type = TypeRegistry::Get().GetTypeInfo( "TapGestureDetector" );
1637 DALI_TEST_CHECK( type );
1638 BaseHandle handle = type.CreateInstance();
1639 DALI_TEST_CHECK( handle );
1640 TapGestureDetector detector = TapGestureDetector::DownCast( handle );
1641 DALI_TEST_CHECK( detector );
1643 // Attach actor to detector
1645 GestureReceivedFunctor functor( data );
1646 detector.Attach(actor);
1648 // Connect to signal through type
1649 handle.ConnectSignal( &application, "tap-detected", functor );
1651 // Render and notify
1652 application.SendNotification();
1653 application.Render();
1656 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
1657 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
1658 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
1662 int UtcDaliTypeRegistryNamedType(void)
1664 TestApplication application;
1665 TypeRegistry typeRegistry = TypeRegistry::Get();
1667 // Create a normal actor
1668 BaseHandle actorHandle = typeRegistry.GetTypeInfo( "Actor" ).CreateInstance();
1669 DALI_TEST_CHECK( actorHandle );
1670 Actor actor( Actor::DownCast( actorHandle ) );
1671 DALI_TEST_CHECK( actor );
1672 unsigned int actorPropertyCount( actor.GetPropertyCount() );
1674 // Create Named Actor Type
1675 BaseHandle namedHandle = typeRegistry.GetTypeInfo( "MyNamedActor" ).CreateInstance();
1676 DALI_TEST_CHECK( namedHandle );
1677 Actor namedActor( Actor::DownCast( namedHandle ) );
1678 DALI_TEST_CHECK( namedActor );
1679 unsigned int namedActorPropertyCount( namedActor.GetPropertyCount() );
1681 DALI_TEST_CHECK( namedActorPropertyCount > actorPropertyCount );