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 OnMouseWheelEvent(const MouseWheelEvent& 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 std::vector<Property::Value>& 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 UtcDaliTypeRegistryGetTypeInfoFromTypeNameP(void)
579 TestApplication application;
581 TypeRegistry registry = TypeRegistry::Get();
586 type = registry.GetTypeInfo( "ImageActor" );
587 DALI_TEST_CHECK( type );
588 DALI_TEST_CHECK( type.GetCreator() );
589 DALI_TEST_CHECK( ImageActor::DownCast( type.GetCreator()() ) );
590 ImageActor ia = ImageActor::DownCast(type.CreateInstance());
591 DALI_TEST_CHECK( ia );
592 Stage::GetCurrent().Add( ia );
593 application.Render();
596 type = registry.GetTypeInfo( "CameraActor" );
597 DALI_TEST_CHECK( type );
598 CameraActor ca = CameraActor::DownCast(type.CreateInstance());
599 DALI_TEST_CHECK( ca );
600 Stage::GetCurrent().Add( ca );
601 application.Render();
604 type = registry.GetTypeInfo( "Animation" );
605 DALI_TEST_CHECK( type );
606 Animation an = Animation::DownCast(type.CreateInstance());
607 DALI_TEST_CHECK( an );
609 application.Render();
612 type = registry.GetTypeInfo( "ShaderEffect" );
613 DALI_TEST_CHECK( type );
614 ShaderEffect ef = ShaderEffect::DownCast(type.CreateInstance());
615 DALI_TEST_CHECK( ef );
616 application.Render();
621 int UtcDaliTypeRegistryGetTypeInfoFromTypeNameN(void)
623 TestApplication application;
625 TypeRegistry registry = TypeRegistry::Get();
629 type = registry.GetTypeInfo( "MyDummyActor" );
630 DALI_TEST_CHECK( !type );
635 int UtcDaliTypeRegistryGetTypeInfoFromTypeIdP(void)
637 TypeInfo named_type = TypeRegistry::Get().GetTypeInfo( "ImageActor" );
638 TypeInfo typeinfo_type = TypeRegistry::Get().GetTypeInfo( typeid(Dali::ImageActor) );
640 DALI_TEST_CHECK( named_type );
641 DALI_TEST_CHECK( typeinfo_type );
643 // Check named and typeid are equivalent
644 DALI_TEST_CHECK( named_type == typeinfo_type );
646 DALI_TEST_CHECK( named_type.GetName() == typeinfo_type.GetName() );
647 DALI_TEST_CHECK( named_type.GetBaseName() == typeinfo_type.GetBaseName() );
652 int UtcDaliTypeRegistryGetTypeInfoFromTypeIdN(void)
654 TestApplication application;
655 TypeRegistry typeRegistry = TypeRegistry::Get();
657 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(Vector2) );
658 DALI_TEST_CHECK( !typeInfo );
663 int UtcDaliTypeRegistryGetTypeNamesP(void)
665 TestApplication application;
669 TypeRegistry::NameContainer names = TypeRegistry::Get().GetTypeNames();
671 for(TypeRegistry::NameContainer::iterator iter = names.begin();
672 iter != names.end(); ++iter)
674 type = TypeRegistry::Get().GetTypeInfo( *iter );
675 DALI_TEST_CHECK( type );
681 int UtcDaliTypeRegistryGetTypeNamesN(void)
683 TestApplication application;
687 TypeRegistry::NameContainer names = TypeRegistry::Get().GetTypeNames();
689 for(TypeRegistry::NameContainer::iterator iter = names.begin();
690 iter != names.end(); ++iter)
692 type = TypeRegistry::Get().GetTypeInfo( *iter );
693 DALI_TEST_CHECK( type.GetName() != "MyDummyActor" );
699 // Note: No negative test case for UtcDaliTypeRegistryTypeRegistration can be implemented.
700 int UtcDaliTypeRegistryTypeRegistrationNotCallingCreateOnInitP(void)
702 ResetFunctorCounts();
704 TestApplication application;
706 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
707 DALI_TEST_CHECK( type );
709 TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( "CustomActor" );
710 DALI_TEST_CHECK( baseType );
712 BaseHandle handle = type.CreateInstance();
713 DALI_TEST_CHECK( handle );
715 MyTestCustomActor customHandle = MyTestCustomActor::DownCast( handle );
716 DALI_TEST_CHECK( customHandle );
718 TypeInfo::NameContainer names;
719 type.GetActions(names);
720 TypeInfo::NameContainer baseNames;
721 baseType.GetActions(baseNames);
722 DALI_TEST_EQUALS( names.size(), TEST_ACTION_COUNT + baseNames.size(), TEST_LOCATION );
725 type.GetSignals(names);
728 baseType.GetSignals(baseNames);
730 DALI_TEST_EQUALS( names.size(), TEST_SIGNAL_COUNT + baseNames.size(), 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 std::vector<Property::Value> 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 TypeInfo::NameContainer names;
881 TypeInfo::NameContainer baseNames;
883 type.GetActions(names);
884 baseType.GetActions(baseNames);
886 DALI_TEST_EQUALS( names.size(), TEST_ACTION_COUNT + baseNames.size(), TEST_LOCATION );
891 type.GetSignals(names);
892 baseType.GetSignals(baseNames);
894 DALI_TEST_EQUALS( names.size(), TEST_SIGNAL_COUNT + baseNames.size(), TEST_LOCATION );
897 TestConnectionTracker tracker;
899 bool connected = handle.ConnectSignal( &tracker, "sig2", CustomTestFunctor() );
900 DALI_TEST_EQUALS( connected, false/*This is supposed to fail*/, TEST_LOCATION );
901 DALI_TEST_CHECK( lastSignalConnectionCustom == "failed" );
902 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
903 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0/*deleted along with FunctorDelegate*/, TEST_LOCATION );
906 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
907 customHandle.GetCustomSignal().Emit();
908 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0/*never called*/, TEST_LOCATION );
910 // tracker should have nothing to disconnect here
913 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
914 customHandle.GetCustomSignal().Emit();
915 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0/*never called*/, TEST_LOCATION );
919 int UtcDaliTypeRegistryTypeActionP(void)
921 ResetFunctorCounts();
923 TestApplication application;
925 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
926 DALI_TEST_CHECK( type );
928 BaseHandle handle = type.CreateInstance();
929 DALI_TEST_CHECK( handle );
931 std::vector<Property::Value> attributes;
932 DALI_TEST_CHECK( handle.DoAction("act1", attributes) );
933 DALI_TEST_CHECK( lastActionCustom == "act1" );
938 int UtcDaliTypeRegistryTypeActionN(void)
940 ResetFunctorCounts();
942 TestApplication application;
944 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
945 DALI_TEST_CHECK( type );
947 BaseHandle handle = type.CreateInstance();
948 DALI_TEST_CHECK( handle );
950 std::vector<Property::Value> attributes;
951 DALI_TEST_CHECK( !handle.DoAction( "unknown-action", attributes ) );
956 int UtcDaliTypeRegistryPropertyRegistrationP(void)
958 TestApplication application;
959 TypeRegistry typeRegistry = TypeRegistry::Get();
961 // Check property count before property registration
962 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
963 DALI_TEST_CHECK( typeInfo );
964 BaseHandle handle = typeInfo.CreateInstance();
965 DALI_TEST_CHECK( handle );
966 Actor customActor = Actor::DownCast( handle );
967 DALI_TEST_CHECK( customActor );
968 unsigned int initialPropertyCount( customActor.GetPropertyCount() );
970 std::string propertyName( "prop-1" );
971 int propertyIndex( PROPERTY_REGISTRATION_START_INDEX );
972 Property::Type propertyType( Property::BOOLEAN );
973 PropertyRegistration property1( customType1, propertyName, propertyIndex, propertyType, &SetProperty, &GetProperty );
975 // Check property count after registration
976 unsigned int postRegistrationPropertyCount( customActor.GetPropertyCount() );
977 DALI_TEST_EQUALS( initialPropertyCount + 1u, postRegistrationPropertyCount, TEST_LOCATION );
979 // Add custom property and check property count
980 customActor.RegisterProperty( "custom-prop-1", true );
981 unsigned int customPropertyCount( customActor.GetPropertyCount() );
982 DALI_TEST_EQUALS( postRegistrationPropertyCount + 1u, customPropertyCount, TEST_LOCATION );
984 // Set the property, ensure SetProperty called
985 DALI_TEST_CHECK( !setPropertyCalled );
986 customActor.SetProperty( propertyIndex, false );
987 DALI_TEST_CHECK( setPropertyCalled );
989 // Get the property, ensure GetProperty called
990 DALI_TEST_CHECK( !getPropertyCalled );
991 (void)customActor.GetProperty< bool >( propertyIndex );
992 DALI_TEST_CHECK( getPropertyCalled );
994 // Check the property name
995 DALI_TEST_EQUALS( customActor.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
996 DALI_TEST_EQUALS( typeInfo.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
998 // Check the property index
999 DALI_TEST_EQUALS( customActor.GetPropertyIndex( propertyName ), propertyIndex, TEST_LOCATION );
1001 // Check the property type
1002 DALI_TEST_EQUALS( customActor.GetPropertyType( propertyIndex ), propertyType, TEST_LOCATION );
1004 // Check property count of type-info is 1
1005 Property::IndexContainer indices;
1006 typeInfo.GetPropertyIndices( indices );
1007 DALI_TEST_EQUALS( indices.size(), 1u, TEST_LOCATION );
1009 // Ensure indices returned from actor and customActor differ by two
1010 Actor actor = Actor::New();
1011 actor.GetPropertyIndices( indices );
1012 unsigned int actorIndices = indices.size();
1013 customActor.GetPropertyIndices( indices );
1014 unsigned int customActorIndices = indices.size();
1015 DALI_TEST_EQUALS( actorIndices + 2u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1019 int UtcDaliTypeRegistryPropertyRegistrationN(void)
1021 TestApplication application;
1022 TypeRegistry typeRegistry = TypeRegistry::Get();
1024 // Attempt to register a property type out-of-bounds index (less than)
1027 PropertyRegistration property1( customType1, "prop-name", PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN, &SetProperty, &GetProperty );
1028 tet_result( TET_FAIL );
1030 catch ( DaliException& e )
1032 DALI_TEST_ASSERT( e, "( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1035 // Attempt to register a property type out-of-bounds index (greater than)
1038 PropertyRegistration property1( customType1, "prop-name", PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN, &SetProperty, &GetProperty );
1039 tet_result( TET_FAIL );
1041 catch ( DaliException& e )
1043 DALI_TEST_ASSERT( e, "( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1049 int UtcDaliTypeRegistryAnimatablePropertyRegistrationP(void)
1051 TestApplication application;
1052 TypeRegistry typeRegistry = TypeRegistry::Get();
1054 // Check property count before property registration
1055 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1056 DALI_TEST_CHECK( typeInfo );
1057 BaseHandle handle = typeInfo.CreateInstance();
1058 DALI_TEST_CHECK( handle );
1059 Actor customActor = Actor::DownCast( handle );
1060 DALI_TEST_CHECK( customActor );
1062 unsigned int customPropertyCount( customActor.GetPropertyCount() );
1064 // Register animatable property
1065 std::string animatablePropertyName( "animatable-prop-1" );
1066 int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1067 Property::Type animatablePropertyType( Property::FLOAT );
1068 AnimatablePropertyRegistration animatableProperty1( customType1, animatablePropertyName, animatablePropertyIndex, animatablePropertyType );
1070 // Check property count after registration
1071 DALI_TEST_EQUALS( customPropertyCount + 1u, customActor.GetPropertyCount(), TEST_LOCATION );
1073 // Set the animatable property value
1074 customActor.SetProperty( animatablePropertyIndex, 25.0f );
1076 // Render and notify
1077 application.SendNotification();
1078 application.Render();
1080 // Check the animatable property value
1081 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 25.0f, TEST_LOCATION );
1083 // Check the animatable property name
1084 DALI_TEST_EQUALS( customActor.GetPropertyName( animatablePropertyIndex ), animatablePropertyName, TEST_LOCATION );
1086 // Check the animatable property index
1087 DALI_TEST_EQUALS( customActor.GetPropertyIndex( animatablePropertyName ), animatablePropertyIndex, TEST_LOCATION );
1089 // Check the animatable property type
1090 DALI_TEST_EQUALS( customActor.GetPropertyType( animatablePropertyIndex ), animatablePropertyType, TEST_LOCATION );
1092 // Check property count of type-info is 1
1093 Property::IndexContainer indices;
1094 typeInfo.GetPropertyIndices( indices );
1095 DALI_TEST_EQUALS( indices.size(), 1u, TEST_LOCATION );
1097 // Ensure indices returned from actor and customActor differ by one
1098 Actor actor = Actor::New();
1099 actor.GetPropertyIndices( indices );
1100 unsigned int actorIndices = indices.size();
1101 customActor.GetPropertyIndices( indices );
1102 unsigned int customActorIndices = indices.size();
1103 DALI_TEST_EQUALS( actorIndices + 1u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1108 int UtcDaliTypeRegistryAnimatablePropertyRegistrationN(void)
1110 TestApplication application;
1111 TypeRegistry typeRegistry = TypeRegistry::Get();
1113 // Attempt to register an animatable property type out-of-bounds index (less than)
1116 AnimatablePropertyRegistration property1( customType1, "anim-prop-name", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN );
1117 tet_result( TET_FAIL );
1119 catch ( DaliException& e )
1121 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1124 // Attempt to register an animatable property type out-of-bounds index (greater than)
1127 AnimatablePropertyRegistration property1( customType1, "anim-prop-name", ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN );
1128 tet_result( TET_FAIL );
1130 catch ( DaliException& e )
1132 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1138 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationP(void)
1140 TestApplication application;
1141 TypeRegistry typeRegistry = TypeRegistry::Get();
1143 // Check property count before property registration
1144 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1145 DALI_TEST_CHECK( typeInfo );
1146 BaseHandle handle = typeInfo.CreateInstance();
1147 DALI_TEST_CHECK( handle );
1148 Actor customActor = Actor::DownCast( handle );
1149 DALI_TEST_CHECK( customActor );
1151 unsigned int customPropertyCount( customActor.GetPropertyCount() );
1153 // Register animatable property
1154 std::string animatablePropertyName( "animatable-prop-1" );
1155 int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1156 Property::Type animatablePropertyType( Property::VECTOR2 );
1157 AnimatablePropertyRegistration animatableProperty1( customType1, animatablePropertyName, animatablePropertyIndex, animatablePropertyType );
1159 // Check property count after registration
1160 DALI_TEST_EQUALS( customPropertyCount + 1u, customActor.GetPropertyCount(), TEST_LOCATION );
1162 // Set the animatable property value
1163 customActor.SetProperty( animatablePropertyIndex, Vector2(25.0f, 50.0f) );
1165 // Render and notify
1166 application.SendNotification();
1167 application.Render();
1169 // Check the animatable property value
1170 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( animatablePropertyIndex ), Vector2(25.0f, 50.0f), TEST_LOCATION );
1172 // Check the animatable property name
1173 DALI_TEST_EQUALS( customActor.GetPropertyName( animatablePropertyIndex ), animatablePropertyName, TEST_LOCATION );
1175 // Check the animatable property index
1176 DALI_TEST_EQUALS( customActor.GetPropertyIndex( animatablePropertyName ), animatablePropertyIndex, TEST_LOCATION );
1178 // Check the animatable property type
1179 DALI_TEST_EQUALS( customActor.GetPropertyType( animatablePropertyIndex ), animatablePropertyType, TEST_LOCATION );
1181 // Check property count of type-info is 1
1182 Property::IndexContainer indices;
1183 typeInfo.GetPropertyIndices( indices );
1184 DALI_TEST_EQUALS( indices.size(), 1u, TEST_LOCATION );
1186 // Register animatable property components
1187 std::string animatablePropertyComponentName1( "animatable-prop-1-x" );
1188 int animatablePropertyComponentIndex1( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1 );
1189 AnimatablePropertyComponentRegistration animatablePropertyComponent1( customType1, animatablePropertyComponentName1, animatablePropertyComponentIndex1, animatablePropertyIndex, 0 );
1191 std::string animatablePropertyComponentName2( "animatable-prop-1-y" );
1192 int animatablePropertyComponentIndex2( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2 );
1193 AnimatablePropertyComponentRegistration animatablePropertyComponent2( customType1, animatablePropertyComponentName2, animatablePropertyComponentIndex2, animatablePropertyIndex, 1 );
1195 // Check property count after registration
1196 DALI_TEST_EQUALS( customPropertyCount + 3u, customActor.GetPropertyCount(), TEST_LOCATION );
1198 // Check the animatable property component value
1199 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex1 ), 25.0f, TEST_LOCATION );
1200 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex2 ), 50.0f, TEST_LOCATION );
1202 // Set the animatable property component value
1203 customActor.SetProperty( animatablePropertyComponentIndex1, 150.0f );
1205 // Render and notify
1206 application.SendNotification();
1207 application.Render();
1209 // Check the animatable property value
1210 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( animatablePropertyIndex ), Vector2(150.0f, 50.0f), TEST_LOCATION );
1211 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex1 ), 150.0f, TEST_LOCATION );
1212 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex2 ), 50.0f, TEST_LOCATION );
1214 // Set the animatable property component value
1215 customActor.SetProperty( animatablePropertyComponentIndex2, 225.0f );
1217 // Render and notify
1218 application.SendNotification();
1219 application.Render();
1221 // Check the animatable property value
1222 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( animatablePropertyIndex ), Vector2(150.0f, 225.0f), TEST_LOCATION );
1223 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex1 ), 150.0f, TEST_LOCATION );
1224 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex2 ), 225.0f, TEST_LOCATION );
1226 // Ensure indices returned from actor and customActor differ by three
1227 Actor actor = Actor::New();
1228 actor.GetPropertyIndices( indices );
1229 unsigned int actorIndices = indices.size();
1230 customActor.GetPropertyIndices( indices );
1231 unsigned int customActorIndices = indices.size();
1232 DALI_TEST_EQUALS( actorIndices + 3u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1237 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationN(void)
1239 TestApplication application;
1240 TypeRegistry typeRegistry = TypeRegistry::Get();
1242 // Register animatable property with the type of Vector2
1243 int animatablePropertyIndex1( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1244 AnimatablePropertyRegistration animatableProperty1( customType1, "animatable-prop-1", animatablePropertyIndex1, Property::VECTOR2 );
1246 // Attempt to register an animatable property component out-of-bounds index (less than)
1249 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatable-prop-1-x", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX - 1, animatablePropertyIndex1, 0 );
1250 tet_result( TET_FAIL );
1252 catch ( DaliException& e )
1254 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1257 // Attempt to register an animatable property component out-of-bounds index (greater than)
1260 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatable-prop-1-x", ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX + 1, animatablePropertyIndex1, 0 );
1261 tet_result( TET_FAIL );
1263 catch ( DaliException& e )
1265 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1268 // Register an animatable property component
1269 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatable-prop-1-x", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1, animatablePropertyIndex1, 0 );
1271 // Attempt to register another animatable property component with the same component index
1274 AnimatablePropertyComponentRegistration propertyComponent2( customType1, "animatable-prop-1-y", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2, animatablePropertyIndex1, 0 );
1275 tet_result( TET_FAIL );
1277 catch ( DaliException& e )
1279 DALI_TEST_ASSERT( e, "Property component already registered", TEST_LOCATION );
1282 // Register animatable property with the type of boolean
1283 int animatablePropertyIndex2( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2 );
1284 AnimatablePropertyRegistration animatableProperty2( customType1, "animatable-prop-2", animatablePropertyIndex2, Property::BOOLEAN );
1286 // Attempt to register an animatable property component for the above property with boolean type
1289 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatable-prop-2-x", animatablePropertyIndex2 + 1, animatablePropertyIndex2, 0 );
1290 tet_result( TET_FAIL );
1292 catch ( DaliException& e )
1294 DALI_TEST_ASSERT( e, "Base property does not support component", TEST_LOCATION );
1301 /*******************************************************************************
1303 * Action through the base handle
1305 ******************************************************************************/
1306 int UtcDaliTypeRegistryActionViaBaseHandle(void)
1308 TestApplication application;
1312 type = TypeRegistry::Get().GetTypeInfo( "Actor" );
1313 DALI_TEST_CHECK( type );
1315 BaseHandle hdl = type.CreateInstance();
1316 DALI_TEST_CHECK( hdl );
1318 Actor a = Actor::DownCast(hdl);
1319 DALI_TEST_CHECK( a );
1321 a.SetVisible(false);
1323 application.SendNotification();
1324 application.Render(0);
1325 DALI_TEST_CHECK(!a.IsVisible());
1327 std::vector<Property::Value> attributes;
1329 DALI_TEST_CHECK(hdl.DoAction("show", attributes));
1331 application.SendNotification();
1332 application.Render(0);
1333 DALI_TEST_CHECK(a.IsVisible());
1335 DALI_TEST_CHECK(!hdl.DoAction("unknown-action", attributes));
1339 int UtcDaliPropertyRegistrationFunctions(void)
1341 TestApplication application;
1342 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 10;
1344 // Attempt to register a property without a setter
1347 PropertyRegistration property1( customType1, "prop-name", propertyIndex++, Property::BOOLEAN, NULL, &GetProperty );
1348 tet_result( TET_PASS );
1350 catch ( DaliException& e )
1352 tet_result( TET_FAIL );
1355 // Attempt to register a property without a getter
1358 PropertyRegistration property1( customType1, "prop-name", propertyIndex++, Property::BOOLEAN, NULL, NULL );
1359 tet_result( TET_FAIL );
1361 catch ( DaliException& e )
1363 DALI_TEST_ASSERT( e, "! \"GetProperty", TEST_LOCATION );
1368 int UtcDaliPropertyRegistrationAddSameIndex(void)
1370 TestApplication application;
1371 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 100;
1373 // Add one property with a valid property index
1374 PropertyRegistration property1( customType1, "prop-name", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
1376 // Attempt to add another property with the same index
1379 PropertyRegistration property2( customType1, "prop-name-2", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
1381 catch ( DaliException& e )
1383 DALI_TEST_ASSERT( e, "! \"Property index already added", TEST_LOCATION );
1386 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 100;
1388 // Add one property with a valid property index
1389 AnimatablePropertyRegistration property3( customType1, "anim-prop-name", animatablePropertyIndex, Property::BOOLEAN );
1391 // Attempt to add another property with the same index
1394 AnimatablePropertyRegistration property4( customType1, "anim-prop-name-2", animatablePropertyIndex, Property::BOOLEAN );
1396 catch ( DaliException& e )
1398 DALI_TEST_ASSERT( e, "! \"Property index already added", TEST_LOCATION );
1403 int UtcDaliPropertyRegistrationPropertyWritable(void)
1405 TestApplication application;
1406 int propertyIndex1 = PROPERTY_REGISTRATION_START_INDEX + 200;
1407 int propertyIndex2 = PROPERTY_REGISTRATION_START_INDEX + 201;
1409 // Add two properties, one with SetProperty, one without
1410 PropertyRegistration property1( customType1, "prop-name-readwrite", propertyIndex1, Property::BOOLEAN, &SetProperty, &GetProperty );
1411 PropertyRegistration property2( customType1, "prop-name-readonly", propertyIndex2, Property::BOOLEAN, NULL, &GetProperty );
1413 // Create custom-actor
1414 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
1415 DALI_TEST_CHECK( typeInfo );
1416 BaseHandle handle = typeInfo.CreateInstance();
1417 DALI_TEST_CHECK( handle );
1418 Actor customActor = Actor::DownCast( handle );
1419 DALI_TEST_CHECK( customActor );
1421 // Check whether properties are writable
1422 DALI_TEST_CHECK( customActor.IsPropertyWritable( propertyIndex1 ) );
1423 DALI_TEST_CHECK( ! customActor.IsPropertyWritable( propertyIndex2 ) );
1427 int UtcDaliPropertyRegistrationPropertyAnimatable(void)
1429 TestApplication application;
1430 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 400;
1431 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 400;
1433 // These properties are not animatable
1434 PropertyRegistration property1( customType1, "prop-name", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
1436 // These properties are animatable
1437 AnimatablePropertyRegistration property2( customType1, "anim-prop-name", animatablePropertyIndex, Property::BOOLEAN );
1439 // Create custom-actor
1440 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
1441 DALI_TEST_CHECK( typeInfo );
1442 BaseHandle handle = typeInfo.CreateInstance();
1443 DALI_TEST_CHECK( handle );
1444 Actor customActor = Actor::DownCast( handle );
1445 DALI_TEST_CHECK( customActor );
1447 // Check if animatable
1448 DALI_TEST_CHECK( ! customActor.IsPropertyAnimatable( propertyIndex ) );
1449 DALI_TEST_CHECK( customActor.IsPropertyAnimatable( animatablePropertyIndex ) );
1451 // Create another instance of custom-actor
1452 BaseHandle handle2 = typeInfo.CreateInstance();
1453 DALI_TEST_CHECK( handle2 );
1454 Actor customActor2 = Actor::DownCast( handle2 );
1455 DALI_TEST_CHECK( customActor2 );
1457 // Check if animatable
1458 DALI_TEST_CHECK( ! customActor2.IsPropertyAnimatable( propertyIndex ) );
1459 DALI_TEST_CHECK( customActor2.IsPropertyAnimatable( animatablePropertyIndex ) );
1463 int UtcDaliPropertyRegistrationInvalidGetAndSet(void)
1465 TestApplication application;
1466 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 2000;
1467 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2000;
1469 // Create custom-actor
1470 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
1471 DALI_TEST_CHECK( typeInfo );
1472 BaseHandle handle = typeInfo.CreateInstance();
1473 DALI_TEST_CHECK( handle );
1474 Actor customActor = Actor::DownCast( handle );
1475 DALI_TEST_CHECK( customActor );
1477 // Try to set an index that hasn't been added
1480 customActor.SetProperty( propertyIndex, true );
1481 tet_result( TET_FAIL );
1483 catch ( DaliException& e )
1485 DALI_TEST_ASSERT( e, "! \"Cannot find property index", TEST_LOCATION );
1490 customActor.SetProperty( animatablePropertyIndex, true );
1491 tet_result( TET_FAIL );
1493 catch ( DaliException& e )
1495 DALI_TEST_ASSERT( e, "! \"Cannot find property index", TEST_LOCATION );
1498 // Try to get an index that hasn't been added
1501 (void) customActor.GetProperty< bool >( propertyIndex );
1502 tet_result( TET_FAIL );
1504 catch ( DaliException& e )
1506 DALI_TEST_ASSERT( e, "! \"Cannot find property index", TEST_LOCATION );
1511 (void) customActor.GetProperty< bool >( animatablePropertyIndex );
1512 tet_result( TET_FAIL );
1514 catch ( DaliException& e )
1516 DALI_TEST_ASSERT( e, "! \"Cannot find property index", TEST_LOCATION );
1522 int UtcDaliLongPressGestureDetectorTypeRegistry(void)
1524 TestApplication application;
1526 Actor actor = Actor::New();
1527 actor.SetSize(100.0f, 100.0f);
1528 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1529 Stage::GetCurrent().Add(actor);
1533 type = TypeRegistry::Get().GetTypeInfo( "LongPressGestureDetector" );
1534 DALI_TEST_CHECK( type );
1535 BaseHandle handle = type.CreateInstance();
1536 DALI_TEST_CHECK( handle );
1537 LongPressGestureDetector detector = LongPressGestureDetector::DownCast( handle );
1538 DALI_TEST_CHECK( detector );
1540 // Attach actor to detector
1542 GestureReceivedFunctor functor( data );
1543 detector.Attach(actor);
1545 // Connect to signal through type
1546 handle.ConnectSignal( &application, "long-press-detected", functor );
1548 // Render and notify
1549 application.SendNotification();
1550 application.Render();
1553 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f)));
1554 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f)));
1555 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f)));
1556 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
1560 int UtcDaliPanGestureDetectorTypeRegistry(void)
1562 TestApplication application;
1564 Actor actor = Actor::New();
1565 actor.SetSize(100.0f, 100.0f);
1566 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1567 Stage::GetCurrent().Add(actor);
1571 type = TypeRegistry::Get().GetTypeInfo( "PanGestureDetector" );
1572 DALI_TEST_CHECK( type );
1573 BaseHandle handle = type.CreateInstance();
1574 DALI_TEST_CHECK( handle );
1575 PanGestureDetector detector = PanGestureDetector::DownCast( handle );
1576 DALI_TEST_CHECK( detector );
1578 // Attach actor to detector
1580 GestureReceivedFunctor functor( data );
1581 detector.Attach(actor);
1583 // Connect to signal through type
1584 handle.ConnectSignal( &application, "pan-detected", functor );
1586 // Render and notify
1587 application.SendNotification();
1588 application.Render();
1591 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1592 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1593 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1594 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
1598 int UtcDaliPinchGestureDetectorTypeRegistry(void)
1600 TestApplication application;
1602 Actor actor = Actor::New();
1603 actor.SetSize(100.0f, 100.0f);
1604 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1605 Stage::GetCurrent().Add(actor);
1609 type = TypeRegistry::Get().GetTypeInfo( "PinchGestureDetector" );
1610 DALI_TEST_CHECK( type );
1611 BaseHandle handle = type.CreateInstance();
1612 DALI_TEST_CHECK( handle );
1613 PinchGestureDetector detector = PinchGestureDetector::DownCast( handle );
1614 DALI_TEST_CHECK( detector );
1616 // Attach actor to detector
1618 GestureReceivedFunctor functor( data );
1619 detector.Attach(actor);
1621 // Connect to signal through type
1622 handle.ConnectSignal( &application, "pinch-detected", functor );
1624 // Render and notify
1625 application.SendNotification();
1626 application.Render();
1629 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
1630 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
1634 int UtcDaliTapGestureDetectorTypeRegistry(void)
1636 TestApplication application;
1638 Actor actor = Actor::New();
1639 actor.SetSize(100.0f, 100.0f);
1640 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1641 Stage::GetCurrent().Add(actor);
1645 type = TypeRegistry::Get().GetTypeInfo( "TapGestureDetector" );
1646 DALI_TEST_CHECK( type );
1647 BaseHandle handle = type.CreateInstance();
1648 DALI_TEST_CHECK( handle );
1649 TapGestureDetector detector = TapGestureDetector::DownCast( handle );
1650 DALI_TEST_CHECK( detector );
1652 // Attach actor to detector
1654 GestureReceivedFunctor functor( data );
1655 detector.Attach(actor);
1657 // Connect to signal through type
1658 handle.ConnectSignal( &application, "tap-detected", functor );
1660 // Render and notify
1661 application.SendNotification();
1662 application.Render();
1665 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
1666 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
1667 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
1671 int UtcDaliTypeRegistryNamedType(void)
1673 TestApplication application;
1674 TypeRegistry typeRegistry = TypeRegistry::Get();
1676 // Create a normal actor
1677 BaseHandle actorHandle = typeRegistry.GetTypeInfo( "Actor" ).CreateInstance();
1678 DALI_TEST_CHECK( actorHandle );
1679 Actor actor( Actor::DownCast( actorHandle ) );
1680 DALI_TEST_CHECK( actor );
1681 unsigned int actorPropertyCount( actor.GetPropertyCount() );
1683 // Create Named Actor Type
1684 BaseHandle namedHandle = typeRegistry.GetTypeInfo( "MyNamedActor" ).CreateInstance();
1685 DALI_TEST_CHECK( namedHandle );
1686 Actor namedActor( Actor::DownCast( namedHandle ) );
1687 DALI_TEST_CHECK( namedActor );
1688 unsigned int namedActorPropertyCount( namedActor.GetPropertyCount() );
1690 DALI_TEST_CHECK( namedActorPropertyCount > actorPropertyCount );