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>
33 // Stores data that is populated in the callback and will be read by the Test cases
37 : functorCalled( false ),
38 voidFunctorCalled( false ),
39 receivedGesture( Gesture::Clear ),
45 functorCalled = false;
46 voidFunctorCalled = false;
48 receivedGesture.numberOfTouches = 0u;
49 receivedGesture.screenPoint = Vector2(0.0f, 0.0f);
50 receivedGesture.localPoint = Vector2(0.0f, 0.0f);
56 bool voidFunctorCalled;
57 LongPressGesture receivedGesture;
61 // Functor that sets the data when called
62 struct GestureReceivedFunctor
64 GestureReceivedFunctor(SignalData& data) : signalData(data) { }
66 void operator()(Actor actor, LongPressGesture longPress)
68 signalData.functorCalled = true;
69 signalData.receivedGesture = longPress;
70 signalData.pressedActor = actor;
75 signalData.voidFunctorCalled = true;
78 SignalData& signalData;
82 // Create function as Init function called
84 static bool CreateCustomInitCalled = false;
85 BaseHandle CreateCustomInit(void)
87 CreateCustomInitCalled = true;
91 static bool CreateCustomNamedInitCalled = false;
92 BaseHandle CreateCustomNamedInit(void)
94 CreateCustomNamedInitCalled = true;
98 const std::string scriptedName("PopupStyle");
99 static TypeRegistration scriptedType( scriptedName, typeid(Dali::CustomActor), CreateCustomNamedInit );
101 // Property Registration
102 bool setPropertyCalled = false;
103 bool getPropertyCalled = false;
104 void SetProperty( BaseObject* object, Property::Index propertyIndex, const Property::Value& value )
106 setPropertyCalled = true;
108 Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex )
110 getPropertyCalled = true;
111 return Property::Value( true );
116 /*******************************************************************************
120 ******************************************************************************/
123 struct MyTestCustomActor : public CustomActorImpl
125 typedef Signal< void ()> SignalType;
126 typedef Signal< void (float)> SignalTypeFloat;
128 MyTestCustomActor() : CustomActorImpl( ActorFlags( REQUIRES_TOUCH_EVENTS ) )
131 virtual ~MyTestCustomActor()
134 void ResetCallStack()
138 // From CustomActorImpl
139 virtual void OnStageConnection( int depth )
142 virtual void OnStageDisconnection()
145 virtual void OnChildAdd(Actor& child)
148 virtual void OnChildRemove(Actor& child)
151 virtual void OnSizeSet(const Vector3& targetSize)
154 virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize)
157 virtual bool OnTouchEvent(const TouchEvent& event)
161 virtual bool OnHoverEvent(const HoverEvent& event)
165 virtual bool OnWheelEvent(const WheelEvent& event)
169 virtual bool OnKeyEvent(const KeyEvent& event)
173 virtual void OnKeyInputFocusGained()
176 virtual void OnKeyInputFocusLost()
179 virtual Vector3 GetNaturalSize()
181 return Vector3( 0.0f, 0.0f, 0.0f );
184 virtual float GetHeightForWidth( float width )
189 virtual float GetWidthForHeight( float height )
194 virtual void OnRelayout( const Vector2& size, RelayoutContainer& container )
198 virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
202 virtual void OnCalculateRelayoutSize( Dimension::Type dimension )
206 virtual float CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension )
211 virtual void OnLayoutNegotiated( float size, Dimension::Type dimension )
215 virtual bool RelayoutDependentOnChildren( Dimension::Type dimension = Dimension::ALL_DIMENSIONS )
227 class MyTestCustomActor : public CustomActor
231 typedef Signal< void ()> SignalType;
232 typedef Signal< void (float)> SignalTypeFloat;
238 static MyTestCustomActor New()
240 Impl::MyTestCustomActor* p = new Impl::MyTestCustomActor;
241 return MyTestCustomActor( *p ); // takes ownership
244 virtual ~MyTestCustomActor()
248 static MyTestCustomActor DownCast( BaseHandle handle )
250 MyTestCustomActor result;
252 CustomActor custom = Dali::CustomActor::DownCast( handle );
255 CustomActorImpl& customImpl = custom.GetImplementation();
257 Impl::MyTestCustomActor* impl = dynamic_cast<Impl::MyTestCustomActor*>(&customImpl);
261 result = MyTestCustomActor(customImpl.GetOwner());
268 SignalType& GetCustomSignal()
270 Dali::RefObject& obj = GetImplementation();
271 return static_cast<Impl::MyTestCustomActor&>( obj ).mSignal;
276 MyTestCustomActor(Internal::CustomActor* internal)
277 : CustomActor(internal)
281 MyTestCustomActor( Impl::MyTestCustomActor& impl )
282 : CustomActor( impl )
288 class MyTestCustomActor2 : public CustomActor
296 P1=Dali::PROPERTY_REGISTRATION_START_INDEX,
306 static MyTestCustomActor2 New()
308 return MyTestCustomActor2(); // takes ownership
311 virtual ~MyTestCustomActor2()
315 static MyTestCustomActor2 DownCast( BaseHandle handle )
317 MyTestCustomActor2 result;
319 CustomActor custom = Dali::CustomActor::DownCast( handle );
322 CustomActorImpl& customImpl = custom.GetImplementation();
324 Impl::MyTestCustomActor* impl = dynamic_cast<Impl::MyTestCustomActor*>(&customImpl);
328 result = MyTestCustomActor2(customImpl.GetOwner());
337 MyTestCustomActor2(Internal::CustomActor* internal)
338 : CustomActor(internal)
342 MyTestCustomActor2( Impl::MyTestCustomActor& impl )
343 : CustomActor( impl )
348 static TypeRegistration customTypeInit( typeid(MyTestCustomActor2), typeid(Dali::CustomActor), CreateCustomInit, true );
350 PropertyRegistration P1( customTypeInit, "propertyOne", MyTestCustomActor2::Property::P1, Property::INTEGER, &SetProperty, &GetProperty );
351 PropertyRegistration P2( customTypeInit, "propertyTwo", MyTestCustomActor2::Property::P2, Property::STRING, &SetProperty, &GetProperty );
354 class MyTestCustomActor3 : public CustomActor
361 static MyTestCustomActor3 New()
363 return MyTestCustomActor3(); // takes ownership
366 virtual ~MyTestCustomActor3()
370 static MyTestCustomActor3 DownCast( BaseHandle handle )
372 MyTestCustomActor3 result;
374 CustomActor custom = Dali::CustomActor::DownCast( handle );
377 CustomActorImpl& customImpl = custom.GetImplementation();
379 Impl::MyTestCustomActor* impl = dynamic_cast<Impl::MyTestCustomActor*>(&customImpl);
383 result = MyTestCustomActor3(customImpl.GetOwner());
392 MyTestCustomActor3(Internal::CustomActor* internal)
393 : CustomActor(internal)
397 MyTestCustomActor3( Impl::MyTestCustomActor& impl )
398 : CustomActor( impl )
403 static TypeRegistration customTypeBadInit( typeid(MyTestCustomActor3), typeid(Dali::CustomActor), NULL, false );
405 BaseHandle CreateCustom(void)
407 return MyTestCustomActor::New();
410 static std::string lastSignalConnectionCustom;
412 bool DoConnectSignalCustom( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
414 lastSignalConnectionCustom = signalName;
416 bool connected( true );
418 Dali::BaseHandle handle(object);
419 MyTestCustomActor customActor = MyTestCustomActor::DownCast(handle);
421 if( "sig1" == signalName )
423 customActor.GetCustomSignal().Connect( tracker, functor );
427 // signalName does not match any signal
434 bool DoConnectSignalCustomFailure( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
436 lastSignalConnectionCustom = "failed";
438 return false; // This is supposed to fail
441 struct CustomTestFunctor
445 ++mTotalInstanceCount;
446 ++mCurrentInstanceCount;
449 CustomTestFunctor( const CustomTestFunctor& copyMe )
451 ++mTotalInstanceCount;
452 ++mCurrentInstanceCount;
457 --mCurrentInstanceCount;
465 static int mTotalInstanceCount;
466 static int mCurrentInstanceCount;
467 static int mCallbackCount;
470 int CustomTestFunctor::mTotalInstanceCount = 0;
471 int CustomTestFunctor::mCurrentInstanceCount = 0;
472 int CustomTestFunctor::mCallbackCount = 0;
474 static void ResetFunctorCounts()
476 CustomTestFunctor::mTotalInstanceCount = 0;
477 CustomTestFunctor::mCurrentInstanceCount = 0;
478 CustomTestFunctor::mCallbackCount = 0;
481 static std::string lastActionCustom;
482 bool DoActionCustom(BaseObject* object, const std::string& actionName, const Property::Map& /*attributes*/)
484 lastActionCustom = actionName;
488 // Custom type registration
489 static TypeRegistration customType1( typeid(MyTestCustomActor), typeid(Dali::CustomActor), CreateCustom );
492 static SignalConnectorType customSignalConnector1( customType1, "sig1", DoConnectSignalCustom );
493 static SignalConnectorType customSignalConnector2( customType1, "sig2", DoConnectSignalCustomFailure );
494 static const int TEST_SIGNAL_COUNT = 2;
497 static TypeAction customAction1( customType1, "act1", DoActionCustom);
498 static const int TEST_ACTION_COUNT = 1;
500 class TestConnectionTracker : public ConnectionTracker
504 TestConnectionTracker()
509 BaseHandle CreateNamedActorType()
511 Actor actor = Actor::New();
512 actor.SetName( "NamedActor" );
516 TypeRegistration namedActorType( "MyNamedActor", typeid(Dali::Actor), CreateNamedActorType );
517 PropertyRegistration namedActorPropertyOne( namedActorType, "propName", PROPERTY_REGISTRATION_START_INDEX, Property::BOOLEAN, &SetProperty, &GetProperty );
519 } // Anonymous namespace
521 // Note: No negative test case for UtcDaliTypeRegistryGet can be implemented.
522 int UtcDaliTypeRegistryGetP(void)
524 TestApplication application;
526 TypeRegistry registry = TypeRegistry::Get();
527 DALI_TEST_CHECK( registry );
532 // Note: No negative test case for UtcDaliTypeRegistryConstructor can be implemented.
533 int UtcDaliTypeRegistryConstructorP(void)
535 TestApplication application;
537 TypeRegistry registry;
538 DALI_TEST_CHECK( !registry );
542 // Note: No negative test case for UtcDaliTypeRegistryCopyConstructor can be implemented.
543 int UtcDaliTypeRegistryCopyConstructorP(void)
545 TestApplication application;
547 TypeRegistry registry = TypeRegistry::Get();
548 DALI_TEST_CHECK( registry );
550 TypeRegistry copy( registry );
551 DALI_TEST_CHECK( copy );
553 DALI_TEST_CHECK( registry.GetTypeInfo( "Actor" ).GetName() == copy.GetTypeInfo( "Actor" ).GetName() );
558 // Note: No negative test case for UtcDaliTypeRegistryAssignmentOperator can be implemented.
559 int UtcDaliTypeRegistryAssignmentOperatorP(void)
561 TestApplication application;
563 TypeRegistry registry = TypeRegistry::Get();
564 DALI_TEST_CHECK( registry );
566 TypeRegistry copy = registry;
567 DALI_TEST_CHECK( copy );
568 DALI_TEST_CHECK( registry == copy );
570 DALI_TEST_CHECK( registry.GetTypeInfo( "Actor" ).GetName() == copy.GetTypeInfo( "Actor" ).GetName() );
575 int UtcDaliTypeRegistryAssignP(void)
577 TestApplication application;
579 TypeRegistry registry = TypeRegistry::Get();
580 TypeRegistry registry2;
581 registry2 = registry;
582 DALI_TEST_CHECK( registry2 );
584 DALI_TEST_CHECK( registry2.GetTypeInfo( "Actor" ).GetName() == registry2.GetTypeInfo( "Actor" ).GetName() );
589 int UtcDaliTypeRegistryGetTypeInfoFromTypeNameP(void)
591 TestApplication application;
593 TypeRegistry registry = TypeRegistry::Get();
598 type = registry.GetTypeInfo( "CameraActor" );
599 DALI_TEST_CHECK( type );
600 CameraActor ca = CameraActor::DownCast(type.CreateInstance());
601 DALI_TEST_CHECK( ca );
602 Stage::GetCurrent().Add( ca );
603 application.Render();
606 type = registry.GetTypeInfo( "Animation" );
607 DALI_TEST_CHECK( type );
608 Animation an = Animation::DownCast(type.CreateInstance());
609 DALI_TEST_CHECK( an );
611 application.Render();
616 int UtcDaliTypeRegistryGetTypeInfoFromTypeNameN(void)
618 TestApplication application;
620 TypeRegistry registry = TypeRegistry::Get();
624 type = registry.GetTypeInfo( "MyDummyActor" );
625 DALI_TEST_CHECK( !type );
630 int UtcDaliTypeRegistryGetTypeInfoFromTypeIdP(void)
632 TypeInfo named_type = TypeRegistry::Get().GetTypeInfo( "CameraActor" );
633 TypeInfo typeinfo_type = TypeRegistry::Get().GetTypeInfo( typeid(Dali::CameraActor) );
635 DALI_TEST_CHECK( named_type );
636 DALI_TEST_CHECK( typeinfo_type );
638 // Check named and typeid are equivalent
639 DALI_TEST_CHECK( named_type == typeinfo_type );
641 DALI_TEST_CHECK( named_type.GetName() == typeinfo_type.GetName() );
642 DALI_TEST_CHECK( named_type.GetBaseName() == typeinfo_type.GetBaseName() );
647 int UtcDaliTypeRegistryGetTypeInfoFromTypeIdN(void)
649 TestApplication application;
650 TypeRegistry typeRegistry = TypeRegistry::Get();
652 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(Vector2) );
653 DALI_TEST_CHECK( !typeInfo );
658 int UtcDaliTypeRegistryGetTypeNameCountP(void)
660 TestApplication application;
661 TypeRegistry typeRegistry = TypeRegistry::Get();
664 for(size_t i = 0; i < typeRegistry.GetTypeNameCount(); i++)
666 type = typeRegistry.GetTypeInfo( typeRegistry.GetTypeName(i) );
667 DALI_TEST_CHECK( type );
674 int UtcDaliTypeRegistryGetTypeNamesP(void)
676 TestApplication application;
677 TypeRegistry typeRegistry = TypeRegistry::Get();
680 for(size_t i = 0; i < typeRegistry.GetTypeNameCount(); i++)
682 type = typeRegistry.GetTypeInfo( typeRegistry.GetTypeName(i) );
683 DALI_TEST_CHECK( type );
690 // Note: No negative test case for UtcDaliTypeRegistryTypeRegistration can be implemented.
691 int UtcDaliTypeRegistryTypeRegistrationNotCallingCreateOnInitP(void)
693 ResetFunctorCounts();
695 TestApplication application;
697 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
698 DALI_TEST_CHECK( type );
700 TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( "CustomActor" );
701 DALI_TEST_CHECK( baseType );
703 BaseHandle handle = type.CreateInstance();
704 DALI_TEST_CHECK( handle );
706 MyTestCustomActor customHandle = MyTestCustomActor::DownCast( handle );
707 DALI_TEST_CHECK( customHandle );
709 DALI_TEST_EQUALS( type.GetActionCount(), TEST_ACTION_COUNT + baseType.GetActionCount(), TEST_LOCATION );
711 DALI_TEST_EQUALS( type.GetSignalCount(), TEST_SIGNAL_COUNT + baseType.GetSignalCount(), TEST_LOCATION );
714 TestConnectionTracker tracker;
716 bool connected = handle.ConnectSignal( &tracker, "sig1", CustomTestFunctor() );
717 DALI_TEST_EQUALS( connected, true, TEST_LOCATION );
718 DALI_TEST_CHECK( lastSignalConnectionCustom == "sig1" );
719 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
720 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION );
722 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
723 customHandle.GetCustomSignal().Emit();
724 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION );
725 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
726 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION );
728 // tracker should automatically disconnect here
729 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
730 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
732 // Test that functor is disconnected
733 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION );
734 customHandle.GetCustomSignal().Emit();
735 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1/*not incremented*/, TEST_LOCATION );
736 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
737 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
739 Property::Map attributes;
740 handle.DoAction("act1", attributes);
741 DALI_TEST_CHECK( lastActionCustom == "act1" );
745 // Note: No negative test case for UtcDaliTypeRegistryTypeRegistration can be implemented.
746 int UtcDaliTypeRegistryTypeRegistrationCallingCreateOnInitP(void)
748 TestApplication application;
750 DALI_TEST_CHECK( "MyTestCustomActor2" == customTypeInit.RegisteredName() );
752 DALI_TEST_CHECK( true == CreateCustomInitCalled );
753 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor2" );
754 DALI_TEST_CHECK( type );
758 // Note: No negative test case for UtcDaliTypeRegistryTypeRegistration can be implemented.
759 int UtcDaliTypeRegistryTypeRegistrationForNamedTypeP(void)
761 TestApplication application;
763 // Create Named Actor Type
764 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyNamedActor" );
765 DALI_TEST_CHECK( type );
767 BaseHandle namedHandle = type.CreateInstance();
768 DALI_TEST_CHECK( namedHandle );
769 Actor namedActor( Actor::DownCast( namedHandle ) );
770 DALI_TEST_CHECK( namedActor );
772 DALI_TEST_CHECK( namedActor.GetName() == "NamedActor" );
773 DALI_TEST_CHECK( type.GetName() == "MyNamedActor" );
774 DALI_TEST_CHECK( type.GetBaseName() == "Actor" );
779 int UtcDaliTypeRegistryRegisteredNameP(void)
781 TestApplication application;
783 DALI_TEST_CHECK( scriptedName == scriptedType.RegisteredName() );
785 TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( scriptedName );
786 DALI_TEST_CHECK( baseType );
788 BaseHandle handle = baseType.CreateInstance();
790 DALI_TEST_CHECK( true == CreateCustomNamedInitCalled );
791 TypeInfo type = TypeRegistry::Get().GetTypeInfo( scriptedName );
792 DALI_TEST_CHECK( type );
797 int UtcDaliTypeRegistryRegisteredNameN(void)
799 TestApplication application;
801 DALI_TEST_CHECK( scriptedName == scriptedType.RegisteredName() );
803 TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( scriptedName );
804 DALI_TEST_CHECK( baseType );
806 // should cause an assert because we're registering same type twice
807 // once statically at the start of this file, then again now
810 TypeRegistration scriptedType( scriptedName, typeid(Dali::CustomActor), CreateCustomNamedInit );
811 tet_result( TET_FAIL );
813 catch ( DaliException& e )
815 DALI_TEST_ASSERT( e, "Duplicate type name in Type Registration", TEST_LOCATION );
822 int UtcDaliTypeRegistrySignalConnectorTypeP(void)
824 ResetFunctorCounts();
826 TestApplication application;
828 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
829 DALI_TEST_CHECK( type );
831 BaseHandle handle = type.CreateInstance();
832 DALI_TEST_CHECK( handle );
834 MyTestCustomActor customHandle = MyTestCustomActor::DownCast( handle );
835 DALI_TEST_CHECK( customHandle );
838 TestConnectionTracker tracker;
840 bool connected = handle.ConnectSignal( &tracker, "sig1", CustomTestFunctor() );
841 DALI_TEST_EQUALS( connected, true, TEST_LOCATION );
842 DALI_TEST_CHECK( lastSignalConnectionCustom == "sig1" );
843 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
844 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION );
846 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
847 customHandle.GetCustomSignal().Emit();
848 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION );
849 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
850 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION );
852 // tracker should automatically disconnect here
853 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
854 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
856 // Test that functor is disconnected
857 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION );
858 customHandle.GetCustomSignal().Emit();
859 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1/*not incremented*/, TEST_LOCATION );
860 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
861 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
866 int UtcDaliTypeRegistrySignalConnectorTypeN(void)
868 // Test what happens when signal connnector (DoConnectSignalFailure method) returns false
870 ResetFunctorCounts();
872 TestApplication application;
874 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
875 DALI_TEST_CHECK( type );
877 TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( "CustomActor" );
878 DALI_TEST_CHECK( baseType );
880 BaseHandle handle = type.CreateInstance();
881 DALI_TEST_CHECK( handle );
883 MyTestCustomActor customHandle = MyTestCustomActor::DownCast( handle );
884 DALI_TEST_CHECK( customHandle );
886 DALI_TEST_EQUALS( type.GetActionCount(), TEST_ACTION_COUNT + baseType.GetActionCount(), TEST_LOCATION );
888 DALI_TEST_EQUALS( type.GetSignalCount(), TEST_SIGNAL_COUNT + baseType.GetSignalCount(), TEST_LOCATION );
891 TestConnectionTracker tracker;
893 bool connected = handle.ConnectSignal( &tracker, "sig2", CustomTestFunctor() );
894 DALI_TEST_EQUALS( connected, false/*This is supposed to fail*/, TEST_LOCATION );
895 DALI_TEST_CHECK( lastSignalConnectionCustom == "failed" );
896 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
897 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0/*deleted along with FunctorDelegate*/, TEST_LOCATION );
900 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
901 customHandle.GetCustomSignal().Emit();
902 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0/*never called*/, TEST_LOCATION );
904 // tracker should have nothing to disconnect here
907 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
908 customHandle.GetCustomSignal().Emit();
909 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0/*never called*/, TEST_LOCATION );
913 int UtcDaliTypeRegistryTypeActionP(void)
915 ResetFunctorCounts();
917 TestApplication application;
919 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
920 DALI_TEST_CHECK( type );
922 BaseHandle handle = type.CreateInstance();
923 DALI_TEST_CHECK( handle );
925 Property::Map attributes;
926 DALI_TEST_CHECK( handle.DoAction("act1", attributes) );
927 DALI_TEST_CHECK( lastActionCustom == "act1" );
932 int UtcDaliTypeRegistryTypeActionN(void)
934 ResetFunctorCounts();
936 TestApplication application;
938 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
939 DALI_TEST_CHECK( type );
941 BaseHandle handle = type.CreateInstance();
942 DALI_TEST_CHECK( handle );
944 Property::Map attributes;
945 DALI_TEST_CHECK( !handle.DoAction( "unknownAction", attributes ) );
950 int UtcDaliTypeRegistryPropertyRegistrationP(void)
952 TestApplication application;
953 TypeRegistry typeRegistry = TypeRegistry::Get();
955 // Check property count before property registration
956 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
957 DALI_TEST_CHECK( typeInfo );
958 BaseHandle handle = typeInfo.CreateInstance();
959 DALI_TEST_CHECK( handle );
960 Actor customActor = Actor::DownCast( handle );
961 DALI_TEST_CHECK( customActor );
962 unsigned int initialPropertyCount( customActor.GetPropertyCount() );
964 std::string propertyName( "prop1" );
965 int propertyIndex( PROPERTY_REGISTRATION_START_INDEX );
966 Property::Type propertyType( Property::BOOLEAN );
967 PropertyRegistration property1( customType1, propertyName, propertyIndex, propertyType, &SetProperty, &GetProperty );
969 // Check property count after registration
970 unsigned int postRegistrationPropertyCount( customActor.GetPropertyCount() );
971 DALI_TEST_EQUALS( initialPropertyCount + 1u, postRegistrationPropertyCount, TEST_LOCATION );
973 // Add custom property and check property count
974 customActor.RegisterProperty( "customProp1", true );
975 unsigned int customPropertyCount( customActor.GetPropertyCount() );
976 DALI_TEST_EQUALS( postRegistrationPropertyCount + 1u, customPropertyCount, TEST_LOCATION );
978 // Set the property, ensure SetProperty called
979 DALI_TEST_CHECK( !setPropertyCalled );
980 customActor.SetProperty( propertyIndex, false );
981 DALI_TEST_CHECK( setPropertyCalled );
983 // Get the property, ensure GetProperty called
984 DALI_TEST_CHECK( !getPropertyCalled );
985 (void)customActor.GetProperty< bool >( propertyIndex );
986 DALI_TEST_CHECK( getPropertyCalled );
988 // Get the property using GetCurrentProperty and ensure GetProperty is called
989 getPropertyCalled = false;
990 DALI_TEST_CHECK( !getPropertyCalled );
991 customActor.GetCurrentProperty< bool >( propertyIndex );
992 DALI_TEST_CHECK( getPropertyCalled );
994 // Check the property name
995 DALI_TEST_EQUALS( customActor.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
996 DALI_TEST_EQUALS( typeInfo.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
998 // Check the property index
999 DALI_TEST_EQUALS( customActor.GetPropertyIndex( propertyName ), propertyIndex, TEST_LOCATION );
1001 // Check the property type
1002 DALI_TEST_EQUALS( customActor.GetPropertyType( propertyIndex ), propertyType, TEST_LOCATION );
1004 // Check property count of type-info is 1
1005 Property::IndexContainer indices;
1006 typeInfo.GetPropertyIndices( indices );
1008 size_t typePropertyCount = typeInfo.GetPropertyCount();
1009 DALI_TEST_EQUALS( indices.Size(), Actor::New().GetPropertyCount() + 1u, TEST_LOCATION );
1010 DALI_TEST_EQUALS( indices.Size(), typePropertyCount, TEST_LOCATION );
1012 // Ensure indices returned from actor and customActor differ by two
1013 Actor actor = Actor::New();
1014 actor.GetPropertyIndices( indices );
1015 unsigned int actorIndices = indices.Size();
1016 customActor.GetPropertyIndices( indices );
1017 unsigned int customActorIndices = indices.Size();
1018 DALI_TEST_EQUALS( actorIndices + 2u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1022 int UtcDaliTypeRegistryPropertyRegistrationN(void)
1024 TestApplication application;
1025 TypeRegistry typeRegistry = TypeRegistry::Get();
1027 // Attempt to register a property type out-of-bounds index (less than)
1030 PropertyRegistration property1( customType1, "propName", PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN, &SetProperty, &GetProperty );
1031 tet_result( TET_FAIL );
1033 catch ( DaliException& e )
1035 DALI_TEST_ASSERT( e, "( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1038 // Attempt to register a property type out-of-bounds index (greater than)
1041 PropertyRegistration property1( customType1, "propName", PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN, &SetProperty, &GetProperty );
1042 tet_result( TET_FAIL );
1044 catch ( DaliException& e )
1046 DALI_TEST_ASSERT( e, "( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1052 int UtcDaliTypeRegistryAnimatablePropertyRegistrationP(void)
1054 TestApplication application;
1055 TypeRegistry typeRegistry = TypeRegistry::Get();
1057 // Check property count before property registration
1058 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1059 DALI_TEST_CHECK( typeInfo );
1060 BaseHandle handle = typeInfo.CreateInstance();
1061 DALI_TEST_CHECK( handle );
1062 Actor customActor = Actor::DownCast( handle );
1063 DALI_TEST_CHECK( customActor );
1064 Stage::GetCurrent().Add(customActor);
1066 unsigned int customPropertyCount( customActor.GetPropertyCount() );
1068 // Register animatable property
1069 std::string animatablePropertyName( "animatableProp1" );
1070 int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1071 Property::Type animatablePropertyType( Property::FLOAT );
1072 AnimatablePropertyRegistration animatableProperty( customType1, animatablePropertyName, animatablePropertyIndex, animatablePropertyType );
1074 // Check property count after registration
1075 DALI_TEST_EQUALS( customPropertyCount + 1u, customActor.GetPropertyCount(), TEST_LOCATION );
1077 // Set the animatable property value
1078 customActor.SetProperty( animatablePropertyIndex, 25.0f );
1080 // Render and notify
1081 application.SendNotification();
1082 application.Render();
1084 // Check the animatable property value
1085 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 25.f, TEST_LOCATION );
1087 // Check the animatable property name
1088 DALI_TEST_EQUALS( customActor.GetPropertyName( animatablePropertyIndex ), animatablePropertyName, TEST_LOCATION );
1090 // Check the animatable property index
1091 DALI_TEST_EQUALS( customActor.GetPropertyIndex( animatablePropertyName ), animatablePropertyIndex, TEST_LOCATION );
1093 // Check the animatable property type
1094 DALI_TEST_EQUALS( customActor.GetPropertyType( animatablePropertyIndex ), animatablePropertyType, TEST_LOCATION );
1096 // Check property count of type-info is 1
1097 Property::IndexContainer indices;
1098 typeInfo.GetPropertyIndices( indices );
1099 DALI_TEST_EQUALS( indices.Size(), customActor.GetPropertyCount(), TEST_LOCATION );
1101 // Ensure indices returned from actor and customActor differ by one
1102 Actor actor = Actor::New();
1103 actor.GetPropertyIndices( indices );
1104 unsigned int actorIndices = indices.Size();
1105 customActor.GetPropertyIndices( indices );
1106 unsigned int customActorIndices = indices.Size();
1107 DALI_TEST_EQUALS( actorIndices + 1u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1109 // check that the property is animatable
1110 Animation animation = Animation::New(0.2f);
1111 animation.AnimateTo( Property( customActor, animatablePropertyIndex ), 15.f, AlphaFunction::LINEAR );
1114 // Target value should change straight away
1115 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 15.0f, TEST_LOCATION );
1117 // Render and notify, animation play for 0.05 seconds
1118 application.SendNotification();
1119 application.Render(50);
1120 DALI_TEST_EQUALS( 0.25f, animation.GetCurrentProgress(), TEST_LOCATION );
1121 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 22.5f, TEST_LOCATION );
1123 // Render and notify, animation play for another 0.1 seconds
1124 application.SendNotification();
1125 application.Render(100);
1126 DALI_TEST_EQUALS( 0.75f, animation.GetCurrentProgress(), TEST_LOCATION );
1127 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 17.5f, TEST_LOCATION );
1132 int UtcDaliTypeRegistryAnimatablePropertyRegistrationN(void)
1134 TestApplication application;
1135 TypeRegistry typeRegistry = TypeRegistry::Get();
1137 // Attempt to register an animatable property type out-of-bounds index (less than)
1140 AnimatablePropertyRegistration property1( customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN );
1141 tet_result( TET_FAIL );
1143 catch ( DaliException& e )
1145 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1148 // Attempt to register an animatable property type out-of-bounds index (greater than)
1151 AnimatablePropertyRegistration property1( customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN );
1152 tet_result( TET_FAIL );
1154 catch ( DaliException& e )
1156 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1162 int UtcDaliTypeRegistryAnimatablePropertyRegistrationWithDefaultP(void)
1164 TestApplication application;
1165 TypeRegistry typeRegistry = TypeRegistry::Get();
1167 // Check property count before property registration
1168 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1169 DALI_TEST_CHECK( typeInfo );
1170 BaseHandle handle = typeInfo.CreateInstance();
1171 DALI_TEST_CHECK( handle );
1172 Actor customActor = Actor::DownCast( handle );
1173 DALI_TEST_CHECK( customActor );
1174 Stage::GetCurrent().Add(customActor);
1176 unsigned int customPropertyCount( customActor.GetPropertyCount() );
1178 // Register animatable property
1179 std::string animatablePropertyName( "animatableProp1" );
1180 int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1181 AnimatablePropertyRegistration animatableProperty1( customType1, animatablePropertyName, animatablePropertyIndex, 10.f );
1183 // Check property count after registration
1184 DALI_TEST_EQUALS( customPropertyCount + 1u, customActor.GetPropertyCount(), TEST_LOCATION );
1186 // Render and notify
1187 application.SendNotification();
1188 application.Render();
1190 // Check the animatable property value
1191 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 10.f, TEST_LOCATION );
1193 // Check the animatable property name
1194 DALI_TEST_EQUALS( customActor.GetPropertyName( animatablePropertyIndex ), animatablePropertyName, TEST_LOCATION );
1196 // Check the animatable property index
1197 DALI_TEST_EQUALS( customActor.GetPropertyIndex( animatablePropertyName ), animatablePropertyIndex, TEST_LOCATION );
1199 // Check the animatable property type
1200 DALI_TEST_EQUALS( customActor.GetPropertyType( animatablePropertyIndex ), Property::FLOAT, TEST_LOCATION );
1202 // Check property count of type-info
1203 Property::IndexContainer indices;
1204 typeInfo.GetPropertyIndices( indices );
1205 DALI_TEST_EQUALS( indices.Size(), customActor.GetPropertyCount(), TEST_LOCATION );
1207 // Ensure indices returned from actor and customActor differ by one
1208 Actor actor = Actor::New();
1209 actor.GetPropertyIndices( indices );
1210 unsigned int actorIndices = indices.Size();
1211 customActor.GetPropertyIndices( indices );
1212 unsigned int customActorIndices = indices.Size();
1213 DALI_TEST_EQUALS( actorIndices + 1u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1215 // check that the property is animatable
1216 Animation animation = Animation::New(0.2f);
1217 animation.AnimateTo( Property( customActor, animatablePropertyIndex ), 20.f, AlphaFunction::LINEAR );
1220 // Target value should change straight away
1221 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 20.0f, TEST_LOCATION );
1223 // Render and notify, animation play for 0.05 seconds
1224 application.SendNotification();
1225 application.Render(50);
1226 DALI_TEST_EQUALS( 0.25f, animation.GetCurrentProgress(), TEST_LOCATION );
1227 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 12.5f, TEST_LOCATION );
1229 // Render and notify, animation play for another 0.1 seconds
1230 application.SendNotification();
1231 application.Render(100);
1232 DALI_TEST_EQUALS( 0.75f, animation.GetCurrentProgress(), TEST_LOCATION );
1233 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 17.5f, TEST_LOCATION );
1238 int UtcDaliTypeRegistryAnimatablePropertyRegistrationWithDefaultN(void)
1240 TestApplication application;
1241 TypeRegistry typeRegistry = TypeRegistry::Get();
1243 // Attempt to register an animatable property type out-of-bounds index (less than)
1246 AnimatablePropertyRegistration property1( customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX - 1, false );
1247 tet_result( TET_FAIL );
1249 catch ( DaliException& e )
1251 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1254 // Attempt to register an animatable property type out-of-bounds index (greater than)
1257 AnimatablePropertyRegistration property1( customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX + 1, true );
1258 tet_result( TET_FAIL );
1260 catch ( DaliException& e )
1262 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1268 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationP(void)
1270 TestApplication application;
1271 TypeRegistry typeRegistry = TypeRegistry::Get();
1273 // Check property count before property registration
1274 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1275 DALI_TEST_CHECK( typeInfo );
1276 BaseHandle handle = typeInfo.CreateInstance();
1277 DALI_TEST_CHECK( handle );
1278 Actor customActor = Actor::DownCast( handle );
1279 DALI_TEST_CHECK( customActor );
1281 unsigned int customPropertyCount( customActor.GetPropertyCount() );
1283 // Register animatable property
1284 std::string animatablePropertyName( "animatableProp1" );
1285 int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1286 Property::Type animatablePropertyType( Property::VECTOR2 );
1287 AnimatablePropertyRegistration animatableProperty1( customType1, animatablePropertyName, animatablePropertyIndex, animatablePropertyType );
1289 // Check property count after registration
1290 DALI_TEST_EQUALS( customPropertyCount + 1u, customActor.GetPropertyCount(), TEST_LOCATION );
1292 // Set the animatable property value
1293 customActor.SetProperty( animatablePropertyIndex, Vector2(25.0f, 50.0f) );
1295 // Render and notify
1296 application.SendNotification();
1297 application.Render();
1299 // Check the animatable property value
1300 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( animatablePropertyIndex ), Vector2(25.0f, 50.0f), TEST_LOCATION );
1302 // Check the animatable property name
1303 DALI_TEST_EQUALS( customActor.GetPropertyName( animatablePropertyIndex ), animatablePropertyName, TEST_LOCATION );
1305 // Check the animatable property index
1306 DALI_TEST_EQUALS( customActor.GetPropertyIndex( animatablePropertyName ), animatablePropertyIndex, TEST_LOCATION );
1308 // Check the animatable property type
1309 DALI_TEST_EQUALS( customActor.GetPropertyType( animatablePropertyIndex ), animatablePropertyType, TEST_LOCATION );
1311 // Check property count of type-info
1312 Property::IndexContainer indices;
1313 typeInfo.GetPropertyIndices( indices );
1314 DALI_TEST_EQUALS( indices.Size(), customActor.GetPropertyCount(), TEST_LOCATION );
1316 // Register animatable property components
1317 std::string animatablePropertyComponentName1( "animatableProp1X" );
1318 int animatablePropertyComponentIndex1( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1 );
1319 AnimatablePropertyComponentRegistration animatablePropertyComponent1( customType1, animatablePropertyComponentName1, animatablePropertyComponentIndex1, animatablePropertyIndex, 0 );
1321 std::string animatablePropertyComponentName2( "animatableProp1Y" );
1322 int animatablePropertyComponentIndex2( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2 );
1323 AnimatablePropertyComponentRegistration animatablePropertyComponent2( customType1, animatablePropertyComponentName2, animatablePropertyComponentIndex2, animatablePropertyIndex, 1 );
1325 // Check property count after registration
1326 DALI_TEST_EQUALS( customPropertyCount + 3u, customActor.GetPropertyCount(), TEST_LOCATION );
1328 // Check the animatable property component value
1329 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex1 ), 25.0f, TEST_LOCATION );
1330 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex2 ), 50.0f, TEST_LOCATION );
1332 // Set the animatable property component value
1333 customActor.SetProperty( animatablePropertyComponentIndex1, 150.0f );
1335 // Render and notify
1336 application.SendNotification();
1337 application.Render();
1339 // Check the animatable property value
1340 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector2 >( animatablePropertyIndex ), Vector2(150.0f, 50.0f), TEST_LOCATION );
1341 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex1 ), 150.0f, TEST_LOCATION );
1342 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex2 ), 50.0f, TEST_LOCATION );
1344 // Set the animatable property component value
1345 customActor.SetProperty( animatablePropertyComponentIndex2, 225.0f );
1347 // Render and notify
1348 application.SendNotification();
1349 application.Render();
1351 // Check the animatable property value
1352 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector2 >( animatablePropertyIndex ), Vector2(150.0f, 225.0f), TEST_LOCATION );
1353 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex1 ), 150.0f, TEST_LOCATION );
1354 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex2 ), 225.0f, TEST_LOCATION );
1356 // Ensure indices returned from actor and customActor differ by three
1357 Actor actor = Actor::New();
1358 actor.GetPropertyIndices( indices );
1359 unsigned int actorIndices = indices.Size();
1360 customActor.GetPropertyIndices( indices );
1361 unsigned int customActorIndices = indices.Size();
1362 DALI_TEST_EQUALS( actorIndices + 3u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1364 // Attempt to animate component property, it should not crash
1365 Animation animation = Animation::New( 1.0f );
1366 animation.AnimateTo( Property( customActor, animatablePropertyComponentIndex1 ), 200.0f );
1369 // Check the property value
1370 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( animatablePropertyIndex ), Vector2(200.0f, 225.0f), TEST_LOCATION );
1371 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex1 ), 200.0f, TEST_LOCATION );
1372 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex2 ), 225.0f, TEST_LOCATION );
1377 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationVector2AnimateByP(void)
1379 TestApplication application;
1380 TypeRegistry typeRegistry = TypeRegistry::Get();
1382 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1383 DALI_TEST_CHECK( typeInfo );
1384 BaseHandle handle = typeInfo.CreateInstance();
1385 DALI_TEST_CHECK( handle );
1386 Actor customActor = Actor::DownCast( handle );
1387 DALI_TEST_CHECK( customActor );
1389 const unsigned int index = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX;
1390 const unsigned int xComponentIndex = index + 1;
1391 const unsigned int yComponentIndex = index + 2;
1392 const Vector2 initialValue( 20.0f, 40.0f );
1394 // Register animatable property & its components
1395 AnimatablePropertyRegistration animatableProperty1( customType1, "animatableProp1", index, initialValue );
1396 AnimatablePropertyComponentRegistration animatablePropertyComponent1( customType1, "animatableProp1X", xComponentIndex, index, 0 );
1397 AnimatablePropertyComponentRegistration animatablePropertyComponent2( customType1, "animatableProp1Y", yComponentIndex, index, 1 );
1399 // Check the animatable property value
1400 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( index ), initialValue, TEST_LOCATION );
1401 DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
1402 DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
1404 // Render and notify
1405 application.SendNotification();
1406 application.Render();
1408 // Check the animatable property current value
1409 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector2 >( index ), initialValue, TEST_LOCATION );
1410 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
1411 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
1414 const Vector2 targetValue( 45.0f, 53.0f );
1415 const Vector2 relativeValue( targetValue - initialValue );
1417 Animation animation = Animation::New( 1.0f );
1418 animation.AnimateBy( Property( customActor, xComponentIndex ), relativeValue.x );
1419 animation.AnimateBy( Property( customActor, yComponentIndex ), relativeValue.y );
1422 // Target values should change straight away
1423 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
1424 DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), targetValue.x, TEST_LOCATION );
1425 DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), targetValue.y, TEST_LOCATION );
1430 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationVector3AnimateByP(void)
1432 TestApplication application;
1433 TypeRegistry typeRegistry = TypeRegistry::Get();
1435 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1436 DALI_TEST_CHECK( typeInfo );
1437 BaseHandle handle = typeInfo.CreateInstance();
1438 DALI_TEST_CHECK( handle );
1439 Actor customActor = Actor::DownCast( handle );
1440 DALI_TEST_CHECK( customActor );
1442 const unsigned int index = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX;
1443 const unsigned int xComponentIndex = index + 1;
1444 const unsigned int yComponentIndex = index + 2;
1445 const unsigned int zComponentIndex = index + 3;
1446 const Vector3 initialValue( 20.0f, 40.0f, 50.0f );
1448 // Register animatable property & its components
1449 AnimatablePropertyRegistration animatableProperty1( customType1, "animatableProp1", index, initialValue );
1450 AnimatablePropertyComponentRegistration animatablePropertyComponent1( customType1, "animatableProp1X", xComponentIndex, index, 0 );
1451 AnimatablePropertyComponentRegistration animatablePropertyComponent2( customType1, "animatableProp1Y", yComponentIndex, index, 1 );
1452 AnimatablePropertyComponentRegistration animatablePropertyComponent3( customType1, "animatableProp1Z", zComponentIndex, index, 2 );
1454 // Check the animatable property value
1455 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( index ), initialValue, TEST_LOCATION );
1456 DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
1457 DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
1458 DALI_TEST_EQUALS( customActor.GetProperty< float >( zComponentIndex ), initialValue.z, TEST_LOCATION );
1460 // Render and notify
1461 application.SendNotification();
1462 application.Render();
1464 // Check the animatable property current value
1465 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector3 >( index ), initialValue, TEST_LOCATION );
1466 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
1467 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
1468 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( zComponentIndex ), initialValue.z, TEST_LOCATION );
1471 const Vector3 targetValue( 45.0f, 53.0f, 25.0f );
1472 const Vector3 relativeValue( targetValue - initialValue );
1474 Animation animation = Animation::New( 1.0f );
1475 animation.AnimateBy( Property( customActor, xComponentIndex ), relativeValue.x );
1476 animation.AnimateBy( Property( customActor, yComponentIndex ), relativeValue.y );
1477 animation.AnimateBy( Property( customActor, zComponentIndex ), relativeValue.z );
1480 // Target values should change straight away
1481 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
1482 DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), targetValue.x, TEST_LOCATION );
1483 DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), targetValue.y, TEST_LOCATION );
1484 DALI_TEST_EQUALS( customActor.GetProperty< float >( zComponentIndex ), targetValue.z, TEST_LOCATION );
1489 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationVector4AnimateByP(void)
1491 TestApplication application;
1492 TypeRegistry typeRegistry = TypeRegistry::Get();
1494 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1495 DALI_TEST_CHECK( typeInfo );
1496 BaseHandle handle = typeInfo.CreateInstance();
1497 DALI_TEST_CHECK( handle );
1498 Actor customActor = Actor::DownCast( handle );
1499 DALI_TEST_CHECK( customActor );
1501 const unsigned int index = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX;
1502 const unsigned int xComponentIndex = index + 1;
1503 const unsigned int yComponentIndex = index + 2;
1504 const unsigned int zComponentIndex = index + 3;
1505 const unsigned int wComponentIndex = index + 4;
1506 const Vector4 initialValue( 20.0f, 40.0f, 50.0f, 60.0f );
1508 // Register animatable property & its components
1509 AnimatablePropertyRegistration animatableProperty1( customType1, "animatableProp1", index, initialValue );
1510 AnimatablePropertyComponentRegistration animatablePropertyComponent1( customType1, "animatableProp1X", xComponentIndex, index, 0 );
1511 AnimatablePropertyComponentRegistration animatablePropertyComponent2( customType1, "animatableProp1Y", yComponentIndex, index, 1 );
1512 AnimatablePropertyComponentRegistration animatablePropertyComponent3( customType1, "animatableProp1Z", zComponentIndex, index, 2 );
1513 AnimatablePropertyComponentRegistration animatablePropertyComponent4( customType1, "animatableProp1W", wComponentIndex, index, 3 );
1515 // Check the animatable property value
1516 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( index ), initialValue, TEST_LOCATION );
1517 DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
1518 DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
1519 DALI_TEST_EQUALS( customActor.GetProperty< float >( zComponentIndex ), initialValue.z, TEST_LOCATION );
1520 DALI_TEST_EQUALS( customActor.GetProperty< float >( wComponentIndex ), initialValue.w, TEST_LOCATION );
1522 // Render and notify
1523 application.SendNotification();
1524 application.Render();
1526 // Check the animatable property current value
1527 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector4 >( index ), initialValue, TEST_LOCATION );
1528 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
1529 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
1530 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( zComponentIndex ), initialValue.z, TEST_LOCATION );
1531 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( wComponentIndex ), initialValue.w, TEST_LOCATION );
1534 const Vector4 targetValue( 45.0f, 53.0f, 25.0f, 13.0f );
1535 const Vector4 relativeValue( targetValue - initialValue );
1537 Animation animation = Animation::New( 1.0f );
1538 animation.AnimateBy( Property( customActor, xComponentIndex ), relativeValue.x );
1539 animation.AnimateBy( Property( customActor, yComponentIndex ), relativeValue.y );
1540 animation.AnimateBy( Property( customActor, zComponentIndex ), relativeValue.z );
1541 animation.AnimateBy( Property( customActor, wComponentIndex ), relativeValue.w );
1544 // Target values should change straight away
1545 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
1546 DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), targetValue.x, TEST_LOCATION );
1547 DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), targetValue.y, TEST_LOCATION );
1548 DALI_TEST_EQUALS( customActor.GetProperty< float >( zComponentIndex ), targetValue.z, TEST_LOCATION );
1549 DALI_TEST_EQUALS( customActor.GetProperty< float >( wComponentIndex ), targetValue.w, TEST_LOCATION );
1554 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationN(void)
1556 TestApplication application;
1557 TypeRegistry typeRegistry = TypeRegistry::Get();
1559 // Register animatable property with the type of Vector2
1560 int animatablePropertyIndex1( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1561 AnimatablePropertyRegistration animatableProperty1( customType1, "animatableProp1", animatablePropertyIndex1, Property::VECTOR2 );
1563 // Attempt to register an animatable property component out-of-bounds index (less than)
1566 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp1X", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX - 1, animatablePropertyIndex1, 0 );
1567 tet_result( TET_FAIL );
1569 catch ( DaliException& e )
1571 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1574 // Attempt to register an animatable property component out-of-bounds index (greater than)
1577 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp1X", ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX + 1, animatablePropertyIndex1, 0 );
1578 tet_result( TET_FAIL );
1580 catch ( DaliException& e )
1582 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1585 // Register an animatable property component
1586 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp1X", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1, animatablePropertyIndex1, 0 );
1588 // Attempt to register another animatable property component with the same component index
1591 AnimatablePropertyComponentRegistration propertyComponent2( customType1, "animatableProp1Y", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2, animatablePropertyIndex1, 0 );
1592 tet_result( TET_FAIL );
1594 catch ( DaliException& e )
1596 DALI_TEST_ASSERT( e, "Property component already registered", TEST_LOCATION );
1599 // Register animatable property with the type of boolean
1600 int animatablePropertyIndex2( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2 );
1601 AnimatablePropertyRegistration animatableProperty2( customType1, "animatableProp2", animatablePropertyIndex2, Property::BOOLEAN );
1603 // Attempt to register an animatable property component for the above property with boolean type
1606 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp2X", animatablePropertyIndex2 + 1, animatablePropertyIndex2, 0 );
1607 tet_result( TET_FAIL );
1609 catch ( DaliException& e )
1611 DALI_TEST_ASSERT( e, "Base property does not support component", TEST_LOCATION );
1617 int UtcDaliTypeRegistryChildPropertyRegistrationP(void)
1619 TestApplication application;
1620 TypeRegistry typeRegistry = TypeRegistry::Get();
1622 // Check property count before property registration
1623 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1624 DALI_TEST_CHECK( typeInfo );
1625 BaseHandle handle = typeInfo.CreateInstance();
1626 DALI_TEST_CHECK( handle );
1627 Actor customActor = Actor::DownCast( handle );
1628 DALI_TEST_CHECK( customActor );
1629 unsigned int initialPropertyCount( customActor.GetPropertyCount() );
1631 // Register child properties to the parent
1632 std::string propertyName( "childProp1" );
1633 int propertyIndex( CHILD_PROPERTY_REGISTRATION_START_INDEX );
1634 Property::Type propertyType( Property::BOOLEAN );
1635 ChildPropertyRegistration childProperty1( customType1, propertyName, propertyIndex, propertyType );
1637 std::string propertyName2( "childProp2" );
1638 int propertyIndex2( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1 );
1639 Property::Type propertyType2( Property::INTEGER );
1640 ChildPropertyRegistration childProperty2( customType1, propertyName2, propertyIndex2, propertyType2 );
1642 std::string propertyName3( "childProp3" );
1643 int propertyIndex3( CHILD_PROPERTY_REGISTRATION_START_INDEX + 2 );
1644 Property::Type propertyType3( Property::FLOAT );
1645 ChildPropertyRegistration childProperty3( customType1, propertyName3, propertyIndex3, propertyType3 );
1647 std::string propertyName4( "childProp4" );
1648 int propertyIndex4( CHILD_PROPERTY_REGISTRATION_START_INDEX + 3 );
1649 Property::Type propertyType4( Property::INTEGER );
1650 ChildPropertyRegistration childProperty4( customType1, propertyName4, propertyIndex4, propertyType4 );
1652 // Check property count are not changed because the child properties will not be created for the parent
1653 DALI_TEST_EQUALS( initialPropertyCount, customActor.GetPropertyCount(), TEST_LOCATION );
1655 // check the child property type
1656 Internal::TypeInfo& typeInfoImpl = GetImplementation( typeInfo );
1657 Property::Type type = typeInfoImpl.GetChildPropertyType( typeInfoImpl.GetChildPropertyIndex("childProp4") );
1658 DALI_TEST_EQUALS( type, Property::INTEGER, TEST_LOCATION );
1660 std::string unRegisteredChildName( typeInfoImpl.GetChildPropertyName( CHILD_PROPERTY_REGISTRATION_START_INDEX + 4 ) );
1661 DALI_TEST_EQUALS( unRegisteredChildName, "", TEST_LOCATION );
1663 // Create a child actor
1664 Actor childActor = Actor::New();
1665 DALI_TEST_CHECK( childActor );
1666 unsigned int initialChildActorPropertyCount( childActor.GetPropertyCount() );
1668 // The type of child properties should be Property::None as the child hasn't registered any child property yet.
1669 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex ), Property::NONE, TEST_LOCATION );
1670 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex2 ), Property::NONE, TEST_LOCATION );
1671 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex3 ), Property::NONE, TEST_LOCATION );
1672 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex4 ), Property::NONE, TEST_LOCATION );
1674 // Set the value for the first child property when the child actor doesn't have a parent yet
1675 childActor.SetProperty(propertyIndex, true);
1677 // Check that the first child property is dynamically created
1678 DALI_TEST_EQUALS( initialChildActorPropertyCount + 1u, childActor.GetPropertyCount(), TEST_LOCATION );
1680 // Check the first child property value
1681 DALI_TEST_EQUALS( childActor.GetProperty< bool >( propertyIndex ), true, TEST_LOCATION );
1683 // Check the first child property type
1684 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex ), propertyType, TEST_LOCATION );
1686 // Check that the first child property have no name, as it doesn't have a parent yet.
1687 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex ), "", TEST_LOCATION );
1689 // Check that the first property can't be accessed through its name, as it doesn't have a parent yet.
1690 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName ), Property::INVALID_INDEX, TEST_LOCATION );
1692 // Create a custom property for the child with the same name as the second child property registered to the parent
1693 Property::Index customPropertyIndex = childActor.RegisterProperty(propertyName2, 100, Property::READ_WRITE);
1695 // Check that the custom property is created
1696 DALI_TEST_EQUALS( initialChildActorPropertyCount + 2u, childActor.GetPropertyCount(), TEST_LOCATION );
1698 // Check the property value
1699 DALI_TEST_EQUALS( childActor.GetProperty< int >( customPropertyIndex ), 100, TEST_LOCATION );
1701 // Check the property index
1702 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName2 ), customPropertyIndex, TEST_LOCATION );
1704 // Check the property type
1705 DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex ), propertyType2, TEST_LOCATION );
1707 // Check the property name
1708 DALI_TEST_EQUALS( childActor.GetPropertyName( customPropertyIndex ), propertyName2, TEST_LOCATION );
1710 // Now add the child actor to the parent
1711 customActor.Add( childActor );
1713 // Check that the first child property now has the correct name as previously registered to the parent
1714 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
1716 // Check that the child property index for the first child property can now be retrieved through its child property name
1717 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName ), propertyIndex, TEST_LOCATION );
1719 // Check that the second child property now has the correct index as previously registered to the parent
1720 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex2 ), propertyName2, TEST_LOCATION );
1722 // Check that the second child property can be accessed through both its custom property index and its child property index
1723 DALI_TEST_EQUALS( childActor.GetProperty< int >( customPropertyIndex ), 100, TEST_LOCATION );
1724 DALI_TEST_EQUALS( childActor.GetProperty< int >( propertyIndex2 ), 100, TEST_LOCATION );
1725 DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex ), propertyType2, TEST_LOCATION );
1726 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex2 ), propertyType2, TEST_LOCATION );
1728 // Check that the child property index for the second child property can now be retrieved through its child property name
1729 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName2 ), propertyIndex2, TEST_LOCATION );
1731 // Set the value for the third child property when the child actor is already added to the parent
1732 childActor.SetProperty(propertyIndex3, 0.15f);
1734 // Check that the third child property is dynamically created
1735 DALI_TEST_EQUALS( initialChildActorPropertyCount + 3u, childActor.GetPropertyCount(), TEST_LOCATION );
1737 // Check the third child property value
1738 DALI_TEST_EQUALS( childActor.GetProperty< float >( propertyIndex3 ), 0.15f, TEST_LOCATION );
1740 // Check the third child property type
1741 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex3 ), propertyType3, TEST_LOCATION );
1743 // Check the third child property name
1744 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex3 ), propertyName3, TEST_LOCATION );
1746 // Check the third child property index.
1747 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName3 ), propertyIndex3, TEST_LOCATION );
1749 // Create a custom property for the child with the same name as the fourth child property registered to the parent
1750 Property::Index customPropertyIndex2 = childActor.RegisterProperty(propertyName4, 20, Property::READ_WRITE);
1752 // Check that the custom property is created
1753 DALI_TEST_EQUALS( initialChildActorPropertyCount + 4u, childActor.GetPropertyCount(), TEST_LOCATION );
1755 // Check the fourth child property value
1756 DALI_TEST_EQUALS( childActor.GetProperty< int >( propertyIndex4 ), 20, TEST_LOCATION );
1757 DALI_TEST_EQUALS( childActor.GetProperty< int >( customPropertyIndex2 ), 20, TEST_LOCATION );
1759 // Check the fourth child property type
1760 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex4 ), propertyType4, TEST_LOCATION );
1761 DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex2 ), propertyType4, TEST_LOCATION );
1763 // Check the fourth child property name
1764 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex4 ), propertyName4, TEST_LOCATION );
1765 DALI_TEST_EQUALS( childActor.GetPropertyName( customPropertyIndex2 ), propertyName4, TEST_LOCATION );
1767 // Check the fourth child property index.
1768 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName4 ), propertyIndex4, TEST_LOCATION );
1770 // Now create another parent actor with different child properties registered
1771 TypeInfo typeInfo2 = typeRegistry.GetTypeInfo( "MyNamedActor" );
1772 DALI_TEST_CHECK( typeInfo2 );
1773 BaseHandle handle2 = typeInfo2.CreateInstance();
1774 DALI_TEST_CHECK( handle2 );
1775 Actor customActor2 = Actor::DownCast( handle2 );
1776 DALI_TEST_CHECK( customActor2 );
1778 // Register child properties to the new parent
1779 std::string newPropertyName( "newChildProp" );
1780 int newPropertyIndex( CHILD_PROPERTY_REGISTRATION_START_INDEX ); // The same index as the first child property "childProp1" in the old parent
1781 Property::Type newPropertyType( Property::VECTOR2 );
1782 ChildPropertyRegistration newChildProperty( namedActorType, newPropertyName, newPropertyIndex, newPropertyType );
1784 std::string newPropertyName2( "childProp3" ); // The same name as the third child property in the old parent
1785 int newPropertyIndex2( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1 ); // The same index as the second child property "childProp2" in the old parent
1786 Property::Type newPropertyType2( Property::FLOAT ); // The same type as the third child property in the old parent
1787 ChildPropertyRegistration newChildProperty2( namedActorType, newPropertyName2, newPropertyIndex2, newPropertyType2 );
1789 // Now move the child actor to the new parent
1790 customActor2.Add( childActor );
1792 // "childProp1" is not a valid child property supported by the new parent, so nothing changed
1793 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex ), propertyType, TEST_LOCATION );
1794 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
1795 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName ), propertyIndex, TEST_LOCATION );
1797 // "childProp3" is a valid child property supported by the new parent
1798 // So it should get its new child property index and should just work
1799 DALI_TEST_EQUALS( childActor.GetPropertyType( newPropertyIndex2 ), newPropertyType2, TEST_LOCATION );
1800 DALI_TEST_EQUALS( childActor.GetPropertyName( newPropertyIndex2 ), newPropertyName2, TEST_LOCATION );
1801 DALI_TEST_EQUALS( childActor.GetPropertyIndex( newPropertyName2 ), newPropertyIndex2, TEST_LOCATION );
1802 DALI_TEST_EQUALS( childActor.GetProperty< float >( newPropertyIndex2 ), 0.15f, TEST_LOCATION );
1804 // Now register a custom property called "newChildProp"
1805 Property::Index customPropertyIndex3 = childActor.RegisterProperty("newChildProp", Vector2( 10.0f, 10.0f ), Property::READ_WRITE);
1807 // Check that the custom property is created
1808 DALI_TEST_EQUALS( initialChildActorPropertyCount + 5u, childActor.GetPropertyCount(), TEST_LOCATION );
1810 // This is a valid child property registered to the new parent
1811 // So should be able to access it through both its custom property index and its registered child property index
1812 DALI_TEST_EQUALS( childActor.GetPropertyType( newPropertyIndex ), newPropertyType, TEST_LOCATION );
1813 DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex3 ), newPropertyType, TEST_LOCATION );
1814 DALI_TEST_EQUALS( childActor.GetPropertyName( newPropertyIndex ), newPropertyName, TEST_LOCATION ); // This should return the new name, although the child property index remains the same
1815 DALI_TEST_EQUALS( childActor.GetPropertyName( customPropertyIndex3 ), newPropertyName, TEST_LOCATION );
1816 DALI_TEST_EQUALS( childActor.GetProperty< Vector2 >( newPropertyIndex ), Vector2( 10.0f, 10.0f ), TEST_LOCATION );
1817 DALI_TEST_EQUALS( childActor.GetProperty< Vector2 >( customPropertyIndex3 ), Vector2( 10.0f, 10.0f ), TEST_LOCATION );
1819 // Should return the child property index by given its name
1820 DALI_TEST_EQUALS( childActor.GetPropertyIndex( newPropertyName ), newPropertyIndex, TEST_LOCATION );
1826 int UtcDaliTypeRegistryChildPropertyRegistrationN(void)
1828 TestApplication application;
1829 TypeRegistry typeRegistry = TypeRegistry::Get();
1831 // Attempt to register a child property type out-of-bounds index (less than)
1834 ChildPropertyRegistration property1( customType1, "propName", CHILD_PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN );
1835 tet_result( TET_FAIL );
1837 catch ( DaliException& e )
1839 DALI_TEST_ASSERT( e, "( index >= CHILD_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1842 // Attempt to register a child property type out-of-bounds index (greater than)
1845 ChildPropertyRegistration property1( customType1, "propName", CHILD_PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN );
1846 tet_result( TET_FAIL );
1848 catch ( DaliException& e )
1850 DALI_TEST_ASSERT( e, "( index >= CHILD_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1857 /*******************************************************************************
1859 * Action through the base handle
1861 ******************************************************************************/
1862 int UtcDaliTypeRegistryActionViaBaseHandle(void)
1864 TestApplication application;
1868 type = TypeRegistry::Get().GetTypeInfo( "Actor" );
1869 DALI_TEST_CHECK( type );
1871 BaseHandle hdl = type.CreateInstance();
1872 DALI_TEST_CHECK( hdl );
1874 Actor a = Actor::DownCast(hdl);
1875 DALI_TEST_CHECK( a );
1877 a.SetVisible(false);
1879 application.SendNotification();
1880 application.Render(0);
1881 DALI_TEST_CHECK(!a.IsVisible());
1883 Property::Map attributes;
1885 DALI_TEST_CHECK(hdl.DoAction("show", attributes));
1887 application.SendNotification();
1888 application.Render(0);
1889 DALI_TEST_CHECK(a.IsVisible());
1891 DALI_TEST_CHECK(!hdl.DoAction("unknownAction", attributes));
1895 int UtcDaliPropertyRegistrationFunctions(void)
1897 TestApplication application;
1898 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 10;
1900 // Attempt to register a property without a setter
1903 PropertyRegistration property1( customType1, "propName", propertyIndex++, Property::BOOLEAN, NULL, &GetProperty );
1904 tet_result( TET_PASS );
1906 catch ( DaliException& e )
1908 tet_result( TET_FAIL );
1911 // Attempt to register a property without a getter
1914 PropertyRegistration property1( customType1, "propName", propertyIndex++, Property::BOOLEAN, NULL, NULL );
1915 tet_result( TET_FAIL );
1917 catch ( DaliException& e )
1919 DALI_TEST_ASSERT( e, "! \"GetProperty", TEST_LOCATION );
1924 int UtcDaliPropertyRegistrationAddSameIndex(void)
1926 TestApplication application;
1927 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 100;
1929 // Add one property with a valid property index
1930 PropertyRegistration property1( customType1, "propName", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
1932 // Attempt to add another property with the same index
1935 PropertyRegistration property2( customType1, "propName2", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
1937 catch ( DaliException& e )
1939 DALI_TEST_ASSERT( e, "! \"Property index already added", TEST_LOCATION );
1942 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 100;
1944 // Add one property with a valid property index
1945 AnimatablePropertyRegistration property3( customType1, "animPropName", animatablePropertyIndex, Property::BOOLEAN );
1947 // Attempt to add another property with the same index
1950 AnimatablePropertyRegistration property4( customType1, "animPropName2", animatablePropertyIndex, Property::BOOLEAN );
1952 catch ( DaliException& e )
1954 DALI_TEST_ASSERT( e, "! \"Property index already added", TEST_LOCATION );
1959 int UtcDaliPropertyRegistrationPropertyWritableP(void)
1961 TestApplication application;
1962 int propertyIndex1 = PROPERTY_REGISTRATION_START_INDEX + 200;
1963 int propertyIndex2 = PROPERTY_REGISTRATION_START_INDEX + 201;
1965 // Add two properties, one with SetProperty, one without
1966 PropertyRegistration property1( customType1, "propNameReadwrite", propertyIndex1, Property::BOOLEAN, &SetProperty, &GetProperty );
1967 PropertyRegistration property2( customType1, "propNameReadonly", propertyIndex2, Property::BOOLEAN, NULL, &GetProperty );
1969 // Create custom-actor
1970 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
1971 DALI_TEST_CHECK( typeInfo );
1972 BaseHandle handle = typeInfo.CreateInstance();
1973 DALI_TEST_CHECK( handle );
1974 Actor customActor = Actor::DownCast( handle );
1975 DALI_TEST_CHECK( customActor );
1977 // Check whether properties are writable
1978 DALI_TEST_CHECK( customActor.IsPropertyWritable( propertyIndex1 ) );
1979 DALI_TEST_CHECK( ! customActor.IsPropertyWritable( propertyIndex2 ) );
1982 // Check the property is writable in the type registry
1983 Internal::TypeInfo& typeInfoImpl = GetImplementation( typeInfo );
1985 DALI_TEST_EQUALS( typeInfoImpl.IsPropertyWritable( propertyIndex1 ), true, TEST_LOCATION );
1990 int UtcDaliPropertyRegistrationPropertyWritableN(void)
1992 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
1993 Internal::TypeInfo& typeInfoImpl = GetImplementation( typeInfo );
1995 DALI_TEST_EQUALS( typeInfoImpl.IsPropertyWritable( Actor::Property::COLOR), true, TEST_LOCATION );
2000 int UtcDaliPropertyRegistrationPropertyAnimatable(void)
2002 TestApplication application;
2003 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 400;
2004 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 400;
2006 // These properties are not animatable
2007 PropertyRegistration property1( customType1, "propName", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
2009 // These properties are animatable
2010 AnimatablePropertyRegistration property2( customType1, "animPropName", animatablePropertyIndex, Property::BOOLEAN );
2012 // Create custom-actor
2013 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
2014 DALI_TEST_CHECK( typeInfo );
2015 BaseHandle handle = typeInfo.CreateInstance();
2016 DALI_TEST_CHECK( handle );
2017 Actor customActor = Actor::DownCast( handle );
2018 DALI_TEST_CHECK( customActor );
2020 // Check if animatable
2021 DALI_TEST_CHECK( ! customActor.IsPropertyAnimatable( propertyIndex ) );
2022 DALI_TEST_CHECK( customActor.IsPropertyAnimatable( animatablePropertyIndex ) );
2024 // Create another instance of custom-actor
2025 BaseHandle handle2 = typeInfo.CreateInstance();
2026 DALI_TEST_CHECK( handle2 );
2027 Actor customActor2 = Actor::DownCast( handle2 );
2028 DALI_TEST_CHECK( customActor2 );
2030 // Check if animatable
2031 DALI_TEST_CHECK( ! customActor2.IsPropertyAnimatable( propertyIndex ) );
2032 DALI_TEST_CHECK( customActor2.IsPropertyAnimatable( animatablePropertyIndex ) );
2036 int UtcDaliPropertyRegistrationUnregisteredGetAndSet(void)
2038 TestApplication application;
2039 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 2000;
2040 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2000;
2042 // Create custom-actor
2043 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
2044 DALI_TEST_CHECK( typeInfo );
2045 BaseHandle handle = typeInfo.CreateInstance();
2046 DALI_TEST_CHECK( handle );
2047 Actor customActor = Actor::DownCast( handle );
2048 DALI_TEST_CHECK( customActor );
2050 // Try to set an index that hasn't been registered, this is a no-op for now, to be fixed in future
2051 customActor.SetProperty( propertyIndex, true );
2052 // DALI_TEST_EQUALS( true, customActor.GetProperty( propertyIndex ).Get<bool>(), TEST_LOCATION);
2054 // Try to set an index that hasn't been registered
2055 customActor.SetProperty( animatablePropertyIndex, true );
2056 DALI_TEST_EQUALS( true, customActor.GetProperty( animatablePropertyIndex ).Get<bool>(), TEST_LOCATION);
2062 int UtcDaliLongPressGestureDetectorTypeRegistry(void)
2064 TestApplication application;
2066 Actor actor = Actor::New();
2067 actor.SetSize(100.0f, 100.0f);
2068 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2069 Stage::GetCurrent().Add(actor);
2073 type = TypeRegistry::Get().GetTypeInfo( "LongPressGestureDetector" );
2074 DALI_TEST_CHECK( type );
2075 BaseHandle handle = type.CreateInstance();
2076 DALI_TEST_CHECK( handle );
2077 LongPressGestureDetector detector = LongPressGestureDetector::DownCast( handle );
2078 DALI_TEST_CHECK( detector );
2080 // Attach actor to detector
2082 GestureReceivedFunctor functor( data );
2083 detector.Attach(actor);
2085 // Connect to signal through type
2086 handle.ConnectSignal( &application, "longPressDetected", functor );
2088 // Render and notify
2089 application.SendNotification();
2090 application.Render();
2093 TestGenerateLongPress( application, 50.0f, 10.0f );
2094 TestEndLongPress( application, 50.0f, 10.0f );
2096 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2100 int UtcDaliPanGestureDetectorTypeRegistry(void)
2102 TestApplication application;
2104 Actor actor = Actor::New();
2105 actor.SetSize(100.0f, 100.0f);
2106 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2107 Stage::GetCurrent().Add(actor);
2111 type = TypeRegistry::Get().GetTypeInfo( "PanGestureDetector" );
2112 DALI_TEST_CHECK( type );
2113 BaseHandle handle = type.CreateInstance();
2114 DALI_TEST_CHECK( handle );
2115 PanGestureDetector detector = PanGestureDetector::DownCast( handle );
2116 DALI_TEST_CHECK( detector );
2118 // Attach actor to detector
2120 GestureReceivedFunctor functor( data );
2121 detector.Attach(actor);
2123 // Connect to signal through type
2124 handle.ConnectSignal( &application, "panDetected", functor );
2126 // Render and notify
2127 application.SendNotification();
2128 application.Render();
2131 TestGenerateMiniPan( application );
2132 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2136 int UtcDaliPinchGestureDetectorTypeRegistry(void)
2138 TestApplication application;
2140 Actor actor = Actor::New();
2141 actor.SetSize(100.0f, 100.0f);
2142 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2143 Stage::GetCurrent().Add(actor);
2147 type = TypeRegistry::Get().GetTypeInfo( "PinchGestureDetector" );
2148 DALI_TEST_CHECK( type );
2149 BaseHandle handle = type.CreateInstance();
2150 DALI_TEST_CHECK( handle );
2151 PinchGestureDetector detector = PinchGestureDetector::DownCast( handle );
2152 DALI_TEST_CHECK( detector );
2154 // Attach actor to detector
2156 GestureReceivedFunctor functor( data );
2157 detector.Attach(actor);
2159 // Connect to signal through type
2160 handle.ConnectSignal( &application, "pinchDetected", functor );
2162 // Render and notify
2163 application.SendNotification();
2164 application.Render();
2167 TestGeneratePinch( application );
2169 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2173 int UtcDaliTapGestureDetectorTypeRegistry(void)
2175 TestApplication application;
2177 Actor actor = Actor::New();
2178 actor.SetSize(100.0f, 100.0f);
2179 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2180 Stage::GetCurrent().Add(actor);
2184 type = TypeRegistry::Get().GetTypeInfo( "TapGestureDetector" );
2185 DALI_TEST_CHECK( type );
2186 BaseHandle handle = type.CreateInstance();
2187 DALI_TEST_CHECK( handle );
2188 TapGestureDetector detector = TapGestureDetector::DownCast( handle );
2189 DALI_TEST_CHECK( detector );
2191 // Attach actor to detector
2193 GestureReceivedFunctor functor( data );
2194 detector.Attach(actor);
2196 // Connect to signal through type
2197 handle.ConnectSignal( &application, "tapDetected", functor );
2199 // Render and notify
2200 application.SendNotification();
2201 application.Render();
2204 TestGenerateTap( application, 50.0, 10.0, 100 );
2206 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2210 int UtcDaliTypeRegistryNamedType(void)
2212 TestApplication application;
2213 TypeRegistry typeRegistry = TypeRegistry::Get();
2215 // Create a normal actor
2216 BaseHandle actorHandle = typeRegistry.GetTypeInfo( "Actor" ).CreateInstance();
2217 DALI_TEST_CHECK( actorHandle );
2218 Actor actor( Actor::DownCast( actorHandle ) );
2219 DALI_TEST_CHECK( actor );
2220 unsigned int actorPropertyCount( actor.GetPropertyCount() );
2222 // Create Named Actor Type
2223 BaseHandle namedHandle = typeRegistry.GetTypeInfo( "MyNamedActor" ).CreateInstance();
2224 DALI_TEST_CHECK( namedHandle );
2225 Actor namedActor( Actor::DownCast( namedHandle ) );
2226 DALI_TEST_CHECK( namedActor );
2227 unsigned int namedActorPropertyCount( namedActor.GetPropertyCount() );
2229 DALI_TEST_CHECK( namedActorPropertyCount > actorPropertyCount );
2233 int UtcDaliTypeInfoGetActionNameP(void)
2235 TestApplication application;
2236 TypeRegistry typeRegistry = TypeRegistry::Get();
2238 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2239 DALI_TEST_CHECK( typeInfo );
2241 DALI_TEST_CHECK( 0 != typeInfo.GetActionCount() );
2243 std::string name = typeInfo.GetActionName(0);
2245 DALI_TEST_EQUALS( name, "show", TEST_LOCATION );
2248 TypeInfo typeInfo2 = typeRegistry.GetTypeInfo( "MyTestCustomActor" );
2250 // search for show action in base class, given a derived class
2251 bool foundChildAction = false;
2252 for( std::size_t i = 0; i < typeInfo2.GetActionCount(); i++ )
2255 std::string name = typeInfo2.GetActionName( i );
2258 foundChildAction = true;
2263 DALI_TEST_EQUALS( foundChildAction, true, TEST_LOCATION );
2269 int UtcDaliTypeInfoGetActionNameN(void)
2271 TestApplication application;
2272 TypeRegistry typeRegistry = TypeRegistry::Get();
2274 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2275 DALI_TEST_CHECK( typeInfo );
2277 DALI_TEST_CHECK( 0 != typeInfo.GetActionCount() );
2279 std::string name = typeInfo.GetActionName(std::numeric_limits<size_t>::max());
2281 DALI_TEST_EQUALS( 0u, name.size(), TEST_LOCATION );
2286 int UtcDaliTypeInfoGetSignalNameP(void)
2288 TestApplication application;
2289 TypeRegistry typeRegistry = TypeRegistry::Get();
2291 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2292 DALI_TEST_CHECK( typeInfo );
2294 DALI_TEST_CHECK( 0 != typeInfo.GetSignalCount() );
2296 std::string name = typeInfo.GetSignalName(0);
2298 DALI_TEST_EQUALS( name, "touched", TEST_LOCATION );
2300 TypeInfo typeInfo2 = typeRegistry.GetTypeInfo( "MyTestCustomActor" );
2302 // search for signal in base class, given a derived class
2303 bool foundSignal = false;
2304 for( std::size_t i = 0; i < typeInfo2.GetSignalCount(); i++ )
2307 std::string name = typeInfo2.GetSignalName( i );
2308 if( name == "touched")
2315 DALI_TEST_EQUALS( foundSignal, true, TEST_LOCATION );
2320 int UtcDaliTypeInfoGetSignalNameN(void)
2322 TestApplication application;
2323 TypeRegistry typeRegistry = TypeRegistry::Get();
2325 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2326 DALI_TEST_CHECK( typeInfo );
2328 DALI_TEST_CHECK( 0 != typeInfo.GetSignalCount() );
2330 std::string name = typeInfo.GetSignalName(std::numeric_limits<size_t>::max());
2332 DALI_TEST_EQUALS( 0u, name.size(), TEST_LOCATION );
2338 int UtcDaliTypeInfoGetCreatorP(void)
2340 TestApplication application;
2341 TypeRegistry typeRegistry = TypeRegistry::Get();
2343 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2344 DALI_TEST_CHECK( typeInfo );
2346 TypeInfo::CreateFunction createFn = typeInfo.GetCreator();
2347 DALI_TEST_EQUALS( createFn != NULL, true, TEST_LOCATION );
2351 BaseHandle handle = createFn();
2352 DALI_TEST_EQUALS( (bool)handle, true, TEST_LOCATION );
2358 int UtcDaliTypeInfoGetCreatorN(void)
2360 TestApplication application;
2361 TypeRegistry typeRegistry = TypeRegistry::Get();
2363 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "MyTestCustomActor3" );
2364 DALI_TEST_CHECK( typeInfo );
2366 TypeInfo::CreateFunction createFn = typeInfo.GetCreator();
2367 DALI_TEST_EQUALS( createFn == NULL, true, TEST_LOCATION );
2372 int UtcDaliTypeInfoGetPropertyCountP1(void)
2374 TestApplication application;
2375 TypeRegistry typeRegistry = TypeRegistry::Get();
2377 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2378 DALI_TEST_CHECK( typeInfo );
2379 size_t actorPropertyCount = typeInfo.GetPropertyCount();
2381 DALI_TEST_EQUALS( actorPropertyCount, Actor::New().GetPropertyCount(), TEST_LOCATION ); // No event only props
2385 int UtcDaliTypeInfoGetPropertyCountP2(void)
2387 TestApplication application;
2388 TypeRegistry typeRegistry = TypeRegistry::Get();
2390 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "MyTestCustomActor2" );
2391 DALI_TEST_CHECK( typeInfo );
2392 size_t propertyCount = typeInfo.GetPropertyCount();
2393 Property::IndexContainer indices;
2394 typeInfo.GetPropertyIndices( indices );
2396 DALI_TEST_EQUALS( propertyCount > 0 && propertyCount <= indices.Size(), true, TEST_LOCATION );
2397 DALI_TEST_EQUALS( propertyCount, Actor::New().GetPropertyCount() + 2, TEST_LOCATION );
2402 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGet01(void)
2404 TestApplication application;
2405 TypeRegistry typeRegistry = TypeRegistry::Get();
2407 tet_infoline( "Register a type registered animatable property and ensure set/get behaviour works synchronously" );
2409 // Register animatable property
2410 const int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
2411 AnimatablePropertyRegistration animatableProperty( customType1, "animatableProp1", animatablePropertyIndex, Property::FLOAT );
2413 // Check property count before property registration
2414 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2415 DALI_TEST_CHECK( typeInfo );
2416 BaseHandle handle = typeInfo.CreateInstance();
2417 DALI_TEST_CHECK( handle );
2418 Actor customActor = Actor::DownCast( handle );
2419 DALI_TEST_CHECK( customActor );
2420 Stage::GetCurrent().Add(customActor);
2422 tet_infoline( "Set the value and ensure it changes straight away" );
2423 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 0.0f, TEST_LOCATION );
2424 customActor.SetProperty( animatablePropertyIndex, 25.0f );
2425 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 25.0f, TEST_LOCATION );
2427 tet_infoline( "Check latest scene-graph value is unchanged" );
2428 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 0.0f, TEST_LOCATION );
2430 // Render and notify
2431 application.SendNotification();
2432 application.Render();
2434 tet_infoline( "Check values after rendering and both retrieval methods should return the latest" );
2436 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 25.0f, TEST_LOCATION );
2437 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 25.0f, TEST_LOCATION );
2442 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGetWithComponentsVector2(void)
2444 TestApplication application;
2445 TypeRegistry typeRegistry = TypeRegistry::Get();
2447 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" );
2449 // Register the animatable propeties
2450 const int basePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
2451 const int componentZeroPropertyIndex( basePropertyIndex + 1 );
2452 const int componentOnePropertyIndex( componentZeroPropertyIndex + 1 );
2453 AnimatablePropertyRegistration baseAnimatableProperty( customType1, "baseProp", basePropertyIndex, Vector2( 13.0f, 24.0f ) );
2454 AnimatablePropertyComponentRegistration componentZeroAnimatableProperty( customType1, "componentZeroProp", componentZeroPropertyIndex, basePropertyIndex, 0 );
2455 AnimatablePropertyComponentRegistration componentOneAnimatableProperty( customType1, "componentOneProp", componentOnePropertyIndex, basePropertyIndex, 1 );
2457 // Check property count before property registration
2458 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2459 DALI_TEST_CHECK( typeInfo );
2460 BaseHandle handle = typeInfo.CreateInstance();
2461 DALI_TEST_CHECK( handle );
2462 Actor customActor = Actor::DownCast( handle );
2463 DALI_TEST_CHECK( customActor );
2464 Stage::GetCurrent().Add(customActor);
2466 tet_infoline( "Get the component values, they should be the default value of the base-property" );
2467 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2468 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2469 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 13.0f, 24.0f ), TEST_LOCATION );
2471 tet_infoline( "Set a component value and ensure it changes for the base property as well" );
2472 customActor.SetProperty( componentZeroPropertyIndex, 125.0f );
2473 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2474 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 125.0f, 24.0f ), TEST_LOCATION );
2476 customActor.SetProperty( componentOnePropertyIndex, 225.0f );
2477 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2478 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 125.0f, 225.0f ), TEST_LOCATION );
2480 tet_infoline( "Check latest scene-graph value is unchanged" );
2481 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector2 >( basePropertyIndex ), Vector2( 13.0f, 24.0f ), TEST_LOCATION );
2482 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2483 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2485 // Render and notify
2486 application.SendNotification();
2487 application.Render();
2489 tet_infoline( "Check values after rendering and both retrieval methods should return the latest" );
2490 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 125.0f, 225.0f ), TEST_LOCATION );
2491 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2492 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2494 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector2 >( basePropertyIndex ), Vector2( 125.0f, 225.0f ), TEST_LOCATION );
2495 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2496 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2498 tet_infoline( "Set the base property value and ensure the component values reflect the change" );
2499 customActor.SetProperty( basePropertyIndex, Vector2( 1.0f, 2.0f ) );
2500 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 1.0f, TEST_LOCATION );
2501 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 2.0f, TEST_LOCATION );
2502 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 1.0f, 2.0f ), TEST_LOCATION );
2507 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGetWithComponentsVector3(void)
2509 TestApplication application;
2510 TypeRegistry typeRegistry = TypeRegistry::Get();
2512 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" );
2514 // Register the animatable propeties
2515 const int basePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
2516 const int componentZeroPropertyIndex( basePropertyIndex + 1 );
2517 const int componentOnePropertyIndex( componentZeroPropertyIndex + 1 );
2518 const int componentTwoPropertyIndex( componentOnePropertyIndex + 1 );
2519 AnimatablePropertyRegistration baseAnimatableProperty( customType1, "baseProp", basePropertyIndex, Vector3( 13.0f, 24.0f, 35.0 ) );
2520 AnimatablePropertyComponentRegistration componentZeroAnimatableProperty( customType1, "componentZeroProp", componentZeroPropertyIndex, basePropertyIndex, 0 );
2521 AnimatablePropertyComponentRegistration componentOneAnimatableProperty( customType1, "componentOneProp", componentOnePropertyIndex, basePropertyIndex, 1 );
2522 AnimatablePropertyComponentRegistration componentTwoAnimatableProperty( customType1, "componentTwoProp", componentTwoPropertyIndex, basePropertyIndex, 2 );
2524 // Check property count before property registration
2525 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2526 DALI_TEST_CHECK( typeInfo );
2527 BaseHandle handle = typeInfo.CreateInstance();
2528 DALI_TEST_CHECK( handle );
2529 Actor customActor = Actor::DownCast( handle );
2530 DALI_TEST_CHECK( customActor );
2531 Stage::GetCurrent().Add(customActor);
2533 tet_infoline( "Get the component values, they should be the default value of the base-property" );
2534 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2535 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2536 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 35.0f, TEST_LOCATION );
2537 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 13.0f, 24.0f, 35.0f ), TEST_LOCATION );
2539 tet_infoline( "Set a component value and ensure it changes for the base property as well" );
2540 customActor.SetProperty( componentZeroPropertyIndex, 125.0f );
2541 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2542 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 24.0f, 35.0f ), TEST_LOCATION );
2544 customActor.SetProperty( componentOnePropertyIndex, 225.0f );
2545 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2546 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 225.0f, 35.0f ), TEST_LOCATION );
2548 customActor.SetProperty( componentTwoPropertyIndex, 325.0f );
2549 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2550 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 225.0f, 325.0f ), TEST_LOCATION );
2552 tet_infoline( "Check latest scene-graph value is unchanged" );
2553 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector3 >( basePropertyIndex ), Vector3( 13.0f, 24.0f, 35.0f ), TEST_LOCATION );
2554 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2555 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2556 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentTwoPropertyIndex ), 35.0f, TEST_LOCATION );
2558 // Render and notify
2559 application.SendNotification();
2560 application.Render();
2562 tet_infoline( "Check values after rendering and both retrieval methods should return the latest" );
2563 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 225.0f, 325.0f ), TEST_LOCATION );
2564 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2565 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2566 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2568 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 225.0f, 325.0f ), TEST_LOCATION );
2569 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2570 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2571 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2573 tet_infoline( "Set the base property value and ensure the component values reflect the change" );
2574 customActor.SetProperty( basePropertyIndex, Vector3( 1.0f, 2.0f, 3.0f ) );
2575 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 1.0f, TEST_LOCATION );
2576 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 2.0f, TEST_LOCATION );
2577 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 3.0f, TEST_LOCATION );
2578 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 1.0f, 2.0f, 3.0f ), TEST_LOCATION );
2583 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGetWithComponentsVector4(void)
2585 TestApplication application;
2586 TypeRegistry typeRegistry = TypeRegistry::Get();
2588 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" );
2590 // Register the animatable propeties
2591 const int basePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
2592 const int componentZeroPropertyIndex( basePropertyIndex + 1 );
2593 const int componentOnePropertyIndex( componentZeroPropertyIndex + 1 );
2594 const int componentTwoPropertyIndex( componentOnePropertyIndex + 1 );
2595 const int componentThreePropertyIndex( componentTwoPropertyIndex + 1 );
2596 AnimatablePropertyRegistration baseAnimatableProperty( customType1, "baseProp", basePropertyIndex, Vector4( 13.0f, 24.0f, 35.0, 47.0f ) );
2597 AnimatablePropertyComponentRegistration componentZeroAnimatableProperty( customType1, "componentZeroProp", componentZeroPropertyIndex, basePropertyIndex, 0 );
2598 AnimatablePropertyComponentRegistration componentOneAnimatableProperty( customType1, "componentOneProp", componentOnePropertyIndex, basePropertyIndex, 1 );
2599 AnimatablePropertyComponentRegistration componentTwoAnimatableProperty( customType1, "componentTwoProp", componentTwoPropertyIndex, basePropertyIndex, 2 );
2600 AnimatablePropertyComponentRegistration componentThreeAnimatableProperty( customType1, "componentThreeProp", componentThreePropertyIndex, basePropertyIndex, 3 );
2602 // Check property count before property registration
2603 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2604 DALI_TEST_CHECK( typeInfo );
2605 BaseHandle handle = typeInfo.CreateInstance();
2606 DALI_TEST_CHECK( handle );
2607 Actor customActor = Actor::DownCast( handle );
2608 DALI_TEST_CHECK( customActor );
2609 Stage::GetCurrent().Add(customActor);
2611 tet_infoline( "Get the component values, they should be the default value of the base-property" );
2612 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2613 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2614 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 35.0f, TEST_LOCATION );
2615 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentThreePropertyIndex ), 47.0f, TEST_LOCATION );
2616 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 13.0f, 24.0f, 35.0f, 47.0f ), TEST_LOCATION );
2618 tet_infoline( "Set a component value and ensure it changes for the base property as well" );
2619 customActor.SetProperty( componentZeroPropertyIndex, 125.0f );
2620 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2621 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 24.0f, 35.0f, 47.0f ), TEST_LOCATION );
2623 customActor.SetProperty( componentOnePropertyIndex, 225.0f );
2624 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2625 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 35.0f, 47.0f ), TEST_LOCATION );
2627 customActor.SetProperty( componentTwoPropertyIndex, 325.0f );
2628 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2629 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 325.0f, 47.0f ), TEST_LOCATION );
2631 customActor.SetProperty( componentThreePropertyIndex, 435.0f );
2632 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentThreePropertyIndex ), 435.0f, TEST_LOCATION );
2633 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 325.0f, 435.0f ), TEST_LOCATION );
2635 tet_infoline( "Check latest scene-graph value is unchanged" );
2636 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector4 >( basePropertyIndex ), Vector4( 13.0f, 24.0f, 35.0f, 47.0f ), TEST_LOCATION );
2637 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2638 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2639 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentTwoPropertyIndex ), 35.0f, TEST_LOCATION );
2640 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentThreePropertyIndex ), 47.0f, TEST_LOCATION );
2642 // Render and notify
2643 application.SendNotification();
2644 application.Render();
2646 tet_infoline( "Check values after rendering and both retrieval methods should return the latest" );
2647 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 325.0f, 435.0f ), TEST_LOCATION );
2648 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2649 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2650 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2651 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentThreePropertyIndex ), 435.0f, TEST_LOCATION );
2653 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 325.0f, 435.0f ), TEST_LOCATION );
2654 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2655 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2656 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2657 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentThreePropertyIndex ), 435.0f, TEST_LOCATION );
2659 tet_infoline( "Set the base property value and ensure the component values reflect the change" );
2660 customActor.SetProperty( basePropertyIndex, Vector4( 1.0f, 2.0f, 3.0f, 4.0f ) );
2661 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 1.0f, TEST_LOCATION );
2662 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 2.0f, TEST_LOCATION );
2663 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 3.0f, TEST_LOCATION );
2664 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentThreePropertyIndex ), 4.0f, TEST_LOCATION );
2665 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 1.0f, 2.0f, 3.0f, 4.0f ), TEST_LOCATION );
2671 int UtcDaliTypeInfoRegisterChildProperties01(void)
2673 TestApplication application;
2674 TypeRegistry typeRegistry = TypeRegistry::Get();
2676 tet_infoline( "Register child properties on a type via name" );
2678 auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(CustomActor) );
2679 auto myCustomTypeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2680 DALI_TEST_CHECK( customActorTypeInfo );
2681 DALI_TEST_CHECK( myCustomTypeInfo );
2683 const Property::Index WIDTH_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX );
2684 const Property::Index HEIGHT_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1);
2685 const Property::Index MARGIN_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 100);
2687 ChildPropertyRegistration( customActorTypeInfo.GetName(), "widthSpecification", WIDTH_SPECIFICATION, Property::INTEGER );
2688 ChildPropertyRegistration( customActorTypeInfo.GetName(), "heightSpecification", HEIGHT_SPECIFICATION, Property::INTEGER );
2689 ChildPropertyRegistration( myCustomTypeInfo.GetName(), "marginSpecification", MARGIN_SPECIFICATION, Property::EXTENTS );
2691 auto customActor = MyTestCustomActor::New();
2692 Stage::GetCurrent().Add( customActor );
2693 auto child = Actor::New();
2694 customActor.Add( child );
2696 child.SetProperty( WIDTH_SPECIFICATION, 33 );
2698 auto value = child.GetProperty( WIDTH_SPECIFICATION );
2699 DALI_TEST_EQUALS( value, Property::Value(33), TEST_LOCATION );
2701 child.SetProperty( HEIGHT_SPECIFICATION, 44 );
2702 value = child.GetProperty( HEIGHT_SPECIFICATION );
2703 DALI_TEST_EQUALS( value, Property::Value(44), TEST_LOCATION );
2705 child.SetProperty( MARGIN_SPECIFICATION, Extents(10, 10, 10, 10) );
2706 value = child.GetProperty( MARGIN_SPECIFICATION );
2707 DALI_TEST_EQUALS( value, Property::Value(Extents(10,10,10,10)), TEST_LOCATION );
2713 int UtcDaliTypeInfoRegisterChildProperties02(void)
2715 TestApplication application;
2716 TypeRegistry typeRegistry = TypeRegistry::Get();
2718 tet_infoline( "Register child properties on a type via name" );
2720 auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(CustomActor) );
2721 auto myCustomTypeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2722 DALI_TEST_CHECK( customActorTypeInfo );
2723 DALI_TEST_CHECK( myCustomTypeInfo );
2725 const Property::Index WIDTH_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX );
2726 const Property::Index HEIGHT_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1);
2727 const Property::Index MARGIN_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 100);
2729 ChildPropertyRegistration( customActorTypeInfo.GetName(), "widthSpecification", WIDTH_SPECIFICATION, Property::INTEGER );
2730 ChildPropertyRegistration( customActorTypeInfo.GetName(), "heightSpecification", HEIGHT_SPECIFICATION, Property::INTEGER );
2731 ChildPropertyRegistration( myCustomTypeInfo.GetName(), "marginSpecification", MARGIN_SPECIFICATION, Property::EXTENTS );
2734 auto index = customActorTypeInfo.GetChildPropertyIndex( "widthSpecification" );
2735 DALI_TEST_EQUALS( index, WIDTH_SPECIFICATION, TEST_LOCATION );
2737 index = customActorTypeInfo.GetChildPropertyIndex( "heightSpecification" );
2738 DALI_TEST_EQUALS( index, HEIGHT_SPECIFICATION, TEST_LOCATION );
2740 index = customActorTypeInfo.GetChildPropertyIndex( "marginSpecification" );
2741 DALI_TEST_EQUALS( index, Property::INVALID_INDEX, TEST_LOCATION );
2743 index = myCustomTypeInfo.GetChildPropertyIndex( "marginSpecification" );
2744 DALI_TEST_EQUALS( index, MARGIN_SPECIFICATION, TEST_LOCATION );
2747 auto name = customActorTypeInfo.GetChildPropertyName( WIDTH_SPECIFICATION );
2748 DALI_TEST_EQUALS( name, "widthSpecification", TEST_LOCATION );
2750 name = customActorTypeInfo.GetChildPropertyName( HEIGHT_SPECIFICATION );
2751 DALI_TEST_EQUALS( name, "heightSpecification", TEST_LOCATION );
2753 name = myCustomTypeInfo.GetChildPropertyName( MARGIN_SPECIFICATION );
2754 DALI_TEST_EQUALS( name, "marginSpecification", TEST_LOCATION );
2757 auto type = customActorTypeInfo.GetChildPropertyType( WIDTH_SPECIFICATION );
2758 DALI_TEST_EQUALS( type, Property::INTEGER, TEST_LOCATION );
2760 type = customActorTypeInfo.GetChildPropertyType( HEIGHT_SPECIFICATION );
2761 DALI_TEST_EQUALS( type, Property::INTEGER, TEST_LOCATION );
2763 type = myCustomTypeInfo.GetChildPropertyType( MARGIN_SPECIFICATION );
2764 DALI_TEST_EQUALS( type, Property::EXTENTS, TEST_LOCATION );
2771 int UtcDaliTypeInfoRegisterChildProperties03(void)
2773 TestApplication application;
2774 TypeRegistry typeRegistry = TypeRegistry::Get();
2776 tet_infoline( "Check registered child properties can be retrieved" );
2778 auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(CustomActor) );
2779 auto myCustomTypeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2780 DALI_TEST_CHECK( customActorTypeInfo );
2781 DALI_TEST_CHECK( myCustomTypeInfo );
2783 const Property::Index WIDTH_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX );
2784 const Property::Index HEIGHT_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1);
2785 const Property::Index MARGIN_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 100);
2787 ChildPropertyRegistration( customActorTypeInfo.GetName(), "widthSpecification", WIDTH_SPECIFICATION, Property::INTEGER );
2788 ChildPropertyRegistration( customActorTypeInfo.GetName(), "heightSpecification", HEIGHT_SPECIFICATION, Property::INTEGER );
2789 ChildPropertyRegistration( myCustomTypeInfo.GetName(), "marginSpecification", MARGIN_SPECIFICATION, Property::EXTENTS );
2791 Property::IndexContainer indices;
2792 myCustomTypeInfo.GetChildPropertyIndices( indices );
2794 auto result = std::find( indices.Begin(), indices.End(), WIDTH_SPECIFICATION );
2795 DALI_TEST_EQUALS( result != indices.End(), true, TEST_LOCATION );
2797 result = std::find( indices.Begin(), indices.End(), HEIGHT_SPECIFICATION );
2798 DALI_TEST_EQUALS( result != indices.End(), true, TEST_LOCATION );
2800 result = std::find( indices.Begin(), indices.End(), MARGIN_SPECIFICATION );
2801 DALI_TEST_EQUALS( result != indices.End(), true, TEST_LOCATION );