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>
33 // Stores data that is populated in the callback and will be read by the Test cases
37 : functorCalled( false ),
38 voidFunctorCalled( false ),
45 functorCalled = false;
46 voidFunctorCalled = false;
48 receivedGesture.Reset();
54 bool voidFunctorCalled;
55 LongPressGesture receivedGesture;
59 // Functor that sets the data when called
60 struct GestureReceivedFunctor
62 GestureReceivedFunctor(SignalData& data) : signalData(data) { }
64 void operator()(Actor actor, LongPressGesture longPress)
66 signalData.functorCalled = true;
67 signalData.receivedGesture = longPress;
68 signalData.pressedActor = actor;
73 signalData.voidFunctorCalled = true;
76 SignalData& signalData;
80 // Create function as Init function called
82 static bool CreateCustomInitCalled = false;
83 BaseHandle CreateCustomInit(void)
85 CreateCustomInitCalled = true;
89 static bool CreateCustomNamedInitCalled = false;
90 BaseHandle CreateCustomNamedInit(void)
92 CreateCustomNamedInitCalled = true;
96 const std::string scriptedName("PopupStyle");
97 static TypeRegistration scriptedType( scriptedName, typeid(Dali::CustomActor), CreateCustomNamedInit );
99 // Property Registration
100 bool setPropertyCalled = false;
101 bool getPropertyCalled = false;
102 void SetProperty( BaseObject* object, Property::Index propertyIndex, const Property::Value& value )
104 setPropertyCalled = true;
106 Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex )
108 getPropertyCalled = true;
109 return Property::Value( true );
114 /*******************************************************************************
118 ******************************************************************************/
121 struct MyTestCustomActor : public CustomActorImpl
123 typedef Signal< void ()> SignalType;
124 typedef Signal< void (float)> SignalTypeFloat;
126 MyTestCustomActor() : CustomActorImpl( ActorFlags( REQUIRES_TOUCH_EVENTS ) )
129 virtual ~MyTestCustomActor()
132 void ResetCallStack()
136 // From CustomActorImpl
137 virtual void OnSceneConnection( int depth )
140 virtual void OnSceneDisconnection()
143 virtual void OnChildAdd(Actor& child)
146 virtual void OnChildRemove(Actor& child)
149 virtual void OnSizeSet(const Vector3& targetSize)
152 virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize)
155 virtual bool OnHoverEvent(const HoverEvent& event)
159 virtual bool OnWheelEvent(const WheelEvent& event)
163 virtual bool OnKeyEvent(const KeyEvent& event)
167 virtual void OnKeyInputFocusGained()
170 virtual void OnKeyInputFocusLost()
173 virtual Vector3 GetNaturalSize()
175 return Vector3( 0.0f, 0.0f, 0.0f );
178 virtual float GetHeightForWidth( float width )
183 virtual float GetWidthForHeight( float height )
188 virtual void OnRelayout( const Vector2& size, RelayoutContainer& container )
192 virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
196 virtual void OnCalculateRelayoutSize( Dimension::Type dimension )
200 virtual float CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension )
205 virtual void OnLayoutNegotiated( float size, Dimension::Type dimension )
209 virtual bool RelayoutDependentOnChildren( Dimension::Type dimension = Dimension::ALL_DIMENSIONS )
221 class MyTestCustomActor : public CustomActor
225 typedef Signal< void ()> SignalType;
226 typedef Signal< void (float)> SignalTypeFloat;
232 static MyTestCustomActor New()
234 Impl::MyTestCustomActor* p = new Impl::MyTestCustomActor;
235 return MyTestCustomActor( *p ); // takes ownership
238 virtual ~MyTestCustomActor()
242 static MyTestCustomActor DownCast( BaseHandle handle )
244 MyTestCustomActor result;
246 CustomActor custom = Dali::CustomActor::DownCast( handle );
249 CustomActorImpl& customImpl = custom.GetImplementation();
251 Impl::MyTestCustomActor* impl = dynamic_cast<Impl::MyTestCustomActor*>(&customImpl);
255 result = MyTestCustomActor(customImpl.GetOwner());
262 SignalType& GetCustomSignal()
264 Dali::RefObject& obj = GetImplementation();
265 return static_cast<Impl::MyTestCustomActor&>( obj ).mSignal;
270 MyTestCustomActor(Internal::CustomActor* internal)
271 : CustomActor(internal)
275 MyTestCustomActor( Impl::MyTestCustomActor& impl )
276 : CustomActor( impl )
282 class MyTestCustomActor2 : public CustomActor
290 P1=Dali::PROPERTY_REGISTRATION_START_INDEX,
300 static MyTestCustomActor2 New()
302 return MyTestCustomActor2(); // takes ownership
305 virtual ~MyTestCustomActor2()
309 static MyTestCustomActor2 DownCast( BaseHandle handle )
311 MyTestCustomActor2 result;
313 CustomActor custom = Dali::CustomActor::DownCast( handle );
316 CustomActorImpl& customImpl = custom.GetImplementation();
318 Impl::MyTestCustomActor* impl = dynamic_cast<Impl::MyTestCustomActor*>(&customImpl);
322 result = MyTestCustomActor2(customImpl.GetOwner());
331 MyTestCustomActor2(Internal::CustomActor* internal)
332 : CustomActor(internal)
336 MyTestCustomActor2( Impl::MyTestCustomActor& impl )
337 : CustomActor( impl )
342 static TypeRegistration customTypeInit( typeid(MyTestCustomActor2), typeid(Dali::CustomActor), CreateCustomInit, true );
344 PropertyRegistration P1( customTypeInit, "propertyOne", MyTestCustomActor2::Property::P1, Property::INTEGER, &SetProperty, &GetProperty );
345 PropertyRegistration P2( customTypeInit, "propertyTwo", MyTestCustomActor2::Property::P2, Property::STRING, &SetProperty, &GetProperty );
348 class MyTestCustomActor3 : public CustomActor
355 static MyTestCustomActor3 New()
357 return MyTestCustomActor3(); // takes ownership
360 virtual ~MyTestCustomActor3()
364 static MyTestCustomActor3 DownCast( BaseHandle handle )
366 MyTestCustomActor3 result;
368 CustomActor custom = Dali::CustomActor::DownCast( handle );
371 CustomActorImpl& customImpl = custom.GetImplementation();
373 Impl::MyTestCustomActor* impl = dynamic_cast<Impl::MyTestCustomActor*>(&customImpl);
377 result = MyTestCustomActor3(customImpl.GetOwner());
386 MyTestCustomActor3(Internal::CustomActor* internal)
387 : CustomActor(internal)
391 MyTestCustomActor3( Impl::MyTestCustomActor& impl )
392 : CustomActor( impl )
397 static TypeRegistration customTypeBadInit( typeid(MyTestCustomActor3), typeid(Dali::CustomActor), NULL, false );
399 BaseHandle CreateCustom(void)
401 return MyTestCustomActor::New();
404 static std::string lastSignalConnectionCustom;
406 bool DoConnectSignalCustom( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
408 lastSignalConnectionCustom = signalName;
410 bool connected( true );
412 Dali::BaseHandle handle(object);
413 MyTestCustomActor customActor = MyTestCustomActor::DownCast(handle);
415 if( "sig1" == signalName )
417 customActor.GetCustomSignal().Connect( tracker, functor );
421 // signalName does not match any signal
428 bool DoConnectSignalCustomFailure( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
430 lastSignalConnectionCustom = "failed";
432 return false; // This is supposed to fail
435 struct CustomTestFunctor
439 ++mTotalInstanceCount;
440 ++mCurrentInstanceCount;
443 CustomTestFunctor( const CustomTestFunctor& copyMe )
445 ++mTotalInstanceCount;
446 ++mCurrentInstanceCount;
451 --mCurrentInstanceCount;
459 static int mTotalInstanceCount;
460 static int mCurrentInstanceCount;
461 static int mCallbackCount;
464 int CustomTestFunctor::mTotalInstanceCount = 0;
465 int CustomTestFunctor::mCurrentInstanceCount = 0;
466 int CustomTestFunctor::mCallbackCount = 0;
468 static void ResetFunctorCounts()
470 CustomTestFunctor::mTotalInstanceCount = 0;
471 CustomTestFunctor::mCurrentInstanceCount = 0;
472 CustomTestFunctor::mCallbackCount = 0;
475 static std::string lastActionCustom;
476 bool DoActionCustom(BaseObject* object, const std::string& actionName, const Property::Map& /*attributes*/)
478 lastActionCustom = actionName;
482 // Custom type registration
483 static TypeRegistration customType1( typeid(MyTestCustomActor), typeid(Dali::CustomActor), CreateCustom );
486 static SignalConnectorType customSignalConnector1( customType1, "sig1", DoConnectSignalCustom );
487 static SignalConnectorType customSignalConnector2( customType1, "sig2", DoConnectSignalCustomFailure );
488 static const int TEST_SIGNAL_COUNT = 2;
491 static TypeAction customAction1( customType1, "act1", DoActionCustom);
492 static const int TEST_ACTION_COUNT = 1;
494 class TestConnectionTracker : public ConnectionTracker
498 TestConnectionTracker()
503 BaseHandle CreateNamedActorType()
505 Actor actor = Actor::New();
506 actor.SetProperty( Actor::Property::NAME, "NamedActor" );
510 TypeRegistration namedActorType( "MyNamedActor", typeid(Dali::Actor), CreateNamedActorType );
511 PropertyRegistration namedActorPropertyOne( namedActorType, "propName", PROPERTY_REGISTRATION_START_INDEX, Property::BOOLEAN, &SetProperty, &GetProperty );
513 } // Anonymous namespace
515 // Note: No negative test case for UtcDaliTypeRegistryGet can be implemented.
516 int UtcDaliTypeRegistryGetP(void)
518 TestApplication application;
520 TypeRegistry registry = TypeRegistry::Get();
521 DALI_TEST_CHECK( registry );
526 // Note: No negative test case for UtcDaliTypeRegistryConstructor can be implemented.
527 int UtcDaliTypeRegistryConstructorP(void)
529 TestApplication application;
531 TypeRegistry registry;
532 DALI_TEST_CHECK( !registry );
536 // Note: No negative test case for UtcDaliTypeRegistryCopyConstructor can be implemented.
537 int UtcDaliTypeRegistryCopyConstructorP(void)
539 TestApplication application;
541 TypeRegistry registry = TypeRegistry::Get();
542 DALI_TEST_CHECK( registry );
544 TypeRegistry copy( registry );
545 DALI_TEST_CHECK( copy );
547 DALI_TEST_CHECK( registry.GetTypeInfo( "Actor" ).GetName() == copy.GetTypeInfo( "Actor" ).GetName() );
552 // Note: No negative test case for UtcDaliTypeRegistryAssignmentOperator can be implemented.
553 int UtcDaliTypeRegistryAssignmentOperatorP(void)
555 TestApplication application;
557 TypeRegistry registry = TypeRegistry::Get();
558 DALI_TEST_CHECK( registry );
560 TypeRegistry copy = registry;
561 DALI_TEST_CHECK( copy );
562 DALI_TEST_CHECK( registry == copy );
564 DALI_TEST_CHECK( registry.GetTypeInfo( "Actor" ).GetName() == copy.GetTypeInfo( "Actor" ).GetName() );
569 int UtcDaliTypeRegistryMoveConstructor(void)
571 TestApplication application;
573 TypeRegistry registry = TypeRegistry::Get();
574 DALI_TEST_CHECK( registry );
575 DALI_TEST_EQUALS( 16, registry.GetBaseObject().ReferenceCount(), TEST_LOCATION );
576 DALI_TEST_CHECK( registry.GetTypeInfo( "Actor" ).GetName() == "Actor" );
578 TypeRegistry movedRegistry = std::move( registry );
579 DALI_TEST_CHECK( movedRegistry );
580 DALI_TEST_EQUALS( 16, movedRegistry.GetBaseObject().ReferenceCount(), TEST_LOCATION );
581 DALI_TEST_CHECK( movedRegistry.GetTypeInfo( "Actor" ).GetName() == "Actor" );
582 DALI_TEST_CHECK( !registry );
584 Dali::TypeInfo info = movedRegistry.GetTypeInfo( "Actor" );
585 DALI_TEST_CHECK( info );
586 DALI_TEST_EQUALS( 2, info.GetBaseObject().ReferenceCount(), TEST_LOCATION );
587 DALI_TEST_CHECK( info.GetName() == "Actor" );
589 Dali::TypeInfo movedInfo = std::move( info );
590 DALI_TEST_CHECK( movedInfo );
591 DALI_TEST_EQUALS( 2, movedInfo.GetBaseObject().ReferenceCount(), TEST_LOCATION );
592 DALI_TEST_CHECK( movedInfo.GetName() == "Actor" );
593 DALI_TEST_CHECK( !info );
598 int UtcDaliTypeRegistryMoveAssignment(void)
600 TestApplication application;
602 TypeRegistry registry = TypeRegistry::Get();
603 DALI_TEST_CHECK( registry );
604 DALI_TEST_EQUALS( 16, registry.GetBaseObject().ReferenceCount(), TEST_LOCATION );
605 DALI_TEST_CHECK( registry.GetTypeInfo( "Actor" ).GetName() == "Actor" );
607 TypeRegistry movedRegistry;
608 movedRegistry = std::move( registry );
609 DALI_TEST_CHECK( movedRegistry );
610 DALI_TEST_EQUALS( 16, movedRegistry.GetBaseObject().ReferenceCount(), TEST_LOCATION );
611 DALI_TEST_CHECK( movedRegistry.GetTypeInfo( "Actor" ).GetName() == "Actor" );
612 DALI_TEST_CHECK( !registry );
614 Dali::TypeInfo info = movedRegistry.GetTypeInfo( "Actor" );
615 DALI_TEST_CHECK( info );
616 DALI_TEST_EQUALS( 2, info.GetBaseObject().ReferenceCount(), TEST_LOCATION );
617 DALI_TEST_CHECK( info.GetName() == "Actor" );
619 Dali::TypeInfo movedInfo;
620 movedInfo = std::move( info );
621 DALI_TEST_CHECK( movedInfo );
622 DALI_TEST_EQUALS( 2, movedInfo.GetBaseObject().ReferenceCount(), TEST_LOCATION );
623 DALI_TEST_CHECK( movedInfo.GetName() == "Actor" );
624 DALI_TEST_CHECK( !info );
629 int UtcDaliTypeRegistryAssignP(void)
631 TestApplication application;
633 TypeRegistry registry = TypeRegistry::Get();
634 TypeRegistry registry2;
635 registry2 = registry;
636 DALI_TEST_CHECK( registry2 );
638 DALI_TEST_CHECK( registry2.GetTypeInfo( "Actor" ).GetName() == registry2.GetTypeInfo( "Actor" ).GetName() );
643 int UtcDaliTypeRegistryGetTypeInfoFromTypeNameP(void)
645 TestApplication application;
647 TypeRegistry registry = TypeRegistry::Get();
652 type = registry.GetTypeInfo( "CameraActor" );
653 DALI_TEST_CHECK( type );
654 CameraActor ca = CameraActor::DownCast(type.CreateInstance());
655 DALI_TEST_CHECK( ca );
656 application.GetScene().Add( ca );
657 application.Render();
660 type = registry.GetTypeInfo( "Animation" );
661 DALI_TEST_CHECK( type );
662 Animation an = Animation::DownCast(type.CreateInstance());
663 DALI_TEST_CHECK( an );
665 application.Render();
670 int UtcDaliTypeRegistryGetTypeInfoFromTypeNameN(void)
672 TestApplication application;
674 TypeRegistry registry = TypeRegistry::Get();
678 type = registry.GetTypeInfo( "MyDummyActor" );
679 DALI_TEST_CHECK( !type );
684 int UtcDaliTypeRegistryGetTypeInfoFromTypeIdP(void)
686 TypeInfo named_type = TypeRegistry::Get().GetTypeInfo( "CameraActor" );
687 TypeInfo typeinfo_type = TypeRegistry::Get().GetTypeInfo( typeid(Dali::CameraActor) );
689 DALI_TEST_CHECK( named_type );
690 DALI_TEST_CHECK( typeinfo_type );
692 // Check named and typeid are equivalent
693 DALI_TEST_CHECK( named_type == typeinfo_type );
695 DALI_TEST_CHECK( named_type.GetName() == typeinfo_type.GetName() );
696 DALI_TEST_CHECK( named_type.GetBaseName() == typeinfo_type.GetBaseName() );
701 int UtcDaliTypeRegistryGetTypeInfoFromTypeIdN(void)
703 TestApplication application;
704 TypeRegistry typeRegistry = TypeRegistry::Get();
706 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(Vector2) );
707 DALI_TEST_CHECK( !typeInfo );
712 int UtcDaliTypeRegistryGetTypeNameCountP(void)
714 TestApplication application;
715 TypeRegistry typeRegistry = TypeRegistry::Get();
718 for(size_t i = 0; i < typeRegistry.GetTypeNameCount(); i++)
720 type = typeRegistry.GetTypeInfo( typeRegistry.GetTypeName(i) );
721 DALI_TEST_CHECK( type );
728 int UtcDaliTypeRegistryGetTypeNamesP(void)
730 TestApplication application;
731 TypeRegistry typeRegistry = TypeRegistry::Get();
734 for(size_t i = 0; i < typeRegistry.GetTypeNameCount(); i++)
736 type = typeRegistry.GetTypeInfo( typeRegistry.GetTypeName(i) );
737 DALI_TEST_CHECK( type );
744 // Note: No negative test case for UtcDaliTypeRegistryTypeRegistration can be implemented.
745 int UtcDaliTypeRegistryTypeRegistrationNotCallingCreateOnInitP(void)
747 ResetFunctorCounts();
749 TestApplication application;
751 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
752 DALI_TEST_CHECK( type );
754 TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( "CustomActor" );
755 DALI_TEST_CHECK( baseType );
757 BaseHandle handle = type.CreateInstance();
758 DALI_TEST_CHECK( handle );
760 MyTestCustomActor customHandle = MyTestCustomActor::DownCast( handle );
761 DALI_TEST_CHECK( customHandle );
763 DALI_TEST_EQUALS( type.GetActionCount(), TEST_ACTION_COUNT + baseType.GetActionCount(), TEST_LOCATION );
765 DALI_TEST_EQUALS( type.GetSignalCount(), TEST_SIGNAL_COUNT + baseType.GetSignalCount(), TEST_LOCATION );
768 TestConnectionTracker tracker;
770 bool connected = handle.ConnectSignal( &tracker, "sig1", CustomTestFunctor() );
771 DALI_TEST_EQUALS( connected, true, TEST_LOCATION );
772 DALI_TEST_CHECK( lastSignalConnectionCustom == "sig1" );
773 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
774 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION );
776 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
777 customHandle.GetCustomSignal().Emit();
778 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION );
779 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
780 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION );
782 // tracker should automatically disconnect here
783 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
784 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
786 // Test that functor is disconnected
787 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION );
788 customHandle.GetCustomSignal().Emit();
789 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1/*not incremented*/, TEST_LOCATION );
790 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
791 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
793 Property::Map attributes;
794 handle.DoAction("act1", attributes);
795 DALI_TEST_CHECK( lastActionCustom == "act1" );
799 // Note: No negative test case for UtcDaliTypeRegistryTypeRegistration can be implemented.
800 int UtcDaliTypeRegistryTypeRegistrationCallingCreateOnInitP(void)
802 TestApplication application;
804 DALI_TEST_CHECK( "MyTestCustomActor2" == customTypeInit.RegisteredName() );
806 DALI_TEST_CHECK( true == CreateCustomInitCalled );
807 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor2" );
808 DALI_TEST_CHECK( type );
812 // Note: No negative test case for UtcDaliTypeRegistryTypeRegistration can be implemented.
813 int UtcDaliTypeRegistryTypeRegistrationForNamedTypeP(void)
815 TestApplication application;
817 // Create Named Actor Type
818 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyNamedActor" );
819 DALI_TEST_CHECK( type );
821 BaseHandle namedHandle = type.CreateInstance();
822 DALI_TEST_CHECK( namedHandle );
823 Actor namedActor( Actor::DownCast( namedHandle ) );
824 DALI_TEST_CHECK( namedActor );
826 DALI_TEST_CHECK( namedActor.GetProperty< std::string >( Actor::Property::NAME ) == "NamedActor" );
827 DALI_TEST_CHECK( type.GetName() == "MyNamedActor" );
828 DALI_TEST_CHECK( type.GetBaseName() == "Actor" );
833 int UtcDaliTypeRegistryRegisteredNameP(void)
835 TestApplication application;
837 DALI_TEST_CHECK( scriptedName == scriptedType.RegisteredName() );
839 TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( scriptedName );
840 DALI_TEST_CHECK( baseType );
842 BaseHandle handle = baseType.CreateInstance();
844 DALI_TEST_CHECK( true == CreateCustomNamedInitCalled );
845 TypeInfo type = TypeRegistry::Get().GetTypeInfo( scriptedName );
846 DALI_TEST_CHECK( type );
851 int UtcDaliTypeRegistryRegisteredNameN(void)
853 TestApplication application;
855 DALI_TEST_CHECK( scriptedName == scriptedType.RegisteredName() );
857 TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( scriptedName );
858 DALI_TEST_CHECK( baseType );
860 // should cause an assert because we're registering same type twice
861 // once statically at the start of this file, then again now
864 TypeRegistration scriptedType( scriptedName, typeid(Dali::CustomActor), CreateCustomNamedInit );
865 tet_result( TET_FAIL );
867 catch ( DaliException& e )
869 DALI_TEST_ASSERT( e, "Duplicate type name in Type Registration", TEST_LOCATION );
876 int UtcDaliTypeRegistrySignalConnectorTypeP(void)
878 ResetFunctorCounts();
880 TestApplication application;
882 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
883 DALI_TEST_CHECK( type );
885 BaseHandle handle = type.CreateInstance();
886 DALI_TEST_CHECK( handle );
888 MyTestCustomActor customHandle = MyTestCustomActor::DownCast( handle );
889 DALI_TEST_CHECK( customHandle );
892 TestConnectionTracker tracker;
894 bool connected = handle.ConnectSignal( &tracker, "sig1", CustomTestFunctor() );
895 DALI_TEST_EQUALS( connected, true, TEST_LOCATION );
896 DALI_TEST_CHECK( lastSignalConnectionCustom == "sig1" );
897 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
898 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION );
900 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
901 customHandle.GetCustomSignal().Emit();
902 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION );
903 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
904 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION );
906 // tracker should automatically disconnect here
907 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
908 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
910 // Test that functor is disconnected
911 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION );
912 customHandle.GetCustomSignal().Emit();
913 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1/*not incremented*/, TEST_LOCATION );
914 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
915 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
920 int UtcDaliTypeRegistrySignalConnectorTypeN(void)
922 // Test what happens when signal connnector (DoConnectSignalFailure method) returns false
924 ResetFunctorCounts();
926 TestApplication application;
928 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
929 DALI_TEST_CHECK( type );
931 TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( "CustomActor" );
932 DALI_TEST_CHECK( baseType );
934 BaseHandle handle = type.CreateInstance();
935 DALI_TEST_CHECK( handle );
937 MyTestCustomActor customHandle = MyTestCustomActor::DownCast( handle );
938 DALI_TEST_CHECK( customHandle );
940 DALI_TEST_EQUALS( type.GetActionCount(), TEST_ACTION_COUNT + baseType.GetActionCount(), TEST_LOCATION );
942 DALI_TEST_EQUALS( type.GetSignalCount(), TEST_SIGNAL_COUNT + baseType.GetSignalCount(), TEST_LOCATION );
945 TestConnectionTracker tracker;
947 bool connected = handle.ConnectSignal( &tracker, "sig2", CustomTestFunctor() );
948 DALI_TEST_EQUALS( connected, false/*This is supposed to fail*/, TEST_LOCATION );
949 DALI_TEST_CHECK( lastSignalConnectionCustom == "failed" );
950 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
951 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0/*deleted along with FunctorDelegate*/, TEST_LOCATION );
954 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
955 customHandle.GetCustomSignal().Emit();
956 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0/*never called*/, TEST_LOCATION );
958 // tracker should have nothing to disconnect here
961 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
962 customHandle.GetCustomSignal().Emit();
963 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0/*never called*/, TEST_LOCATION );
967 int UtcDaliTypeRegistryTypeActionP(void)
969 ResetFunctorCounts();
971 TestApplication application;
973 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
974 DALI_TEST_CHECK( type );
976 BaseHandle handle = type.CreateInstance();
977 DALI_TEST_CHECK( handle );
979 Property::Map attributes;
980 DALI_TEST_CHECK( handle.DoAction("act1", attributes) );
981 DALI_TEST_CHECK( lastActionCustom == "act1" );
986 int UtcDaliTypeRegistryTypeActionN(void)
988 ResetFunctorCounts();
990 TestApplication application;
992 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
993 DALI_TEST_CHECK( type );
995 BaseHandle handle = type.CreateInstance();
996 DALI_TEST_CHECK( handle );
998 Property::Map attributes;
999 DALI_TEST_CHECK( !handle.DoAction( "unknownAction", attributes ) );
1004 int UtcDaliTypeRegistryPropertyRegistrationP(void)
1006 TestApplication application;
1007 TypeRegistry typeRegistry = TypeRegistry::Get();
1009 // Check property count before property registration
1010 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1011 DALI_TEST_CHECK( typeInfo );
1012 BaseHandle handle = typeInfo.CreateInstance();
1013 DALI_TEST_CHECK( handle );
1014 Actor customActor = Actor::DownCast( handle );
1015 DALI_TEST_CHECK( customActor );
1016 unsigned int initialPropertyCount( customActor.GetPropertyCount() );
1018 std::string propertyName( "prop1" );
1019 int propertyIndex( PROPERTY_REGISTRATION_START_INDEX );
1020 Property::Type propertyType( Property::BOOLEAN );
1021 PropertyRegistration property1( customType1, propertyName, propertyIndex, propertyType, &SetProperty, &GetProperty );
1023 // Check property count after registration
1024 unsigned int postRegistrationPropertyCount( customActor.GetPropertyCount() );
1025 DALI_TEST_EQUALS( initialPropertyCount + 1u, postRegistrationPropertyCount, TEST_LOCATION );
1027 // Add custom property and check property count
1028 customActor.RegisterProperty( "customProp1", true );
1029 unsigned int customPropertyCount( customActor.GetPropertyCount() );
1030 DALI_TEST_EQUALS( postRegistrationPropertyCount + 1u, customPropertyCount, TEST_LOCATION );
1032 // Set the property, ensure SetProperty called
1033 DALI_TEST_CHECK( !setPropertyCalled );
1034 customActor.SetProperty( propertyIndex, false );
1035 DALI_TEST_CHECK( setPropertyCalled );
1037 // Get the property, ensure GetProperty called
1038 DALI_TEST_CHECK( !getPropertyCalled );
1039 (void)customActor.GetProperty< bool >( propertyIndex );
1040 DALI_TEST_CHECK( getPropertyCalled );
1042 // Get the property using GetCurrentProperty and ensure GetProperty is called
1043 getPropertyCalled = false;
1044 DALI_TEST_CHECK( !getPropertyCalled );
1045 customActor.GetCurrentProperty< bool >( propertyIndex );
1046 DALI_TEST_CHECK( getPropertyCalled );
1048 // Check the property name
1049 DALI_TEST_EQUALS( customActor.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
1050 DALI_TEST_EQUALS( typeInfo.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
1052 // Check the property index
1053 DALI_TEST_EQUALS( customActor.GetPropertyIndex( propertyName ), propertyIndex, TEST_LOCATION );
1055 // Check the property type
1056 DALI_TEST_EQUALS( customActor.GetPropertyType( propertyIndex ), propertyType, TEST_LOCATION );
1058 // Check property count of type-info is 1
1059 Property::IndexContainer indices;
1060 typeInfo.GetPropertyIndices( indices );
1062 size_t typePropertyCount = typeInfo.GetPropertyCount();
1063 DALI_TEST_EQUALS( indices.Size(), Actor::New().GetPropertyCount() + 1u, TEST_LOCATION );
1064 DALI_TEST_EQUALS( indices.Size(), typePropertyCount, TEST_LOCATION );
1066 // Ensure indices returned from actor and customActor differ by two
1067 Actor actor = Actor::New();
1068 actor.GetPropertyIndices( indices );
1069 unsigned int actorIndices = indices.Size();
1070 customActor.GetPropertyIndices( indices );
1071 unsigned int customActorIndices = indices.Size();
1072 DALI_TEST_EQUALS( actorIndices + 2u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1076 int UtcDaliTypeRegistryPropertyRegistrationN(void)
1078 TestApplication application;
1079 TypeRegistry typeRegistry = TypeRegistry::Get();
1081 // Attempt to register a property type out-of-bounds index (less than)
1084 PropertyRegistration property1( customType1, "propName", PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN, &SetProperty, &GetProperty );
1085 tet_result( TET_FAIL );
1087 catch ( DaliException& e )
1089 DALI_TEST_ASSERT( e, "( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1092 // Attempt to register a property type out-of-bounds index (greater than)
1095 PropertyRegistration property1( customType1, "propName", PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN, &SetProperty, &GetProperty );
1096 tet_result( TET_FAIL );
1098 catch ( DaliException& e )
1100 DALI_TEST_ASSERT( e, "( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1106 int UtcDaliTypeRegistryAnimatablePropertyRegistrationP(void)
1108 TestApplication application;
1109 TypeRegistry typeRegistry = TypeRegistry::Get();
1111 // Check property count before property registration
1112 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1113 DALI_TEST_CHECK( typeInfo );
1114 BaseHandle handle = typeInfo.CreateInstance();
1115 DALI_TEST_CHECK( handle );
1116 Actor customActor = Actor::DownCast( handle );
1117 DALI_TEST_CHECK( customActor );
1118 application.GetScene().Add(customActor);
1120 unsigned int customPropertyCount( customActor.GetPropertyCount() );
1122 // Register animatable property
1123 std::string animatablePropertyName( "animatableProp1" );
1124 int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1125 Property::Type animatablePropertyType( Property::FLOAT );
1126 AnimatablePropertyRegistration animatableProperty( customType1, animatablePropertyName, animatablePropertyIndex, animatablePropertyType );
1128 // Check property count after registration
1129 DALI_TEST_EQUALS( customPropertyCount + 1u, customActor.GetPropertyCount(), TEST_LOCATION );
1131 // Set the animatable property value
1132 customActor.SetProperty( animatablePropertyIndex, 25.0f );
1134 // Render and notify
1135 application.SendNotification();
1136 application.Render();
1138 // Check the animatable property value
1139 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 25.f, TEST_LOCATION );
1141 // Check the animatable property name
1142 DALI_TEST_EQUALS( customActor.GetPropertyName( animatablePropertyIndex ), animatablePropertyName, TEST_LOCATION );
1144 // Check the animatable property index
1145 DALI_TEST_EQUALS( customActor.GetPropertyIndex( animatablePropertyName ), animatablePropertyIndex, TEST_LOCATION );
1147 // Check the animatable property type
1148 DALI_TEST_EQUALS( customActor.GetPropertyType( animatablePropertyIndex ), animatablePropertyType, TEST_LOCATION );
1150 // Check property count of type-info is 1
1151 Property::IndexContainer indices;
1152 typeInfo.GetPropertyIndices( indices );
1153 DALI_TEST_EQUALS( indices.Size(), customActor.GetPropertyCount(), TEST_LOCATION );
1155 // Ensure indices returned from actor and customActor differ by one
1156 Actor actor = Actor::New();
1157 actor.GetPropertyIndices( indices );
1158 unsigned int actorIndices = indices.Size();
1159 customActor.GetPropertyIndices( indices );
1160 unsigned int customActorIndices = indices.Size();
1161 DALI_TEST_EQUALS( actorIndices + 1u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1163 // check that the property is animatable
1164 Animation animation = Animation::New(0.2f);
1165 animation.AnimateTo( Property( customActor, animatablePropertyIndex ), 15.f, AlphaFunction::LINEAR );
1168 // Target value should change straight away
1169 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 15.0f, TEST_LOCATION );
1171 // Render and notify, animation play for 0.05 seconds
1172 application.SendNotification();
1173 application.Render(50);
1174 DALI_TEST_EQUALS( 0.25f, animation.GetCurrentProgress(), TEST_LOCATION );
1175 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 22.5f, TEST_LOCATION );
1177 // Render and notify, animation play for another 0.1 seconds
1178 application.SendNotification();
1179 application.Render(100);
1180 DALI_TEST_EQUALS( 0.75f, animation.GetCurrentProgress(), TEST_LOCATION );
1181 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 17.5f, TEST_LOCATION );
1186 int UtcDaliTypeRegistryAnimatablePropertyRegistrationN(void)
1188 TestApplication application;
1189 TypeRegistry typeRegistry = TypeRegistry::Get();
1191 // Attempt to register an animatable property type out-of-bounds index (less than)
1194 AnimatablePropertyRegistration property1( customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN );
1195 tet_result( TET_FAIL );
1197 catch ( DaliException& e )
1199 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1202 // Attempt to register an animatable property type out-of-bounds index (greater than)
1205 AnimatablePropertyRegistration property1( customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN );
1206 tet_result( TET_FAIL );
1208 catch ( DaliException& e )
1210 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1216 int UtcDaliTypeRegistryAnimatablePropertyRegistrationWithDefaultP(void)
1218 TestApplication application;
1219 TypeRegistry typeRegistry = TypeRegistry::Get();
1221 // Check property count before property registration
1222 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1223 DALI_TEST_CHECK( typeInfo );
1224 BaseHandle handle = typeInfo.CreateInstance();
1225 DALI_TEST_CHECK( handle );
1226 Actor customActor = Actor::DownCast( handle );
1227 DALI_TEST_CHECK( customActor );
1228 application.GetScene().Add(customActor);
1230 unsigned int customPropertyCount( customActor.GetPropertyCount() );
1232 // Register animatable property
1233 std::string animatablePropertyName( "animatableProp1" );
1234 int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1235 AnimatablePropertyRegistration animatableProperty1( customType1, animatablePropertyName, animatablePropertyIndex, 10.f );
1237 // Check property count after registration
1238 DALI_TEST_EQUALS( customPropertyCount + 1u, customActor.GetPropertyCount(), TEST_LOCATION );
1240 // Render and notify
1241 application.SendNotification();
1242 application.Render();
1244 // Check the animatable property value
1245 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 10.f, TEST_LOCATION );
1247 // Check the animatable property name
1248 DALI_TEST_EQUALS( customActor.GetPropertyName( animatablePropertyIndex ), animatablePropertyName, TEST_LOCATION );
1250 // Check the animatable property index
1251 DALI_TEST_EQUALS( customActor.GetPropertyIndex( animatablePropertyName ), animatablePropertyIndex, TEST_LOCATION );
1253 // Check the animatable property type
1254 DALI_TEST_EQUALS( customActor.GetPropertyType( animatablePropertyIndex ), Property::FLOAT, TEST_LOCATION );
1256 // Check property count of type-info
1257 Property::IndexContainer indices;
1258 typeInfo.GetPropertyIndices( indices );
1259 DALI_TEST_EQUALS( indices.Size(), customActor.GetPropertyCount(), TEST_LOCATION );
1261 // Ensure indices returned from actor and customActor differ by one
1262 Actor actor = Actor::New();
1263 actor.GetPropertyIndices( indices );
1264 unsigned int actorIndices = indices.Size();
1265 customActor.GetPropertyIndices( indices );
1266 unsigned int customActorIndices = indices.Size();
1267 DALI_TEST_EQUALS( actorIndices + 1u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1269 // check that the property is animatable
1270 Animation animation = Animation::New(0.2f);
1271 animation.AnimateTo( Property( customActor, animatablePropertyIndex ), 20.f, AlphaFunction::LINEAR );
1274 // Target value should change straight away
1275 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 20.0f, TEST_LOCATION );
1277 // Render and notify, animation play for 0.05 seconds
1278 application.SendNotification();
1279 application.Render(50);
1280 DALI_TEST_EQUALS( 0.25f, animation.GetCurrentProgress(), TEST_LOCATION );
1281 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 12.5f, TEST_LOCATION );
1283 // Render and notify, animation play for another 0.1 seconds
1284 application.SendNotification();
1285 application.Render(100);
1286 DALI_TEST_EQUALS( 0.75f, animation.GetCurrentProgress(), TEST_LOCATION );
1287 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 17.5f, TEST_LOCATION );
1292 int UtcDaliTypeRegistryAnimatablePropertyRegistrationWithDefaultN(void)
1294 TestApplication application;
1295 TypeRegistry typeRegistry = TypeRegistry::Get();
1297 // Attempt to register an animatable property type out-of-bounds index (less than)
1300 AnimatablePropertyRegistration property1( customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX - 1, false );
1301 tet_result( TET_FAIL );
1303 catch ( DaliException& e )
1305 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1308 // Attempt to register an animatable property type out-of-bounds index (greater than)
1311 AnimatablePropertyRegistration property1( customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX + 1, true );
1312 tet_result( TET_FAIL );
1314 catch ( DaliException& e )
1316 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1322 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationP(void)
1324 TestApplication application;
1325 TypeRegistry typeRegistry = TypeRegistry::Get();
1327 // Check property count before property registration
1328 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1329 DALI_TEST_CHECK( typeInfo );
1330 BaseHandle handle = typeInfo.CreateInstance();
1331 DALI_TEST_CHECK( handle );
1332 Actor customActor = Actor::DownCast( handle );
1333 DALI_TEST_CHECK( customActor );
1335 unsigned int customPropertyCount( customActor.GetPropertyCount() );
1337 // Register animatable property
1338 std::string animatablePropertyName( "animatableProp1" );
1339 int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1340 Property::Type animatablePropertyType( Property::VECTOR2 );
1341 AnimatablePropertyRegistration animatableProperty1( customType1, animatablePropertyName, animatablePropertyIndex, animatablePropertyType );
1343 // Check property count after registration
1344 DALI_TEST_EQUALS( customPropertyCount + 1u, customActor.GetPropertyCount(), TEST_LOCATION );
1346 // Set the animatable property value
1347 customActor.SetProperty( animatablePropertyIndex, Vector2(25.0f, 50.0f) );
1349 // Render and notify
1350 application.SendNotification();
1351 application.Render();
1353 // Check the animatable property value
1354 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( animatablePropertyIndex ), Vector2(25.0f, 50.0f), TEST_LOCATION );
1356 // Check the animatable property name
1357 DALI_TEST_EQUALS( customActor.GetPropertyName( animatablePropertyIndex ), animatablePropertyName, TEST_LOCATION );
1359 // Check the animatable property index
1360 DALI_TEST_EQUALS( customActor.GetPropertyIndex( animatablePropertyName ), animatablePropertyIndex, TEST_LOCATION );
1362 // Check the animatable property type
1363 DALI_TEST_EQUALS( customActor.GetPropertyType( animatablePropertyIndex ), animatablePropertyType, TEST_LOCATION );
1365 // Check property count of type-info
1366 Property::IndexContainer indices;
1367 typeInfo.GetPropertyIndices( indices );
1368 DALI_TEST_EQUALS( indices.Size(), customActor.GetPropertyCount(), TEST_LOCATION );
1370 // Register animatable property components
1371 std::string animatablePropertyComponentName1( "animatableProp1X" );
1372 int animatablePropertyComponentIndex1( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1 );
1373 AnimatablePropertyComponentRegistration animatablePropertyComponent1( customType1, animatablePropertyComponentName1, animatablePropertyComponentIndex1, animatablePropertyIndex, 0 );
1375 std::string animatablePropertyComponentName2( "animatableProp1Y" );
1376 int animatablePropertyComponentIndex2( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2 );
1377 AnimatablePropertyComponentRegistration animatablePropertyComponent2( customType1, animatablePropertyComponentName2, animatablePropertyComponentIndex2, animatablePropertyIndex, 1 );
1379 // Check property count after registration
1380 DALI_TEST_EQUALS( customPropertyCount + 3u, customActor.GetPropertyCount(), TEST_LOCATION );
1382 // Check the animatable property component value
1383 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex1 ), 25.0f, TEST_LOCATION );
1384 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex2 ), 50.0f, TEST_LOCATION );
1386 // Set the animatable property component value
1387 customActor.SetProperty( animatablePropertyComponentIndex1, 150.0f );
1389 // Render and notify
1390 application.SendNotification();
1391 application.Render();
1393 // Check the animatable property value
1394 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector2 >( animatablePropertyIndex ), Vector2(150.0f, 50.0f), TEST_LOCATION );
1395 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex1 ), 150.0f, TEST_LOCATION );
1396 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex2 ), 50.0f, TEST_LOCATION );
1398 // Set the animatable property component value
1399 customActor.SetProperty( animatablePropertyComponentIndex2, 225.0f );
1401 // Render and notify
1402 application.SendNotification();
1403 application.Render();
1405 // Check the animatable property value
1406 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector2 >( animatablePropertyIndex ), Vector2(150.0f, 225.0f), TEST_LOCATION );
1407 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex1 ), 150.0f, TEST_LOCATION );
1408 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex2 ), 225.0f, TEST_LOCATION );
1410 // Ensure indices returned from actor and customActor differ by three
1411 Actor actor = Actor::New();
1412 actor.GetPropertyIndices( indices );
1413 unsigned int actorIndices = indices.Size();
1414 customActor.GetPropertyIndices( indices );
1415 unsigned int customActorIndices = indices.Size();
1416 DALI_TEST_EQUALS( actorIndices + 3u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1418 // Attempt to animate component property, it should not crash
1419 Animation animation = Animation::New( 1.0f );
1420 animation.AnimateTo( Property( customActor, animatablePropertyComponentIndex1 ), 200.0f );
1423 // Check the property value
1424 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( animatablePropertyIndex ), Vector2(200.0f, 225.0f), TEST_LOCATION );
1425 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex1 ), 200.0f, TEST_LOCATION );
1426 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex2 ), 225.0f, TEST_LOCATION );
1431 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationVector2AnimateByP(void)
1433 TestApplication application;
1434 TypeRegistry typeRegistry = TypeRegistry::Get();
1436 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1437 DALI_TEST_CHECK( typeInfo );
1438 BaseHandle handle = typeInfo.CreateInstance();
1439 DALI_TEST_CHECK( handle );
1440 Actor customActor = Actor::DownCast( handle );
1441 DALI_TEST_CHECK( customActor );
1443 const unsigned int index = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX;
1444 const unsigned int xComponentIndex = index + 1;
1445 const unsigned int yComponentIndex = index + 2;
1446 const Vector2 initialValue( 20.0f, 40.0f );
1448 // Register animatable property & its components
1449 AnimatablePropertyRegistration animatableProperty1( customType1, "animatableProp1", index, initialValue );
1450 AnimatablePropertyComponentRegistration animatablePropertyComponent1( customType1, "animatableProp1X", xComponentIndex, index, 0 );
1451 AnimatablePropertyComponentRegistration animatablePropertyComponent2( customType1, "animatableProp1Y", yComponentIndex, index, 1 );
1453 // Check the animatable property value
1454 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( index ), initialValue, TEST_LOCATION );
1455 DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
1456 DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
1458 // Render and notify
1459 application.SendNotification();
1460 application.Render();
1462 // Check the animatable property current value
1463 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector2 >( index ), initialValue, TEST_LOCATION );
1464 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
1465 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
1468 const Vector2 targetValue( 45.0f, 53.0f );
1469 const Vector2 relativeValue( targetValue - initialValue );
1471 Animation animation = Animation::New( 1.0f );
1472 animation.AnimateBy( Property( customActor, xComponentIndex ), relativeValue.x );
1473 animation.AnimateBy( Property( customActor, yComponentIndex ), relativeValue.y );
1476 // Target values should change straight away
1477 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
1478 DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), targetValue.x, TEST_LOCATION );
1479 DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), targetValue.y, TEST_LOCATION );
1484 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationVector3AnimateByP(void)
1486 TestApplication application;
1487 TypeRegistry typeRegistry = TypeRegistry::Get();
1489 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1490 DALI_TEST_CHECK( typeInfo );
1491 BaseHandle handle = typeInfo.CreateInstance();
1492 DALI_TEST_CHECK( handle );
1493 Actor customActor = Actor::DownCast( handle );
1494 DALI_TEST_CHECK( customActor );
1496 const unsigned int index = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX;
1497 const unsigned int xComponentIndex = index + 1;
1498 const unsigned int yComponentIndex = index + 2;
1499 const unsigned int zComponentIndex = index + 3;
1500 const Vector3 initialValue( 20.0f, 40.0f, 50.0f );
1502 // Register animatable property & its components
1503 AnimatablePropertyRegistration animatableProperty1( customType1, "animatableProp1", index, initialValue );
1504 AnimatablePropertyComponentRegistration animatablePropertyComponent1( customType1, "animatableProp1X", xComponentIndex, index, 0 );
1505 AnimatablePropertyComponentRegistration animatablePropertyComponent2( customType1, "animatableProp1Y", yComponentIndex, index, 1 );
1506 AnimatablePropertyComponentRegistration animatablePropertyComponent3( customType1, "animatableProp1Z", zComponentIndex, index, 2 );
1508 // Check the animatable property value
1509 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( index ), initialValue, TEST_LOCATION );
1510 DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
1511 DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
1512 DALI_TEST_EQUALS( customActor.GetProperty< float >( zComponentIndex ), initialValue.z, TEST_LOCATION );
1514 // Render and notify
1515 application.SendNotification();
1516 application.Render();
1518 // Check the animatable property current value
1519 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector3 >( index ), initialValue, TEST_LOCATION );
1520 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
1521 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
1522 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( zComponentIndex ), initialValue.z, TEST_LOCATION );
1525 const Vector3 targetValue( 45.0f, 53.0f, 25.0f );
1526 const Vector3 relativeValue( targetValue - initialValue );
1528 Animation animation = Animation::New( 1.0f );
1529 animation.AnimateBy( Property( customActor, xComponentIndex ), relativeValue.x );
1530 animation.AnimateBy( Property( customActor, yComponentIndex ), relativeValue.y );
1531 animation.AnimateBy( Property( customActor, zComponentIndex ), relativeValue.z );
1534 // Target values should change straight away
1535 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
1536 DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), targetValue.x, TEST_LOCATION );
1537 DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), targetValue.y, TEST_LOCATION );
1538 DALI_TEST_EQUALS( customActor.GetProperty< float >( zComponentIndex ), targetValue.z, TEST_LOCATION );
1543 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationVector4AnimateByP(void)
1545 TestApplication application;
1546 TypeRegistry typeRegistry = TypeRegistry::Get();
1548 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1549 DALI_TEST_CHECK( typeInfo );
1550 BaseHandle handle = typeInfo.CreateInstance();
1551 DALI_TEST_CHECK( handle );
1552 Actor customActor = Actor::DownCast( handle );
1553 DALI_TEST_CHECK( customActor );
1555 const unsigned int index = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX;
1556 const unsigned int xComponentIndex = index + 1;
1557 const unsigned int yComponentIndex = index + 2;
1558 const unsigned int zComponentIndex = index + 3;
1559 const unsigned int wComponentIndex = index + 4;
1560 const Vector4 initialValue( 20.0f, 40.0f, 50.0f, 60.0f );
1562 // Register animatable property & its components
1563 AnimatablePropertyRegistration animatableProperty1( customType1, "animatableProp1", index, initialValue );
1564 AnimatablePropertyComponentRegistration animatablePropertyComponent1( customType1, "animatableProp1X", xComponentIndex, index, 0 );
1565 AnimatablePropertyComponentRegistration animatablePropertyComponent2( customType1, "animatableProp1Y", yComponentIndex, index, 1 );
1566 AnimatablePropertyComponentRegistration animatablePropertyComponent3( customType1, "animatableProp1Z", zComponentIndex, index, 2 );
1567 AnimatablePropertyComponentRegistration animatablePropertyComponent4( customType1, "animatableProp1W", wComponentIndex, index, 3 );
1569 // Check the animatable property value
1570 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( index ), initialValue, TEST_LOCATION );
1571 DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
1572 DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
1573 DALI_TEST_EQUALS( customActor.GetProperty< float >( zComponentIndex ), initialValue.z, TEST_LOCATION );
1574 DALI_TEST_EQUALS( customActor.GetProperty< float >( wComponentIndex ), initialValue.w, TEST_LOCATION );
1576 // Render and notify
1577 application.SendNotification();
1578 application.Render();
1580 // Check the animatable property current value
1581 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector4 >( index ), initialValue, TEST_LOCATION );
1582 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
1583 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
1584 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( zComponentIndex ), initialValue.z, TEST_LOCATION );
1585 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( wComponentIndex ), initialValue.w, TEST_LOCATION );
1588 const Vector4 targetValue( 45.0f, 53.0f, 25.0f, 13.0f );
1589 const Vector4 relativeValue( targetValue - initialValue );
1591 Animation animation = Animation::New( 1.0f );
1592 animation.AnimateBy( Property( customActor, xComponentIndex ), relativeValue.x );
1593 animation.AnimateBy( Property( customActor, yComponentIndex ), relativeValue.y );
1594 animation.AnimateBy( Property( customActor, zComponentIndex ), relativeValue.z );
1595 animation.AnimateBy( Property( customActor, wComponentIndex ), relativeValue.w );
1598 // Target values should change straight away
1599 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
1600 DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), targetValue.x, TEST_LOCATION );
1601 DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), targetValue.y, TEST_LOCATION );
1602 DALI_TEST_EQUALS( customActor.GetProperty< float >( zComponentIndex ), targetValue.z, TEST_LOCATION );
1603 DALI_TEST_EQUALS( customActor.GetProperty< float >( wComponentIndex ), targetValue.w, TEST_LOCATION );
1608 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationN(void)
1610 TestApplication application;
1611 TypeRegistry typeRegistry = TypeRegistry::Get();
1613 // Register animatable property with the type of Vector2
1614 int animatablePropertyIndex1( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1615 AnimatablePropertyRegistration animatableProperty1( customType1, "animatableProp1", animatablePropertyIndex1, Property::VECTOR2 );
1617 // Attempt to register an animatable property component out-of-bounds index (less than)
1620 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp1X", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX - 1, animatablePropertyIndex1, 0 );
1621 tet_result( TET_FAIL );
1623 catch ( DaliException& e )
1625 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1628 // Attempt to register an animatable property component out-of-bounds index (greater than)
1631 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp1X", ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX + 1, animatablePropertyIndex1, 0 );
1632 tet_result( TET_FAIL );
1634 catch ( DaliException& e )
1636 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1639 // Register an animatable property component
1640 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp1X", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1, animatablePropertyIndex1, 0 );
1642 // Attempt to register another animatable property component with the same component index
1645 AnimatablePropertyComponentRegistration propertyComponent2( customType1, "animatableProp1Y", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2, animatablePropertyIndex1, 0 );
1646 tet_result( TET_FAIL );
1648 catch ( DaliException& e )
1650 DALI_TEST_ASSERT( e, "Property component already registered", TEST_LOCATION );
1653 // Register animatable property with the type of boolean
1654 int animatablePropertyIndex2( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2 );
1655 AnimatablePropertyRegistration animatableProperty2( customType1, "animatableProp2", animatablePropertyIndex2, Property::BOOLEAN );
1657 // Attempt to register an animatable property component for the above property with boolean type
1660 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp2X", animatablePropertyIndex2 + 1, animatablePropertyIndex2, 0 );
1661 tet_result( TET_FAIL );
1663 catch ( DaliException& e )
1665 DALI_TEST_ASSERT( e, "Base property does not support component", TEST_LOCATION );
1671 int UtcDaliTypeRegistryChildPropertyRegistrationP(void)
1673 TestApplication application;
1674 TypeRegistry typeRegistry = TypeRegistry::Get();
1676 // Check property count before property registration
1677 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1678 DALI_TEST_CHECK( typeInfo );
1679 BaseHandle handle = typeInfo.CreateInstance();
1680 DALI_TEST_CHECK( handle );
1681 Actor customActor = Actor::DownCast( handle );
1682 DALI_TEST_CHECK( customActor );
1683 unsigned int initialPropertyCount( customActor.GetPropertyCount() );
1685 // Register child properties to the parent
1686 std::string propertyName( "childProp1" );
1687 int propertyIndex( CHILD_PROPERTY_REGISTRATION_START_INDEX );
1688 Property::Type propertyType( Property::BOOLEAN );
1689 ChildPropertyRegistration childProperty1( customType1, propertyName, propertyIndex, propertyType );
1691 std::string propertyName2( "childProp2" );
1692 int propertyIndex2( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1 );
1693 Property::Type propertyType2( Property::INTEGER );
1694 ChildPropertyRegistration childProperty2( customType1, propertyName2, propertyIndex2, propertyType2 );
1696 std::string propertyName3( "childProp3" );
1697 int propertyIndex3( CHILD_PROPERTY_REGISTRATION_START_INDEX + 2 );
1698 Property::Type propertyType3( Property::FLOAT );
1699 ChildPropertyRegistration childProperty3( customType1, propertyName3, propertyIndex3, propertyType3 );
1701 std::string propertyName4( "childProp4" );
1702 int propertyIndex4( CHILD_PROPERTY_REGISTRATION_START_INDEX + 3 );
1703 Property::Type propertyType4( Property::INTEGER );
1704 ChildPropertyRegistration childProperty4( customType1, propertyName4, propertyIndex4, propertyType4 );
1706 // Check property count are not changed because the child properties will not be created for the parent
1707 DALI_TEST_EQUALS( initialPropertyCount, customActor.GetPropertyCount(), TEST_LOCATION );
1709 // check the child property type
1710 Internal::TypeInfo& typeInfoImpl = GetImplementation( typeInfo );
1711 Property::Type type = typeInfoImpl.GetChildPropertyType( typeInfoImpl.GetChildPropertyIndex("childProp4") );
1712 DALI_TEST_EQUALS( type, Property::INTEGER, TEST_LOCATION );
1714 std::string unRegisteredChildName( typeInfoImpl.GetChildPropertyName( CHILD_PROPERTY_REGISTRATION_START_INDEX + 4 ) );
1715 DALI_TEST_EQUALS( unRegisteredChildName, "", TEST_LOCATION );
1717 // Create a child actor
1718 Actor childActor = Actor::New();
1719 DALI_TEST_CHECK( childActor );
1720 unsigned int initialChildActorPropertyCount( childActor.GetPropertyCount() );
1722 // The type of child properties should be Property::None as the child hasn't registered any child property yet.
1723 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex ), Property::NONE, TEST_LOCATION );
1724 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex2 ), Property::NONE, TEST_LOCATION );
1725 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex3 ), Property::NONE, TEST_LOCATION );
1726 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex4 ), Property::NONE, TEST_LOCATION );
1728 // Set the value for the first child property when the child actor doesn't have a parent yet
1729 childActor.SetProperty(propertyIndex, true);
1731 // Check that the first child property is dynamically created
1732 DALI_TEST_EQUALS( initialChildActorPropertyCount + 1u, childActor.GetPropertyCount(), TEST_LOCATION );
1734 // Check the first child property value
1735 DALI_TEST_EQUALS( childActor.GetProperty< bool >( propertyIndex ), true, TEST_LOCATION );
1737 // Check the first child property type
1738 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex ), propertyType, TEST_LOCATION );
1740 // Check that the first child property have no name, as it doesn't have a parent yet.
1741 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex ), "", TEST_LOCATION );
1743 // Check that the first property can't be accessed through its name, as it doesn't have a parent yet.
1744 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName ), Property::INVALID_INDEX, TEST_LOCATION );
1746 // Create a custom property for the child with the same name as the second child property registered to the parent
1747 Property::Index customPropertyIndex = childActor.RegisterProperty(propertyName2, 100, Property::READ_WRITE);
1749 // Check that the custom property is created
1750 DALI_TEST_EQUALS( initialChildActorPropertyCount + 2u, childActor.GetPropertyCount(), TEST_LOCATION );
1752 // Check the property value
1753 DALI_TEST_EQUALS( childActor.GetProperty< int >( customPropertyIndex ), 100, TEST_LOCATION );
1755 // Check the property index
1756 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName2 ), customPropertyIndex, TEST_LOCATION );
1758 // Check the property type
1759 DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex ), propertyType2, TEST_LOCATION );
1761 // Check the property name
1762 DALI_TEST_EQUALS( childActor.GetPropertyName( customPropertyIndex ), propertyName2, TEST_LOCATION );
1764 // Now add the child actor to the parent
1765 customActor.Add( childActor );
1767 // Check that the first child property now has the correct name as previously registered to the parent
1768 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
1770 // Check that the child property index for the first child property can now be retrieved through its child property name
1771 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName ), propertyIndex, TEST_LOCATION );
1773 // Check that the second child property now has the correct index as previously registered to the parent
1774 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex2 ), propertyName2, TEST_LOCATION );
1776 // Check that the second child property can be accessed through both its custom property index and its child property index
1777 DALI_TEST_EQUALS( childActor.GetProperty< int >( customPropertyIndex ), 100, TEST_LOCATION );
1778 DALI_TEST_EQUALS( childActor.GetProperty< int >( propertyIndex2 ), 100, TEST_LOCATION );
1779 DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex ), propertyType2, TEST_LOCATION );
1780 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex2 ), propertyType2, TEST_LOCATION );
1782 // Check that the child property index for the second child property can now be retrieved through its child property name
1783 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName2 ), propertyIndex2, TEST_LOCATION );
1785 // Set the value for the third child property when the child actor is already added to the parent
1786 childActor.SetProperty(propertyIndex3, 0.15f);
1788 // Check that the third child property is dynamically created
1789 DALI_TEST_EQUALS( initialChildActorPropertyCount + 3u, childActor.GetPropertyCount(), TEST_LOCATION );
1791 // Check the third child property value
1792 DALI_TEST_EQUALS( childActor.GetProperty< float >( propertyIndex3 ), 0.15f, TEST_LOCATION );
1794 // Check the third child property type
1795 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex3 ), propertyType3, TEST_LOCATION );
1797 // Check the third child property name
1798 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex3 ), propertyName3, TEST_LOCATION );
1800 // Check the third child property index.
1801 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName3 ), propertyIndex3, TEST_LOCATION );
1803 // Create a custom property for the child with the same name as the fourth child property registered to the parent
1804 Property::Index customPropertyIndex2 = childActor.RegisterProperty(propertyName4, 20, Property::READ_WRITE);
1806 // Check that the custom property is created
1807 DALI_TEST_EQUALS( initialChildActorPropertyCount + 4u, childActor.GetPropertyCount(), TEST_LOCATION );
1809 // Check the fourth child property value
1810 DALI_TEST_EQUALS( childActor.GetProperty< int >( propertyIndex4 ), 20, TEST_LOCATION );
1811 DALI_TEST_EQUALS( childActor.GetProperty< int >( customPropertyIndex2 ), 20, TEST_LOCATION );
1813 // Check the fourth child property type
1814 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex4 ), propertyType4, TEST_LOCATION );
1815 DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex2 ), propertyType4, TEST_LOCATION );
1817 // Check the fourth child property name
1818 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex4 ), propertyName4, TEST_LOCATION );
1819 DALI_TEST_EQUALS( childActor.GetPropertyName( customPropertyIndex2 ), propertyName4, TEST_LOCATION );
1821 // Check the fourth child property index.
1822 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName4 ), propertyIndex4, TEST_LOCATION );
1824 // Now create another parent actor with different child properties registered
1825 TypeInfo typeInfo2 = typeRegistry.GetTypeInfo( "MyNamedActor" );
1826 DALI_TEST_CHECK( typeInfo2 );
1827 BaseHandle handle2 = typeInfo2.CreateInstance();
1828 DALI_TEST_CHECK( handle2 );
1829 Actor customActor2 = Actor::DownCast( handle2 );
1830 DALI_TEST_CHECK( customActor2 );
1832 // Register child properties to the new parent
1833 std::string newPropertyName( "newChildProp" );
1834 int newPropertyIndex( CHILD_PROPERTY_REGISTRATION_START_INDEX ); // The same index as the first child property "childProp1" in the old parent
1835 Property::Type newPropertyType( Property::VECTOR2 );
1836 ChildPropertyRegistration newChildProperty( namedActorType, newPropertyName, newPropertyIndex, newPropertyType );
1838 std::string newPropertyName2( "childProp3" ); // The same name as the third child property in the old parent
1839 int newPropertyIndex2( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1 ); // The same index as the second child property "childProp2" in the old parent
1840 Property::Type newPropertyType2( Property::FLOAT ); // The same type as the third child property in the old parent
1841 ChildPropertyRegistration newChildProperty2( namedActorType, newPropertyName2, newPropertyIndex2, newPropertyType2 );
1843 // Now move the child actor to the new parent
1844 customActor2.Add( childActor );
1846 // "childProp1" is not a valid child property supported by the new parent, so nothing changed
1847 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex ), propertyType, TEST_LOCATION );
1848 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
1849 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName ), propertyIndex, TEST_LOCATION );
1851 // "childProp3" is a valid child property supported by the new parent
1852 // So it should get its new child property index and should just work
1853 DALI_TEST_EQUALS( childActor.GetPropertyType( newPropertyIndex2 ), newPropertyType2, TEST_LOCATION );
1854 DALI_TEST_EQUALS( childActor.GetPropertyName( newPropertyIndex2 ), newPropertyName2, TEST_LOCATION );
1855 DALI_TEST_EQUALS( childActor.GetPropertyIndex( newPropertyName2 ), newPropertyIndex2, TEST_LOCATION );
1856 DALI_TEST_EQUALS( childActor.GetProperty< float >( newPropertyIndex2 ), 0.15f, TEST_LOCATION );
1858 // Now register a custom property called "newChildProp"
1859 Property::Index customPropertyIndex3 = childActor.RegisterProperty("newChildProp", Vector2( 10.0f, 10.0f ), Property::READ_WRITE);
1861 // Check that the custom property is created
1862 DALI_TEST_EQUALS( initialChildActorPropertyCount + 5u, childActor.GetPropertyCount(), TEST_LOCATION );
1864 // This is a valid child property registered to the new parent
1865 // So should be able to access it through both its custom property index and its registered child property index
1866 DALI_TEST_EQUALS( childActor.GetPropertyType( newPropertyIndex ), newPropertyType, TEST_LOCATION );
1867 DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex3 ), newPropertyType, TEST_LOCATION );
1868 DALI_TEST_EQUALS( childActor.GetPropertyName( newPropertyIndex ), newPropertyName, TEST_LOCATION ); // This should return the new name, although the child property index remains the same
1869 DALI_TEST_EQUALS( childActor.GetPropertyName( customPropertyIndex3 ), newPropertyName, TEST_LOCATION );
1870 DALI_TEST_EQUALS( childActor.GetProperty< Vector2 >( newPropertyIndex ), Vector2( 10.0f, 10.0f ), TEST_LOCATION );
1871 DALI_TEST_EQUALS( childActor.GetProperty< Vector2 >( customPropertyIndex3 ), Vector2( 10.0f, 10.0f ), TEST_LOCATION );
1873 // Should return the child property index by given its name
1874 DALI_TEST_EQUALS( childActor.GetPropertyIndex( newPropertyName ), newPropertyIndex, TEST_LOCATION );
1880 int UtcDaliTypeRegistryChildPropertyRegistrationN(void)
1882 TestApplication application;
1883 TypeRegistry typeRegistry = TypeRegistry::Get();
1885 // Attempt to register a child property type out-of-bounds index (less than)
1888 ChildPropertyRegistration property1( customType1, "propName", CHILD_PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN );
1889 tet_result( TET_FAIL );
1891 catch ( DaliException& e )
1893 DALI_TEST_ASSERT( e, "( index >= CHILD_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1896 // Attempt to register a child property type out-of-bounds index (greater than)
1899 ChildPropertyRegistration property1( customType1, "propName", CHILD_PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN );
1900 tet_result( TET_FAIL );
1902 catch ( DaliException& e )
1904 DALI_TEST_ASSERT( e, "( index >= CHILD_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1911 /*******************************************************************************
1913 * Action through the base handle
1915 ******************************************************************************/
1916 int UtcDaliTypeRegistryActionViaBaseHandle(void)
1918 TestApplication application;
1922 type = TypeRegistry::Get().GetTypeInfo( "Actor" );
1923 DALI_TEST_CHECK( type );
1925 BaseHandle hdl = type.CreateInstance();
1926 DALI_TEST_CHECK( hdl );
1928 Actor a = Actor::DownCast(hdl);
1929 DALI_TEST_CHECK( a );
1931 a.SetProperty( Actor::Property::VISIBLE,false);
1933 application.SendNotification();
1934 application.Render(0);
1935 DALI_TEST_CHECK(!a.GetCurrentProperty< bool >( Actor::Property::VISIBLE ));
1937 Property::Map attributes;
1939 DALI_TEST_CHECK(hdl.DoAction("show", attributes));
1941 application.SendNotification();
1942 application.Render(0);
1943 DALI_TEST_CHECK(a.GetCurrentProperty< bool >( Actor::Property::VISIBLE ));
1945 DALI_TEST_CHECK(!hdl.DoAction("unknownAction", attributes));
1949 int UtcDaliPropertyRegistrationFunctions(void)
1951 TestApplication application;
1952 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 10;
1954 // Attempt to register a property without a setter
1957 PropertyRegistration property1( customType1, "propName", propertyIndex++, Property::BOOLEAN, NULL, &GetProperty );
1958 tet_result( TET_PASS );
1960 catch ( DaliException& e )
1962 tet_result( TET_FAIL );
1965 // Attempt to register a property without a getter
1968 PropertyRegistration property1( customType1, "propName", propertyIndex++, Property::BOOLEAN, NULL, NULL );
1969 tet_result( TET_FAIL );
1971 catch ( DaliException& e )
1973 DALI_TEST_ASSERT( e, "! \"GetProperty", TEST_LOCATION );
1978 int UtcDaliPropertyRegistrationAddSameIndex(void)
1980 TestApplication application;
1981 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 100;
1983 // Add one property with a valid property index
1984 PropertyRegistration property1( customType1, "propName", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
1986 // Attempt to add another property with the same index
1989 PropertyRegistration property2( customType1, "propName2", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
1991 catch ( DaliException& e )
1993 DALI_TEST_ASSERT( e, "! \"Property index already added", TEST_LOCATION );
1996 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 100;
1998 // Add one property with a valid property index
1999 AnimatablePropertyRegistration property3( customType1, "animPropName", animatablePropertyIndex, Property::BOOLEAN );
2001 // Attempt to add another property with the same index
2004 AnimatablePropertyRegistration property4( customType1, "animPropName2", animatablePropertyIndex, Property::BOOLEAN );
2006 catch ( DaliException& e )
2008 DALI_TEST_ASSERT( e, "! \"Property index already added", TEST_LOCATION );
2013 int UtcDaliPropertyRegistrationPropertyWritableP(void)
2015 TestApplication application;
2016 int propertyIndex1 = PROPERTY_REGISTRATION_START_INDEX + 200;
2017 int propertyIndex2 = PROPERTY_REGISTRATION_START_INDEX + 201;
2019 // Add two properties, one with SetProperty, one without
2020 PropertyRegistration property1( customType1, "propNameReadwrite", propertyIndex1, Property::BOOLEAN, &SetProperty, &GetProperty );
2021 PropertyRegistration property2( customType1, "propNameReadonly", propertyIndex2, Property::BOOLEAN, NULL, &GetProperty );
2023 // Create custom-actor
2024 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
2025 DALI_TEST_CHECK( typeInfo );
2026 BaseHandle handle = typeInfo.CreateInstance();
2027 DALI_TEST_CHECK( handle );
2028 Actor customActor = Actor::DownCast( handle );
2029 DALI_TEST_CHECK( customActor );
2031 // Check whether properties are writable
2032 DALI_TEST_CHECK( customActor.IsPropertyWritable( propertyIndex1 ) );
2033 DALI_TEST_CHECK( ! customActor.IsPropertyWritable( propertyIndex2 ) );
2036 // Check the property is writable in the type registry
2037 Internal::TypeInfo& typeInfoImpl = GetImplementation( typeInfo );
2039 DALI_TEST_EQUALS( typeInfoImpl.IsPropertyWritable( propertyIndex1 ), true, TEST_LOCATION );
2044 int UtcDaliPropertyRegistrationPropertyWritableN(void)
2046 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
2047 Internal::TypeInfo& typeInfoImpl = GetImplementation( typeInfo );
2049 DALI_TEST_EQUALS( typeInfoImpl.IsPropertyWritable( Actor::Property::COLOR), true, TEST_LOCATION );
2054 int UtcDaliPropertyRegistrationPropertyAnimatable(void)
2056 TestApplication application;
2057 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 400;
2058 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 400;
2060 // These properties are not animatable
2061 PropertyRegistration property1( customType1, "propName", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
2063 // These properties are animatable
2064 AnimatablePropertyRegistration property2( customType1, "animPropName", animatablePropertyIndex, Property::BOOLEAN );
2066 // Create custom-actor
2067 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
2068 DALI_TEST_CHECK( typeInfo );
2069 BaseHandle handle = typeInfo.CreateInstance();
2070 DALI_TEST_CHECK( handle );
2071 Actor customActor = Actor::DownCast( handle );
2072 DALI_TEST_CHECK( customActor );
2074 // Check if animatable
2075 DALI_TEST_CHECK( ! customActor.IsPropertyAnimatable( propertyIndex ) );
2076 DALI_TEST_CHECK( customActor.IsPropertyAnimatable( animatablePropertyIndex ) );
2078 // Create another instance of custom-actor
2079 BaseHandle handle2 = typeInfo.CreateInstance();
2080 DALI_TEST_CHECK( handle2 );
2081 Actor customActor2 = Actor::DownCast( handle2 );
2082 DALI_TEST_CHECK( customActor2 );
2084 // Check if animatable
2085 DALI_TEST_CHECK( ! customActor2.IsPropertyAnimatable( propertyIndex ) );
2086 DALI_TEST_CHECK( customActor2.IsPropertyAnimatable( animatablePropertyIndex ) );
2090 int UtcDaliPropertyRegistrationUnregisteredGetAndSet(void)
2092 TestApplication application;
2093 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 2000;
2094 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2000;
2096 // Create custom-actor
2097 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
2098 DALI_TEST_CHECK( typeInfo );
2099 BaseHandle handle = typeInfo.CreateInstance();
2100 DALI_TEST_CHECK( handle );
2101 Actor customActor = Actor::DownCast( handle );
2102 DALI_TEST_CHECK( customActor );
2104 // Try to set an index that hasn't been registered, this is a no-op for now, to be fixed in future
2105 customActor.SetProperty( propertyIndex, true );
2106 // DALI_TEST_EQUALS( true, customActor.GetProperty( propertyIndex ).Get<bool>(), TEST_LOCATION);
2108 // Try to set an index that hasn't been registered
2109 customActor.SetProperty( animatablePropertyIndex, true );
2110 DALI_TEST_EQUALS( true, customActor.GetProperty( animatablePropertyIndex ).Get<bool>(), TEST_LOCATION);
2116 int UtcDaliLongPressGestureDetectorTypeRegistry(void)
2118 TestApplication application;
2120 Actor actor = Actor::New();
2121 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
2122 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
2123 application.GetScene().Add(actor);
2127 type = TypeRegistry::Get().GetTypeInfo( "LongPressGestureDetector" );
2128 DALI_TEST_CHECK( type );
2129 BaseHandle handle = type.CreateInstance();
2130 DALI_TEST_CHECK( handle );
2131 LongPressGestureDetector detector = LongPressGestureDetector::DownCast( handle );
2132 DALI_TEST_CHECK( detector );
2134 // Attach actor to detector
2136 GestureReceivedFunctor functor( data );
2137 detector.Attach(actor);
2139 // Connect to signal through type
2140 handle.ConnectSignal( &application, "longPressDetected", functor );
2142 // Render and notify
2143 application.SendNotification();
2144 application.Render();
2147 TestGenerateLongPress( application, 50.0f, 10.0f );
2148 TestEndLongPress( application, 50.0f, 10.0f );
2150 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2154 int UtcDaliPanGestureDetectorTypeRegistry(void)
2156 TestApplication application;
2158 Actor actor = Actor::New();
2159 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
2160 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
2161 application.GetScene().Add(actor);
2165 type = TypeRegistry::Get().GetTypeInfo( "PanGestureDetector" );
2166 DALI_TEST_CHECK( type );
2167 BaseHandle handle = type.CreateInstance();
2168 DALI_TEST_CHECK( handle );
2169 PanGestureDetector detector = PanGestureDetector::DownCast( handle );
2170 DALI_TEST_CHECK( detector );
2172 // Attach actor to detector
2174 GestureReceivedFunctor functor( data );
2175 detector.Attach(actor);
2177 // Connect to signal through type
2178 handle.ConnectSignal( &application, "panDetected", functor );
2180 // Render and notify
2181 application.SendNotification();
2182 application.Render();
2185 TestGenerateMiniPan( application );
2186 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2190 int UtcDaliPinchGestureDetectorTypeRegistry(void)
2192 TestApplication application;
2194 Actor actor = Actor::New();
2195 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
2196 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
2197 application.GetScene().Add(actor);
2201 type = TypeRegistry::Get().GetTypeInfo( "PinchGestureDetector" );
2202 DALI_TEST_CHECK( type );
2203 BaseHandle handle = type.CreateInstance();
2204 DALI_TEST_CHECK( handle );
2205 PinchGestureDetector detector = PinchGestureDetector::DownCast( handle );
2206 DALI_TEST_CHECK( detector );
2208 // Attach actor to detector
2210 GestureReceivedFunctor functor( data );
2211 detector.Attach(actor);
2213 // Connect to signal through type
2214 handle.ConnectSignal( &application, "pinchDetected", functor );
2216 // Render and notify
2217 application.SendNotification();
2218 application.Render();
2221 TestGeneratePinch( application );
2223 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2227 int UtcDaliRotationGestureDetectorTypeRegistry(void)
2229 TestApplication application;
2231 Actor actor = Actor::New();
2232 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
2233 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
2234 application.GetScene().Add(actor);
2238 type = TypeRegistry::Get().GetTypeInfo( "RotationGestureDetector" );
2239 DALI_TEST_CHECK( type );
2240 BaseHandle handle = type.CreateInstance();
2241 DALI_TEST_CHECK( handle );
2242 RotationGestureDetector detector = RotationGestureDetector::DownCast( handle );
2243 DALI_TEST_CHECK( detector );
2245 // Attach actor to detector
2247 GestureReceivedFunctor functor( data );
2248 detector.Attach(actor);
2250 // Connect to signal through type
2251 handle.ConnectSignal( &application, "rotationDetected", functor );
2253 // Render and notify
2254 application.SendNotification();
2255 application.Render();
2258 TestGenerateRotation( application );
2260 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2264 int UtcDaliTapGestureDetectorTypeRegistry(void)
2266 TestApplication application;
2268 Actor actor = Actor::New();
2269 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
2270 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
2271 application.GetScene().Add(actor);
2275 type = TypeRegistry::Get().GetTypeInfo( "TapGestureDetector" );
2276 DALI_TEST_CHECK( type );
2277 BaseHandle handle = type.CreateInstance();
2278 DALI_TEST_CHECK( handle );
2279 TapGestureDetector detector = TapGestureDetector::DownCast( handle );
2280 DALI_TEST_CHECK( detector );
2282 // Attach actor to detector
2284 GestureReceivedFunctor functor( data );
2285 detector.Attach(actor);
2287 // Connect to signal through type
2288 handle.ConnectSignal( &application, "tapDetected", functor );
2290 // Render and notify
2291 application.SendNotification();
2292 application.Render();
2295 TestGenerateTap( application, 50.0, 10.0, 100 );
2297 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2301 int UtcDaliTypeRegistryNamedType(void)
2303 TestApplication application;
2304 TypeRegistry typeRegistry = TypeRegistry::Get();
2306 // Create a normal actor
2307 BaseHandle actorHandle = typeRegistry.GetTypeInfo( "Actor" ).CreateInstance();
2308 DALI_TEST_CHECK( actorHandle );
2309 Actor actor( Actor::DownCast( actorHandle ) );
2310 DALI_TEST_CHECK( actor );
2311 unsigned int actorPropertyCount( actor.GetPropertyCount() );
2313 // Create Named Actor Type
2314 BaseHandle namedHandle = typeRegistry.GetTypeInfo( "MyNamedActor" ).CreateInstance();
2315 DALI_TEST_CHECK( namedHandle );
2316 Actor namedActor( Actor::DownCast( namedHandle ) );
2317 DALI_TEST_CHECK( namedActor );
2318 unsigned int namedActorPropertyCount( namedActor.GetPropertyCount() );
2320 DALI_TEST_CHECK( namedActorPropertyCount > actorPropertyCount );
2324 int UtcDaliTypeInfoGetActionNameP(void)
2326 TestApplication application;
2327 TypeRegistry typeRegistry = TypeRegistry::Get();
2329 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2330 DALI_TEST_CHECK( typeInfo );
2332 DALI_TEST_CHECK( 0 != typeInfo.GetActionCount() );
2334 std::string name = typeInfo.GetActionName(0);
2336 DALI_TEST_EQUALS( name, "show", TEST_LOCATION );
2339 TypeInfo typeInfo2 = typeRegistry.GetTypeInfo( "MyTestCustomActor" );
2341 // search for show action in base class, given a derived class
2342 bool foundChildAction = false;
2343 for( std::size_t i = 0; i < typeInfo2.GetActionCount(); i++ )
2346 std::string name = typeInfo2.GetActionName( i );
2349 foundChildAction = true;
2354 DALI_TEST_EQUALS( foundChildAction, true, TEST_LOCATION );
2360 int UtcDaliTypeInfoGetActionNameN(void)
2362 TestApplication application;
2363 TypeRegistry typeRegistry = TypeRegistry::Get();
2365 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2366 DALI_TEST_CHECK( typeInfo );
2368 DALI_TEST_CHECK( 0 != typeInfo.GetActionCount() );
2370 std::string name = typeInfo.GetActionName(std::numeric_limits<size_t>::max());
2372 DALI_TEST_EQUALS( 0u, name.size(), TEST_LOCATION );
2377 int UtcDaliTypeInfoGetSignalNameP(void)
2379 TestApplication application;
2380 TypeRegistry typeRegistry = TypeRegistry::Get();
2382 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2383 DALI_TEST_CHECK( typeInfo );
2385 DALI_TEST_CHECK( 0 != typeInfo.GetSignalCount() );
2387 std::string name = typeInfo.GetSignalName(0);
2389 DALI_TEST_EQUALS( name, "hovered", TEST_LOCATION );
2391 TypeInfo typeInfo2 = typeRegistry.GetTypeInfo( "MyTestCustomActor" );
2393 // search for signal in base class, given a derived class
2394 bool foundSignal = false;
2395 for( std::size_t i = 0; i < typeInfo2.GetSignalCount(); i++ )
2397 std::string name = typeInfo2.GetSignalName( i );
2398 if( name == "hovered")
2404 DALI_TEST_EQUALS( foundSignal, true, TEST_LOCATION );
2409 int UtcDaliTypeInfoGetSignalNameN(void)
2411 TestApplication application;
2412 TypeRegistry typeRegistry = TypeRegistry::Get();
2414 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2415 DALI_TEST_CHECK( typeInfo );
2417 DALI_TEST_CHECK( 0 != typeInfo.GetSignalCount() );
2419 std::string name = typeInfo.GetSignalName(std::numeric_limits<size_t>::max());
2421 DALI_TEST_EQUALS( 0u, name.size(), TEST_LOCATION );
2427 int UtcDaliTypeInfoGetCreatorP(void)
2429 TestApplication application;
2430 TypeRegistry typeRegistry = TypeRegistry::Get();
2432 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2433 DALI_TEST_CHECK( typeInfo );
2435 TypeInfo::CreateFunction createFn = typeInfo.GetCreator();
2436 DALI_TEST_EQUALS( createFn != NULL, true, TEST_LOCATION );
2440 BaseHandle handle = createFn();
2441 DALI_TEST_EQUALS( (bool)handle, true, TEST_LOCATION );
2447 int UtcDaliTypeInfoGetCreatorN(void)
2449 TestApplication application;
2450 TypeRegistry typeRegistry = TypeRegistry::Get();
2452 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "MyTestCustomActor3" );
2453 DALI_TEST_CHECK( typeInfo );
2455 TypeInfo::CreateFunction createFn = typeInfo.GetCreator();
2456 DALI_TEST_EQUALS( createFn == NULL, true, TEST_LOCATION );
2461 int UtcDaliTypeInfoGetPropertyCountP1(void)
2463 TestApplication application;
2464 TypeRegistry typeRegistry = TypeRegistry::Get();
2466 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2467 DALI_TEST_CHECK( typeInfo );
2468 size_t actorPropertyCount = typeInfo.GetPropertyCount();
2470 DALI_TEST_EQUALS( actorPropertyCount, Actor::New().GetPropertyCount(), TEST_LOCATION ); // No event only props
2474 int UtcDaliTypeInfoGetPropertyCountP2(void)
2476 TestApplication application;
2477 TypeRegistry typeRegistry = TypeRegistry::Get();
2479 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "MyTestCustomActor2" );
2480 DALI_TEST_CHECK( typeInfo );
2481 size_t propertyCount = typeInfo.GetPropertyCount();
2482 Property::IndexContainer indices;
2483 typeInfo.GetPropertyIndices( indices );
2485 DALI_TEST_EQUALS( propertyCount > 0 && propertyCount <= indices.Size(), true, TEST_LOCATION );
2486 DALI_TEST_EQUALS( propertyCount, Actor::New().GetPropertyCount() + 2, TEST_LOCATION );
2491 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGet01(void)
2493 TestApplication application;
2494 TypeRegistry typeRegistry = TypeRegistry::Get();
2496 tet_infoline( "Register a type registered animatable property and ensure set/get behaviour works synchronously" );
2498 // Register animatable property
2499 const int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
2500 AnimatablePropertyRegistration animatableProperty( customType1, "animatableProp1", animatablePropertyIndex, Property::FLOAT );
2502 // Check property count before property registration
2503 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2504 DALI_TEST_CHECK( typeInfo );
2505 BaseHandle handle = typeInfo.CreateInstance();
2506 DALI_TEST_CHECK( handle );
2507 Actor customActor = Actor::DownCast( handle );
2508 DALI_TEST_CHECK( customActor );
2509 application.GetScene().Add(customActor);
2511 tet_infoline( "Set the value and ensure it changes straight away" );
2512 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 0.0f, TEST_LOCATION );
2513 customActor.SetProperty( animatablePropertyIndex, 25.0f );
2514 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 25.0f, TEST_LOCATION );
2516 tet_infoline( "Check latest scene-graph value is unchanged" );
2517 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 0.0f, TEST_LOCATION );
2519 // Render and notify
2520 application.SendNotification();
2521 application.Render();
2523 tet_infoline( "Check values after rendering and both retrieval methods should return the latest" );
2525 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 25.0f, TEST_LOCATION );
2526 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 25.0f, TEST_LOCATION );
2531 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGetWithComponentsVector2(void)
2533 TestApplication application;
2534 TypeRegistry typeRegistry = TypeRegistry::Get();
2536 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" );
2538 // Register the animatable propeties
2539 const int basePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
2540 const int componentZeroPropertyIndex( basePropertyIndex + 1 );
2541 const int componentOnePropertyIndex( componentZeroPropertyIndex + 1 );
2542 AnimatablePropertyRegistration baseAnimatableProperty( customType1, "baseProp", basePropertyIndex, Vector2( 13.0f, 24.0f ) );
2543 AnimatablePropertyComponentRegistration componentZeroAnimatableProperty( customType1, "componentZeroProp", componentZeroPropertyIndex, basePropertyIndex, 0 );
2544 AnimatablePropertyComponentRegistration componentOneAnimatableProperty( customType1, "componentOneProp", componentOnePropertyIndex, basePropertyIndex, 1 );
2546 // Check property count before property registration
2547 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2548 DALI_TEST_CHECK( typeInfo );
2549 BaseHandle handle = typeInfo.CreateInstance();
2550 DALI_TEST_CHECK( handle );
2551 Actor customActor = Actor::DownCast( handle );
2552 DALI_TEST_CHECK( customActor );
2553 application.GetScene().Add(customActor);
2555 tet_infoline( "Get the component values, they should be the default value of the base-property" );
2556 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2557 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2558 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 13.0f, 24.0f ), TEST_LOCATION );
2560 tet_infoline( "Set a component value and ensure it changes for the base property as well" );
2561 customActor.SetProperty( componentZeroPropertyIndex, 125.0f );
2562 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2563 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 125.0f, 24.0f ), TEST_LOCATION );
2565 customActor.SetProperty( componentOnePropertyIndex, 225.0f );
2566 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2567 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 125.0f, 225.0f ), TEST_LOCATION );
2569 tet_infoline( "Check latest scene-graph value is unchanged" );
2570 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector2 >( basePropertyIndex ), Vector2( 13.0f, 24.0f ), TEST_LOCATION );
2571 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2572 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2574 // Render and notify
2575 application.SendNotification();
2576 application.Render();
2578 tet_infoline( "Check values after rendering and both retrieval methods should return the latest" );
2579 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 125.0f, 225.0f ), TEST_LOCATION );
2580 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2581 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2583 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector2 >( basePropertyIndex ), Vector2( 125.0f, 225.0f ), TEST_LOCATION );
2584 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2585 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2587 tet_infoline( "Set the base property value and ensure the component values reflect the change" );
2588 customActor.SetProperty( basePropertyIndex, Vector2( 1.0f, 2.0f ) );
2589 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 1.0f, TEST_LOCATION );
2590 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 2.0f, TEST_LOCATION );
2591 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 1.0f, 2.0f ), TEST_LOCATION );
2596 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGetWithComponentsVector3(void)
2598 TestApplication application;
2599 TypeRegistry typeRegistry = TypeRegistry::Get();
2601 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" );
2603 // Register the animatable propeties
2604 const int basePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
2605 const int componentZeroPropertyIndex( basePropertyIndex + 1 );
2606 const int componentOnePropertyIndex( componentZeroPropertyIndex + 1 );
2607 const int componentTwoPropertyIndex( componentOnePropertyIndex + 1 );
2608 AnimatablePropertyRegistration baseAnimatableProperty( customType1, "baseProp", basePropertyIndex, Vector3( 13.0f, 24.0f, 35.0 ) );
2609 AnimatablePropertyComponentRegistration componentZeroAnimatableProperty( customType1, "componentZeroProp", componentZeroPropertyIndex, basePropertyIndex, 0 );
2610 AnimatablePropertyComponentRegistration componentOneAnimatableProperty( customType1, "componentOneProp", componentOnePropertyIndex, basePropertyIndex, 1 );
2611 AnimatablePropertyComponentRegistration componentTwoAnimatableProperty( customType1, "componentTwoProp", componentTwoPropertyIndex, basePropertyIndex, 2 );
2613 // Check property count before property registration
2614 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2615 DALI_TEST_CHECK( typeInfo );
2616 BaseHandle handle = typeInfo.CreateInstance();
2617 DALI_TEST_CHECK( handle );
2618 Actor customActor = Actor::DownCast( handle );
2619 DALI_TEST_CHECK( customActor );
2620 application.GetScene().Add(customActor);
2622 tet_infoline( "Get the component values, they should be the default value of the base-property" );
2623 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2624 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2625 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 35.0f, TEST_LOCATION );
2626 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 13.0f, 24.0f, 35.0f ), TEST_LOCATION );
2628 tet_infoline( "Set a component value and ensure it changes for the base property as well" );
2629 customActor.SetProperty( componentZeroPropertyIndex, 125.0f );
2630 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2631 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 24.0f, 35.0f ), TEST_LOCATION );
2633 customActor.SetProperty( componentOnePropertyIndex, 225.0f );
2634 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2635 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 225.0f, 35.0f ), TEST_LOCATION );
2637 customActor.SetProperty( componentTwoPropertyIndex, 325.0f );
2638 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2639 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 225.0f, 325.0f ), TEST_LOCATION );
2641 tet_infoline( "Check latest scene-graph value is unchanged" );
2642 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector3 >( basePropertyIndex ), Vector3( 13.0f, 24.0f, 35.0f ), TEST_LOCATION );
2643 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2644 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2645 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentTwoPropertyIndex ), 35.0f, TEST_LOCATION );
2647 // Render and notify
2648 application.SendNotification();
2649 application.Render();
2651 tet_infoline( "Check values after rendering and both retrieval methods should return the latest" );
2652 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 225.0f, 325.0f ), TEST_LOCATION );
2653 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2654 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2655 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2657 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 225.0f, 325.0f ), TEST_LOCATION );
2658 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2659 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2660 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2662 tet_infoline( "Set the base property value and ensure the component values reflect the change" );
2663 customActor.SetProperty( basePropertyIndex, Vector3( 1.0f, 2.0f, 3.0f ) );
2664 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 1.0f, TEST_LOCATION );
2665 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 2.0f, TEST_LOCATION );
2666 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 3.0f, TEST_LOCATION );
2667 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 1.0f, 2.0f, 3.0f ), TEST_LOCATION );
2672 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGetWithComponentsVector4(void)
2674 TestApplication application;
2675 TypeRegistry typeRegistry = TypeRegistry::Get();
2677 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" );
2679 // Register the animatable propeties
2680 const int basePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
2681 const int componentZeroPropertyIndex( basePropertyIndex + 1 );
2682 const int componentOnePropertyIndex( componentZeroPropertyIndex + 1 );
2683 const int componentTwoPropertyIndex( componentOnePropertyIndex + 1 );
2684 const int componentThreePropertyIndex( componentTwoPropertyIndex + 1 );
2685 AnimatablePropertyRegistration baseAnimatableProperty( customType1, "baseProp", basePropertyIndex, Vector4( 13.0f, 24.0f, 35.0, 47.0f ) );
2686 AnimatablePropertyComponentRegistration componentZeroAnimatableProperty( customType1, "componentZeroProp", componentZeroPropertyIndex, basePropertyIndex, 0 );
2687 AnimatablePropertyComponentRegistration componentOneAnimatableProperty( customType1, "componentOneProp", componentOnePropertyIndex, basePropertyIndex, 1 );
2688 AnimatablePropertyComponentRegistration componentTwoAnimatableProperty( customType1, "componentTwoProp", componentTwoPropertyIndex, basePropertyIndex, 2 );
2689 AnimatablePropertyComponentRegistration componentThreeAnimatableProperty( customType1, "componentThreeProp", componentThreePropertyIndex, basePropertyIndex, 3 );
2691 // Check property count before property registration
2692 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2693 DALI_TEST_CHECK( typeInfo );
2694 BaseHandle handle = typeInfo.CreateInstance();
2695 DALI_TEST_CHECK( handle );
2696 Actor customActor = Actor::DownCast( handle );
2697 DALI_TEST_CHECK( customActor );
2698 application.GetScene().Add(customActor);
2700 tet_infoline( "Get the component values, they should be the default value of the base-property" );
2701 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2702 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2703 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 35.0f, TEST_LOCATION );
2704 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentThreePropertyIndex ), 47.0f, TEST_LOCATION );
2705 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 13.0f, 24.0f, 35.0f, 47.0f ), TEST_LOCATION );
2707 tet_infoline( "Set a component value and ensure it changes for the base property as well" );
2708 customActor.SetProperty( componentZeroPropertyIndex, 125.0f );
2709 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2710 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 24.0f, 35.0f, 47.0f ), TEST_LOCATION );
2712 customActor.SetProperty( componentOnePropertyIndex, 225.0f );
2713 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2714 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 35.0f, 47.0f ), TEST_LOCATION );
2716 customActor.SetProperty( componentTwoPropertyIndex, 325.0f );
2717 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2718 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 325.0f, 47.0f ), TEST_LOCATION );
2720 customActor.SetProperty( componentThreePropertyIndex, 435.0f );
2721 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentThreePropertyIndex ), 435.0f, TEST_LOCATION );
2722 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 325.0f, 435.0f ), TEST_LOCATION );
2724 tet_infoline( "Check latest scene-graph value is unchanged" );
2725 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector4 >( basePropertyIndex ), Vector4( 13.0f, 24.0f, 35.0f, 47.0f ), TEST_LOCATION );
2726 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2727 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2728 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentTwoPropertyIndex ), 35.0f, TEST_LOCATION );
2729 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentThreePropertyIndex ), 47.0f, TEST_LOCATION );
2731 // Render and notify
2732 application.SendNotification();
2733 application.Render();
2735 tet_infoline( "Check values after rendering and both retrieval methods should return the latest" );
2736 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 325.0f, 435.0f ), TEST_LOCATION );
2737 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2738 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2739 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2740 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentThreePropertyIndex ), 435.0f, TEST_LOCATION );
2742 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 325.0f, 435.0f ), TEST_LOCATION );
2743 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2744 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2745 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2746 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentThreePropertyIndex ), 435.0f, TEST_LOCATION );
2748 tet_infoline( "Set the base property value and ensure the component values reflect the change" );
2749 customActor.SetProperty( basePropertyIndex, Vector4( 1.0f, 2.0f, 3.0f, 4.0f ) );
2750 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 1.0f, TEST_LOCATION );
2751 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 2.0f, TEST_LOCATION );
2752 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 3.0f, TEST_LOCATION );
2753 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentThreePropertyIndex ), 4.0f, TEST_LOCATION );
2754 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 1.0f, 2.0f, 3.0f, 4.0f ), TEST_LOCATION );
2760 int UtcDaliTypeInfoRegisterChildProperties01(void)
2762 TestApplication application;
2763 TypeRegistry typeRegistry = TypeRegistry::Get();
2765 tet_infoline( "Register child properties on a type via name" );
2767 auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(CustomActor) );
2768 auto myCustomTypeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2769 DALI_TEST_CHECK( customActorTypeInfo );
2770 DALI_TEST_CHECK( myCustomTypeInfo );
2772 const Property::Index WIDTH_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX );
2773 const Property::Index HEIGHT_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1);
2774 const Property::Index MARGIN_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 100);
2776 ChildPropertyRegistration( customActorTypeInfo.GetName(), "widthSpecification", WIDTH_SPECIFICATION, Property::INTEGER );
2777 ChildPropertyRegistration( customActorTypeInfo.GetName(), "heightSpecification", HEIGHT_SPECIFICATION, Property::INTEGER );
2778 ChildPropertyRegistration( myCustomTypeInfo.GetName(), "marginSpecification", MARGIN_SPECIFICATION, Property::EXTENTS );
2780 auto customActor = MyTestCustomActor::New();
2781 application.GetScene().Add( customActor );
2782 auto child = Actor::New();
2783 customActor.Add( child );
2785 child.SetProperty( WIDTH_SPECIFICATION, 33 );
2787 auto value = child.GetProperty( WIDTH_SPECIFICATION );
2788 DALI_TEST_EQUALS( value, Property::Value(33), TEST_LOCATION );
2790 child.SetProperty( HEIGHT_SPECIFICATION, 44 );
2791 value = child.GetProperty( HEIGHT_SPECIFICATION );
2792 DALI_TEST_EQUALS( value, Property::Value(44), TEST_LOCATION );
2794 child.SetProperty( MARGIN_SPECIFICATION, Extents(10, 10, 10, 10) );
2795 value = child.GetProperty( MARGIN_SPECIFICATION );
2796 DALI_TEST_EQUALS( value, Property::Value(Extents(10,10,10,10)), TEST_LOCATION );
2802 int UtcDaliTypeInfoRegisterChildProperties02(void)
2804 TestApplication application;
2805 TypeRegistry typeRegistry = TypeRegistry::Get();
2807 tet_infoline( "Register child properties on a type via name" );
2809 auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(CustomActor) );
2810 auto myCustomTypeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2811 DALI_TEST_CHECK( customActorTypeInfo );
2812 DALI_TEST_CHECK( myCustomTypeInfo );
2814 const Property::Index WIDTH_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX );
2815 const Property::Index HEIGHT_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1);
2816 const Property::Index MARGIN_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 100);
2818 ChildPropertyRegistration( customActorTypeInfo.GetName(), "widthSpecification", WIDTH_SPECIFICATION, Property::INTEGER );
2819 ChildPropertyRegistration( customActorTypeInfo.GetName(), "heightSpecification", HEIGHT_SPECIFICATION, Property::INTEGER );
2820 ChildPropertyRegistration( myCustomTypeInfo.GetName(), "marginSpecification", MARGIN_SPECIFICATION, Property::EXTENTS );
2823 auto index = customActorTypeInfo.GetChildPropertyIndex( "widthSpecification" );
2824 DALI_TEST_EQUALS( index, WIDTH_SPECIFICATION, TEST_LOCATION );
2826 index = customActorTypeInfo.GetChildPropertyIndex( "heightSpecification" );
2827 DALI_TEST_EQUALS( index, HEIGHT_SPECIFICATION, TEST_LOCATION );
2829 index = customActorTypeInfo.GetChildPropertyIndex( "marginSpecification" );
2830 DALI_TEST_EQUALS( index, Property::INVALID_INDEX, TEST_LOCATION );
2832 index = myCustomTypeInfo.GetChildPropertyIndex( "marginSpecification" );
2833 DALI_TEST_EQUALS( index, MARGIN_SPECIFICATION, TEST_LOCATION );
2836 auto name = customActorTypeInfo.GetChildPropertyName( WIDTH_SPECIFICATION );
2837 DALI_TEST_EQUALS( name, "widthSpecification", TEST_LOCATION );
2839 name = customActorTypeInfo.GetChildPropertyName( HEIGHT_SPECIFICATION );
2840 DALI_TEST_EQUALS( name, "heightSpecification", TEST_LOCATION );
2842 name = myCustomTypeInfo.GetChildPropertyName( MARGIN_SPECIFICATION );
2843 DALI_TEST_EQUALS( name, "marginSpecification", TEST_LOCATION );
2846 auto type = customActorTypeInfo.GetChildPropertyType( WIDTH_SPECIFICATION );
2847 DALI_TEST_EQUALS( type, Property::INTEGER, TEST_LOCATION );
2849 type = customActorTypeInfo.GetChildPropertyType( HEIGHT_SPECIFICATION );
2850 DALI_TEST_EQUALS( type, Property::INTEGER, TEST_LOCATION );
2852 type = myCustomTypeInfo.GetChildPropertyType( MARGIN_SPECIFICATION );
2853 DALI_TEST_EQUALS( type, Property::EXTENTS, TEST_LOCATION );
2860 int UtcDaliTypeInfoRegisterChildProperties03(void)
2862 TestApplication application;
2863 TypeRegistry typeRegistry = TypeRegistry::Get();
2865 tet_infoline( "Check registered child properties can be retrieved" );
2867 auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(CustomActor) );
2868 auto myCustomTypeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2869 DALI_TEST_CHECK( customActorTypeInfo );
2870 DALI_TEST_CHECK( myCustomTypeInfo );
2872 const Property::Index WIDTH_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX );
2873 const Property::Index HEIGHT_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1);
2874 const Property::Index MARGIN_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 100);
2876 ChildPropertyRegistration( customActorTypeInfo.GetName(), "widthSpecification", WIDTH_SPECIFICATION, Property::INTEGER );
2877 ChildPropertyRegistration( customActorTypeInfo.GetName(), "heightSpecification", HEIGHT_SPECIFICATION, Property::INTEGER );
2878 ChildPropertyRegistration( myCustomTypeInfo.GetName(), "marginSpecification", MARGIN_SPECIFICATION, Property::EXTENTS );
2880 Property::IndexContainer indices;
2881 myCustomTypeInfo.GetChildPropertyIndices( indices );
2883 auto result = std::find( indices.Begin(), indices.End(), WIDTH_SPECIFICATION );
2884 DALI_TEST_EQUALS( result != indices.End(), true, TEST_LOCATION );
2886 result = std::find( indices.Begin(), indices.End(), HEIGHT_SPECIFICATION );
2887 DALI_TEST_EQUALS( result != indices.End(), true, TEST_LOCATION );
2889 result = std::find( indices.Begin(), indices.End(), MARGIN_SPECIFICATION );
2890 DALI_TEST_EQUALS( result != indices.End(), true, TEST_LOCATION );
2895 int UtcDaliTypeInfoGetActionNameNegative(void)
2897 TestApplication application;
2898 Dali::TypeInfo instance;
2901 unsigned long arg1(0u);
2902 instance.GetActionName(arg1);
2903 DALI_TEST_CHECK(false); // Should not get here
2907 DALI_TEST_CHECK(true); // We expect an assert
2912 int UtcDaliTypeInfoGetSignalNameNegative(void)
2914 TestApplication application;
2915 Dali::TypeInfo instance;
2918 unsigned long arg1(0u);
2919 instance.GetSignalName(arg1);
2920 DALI_TEST_CHECK(false); // Should not get here
2924 DALI_TEST_CHECK(true); // We expect an assert
2929 int UtcDaliTypeInfoGetCreatorNegative(void)
2931 TestApplication application;
2932 Dali::TypeInfo instance;
2935 instance.GetCreator();
2936 DALI_TEST_CHECK(false); // Should not get here
2940 DALI_TEST_CHECK(true); // We expect an assert
2945 int UtcDaliTypeInfoGetBaseNameNegative(void)
2947 TestApplication application;
2948 Dali::TypeInfo instance;
2951 instance.GetBaseName();
2952 DALI_TEST_CHECK(false); // Should not get here
2956 DALI_TEST_CHECK(true); // We expect an assert
2961 int UtcDaliTypeInfoCreateInstanceNegative(void)
2963 TestApplication application;
2964 Dali::TypeInfo instance;
2967 instance.CreateInstance();
2968 DALI_TEST_CHECK(false); // Should not get here
2972 DALI_TEST_CHECK(true); // We expect an assert
2977 int UtcDaliTypeInfoGetActionCountNegative(void)
2979 TestApplication application;
2980 Dali::TypeInfo instance;
2983 instance.GetActionCount();
2984 DALI_TEST_CHECK(false); // Should not get here
2988 DALI_TEST_CHECK(true); // We expect an assert
2993 int UtcDaliTypeInfoGetSignalCountNegative(void)
2995 TestApplication application;
2996 Dali::TypeInfo instance;
2999 instance.GetSignalCount();
3000 DALI_TEST_CHECK(false); // Should not get here
3004 DALI_TEST_CHECK(true); // We expect an assert
3009 int UtcDaliTypeInfoGetPropertyNameNegative(void)
3011 TestApplication application;
3012 Dali::TypeInfo instance;
3016 instance.GetPropertyName(arg1);
3017 DALI_TEST_CHECK(false); // Should not get here
3021 DALI_TEST_CHECK(true); // We expect an assert
3026 int UtcDaliTypeInfoGetPropertyCountNegative(void)
3028 TestApplication application;
3029 Dali::TypeInfo instance;
3032 instance.GetPropertyCount();
3033 DALI_TEST_CHECK(false); // Should not get here
3037 DALI_TEST_CHECK(true); // We expect an assert
3042 int UtcDaliTypeInfoGetPropertyIndicesNegative(void)
3044 TestApplication application;
3045 Dali::TypeInfo instance;
3048 Dali::Vector<int> arg1;
3049 instance.GetPropertyIndices(arg1);
3050 DALI_TEST_CHECK(false); // Should not get here
3054 DALI_TEST_CHECK(true); // We expect an assert
3059 int UtcDaliTypeInfoGetChildPropertyNameNegative(void)
3061 TestApplication application;
3062 Dali::TypeInfo instance;
3066 instance.GetChildPropertyName(arg1);
3067 DALI_TEST_CHECK(false); // Should not get here
3071 DALI_TEST_CHECK(true); // We expect an assert
3076 int UtcDaliTypeInfoGetChildPropertyTypeNegative(void)
3078 TestApplication application;
3079 Dali::TypeInfo instance;
3083 instance.GetChildPropertyType(arg1);
3084 DALI_TEST_CHECK(false); // Should not get here
3088 DALI_TEST_CHECK(true); // We expect an assert
3093 int UtcDaliTypeInfoGetChildPropertyIndexNegative(void)
3095 TestApplication application;
3096 Dali::TypeInfo instance;
3100 instance.GetChildPropertyIndex(arg1);
3101 DALI_TEST_CHECK(false); // Should not get here
3105 DALI_TEST_CHECK(true); // We expect an assert
3110 int UtcDaliTypeInfoGetChildPropertyIndicesNegative(void)
3112 TestApplication application;
3113 Dali::TypeInfo instance;
3116 Dali::Vector<int> arg1;
3117 instance.GetChildPropertyIndices(arg1);
3118 DALI_TEST_CHECK(false); // Should not get here
3122 DALI_TEST_CHECK(true); // We expect an assert
3127 int UtcDaliTypeInfoGetNameNegative(void)
3129 TestApplication application;
3130 Dali::TypeInfo instance;
3134 DALI_TEST_CHECK(false); // Should not get here
3138 DALI_TEST_CHECK(true); // We expect an assert
3143 int UtcDaliTypeRegistryGetTypeInfoNegative01(void)
3145 TestApplication application;
3146 Dali::TypeRegistry instance;
3150 instance.GetTypeInfo(arg1);
3151 DALI_TEST_CHECK(false); // Should not get here
3155 DALI_TEST_CHECK(true); // We expect an assert
3160 int UtcDaliTypeRegistryGetTypeInfoNegative02(void)
3162 TestApplication application;
3163 Dali::TypeRegistry instance;
3166 instance.GetTypeInfo(typeid(unsigned int));
3167 DALI_TEST_CHECK(false); // Should not get here
3171 DALI_TEST_CHECK(true); // We expect an assert
3176 int UtcDaliTypeRegistryGetTypeNameNegative(void)
3178 TestApplication application;
3179 Dali::TypeRegistry instance;
3182 unsigned long arg1(0u);
3183 instance.GetTypeName(arg1);
3184 DALI_TEST_CHECK(false); // Should not get here
3188 DALI_TEST_CHECK(true); // We expect an assert
3193 int UtcDaliTypeRegistryGetTypeNameCountNegative(void)
3195 TestApplication application;
3196 Dali::TypeRegistry instance;
3199 instance.GetTypeNameCount();
3200 DALI_TEST_CHECK(false); // Should not get here
3204 DALI_TEST_CHECK(true); // We expect an assert