2 * Copyright (c) 2014 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( true ) // requires touch
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 );
1085 // DALI_TEST_EQUALS( typeInfo.GetPropertyName( animatablePropertyIndex ), animatablePropertyName, TEST_LOCATION );
1087 // Check the animatable property index
1088 DALI_TEST_EQUALS( customActor.GetPropertyIndex( animatablePropertyName ), animatablePropertyIndex, TEST_LOCATION );
1090 // Check the animatable property type
1091 DALI_TEST_EQUALS( customActor.GetPropertyType( animatablePropertyIndex ), animatablePropertyType, TEST_LOCATION );
1093 // Check property count of type-info is 1
1094 Property::IndexContainer indices;
1095 typeInfo.GetPropertyIndices( indices );
1096 DALI_TEST_EQUALS( indices.size(), 1u, TEST_LOCATION );
1098 // Ensure indices returned from actor and customActor differ by three
1099 Actor actor = Actor::New();
1100 actor.GetPropertyIndices( indices );
1101 unsigned int actorIndices = indices.size();
1102 customActor.GetPropertyIndices( indices );
1103 unsigned int customActorIndices = indices.size();
1104 DALI_TEST_EQUALS( actorIndices + 1u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1109 int UtcDaliTypeRegistryAnimatablePropertyRegistrationN(void)
1111 TestApplication application;
1112 TypeRegistry typeRegistry = TypeRegistry::Get();
1114 // Attempt to register an animatable property type out-of-bounds index (less than)
1117 AnimatablePropertyRegistration property1( customType1, "anim-prop-name", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN );
1118 tet_result( TET_FAIL );
1120 catch ( DaliException& e )
1122 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1125 // Attempt to register an animatable property type out-of-bounds index (greater than)
1128 AnimatablePropertyRegistration property1( customType1, "anim-prop-name", ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN );
1129 tet_result( TET_FAIL );
1131 catch ( DaliException& e )
1133 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1140 /*******************************************************************************
1142 * Action through the base handle
1144 ******************************************************************************/
1145 int UtcDaliTypeRegistryActionViaBaseHandle(void)
1147 TestApplication application;
1151 type = TypeRegistry::Get().GetTypeInfo( "Actor" );
1152 DALI_TEST_CHECK( type );
1154 BaseHandle hdl = type.CreateInstance();
1155 DALI_TEST_CHECK( hdl );
1157 Actor a = Actor::DownCast(hdl);
1158 DALI_TEST_CHECK( a );
1160 a.SetVisible(false);
1162 application.SendNotification();
1163 application.Render(0);
1164 DALI_TEST_CHECK(!a.IsVisible());
1166 std::vector<Property::Value> attributes;
1168 DALI_TEST_CHECK(hdl.DoAction("show", attributes));
1170 application.SendNotification();
1171 application.Render(0);
1172 DALI_TEST_CHECK(a.IsVisible());
1174 DALI_TEST_CHECK(!hdl.DoAction("unknown-action", attributes));
1178 int UtcDaliPropertyRegistrationFunctions(void)
1180 TestApplication application;
1181 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 10;
1183 // Attempt to register a property without a setter
1186 PropertyRegistration property1( customType1, "prop-name", propertyIndex++, Property::BOOLEAN, NULL, &GetProperty );
1187 tet_result( TET_PASS );
1189 catch ( DaliException& e )
1191 tet_result( TET_FAIL );
1194 // Attempt to register a property without a getter
1197 PropertyRegistration property1( customType1, "prop-name", propertyIndex++, Property::BOOLEAN, NULL, NULL );
1198 tet_result( TET_FAIL );
1200 catch ( DaliException& e )
1202 DALI_TEST_ASSERT( e, "! \"GetProperty", TEST_LOCATION );
1207 int UtcDaliPropertyRegistrationAddSameIndex(void)
1209 TestApplication application;
1210 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 100;
1212 // Add one property with a valid property index
1213 PropertyRegistration property1( customType1, "prop-name", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
1215 // Attempt to add another property with the same index
1218 PropertyRegistration property2( customType1, "prop-name-2", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
1220 catch ( DaliException& e )
1222 DALI_TEST_ASSERT( e, "! \"Property index already added", TEST_LOCATION );
1225 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 100;
1227 // Add one property with a valid property index
1228 AnimatablePropertyRegistration property3( customType1, "anim-prop-name", animatablePropertyIndex, Property::BOOLEAN );
1230 // Attempt to add another property with the same index
1233 AnimatablePropertyRegistration property4( customType1, "anim-prop-name-2", animatablePropertyIndex, Property::BOOLEAN );
1235 catch ( DaliException& e )
1237 DALI_TEST_ASSERT( e, "! \"Property index already added", TEST_LOCATION );
1242 int UtcDaliPropertyRegistrationPropertyWritable(void)
1244 TestApplication application;
1245 int propertyIndex1 = PROPERTY_REGISTRATION_START_INDEX + 200;
1246 int propertyIndex2 = PROPERTY_REGISTRATION_START_INDEX + 201;
1248 // Add two properties, one with SetProperty, one without
1249 PropertyRegistration property1( customType1, "prop-name-readwrite", propertyIndex1, Property::BOOLEAN, &SetProperty, &GetProperty );
1250 PropertyRegistration property2( customType1, "prop-name-readonly", propertyIndex2, Property::BOOLEAN, NULL, &GetProperty );
1252 // Create custom-actor
1253 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
1254 DALI_TEST_CHECK( typeInfo );
1255 BaseHandle handle = typeInfo.CreateInstance();
1256 DALI_TEST_CHECK( handle );
1257 Actor customActor = Actor::DownCast( handle );
1258 DALI_TEST_CHECK( customActor );
1260 // Check whether properties are writable
1261 DALI_TEST_CHECK( customActor.IsPropertyWritable( propertyIndex1 ) );
1262 DALI_TEST_CHECK( ! customActor.IsPropertyWritable( propertyIndex2 ) );
1266 int UtcDaliPropertyRegistrationPropertyAnimatable(void)
1268 TestApplication application;
1269 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 400;
1270 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 400;
1272 // These properties are not animatable
1273 PropertyRegistration property1( customType1, "prop-name", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
1275 // These properties are animatable
1276 AnimatablePropertyRegistration property2( customType1, "anim-prop-name", animatablePropertyIndex, Property::BOOLEAN );
1278 // Create custom-actor
1279 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
1280 DALI_TEST_CHECK( typeInfo );
1281 BaseHandle handle = typeInfo.CreateInstance();
1282 DALI_TEST_CHECK( handle );
1283 Actor customActor = Actor::DownCast( handle );
1284 DALI_TEST_CHECK( customActor );
1286 // Check if animatable
1287 DALI_TEST_CHECK( ! customActor.IsPropertyAnimatable( propertyIndex ) );
1288 DALI_TEST_CHECK( customActor.IsPropertyAnimatable( animatablePropertyIndex ) );
1290 // Create another instance of custom-actor
1291 BaseHandle handle2 = typeInfo.CreateInstance();
1292 DALI_TEST_CHECK( handle2 );
1293 Actor customActor2 = Actor::DownCast( handle2 );
1294 DALI_TEST_CHECK( customActor2 );
1296 // Check if animatable
1297 DALI_TEST_CHECK( ! customActor2.IsPropertyAnimatable( propertyIndex ) );
1298 DALI_TEST_CHECK( customActor2.IsPropertyAnimatable( animatablePropertyIndex ) );
1302 int UtcDaliPropertyRegistrationInvalidGetAndSet(void)
1304 TestApplication application;
1305 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 2000;
1306 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2000;
1308 // Create custom-actor
1309 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
1310 DALI_TEST_CHECK( typeInfo );
1311 BaseHandle handle = typeInfo.CreateInstance();
1312 DALI_TEST_CHECK( handle );
1313 Actor customActor = Actor::DownCast( handle );
1314 DALI_TEST_CHECK( customActor );
1316 // Try to set an index that hasn't been added
1319 customActor.SetProperty( propertyIndex, true );
1320 tet_result( TET_FAIL );
1322 catch ( DaliException& e )
1324 DALI_TEST_ASSERT( e, "! \"Cannot find property index", TEST_LOCATION );
1329 customActor.SetProperty( animatablePropertyIndex, true );
1330 tet_result( TET_FAIL );
1332 catch ( DaliException& e )
1334 DALI_TEST_ASSERT( e, "! \"Cannot find property index", TEST_LOCATION );
1337 // Try to get an index that hasn't been added
1340 (void) customActor.GetProperty< bool >( propertyIndex );
1341 tet_result( TET_FAIL );
1343 catch ( DaliException& e )
1345 DALI_TEST_ASSERT( e, "! \"Cannot find property index", TEST_LOCATION );
1350 (void) customActor.GetProperty< bool >( animatablePropertyIndex );
1351 tet_result( TET_FAIL );
1353 catch ( DaliException& e )
1355 DALI_TEST_ASSERT( e, "! \"Cannot find property index", TEST_LOCATION );
1361 int UtcDaliLongPressGestureDetectorTypeRegistry(void)
1363 TestApplication application;
1365 Actor actor = Actor::New();
1366 actor.SetSize(100.0f, 100.0f);
1367 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1368 Stage::GetCurrent().Add(actor);
1372 type = TypeRegistry::Get().GetTypeInfo( "LongPressGestureDetector" );
1373 DALI_TEST_CHECK( type );
1374 BaseHandle handle = type.CreateInstance();
1375 DALI_TEST_CHECK( handle );
1376 LongPressGestureDetector detector = LongPressGestureDetector::DownCast( handle );
1377 DALI_TEST_CHECK( detector );
1379 // Attach actor to detector
1381 GestureReceivedFunctor functor( data );
1382 detector.Attach(actor);
1384 // Connect to signal through type
1385 handle.ConnectSignal( &application, "long-press-detected", functor );
1387 // Render and notify
1388 application.SendNotification();
1389 application.Render();
1392 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f)));
1393 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f)));
1394 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f)));
1395 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
1399 int UtcDaliPanGestureDetectorTypeRegistry(void)
1401 TestApplication application;
1403 Actor actor = Actor::New();
1404 actor.SetSize(100.0f, 100.0f);
1405 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1406 Stage::GetCurrent().Add(actor);
1410 type = TypeRegistry::Get().GetTypeInfo( "PanGestureDetector" );
1411 DALI_TEST_CHECK( type );
1412 BaseHandle handle = type.CreateInstance();
1413 DALI_TEST_CHECK( handle );
1414 PanGestureDetector detector = PanGestureDetector::DownCast( handle );
1415 DALI_TEST_CHECK( detector );
1417 // Attach actor to detector
1419 GestureReceivedFunctor functor( data );
1420 detector.Attach(actor);
1422 // Connect to signal through type
1423 handle.ConnectSignal( &application, "pan-detected", functor );
1425 // Render and notify
1426 application.SendNotification();
1427 application.Render();
1430 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1431 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1432 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1433 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
1437 int UtcDaliPinchGestureDetectorTypeRegistry(void)
1439 TestApplication application;
1441 Actor actor = Actor::New();
1442 actor.SetSize(100.0f, 100.0f);
1443 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1444 Stage::GetCurrent().Add(actor);
1448 type = TypeRegistry::Get().GetTypeInfo( "PinchGestureDetector" );
1449 DALI_TEST_CHECK( type );
1450 BaseHandle handle = type.CreateInstance();
1451 DALI_TEST_CHECK( handle );
1452 PinchGestureDetector detector = PinchGestureDetector::DownCast( handle );
1453 DALI_TEST_CHECK( detector );
1455 // Attach actor to detector
1457 GestureReceivedFunctor functor( data );
1458 detector.Attach(actor);
1460 // Connect to signal through type
1461 handle.ConnectSignal( &application, "pinch-detected", functor );
1463 // Render and notify
1464 application.SendNotification();
1465 application.Render();
1468 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
1469 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
1473 int UtcDaliTapGestureDetectorTypeRegistry(void)
1475 TestApplication application;
1477 Actor actor = Actor::New();
1478 actor.SetSize(100.0f, 100.0f);
1479 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1480 Stage::GetCurrent().Add(actor);
1484 type = TypeRegistry::Get().GetTypeInfo( "TapGestureDetector" );
1485 DALI_TEST_CHECK( type );
1486 BaseHandle handle = type.CreateInstance();
1487 DALI_TEST_CHECK( handle );
1488 TapGestureDetector detector = TapGestureDetector::DownCast( handle );
1489 DALI_TEST_CHECK( detector );
1491 // Attach actor to detector
1493 GestureReceivedFunctor functor( data );
1494 detector.Attach(actor);
1496 // Connect to signal through type
1497 handle.ConnectSignal( &application, "tap-detected", functor );
1499 // Render and notify
1500 application.SendNotification();
1501 application.Render();
1504 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
1505 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
1506 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
1510 int UtcDaliTypeRegistryNamedType(void)
1512 TestApplication application;
1513 TypeRegistry typeRegistry = TypeRegistry::Get();
1515 // Create a normal actor
1516 BaseHandle actorHandle = typeRegistry.GetTypeInfo( "Actor" ).CreateInstance();
1517 DALI_TEST_CHECK( actorHandle );
1518 Actor actor( Actor::DownCast( actorHandle ) );
1519 DALI_TEST_CHECK( actor );
1520 unsigned int actorPropertyCount( actor.GetPropertyCount() );
1522 // Create Named Actor Type
1523 BaseHandle namedHandle = typeRegistry.GetTypeInfo( "MyNamedActor" ).CreateInstance();
1524 DALI_TEST_CHECK( namedHandle );
1525 Actor namedActor( Actor::DownCast( namedHandle ) );
1526 DALI_TEST_CHECK( namedActor );
1527 unsigned int namedActorPropertyCount( namedActor.GetPropertyCount() );
1529 DALI_TEST_CHECK( namedActorPropertyCount > actorPropertyCount );