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 ),
39 receivedGesture( Gesture::Clear ),
45 functorCalled = false;
46 voidFunctorCalled = false;
48 receivedGesture.numberOfTouches = 0u;
49 receivedGesture.screenPoint = Vector2(0.0f, 0.0f);
50 receivedGesture.localPoint = Vector2(0.0f, 0.0f);
56 bool voidFunctorCalled;
57 LongPressGesture receivedGesture;
61 // Functor that sets the data when called
62 struct GestureReceivedFunctor
64 GestureReceivedFunctor(SignalData& data) : signalData(data) { }
66 void operator()(Actor actor, LongPressGesture longPress)
68 signalData.functorCalled = true;
69 signalData.receivedGesture = longPress;
70 signalData.pressedActor = actor;
75 signalData.voidFunctorCalled = true;
78 SignalData& signalData;
82 // Create function as Init function called
84 static bool CreateCustomInitCalled = false;
85 BaseHandle CreateCustomInit(void)
87 CreateCustomInitCalled = true;
91 static bool CreateCustomNamedInitCalled = false;
92 BaseHandle CreateCustomNamedInit(void)
94 CreateCustomNamedInitCalled = true;
98 const std::string scriptedName("PopupStyle");
99 static TypeRegistration scriptedType( scriptedName, typeid(Dali::CustomActor), CreateCustomNamedInit );
101 // Property Registration
102 bool setPropertyCalled = false;
103 bool getPropertyCalled = false;
104 void SetProperty( BaseObject* object, Property::Index propertyIndex, const Property::Value& value )
106 setPropertyCalled = true;
108 Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex )
110 getPropertyCalled = true;
111 return Property::Value( true );
116 /*******************************************************************************
120 ******************************************************************************/
123 struct MyTestCustomActor : public CustomActorImpl
125 typedef Signal< void ()> SignalType;
126 typedef Signal< void (float)> SignalTypeFloat;
128 MyTestCustomActor() : CustomActorImpl( ActorFlags( REQUIRES_TOUCH_EVENTS ) )
131 virtual ~MyTestCustomActor()
134 void ResetCallStack()
138 // From CustomActorImpl
139 virtual void OnSceneConnection( int depth )
142 virtual void OnSceneDisconnection()
145 virtual void OnChildAdd(Actor& child)
148 virtual void OnChildRemove(Actor& child)
151 virtual void OnSizeSet(const Vector3& targetSize)
154 virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize)
157 virtual bool OnHoverEvent(const HoverEvent& event)
161 virtual bool OnWheelEvent(const WheelEvent& event)
165 virtual bool OnKeyEvent(const KeyEvent& event)
169 virtual void OnKeyInputFocusGained()
172 virtual void OnKeyInputFocusLost()
175 virtual Vector3 GetNaturalSize()
177 return Vector3( 0.0f, 0.0f, 0.0f );
180 virtual float GetHeightForWidth( float width )
185 virtual float GetWidthForHeight( float height )
190 virtual void OnRelayout( const Vector2& size, RelayoutContainer& container )
194 virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
198 virtual void OnCalculateRelayoutSize( Dimension::Type dimension )
202 virtual float CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension )
207 virtual void OnLayoutNegotiated( float size, Dimension::Type dimension )
211 virtual bool RelayoutDependentOnChildren( Dimension::Type dimension = Dimension::ALL_DIMENSIONS )
223 class MyTestCustomActor : public CustomActor
227 typedef Signal< void ()> SignalType;
228 typedef Signal< void (float)> SignalTypeFloat;
234 static MyTestCustomActor New()
236 Impl::MyTestCustomActor* p = new Impl::MyTestCustomActor;
237 return MyTestCustomActor( *p ); // takes ownership
240 virtual ~MyTestCustomActor()
244 static MyTestCustomActor DownCast( BaseHandle handle )
246 MyTestCustomActor result;
248 CustomActor custom = Dali::CustomActor::DownCast( handle );
251 CustomActorImpl& customImpl = custom.GetImplementation();
253 Impl::MyTestCustomActor* impl = dynamic_cast<Impl::MyTestCustomActor*>(&customImpl);
257 result = MyTestCustomActor(customImpl.GetOwner());
264 SignalType& GetCustomSignal()
266 Dali::RefObject& obj = GetImplementation();
267 return static_cast<Impl::MyTestCustomActor&>( obj ).mSignal;
272 MyTestCustomActor(Internal::CustomActor* internal)
273 : CustomActor(internal)
277 MyTestCustomActor( Impl::MyTestCustomActor& impl )
278 : CustomActor( impl )
284 class MyTestCustomActor2 : public CustomActor
292 P1=Dali::PROPERTY_REGISTRATION_START_INDEX,
302 static MyTestCustomActor2 New()
304 return MyTestCustomActor2(); // takes ownership
307 virtual ~MyTestCustomActor2()
311 static MyTestCustomActor2 DownCast( BaseHandle handle )
313 MyTestCustomActor2 result;
315 CustomActor custom = Dali::CustomActor::DownCast( handle );
318 CustomActorImpl& customImpl = custom.GetImplementation();
320 Impl::MyTestCustomActor* impl = dynamic_cast<Impl::MyTestCustomActor*>(&customImpl);
324 result = MyTestCustomActor2(customImpl.GetOwner());
333 MyTestCustomActor2(Internal::CustomActor* internal)
334 : CustomActor(internal)
338 MyTestCustomActor2( Impl::MyTestCustomActor& impl )
339 : CustomActor( impl )
344 static TypeRegistration customTypeInit( typeid(MyTestCustomActor2), typeid(Dali::CustomActor), CreateCustomInit, true );
346 PropertyRegistration P1( customTypeInit, "propertyOne", MyTestCustomActor2::Property::P1, Property::INTEGER, &SetProperty, &GetProperty );
347 PropertyRegistration P2( customTypeInit, "propertyTwo", MyTestCustomActor2::Property::P2, Property::STRING, &SetProperty, &GetProperty );
350 class MyTestCustomActor3 : public CustomActor
357 static MyTestCustomActor3 New()
359 return MyTestCustomActor3(); // takes ownership
362 virtual ~MyTestCustomActor3()
366 static MyTestCustomActor3 DownCast( BaseHandle handle )
368 MyTestCustomActor3 result;
370 CustomActor custom = Dali::CustomActor::DownCast( handle );
373 CustomActorImpl& customImpl = custom.GetImplementation();
375 Impl::MyTestCustomActor* impl = dynamic_cast<Impl::MyTestCustomActor*>(&customImpl);
379 result = MyTestCustomActor3(customImpl.GetOwner());
388 MyTestCustomActor3(Internal::CustomActor* internal)
389 : CustomActor(internal)
393 MyTestCustomActor3( Impl::MyTestCustomActor& impl )
394 : CustomActor( impl )
399 static TypeRegistration customTypeBadInit( typeid(MyTestCustomActor3), typeid(Dali::CustomActor), NULL, false );
401 BaseHandle CreateCustom(void)
403 return MyTestCustomActor::New();
406 static std::string lastSignalConnectionCustom;
408 bool DoConnectSignalCustom( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
410 lastSignalConnectionCustom = signalName;
412 bool connected( true );
414 Dali::BaseHandle handle(object);
415 MyTestCustomActor customActor = MyTestCustomActor::DownCast(handle);
417 if( "sig1" == signalName )
419 customActor.GetCustomSignal().Connect( tracker, functor );
423 // signalName does not match any signal
430 bool DoConnectSignalCustomFailure( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
432 lastSignalConnectionCustom = "failed";
434 return false; // This is supposed to fail
437 struct CustomTestFunctor
441 ++mTotalInstanceCount;
442 ++mCurrentInstanceCount;
445 CustomTestFunctor( const CustomTestFunctor& copyMe )
447 ++mTotalInstanceCount;
448 ++mCurrentInstanceCount;
453 --mCurrentInstanceCount;
461 static int mTotalInstanceCount;
462 static int mCurrentInstanceCount;
463 static int mCallbackCount;
466 int CustomTestFunctor::mTotalInstanceCount = 0;
467 int CustomTestFunctor::mCurrentInstanceCount = 0;
468 int CustomTestFunctor::mCallbackCount = 0;
470 static void ResetFunctorCounts()
472 CustomTestFunctor::mTotalInstanceCount = 0;
473 CustomTestFunctor::mCurrentInstanceCount = 0;
474 CustomTestFunctor::mCallbackCount = 0;
477 static std::string lastActionCustom;
478 bool DoActionCustom(BaseObject* object, const std::string& actionName, const Property::Map& /*attributes*/)
480 lastActionCustom = actionName;
484 // Custom type registration
485 static TypeRegistration customType1( typeid(MyTestCustomActor), typeid(Dali::CustomActor), CreateCustom );
488 static SignalConnectorType customSignalConnector1( customType1, "sig1", DoConnectSignalCustom );
489 static SignalConnectorType customSignalConnector2( customType1, "sig2", DoConnectSignalCustomFailure );
490 static const int TEST_SIGNAL_COUNT = 2;
493 static TypeAction customAction1( customType1, "act1", DoActionCustom);
494 static const int TEST_ACTION_COUNT = 1;
496 class TestConnectionTracker : public ConnectionTracker
500 TestConnectionTracker()
505 BaseHandle CreateNamedActorType()
507 Actor actor = Actor::New();
508 actor.SetProperty( Actor::Property::NAME, "NamedActor" );
512 TypeRegistration namedActorType( "MyNamedActor", typeid(Dali::Actor), CreateNamedActorType );
513 PropertyRegistration namedActorPropertyOne( namedActorType, "propName", PROPERTY_REGISTRATION_START_INDEX, Property::BOOLEAN, &SetProperty, &GetProperty );
515 } // Anonymous namespace
517 // Note: No negative test case for UtcDaliTypeRegistryGet can be implemented.
518 int UtcDaliTypeRegistryGetP(void)
520 TestApplication application;
522 TypeRegistry registry = TypeRegistry::Get();
523 DALI_TEST_CHECK( registry );
528 // Note: No negative test case for UtcDaliTypeRegistryConstructor can be implemented.
529 int UtcDaliTypeRegistryConstructorP(void)
531 TestApplication application;
533 TypeRegistry registry;
534 DALI_TEST_CHECK( !registry );
538 // Note: No negative test case for UtcDaliTypeRegistryCopyConstructor can be implemented.
539 int UtcDaliTypeRegistryCopyConstructorP(void)
541 TestApplication application;
543 TypeRegistry registry = TypeRegistry::Get();
544 DALI_TEST_CHECK( registry );
546 TypeRegistry copy( registry );
547 DALI_TEST_CHECK( copy );
549 DALI_TEST_CHECK( registry.GetTypeInfo( "Actor" ).GetName() == copy.GetTypeInfo( "Actor" ).GetName() );
554 // Note: No negative test case for UtcDaliTypeRegistryAssignmentOperator can be implemented.
555 int UtcDaliTypeRegistryAssignmentOperatorP(void)
557 TestApplication application;
559 TypeRegistry registry = TypeRegistry::Get();
560 DALI_TEST_CHECK( registry );
562 TypeRegistry copy = registry;
563 DALI_TEST_CHECK( copy );
564 DALI_TEST_CHECK( registry == copy );
566 DALI_TEST_CHECK( registry.GetTypeInfo( "Actor" ).GetName() == copy.GetTypeInfo( "Actor" ).GetName() );
571 int UtcDaliTypeRegistryMoveConstructor(void)
573 TestApplication application;
575 TypeRegistry registry = TypeRegistry::Get();
576 DALI_TEST_CHECK( registry );
577 DALI_TEST_EQUALS( 16, registry.GetBaseObject().ReferenceCount(), TEST_LOCATION );
578 DALI_TEST_CHECK( registry.GetTypeInfo( "Actor" ).GetName() == "Actor" );
580 TypeRegistry movedRegistry = std::move( registry );
581 DALI_TEST_CHECK( movedRegistry );
582 DALI_TEST_EQUALS( 16, movedRegistry.GetBaseObject().ReferenceCount(), TEST_LOCATION );
583 DALI_TEST_CHECK( movedRegistry.GetTypeInfo( "Actor" ).GetName() == "Actor" );
584 DALI_TEST_CHECK( !registry );
586 Dali::TypeInfo info = movedRegistry.GetTypeInfo( "Actor" );
587 DALI_TEST_CHECK( info );
588 DALI_TEST_EQUALS( 2, info.GetBaseObject().ReferenceCount(), TEST_LOCATION );
589 DALI_TEST_CHECK( info.GetName() == "Actor" );
591 Dali::TypeInfo movedInfo = std::move( info );
592 DALI_TEST_CHECK( movedInfo );
593 DALI_TEST_EQUALS( 2, movedInfo.GetBaseObject().ReferenceCount(), TEST_LOCATION );
594 DALI_TEST_CHECK( movedInfo.GetName() == "Actor" );
595 DALI_TEST_CHECK( !info );
600 int UtcDaliTypeRegistryMoveAssignment(void)
602 TestApplication application;
604 TypeRegistry registry = TypeRegistry::Get();
605 DALI_TEST_CHECK( registry );
606 DALI_TEST_EQUALS( 16, registry.GetBaseObject().ReferenceCount(), TEST_LOCATION );
607 DALI_TEST_CHECK( registry.GetTypeInfo( "Actor" ).GetName() == "Actor" );
609 TypeRegistry movedRegistry;
610 movedRegistry = std::move( registry );
611 DALI_TEST_CHECK( movedRegistry );
612 DALI_TEST_EQUALS( 16, movedRegistry.GetBaseObject().ReferenceCount(), TEST_LOCATION );
613 DALI_TEST_CHECK( movedRegistry.GetTypeInfo( "Actor" ).GetName() == "Actor" );
614 DALI_TEST_CHECK( !registry );
616 Dali::TypeInfo info = movedRegistry.GetTypeInfo( "Actor" );
617 DALI_TEST_CHECK( info );
618 DALI_TEST_EQUALS( 2, info.GetBaseObject().ReferenceCount(), TEST_LOCATION );
619 DALI_TEST_CHECK( info.GetName() == "Actor" );
621 Dali::TypeInfo movedInfo;
622 movedInfo = std::move( info );
623 DALI_TEST_CHECK( movedInfo );
624 DALI_TEST_EQUALS( 2, movedInfo.GetBaseObject().ReferenceCount(), TEST_LOCATION );
625 DALI_TEST_CHECK( movedInfo.GetName() == "Actor" );
626 DALI_TEST_CHECK( !info );
631 int UtcDaliTypeRegistryAssignP(void)
633 TestApplication application;
635 TypeRegistry registry = TypeRegistry::Get();
636 TypeRegistry registry2;
637 registry2 = registry;
638 DALI_TEST_CHECK( registry2 );
640 DALI_TEST_CHECK( registry2.GetTypeInfo( "Actor" ).GetName() == registry2.GetTypeInfo( "Actor" ).GetName() );
645 int UtcDaliTypeRegistryGetTypeInfoFromTypeNameP(void)
647 TestApplication application;
649 TypeRegistry registry = TypeRegistry::Get();
654 type = registry.GetTypeInfo( "CameraActor" );
655 DALI_TEST_CHECK( type );
656 CameraActor ca = CameraActor::DownCast(type.CreateInstance());
657 DALI_TEST_CHECK( ca );
658 application.GetScene().Add( ca );
659 application.Render();
662 type = registry.GetTypeInfo( "Animation" );
663 DALI_TEST_CHECK( type );
664 Animation an = Animation::DownCast(type.CreateInstance());
665 DALI_TEST_CHECK( an );
667 application.Render();
672 int UtcDaliTypeRegistryGetTypeInfoFromTypeNameN(void)
674 TestApplication application;
676 TypeRegistry registry = TypeRegistry::Get();
680 type = registry.GetTypeInfo( "MyDummyActor" );
681 DALI_TEST_CHECK( !type );
686 int UtcDaliTypeRegistryGetTypeInfoFromTypeIdP(void)
688 TypeInfo named_type = TypeRegistry::Get().GetTypeInfo( "CameraActor" );
689 TypeInfo typeinfo_type = TypeRegistry::Get().GetTypeInfo( typeid(Dali::CameraActor) );
691 DALI_TEST_CHECK( named_type );
692 DALI_TEST_CHECK( typeinfo_type );
694 // Check named and typeid are equivalent
695 DALI_TEST_CHECK( named_type == typeinfo_type );
697 DALI_TEST_CHECK( named_type.GetName() == typeinfo_type.GetName() );
698 DALI_TEST_CHECK( named_type.GetBaseName() == typeinfo_type.GetBaseName() );
703 int UtcDaliTypeRegistryGetTypeInfoFromTypeIdN(void)
705 TestApplication application;
706 TypeRegistry typeRegistry = TypeRegistry::Get();
708 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(Vector2) );
709 DALI_TEST_CHECK( !typeInfo );
714 int UtcDaliTypeRegistryGetTypeNameCountP(void)
716 TestApplication application;
717 TypeRegistry typeRegistry = TypeRegistry::Get();
720 for(size_t i = 0; i < typeRegistry.GetTypeNameCount(); i++)
722 type = typeRegistry.GetTypeInfo( typeRegistry.GetTypeName(i) );
723 DALI_TEST_CHECK( type );
730 int UtcDaliTypeRegistryGetTypeNamesP(void)
732 TestApplication application;
733 TypeRegistry typeRegistry = TypeRegistry::Get();
736 for(size_t i = 0; i < typeRegistry.GetTypeNameCount(); i++)
738 type = typeRegistry.GetTypeInfo( typeRegistry.GetTypeName(i) );
739 DALI_TEST_CHECK( type );
746 // Note: No negative test case for UtcDaliTypeRegistryTypeRegistration can be implemented.
747 int UtcDaliTypeRegistryTypeRegistrationNotCallingCreateOnInitP(void)
749 ResetFunctorCounts();
751 TestApplication application;
753 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
754 DALI_TEST_CHECK( type );
756 TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( "CustomActor" );
757 DALI_TEST_CHECK( baseType );
759 BaseHandle handle = type.CreateInstance();
760 DALI_TEST_CHECK( handle );
762 MyTestCustomActor customHandle = MyTestCustomActor::DownCast( handle );
763 DALI_TEST_CHECK( customHandle );
765 DALI_TEST_EQUALS( type.GetActionCount(), TEST_ACTION_COUNT + baseType.GetActionCount(), TEST_LOCATION );
767 DALI_TEST_EQUALS( type.GetSignalCount(), TEST_SIGNAL_COUNT + baseType.GetSignalCount(), TEST_LOCATION );
770 TestConnectionTracker tracker;
772 bool connected = handle.ConnectSignal( &tracker, "sig1", CustomTestFunctor() );
773 DALI_TEST_EQUALS( connected, true, TEST_LOCATION );
774 DALI_TEST_CHECK( lastSignalConnectionCustom == "sig1" );
775 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
776 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION );
778 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
779 customHandle.GetCustomSignal().Emit();
780 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION );
781 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
782 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION );
784 // tracker should automatically disconnect here
785 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
786 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
788 // Test that functor is disconnected
789 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION );
790 customHandle.GetCustomSignal().Emit();
791 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1/*not incremented*/, TEST_LOCATION );
792 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
793 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
795 Property::Map attributes;
796 handle.DoAction("act1", attributes);
797 DALI_TEST_CHECK( lastActionCustom == "act1" );
801 // Note: No negative test case for UtcDaliTypeRegistryTypeRegistration can be implemented.
802 int UtcDaliTypeRegistryTypeRegistrationCallingCreateOnInitP(void)
804 TestApplication application;
806 DALI_TEST_CHECK( "MyTestCustomActor2" == customTypeInit.RegisteredName() );
808 DALI_TEST_CHECK( true == CreateCustomInitCalled );
809 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor2" );
810 DALI_TEST_CHECK( type );
814 // Note: No negative test case for UtcDaliTypeRegistryTypeRegistration can be implemented.
815 int UtcDaliTypeRegistryTypeRegistrationForNamedTypeP(void)
817 TestApplication application;
819 // Create Named Actor Type
820 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyNamedActor" );
821 DALI_TEST_CHECK( type );
823 BaseHandle namedHandle = type.CreateInstance();
824 DALI_TEST_CHECK( namedHandle );
825 Actor namedActor( Actor::DownCast( namedHandle ) );
826 DALI_TEST_CHECK( namedActor );
828 DALI_TEST_CHECK( namedActor.GetProperty< std::string >( Actor::Property::NAME ) == "NamedActor" );
829 DALI_TEST_CHECK( type.GetName() == "MyNamedActor" );
830 DALI_TEST_CHECK( type.GetBaseName() == "Actor" );
835 int UtcDaliTypeRegistryRegisteredNameP(void)
837 TestApplication application;
839 DALI_TEST_CHECK( scriptedName == scriptedType.RegisteredName() );
841 TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( scriptedName );
842 DALI_TEST_CHECK( baseType );
844 BaseHandle handle = baseType.CreateInstance();
846 DALI_TEST_CHECK( true == CreateCustomNamedInitCalled );
847 TypeInfo type = TypeRegistry::Get().GetTypeInfo( scriptedName );
848 DALI_TEST_CHECK( type );
853 int UtcDaliTypeRegistryRegisteredNameN(void)
855 TestApplication application;
857 DALI_TEST_CHECK( scriptedName == scriptedType.RegisteredName() );
859 TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( scriptedName );
860 DALI_TEST_CHECK( baseType );
862 // should cause an assert because we're registering same type twice
863 // once statically at the start of this file, then again now
866 TypeRegistration scriptedType( scriptedName, typeid(Dali::CustomActor), CreateCustomNamedInit );
867 tet_result( TET_FAIL );
869 catch ( DaliException& e )
871 DALI_TEST_ASSERT( e, "Duplicate type name in Type Registration", TEST_LOCATION );
878 int UtcDaliTypeRegistrySignalConnectorTypeP(void)
880 ResetFunctorCounts();
882 TestApplication application;
884 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
885 DALI_TEST_CHECK( type );
887 BaseHandle handle = type.CreateInstance();
888 DALI_TEST_CHECK( handle );
890 MyTestCustomActor customHandle = MyTestCustomActor::DownCast( handle );
891 DALI_TEST_CHECK( customHandle );
894 TestConnectionTracker tracker;
896 bool connected = handle.ConnectSignal( &tracker, "sig1", CustomTestFunctor() );
897 DALI_TEST_EQUALS( connected, true, TEST_LOCATION );
898 DALI_TEST_CHECK( lastSignalConnectionCustom == "sig1" );
899 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
900 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION );
902 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
903 customHandle.GetCustomSignal().Emit();
904 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION );
905 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
906 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION );
908 // tracker should automatically disconnect here
909 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
910 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
912 // Test that functor is disconnected
913 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION );
914 customHandle.GetCustomSignal().Emit();
915 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1/*not incremented*/, TEST_LOCATION );
916 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
917 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
922 int UtcDaliTypeRegistrySignalConnectorTypeN(void)
924 // Test what happens when signal connnector (DoConnectSignalFailure method) returns false
926 ResetFunctorCounts();
928 TestApplication application;
930 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
931 DALI_TEST_CHECK( type );
933 TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( "CustomActor" );
934 DALI_TEST_CHECK( baseType );
936 BaseHandle handle = type.CreateInstance();
937 DALI_TEST_CHECK( handle );
939 MyTestCustomActor customHandle = MyTestCustomActor::DownCast( handle );
940 DALI_TEST_CHECK( customHandle );
942 DALI_TEST_EQUALS( type.GetActionCount(), TEST_ACTION_COUNT + baseType.GetActionCount(), TEST_LOCATION );
944 DALI_TEST_EQUALS( type.GetSignalCount(), TEST_SIGNAL_COUNT + baseType.GetSignalCount(), TEST_LOCATION );
947 TestConnectionTracker tracker;
949 bool connected = handle.ConnectSignal( &tracker, "sig2", CustomTestFunctor() );
950 DALI_TEST_EQUALS( connected, false/*This is supposed to fail*/, TEST_LOCATION );
951 DALI_TEST_CHECK( lastSignalConnectionCustom == "failed" );
952 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
953 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0/*deleted along with FunctorDelegate*/, TEST_LOCATION );
956 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
957 customHandle.GetCustomSignal().Emit();
958 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0/*never called*/, TEST_LOCATION );
960 // tracker should have nothing to disconnect here
963 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
964 customHandle.GetCustomSignal().Emit();
965 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0/*never called*/, TEST_LOCATION );
969 int UtcDaliTypeRegistryTypeActionP(void)
971 ResetFunctorCounts();
973 TestApplication application;
975 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
976 DALI_TEST_CHECK( type );
978 BaseHandle handle = type.CreateInstance();
979 DALI_TEST_CHECK( handle );
981 Property::Map attributes;
982 DALI_TEST_CHECK( handle.DoAction("act1", attributes) );
983 DALI_TEST_CHECK( lastActionCustom == "act1" );
988 int UtcDaliTypeRegistryTypeActionN(void)
990 ResetFunctorCounts();
992 TestApplication application;
994 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
995 DALI_TEST_CHECK( type );
997 BaseHandle handle = type.CreateInstance();
998 DALI_TEST_CHECK( handle );
1000 Property::Map attributes;
1001 DALI_TEST_CHECK( !handle.DoAction( "unknownAction", attributes ) );
1006 int UtcDaliTypeRegistryPropertyRegistrationP(void)
1008 TestApplication application;
1009 TypeRegistry typeRegistry = TypeRegistry::Get();
1011 // Check property count before property registration
1012 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1013 DALI_TEST_CHECK( typeInfo );
1014 BaseHandle handle = typeInfo.CreateInstance();
1015 DALI_TEST_CHECK( handle );
1016 Actor customActor = Actor::DownCast( handle );
1017 DALI_TEST_CHECK( customActor );
1018 unsigned int initialPropertyCount( customActor.GetPropertyCount() );
1020 std::string propertyName( "prop1" );
1021 int propertyIndex( PROPERTY_REGISTRATION_START_INDEX );
1022 Property::Type propertyType( Property::BOOLEAN );
1023 PropertyRegistration property1( customType1, propertyName, propertyIndex, propertyType, &SetProperty, &GetProperty );
1025 // Check property count after registration
1026 unsigned int postRegistrationPropertyCount( customActor.GetPropertyCount() );
1027 DALI_TEST_EQUALS( initialPropertyCount + 1u, postRegistrationPropertyCount, TEST_LOCATION );
1029 // Add custom property and check property count
1030 customActor.RegisterProperty( "customProp1", true );
1031 unsigned int customPropertyCount( customActor.GetPropertyCount() );
1032 DALI_TEST_EQUALS( postRegistrationPropertyCount + 1u, customPropertyCount, TEST_LOCATION );
1034 // Set the property, ensure SetProperty called
1035 DALI_TEST_CHECK( !setPropertyCalled );
1036 customActor.SetProperty( propertyIndex, false );
1037 DALI_TEST_CHECK( setPropertyCalled );
1039 // Get the property, ensure GetProperty called
1040 DALI_TEST_CHECK( !getPropertyCalled );
1041 (void)customActor.GetProperty< bool >( propertyIndex );
1042 DALI_TEST_CHECK( getPropertyCalled );
1044 // Get the property using GetCurrentProperty and ensure GetProperty is called
1045 getPropertyCalled = false;
1046 DALI_TEST_CHECK( !getPropertyCalled );
1047 customActor.GetCurrentProperty< bool >( propertyIndex );
1048 DALI_TEST_CHECK( getPropertyCalled );
1050 // Check the property name
1051 DALI_TEST_EQUALS( customActor.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
1052 DALI_TEST_EQUALS( typeInfo.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
1054 // Check the property index
1055 DALI_TEST_EQUALS( customActor.GetPropertyIndex( propertyName ), propertyIndex, TEST_LOCATION );
1057 // Check the property type
1058 DALI_TEST_EQUALS( customActor.GetPropertyType( propertyIndex ), propertyType, TEST_LOCATION );
1060 // Check property count of type-info is 1
1061 Property::IndexContainer indices;
1062 typeInfo.GetPropertyIndices( indices );
1064 size_t typePropertyCount = typeInfo.GetPropertyCount();
1065 DALI_TEST_EQUALS( indices.Size(), Actor::New().GetPropertyCount() + 1u, TEST_LOCATION );
1066 DALI_TEST_EQUALS( indices.Size(), typePropertyCount, TEST_LOCATION );
1068 // Ensure indices returned from actor and customActor differ by two
1069 Actor actor = Actor::New();
1070 actor.GetPropertyIndices( indices );
1071 unsigned int actorIndices = indices.Size();
1072 customActor.GetPropertyIndices( indices );
1073 unsigned int customActorIndices = indices.Size();
1074 DALI_TEST_EQUALS( actorIndices + 2u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1078 int UtcDaliTypeRegistryPropertyRegistrationN(void)
1080 TestApplication application;
1081 TypeRegistry typeRegistry = TypeRegistry::Get();
1083 // Attempt to register a property type out-of-bounds index (less than)
1086 PropertyRegistration property1( customType1, "propName", PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN, &SetProperty, &GetProperty );
1087 tet_result( TET_FAIL );
1089 catch ( DaliException& e )
1091 DALI_TEST_ASSERT( e, "( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1094 // Attempt to register a property type out-of-bounds index (greater than)
1097 PropertyRegistration property1( customType1, "propName", PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN, &SetProperty, &GetProperty );
1098 tet_result( TET_FAIL );
1100 catch ( DaliException& e )
1102 DALI_TEST_ASSERT( e, "( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1108 int UtcDaliTypeRegistryAnimatablePropertyRegistrationP(void)
1110 TestApplication application;
1111 TypeRegistry typeRegistry = TypeRegistry::Get();
1113 // Check property count before property registration
1114 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1115 DALI_TEST_CHECK( typeInfo );
1116 BaseHandle handle = typeInfo.CreateInstance();
1117 DALI_TEST_CHECK( handle );
1118 Actor customActor = Actor::DownCast( handle );
1119 DALI_TEST_CHECK( customActor );
1120 application.GetScene().Add(customActor);
1122 unsigned int customPropertyCount( customActor.GetPropertyCount() );
1124 // Register animatable property
1125 std::string animatablePropertyName( "animatableProp1" );
1126 int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1127 Property::Type animatablePropertyType( Property::FLOAT );
1128 AnimatablePropertyRegistration animatableProperty( customType1, animatablePropertyName, animatablePropertyIndex, animatablePropertyType );
1130 // Check property count after registration
1131 DALI_TEST_EQUALS( customPropertyCount + 1u, customActor.GetPropertyCount(), TEST_LOCATION );
1133 // Set the animatable property value
1134 customActor.SetProperty( animatablePropertyIndex, 25.0f );
1136 // Render and notify
1137 application.SendNotification();
1138 application.Render();
1140 // Check the animatable property value
1141 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 25.f, TEST_LOCATION );
1143 // Check the animatable property name
1144 DALI_TEST_EQUALS( customActor.GetPropertyName( animatablePropertyIndex ), animatablePropertyName, TEST_LOCATION );
1146 // Check the animatable property index
1147 DALI_TEST_EQUALS( customActor.GetPropertyIndex( animatablePropertyName ), animatablePropertyIndex, TEST_LOCATION );
1149 // Check the animatable property type
1150 DALI_TEST_EQUALS( customActor.GetPropertyType( animatablePropertyIndex ), animatablePropertyType, TEST_LOCATION );
1152 // Check property count of type-info is 1
1153 Property::IndexContainer indices;
1154 typeInfo.GetPropertyIndices( indices );
1155 DALI_TEST_EQUALS( indices.Size(), customActor.GetPropertyCount(), TEST_LOCATION );
1157 // Ensure indices returned from actor and customActor differ by one
1158 Actor actor = Actor::New();
1159 actor.GetPropertyIndices( indices );
1160 unsigned int actorIndices = indices.Size();
1161 customActor.GetPropertyIndices( indices );
1162 unsigned int customActorIndices = indices.Size();
1163 DALI_TEST_EQUALS( actorIndices + 1u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1165 // check that the property is animatable
1166 Animation animation = Animation::New(0.2f);
1167 animation.AnimateTo( Property( customActor, animatablePropertyIndex ), 15.f, AlphaFunction::LINEAR );
1170 // Target value should change straight away
1171 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 15.0f, TEST_LOCATION );
1173 // Render and notify, animation play for 0.05 seconds
1174 application.SendNotification();
1175 application.Render(50);
1176 DALI_TEST_EQUALS( 0.25f, animation.GetCurrentProgress(), TEST_LOCATION );
1177 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 22.5f, TEST_LOCATION );
1179 // Render and notify, animation play for another 0.1 seconds
1180 application.SendNotification();
1181 application.Render(100);
1182 DALI_TEST_EQUALS( 0.75f, animation.GetCurrentProgress(), TEST_LOCATION );
1183 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 17.5f, TEST_LOCATION );
1188 int UtcDaliTypeRegistryAnimatablePropertyRegistrationN(void)
1190 TestApplication application;
1191 TypeRegistry typeRegistry = TypeRegistry::Get();
1193 // Attempt to register an animatable property type out-of-bounds index (less than)
1196 AnimatablePropertyRegistration property1( customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN );
1197 tet_result( TET_FAIL );
1199 catch ( DaliException& e )
1201 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1204 // Attempt to register an animatable property type out-of-bounds index (greater than)
1207 AnimatablePropertyRegistration property1( customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN );
1208 tet_result( TET_FAIL );
1210 catch ( DaliException& e )
1212 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1218 int UtcDaliTypeRegistryAnimatablePropertyRegistrationWithDefaultP(void)
1220 TestApplication application;
1221 TypeRegistry typeRegistry = TypeRegistry::Get();
1223 // Check property count before property registration
1224 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1225 DALI_TEST_CHECK( typeInfo );
1226 BaseHandle handle = typeInfo.CreateInstance();
1227 DALI_TEST_CHECK( handle );
1228 Actor customActor = Actor::DownCast( handle );
1229 DALI_TEST_CHECK( customActor );
1230 application.GetScene().Add(customActor);
1232 unsigned int customPropertyCount( customActor.GetPropertyCount() );
1234 // Register animatable property
1235 std::string animatablePropertyName( "animatableProp1" );
1236 int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1237 AnimatablePropertyRegistration animatableProperty1( customType1, animatablePropertyName, animatablePropertyIndex, 10.f );
1239 // Check property count after registration
1240 DALI_TEST_EQUALS( customPropertyCount + 1u, customActor.GetPropertyCount(), TEST_LOCATION );
1242 // Render and notify
1243 application.SendNotification();
1244 application.Render();
1246 // Check the animatable property value
1247 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 10.f, TEST_LOCATION );
1249 // Check the animatable property name
1250 DALI_TEST_EQUALS( customActor.GetPropertyName( animatablePropertyIndex ), animatablePropertyName, TEST_LOCATION );
1252 // Check the animatable property index
1253 DALI_TEST_EQUALS( customActor.GetPropertyIndex( animatablePropertyName ), animatablePropertyIndex, TEST_LOCATION );
1255 // Check the animatable property type
1256 DALI_TEST_EQUALS( customActor.GetPropertyType( animatablePropertyIndex ), Property::FLOAT, TEST_LOCATION );
1258 // Check property count of type-info
1259 Property::IndexContainer indices;
1260 typeInfo.GetPropertyIndices( indices );
1261 DALI_TEST_EQUALS( indices.Size(), customActor.GetPropertyCount(), TEST_LOCATION );
1263 // Ensure indices returned from actor and customActor differ by one
1264 Actor actor = Actor::New();
1265 actor.GetPropertyIndices( indices );
1266 unsigned int actorIndices = indices.Size();
1267 customActor.GetPropertyIndices( indices );
1268 unsigned int customActorIndices = indices.Size();
1269 DALI_TEST_EQUALS( actorIndices + 1u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1271 // check that the property is animatable
1272 Animation animation = Animation::New(0.2f);
1273 animation.AnimateTo( Property( customActor, animatablePropertyIndex ), 20.f, AlphaFunction::LINEAR );
1276 // Target value should change straight away
1277 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 20.0f, TEST_LOCATION );
1279 // Render and notify, animation play for 0.05 seconds
1280 application.SendNotification();
1281 application.Render(50);
1282 DALI_TEST_EQUALS( 0.25f, animation.GetCurrentProgress(), TEST_LOCATION );
1283 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 12.5f, TEST_LOCATION );
1285 // Render and notify, animation play for another 0.1 seconds
1286 application.SendNotification();
1287 application.Render(100);
1288 DALI_TEST_EQUALS( 0.75f, animation.GetCurrentProgress(), TEST_LOCATION );
1289 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 17.5f, TEST_LOCATION );
1294 int UtcDaliTypeRegistryAnimatablePropertyRegistrationWithDefaultN(void)
1296 TestApplication application;
1297 TypeRegistry typeRegistry = TypeRegistry::Get();
1299 // Attempt to register an animatable property type out-of-bounds index (less than)
1302 AnimatablePropertyRegistration property1( customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX - 1, false );
1303 tet_result( TET_FAIL );
1305 catch ( DaliException& e )
1307 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1310 // Attempt to register an animatable property type out-of-bounds index (greater than)
1313 AnimatablePropertyRegistration property1( customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX + 1, true );
1314 tet_result( TET_FAIL );
1316 catch ( DaliException& e )
1318 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1324 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationP(void)
1326 TestApplication application;
1327 TypeRegistry typeRegistry = TypeRegistry::Get();
1329 // Check property count before property registration
1330 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1331 DALI_TEST_CHECK( typeInfo );
1332 BaseHandle handle = typeInfo.CreateInstance();
1333 DALI_TEST_CHECK( handle );
1334 Actor customActor = Actor::DownCast( handle );
1335 DALI_TEST_CHECK( customActor );
1337 unsigned int customPropertyCount( customActor.GetPropertyCount() );
1339 // Register animatable property
1340 std::string animatablePropertyName( "animatableProp1" );
1341 int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1342 Property::Type animatablePropertyType( Property::VECTOR2 );
1343 AnimatablePropertyRegistration animatableProperty1( customType1, animatablePropertyName, animatablePropertyIndex, animatablePropertyType );
1345 // Check property count after registration
1346 DALI_TEST_EQUALS( customPropertyCount + 1u, customActor.GetPropertyCount(), TEST_LOCATION );
1348 // Set the animatable property value
1349 customActor.SetProperty( animatablePropertyIndex, Vector2(25.0f, 50.0f) );
1351 // Render and notify
1352 application.SendNotification();
1353 application.Render();
1355 // Check the animatable property value
1356 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( animatablePropertyIndex ), Vector2(25.0f, 50.0f), TEST_LOCATION );
1358 // Check the animatable property name
1359 DALI_TEST_EQUALS( customActor.GetPropertyName( animatablePropertyIndex ), animatablePropertyName, TEST_LOCATION );
1361 // Check the animatable property index
1362 DALI_TEST_EQUALS( customActor.GetPropertyIndex( animatablePropertyName ), animatablePropertyIndex, TEST_LOCATION );
1364 // Check the animatable property type
1365 DALI_TEST_EQUALS( customActor.GetPropertyType( animatablePropertyIndex ), animatablePropertyType, TEST_LOCATION );
1367 // Check property count of type-info
1368 Property::IndexContainer indices;
1369 typeInfo.GetPropertyIndices( indices );
1370 DALI_TEST_EQUALS( indices.Size(), customActor.GetPropertyCount(), TEST_LOCATION );
1372 // Register animatable property components
1373 std::string animatablePropertyComponentName1( "animatableProp1X" );
1374 int animatablePropertyComponentIndex1( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1 );
1375 AnimatablePropertyComponentRegistration animatablePropertyComponent1( customType1, animatablePropertyComponentName1, animatablePropertyComponentIndex1, animatablePropertyIndex, 0 );
1377 std::string animatablePropertyComponentName2( "animatableProp1Y" );
1378 int animatablePropertyComponentIndex2( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2 );
1379 AnimatablePropertyComponentRegistration animatablePropertyComponent2( customType1, animatablePropertyComponentName2, animatablePropertyComponentIndex2, animatablePropertyIndex, 1 );
1381 // Check property count after registration
1382 DALI_TEST_EQUALS( customPropertyCount + 3u, customActor.GetPropertyCount(), TEST_LOCATION );
1384 // Check the animatable property component value
1385 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex1 ), 25.0f, TEST_LOCATION );
1386 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex2 ), 50.0f, TEST_LOCATION );
1388 // Set the animatable property component value
1389 customActor.SetProperty( animatablePropertyComponentIndex1, 150.0f );
1391 // Render and notify
1392 application.SendNotification();
1393 application.Render();
1395 // Check the animatable property value
1396 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector2 >( animatablePropertyIndex ), Vector2(150.0f, 50.0f), TEST_LOCATION );
1397 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex1 ), 150.0f, TEST_LOCATION );
1398 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex2 ), 50.0f, TEST_LOCATION );
1400 // Set the animatable property component value
1401 customActor.SetProperty( animatablePropertyComponentIndex2, 225.0f );
1403 // Render and notify
1404 application.SendNotification();
1405 application.Render();
1407 // Check the animatable property value
1408 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector2 >( animatablePropertyIndex ), Vector2(150.0f, 225.0f), TEST_LOCATION );
1409 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex1 ), 150.0f, TEST_LOCATION );
1410 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex2 ), 225.0f, TEST_LOCATION );
1412 // Ensure indices returned from actor and customActor differ by three
1413 Actor actor = Actor::New();
1414 actor.GetPropertyIndices( indices );
1415 unsigned int actorIndices = indices.Size();
1416 customActor.GetPropertyIndices( indices );
1417 unsigned int customActorIndices = indices.Size();
1418 DALI_TEST_EQUALS( actorIndices + 3u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1420 // Attempt to animate component property, it should not crash
1421 Animation animation = Animation::New( 1.0f );
1422 animation.AnimateTo( Property( customActor, animatablePropertyComponentIndex1 ), 200.0f );
1425 // Check the property value
1426 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( animatablePropertyIndex ), Vector2(200.0f, 225.0f), TEST_LOCATION );
1427 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex1 ), 200.0f, TEST_LOCATION );
1428 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex2 ), 225.0f, TEST_LOCATION );
1433 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationVector2AnimateByP(void)
1435 TestApplication application;
1436 TypeRegistry typeRegistry = TypeRegistry::Get();
1438 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1439 DALI_TEST_CHECK( typeInfo );
1440 BaseHandle handle = typeInfo.CreateInstance();
1441 DALI_TEST_CHECK( handle );
1442 Actor customActor = Actor::DownCast( handle );
1443 DALI_TEST_CHECK( customActor );
1445 const unsigned int index = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX;
1446 const unsigned int xComponentIndex = index + 1;
1447 const unsigned int yComponentIndex = index + 2;
1448 const Vector2 initialValue( 20.0f, 40.0f );
1450 // Register animatable property & its components
1451 AnimatablePropertyRegistration animatableProperty1( customType1, "animatableProp1", index, initialValue );
1452 AnimatablePropertyComponentRegistration animatablePropertyComponent1( customType1, "animatableProp1X", xComponentIndex, index, 0 );
1453 AnimatablePropertyComponentRegistration animatablePropertyComponent2( customType1, "animatableProp1Y", yComponentIndex, index, 1 );
1455 // Check the animatable property value
1456 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( index ), initialValue, TEST_LOCATION );
1457 DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
1458 DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
1460 // Render and notify
1461 application.SendNotification();
1462 application.Render();
1464 // Check the animatable property current value
1465 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector2 >( index ), initialValue, TEST_LOCATION );
1466 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
1467 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
1470 const Vector2 targetValue( 45.0f, 53.0f );
1471 const Vector2 relativeValue( targetValue - initialValue );
1473 Animation animation = Animation::New( 1.0f );
1474 animation.AnimateBy( Property( customActor, xComponentIndex ), relativeValue.x );
1475 animation.AnimateBy( Property( customActor, yComponentIndex ), relativeValue.y );
1478 // Target values should change straight away
1479 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
1480 DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), targetValue.x, TEST_LOCATION );
1481 DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), targetValue.y, TEST_LOCATION );
1486 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationVector3AnimateByP(void)
1488 TestApplication application;
1489 TypeRegistry typeRegistry = TypeRegistry::Get();
1491 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1492 DALI_TEST_CHECK( typeInfo );
1493 BaseHandle handle = typeInfo.CreateInstance();
1494 DALI_TEST_CHECK( handle );
1495 Actor customActor = Actor::DownCast( handle );
1496 DALI_TEST_CHECK( customActor );
1498 const unsigned int index = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX;
1499 const unsigned int xComponentIndex = index + 1;
1500 const unsigned int yComponentIndex = index + 2;
1501 const unsigned int zComponentIndex = index + 3;
1502 const Vector3 initialValue( 20.0f, 40.0f, 50.0f );
1504 // Register animatable property & its components
1505 AnimatablePropertyRegistration animatableProperty1( customType1, "animatableProp1", index, initialValue );
1506 AnimatablePropertyComponentRegistration animatablePropertyComponent1( customType1, "animatableProp1X", xComponentIndex, index, 0 );
1507 AnimatablePropertyComponentRegistration animatablePropertyComponent2( customType1, "animatableProp1Y", yComponentIndex, index, 1 );
1508 AnimatablePropertyComponentRegistration animatablePropertyComponent3( customType1, "animatableProp1Z", zComponentIndex, index, 2 );
1510 // Check the animatable property value
1511 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( index ), initialValue, TEST_LOCATION );
1512 DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
1513 DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
1514 DALI_TEST_EQUALS( customActor.GetProperty< float >( zComponentIndex ), initialValue.z, TEST_LOCATION );
1516 // Render and notify
1517 application.SendNotification();
1518 application.Render();
1520 // Check the animatable property current value
1521 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector3 >( index ), initialValue, TEST_LOCATION );
1522 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
1523 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
1524 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( zComponentIndex ), initialValue.z, TEST_LOCATION );
1527 const Vector3 targetValue( 45.0f, 53.0f, 25.0f );
1528 const Vector3 relativeValue( targetValue - initialValue );
1530 Animation animation = Animation::New( 1.0f );
1531 animation.AnimateBy( Property( customActor, xComponentIndex ), relativeValue.x );
1532 animation.AnimateBy( Property( customActor, yComponentIndex ), relativeValue.y );
1533 animation.AnimateBy( Property( customActor, zComponentIndex ), relativeValue.z );
1536 // Target values should change straight away
1537 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
1538 DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), targetValue.x, TEST_LOCATION );
1539 DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), targetValue.y, TEST_LOCATION );
1540 DALI_TEST_EQUALS( customActor.GetProperty< float >( zComponentIndex ), targetValue.z, TEST_LOCATION );
1545 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationVector4AnimateByP(void)
1547 TestApplication application;
1548 TypeRegistry typeRegistry = TypeRegistry::Get();
1550 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1551 DALI_TEST_CHECK( typeInfo );
1552 BaseHandle handle = typeInfo.CreateInstance();
1553 DALI_TEST_CHECK( handle );
1554 Actor customActor = Actor::DownCast( handle );
1555 DALI_TEST_CHECK( customActor );
1557 const unsigned int index = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX;
1558 const unsigned int xComponentIndex = index + 1;
1559 const unsigned int yComponentIndex = index + 2;
1560 const unsigned int zComponentIndex = index + 3;
1561 const unsigned int wComponentIndex = index + 4;
1562 const Vector4 initialValue( 20.0f, 40.0f, 50.0f, 60.0f );
1564 // Register animatable property & its components
1565 AnimatablePropertyRegistration animatableProperty1( customType1, "animatableProp1", index, initialValue );
1566 AnimatablePropertyComponentRegistration animatablePropertyComponent1( customType1, "animatableProp1X", xComponentIndex, index, 0 );
1567 AnimatablePropertyComponentRegistration animatablePropertyComponent2( customType1, "animatableProp1Y", yComponentIndex, index, 1 );
1568 AnimatablePropertyComponentRegistration animatablePropertyComponent3( customType1, "animatableProp1Z", zComponentIndex, index, 2 );
1569 AnimatablePropertyComponentRegistration animatablePropertyComponent4( customType1, "animatableProp1W", wComponentIndex, index, 3 );
1571 // Check the animatable property value
1572 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( index ), initialValue, TEST_LOCATION );
1573 DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
1574 DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
1575 DALI_TEST_EQUALS( customActor.GetProperty< float >( zComponentIndex ), initialValue.z, TEST_LOCATION );
1576 DALI_TEST_EQUALS( customActor.GetProperty< float >( wComponentIndex ), initialValue.w, TEST_LOCATION );
1578 // Render and notify
1579 application.SendNotification();
1580 application.Render();
1582 // Check the animatable property current value
1583 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector4 >( index ), initialValue, TEST_LOCATION );
1584 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
1585 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
1586 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( zComponentIndex ), initialValue.z, TEST_LOCATION );
1587 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( wComponentIndex ), initialValue.w, TEST_LOCATION );
1590 const Vector4 targetValue( 45.0f, 53.0f, 25.0f, 13.0f );
1591 const Vector4 relativeValue( targetValue - initialValue );
1593 Animation animation = Animation::New( 1.0f );
1594 animation.AnimateBy( Property( customActor, xComponentIndex ), relativeValue.x );
1595 animation.AnimateBy( Property( customActor, yComponentIndex ), relativeValue.y );
1596 animation.AnimateBy( Property( customActor, zComponentIndex ), relativeValue.z );
1597 animation.AnimateBy( Property( customActor, wComponentIndex ), relativeValue.w );
1600 // Target values should change straight away
1601 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
1602 DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), targetValue.x, TEST_LOCATION );
1603 DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), targetValue.y, TEST_LOCATION );
1604 DALI_TEST_EQUALS( customActor.GetProperty< float >( zComponentIndex ), targetValue.z, TEST_LOCATION );
1605 DALI_TEST_EQUALS( customActor.GetProperty< float >( wComponentIndex ), targetValue.w, TEST_LOCATION );
1610 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationN(void)
1612 TestApplication application;
1613 TypeRegistry typeRegistry = TypeRegistry::Get();
1615 // Register animatable property with the type of Vector2
1616 int animatablePropertyIndex1( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1617 AnimatablePropertyRegistration animatableProperty1( customType1, "animatableProp1", animatablePropertyIndex1, Property::VECTOR2 );
1619 // Attempt to register an animatable property component out-of-bounds index (less than)
1622 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp1X", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX - 1, animatablePropertyIndex1, 0 );
1623 tet_result( TET_FAIL );
1625 catch ( DaliException& e )
1627 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1630 // Attempt to register an animatable property component out-of-bounds index (greater than)
1633 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp1X", ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX + 1, animatablePropertyIndex1, 0 );
1634 tet_result( TET_FAIL );
1636 catch ( DaliException& e )
1638 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1641 // Register an animatable property component
1642 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp1X", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1, animatablePropertyIndex1, 0 );
1644 // Attempt to register another animatable property component with the same component index
1647 AnimatablePropertyComponentRegistration propertyComponent2( customType1, "animatableProp1Y", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2, animatablePropertyIndex1, 0 );
1648 tet_result( TET_FAIL );
1650 catch ( DaliException& e )
1652 DALI_TEST_ASSERT( e, "Property component already registered", TEST_LOCATION );
1655 // Register animatable property with the type of boolean
1656 int animatablePropertyIndex2( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2 );
1657 AnimatablePropertyRegistration animatableProperty2( customType1, "animatableProp2", animatablePropertyIndex2, Property::BOOLEAN );
1659 // Attempt to register an animatable property component for the above property with boolean type
1662 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp2X", animatablePropertyIndex2 + 1, animatablePropertyIndex2, 0 );
1663 tet_result( TET_FAIL );
1665 catch ( DaliException& e )
1667 DALI_TEST_ASSERT( e, "Base property does not support component", TEST_LOCATION );
1673 int UtcDaliTypeRegistryChildPropertyRegistrationP(void)
1675 TestApplication application;
1676 TypeRegistry typeRegistry = TypeRegistry::Get();
1678 // Check property count before property registration
1679 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1680 DALI_TEST_CHECK( typeInfo );
1681 BaseHandle handle = typeInfo.CreateInstance();
1682 DALI_TEST_CHECK( handle );
1683 Actor customActor = Actor::DownCast( handle );
1684 DALI_TEST_CHECK( customActor );
1685 unsigned int initialPropertyCount( customActor.GetPropertyCount() );
1687 // Register child properties to the parent
1688 std::string propertyName( "childProp1" );
1689 int propertyIndex( CHILD_PROPERTY_REGISTRATION_START_INDEX );
1690 Property::Type propertyType( Property::BOOLEAN );
1691 ChildPropertyRegistration childProperty1( customType1, propertyName, propertyIndex, propertyType );
1693 std::string propertyName2( "childProp2" );
1694 int propertyIndex2( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1 );
1695 Property::Type propertyType2( Property::INTEGER );
1696 ChildPropertyRegistration childProperty2( customType1, propertyName2, propertyIndex2, propertyType2 );
1698 std::string propertyName3( "childProp3" );
1699 int propertyIndex3( CHILD_PROPERTY_REGISTRATION_START_INDEX + 2 );
1700 Property::Type propertyType3( Property::FLOAT );
1701 ChildPropertyRegistration childProperty3( customType1, propertyName3, propertyIndex3, propertyType3 );
1703 std::string propertyName4( "childProp4" );
1704 int propertyIndex4( CHILD_PROPERTY_REGISTRATION_START_INDEX + 3 );
1705 Property::Type propertyType4( Property::INTEGER );
1706 ChildPropertyRegistration childProperty4( customType1, propertyName4, propertyIndex4, propertyType4 );
1708 // Check property count are not changed because the child properties will not be created for the parent
1709 DALI_TEST_EQUALS( initialPropertyCount, customActor.GetPropertyCount(), TEST_LOCATION );
1711 // check the child property type
1712 Internal::TypeInfo& typeInfoImpl = GetImplementation( typeInfo );
1713 Property::Type type = typeInfoImpl.GetChildPropertyType( typeInfoImpl.GetChildPropertyIndex("childProp4") );
1714 DALI_TEST_EQUALS( type, Property::INTEGER, TEST_LOCATION );
1716 std::string unRegisteredChildName( typeInfoImpl.GetChildPropertyName( CHILD_PROPERTY_REGISTRATION_START_INDEX + 4 ) );
1717 DALI_TEST_EQUALS( unRegisteredChildName, "", TEST_LOCATION );
1719 // Create a child actor
1720 Actor childActor = Actor::New();
1721 DALI_TEST_CHECK( childActor );
1722 unsigned int initialChildActorPropertyCount( childActor.GetPropertyCount() );
1724 // The type of child properties should be Property::None as the child hasn't registered any child property yet.
1725 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex ), Property::NONE, TEST_LOCATION );
1726 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex2 ), Property::NONE, TEST_LOCATION );
1727 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex3 ), Property::NONE, TEST_LOCATION );
1728 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex4 ), Property::NONE, TEST_LOCATION );
1730 // Set the value for the first child property when the child actor doesn't have a parent yet
1731 childActor.SetProperty(propertyIndex, true);
1733 // Check that the first child property is dynamically created
1734 DALI_TEST_EQUALS( initialChildActorPropertyCount + 1u, childActor.GetPropertyCount(), TEST_LOCATION );
1736 // Check the first child property value
1737 DALI_TEST_EQUALS( childActor.GetProperty< bool >( propertyIndex ), true, TEST_LOCATION );
1739 // Check the first child property type
1740 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex ), propertyType, TEST_LOCATION );
1742 // Check that the first child property have no name, as it doesn't have a parent yet.
1743 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex ), "", TEST_LOCATION );
1745 // Check that the first property can't be accessed through its name, as it doesn't have a parent yet.
1746 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName ), Property::INVALID_INDEX, TEST_LOCATION );
1748 // Create a custom property for the child with the same name as the second child property registered to the parent
1749 Property::Index customPropertyIndex = childActor.RegisterProperty(propertyName2, 100, Property::READ_WRITE);
1751 // Check that the custom property is created
1752 DALI_TEST_EQUALS( initialChildActorPropertyCount + 2u, childActor.GetPropertyCount(), TEST_LOCATION );
1754 // Check the property value
1755 DALI_TEST_EQUALS( childActor.GetProperty< int >( customPropertyIndex ), 100, TEST_LOCATION );
1757 // Check the property index
1758 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName2 ), customPropertyIndex, TEST_LOCATION );
1760 // Check the property type
1761 DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex ), propertyType2, TEST_LOCATION );
1763 // Check the property name
1764 DALI_TEST_EQUALS( childActor.GetPropertyName( customPropertyIndex ), propertyName2, TEST_LOCATION );
1766 // Now add the child actor to the parent
1767 customActor.Add( childActor );
1769 // Check that the first child property now has the correct name as previously registered to the parent
1770 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
1772 // Check that the child property index for the first child property can now be retrieved through its child property name
1773 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName ), propertyIndex, TEST_LOCATION );
1775 // Check that the second child property now has the correct index as previously registered to the parent
1776 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex2 ), propertyName2, TEST_LOCATION );
1778 // Check that the second child property can be accessed through both its custom property index and its child property index
1779 DALI_TEST_EQUALS( childActor.GetProperty< int >( customPropertyIndex ), 100, TEST_LOCATION );
1780 DALI_TEST_EQUALS( childActor.GetProperty< int >( propertyIndex2 ), 100, TEST_LOCATION );
1781 DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex ), propertyType2, TEST_LOCATION );
1782 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex2 ), propertyType2, TEST_LOCATION );
1784 // Check that the child property index for the second child property can now be retrieved through its child property name
1785 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName2 ), propertyIndex2, TEST_LOCATION );
1787 // Set the value for the third child property when the child actor is already added to the parent
1788 childActor.SetProperty(propertyIndex3, 0.15f);
1790 // Check that the third child property is dynamically created
1791 DALI_TEST_EQUALS( initialChildActorPropertyCount + 3u, childActor.GetPropertyCount(), TEST_LOCATION );
1793 // Check the third child property value
1794 DALI_TEST_EQUALS( childActor.GetProperty< float >( propertyIndex3 ), 0.15f, TEST_LOCATION );
1796 // Check the third child property type
1797 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex3 ), propertyType3, TEST_LOCATION );
1799 // Check the third child property name
1800 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex3 ), propertyName3, TEST_LOCATION );
1802 // Check the third child property index.
1803 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName3 ), propertyIndex3, TEST_LOCATION );
1805 // Create a custom property for the child with the same name as the fourth child property registered to the parent
1806 Property::Index customPropertyIndex2 = childActor.RegisterProperty(propertyName4, 20, Property::READ_WRITE);
1808 // Check that the custom property is created
1809 DALI_TEST_EQUALS( initialChildActorPropertyCount + 4u, childActor.GetPropertyCount(), TEST_LOCATION );
1811 // Check the fourth child property value
1812 DALI_TEST_EQUALS( childActor.GetProperty< int >( propertyIndex4 ), 20, TEST_LOCATION );
1813 DALI_TEST_EQUALS( childActor.GetProperty< int >( customPropertyIndex2 ), 20, TEST_LOCATION );
1815 // Check the fourth child property type
1816 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex4 ), propertyType4, TEST_LOCATION );
1817 DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex2 ), propertyType4, TEST_LOCATION );
1819 // Check the fourth child property name
1820 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex4 ), propertyName4, TEST_LOCATION );
1821 DALI_TEST_EQUALS( childActor.GetPropertyName( customPropertyIndex2 ), propertyName4, TEST_LOCATION );
1823 // Check the fourth child property index.
1824 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName4 ), propertyIndex4, TEST_LOCATION );
1826 // Now create another parent actor with different child properties registered
1827 TypeInfo typeInfo2 = typeRegistry.GetTypeInfo( "MyNamedActor" );
1828 DALI_TEST_CHECK( typeInfo2 );
1829 BaseHandle handle2 = typeInfo2.CreateInstance();
1830 DALI_TEST_CHECK( handle2 );
1831 Actor customActor2 = Actor::DownCast( handle2 );
1832 DALI_TEST_CHECK( customActor2 );
1834 // Register child properties to the new parent
1835 std::string newPropertyName( "newChildProp" );
1836 int newPropertyIndex( CHILD_PROPERTY_REGISTRATION_START_INDEX ); // The same index as the first child property "childProp1" in the old parent
1837 Property::Type newPropertyType( Property::VECTOR2 );
1838 ChildPropertyRegistration newChildProperty( namedActorType, newPropertyName, newPropertyIndex, newPropertyType );
1840 std::string newPropertyName2( "childProp3" ); // The same name as the third child property in the old parent
1841 int newPropertyIndex2( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1 ); // The same index as the second child property "childProp2" in the old parent
1842 Property::Type newPropertyType2( Property::FLOAT ); // The same type as the third child property in the old parent
1843 ChildPropertyRegistration newChildProperty2( namedActorType, newPropertyName2, newPropertyIndex2, newPropertyType2 );
1845 // Now move the child actor to the new parent
1846 customActor2.Add( childActor );
1848 // "childProp1" is not a valid child property supported by the new parent, so nothing changed
1849 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex ), propertyType, TEST_LOCATION );
1850 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
1851 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName ), propertyIndex, TEST_LOCATION );
1853 // "childProp3" is a valid child property supported by the new parent
1854 // So it should get its new child property index and should just work
1855 DALI_TEST_EQUALS( childActor.GetPropertyType( newPropertyIndex2 ), newPropertyType2, TEST_LOCATION );
1856 DALI_TEST_EQUALS( childActor.GetPropertyName( newPropertyIndex2 ), newPropertyName2, TEST_LOCATION );
1857 DALI_TEST_EQUALS( childActor.GetPropertyIndex( newPropertyName2 ), newPropertyIndex2, TEST_LOCATION );
1858 DALI_TEST_EQUALS( childActor.GetProperty< float >( newPropertyIndex2 ), 0.15f, TEST_LOCATION );
1860 // Now register a custom property called "newChildProp"
1861 Property::Index customPropertyIndex3 = childActor.RegisterProperty("newChildProp", Vector2( 10.0f, 10.0f ), Property::READ_WRITE);
1863 // Check that the custom property is created
1864 DALI_TEST_EQUALS( initialChildActorPropertyCount + 5u, childActor.GetPropertyCount(), TEST_LOCATION );
1866 // This is a valid child property registered to the new parent
1867 // So should be able to access it through both its custom property index and its registered child property index
1868 DALI_TEST_EQUALS( childActor.GetPropertyType( newPropertyIndex ), newPropertyType, TEST_LOCATION );
1869 DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex3 ), newPropertyType, TEST_LOCATION );
1870 DALI_TEST_EQUALS( childActor.GetPropertyName( newPropertyIndex ), newPropertyName, TEST_LOCATION ); // This should return the new name, although the child property index remains the same
1871 DALI_TEST_EQUALS( childActor.GetPropertyName( customPropertyIndex3 ), newPropertyName, TEST_LOCATION );
1872 DALI_TEST_EQUALS( childActor.GetProperty< Vector2 >( newPropertyIndex ), Vector2( 10.0f, 10.0f ), TEST_LOCATION );
1873 DALI_TEST_EQUALS( childActor.GetProperty< Vector2 >( customPropertyIndex3 ), Vector2( 10.0f, 10.0f ), TEST_LOCATION );
1875 // Should return the child property index by given its name
1876 DALI_TEST_EQUALS( childActor.GetPropertyIndex( newPropertyName ), newPropertyIndex, TEST_LOCATION );
1882 int UtcDaliTypeRegistryChildPropertyRegistrationN(void)
1884 TestApplication application;
1885 TypeRegistry typeRegistry = TypeRegistry::Get();
1887 // Attempt to register a child property type out-of-bounds index (less than)
1890 ChildPropertyRegistration property1( customType1, "propName", CHILD_PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN );
1891 tet_result( TET_FAIL );
1893 catch ( DaliException& e )
1895 DALI_TEST_ASSERT( e, "( index >= CHILD_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1898 // Attempt to register a child property type out-of-bounds index (greater than)
1901 ChildPropertyRegistration property1( customType1, "propName", CHILD_PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN );
1902 tet_result( TET_FAIL );
1904 catch ( DaliException& e )
1906 DALI_TEST_ASSERT( e, "( index >= CHILD_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1913 /*******************************************************************************
1915 * Action through the base handle
1917 ******************************************************************************/
1918 int UtcDaliTypeRegistryActionViaBaseHandle(void)
1920 TestApplication application;
1924 type = TypeRegistry::Get().GetTypeInfo( "Actor" );
1925 DALI_TEST_CHECK( type );
1927 BaseHandle hdl = type.CreateInstance();
1928 DALI_TEST_CHECK( hdl );
1930 Actor a = Actor::DownCast(hdl);
1931 DALI_TEST_CHECK( a );
1933 a.SetProperty( Actor::Property::VISIBLE,false);
1935 application.SendNotification();
1936 application.Render(0);
1937 DALI_TEST_CHECK(!a.GetCurrentProperty< bool >( Actor::Property::VISIBLE ));
1939 Property::Map attributes;
1941 DALI_TEST_CHECK(hdl.DoAction("show", attributes));
1943 application.SendNotification();
1944 application.Render(0);
1945 DALI_TEST_CHECK(a.GetCurrentProperty< bool >( Actor::Property::VISIBLE ));
1947 DALI_TEST_CHECK(!hdl.DoAction("unknownAction", attributes));
1951 int UtcDaliPropertyRegistrationFunctions(void)
1953 TestApplication application;
1954 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 10;
1956 // Attempt to register a property without a setter
1959 PropertyRegistration property1( customType1, "propName", propertyIndex++, Property::BOOLEAN, NULL, &GetProperty );
1960 tet_result( TET_PASS );
1962 catch ( DaliException& e )
1964 tet_result( TET_FAIL );
1967 // Attempt to register a property without a getter
1970 PropertyRegistration property1( customType1, "propName", propertyIndex++, Property::BOOLEAN, NULL, NULL );
1971 tet_result( TET_FAIL );
1973 catch ( DaliException& e )
1975 DALI_TEST_ASSERT( e, "! \"GetProperty", TEST_LOCATION );
1980 int UtcDaliPropertyRegistrationAddSameIndex(void)
1982 TestApplication application;
1983 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 100;
1985 // Add one property with a valid property index
1986 PropertyRegistration property1( customType1, "propName", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
1988 // Attempt to add another property with the same index
1991 PropertyRegistration property2( customType1, "propName2", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
1993 catch ( DaliException& e )
1995 DALI_TEST_ASSERT( e, "! \"Property index already added", TEST_LOCATION );
1998 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 100;
2000 // Add one property with a valid property index
2001 AnimatablePropertyRegistration property3( customType1, "animPropName", animatablePropertyIndex, Property::BOOLEAN );
2003 // Attempt to add another property with the same index
2006 AnimatablePropertyRegistration property4( customType1, "animPropName2", animatablePropertyIndex, Property::BOOLEAN );
2008 catch ( DaliException& e )
2010 DALI_TEST_ASSERT( e, "! \"Property index already added", TEST_LOCATION );
2015 int UtcDaliPropertyRegistrationPropertyWritableP(void)
2017 TestApplication application;
2018 int propertyIndex1 = PROPERTY_REGISTRATION_START_INDEX + 200;
2019 int propertyIndex2 = PROPERTY_REGISTRATION_START_INDEX + 201;
2021 // Add two properties, one with SetProperty, one without
2022 PropertyRegistration property1( customType1, "propNameReadwrite", propertyIndex1, Property::BOOLEAN, &SetProperty, &GetProperty );
2023 PropertyRegistration property2( customType1, "propNameReadonly", propertyIndex2, Property::BOOLEAN, NULL, &GetProperty );
2025 // Create custom-actor
2026 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
2027 DALI_TEST_CHECK( typeInfo );
2028 BaseHandle handle = typeInfo.CreateInstance();
2029 DALI_TEST_CHECK( handle );
2030 Actor customActor = Actor::DownCast( handle );
2031 DALI_TEST_CHECK( customActor );
2033 // Check whether properties are writable
2034 DALI_TEST_CHECK( customActor.IsPropertyWritable( propertyIndex1 ) );
2035 DALI_TEST_CHECK( ! customActor.IsPropertyWritable( propertyIndex2 ) );
2038 // Check the property is writable in the type registry
2039 Internal::TypeInfo& typeInfoImpl = GetImplementation( typeInfo );
2041 DALI_TEST_EQUALS( typeInfoImpl.IsPropertyWritable( propertyIndex1 ), true, TEST_LOCATION );
2046 int UtcDaliPropertyRegistrationPropertyWritableN(void)
2048 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
2049 Internal::TypeInfo& typeInfoImpl = GetImplementation( typeInfo );
2051 DALI_TEST_EQUALS( typeInfoImpl.IsPropertyWritable( Actor::Property::COLOR), true, TEST_LOCATION );
2056 int UtcDaliPropertyRegistrationPropertyAnimatable(void)
2058 TestApplication application;
2059 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 400;
2060 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 400;
2062 // These properties are not animatable
2063 PropertyRegistration property1( customType1, "propName", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
2065 // These properties are animatable
2066 AnimatablePropertyRegistration property2( customType1, "animPropName", animatablePropertyIndex, Property::BOOLEAN );
2068 // Create custom-actor
2069 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
2070 DALI_TEST_CHECK( typeInfo );
2071 BaseHandle handle = typeInfo.CreateInstance();
2072 DALI_TEST_CHECK( handle );
2073 Actor customActor = Actor::DownCast( handle );
2074 DALI_TEST_CHECK( customActor );
2076 // Check if animatable
2077 DALI_TEST_CHECK( ! customActor.IsPropertyAnimatable( propertyIndex ) );
2078 DALI_TEST_CHECK( customActor.IsPropertyAnimatable( animatablePropertyIndex ) );
2080 // Create another instance of custom-actor
2081 BaseHandle handle2 = typeInfo.CreateInstance();
2082 DALI_TEST_CHECK( handle2 );
2083 Actor customActor2 = Actor::DownCast( handle2 );
2084 DALI_TEST_CHECK( customActor2 );
2086 // Check if animatable
2087 DALI_TEST_CHECK( ! customActor2.IsPropertyAnimatable( propertyIndex ) );
2088 DALI_TEST_CHECK( customActor2.IsPropertyAnimatable( animatablePropertyIndex ) );
2092 int UtcDaliPropertyRegistrationUnregisteredGetAndSet(void)
2094 TestApplication application;
2095 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 2000;
2096 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2000;
2098 // Create custom-actor
2099 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
2100 DALI_TEST_CHECK( typeInfo );
2101 BaseHandle handle = typeInfo.CreateInstance();
2102 DALI_TEST_CHECK( handle );
2103 Actor customActor = Actor::DownCast( handle );
2104 DALI_TEST_CHECK( customActor );
2106 // Try to set an index that hasn't been registered, this is a no-op for now, to be fixed in future
2107 customActor.SetProperty( propertyIndex, true );
2108 // DALI_TEST_EQUALS( true, customActor.GetProperty( propertyIndex ).Get<bool>(), TEST_LOCATION);
2110 // Try to set an index that hasn't been registered
2111 customActor.SetProperty( animatablePropertyIndex, true );
2112 DALI_TEST_EQUALS( true, customActor.GetProperty( animatablePropertyIndex ).Get<bool>(), TEST_LOCATION);
2118 int UtcDaliLongPressGestureDetectorTypeRegistry(void)
2120 TestApplication application;
2122 Actor actor = Actor::New();
2123 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
2124 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
2125 application.GetScene().Add(actor);
2129 type = TypeRegistry::Get().GetTypeInfo( "LongPressGestureDetector" );
2130 DALI_TEST_CHECK( type );
2131 BaseHandle handle = type.CreateInstance();
2132 DALI_TEST_CHECK( handle );
2133 LongPressGestureDetector detector = LongPressGestureDetector::DownCast( handle );
2134 DALI_TEST_CHECK( detector );
2136 // Attach actor to detector
2138 GestureReceivedFunctor functor( data );
2139 detector.Attach(actor);
2141 // Connect to signal through type
2142 handle.ConnectSignal( &application, "longPressDetected", functor );
2144 // Render and notify
2145 application.SendNotification();
2146 application.Render();
2149 TestGenerateLongPress( application, 50.0f, 10.0f );
2150 TestEndLongPress( application, 50.0f, 10.0f );
2152 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2156 int UtcDaliPanGestureDetectorTypeRegistry(void)
2158 TestApplication application;
2160 Actor actor = Actor::New();
2161 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
2162 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
2163 application.GetScene().Add(actor);
2167 type = TypeRegistry::Get().GetTypeInfo( "PanGestureDetector" );
2168 DALI_TEST_CHECK( type );
2169 BaseHandle handle = type.CreateInstance();
2170 DALI_TEST_CHECK( handle );
2171 PanGestureDetector detector = PanGestureDetector::DownCast( handle );
2172 DALI_TEST_CHECK( detector );
2174 // Attach actor to detector
2176 GestureReceivedFunctor functor( data );
2177 detector.Attach(actor);
2179 // Connect to signal through type
2180 handle.ConnectSignal( &application, "panDetected", functor );
2182 // Render and notify
2183 application.SendNotification();
2184 application.Render();
2187 TestGenerateMiniPan( application );
2188 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2192 int UtcDaliPinchGestureDetectorTypeRegistry(void)
2194 TestApplication application;
2196 Actor actor = Actor::New();
2197 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
2198 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
2199 application.GetScene().Add(actor);
2203 type = TypeRegistry::Get().GetTypeInfo( "PinchGestureDetector" );
2204 DALI_TEST_CHECK( type );
2205 BaseHandle handle = type.CreateInstance();
2206 DALI_TEST_CHECK( handle );
2207 PinchGestureDetector detector = PinchGestureDetector::DownCast( handle );
2208 DALI_TEST_CHECK( detector );
2210 // Attach actor to detector
2212 GestureReceivedFunctor functor( data );
2213 detector.Attach(actor);
2215 // Connect to signal through type
2216 handle.ConnectSignal( &application, "pinchDetected", functor );
2218 // Render and notify
2219 application.SendNotification();
2220 application.Render();
2223 TestGeneratePinch( application );
2225 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2229 int UtcDaliRotationGestureDetectorTypeRegistry(void)
2231 TestApplication application;
2233 Actor actor = Actor::New();
2234 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
2235 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
2236 application.GetScene().Add(actor);
2240 type = TypeRegistry::Get().GetTypeInfo( "RotationGestureDetector" );
2241 DALI_TEST_CHECK( type );
2242 BaseHandle handle = type.CreateInstance();
2243 DALI_TEST_CHECK( handle );
2244 RotationGestureDetector detector = RotationGestureDetector::DownCast( handle );
2245 DALI_TEST_CHECK( detector );
2247 // Attach actor to detector
2249 GestureReceivedFunctor functor( data );
2250 detector.Attach(actor);
2252 // Connect to signal through type
2253 handle.ConnectSignal( &application, "rotationDetected", functor );
2255 // Render and notify
2256 application.SendNotification();
2257 application.Render();
2260 TestGenerateRotation( application );
2262 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2266 int UtcDaliTapGestureDetectorTypeRegistry(void)
2268 TestApplication application;
2270 Actor actor = Actor::New();
2271 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
2272 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
2273 application.GetScene().Add(actor);
2277 type = TypeRegistry::Get().GetTypeInfo( "TapGestureDetector" );
2278 DALI_TEST_CHECK( type );
2279 BaseHandle handle = type.CreateInstance();
2280 DALI_TEST_CHECK( handle );
2281 TapGestureDetector detector = TapGestureDetector::DownCast( handle );
2282 DALI_TEST_CHECK( detector );
2284 // Attach actor to detector
2286 GestureReceivedFunctor functor( data );
2287 detector.Attach(actor);
2289 // Connect to signal through type
2290 handle.ConnectSignal( &application, "tapDetected", functor );
2292 // Render and notify
2293 application.SendNotification();
2294 application.Render();
2297 TestGenerateTap( application, 50.0, 10.0, 100 );
2299 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2303 int UtcDaliTypeRegistryNamedType(void)
2305 TestApplication application;
2306 TypeRegistry typeRegistry = TypeRegistry::Get();
2308 // Create a normal actor
2309 BaseHandle actorHandle = typeRegistry.GetTypeInfo( "Actor" ).CreateInstance();
2310 DALI_TEST_CHECK( actorHandle );
2311 Actor actor( Actor::DownCast( actorHandle ) );
2312 DALI_TEST_CHECK( actor );
2313 unsigned int actorPropertyCount( actor.GetPropertyCount() );
2315 // Create Named Actor Type
2316 BaseHandle namedHandle = typeRegistry.GetTypeInfo( "MyNamedActor" ).CreateInstance();
2317 DALI_TEST_CHECK( namedHandle );
2318 Actor namedActor( Actor::DownCast( namedHandle ) );
2319 DALI_TEST_CHECK( namedActor );
2320 unsigned int namedActorPropertyCount( namedActor.GetPropertyCount() );
2322 DALI_TEST_CHECK( namedActorPropertyCount > actorPropertyCount );
2326 int UtcDaliTypeInfoGetActionNameP(void)
2328 TestApplication application;
2329 TypeRegistry typeRegistry = TypeRegistry::Get();
2331 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2332 DALI_TEST_CHECK( typeInfo );
2334 DALI_TEST_CHECK( 0 != typeInfo.GetActionCount() );
2336 std::string name = typeInfo.GetActionName(0);
2338 DALI_TEST_EQUALS( name, "show", TEST_LOCATION );
2341 TypeInfo typeInfo2 = typeRegistry.GetTypeInfo( "MyTestCustomActor" );
2343 // search for show action in base class, given a derived class
2344 bool foundChildAction = false;
2345 for( std::size_t i = 0; i < typeInfo2.GetActionCount(); i++ )
2348 std::string name = typeInfo2.GetActionName( i );
2351 foundChildAction = true;
2356 DALI_TEST_EQUALS( foundChildAction, true, TEST_LOCATION );
2362 int UtcDaliTypeInfoGetActionNameN(void)
2364 TestApplication application;
2365 TypeRegistry typeRegistry = TypeRegistry::Get();
2367 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2368 DALI_TEST_CHECK( typeInfo );
2370 DALI_TEST_CHECK( 0 != typeInfo.GetActionCount() );
2372 std::string name = typeInfo.GetActionName(std::numeric_limits<size_t>::max());
2374 DALI_TEST_EQUALS( 0u, name.size(), TEST_LOCATION );
2379 int UtcDaliTypeInfoGetSignalNameP(void)
2381 TestApplication application;
2382 TypeRegistry typeRegistry = TypeRegistry::Get();
2384 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2385 DALI_TEST_CHECK( typeInfo );
2387 DALI_TEST_CHECK( 0 != typeInfo.GetSignalCount() );
2389 std::string name = typeInfo.GetSignalName(0);
2391 DALI_TEST_EQUALS( name, "hovered", TEST_LOCATION );
2393 TypeInfo typeInfo2 = typeRegistry.GetTypeInfo( "MyTestCustomActor" );
2395 // search for signal in base class, given a derived class
2396 bool foundSignal = false;
2397 for( std::size_t i = 0; i < typeInfo2.GetSignalCount(); i++ )
2399 std::string name = typeInfo2.GetSignalName( i );
2400 if( name == "hovered")
2406 DALI_TEST_EQUALS( foundSignal, true, TEST_LOCATION );
2411 int UtcDaliTypeInfoGetSignalNameN(void)
2413 TestApplication application;
2414 TypeRegistry typeRegistry = TypeRegistry::Get();
2416 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2417 DALI_TEST_CHECK( typeInfo );
2419 DALI_TEST_CHECK( 0 != typeInfo.GetSignalCount() );
2421 std::string name = typeInfo.GetSignalName(std::numeric_limits<size_t>::max());
2423 DALI_TEST_EQUALS( 0u, name.size(), TEST_LOCATION );
2429 int UtcDaliTypeInfoGetCreatorP(void)
2431 TestApplication application;
2432 TypeRegistry typeRegistry = TypeRegistry::Get();
2434 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2435 DALI_TEST_CHECK( typeInfo );
2437 TypeInfo::CreateFunction createFn = typeInfo.GetCreator();
2438 DALI_TEST_EQUALS( createFn != NULL, true, TEST_LOCATION );
2442 BaseHandle handle = createFn();
2443 DALI_TEST_EQUALS( (bool)handle, true, TEST_LOCATION );
2449 int UtcDaliTypeInfoGetCreatorN(void)
2451 TestApplication application;
2452 TypeRegistry typeRegistry = TypeRegistry::Get();
2454 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "MyTestCustomActor3" );
2455 DALI_TEST_CHECK( typeInfo );
2457 TypeInfo::CreateFunction createFn = typeInfo.GetCreator();
2458 DALI_TEST_EQUALS( createFn == NULL, true, TEST_LOCATION );
2463 int UtcDaliTypeInfoGetPropertyCountP1(void)
2465 TestApplication application;
2466 TypeRegistry typeRegistry = TypeRegistry::Get();
2468 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2469 DALI_TEST_CHECK( typeInfo );
2470 size_t actorPropertyCount = typeInfo.GetPropertyCount();
2472 DALI_TEST_EQUALS( actorPropertyCount, Actor::New().GetPropertyCount(), TEST_LOCATION ); // No event only props
2476 int UtcDaliTypeInfoGetPropertyCountP2(void)
2478 TestApplication application;
2479 TypeRegistry typeRegistry = TypeRegistry::Get();
2481 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "MyTestCustomActor2" );
2482 DALI_TEST_CHECK( typeInfo );
2483 size_t propertyCount = typeInfo.GetPropertyCount();
2484 Property::IndexContainer indices;
2485 typeInfo.GetPropertyIndices( indices );
2487 DALI_TEST_EQUALS( propertyCount > 0 && propertyCount <= indices.Size(), true, TEST_LOCATION );
2488 DALI_TEST_EQUALS( propertyCount, Actor::New().GetPropertyCount() + 2, TEST_LOCATION );
2493 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGet01(void)
2495 TestApplication application;
2496 TypeRegistry typeRegistry = TypeRegistry::Get();
2498 tet_infoline( "Register a type registered animatable property and ensure set/get behaviour works synchronously" );
2500 // Register animatable property
2501 const int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
2502 AnimatablePropertyRegistration animatableProperty( customType1, "animatableProp1", animatablePropertyIndex, Property::FLOAT );
2504 // Check property count before property registration
2505 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2506 DALI_TEST_CHECK( typeInfo );
2507 BaseHandle handle = typeInfo.CreateInstance();
2508 DALI_TEST_CHECK( handle );
2509 Actor customActor = Actor::DownCast( handle );
2510 DALI_TEST_CHECK( customActor );
2511 application.GetScene().Add(customActor);
2513 tet_infoline( "Set the value and ensure it changes straight away" );
2514 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 0.0f, TEST_LOCATION );
2515 customActor.SetProperty( animatablePropertyIndex, 25.0f );
2516 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 25.0f, TEST_LOCATION );
2518 tet_infoline( "Check latest scene-graph value is unchanged" );
2519 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 0.0f, TEST_LOCATION );
2521 // Render and notify
2522 application.SendNotification();
2523 application.Render();
2525 tet_infoline( "Check values after rendering and both retrieval methods should return the latest" );
2527 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 25.0f, TEST_LOCATION );
2528 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 25.0f, TEST_LOCATION );
2533 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGetWithComponentsVector2(void)
2535 TestApplication application;
2536 TypeRegistry typeRegistry = TypeRegistry::Get();
2538 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" );
2540 // Register the animatable propeties
2541 const int basePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
2542 const int componentZeroPropertyIndex( basePropertyIndex + 1 );
2543 const int componentOnePropertyIndex( componentZeroPropertyIndex + 1 );
2544 AnimatablePropertyRegistration baseAnimatableProperty( customType1, "baseProp", basePropertyIndex, Vector2( 13.0f, 24.0f ) );
2545 AnimatablePropertyComponentRegistration componentZeroAnimatableProperty( customType1, "componentZeroProp", componentZeroPropertyIndex, basePropertyIndex, 0 );
2546 AnimatablePropertyComponentRegistration componentOneAnimatableProperty( customType1, "componentOneProp", componentOnePropertyIndex, basePropertyIndex, 1 );
2548 // Check property count before property registration
2549 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2550 DALI_TEST_CHECK( typeInfo );
2551 BaseHandle handle = typeInfo.CreateInstance();
2552 DALI_TEST_CHECK( handle );
2553 Actor customActor = Actor::DownCast( handle );
2554 DALI_TEST_CHECK( customActor );
2555 application.GetScene().Add(customActor);
2557 tet_infoline( "Get the component values, they should be the default value of the base-property" );
2558 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2559 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2560 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 13.0f, 24.0f ), TEST_LOCATION );
2562 tet_infoline( "Set a component value and ensure it changes for the base property as well" );
2563 customActor.SetProperty( componentZeroPropertyIndex, 125.0f );
2564 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2565 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 125.0f, 24.0f ), TEST_LOCATION );
2567 customActor.SetProperty( componentOnePropertyIndex, 225.0f );
2568 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2569 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 125.0f, 225.0f ), TEST_LOCATION );
2571 tet_infoline( "Check latest scene-graph value is unchanged" );
2572 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector2 >( basePropertyIndex ), Vector2( 13.0f, 24.0f ), TEST_LOCATION );
2573 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2574 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2576 // Render and notify
2577 application.SendNotification();
2578 application.Render();
2580 tet_infoline( "Check values after rendering and both retrieval methods should return the latest" );
2581 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 125.0f, 225.0f ), TEST_LOCATION );
2582 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2583 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2585 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector2 >( basePropertyIndex ), Vector2( 125.0f, 225.0f ), TEST_LOCATION );
2586 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2587 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2589 tet_infoline( "Set the base property value and ensure the component values reflect the change" );
2590 customActor.SetProperty( basePropertyIndex, Vector2( 1.0f, 2.0f ) );
2591 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 1.0f, TEST_LOCATION );
2592 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 2.0f, TEST_LOCATION );
2593 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 1.0f, 2.0f ), TEST_LOCATION );
2598 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGetWithComponentsVector3(void)
2600 TestApplication application;
2601 TypeRegistry typeRegistry = TypeRegistry::Get();
2603 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" );
2605 // Register the animatable propeties
2606 const int basePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
2607 const int componentZeroPropertyIndex( basePropertyIndex + 1 );
2608 const int componentOnePropertyIndex( componentZeroPropertyIndex + 1 );
2609 const int componentTwoPropertyIndex( componentOnePropertyIndex + 1 );
2610 AnimatablePropertyRegistration baseAnimatableProperty( customType1, "baseProp", basePropertyIndex, Vector3( 13.0f, 24.0f, 35.0 ) );
2611 AnimatablePropertyComponentRegistration componentZeroAnimatableProperty( customType1, "componentZeroProp", componentZeroPropertyIndex, basePropertyIndex, 0 );
2612 AnimatablePropertyComponentRegistration componentOneAnimatableProperty( customType1, "componentOneProp", componentOnePropertyIndex, basePropertyIndex, 1 );
2613 AnimatablePropertyComponentRegistration componentTwoAnimatableProperty( customType1, "componentTwoProp", componentTwoPropertyIndex, basePropertyIndex, 2 );
2615 // Check property count before property registration
2616 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2617 DALI_TEST_CHECK( typeInfo );
2618 BaseHandle handle = typeInfo.CreateInstance();
2619 DALI_TEST_CHECK( handle );
2620 Actor customActor = Actor::DownCast( handle );
2621 DALI_TEST_CHECK( customActor );
2622 application.GetScene().Add(customActor);
2624 tet_infoline( "Get the component values, they should be the default value of the base-property" );
2625 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2626 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2627 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 35.0f, TEST_LOCATION );
2628 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 13.0f, 24.0f, 35.0f ), TEST_LOCATION );
2630 tet_infoline( "Set a component value and ensure it changes for the base property as well" );
2631 customActor.SetProperty( componentZeroPropertyIndex, 125.0f );
2632 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2633 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 24.0f, 35.0f ), TEST_LOCATION );
2635 customActor.SetProperty( componentOnePropertyIndex, 225.0f );
2636 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2637 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 225.0f, 35.0f ), TEST_LOCATION );
2639 customActor.SetProperty( componentTwoPropertyIndex, 325.0f );
2640 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2641 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 225.0f, 325.0f ), TEST_LOCATION );
2643 tet_infoline( "Check latest scene-graph value is unchanged" );
2644 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector3 >( basePropertyIndex ), Vector3( 13.0f, 24.0f, 35.0f ), TEST_LOCATION );
2645 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2646 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2647 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentTwoPropertyIndex ), 35.0f, TEST_LOCATION );
2649 // Render and notify
2650 application.SendNotification();
2651 application.Render();
2653 tet_infoline( "Check values after rendering and both retrieval methods should return the latest" );
2654 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 225.0f, 325.0f ), TEST_LOCATION );
2655 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2656 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2657 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2659 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 225.0f, 325.0f ), TEST_LOCATION );
2660 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2661 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2662 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2664 tet_infoline( "Set the base property value and ensure the component values reflect the change" );
2665 customActor.SetProperty( basePropertyIndex, Vector3( 1.0f, 2.0f, 3.0f ) );
2666 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 1.0f, TEST_LOCATION );
2667 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 2.0f, TEST_LOCATION );
2668 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 3.0f, TEST_LOCATION );
2669 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 1.0f, 2.0f, 3.0f ), TEST_LOCATION );
2674 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGetWithComponentsVector4(void)
2676 TestApplication application;
2677 TypeRegistry typeRegistry = TypeRegistry::Get();
2679 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" );
2681 // Register the animatable propeties
2682 const int basePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
2683 const int componentZeroPropertyIndex( basePropertyIndex + 1 );
2684 const int componentOnePropertyIndex( componentZeroPropertyIndex + 1 );
2685 const int componentTwoPropertyIndex( componentOnePropertyIndex + 1 );
2686 const int componentThreePropertyIndex( componentTwoPropertyIndex + 1 );
2687 AnimatablePropertyRegistration baseAnimatableProperty( customType1, "baseProp", basePropertyIndex, Vector4( 13.0f, 24.0f, 35.0, 47.0f ) );
2688 AnimatablePropertyComponentRegistration componentZeroAnimatableProperty( customType1, "componentZeroProp", componentZeroPropertyIndex, basePropertyIndex, 0 );
2689 AnimatablePropertyComponentRegistration componentOneAnimatableProperty( customType1, "componentOneProp", componentOnePropertyIndex, basePropertyIndex, 1 );
2690 AnimatablePropertyComponentRegistration componentTwoAnimatableProperty( customType1, "componentTwoProp", componentTwoPropertyIndex, basePropertyIndex, 2 );
2691 AnimatablePropertyComponentRegistration componentThreeAnimatableProperty( customType1, "componentThreeProp", componentThreePropertyIndex, basePropertyIndex, 3 );
2693 // Check property count before property registration
2694 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2695 DALI_TEST_CHECK( typeInfo );
2696 BaseHandle handle = typeInfo.CreateInstance();
2697 DALI_TEST_CHECK( handle );
2698 Actor customActor = Actor::DownCast( handle );
2699 DALI_TEST_CHECK( customActor );
2700 application.GetScene().Add(customActor);
2702 tet_infoline( "Get the component values, they should be the default value of the base-property" );
2703 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2704 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2705 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 35.0f, TEST_LOCATION );
2706 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentThreePropertyIndex ), 47.0f, TEST_LOCATION );
2707 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 13.0f, 24.0f, 35.0f, 47.0f ), TEST_LOCATION );
2709 tet_infoline( "Set a component value and ensure it changes for the base property as well" );
2710 customActor.SetProperty( componentZeroPropertyIndex, 125.0f );
2711 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2712 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 24.0f, 35.0f, 47.0f ), TEST_LOCATION );
2714 customActor.SetProperty( componentOnePropertyIndex, 225.0f );
2715 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2716 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 35.0f, 47.0f ), TEST_LOCATION );
2718 customActor.SetProperty( componentTwoPropertyIndex, 325.0f );
2719 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2720 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 325.0f, 47.0f ), TEST_LOCATION );
2722 customActor.SetProperty( componentThreePropertyIndex, 435.0f );
2723 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentThreePropertyIndex ), 435.0f, TEST_LOCATION );
2724 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 325.0f, 435.0f ), TEST_LOCATION );
2726 tet_infoline( "Check latest scene-graph value is unchanged" );
2727 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector4 >( basePropertyIndex ), Vector4( 13.0f, 24.0f, 35.0f, 47.0f ), TEST_LOCATION );
2728 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2729 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2730 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentTwoPropertyIndex ), 35.0f, TEST_LOCATION );
2731 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentThreePropertyIndex ), 47.0f, TEST_LOCATION );
2733 // Render and notify
2734 application.SendNotification();
2735 application.Render();
2737 tet_infoline( "Check values after rendering and both retrieval methods should return the latest" );
2738 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 325.0f, 435.0f ), TEST_LOCATION );
2739 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2740 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2741 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2742 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentThreePropertyIndex ), 435.0f, TEST_LOCATION );
2744 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 325.0f, 435.0f ), TEST_LOCATION );
2745 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2746 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2747 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2748 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentThreePropertyIndex ), 435.0f, TEST_LOCATION );
2750 tet_infoline( "Set the base property value and ensure the component values reflect the change" );
2751 customActor.SetProperty( basePropertyIndex, Vector4( 1.0f, 2.0f, 3.0f, 4.0f ) );
2752 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 1.0f, TEST_LOCATION );
2753 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 2.0f, TEST_LOCATION );
2754 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 3.0f, TEST_LOCATION );
2755 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentThreePropertyIndex ), 4.0f, TEST_LOCATION );
2756 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 1.0f, 2.0f, 3.0f, 4.0f ), TEST_LOCATION );
2762 int UtcDaliTypeInfoRegisterChildProperties01(void)
2764 TestApplication application;
2765 TypeRegistry typeRegistry = TypeRegistry::Get();
2767 tet_infoline( "Register child properties on a type via name" );
2769 auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(CustomActor) );
2770 auto myCustomTypeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2771 DALI_TEST_CHECK( customActorTypeInfo );
2772 DALI_TEST_CHECK( myCustomTypeInfo );
2774 const Property::Index WIDTH_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX );
2775 const Property::Index HEIGHT_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1);
2776 const Property::Index MARGIN_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 100);
2778 ChildPropertyRegistration( customActorTypeInfo.GetName(), "widthSpecification", WIDTH_SPECIFICATION, Property::INTEGER );
2779 ChildPropertyRegistration( customActorTypeInfo.GetName(), "heightSpecification", HEIGHT_SPECIFICATION, Property::INTEGER );
2780 ChildPropertyRegistration( myCustomTypeInfo.GetName(), "marginSpecification", MARGIN_SPECIFICATION, Property::EXTENTS );
2782 auto customActor = MyTestCustomActor::New();
2783 application.GetScene().Add( customActor );
2784 auto child = Actor::New();
2785 customActor.Add( child );
2787 child.SetProperty( WIDTH_SPECIFICATION, 33 );
2789 auto value = child.GetProperty( WIDTH_SPECIFICATION );
2790 DALI_TEST_EQUALS( value, Property::Value(33), TEST_LOCATION );
2792 child.SetProperty( HEIGHT_SPECIFICATION, 44 );
2793 value = child.GetProperty( HEIGHT_SPECIFICATION );
2794 DALI_TEST_EQUALS( value, Property::Value(44), TEST_LOCATION );
2796 child.SetProperty( MARGIN_SPECIFICATION, Extents(10, 10, 10, 10) );
2797 value = child.GetProperty( MARGIN_SPECIFICATION );
2798 DALI_TEST_EQUALS( value, Property::Value(Extents(10,10,10,10)), TEST_LOCATION );
2804 int UtcDaliTypeInfoRegisterChildProperties02(void)
2806 TestApplication application;
2807 TypeRegistry typeRegistry = TypeRegistry::Get();
2809 tet_infoline( "Register child properties on a type via name" );
2811 auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(CustomActor) );
2812 auto myCustomTypeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2813 DALI_TEST_CHECK( customActorTypeInfo );
2814 DALI_TEST_CHECK( myCustomTypeInfo );
2816 const Property::Index WIDTH_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX );
2817 const Property::Index HEIGHT_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1);
2818 const Property::Index MARGIN_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 100);
2820 ChildPropertyRegistration( customActorTypeInfo.GetName(), "widthSpecification", WIDTH_SPECIFICATION, Property::INTEGER );
2821 ChildPropertyRegistration( customActorTypeInfo.GetName(), "heightSpecification", HEIGHT_SPECIFICATION, Property::INTEGER );
2822 ChildPropertyRegistration( myCustomTypeInfo.GetName(), "marginSpecification", MARGIN_SPECIFICATION, Property::EXTENTS );
2825 auto index = customActorTypeInfo.GetChildPropertyIndex( "widthSpecification" );
2826 DALI_TEST_EQUALS( index, WIDTH_SPECIFICATION, TEST_LOCATION );
2828 index = customActorTypeInfo.GetChildPropertyIndex( "heightSpecification" );
2829 DALI_TEST_EQUALS( index, HEIGHT_SPECIFICATION, TEST_LOCATION );
2831 index = customActorTypeInfo.GetChildPropertyIndex( "marginSpecification" );
2832 DALI_TEST_EQUALS( index, Property::INVALID_INDEX, TEST_LOCATION );
2834 index = myCustomTypeInfo.GetChildPropertyIndex( "marginSpecification" );
2835 DALI_TEST_EQUALS( index, MARGIN_SPECIFICATION, TEST_LOCATION );
2838 auto name = customActorTypeInfo.GetChildPropertyName( WIDTH_SPECIFICATION );
2839 DALI_TEST_EQUALS( name, "widthSpecification", TEST_LOCATION );
2841 name = customActorTypeInfo.GetChildPropertyName( HEIGHT_SPECIFICATION );
2842 DALI_TEST_EQUALS( name, "heightSpecification", TEST_LOCATION );
2844 name = myCustomTypeInfo.GetChildPropertyName( MARGIN_SPECIFICATION );
2845 DALI_TEST_EQUALS( name, "marginSpecification", TEST_LOCATION );
2848 auto type = customActorTypeInfo.GetChildPropertyType( WIDTH_SPECIFICATION );
2849 DALI_TEST_EQUALS( type, Property::INTEGER, TEST_LOCATION );
2851 type = customActorTypeInfo.GetChildPropertyType( HEIGHT_SPECIFICATION );
2852 DALI_TEST_EQUALS( type, Property::INTEGER, TEST_LOCATION );
2854 type = myCustomTypeInfo.GetChildPropertyType( MARGIN_SPECIFICATION );
2855 DALI_TEST_EQUALS( type, Property::EXTENTS, TEST_LOCATION );
2862 int UtcDaliTypeInfoRegisterChildProperties03(void)
2864 TestApplication application;
2865 TypeRegistry typeRegistry = TypeRegistry::Get();
2867 tet_infoline( "Check registered child properties can be retrieved" );
2869 auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(CustomActor) );
2870 auto myCustomTypeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2871 DALI_TEST_CHECK( customActorTypeInfo );
2872 DALI_TEST_CHECK( myCustomTypeInfo );
2874 const Property::Index WIDTH_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX );
2875 const Property::Index HEIGHT_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1);
2876 const Property::Index MARGIN_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 100);
2878 ChildPropertyRegistration( customActorTypeInfo.GetName(), "widthSpecification", WIDTH_SPECIFICATION, Property::INTEGER );
2879 ChildPropertyRegistration( customActorTypeInfo.GetName(), "heightSpecification", HEIGHT_SPECIFICATION, Property::INTEGER );
2880 ChildPropertyRegistration( myCustomTypeInfo.GetName(), "marginSpecification", MARGIN_SPECIFICATION, Property::EXTENTS );
2882 Property::IndexContainer indices;
2883 myCustomTypeInfo.GetChildPropertyIndices( indices );
2885 auto result = std::find( indices.Begin(), indices.End(), WIDTH_SPECIFICATION );
2886 DALI_TEST_EQUALS( result != indices.End(), true, TEST_LOCATION );
2888 result = std::find( indices.Begin(), indices.End(), HEIGHT_SPECIFICATION );
2889 DALI_TEST_EQUALS( result != indices.End(), true, TEST_LOCATION );
2891 result = std::find( indices.Begin(), indices.End(), MARGIN_SPECIFICATION );
2892 DALI_TEST_EQUALS( result != indices.End(), true, TEST_LOCATION );
2897 int UtcDaliTypeInfoGetActionNameNegative(void)
2899 TestApplication application;
2900 Dali::TypeInfo instance;
2903 unsigned long arg1(0u);
2904 instance.GetActionName(arg1);
2905 DALI_TEST_CHECK(false); // Should not get here
2909 DALI_TEST_CHECK(true); // We expect an assert
2914 int UtcDaliTypeInfoGetSignalNameNegative(void)
2916 TestApplication application;
2917 Dali::TypeInfo instance;
2920 unsigned long arg1(0u);
2921 instance.GetSignalName(arg1);
2922 DALI_TEST_CHECK(false); // Should not get here
2926 DALI_TEST_CHECK(true); // We expect an assert
2931 int UtcDaliTypeInfoGetCreatorNegative(void)
2933 TestApplication application;
2934 Dali::TypeInfo instance;
2937 instance.GetCreator();
2938 DALI_TEST_CHECK(false); // Should not get here
2942 DALI_TEST_CHECK(true); // We expect an assert
2947 int UtcDaliTypeInfoGetBaseNameNegative(void)
2949 TestApplication application;
2950 Dali::TypeInfo instance;
2953 instance.GetBaseName();
2954 DALI_TEST_CHECK(false); // Should not get here
2958 DALI_TEST_CHECK(true); // We expect an assert
2963 int UtcDaliTypeInfoCreateInstanceNegative(void)
2965 TestApplication application;
2966 Dali::TypeInfo instance;
2969 instance.CreateInstance();
2970 DALI_TEST_CHECK(false); // Should not get here
2974 DALI_TEST_CHECK(true); // We expect an assert
2979 int UtcDaliTypeInfoGetActionCountNegative(void)
2981 TestApplication application;
2982 Dali::TypeInfo instance;
2985 instance.GetActionCount();
2986 DALI_TEST_CHECK(false); // Should not get here
2990 DALI_TEST_CHECK(true); // We expect an assert
2995 int UtcDaliTypeInfoGetSignalCountNegative(void)
2997 TestApplication application;
2998 Dali::TypeInfo instance;
3001 instance.GetSignalCount();
3002 DALI_TEST_CHECK(false); // Should not get here
3006 DALI_TEST_CHECK(true); // We expect an assert
3011 int UtcDaliTypeInfoGetPropertyNameNegative(void)
3013 TestApplication application;
3014 Dali::TypeInfo instance;
3018 instance.GetPropertyName(arg1);
3019 DALI_TEST_CHECK(false); // Should not get here
3023 DALI_TEST_CHECK(true); // We expect an assert
3028 int UtcDaliTypeInfoGetPropertyCountNegative(void)
3030 TestApplication application;
3031 Dali::TypeInfo instance;
3034 instance.GetPropertyCount();
3035 DALI_TEST_CHECK(false); // Should not get here
3039 DALI_TEST_CHECK(true); // We expect an assert
3044 int UtcDaliTypeInfoGetPropertyIndicesNegative(void)
3046 TestApplication application;
3047 Dali::TypeInfo instance;
3050 Dali::Vector<int> arg1;
3051 instance.GetPropertyIndices(arg1);
3052 DALI_TEST_CHECK(false); // Should not get here
3056 DALI_TEST_CHECK(true); // We expect an assert
3061 int UtcDaliTypeInfoGetChildPropertyNameNegative(void)
3063 TestApplication application;
3064 Dali::TypeInfo instance;
3068 instance.GetChildPropertyName(arg1);
3069 DALI_TEST_CHECK(false); // Should not get here
3073 DALI_TEST_CHECK(true); // We expect an assert
3078 int UtcDaliTypeInfoGetChildPropertyTypeNegative(void)
3080 TestApplication application;
3081 Dali::TypeInfo instance;
3085 instance.GetChildPropertyType(arg1);
3086 DALI_TEST_CHECK(false); // Should not get here
3090 DALI_TEST_CHECK(true); // We expect an assert
3095 int UtcDaliTypeInfoGetChildPropertyIndexNegative(void)
3097 TestApplication application;
3098 Dali::TypeInfo instance;
3102 instance.GetChildPropertyIndex(arg1);
3103 DALI_TEST_CHECK(false); // Should not get here
3107 DALI_TEST_CHECK(true); // We expect an assert
3112 int UtcDaliTypeInfoGetChildPropertyIndicesNegative(void)
3114 TestApplication application;
3115 Dali::TypeInfo instance;
3118 Dali::Vector<int> arg1;
3119 instance.GetChildPropertyIndices(arg1);
3120 DALI_TEST_CHECK(false); // Should not get here
3124 DALI_TEST_CHECK(true); // We expect an assert
3129 int UtcDaliTypeInfoGetNameNegative(void)
3131 TestApplication application;
3132 Dali::TypeInfo instance;
3136 DALI_TEST_CHECK(false); // Should not get here
3140 DALI_TEST_CHECK(true); // We expect an assert
3145 int UtcDaliTypeRegistryGetTypeInfoNegative01(void)
3147 TestApplication application;
3148 Dali::TypeRegistry instance;
3152 instance.GetTypeInfo(arg1);
3153 DALI_TEST_CHECK(false); // Should not get here
3157 DALI_TEST_CHECK(true); // We expect an assert
3162 int UtcDaliTypeRegistryGetTypeInfoNegative02(void)
3164 TestApplication application;
3165 Dali::TypeRegistry instance;
3168 instance.GetTypeInfo(typeid(unsigned int));
3169 DALI_TEST_CHECK(false); // Should not get here
3173 DALI_TEST_CHECK(true); // We expect an assert
3178 int UtcDaliTypeRegistryGetTypeNameNegative(void)
3180 TestApplication application;
3181 Dali::TypeRegistry instance;
3184 unsigned long arg1(0u);
3185 instance.GetTypeName(arg1);
3186 DALI_TEST_CHECK(false); // Should not get here
3190 DALI_TEST_CHECK(true); // We expect an assert
3195 int UtcDaliTypeRegistryGetTypeNameCountNegative(void)
3197 TestApplication application;
3198 Dali::TypeRegistry instance;
3201 instance.GetTypeNameCount();
3202 DALI_TEST_CHECK(false); // Should not get here
3206 DALI_TEST_CHECK(true); // We expect an assert