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() )
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 void OnKeyInputFocusGained()
158 virtual void OnKeyInputFocusLost()
161 virtual Vector3 GetNaturalSize()
163 return Vector3( 0.0f, 0.0f, 0.0f );
166 virtual float GetHeightForWidth( float width )
171 virtual float GetWidthForHeight( float height )
176 virtual void OnRelayout( const Vector2& size, RelayoutContainer& container )
180 virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
184 virtual void OnCalculateRelayoutSize( Dimension::Type dimension )
188 virtual float CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension )
193 virtual void OnLayoutNegotiated( float size, Dimension::Type dimension )
197 virtual bool RelayoutDependentOnChildren( Dimension::Type dimension = Dimension::ALL_DIMENSIONS )
209 class MyTestCustomActor : public CustomActor
213 typedef Signal< void ()> SignalType;
214 typedef Signal< void (float)> SignalTypeFloat;
220 static MyTestCustomActor New()
222 Impl::MyTestCustomActor* p = new Impl::MyTestCustomActor;
223 return MyTestCustomActor( *p ); // takes ownership
226 virtual ~MyTestCustomActor()
230 static MyTestCustomActor DownCast( BaseHandle handle )
232 MyTestCustomActor result;
234 CustomActor custom = Dali::CustomActor::DownCast( handle );
237 CustomActorImpl& customImpl = custom.GetImplementation();
239 Impl::MyTestCustomActor* impl = dynamic_cast<Impl::MyTestCustomActor*>(&customImpl);
243 result = MyTestCustomActor(customImpl.GetOwner());
250 SignalType& GetCustomSignal()
252 Dali::RefObject& obj = GetImplementation();
253 return static_cast<Impl::MyTestCustomActor&>( obj ).mSignal;
258 MyTestCustomActor(Internal::CustomActor* internal)
259 : CustomActor(internal)
263 MyTestCustomActor( Impl::MyTestCustomActor& impl )
264 : CustomActor( impl )
270 class MyTestCustomActor2 : public CustomActor
278 P1=Dali::PROPERTY_REGISTRATION_START_INDEX,
288 static MyTestCustomActor2 New()
290 return MyTestCustomActor2(); // takes ownership
293 virtual ~MyTestCustomActor2()
297 static MyTestCustomActor2 DownCast( BaseHandle handle )
299 MyTestCustomActor2 result;
301 CustomActor custom = Dali::CustomActor::DownCast( handle );
304 CustomActorImpl& customImpl = custom.GetImplementation();
306 Impl::MyTestCustomActor* impl = dynamic_cast<Impl::MyTestCustomActor*>(&customImpl);
310 result = MyTestCustomActor2(customImpl.GetOwner());
319 MyTestCustomActor2(Internal::CustomActor* internal)
320 : CustomActor(internal)
324 MyTestCustomActor2( Impl::MyTestCustomActor& impl )
325 : CustomActor( impl )
330 static TypeRegistration customTypeInit( typeid(MyTestCustomActor2), typeid(Dali::CustomActor), CreateCustomInit, true );
332 PropertyRegistration P1( customTypeInit, "propertyOne", MyTestCustomActor2::Property::P1, Property::INTEGER, &SetProperty, &GetProperty );
333 PropertyRegistration P2( customTypeInit, "propertyTwo", MyTestCustomActor2::Property::P2, Property::STRING, &SetProperty, &GetProperty );
336 class MyTestCustomActor3 : public CustomActor
343 static MyTestCustomActor3 New()
345 return MyTestCustomActor3(); // takes ownership
348 virtual ~MyTestCustomActor3()
352 static MyTestCustomActor3 DownCast( BaseHandle handle )
354 MyTestCustomActor3 result;
356 CustomActor custom = Dali::CustomActor::DownCast( handle );
359 CustomActorImpl& customImpl = custom.GetImplementation();
361 Impl::MyTestCustomActor* impl = dynamic_cast<Impl::MyTestCustomActor*>(&customImpl);
365 result = MyTestCustomActor3(customImpl.GetOwner());
374 MyTestCustomActor3(Internal::CustomActor* internal)
375 : CustomActor(internal)
379 MyTestCustomActor3( Impl::MyTestCustomActor& impl )
380 : CustomActor( impl )
385 static TypeRegistration customTypeBadInit( typeid(MyTestCustomActor3), typeid(Dali::CustomActor), NULL, false );
387 BaseHandle CreateCustom(void)
389 return MyTestCustomActor::New();
392 static std::string lastSignalConnectionCustom;
394 bool DoConnectSignalCustom( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
396 lastSignalConnectionCustom = signalName;
398 bool connected( true );
400 Dali::BaseHandle handle(object);
401 MyTestCustomActor customActor = MyTestCustomActor::DownCast(handle);
403 if( "sig1" == signalName )
405 customActor.GetCustomSignal().Connect( tracker, functor );
409 // signalName does not match any signal
416 bool DoConnectSignalCustomFailure( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
418 lastSignalConnectionCustom = "failed";
420 return false; // This is supposed to fail
423 struct CustomTestFunctor
427 ++mTotalInstanceCount;
428 ++mCurrentInstanceCount;
431 CustomTestFunctor( const CustomTestFunctor& copyMe )
433 ++mTotalInstanceCount;
434 ++mCurrentInstanceCount;
439 --mCurrentInstanceCount;
447 static int mTotalInstanceCount;
448 static int mCurrentInstanceCount;
449 static int mCallbackCount;
452 int CustomTestFunctor::mTotalInstanceCount = 0;
453 int CustomTestFunctor::mCurrentInstanceCount = 0;
454 int CustomTestFunctor::mCallbackCount = 0;
456 static void ResetFunctorCounts()
458 CustomTestFunctor::mTotalInstanceCount = 0;
459 CustomTestFunctor::mCurrentInstanceCount = 0;
460 CustomTestFunctor::mCallbackCount = 0;
463 static std::string lastActionCustom;
464 bool DoActionCustom(BaseObject* object, const std::string& actionName, const Property::Map& /*attributes*/)
466 lastActionCustom = actionName;
470 // Custom type registration
471 static TypeRegistration customType1( typeid(MyTestCustomActor), typeid(Dali::CustomActor), CreateCustom );
474 static SignalConnectorType customSignalConnector1( customType1, "sig1", DoConnectSignalCustom );
475 static SignalConnectorType customSignalConnector2( customType1, "sig2", DoConnectSignalCustomFailure );
476 static const int TEST_SIGNAL_COUNT = 2;
479 static TypeAction customAction1( customType1, "act1", DoActionCustom);
480 static const int TEST_ACTION_COUNT = 1;
482 class TestConnectionTracker : public ConnectionTracker
486 TestConnectionTracker()
491 BaseHandle CreateNamedActorType()
493 Actor actor = Actor::New();
494 actor.SetProperty( Actor::Property::NAME, "NamedActor" );
498 TypeRegistration namedActorType( "MyNamedActor", typeid(Dali::Actor), CreateNamedActorType );
499 PropertyRegistration namedActorPropertyOne( namedActorType, "propName", PROPERTY_REGISTRATION_START_INDEX, Property::BOOLEAN, &SetProperty, &GetProperty );
501 } // Anonymous namespace
503 // Note: No negative test case for UtcDaliTypeRegistryGet can be implemented.
504 int UtcDaliTypeRegistryGetP(void)
506 TestApplication application;
508 TypeRegistry registry = TypeRegistry::Get();
509 DALI_TEST_CHECK( registry );
514 // Note: No negative test case for UtcDaliTypeRegistryConstructor can be implemented.
515 int UtcDaliTypeRegistryConstructorP(void)
517 TestApplication application;
519 TypeRegistry registry;
520 DALI_TEST_CHECK( !registry );
524 // Note: No negative test case for UtcDaliTypeRegistryCopyConstructor can be implemented.
525 int UtcDaliTypeRegistryCopyConstructorP(void)
527 TestApplication application;
529 TypeRegistry registry = TypeRegistry::Get();
530 DALI_TEST_CHECK( registry );
532 TypeRegistry copy( registry );
533 DALI_TEST_CHECK( copy );
535 DALI_TEST_CHECK( registry.GetTypeInfo( "Actor" ).GetName() == copy.GetTypeInfo( "Actor" ).GetName() );
540 // Note: No negative test case for UtcDaliTypeRegistryAssignmentOperator can be implemented.
541 int UtcDaliTypeRegistryAssignmentOperatorP(void)
543 TestApplication application;
545 TypeRegistry registry = TypeRegistry::Get();
546 DALI_TEST_CHECK( registry );
548 TypeRegistry copy = registry;
549 DALI_TEST_CHECK( copy );
550 DALI_TEST_CHECK( registry == copy );
552 DALI_TEST_CHECK( registry.GetTypeInfo( "Actor" ).GetName() == copy.GetTypeInfo( "Actor" ).GetName() );
557 int UtcDaliTypeRegistryMoveConstructor(void)
559 TestApplication application;
561 TypeRegistry registry = TypeRegistry::Get();
562 DALI_TEST_CHECK( registry );
563 DALI_TEST_EQUALS( 16, registry.GetBaseObject().ReferenceCount(), TEST_LOCATION );
564 DALI_TEST_CHECK( registry.GetTypeInfo( "Actor" ).GetName() == "Actor" );
566 TypeRegistry movedRegistry = std::move( registry );
567 DALI_TEST_CHECK( movedRegistry );
568 DALI_TEST_EQUALS( 16, movedRegistry.GetBaseObject().ReferenceCount(), TEST_LOCATION );
569 DALI_TEST_CHECK( movedRegistry.GetTypeInfo( "Actor" ).GetName() == "Actor" );
570 DALI_TEST_CHECK( !registry );
572 Dali::TypeInfo info = movedRegistry.GetTypeInfo( "Actor" );
573 DALI_TEST_CHECK( info );
574 DALI_TEST_EQUALS( 2, info.GetBaseObject().ReferenceCount(), TEST_LOCATION );
575 DALI_TEST_CHECK( info.GetName() == "Actor" );
577 Dali::TypeInfo movedInfo = std::move( info );
578 DALI_TEST_CHECK( movedInfo );
579 DALI_TEST_EQUALS( 2, movedInfo.GetBaseObject().ReferenceCount(), TEST_LOCATION );
580 DALI_TEST_CHECK( movedInfo.GetName() == "Actor" );
581 DALI_TEST_CHECK( !info );
586 int UtcDaliTypeRegistryMoveAssignment(void)
588 TestApplication application;
590 TypeRegistry registry = TypeRegistry::Get();
591 DALI_TEST_CHECK( registry );
592 DALI_TEST_EQUALS( 16, registry.GetBaseObject().ReferenceCount(), TEST_LOCATION );
593 DALI_TEST_CHECK( registry.GetTypeInfo( "Actor" ).GetName() == "Actor" );
595 TypeRegistry movedRegistry;
596 movedRegistry = std::move( registry );
597 DALI_TEST_CHECK( movedRegistry );
598 DALI_TEST_EQUALS( 16, movedRegistry.GetBaseObject().ReferenceCount(), TEST_LOCATION );
599 DALI_TEST_CHECK( movedRegistry.GetTypeInfo( "Actor" ).GetName() == "Actor" );
600 DALI_TEST_CHECK( !registry );
602 Dali::TypeInfo info = movedRegistry.GetTypeInfo( "Actor" );
603 DALI_TEST_CHECK( info );
604 DALI_TEST_EQUALS( 2, info.GetBaseObject().ReferenceCount(), TEST_LOCATION );
605 DALI_TEST_CHECK( info.GetName() == "Actor" );
607 Dali::TypeInfo movedInfo;
608 movedInfo = std::move( info );
609 DALI_TEST_CHECK( movedInfo );
610 DALI_TEST_EQUALS( 2, movedInfo.GetBaseObject().ReferenceCount(), TEST_LOCATION );
611 DALI_TEST_CHECK( movedInfo.GetName() == "Actor" );
612 DALI_TEST_CHECK( !info );
617 int UtcDaliTypeRegistryAssignP(void)
619 TestApplication application;
621 TypeRegistry registry = TypeRegistry::Get();
622 TypeRegistry registry2;
623 registry2 = registry;
624 DALI_TEST_CHECK( registry2 );
626 DALI_TEST_CHECK( registry2.GetTypeInfo( "Actor" ).GetName() == registry2.GetTypeInfo( "Actor" ).GetName() );
631 int UtcDaliTypeRegistryGetTypeInfoFromTypeNameP(void)
633 TestApplication application;
635 TypeRegistry registry = TypeRegistry::Get();
640 type = registry.GetTypeInfo( "CameraActor" );
641 DALI_TEST_CHECK( type );
642 CameraActor ca = CameraActor::DownCast(type.CreateInstance());
643 DALI_TEST_CHECK( ca );
644 application.GetScene().Add( ca );
645 application.Render();
648 type = registry.GetTypeInfo( "Animation" );
649 DALI_TEST_CHECK( type );
650 Animation an = Animation::DownCast(type.CreateInstance());
651 DALI_TEST_CHECK( an );
653 application.Render();
658 int UtcDaliTypeRegistryGetTypeInfoFromTypeNameN(void)
660 TestApplication application;
662 TypeRegistry registry = TypeRegistry::Get();
666 type = registry.GetTypeInfo( "MyDummyActor" );
667 DALI_TEST_CHECK( !type );
672 int UtcDaliTypeRegistryGetTypeInfoFromTypeIdP(void)
674 TypeInfo named_type = TypeRegistry::Get().GetTypeInfo( "CameraActor" );
675 TypeInfo typeinfo_type = TypeRegistry::Get().GetTypeInfo( typeid(Dali::CameraActor) );
677 DALI_TEST_CHECK( named_type );
678 DALI_TEST_CHECK( typeinfo_type );
680 // Check named and typeid are equivalent
681 DALI_TEST_CHECK( named_type == typeinfo_type );
683 DALI_TEST_CHECK( named_type.GetName() == typeinfo_type.GetName() );
684 DALI_TEST_CHECK( named_type.GetBaseName() == typeinfo_type.GetBaseName() );
689 int UtcDaliTypeRegistryGetTypeInfoFromTypeIdN(void)
691 TestApplication application;
692 TypeRegistry typeRegistry = TypeRegistry::Get();
694 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(Vector2) );
695 DALI_TEST_CHECK( !typeInfo );
700 int UtcDaliTypeRegistryGetTypeNameCountP(void)
702 TestApplication application;
703 TypeRegistry typeRegistry = TypeRegistry::Get();
706 for(size_t i = 0; i < typeRegistry.GetTypeNameCount(); i++)
708 type = typeRegistry.GetTypeInfo( typeRegistry.GetTypeName(i) );
709 DALI_TEST_CHECK( type );
716 int UtcDaliTypeRegistryGetTypeNamesP(void)
718 TestApplication application;
719 TypeRegistry typeRegistry = TypeRegistry::Get();
722 for(size_t i = 0; i < typeRegistry.GetTypeNameCount(); i++)
724 type = typeRegistry.GetTypeInfo( typeRegistry.GetTypeName(i) );
725 DALI_TEST_CHECK( type );
732 // Note: No negative test case for UtcDaliTypeRegistryTypeRegistration can be implemented.
733 int UtcDaliTypeRegistryTypeRegistrationNotCallingCreateOnInitP(void)
735 ResetFunctorCounts();
737 TestApplication application;
739 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
740 DALI_TEST_CHECK( type );
742 TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( "CustomActor" );
743 DALI_TEST_CHECK( baseType );
745 BaseHandle handle = type.CreateInstance();
746 DALI_TEST_CHECK( handle );
748 MyTestCustomActor customHandle = MyTestCustomActor::DownCast( handle );
749 DALI_TEST_CHECK( customHandle );
751 DALI_TEST_EQUALS( type.GetActionCount(), TEST_ACTION_COUNT + baseType.GetActionCount(), TEST_LOCATION );
753 DALI_TEST_EQUALS( type.GetSignalCount(), TEST_SIGNAL_COUNT + baseType.GetSignalCount(), TEST_LOCATION );
756 TestConnectionTracker tracker;
758 bool connected = handle.ConnectSignal( &tracker, "sig1", CustomTestFunctor() );
759 DALI_TEST_EQUALS( connected, true, TEST_LOCATION );
760 DALI_TEST_CHECK( lastSignalConnectionCustom == "sig1" );
761 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
762 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION );
764 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
765 customHandle.GetCustomSignal().Emit();
766 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION );
767 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
768 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION );
770 // tracker should automatically disconnect here
771 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
772 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
774 // Test that functor is disconnected
775 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION );
776 customHandle.GetCustomSignal().Emit();
777 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1/*not incremented*/, TEST_LOCATION );
778 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
779 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
781 Property::Map attributes;
782 handle.DoAction("act1", attributes);
783 DALI_TEST_CHECK( lastActionCustom == "act1" );
787 // Note: No negative test case for UtcDaliTypeRegistryTypeRegistration can be implemented.
788 int UtcDaliTypeRegistryTypeRegistrationCallingCreateOnInitP(void)
790 TestApplication application;
792 DALI_TEST_CHECK( "MyTestCustomActor2" == customTypeInit.RegisteredName() );
794 DALI_TEST_CHECK( true == CreateCustomInitCalled );
795 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor2" );
796 DALI_TEST_CHECK( type );
800 // Note: No negative test case for UtcDaliTypeRegistryTypeRegistration can be implemented.
801 int UtcDaliTypeRegistryTypeRegistrationForNamedTypeP(void)
803 TestApplication application;
805 // Create Named Actor Type
806 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyNamedActor" );
807 DALI_TEST_CHECK( type );
809 BaseHandle namedHandle = type.CreateInstance();
810 DALI_TEST_CHECK( namedHandle );
811 Actor namedActor( Actor::DownCast( namedHandle ) );
812 DALI_TEST_CHECK( namedActor );
814 DALI_TEST_CHECK( namedActor.GetProperty< std::string >( Actor::Property::NAME ) == "NamedActor" );
815 DALI_TEST_CHECK( type.GetName() == "MyNamedActor" );
816 DALI_TEST_CHECK( type.GetBaseName() == "Actor" );
821 int UtcDaliTypeRegistryRegisteredNameP(void)
823 TestApplication application;
825 DALI_TEST_CHECK( scriptedName == scriptedType.RegisteredName() );
827 TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( scriptedName );
828 DALI_TEST_CHECK( baseType );
830 BaseHandle handle = baseType.CreateInstance();
832 DALI_TEST_CHECK( true == CreateCustomNamedInitCalled );
833 TypeInfo type = TypeRegistry::Get().GetTypeInfo( scriptedName );
834 DALI_TEST_CHECK( type );
839 int UtcDaliTypeRegistryRegisteredNameN(void)
841 TestApplication application;
843 DALI_TEST_CHECK( scriptedName == scriptedType.RegisteredName() );
845 TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( scriptedName );
846 DALI_TEST_CHECK( baseType );
848 // should cause an assert because we're registering same type twice
849 // once statically at the start of this file, then again now
852 TypeRegistration scriptedType( scriptedName, typeid(Dali::CustomActor), CreateCustomNamedInit );
853 tet_result( TET_FAIL );
855 catch ( DaliException& e )
857 DALI_TEST_ASSERT( e, "Duplicate type name in Type Registration", TEST_LOCATION );
864 int UtcDaliTypeRegistrySignalConnectorTypeP(void)
866 ResetFunctorCounts();
868 TestApplication application;
870 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
871 DALI_TEST_CHECK( type );
873 BaseHandle handle = type.CreateInstance();
874 DALI_TEST_CHECK( handle );
876 MyTestCustomActor customHandle = MyTestCustomActor::DownCast( handle );
877 DALI_TEST_CHECK( customHandle );
880 TestConnectionTracker tracker;
882 bool connected = handle.ConnectSignal( &tracker, "sig1", CustomTestFunctor() );
883 DALI_TEST_EQUALS( connected, true, TEST_LOCATION );
884 DALI_TEST_CHECK( lastSignalConnectionCustom == "sig1" );
885 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
886 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION );
888 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
889 customHandle.GetCustomSignal().Emit();
890 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION );
891 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
892 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION );
894 // tracker should automatically disconnect here
895 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
896 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
898 // Test that functor is disconnected
899 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION );
900 customHandle.GetCustomSignal().Emit();
901 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1/*not incremented*/, TEST_LOCATION );
902 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
903 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
908 int UtcDaliTypeRegistrySignalConnectorTypeN(void)
910 // Test what happens when signal connnector (DoConnectSignalFailure method) returns false
912 ResetFunctorCounts();
914 TestApplication application;
916 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
917 DALI_TEST_CHECK( type );
919 TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( "CustomActor" );
920 DALI_TEST_CHECK( baseType );
922 BaseHandle handle = type.CreateInstance();
923 DALI_TEST_CHECK( handle );
925 MyTestCustomActor customHandle = MyTestCustomActor::DownCast( handle );
926 DALI_TEST_CHECK( customHandle );
928 DALI_TEST_EQUALS( type.GetActionCount(), TEST_ACTION_COUNT + baseType.GetActionCount(), TEST_LOCATION );
930 DALI_TEST_EQUALS( type.GetSignalCount(), TEST_SIGNAL_COUNT + baseType.GetSignalCount(), TEST_LOCATION );
933 TestConnectionTracker tracker;
935 bool connected = handle.ConnectSignal( &tracker, "sig2", CustomTestFunctor() );
936 DALI_TEST_EQUALS( connected, false/*This is supposed to fail*/, TEST_LOCATION );
937 DALI_TEST_CHECK( lastSignalConnectionCustom == "failed" );
938 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
939 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0/*deleted along with FunctorDelegate*/, TEST_LOCATION );
942 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
943 customHandle.GetCustomSignal().Emit();
944 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0/*never called*/, TEST_LOCATION );
946 // tracker should have nothing to disconnect here
949 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
950 customHandle.GetCustomSignal().Emit();
951 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0/*never called*/, TEST_LOCATION );
955 int UtcDaliTypeRegistryTypeActionP(void)
957 ResetFunctorCounts();
959 TestApplication application;
961 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
962 DALI_TEST_CHECK( type );
964 BaseHandle handle = type.CreateInstance();
965 DALI_TEST_CHECK( handle );
967 Property::Map attributes;
968 DALI_TEST_CHECK( handle.DoAction("act1", attributes) );
969 DALI_TEST_CHECK( lastActionCustom == "act1" );
974 int UtcDaliTypeRegistryTypeActionN(void)
976 ResetFunctorCounts();
978 TestApplication application;
980 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
981 DALI_TEST_CHECK( type );
983 BaseHandle handle = type.CreateInstance();
984 DALI_TEST_CHECK( handle );
986 Property::Map attributes;
987 DALI_TEST_CHECK( !handle.DoAction( "unknownAction", attributes ) );
992 int UtcDaliTypeRegistryPropertyRegistrationP(void)
994 TestApplication application;
995 TypeRegistry typeRegistry = TypeRegistry::Get();
997 // Check property count before property registration
998 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
999 DALI_TEST_CHECK( typeInfo );
1000 BaseHandle handle = typeInfo.CreateInstance();
1001 DALI_TEST_CHECK( handle );
1002 Actor customActor = Actor::DownCast( handle );
1003 DALI_TEST_CHECK( customActor );
1004 unsigned int initialPropertyCount( customActor.GetPropertyCount() );
1006 std::string propertyName( "prop1" );
1007 int propertyIndex( PROPERTY_REGISTRATION_START_INDEX );
1008 Property::Type propertyType( Property::BOOLEAN );
1009 PropertyRegistration property1( customType1, propertyName, propertyIndex, propertyType, &SetProperty, &GetProperty );
1011 // Check property count after registration
1012 unsigned int postRegistrationPropertyCount( customActor.GetPropertyCount() );
1013 DALI_TEST_EQUALS( initialPropertyCount + 1u, postRegistrationPropertyCount, TEST_LOCATION );
1015 // Add custom property and check property count
1016 customActor.RegisterProperty( "customProp1", true );
1017 unsigned int customPropertyCount( customActor.GetPropertyCount() );
1018 DALI_TEST_EQUALS( postRegistrationPropertyCount + 1u, customPropertyCount, TEST_LOCATION );
1020 // Set the property, ensure SetProperty called
1021 DALI_TEST_CHECK( !setPropertyCalled );
1022 customActor.SetProperty( propertyIndex, false );
1023 DALI_TEST_CHECK( setPropertyCalled );
1025 // Get the property, ensure GetProperty called
1026 DALI_TEST_CHECK( !getPropertyCalled );
1027 (void)customActor.GetProperty< bool >( propertyIndex );
1028 DALI_TEST_CHECK( getPropertyCalled );
1030 // Get the property using GetCurrentProperty and ensure GetProperty is called
1031 getPropertyCalled = false;
1032 DALI_TEST_CHECK( !getPropertyCalled );
1033 customActor.GetCurrentProperty< bool >( propertyIndex );
1034 DALI_TEST_CHECK( getPropertyCalled );
1036 // Check the property name
1037 DALI_TEST_EQUALS( customActor.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
1038 DALI_TEST_EQUALS( typeInfo.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
1040 // Check the property index
1041 DALI_TEST_EQUALS( customActor.GetPropertyIndex( propertyName ), propertyIndex, TEST_LOCATION );
1043 // Check the property type
1044 DALI_TEST_EQUALS( customActor.GetPropertyType( propertyIndex ), propertyType, TEST_LOCATION );
1046 // Check property count of type-info is 1
1047 Property::IndexContainer indices;
1048 typeInfo.GetPropertyIndices( indices );
1050 size_t typePropertyCount = typeInfo.GetPropertyCount();
1051 DALI_TEST_EQUALS( indices.Size(), Actor::New().GetPropertyCount() + 1u, TEST_LOCATION );
1052 DALI_TEST_EQUALS( indices.Size(), typePropertyCount, TEST_LOCATION );
1054 // Ensure indices returned from actor and customActor differ by two
1055 Actor actor = Actor::New();
1056 actor.GetPropertyIndices( indices );
1057 unsigned int actorIndices = indices.Size();
1058 customActor.GetPropertyIndices( indices );
1059 unsigned int customActorIndices = indices.Size();
1060 DALI_TEST_EQUALS( actorIndices + 2u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1064 int UtcDaliTypeRegistryPropertyRegistrationN(void)
1066 TestApplication application;
1067 TypeRegistry typeRegistry = TypeRegistry::Get();
1069 // Attempt to register a property type out-of-bounds index (less than)
1072 PropertyRegistration property1( customType1, "propName", PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN, &SetProperty, &GetProperty );
1073 tet_result( TET_FAIL );
1075 catch ( DaliException& e )
1077 DALI_TEST_ASSERT( e, "( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1080 // Attempt to register a property type out-of-bounds index (greater than)
1083 PropertyRegistration property1( customType1, "propName", PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN, &SetProperty, &GetProperty );
1084 tet_result( TET_FAIL );
1086 catch ( DaliException& e )
1088 DALI_TEST_ASSERT( e, "( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1094 int UtcDaliTypeRegistryAnimatablePropertyRegistrationP(void)
1096 TestApplication application;
1097 TypeRegistry typeRegistry = TypeRegistry::Get();
1099 // Check property count before property registration
1100 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1101 DALI_TEST_CHECK( typeInfo );
1102 BaseHandle handle = typeInfo.CreateInstance();
1103 DALI_TEST_CHECK( handle );
1104 Actor customActor = Actor::DownCast( handle );
1105 DALI_TEST_CHECK( customActor );
1106 application.GetScene().Add(customActor);
1108 unsigned int customPropertyCount( customActor.GetPropertyCount() );
1110 // Register animatable property
1111 std::string animatablePropertyName( "animatableProp1" );
1112 int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1113 Property::Type animatablePropertyType( Property::FLOAT );
1114 AnimatablePropertyRegistration animatableProperty( customType1, animatablePropertyName, animatablePropertyIndex, animatablePropertyType );
1116 // Check property count after registration
1117 DALI_TEST_EQUALS( customPropertyCount + 1u, customActor.GetPropertyCount(), TEST_LOCATION );
1119 // Set the animatable property value
1120 customActor.SetProperty( animatablePropertyIndex, 25.0f );
1122 // Render and notify
1123 application.SendNotification();
1124 application.Render();
1126 // Check the animatable property value
1127 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 25.f, TEST_LOCATION );
1129 // Check the animatable property name
1130 DALI_TEST_EQUALS( customActor.GetPropertyName( animatablePropertyIndex ), animatablePropertyName, TEST_LOCATION );
1132 // Check the animatable property index
1133 DALI_TEST_EQUALS( customActor.GetPropertyIndex( animatablePropertyName ), animatablePropertyIndex, TEST_LOCATION );
1135 // Check the animatable property type
1136 DALI_TEST_EQUALS( customActor.GetPropertyType( animatablePropertyIndex ), animatablePropertyType, TEST_LOCATION );
1138 // Check property count of type-info is 1
1139 Property::IndexContainer indices;
1140 typeInfo.GetPropertyIndices( indices );
1141 DALI_TEST_EQUALS( indices.Size(), customActor.GetPropertyCount(), TEST_LOCATION );
1143 // Ensure indices returned from actor and customActor differ by one
1144 Actor actor = Actor::New();
1145 actor.GetPropertyIndices( indices );
1146 unsigned int actorIndices = indices.Size();
1147 customActor.GetPropertyIndices( indices );
1148 unsigned int customActorIndices = indices.Size();
1149 DALI_TEST_EQUALS( actorIndices + 1u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1151 // check that the property is animatable
1152 Animation animation = Animation::New(0.2f);
1153 animation.AnimateTo( Property( customActor, animatablePropertyIndex ), 15.f, AlphaFunction::LINEAR );
1156 // Target value should change straight away
1157 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 15.0f, TEST_LOCATION );
1159 // Render and notify, animation play for 0.05 seconds
1160 application.SendNotification();
1161 application.Render(50);
1162 DALI_TEST_EQUALS( 0.25f, animation.GetCurrentProgress(), TEST_LOCATION );
1163 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 22.5f, TEST_LOCATION );
1165 // Render and notify, animation play for another 0.1 seconds
1166 application.SendNotification();
1167 application.Render(100);
1168 DALI_TEST_EQUALS( 0.75f, animation.GetCurrentProgress(), TEST_LOCATION );
1169 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 17.5f, TEST_LOCATION );
1174 int UtcDaliTypeRegistryAnimatablePropertyRegistrationN(void)
1176 TestApplication application;
1177 TypeRegistry typeRegistry = TypeRegistry::Get();
1179 // Attempt to register an animatable property type out-of-bounds index (less than)
1182 AnimatablePropertyRegistration property1( customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN );
1183 tet_result( TET_FAIL );
1185 catch ( DaliException& e )
1187 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1190 // Attempt to register an animatable property type out-of-bounds index (greater than)
1193 AnimatablePropertyRegistration property1( customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN );
1194 tet_result( TET_FAIL );
1196 catch ( DaliException& e )
1198 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1204 int UtcDaliTypeRegistryAnimatablePropertyRegistrationWithDefaultP(void)
1206 TestApplication application;
1207 TypeRegistry typeRegistry = TypeRegistry::Get();
1209 // Check property count before property registration
1210 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1211 DALI_TEST_CHECK( typeInfo );
1212 BaseHandle handle = typeInfo.CreateInstance();
1213 DALI_TEST_CHECK( handle );
1214 Actor customActor = Actor::DownCast( handle );
1215 DALI_TEST_CHECK( customActor );
1216 application.GetScene().Add(customActor);
1218 unsigned int customPropertyCount( customActor.GetPropertyCount() );
1220 // Register animatable property
1221 std::string animatablePropertyName( "animatableProp1" );
1222 int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1223 AnimatablePropertyRegistration animatableProperty1( customType1, animatablePropertyName, animatablePropertyIndex, 10.f );
1225 // Check property count after registration
1226 DALI_TEST_EQUALS( customPropertyCount + 1u, customActor.GetPropertyCount(), TEST_LOCATION );
1228 // Render and notify
1229 application.SendNotification();
1230 application.Render();
1232 // Check the animatable property value
1233 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 10.f, TEST_LOCATION );
1235 // Check the animatable property name
1236 DALI_TEST_EQUALS( customActor.GetPropertyName( animatablePropertyIndex ), animatablePropertyName, TEST_LOCATION );
1238 // Check the animatable property index
1239 DALI_TEST_EQUALS( customActor.GetPropertyIndex( animatablePropertyName ), animatablePropertyIndex, TEST_LOCATION );
1241 // Check the animatable property type
1242 DALI_TEST_EQUALS( customActor.GetPropertyType( animatablePropertyIndex ), Property::FLOAT, TEST_LOCATION );
1244 // Check property count of type-info
1245 Property::IndexContainer indices;
1246 typeInfo.GetPropertyIndices( indices );
1247 DALI_TEST_EQUALS( indices.Size(), customActor.GetPropertyCount(), TEST_LOCATION );
1249 // Ensure indices returned from actor and customActor differ by one
1250 Actor actor = Actor::New();
1251 actor.GetPropertyIndices( indices );
1252 unsigned int actorIndices = indices.Size();
1253 customActor.GetPropertyIndices( indices );
1254 unsigned int customActorIndices = indices.Size();
1255 DALI_TEST_EQUALS( actorIndices + 1u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1257 // check that the property is animatable
1258 Animation animation = Animation::New(0.2f);
1259 animation.AnimateTo( Property( customActor, animatablePropertyIndex ), 20.f, AlphaFunction::LINEAR );
1262 // Target value should change straight away
1263 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 20.0f, TEST_LOCATION );
1265 // Render and notify, animation play for 0.05 seconds
1266 application.SendNotification();
1267 application.Render(50);
1268 DALI_TEST_EQUALS( 0.25f, animation.GetCurrentProgress(), TEST_LOCATION );
1269 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 12.5f, TEST_LOCATION );
1271 // Render and notify, animation play for another 0.1 seconds
1272 application.SendNotification();
1273 application.Render(100);
1274 DALI_TEST_EQUALS( 0.75f, animation.GetCurrentProgress(), TEST_LOCATION );
1275 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 17.5f, TEST_LOCATION );
1280 int UtcDaliTypeRegistryAnimatablePropertyRegistrationWithDefaultN(void)
1282 TestApplication application;
1283 TypeRegistry typeRegistry = TypeRegistry::Get();
1285 // Attempt to register an animatable property type out-of-bounds index (less than)
1288 AnimatablePropertyRegistration property1( customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX - 1, false );
1289 tet_result( TET_FAIL );
1291 catch ( DaliException& e )
1293 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1296 // Attempt to register an animatable property type out-of-bounds index (greater than)
1299 AnimatablePropertyRegistration property1( customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX + 1, true );
1300 tet_result( TET_FAIL );
1302 catch ( DaliException& e )
1304 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1310 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationP(void)
1312 TestApplication application;
1313 TypeRegistry typeRegistry = TypeRegistry::Get();
1315 // Check property count before property registration
1316 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1317 DALI_TEST_CHECK( typeInfo );
1318 BaseHandle handle = typeInfo.CreateInstance();
1319 DALI_TEST_CHECK( handle );
1320 Actor customActor = Actor::DownCast( handle );
1321 DALI_TEST_CHECK( customActor );
1323 unsigned int customPropertyCount( customActor.GetPropertyCount() );
1325 // Register animatable property
1326 std::string animatablePropertyName( "animatableProp1" );
1327 int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1328 Property::Type animatablePropertyType( Property::VECTOR2 );
1329 AnimatablePropertyRegistration animatableProperty1( customType1, animatablePropertyName, animatablePropertyIndex, animatablePropertyType );
1331 // Check property count after registration
1332 DALI_TEST_EQUALS( customPropertyCount + 1u, customActor.GetPropertyCount(), TEST_LOCATION );
1334 // Set the animatable property value
1335 customActor.SetProperty( animatablePropertyIndex, Vector2(25.0f, 50.0f) );
1337 // Render and notify
1338 application.SendNotification();
1339 application.Render();
1341 // Check the animatable property value
1342 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( animatablePropertyIndex ), Vector2(25.0f, 50.0f), TEST_LOCATION );
1344 // Check the animatable property name
1345 DALI_TEST_EQUALS( customActor.GetPropertyName( animatablePropertyIndex ), animatablePropertyName, TEST_LOCATION );
1347 // Check the animatable property index
1348 DALI_TEST_EQUALS( customActor.GetPropertyIndex( animatablePropertyName ), animatablePropertyIndex, TEST_LOCATION );
1350 // Check the animatable property type
1351 DALI_TEST_EQUALS( customActor.GetPropertyType( animatablePropertyIndex ), animatablePropertyType, TEST_LOCATION );
1353 // Check property count of type-info
1354 Property::IndexContainer indices;
1355 typeInfo.GetPropertyIndices( indices );
1356 DALI_TEST_EQUALS( indices.Size(), customActor.GetPropertyCount(), TEST_LOCATION );
1358 // Register animatable property components
1359 std::string animatablePropertyComponentName1( "animatableProp1X" );
1360 int animatablePropertyComponentIndex1( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1 );
1361 AnimatablePropertyComponentRegistration animatablePropertyComponent1( customType1, animatablePropertyComponentName1, animatablePropertyComponentIndex1, animatablePropertyIndex, 0 );
1363 std::string animatablePropertyComponentName2( "animatableProp1Y" );
1364 int animatablePropertyComponentIndex2( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2 );
1365 AnimatablePropertyComponentRegistration animatablePropertyComponent2( customType1, animatablePropertyComponentName2, animatablePropertyComponentIndex2, animatablePropertyIndex, 1 );
1367 // Check property count after registration
1368 DALI_TEST_EQUALS( customPropertyCount + 3u, customActor.GetPropertyCount(), TEST_LOCATION );
1370 // Check the animatable property component value
1371 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex1 ), 25.0f, TEST_LOCATION );
1372 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex2 ), 50.0f, TEST_LOCATION );
1374 // Set the animatable property component value
1375 customActor.SetProperty( animatablePropertyComponentIndex1, 150.0f );
1377 // Render and notify
1378 application.SendNotification();
1379 application.Render();
1381 // Check the animatable property value
1382 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector2 >( animatablePropertyIndex ), Vector2(150.0f, 50.0f), TEST_LOCATION );
1383 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex1 ), 150.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( animatablePropertyComponentIndex2, 225.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, 225.0f), TEST_LOCATION );
1395 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex1 ), 150.0f, TEST_LOCATION );
1396 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex2 ), 225.0f, TEST_LOCATION );
1398 // Ensure indices returned from actor and customActor differ by three
1399 Actor actor = Actor::New();
1400 actor.GetPropertyIndices( indices );
1401 unsigned int actorIndices = indices.Size();
1402 customActor.GetPropertyIndices( indices );
1403 unsigned int customActorIndices = indices.Size();
1404 DALI_TEST_EQUALS( actorIndices + 3u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1406 // Attempt to animate component property, it should not crash
1407 Animation animation = Animation::New( 1.0f );
1408 animation.AnimateTo( Property( customActor, animatablePropertyComponentIndex1 ), 200.0f );
1411 // Check the property value
1412 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( animatablePropertyIndex ), Vector2(200.0f, 225.0f), TEST_LOCATION );
1413 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex1 ), 200.0f, TEST_LOCATION );
1414 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex2 ), 225.0f, TEST_LOCATION );
1419 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationVector2AnimateByP(void)
1421 TestApplication application;
1422 TypeRegistry typeRegistry = TypeRegistry::Get();
1424 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1425 DALI_TEST_CHECK( typeInfo );
1426 BaseHandle handle = typeInfo.CreateInstance();
1427 DALI_TEST_CHECK( handle );
1428 Actor customActor = Actor::DownCast( handle );
1429 DALI_TEST_CHECK( customActor );
1431 const unsigned int index = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX;
1432 const unsigned int xComponentIndex = index + 1;
1433 const unsigned int yComponentIndex = index + 2;
1434 const Vector2 initialValue( 20.0f, 40.0f );
1436 // Register animatable property & its components
1437 AnimatablePropertyRegistration animatableProperty1( customType1, "animatableProp1", index, initialValue );
1438 AnimatablePropertyComponentRegistration animatablePropertyComponent1( customType1, "animatableProp1X", xComponentIndex, index, 0 );
1439 AnimatablePropertyComponentRegistration animatablePropertyComponent2( customType1, "animatableProp1Y", yComponentIndex, index, 1 );
1441 // Check the animatable property value
1442 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( index ), initialValue, TEST_LOCATION );
1443 DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
1444 DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
1446 // Render and notify
1447 application.SendNotification();
1448 application.Render();
1450 // Check the animatable property current value
1451 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector2 >( index ), initialValue, TEST_LOCATION );
1452 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
1453 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
1456 const Vector2 targetValue( 45.0f, 53.0f );
1457 const Vector2 relativeValue( targetValue - initialValue );
1459 Animation animation = Animation::New( 1.0f );
1460 animation.AnimateBy( Property( customActor, xComponentIndex ), relativeValue.x );
1461 animation.AnimateBy( Property( customActor, yComponentIndex ), relativeValue.y );
1464 // Target values should change straight away
1465 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
1466 DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), targetValue.x, TEST_LOCATION );
1467 DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), targetValue.y, TEST_LOCATION );
1472 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationVector3AnimateByP(void)
1474 TestApplication application;
1475 TypeRegistry typeRegistry = TypeRegistry::Get();
1477 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1478 DALI_TEST_CHECK( typeInfo );
1479 BaseHandle handle = typeInfo.CreateInstance();
1480 DALI_TEST_CHECK( handle );
1481 Actor customActor = Actor::DownCast( handle );
1482 DALI_TEST_CHECK( customActor );
1484 const unsigned int index = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX;
1485 const unsigned int xComponentIndex = index + 1;
1486 const unsigned int yComponentIndex = index + 2;
1487 const unsigned int zComponentIndex = index + 3;
1488 const Vector3 initialValue( 20.0f, 40.0f, 50.0f );
1490 // Register animatable property & its components
1491 AnimatablePropertyRegistration animatableProperty1( customType1, "animatableProp1", index, initialValue );
1492 AnimatablePropertyComponentRegistration animatablePropertyComponent1( customType1, "animatableProp1X", xComponentIndex, index, 0 );
1493 AnimatablePropertyComponentRegistration animatablePropertyComponent2( customType1, "animatableProp1Y", yComponentIndex, index, 1 );
1494 AnimatablePropertyComponentRegistration animatablePropertyComponent3( customType1, "animatableProp1Z", zComponentIndex, index, 2 );
1496 // Check the animatable property value
1497 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( index ), initialValue, TEST_LOCATION );
1498 DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
1499 DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
1500 DALI_TEST_EQUALS( customActor.GetProperty< float >( zComponentIndex ), initialValue.z, TEST_LOCATION );
1502 // Render and notify
1503 application.SendNotification();
1504 application.Render();
1506 // Check the animatable property current value
1507 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector3 >( index ), initialValue, TEST_LOCATION );
1508 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
1509 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
1510 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( zComponentIndex ), initialValue.z, TEST_LOCATION );
1513 const Vector3 targetValue( 45.0f, 53.0f, 25.0f );
1514 const Vector3 relativeValue( targetValue - initialValue );
1516 Animation animation = Animation::New( 1.0f );
1517 animation.AnimateBy( Property( customActor, xComponentIndex ), relativeValue.x );
1518 animation.AnimateBy( Property( customActor, yComponentIndex ), relativeValue.y );
1519 animation.AnimateBy( Property( customActor, zComponentIndex ), relativeValue.z );
1522 // Target values should change straight away
1523 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
1524 DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), targetValue.x, TEST_LOCATION );
1525 DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), targetValue.y, TEST_LOCATION );
1526 DALI_TEST_EQUALS( customActor.GetProperty< float >( zComponentIndex ), targetValue.z, TEST_LOCATION );
1531 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationVector4AnimateByP(void)
1533 TestApplication application;
1534 TypeRegistry typeRegistry = TypeRegistry::Get();
1536 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1537 DALI_TEST_CHECK( typeInfo );
1538 BaseHandle handle = typeInfo.CreateInstance();
1539 DALI_TEST_CHECK( handle );
1540 Actor customActor = Actor::DownCast( handle );
1541 DALI_TEST_CHECK( customActor );
1543 const unsigned int index = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX;
1544 const unsigned int xComponentIndex = index + 1;
1545 const unsigned int yComponentIndex = index + 2;
1546 const unsigned int zComponentIndex = index + 3;
1547 const unsigned int wComponentIndex = index + 4;
1548 const Vector4 initialValue( 20.0f, 40.0f, 50.0f, 60.0f );
1550 // Register animatable property & its components
1551 AnimatablePropertyRegistration animatableProperty1( customType1, "animatableProp1", index, initialValue );
1552 AnimatablePropertyComponentRegistration animatablePropertyComponent1( customType1, "animatableProp1X", xComponentIndex, index, 0 );
1553 AnimatablePropertyComponentRegistration animatablePropertyComponent2( customType1, "animatableProp1Y", yComponentIndex, index, 1 );
1554 AnimatablePropertyComponentRegistration animatablePropertyComponent3( customType1, "animatableProp1Z", zComponentIndex, index, 2 );
1555 AnimatablePropertyComponentRegistration animatablePropertyComponent4( customType1, "animatableProp1W", wComponentIndex, index, 3 );
1557 // Check the animatable property value
1558 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( index ), initialValue, TEST_LOCATION );
1559 DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
1560 DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
1561 DALI_TEST_EQUALS( customActor.GetProperty< float >( zComponentIndex ), initialValue.z, TEST_LOCATION );
1562 DALI_TEST_EQUALS( customActor.GetProperty< float >( wComponentIndex ), initialValue.w, TEST_LOCATION );
1564 // Render and notify
1565 application.SendNotification();
1566 application.Render();
1568 // Check the animatable property current value
1569 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector4 >( index ), initialValue, TEST_LOCATION );
1570 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
1571 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
1572 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( zComponentIndex ), initialValue.z, TEST_LOCATION );
1573 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( wComponentIndex ), initialValue.w, TEST_LOCATION );
1576 const Vector4 targetValue( 45.0f, 53.0f, 25.0f, 13.0f );
1577 const Vector4 relativeValue( targetValue - initialValue );
1579 Animation animation = Animation::New( 1.0f );
1580 animation.AnimateBy( Property( customActor, xComponentIndex ), relativeValue.x );
1581 animation.AnimateBy( Property( customActor, yComponentIndex ), relativeValue.y );
1582 animation.AnimateBy( Property( customActor, zComponentIndex ), relativeValue.z );
1583 animation.AnimateBy( Property( customActor, wComponentIndex ), relativeValue.w );
1586 // Target values should change straight away
1587 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
1588 DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), targetValue.x, TEST_LOCATION );
1589 DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), targetValue.y, TEST_LOCATION );
1590 DALI_TEST_EQUALS( customActor.GetProperty< float >( zComponentIndex ), targetValue.z, TEST_LOCATION );
1591 DALI_TEST_EQUALS( customActor.GetProperty< float >( wComponentIndex ), targetValue.w, TEST_LOCATION );
1596 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationN(void)
1598 TestApplication application;
1599 TypeRegistry typeRegistry = TypeRegistry::Get();
1601 // Register animatable property with the type of Vector2
1602 int animatablePropertyIndex1( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1603 AnimatablePropertyRegistration animatableProperty1( customType1, "animatableProp1", animatablePropertyIndex1, Property::VECTOR2 );
1605 // Attempt to register an animatable property component out-of-bounds index (less than)
1608 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp1X", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX - 1, animatablePropertyIndex1, 0 );
1609 tet_result( TET_FAIL );
1611 catch ( DaliException& e )
1613 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1616 // Attempt to register an animatable property component out-of-bounds index (greater than)
1619 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp1X", ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX + 1, animatablePropertyIndex1, 0 );
1620 tet_result( TET_FAIL );
1622 catch ( DaliException& e )
1624 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1627 // Register an animatable property component
1628 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp1X", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1, animatablePropertyIndex1, 0 );
1630 // Attempt to register another animatable property component with the same component index
1633 AnimatablePropertyComponentRegistration propertyComponent2( customType1, "animatableProp1Y", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2, animatablePropertyIndex1, 0 );
1634 tet_result( TET_FAIL );
1636 catch ( DaliException& e )
1638 DALI_TEST_ASSERT( e, "Property component already registered", TEST_LOCATION );
1641 // Register animatable property with the type of boolean
1642 int animatablePropertyIndex2( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2 );
1643 AnimatablePropertyRegistration animatableProperty2( customType1, "animatableProp2", animatablePropertyIndex2, Property::BOOLEAN );
1645 // Attempt to register an animatable property component for the above property with boolean type
1648 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp2X", animatablePropertyIndex2 + 1, animatablePropertyIndex2, 0 );
1649 tet_result( TET_FAIL );
1651 catch ( DaliException& e )
1653 DALI_TEST_ASSERT( e, "Base property does not support component", TEST_LOCATION );
1659 int UtcDaliTypeRegistryChildPropertyRegistrationP(void)
1661 TestApplication application;
1662 TypeRegistry typeRegistry = TypeRegistry::Get();
1664 // Check property count before property registration
1665 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1666 DALI_TEST_CHECK( typeInfo );
1667 BaseHandle handle = typeInfo.CreateInstance();
1668 DALI_TEST_CHECK( handle );
1669 Actor customActor = Actor::DownCast( handle );
1670 DALI_TEST_CHECK( customActor );
1671 unsigned int initialPropertyCount( customActor.GetPropertyCount() );
1673 // Register child properties to the parent
1674 std::string propertyName( "childProp1" );
1675 int propertyIndex( CHILD_PROPERTY_REGISTRATION_START_INDEX );
1676 Property::Type propertyType( Property::BOOLEAN );
1677 ChildPropertyRegistration childProperty1( customType1, propertyName, propertyIndex, propertyType );
1679 std::string propertyName2( "childProp2" );
1680 int propertyIndex2( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1 );
1681 Property::Type propertyType2( Property::INTEGER );
1682 ChildPropertyRegistration childProperty2( customType1, propertyName2, propertyIndex2, propertyType2 );
1684 std::string propertyName3( "childProp3" );
1685 int propertyIndex3( CHILD_PROPERTY_REGISTRATION_START_INDEX + 2 );
1686 Property::Type propertyType3( Property::FLOAT );
1687 ChildPropertyRegistration childProperty3( customType1, propertyName3, propertyIndex3, propertyType3 );
1689 std::string propertyName4( "childProp4" );
1690 int propertyIndex4( CHILD_PROPERTY_REGISTRATION_START_INDEX + 3 );
1691 Property::Type propertyType4( Property::INTEGER );
1692 ChildPropertyRegistration childProperty4( customType1, propertyName4, propertyIndex4, propertyType4 );
1694 // Check property count are not changed because the child properties will not be created for the parent
1695 DALI_TEST_EQUALS( initialPropertyCount, customActor.GetPropertyCount(), TEST_LOCATION );
1697 // check the child property type
1698 Internal::TypeInfo& typeInfoImpl = GetImplementation( typeInfo );
1699 Property::Type type = typeInfoImpl.GetChildPropertyType( typeInfoImpl.GetChildPropertyIndex("childProp4") );
1700 DALI_TEST_EQUALS( type, Property::INTEGER, TEST_LOCATION );
1702 std::string unRegisteredChildName( typeInfoImpl.GetChildPropertyName( CHILD_PROPERTY_REGISTRATION_START_INDEX + 4 ) );
1703 DALI_TEST_EQUALS( unRegisteredChildName, "", TEST_LOCATION );
1705 // Create a child actor
1706 Actor childActor = Actor::New();
1707 DALI_TEST_CHECK( childActor );
1708 unsigned int initialChildActorPropertyCount( childActor.GetPropertyCount() );
1710 // The type of child properties should be Property::None as the child hasn't registered any child property yet.
1711 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex ), Property::NONE, TEST_LOCATION );
1712 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex2 ), Property::NONE, TEST_LOCATION );
1713 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex3 ), Property::NONE, TEST_LOCATION );
1714 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex4 ), Property::NONE, TEST_LOCATION );
1716 // Set the value for the first child property when the child actor doesn't have a parent yet
1717 childActor.SetProperty(propertyIndex, true);
1719 // Check that the first child property is dynamically created
1720 DALI_TEST_EQUALS( initialChildActorPropertyCount + 1u, childActor.GetPropertyCount(), TEST_LOCATION );
1722 // Check the first child property value
1723 DALI_TEST_EQUALS( childActor.GetProperty< bool >( propertyIndex ), true, TEST_LOCATION );
1725 // Check the first child property type
1726 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex ), propertyType, TEST_LOCATION );
1728 // Check that the first child property have no name, as it doesn't have a parent yet.
1729 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex ), "", TEST_LOCATION );
1731 // Check that the first property can't be accessed through its name, as it doesn't have a parent yet.
1732 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName ), Property::INVALID_INDEX, TEST_LOCATION );
1734 // Create a custom property for the child with the same name as the second child property registered to the parent
1735 Property::Index customPropertyIndex = childActor.RegisterProperty(propertyName2, 100, Property::READ_WRITE);
1737 // Check that the custom property is created
1738 DALI_TEST_EQUALS( initialChildActorPropertyCount + 2u, childActor.GetPropertyCount(), TEST_LOCATION );
1740 // Check the property value
1741 DALI_TEST_EQUALS( childActor.GetProperty< int >( customPropertyIndex ), 100, TEST_LOCATION );
1743 // Check the property index
1744 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName2 ), customPropertyIndex, TEST_LOCATION );
1746 // Check the property type
1747 DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex ), propertyType2, TEST_LOCATION );
1749 // Check the property name
1750 DALI_TEST_EQUALS( childActor.GetPropertyName( customPropertyIndex ), propertyName2, TEST_LOCATION );
1752 // Now add the child actor to the parent
1753 customActor.Add( childActor );
1755 // Check that the first child property now has the correct name as previously registered to the parent
1756 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
1758 // Check that the child property index for the first child property can now be retrieved through its child property name
1759 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName ), propertyIndex, TEST_LOCATION );
1761 // Check that the second child property now has the correct index as previously registered to the parent
1762 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex2 ), propertyName2, TEST_LOCATION );
1764 // Check that the second child property can be accessed through both its custom property index and its child property index
1765 DALI_TEST_EQUALS( childActor.GetProperty< int >( customPropertyIndex ), 100, TEST_LOCATION );
1766 DALI_TEST_EQUALS( childActor.GetProperty< int >( propertyIndex2 ), 100, TEST_LOCATION );
1767 DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex ), propertyType2, TEST_LOCATION );
1768 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex2 ), propertyType2, TEST_LOCATION );
1770 // Check that the child property index for the second child property can now be retrieved through its child property name
1771 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName2 ), propertyIndex2, TEST_LOCATION );
1773 // Set the value for the third child property when the child actor is already added to the parent
1774 childActor.SetProperty(propertyIndex3, 0.15f);
1776 // Check that the third child property is dynamically created
1777 DALI_TEST_EQUALS( initialChildActorPropertyCount + 3u, childActor.GetPropertyCount(), TEST_LOCATION );
1779 // Check the third child property value
1780 DALI_TEST_EQUALS( childActor.GetProperty< float >( propertyIndex3 ), 0.15f, TEST_LOCATION );
1782 // Check the third child property type
1783 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex3 ), propertyType3, TEST_LOCATION );
1785 // Check the third child property name
1786 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex3 ), propertyName3, TEST_LOCATION );
1788 // Check the third child property index.
1789 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName3 ), propertyIndex3, TEST_LOCATION );
1791 // Create a custom property for the child with the same name as the fourth child property registered to the parent
1792 Property::Index customPropertyIndex2 = childActor.RegisterProperty(propertyName4, 20, Property::READ_WRITE);
1794 // Check that the custom property is created
1795 DALI_TEST_EQUALS( initialChildActorPropertyCount + 4u, childActor.GetPropertyCount(), TEST_LOCATION );
1797 // Check the fourth child property value
1798 DALI_TEST_EQUALS( childActor.GetProperty< int >( propertyIndex4 ), 20, TEST_LOCATION );
1799 DALI_TEST_EQUALS( childActor.GetProperty< int >( customPropertyIndex2 ), 20, TEST_LOCATION );
1801 // Check the fourth child property type
1802 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex4 ), propertyType4, TEST_LOCATION );
1803 DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex2 ), propertyType4, TEST_LOCATION );
1805 // Check the fourth child property name
1806 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex4 ), propertyName4, TEST_LOCATION );
1807 DALI_TEST_EQUALS( childActor.GetPropertyName( customPropertyIndex2 ), propertyName4, TEST_LOCATION );
1809 // Check the fourth child property index.
1810 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName4 ), propertyIndex4, TEST_LOCATION );
1812 // Now create another parent actor with different child properties registered
1813 TypeInfo typeInfo2 = typeRegistry.GetTypeInfo( "MyNamedActor" );
1814 DALI_TEST_CHECK( typeInfo2 );
1815 BaseHandle handle2 = typeInfo2.CreateInstance();
1816 DALI_TEST_CHECK( handle2 );
1817 Actor customActor2 = Actor::DownCast( handle2 );
1818 DALI_TEST_CHECK( customActor2 );
1820 // Register child properties to the new parent
1821 std::string newPropertyName( "newChildProp" );
1822 int newPropertyIndex( CHILD_PROPERTY_REGISTRATION_START_INDEX ); // The same index as the first child property "childProp1" in the old parent
1823 Property::Type newPropertyType( Property::VECTOR2 );
1824 ChildPropertyRegistration newChildProperty( namedActorType, newPropertyName, newPropertyIndex, newPropertyType );
1826 std::string newPropertyName2( "childProp3" ); // The same name as the third child property in the old parent
1827 int newPropertyIndex2( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1 ); // The same index as the second child property "childProp2" in the old parent
1828 Property::Type newPropertyType2( Property::FLOAT ); // The same type as the third child property in the old parent
1829 ChildPropertyRegistration newChildProperty2( namedActorType, newPropertyName2, newPropertyIndex2, newPropertyType2 );
1831 // Now move the child actor to the new parent
1832 customActor2.Add( childActor );
1834 // "childProp1" is not a valid child property supported by the new parent, so nothing changed
1835 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex ), propertyType, TEST_LOCATION );
1836 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
1837 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName ), propertyIndex, TEST_LOCATION );
1839 // "childProp3" is a valid child property supported by the new parent
1840 // So it should get its new child property index and should just work
1841 DALI_TEST_EQUALS( childActor.GetPropertyType( newPropertyIndex2 ), newPropertyType2, TEST_LOCATION );
1842 DALI_TEST_EQUALS( childActor.GetPropertyName( newPropertyIndex2 ), newPropertyName2, TEST_LOCATION );
1843 DALI_TEST_EQUALS( childActor.GetPropertyIndex( newPropertyName2 ), newPropertyIndex2, TEST_LOCATION );
1844 DALI_TEST_EQUALS( childActor.GetProperty< float >( newPropertyIndex2 ), 0.15f, TEST_LOCATION );
1846 // Now register a custom property called "newChildProp"
1847 Property::Index customPropertyIndex3 = childActor.RegisterProperty("newChildProp", Vector2( 10.0f, 10.0f ), Property::READ_WRITE);
1849 // Check that the custom property is created
1850 DALI_TEST_EQUALS( initialChildActorPropertyCount + 5u, childActor.GetPropertyCount(), TEST_LOCATION );
1852 // This is a valid child property registered to the new parent
1853 // So should be able to access it through both its custom property index and its registered child property index
1854 DALI_TEST_EQUALS( childActor.GetPropertyType( newPropertyIndex ), newPropertyType, TEST_LOCATION );
1855 DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex3 ), newPropertyType, TEST_LOCATION );
1856 DALI_TEST_EQUALS( childActor.GetPropertyName( newPropertyIndex ), newPropertyName, TEST_LOCATION ); // This should return the new name, although the child property index remains the same
1857 DALI_TEST_EQUALS( childActor.GetPropertyName( customPropertyIndex3 ), newPropertyName, TEST_LOCATION );
1858 DALI_TEST_EQUALS( childActor.GetProperty< Vector2 >( newPropertyIndex ), Vector2( 10.0f, 10.0f ), TEST_LOCATION );
1859 DALI_TEST_EQUALS( childActor.GetProperty< Vector2 >( customPropertyIndex3 ), Vector2( 10.0f, 10.0f ), TEST_LOCATION );
1861 // Should return the child property index by given its name
1862 DALI_TEST_EQUALS( childActor.GetPropertyIndex( newPropertyName ), newPropertyIndex, TEST_LOCATION );
1868 int UtcDaliTypeRegistryChildPropertyRegistrationN(void)
1870 TestApplication application;
1871 TypeRegistry typeRegistry = TypeRegistry::Get();
1873 // Attempt to register a child property type out-of-bounds index (less than)
1876 ChildPropertyRegistration property1( customType1, "propName", CHILD_PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN );
1877 tet_result( TET_FAIL );
1879 catch ( DaliException& e )
1881 DALI_TEST_ASSERT( e, "( index >= CHILD_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1884 // Attempt to register a child property type out-of-bounds index (greater than)
1887 ChildPropertyRegistration property1( customType1, "propName", CHILD_PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN );
1888 tet_result( TET_FAIL );
1890 catch ( DaliException& e )
1892 DALI_TEST_ASSERT( e, "( index >= CHILD_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1899 /*******************************************************************************
1901 * Action through the base handle
1903 ******************************************************************************/
1904 int UtcDaliTypeRegistryActionViaBaseHandle(void)
1906 TestApplication application;
1910 type = TypeRegistry::Get().GetTypeInfo( "Actor" );
1911 DALI_TEST_CHECK( type );
1913 BaseHandle hdl = type.CreateInstance();
1914 DALI_TEST_CHECK( hdl );
1916 Actor a = Actor::DownCast(hdl);
1917 DALI_TEST_CHECK( a );
1919 a.SetProperty( Actor::Property::VISIBLE,false);
1921 application.SendNotification();
1922 application.Render(0);
1923 DALI_TEST_CHECK(!a.GetCurrentProperty< bool >( Actor::Property::VISIBLE ));
1925 Property::Map attributes;
1927 DALI_TEST_CHECK(hdl.DoAction("show", attributes));
1929 application.SendNotification();
1930 application.Render(0);
1931 DALI_TEST_CHECK(a.GetCurrentProperty< bool >( Actor::Property::VISIBLE ));
1933 DALI_TEST_CHECK(!hdl.DoAction("unknownAction", attributes));
1937 int UtcDaliPropertyRegistrationFunctions(void)
1939 TestApplication application;
1940 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 10;
1942 // Attempt to register a property without a setter
1945 PropertyRegistration property1( customType1, "propName", propertyIndex++, Property::BOOLEAN, NULL, &GetProperty );
1946 tet_result( TET_PASS );
1948 catch ( DaliException& e )
1950 tet_result( TET_FAIL );
1953 // Attempt to register a property without a getter
1956 PropertyRegistration property1( customType1, "propName", propertyIndex++, Property::BOOLEAN, NULL, NULL );
1957 tet_result( TET_FAIL );
1959 catch ( DaliException& e )
1961 DALI_TEST_ASSERT( e, "! \"GetProperty", TEST_LOCATION );
1966 int UtcDaliPropertyRegistrationAddSameIndex(void)
1968 TestApplication application;
1969 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 100;
1971 // Add one property with a valid property index
1972 PropertyRegistration property1( customType1, "propName", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
1974 // Attempt to add another property with the same index
1977 PropertyRegistration property2( customType1, "propName2", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
1979 catch ( DaliException& e )
1981 DALI_TEST_ASSERT( e, "! \"Property index already added", TEST_LOCATION );
1984 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 100;
1986 // Add one property with a valid property index
1987 AnimatablePropertyRegistration property3( customType1, "animPropName", animatablePropertyIndex, Property::BOOLEAN );
1989 // Attempt to add another property with the same index
1992 AnimatablePropertyRegistration property4( customType1, "animPropName2", animatablePropertyIndex, Property::BOOLEAN );
1994 catch ( DaliException& e )
1996 DALI_TEST_ASSERT( e, "! \"Property index already added", TEST_LOCATION );
2001 int UtcDaliPropertyRegistrationPropertyWritableP(void)
2003 TestApplication application;
2004 int propertyIndex1 = PROPERTY_REGISTRATION_START_INDEX + 200;
2005 int propertyIndex2 = PROPERTY_REGISTRATION_START_INDEX + 201;
2007 // Add two properties, one with SetProperty, one without
2008 PropertyRegistration property1( customType1, "propNameReadwrite", propertyIndex1, Property::BOOLEAN, &SetProperty, &GetProperty );
2009 PropertyRegistration property2( customType1, "propNameReadonly", propertyIndex2, Property::BOOLEAN, NULL, &GetProperty );
2011 // Create custom-actor
2012 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
2013 DALI_TEST_CHECK( typeInfo );
2014 BaseHandle handle = typeInfo.CreateInstance();
2015 DALI_TEST_CHECK( handle );
2016 Actor customActor = Actor::DownCast( handle );
2017 DALI_TEST_CHECK( customActor );
2019 // Check whether properties are writable
2020 DALI_TEST_CHECK( customActor.IsPropertyWritable( propertyIndex1 ) );
2021 DALI_TEST_CHECK( ! customActor.IsPropertyWritable( propertyIndex2 ) );
2024 // Check the property is writable in the type registry
2025 Internal::TypeInfo& typeInfoImpl = GetImplementation( typeInfo );
2027 DALI_TEST_EQUALS( typeInfoImpl.IsPropertyWritable( propertyIndex1 ), true, TEST_LOCATION );
2032 int UtcDaliPropertyRegistrationPropertyWritableN(void)
2034 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
2035 Internal::TypeInfo& typeInfoImpl = GetImplementation( typeInfo );
2037 DALI_TEST_EQUALS( typeInfoImpl.IsPropertyWritable( Actor::Property::COLOR), true, TEST_LOCATION );
2042 int UtcDaliPropertyRegistrationPropertyAnimatable(void)
2044 TestApplication application;
2045 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 400;
2046 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 400;
2048 // These properties are not animatable
2049 PropertyRegistration property1( customType1, "propName", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
2051 // These properties are animatable
2052 AnimatablePropertyRegistration property2( customType1, "animPropName", animatablePropertyIndex, Property::BOOLEAN );
2054 // Create custom-actor
2055 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
2056 DALI_TEST_CHECK( typeInfo );
2057 BaseHandle handle = typeInfo.CreateInstance();
2058 DALI_TEST_CHECK( handle );
2059 Actor customActor = Actor::DownCast( handle );
2060 DALI_TEST_CHECK( customActor );
2062 // Check if animatable
2063 DALI_TEST_CHECK( ! customActor.IsPropertyAnimatable( propertyIndex ) );
2064 DALI_TEST_CHECK( customActor.IsPropertyAnimatable( animatablePropertyIndex ) );
2066 // Create another instance of custom-actor
2067 BaseHandle handle2 = typeInfo.CreateInstance();
2068 DALI_TEST_CHECK( handle2 );
2069 Actor customActor2 = Actor::DownCast( handle2 );
2070 DALI_TEST_CHECK( customActor2 );
2072 // Check if animatable
2073 DALI_TEST_CHECK( ! customActor2.IsPropertyAnimatable( propertyIndex ) );
2074 DALI_TEST_CHECK( customActor2.IsPropertyAnimatable( animatablePropertyIndex ) );
2078 int UtcDaliPropertyRegistrationUnregisteredGetAndSet(void)
2080 TestApplication application;
2081 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 2000;
2082 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2000;
2084 // Create custom-actor
2085 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
2086 DALI_TEST_CHECK( typeInfo );
2087 BaseHandle handle = typeInfo.CreateInstance();
2088 DALI_TEST_CHECK( handle );
2089 Actor customActor = Actor::DownCast( handle );
2090 DALI_TEST_CHECK( customActor );
2092 // Try to set an index that hasn't been registered, this is a no-op for now, to be fixed in future
2093 customActor.SetProperty( propertyIndex, true );
2094 // DALI_TEST_EQUALS( true, customActor.GetProperty( propertyIndex ).Get<bool>(), TEST_LOCATION);
2096 // Try to set an index that hasn't been registered
2097 customActor.SetProperty( animatablePropertyIndex, true );
2098 DALI_TEST_EQUALS( true, customActor.GetProperty( animatablePropertyIndex ).Get<bool>(), TEST_LOCATION);
2104 int UtcDaliLongPressGestureDetectorTypeRegistry(void)
2106 TestApplication application;
2108 Actor actor = Actor::New();
2109 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
2110 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
2111 application.GetScene().Add(actor);
2115 type = TypeRegistry::Get().GetTypeInfo( "LongPressGestureDetector" );
2116 DALI_TEST_CHECK( type );
2117 BaseHandle handle = type.CreateInstance();
2118 DALI_TEST_CHECK( handle );
2119 LongPressGestureDetector detector = LongPressGestureDetector::DownCast( handle );
2120 DALI_TEST_CHECK( detector );
2122 // Attach actor to detector
2124 GestureReceivedFunctor functor( data );
2125 detector.Attach(actor);
2127 // Connect to signal through type
2128 handle.ConnectSignal( &application, "longPressDetected", functor );
2130 // Render and notify
2131 application.SendNotification();
2132 application.Render();
2135 TestGenerateLongPress( application, 50.0f, 10.0f );
2136 TestEndLongPress( application, 50.0f, 10.0f );
2138 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2142 int UtcDaliPanGestureDetectorTypeRegistry(void)
2144 TestApplication application;
2146 Actor actor = Actor::New();
2147 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
2148 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
2149 application.GetScene().Add(actor);
2153 type = TypeRegistry::Get().GetTypeInfo( "PanGestureDetector" );
2154 DALI_TEST_CHECK( type );
2155 BaseHandle handle = type.CreateInstance();
2156 DALI_TEST_CHECK( handle );
2157 PanGestureDetector detector = PanGestureDetector::DownCast( handle );
2158 DALI_TEST_CHECK( detector );
2160 // Attach actor to detector
2162 GestureReceivedFunctor functor( data );
2163 detector.Attach(actor);
2165 // Connect to signal through type
2166 handle.ConnectSignal( &application, "panDetected", functor );
2168 // Render and notify
2169 application.SendNotification();
2170 application.Render();
2173 TestGenerateMiniPan( application );
2174 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2178 int UtcDaliPinchGestureDetectorTypeRegistry(void)
2180 TestApplication application;
2182 Actor actor = Actor::New();
2183 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
2184 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
2185 application.GetScene().Add(actor);
2189 type = TypeRegistry::Get().GetTypeInfo( "PinchGestureDetector" );
2190 DALI_TEST_CHECK( type );
2191 BaseHandle handle = type.CreateInstance();
2192 DALI_TEST_CHECK( handle );
2193 PinchGestureDetector detector = PinchGestureDetector::DownCast( handle );
2194 DALI_TEST_CHECK( detector );
2196 // Attach actor to detector
2198 GestureReceivedFunctor functor( data );
2199 detector.Attach(actor);
2201 // Connect to signal through type
2202 handle.ConnectSignal( &application, "pinchDetected", functor );
2204 // Render and notify
2205 application.SendNotification();
2206 application.Render();
2209 TestGeneratePinch( application );
2211 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2215 int UtcDaliRotationGestureDetectorTypeRegistry(void)
2217 TestApplication application;
2219 Actor actor = Actor::New();
2220 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
2221 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
2222 application.GetScene().Add(actor);
2226 type = TypeRegistry::Get().GetTypeInfo( "RotationGestureDetector" );
2227 DALI_TEST_CHECK( type );
2228 BaseHandle handle = type.CreateInstance();
2229 DALI_TEST_CHECK( handle );
2230 RotationGestureDetector detector = RotationGestureDetector::DownCast( handle );
2231 DALI_TEST_CHECK( detector );
2233 // Attach actor to detector
2235 GestureReceivedFunctor functor( data );
2236 detector.Attach(actor);
2238 // Connect to signal through type
2239 handle.ConnectSignal( &application, "rotationDetected", functor );
2241 // Render and notify
2242 application.SendNotification();
2243 application.Render();
2246 TestGenerateRotation( application );
2248 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2252 int UtcDaliTapGestureDetectorTypeRegistry(void)
2254 TestApplication application;
2256 Actor actor = Actor::New();
2257 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
2258 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
2259 application.GetScene().Add(actor);
2263 type = TypeRegistry::Get().GetTypeInfo( "TapGestureDetector" );
2264 DALI_TEST_CHECK( type );
2265 BaseHandle handle = type.CreateInstance();
2266 DALI_TEST_CHECK( handle );
2267 TapGestureDetector detector = TapGestureDetector::DownCast( handle );
2268 DALI_TEST_CHECK( detector );
2270 // Attach actor to detector
2272 GestureReceivedFunctor functor( data );
2273 detector.Attach(actor);
2275 // Connect to signal through type
2276 handle.ConnectSignal( &application, "tapDetected", functor );
2278 // Render and notify
2279 application.SendNotification();
2280 application.Render();
2283 TestGenerateTap( application, 50.0, 10.0, 100 );
2285 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2289 int UtcDaliTypeRegistryNamedType(void)
2291 TestApplication application;
2292 TypeRegistry typeRegistry = TypeRegistry::Get();
2294 // Create a normal actor
2295 BaseHandle actorHandle = typeRegistry.GetTypeInfo( "Actor" ).CreateInstance();
2296 DALI_TEST_CHECK( actorHandle );
2297 Actor actor( Actor::DownCast( actorHandle ) );
2298 DALI_TEST_CHECK( actor );
2299 unsigned int actorPropertyCount( actor.GetPropertyCount() );
2301 // Create Named Actor Type
2302 BaseHandle namedHandle = typeRegistry.GetTypeInfo( "MyNamedActor" ).CreateInstance();
2303 DALI_TEST_CHECK( namedHandle );
2304 Actor namedActor( Actor::DownCast( namedHandle ) );
2305 DALI_TEST_CHECK( namedActor );
2306 unsigned int namedActorPropertyCount( namedActor.GetPropertyCount() );
2308 DALI_TEST_CHECK( namedActorPropertyCount > actorPropertyCount );
2312 int UtcDaliTypeInfoGetActionNameP(void)
2314 TestApplication application;
2315 TypeRegistry typeRegistry = TypeRegistry::Get();
2317 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2318 DALI_TEST_CHECK( typeInfo );
2320 DALI_TEST_CHECK( 0 != typeInfo.GetActionCount() );
2322 std::string name = typeInfo.GetActionName(0);
2324 DALI_TEST_EQUALS( name, "show", TEST_LOCATION );
2327 TypeInfo typeInfo2 = typeRegistry.GetTypeInfo( "MyTestCustomActor" );
2329 // search for show action in base class, given a derived class
2330 bool foundChildAction = false;
2331 for( std::size_t i = 0; i < typeInfo2.GetActionCount(); i++ )
2334 std::string name = typeInfo2.GetActionName( i );
2337 foundChildAction = true;
2342 DALI_TEST_EQUALS( foundChildAction, true, TEST_LOCATION );
2348 int UtcDaliTypeInfoGetActionNameN(void)
2350 TestApplication application;
2351 TypeRegistry typeRegistry = TypeRegistry::Get();
2353 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2354 DALI_TEST_CHECK( typeInfo );
2356 DALI_TEST_CHECK( 0 != typeInfo.GetActionCount() );
2358 std::string name = typeInfo.GetActionName(std::numeric_limits<size_t>::max());
2360 DALI_TEST_EQUALS( 0u, name.size(), TEST_LOCATION );
2365 int UtcDaliTypeInfoGetSignalNameP(void)
2367 TestApplication application;
2368 TypeRegistry typeRegistry = TypeRegistry::Get();
2370 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2371 DALI_TEST_CHECK( typeInfo );
2373 DALI_TEST_CHECK( 0 != typeInfo.GetSignalCount() );
2375 std::string name = typeInfo.GetSignalName(0);
2377 DALI_TEST_EQUALS( name, "hovered", TEST_LOCATION );
2379 TypeInfo typeInfo2 = typeRegistry.GetTypeInfo( "MyTestCustomActor" );
2381 // search for signal in base class, given a derived class
2382 bool foundSignal = false;
2383 for( std::size_t i = 0; i < typeInfo2.GetSignalCount(); i++ )
2385 std::string name = typeInfo2.GetSignalName( i );
2386 if( name == "hovered")
2392 DALI_TEST_EQUALS( foundSignal, true, TEST_LOCATION );
2397 int UtcDaliTypeInfoGetSignalNameN(void)
2399 TestApplication application;
2400 TypeRegistry typeRegistry = TypeRegistry::Get();
2402 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2403 DALI_TEST_CHECK( typeInfo );
2405 DALI_TEST_CHECK( 0 != typeInfo.GetSignalCount() );
2407 std::string name = typeInfo.GetSignalName(std::numeric_limits<size_t>::max());
2409 DALI_TEST_EQUALS( 0u, name.size(), TEST_LOCATION );
2415 int UtcDaliTypeInfoGetCreatorP(void)
2417 TestApplication application;
2418 TypeRegistry typeRegistry = TypeRegistry::Get();
2420 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2421 DALI_TEST_CHECK( typeInfo );
2423 TypeInfo::CreateFunction createFn = typeInfo.GetCreator();
2424 DALI_TEST_EQUALS( createFn != NULL, true, TEST_LOCATION );
2428 BaseHandle handle = createFn();
2429 DALI_TEST_EQUALS( (bool)handle, true, TEST_LOCATION );
2435 int UtcDaliTypeInfoGetCreatorN(void)
2437 TestApplication application;
2438 TypeRegistry typeRegistry = TypeRegistry::Get();
2440 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "MyTestCustomActor3" );
2441 DALI_TEST_CHECK( typeInfo );
2443 TypeInfo::CreateFunction createFn = typeInfo.GetCreator();
2444 DALI_TEST_EQUALS( createFn == NULL, true, TEST_LOCATION );
2449 int UtcDaliTypeInfoGetPropertyCountP1(void)
2451 TestApplication application;
2452 TypeRegistry typeRegistry = TypeRegistry::Get();
2454 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2455 DALI_TEST_CHECK( typeInfo );
2456 size_t actorPropertyCount = typeInfo.GetPropertyCount();
2458 DALI_TEST_EQUALS( actorPropertyCount, Actor::New().GetPropertyCount(), TEST_LOCATION ); // No event only props
2462 int UtcDaliTypeInfoGetPropertyCountP2(void)
2464 TestApplication application;
2465 TypeRegistry typeRegistry = TypeRegistry::Get();
2467 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "MyTestCustomActor2" );
2468 DALI_TEST_CHECK( typeInfo );
2469 size_t propertyCount = typeInfo.GetPropertyCount();
2470 Property::IndexContainer indices;
2471 typeInfo.GetPropertyIndices( indices );
2473 DALI_TEST_EQUALS( propertyCount > 0 && propertyCount <= indices.Size(), true, TEST_LOCATION );
2474 DALI_TEST_EQUALS( propertyCount, Actor::New().GetPropertyCount() + 2, TEST_LOCATION );
2479 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGet01(void)
2481 TestApplication application;
2482 TypeRegistry typeRegistry = TypeRegistry::Get();
2484 tet_infoline( "Register a type registered animatable property and ensure set/get behaviour works synchronously" );
2486 // Register animatable property
2487 const int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
2488 AnimatablePropertyRegistration animatableProperty( customType1, "animatableProp1", animatablePropertyIndex, Property::FLOAT );
2490 // Check property count before property registration
2491 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2492 DALI_TEST_CHECK( typeInfo );
2493 BaseHandle handle = typeInfo.CreateInstance();
2494 DALI_TEST_CHECK( handle );
2495 Actor customActor = Actor::DownCast( handle );
2496 DALI_TEST_CHECK( customActor );
2497 application.GetScene().Add(customActor);
2499 tet_infoline( "Set the value and ensure it changes straight away" );
2500 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 0.0f, TEST_LOCATION );
2501 customActor.SetProperty( animatablePropertyIndex, 25.0f );
2502 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 25.0f, TEST_LOCATION );
2504 tet_infoline( "Check latest scene-graph value is unchanged" );
2505 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 0.0f, TEST_LOCATION );
2507 // Render and notify
2508 application.SendNotification();
2509 application.Render();
2511 tet_infoline( "Check values after rendering and both retrieval methods should return the latest" );
2513 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 25.0f, TEST_LOCATION );
2514 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 25.0f, TEST_LOCATION );
2519 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGetWithComponentsVector2(void)
2521 TestApplication application;
2522 TypeRegistry typeRegistry = TypeRegistry::Get();
2524 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" );
2526 // Register the animatable propeties
2527 const int basePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
2528 const int componentZeroPropertyIndex( basePropertyIndex + 1 );
2529 const int componentOnePropertyIndex( componentZeroPropertyIndex + 1 );
2530 AnimatablePropertyRegistration baseAnimatableProperty( customType1, "baseProp", basePropertyIndex, Vector2( 13.0f, 24.0f ) );
2531 AnimatablePropertyComponentRegistration componentZeroAnimatableProperty( customType1, "componentZeroProp", componentZeroPropertyIndex, basePropertyIndex, 0 );
2532 AnimatablePropertyComponentRegistration componentOneAnimatableProperty( customType1, "componentOneProp", componentOnePropertyIndex, basePropertyIndex, 1 );
2534 // Check property count before property registration
2535 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2536 DALI_TEST_CHECK( typeInfo );
2537 BaseHandle handle = typeInfo.CreateInstance();
2538 DALI_TEST_CHECK( handle );
2539 Actor customActor = Actor::DownCast( handle );
2540 DALI_TEST_CHECK( customActor );
2541 application.GetScene().Add(customActor);
2543 tet_infoline( "Get the component values, they should be the default value of the base-property" );
2544 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2545 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2546 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 13.0f, 24.0f ), TEST_LOCATION );
2548 tet_infoline( "Set a component value and ensure it changes for the base property as well" );
2549 customActor.SetProperty( componentZeroPropertyIndex, 125.0f );
2550 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2551 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 125.0f, 24.0f ), TEST_LOCATION );
2553 customActor.SetProperty( componentOnePropertyIndex, 225.0f );
2554 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2555 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 125.0f, 225.0f ), TEST_LOCATION );
2557 tet_infoline( "Check latest scene-graph value is unchanged" );
2558 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector2 >( basePropertyIndex ), Vector2( 13.0f, 24.0f ), TEST_LOCATION );
2559 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2560 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2562 // Render and notify
2563 application.SendNotification();
2564 application.Render();
2566 tet_infoline( "Check values after rendering and both retrieval methods should return the latest" );
2567 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 125.0f, 225.0f ), TEST_LOCATION );
2568 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2569 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2571 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector2 >( basePropertyIndex ), Vector2( 125.0f, 225.0f ), TEST_LOCATION );
2572 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2573 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2575 tet_infoline( "Set the base property value and ensure the component values reflect the change" );
2576 customActor.SetProperty( basePropertyIndex, Vector2( 1.0f, 2.0f ) );
2577 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 1.0f, TEST_LOCATION );
2578 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 2.0f, TEST_LOCATION );
2579 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 1.0f, 2.0f ), TEST_LOCATION );
2584 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGetWithComponentsVector3(void)
2586 TestApplication application;
2587 TypeRegistry typeRegistry = TypeRegistry::Get();
2589 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" );
2591 // Register the animatable propeties
2592 const int basePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
2593 const int componentZeroPropertyIndex( basePropertyIndex + 1 );
2594 const int componentOnePropertyIndex( componentZeroPropertyIndex + 1 );
2595 const int componentTwoPropertyIndex( componentOnePropertyIndex + 1 );
2596 AnimatablePropertyRegistration baseAnimatableProperty( customType1, "baseProp", basePropertyIndex, Vector3( 13.0f, 24.0f, 35.0 ) );
2597 AnimatablePropertyComponentRegistration componentZeroAnimatableProperty( customType1, "componentZeroProp", componentZeroPropertyIndex, basePropertyIndex, 0 );
2598 AnimatablePropertyComponentRegistration componentOneAnimatableProperty( customType1, "componentOneProp", componentOnePropertyIndex, basePropertyIndex, 1 );
2599 AnimatablePropertyComponentRegistration componentTwoAnimatableProperty( customType1, "componentTwoProp", componentTwoPropertyIndex, basePropertyIndex, 2 );
2601 // Check property count before property registration
2602 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2603 DALI_TEST_CHECK( typeInfo );
2604 BaseHandle handle = typeInfo.CreateInstance();
2605 DALI_TEST_CHECK( handle );
2606 Actor customActor = Actor::DownCast( handle );
2607 DALI_TEST_CHECK( customActor );
2608 application.GetScene().Add(customActor);
2610 tet_infoline( "Get the component values, they should be the default value of the base-property" );
2611 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2612 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2613 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 35.0f, TEST_LOCATION );
2614 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 13.0f, 24.0f, 35.0f ), TEST_LOCATION );
2616 tet_infoline( "Set a component value and ensure it changes for the base property as well" );
2617 customActor.SetProperty( componentZeroPropertyIndex, 125.0f );
2618 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2619 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 24.0f, 35.0f ), TEST_LOCATION );
2621 customActor.SetProperty( componentOnePropertyIndex, 225.0f );
2622 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2623 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 225.0f, 35.0f ), TEST_LOCATION );
2625 customActor.SetProperty( componentTwoPropertyIndex, 325.0f );
2626 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2627 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 225.0f, 325.0f ), TEST_LOCATION );
2629 tet_infoline( "Check latest scene-graph value is unchanged" );
2630 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector3 >( basePropertyIndex ), Vector3( 13.0f, 24.0f, 35.0f ), TEST_LOCATION );
2631 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2632 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2633 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentTwoPropertyIndex ), 35.0f, TEST_LOCATION );
2635 // Render and notify
2636 application.SendNotification();
2637 application.Render();
2639 tet_infoline( "Check values after rendering and both retrieval methods should return the latest" );
2640 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 225.0f, 325.0f ), TEST_LOCATION );
2641 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2642 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2643 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2645 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 225.0f, 325.0f ), TEST_LOCATION );
2646 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2647 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2648 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2650 tet_infoline( "Set the base property value and ensure the component values reflect the change" );
2651 customActor.SetProperty( basePropertyIndex, Vector3( 1.0f, 2.0f, 3.0f ) );
2652 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 1.0f, TEST_LOCATION );
2653 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 2.0f, TEST_LOCATION );
2654 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 3.0f, TEST_LOCATION );
2655 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 1.0f, 2.0f, 3.0f ), TEST_LOCATION );
2660 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGetWithComponentsVector4(void)
2662 TestApplication application;
2663 TypeRegistry typeRegistry = TypeRegistry::Get();
2665 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" );
2667 // Register the animatable propeties
2668 const int basePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
2669 const int componentZeroPropertyIndex( basePropertyIndex + 1 );
2670 const int componentOnePropertyIndex( componentZeroPropertyIndex + 1 );
2671 const int componentTwoPropertyIndex( componentOnePropertyIndex + 1 );
2672 const int componentThreePropertyIndex( componentTwoPropertyIndex + 1 );
2673 AnimatablePropertyRegistration baseAnimatableProperty( customType1, "baseProp", basePropertyIndex, Vector4( 13.0f, 24.0f, 35.0, 47.0f ) );
2674 AnimatablePropertyComponentRegistration componentZeroAnimatableProperty( customType1, "componentZeroProp", componentZeroPropertyIndex, basePropertyIndex, 0 );
2675 AnimatablePropertyComponentRegistration componentOneAnimatableProperty( customType1, "componentOneProp", componentOnePropertyIndex, basePropertyIndex, 1 );
2676 AnimatablePropertyComponentRegistration componentTwoAnimatableProperty( customType1, "componentTwoProp", componentTwoPropertyIndex, basePropertyIndex, 2 );
2677 AnimatablePropertyComponentRegistration componentThreeAnimatableProperty( customType1, "componentThreeProp", componentThreePropertyIndex, basePropertyIndex, 3 );
2679 // Check property count before property registration
2680 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2681 DALI_TEST_CHECK( typeInfo );
2682 BaseHandle handle = typeInfo.CreateInstance();
2683 DALI_TEST_CHECK( handle );
2684 Actor customActor = Actor::DownCast( handle );
2685 DALI_TEST_CHECK( customActor );
2686 application.GetScene().Add(customActor);
2688 tet_infoline( "Get the component values, they should be the default value of the base-property" );
2689 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2690 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2691 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 35.0f, TEST_LOCATION );
2692 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentThreePropertyIndex ), 47.0f, TEST_LOCATION );
2693 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 13.0f, 24.0f, 35.0f, 47.0f ), TEST_LOCATION );
2695 tet_infoline( "Set a component value and ensure it changes for the base property as well" );
2696 customActor.SetProperty( componentZeroPropertyIndex, 125.0f );
2697 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2698 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 24.0f, 35.0f, 47.0f ), TEST_LOCATION );
2700 customActor.SetProperty( componentOnePropertyIndex, 225.0f );
2701 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2702 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 35.0f, 47.0f ), TEST_LOCATION );
2704 customActor.SetProperty( componentTwoPropertyIndex, 325.0f );
2705 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2706 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 325.0f, 47.0f ), TEST_LOCATION );
2708 customActor.SetProperty( componentThreePropertyIndex, 435.0f );
2709 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentThreePropertyIndex ), 435.0f, TEST_LOCATION );
2710 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 325.0f, 435.0f ), TEST_LOCATION );
2712 tet_infoline( "Check latest scene-graph value is unchanged" );
2713 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector4 >( basePropertyIndex ), Vector4( 13.0f, 24.0f, 35.0f, 47.0f ), TEST_LOCATION );
2714 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2715 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2716 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentTwoPropertyIndex ), 35.0f, TEST_LOCATION );
2717 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentThreePropertyIndex ), 47.0f, TEST_LOCATION );
2719 // Render and notify
2720 application.SendNotification();
2721 application.Render();
2723 tet_infoline( "Check values after rendering and both retrieval methods should return the latest" );
2724 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 325.0f, 435.0f ), TEST_LOCATION );
2725 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2726 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2727 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2728 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentThreePropertyIndex ), 435.0f, TEST_LOCATION );
2730 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 325.0f, 435.0f ), TEST_LOCATION );
2731 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2732 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2733 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2734 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentThreePropertyIndex ), 435.0f, TEST_LOCATION );
2736 tet_infoline( "Set the base property value and ensure the component values reflect the change" );
2737 customActor.SetProperty( basePropertyIndex, Vector4( 1.0f, 2.0f, 3.0f, 4.0f ) );
2738 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 1.0f, TEST_LOCATION );
2739 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 2.0f, TEST_LOCATION );
2740 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 3.0f, TEST_LOCATION );
2741 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentThreePropertyIndex ), 4.0f, TEST_LOCATION );
2742 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 1.0f, 2.0f, 3.0f, 4.0f ), TEST_LOCATION );
2748 int UtcDaliTypeInfoRegisterChildProperties01(void)
2750 TestApplication application;
2751 TypeRegistry typeRegistry = TypeRegistry::Get();
2753 tet_infoline( "Register child properties on a type via name" );
2755 auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(CustomActor) );
2756 auto myCustomTypeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2757 DALI_TEST_CHECK( customActorTypeInfo );
2758 DALI_TEST_CHECK( myCustomTypeInfo );
2760 const Property::Index WIDTH_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX );
2761 const Property::Index HEIGHT_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1);
2762 const Property::Index MARGIN_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 100);
2764 ChildPropertyRegistration( customActorTypeInfo.GetName(), "widthSpecification", WIDTH_SPECIFICATION, Property::INTEGER );
2765 ChildPropertyRegistration( customActorTypeInfo.GetName(), "heightSpecification", HEIGHT_SPECIFICATION, Property::INTEGER );
2766 ChildPropertyRegistration( myCustomTypeInfo.GetName(), "marginSpecification", MARGIN_SPECIFICATION, Property::EXTENTS );
2768 auto customActor = MyTestCustomActor::New();
2769 application.GetScene().Add( customActor );
2770 auto child = Actor::New();
2771 customActor.Add( child );
2773 child.SetProperty( WIDTH_SPECIFICATION, 33 );
2775 auto value = child.GetProperty( WIDTH_SPECIFICATION );
2776 DALI_TEST_EQUALS( value, Property::Value(33), TEST_LOCATION );
2778 child.SetProperty( HEIGHT_SPECIFICATION, 44 );
2779 value = child.GetProperty( HEIGHT_SPECIFICATION );
2780 DALI_TEST_EQUALS( value, Property::Value(44), TEST_LOCATION );
2782 child.SetProperty( MARGIN_SPECIFICATION, Extents(10, 10, 10, 10) );
2783 value = child.GetProperty( MARGIN_SPECIFICATION );
2784 DALI_TEST_EQUALS( value, Property::Value(Extents(10,10,10,10)), TEST_LOCATION );
2790 int UtcDaliTypeInfoRegisterChildProperties02(void)
2792 TestApplication application;
2793 TypeRegistry typeRegistry = TypeRegistry::Get();
2795 tet_infoline( "Register child properties on a type via name" );
2797 auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(CustomActor) );
2798 auto myCustomTypeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2799 DALI_TEST_CHECK( customActorTypeInfo );
2800 DALI_TEST_CHECK( myCustomTypeInfo );
2802 const Property::Index WIDTH_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX );
2803 const Property::Index HEIGHT_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1);
2804 const Property::Index MARGIN_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 100);
2806 ChildPropertyRegistration( customActorTypeInfo.GetName(), "widthSpecification", WIDTH_SPECIFICATION, Property::INTEGER );
2807 ChildPropertyRegistration( customActorTypeInfo.GetName(), "heightSpecification", HEIGHT_SPECIFICATION, Property::INTEGER );
2808 ChildPropertyRegistration( myCustomTypeInfo.GetName(), "marginSpecification", MARGIN_SPECIFICATION, Property::EXTENTS );
2811 auto index = customActorTypeInfo.GetChildPropertyIndex( "widthSpecification" );
2812 DALI_TEST_EQUALS( index, WIDTH_SPECIFICATION, TEST_LOCATION );
2814 index = customActorTypeInfo.GetChildPropertyIndex( "heightSpecification" );
2815 DALI_TEST_EQUALS( index, HEIGHT_SPECIFICATION, TEST_LOCATION );
2817 index = customActorTypeInfo.GetChildPropertyIndex( "marginSpecification" );
2818 DALI_TEST_EQUALS( index, Property::INVALID_INDEX, TEST_LOCATION );
2820 index = myCustomTypeInfo.GetChildPropertyIndex( "marginSpecification" );
2821 DALI_TEST_EQUALS( index, MARGIN_SPECIFICATION, TEST_LOCATION );
2824 auto name = customActorTypeInfo.GetChildPropertyName( WIDTH_SPECIFICATION );
2825 DALI_TEST_EQUALS( name, "widthSpecification", TEST_LOCATION );
2827 name = customActorTypeInfo.GetChildPropertyName( HEIGHT_SPECIFICATION );
2828 DALI_TEST_EQUALS( name, "heightSpecification", TEST_LOCATION );
2830 name = myCustomTypeInfo.GetChildPropertyName( MARGIN_SPECIFICATION );
2831 DALI_TEST_EQUALS( name, "marginSpecification", TEST_LOCATION );
2834 auto type = customActorTypeInfo.GetChildPropertyType( WIDTH_SPECIFICATION );
2835 DALI_TEST_EQUALS( type, Property::INTEGER, TEST_LOCATION );
2837 type = customActorTypeInfo.GetChildPropertyType( HEIGHT_SPECIFICATION );
2838 DALI_TEST_EQUALS( type, Property::INTEGER, TEST_LOCATION );
2840 type = myCustomTypeInfo.GetChildPropertyType( MARGIN_SPECIFICATION );
2841 DALI_TEST_EQUALS( type, Property::EXTENTS, TEST_LOCATION );
2848 int UtcDaliTypeInfoRegisterChildProperties03(void)
2850 TestApplication application;
2851 TypeRegistry typeRegistry = TypeRegistry::Get();
2853 tet_infoline( "Check registered child properties can be retrieved" );
2855 auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(CustomActor) );
2856 auto myCustomTypeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2857 DALI_TEST_CHECK( customActorTypeInfo );
2858 DALI_TEST_CHECK( myCustomTypeInfo );
2860 const Property::Index WIDTH_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX );
2861 const Property::Index HEIGHT_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1);
2862 const Property::Index MARGIN_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 100);
2864 ChildPropertyRegistration( customActorTypeInfo.GetName(), "widthSpecification", WIDTH_SPECIFICATION, Property::INTEGER );
2865 ChildPropertyRegistration( customActorTypeInfo.GetName(), "heightSpecification", HEIGHT_SPECIFICATION, Property::INTEGER );
2866 ChildPropertyRegistration( myCustomTypeInfo.GetName(), "marginSpecification", MARGIN_SPECIFICATION, Property::EXTENTS );
2868 Property::IndexContainer indices;
2869 myCustomTypeInfo.GetChildPropertyIndices( indices );
2871 auto result = std::find( indices.Begin(), indices.End(), WIDTH_SPECIFICATION );
2872 DALI_TEST_EQUALS( result != indices.End(), true, TEST_LOCATION );
2874 result = std::find( indices.Begin(), indices.End(), HEIGHT_SPECIFICATION );
2875 DALI_TEST_EQUALS( result != indices.End(), true, TEST_LOCATION );
2877 result = std::find( indices.Begin(), indices.End(), MARGIN_SPECIFICATION );
2878 DALI_TEST_EQUALS( result != indices.End(), true, TEST_LOCATION );
2883 int UtcDaliTypeInfoGetActionNameNegative(void)
2885 TestApplication application;
2886 Dali::TypeInfo instance;
2889 unsigned long arg1(0u);
2890 instance.GetActionName(arg1);
2891 DALI_TEST_CHECK(false); // Should not get here
2895 DALI_TEST_CHECK(true); // We expect an assert
2900 int UtcDaliTypeInfoGetSignalNameNegative(void)
2902 TestApplication application;
2903 Dali::TypeInfo instance;
2906 unsigned long arg1(0u);
2907 instance.GetSignalName(arg1);
2908 DALI_TEST_CHECK(false); // Should not get here
2912 DALI_TEST_CHECK(true); // We expect an assert
2917 int UtcDaliTypeInfoGetCreatorNegative(void)
2919 TestApplication application;
2920 Dali::TypeInfo instance;
2923 instance.GetCreator();
2924 DALI_TEST_CHECK(false); // Should not get here
2928 DALI_TEST_CHECK(true); // We expect an assert
2933 int UtcDaliTypeInfoGetBaseNameNegative(void)
2935 TestApplication application;
2936 Dali::TypeInfo instance;
2939 instance.GetBaseName();
2940 DALI_TEST_CHECK(false); // Should not get here
2944 DALI_TEST_CHECK(true); // We expect an assert
2949 int UtcDaliTypeInfoCreateInstanceNegative(void)
2951 TestApplication application;
2952 Dali::TypeInfo instance;
2955 instance.CreateInstance();
2956 DALI_TEST_CHECK(false); // Should not get here
2960 DALI_TEST_CHECK(true); // We expect an assert
2965 int UtcDaliTypeInfoGetActionCountNegative(void)
2967 TestApplication application;
2968 Dali::TypeInfo instance;
2971 instance.GetActionCount();
2972 DALI_TEST_CHECK(false); // Should not get here
2976 DALI_TEST_CHECK(true); // We expect an assert
2981 int UtcDaliTypeInfoGetSignalCountNegative(void)
2983 TestApplication application;
2984 Dali::TypeInfo instance;
2987 instance.GetSignalCount();
2988 DALI_TEST_CHECK(false); // Should not get here
2992 DALI_TEST_CHECK(true); // We expect an assert
2997 int UtcDaliTypeInfoGetPropertyNameNegative(void)
2999 TestApplication application;
3000 Dali::TypeInfo instance;
3004 instance.GetPropertyName(arg1);
3005 DALI_TEST_CHECK(false); // Should not get here
3009 DALI_TEST_CHECK(true); // We expect an assert
3014 int UtcDaliTypeInfoGetPropertyCountNegative(void)
3016 TestApplication application;
3017 Dali::TypeInfo instance;
3020 instance.GetPropertyCount();
3021 DALI_TEST_CHECK(false); // Should not get here
3025 DALI_TEST_CHECK(true); // We expect an assert
3030 int UtcDaliTypeInfoGetPropertyIndicesNegative(void)
3032 TestApplication application;
3033 Dali::TypeInfo instance;
3036 Dali::Vector<int> arg1;
3037 instance.GetPropertyIndices(arg1);
3038 DALI_TEST_CHECK(false); // Should not get here
3042 DALI_TEST_CHECK(true); // We expect an assert
3047 int UtcDaliTypeInfoGetChildPropertyNameNegative(void)
3049 TestApplication application;
3050 Dali::TypeInfo instance;
3054 instance.GetChildPropertyName(arg1);
3055 DALI_TEST_CHECK(false); // Should not get here
3059 DALI_TEST_CHECK(true); // We expect an assert
3064 int UtcDaliTypeInfoGetChildPropertyTypeNegative(void)
3066 TestApplication application;
3067 Dali::TypeInfo instance;
3071 instance.GetChildPropertyType(arg1);
3072 DALI_TEST_CHECK(false); // Should not get here
3076 DALI_TEST_CHECK(true); // We expect an assert
3081 int UtcDaliTypeInfoGetChildPropertyIndexNegative(void)
3083 TestApplication application;
3084 Dali::TypeInfo instance;
3088 instance.GetChildPropertyIndex(arg1);
3089 DALI_TEST_CHECK(false); // Should not get here
3093 DALI_TEST_CHECK(true); // We expect an assert
3098 int UtcDaliTypeInfoGetChildPropertyIndicesNegative(void)
3100 TestApplication application;
3101 Dali::TypeInfo instance;
3104 Dali::Vector<int> arg1;
3105 instance.GetChildPropertyIndices(arg1);
3106 DALI_TEST_CHECK(false); // Should not get here
3110 DALI_TEST_CHECK(true); // We expect an assert
3115 int UtcDaliTypeInfoGetNameNegative(void)
3117 TestApplication application;
3118 Dali::TypeInfo instance;
3122 DALI_TEST_CHECK(false); // Should not get here
3126 DALI_TEST_CHECK(true); // We expect an assert
3131 int UtcDaliTypeRegistryGetTypeInfoNegative01(void)
3133 TestApplication application;
3134 Dali::TypeRegistry instance;
3138 instance.GetTypeInfo(arg1);
3139 DALI_TEST_CHECK(false); // Should not get here
3143 DALI_TEST_CHECK(true); // We expect an assert
3148 int UtcDaliTypeRegistryGetTypeInfoNegative02(void)
3150 TestApplication application;
3151 Dali::TypeRegistry instance;
3154 instance.GetTypeInfo(typeid(unsigned int));
3155 DALI_TEST_CHECK(false); // Should not get here
3159 DALI_TEST_CHECK(true); // We expect an assert
3164 int UtcDaliTypeRegistryGetTypeNameNegative(void)
3166 TestApplication application;
3167 Dali::TypeRegistry instance;
3170 unsigned long arg1(0u);
3171 instance.GetTypeName(arg1);
3172 DALI_TEST_CHECK(false); // Should not get here
3176 DALI_TEST_CHECK(true); // We expect an assert
3181 int UtcDaliTypeRegistryGetTypeNameCountNegative(void)
3183 TestApplication application;
3184 Dali::TypeRegistry instance;
3187 instance.GetTypeNameCount();
3188 DALI_TEST_CHECK(false); // Should not get here
3192 DALI_TEST_CHECK(true); // We expect an assert