2 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <dali/public-api/dali-core.h>
22 #include <dali-test-suite-utils.h>
23 #include <dali/internal/event/common/type-info-impl.h>
24 #include <dali/integration-api/events/touch-event-integ.h>
25 #include <dali/integration-api/events/hover-event-integ.h>
26 #include <dali/devel-api/events/rotation-gesture-detector.h>
34 // Stores data that is populated in the callback and will be read by the Test cases
38 : functorCalled( false ),
39 voidFunctorCalled( false ),
40 receivedGesture( Gesture::Clear ),
46 functorCalled = false;
47 voidFunctorCalled = false;
49 receivedGesture.numberOfTouches = 0u;
50 receivedGesture.screenPoint = Vector2(0.0f, 0.0f);
51 receivedGesture.localPoint = Vector2(0.0f, 0.0f);
57 bool voidFunctorCalled;
58 LongPressGesture receivedGesture;
62 // Functor that sets the data when called
63 struct GestureReceivedFunctor
65 GestureReceivedFunctor(SignalData& data) : signalData(data) { }
67 void operator()(Actor actor, LongPressGesture longPress)
69 signalData.functorCalled = true;
70 signalData.receivedGesture = longPress;
71 signalData.pressedActor = actor;
76 signalData.voidFunctorCalled = true;
79 SignalData& signalData;
83 // Create function as Init function called
85 static bool CreateCustomInitCalled = false;
86 BaseHandle CreateCustomInit(void)
88 CreateCustomInitCalled = true;
92 static bool CreateCustomNamedInitCalled = false;
93 BaseHandle CreateCustomNamedInit(void)
95 CreateCustomNamedInitCalled = true;
99 const std::string scriptedName("PopupStyle");
100 static TypeRegistration scriptedType( scriptedName, typeid(Dali::CustomActor), CreateCustomNamedInit );
102 // Property Registration
103 bool setPropertyCalled = false;
104 bool getPropertyCalled = false;
105 void SetProperty( BaseObject* object, Property::Index propertyIndex, const Property::Value& value )
107 setPropertyCalled = true;
109 Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex )
111 getPropertyCalled = true;
112 return Property::Value( true );
117 /*******************************************************************************
121 ******************************************************************************/
124 struct MyTestCustomActor : public CustomActorImpl
126 typedef Signal< void ()> SignalType;
127 typedef Signal< void (float)> SignalTypeFloat;
129 MyTestCustomActor() : CustomActorImpl( ActorFlags( REQUIRES_TOUCH_EVENTS ) )
132 virtual ~MyTestCustomActor()
135 void ResetCallStack()
139 // From CustomActorImpl
140 virtual void OnStageConnection( int depth )
143 virtual void OnStageDisconnection()
146 virtual void OnChildAdd(Actor& child)
149 virtual void OnChildRemove(Actor& child)
152 virtual void OnSizeSet(const Vector3& targetSize)
155 virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize)
158 virtual bool OnTouchEvent(const TouchEvent& event)
162 virtual bool OnHoverEvent(const HoverEvent& event)
166 virtual bool OnWheelEvent(const WheelEvent& event)
170 virtual bool OnKeyEvent(const KeyEvent& event)
174 virtual void OnKeyInputFocusGained()
177 virtual void OnKeyInputFocusLost()
180 virtual Vector3 GetNaturalSize()
182 return Vector3( 0.0f, 0.0f, 0.0f );
185 virtual float GetHeightForWidth( float width )
190 virtual float GetWidthForHeight( float height )
195 virtual void OnRelayout( const Vector2& size, RelayoutContainer& container )
199 virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
203 virtual void OnCalculateRelayoutSize( Dimension::Type dimension )
207 virtual float CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension )
212 virtual void OnLayoutNegotiated( float size, Dimension::Type dimension )
216 virtual bool RelayoutDependentOnChildren( Dimension::Type dimension = Dimension::ALL_DIMENSIONS )
228 class MyTestCustomActor : public CustomActor
232 typedef Signal< void ()> SignalType;
233 typedef Signal< void (float)> SignalTypeFloat;
239 static MyTestCustomActor New()
241 Impl::MyTestCustomActor* p = new Impl::MyTestCustomActor;
242 return MyTestCustomActor( *p ); // takes ownership
245 virtual ~MyTestCustomActor()
249 static MyTestCustomActor DownCast( BaseHandle handle )
251 MyTestCustomActor result;
253 CustomActor custom = Dali::CustomActor::DownCast( handle );
256 CustomActorImpl& customImpl = custom.GetImplementation();
258 Impl::MyTestCustomActor* impl = dynamic_cast<Impl::MyTestCustomActor*>(&customImpl);
262 result = MyTestCustomActor(customImpl.GetOwner());
269 SignalType& GetCustomSignal()
271 Dali::RefObject& obj = GetImplementation();
272 return static_cast<Impl::MyTestCustomActor&>( obj ).mSignal;
277 MyTestCustomActor(Internal::CustomActor* internal)
278 : CustomActor(internal)
282 MyTestCustomActor( Impl::MyTestCustomActor& impl )
283 : CustomActor( impl )
289 class MyTestCustomActor2 : public CustomActor
297 P1=Dali::PROPERTY_REGISTRATION_START_INDEX,
307 static MyTestCustomActor2 New()
309 return MyTestCustomActor2(); // takes ownership
312 virtual ~MyTestCustomActor2()
316 static MyTestCustomActor2 DownCast( BaseHandle handle )
318 MyTestCustomActor2 result;
320 CustomActor custom = Dali::CustomActor::DownCast( handle );
323 CustomActorImpl& customImpl = custom.GetImplementation();
325 Impl::MyTestCustomActor* impl = dynamic_cast<Impl::MyTestCustomActor*>(&customImpl);
329 result = MyTestCustomActor2(customImpl.GetOwner());
338 MyTestCustomActor2(Internal::CustomActor* internal)
339 : CustomActor(internal)
343 MyTestCustomActor2( Impl::MyTestCustomActor& impl )
344 : CustomActor( impl )
349 static TypeRegistration customTypeInit( typeid(MyTestCustomActor2), typeid(Dali::CustomActor), CreateCustomInit, true );
351 PropertyRegistration P1( customTypeInit, "propertyOne", MyTestCustomActor2::Property::P1, Property::INTEGER, &SetProperty, &GetProperty );
352 PropertyRegistration P2( customTypeInit, "propertyTwo", MyTestCustomActor2::Property::P2, Property::STRING, &SetProperty, &GetProperty );
355 class MyTestCustomActor3 : public CustomActor
362 static MyTestCustomActor3 New()
364 return MyTestCustomActor3(); // takes ownership
367 virtual ~MyTestCustomActor3()
371 static MyTestCustomActor3 DownCast( BaseHandle handle )
373 MyTestCustomActor3 result;
375 CustomActor custom = Dali::CustomActor::DownCast( handle );
378 CustomActorImpl& customImpl = custom.GetImplementation();
380 Impl::MyTestCustomActor* impl = dynamic_cast<Impl::MyTestCustomActor*>(&customImpl);
384 result = MyTestCustomActor3(customImpl.GetOwner());
393 MyTestCustomActor3(Internal::CustomActor* internal)
394 : CustomActor(internal)
398 MyTestCustomActor3( Impl::MyTestCustomActor& impl )
399 : CustomActor( impl )
404 static TypeRegistration customTypeBadInit( typeid(MyTestCustomActor3), typeid(Dali::CustomActor), NULL, false );
406 BaseHandle CreateCustom(void)
408 return MyTestCustomActor::New();
411 static std::string lastSignalConnectionCustom;
413 bool DoConnectSignalCustom( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
415 lastSignalConnectionCustom = signalName;
417 bool connected( true );
419 Dali::BaseHandle handle(object);
420 MyTestCustomActor customActor = MyTestCustomActor::DownCast(handle);
422 if( "sig1" == signalName )
424 customActor.GetCustomSignal().Connect( tracker, functor );
428 // signalName does not match any signal
435 bool DoConnectSignalCustomFailure( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
437 lastSignalConnectionCustom = "failed";
439 return false; // This is supposed to fail
442 struct CustomTestFunctor
446 ++mTotalInstanceCount;
447 ++mCurrentInstanceCount;
450 CustomTestFunctor( const CustomTestFunctor& copyMe )
452 ++mTotalInstanceCount;
453 ++mCurrentInstanceCount;
458 --mCurrentInstanceCount;
466 static int mTotalInstanceCount;
467 static int mCurrentInstanceCount;
468 static int mCallbackCount;
471 int CustomTestFunctor::mTotalInstanceCount = 0;
472 int CustomTestFunctor::mCurrentInstanceCount = 0;
473 int CustomTestFunctor::mCallbackCount = 0;
475 static void ResetFunctorCounts()
477 CustomTestFunctor::mTotalInstanceCount = 0;
478 CustomTestFunctor::mCurrentInstanceCount = 0;
479 CustomTestFunctor::mCallbackCount = 0;
482 static std::string lastActionCustom;
483 bool DoActionCustom(BaseObject* object, const std::string& actionName, const Property::Map& /*attributes*/)
485 lastActionCustom = actionName;
489 // Custom type registration
490 static TypeRegistration customType1( typeid(MyTestCustomActor), typeid(Dali::CustomActor), CreateCustom );
493 static SignalConnectorType customSignalConnector1( customType1, "sig1", DoConnectSignalCustom );
494 static SignalConnectorType customSignalConnector2( customType1, "sig2", DoConnectSignalCustomFailure );
495 static const int TEST_SIGNAL_COUNT = 2;
498 static TypeAction customAction1( customType1, "act1", DoActionCustom);
499 static const int TEST_ACTION_COUNT = 1;
501 class TestConnectionTracker : public ConnectionTracker
505 TestConnectionTracker()
510 BaseHandle CreateNamedActorType()
512 Actor actor = Actor::New();
513 actor.SetName( "NamedActor" );
517 TypeRegistration namedActorType( "MyNamedActor", typeid(Dali::Actor), CreateNamedActorType );
518 PropertyRegistration namedActorPropertyOne( namedActorType, "propName", PROPERTY_REGISTRATION_START_INDEX, Property::BOOLEAN, &SetProperty, &GetProperty );
520 } // Anonymous namespace
522 // Note: No negative test case for UtcDaliTypeRegistryGet can be implemented.
523 int UtcDaliTypeRegistryGetP(void)
525 TestApplication application;
527 TypeRegistry registry = TypeRegistry::Get();
528 DALI_TEST_CHECK( registry );
533 // Note: No negative test case for UtcDaliTypeRegistryConstructor can be implemented.
534 int UtcDaliTypeRegistryConstructorP(void)
536 TestApplication application;
538 TypeRegistry registry;
539 DALI_TEST_CHECK( !registry );
543 // Note: No negative test case for UtcDaliTypeRegistryCopyConstructor can be implemented.
544 int UtcDaliTypeRegistryCopyConstructorP(void)
546 TestApplication application;
548 TypeRegistry registry = TypeRegistry::Get();
549 DALI_TEST_CHECK( registry );
551 TypeRegistry copy( registry );
552 DALI_TEST_CHECK( copy );
554 DALI_TEST_CHECK( registry.GetTypeInfo( "Actor" ).GetName() == copy.GetTypeInfo( "Actor" ).GetName() );
559 // Note: No negative test case for UtcDaliTypeRegistryAssignmentOperator can be implemented.
560 int UtcDaliTypeRegistryAssignmentOperatorP(void)
562 TestApplication application;
564 TypeRegistry registry = TypeRegistry::Get();
565 DALI_TEST_CHECK( registry );
567 TypeRegistry copy = registry;
568 DALI_TEST_CHECK( copy );
569 DALI_TEST_CHECK( registry == copy );
571 DALI_TEST_CHECK( registry.GetTypeInfo( "Actor" ).GetName() == copy.GetTypeInfo( "Actor" ).GetName() );
576 int UtcDaliTypeRegistryAssignP(void)
578 TestApplication application;
580 TypeRegistry registry = TypeRegistry::Get();
581 TypeRegistry registry2;
582 registry2 = registry;
583 DALI_TEST_CHECK( registry2 );
585 DALI_TEST_CHECK( registry2.GetTypeInfo( "Actor" ).GetName() == registry2.GetTypeInfo( "Actor" ).GetName() );
590 int UtcDaliTypeRegistryGetTypeInfoFromTypeNameP(void)
592 TestApplication application;
594 TypeRegistry registry = TypeRegistry::Get();
599 type = registry.GetTypeInfo( "CameraActor" );
600 DALI_TEST_CHECK( type );
601 CameraActor ca = CameraActor::DownCast(type.CreateInstance());
602 DALI_TEST_CHECK( ca );
603 Stage::GetCurrent().Add( ca );
604 application.Render();
607 type = registry.GetTypeInfo( "Animation" );
608 DALI_TEST_CHECK( type );
609 Animation an = Animation::DownCast(type.CreateInstance());
610 DALI_TEST_CHECK( an );
612 application.Render();
617 int UtcDaliTypeRegistryGetTypeInfoFromTypeNameN(void)
619 TestApplication application;
621 TypeRegistry registry = TypeRegistry::Get();
625 type = registry.GetTypeInfo( "MyDummyActor" );
626 DALI_TEST_CHECK( !type );
631 int UtcDaliTypeRegistryGetTypeInfoFromTypeIdP(void)
633 TypeInfo named_type = TypeRegistry::Get().GetTypeInfo( "CameraActor" );
634 TypeInfo typeinfo_type = TypeRegistry::Get().GetTypeInfo( typeid(Dali::CameraActor) );
636 DALI_TEST_CHECK( named_type );
637 DALI_TEST_CHECK( typeinfo_type );
639 // Check named and typeid are equivalent
640 DALI_TEST_CHECK( named_type == typeinfo_type );
642 DALI_TEST_CHECK( named_type.GetName() == typeinfo_type.GetName() );
643 DALI_TEST_CHECK( named_type.GetBaseName() == typeinfo_type.GetBaseName() );
648 int UtcDaliTypeRegistryGetTypeInfoFromTypeIdN(void)
650 TestApplication application;
651 TypeRegistry typeRegistry = TypeRegistry::Get();
653 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(Vector2) );
654 DALI_TEST_CHECK( !typeInfo );
659 int UtcDaliTypeRegistryGetTypeNameCountP(void)
661 TestApplication application;
662 TypeRegistry typeRegistry = TypeRegistry::Get();
665 for(size_t i = 0; i < typeRegistry.GetTypeNameCount(); i++)
667 type = typeRegistry.GetTypeInfo( typeRegistry.GetTypeName(i) );
668 DALI_TEST_CHECK( type );
675 int UtcDaliTypeRegistryGetTypeNamesP(void)
677 TestApplication application;
678 TypeRegistry typeRegistry = TypeRegistry::Get();
681 for(size_t i = 0; i < typeRegistry.GetTypeNameCount(); i++)
683 type = typeRegistry.GetTypeInfo( typeRegistry.GetTypeName(i) );
684 DALI_TEST_CHECK( type );
691 // Note: No negative test case for UtcDaliTypeRegistryTypeRegistration can be implemented.
692 int UtcDaliTypeRegistryTypeRegistrationNotCallingCreateOnInitP(void)
694 ResetFunctorCounts();
696 TestApplication application;
698 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
699 DALI_TEST_CHECK( type );
701 TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( "CustomActor" );
702 DALI_TEST_CHECK( baseType );
704 BaseHandle handle = type.CreateInstance();
705 DALI_TEST_CHECK( handle );
707 MyTestCustomActor customHandle = MyTestCustomActor::DownCast( handle );
708 DALI_TEST_CHECK( customHandle );
710 DALI_TEST_EQUALS( type.GetActionCount(), TEST_ACTION_COUNT + baseType.GetActionCount(), TEST_LOCATION );
712 DALI_TEST_EQUALS( type.GetSignalCount(), TEST_SIGNAL_COUNT + baseType.GetSignalCount(), TEST_LOCATION );
715 TestConnectionTracker tracker;
717 bool connected = handle.ConnectSignal( &tracker, "sig1", CustomTestFunctor() );
718 DALI_TEST_EQUALS( connected, true, TEST_LOCATION );
719 DALI_TEST_CHECK( lastSignalConnectionCustom == "sig1" );
720 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
721 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION );
723 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
724 customHandle.GetCustomSignal().Emit();
725 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION );
726 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
727 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION );
729 // tracker should automatically disconnect here
730 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
731 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
733 // Test that functor is disconnected
734 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION );
735 customHandle.GetCustomSignal().Emit();
736 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1/*not incremented*/, TEST_LOCATION );
737 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
738 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
740 Property::Map attributes;
741 handle.DoAction("act1", attributes);
742 DALI_TEST_CHECK( lastActionCustom == "act1" );
746 // Note: No negative test case for UtcDaliTypeRegistryTypeRegistration can be implemented.
747 int UtcDaliTypeRegistryTypeRegistrationCallingCreateOnInitP(void)
749 TestApplication application;
751 DALI_TEST_CHECK( "MyTestCustomActor2" == customTypeInit.RegisteredName() );
753 DALI_TEST_CHECK( true == CreateCustomInitCalled );
754 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor2" );
755 DALI_TEST_CHECK( type );
759 // Note: No negative test case for UtcDaliTypeRegistryTypeRegistration can be implemented.
760 int UtcDaliTypeRegistryTypeRegistrationForNamedTypeP(void)
762 TestApplication application;
764 // Create Named Actor Type
765 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyNamedActor" );
766 DALI_TEST_CHECK( type );
768 BaseHandle namedHandle = type.CreateInstance();
769 DALI_TEST_CHECK( namedHandle );
770 Actor namedActor( Actor::DownCast( namedHandle ) );
771 DALI_TEST_CHECK( namedActor );
773 DALI_TEST_CHECK( namedActor.GetName() == "NamedActor" );
774 DALI_TEST_CHECK( type.GetName() == "MyNamedActor" );
775 DALI_TEST_CHECK( type.GetBaseName() == "Actor" );
780 int UtcDaliTypeRegistryRegisteredNameP(void)
782 TestApplication application;
784 DALI_TEST_CHECK( scriptedName == scriptedType.RegisteredName() );
786 TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( scriptedName );
787 DALI_TEST_CHECK( baseType );
789 BaseHandle handle = baseType.CreateInstance();
791 DALI_TEST_CHECK( true == CreateCustomNamedInitCalled );
792 TypeInfo type = TypeRegistry::Get().GetTypeInfo( scriptedName );
793 DALI_TEST_CHECK( type );
798 int UtcDaliTypeRegistryRegisteredNameN(void)
800 TestApplication application;
802 DALI_TEST_CHECK( scriptedName == scriptedType.RegisteredName() );
804 TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( scriptedName );
805 DALI_TEST_CHECK( baseType );
807 // should cause an assert because we're registering same type twice
808 // once statically at the start of this file, then again now
811 TypeRegistration scriptedType( scriptedName, typeid(Dali::CustomActor), CreateCustomNamedInit );
812 tet_result( TET_FAIL );
814 catch ( DaliException& e )
816 DALI_TEST_ASSERT( e, "Duplicate type name in Type Registration", TEST_LOCATION );
823 int UtcDaliTypeRegistrySignalConnectorTypeP(void)
825 ResetFunctorCounts();
827 TestApplication application;
829 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
830 DALI_TEST_CHECK( type );
832 BaseHandle handle = type.CreateInstance();
833 DALI_TEST_CHECK( handle );
835 MyTestCustomActor customHandle = MyTestCustomActor::DownCast( handle );
836 DALI_TEST_CHECK( customHandle );
839 TestConnectionTracker tracker;
841 bool connected = handle.ConnectSignal( &tracker, "sig1", CustomTestFunctor() );
842 DALI_TEST_EQUALS( connected, true, TEST_LOCATION );
843 DALI_TEST_CHECK( lastSignalConnectionCustom == "sig1" );
844 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
845 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION );
847 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
848 customHandle.GetCustomSignal().Emit();
849 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION );
850 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
851 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION );
853 // tracker should automatically disconnect here
854 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
855 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
857 // Test that functor is disconnected
858 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION );
859 customHandle.GetCustomSignal().Emit();
860 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1/*not incremented*/, TEST_LOCATION );
861 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
862 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
867 int UtcDaliTypeRegistrySignalConnectorTypeN(void)
869 // Test what happens when signal connnector (DoConnectSignalFailure method) returns false
871 ResetFunctorCounts();
873 TestApplication application;
875 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
876 DALI_TEST_CHECK( type );
878 TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( "CustomActor" );
879 DALI_TEST_CHECK( baseType );
881 BaseHandle handle = type.CreateInstance();
882 DALI_TEST_CHECK( handle );
884 MyTestCustomActor customHandle = MyTestCustomActor::DownCast( handle );
885 DALI_TEST_CHECK( customHandle );
887 DALI_TEST_EQUALS( type.GetActionCount(), TEST_ACTION_COUNT + baseType.GetActionCount(), TEST_LOCATION );
889 DALI_TEST_EQUALS( type.GetSignalCount(), TEST_SIGNAL_COUNT + baseType.GetSignalCount(), TEST_LOCATION );
892 TestConnectionTracker tracker;
894 bool connected = handle.ConnectSignal( &tracker, "sig2", CustomTestFunctor() );
895 DALI_TEST_EQUALS( connected, false/*This is supposed to fail*/, TEST_LOCATION );
896 DALI_TEST_CHECK( lastSignalConnectionCustom == "failed" );
897 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
898 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0/*deleted along with FunctorDelegate*/, TEST_LOCATION );
901 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
902 customHandle.GetCustomSignal().Emit();
903 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0/*never called*/, TEST_LOCATION );
905 // tracker should have nothing to disconnect here
908 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
909 customHandle.GetCustomSignal().Emit();
910 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0/*never called*/, TEST_LOCATION );
914 int UtcDaliTypeRegistryTypeActionP(void)
916 ResetFunctorCounts();
918 TestApplication application;
920 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
921 DALI_TEST_CHECK( type );
923 BaseHandle handle = type.CreateInstance();
924 DALI_TEST_CHECK( handle );
926 Property::Map attributes;
927 DALI_TEST_CHECK( handle.DoAction("act1", attributes) );
928 DALI_TEST_CHECK( lastActionCustom == "act1" );
933 int UtcDaliTypeRegistryTypeActionN(void)
935 ResetFunctorCounts();
937 TestApplication application;
939 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
940 DALI_TEST_CHECK( type );
942 BaseHandle handle = type.CreateInstance();
943 DALI_TEST_CHECK( handle );
945 Property::Map attributes;
946 DALI_TEST_CHECK( !handle.DoAction( "unknownAction", attributes ) );
951 int UtcDaliTypeRegistryPropertyRegistrationP(void)
953 TestApplication application;
954 TypeRegistry typeRegistry = TypeRegistry::Get();
956 // Check property count before property registration
957 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
958 DALI_TEST_CHECK( typeInfo );
959 BaseHandle handle = typeInfo.CreateInstance();
960 DALI_TEST_CHECK( handle );
961 Actor customActor = Actor::DownCast( handle );
962 DALI_TEST_CHECK( customActor );
963 unsigned int initialPropertyCount( customActor.GetPropertyCount() );
965 std::string propertyName( "prop1" );
966 int propertyIndex( PROPERTY_REGISTRATION_START_INDEX );
967 Property::Type propertyType( Property::BOOLEAN );
968 PropertyRegistration property1( customType1, propertyName, propertyIndex, propertyType, &SetProperty, &GetProperty );
970 // Check property count after registration
971 unsigned int postRegistrationPropertyCount( customActor.GetPropertyCount() );
972 DALI_TEST_EQUALS( initialPropertyCount + 1u, postRegistrationPropertyCount, TEST_LOCATION );
974 // Add custom property and check property count
975 customActor.RegisterProperty( "customProp1", true );
976 unsigned int customPropertyCount( customActor.GetPropertyCount() );
977 DALI_TEST_EQUALS( postRegistrationPropertyCount + 1u, customPropertyCount, TEST_LOCATION );
979 // Set the property, ensure SetProperty called
980 DALI_TEST_CHECK( !setPropertyCalled );
981 customActor.SetProperty( propertyIndex, false );
982 DALI_TEST_CHECK( setPropertyCalled );
984 // Get the property, ensure GetProperty called
985 DALI_TEST_CHECK( !getPropertyCalled );
986 (void)customActor.GetProperty< bool >( propertyIndex );
987 DALI_TEST_CHECK( getPropertyCalled );
989 // Get the property using GetCurrentProperty and ensure GetProperty is called
990 getPropertyCalled = false;
991 DALI_TEST_CHECK( !getPropertyCalled );
992 customActor.GetCurrentProperty< bool >( propertyIndex );
993 DALI_TEST_CHECK( getPropertyCalled );
995 // Check the property name
996 DALI_TEST_EQUALS( customActor.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
997 DALI_TEST_EQUALS( typeInfo.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
999 // Check the property index
1000 DALI_TEST_EQUALS( customActor.GetPropertyIndex( propertyName ), propertyIndex, TEST_LOCATION );
1002 // Check the property type
1003 DALI_TEST_EQUALS( customActor.GetPropertyType( propertyIndex ), propertyType, TEST_LOCATION );
1005 // Check property count of type-info is 1
1006 Property::IndexContainer indices;
1007 typeInfo.GetPropertyIndices( indices );
1009 size_t typePropertyCount = typeInfo.GetPropertyCount();
1010 DALI_TEST_EQUALS( indices.Size(), Actor::New().GetPropertyCount() + 1u, TEST_LOCATION );
1011 DALI_TEST_EQUALS( indices.Size(), typePropertyCount, TEST_LOCATION );
1013 // Ensure indices returned from actor and customActor differ by two
1014 Actor actor = Actor::New();
1015 actor.GetPropertyIndices( indices );
1016 unsigned int actorIndices = indices.Size();
1017 customActor.GetPropertyIndices( indices );
1018 unsigned int customActorIndices = indices.Size();
1019 DALI_TEST_EQUALS( actorIndices + 2u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1023 int UtcDaliTypeRegistryPropertyRegistrationN(void)
1025 TestApplication application;
1026 TypeRegistry typeRegistry = TypeRegistry::Get();
1028 // Attempt to register a property type out-of-bounds index (less than)
1031 PropertyRegistration property1( customType1, "propName", PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN, &SetProperty, &GetProperty );
1032 tet_result( TET_FAIL );
1034 catch ( DaliException& e )
1036 DALI_TEST_ASSERT( e, "( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1039 // Attempt to register a property type out-of-bounds index (greater than)
1042 PropertyRegistration property1( customType1, "propName", PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN, &SetProperty, &GetProperty );
1043 tet_result( TET_FAIL );
1045 catch ( DaliException& e )
1047 DALI_TEST_ASSERT( e, "( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1053 int UtcDaliTypeRegistryAnimatablePropertyRegistrationP(void)
1055 TestApplication application;
1056 TypeRegistry typeRegistry = TypeRegistry::Get();
1058 // Check property count before property registration
1059 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1060 DALI_TEST_CHECK( typeInfo );
1061 BaseHandle handle = typeInfo.CreateInstance();
1062 DALI_TEST_CHECK( handle );
1063 Actor customActor = Actor::DownCast( handle );
1064 DALI_TEST_CHECK( customActor );
1065 Stage::GetCurrent().Add(customActor);
1067 unsigned int customPropertyCount( customActor.GetPropertyCount() );
1069 // Register animatable property
1070 std::string animatablePropertyName( "animatableProp1" );
1071 int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1072 Property::Type animatablePropertyType( Property::FLOAT );
1073 AnimatablePropertyRegistration animatableProperty( customType1, animatablePropertyName, animatablePropertyIndex, animatablePropertyType );
1075 // Check property count after registration
1076 DALI_TEST_EQUALS( customPropertyCount + 1u, customActor.GetPropertyCount(), TEST_LOCATION );
1078 // Set the animatable property value
1079 customActor.SetProperty( animatablePropertyIndex, 25.0f );
1081 // Render and notify
1082 application.SendNotification();
1083 application.Render();
1085 // Check the animatable property value
1086 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 25.f, TEST_LOCATION );
1088 // Check the animatable property name
1089 DALI_TEST_EQUALS( customActor.GetPropertyName( animatablePropertyIndex ), animatablePropertyName, TEST_LOCATION );
1091 // Check the animatable property index
1092 DALI_TEST_EQUALS( customActor.GetPropertyIndex( animatablePropertyName ), animatablePropertyIndex, TEST_LOCATION );
1094 // Check the animatable property type
1095 DALI_TEST_EQUALS( customActor.GetPropertyType( animatablePropertyIndex ), animatablePropertyType, TEST_LOCATION );
1097 // Check property count of type-info is 1
1098 Property::IndexContainer indices;
1099 typeInfo.GetPropertyIndices( indices );
1100 DALI_TEST_EQUALS( indices.Size(), customActor.GetPropertyCount(), TEST_LOCATION );
1102 // Ensure indices returned from actor and customActor differ by one
1103 Actor actor = Actor::New();
1104 actor.GetPropertyIndices( indices );
1105 unsigned int actorIndices = indices.Size();
1106 customActor.GetPropertyIndices( indices );
1107 unsigned int customActorIndices = indices.Size();
1108 DALI_TEST_EQUALS( actorIndices + 1u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1110 // check that the property is animatable
1111 Animation animation = Animation::New(0.2f);
1112 animation.AnimateTo( Property( customActor, animatablePropertyIndex ), 15.f, AlphaFunction::LINEAR );
1115 // Target value should change straight away
1116 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 15.0f, TEST_LOCATION );
1118 // Render and notify, animation play for 0.05 seconds
1119 application.SendNotification();
1120 application.Render(50);
1121 DALI_TEST_EQUALS( 0.25f, animation.GetCurrentProgress(), TEST_LOCATION );
1122 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 22.5f, TEST_LOCATION );
1124 // Render and notify, animation play for another 0.1 seconds
1125 application.SendNotification();
1126 application.Render(100);
1127 DALI_TEST_EQUALS( 0.75f, animation.GetCurrentProgress(), TEST_LOCATION );
1128 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 17.5f, TEST_LOCATION );
1133 int UtcDaliTypeRegistryAnimatablePropertyRegistrationN(void)
1135 TestApplication application;
1136 TypeRegistry typeRegistry = TypeRegistry::Get();
1138 // Attempt to register an animatable property type out-of-bounds index (less than)
1141 AnimatablePropertyRegistration property1( customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN );
1142 tet_result( TET_FAIL );
1144 catch ( DaliException& e )
1146 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1149 // Attempt to register an animatable property type out-of-bounds index (greater than)
1152 AnimatablePropertyRegistration property1( customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN );
1153 tet_result( TET_FAIL );
1155 catch ( DaliException& e )
1157 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1163 int UtcDaliTypeRegistryAnimatablePropertyRegistrationWithDefaultP(void)
1165 TestApplication application;
1166 TypeRegistry typeRegistry = TypeRegistry::Get();
1168 // Check property count before property registration
1169 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1170 DALI_TEST_CHECK( typeInfo );
1171 BaseHandle handle = typeInfo.CreateInstance();
1172 DALI_TEST_CHECK( handle );
1173 Actor customActor = Actor::DownCast( handle );
1174 DALI_TEST_CHECK( customActor );
1175 Stage::GetCurrent().Add(customActor);
1177 unsigned int customPropertyCount( customActor.GetPropertyCount() );
1179 // Register animatable property
1180 std::string animatablePropertyName( "animatableProp1" );
1181 int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1182 AnimatablePropertyRegistration animatableProperty1( customType1, animatablePropertyName, animatablePropertyIndex, 10.f );
1184 // Check property count after registration
1185 DALI_TEST_EQUALS( customPropertyCount + 1u, customActor.GetPropertyCount(), TEST_LOCATION );
1187 // Render and notify
1188 application.SendNotification();
1189 application.Render();
1191 // Check the animatable property value
1192 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 10.f, TEST_LOCATION );
1194 // Check the animatable property name
1195 DALI_TEST_EQUALS( customActor.GetPropertyName( animatablePropertyIndex ), animatablePropertyName, TEST_LOCATION );
1197 // Check the animatable property index
1198 DALI_TEST_EQUALS( customActor.GetPropertyIndex( animatablePropertyName ), animatablePropertyIndex, TEST_LOCATION );
1200 // Check the animatable property type
1201 DALI_TEST_EQUALS( customActor.GetPropertyType( animatablePropertyIndex ), Property::FLOAT, TEST_LOCATION );
1203 // Check property count of type-info
1204 Property::IndexContainer indices;
1205 typeInfo.GetPropertyIndices( indices );
1206 DALI_TEST_EQUALS( indices.Size(), customActor.GetPropertyCount(), TEST_LOCATION );
1208 // Ensure indices returned from actor and customActor differ by one
1209 Actor actor = Actor::New();
1210 actor.GetPropertyIndices( indices );
1211 unsigned int actorIndices = indices.Size();
1212 customActor.GetPropertyIndices( indices );
1213 unsigned int customActorIndices = indices.Size();
1214 DALI_TEST_EQUALS( actorIndices + 1u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1216 // check that the property is animatable
1217 Animation animation = Animation::New(0.2f);
1218 animation.AnimateTo( Property( customActor, animatablePropertyIndex ), 20.f, AlphaFunction::LINEAR );
1221 // Target value should change straight away
1222 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 20.0f, TEST_LOCATION );
1224 // Render and notify, animation play for 0.05 seconds
1225 application.SendNotification();
1226 application.Render(50);
1227 DALI_TEST_EQUALS( 0.25f, animation.GetCurrentProgress(), TEST_LOCATION );
1228 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 12.5f, TEST_LOCATION );
1230 // Render and notify, animation play for another 0.1 seconds
1231 application.SendNotification();
1232 application.Render(100);
1233 DALI_TEST_EQUALS( 0.75f, animation.GetCurrentProgress(), TEST_LOCATION );
1234 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 17.5f, TEST_LOCATION );
1239 int UtcDaliTypeRegistryAnimatablePropertyRegistrationWithDefaultN(void)
1241 TestApplication application;
1242 TypeRegistry typeRegistry = TypeRegistry::Get();
1244 // Attempt to register an animatable property type out-of-bounds index (less than)
1247 AnimatablePropertyRegistration property1( customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX - 1, false );
1248 tet_result( TET_FAIL );
1250 catch ( DaliException& e )
1252 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1255 // Attempt to register an animatable property type out-of-bounds index (greater than)
1258 AnimatablePropertyRegistration property1( customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX + 1, true );
1259 tet_result( TET_FAIL );
1261 catch ( DaliException& e )
1263 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1269 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationP(void)
1271 TestApplication application;
1272 TypeRegistry typeRegistry = TypeRegistry::Get();
1274 // Check property count before property registration
1275 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1276 DALI_TEST_CHECK( typeInfo );
1277 BaseHandle handle = typeInfo.CreateInstance();
1278 DALI_TEST_CHECK( handle );
1279 Actor customActor = Actor::DownCast( handle );
1280 DALI_TEST_CHECK( customActor );
1282 unsigned int customPropertyCount( customActor.GetPropertyCount() );
1284 // Register animatable property
1285 std::string animatablePropertyName( "animatableProp1" );
1286 int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1287 Property::Type animatablePropertyType( Property::VECTOR2 );
1288 AnimatablePropertyRegistration animatableProperty1( customType1, animatablePropertyName, animatablePropertyIndex, animatablePropertyType );
1290 // Check property count after registration
1291 DALI_TEST_EQUALS( customPropertyCount + 1u, customActor.GetPropertyCount(), TEST_LOCATION );
1293 // Set the animatable property value
1294 customActor.SetProperty( animatablePropertyIndex, Vector2(25.0f, 50.0f) );
1296 // Render and notify
1297 application.SendNotification();
1298 application.Render();
1300 // Check the animatable property value
1301 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( animatablePropertyIndex ), Vector2(25.0f, 50.0f), TEST_LOCATION );
1303 // Check the animatable property name
1304 DALI_TEST_EQUALS( customActor.GetPropertyName( animatablePropertyIndex ), animatablePropertyName, TEST_LOCATION );
1306 // Check the animatable property index
1307 DALI_TEST_EQUALS( customActor.GetPropertyIndex( animatablePropertyName ), animatablePropertyIndex, TEST_LOCATION );
1309 // Check the animatable property type
1310 DALI_TEST_EQUALS( customActor.GetPropertyType( animatablePropertyIndex ), animatablePropertyType, TEST_LOCATION );
1312 // Check property count of type-info
1313 Property::IndexContainer indices;
1314 typeInfo.GetPropertyIndices( indices );
1315 DALI_TEST_EQUALS( indices.Size(), customActor.GetPropertyCount(), TEST_LOCATION );
1317 // Register animatable property components
1318 std::string animatablePropertyComponentName1( "animatableProp1X" );
1319 int animatablePropertyComponentIndex1( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1 );
1320 AnimatablePropertyComponentRegistration animatablePropertyComponent1( customType1, animatablePropertyComponentName1, animatablePropertyComponentIndex1, animatablePropertyIndex, 0 );
1322 std::string animatablePropertyComponentName2( "animatableProp1Y" );
1323 int animatablePropertyComponentIndex2( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2 );
1324 AnimatablePropertyComponentRegistration animatablePropertyComponent2( customType1, animatablePropertyComponentName2, animatablePropertyComponentIndex2, animatablePropertyIndex, 1 );
1326 // Check property count after registration
1327 DALI_TEST_EQUALS( customPropertyCount + 3u, customActor.GetPropertyCount(), TEST_LOCATION );
1329 // Check the animatable property component value
1330 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex1 ), 25.0f, TEST_LOCATION );
1331 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex2 ), 50.0f, TEST_LOCATION );
1333 // Set the animatable property component value
1334 customActor.SetProperty( animatablePropertyComponentIndex1, 150.0f );
1336 // Render and notify
1337 application.SendNotification();
1338 application.Render();
1340 // Check the animatable property value
1341 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector2 >( animatablePropertyIndex ), Vector2(150.0f, 50.0f), TEST_LOCATION );
1342 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex1 ), 150.0f, TEST_LOCATION );
1343 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex2 ), 50.0f, TEST_LOCATION );
1345 // Set the animatable property component value
1346 customActor.SetProperty( animatablePropertyComponentIndex2, 225.0f );
1348 // Render and notify
1349 application.SendNotification();
1350 application.Render();
1352 // Check the animatable property value
1353 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector2 >( animatablePropertyIndex ), Vector2(150.0f, 225.0f), TEST_LOCATION );
1354 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex1 ), 150.0f, TEST_LOCATION );
1355 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex2 ), 225.0f, TEST_LOCATION );
1357 // Ensure indices returned from actor and customActor differ by three
1358 Actor actor = Actor::New();
1359 actor.GetPropertyIndices( indices );
1360 unsigned int actorIndices = indices.Size();
1361 customActor.GetPropertyIndices( indices );
1362 unsigned int customActorIndices = indices.Size();
1363 DALI_TEST_EQUALS( actorIndices + 3u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1365 // Attempt to animate component property, it should not crash
1366 Animation animation = Animation::New( 1.0f );
1367 animation.AnimateTo( Property( customActor, animatablePropertyComponentIndex1 ), 200.0f );
1370 // Check the property value
1371 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( animatablePropertyIndex ), Vector2(200.0f, 225.0f), TEST_LOCATION );
1372 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex1 ), 200.0f, TEST_LOCATION );
1373 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex2 ), 225.0f, TEST_LOCATION );
1378 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationVector2AnimateByP(void)
1380 TestApplication application;
1381 TypeRegistry typeRegistry = TypeRegistry::Get();
1383 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1384 DALI_TEST_CHECK( typeInfo );
1385 BaseHandle handle = typeInfo.CreateInstance();
1386 DALI_TEST_CHECK( handle );
1387 Actor customActor = Actor::DownCast( handle );
1388 DALI_TEST_CHECK( customActor );
1390 const unsigned int index = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX;
1391 const unsigned int xComponentIndex = index + 1;
1392 const unsigned int yComponentIndex = index + 2;
1393 const Vector2 initialValue( 20.0f, 40.0f );
1395 // Register animatable property & its components
1396 AnimatablePropertyRegistration animatableProperty1( customType1, "animatableProp1", index, initialValue );
1397 AnimatablePropertyComponentRegistration animatablePropertyComponent1( customType1, "animatableProp1X", xComponentIndex, index, 0 );
1398 AnimatablePropertyComponentRegistration animatablePropertyComponent2( customType1, "animatableProp1Y", yComponentIndex, index, 1 );
1400 // Check the animatable property value
1401 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( index ), initialValue, TEST_LOCATION );
1402 DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
1403 DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
1405 // Render and notify
1406 application.SendNotification();
1407 application.Render();
1409 // Check the animatable property current value
1410 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector2 >( index ), initialValue, TEST_LOCATION );
1411 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
1412 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
1415 const Vector2 targetValue( 45.0f, 53.0f );
1416 const Vector2 relativeValue( targetValue - initialValue );
1418 Animation animation = Animation::New( 1.0f );
1419 animation.AnimateBy( Property( customActor, xComponentIndex ), relativeValue.x );
1420 animation.AnimateBy( Property( customActor, yComponentIndex ), relativeValue.y );
1423 // Target values should change straight away
1424 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
1425 DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), targetValue.x, TEST_LOCATION );
1426 DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), targetValue.y, TEST_LOCATION );
1431 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationVector3AnimateByP(void)
1433 TestApplication application;
1434 TypeRegistry typeRegistry = TypeRegistry::Get();
1436 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1437 DALI_TEST_CHECK( typeInfo );
1438 BaseHandle handle = typeInfo.CreateInstance();
1439 DALI_TEST_CHECK( handle );
1440 Actor customActor = Actor::DownCast( handle );
1441 DALI_TEST_CHECK( customActor );
1443 const unsigned int index = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX;
1444 const unsigned int xComponentIndex = index + 1;
1445 const unsigned int yComponentIndex = index + 2;
1446 const unsigned int zComponentIndex = index + 3;
1447 const Vector3 initialValue( 20.0f, 40.0f, 50.0f );
1449 // Register animatable property & its components
1450 AnimatablePropertyRegistration animatableProperty1( customType1, "animatableProp1", index, initialValue );
1451 AnimatablePropertyComponentRegistration animatablePropertyComponent1( customType1, "animatableProp1X", xComponentIndex, index, 0 );
1452 AnimatablePropertyComponentRegistration animatablePropertyComponent2( customType1, "animatableProp1Y", yComponentIndex, index, 1 );
1453 AnimatablePropertyComponentRegistration animatablePropertyComponent3( customType1, "animatableProp1Z", zComponentIndex, index, 2 );
1455 // Check the animatable property value
1456 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( index ), initialValue, TEST_LOCATION );
1457 DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
1458 DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
1459 DALI_TEST_EQUALS( customActor.GetProperty< float >( zComponentIndex ), initialValue.z, TEST_LOCATION );
1461 // Render and notify
1462 application.SendNotification();
1463 application.Render();
1465 // Check the animatable property current value
1466 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector3 >( index ), initialValue, TEST_LOCATION );
1467 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
1468 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
1469 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( zComponentIndex ), initialValue.z, TEST_LOCATION );
1472 const Vector3 targetValue( 45.0f, 53.0f, 25.0f );
1473 const Vector3 relativeValue( targetValue - initialValue );
1475 Animation animation = Animation::New( 1.0f );
1476 animation.AnimateBy( Property( customActor, xComponentIndex ), relativeValue.x );
1477 animation.AnimateBy( Property( customActor, yComponentIndex ), relativeValue.y );
1478 animation.AnimateBy( Property( customActor, zComponentIndex ), relativeValue.z );
1481 // Target values should change straight away
1482 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
1483 DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), targetValue.x, TEST_LOCATION );
1484 DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), targetValue.y, TEST_LOCATION );
1485 DALI_TEST_EQUALS( customActor.GetProperty< float >( zComponentIndex ), targetValue.z, TEST_LOCATION );
1490 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationVector4AnimateByP(void)
1492 TestApplication application;
1493 TypeRegistry typeRegistry = TypeRegistry::Get();
1495 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1496 DALI_TEST_CHECK( typeInfo );
1497 BaseHandle handle = typeInfo.CreateInstance();
1498 DALI_TEST_CHECK( handle );
1499 Actor customActor = Actor::DownCast( handle );
1500 DALI_TEST_CHECK( customActor );
1502 const unsigned int index = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX;
1503 const unsigned int xComponentIndex = index + 1;
1504 const unsigned int yComponentIndex = index + 2;
1505 const unsigned int zComponentIndex = index + 3;
1506 const unsigned int wComponentIndex = index + 4;
1507 const Vector4 initialValue( 20.0f, 40.0f, 50.0f, 60.0f );
1509 // Register animatable property & its components
1510 AnimatablePropertyRegistration animatableProperty1( customType1, "animatableProp1", index, initialValue );
1511 AnimatablePropertyComponentRegistration animatablePropertyComponent1( customType1, "animatableProp1X", xComponentIndex, index, 0 );
1512 AnimatablePropertyComponentRegistration animatablePropertyComponent2( customType1, "animatableProp1Y", yComponentIndex, index, 1 );
1513 AnimatablePropertyComponentRegistration animatablePropertyComponent3( customType1, "animatableProp1Z", zComponentIndex, index, 2 );
1514 AnimatablePropertyComponentRegistration animatablePropertyComponent4( customType1, "animatableProp1W", wComponentIndex, index, 3 );
1516 // Check the animatable property value
1517 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( index ), initialValue, TEST_LOCATION );
1518 DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
1519 DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
1520 DALI_TEST_EQUALS( customActor.GetProperty< float >( zComponentIndex ), initialValue.z, TEST_LOCATION );
1521 DALI_TEST_EQUALS( customActor.GetProperty< float >( wComponentIndex ), initialValue.w, TEST_LOCATION );
1523 // Render and notify
1524 application.SendNotification();
1525 application.Render();
1527 // Check the animatable property current value
1528 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector4 >( index ), initialValue, TEST_LOCATION );
1529 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
1530 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
1531 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( zComponentIndex ), initialValue.z, TEST_LOCATION );
1532 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( wComponentIndex ), initialValue.w, TEST_LOCATION );
1535 const Vector4 targetValue( 45.0f, 53.0f, 25.0f, 13.0f );
1536 const Vector4 relativeValue( targetValue - initialValue );
1538 Animation animation = Animation::New( 1.0f );
1539 animation.AnimateBy( Property( customActor, xComponentIndex ), relativeValue.x );
1540 animation.AnimateBy( Property( customActor, yComponentIndex ), relativeValue.y );
1541 animation.AnimateBy( Property( customActor, zComponentIndex ), relativeValue.z );
1542 animation.AnimateBy( Property( customActor, wComponentIndex ), relativeValue.w );
1545 // Target values should change straight away
1546 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
1547 DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), targetValue.x, TEST_LOCATION );
1548 DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), targetValue.y, TEST_LOCATION );
1549 DALI_TEST_EQUALS( customActor.GetProperty< float >( zComponentIndex ), targetValue.z, TEST_LOCATION );
1550 DALI_TEST_EQUALS( customActor.GetProperty< float >( wComponentIndex ), targetValue.w, TEST_LOCATION );
1555 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationN(void)
1557 TestApplication application;
1558 TypeRegistry typeRegistry = TypeRegistry::Get();
1560 // Register animatable property with the type of Vector2
1561 int animatablePropertyIndex1( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1562 AnimatablePropertyRegistration animatableProperty1( customType1, "animatableProp1", animatablePropertyIndex1, Property::VECTOR2 );
1564 // Attempt to register an animatable property component out-of-bounds index (less than)
1567 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp1X", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX - 1, animatablePropertyIndex1, 0 );
1568 tet_result( TET_FAIL );
1570 catch ( DaliException& e )
1572 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1575 // Attempt to register an animatable property component out-of-bounds index (greater than)
1578 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp1X", ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX + 1, animatablePropertyIndex1, 0 );
1579 tet_result( TET_FAIL );
1581 catch ( DaliException& e )
1583 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1586 // Register an animatable property component
1587 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp1X", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1, animatablePropertyIndex1, 0 );
1589 // Attempt to register another animatable property component with the same component index
1592 AnimatablePropertyComponentRegistration propertyComponent2( customType1, "animatableProp1Y", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2, animatablePropertyIndex1, 0 );
1593 tet_result( TET_FAIL );
1595 catch ( DaliException& e )
1597 DALI_TEST_ASSERT( e, "Property component already registered", TEST_LOCATION );
1600 // Register animatable property with the type of boolean
1601 int animatablePropertyIndex2( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2 );
1602 AnimatablePropertyRegistration animatableProperty2( customType1, "animatableProp2", animatablePropertyIndex2, Property::BOOLEAN );
1604 // Attempt to register an animatable property component for the above property with boolean type
1607 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp2X", animatablePropertyIndex2 + 1, animatablePropertyIndex2, 0 );
1608 tet_result( TET_FAIL );
1610 catch ( DaliException& e )
1612 DALI_TEST_ASSERT( e, "Base property does not support component", TEST_LOCATION );
1618 int UtcDaliTypeRegistryChildPropertyRegistrationP(void)
1620 TestApplication application;
1621 TypeRegistry typeRegistry = TypeRegistry::Get();
1623 // Check property count before property registration
1624 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1625 DALI_TEST_CHECK( typeInfo );
1626 BaseHandle handle = typeInfo.CreateInstance();
1627 DALI_TEST_CHECK( handle );
1628 Actor customActor = Actor::DownCast( handle );
1629 DALI_TEST_CHECK( customActor );
1630 unsigned int initialPropertyCount( customActor.GetPropertyCount() );
1632 // Register child properties to the parent
1633 std::string propertyName( "childProp1" );
1634 int propertyIndex( CHILD_PROPERTY_REGISTRATION_START_INDEX );
1635 Property::Type propertyType( Property::BOOLEAN );
1636 ChildPropertyRegistration childProperty1( customType1, propertyName, propertyIndex, propertyType );
1638 std::string propertyName2( "childProp2" );
1639 int propertyIndex2( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1 );
1640 Property::Type propertyType2( Property::INTEGER );
1641 ChildPropertyRegistration childProperty2( customType1, propertyName2, propertyIndex2, propertyType2 );
1643 std::string propertyName3( "childProp3" );
1644 int propertyIndex3( CHILD_PROPERTY_REGISTRATION_START_INDEX + 2 );
1645 Property::Type propertyType3( Property::FLOAT );
1646 ChildPropertyRegistration childProperty3( customType1, propertyName3, propertyIndex3, propertyType3 );
1648 std::string propertyName4( "childProp4" );
1649 int propertyIndex4( CHILD_PROPERTY_REGISTRATION_START_INDEX + 3 );
1650 Property::Type propertyType4( Property::INTEGER );
1651 ChildPropertyRegistration childProperty4( customType1, propertyName4, propertyIndex4, propertyType4 );
1653 // Check property count are not changed because the child properties will not be created for the parent
1654 DALI_TEST_EQUALS( initialPropertyCount, customActor.GetPropertyCount(), TEST_LOCATION );
1656 // check the child property type
1657 Internal::TypeInfo& typeInfoImpl = GetImplementation( typeInfo );
1658 Property::Type type = typeInfoImpl.GetChildPropertyType( typeInfoImpl.GetChildPropertyIndex("childProp4") );
1659 DALI_TEST_EQUALS( type, Property::INTEGER, TEST_LOCATION );
1661 std::string unRegisteredChildName( typeInfoImpl.GetChildPropertyName( CHILD_PROPERTY_REGISTRATION_START_INDEX + 4 ) );
1662 DALI_TEST_EQUALS( unRegisteredChildName, "", TEST_LOCATION );
1664 // Create a child actor
1665 Actor childActor = Actor::New();
1666 DALI_TEST_CHECK( childActor );
1667 unsigned int initialChildActorPropertyCount( childActor.GetPropertyCount() );
1669 // The type of child properties should be Property::None as the child hasn't registered any child property yet.
1670 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex ), Property::NONE, TEST_LOCATION );
1671 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex2 ), Property::NONE, TEST_LOCATION );
1672 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex3 ), Property::NONE, TEST_LOCATION );
1673 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex4 ), Property::NONE, TEST_LOCATION );
1675 // Set the value for the first child property when the child actor doesn't have a parent yet
1676 childActor.SetProperty(propertyIndex, true);
1678 // Check that the first child property is dynamically created
1679 DALI_TEST_EQUALS( initialChildActorPropertyCount + 1u, childActor.GetPropertyCount(), TEST_LOCATION );
1681 // Check the first child property value
1682 DALI_TEST_EQUALS( childActor.GetProperty< bool >( propertyIndex ), true, TEST_LOCATION );
1684 // Check the first child property type
1685 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex ), propertyType, TEST_LOCATION );
1687 // Check that the first child property have no name, as it doesn't have a parent yet.
1688 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex ), "", TEST_LOCATION );
1690 // Check that the first property can't be accessed through its name, as it doesn't have a parent yet.
1691 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName ), Property::INVALID_INDEX, TEST_LOCATION );
1693 // Create a custom property for the child with the same name as the second child property registered to the parent
1694 Property::Index customPropertyIndex = childActor.RegisterProperty(propertyName2, 100, Property::READ_WRITE);
1696 // Check that the custom property is created
1697 DALI_TEST_EQUALS( initialChildActorPropertyCount + 2u, childActor.GetPropertyCount(), TEST_LOCATION );
1699 // Check the property value
1700 DALI_TEST_EQUALS( childActor.GetProperty< int >( customPropertyIndex ), 100, TEST_LOCATION );
1702 // Check the property index
1703 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName2 ), customPropertyIndex, TEST_LOCATION );
1705 // Check the property type
1706 DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex ), propertyType2, TEST_LOCATION );
1708 // Check the property name
1709 DALI_TEST_EQUALS( childActor.GetPropertyName( customPropertyIndex ), propertyName2, TEST_LOCATION );
1711 // Now add the child actor to the parent
1712 customActor.Add( childActor );
1714 // Check that the first child property now has the correct name as previously registered to the parent
1715 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
1717 // Check that the child property index for the first child property can now be retrieved through its child property name
1718 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName ), propertyIndex, TEST_LOCATION );
1720 // Check that the second child property now has the correct index as previously registered to the parent
1721 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex2 ), propertyName2, TEST_LOCATION );
1723 // Check that the second child property can be accessed through both its custom property index and its child property index
1724 DALI_TEST_EQUALS( childActor.GetProperty< int >( customPropertyIndex ), 100, TEST_LOCATION );
1725 DALI_TEST_EQUALS( childActor.GetProperty< int >( propertyIndex2 ), 100, TEST_LOCATION );
1726 DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex ), propertyType2, TEST_LOCATION );
1727 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex2 ), propertyType2, TEST_LOCATION );
1729 // Check that the child property index for the second child property can now be retrieved through its child property name
1730 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName2 ), propertyIndex2, TEST_LOCATION );
1732 // Set the value for the third child property when the child actor is already added to the parent
1733 childActor.SetProperty(propertyIndex3, 0.15f);
1735 // Check that the third child property is dynamically created
1736 DALI_TEST_EQUALS( initialChildActorPropertyCount + 3u, childActor.GetPropertyCount(), TEST_LOCATION );
1738 // Check the third child property value
1739 DALI_TEST_EQUALS( childActor.GetProperty< float >( propertyIndex3 ), 0.15f, TEST_LOCATION );
1741 // Check the third child property type
1742 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex3 ), propertyType3, TEST_LOCATION );
1744 // Check the third child property name
1745 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex3 ), propertyName3, TEST_LOCATION );
1747 // Check the third child property index.
1748 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName3 ), propertyIndex3, TEST_LOCATION );
1750 // Create a custom property for the child with the same name as the fourth child property registered to the parent
1751 Property::Index customPropertyIndex2 = childActor.RegisterProperty(propertyName4, 20, Property::READ_WRITE);
1753 // Check that the custom property is created
1754 DALI_TEST_EQUALS( initialChildActorPropertyCount + 4u, childActor.GetPropertyCount(), TEST_LOCATION );
1756 // Check the fourth child property value
1757 DALI_TEST_EQUALS( childActor.GetProperty< int >( propertyIndex4 ), 20, TEST_LOCATION );
1758 DALI_TEST_EQUALS( childActor.GetProperty< int >( customPropertyIndex2 ), 20, TEST_LOCATION );
1760 // Check the fourth child property type
1761 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex4 ), propertyType4, TEST_LOCATION );
1762 DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex2 ), propertyType4, TEST_LOCATION );
1764 // Check the fourth child property name
1765 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex4 ), propertyName4, TEST_LOCATION );
1766 DALI_TEST_EQUALS( childActor.GetPropertyName( customPropertyIndex2 ), propertyName4, TEST_LOCATION );
1768 // Check the fourth child property index.
1769 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName4 ), propertyIndex4, TEST_LOCATION );
1771 // Now create another parent actor with different child properties registered
1772 TypeInfo typeInfo2 = typeRegistry.GetTypeInfo( "MyNamedActor" );
1773 DALI_TEST_CHECK( typeInfo2 );
1774 BaseHandle handle2 = typeInfo2.CreateInstance();
1775 DALI_TEST_CHECK( handle2 );
1776 Actor customActor2 = Actor::DownCast( handle2 );
1777 DALI_TEST_CHECK( customActor2 );
1779 // Register child properties to the new parent
1780 std::string newPropertyName( "newChildProp" );
1781 int newPropertyIndex( CHILD_PROPERTY_REGISTRATION_START_INDEX ); // The same index as the first child property "childProp1" in the old parent
1782 Property::Type newPropertyType( Property::VECTOR2 );
1783 ChildPropertyRegistration newChildProperty( namedActorType, newPropertyName, newPropertyIndex, newPropertyType );
1785 std::string newPropertyName2( "childProp3" ); // The same name as the third child property in the old parent
1786 int newPropertyIndex2( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1 ); // The same index as the second child property "childProp2" in the old parent
1787 Property::Type newPropertyType2( Property::FLOAT ); // The same type as the third child property in the old parent
1788 ChildPropertyRegistration newChildProperty2( namedActorType, newPropertyName2, newPropertyIndex2, newPropertyType2 );
1790 // Now move the child actor to the new parent
1791 customActor2.Add( childActor );
1793 // "childProp1" is not a valid child property supported by the new parent, so nothing changed
1794 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex ), propertyType, TEST_LOCATION );
1795 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
1796 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName ), propertyIndex, TEST_LOCATION );
1798 // "childProp3" is a valid child property supported by the new parent
1799 // So it should get its new child property index and should just work
1800 DALI_TEST_EQUALS( childActor.GetPropertyType( newPropertyIndex2 ), newPropertyType2, TEST_LOCATION );
1801 DALI_TEST_EQUALS( childActor.GetPropertyName( newPropertyIndex2 ), newPropertyName2, TEST_LOCATION );
1802 DALI_TEST_EQUALS( childActor.GetPropertyIndex( newPropertyName2 ), newPropertyIndex2, TEST_LOCATION );
1803 DALI_TEST_EQUALS( childActor.GetProperty< float >( newPropertyIndex2 ), 0.15f, TEST_LOCATION );
1805 // Now register a custom property called "newChildProp"
1806 Property::Index customPropertyIndex3 = childActor.RegisterProperty("newChildProp", Vector2( 10.0f, 10.0f ), Property::READ_WRITE);
1808 // Check that the custom property is created
1809 DALI_TEST_EQUALS( initialChildActorPropertyCount + 5u, childActor.GetPropertyCount(), TEST_LOCATION );
1811 // This is a valid child property registered to the new parent
1812 // So should be able to access it through both its custom property index and its registered child property index
1813 DALI_TEST_EQUALS( childActor.GetPropertyType( newPropertyIndex ), newPropertyType, TEST_LOCATION );
1814 DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex3 ), newPropertyType, TEST_LOCATION );
1815 DALI_TEST_EQUALS( childActor.GetPropertyName( newPropertyIndex ), newPropertyName, TEST_LOCATION ); // This should return the new name, although the child property index remains the same
1816 DALI_TEST_EQUALS( childActor.GetPropertyName( customPropertyIndex3 ), newPropertyName, TEST_LOCATION );
1817 DALI_TEST_EQUALS( childActor.GetProperty< Vector2 >( newPropertyIndex ), Vector2( 10.0f, 10.0f ), TEST_LOCATION );
1818 DALI_TEST_EQUALS( childActor.GetProperty< Vector2 >( customPropertyIndex3 ), Vector2( 10.0f, 10.0f ), TEST_LOCATION );
1820 // Should return the child property index by given its name
1821 DALI_TEST_EQUALS( childActor.GetPropertyIndex( newPropertyName ), newPropertyIndex, TEST_LOCATION );
1827 int UtcDaliTypeRegistryChildPropertyRegistrationN(void)
1829 TestApplication application;
1830 TypeRegistry typeRegistry = TypeRegistry::Get();
1832 // Attempt to register a child property type out-of-bounds index (less than)
1835 ChildPropertyRegistration property1( customType1, "propName", CHILD_PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN );
1836 tet_result( TET_FAIL );
1838 catch ( DaliException& e )
1840 DALI_TEST_ASSERT( e, "( index >= CHILD_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1843 // Attempt to register a child property type out-of-bounds index (greater than)
1846 ChildPropertyRegistration property1( customType1, "propName", CHILD_PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN );
1847 tet_result( TET_FAIL );
1849 catch ( DaliException& e )
1851 DALI_TEST_ASSERT( e, "( index >= CHILD_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1858 /*******************************************************************************
1860 * Action through the base handle
1862 ******************************************************************************/
1863 int UtcDaliTypeRegistryActionViaBaseHandle(void)
1865 TestApplication application;
1869 type = TypeRegistry::Get().GetTypeInfo( "Actor" );
1870 DALI_TEST_CHECK( type );
1872 BaseHandle hdl = type.CreateInstance();
1873 DALI_TEST_CHECK( hdl );
1875 Actor a = Actor::DownCast(hdl);
1876 DALI_TEST_CHECK( a );
1878 a.SetVisible(false);
1880 application.SendNotification();
1881 application.Render(0);
1882 DALI_TEST_CHECK(!a.IsVisible());
1884 Property::Map attributes;
1886 DALI_TEST_CHECK(hdl.DoAction("show", attributes));
1888 application.SendNotification();
1889 application.Render(0);
1890 DALI_TEST_CHECK(a.IsVisible());
1892 DALI_TEST_CHECK(!hdl.DoAction("unknownAction", attributes));
1896 int UtcDaliPropertyRegistrationFunctions(void)
1898 TestApplication application;
1899 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 10;
1901 // Attempt to register a property without a setter
1904 PropertyRegistration property1( customType1, "propName", propertyIndex++, Property::BOOLEAN, NULL, &GetProperty );
1905 tet_result( TET_PASS );
1907 catch ( DaliException& e )
1909 tet_result( TET_FAIL );
1912 // Attempt to register a property without a getter
1915 PropertyRegistration property1( customType1, "propName", propertyIndex++, Property::BOOLEAN, NULL, NULL );
1916 tet_result( TET_FAIL );
1918 catch ( DaliException& e )
1920 DALI_TEST_ASSERT( e, "! \"GetProperty", TEST_LOCATION );
1925 int UtcDaliPropertyRegistrationAddSameIndex(void)
1927 TestApplication application;
1928 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 100;
1930 // Add one property with a valid property index
1931 PropertyRegistration property1( customType1, "propName", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
1933 // Attempt to add another property with the same index
1936 PropertyRegistration property2( customType1, "propName2", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
1938 catch ( DaliException& e )
1940 DALI_TEST_ASSERT( e, "! \"Property index already added", TEST_LOCATION );
1943 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 100;
1945 // Add one property with a valid property index
1946 AnimatablePropertyRegistration property3( customType1, "animPropName", animatablePropertyIndex, Property::BOOLEAN );
1948 // Attempt to add another property with the same index
1951 AnimatablePropertyRegistration property4( customType1, "animPropName2", animatablePropertyIndex, Property::BOOLEAN );
1953 catch ( DaliException& e )
1955 DALI_TEST_ASSERT( e, "! \"Property index already added", TEST_LOCATION );
1960 int UtcDaliPropertyRegistrationPropertyWritableP(void)
1962 TestApplication application;
1963 int propertyIndex1 = PROPERTY_REGISTRATION_START_INDEX + 200;
1964 int propertyIndex2 = PROPERTY_REGISTRATION_START_INDEX + 201;
1966 // Add two properties, one with SetProperty, one without
1967 PropertyRegistration property1( customType1, "propNameReadwrite", propertyIndex1, Property::BOOLEAN, &SetProperty, &GetProperty );
1968 PropertyRegistration property2( customType1, "propNameReadonly", propertyIndex2, Property::BOOLEAN, NULL, &GetProperty );
1970 // Create custom-actor
1971 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
1972 DALI_TEST_CHECK( typeInfo );
1973 BaseHandle handle = typeInfo.CreateInstance();
1974 DALI_TEST_CHECK( handle );
1975 Actor customActor = Actor::DownCast( handle );
1976 DALI_TEST_CHECK( customActor );
1978 // Check whether properties are writable
1979 DALI_TEST_CHECK( customActor.IsPropertyWritable( propertyIndex1 ) );
1980 DALI_TEST_CHECK( ! customActor.IsPropertyWritable( propertyIndex2 ) );
1983 // Check the property is writable in the type registry
1984 Internal::TypeInfo& typeInfoImpl = GetImplementation( typeInfo );
1986 DALI_TEST_EQUALS( typeInfoImpl.IsPropertyWritable( propertyIndex1 ), true, TEST_LOCATION );
1991 int UtcDaliPropertyRegistrationPropertyWritableN(void)
1993 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
1994 Internal::TypeInfo& typeInfoImpl = GetImplementation( typeInfo );
1996 DALI_TEST_EQUALS( typeInfoImpl.IsPropertyWritable( Actor::Property::COLOR), true, TEST_LOCATION );
2001 int UtcDaliPropertyRegistrationPropertyAnimatable(void)
2003 TestApplication application;
2004 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 400;
2005 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 400;
2007 // These properties are not animatable
2008 PropertyRegistration property1( customType1, "propName", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
2010 // These properties are animatable
2011 AnimatablePropertyRegistration property2( customType1, "animPropName", animatablePropertyIndex, Property::BOOLEAN );
2013 // Create custom-actor
2014 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
2015 DALI_TEST_CHECK( typeInfo );
2016 BaseHandle handle = typeInfo.CreateInstance();
2017 DALI_TEST_CHECK( handle );
2018 Actor customActor = Actor::DownCast( handle );
2019 DALI_TEST_CHECK( customActor );
2021 // Check if animatable
2022 DALI_TEST_CHECK( ! customActor.IsPropertyAnimatable( propertyIndex ) );
2023 DALI_TEST_CHECK( customActor.IsPropertyAnimatable( animatablePropertyIndex ) );
2025 // Create another instance of custom-actor
2026 BaseHandle handle2 = typeInfo.CreateInstance();
2027 DALI_TEST_CHECK( handle2 );
2028 Actor customActor2 = Actor::DownCast( handle2 );
2029 DALI_TEST_CHECK( customActor2 );
2031 // Check if animatable
2032 DALI_TEST_CHECK( ! customActor2.IsPropertyAnimatable( propertyIndex ) );
2033 DALI_TEST_CHECK( customActor2.IsPropertyAnimatable( animatablePropertyIndex ) );
2037 int UtcDaliPropertyRegistrationUnregisteredGetAndSet(void)
2039 TestApplication application;
2040 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 2000;
2041 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2000;
2043 // Create custom-actor
2044 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
2045 DALI_TEST_CHECK( typeInfo );
2046 BaseHandle handle = typeInfo.CreateInstance();
2047 DALI_TEST_CHECK( handle );
2048 Actor customActor = Actor::DownCast( handle );
2049 DALI_TEST_CHECK( customActor );
2051 // Try to set an index that hasn't been registered, this is a no-op for now, to be fixed in future
2052 customActor.SetProperty( propertyIndex, true );
2053 // DALI_TEST_EQUALS( true, customActor.GetProperty( propertyIndex ).Get<bool>(), TEST_LOCATION);
2055 // Try to set an index that hasn't been registered
2056 customActor.SetProperty( animatablePropertyIndex, true );
2057 DALI_TEST_EQUALS( true, customActor.GetProperty( animatablePropertyIndex ).Get<bool>(), TEST_LOCATION);
2063 int UtcDaliLongPressGestureDetectorTypeRegistry(void)
2065 TestApplication application;
2067 Actor actor = Actor::New();
2068 actor.SetSize(100.0f, 100.0f);
2069 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2070 Stage::GetCurrent().Add(actor);
2074 type = TypeRegistry::Get().GetTypeInfo( "LongPressGestureDetector" );
2075 DALI_TEST_CHECK( type );
2076 BaseHandle handle = type.CreateInstance();
2077 DALI_TEST_CHECK( handle );
2078 LongPressGestureDetector detector = LongPressGestureDetector::DownCast( handle );
2079 DALI_TEST_CHECK( detector );
2081 // Attach actor to detector
2083 GestureReceivedFunctor functor( data );
2084 detector.Attach(actor);
2086 // Connect to signal through type
2087 handle.ConnectSignal( &application, "longPressDetected", functor );
2089 // Render and notify
2090 application.SendNotification();
2091 application.Render();
2094 TestGenerateLongPress( application, 50.0f, 10.0f );
2095 TestEndLongPress( application, 50.0f, 10.0f );
2097 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2101 int UtcDaliPanGestureDetectorTypeRegistry(void)
2103 TestApplication application;
2105 Actor actor = Actor::New();
2106 actor.SetSize(100.0f, 100.0f);
2107 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2108 Stage::GetCurrent().Add(actor);
2112 type = TypeRegistry::Get().GetTypeInfo( "PanGestureDetector" );
2113 DALI_TEST_CHECK( type );
2114 BaseHandle handle = type.CreateInstance();
2115 DALI_TEST_CHECK( handle );
2116 PanGestureDetector detector = PanGestureDetector::DownCast( handle );
2117 DALI_TEST_CHECK( detector );
2119 // Attach actor to detector
2121 GestureReceivedFunctor functor( data );
2122 detector.Attach(actor);
2124 // Connect to signal through type
2125 handle.ConnectSignal( &application, "panDetected", functor );
2127 // Render and notify
2128 application.SendNotification();
2129 application.Render();
2132 TestGenerateMiniPan( application );
2133 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2137 int UtcDaliPinchGestureDetectorTypeRegistry(void)
2139 TestApplication application;
2141 Actor actor = Actor::New();
2142 actor.SetSize(100.0f, 100.0f);
2143 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2144 Stage::GetCurrent().Add(actor);
2148 type = TypeRegistry::Get().GetTypeInfo( "PinchGestureDetector" );
2149 DALI_TEST_CHECK( type );
2150 BaseHandle handle = type.CreateInstance();
2151 DALI_TEST_CHECK( handle );
2152 PinchGestureDetector detector = PinchGestureDetector::DownCast( handle );
2153 DALI_TEST_CHECK( detector );
2155 // Attach actor to detector
2157 GestureReceivedFunctor functor( data );
2158 detector.Attach(actor);
2160 // Connect to signal through type
2161 handle.ConnectSignal( &application, "pinchDetected", functor );
2163 // Render and notify
2164 application.SendNotification();
2165 application.Render();
2168 TestGeneratePinch( application );
2170 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2174 int UtcDaliRotationGestureDetectorTypeRegistry(void)
2176 TestApplication application;
2178 Actor actor = Actor::New();
2179 actor.SetSize(100.0f, 100.0f);
2180 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2181 Stage::GetCurrent().Add(actor);
2185 type = TypeRegistry::Get().GetTypeInfo( "RotationGestureDetector" );
2186 DALI_TEST_CHECK( type );
2187 BaseHandle handle = type.CreateInstance();
2188 DALI_TEST_CHECK( handle );
2189 RotationGestureDetector detector = RotationGestureDetector::DownCast( handle );
2190 DALI_TEST_CHECK( detector );
2192 // Attach actor to detector
2194 GestureReceivedFunctor functor( data );
2195 detector.Attach(actor);
2197 // Connect to signal through type
2198 handle.ConnectSignal( &application, "rotationDetected", functor );
2200 // Render and notify
2201 application.SendNotification();
2202 application.Render();
2205 TestGenerateRotation( application );
2207 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2211 int UtcDaliTapGestureDetectorTypeRegistry(void)
2213 TestApplication application;
2215 Actor actor = Actor::New();
2216 actor.SetSize(100.0f, 100.0f);
2217 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2218 Stage::GetCurrent().Add(actor);
2222 type = TypeRegistry::Get().GetTypeInfo( "TapGestureDetector" );
2223 DALI_TEST_CHECK( type );
2224 BaseHandle handle = type.CreateInstance();
2225 DALI_TEST_CHECK( handle );
2226 TapGestureDetector detector = TapGestureDetector::DownCast( handle );
2227 DALI_TEST_CHECK( detector );
2229 // Attach actor to detector
2231 GestureReceivedFunctor functor( data );
2232 detector.Attach(actor);
2234 // Connect to signal through type
2235 handle.ConnectSignal( &application, "tapDetected", functor );
2237 // Render and notify
2238 application.SendNotification();
2239 application.Render();
2242 TestGenerateTap( application, 50.0, 10.0, 100 );
2244 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2248 int UtcDaliTypeRegistryNamedType(void)
2250 TestApplication application;
2251 TypeRegistry typeRegistry = TypeRegistry::Get();
2253 // Create a normal actor
2254 BaseHandle actorHandle = typeRegistry.GetTypeInfo( "Actor" ).CreateInstance();
2255 DALI_TEST_CHECK( actorHandle );
2256 Actor actor( Actor::DownCast( actorHandle ) );
2257 DALI_TEST_CHECK( actor );
2258 unsigned int actorPropertyCount( actor.GetPropertyCount() );
2260 // Create Named Actor Type
2261 BaseHandle namedHandle = typeRegistry.GetTypeInfo( "MyNamedActor" ).CreateInstance();
2262 DALI_TEST_CHECK( namedHandle );
2263 Actor namedActor( Actor::DownCast( namedHandle ) );
2264 DALI_TEST_CHECK( namedActor );
2265 unsigned int namedActorPropertyCount( namedActor.GetPropertyCount() );
2267 DALI_TEST_CHECK( namedActorPropertyCount > actorPropertyCount );
2271 int UtcDaliTypeInfoGetActionNameP(void)
2273 TestApplication application;
2274 TypeRegistry typeRegistry = TypeRegistry::Get();
2276 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2277 DALI_TEST_CHECK( typeInfo );
2279 DALI_TEST_CHECK( 0 != typeInfo.GetActionCount() );
2281 std::string name = typeInfo.GetActionName(0);
2283 DALI_TEST_EQUALS( name, "show", TEST_LOCATION );
2286 TypeInfo typeInfo2 = typeRegistry.GetTypeInfo( "MyTestCustomActor" );
2288 // search for show action in base class, given a derived class
2289 bool foundChildAction = false;
2290 for( std::size_t i = 0; i < typeInfo2.GetActionCount(); i++ )
2293 std::string name = typeInfo2.GetActionName( i );
2296 foundChildAction = true;
2301 DALI_TEST_EQUALS( foundChildAction, true, TEST_LOCATION );
2307 int UtcDaliTypeInfoGetActionNameN(void)
2309 TestApplication application;
2310 TypeRegistry typeRegistry = TypeRegistry::Get();
2312 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2313 DALI_TEST_CHECK( typeInfo );
2315 DALI_TEST_CHECK( 0 != typeInfo.GetActionCount() );
2317 std::string name = typeInfo.GetActionName(std::numeric_limits<size_t>::max());
2319 DALI_TEST_EQUALS( 0u, name.size(), TEST_LOCATION );
2324 int UtcDaliTypeInfoGetSignalNameP(void)
2326 TestApplication application;
2327 TypeRegistry typeRegistry = TypeRegistry::Get();
2329 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2330 DALI_TEST_CHECK( typeInfo );
2332 DALI_TEST_CHECK( 0 != typeInfo.GetSignalCount() );
2334 std::string name = typeInfo.GetSignalName(0);
2336 DALI_TEST_EQUALS( name, "touched", TEST_LOCATION );
2338 TypeInfo typeInfo2 = typeRegistry.GetTypeInfo( "MyTestCustomActor" );
2340 // search for signal in base class, given a derived class
2341 bool foundSignal = false;
2342 for( std::size_t i = 0; i < typeInfo2.GetSignalCount(); i++ )
2345 std::string name = typeInfo2.GetSignalName( i );
2346 if( name == "touched")
2353 DALI_TEST_EQUALS( foundSignal, true, TEST_LOCATION );
2358 int UtcDaliTypeInfoGetSignalNameN(void)
2360 TestApplication application;
2361 TypeRegistry typeRegistry = TypeRegistry::Get();
2363 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2364 DALI_TEST_CHECK( typeInfo );
2366 DALI_TEST_CHECK( 0 != typeInfo.GetSignalCount() );
2368 std::string name = typeInfo.GetSignalName(std::numeric_limits<size_t>::max());
2370 DALI_TEST_EQUALS( 0u, name.size(), TEST_LOCATION );
2376 int UtcDaliTypeInfoGetCreatorP(void)
2378 TestApplication application;
2379 TypeRegistry typeRegistry = TypeRegistry::Get();
2381 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2382 DALI_TEST_CHECK( typeInfo );
2384 TypeInfo::CreateFunction createFn = typeInfo.GetCreator();
2385 DALI_TEST_EQUALS( createFn != NULL, true, TEST_LOCATION );
2389 BaseHandle handle = createFn();
2390 DALI_TEST_EQUALS( (bool)handle, true, TEST_LOCATION );
2396 int UtcDaliTypeInfoGetCreatorN(void)
2398 TestApplication application;
2399 TypeRegistry typeRegistry = TypeRegistry::Get();
2401 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "MyTestCustomActor3" );
2402 DALI_TEST_CHECK( typeInfo );
2404 TypeInfo::CreateFunction createFn = typeInfo.GetCreator();
2405 DALI_TEST_EQUALS( createFn == NULL, true, TEST_LOCATION );
2410 int UtcDaliTypeInfoGetPropertyCountP1(void)
2412 TestApplication application;
2413 TypeRegistry typeRegistry = TypeRegistry::Get();
2415 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2416 DALI_TEST_CHECK( typeInfo );
2417 size_t actorPropertyCount = typeInfo.GetPropertyCount();
2419 DALI_TEST_EQUALS( actorPropertyCount, Actor::New().GetPropertyCount(), TEST_LOCATION ); // No event only props
2423 int UtcDaliTypeInfoGetPropertyCountP2(void)
2425 TestApplication application;
2426 TypeRegistry typeRegistry = TypeRegistry::Get();
2428 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "MyTestCustomActor2" );
2429 DALI_TEST_CHECK( typeInfo );
2430 size_t propertyCount = typeInfo.GetPropertyCount();
2431 Property::IndexContainer indices;
2432 typeInfo.GetPropertyIndices( indices );
2434 DALI_TEST_EQUALS( propertyCount > 0 && propertyCount <= indices.Size(), true, TEST_LOCATION );
2435 DALI_TEST_EQUALS( propertyCount, Actor::New().GetPropertyCount() + 2, TEST_LOCATION );
2440 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGet01(void)
2442 TestApplication application;
2443 TypeRegistry typeRegistry = TypeRegistry::Get();
2445 tet_infoline( "Register a type registered animatable property and ensure set/get behaviour works synchronously" );
2447 // Register animatable property
2448 const int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
2449 AnimatablePropertyRegistration animatableProperty( customType1, "animatableProp1", animatablePropertyIndex, Property::FLOAT );
2451 // Check property count before property registration
2452 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2453 DALI_TEST_CHECK( typeInfo );
2454 BaseHandle handle = typeInfo.CreateInstance();
2455 DALI_TEST_CHECK( handle );
2456 Actor customActor = Actor::DownCast( handle );
2457 DALI_TEST_CHECK( customActor );
2458 Stage::GetCurrent().Add(customActor);
2460 tet_infoline( "Set the value and ensure it changes straight away" );
2461 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 0.0f, TEST_LOCATION );
2462 customActor.SetProperty( animatablePropertyIndex, 25.0f );
2463 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 25.0f, TEST_LOCATION );
2465 tet_infoline( "Check latest scene-graph value is unchanged" );
2466 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 0.0f, TEST_LOCATION );
2468 // Render and notify
2469 application.SendNotification();
2470 application.Render();
2472 tet_infoline( "Check values after rendering and both retrieval methods should return the latest" );
2474 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 25.0f, TEST_LOCATION );
2475 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 25.0f, TEST_LOCATION );
2480 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGetWithComponentsVector2(void)
2482 TestApplication application;
2483 TypeRegistry typeRegistry = TypeRegistry::Get();
2485 tet_infoline( "Register a type registered animatable property that has component indices and ensure set/get behaviour works synchronously and is the same regardless of how the property is set" );
2487 // Register the animatable propeties
2488 const int basePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
2489 const int componentZeroPropertyIndex( basePropertyIndex + 1 );
2490 const int componentOnePropertyIndex( componentZeroPropertyIndex + 1 );
2491 AnimatablePropertyRegistration baseAnimatableProperty( customType1, "baseProp", basePropertyIndex, Vector2( 13.0f, 24.0f ) );
2492 AnimatablePropertyComponentRegistration componentZeroAnimatableProperty( customType1, "componentZeroProp", componentZeroPropertyIndex, basePropertyIndex, 0 );
2493 AnimatablePropertyComponentRegistration componentOneAnimatableProperty( customType1, "componentOneProp", componentOnePropertyIndex, basePropertyIndex, 1 );
2495 // Check property count before property registration
2496 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2497 DALI_TEST_CHECK( typeInfo );
2498 BaseHandle handle = typeInfo.CreateInstance();
2499 DALI_TEST_CHECK( handle );
2500 Actor customActor = Actor::DownCast( handle );
2501 DALI_TEST_CHECK( customActor );
2502 Stage::GetCurrent().Add(customActor);
2504 tet_infoline( "Get the component values, they should be the default value of the base-property" );
2505 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2506 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2507 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 13.0f, 24.0f ), TEST_LOCATION );
2509 tet_infoline( "Set a component value and ensure it changes for the base property as well" );
2510 customActor.SetProperty( componentZeroPropertyIndex, 125.0f );
2511 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2512 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 125.0f, 24.0f ), TEST_LOCATION );
2514 customActor.SetProperty( componentOnePropertyIndex, 225.0f );
2515 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2516 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 125.0f, 225.0f ), TEST_LOCATION );
2518 tet_infoline( "Check latest scene-graph value is unchanged" );
2519 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector2 >( basePropertyIndex ), Vector2( 13.0f, 24.0f ), TEST_LOCATION );
2520 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2521 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2523 // Render and notify
2524 application.SendNotification();
2525 application.Render();
2527 tet_infoline( "Check values after rendering and both retrieval methods should return the latest" );
2528 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 125.0f, 225.0f ), TEST_LOCATION );
2529 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2530 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2532 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector2 >( basePropertyIndex ), Vector2( 125.0f, 225.0f ), TEST_LOCATION );
2533 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2534 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2536 tet_infoline( "Set the base property value and ensure the component values reflect the change" );
2537 customActor.SetProperty( basePropertyIndex, Vector2( 1.0f, 2.0f ) );
2538 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 1.0f, TEST_LOCATION );
2539 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 2.0f, TEST_LOCATION );
2540 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 1.0f, 2.0f ), TEST_LOCATION );
2545 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGetWithComponentsVector3(void)
2547 TestApplication application;
2548 TypeRegistry typeRegistry = TypeRegistry::Get();
2550 tet_infoline( "Register a type registered animatable property that has component indices and ensure set/get behaviour works synchronously and is the same regardless of how the property is set" );
2552 // Register the animatable propeties
2553 const int basePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
2554 const int componentZeroPropertyIndex( basePropertyIndex + 1 );
2555 const int componentOnePropertyIndex( componentZeroPropertyIndex + 1 );
2556 const int componentTwoPropertyIndex( componentOnePropertyIndex + 1 );
2557 AnimatablePropertyRegistration baseAnimatableProperty( customType1, "baseProp", basePropertyIndex, Vector3( 13.0f, 24.0f, 35.0 ) );
2558 AnimatablePropertyComponentRegistration componentZeroAnimatableProperty( customType1, "componentZeroProp", componentZeroPropertyIndex, basePropertyIndex, 0 );
2559 AnimatablePropertyComponentRegistration componentOneAnimatableProperty( customType1, "componentOneProp", componentOnePropertyIndex, basePropertyIndex, 1 );
2560 AnimatablePropertyComponentRegistration componentTwoAnimatableProperty( customType1, "componentTwoProp", componentTwoPropertyIndex, basePropertyIndex, 2 );
2562 // Check property count before property registration
2563 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2564 DALI_TEST_CHECK( typeInfo );
2565 BaseHandle handle = typeInfo.CreateInstance();
2566 DALI_TEST_CHECK( handle );
2567 Actor customActor = Actor::DownCast( handle );
2568 DALI_TEST_CHECK( customActor );
2569 Stage::GetCurrent().Add(customActor);
2571 tet_infoline( "Get the component values, they should be the default value of the base-property" );
2572 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2573 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2574 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 35.0f, TEST_LOCATION );
2575 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 13.0f, 24.0f, 35.0f ), TEST_LOCATION );
2577 tet_infoline( "Set a component value and ensure it changes for the base property as well" );
2578 customActor.SetProperty( componentZeroPropertyIndex, 125.0f );
2579 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2580 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 24.0f, 35.0f ), TEST_LOCATION );
2582 customActor.SetProperty( componentOnePropertyIndex, 225.0f );
2583 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2584 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 225.0f, 35.0f ), TEST_LOCATION );
2586 customActor.SetProperty( componentTwoPropertyIndex, 325.0f );
2587 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2588 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 225.0f, 325.0f ), TEST_LOCATION );
2590 tet_infoline( "Check latest scene-graph value is unchanged" );
2591 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector3 >( basePropertyIndex ), Vector3( 13.0f, 24.0f, 35.0f ), TEST_LOCATION );
2592 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2593 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2594 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentTwoPropertyIndex ), 35.0f, TEST_LOCATION );
2596 // Render and notify
2597 application.SendNotification();
2598 application.Render();
2600 tet_infoline( "Check values after rendering and both retrieval methods should return the latest" );
2601 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 225.0f, 325.0f ), TEST_LOCATION );
2602 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2603 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2604 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2606 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 225.0f, 325.0f ), TEST_LOCATION );
2607 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2608 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2609 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2611 tet_infoline( "Set the base property value and ensure the component values reflect the change" );
2612 customActor.SetProperty( basePropertyIndex, Vector3( 1.0f, 2.0f, 3.0f ) );
2613 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 1.0f, TEST_LOCATION );
2614 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 2.0f, TEST_LOCATION );
2615 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 3.0f, TEST_LOCATION );
2616 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 1.0f, 2.0f, 3.0f ), TEST_LOCATION );
2621 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGetWithComponentsVector4(void)
2623 TestApplication application;
2624 TypeRegistry typeRegistry = TypeRegistry::Get();
2626 tet_infoline( "Register a type registered animatable property that has component indices and ensure set/get behaviour works synchronously and is the same regardless of how the property is set" );
2628 // Register the animatable propeties
2629 const int basePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
2630 const int componentZeroPropertyIndex( basePropertyIndex + 1 );
2631 const int componentOnePropertyIndex( componentZeroPropertyIndex + 1 );
2632 const int componentTwoPropertyIndex( componentOnePropertyIndex + 1 );
2633 const int componentThreePropertyIndex( componentTwoPropertyIndex + 1 );
2634 AnimatablePropertyRegistration baseAnimatableProperty( customType1, "baseProp", basePropertyIndex, Vector4( 13.0f, 24.0f, 35.0, 47.0f ) );
2635 AnimatablePropertyComponentRegistration componentZeroAnimatableProperty( customType1, "componentZeroProp", componentZeroPropertyIndex, basePropertyIndex, 0 );
2636 AnimatablePropertyComponentRegistration componentOneAnimatableProperty( customType1, "componentOneProp", componentOnePropertyIndex, basePropertyIndex, 1 );
2637 AnimatablePropertyComponentRegistration componentTwoAnimatableProperty( customType1, "componentTwoProp", componentTwoPropertyIndex, basePropertyIndex, 2 );
2638 AnimatablePropertyComponentRegistration componentThreeAnimatableProperty( customType1, "componentThreeProp", componentThreePropertyIndex, basePropertyIndex, 3 );
2640 // Check property count before property registration
2641 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2642 DALI_TEST_CHECK( typeInfo );
2643 BaseHandle handle = typeInfo.CreateInstance();
2644 DALI_TEST_CHECK( handle );
2645 Actor customActor = Actor::DownCast( handle );
2646 DALI_TEST_CHECK( customActor );
2647 Stage::GetCurrent().Add(customActor);
2649 tet_infoline( "Get the component values, they should be the default value of the base-property" );
2650 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2651 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2652 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 35.0f, TEST_LOCATION );
2653 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentThreePropertyIndex ), 47.0f, TEST_LOCATION );
2654 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 13.0f, 24.0f, 35.0f, 47.0f ), TEST_LOCATION );
2656 tet_infoline( "Set a component value and ensure it changes for the base property as well" );
2657 customActor.SetProperty( componentZeroPropertyIndex, 125.0f );
2658 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2659 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 24.0f, 35.0f, 47.0f ), TEST_LOCATION );
2661 customActor.SetProperty( componentOnePropertyIndex, 225.0f );
2662 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2663 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 35.0f, 47.0f ), TEST_LOCATION );
2665 customActor.SetProperty( componentTwoPropertyIndex, 325.0f );
2666 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2667 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 325.0f, 47.0f ), TEST_LOCATION );
2669 customActor.SetProperty( componentThreePropertyIndex, 435.0f );
2670 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentThreePropertyIndex ), 435.0f, TEST_LOCATION );
2671 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 325.0f, 435.0f ), TEST_LOCATION );
2673 tet_infoline( "Check latest scene-graph value is unchanged" );
2674 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector4 >( basePropertyIndex ), Vector4( 13.0f, 24.0f, 35.0f, 47.0f ), TEST_LOCATION );
2675 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2676 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2677 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentTwoPropertyIndex ), 35.0f, TEST_LOCATION );
2678 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentThreePropertyIndex ), 47.0f, TEST_LOCATION );
2680 // Render and notify
2681 application.SendNotification();
2682 application.Render();
2684 tet_infoline( "Check values after rendering and both retrieval methods should return the latest" );
2685 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 325.0f, 435.0f ), TEST_LOCATION );
2686 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2687 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2688 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2689 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentThreePropertyIndex ), 435.0f, TEST_LOCATION );
2691 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 325.0f, 435.0f ), TEST_LOCATION );
2692 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2693 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2694 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2695 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentThreePropertyIndex ), 435.0f, TEST_LOCATION );
2697 tet_infoline( "Set the base property value and ensure the component values reflect the change" );
2698 customActor.SetProperty( basePropertyIndex, Vector4( 1.0f, 2.0f, 3.0f, 4.0f ) );
2699 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 1.0f, TEST_LOCATION );
2700 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 2.0f, TEST_LOCATION );
2701 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 3.0f, TEST_LOCATION );
2702 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentThreePropertyIndex ), 4.0f, TEST_LOCATION );
2703 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 1.0f, 2.0f, 3.0f, 4.0f ), TEST_LOCATION );
2709 int UtcDaliTypeInfoRegisterChildProperties01(void)
2711 TestApplication application;
2712 TypeRegistry typeRegistry = TypeRegistry::Get();
2714 tet_infoline( "Register child properties on a type via name" );
2716 auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(CustomActor) );
2717 auto myCustomTypeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2718 DALI_TEST_CHECK( customActorTypeInfo );
2719 DALI_TEST_CHECK( myCustomTypeInfo );
2721 const Property::Index WIDTH_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX );
2722 const Property::Index HEIGHT_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1);
2723 const Property::Index MARGIN_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 100);
2725 ChildPropertyRegistration( customActorTypeInfo.GetName(), "widthSpecification", WIDTH_SPECIFICATION, Property::INTEGER );
2726 ChildPropertyRegistration( customActorTypeInfo.GetName(), "heightSpecification", HEIGHT_SPECIFICATION, Property::INTEGER );
2727 ChildPropertyRegistration( myCustomTypeInfo.GetName(), "marginSpecification", MARGIN_SPECIFICATION, Property::EXTENTS );
2729 auto customActor = MyTestCustomActor::New();
2730 Stage::GetCurrent().Add( customActor );
2731 auto child = Actor::New();
2732 customActor.Add( child );
2734 child.SetProperty( WIDTH_SPECIFICATION, 33 );
2736 auto value = child.GetProperty( WIDTH_SPECIFICATION );
2737 DALI_TEST_EQUALS( value, Property::Value(33), TEST_LOCATION );
2739 child.SetProperty( HEIGHT_SPECIFICATION, 44 );
2740 value = child.GetProperty( HEIGHT_SPECIFICATION );
2741 DALI_TEST_EQUALS( value, Property::Value(44), TEST_LOCATION );
2743 child.SetProperty( MARGIN_SPECIFICATION, Extents(10, 10, 10, 10) );
2744 value = child.GetProperty( MARGIN_SPECIFICATION );
2745 DALI_TEST_EQUALS( value, Property::Value(Extents(10,10,10,10)), TEST_LOCATION );
2751 int UtcDaliTypeInfoRegisterChildProperties02(void)
2753 TestApplication application;
2754 TypeRegistry typeRegistry = TypeRegistry::Get();
2756 tet_infoline( "Register child properties on a type via name" );
2758 auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(CustomActor) );
2759 auto myCustomTypeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2760 DALI_TEST_CHECK( customActorTypeInfo );
2761 DALI_TEST_CHECK( myCustomTypeInfo );
2763 const Property::Index WIDTH_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX );
2764 const Property::Index HEIGHT_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1);
2765 const Property::Index MARGIN_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 100);
2767 ChildPropertyRegistration( customActorTypeInfo.GetName(), "widthSpecification", WIDTH_SPECIFICATION, Property::INTEGER );
2768 ChildPropertyRegistration( customActorTypeInfo.GetName(), "heightSpecification", HEIGHT_SPECIFICATION, Property::INTEGER );
2769 ChildPropertyRegistration( myCustomTypeInfo.GetName(), "marginSpecification", MARGIN_SPECIFICATION, Property::EXTENTS );
2772 auto index = customActorTypeInfo.GetChildPropertyIndex( "widthSpecification" );
2773 DALI_TEST_EQUALS( index, WIDTH_SPECIFICATION, TEST_LOCATION );
2775 index = customActorTypeInfo.GetChildPropertyIndex( "heightSpecification" );
2776 DALI_TEST_EQUALS( index, HEIGHT_SPECIFICATION, TEST_LOCATION );
2778 index = customActorTypeInfo.GetChildPropertyIndex( "marginSpecification" );
2779 DALI_TEST_EQUALS( index, Property::INVALID_INDEX, TEST_LOCATION );
2781 index = myCustomTypeInfo.GetChildPropertyIndex( "marginSpecification" );
2782 DALI_TEST_EQUALS( index, MARGIN_SPECIFICATION, TEST_LOCATION );
2785 auto name = customActorTypeInfo.GetChildPropertyName( WIDTH_SPECIFICATION );
2786 DALI_TEST_EQUALS( name, "widthSpecification", TEST_LOCATION );
2788 name = customActorTypeInfo.GetChildPropertyName( HEIGHT_SPECIFICATION );
2789 DALI_TEST_EQUALS( name, "heightSpecification", TEST_LOCATION );
2791 name = myCustomTypeInfo.GetChildPropertyName( MARGIN_SPECIFICATION );
2792 DALI_TEST_EQUALS( name, "marginSpecification", TEST_LOCATION );
2795 auto type = customActorTypeInfo.GetChildPropertyType( WIDTH_SPECIFICATION );
2796 DALI_TEST_EQUALS( type, Property::INTEGER, TEST_LOCATION );
2798 type = customActorTypeInfo.GetChildPropertyType( HEIGHT_SPECIFICATION );
2799 DALI_TEST_EQUALS( type, Property::INTEGER, TEST_LOCATION );
2801 type = myCustomTypeInfo.GetChildPropertyType( MARGIN_SPECIFICATION );
2802 DALI_TEST_EQUALS( type, Property::EXTENTS, TEST_LOCATION );
2809 int UtcDaliTypeInfoRegisterChildProperties03(void)
2811 TestApplication application;
2812 TypeRegistry typeRegistry = TypeRegistry::Get();
2814 tet_infoline( "Check registered child properties can be retrieved" );
2816 auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(CustomActor) );
2817 auto myCustomTypeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2818 DALI_TEST_CHECK( customActorTypeInfo );
2819 DALI_TEST_CHECK( myCustomTypeInfo );
2821 const Property::Index WIDTH_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX );
2822 const Property::Index HEIGHT_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1);
2823 const Property::Index MARGIN_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 100);
2825 ChildPropertyRegistration( customActorTypeInfo.GetName(), "widthSpecification", WIDTH_SPECIFICATION, Property::INTEGER );
2826 ChildPropertyRegistration( customActorTypeInfo.GetName(), "heightSpecification", HEIGHT_SPECIFICATION, Property::INTEGER );
2827 ChildPropertyRegistration( myCustomTypeInfo.GetName(), "marginSpecification", MARGIN_SPECIFICATION, Property::EXTENTS );
2829 Property::IndexContainer indices;
2830 myCustomTypeInfo.GetChildPropertyIndices( indices );
2832 auto result = std::find( indices.Begin(), indices.End(), WIDTH_SPECIFICATION );
2833 DALI_TEST_EQUALS( result != indices.End(), true, TEST_LOCATION );
2835 result = std::find( indices.Begin(), indices.End(), HEIGHT_SPECIFICATION );
2836 DALI_TEST_EQUALS( result != indices.End(), true, TEST_LOCATION );
2838 result = std::find( indices.Begin(), indices.End(), MARGIN_SPECIFICATION );
2839 DALI_TEST_EQUALS( result != indices.End(), true, TEST_LOCATION );