2 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <dali/public-api/dali-core.h>
22 #include <dali-test-suite-utils.h>
23 #include <dali/internal/event/common/type-info-impl.h>
24 #include <dali/integration-api/events/touch-event-integ.h>
25 #include <dali/integration-api/events/hover-event-integ.h>
26 #include <dali/devel-api/events/rotation-gesture-detector.h>
34 // Stores data that is populated in the callback and will be read by the Test cases
38 : functorCalled( false ),
39 voidFunctorCalled( false ),
40 receivedGesture( Gesture::Clear ),
46 functorCalled = false;
47 voidFunctorCalled = false;
49 receivedGesture.numberOfTouches = 0u;
50 receivedGesture.screenPoint = Vector2(0.0f, 0.0f);
51 receivedGesture.localPoint = Vector2(0.0f, 0.0f);
57 bool voidFunctorCalled;
58 LongPressGesture receivedGesture;
62 // Functor that sets the data when called
63 struct GestureReceivedFunctor
65 GestureReceivedFunctor(SignalData& data) : signalData(data) { }
67 void operator()(Actor actor, LongPressGesture longPress)
69 signalData.functorCalled = true;
70 signalData.receivedGesture = longPress;
71 signalData.pressedActor = actor;
76 signalData.voidFunctorCalled = true;
79 SignalData& signalData;
83 // Create function as Init function called
85 static bool CreateCustomInitCalled = false;
86 BaseHandle CreateCustomInit(void)
88 CreateCustomInitCalled = true;
92 static bool CreateCustomNamedInitCalled = false;
93 BaseHandle CreateCustomNamedInit(void)
95 CreateCustomNamedInitCalled = true;
99 const std::string scriptedName("PopupStyle");
100 static TypeRegistration scriptedType( scriptedName, typeid(Dali::CustomActor), CreateCustomNamedInit );
102 // Property Registration
103 bool setPropertyCalled = false;
104 bool getPropertyCalled = false;
105 void SetProperty( BaseObject* object, Property::Index propertyIndex, const Property::Value& value )
107 setPropertyCalled = true;
109 Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex )
111 getPropertyCalled = true;
112 return Property::Value( true );
117 /*******************************************************************************
121 ******************************************************************************/
124 struct MyTestCustomActor : public CustomActorImpl
126 typedef Signal< void ()> SignalType;
127 typedef Signal< void (float)> SignalTypeFloat;
129 MyTestCustomActor() : CustomActorImpl( ActorFlags( REQUIRES_TOUCH_EVENTS ) )
132 virtual ~MyTestCustomActor()
135 void ResetCallStack()
139 // From CustomActorImpl
140 virtual void OnSceneConnection( int depth )
143 virtual void OnSceneDisconnection()
146 virtual void OnChildAdd(Actor& child)
149 virtual void OnChildRemove(Actor& child)
152 virtual void OnSizeSet(const Vector3& targetSize)
155 virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize)
158 virtual bool OnTouchEvent(const TouchEvent& event)
162 virtual bool OnHoverEvent(const HoverEvent& event)
166 virtual bool OnWheelEvent(const WheelEvent& event)
170 virtual bool OnKeyEvent(const KeyEvent& event)
174 virtual void OnKeyInputFocusGained()
177 virtual void OnKeyInputFocusLost()
180 virtual Vector3 GetNaturalSize()
182 return Vector3( 0.0f, 0.0f, 0.0f );
185 virtual float GetHeightForWidth( float width )
190 virtual float GetWidthForHeight( float height )
195 virtual void OnRelayout( const Vector2& size, RelayoutContainer& container )
199 virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
203 virtual void OnCalculateRelayoutSize( Dimension::Type dimension )
207 virtual float CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension )
212 virtual void OnLayoutNegotiated( float size, Dimension::Type dimension )
216 virtual bool RelayoutDependentOnChildren( Dimension::Type dimension = Dimension::ALL_DIMENSIONS )
228 class MyTestCustomActor : public CustomActor
232 typedef Signal< void ()> SignalType;
233 typedef Signal< void (float)> SignalTypeFloat;
239 static MyTestCustomActor New()
241 Impl::MyTestCustomActor* p = new Impl::MyTestCustomActor;
242 return MyTestCustomActor( *p ); // takes ownership
245 virtual ~MyTestCustomActor()
249 static MyTestCustomActor DownCast( BaseHandle handle )
251 MyTestCustomActor result;
253 CustomActor custom = Dali::CustomActor::DownCast( handle );
256 CustomActorImpl& customImpl = custom.GetImplementation();
258 Impl::MyTestCustomActor* impl = dynamic_cast<Impl::MyTestCustomActor*>(&customImpl);
262 result = MyTestCustomActor(customImpl.GetOwner());
269 SignalType& GetCustomSignal()
271 Dali::RefObject& obj = GetImplementation();
272 return static_cast<Impl::MyTestCustomActor&>( obj ).mSignal;
277 MyTestCustomActor(Internal::CustomActor* internal)
278 : CustomActor(internal)
282 MyTestCustomActor( Impl::MyTestCustomActor& impl )
283 : CustomActor( impl )
289 class MyTestCustomActor2 : public CustomActor
297 P1=Dali::PROPERTY_REGISTRATION_START_INDEX,
307 static MyTestCustomActor2 New()
309 return MyTestCustomActor2(); // takes ownership
312 virtual ~MyTestCustomActor2()
316 static MyTestCustomActor2 DownCast( BaseHandle handle )
318 MyTestCustomActor2 result;
320 CustomActor custom = Dali::CustomActor::DownCast( handle );
323 CustomActorImpl& customImpl = custom.GetImplementation();
325 Impl::MyTestCustomActor* impl = dynamic_cast<Impl::MyTestCustomActor*>(&customImpl);
329 result = MyTestCustomActor2(customImpl.GetOwner());
338 MyTestCustomActor2(Internal::CustomActor* internal)
339 : CustomActor(internal)
343 MyTestCustomActor2( Impl::MyTestCustomActor& impl )
344 : CustomActor( impl )
349 static TypeRegistration customTypeInit( typeid(MyTestCustomActor2), typeid(Dali::CustomActor), CreateCustomInit, true );
351 PropertyRegistration P1( customTypeInit, "propertyOne", MyTestCustomActor2::Property::P1, Property::INTEGER, &SetProperty, &GetProperty );
352 PropertyRegistration P2( customTypeInit, "propertyTwo", MyTestCustomActor2::Property::P2, Property::STRING, &SetProperty, &GetProperty );
355 class MyTestCustomActor3 : public CustomActor
362 static MyTestCustomActor3 New()
364 return MyTestCustomActor3(); // takes ownership
367 virtual ~MyTestCustomActor3()
371 static MyTestCustomActor3 DownCast( BaseHandle handle )
373 MyTestCustomActor3 result;
375 CustomActor custom = Dali::CustomActor::DownCast( handle );
378 CustomActorImpl& customImpl = custom.GetImplementation();
380 Impl::MyTestCustomActor* impl = dynamic_cast<Impl::MyTestCustomActor*>(&customImpl);
384 result = MyTestCustomActor3(customImpl.GetOwner());
393 MyTestCustomActor3(Internal::CustomActor* internal)
394 : CustomActor(internal)
398 MyTestCustomActor3( Impl::MyTestCustomActor& impl )
399 : CustomActor( impl )
404 static TypeRegistration customTypeBadInit( typeid(MyTestCustomActor3), typeid(Dali::CustomActor), NULL, false );
406 BaseHandle CreateCustom(void)
408 return MyTestCustomActor::New();
411 static std::string lastSignalConnectionCustom;
413 bool DoConnectSignalCustom( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
415 lastSignalConnectionCustom = signalName;
417 bool connected( true );
419 Dali::BaseHandle handle(object);
420 MyTestCustomActor customActor = MyTestCustomActor::DownCast(handle);
422 if( "sig1" == signalName )
424 customActor.GetCustomSignal().Connect( tracker, functor );
428 // signalName does not match any signal
435 bool DoConnectSignalCustomFailure( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
437 lastSignalConnectionCustom = "failed";
439 return false; // This is supposed to fail
442 struct CustomTestFunctor
446 ++mTotalInstanceCount;
447 ++mCurrentInstanceCount;
450 CustomTestFunctor( const CustomTestFunctor& copyMe )
452 ++mTotalInstanceCount;
453 ++mCurrentInstanceCount;
458 --mCurrentInstanceCount;
466 static int mTotalInstanceCount;
467 static int mCurrentInstanceCount;
468 static int mCallbackCount;
471 int CustomTestFunctor::mTotalInstanceCount = 0;
472 int CustomTestFunctor::mCurrentInstanceCount = 0;
473 int CustomTestFunctor::mCallbackCount = 0;
475 static void ResetFunctorCounts()
477 CustomTestFunctor::mTotalInstanceCount = 0;
478 CustomTestFunctor::mCurrentInstanceCount = 0;
479 CustomTestFunctor::mCallbackCount = 0;
482 static std::string lastActionCustom;
483 bool DoActionCustom(BaseObject* object, const std::string& actionName, const Property::Map& /*attributes*/)
485 lastActionCustom = actionName;
489 // Custom type registration
490 static TypeRegistration customType1( typeid(MyTestCustomActor), typeid(Dali::CustomActor), CreateCustom );
493 static SignalConnectorType customSignalConnector1( customType1, "sig1", DoConnectSignalCustom );
494 static SignalConnectorType customSignalConnector2( customType1, "sig2", DoConnectSignalCustomFailure );
495 static const int TEST_SIGNAL_COUNT = 2;
498 static TypeAction customAction1( customType1, "act1", DoActionCustom);
499 static const int TEST_ACTION_COUNT = 1;
501 class TestConnectionTracker : public ConnectionTracker
505 TestConnectionTracker()
510 BaseHandle CreateNamedActorType()
512 Actor actor = Actor::New();
513 actor.SetProperty( Actor::Property::NAME, "NamedActor" );
517 TypeRegistration namedActorType( "MyNamedActor", typeid(Dali::Actor), CreateNamedActorType );
518 PropertyRegistration namedActorPropertyOne( namedActorType, "propName", PROPERTY_REGISTRATION_START_INDEX, Property::BOOLEAN, &SetProperty, &GetProperty );
520 } // Anonymous namespace
522 // Note: No negative test case for UtcDaliTypeRegistryGet can be implemented.
523 int UtcDaliTypeRegistryGetP(void)
525 TestApplication application;
527 TypeRegistry registry = TypeRegistry::Get();
528 DALI_TEST_CHECK( registry );
533 // Note: No negative test case for UtcDaliTypeRegistryConstructor can be implemented.
534 int UtcDaliTypeRegistryConstructorP(void)
536 TestApplication application;
538 TypeRegistry registry;
539 DALI_TEST_CHECK( !registry );
543 // Note: No negative test case for UtcDaliTypeRegistryCopyConstructor can be implemented.
544 int UtcDaliTypeRegistryCopyConstructorP(void)
546 TestApplication application;
548 TypeRegistry registry = TypeRegistry::Get();
549 DALI_TEST_CHECK( registry );
551 TypeRegistry copy( registry );
552 DALI_TEST_CHECK( copy );
554 DALI_TEST_CHECK( registry.GetTypeInfo( "Actor" ).GetName() == copy.GetTypeInfo( "Actor" ).GetName() );
559 // Note: No negative test case for UtcDaliTypeRegistryAssignmentOperator can be implemented.
560 int UtcDaliTypeRegistryAssignmentOperatorP(void)
562 TestApplication application;
564 TypeRegistry registry = TypeRegistry::Get();
565 DALI_TEST_CHECK( registry );
567 TypeRegistry copy = registry;
568 DALI_TEST_CHECK( copy );
569 DALI_TEST_CHECK( registry == copy );
571 DALI_TEST_CHECK( registry.GetTypeInfo( "Actor" ).GetName() == copy.GetTypeInfo( "Actor" ).GetName() );
576 int UtcDaliTypeRegistryMoveConstructor(void)
578 TestApplication application;
580 TypeRegistry registry = TypeRegistry::Get();
581 DALI_TEST_CHECK( registry );
582 DALI_TEST_EQUALS( 16, registry.GetBaseObject().ReferenceCount(), TEST_LOCATION );
583 DALI_TEST_CHECK( registry.GetTypeInfo( "Actor" ).GetName() == "Actor" );
585 TypeRegistry movedRegistry = std::move( registry );
586 DALI_TEST_CHECK( movedRegistry );
587 DALI_TEST_EQUALS( 16, movedRegistry.GetBaseObject().ReferenceCount(), TEST_LOCATION );
588 DALI_TEST_CHECK( movedRegistry.GetTypeInfo( "Actor" ).GetName() == "Actor" );
589 DALI_TEST_CHECK( !registry );
591 Dali::TypeInfo info = movedRegistry.GetTypeInfo( "Actor" );
592 DALI_TEST_CHECK( info );
593 DALI_TEST_EQUALS( 2, info.GetBaseObject().ReferenceCount(), TEST_LOCATION );
594 DALI_TEST_CHECK( info.GetName() == "Actor" );
596 Dali::TypeInfo movedInfo = std::move( info );
597 DALI_TEST_CHECK( movedInfo );
598 DALI_TEST_EQUALS( 2, movedInfo.GetBaseObject().ReferenceCount(), TEST_LOCATION );
599 DALI_TEST_CHECK( movedInfo.GetName() == "Actor" );
600 DALI_TEST_CHECK( !info );
605 int UtcDaliTypeRegistryMoveAssignment(void)
607 TestApplication application;
609 TypeRegistry registry = TypeRegistry::Get();
610 DALI_TEST_CHECK( registry );
611 DALI_TEST_EQUALS( 16, registry.GetBaseObject().ReferenceCount(), TEST_LOCATION );
612 DALI_TEST_CHECK( registry.GetTypeInfo( "Actor" ).GetName() == "Actor" );
614 TypeRegistry movedRegistry;
615 movedRegistry = std::move( registry );
616 DALI_TEST_CHECK( movedRegistry );
617 DALI_TEST_EQUALS( 16, movedRegistry.GetBaseObject().ReferenceCount(), TEST_LOCATION );
618 DALI_TEST_CHECK( movedRegistry.GetTypeInfo( "Actor" ).GetName() == "Actor" );
619 DALI_TEST_CHECK( !registry );
621 Dali::TypeInfo info = movedRegistry.GetTypeInfo( "Actor" );
622 DALI_TEST_CHECK( info );
623 DALI_TEST_EQUALS( 2, info.GetBaseObject().ReferenceCount(), TEST_LOCATION );
624 DALI_TEST_CHECK( info.GetName() == "Actor" );
626 Dali::TypeInfo movedInfo;
627 movedInfo = std::move( info );
628 DALI_TEST_CHECK( movedInfo );
629 DALI_TEST_EQUALS( 2, movedInfo.GetBaseObject().ReferenceCount(), TEST_LOCATION );
630 DALI_TEST_CHECK( movedInfo.GetName() == "Actor" );
631 DALI_TEST_CHECK( !info );
636 int UtcDaliTypeRegistryAssignP(void)
638 TestApplication application;
640 TypeRegistry registry = TypeRegistry::Get();
641 TypeRegistry registry2;
642 registry2 = registry;
643 DALI_TEST_CHECK( registry2 );
645 DALI_TEST_CHECK( registry2.GetTypeInfo( "Actor" ).GetName() == registry2.GetTypeInfo( "Actor" ).GetName() );
650 int UtcDaliTypeRegistryGetTypeInfoFromTypeNameP(void)
652 TestApplication application;
654 TypeRegistry registry = TypeRegistry::Get();
659 type = registry.GetTypeInfo( "CameraActor" );
660 DALI_TEST_CHECK( type );
661 CameraActor ca = CameraActor::DownCast(type.CreateInstance());
662 DALI_TEST_CHECK( ca );
663 application.GetScene().Add( ca );
664 application.Render();
667 type = registry.GetTypeInfo( "Animation" );
668 DALI_TEST_CHECK( type );
669 Animation an = Animation::DownCast(type.CreateInstance());
670 DALI_TEST_CHECK( an );
672 application.Render();
677 int UtcDaliTypeRegistryGetTypeInfoFromTypeNameN(void)
679 TestApplication application;
681 TypeRegistry registry = TypeRegistry::Get();
685 type = registry.GetTypeInfo( "MyDummyActor" );
686 DALI_TEST_CHECK( !type );
691 int UtcDaliTypeRegistryGetTypeInfoFromTypeIdP(void)
693 TypeInfo named_type = TypeRegistry::Get().GetTypeInfo( "CameraActor" );
694 TypeInfo typeinfo_type = TypeRegistry::Get().GetTypeInfo( typeid(Dali::CameraActor) );
696 DALI_TEST_CHECK( named_type );
697 DALI_TEST_CHECK( typeinfo_type );
699 // Check named and typeid are equivalent
700 DALI_TEST_CHECK( named_type == typeinfo_type );
702 DALI_TEST_CHECK( named_type.GetName() == typeinfo_type.GetName() );
703 DALI_TEST_CHECK( named_type.GetBaseName() == typeinfo_type.GetBaseName() );
708 int UtcDaliTypeRegistryGetTypeInfoFromTypeIdN(void)
710 TestApplication application;
711 TypeRegistry typeRegistry = TypeRegistry::Get();
713 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(Vector2) );
714 DALI_TEST_CHECK( !typeInfo );
719 int UtcDaliTypeRegistryGetTypeNameCountP(void)
721 TestApplication application;
722 TypeRegistry typeRegistry = TypeRegistry::Get();
725 for(size_t i = 0; i < typeRegistry.GetTypeNameCount(); i++)
727 type = typeRegistry.GetTypeInfo( typeRegistry.GetTypeName(i) );
728 DALI_TEST_CHECK( type );
735 int UtcDaliTypeRegistryGetTypeNamesP(void)
737 TestApplication application;
738 TypeRegistry typeRegistry = TypeRegistry::Get();
741 for(size_t i = 0; i < typeRegistry.GetTypeNameCount(); i++)
743 type = typeRegistry.GetTypeInfo( typeRegistry.GetTypeName(i) );
744 DALI_TEST_CHECK( type );
751 // Note: No negative test case for UtcDaliTypeRegistryTypeRegistration can be implemented.
752 int UtcDaliTypeRegistryTypeRegistrationNotCallingCreateOnInitP(void)
754 ResetFunctorCounts();
756 TestApplication application;
758 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
759 DALI_TEST_CHECK( type );
761 TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( "CustomActor" );
762 DALI_TEST_CHECK( baseType );
764 BaseHandle handle = type.CreateInstance();
765 DALI_TEST_CHECK( handle );
767 MyTestCustomActor customHandle = MyTestCustomActor::DownCast( handle );
768 DALI_TEST_CHECK( customHandle );
770 DALI_TEST_EQUALS( type.GetActionCount(), TEST_ACTION_COUNT + baseType.GetActionCount(), TEST_LOCATION );
772 DALI_TEST_EQUALS( type.GetSignalCount(), TEST_SIGNAL_COUNT + baseType.GetSignalCount(), TEST_LOCATION );
775 TestConnectionTracker tracker;
777 bool connected = handle.ConnectSignal( &tracker, "sig1", CustomTestFunctor() );
778 DALI_TEST_EQUALS( connected, true, TEST_LOCATION );
779 DALI_TEST_CHECK( lastSignalConnectionCustom == "sig1" );
780 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
781 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION );
783 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
784 customHandle.GetCustomSignal().Emit();
785 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION );
786 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
787 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION );
789 // tracker should automatically disconnect here
790 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
791 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
793 // Test that functor is disconnected
794 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION );
795 customHandle.GetCustomSignal().Emit();
796 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1/*not incremented*/, TEST_LOCATION );
797 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
798 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
800 Property::Map attributes;
801 handle.DoAction("act1", attributes);
802 DALI_TEST_CHECK( lastActionCustom == "act1" );
806 // Note: No negative test case for UtcDaliTypeRegistryTypeRegistration can be implemented.
807 int UtcDaliTypeRegistryTypeRegistrationCallingCreateOnInitP(void)
809 TestApplication application;
811 DALI_TEST_CHECK( "MyTestCustomActor2" == customTypeInit.RegisteredName() );
813 DALI_TEST_CHECK( true == CreateCustomInitCalled );
814 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor2" );
815 DALI_TEST_CHECK( type );
819 // Note: No negative test case for UtcDaliTypeRegistryTypeRegistration can be implemented.
820 int UtcDaliTypeRegistryTypeRegistrationForNamedTypeP(void)
822 TestApplication application;
824 // Create Named Actor Type
825 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyNamedActor" );
826 DALI_TEST_CHECK( type );
828 BaseHandle namedHandle = type.CreateInstance();
829 DALI_TEST_CHECK( namedHandle );
830 Actor namedActor( Actor::DownCast( namedHandle ) );
831 DALI_TEST_CHECK( namedActor );
833 DALI_TEST_CHECK( namedActor.GetProperty< std::string >( Actor::Property::NAME ) == "NamedActor" );
834 DALI_TEST_CHECK( type.GetName() == "MyNamedActor" );
835 DALI_TEST_CHECK( type.GetBaseName() == "Actor" );
840 int UtcDaliTypeRegistryRegisteredNameP(void)
842 TestApplication application;
844 DALI_TEST_CHECK( scriptedName == scriptedType.RegisteredName() );
846 TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( scriptedName );
847 DALI_TEST_CHECK( baseType );
849 BaseHandle handle = baseType.CreateInstance();
851 DALI_TEST_CHECK( true == CreateCustomNamedInitCalled );
852 TypeInfo type = TypeRegistry::Get().GetTypeInfo( scriptedName );
853 DALI_TEST_CHECK( type );
858 int UtcDaliTypeRegistryRegisteredNameN(void)
860 TestApplication application;
862 DALI_TEST_CHECK( scriptedName == scriptedType.RegisteredName() );
864 TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( scriptedName );
865 DALI_TEST_CHECK( baseType );
867 // should cause an assert because we're registering same type twice
868 // once statically at the start of this file, then again now
871 TypeRegistration scriptedType( scriptedName, typeid(Dali::CustomActor), CreateCustomNamedInit );
872 tet_result( TET_FAIL );
874 catch ( DaliException& e )
876 DALI_TEST_ASSERT( e, "Duplicate type name in Type Registration", TEST_LOCATION );
883 int UtcDaliTypeRegistrySignalConnectorTypeP(void)
885 ResetFunctorCounts();
887 TestApplication application;
889 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
890 DALI_TEST_CHECK( type );
892 BaseHandle handle = type.CreateInstance();
893 DALI_TEST_CHECK( handle );
895 MyTestCustomActor customHandle = MyTestCustomActor::DownCast( handle );
896 DALI_TEST_CHECK( customHandle );
899 TestConnectionTracker tracker;
901 bool connected = handle.ConnectSignal( &tracker, "sig1", CustomTestFunctor() );
902 DALI_TEST_EQUALS( connected, true, TEST_LOCATION );
903 DALI_TEST_CHECK( lastSignalConnectionCustom == "sig1" );
904 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
905 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION );
907 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
908 customHandle.GetCustomSignal().Emit();
909 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION );
910 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
911 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION );
913 // tracker should automatically disconnect here
914 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
915 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
917 // Test that functor is disconnected
918 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION );
919 customHandle.GetCustomSignal().Emit();
920 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1/*not incremented*/, TEST_LOCATION );
921 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
922 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
927 int UtcDaliTypeRegistrySignalConnectorTypeN(void)
929 // Test what happens when signal connnector (DoConnectSignalFailure method) returns false
931 ResetFunctorCounts();
933 TestApplication application;
935 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
936 DALI_TEST_CHECK( type );
938 TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( "CustomActor" );
939 DALI_TEST_CHECK( baseType );
941 BaseHandle handle = type.CreateInstance();
942 DALI_TEST_CHECK( handle );
944 MyTestCustomActor customHandle = MyTestCustomActor::DownCast( handle );
945 DALI_TEST_CHECK( customHandle );
947 DALI_TEST_EQUALS( type.GetActionCount(), TEST_ACTION_COUNT + baseType.GetActionCount(), TEST_LOCATION );
949 DALI_TEST_EQUALS( type.GetSignalCount(), TEST_SIGNAL_COUNT + baseType.GetSignalCount(), TEST_LOCATION );
952 TestConnectionTracker tracker;
954 bool connected = handle.ConnectSignal( &tracker, "sig2", CustomTestFunctor() );
955 DALI_TEST_EQUALS( connected, false/*This is supposed to fail*/, TEST_LOCATION );
956 DALI_TEST_CHECK( lastSignalConnectionCustom == "failed" );
957 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
958 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0/*deleted along with FunctorDelegate*/, TEST_LOCATION );
961 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
962 customHandle.GetCustomSignal().Emit();
963 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0/*never called*/, TEST_LOCATION );
965 // tracker should have nothing to disconnect here
968 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
969 customHandle.GetCustomSignal().Emit();
970 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0/*never called*/, TEST_LOCATION );
974 int UtcDaliTypeRegistryTypeActionP(void)
976 ResetFunctorCounts();
978 TestApplication application;
980 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
981 DALI_TEST_CHECK( type );
983 BaseHandle handle = type.CreateInstance();
984 DALI_TEST_CHECK( handle );
986 Property::Map attributes;
987 DALI_TEST_CHECK( handle.DoAction("act1", attributes) );
988 DALI_TEST_CHECK( lastActionCustom == "act1" );
993 int UtcDaliTypeRegistryTypeActionN(void)
995 ResetFunctorCounts();
997 TestApplication application;
999 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
1000 DALI_TEST_CHECK( type );
1002 BaseHandle handle = type.CreateInstance();
1003 DALI_TEST_CHECK( handle );
1005 Property::Map attributes;
1006 DALI_TEST_CHECK( !handle.DoAction( "unknownAction", attributes ) );
1011 int UtcDaliTypeRegistryPropertyRegistrationP(void)
1013 TestApplication application;
1014 TypeRegistry typeRegistry = TypeRegistry::Get();
1016 // Check property count before property registration
1017 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1018 DALI_TEST_CHECK( typeInfo );
1019 BaseHandle handle = typeInfo.CreateInstance();
1020 DALI_TEST_CHECK( handle );
1021 Actor customActor = Actor::DownCast( handle );
1022 DALI_TEST_CHECK( customActor );
1023 unsigned int initialPropertyCount( customActor.GetPropertyCount() );
1025 std::string propertyName( "prop1" );
1026 int propertyIndex( PROPERTY_REGISTRATION_START_INDEX );
1027 Property::Type propertyType( Property::BOOLEAN );
1028 PropertyRegistration property1( customType1, propertyName, propertyIndex, propertyType, &SetProperty, &GetProperty );
1030 // Check property count after registration
1031 unsigned int postRegistrationPropertyCount( customActor.GetPropertyCount() );
1032 DALI_TEST_EQUALS( initialPropertyCount + 1u, postRegistrationPropertyCount, TEST_LOCATION );
1034 // Add custom property and check property count
1035 customActor.RegisterProperty( "customProp1", true );
1036 unsigned int customPropertyCount( customActor.GetPropertyCount() );
1037 DALI_TEST_EQUALS( postRegistrationPropertyCount + 1u, customPropertyCount, TEST_LOCATION );
1039 // Set the property, ensure SetProperty called
1040 DALI_TEST_CHECK( !setPropertyCalled );
1041 customActor.SetProperty( propertyIndex, false );
1042 DALI_TEST_CHECK( setPropertyCalled );
1044 // Get the property, ensure GetProperty called
1045 DALI_TEST_CHECK( !getPropertyCalled );
1046 (void)customActor.GetProperty< bool >( propertyIndex );
1047 DALI_TEST_CHECK( getPropertyCalled );
1049 // Get the property using GetCurrentProperty and ensure GetProperty is called
1050 getPropertyCalled = false;
1051 DALI_TEST_CHECK( !getPropertyCalled );
1052 customActor.GetCurrentProperty< bool >( propertyIndex );
1053 DALI_TEST_CHECK( getPropertyCalled );
1055 // Check the property name
1056 DALI_TEST_EQUALS( customActor.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
1057 DALI_TEST_EQUALS( typeInfo.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
1059 // Check the property index
1060 DALI_TEST_EQUALS( customActor.GetPropertyIndex( propertyName ), propertyIndex, TEST_LOCATION );
1062 // Check the property type
1063 DALI_TEST_EQUALS( customActor.GetPropertyType( propertyIndex ), propertyType, TEST_LOCATION );
1065 // Check property count of type-info is 1
1066 Property::IndexContainer indices;
1067 typeInfo.GetPropertyIndices( indices );
1069 size_t typePropertyCount = typeInfo.GetPropertyCount();
1070 DALI_TEST_EQUALS( indices.Size(), Actor::New().GetPropertyCount() + 1u, TEST_LOCATION );
1071 DALI_TEST_EQUALS( indices.Size(), typePropertyCount, TEST_LOCATION );
1073 // Ensure indices returned from actor and customActor differ by two
1074 Actor actor = Actor::New();
1075 actor.GetPropertyIndices( indices );
1076 unsigned int actorIndices = indices.Size();
1077 customActor.GetPropertyIndices( indices );
1078 unsigned int customActorIndices = indices.Size();
1079 DALI_TEST_EQUALS( actorIndices + 2u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1083 int UtcDaliTypeRegistryPropertyRegistrationN(void)
1085 TestApplication application;
1086 TypeRegistry typeRegistry = TypeRegistry::Get();
1088 // Attempt to register a property type out-of-bounds index (less than)
1091 PropertyRegistration property1( customType1, "propName", PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN, &SetProperty, &GetProperty );
1092 tet_result( TET_FAIL );
1094 catch ( DaliException& e )
1096 DALI_TEST_ASSERT( e, "( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1099 // Attempt to register a property type out-of-bounds index (greater than)
1102 PropertyRegistration property1( customType1, "propName", PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN, &SetProperty, &GetProperty );
1103 tet_result( TET_FAIL );
1105 catch ( DaliException& e )
1107 DALI_TEST_ASSERT( e, "( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1113 int UtcDaliTypeRegistryAnimatablePropertyRegistrationP(void)
1115 TestApplication application;
1116 TypeRegistry typeRegistry = TypeRegistry::Get();
1118 // Check property count before property registration
1119 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1120 DALI_TEST_CHECK( typeInfo );
1121 BaseHandle handle = typeInfo.CreateInstance();
1122 DALI_TEST_CHECK( handle );
1123 Actor customActor = Actor::DownCast( handle );
1124 DALI_TEST_CHECK( customActor );
1125 application.GetScene().Add(customActor);
1127 unsigned int customPropertyCount( customActor.GetPropertyCount() );
1129 // Register animatable property
1130 std::string animatablePropertyName( "animatableProp1" );
1131 int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1132 Property::Type animatablePropertyType( Property::FLOAT );
1133 AnimatablePropertyRegistration animatableProperty( customType1, animatablePropertyName, animatablePropertyIndex, animatablePropertyType );
1135 // Check property count after registration
1136 DALI_TEST_EQUALS( customPropertyCount + 1u, customActor.GetPropertyCount(), TEST_LOCATION );
1138 // Set the animatable property value
1139 customActor.SetProperty( animatablePropertyIndex, 25.0f );
1141 // Render and notify
1142 application.SendNotification();
1143 application.Render();
1145 // Check the animatable property value
1146 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 25.f, TEST_LOCATION );
1148 // Check the animatable property name
1149 DALI_TEST_EQUALS( customActor.GetPropertyName( animatablePropertyIndex ), animatablePropertyName, TEST_LOCATION );
1151 // Check the animatable property index
1152 DALI_TEST_EQUALS( customActor.GetPropertyIndex( animatablePropertyName ), animatablePropertyIndex, TEST_LOCATION );
1154 // Check the animatable property type
1155 DALI_TEST_EQUALS( customActor.GetPropertyType( animatablePropertyIndex ), animatablePropertyType, TEST_LOCATION );
1157 // Check property count of type-info is 1
1158 Property::IndexContainer indices;
1159 typeInfo.GetPropertyIndices( indices );
1160 DALI_TEST_EQUALS( indices.Size(), customActor.GetPropertyCount(), TEST_LOCATION );
1162 // Ensure indices returned from actor and customActor differ by one
1163 Actor actor = Actor::New();
1164 actor.GetPropertyIndices( indices );
1165 unsigned int actorIndices = indices.Size();
1166 customActor.GetPropertyIndices( indices );
1167 unsigned int customActorIndices = indices.Size();
1168 DALI_TEST_EQUALS( actorIndices + 1u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1170 // check that the property is animatable
1171 Animation animation = Animation::New(0.2f);
1172 animation.AnimateTo( Property( customActor, animatablePropertyIndex ), 15.f, AlphaFunction::LINEAR );
1175 // Target value should change straight away
1176 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 15.0f, TEST_LOCATION );
1178 // Render and notify, animation play for 0.05 seconds
1179 application.SendNotification();
1180 application.Render(50);
1181 DALI_TEST_EQUALS( 0.25f, animation.GetCurrentProgress(), TEST_LOCATION );
1182 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 22.5f, TEST_LOCATION );
1184 // Render and notify, animation play for another 0.1 seconds
1185 application.SendNotification();
1186 application.Render(100);
1187 DALI_TEST_EQUALS( 0.75f, animation.GetCurrentProgress(), TEST_LOCATION );
1188 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 17.5f, TEST_LOCATION );
1193 int UtcDaliTypeRegistryAnimatablePropertyRegistrationN(void)
1195 TestApplication application;
1196 TypeRegistry typeRegistry = TypeRegistry::Get();
1198 // Attempt to register an animatable property type out-of-bounds index (less than)
1201 AnimatablePropertyRegistration property1( customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN );
1202 tet_result( TET_FAIL );
1204 catch ( DaliException& e )
1206 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1209 // Attempt to register an animatable property type out-of-bounds index (greater than)
1212 AnimatablePropertyRegistration property1( customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN );
1213 tet_result( TET_FAIL );
1215 catch ( DaliException& e )
1217 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1223 int UtcDaliTypeRegistryAnimatablePropertyRegistrationWithDefaultP(void)
1225 TestApplication application;
1226 TypeRegistry typeRegistry = TypeRegistry::Get();
1228 // Check property count before property registration
1229 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1230 DALI_TEST_CHECK( typeInfo );
1231 BaseHandle handle = typeInfo.CreateInstance();
1232 DALI_TEST_CHECK( handle );
1233 Actor customActor = Actor::DownCast( handle );
1234 DALI_TEST_CHECK( customActor );
1235 application.GetScene().Add(customActor);
1237 unsigned int customPropertyCount( customActor.GetPropertyCount() );
1239 // Register animatable property
1240 std::string animatablePropertyName( "animatableProp1" );
1241 int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1242 AnimatablePropertyRegistration animatableProperty1( customType1, animatablePropertyName, animatablePropertyIndex, 10.f );
1244 // Check property count after registration
1245 DALI_TEST_EQUALS( customPropertyCount + 1u, customActor.GetPropertyCount(), TEST_LOCATION );
1247 // Render and notify
1248 application.SendNotification();
1249 application.Render();
1251 // Check the animatable property value
1252 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 10.f, TEST_LOCATION );
1254 // Check the animatable property name
1255 DALI_TEST_EQUALS( customActor.GetPropertyName( animatablePropertyIndex ), animatablePropertyName, TEST_LOCATION );
1257 // Check the animatable property index
1258 DALI_TEST_EQUALS( customActor.GetPropertyIndex( animatablePropertyName ), animatablePropertyIndex, TEST_LOCATION );
1260 // Check the animatable property type
1261 DALI_TEST_EQUALS( customActor.GetPropertyType( animatablePropertyIndex ), Property::FLOAT, TEST_LOCATION );
1263 // Check property count of type-info
1264 Property::IndexContainer indices;
1265 typeInfo.GetPropertyIndices( indices );
1266 DALI_TEST_EQUALS( indices.Size(), customActor.GetPropertyCount(), TEST_LOCATION );
1268 // Ensure indices returned from actor and customActor differ by one
1269 Actor actor = Actor::New();
1270 actor.GetPropertyIndices( indices );
1271 unsigned int actorIndices = indices.Size();
1272 customActor.GetPropertyIndices( indices );
1273 unsigned int customActorIndices = indices.Size();
1274 DALI_TEST_EQUALS( actorIndices + 1u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1276 // check that the property is animatable
1277 Animation animation = Animation::New(0.2f);
1278 animation.AnimateTo( Property( customActor, animatablePropertyIndex ), 20.f, AlphaFunction::LINEAR );
1281 // Target value should change straight away
1282 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 20.0f, TEST_LOCATION );
1284 // Render and notify, animation play for 0.05 seconds
1285 application.SendNotification();
1286 application.Render(50);
1287 DALI_TEST_EQUALS( 0.25f, animation.GetCurrentProgress(), TEST_LOCATION );
1288 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 12.5f, TEST_LOCATION );
1290 // Render and notify, animation play for another 0.1 seconds
1291 application.SendNotification();
1292 application.Render(100);
1293 DALI_TEST_EQUALS( 0.75f, animation.GetCurrentProgress(), TEST_LOCATION );
1294 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 17.5f, TEST_LOCATION );
1299 int UtcDaliTypeRegistryAnimatablePropertyRegistrationWithDefaultN(void)
1301 TestApplication application;
1302 TypeRegistry typeRegistry = TypeRegistry::Get();
1304 // Attempt to register an animatable property type out-of-bounds index (less than)
1307 AnimatablePropertyRegistration property1( customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX - 1, false );
1308 tet_result( TET_FAIL );
1310 catch ( DaliException& e )
1312 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1315 // Attempt to register an animatable property type out-of-bounds index (greater than)
1318 AnimatablePropertyRegistration property1( customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX + 1, true );
1319 tet_result( TET_FAIL );
1321 catch ( DaliException& e )
1323 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1329 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationP(void)
1331 TestApplication application;
1332 TypeRegistry typeRegistry = TypeRegistry::Get();
1334 // Check property count before property registration
1335 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1336 DALI_TEST_CHECK( typeInfo );
1337 BaseHandle handle = typeInfo.CreateInstance();
1338 DALI_TEST_CHECK( handle );
1339 Actor customActor = Actor::DownCast( handle );
1340 DALI_TEST_CHECK( customActor );
1342 unsigned int customPropertyCount( customActor.GetPropertyCount() );
1344 // Register animatable property
1345 std::string animatablePropertyName( "animatableProp1" );
1346 int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1347 Property::Type animatablePropertyType( Property::VECTOR2 );
1348 AnimatablePropertyRegistration animatableProperty1( customType1, animatablePropertyName, animatablePropertyIndex, animatablePropertyType );
1350 // Check property count after registration
1351 DALI_TEST_EQUALS( customPropertyCount + 1u, customActor.GetPropertyCount(), TEST_LOCATION );
1353 // Set the animatable property value
1354 customActor.SetProperty( animatablePropertyIndex, Vector2(25.0f, 50.0f) );
1356 // Render and notify
1357 application.SendNotification();
1358 application.Render();
1360 // Check the animatable property value
1361 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( animatablePropertyIndex ), Vector2(25.0f, 50.0f), TEST_LOCATION );
1363 // Check the animatable property name
1364 DALI_TEST_EQUALS( customActor.GetPropertyName( animatablePropertyIndex ), animatablePropertyName, TEST_LOCATION );
1366 // Check the animatable property index
1367 DALI_TEST_EQUALS( customActor.GetPropertyIndex( animatablePropertyName ), animatablePropertyIndex, TEST_LOCATION );
1369 // Check the animatable property type
1370 DALI_TEST_EQUALS( customActor.GetPropertyType( animatablePropertyIndex ), animatablePropertyType, TEST_LOCATION );
1372 // Check property count of type-info
1373 Property::IndexContainer indices;
1374 typeInfo.GetPropertyIndices( indices );
1375 DALI_TEST_EQUALS( indices.Size(), customActor.GetPropertyCount(), TEST_LOCATION );
1377 // Register animatable property components
1378 std::string animatablePropertyComponentName1( "animatableProp1X" );
1379 int animatablePropertyComponentIndex1( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1 );
1380 AnimatablePropertyComponentRegistration animatablePropertyComponent1( customType1, animatablePropertyComponentName1, animatablePropertyComponentIndex1, animatablePropertyIndex, 0 );
1382 std::string animatablePropertyComponentName2( "animatableProp1Y" );
1383 int animatablePropertyComponentIndex2( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2 );
1384 AnimatablePropertyComponentRegistration animatablePropertyComponent2( customType1, animatablePropertyComponentName2, animatablePropertyComponentIndex2, animatablePropertyIndex, 1 );
1386 // Check property count after registration
1387 DALI_TEST_EQUALS( customPropertyCount + 3u, customActor.GetPropertyCount(), TEST_LOCATION );
1389 // Check the animatable property component value
1390 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex1 ), 25.0f, TEST_LOCATION );
1391 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex2 ), 50.0f, TEST_LOCATION );
1393 // Set the animatable property component value
1394 customActor.SetProperty( animatablePropertyComponentIndex1, 150.0f );
1396 // Render and notify
1397 application.SendNotification();
1398 application.Render();
1400 // Check the animatable property value
1401 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector2 >( animatablePropertyIndex ), Vector2(150.0f, 50.0f), TEST_LOCATION );
1402 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex1 ), 150.0f, TEST_LOCATION );
1403 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex2 ), 50.0f, TEST_LOCATION );
1405 // Set the animatable property component value
1406 customActor.SetProperty( animatablePropertyComponentIndex2, 225.0f );
1408 // Render and notify
1409 application.SendNotification();
1410 application.Render();
1412 // Check the animatable property value
1413 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector2 >( animatablePropertyIndex ), Vector2(150.0f, 225.0f), TEST_LOCATION );
1414 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex1 ), 150.0f, TEST_LOCATION );
1415 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex2 ), 225.0f, TEST_LOCATION );
1417 // Ensure indices returned from actor and customActor differ by three
1418 Actor actor = Actor::New();
1419 actor.GetPropertyIndices( indices );
1420 unsigned int actorIndices = indices.Size();
1421 customActor.GetPropertyIndices( indices );
1422 unsigned int customActorIndices = indices.Size();
1423 DALI_TEST_EQUALS( actorIndices + 3u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1425 // Attempt to animate component property, it should not crash
1426 Animation animation = Animation::New( 1.0f );
1427 animation.AnimateTo( Property( customActor, animatablePropertyComponentIndex1 ), 200.0f );
1430 // Check the property value
1431 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( animatablePropertyIndex ), Vector2(200.0f, 225.0f), TEST_LOCATION );
1432 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex1 ), 200.0f, TEST_LOCATION );
1433 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex2 ), 225.0f, TEST_LOCATION );
1438 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationVector2AnimateByP(void)
1440 TestApplication application;
1441 TypeRegistry typeRegistry = TypeRegistry::Get();
1443 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1444 DALI_TEST_CHECK( typeInfo );
1445 BaseHandle handle = typeInfo.CreateInstance();
1446 DALI_TEST_CHECK( handle );
1447 Actor customActor = Actor::DownCast( handle );
1448 DALI_TEST_CHECK( customActor );
1450 const unsigned int index = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX;
1451 const unsigned int xComponentIndex = index + 1;
1452 const unsigned int yComponentIndex = index + 2;
1453 const Vector2 initialValue( 20.0f, 40.0f );
1455 // Register animatable property & its components
1456 AnimatablePropertyRegistration animatableProperty1( customType1, "animatableProp1", index, initialValue );
1457 AnimatablePropertyComponentRegistration animatablePropertyComponent1( customType1, "animatableProp1X", xComponentIndex, index, 0 );
1458 AnimatablePropertyComponentRegistration animatablePropertyComponent2( customType1, "animatableProp1Y", yComponentIndex, index, 1 );
1460 // Check the animatable property value
1461 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( index ), initialValue, TEST_LOCATION );
1462 DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
1463 DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
1465 // Render and notify
1466 application.SendNotification();
1467 application.Render();
1469 // Check the animatable property current value
1470 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector2 >( index ), initialValue, TEST_LOCATION );
1471 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
1472 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
1475 const Vector2 targetValue( 45.0f, 53.0f );
1476 const Vector2 relativeValue( targetValue - initialValue );
1478 Animation animation = Animation::New( 1.0f );
1479 animation.AnimateBy( Property( customActor, xComponentIndex ), relativeValue.x );
1480 animation.AnimateBy( Property( customActor, yComponentIndex ), relativeValue.y );
1483 // Target values should change straight away
1484 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
1485 DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), targetValue.x, TEST_LOCATION );
1486 DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), targetValue.y, TEST_LOCATION );
1491 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationVector3AnimateByP(void)
1493 TestApplication application;
1494 TypeRegistry typeRegistry = TypeRegistry::Get();
1496 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1497 DALI_TEST_CHECK( typeInfo );
1498 BaseHandle handle = typeInfo.CreateInstance();
1499 DALI_TEST_CHECK( handle );
1500 Actor customActor = Actor::DownCast( handle );
1501 DALI_TEST_CHECK( customActor );
1503 const unsigned int index = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX;
1504 const unsigned int xComponentIndex = index + 1;
1505 const unsigned int yComponentIndex = index + 2;
1506 const unsigned int zComponentIndex = index + 3;
1507 const Vector3 initialValue( 20.0f, 40.0f, 50.0f );
1509 // Register animatable property & its components
1510 AnimatablePropertyRegistration animatableProperty1( customType1, "animatableProp1", index, initialValue );
1511 AnimatablePropertyComponentRegistration animatablePropertyComponent1( customType1, "animatableProp1X", xComponentIndex, index, 0 );
1512 AnimatablePropertyComponentRegistration animatablePropertyComponent2( customType1, "animatableProp1Y", yComponentIndex, index, 1 );
1513 AnimatablePropertyComponentRegistration animatablePropertyComponent3( customType1, "animatableProp1Z", zComponentIndex, index, 2 );
1515 // Check the animatable property value
1516 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( 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 );
1521 // Render and notify
1522 application.SendNotification();
1523 application.Render();
1525 // Check the animatable property current value
1526 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector3 >( index ), initialValue, TEST_LOCATION );
1527 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
1528 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
1529 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( zComponentIndex ), initialValue.z, TEST_LOCATION );
1532 const Vector3 targetValue( 45.0f, 53.0f, 25.0f );
1533 const Vector3 relativeValue( targetValue - initialValue );
1535 Animation animation = Animation::New( 1.0f );
1536 animation.AnimateBy( Property( customActor, xComponentIndex ), relativeValue.x );
1537 animation.AnimateBy( Property( customActor, yComponentIndex ), relativeValue.y );
1538 animation.AnimateBy( Property( customActor, zComponentIndex ), relativeValue.z );
1541 // Target values should change straight away
1542 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
1543 DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), targetValue.x, TEST_LOCATION );
1544 DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), targetValue.y, TEST_LOCATION );
1545 DALI_TEST_EQUALS( customActor.GetProperty< float >( zComponentIndex ), targetValue.z, TEST_LOCATION );
1550 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationVector4AnimateByP(void)
1552 TestApplication application;
1553 TypeRegistry typeRegistry = TypeRegistry::Get();
1555 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1556 DALI_TEST_CHECK( typeInfo );
1557 BaseHandle handle = typeInfo.CreateInstance();
1558 DALI_TEST_CHECK( handle );
1559 Actor customActor = Actor::DownCast( handle );
1560 DALI_TEST_CHECK( customActor );
1562 const unsigned int index = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX;
1563 const unsigned int xComponentIndex = index + 1;
1564 const unsigned int yComponentIndex = index + 2;
1565 const unsigned int zComponentIndex = index + 3;
1566 const unsigned int wComponentIndex = index + 4;
1567 const Vector4 initialValue( 20.0f, 40.0f, 50.0f, 60.0f );
1569 // Register animatable property & its components
1570 AnimatablePropertyRegistration animatableProperty1( customType1, "animatableProp1", index, initialValue );
1571 AnimatablePropertyComponentRegistration animatablePropertyComponent1( customType1, "animatableProp1X", xComponentIndex, index, 0 );
1572 AnimatablePropertyComponentRegistration animatablePropertyComponent2( customType1, "animatableProp1Y", yComponentIndex, index, 1 );
1573 AnimatablePropertyComponentRegistration animatablePropertyComponent3( customType1, "animatableProp1Z", zComponentIndex, index, 2 );
1574 AnimatablePropertyComponentRegistration animatablePropertyComponent4( customType1, "animatableProp1W", wComponentIndex, index, 3 );
1576 // Check the animatable property value
1577 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( index ), initialValue, TEST_LOCATION );
1578 DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
1579 DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
1580 DALI_TEST_EQUALS( customActor.GetProperty< float >( zComponentIndex ), initialValue.z, TEST_LOCATION );
1581 DALI_TEST_EQUALS( customActor.GetProperty< float >( wComponentIndex ), initialValue.w, TEST_LOCATION );
1583 // Render and notify
1584 application.SendNotification();
1585 application.Render();
1587 // Check the animatable property current value
1588 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector4 >( index ), initialValue, TEST_LOCATION );
1589 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
1590 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
1591 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( zComponentIndex ), initialValue.z, TEST_LOCATION );
1592 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( wComponentIndex ), initialValue.w, TEST_LOCATION );
1595 const Vector4 targetValue( 45.0f, 53.0f, 25.0f, 13.0f );
1596 const Vector4 relativeValue( targetValue - initialValue );
1598 Animation animation = Animation::New( 1.0f );
1599 animation.AnimateBy( Property( customActor, xComponentIndex ), relativeValue.x );
1600 animation.AnimateBy( Property( customActor, yComponentIndex ), relativeValue.y );
1601 animation.AnimateBy( Property( customActor, zComponentIndex ), relativeValue.z );
1602 animation.AnimateBy( Property( customActor, wComponentIndex ), relativeValue.w );
1605 // Target values should change straight away
1606 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
1607 DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), targetValue.x, TEST_LOCATION );
1608 DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), targetValue.y, TEST_LOCATION );
1609 DALI_TEST_EQUALS( customActor.GetProperty< float >( zComponentIndex ), targetValue.z, TEST_LOCATION );
1610 DALI_TEST_EQUALS( customActor.GetProperty< float >( wComponentIndex ), targetValue.w, TEST_LOCATION );
1615 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationN(void)
1617 TestApplication application;
1618 TypeRegistry typeRegistry = TypeRegistry::Get();
1620 // Register animatable property with the type of Vector2
1621 int animatablePropertyIndex1( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1622 AnimatablePropertyRegistration animatableProperty1( customType1, "animatableProp1", animatablePropertyIndex1, Property::VECTOR2 );
1624 // Attempt to register an animatable property component out-of-bounds index (less than)
1627 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp1X", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX - 1, animatablePropertyIndex1, 0 );
1628 tet_result( TET_FAIL );
1630 catch ( DaliException& e )
1632 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1635 // Attempt to register an animatable property component out-of-bounds index (greater than)
1638 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp1X", ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX + 1, animatablePropertyIndex1, 0 );
1639 tet_result( TET_FAIL );
1641 catch ( DaliException& e )
1643 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1646 // Register an animatable property component
1647 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp1X", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1, animatablePropertyIndex1, 0 );
1649 // Attempt to register another animatable property component with the same component index
1652 AnimatablePropertyComponentRegistration propertyComponent2( customType1, "animatableProp1Y", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2, animatablePropertyIndex1, 0 );
1653 tet_result( TET_FAIL );
1655 catch ( DaliException& e )
1657 DALI_TEST_ASSERT( e, "Property component already registered", TEST_LOCATION );
1660 // Register animatable property with the type of boolean
1661 int animatablePropertyIndex2( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2 );
1662 AnimatablePropertyRegistration animatableProperty2( customType1, "animatableProp2", animatablePropertyIndex2, Property::BOOLEAN );
1664 // Attempt to register an animatable property component for the above property with boolean type
1667 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp2X", animatablePropertyIndex2 + 1, animatablePropertyIndex2, 0 );
1668 tet_result( TET_FAIL );
1670 catch ( DaliException& e )
1672 DALI_TEST_ASSERT( e, "Base property does not support component", TEST_LOCATION );
1678 int UtcDaliTypeRegistryChildPropertyRegistrationP(void)
1680 TestApplication application;
1681 TypeRegistry typeRegistry = TypeRegistry::Get();
1683 // Check property count before property registration
1684 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1685 DALI_TEST_CHECK( typeInfo );
1686 BaseHandle handle = typeInfo.CreateInstance();
1687 DALI_TEST_CHECK( handle );
1688 Actor customActor = Actor::DownCast( handle );
1689 DALI_TEST_CHECK( customActor );
1690 unsigned int initialPropertyCount( customActor.GetPropertyCount() );
1692 // Register child properties to the parent
1693 std::string propertyName( "childProp1" );
1694 int propertyIndex( CHILD_PROPERTY_REGISTRATION_START_INDEX );
1695 Property::Type propertyType( Property::BOOLEAN );
1696 ChildPropertyRegistration childProperty1( customType1, propertyName, propertyIndex, propertyType );
1698 std::string propertyName2( "childProp2" );
1699 int propertyIndex2( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1 );
1700 Property::Type propertyType2( Property::INTEGER );
1701 ChildPropertyRegistration childProperty2( customType1, propertyName2, propertyIndex2, propertyType2 );
1703 std::string propertyName3( "childProp3" );
1704 int propertyIndex3( CHILD_PROPERTY_REGISTRATION_START_INDEX + 2 );
1705 Property::Type propertyType3( Property::FLOAT );
1706 ChildPropertyRegistration childProperty3( customType1, propertyName3, propertyIndex3, propertyType3 );
1708 std::string propertyName4( "childProp4" );
1709 int propertyIndex4( CHILD_PROPERTY_REGISTRATION_START_INDEX + 3 );
1710 Property::Type propertyType4( Property::INTEGER );
1711 ChildPropertyRegistration childProperty4( customType1, propertyName4, propertyIndex4, propertyType4 );
1713 // Check property count are not changed because the child properties will not be created for the parent
1714 DALI_TEST_EQUALS( initialPropertyCount, customActor.GetPropertyCount(), TEST_LOCATION );
1716 // check the child property type
1717 Internal::TypeInfo& typeInfoImpl = GetImplementation( typeInfo );
1718 Property::Type type = typeInfoImpl.GetChildPropertyType( typeInfoImpl.GetChildPropertyIndex("childProp4") );
1719 DALI_TEST_EQUALS( type, Property::INTEGER, TEST_LOCATION );
1721 std::string unRegisteredChildName( typeInfoImpl.GetChildPropertyName( CHILD_PROPERTY_REGISTRATION_START_INDEX + 4 ) );
1722 DALI_TEST_EQUALS( unRegisteredChildName, "", TEST_LOCATION );
1724 // Create a child actor
1725 Actor childActor = Actor::New();
1726 DALI_TEST_CHECK( childActor );
1727 unsigned int initialChildActorPropertyCount( childActor.GetPropertyCount() );
1729 // The type of child properties should be Property::None as the child hasn't registered any child property yet.
1730 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex ), Property::NONE, TEST_LOCATION );
1731 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex2 ), Property::NONE, TEST_LOCATION );
1732 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex3 ), Property::NONE, TEST_LOCATION );
1733 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex4 ), Property::NONE, TEST_LOCATION );
1735 // Set the value for the first child property when the child actor doesn't have a parent yet
1736 childActor.SetProperty(propertyIndex, true);
1738 // Check that the first child property is dynamically created
1739 DALI_TEST_EQUALS( initialChildActorPropertyCount + 1u, childActor.GetPropertyCount(), TEST_LOCATION );
1741 // Check the first child property value
1742 DALI_TEST_EQUALS( childActor.GetProperty< bool >( propertyIndex ), true, TEST_LOCATION );
1744 // Check the first child property type
1745 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex ), propertyType, TEST_LOCATION );
1747 // Check that the first child property have no name, as it doesn't have a parent yet.
1748 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex ), "", TEST_LOCATION );
1750 // Check that the first property can't be accessed through its name, as it doesn't have a parent yet.
1751 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName ), Property::INVALID_INDEX, TEST_LOCATION );
1753 // Create a custom property for the child with the same name as the second child property registered to the parent
1754 Property::Index customPropertyIndex = childActor.RegisterProperty(propertyName2, 100, Property::READ_WRITE);
1756 // Check that the custom property is created
1757 DALI_TEST_EQUALS( initialChildActorPropertyCount + 2u, childActor.GetPropertyCount(), TEST_LOCATION );
1759 // Check the property value
1760 DALI_TEST_EQUALS( childActor.GetProperty< int >( customPropertyIndex ), 100, TEST_LOCATION );
1762 // Check the property index
1763 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName2 ), customPropertyIndex, TEST_LOCATION );
1765 // Check the property type
1766 DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex ), propertyType2, TEST_LOCATION );
1768 // Check the property name
1769 DALI_TEST_EQUALS( childActor.GetPropertyName( customPropertyIndex ), propertyName2, TEST_LOCATION );
1771 // Now add the child actor to the parent
1772 customActor.Add( childActor );
1774 // Check that the first child property now has the correct name as previously registered to the parent
1775 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
1777 // Check that the child property index for the first child property can now be retrieved through its child property name
1778 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName ), propertyIndex, TEST_LOCATION );
1780 // Check that the second child property now has the correct index as previously registered to the parent
1781 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex2 ), propertyName2, TEST_LOCATION );
1783 // Check that the second child property can be accessed through both its custom property index and its child property index
1784 DALI_TEST_EQUALS( childActor.GetProperty< int >( customPropertyIndex ), 100, TEST_LOCATION );
1785 DALI_TEST_EQUALS( childActor.GetProperty< int >( propertyIndex2 ), 100, TEST_LOCATION );
1786 DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex ), propertyType2, TEST_LOCATION );
1787 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex2 ), propertyType2, TEST_LOCATION );
1789 // Check that the child property index for the second child property can now be retrieved through its child property name
1790 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName2 ), propertyIndex2, TEST_LOCATION );
1792 // Set the value for the third child property when the child actor is already added to the parent
1793 childActor.SetProperty(propertyIndex3, 0.15f);
1795 // Check that the third child property is dynamically created
1796 DALI_TEST_EQUALS( initialChildActorPropertyCount + 3u, childActor.GetPropertyCount(), TEST_LOCATION );
1798 // Check the third child property value
1799 DALI_TEST_EQUALS( childActor.GetProperty< float >( propertyIndex3 ), 0.15f, TEST_LOCATION );
1801 // Check the third child property type
1802 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex3 ), propertyType3, TEST_LOCATION );
1804 // Check the third child property name
1805 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex3 ), propertyName3, TEST_LOCATION );
1807 // Check the third child property index.
1808 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName3 ), propertyIndex3, TEST_LOCATION );
1810 // Create a custom property for the child with the same name as the fourth child property registered to the parent
1811 Property::Index customPropertyIndex2 = childActor.RegisterProperty(propertyName4, 20, Property::READ_WRITE);
1813 // Check that the custom property is created
1814 DALI_TEST_EQUALS( initialChildActorPropertyCount + 4u, childActor.GetPropertyCount(), TEST_LOCATION );
1816 // Check the fourth child property value
1817 DALI_TEST_EQUALS( childActor.GetProperty< int >( propertyIndex4 ), 20, TEST_LOCATION );
1818 DALI_TEST_EQUALS( childActor.GetProperty< int >( customPropertyIndex2 ), 20, TEST_LOCATION );
1820 // Check the fourth child property type
1821 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex4 ), propertyType4, TEST_LOCATION );
1822 DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex2 ), propertyType4, TEST_LOCATION );
1824 // Check the fourth child property name
1825 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex4 ), propertyName4, TEST_LOCATION );
1826 DALI_TEST_EQUALS( childActor.GetPropertyName( customPropertyIndex2 ), propertyName4, TEST_LOCATION );
1828 // Check the fourth child property index.
1829 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName4 ), propertyIndex4, TEST_LOCATION );
1831 // Now create another parent actor with different child properties registered
1832 TypeInfo typeInfo2 = typeRegistry.GetTypeInfo( "MyNamedActor" );
1833 DALI_TEST_CHECK( typeInfo2 );
1834 BaseHandle handle2 = typeInfo2.CreateInstance();
1835 DALI_TEST_CHECK( handle2 );
1836 Actor customActor2 = Actor::DownCast( handle2 );
1837 DALI_TEST_CHECK( customActor2 );
1839 // Register child properties to the new parent
1840 std::string newPropertyName( "newChildProp" );
1841 int newPropertyIndex( CHILD_PROPERTY_REGISTRATION_START_INDEX ); // The same index as the first child property "childProp1" in the old parent
1842 Property::Type newPropertyType( Property::VECTOR2 );
1843 ChildPropertyRegistration newChildProperty( namedActorType, newPropertyName, newPropertyIndex, newPropertyType );
1845 std::string newPropertyName2( "childProp3" ); // The same name as the third child property in the old parent
1846 int newPropertyIndex2( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1 ); // The same index as the second child property "childProp2" in the old parent
1847 Property::Type newPropertyType2( Property::FLOAT ); // The same type as the third child property in the old parent
1848 ChildPropertyRegistration newChildProperty2( namedActorType, newPropertyName2, newPropertyIndex2, newPropertyType2 );
1850 // Now move the child actor to the new parent
1851 customActor2.Add( childActor );
1853 // "childProp1" is not a valid child property supported by the new parent, so nothing changed
1854 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex ), propertyType, TEST_LOCATION );
1855 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
1856 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName ), propertyIndex, TEST_LOCATION );
1858 // "childProp3" is a valid child property supported by the new parent
1859 // So it should get its new child property index and should just work
1860 DALI_TEST_EQUALS( childActor.GetPropertyType( newPropertyIndex2 ), newPropertyType2, TEST_LOCATION );
1861 DALI_TEST_EQUALS( childActor.GetPropertyName( newPropertyIndex2 ), newPropertyName2, TEST_LOCATION );
1862 DALI_TEST_EQUALS( childActor.GetPropertyIndex( newPropertyName2 ), newPropertyIndex2, TEST_LOCATION );
1863 DALI_TEST_EQUALS( childActor.GetProperty< float >( newPropertyIndex2 ), 0.15f, TEST_LOCATION );
1865 // Now register a custom property called "newChildProp"
1866 Property::Index customPropertyIndex3 = childActor.RegisterProperty("newChildProp", Vector2( 10.0f, 10.0f ), Property::READ_WRITE);
1868 // Check that the custom property is created
1869 DALI_TEST_EQUALS( initialChildActorPropertyCount + 5u, childActor.GetPropertyCount(), TEST_LOCATION );
1871 // This is a valid child property registered to the new parent
1872 // So should be able to access it through both its custom property index and its registered child property index
1873 DALI_TEST_EQUALS( childActor.GetPropertyType( newPropertyIndex ), newPropertyType, TEST_LOCATION );
1874 DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex3 ), newPropertyType, TEST_LOCATION );
1875 DALI_TEST_EQUALS( childActor.GetPropertyName( newPropertyIndex ), newPropertyName, TEST_LOCATION ); // This should return the new name, although the child property index remains the same
1876 DALI_TEST_EQUALS( childActor.GetPropertyName( customPropertyIndex3 ), newPropertyName, TEST_LOCATION );
1877 DALI_TEST_EQUALS( childActor.GetProperty< Vector2 >( newPropertyIndex ), Vector2( 10.0f, 10.0f ), TEST_LOCATION );
1878 DALI_TEST_EQUALS( childActor.GetProperty< Vector2 >( customPropertyIndex3 ), Vector2( 10.0f, 10.0f ), TEST_LOCATION );
1880 // Should return the child property index by given its name
1881 DALI_TEST_EQUALS( childActor.GetPropertyIndex( newPropertyName ), newPropertyIndex, TEST_LOCATION );
1887 int UtcDaliTypeRegistryChildPropertyRegistrationN(void)
1889 TestApplication application;
1890 TypeRegistry typeRegistry = TypeRegistry::Get();
1892 // Attempt to register a child property type out-of-bounds index (less than)
1895 ChildPropertyRegistration property1( customType1, "propName", CHILD_PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN );
1896 tet_result( TET_FAIL );
1898 catch ( DaliException& e )
1900 DALI_TEST_ASSERT( e, "( index >= CHILD_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1903 // Attempt to register a child property type out-of-bounds index (greater than)
1906 ChildPropertyRegistration property1( customType1, "propName", CHILD_PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN );
1907 tet_result( TET_FAIL );
1909 catch ( DaliException& e )
1911 DALI_TEST_ASSERT( e, "( index >= CHILD_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1918 /*******************************************************************************
1920 * Action through the base handle
1922 ******************************************************************************/
1923 int UtcDaliTypeRegistryActionViaBaseHandle(void)
1925 TestApplication application;
1929 type = TypeRegistry::Get().GetTypeInfo( "Actor" );
1930 DALI_TEST_CHECK( type );
1932 BaseHandle hdl = type.CreateInstance();
1933 DALI_TEST_CHECK( hdl );
1935 Actor a = Actor::DownCast(hdl);
1936 DALI_TEST_CHECK( a );
1938 a.SetProperty( Actor::Property::VISIBLE,false);
1940 application.SendNotification();
1941 application.Render(0);
1942 DALI_TEST_CHECK(!a.GetCurrentProperty< bool >( Actor::Property::VISIBLE ));
1944 Property::Map attributes;
1946 DALI_TEST_CHECK(hdl.DoAction("show", attributes));
1948 application.SendNotification();
1949 application.Render(0);
1950 DALI_TEST_CHECK(a.GetCurrentProperty< bool >( Actor::Property::VISIBLE ));
1952 DALI_TEST_CHECK(!hdl.DoAction("unknownAction", attributes));
1956 int UtcDaliPropertyRegistrationFunctions(void)
1958 TestApplication application;
1959 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 10;
1961 // Attempt to register a property without a setter
1964 PropertyRegistration property1( customType1, "propName", propertyIndex++, Property::BOOLEAN, NULL, &GetProperty );
1965 tet_result( TET_PASS );
1967 catch ( DaliException& e )
1969 tet_result( TET_FAIL );
1972 // Attempt to register a property without a getter
1975 PropertyRegistration property1( customType1, "propName", propertyIndex++, Property::BOOLEAN, NULL, NULL );
1976 tet_result( TET_FAIL );
1978 catch ( DaliException& e )
1980 DALI_TEST_ASSERT( e, "! \"GetProperty", TEST_LOCATION );
1985 int UtcDaliPropertyRegistrationAddSameIndex(void)
1987 TestApplication application;
1988 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 100;
1990 // Add one property with a valid property index
1991 PropertyRegistration property1( customType1, "propName", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
1993 // Attempt to add another property with the same index
1996 PropertyRegistration property2( customType1, "propName2", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
1998 catch ( DaliException& e )
2000 DALI_TEST_ASSERT( e, "! \"Property index already added", TEST_LOCATION );
2003 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 100;
2005 // Add one property with a valid property index
2006 AnimatablePropertyRegistration property3( customType1, "animPropName", animatablePropertyIndex, Property::BOOLEAN );
2008 // Attempt to add another property with the same index
2011 AnimatablePropertyRegistration property4( customType1, "animPropName2", animatablePropertyIndex, Property::BOOLEAN );
2013 catch ( DaliException& e )
2015 DALI_TEST_ASSERT( e, "! \"Property index already added", TEST_LOCATION );
2020 int UtcDaliPropertyRegistrationPropertyWritableP(void)
2022 TestApplication application;
2023 int propertyIndex1 = PROPERTY_REGISTRATION_START_INDEX + 200;
2024 int propertyIndex2 = PROPERTY_REGISTRATION_START_INDEX + 201;
2026 // Add two properties, one with SetProperty, one without
2027 PropertyRegistration property1( customType1, "propNameReadwrite", propertyIndex1, Property::BOOLEAN, &SetProperty, &GetProperty );
2028 PropertyRegistration property2( customType1, "propNameReadonly", propertyIndex2, Property::BOOLEAN, NULL, &GetProperty );
2030 // Create custom-actor
2031 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
2032 DALI_TEST_CHECK( typeInfo );
2033 BaseHandle handle = typeInfo.CreateInstance();
2034 DALI_TEST_CHECK( handle );
2035 Actor customActor = Actor::DownCast( handle );
2036 DALI_TEST_CHECK( customActor );
2038 // Check whether properties are writable
2039 DALI_TEST_CHECK( customActor.IsPropertyWritable( propertyIndex1 ) );
2040 DALI_TEST_CHECK( ! customActor.IsPropertyWritable( propertyIndex2 ) );
2043 // Check the property is writable in the type registry
2044 Internal::TypeInfo& typeInfoImpl = GetImplementation( typeInfo );
2046 DALI_TEST_EQUALS( typeInfoImpl.IsPropertyWritable( propertyIndex1 ), true, TEST_LOCATION );
2051 int UtcDaliPropertyRegistrationPropertyWritableN(void)
2053 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
2054 Internal::TypeInfo& typeInfoImpl = GetImplementation( typeInfo );
2056 DALI_TEST_EQUALS( typeInfoImpl.IsPropertyWritable( Actor::Property::COLOR), true, TEST_LOCATION );
2061 int UtcDaliPropertyRegistrationPropertyAnimatable(void)
2063 TestApplication application;
2064 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 400;
2065 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 400;
2067 // These properties are not animatable
2068 PropertyRegistration property1( customType1, "propName", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
2070 // These properties are animatable
2071 AnimatablePropertyRegistration property2( customType1, "animPropName", animatablePropertyIndex, Property::BOOLEAN );
2073 // Create custom-actor
2074 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
2075 DALI_TEST_CHECK( typeInfo );
2076 BaseHandle handle = typeInfo.CreateInstance();
2077 DALI_TEST_CHECK( handle );
2078 Actor customActor = Actor::DownCast( handle );
2079 DALI_TEST_CHECK( customActor );
2081 // Check if animatable
2082 DALI_TEST_CHECK( ! customActor.IsPropertyAnimatable( propertyIndex ) );
2083 DALI_TEST_CHECK( customActor.IsPropertyAnimatable( animatablePropertyIndex ) );
2085 // Create another instance of custom-actor
2086 BaseHandle handle2 = typeInfo.CreateInstance();
2087 DALI_TEST_CHECK( handle2 );
2088 Actor customActor2 = Actor::DownCast( handle2 );
2089 DALI_TEST_CHECK( customActor2 );
2091 // Check if animatable
2092 DALI_TEST_CHECK( ! customActor2.IsPropertyAnimatable( propertyIndex ) );
2093 DALI_TEST_CHECK( customActor2.IsPropertyAnimatable( animatablePropertyIndex ) );
2097 int UtcDaliPropertyRegistrationUnregisteredGetAndSet(void)
2099 TestApplication application;
2100 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 2000;
2101 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2000;
2103 // Create custom-actor
2104 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
2105 DALI_TEST_CHECK( typeInfo );
2106 BaseHandle handle = typeInfo.CreateInstance();
2107 DALI_TEST_CHECK( handle );
2108 Actor customActor = Actor::DownCast( handle );
2109 DALI_TEST_CHECK( customActor );
2111 // Try to set an index that hasn't been registered, this is a no-op for now, to be fixed in future
2112 customActor.SetProperty( propertyIndex, true );
2113 // DALI_TEST_EQUALS( true, customActor.GetProperty( propertyIndex ).Get<bool>(), TEST_LOCATION);
2115 // Try to set an index that hasn't been registered
2116 customActor.SetProperty( animatablePropertyIndex, true );
2117 DALI_TEST_EQUALS( true, customActor.GetProperty( animatablePropertyIndex ).Get<bool>(), TEST_LOCATION);
2123 int UtcDaliLongPressGestureDetectorTypeRegistry(void)
2125 TestApplication application;
2127 Actor actor = Actor::New();
2128 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
2129 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
2130 application.GetScene().Add(actor);
2134 type = TypeRegistry::Get().GetTypeInfo( "LongPressGestureDetector" );
2135 DALI_TEST_CHECK( type );
2136 BaseHandle handle = type.CreateInstance();
2137 DALI_TEST_CHECK( handle );
2138 LongPressGestureDetector detector = LongPressGestureDetector::DownCast( handle );
2139 DALI_TEST_CHECK( detector );
2141 // Attach actor to detector
2143 GestureReceivedFunctor functor( data );
2144 detector.Attach(actor);
2146 // Connect to signal through type
2147 handle.ConnectSignal( &application, "longPressDetected", functor );
2149 // Render and notify
2150 application.SendNotification();
2151 application.Render();
2154 TestGenerateLongPress( application, 50.0f, 10.0f );
2155 TestEndLongPress( application, 50.0f, 10.0f );
2157 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2161 int UtcDaliPanGestureDetectorTypeRegistry(void)
2163 TestApplication application;
2165 Actor actor = Actor::New();
2166 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
2167 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
2168 application.GetScene().Add(actor);
2172 type = TypeRegistry::Get().GetTypeInfo( "PanGestureDetector" );
2173 DALI_TEST_CHECK( type );
2174 BaseHandle handle = type.CreateInstance();
2175 DALI_TEST_CHECK( handle );
2176 PanGestureDetector detector = PanGestureDetector::DownCast( handle );
2177 DALI_TEST_CHECK( detector );
2179 // Attach actor to detector
2181 GestureReceivedFunctor functor( data );
2182 detector.Attach(actor);
2184 // Connect to signal through type
2185 handle.ConnectSignal( &application, "panDetected", functor );
2187 // Render and notify
2188 application.SendNotification();
2189 application.Render();
2192 TestGenerateMiniPan( application );
2193 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2197 int UtcDaliPinchGestureDetectorTypeRegistry(void)
2199 TestApplication application;
2201 Actor actor = Actor::New();
2202 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
2203 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
2204 application.GetScene().Add(actor);
2208 type = TypeRegistry::Get().GetTypeInfo( "PinchGestureDetector" );
2209 DALI_TEST_CHECK( type );
2210 BaseHandle handle = type.CreateInstance();
2211 DALI_TEST_CHECK( handle );
2212 PinchGestureDetector detector = PinchGestureDetector::DownCast( handle );
2213 DALI_TEST_CHECK( detector );
2215 // Attach actor to detector
2217 GestureReceivedFunctor functor( data );
2218 detector.Attach(actor);
2220 // Connect to signal through type
2221 handle.ConnectSignal( &application, "pinchDetected", functor );
2223 // Render and notify
2224 application.SendNotification();
2225 application.Render();
2228 TestGeneratePinch( application );
2230 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2234 int UtcDaliRotationGestureDetectorTypeRegistry(void)
2236 TestApplication application;
2238 Actor actor = Actor::New();
2239 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
2240 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
2241 application.GetScene().Add(actor);
2245 type = TypeRegistry::Get().GetTypeInfo( "RotationGestureDetector" );
2246 DALI_TEST_CHECK( type );
2247 BaseHandle handle = type.CreateInstance();
2248 DALI_TEST_CHECK( handle );
2249 RotationGestureDetector detector = RotationGestureDetector::DownCast( handle );
2250 DALI_TEST_CHECK( detector );
2252 // Attach actor to detector
2254 GestureReceivedFunctor functor( data );
2255 detector.Attach(actor);
2257 // Connect to signal through type
2258 handle.ConnectSignal( &application, "rotationDetected", functor );
2260 // Render and notify
2261 application.SendNotification();
2262 application.Render();
2265 TestGenerateRotation( application );
2267 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2271 int UtcDaliTapGestureDetectorTypeRegistry(void)
2273 TestApplication application;
2275 Actor actor = Actor::New();
2276 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
2277 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
2278 application.GetScene().Add(actor);
2282 type = TypeRegistry::Get().GetTypeInfo( "TapGestureDetector" );
2283 DALI_TEST_CHECK( type );
2284 BaseHandle handle = type.CreateInstance();
2285 DALI_TEST_CHECK( handle );
2286 TapGestureDetector detector = TapGestureDetector::DownCast( handle );
2287 DALI_TEST_CHECK( detector );
2289 // Attach actor to detector
2291 GestureReceivedFunctor functor( data );
2292 detector.Attach(actor);
2294 // Connect to signal through type
2295 handle.ConnectSignal( &application, "tapDetected", functor );
2297 // Render and notify
2298 application.SendNotification();
2299 application.Render();
2302 TestGenerateTap( application, 50.0, 10.0, 100 );
2304 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2308 int UtcDaliTypeRegistryNamedType(void)
2310 TestApplication application;
2311 TypeRegistry typeRegistry = TypeRegistry::Get();
2313 // Create a normal actor
2314 BaseHandle actorHandle = typeRegistry.GetTypeInfo( "Actor" ).CreateInstance();
2315 DALI_TEST_CHECK( actorHandle );
2316 Actor actor( Actor::DownCast( actorHandle ) );
2317 DALI_TEST_CHECK( actor );
2318 unsigned int actorPropertyCount( actor.GetPropertyCount() );
2320 // Create Named Actor Type
2321 BaseHandle namedHandle = typeRegistry.GetTypeInfo( "MyNamedActor" ).CreateInstance();
2322 DALI_TEST_CHECK( namedHandle );
2323 Actor namedActor( Actor::DownCast( namedHandle ) );
2324 DALI_TEST_CHECK( namedActor );
2325 unsigned int namedActorPropertyCount( namedActor.GetPropertyCount() );
2327 DALI_TEST_CHECK( namedActorPropertyCount > actorPropertyCount );
2331 int UtcDaliTypeInfoGetActionNameP(void)
2333 TestApplication application;
2334 TypeRegistry typeRegistry = TypeRegistry::Get();
2336 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2337 DALI_TEST_CHECK( typeInfo );
2339 DALI_TEST_CHECK( 0 != typeInfo.GetActionCount() );
2341 std::string name = typeInfo.GetActionName(0);
2343 DALI_TEST_EQUALS( name, "show", TEST_LOCATION );
2346 TypeInfo typeInfo2 = typeRegistry.GetTypeInfo( "MyTestCustomActor" );
2348 // search for show action in base class, given a derived class
2349 bool foundChildAction = false;
2350 for( std::size_t i = 0; i < typeInfo2.GetActionCount(); i++ )
2353 std::string name = typeInfo2.GetActionName( i );
2356 foundChildAction = true;
2361 DALI_TEST_EQUALS( foundChildAction, true, TEST_LOCATION );
2367 int UtcDaliTypeInfoGetActionNameN(void)
2369 TestApplication application;
2370 TypeRegistry typeRegistry = TypeRegistry::Get();
2372 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2373 DALI_TEST_CHECK( typeInfo );
2375 DALI_TEST_CHECK( 0 != typeInfo.GetActionCount() );
2377 std::string name = typeInfo.GetActionName(std::numeric_limits<size_t>::max());
2379 DALI_TEST_EQUALS( 0u, name.size(), TEST_LOCATION );
2384 int UtcDaliTypeInfoGetSignalNameP(void)
2386 TestApplication application;
2387 TypeRegistry typeRegistry = TypeRegistry::Get();
2389 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2390 DALI_TEST_CHECK( typeInfo );
2392 DALI_TEST_CHECK( 0 != typeInfo.GetSignalCount() );
2394 std::string name = typeInfo.GetSignalName(0);
2396 DALI_TEST_EQUALS( name, "touched", TEST_LOCATION );
2398 TypeInfo typeInfo2 = typeRegistry.GetTypeInfo( "MyTestCustomActor" );
2400 // search for signal in base class, given a derived class
2401 bool foundSignal = false;
2402 for( std::size_t i = 0; i < typeInfo2.GetSignalCount(); i++ )
2405 std::string name = typeInfo2.GetSignalName( i );
2406 if( name == "touched")
2413 DALI_TEST_EQUALS( foundSignal, true, TEST_LOCATION );
2418 int UtcDaliTypeInfoGetSignalNameN(void)
2420 TestApplication application;
2421 TypeRegistry typeRegistry = TypeRegistry::Get();
2423 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2424 DALI_TEST_CHECK( typeInfo );
2426 DALI_TEST_CHECK( 0 != typeInfo.GetSignalCount() );
2428 std::string name = typeInfo.GetSignalName(std::numeric_limits<size_t>::max());
2430 DALI_TEST_EQUALS( 0u, name.size(), TEST_LOCATION );
2436 int UtcDaliTypeInfoGetCreatorP(void)
2438 TestApplication application;
2439 TypeRegistry typeRegistry = TypeRegistry::Get();
2441 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2442 DALI_TEST_CHECK( typeInfo );
2444 TypeInfo::CreateFunction createFn = typeInfo.GetCreator();
2445 DALI_TEST_EQUALS( createFn != NULL, true, TEST_LOCATION );
2449 BaseHandle handle = createFn();
2450 DALI_TEST_EQUALS( (bool)handle, true, TEST_LOCATION );
2456 int UtcDaliTypeInfoGetCreatorN(void)
2458 TestApplication application;
2459 TypeRegistry typeRegistry = TypeRegistry::Get();
2461 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "MyTestCustomActor3" );
2462 DALI_TEST_CHECK( typeInfo );
2464 TypeInfo::CreateFunction createFn = typeInfo.GetCreator();
2465 DALI_TEST_EQUALS( createFn == NULL, true, TEST_LOCATION );
2470 int UtcDaliTypeInfoGetPropertyCountP1(void)
2472 TestApplication application;
2473 TypeRegistry typeRegistry = TypeRegistry::Get();
2475 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2476 DALI_TEST_CHECK( typeInfo );
2477 size_t actorPropertyCount = typeInfo.GetPropertyCount();
2479 DALI_TEST_EQUALS( actorPropertyCount, Actor::New().GetPropertyCount(), TEST_LOCATION ); // No event only props
2483 int UtcDaliTypeInfoGetPropertyCountP2(void)
2485 TestApplication application;
2486 TypeRegistry typeRegistry = TypeRegistry::Get();
2488 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "MyTestCustomActor2" );
2489 DALI_TEST_CHECK( typeInfo );
2490 size_t propertyCount = typeInfo.GetPropertyCount();
2491 Property::IndexContainer indices;
2492 typeInfo.GetPropertyIndices( indices );
2494 DALI_TEST_EQUALS( propertyCount > 0 && propertyCount <= indices.Size(), true, TEST_LOCATION );
2495 DALI_TEST_EQUALS( propertyCount, Actor::New().GetPropertyCount() + 2, TEST_LOCATION );
2500 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGet01(void)
2502 TestApplication application;
2503 TypeRegistry typeRegistry = TypeRegistry::Get();
2505 tet_infoline( "Register a type registered animatable property and ensure set/get behaviour works synchronously" );
2507 // Register animatable property
2508 const int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
2509 AnimatablePropertyRegistration animatableProperty( customType1, "animatableProp1", animatablePropertyIndex, Property::FLOAT );
2511 // Check property count before property registration
2512 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2513 DALI_TEST_CHECK( typeInfo );
2514 BaseHandle handle = typeInfo.CreateInstance();
2515 DALI_TEST_CHECK( handle );
2516 Actor customActor = Actor::DownCast( handle );
2517 DALI_TEST_CHECK( customActor );
2518 application.GetScene().Add(customActor);
2520 tet_infoline( "Set the value and ensure it changes straight away" );
2521 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 0.0f, TEST_LOCATION );
2522 customActor.SetProperty( animatablePropertyIndex, 25.0f );
2523 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 25.0f, TEST_LOCATION );
2525 tet_infoline( "Check latest scene-graph value is unchanged" );
2526 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 0.0f, TEST_LOCATION );
2528 // Render and notify
2529 application.SendNotification();
2530 application.Render();
2532 tet_infoline( "Check values after rendering and both retrieval methods should return the latest" );
2534 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 25.0f, TEST_LOCATION );
2535 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 25.0f, TEST_LOCATION );
2540 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGetWithComponentsVector2(void)
2542 TestApplication application;
2543 TypeRegistry typeRegistry = TypeRegistry::Get();
2545 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" );
2547 // Register the animatable propeties
2548 const int basePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
2549 const int componentZeroPropertyIndex( basePropertyIndex + 1 );
2550 const int componentOnePropertyIndex( componentZeroPropertyIndex + 1 );
2551 AnimatablePropertyRegistration baseAnimatableProperty( customType1, "baseProp", basePropertyIndex, Vector2( 13.0f, 24.0f ) );
2552 AnimatablePropertyComponentRegistration componentZeroAnimatableProperty( customType1, "componentZeroProp", componentZeroPropertyIndex, basePropertyIndex, 0 );
2553 AnimatablePropertyComponentRegistration componentOneAnimatableProperty( customType1, "componentOneProp", componentOnePropertyIndex, basePropertyIndex, 1 );
2555 // Check property count before property registration
2556 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2557 DALI_TEST_CHECK( typeInfo );
2558 BaseHandle handle = typeInfo.CreateInstance();
2559 DALI_TEST_CHECK( handle );
2560 Actor customActor = Actor::DownCast( handle );
2561 DALI_TEST_CHECK( customActor );
2562 application.GetScene().Add(customActor);
2564 tet_infoline( "Get the component values, they should be the default value of the base-property" );
2565 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2566 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2567 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 13.0f, 24.0f ), TEST_LOCATION );
2569 tet_infoline( "Set a component value and ensure it changes for the base property as well" );
2570 customActor.SetProperty( componentZeroPropertyIndex, 125.0f );
2571 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2572 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 125.0f, 24.0f ), TEST_LOCATION );
2574 customActor.SetProperty( componentOnePropertyIndex, 225.0f );
2575 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2576 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 125.0f, 225.0f ), TEST_LOCATION );
2578 tet_infoline( "Check latest scene-graph value is unchanged" );
2579 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector2 >( basePropertyIndex ), Vector2( 13.0f, 24.0f ), TEST_LOCATION );
2580 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2581 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2583 // Render and notify
2584 application.SendNotification();
2585 application.Render();
2587 tet_infoline( "Check values after rendering and both retrieval methods should return the latest" );
2588 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 125.0f, 225.0f ), TEST_LOCATION );
2589 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2590 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2592 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector2 >( basePropertyIndex ), Vector2( 125.0f, 225.0f ), TEST_LOCATION );
2593 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2594 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2596 tet_infoline( "Set the base property value and ensure the component values reflect the change" );
2597 customActor.SetProperty( basePropertyIndex, Vector2( 1.0f, 2.0f ) );
2598 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 1.0f, TEST_LOCATION );
2599 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 2.0f, TEST_LOCATION );
2600 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 1.0f, 2.0f ), TEST_LOCATION );
2605 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGetWithComponentsVector3(void)
2607 TestApplication application;
2608 TypeRegistry typeRegistry = TypeRegistry::Get();
2610 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" );
2612 // Register the animatable propeties
2613 const int basePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
2614 const int componentZeroPropertyIndex( basePropertyIndex + 1 );
2615 const int componentOnePropertyIndex( componentZeroPropertyIndex + 1 );
2616 const int componentTwoPropertyIndex( componentOnePropertyIndex + 1 );
2617 AnimatablePropertyRegistration baseAnimatableProperty( customType1, "baseProp", basePropertyIndex, Vector3( 13.0f, 24.0f, 35.0 ) );
2618 AnimatablePropertyComponentRegistration componentZeroAnimatableProperty( customType1, "componentZeroProp", componentZeroPropertyIndex, basePropertyIndex, 0 );
2619 AnimatablePropertyComponentRegistration componentOneAnimatableProperty( customType1, "componentOneProp", componentOnePropertyIndex, basePropertyIndex, 1 );
2620 AnimatablePropertyComponentRegistration componentTwoAnimatableProperty( customType1, "componentTwoProp", componentTwoPropertyIndex, basePropertyIndex, 2 );
2622 // Check property count before property registration
2623 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2624 DALI_TEST_CHECK( typeInfo );
2625 BaseHandle handle = typeInfo.CreateInstance();
2626 DALI_TEST_CHECK( handle );
2627 Actor customActor = Actor::DownCast( handle );
2628 DALI_TEST_CHECK( customActor );
2629 application.GetScene().Add(customActor);
2631 tet_infoline( "Get the component values, they should be the default value of the base-property" );
2632 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2633 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2634 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 35.0f, TEST_LOCATION );
2635 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 13.0f, 24.0f, 35.0f ), TEST_LOCATION );
2637 tet_infoline( "Set a component value and ensure it changes for the base property as well" );
2638 customActor.SetProperty( componentZeroPropertyIndex, 125.0f );
2639 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2640 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 24.0f, 35.0f ), TEST_LOCATION );
2642 customActor.SetProperty( componentOnePropertyIndex, 225.0f );
2643 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2644 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 225.0f, 35.0f ), TEST_LOCATION );
2646 customActor.SetProperty( componentTwoPropertyIndex, 325.0f );
2647 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2648 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 225.0f, 325.0f ), TEST_LOCATION );
2650 tet_infoline( "Check latest scene-graph value is unchanged" );
2651 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector3 >( basePropertyIndex ), Vector3( 13.0f, 24.0f, 35.0f ), TEST_LOCATION );
2652 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2653 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2654 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentTwoPropertyIndex ), 35.0f, TEST_LOCATION );
2656 // Render and notify
2657 application.SendNotification();
2658 application.Render();
2660 tet_infoline( "Check values after rendering and both retrieval methods should return the latest" );
2661 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 225.0f, 325.0f ), TEST_LOCATION );
2662 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2663 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2664 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2666 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 225.0f, 325.0f ), TEST_LOCATION );
2667 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2668 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2669 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2671 tet_infoline( "Set the base property value and ensure the component values reflect the change" );
2672 customActor.SetProperty( basePropertyIndex, Vector3( 1.0f, 2.0f, 3.0f ) );
2673 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 1.0f, TEST_LOCATION );
2674 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 2.0f, TEST_LOCATION );
2675 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 3.0f, TEST_LOCATION );
2676 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 1.0f, 2.0f, 3.0f ), TEST_LOCATION );
2681 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGetWithComponentsVector4(void)
2683 TestApplication application;
2684 TypeRegistry typeRegistry = TypeRegistry::Get();
2686 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" );
2688 // Register the animatable propeties
2689 const int basePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
2690 const int componentZeroPropertyIndex( basePropertyIndex + 1 );
2691 const int componentOnePropertyIndex( componentZeroPropertyIndex + 1 );
2692 const int componentTwoPropertyIndex( componentOnePropertyIndex + 1 );
2693 const int componentThreePropertyIndex( componentTwoPropertyIndex + 1 );
2694 AnimatablePropertyRegistration baseAnimatableProperty( customType1, "baseProp", basePropertyIndex, Vector4( 13.0f, 24.0f, 35.0, 47.0f ) );
2695 AnimatablePropertyComponentRegistration componentZeroAnimatableProperty( customType1, "componentZeroProp", componentZeroPropertyIndex, basePropertyIndex, 0 );
2696 AnimatablePropertyComponentRegistration componentOneAnimatableProperty( customType1, "componentOneProp", componentOnePropertyIndex, basePropertyIndex, 1 );
2697 AnimatablePropertyComponentRegistration componentTwoAnimatableProperty( customType1, "componentTwoProp", componentTwoPropertyIndex, basePropertyIndex, 2 );
2698 AnimatablePropertyComponentRegistration componentThreeAnimatableProperty( customType1, "componentThreeProp", componentThreePropertyIndex, basePropertyIndex, 3 );
2700 // Check property count before property registration
2701 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2702 DALI_TEST_CHECK( typeInfo );
2703 BaseHandle handle = typeInfo.CreateInstance();
2704 DALI_TEST_CHECK( handle );
2705 Actor customActor = Actor::DownCast( handle );
2706 DALI_TEST_CHECK( customActor );
2707 application.GetScene().Add(customActor);
2709 tet_infoline( "Get the component values, they should be the default value of the base-property" );
2710 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2711 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2712 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 35.0f, TEST_LOCATION );
2713 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentThreePropertyIndex ), 47.0f, TEST_LOCATION );
2714 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 13.0f, 24.0f, 35.0f, 47.0f ), TEST_LOCATION );
2716 tet_infoline( "Set a component value and ensure it changes for the base property as well" );
2717 customActor.SetProperty( componentZeroPropertyIndex, 125.0f );
2718 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2719 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 24.0f, 35.0f, 47.0f ), TEST_LOCATION );
2721 customActor.SetProperty( componentOnePropertyIndex, 225.0f );
2722 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2723 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 35.0f, 47.0f ), TEST_LOCATION );
2725 customActor.SetProperty( componentTwoPropertyIndex, 325.0f );
2726 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2727 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 325.0f, 47.0f ), TEST_LOCATION );
2729 customActor.SetProperty( componentThreePropertyIndex, 435.0f );
2730 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentThreePropertyIndex ), 435.0f, TEST_LOCATION );
2731 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 325.0f, 435.0f ), TEST_LOCATION );
2733 tet_infoline( "Check latest scene-graph value is unchanged" );
2734 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector4 >( basePropertyIndex ), Vector4( 13.0f, 24.0f, 35.0f, 47.0f ), TEST_LOCATION );
2735 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2736 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2737 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentTwoPropertyIndex ), 35.0f, TEST_LOCATION );
2738 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentThreePropertyIndex ), 47.0f, TEST_LOCATION );
2740 // Render and notify
2741 application.SendNotification();
2742 application.Render();
2744 tet_infoline( "Check values after rendering and both retrieval methods should return the latest" );
2745 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 325.0f, 435.0f ), TEST_LOCATION );
2746 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2747 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2748 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2749 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentThreePropertyIndex ), 435.0f, TEST_LOCATION );
2751 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 325.0f, 435.0f ), TEST_LOCATION );
2752 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2753 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2754 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2755 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentThreePropertyIndex ), 435.0f, TEST_LOCATION );
2757 tet_infoline( "Set the base property value and ensure the component values reflect the change" );
2758 customActor.SetProperty( basePropertyIndex, Vector4( 1.0f, 2.0f, 3.0f, 4.0f ) );
2759 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 1.0f, TEST_LOCATION );
2760 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 2.0f, TEST_LOCATION );
2761 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 3.0f, TEST_LOCATION );
2762 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentThreePropertyIndex ), 4.0f, TEST_LOCATION );
2763 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 1.0f, 2.0f, 3.0f, 4.0f ), TEST_LOCATION );
2769 int UtcDaliTypeInfoRegisterChildProperties01(void)
2771 TestApplication application;
2772 TypeRegistry typeRegistry = TypeRegistry::Get();
2774 tet_infoline( "Register child properties on a type via name" );
2776 auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(CustomActor) );
2777 auto myCustomTypeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2778 DALI_TEST_CHECK( customActorTypeInfo );
2779 DALI_TEST_CHECK( myCustomTypeInfo );
2781 const Property::Index WIDTH_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX );
2782 const Property::Index HEIGHT_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1);
2783 const Property::Index MARGIN_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 100);
2785 ChildPropertyRegistration( customActorTypeInfo.GetName(), "widthSpecification", WIDTH_SPECIFICATION, Property::INTEGER );
2786 ChildPropertyRegistration( customActorTypeInfo.GetName(), "heightSpecification", HEIGHT_SPECIFICATION, Property::INTEGER );
2787 ChildPropertyRegistration( myCustomTypeInfo.GetName(), "marginSpecification", MARGIN_SPECIFICATION, Property::EXTENTS );
2789 auto customActor = MyTestCustomActor::New();
2790 application.GetScene().Add( customActor );
2791 auto child = Actor::New();
2792 customActor.Add( child );
2794 child.SetProperty( WIDTH_SPECIFICATION, 33 );
2796 auto value = child.GetProperty( WIDTH_SPECIFICATION );
2797 DALI_TEST_EQUALS( value, Property::Value(33), TEST_LOCATION );
2799 child.SetProperty( HEIGHT_SPECIFICATION, 44 );
2800 value = child.GetProperty( HEIGHT_SPECIFICATION );
2801 DALI_TEST_EQUALS( value, Property::Value(44), TEST_LOCATION );
2803 child.SetProperty( MARGIN_SPECIFICATION, Extents(10, 10, 10, 10) );
2804 value = child.GetProperty( MARGIN_SPECIFICATION );
2805 DALI_TEST_EQUALS( value, Property::Value(Extents(10,10,10,10)), TEST_LOCATION );
2811 int UtcDaliTypeInfoRegisterChildProperties02(void)
2813 TestApplication application;
2814 TypeRegistry typeRegistry = TypeRegistry::Get();
2816 tet_infoline( "Register child properties on a type via name" );
2818 auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(CustomActor) );
2819 auto myCustomTypeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2820 DALI_TEST_CHECK( customActorTypeInfo );
2821 DALI_TEST_CHECK( myCustomTypeInfo );
2823 const Property::Index WIDTH_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX );
2824 const Property::Index HEIGHT_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1);
2825 const Property::Index MARGIN_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 100);
2827 ChildPropertyRegistration( customActorTypeInfo.GetName(), "widthSpecification", WIDTH_SPECIFICATION, Property::INTEGER );
2828 ChildPropertyRegistration( customActorTypeInfo.GetName(), "heightSpecification", HEIGHT_SPECIFICATION, Property::INTEGER );
2829 ChildPropertyRegistration( myCustomTypeInfo.GetName(), "marginSpecification", MARGIN_SPECIFICATION, Property::EXTENTS );
2832 auto index = customActorTypeInfo.GetChildPropertyIndex( "widthSpecification" );
2833 DALI_TEST_EQUALS( index, WIDTH_SPECIFICATION, TEST_LOCATION );
2835 index = customActorTypeInfo.GetChildPropertyIndex( "heightSpecification" );
2836 DALI_TEST_EQUALS( index, HEIGHT_SPECIFICATION, TEST_LOCATION );
2838 index = customActorTypeInfo.GetChildPropertyIndex( "marginSpecification" );
2839 DALI_TEST_EQUALS( index, Property::INVALID_INDEX, TEST_LOCATION );
2841 index = myCustomTypeInfo.GetChildPropertyIndex( "marginSpecification" );
2842 DALI_TEST_EQUALS( index, MARGIN_SPECIFICATION, TEST_LOCATION );
2845 auto name = customActorTypeInfo.GetChildPropertyName( WIDTH_SPECIFICATION );
2846 DALI_TEST_EQUALS( name, "widthSpecification", TEST_LOCATION );
2848 name = customActorTypeInfo.GetChildPropertyName( HEIGHT_SPECIFICATION );
2849 DALI_TEST_EQUALS( name, "heightSpecification", TEST_LOCATION );
2851 name = myCustomTypeInfo.GetChildPropertyName( MARGIN_SPECIFICATION );
2852 DALI_TEST_EQUALS( name, "marginSpecification", TEST_LOCATION );
2855 auto type = customActorTypeInfo.GetChildPropertyType( WIDTH_SPECIFICATION );
2856 DALI_TEST_EQUALS( type, Property::INTEGER, TEST_LOCATION );
2858 type = customActorTypeInfo.GetChildPropertyType( HEIGHT_SPECIFICATION );
2859 DALI_TEST_EQUALS( type, Property::INTEGER, TEST_LOCATION );
2861 type = myCustomTypeInfo.GetChildPropertyType( MARGIN_SPECIFICATION );
2862 DALI_TEST_EQUALS( type, Property::EXTENTS, TEST_LOCATION );
2869 int UtcDaliTypeInfoRegisterChildProperties03(void)
2871 TestApplication application;
2872 TypeRegistry typeRegistry = TypeRegistry::Get();
2874 tet_infoline( "Check registered child properties can be retrieved" );
2876 auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(CustomActor) );
2877 auto myCustomTypeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2878 DALI_TEST_CHECK( customActorTypeInfo );
2879 DALI_TEST_CHECK( myCustomTypeInfo );
2881 const Property::Index WIDTH_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX );
2882 const Property::Index HEIGHT_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1);
2883 const Property::Index MARGIN_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 100);
2885 ChildPropertyRegistration( customActorTypeInfo.GetName(), "widthSpecification", WIDTH_SPECIFICATION, Property::INTEGER );
2886 ChildPropertyRegistration( customActorTypeInfo.GetName(), "heightSpecification", HEIGHT_SPECIFICATION, Property::INTEGER );
2887 ChildPropertyRegistration( myCustomTypeInfo.GetName(), "marginSpecification", MARGIN_SPECIFICATION, Property::EXTENTS );
2889 Property::IndexContainer indices;
2890 myCustomTypeInfo.GetChildPropertyIndices( indices );
2892 auto result = std::find( indices.Begin(), indices.End(), WIDTH_SPECIFICATION );
2893 DALI_TEST_EQUALS( result != indices.End(), true, TEST_LOCATION );
2895 result = std::find( indices.Begin(), indices.End(), HEIGHT_SPECIFICATION );
2896 DALI_TEST_EQUALS( result != indices.End(), true, TEST_LOCATION );
2898 result = std::find( indices.Begin(), indices.End(), MARGIN_SPECIFICATION );
2899 DALI_TEST_EQUALS( result != indices.End(), true, TEST_LOCATION );