2 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <dali/public-api/dali-core.h>
22 #include <dali-test-suite-utils.h>
23 #include <dali/internal/event/common/type-info-impl.h>
24 #include <dali/integration-api/events/touch-event-integ.h>
25 #include <dali/integration-api/events/hover-event-integ.h>
26 #include <dali/devel-api/events/rotation-gesture-detector.h>
34 // Stores data that is populated in the callback and will be read by the Test cases
38 : functorCalled( false ),
39 voidFunctorCalled( false ),
40 receivedGesture( Gesture::Clear ),
46 functorCalled = false;
47 voidFunctorCalled = false;
49 receivedGesture.numberOfTouches = 0u;
50 receivedGesture.screenPoint = Vector2(0.0f, 0.0f);
51 receivedGesture.localPoint = Vector2(0.0f, 0.0f);
57 bool voidFunctorCalled;
58 LongPressGesture receivedGesture;
62 // Functor that sets the data when called
63 struct GestureReceivedFunctor
65 GestureReceivedFunctor(SignalData& data) : signalData(data) { }
67 void operator()(Actor actor, LongPressGesture longPress)
69 signalData.functorCalled = true;
70 signalData.receivedGesture = longPress;
71 signalData.pressedActor = actor;
76 signalData.voidFunctorCalled = true;
79 SignalData& signalData;
83 // Create function as Init function called
85 static bool CreateCustomInitCalled = false;
86 BaseHandle CreateCustomInit(void)
88 CreateCustomInitCalled = true;
92 static bool CreateCustomNamedInitCalled = false;
93 BaseHandle CreateCustomNamedInit(void)
95 CreateCustomNamedInitCalled = true;
99 const std::string scriptedName("PopupStyle");
100 static TypeRegistration scriptedType( scriptedName, typeid(Dali::CustomActor), CreateCustomNamedInit );
102 // Property Registration
103 bool setPropertyCalled = false;
104 bool getPropertyCalled = false;
105 void SetProperty( BaseObject* object, Property::Index propertyIndex, const Property::Value& value )
107 setPropertyCalled = true;
109 Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex )
111 getPropertyCalled = true;
112 return Property::Value( true );
117 /*******************************************************************************
121 ******************************************************************************/
124 struct MyTestCustomActor : public CustomActorImpl
126 typedef Signal< void ()> SignalType;
127 typedef Signal< void (float)> SignalTypeFloat;
129 MyTestCustomActor() : CustomActorImpl( ActorFlags( REQUIRES_TOUCH_EVENTS ) )
132 virtual ~MyTestCustomActor()
135 void ResetCallStack()
139 // From CustomActorImpl
140 virtual void OnSceneConnection( int depth )
143 virtual void OnSceneDisconnection()
146 virtual void OnChildAdd(Actor& child)
149 virtual void OnChildRemove(Actor& child)
152 virtual void OnSizeSet(const Vector3& targetSize)
155 virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize)
158 virtual bool OnHoverEvent(const HoverEvent& event)
162 virtual bool OnWheelEvent(const WheelEvent& event)
166 virtual bool OnKeyEvent(const KeyEvent& event)
170 virtual void OnKeyInputFocusGained()
173 virtual void OnKeyInputFocusLost()
176 virtual Vector3 GetNaturalSize()
178 return Vector3( 0.0f, 0.0f, 0.0f );
181 virtual float GetHeightForWidth( float width )
186 virtual float GetWidthForHeight( float height )
191 virtual void OnRelayout( const Vector2& size, RelayoutContainer& container )
195 virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
199 virtual void OnCalculateRelayoutSize( Dimension::Type dimension )
203 virtual float CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension )
208 virtual void OnLayoutNegotiated( float size, Dimension::Type dimension )
212 virtual bool RelayoutDependentOnChildren( Dimension::Type dimension = Dimension::ALL_DIMENSIONS )
224 class MyTestCustomActor : public CustomActor
228 typedef Signal< void ()> SignalType;
229 typedef Signal< void (float)> SignalTypeFloat;
235 static MyTestCustomActor New()
237 Impl::MyTestCustomActor* p = new Impl::MyTestCustomActor;
238 return MyTestCustomActor( *p ); // takes ownership
241 virtual ~MyTestCustomActor()
245 static MyTestCustomActor DownCast( BaseHandle handle )
247 MyTestCustomActor result;
249 CustomActor custom = Dali::CustomActor::DownCast( handle );
252 CustomActorImpl& customImpl = custom.GetImplementation();
254 Impl::MyTestCustomActor* impl = dynamic_cast<Impl::MyTestCustomActor*>(&customImpl);
258 result = MyTestCustomActor(customImpl.GetOwner());
265 SignalType& GetCustomSignal()
267 Dali::RefObject& obj = GetImplementation();
268 return static_cast<Impl::MyTestCustomActor&>( obj ).mSignal;
273 MyTestCustomActor(Internal::CustomActor* internal)
274 : CustomActor(internal)
278 MyTestCustomActor( Impl::MyTestCustomActor& impl )
279 : CustomActor( impl )
285 class MyTestCustomActor2 : public CustomActor
293 P1=Dali::PROPERTY_REGISTRATION_START_INDEX,
303 static MyTestCustomActor2 New()
305 return MyTestCustomActor2(); // takes ownership
308 virtual ~MyTestCustomActor2()
312 static MyTestCustomActor2 DownCast( BaseHandle handle )
314 MyTestCustomActor2 result;
316 CustomActor custom = Dali::CustomActor::DownCast( handle );
319 CustomActorImpl& customImpl = custom.GetImplementation();
321 Impl::MyTestCustomActor* impl = dynamic_cast<Impl::MyTestCustomActor*>(&customImpl);
325 result = MyTestCustomActor2(customImpl.GetOwner());
334 MyTestCustomActor2(Internal::CustomActor* internal)
335 : CustomActor(internal)
339 MyTestCustomActor2( Impl::MyTestCustomActor& impl )
340 : CustomActor( impl )
345 static TypeRegistration customTypeInit( typeid(MyTestCustomActor2), typeid(Dali::CustomActor), CreateCustomInit, true );
347 PropertyRegistration P1( customTypeInit, "propertyOne", MyTestCustomActor2::Property::P1, Property::INTEGER, &SetProperty, &GetProperty );
348 PropertyRegistration P2( customTypeInit, "propertyTwo", MyTestCustomActor2::Property::P2, Property::STRING, &SetProperty, &GetProperty );
351 class MyTestCustomActor3 : public CustomActor
358 static MyTestCustomActor3 New()
360 return MyTestCustomActor3(); // takes ownership
363 virtual ~MyTestCustomActor3()
367 static MyTestCustomActor3 DownCast( BaseHandle handle )
369 MyTestCustomActor3 result;
371 CustomActor custom = Dali::CustomActor::DownCast( handle );
374 CustomActorImpl& customImpl = custom.GetImplementation();
376 Impl::MyTestCustomActor* impl = dynamic_cast<Impl::MyTestCustomActor*>(&customImpl);
380 result = MyTestCustomActor3(customImpl.GetOwner());
389 MyTestCustomActor3(Internal::CustomActor* internal)
390 : CustomActor(internal)
394 MyTestCustomActor3( Impl::MyTestCustomActor& impl )
395 : CustomActor( impl )
400 static TypeRegistration customTypeBadInit( typeid(MyTestCustomActor3), typeid(Dali::CustomActor), NULL, false );
402 BaseHandle CreateCustom(void)
404 return MyTestCustomActor::New();
407 static std::string lastSignalConnectionCustom;
409 bool DoConnectSignalCustom( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
411 lastSignalConnectionCustom = signalName;
413 bool connected( true );
415 Dali::BaseHandle handle(object);
416 MyTestCustomActor customActor = MyTestCustomActor::DownCast(handle);
418 if( "sig1" == signalName )
420 customActor.GetCustomSignal().Connect( tracker, functor );
424 // signalName does not match any signal
431 bool DoConnectSignalCustomFailure( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
433 lastSignalConnectionCustom = "failed";
435 return false; // This is supposed to fail
438 struct CustomTestFunctor
442 ++mTotalInstanceCount;
443 ++mCurrentInstanceCount;
446 CustomTestFunctor( const CustomTestFunctor& copyMe )
448 ++mTotalInstanceCount;
449 ++mCurrentInstanceCount;
454 --mCurrentInstanceCount;
462 static int mTotalInstanceCount;
463 static int mCurrentInstanceCount;
464 static int mCallbackCount;
467 int CustomTestFunctor::mTotalInstanceCount = 0;
468 int CustomTestFunctor::mCurrentInstanceCount = 0;
469 int CustomTestFunctor::mCallbackCount = 0;
471 static void ResetFunctorCounts()
473 CustomTestFunctor::mTotalInstanceCount = 0;
474 CustomTestFunctor::mCurrentInstanceCount = 0;
475 CustomTestFunctor::mCallbackCount = 0;
478 static std::string lastActionCustom;
479 bool DoActionCustom(BaseObject* object, const std::string& actionName, const Property::Map& /*attributes*/)
481 lastActionCustom = actionName;
485 // Custom type registration
486 static TypeRegistration customType1( typeid(MyTestCustomActor), typeid(Dali::CustomActor), CreateCustom );
489 static SignalConnectorType customSignalConnector1( customType1, "sig1", DoConnectSignalCustom );
490 static SignalConnectorType customSignalConnector2( customType1, "sig2", DoConnectSignalCustomFailure );
491 static const int TEST_SIGNAL_COUNT = 2;
494 static TypeAction customAction1( customType1, "act1", DoActionCustom);
495 static const int TEST_ACTION_COUNT = 1;
497 class TestConnectionTracker : public ConnectionTracker
501 TestConnectionTracker()
506 BaseHandle CreateNamedActorType()
508 Actor actor = Actor::New();
509 actor.SetProperty( Actor::Property::NAME, "NamedActor" );
513 TypeRegistration namedActorType( "MyNamedActor", typeid(Dali::Actor), CreateNamedActorType );
514 PropertyRegistration namedActorPropertyOne( namedActorType, "propName", PROPERTY_REGISTRATION_START_INDEX, Property::BOOLEAN, &SetProperty, &GetProperty );
516 } // Anonymous namespace
518 // Note: No negative test case for UtcDaliTypeRegistryGet can be implemented.
519 int UtcDaliTypeRegistryGetP(void)
521 TestApplication application;
523 TypeRegistry registry = TypeRegistry::Get();
524 DALI_TEST_CHECK( registry );
529 // Note: No negative test case for UtcDaliTypeRegistryConstructor can be implemented.
530 int UtcDaliTypeRegistryConstructorP(void)
532 TestApplication application;
534 TypeRegistry registry;
535 DALI_TEST_CHECK( !registry );
539 // Note: No negative test case for UtcDaliTypeRegistryCopyConstructor can be implemented.
540 int UtcDaliTypeRegistryCopyConstructorP(void)
542 TestApplication application;
544 TypeRegistry registry = TypeRegistry::Get();
545 DALI_TEST_CHECK( registry );
547 TypeRegistry copy( registry );
548 DALI_TEST_CHECK( copy );
550 DALI_TEST_CHECK( registry.GetTypeInfo( "Actor" ).GetName() == copy.GetTypeInfo( "Actor" ).GetName() );
555 // Note: No negative test case for UtcDaliTypeRegistryAssignmentOperator can be implemented.
556 int UtcDaliTypeRegistryAssignmentOperatorP(void)
558 TestApplication application;
560 TypeRegistry registry = TypeRegistry::Get();
561 DALI_TEST_CHECK( registry );
563 TypeRegistry copy = registry;
564 DALI_TEST_CHECK( copy );
565 DALI_TEST_CHECK( registry == copy );
567 DALI_TEST_CHECK( registry.GetTypeInfo( "Actor" ).GetName() == copy.GetTypeInfo( "Actor" ).GetName() );
572 int UtcDaliTypeRegistryMoveConstructor(void)
574 TestApplication application;
576 TypeRegistry registry = TypeRegistry::Get();
577 DALI_TEST_CHECK( registry );
578 DALI_TEST_EQUALS( 16, registry.GetBaseObject().ReferenceCount(), TEST_LOCATION );
579 DALI_TEST_CHECK( registry.GetTypeInfo( "Actor" ).GetName() == "Actor" );
581 TypeRegistry movedRegistry = std::move( registry );
582 DALI_TEST_CHECK( movedRegistry );
583 DALI_TEST_EQUALS( 16, movedRegistry.GetBaseObject().ReferenceCount(), TEST_LOCATION );
584 DALI_TEST_CHECK( movedRegistry.GetTypeInfo( "Actor" ).GetName() == "Actor" );
585 DALI_TEST_CHECK( !registry );
587 Dali::TypeInfo info = movedRegistry.GetTypeInfo( "Actor" );
588 DALI_TEST_CHECK( info );
589 DALI_TEST_EQUALS( 2, info.GetBaseObject().ReferenceCount(), TEST_LOCATION );
590 DALI_TEST_CHECK( info.GetName() == "Actor" );
592 Dali::TypeInfo movedInfo = std::move( info );
593 DALI_TEST_CHECK( movedInfo );
594 DALI_TEST_EQUALS( 2, movedInfo.GetBaseObject().ReferenceCount(), TEST_LOCATION );
595 DALI_TEST_CHECK( movedInfo.GetName() == "Actor" );
596 DALI_TEST_CHECK( !info );
601 int UtcDaliTypeRegistryMoveAssignment(void)
603 TestApplication application;
605 TypeRegistry registry = TypeRegistry::Get();
606 DALI_TEST_CHECK( registry );
607 DALI_TEST_EQUALS( 16, registry.GetBaseObject().ReferenceCount(), TEST_LOCATION );
608 DALI_TEST_CHECK( registry.GetTypeInfo( "Actor" ).GetName() == "Actor" );
610 TypeRegistry movedRegistry;
611 movedRegistry = std::move( registry );
612 DALI_TEST_CHECK( movedRegistry );
613 DALI_TEST_EQUALS( 16, movedRegistry.GetBaseObject().ReferenceCount(), TEST_LOCATION );
614 DALI_TEST_CHECK( movedRegistry.GetTypeInfo( "Actor" ).GetName() == "Actor" );
615 DALI_TEST_CHECK( !registry );
617 Dali::TypeInfo info = movedRegistry.GetTypeInfo( "Actor" );
618 DALI_TEST_CHECK( info );
619 DALI_TEST_EQUALS( 2, info.GetBaseObject().ReferenceCount(), TEST_LOCATION );
620 DALI_TEST_CHECK( info.GetName() == "Actor" );
622 Dali::TypeInfo movedInfo;
623 movedInfo = std::move( info );
624 DALI_TEST_CHECK( movedInfo );
625 DALI_TEST_EQUALS( 2, movedInfo.GetBaseObject().ReferenceCount(), TEST_LOCATION );
626 DALI_TEST_CHECK( movedInfo.GetName() == "Actor" );
627 DALI_TEST_CHECK( !info );
632 int UtcDaliTypeRegistryAssignP(void)
634 TestApplication application;
636 TypeRegistry registry = TypeRegistry::Get();
637 TypeRegistry registry2;
638 registry2 = registry;
639 DALI_TEST_CHECK( registry2 );
641 DALI_TEST_CHECK( registry2.GetTypeInfo( "Actor" ).GetName() == registry2.GetTypeInfo( "Actor" ).GetName() );
646 int UtcDaliTypeRegistryGetTypeInfoFromTypeNameP(void)
648 TestApplication application;
650 TypeRegistry registry = TypeRegistry::Get();
655 type = registry.GetTypeInfo( "CameraActor" );
656 DALI_TEST_CHECK( type );
657 CameraActor ca = CameraActor::DownCast(type.CreateInstance());
658 DALI_TEST_CHECK( ca );
659 application.GetScene().Add( ca );
660 application.Render();
663 type = registry.GetTypeInfo( "Animation" );
664 DALI_TEST_CHECK( type );
665 Animation an = Animation::DownCast(type.CreateInstance());
666 DALI_TEST_CHECK( an );
668 application.Render();
673 int UtcDaliTypeRegistryGetTypeInfoFromTypeNameN(void)
675 TestApplication application;
677 TypeRegistry registry = TypeRegistry::Get();
681 type = registry.GetTypeInfo( "MyDummyActor" );
682 DALI_TEST_CHECK( !type );
687 int UtcDaliTypeRegistryGetTypeInfoFromTypeIdP(void)
689 TypeInfo named_type = TypeRegistry::Get().GetTypeInfo( "CameraActor" );
690 TypeInfo typeinfo_type = TypeRegistry::Get().GetTypeInfo( typeid(Dali::CameraActor) );
692 DALI_TEST_CHECK( named_type );
693 DALI_TEST_CHECK( typeinfo_type );
695 // Check named and typeid are equivalent
696 DALI_TEST_CHECK( named_type == typeinfo_type );
698 DALI_TEST_CHECK( named_type.GetName() == typeinfo_type.GetName() );
699 DALI_TEST_CHECK( named_type.GetBaseName() == typeinfo_type.GetBaseName() );
704 int UtcDaliTypeRegistryGetTypeInfoFromTypeIdN(void)
706 TestApplication application;
707 TypeRegistry typeRegistry = TypeRegistry::Get();
709 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(Vector2) );
710 DALI_TEST_CHECK( !typeInfo );
715 int UtcDaliTypeRegistryGetTypeNameCountP(void)
717 TestApplication application;
718 TypeRegistry typeRegistry = TypeRegistry::Get();
721 for(size_t i = 0; i < typeRegistry.GetTypeNameCount(); i++)
723 type = typeRegistry.GetTypeInfo( typeRegistry.GetTypeName(i) );
724 DALI_TEST_CHECK( type );
731 int UtcDaliTypeRegistryGetTypeNamesP(void)
733 TestApplication application;
734 TypeRegistry typeRegistry = TypeRegistry::Get();
737 for(size_t i = 0; i < typeRegistry.GetTypeNameCount(); i++)
739 type = typeRegistry.GetTypeInfo( typeRegistry.GetTypeName(i) );
740 DALI_TEST_CHECK( type );
747 // Note: No negative test case for UtcDaliTypeRegistryTypeRegistration can be implemented.
748 int UtcDaliTypeRegistryTypeRegistrationNotCallingCreateOnInitP(void)
750 ResetFunctorCounts();
752 TestApplication application;
754 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
755 DALI_TEST_CHECK( type );
757 TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( "CustomActor" );
758 DALI_TEST_CHECK( baseType );
760 BaseHandle handle = type.CreateInstance();
761 DALI_TEST_CHECK( handle );
763 MyTestCustomActor customHandle = MyTestCustomActor::DownCast( handle );
764 DALI_TEST_CHECK( customHandle );
766 DALI_TEST_EQUALS( type.GetActionCount(), TEST_ACTION_COUNT + baseType.GetActionCount(), TEST_LOCATION );
768 DALI_TEST_EQUALS( type.GetSignalCount(), TEST_SIGNAL_COUNT + baseType.GetSignalCount(), TEST_LOCATION );
771 TestConnectionTracker tracker;
773 bool connected = handle.ConnectSignal( &tracker, "sig1", CustomTestFunctor() );
774 DALI_TEST_EQUALS( connected, true, TEST_LOCATION );
775 DALI_TEST_CHECK( lastSignalConnectionCustom == "sig1" );
776 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
777 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION );
779 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
780 customHandle.GetCustomSignal().Emit();
781 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION );
782 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
783 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION );
785 // tracker should automatically disconnect here
786 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
787 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
789 // Test that functor is disconnected
790 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION );
791 customHandle.GetCustomSignal().Emit();
792 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1/*not incremented*/, TEST_LOCATION );
793 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
794 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
796 Property::Map attributes;
797 handle.DoAction("act1", attributes);
798 DALI_TEST_CHECK( lastActionCustom == "act1" );
802 // Note: No negative test case for UtcDaliTypeRegistryTypeRegistration can be implemented.
803 int UtcDaliTypeRegistryTypeRegistrationCallingCreateOnInitP(void)
805 TestApplication application;
807 DALI_TEST_CHECK( "MyTestCustomActor2" == customTypeInit.RegisteredName() );
809 DALI_TEST_CHECK( true == CreateCustomInitCalled );
810 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor2" );
811 DALI_TEST_CHECK( type );
815 // Note: No negative test case for UtcDaliTypeRegistryTypeRegistration can be implemented.
816 int UtcDaliTypeRegistryTypeRegistrationForNamedTypeP(void)
818 TestApplication application;
820 // Create Named Actor Type
821 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyNamedActor" );
822 DALI_TEST_CHECK( type );
824 BaseHandle namedHandle = type.CreateInstance();
825 DALI_TEST_CHECK( namedHandle );
826 Actor namedActor( Actor::DownCast( namedHandle ) );
827 DALI_TEST_CHECK( namedActor );
829 DALI_TEST_CHECK( namedActor.GetProperty< std::string >( Actor::Property::NAME ) == "NamedActor" );
830 DALI_TEST_CHECK( type.GetName() == "MyNamedActor" );
831 DALI_TEST_CHECK( type.GetBaseName() == "Actor" );
836 int UtcDaliTypeRegistryRegisteredNameP(void)
838 TestApplication application;
840 DALI_TEST_CHECK( scriptedName == scriptedType.RegisteredName() );
842 TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( scriptedName );
843 DALI_TEST_CHECK( baseType );
845 BaseHandle handle = baseType.CreateInstance();
847 DALI_TEST_CHECK( true == CreateCustomNamedInitCalled );
848 TypeInfo type = TypeRegistry::Get().GetTypeInfo( scriptedName );
849 DALI_TEST_CHECK( type );
854 int UtcDaliTypeRegistryRegisteredNameN(void)
856 TestApplication application;
858 DALI_TEST_CHECK( scriptedName == scriptedType.RegisteredName() );
860 TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( scriptedName );
861 DALI_TEST_CHECK( baseType );
863 // should cause an assert because we're registering same type twice
864 // once statically at the start of this file, then again now
867 TypeRegistration scriptedType( scriptedName, typeid(Dali::CustomActor), CreateCustomNamedInit );
868 tet_result( TET_FAIL );
870 catch ( DaliException& e )
872 DALI_TEST_ASSERT( e, "Duplicate type name in Type Registration", TEST_LOCATION );
879 int UtcDaliTypeRegistrySignalConnectorTypeP(void)
881 ResetFunctorCounts();
883 TestApplication application;
885 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
886 DALI_TEST_CHECK( type );
888 BaseHandle handle = type.CreateInstance();
889 DALI_TEST_CHECK( handle );
891 MyTestCustomActor customHandle = MyTestCustomActor::DownCast( handle );
892 DALI_TEST_CHECK( customHandle );
895 TestConnectionTracker tracker;
897 bool connected = handle.ConnectSignal( &tracker, "sig1", CustomTestFunctor() );
898 DALI_TEST_EQUALS( connected, true, TEST_LOCATION );
899 DALI_TEST_CHECK( lastSignalConnectionCustom == "sig1" );
900 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
901 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION );
903 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
904 customHandle.GetCustomSignal().Emit();
905 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION );
906 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
907 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION );
909 // tracker should automatically disconnect here
910 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
911 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
913 // Test that functor is disconnected
914 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION );
915 customHandle.GetCustomSignal().Emit();
916 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1/*not incremented*/, TEST_LOCATION );
917 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
918 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
923 int UtcDaliTypeRegistrySignalConnectorTypeN(void)
925 // Test what happens when signal connnector (DoConnectSignalFailure method) returns false
927 ResetFunctorCounts();
929 TestApplication application;
931 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
932 DALI_TEST_CHECK( type );
934 TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( "CustomActor" );
935 DALI_TEST_CHECK( baseType );
937 BaseHandle handle = type.CreateInstance();
938 DALI_TEST_CHECK( handle );
940 MyTestCustomActor customHandle = MyTestCustomActor::DownCast( handle );
941 DALI_TEST_CHECK( customHandle );
943 DALI_TEST_EQUALS( type.GetActionCount(), TEST_ACTION_COUNT + baseType.GetActionCount(), TEST_LOCATION );
945 DALI_TEST_EQUALS( type.GetSignalCount(), TEST_SIGNAL_COUNT + baseType.GetSignalCount(), TEST_LOCATION );
948 TestConnectionTracker tracker;
950 bool connected = handle.ConnectSignal( &tracker, "sig2", CustomTestFunctor() );
951 DALI_TEST_EQUALS( connected, false/*This is supposed to fail*/, TEST_LOCATION );
952 DALI_TEST_CHECK( lastSignalConnectionCustom == "failed" );
953 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
954 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0/*deleted along with FunctorDelegate*/, TEST_LOCATION );
957 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
958 customHandle.GetCustomSignal().Emit();
959 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0/*never called*/, TEST_LOCATION );
961 // tracker should have nothing to disconnect here
964 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
965 customHandle.GetCustomSignal().Emit();
966 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0/*never called*/, TEST_LOCATION );
970 int UtcDaliTypeRegistryTypeActionP(void)
972 ResetFunctorCounts();
974 TestApplication application;
976 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
977 DALI_TEST_CHECK( type );
979 BaseHandle handle = type.CreateInstance();
980 DALI_TEST_CHECK( handle );
982 Property::Map attributes;
983 DALI_TEST_CHECK( handle.DoAction("act1", attributes) );
984 DALI_TEST_CHECK( lastActionCustom == "act1" );
989 int UtcDaliTypeRegistryTypeActionN(void)
991 ResetFunctorCounts();
993 TestApplication application;
995 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
996 DALI_TEST_CHECK( type );
998 BaseHandle handle = type.CreateInstance();
999 DALI_TEST_CHECK( handle );
1001 Property::Map attributes;
1002 DALI_TEST_CHECK( !handle.DoAction( "unknownAction", attributes ) );
1007 int UtcDaliTypeRegistryPropertyRegistrationP(void)
1009 TestApplication application;
1010 TypeRegistry typeRegistry = TypeRegistry::Get();
1012 // Check property count before property registration
1013 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1014 DALI_TEST_CHECK( typeInfo );
1015 BaseHandle handle = typeInfo.CreateInstance();
1016 DALI_TEST_CHECK( handle );
1017 Actor customActor = Actor::DownCast( handle );
1018 DALI_TEST_CHECK( customActor );
1019 unsigned int initialPropertyCount( customActor.GetPropertyCount() );
1021 std::string propertyName( "prop1" );
1022 int propertyIndex( PROPERTY_REGISTRATION_START_INDEX );
1023 Property::Type propertyType( Property::BOOLEAN );
1024 PropertyRegistration property1( customType1, propertyName, propertyIndex, propertyType, &SetProperty, &GetProperty );
1026 // Check property count after registration
1027 unsigned int postRegistrationPropertyCount( customActor.GetPropertyCount() );
1028 DALI_TEST_EQUALS( initialPropertyCount + 1u, postRegistrationPropertyCount, TEST_LOCATION );
1030 // Add custom property and check property count
1031 customActor.RegisterProperty( "customProp1", true );
1032 unsigned int customPropertyCount( customActor.GetPropertyCount() );
1033 DALI_TEST_EQUALS( postRegistrationPropertyCount + 1u, customPropertyCount, TEST_LOCATION );
1035 // Set the property, ensure SetProperty called
1036 DALI_TEST_CHECK( !setPropertyCalled );
1037 customActor.SetProperty( propertyIndex, false );
1038 DALI_TEST_CHECK( setPropertyCalled );
1040 // Get the property, ensure GetProperty called
1041 DALI_TEST_CHECK( !getPropertyCalled );
1042 (void)customActor.GetProperty< bool >( propertyIndex );
1043 DALI_TEST_CHECK( getPropertyCalled );
1045 // Get the property using GetCurrentProperty and ensure GetProperty is called
1046 getPropertyCalled = false;
1047 DALI_TEST_CHECK( !getPropertyCalled );
1048 customActor.GetCurrentProperty< bool >( propertyIndex );
1049 DALI_TEST_CHECK( getPropertyCalled );
1051 // Check the property name
1052 DALI_TEST_EQUALS( customActor.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
1053 DALI_TEST_EQUALS( typeInfo.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
1055 // Check the property index
1056 DALI_TEST_EQUALS( customActor.GetPropertyIndex( propertyName ), propertyIndex, TEST_LOCATION );
1058 // Check the property type
1059 DALI_TEST_EQUALS( customActor.GetPropertyType( propertyIndex ), propertyType, TEST_LOCATION );
1061 // Check property count of type-info is 1
1062 Property::IndexContainer indices;
1063 typeInfo.GetPropertyIndices( indices );
1065 size_t typePropertyCount = typeInfo.GetPropertyCount();
1066 DALI_TEST_EQUALS( indices.Size(), Actor::New().GetPropertyCount() + 1u, TEST_LOCATION );
1067 DALI_TEST_EQUALS( indices.Size(), typePropertyCount, TEST_LOCATION );
1069 // Ensure indices returned from actor and customActor differ by two
1070 Actor actor = Actor::New();
1071 actor.GetPropertyIndices( indices );
1072 unsigned int actorIndices = indices.Size();
1073 customActor.GetPropertyIndices( indices );
1074 unsigned int customActorIndices = indices.Size();
1075 DALI_TEST_EQUALS( actorIndices + 2u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1079 int UtcDaliTypeRegistryPropertyRegistrationN(void)
1081 TestApplication application;
1082 TypeRegistry typeRegistry = TypeRegistry::Get();
1084 // Attempt to register a property type out-of-bounds index (less than)
1087 PropertyRegistration property1( customType1, "propName", PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN, &SetProperty, &GetProperty );
1088 tet_result( TET_FAIL );
1090 catch ( DaliException& e )
1092 DALI_TEST_ASSERT( e, "( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1095 // Attempt to register a property type out-of-bounds index (greater than)
1098 PropertyRegistration property1( customType1, "propName", PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN, &SetProperty, &GetProperty );
1099 tet_result( TET_FAIL );
1101 catch ( DaliException& e )
1103 DALI_TEST_ASSERT( e, "( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1109 int UtcDaliTypeRegistryAnimatablePropertyRegistrationP(void)
1111 TestApplication application;
1112 TypeRegistry typeRegistry = TypeRegistry::Get();
1114 // Check property count before property registration
1115 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1116 DALI_TEST_CHECK( typeInfo );
1117 BaseHandle handle = typeInfo.CreateInstance();
1118 DALI_TEST_CHECK( handle );
1119 Actor customActor = Actor::DownCast( handle );
1120 DALI_TEST_CHECK( customActor );
1121 application.GetScene().Add(customActor);
1123 unsigned int customPropertyCount( customActor.GetPropertyCount() );
1125 // Register animatable property
1126 std::string animatablePropertyName( "animatableProp1" );
1127 int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1128 Property::Type animatablePropertyType( Property::FLOAT );
1129 AnimatablePropertyRegistration animatableProperty( customType1, animatablePropertyName, animatablePropertyIndex, animatablePropertyType );
1131 // Check property count after registration
1132 DALI_TEST_EQUALS( customPropertyCount + 1u, customActor.GetPropertyCount(), TEST_LOCATION );
1134 // Set the animatable property value
1135 customActor.SetProperty( animatablePropertyIndex, 25.0f );
1137 // Render and notify
1138 application.SendNotification();
1139 application.Render();
1141 // Check the animatable property value
1142 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 25.f, TEST_LOCATION );
1144 // Check the animatable property name
1145 DALI_TEST_EQUALS( customActor.GetPropertyName( animatablePropertyIndex ), animatablePropertyName, TEST_LOCATION );
1147 // Check the animatable property index
1148 DALI_TEST_EQUALS( customActor.GetPropertyIndex( animatablePropertyName ), animatablePropertyIndex, TEST_LOCATION );
1150 // Check the animatable property type
1151 DALI_TEST_EQUALS( customActor.GetPropertyType( animatablePropertyIndex ), animatablePropertyType, TEST_LOCATION );
1153 // Check property count of type-info is 1
1154 Property::IndexContainer indices;
1155 typeInfo.GetPropertyIndices( indices );
1156 DALI_TEST_EQUALS( indices.Size(), customActor.GetPropertyCount(), TEST_LOCATION );
1158 // Ensure indices returned from actor and customActor differ by one
1159 Actor actor = Actor::New();
1160 actor.GetPropertyIndices( indices );
1161 unsigned int actorIndices = indices.Size();
1162 customActor.GetPropertyIndices( indices );
1163 unsigned int customActorIndices = indices.Size();
1164 DALI_TEST_EQUALS( actorIndices + 1u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1166 // check that the property is animatable
1167 Animation animation = Animation::New(0.2f);
1168 animation.AnimateTo( Property( customActor, animatablePropertyIndex ), 15.f, AlphaFunction::LINEAR );
1171 // Target value should change straight away
1172 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 15.0f, TEST_LOCATION );
1174 // Render and notify, animation play for 0.05 seconds
1175 application.SendNotification();
1176 application.Render(50);
1177 DALI_TEST_EQUALS( 0.25f, animation.GetCurrentProgress(), TEST_LOCATION );
1178 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 22.5f, TEST_LOCATION );
1180 // Render and notify, animation play for another 0.1 seconds
1181 application.SendNotification();
1182 application.Render(100);
1183 DALI_TEST_EQUALS( 0.75f, animation.GetCurrentProgress(), TEST_LOCATION );
1184 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 17.5f, TEST_LOCATION );
1189 int UtcDaliTypeRegistryAnimatablePropertyRegistrationN(void)
1191 TestApplication application;
1192 TypeRegistry typeRegistry = TypeRegistry::Get();
1194 // Attempt to register an animatable property type out-of-bounds index (less than)
1197 AnimatablePropertyRegistration property1( customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN );
1198 tet_result( TET_FAIL );
1200 catch ( DaliException& e )
1202 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1205 // Attempt to register an animatable property type out-of-bounds index (greater than)
1208 AnimatablePropertyRegistration property1( customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN );
1209 tet_result( TET_FAIL );
1211 catch ( DaliException& e )
1213 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1219 int UtcDaliTypeRegistryAnimatablePropertyRegistrationWithDefaultP(void)
1221 TestApplication application;
1222 TypeRegistry typeRegistry = TypeRegistry::Get();
1224 // Check property count before property registration
1225 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1226 DALI_TEST_CHECK( typeInfo );
1227 BaseHandle handle = typeInfo.CreateInstance();
1228 DALI_TEST_CHECK( handle );
1229 Actor customActor = Actor::DownCast( handle );
1230 DALI_TEST_CHECK( customActor );
1231 application.GetScene().Add(customActor);
1233 unsigned int customPropertyCount( customActor.GetPropertyCount() );
1235 // Register animatable property
1236 std::string animatablePropertyName( "animatableProp1" );
1237 int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1238 AnimatablePropertyRegistration animatableProperty1( customType1, animatablePropertyName, animatablePropertyIndex, 10.f );
1240 // Check property count after registration
1241 DALI_TEST_EQUALS( customPropertyCount + 1u, customActor.GetPropertyCount(), TEST_LOCATION );
1243 // Render and notify
1244 application.SendNotification();
1245 application.Render();
1247 // Check the animatable property value
1248 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 10.f, TEST_LOCATION );
1250 // Check the animatable property name
1251 DALI_TEST_EQUALS( customActor.GetPropertyName( animatablePropertyIndex ), animatablePropertyName, TEST_LOCATION );
1253 // Check the animatable property index
1254 DALI_TEST_EQUALS( customActor.GetPropertyIndex( animatablePropertyName ), animatablePropertyIndex, TEST_LOCATION );
1256 // Check the animatable property type
1257 DALI_TEST_EQUALS( customActor.GetPropertyType( animatablePropertyIndex ), Property::FLOAT, TEST_LOCATION );
1259 // Check property count of type-info
1260 Property::IndexContainer indices;
1261 typeInfo.GetPropertyIndices( indices );
1262 DALI_TEST_EQUALS( indices.Size(), customActor.GetPropertyCount(), TEST_LOCATION );
1264 // Ensure indices returned from actor and customActor differ by one
1265 Actor actor = Actor::New();
1266 actor.GetPropertyIndices( indices );
1267 unsigned int actorIndices = indices.Size();
1268 customActor.GetPropertyIndices( indices );
1269 unsigned int customActorIndices = indices.Size();
1270 DALI_TEST_EQUALS( actorIndices + 1u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1272 // check that the property is animatable
1273 Animation animation = Animation::New(0.2f);
1274 animation.AnimateTo( Property( customActor, animatablePropertyIndex ), 20.f, AlphaFunction::LINEAR );
1277 // Target value should change straight away
1278 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 20.0f, TEST_LOCATION );
1280 // Render and notify, animation play for 0.05 seconds
1281 application.SendNotification();
1282 application.Render(50);
1283 DALI_TEST_EQUALS( 0.25f, animation.GetCurrentProgress(), TEST_LOCATION );
1284 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 12.5f, TEST_LOCATION );
1286 // Render and notify, animation play for another 0.1 seconds
1287 application.SendNotification();
1288 application.Render(100);
1289 DALI_TEST_EQUALS( 0.75f, animation.GetCurrentProgress(), TEST_LOCATION );
1290 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 17.5f, TEST_LOCATION );
1295 int UtcDaliTypeRegistryAnimatablePropertyRegistrationWithDefaultN(void)
1297 TestApplication application;
1298 TypeRegistry typeRegistry = TypeRegistry::Get();
1300 // Attempt to register an animatable property type out-of-bounds index (less than)
1303 AnimatablePropertyRegistration property1( customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX - 1, false );
1304 tet_result( TET_FAIL );
1306 catch ( DaliException& e )
1308 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1311 // Attempt to register an animatable property type out-of-bounds index (greater than)
1314 AnimatablePropertyRegistration property1( customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX + 1, true );
1315 tet_result( TET_FAIL );
1317 catch ( DaliException& e )
1319 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1325 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationP(void)
1327 TestApplication application;
1328 TypeRegistry typeRegistry = TypeRegistry::Get();
1330 // Check property count before property registration
1331 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1332 DALI_TEST_CHECK( typeInfo );
1333 BaseHandle handle = typeInfo.CreateInstance();
1334 DALI_TEST_CHECK( handle );
1335 Actor customActor = Actor::DownCast( handle );
1336 DALI_TEST_CHECK( customActor );
1338 unsigned int customPropertyCount( customActor.GetPropertyCount() );
1340 // Register animatable property
1341 std::string animatablePropertyName( "animatableProp1" );
1342 int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1343 Property::Type animatablePropertyType( Property::VECTOR2 );
1344 AnimatablePropertyRegistration animatableProperty1( customType1, animatablePropertyName, animatablePropertyIndex, animatablePropertyType );
1346 // Check property count after registration
1347 DALI_TEST_EQUALS( customPropertyCount + 1u, customActor.GetPropertyCount(), TEST_LOCATION );
1349 // Set the animatable property value
1350 customActor.SetProperty( animatablePropertyIndex, Vector2(25.0f, 50.0f) );
1352 // Render and notify
1353 application.SendNotification();
1354 application.Render();
1356 // Check the animatable property value
1357 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( animatablePropertyIndex ), Vector2(25.0f, 50.0f), TEST_LOCATION );
1359 // Check the animatable property name
1360 DALI_TEST_EQUALS( customActor.GetPropertyName( animatablePropertyIndex ), animatablePropertyName, TEST_LOCATION );
1362 // Check the animatable property index
1363 DALI_TEST_EQUALS( customActor.GetPropertyIndex( animatablePropertyName ), animatablePropertyIndex, TEST_LOCATION );
1365 // Check the animatable property type
1366 DALI_TEST_EQUALS( customActor.GetPropertyType( animatablePropertyIndex ), animatablePropertyType, TEST_LOCATION );
1368 // Check property count of type-info
1369 Property::IndexContainer indices;
1370 typeInfo.GetPropertyIndices( indices );
1371 DALI_TEST_EQUALS( indices.Size(), customActor.GetPropertyCount(), TEST_LOCATION );
1373 // Register animatable property components
1374 std::string animatablePropertyComponentName1( "animatableProp1X" );
1375 int animatablePropertyComponentIndex1( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1 );
1376 AnimatablePropertyComponentRegistration animatablePropertyComponent1( customType1, animatablePropertyComponentName1, animatablePropertyComponentIndex1, animatablePropertyIndex, 0 );
1378 std::string animatablePropertyComponentName2( "animatableProp1Y" );
1379 int animatablePropertyComponentIndex2( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2 );
1380 AnimatablePropertyComponentRegistration animatablePropertyComponent2( customType1, animatablePropertyComponentName2, animatablePropertyComponentIndex2, animatablePropertyIndex, 1 );
1382 // Check property count after registration
1383 DALI_TEST_EQUALS( customPropertyCount + 3u, customActor.GetPropertyCount(), TEST_LOCATION );
1385 // Check the animatable property component value
1386 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex1 ), 25.0f, TEST_LOCATION );
1387 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex2 ), 50.0f, TEST_LOCATION );
1389 // Set the animatable property component value
1390 customActor.SetProperty( animatablePropertyComponentIndex1, 150.0f );
1392 // Render and notify
1393 application.SendNotification();
1394 application.Render();
1396 // Check the animatable property value
1397 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector2 >( animatablePropertyIndex ), Vector2(150.0f, 50.0f), TEST_LOCATION );
1398 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex1 ), 150.0f, TEST_LOCATION );
1399 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex2 ), 50.0f, TEST_LOCATION );
1401 // Set the animatable property component value
1402 customActor.SetProperty( animatablePropertyComponentIndex2, 225.0f );
1404 // Render and notify
1405 application.SendNotification();
1406 application.Render();
1408 // Check the animatable property value
1409 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector2 >( animatablePropertyIndex ), Vector2(150.0f, 225.0f), TEST_LOCATION );
1410 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex1 ), 150.0f, TEST_LOCATION );
1411 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex2 ), 225.0f, TEST_LOCATION );
1413 // Ensure indices returned from actor and customActor differ by three
1414 Actor actor = Actor::New();
1415 actor.GetPropertyIndices( indices );
1416 unsigned int actorIndices = indices.Size();
1417 customActor.GetPropertyIndices( indices );
1418 unsigned int customActorIndices = indices.Size();
1419 DALI_TEST_EQUALS( actorIndices + 3u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1421 // Attempt to animate component property, it should not crash
1422 Animation animation = Animation::New( 1.0f );
1423 animation.AnimateTo( Property( customActor, animatablePropertyComponentIndex1 ), 200.0f );
1426 // Check the property value
1427 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( animatablePropertyIndex ), Vector2(200.0f, 225.0f), TEST_LOCATION );
1428 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex1 ), 200.0f, TEST_LOCATION );
1429 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex2 ), 225.0f, TEST_LOCATION );
1434 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationVector2AnimateByP(void)
1436 TestApplication application;
1437 TypeRegistry typeRegistry = TypeRegistry::Get();
1439 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1440 DALI_TEST_CHECK( typeInfo );
1441 BaseHandle handle = typeInfo.CreateInstance();
1442 DALI_TEST_CHECK( handle );
1443 Actor customActor = Actor::DownCast( handle );
1444 DALI_TEST_CHECK( customActor );
1446 const unsigned int index = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX;
1447 const unsigned int xComponentIndex = index + 1;
1448 const unsigned int yComponentIndex = index + 2;
1449 const Vector2 initialValue( 20.0f, 40.0f );
1451 // Register animatable property & its components
1452 AnimatablePropertyRegistration animatableProperty1( customType1, "animatableProp1", index, initialValue );
1453 AnimatablePropertyComponentRegistration animatablePropertyComponent1( customType1, "animatableProp1X", xComponentIndex, index, 0 );
1454 AnimatablePropertyComponentRegistration animatablePropertyComponent2( customType1, "animatableProp1Y", yComponentIndex, index, 1 );
1456 // Check the animatable property value
1457 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( index ), initialValue, TEST_LOCATION );
1458 DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
1459 DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
1461 // Render and notify
1462 application.SendNotification();
1463 application.Render();
1465 // Check the animatable property current value
1466 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector2 >( index ), initialValue, TEST_LOCATION );
1467 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
1468 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
1471 const Vector2 targetValue( 45.0f, 53.0f );
1472 const Vector2 relativeValue( targetValue - initialValue );
1474 Animation animation = Animation::New( 1.0f );
1475 animation.AnimateBy( Property( customActor, xComponentIndex ), relativeValue.x );
1476 animation.AnimateBy( Property( customActor, yComponentIndex ), relativeValue.y );
1479 // Target values should change straight away
1480 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
1481 DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), targetValue.x, TEST_LOCATION );
1482 DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), targetValue.y, TEST_LOCATION );
1487 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationVector3AnimateByP(void)
1489 TestApplication application;
1490 TypeRegistry typeRegistry = TypeRegistry::Get();
1492 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1493 DALI_TEST_CHECK( typeInfo );
1494 BaseHandle handle = typeInfo.CreateInstance();
1495 DALI_TEST_CHECK( handle );
1496 Actor customActor = Actor::DownCast( handle );
1497 DALI_TEST_CHECK( customActor );
1499 const unsigned int index = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX;
1500 const unsigned int xComponentIndex = index + 1;
1501 const unsigned int yComponentIndex = index + 2;
1502 const unsigned int zComponentIndex = index + 3;
1503 const Vector3 initialValue( 20.0f, 40.0f, 50.0f );
1505 // Register animatable property & its components
1506 AnimatablePropertyRegistration animatableProperty1( customType1, "animatableProp1", index, initialValue );
1507 AnimatablePropertyComponentRegistration animatablePropertyComponent1( customType1, "animatableProp1X", xComponentIndex, index, 0 );
1508 AnimatablePropertyComponentRegistration animatablePropertyComponent2( customType1, "animatableProp1Y", yComponentIndex, index, 1 );
1509 AnimatablePropertyComponentRegistration animatablePropertyComponent3( customType1, "animatableProp1Z", zComponentIndex, index, 2 );
1511 // Check the animatable property value
1512 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( index ), initialValue, TEST_LOCATION );
1513 DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
1514 DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
1515 DALI_TEST_EQUALS( customActor.GetProperty< float >( zComponentIndex ), initialValue.z, TEST_LOCATION );
1517 // Render and notify
1518 application.SendNotification();
1519 application.Render();
1521 // Check the animatable property current value
1522 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector3 >( index ), initialValue, TEST_LOCATION );
1523 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
1524 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
1525 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( zComponentIndex ), initialValue.z, TEST_LOCATION );
1528 const Vector3 targetValue( 45.0f, 53.0f, 25.0f );
1529 const Vector3 relativeValue( targetValue - initialValue );
1531 Animation animation = Animation::New( 1.0f );
1532 animation.AnimateBy( Property( customActor, xComponentIndex ), relativeValue.x );
1533 animation.AnimateBy( Property( customActor, yComponentIndex ), relativeValue.y );
1534 animation.AnimateBy( Property( customActor, zComponentIndex ), relativeValue.z );
1537 // Target values should change straight away
1538 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
1539 DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), targetValue.x, TEST_LOCATION );
1540 DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), targetValue.y, TEST_LOCATION );
1541 DALI_TEST_EQUALS( customActor.GetProperty< float >( zComponentIndex ), targetValue.z, TEST_LOCATION );
1546 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationVector4AnimateByP(void)
1548 TestApplication application;
1549 TypeRegistry typeRegistry = TypeRegistry::Get();
1551 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1552 DALI_TEST_CHECK( typeInfo );
1553 BaseHandle handle = typeInfo.CreateInstance();
1554 DALI_TEST_CHECK( handle );
1555 Actor customActor = Actor::DownCast( handle );
1556 DALI_TEST_CHECK( customActor );
1558 const unsigned int index = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX;
1559 const unsigned int xComponentIndex = index + 1;
1560 const unsigned int yComponentIndex = index + 2;
1561 const unsigned int zComponentIndex = index + 3;
1562 const unsigned int wComponentIndex = index + 4;
1563 const Vector4 initialValue( 20.0f, 40.0f, 50.0f, 60.0f );
1565 // Register animatable property & its components
1566 AnimatablePropertyRegistration animatableProperty1( customType1, "animatableProp1", index, initialValue );
1567 AnimatablePropertyComponentRegistration animatablePropertyComponent1( customType1, "animatableProp1X", xComponentIndex, index, 0 );
1568 AnimatablePropertyComponentRegistration animatablePropertyComponent2( customType1, "animatableProp1Y", yComponentIndex, index, 1 );
1569 AnimatablePropertyComponentRegistration animatablePropertyComponent3( customType1, "animatableProp1Z", zComponentIndex, index, 2 );
1570 AnimatablePropertyComponentRegistration animatablePropertyComponent4( customType1, "animatableProp1W", wComponentIndex, index, 3 );
1572 // Check the animatable property value
1573 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( index ), initialValue, TEST_LOCATION );
1574 DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
1575 DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
1576 DALI_TEST_EQUALS( customActor.GetProperty< float >( zComponentIndex ), initialValue.z, TEST_LOCATION );
1577 DALI_TEST_EQUALS( customActor.GetProperty< float >( wComponentIndex ), initialValue.w, TEST_LOCATION );
1579 // Render and notify
1580 application.SendNotification();
1581 application.Render();
1583 // Check the animatable property current value
1584 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector4 >( index ), initialValue, TEST_LOCATION );
1585 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
1586 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
1587 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( zComponentIndex ), initialValue.z, TEST_LOCATION );
1588 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( wComponentIndex ), initialValue.w, TEST_LOCATION );
1591 const Vector4 targetValue( 45.0f, 53.0f, 25.0f, 13.0f );
1592 const Vector4 relativeValue( targetValue - initialValue );
1594 Animation animation = Animation::New( 1.0f );
1595 animation.AnimateBy( Property( customActor, xComponentIndex ), relativeValue.x );
1596 animation.AnimateBy( Property( customActor, yComponentIndex ), relativeValue.y );
1597 animation.AnimateBy( Property( customActor, zComponentIndex ), relativeValue.z );
1598 animation.AnimateBy( Property( customActor, wComponentIndex ), relativeValue.w );
1601 // Target values should change straight away
1602 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
1603 DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), targetValue.x, TEST_LOCATION );
1604 DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), targetValue.y, TEST_LOCATION );
1605 DALI_TEST_EQUALS( customActor.GetProperty< float >( zComponentIndex ), targetValue.z, TEST_LOCATION );
1606 DALI_TEST_EQUALS( customActor.GetProperty< float >( wComponentIndex ), targetValue.w, TEST_LOCATION );
1611 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationN(void)
1613 TestApplication application;
1614 TypeRegistry typeRegistry = TypeRegistry::Get();
1616 // Register animatable property with the type of Vector2
1617 int animatablePropertyIndex1( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1618 AnimatablePropertyRegistration animatableProperty1( customType1, "animatableProp1", animatablePropertyIndex1, Property::VECTOR2 );
1620 // Attempt to register an animatable property component out-of-bounds index (less than)
1623 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp1X", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX - 1, animatablePropertyIndex1, 0 );
1624 tet_result( TET_FAIL );
1626 catch ( DaliException& e )
1628 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1631 // Attempt to register an animatable property component out-of-bounds index (greater than)
1634 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp1X", ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX + 1, animatablePropertyIndex1, 0 );
1635 tet_result( TET_FAIL );
1637 catch ( DaliException& e )
1639 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1642 // Register an animatable property component
1643 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp1X", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1, animatablePropertyIndex1, 0 );
1645 // Attempt to register another animatable property component with the same component index
1648 AnimatablePropertyComponentRegistration propertyComponent2( customType1, "animatableProp1Y", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2, animatablePropertyIndex1, 0 );
1649 tet_result( TET_FAIL );
1651 catch ( DaliException& e )
1653 DALI_TEST_ASSERT( e, "Property component already registered", TEST_LOCATION );
1656 // Register animatable property with the type of boolean
1657 int animatablePropertyIndex2( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2 );
1658 AnimatablePropertyRegistration animatableProperty2( customType1, "animatableProp2", animatablePropertyIndex2, Property::BOOLEAN );
1660 // Attempt to register an animatable property component for the above property with boolean type
1663 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp2X", animatablePropertyIndex2 + 1, animatablePropertyIndex2, 0 );
1664 tet_result( TET_FAIL );
1666 catch ( DaliException& e )
1668 DALI_TEST_ASSERT( e, "Base property does not support component", TEST_LOCATION );
1674 int UtcDaliTypeRegistryChildPropertyRegistrationP(void)
1676 TestApplication application;
1677 TypeRegistry typeRegistry = TypeRegistry::Get();
1679 // Check property count before property registration
1680 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1681 DALI_TEST_CHECK( typeInfo );
1682 BaseHandle handle = typeInfo.CreateInstance();
1683 DALI_TEST_CHECK( handle );
1684 Actor customActor = Actor::DownCast( handle );
1685 DALI_TEST_CHECK( customActor );
1686 unsigned int initialPropertyCount( customActor.GetPropertyCount() );
1688 // Register child properties to the parent
1689 std::string propertyName( "childProp1" );
1690 int propertyIndex( CHILD_PROPERTY_REGISTRATION_START_INDEX );
1691 Property::Type propertyType( Property::BOOLEAN );
1692 ChildPropertyRegistration childProperty1( customType1, propertyName, propertyIndex, propertyType );
1694 std::string propertyName2( "childProp2" );
1695 int propertyIndex2( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1 );
1696 Property::Type propertyType2( Property::INTEGER );
1697 ChildPropertyRegistration childProperty2( customType1, propertyName2, propertyIndex2, propertyType2 );
1699 std::string propertyName3( "childProp3" );
1700 int propertyIndex3( CHILD_PROPERTY_REGISTRATION_START_INDEX + 2 );
1701 Property::Type propertyType3( Property::FLOAT );
1702 ChildPropertyRegistration childProperty3( customType1, propertyName3, propertyIndex3, propertyType3 );
1704 std::string propertyName4( "childProp4" );
1705 int propertyIndex4( CHILD_PROPERTY_REGISTRATION_START_INDEX + 3 );
1706 Property::Type propertyType4( Property::INTEGER );
1707 ChildPropertyRegistration childProperty4( customType1, propertyName4, propertyIndex4, propertyType4 );
1709 // Check property count are not changed because the child properties will not be created for the parent
1710 DALI_TEST_EQUALS( initialPropertyCount, customActor.GetPropertyCount(), TEST_LOCATION );
1712 // check the child property type
1713 Internal::TypeInfo& typeInfoImpl = GetImplementation( typeInfo );
1714 Property::Type type = typeInfoImpl.GetChildPropertyType( typeInfoImpl.GetChildPropertyIndex("childProp4") );
1715 DALI_TEST_EQUALS( type, Property::INTEGER, TEST_LOCATION );
1717 std::string unRegisteredChildName( typeInfoImpl.GetChildPropertyName( CHILD_PROPERTY_REGISTRATION_START_INDEX + 4 ) );
1718 DALI_TEST_EQUALS( unRegisteredChildName, "", TEST_LOCATION );
1720 // Create a child actor
1721 Actor childActor = Actor::New();
1722 DALI_TEST_CHECK( childActor );
1723 unsigned int initialChildActorPropertyCount( childActor.GetPropertyCount() );
1725 // The type of child properties should be Property::None as the child hasn't registered any child property yet.
1726 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex ), Property::NONE, TEST_LOCATION );
1727 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex2 ), Property::NONE, TEST_LOCATION );
1728 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex3 ), Property::NONE, TEST_LOCATION );
1729 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex4 ), Property::NONE, TEST_LOCATION );
1731 // Set the value for the first child property when the child actor doesn't have a parent yet
1732 childActor.SetProperty(propertyIndex, true);
1734 // Check that the first child property is dynamically created
1735 DALI_TEST_EQUALS( initialChildActorPropertyCount + 1u, childActor.GetPropertyCount(), TEST_LOCATION );
1737 // Check the first child property value
1738 DALI_TEST_EQUALS( childActor.GetProperty< bool >( propertyIndex ), true, TEST_LOCATION );
1740 // Check the first child property type
1741 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex ), propertyType, TEST_LOCATION );
1743 // Check that the first child property have no name, as it doesn't have a parent yet.
1744 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex ), "", TEST_LOCATION );
1746 // Check that the first property can't be accessed through its name, as it doesn't have a parent yet.
1747 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName ), Property::INVALID_INDEX, TEST_LOCATION );
1749 // Create a custom property for the child with the same name as the second child property registered to the parent
1750 Property::Index customPropertyIndex = childActor.RegisterProperty(propertyName2, 100, Property::READ_WRITE);
1752 // Check that the custom property is created
1753 DALI_TEST_EQUALS( initialChildActorPropertyCount + 2u, childActor.GetPropertyCount(), TEST_LOCATION );
1755 // Check the property value
1756 DALI_TEST_EQUALS( childActor.GetProperty< int >( customPropertyIndex ), 100, TEST_LOCATION );
1758 // Check the property index
1759 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName2 ), customPropertyIndex, TEST_LOCATION );
1761 // Check the property type
1762 DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex ), propertyType2, TEST_LOCATION );
1764 // Check the property name
1765 DALI_TEST_EQUALS( childActor.GetPropertyName( customPropertyIndex ), propertyName2, TEST_LOCATION );
1767 // Now add the child actor to the parent
1768 customActor.Add( childActor );
1770 // Check that the first child property now has the correct name as previously registered to the parent
1771 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
1773 // Check that the child property index for the first child property can now be retrieved through its child property name
1774 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName ), propertyIndex, TEST_LOCATION );
1776 // Check that the second child property now has the correct index as previously registered to the parent
1777 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex2 ), propertyName2, TEST_LOCATION );
1779 // Check that the second child property can be accessed through both its custom property index and its child property index
1780 DALI_TEST_EQUALS( childActor.GetProperty< int >( customPropertyIndex ), 100, TEST_LOCATION );
1781 DALI_TEST_EQUALS( childActor.GetProperty< int >( propertyIndex2 ), 100, TEST_LOCATION );
1782 DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex ), propertyType2, TEST_LOCATION );
1783 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex2 ), propertyType2, TEST_LOCATION );
1785 // Check that the child property index for the second child property can now be retrieved through its child property name
1786 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName2 ), propertyIndex2, TEST_LOCATION );
1788 // Set the value for the third child property when the child actor is already added to the parent
1789 childActor.SetProperty(propertyIndex3, 0.15f);
1791 // Check that the third child property is dynamically created
1792 DALI_TEST_EQUALS( initialChildActorPropertyCount + 3u, childActor.GetPropertyCount(), TEST_LOCATION );
1794 // Check the third child property value
1795 DALI_TEST_EQUALS( childActor.GetProperty< float >( propertyIndex3 ), 0.15f, TEST_LOCATION );
1797 // Check the third child property type
1798 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex3 ), propertyType3, TEST_LOCATION );
1800 // Check the third child property name
1801 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex3 ), propertyName3, TEST_LOCATION );
1803 // Check the third child property index.
1804 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName3 ), propertyIndex3, TEST_LOCATION );
1806 // Create a custom property for the child with the same name as the fourth child property registered to the parent
1807 Property::Index customPropertyIndex2 = childActor.RegisterProperty(propertyName4, 20, Property::READ_WRITE);
1809 // Check that the custom property is created
1810 DALI_TEST_EQUALS( initialChildActorPropertyCount + 4u, childActor.GetPropertyCount(), TEST_LOCATION );
1812 // Check the fourth child property value
1813 DALI_TEST_EQUALS( childActor.GetProperty< int >( propertyIndex4 ), 20, TEST_LOCATION );
1814 DALI_TEST_EQUALS( childActor.GetProperty< int >( customPropertyIndex2 ), 20, TEST_LOCATION );
1816 // Check the fourth child property type
1817 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex4 ), propertyType4, TEST_LOCATION );
1818 DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex2 ), propertyType4, TEST_LOCATION );
1820 // Check the fourth child property name
1821 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex4 ), propertyName4, TEST_LOCATION );
1822 DALI_TEST_EQUALS( childActor.GetPropertyName( customPropertyIndex2 ), propertyName4, TEST_LOCATION );
1824 // Check the fourth child property index.
1825 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName4 ), propertyIndex4, TEST_LOCATION );
1827 // Now create another parent actor with different child properties registered
1828 TypeInfo typeInfo2 = typeRegistry.GetTypeInfo( "MyNamedActor" );
1829 DALI_TEST_CHECK( typeInfo2 );
1830 BaseHandle handle2 = typeInfo2.CreateInstance();
1831 DALI_TEST_CHECK( handle2 );
1832 Actor customActor2 = Actor::DownCast( handle2 );
1833 DALI_TEST_CHECK( customActor2 );
1835 // Register child properties to the new parent
1836 std::string newPropertyName( "newChildProp" );
1837 int newPropertyIndex( CHILD_PROPERTY_REGISTRATION_START_INDEX ); // The same index as the first child property "childProp1" in the old parent
1838 Property::Type newPropertyType( Property::VECTOR2 );
1839 ChildPropertyRegistration newChildProperty( namedActorType, newPropertyName, newPropertyIndex, newPropertyType );
1841 std::string newPropertyName2( "childProp3" ); // The same name as the third child property in the old parent
1842 int newPropertyIndex2( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1 ); // The same index as the second child property "childProp2" in the old parent
1843 Property::Type newPropertyType2( Property::FLOAT ); // The same type as the third child property in the old parent
1844 ChildPropertyRegistration newChildProperty2( namedActorType, newPropertyName2, newPropertyIndex2, newPropertyType2 );
1846 // Now move the child actor to the new parent
1847 customActor2.Add( childActor );
1849 // "childProp1" is not a valid child property supported by the new parent, so nothing changed
1850 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex ), propertyType, TEST_LOCATION );
1851 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
1852 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName ), propertyIndex, TEST_LOCATION );
1854 // "childProp3" is a valid child property supported by the new parent
1855 // So it should get its new child property index and should just work
1856 DALI_TEST_EQUALS( childActor.GetPropertyType( newPropertyIndex2 ), newPropertyType2, TEST_LOCATION );
1857 DALI_TEST_EQUALS( childActor.GetPropertyName( newPropertyIndex2 ), newPropertyName2, TEST_LOCATION );
1858 DALI_TEST_EQUALS( childActor.GetPropertyIndex( newPropertyName2 ), newPropertyIndex2, TEST_LOCATION );
1859 DALI_TEST_EQUALS( childActor.GetProperty< float >( newPropertyIndex2 ), 0.15f, TEST_LOCATION );
1861 // Now register a custom property called "newChildProp"
1862 Property::Index customPropertyIndex3 = childActor.RegisterProperty("newChildProp", Vector2( 10.0f, 10.0f ), Property::READ_WRITE);
1864 // Check that the custom property is created
1865 DALI_TEST_EQUALS( initialChildActorPropertyCount + 5u, childActor.GetPropertyCount(), TEST_LOCATION );
1867 // This is a valid child property registered to the new parent
1868 // So should be able to access it through both its custom property index and its registered child property index
1869 DALI_TEST_EQUALS( childActor.GetPropertyType( newPropertyIndex ), newPropertyType, TEST_LOCATION );
1870 DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex3 ), newPropertyType, TEST_LOCATION );
1871 DALI_TEST_EQUALS( childActor.GetPropertyName( newPropertyIndex ), newPropertyName, TEST_LOCATION ); // This should return the new name, although the child property index remains the same
1872 DALI_TEST_EQUALS( childActor.GetPropertyName( customPropertyIndex3 ), newPropertyName, TEST_LOCATION );
1873 DALI_TEST_EQUALS( childActor.GetProperty< Vector2 >( newPropertyIndex ), Vector2( 10.0f, 10.0f ), TEST_LOCATION );
1874 DALI_TEST_EQUALS( childActor.GetProperty< Vector2 >( customPropertyIndex3 ), Vector2( 10.0f, 10.0f ), TEST_LOCATION );
1876 // Should return the child property index by given its name
1877 DALI_TEST_EQUALS( childActor.GetPropertyIndex( newPropertyName ), newPropertyIndex, TEST_LOCATION );
1883 int UtcDaliTypeRegistryChildPropertyRegistrationN(void)
1885 TestApplication application;
1886 TypeRegistry typeRegistry = TypeRegistry::Get();
1888 // Attempt to register a child property type out-of-bounds index (less than)
1891 ChildPropertyRegistration property1( customType1, "propName", CHILD_PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN );
1892 tet_result( TET_FAIL );
1894 catch ( DaliException& e )
1896 DALI_TEST_ASSERT( e, "( index >= CHILD_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1899 // Attempt to register a child property type out-of-bounds index (greater than)
1902 ChildPropertyRegistration property1( customType1, "propName", CHILD_PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN );
1903 tet_result( TET_FAIL );
1905 catch ( DaliException& e )
1907 DALI_TEST_ASSERT( e, "( index >= CHILD_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1914 /*******************************************************************************
1916 * Action through the base handle
1918 ******************************************************************************/
1919 int UtcDaliTypeRegistryActionViaBaseHandle(void)
1921 TestApplication application;
1925 type = TypeRegistry::Get().GetTypeInfo( "Actor" );
1926 DALI_TEST_CHECK( type );
1928 BaseHandle hdl = type.CreateInstance();
1929 DALI_TEST_CHECK( hdl );
1931 Actor a = Actor::DownCast(hdl);
1932 DALI_TEST_CHECK( a );
1934 a.SetProperty( Actor::Property::VISIBLE,false);
1936 application.SendNotification();
1937 application.Render(0);
1938 DALI_TEST_CHECK(!a.GetCurrentProperty< bool >( Actor::Property::VISIBLE ));
1940 Property::Map attributes;
1942 DALI_TEST_CHECK(hdl.DoAction("show", attributes));
1944 application.SendNotification();
1945 application.Render(0);
1946 DALI_TEST_CHECK(a.GetCurrentProperty< bool >( Actor::Property::VISIBLE ));
1948 DALI_TEST_CHECK(!hdl.DoAction("unknownAction", attributes));
1952 int UtcDaliPropertyRegistrationFunctions(void)
1954 TestApplication application;
1955 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 10;
1957 // Attempt to register a property without a setter
1960 PropertyRegistration property1( customType1, "propName", propertyIndex++, Property::BOOLEAN, NULL, &GetProperty );
1961 tet_result( TET_PASS );
1963 catch ( DaliException& e )
1965 tet_result( TET_FAIL );
1968 // Attempt to register a property without a getter
1971 PropertyRegistration property1( customType1, "propName", propertyIndex++, Property::BOOLEAN, NULL, NULL );
1972 tet_result( TET_FAIL );
1974 catch ( DaliException& e )
1976 DALI_TEST_ASSERT( e, "! \"GetProperty", TEST_LOCATION );
1981 int UtcDaliPropertyRegistrationAddSameIndex(void)
1983 TestApplication application;
1984 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 100;
1986 // Add one property with a valid property index
1987 PropertyRegistration property1( customType1, "propName", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
1989 // Attempt to add another property with the same index
1992 PropertyRegistration property2( customType1, "propName2", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
1994 catch ( DaliException& e )
1996 DALI_TEST_ASSERT( e, "! \"Property index already added", TEST_LOCATION );
1999 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 100;
2001 // Add one property with a valid property index
2002 AnimatablePropertyRegistration property3( customType1, "animPropName", animatablePropertyIndex, Property::BOOLEAN );
2004 // Attempt to add another property with the same index
2007 AnimatablePropertyRegistration property4( customType1, "animPropName2", animatablePropertyIndex, Property::BOOLEAN );
2009 catch ( DaliException& e )
2011 DALI_TEST_ASSERT( e, "! \"Property index already added", TEST_LOCATION );
2016 int UtcDaliPropertyRegistrationPropertyWritableP(void)
2018 TestApplication application;
2019 int propertyIndex1 = PROPERTY_REGISTRATION_START_INDEX + 200;
2020 int propertyIndex2 = PROPERTY_REGISTRATION_START_INDEX + 201;
2022 // Add two properties, one with SetProperty, one without
2023 PropertyRegistration property1( customType1, "propNameReadwrite", propertyIndex1, Property::BOOLEAN, &SetProperty, &GetProperty );
2024 PropertyRegistration property2( customType1, "propNameReadonly", propertyIndex2, Property::BOOLEAN, NULL, &GetProperty );
2026 // Create custom-actor
2027 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
2028 DALI_TEST_CHECK( typeInfo );
2029 BaseHandle handle = typeInfo.CreateInstance();
2030 DALI_TEST_CHECK( handle );
2031 Actor customActor = Actor::DownCast( handle );
2032 DALI_TEST_CHECK( customActor );
2034 // Check whether properties are writable
2035 DALI_TEST_CHECK( customActor.IsPropertyWritable( propertyIndex1 ) );
2036 DALI_TEST_CHECK( ! customActor.IsPropertyWritable( propertyIndex2 ) );
2039 // Check the property is writable in the type registry
2040 Internal::TypeInfo& typeInfoImpl = GetImplementation( typeInfo );
2042 DALI_TEST_EQUALS( typeInfoImpl.IsPropertyWritable( propertyIndex1 ), true, TEST_LOCATION );
2047 int UtcDaliPropertyRegistrationPropertyWritableN(void)
2049 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
2050 Internal::TypeInfo& typeInfoImpl = GetImplementation( typeInfo );
2052 DALI_TEST_EQUALS( typeInfoImpl.IsPropertyWritable( Actor::Property::COLOR), true, TEST_LOCATION );
2057 int UtcDaliPropertyRegistrationPropertyAnimatable(void)
2059 TestApplication application;
2060 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 400;
2061 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 400;
2063 // These properties are not animatable
2064 PropertyRegistration property1( customType1, "propName", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
2066 // These properties are animatable
2067 AnimatablePropertyRegistration property2( customType1, "animPropName", animatablePropertyIndex, Property::BOOLEAN );
2069 // Create custom-actor
2070 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
2071 DALI_TEST_CHECK( typeInfo );
2072 BaseHandle handle = typeInfo.CreateInstance();
2073 DALI_TEST_CHECK( handle );
2074 Actor customActor = Actor::DownCast( handle );
2075 DALI_TEST_CHECK( customActor );
2077 // Check if animatable
2078 DALI_TEST_CHECK( ! customActor.IsPropertyAnimatable( propertyIndex ) );
2079 DALI_TEST_CHECK( customActor.IsPropertyAnimatable( animatablePropertyIndex ) );
2081 // Create another instance of custom-actor
2082 BaseHandle handle2 = typeInfo.CreateInstance();
2083 DALI_TEST_CHECK( handle2 );
2084 Actor customActor2 = Actor::DownCast( handle2 );
2085 DALI_TEST_CHECK( customActor2 );
2087 // Check if animatable
2088 DALI_TEST_CHECK( ! customActor2.IsPropertyAnimatable( propertyIndex ) );
2089 DALI_TEST_CHECK( customActor2.IsPropertyAnimatable( animatablePropertyIndex ) );
2093 int UtcDaliPropertyRegistrationUnregisteredGetAndSet(void)
2095 TestApplication application;
2096 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 2000;
2097 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2000;
2099 // Create custom-actor
2100 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
2101 DALI_TEST_CHECK( typeInfo );
2102 BaseHandle handle = typeInfo.CreateInstance();
2103 DALI_TEST_CHECK( handle );
2104 Actor customActor = Actor::DownCast( handle );
2105 DALI_TEST_CHECK( customActor );
2107 // Try to set an index that hasn't been registered, this is a no-op for now, to be fixed in future
2108 customActor.SetProperty( propertyIndex, true );
2109 // DALI_TEST_EQUALS( true, customActor.GetProperty( propertyIndex ).Get<bool>(), TEST_LOCATION);
2111 // Try to set an index that hasn't been registered
2112 customActor.SetProperty( animatablePropertyIndex, true );
2113 DALI_TEST_EQUALS( true, customActor.GetProperty( animatablePropertyIndex ).Get<bool>(), TEST_LOCATION);
2119 int UtcDaliLongPressGestureDetectorTypeRegistry(void)
2121 TestApplication application;
2123 Actor actor = Actor::New();
2124 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
2125 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
2126 application.GetScene().Add(actor);
2130 type = TypeRegistry::Get().GetTypeInfo( "LongPressGestureDetector" );
2131 DALI_TEST_CHECK( type );
2132 BaseHandle handle = type.CreateInstance();
2133 DALI_TEST_CHECK( handle );
2134 LongPressGestureDetector detector = LongPressGestureDetector::DownCast( handle );
2135 DALI_TEST_CHECK( detector );
2137 // Attach actor to detector
2139 GestureReceivedFunctor functor( data );
2140 detector.Attach(actor);
2142 // Connect to signal through type
2143 handle.ConnectSignal( &application, "longPressDetected", functor );
2145 // Render and notify
2146 application.SendNotification();
2147 application.Render();
2150 TestGenerateLongPress( application, 50.0f, 10.0f );
2151 TestEndLongPress( application, 50.0f, 10.0f );
2153 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2157 int UtcDaliPanGestureDetectorTypeRegistry(void)
2159 TestApplication application;
2161 Actor actor = Actor::New();
2162 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
2163 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
2164 application.GetScene().Add(actor);
2168 type = TypeRegistry::Get().GetTypeInfo( "PanGestureDetector" );
2169 DALI_TEST_CHECK( type );
2170 BaseHandle handle = type.CreateInstance();
2171 DALI_TEST_CHECK( handle );
2172 PanGestureDetector detector = PanGestureDetector::DownCast( handle );
2173 DALI_TEST_CHECK( detector );
2175 // Attach actor to detector
2177 GestureReceivedFunctor functor( data );
2178 detector.Attach(actor);
2180 // Connect to signal through type
2181 handle.ConnectSignal( &application, "panDetected", functor );
2183 // Render and notify
2184 application.SendNotification();
2185 application.Render();
2188 TestGenerateMiniPan( application );
2189 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2193 int UtcDaliPinchGestureDetectorTypeRegistry(void)
2195 TestApplication application;
2197 Actor actor = Actor::New();
2198 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
2199 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
2200 application.GetScene().Add(actor);
2204 type = TypeRegistry::Get().GetTypeInfo( "PinchGestureDetector" );
2205 DALI_TEST_CHECK( type );
2206 BaseHandle handle = type.CreateInstance();
2207 DALI_TEST_CHECK( handle );
2208 PinchGestureDetector detector = PinchGestureDetector::DownCast( handle );
2209 DALI_TEST_CHECK( detector );
2211 // Attach actor to detector
2213 GestureReceivedFunctor functor( data );
2214 detector.Attach(actor);
2216 // Connect to signal through type
2217 handle.ConnectSignal( &application, "pinchDetected", functor );
2219 // Render and notify
2220 application.SendNotification();
2221 application.Render();
2224 TestGeneratePinch( application );
2226 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2230 int UtcDaliRotationGestureDetectorTypeRegistry(void)
2232 TestApplication application;
2234 Actor actor = Actor::New();
2235 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
2236 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
2237 application.GetScene().Add(actor);
2241 type = TypeRegistry::Get().GetTypeInfo( "RotationGestureDetector" );
2242 DALI_TEST_CHECK( type );
2243 BaseHandle handle = type.CreateInstance();
2244 DALI_TEST_CHECK( handle );
2245 RotationGestureDetector detector = RotationGestureDetector::DownCast( handle );
2246 DALI_TEST_CHECK( detector );
2248 // Attach actor to detector
2250 GestureReceivedFunctor functor( data );
2251 detector.Attach(actor);
2253 // Connect to signal through type
2254 handle.ConnectSignal( &application, "rotationDetected", functor );
2256 // Render and notify
2257 application.SendNotification();
2258 application.Render();
2261 TestGenerateRotation( application );
2263 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2267 int UtcDaliTapGestureDetectorTypeRegistry(void)
2269 TestApplication application;
2271 Actor actor = Actor::New();
2272 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
2273 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
2274 application.GetScene().Add(actor);
2278 type = TypeRegistry::Get().GetTypeInfo( "TapGestureDetector" );
2279 DALI_TEST_CHECK( type );
2280 BaseHandle handle = type.CreateInstance();
2281 DALI_TEST_CHECK( handle );
2282 TapGestureDetector detector = TapGestureDetector::DownCast( handle );
2283 DALI_TEST_CHECK( detector );
2285 // Attach actor to detector
2287 GestureReceivedFunctor functor( data );
2288 detector.Attach(actor);
2290 // Connect to signal through type
2291 handle.ConnectSignal( &application, "tapDetected", functor );
2293 // Render and notify
2294 application.SendNotification();
2295 application.Render();
2298 TestGenerateTap( application, 50.0, 10.0, 100 );
2300 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2304 int UtcDaliTypeRegistryNamedType(void)
2306 TestApplication application;
2307 TypeRegistry typeRegistry = TypeRegistry::Get();
2309 // Create a normal actor
2310 BaseHandle actorHandle = typeRegistry.GetTypeInfo( "Actor" ).CreateInstance();
2311 DALI_TEST_CHECK( actorHandle );
2312 Actor actor( Actor::DownCast( actorHandle ) );
2313 DALI_TEST_CHECK( actor );
2314 unsigned int actorPropertyCount( actor.GetPropertyCount() );
2316 // Create Named Actor Type
2317 BaseHandle namedHandle = typeRegistry.GetTypeInfo( "MyNamedActor" ).CreateInstance();
2318 DALI_TEST_CHECK( namedHandle );
2319 Actor namedActor( Actor::DownCast( namedHandle ) );
2320 DALI_TEST_CHECK( namedActor );
2321 unsigned int namedActorPropertyCount( namedActor.GetPropertyCount() );
2323 DALI_TEST_CHECK( namedActorPropertyCount > actorPropertyCount );
2327 int UtcDaliTypeInfoGetActionNameP(void)
2329 TestApplication application;
2330 TypeRegistry typeRegistry = TypeRegistry::Get();
2332 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2333 DALI_TEST_CHECK( typeInfo );
2335 DALI_TEST_CHECK( 0 != typeInfo.GetActionCount() );
2337 std::string name = typeInfo.GetActionName(0);
2339 DALI_TEST_EQUALS( name, "show", TEST_LOCATION );
2342 TypeInfo typeInfo2 = typeRegistry.GetTypeInfo( "MyTestCustomActor" );
2344 // search for show action in base class, given a derived class
2345 bool foundChildAction = false;
2346 for( std::size_t i = 0; i < typeInfo2.GetActionCount(); i++ )
2349 std::string name = typeInfo2.GetActionName( i );
2352 foundChildAction = true;
2357 DALI_TEST_EQUALS( foundChildAction, true, TEST_LOCATION );
2363 int UtcDaliTypeInfoGetActionNameN(void)
2365 TestApplication application;
2366 TypeRegistry typeRegistry = TypeRegistry::Get();
2368 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2369 DALI_TEST_CHECK( typeInfo );
2371 DALI_TEST_CHECK( 0 != typeInfo.GetActionCount() );
2373 std::string name = typeInfo.GetActionName(std::numeric_limits<size_t>::max());
2375 DALI_TEST_EQUALS( 0u, name.size(), TEST_LOCATION );
2380 int UtcDaliTypeInfoGetSignalNameP(void)
2382 TestApplication application;
2383 TypeRegistry typeRegistry = TypeRegistry::Get();
2385 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2386 DALI_TEST_CHECK( typeInfo );
2388 DALI_TEST_CHECK( 0 != typeInfo.GetSignalCount() );
2390 std::string name = typeInfo.GetSignalName(0);
2392 DALI_TEST_EQUALS( name, "hovered", TEST_LOCATION );
2394 TypeInfo typeInfo2 = typeRegistry.GetTypeInfo( "MyTestCustomActor" );
2396 // search for signal in base class, given a derived class
2397 bool foundSignal = false;
2398 for( std::size_t i = 0; i < typeInfo2.GetSignalCount(); i++ )
2400 std::string name = typeInfo2.GetSignalName( i );
2401 if( name == "hovered")
2407 DALI_TEST_EQUALS( foundSignal, true, TEST_LOCATION );
2412 int UtcDaliTypeInfoGetSignalNameN(void)
2414 TestApplication application;
2415 TypeRegistry typeRegistry = TypeRegistry::Get();
2417 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2418 DALI_TEST_CHECK( typeInfo );
2420 DALI_TEST_CHECK( 0 != typeInfo.GetSignalCount() );
2422 std::string name = typeInfo.GetSignalName(std::numeric_limits<size_t>::max());
2424 DALI_TEST_EQUALS( 0u, name.size(), TEST_LOCATION );
2430 int UtcDaliTypeInfoGetCreatorP(void)
2432 TestApplication application;
2433 TypeRegistry typeRegistry = TypeRegistry::Get();
2435 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2436 DALI_TEST_CHECK( typeInfo );
2438 TypeInfo::CreateFunction createFn = typeInfo.GetCreator();
2439 DALI_TEST_EQUALS( createFn != NULL, true, TEST_LOCATION );
2443 BaseHandle handle = createFn();
2444 DALI_TEST_EQUALS( (bool)handle, true, TEST_LOCATION );
2450 int UtcDaliTypeInfoGetCreatorN(void)
2452 TestApplication application;
2453 TypeRegistry typeRegistry = TypeRegistry::Get();
2455 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "MyTestCustomActor3" );
2456 DALI_TEST_CHECK( typeInfo );
2458 TypeInfo::CreateFunction createFn = typeInfo.GetCreator();
2459 DALI_TEST_EQUALS( createFn == NULL, true, TEST_LOCATION );
2464 int UtcDaliTypeInfoGetPropertyCountP1(void)
2466 TestApplication application;
2467 TypeRegistry typeRegistry = TypeRegistry::Get();
2469 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2470 DALI_TEST_CHECK( typeInfo );
2471 size_t actorPropertyCount = typeInfo.GetPropertyCount();
2473 DALI_TEST_EQUALS( actorPropertyCount, Actor::New().GetPropertyCount(), TEST_LOCATION ); // No event only props
2477 int UtcDaliTypeInfoGetPropertyCountP2(void)
2479 TestApplication application;
2480 TypeRegistry typeRegistry = TypeRegistry::Get();
2482 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "MyTestCustomActor2" );
2483 DALI_TEST_CHECK( typeInfo );
2484 size_t propertyCount = typeInfo.GetPropertyCount();
2485 Property::IndexContainer indices;
2486 typeInfo.GetPropertyIndices( indices );
2488 DALI_TEST_EQUALS( propertyCount > 0 && propertyCount <= indices.Size(), true, TEST_LOCATION );
2489 DALI_TEST_EQUALS( propertyCount, Actor::New().GetPropertyCount() + 2, TEST_LOCATION );
2494 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGet01(void)
2496 TestApplication application;
2497 TypeRegistry typeRegistry = TypeRegistry::Get();
2499 tet_infoline( "Register a type registered animatable property and ensure set/get behaviour works synchronously" );
2501 // Register animatable property
2502 const int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
2503 AnimatablePropertyRegistration animatableProperty( customType1, "animatableProp1", animatablePropertyIndex, Property::FLOAT );
2505 // Check property count before property registration
2506 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2507 DALI_TEST_CHECK( typeInfo );
2508 BaseHandle handle = typeInfo.CreateInstance();
2509 DALI_TEST_CHECK( handle );
2510 Actor customActor = Actor::DownCast( handle );
2511 DALI_TEST_CHECK( customActor );
2512 application.GetScene().Add(customActor);
2514 tet_infoline( "Set the value and ensure it changes straight away" );
2515 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 0.0f, TEST_LOCATION );
2516 customActor.SetProperty( animatablePropertyIndex, 25.0f );
2517 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 25.0f, TEST_LOCATION );
2519 tet_infoline( "Check latest scene-graph value is unchanged" );
2520 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 0.0f, TEST_LOCATION );
2522 // Render and notify
2523 application.SendNotification();
2524 application.Render();
2526 tet_infoline( "Check values after rendering and both retrieval methods should return the latest" );
2528 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 25.0f, TEST_LOCATION );
2529 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 25.0f, TEST_LOCATION );
2534 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGetWithComponentsVector2(void)
2536 TestApplication application;
2537 TypeRegistry typeRegistry = TypeRegistry::Get();
2539 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" );
2541 // Register the animatable propeties
2542 const int basePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
2543 const int componentZeroPropertyIndex( basePropertyIndex + 1 );
2544 const int componentOnePropertyIndex( componentZeroPropertyIndex + 1 );
2545 AnimatablePropertyRegistration baseAnimatableProperty( customType1, "baseProp", basePropertyIndex, Vector2( 13.0f, 24.0f ) );
2546 AnimatablePropertyComponentRegistration componentZeroAnimatableProperty( customType1, "componentZeroProp", componentZeroPropertyIndex, basePropertyIndex, 0 );
2547 AnimatablePropertyComponentRegistration componentOneAnimatableProperty( customType1, "componentOneProp", componentOnePropertyIndex, basePropertyIndex, 1 );
2549 // Check property count before property registration
2550 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2551 DALI_TEST_CHECK( typeInfo );
2552 BaseHandle handle = typeInfo.CreateInstance();
2553 DALI_TEST_CHECK( handle );
2554 Actor customActor = Actor::DownCast( handle );
2555 DALI_TEST_CHECK( customActor );
2556 application.GetScene().Add(customActor);
2558 tet_infoline( "Get the component values, they should be the default value of the base-property" );
2559 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2560 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2561 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 13.0f, 24.0f ), TEST_LOCATION );
2563 tet_infoline( "Set a component value and ensure it changes for the base property as well" );
2564 customActor.SetProperty( componentZeroPropertyIndex, 125.0f );
2565 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2566 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 125.0f, 24.0f ), TEST_LOCATION );
2568 customActor.SetProperty( componentOnePropertyIndex, 225.0f );
2569 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2570 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 125.0f, 225.0f ), TEST_LOCATION );
2572 tet_infoline( "Check latest scene-graph value is unchanged" );
2573 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector2 >( basePropertyIndex ), Vector2( 13.0f, 24.0f ), TEST_LOCATION );
2574 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2575 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2577 // Render and notify
2578 application.SendNotification();
2579 application.Render();
2581 tet_infoline( "Check values after rendering and both retrieval methods should return the latest" );
2582 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 125.0f, 225.0f ), TEST_LOCATION );
2583 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2584 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2586 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector2 >( basePropertyIndex ), Vector2( 125.0f, 225.0f ), TEST_LOCATION );
2587 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2588 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2590 tet_infoline( "Set the base property value and ensure the component values reflect the change" );
2591 customActor.SetProperty( basePropertyIndex, Vector2( 1.0f, 2.0f ) );
2592 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 1.0f, TEST_LOCATION );
2593 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 2.0f, TEST_LOCATION );
2594 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 1.0f, 2.0f ), TEST_LOCATION );
2599 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGetWithComponentsVector3(void)
2601 TestApplication application;
2602 TypeRegistry typeRegistry = TypeRegistry::Get();
2604 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" );
2606 // Register the animatable propeties
2607 const int basePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
2608 const int componentZeroPropertyIndex( basePropertyIndex + 1 );
2609 const int componentOnePropertyIndex( componentZeroPropertyIndex + 1 );
2610 const int componentTwoPropertyIndex( componentOnePropertyIndex + 1 );
2611 AnimatablePropertyRegistration baseAnimatableProperty( customType1, "baseProp", basePropertyIndex, Vector3( 13.0f, 24.0f, 35.0 ) );
2612 AnimatablePropertyComponentRegistration componentZeroAnimatableProperty( customType1, "componentZeroProp", componentZeroPropertyIndex, basePropertyIndex, 0 );
2613 AnimatablePropertyComponentRegistration componentOneAnimatableProperty( customType1, "componentOneProp", componentOnePropertyIndex, basePropertyIndex, 1 );
2614 AnimatablePropertyComponentRegistration componentTwoAnimatableProperty( customType1, "componentTwoProp", componentTwoPropertyIndex, basePropertyIndex, 2 );
2616 // Check property count before property registration
2617 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2618 DALI_TEST_CHECK( typeInfo );
2619 BaseHandle handle = typeInfo.CreateInstance();
2620 DALI_TEST_CHECK( handle );
2621 Actor customActor = Actor::DownCast( handle );
2622 DALI_TEST_CHECK( customActor );
2623 application.GetScene().Add(customActor);
2625 tet_infoline( "Get the component values, they should be the default value of the base-property" );
2626 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2627 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2628 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 35.0f, TEST_LOCATION );
2629 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 13.0f, 24.0f, 35.0f ), TEST_LOCATION );
2631 tet_infoline( "Set a component value and ensure it changes for the base property as well" );
2632 customActor.SetProperty( componentZeroPropertyIndex, 125.0f );
2633 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2634 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 24.0f, 35.0f ), TEST_LOCATION );
2636 customActor.SetProperty( componentOnePropertyIndex, 225.0f );
2637 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2638 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 225.0f, 35.0f ), TEST_LOCATION );
2640 customActor.SetProperty( componentTwoPropertyIndex, 325.0f );
2641 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2642 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 225.0f, 325.0f ), TEST_LOCATION );
2644 tet_infoline( "Check latest scene-graph value is unchanged" );
2645 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector3 >( basePropertyIndex ), Vector3( 13.0f, 24.0f, 35.0f ), TEST_LOCATION );
2646 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2647 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2648 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentTwoPropertyIndex ), 35.0f, TEST_LOCATION );
2650 // Render and notify
2651 application.SendNotification();
2652 application.Render();
2654 tet_infoline( "Check values after rendering and both retrieval methods should return the latest" );
2655 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 225.0f, 325.0f ), TEST_LOCATION );
2656 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2657 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2658 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2660 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 225.0f, 325.0f ), TEST_LOCATION );
2661 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2662 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2663 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2665 tet_infoline( "Set the base property value and ensure the component values reflect the change" );
2666 customActor.SetProperty( basePropertyIndex, Vector3( 1.0f, 2.0f, 3.0f ) );
2667 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 1.0f, TEST_LOCATION );
2668 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 2.0f, TEST_LOCATION );
2669 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 3.0f, TEST_LOCATION );
2670 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 1.0f, 2.0f, 3.0f ), TEST_LOCATION );
2675 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGetWithComponentsVector4(void)
2677 TestApplication application;
2678 TypeRegistry typeRegistry = TypeRegistry::Get();
2680 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" );
2682 // Register the animatable propeties
2683 const int basePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
2684 const int componentZeroPropertyIndex( basePropertyIndex + 1 );
2685 const int componentOnePropertyIndex( componentZeroPropertyIndex + 1 );
2686 const int componentTwoPropertyIndex( componentOnePropertyIndex + 1 );
2687 const int componentThreePropertyIndex( componentTwoPropertyIndex + 1 );
2688 AnimatablePropertyRegistration baseAnimatableProperty( customType1, "baseProp", basePropertyIndex, Vector4( 13.0f, 24.0f, 35.0, 47.0f ) );
2689 AnimatablePropertyComponentRegistration componentZeroAnimatableProperty( customType1, "componentZeroProp", componentZeroPropertyIndex, basePropertyIndex, 0 );
2690 AnimatablePropertyComponentRegistration componentOneAnimatableProperty( customType1, "componentOneProp", componentOnePropertyIndex, basePropertyIndex, 1 );
2691 AnimatablePropertyComponentRegistration componentTwoAnimatableProperty( customType1, "componentTwoProp", componentTwoPropertyIndex, basePropertyIndex, 2 );
2692 AnimatablePropertyComponentRegistration componentThreeAnimatableProperty( customType1, "componentThreeProp", componentThreePropertyIndex, basePropertyIndex, 3 );
2694 // Check property count before property registration
2695 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2696 DALI_TEST_CHECK( typeInfo );
2697 BaseHandle handle = typeInfo.CreateInstance();
2698 DALI_TEST_CHECK( handle );
2699 Actor customActor = Actor::DownCast( handle );
2700 DALI_TEST_CHECK( customActor );
2701 application.GetScene().Add(customActor);
2703 tet_infoline( "Get the component values, they should be the default value of the base-property" );
2704 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2705 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2706 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 35.0f, TEST_LOCATION );
2707 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentThreePropertyIndex ), 47.0f, TEST_LOCATION );
2708 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 13.0f, 24.0f, 35.0f, 47.0f ), TEST_LOCATION );
2710 tet_infoline( "Set a component value and ensure it changes for the base property as well" );
2711 customActor.SetProperty( componentZeroPropertyIndex, 125.0f );
2712 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2713 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 24.0f, 35.0f, 47.0f ), TEST_LOCATION );
2715 customActor.SetProperty( componentOnePropertyIndex, 225.0f );
2716 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2717 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 35.0f, 47.0f ), TEST_LOCATION );
2719 customActor.SetProperty( componentTwoPropertyIndex, 325.0f );
2720 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2721 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 325.0f, 47.0f ), TEST_LOCATION );
2723 customActor.SetProperty( componentThreePropertyIndex, 435.0f );
2724 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentThreePropertyIndex ), 435.0f, TEST_LOCATION );
2725 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 325.0f, 435.0f ), TEST_LOCATION );
2727 tet_infoline( "Check latest scene-graph value is unchanged" );
2728 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector4 >( basePropertyIndex ), Vector4( 13.0f, 24.0f, 35.0f, 47.0f ), TEST_LOCATION );
2729 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2730 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2731 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentTwoPropertyIndex ), 35.0f, TEST_LOCATION );
2732 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentThreePropertyIndex ), 47.0f, TEST_LOCATION );
2734 // Render and notify
2735 application.SendNotification();
2736 application.Render();
2738 tet_infoline( "Check values after rendering and both retrieval methods should return the latest" );
2739 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 325.0f, 435.0f ), TEST_LOCATION );
2740 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2741 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2742 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2743 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentThreePropertyIndex ), 435.0f, TEST_LOCATION );
2745 DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 325.0f, 435.0f ), TEST_LOCATION );
2746 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2747 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2748 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2749 DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentThreePropertyIndex ), 435.0f, TEST_LOCATION );
2751 tet_infoline( "Set the base property value and ensure the component values reflect the change" );
2752 customActor.SetProperty( basePropertyIndex, Vector4( 1.0f, 2.0f, 3.0f, 4.0f ) );
2753 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 1.0f, TEST_LOCATION );
2754 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 2.0f, TEST_LOCATION );
2755 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 3.0f, TEST_LOCATION );
2756 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentThreePropertyIndex ), 4.0f, TEST_LOCATION );
2757 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 1.0f, 2.0f, 3.0f, 4.0f ), TEST_LOCATION );
2763 int UtcDaliTypeInfoRegisterChildProperties01(void)
2765 TestApplication application;
2766 TypeRegistry typeRegistry = TypeRegistry::Get();
2768 tet_infoline( "Register child properties on a type via name" );
2770 auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(CustomActor) );
2771 auto myCustomTypeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2772 DALI_TEST_CHECK( customActorTypeInfo );
2773 DALI_TEST_CHECK( myCustomTypeInfo );
2775 const Property::Index WIDTH_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX );
2776 const Property::Index HEIGHT_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1);
2777 const Property::Index MARGIN_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 100);
2779 ChildPropertyRegistration( customActorTypeInfo.GetName(), "widthSpecification", WIDTH_SPECIFICATION, Property::INTEGER );
2780 ChildPropertyRegistration( customActorTypeInfo.GetName(), "heightSpecification", HEIGHT_SPECIFICATION, Property::INTEGER );
2781 ChildPropertyRegistration( myCustomTypeInfo.GetName(), "marginSpecification", MARGIN_SPECIFICATION, Property::EXTENTS );
2783 auto customActor = MyTestCustomActor::New();
2784 application.GetScene().Add( customActor );
2785 auto child = Actor::New();
2786 customActor.Add( child );
2788 child.SetProperty( WIDTH_SPECIFICATION, 33 );
2790 auto value = child.GetProperty( WIDTH_SPECIFICATION );
2791 DALI_TEST_EQUALS( value, Property::Value(33), TEST_LOCATION );
2793 child.SetProperty( HEIGHT_SPECIFICATION, 44 );
2794 value = child.GetProperty( HEIGHT_SPECIFICATION );
2795 DALI_TEST_EQUALS( value, Property::Value(44), TEST_LOCATION );
2797 child.SetProperty( MARGIN_SPECIFICATION, Extents(10, 10, 10, 10) );
2798 value = child.GetProperty( MARGIN_SPECIFICATION );
2799 DALI_TEST_EQUALS( value, Property::Value(Extents(10,10,10,10)), TEST_LOCATION );
2805 int UtcDaliTypeInfoRegisterChildProperties02(void)
2807 TestApplication application;
2808 TypeRegistry typeRegistry = TypeRegistry::Get();
2810 tet_infoline( "Register child properties on a type via name" );
2812 auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(CustomActor) );
2813 auto myCustomTypeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2814 DALI_TEST_CHECK( customActorTypeInfo );
2815 DALI_TEST_CHECK( myCustomTypeInfo );
2817 const Property::Index WIDTH_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX );
2818 const Property::Index HEIGHT_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1);
2819 const Property::Index MARGIN_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 100);
2821 ChildPropertyRegistration( customActorTypeInfo.GetName(), "widthSpecification", WIDTH_SPECIFICATION, Property::INTEGER );
2822 ChildPropertyRegistration( customActorTypeInfo.GetName(), "heightSpecification", HEIGHT_SPECIFICATION, Property::INTEGER );
2823 ChildPropertyRegistration( myCustomTypeInfo.GetName(), "marginSpecification", MARGIN_SPECIFICATION, Property::EXTENTS );
2826 auto index = customActorTypeInfo.GetChildPropertyIndex( "widthSpecification" );
2827 DALI_TEST_EQUALS( index, WIDTH_SPECIFICATION, TEST_LOCATION );
2829 index = customActorTypeInfo.GetChildPropertyIndex( "heightSpecification" );
2830 DALI_TEST_EQUALS( index, HEIGHT_SPECIFICATION, TEST_LOCATION );
2832 index = customActorTypeInfo.GetChildPropertyIndex( "marginSpecification" );
2833 DALI_TEST_EQUALS( index, Property::INVALID_INDEX, TEST_LOCATION );
2835 index = myCustomTypeInfo.GetChildPropertyIndex( "marginSpecification" );
2836 DALI_TEST_EQUALS( index, MARGIN_SPECIFICATION, TEST_LOCATION );
2839 auto name = customActorTypeInfo.GetChildPropertyName( WIDTH_SPECIFICATION );
2840 DALI_TEST_EQUALS( name, "widthSpecification", TEST_LOCATION );
2842 name = customActorTypeInfo.GetChildPropertyName( HEIGHT_SPECIFICATION );
2843 DALI_TEST_EQUALS( name, "heightSpecification", TEST_LOCATION );
2845 name = myCustomTypeInfo.GetChildPropertyName( MARGIN_SPECIFICATION );
2846 DALI_TEST_EQUALS( name, "marginSpecification", TEST_LOCATION );
2849 auto type = customActorTypeInfo.GetChildPropertyType( WIDTH_SPECIFICATION );
2850 DALI_TEST_EQUALS( type, Property::INTEGER, TEST_LOCATION );
2852 type = customActorTypeInfo.GetChildPropertyType( HEIGHT_SPECIFICATION );
2853 DALI_TEST_EQUALS( type, Property::INTEGER, TEST_LOCATION );
2855 type = myCustomTypeInfo.GetChildPropertyType( MARGIN_SPECIFICATION );
2856 DALI_TEST_EQUALS( type, Property::EXTENTS, TEST_LOCATION );
2863 int UtcDaliTypeInfoRegisterChildProperties03(void)
2865 TestApplication application;
2866 TypeRegistry typeRegistry = TypeRegistry::Get();
2868 tet_infoline( "Check registered child properties can be retrieved" );
2870 auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(CustomActor) );
2871 auto myCustomTypeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2872 DALI_TEST_CHECK( customActorTypeInfo );
2873 DALI_TEST_CHECK( myCustomTypeInfo );
2875 const Property::Index WIDTH_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX );
2876 const Property::Index HEIGHT_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1);
2877 const Property::Index MARGIN_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 100);
2879 ChildPropertyRegistration( customActorTypeInfo.GetName(), "widthSpecification", WIDTH_SPECIFICATION, Property::INTEGER );
2880 ChildPropertyRegistration( customActorTypeInfo.GetName(), "heightSpecification", HEIGHT_SPECIFICATION, Property::INTEGER );
2881 ChildPropertyRegistration( myCustomTypeInfo.GetName(), "marginSpecification", MARGIN_SPECIFICATION, Property::EXTENTS );
2883 Property::IndexContainer indices;
2884 myCustomTypeInfo.GetChildPropertyIndices( indices );
2886 auto result = std::find( indices.Begin(), indices.End(), WIDTH_SPECIFICATION );
2887 DALI_TEST_EQUALS( result != indices.End(), true, TEST_LOCATION );
2889 result = std::find( indices.Begin(), indices.End(), HEIGHT_SPECIFICATION );
2890 DALI_TEST_EQUALS( result != indices.End(), true, TEST_LOCATION );
2892 result = std::find( indices.Begin(), indices.End(), MARGIN_SPECIFICATION );
2893 DALI_TEST_EQUALS( result != indices.End(), true, TEST_LOCATION );
2898 int UtcDaliTypeInfoGetActionNameNegative(void)
2900 TestApplication application;
2901 Dali::TypeInfo instance;
2904 unsigned long arg1(0u);
2905 instance.GetActionName(arg1);
2906 DALI_TEST_CHECK(false); // Should not get here
2910 DALI_TEST_CHECK(true); // We expect an assert
2915 int UtcDaliTypeInfoGetSignalNameNegative(void)
2917 TestApplication application;
2918 Dali::TypeInfo instance;
2921 unsigned long arg1(0u);
2922 instance.GetSignalName(arg1);
2923 DALI_TEST_CHECK(false); // Should not get here
2927 DALI_TEST_CHECK(true); // We expect an assert
2932 int UtcDaliTypeInfoGetCreatorNegative(void)
2934 TestApplication application;
2935 Dali::TypeInfo instance;
2938 instance.GetCreator();
2939 DALI_TEST_CHECK(false); // Should not get here
2943 DALI_TEST_CHECK(true); // We expect an assert
2948 int UtcDaliTypeInfoGetBaseNameNegative(void)
2950 TestApplication application;
2951 Dali::TypeInfo instance;
2954 instance.GetBaseName();
2955 DALI_TEST_CHECK(false); // Should not get here
2959 DALI_TEST_CHECK(true); // We expect an assert
2964 int UtcDaliTypeInfoCreateInstanceNegative(void)
2966 TestApplication application;
2967 Dali::TypeInfo instance;
2970 instance.CreateInstance();
2971 DALI_TEST_CHECK(false); // Should not get here
2975 DALI_TEST_CHECK(true); // We expect an assert
2980 int UtcDaliTypeInfoGetActionCountNegative(void)
2982 TestApplication application;
2983 Dali::TypeInfo instance;
2986 instance.GetActionCount();
2987 DALI_TEST_CHECK(false); // Should not get here
2991 DALI_TEST_CHECK(true); // We expect an assert
2996 int UtcDaliTypeInfoGetSignalCountNegative(void)
2998 TestApplication application;
2999 Dali::TypeInfo instance;
3002 instance.GetSignalCount();
3003 DALI_TEST_CHECK(false); // Should not get here
3007 DALI_TEST_CHECK(true); // We expect an assert
3012 int UtcDaliTypeInfoGetPropertyNameNegative(void)
3014 TestApplication application;
3015 Dali::TypeInfo instance;
3019 instance.GetPropertyName(arg1);
3020 DALI_TEST_CHECK(false); // Should not get here
3024 DALI_TEST_CHECK(true); // We expect an assert
3029 int UtcDaliTypeInfoGetPropertyCountNegative(void)
3031 TestApplication application;
3032 Dali::TypeInfo instance;
3035 instance.GetPropertyCount();
3036 DALI_TEST_CHECK(false); // Should not get here
3040 DALI_TEST_CHECK(true); // We expect an assert
3045 int UtcDaliTypeInfoGetPropertyIndicesNegative(void)
3047 TestApplication application;
3048 Dali::TypeInfo instance;
3051 Dali::Vector<int> arg1;
3052 instance.GetPropertyIndices(arg1);
3053 DALI_TEST_CHECK(false); // Should not get here
3057 DALI_TEST_CHECK(true); // We expect an assert
3062 int UtcDaliTypeInfoGetChildPropertyNameNegative(void)
3064 TestApplication application;
3065 Dali::TypeInfo instance;
3069 instance.GetChildPropertyName(arg1);
3070 DALI_TEST_CHECK(false); // Should not get here
3074 DALI_TEST_CHECK(true); // We expect an assert
3079 int UtcDaliTypeInfoGetChildPropertyTypeNegative(void)
3081 TestApplication application;
3082 Dali::TypeInfo instance;
3086 instance.GetChildPropertyType(arg1);
3087 DALI_TEST_CHECK(false); // Should not get here
3091 DALI_TEST_CHECK(true); // We expect an assert
3096 int UtcDaliTypeInfoGetChildPropertyIndexNegative(void)
3098 TestApplication application;
3099 Dali::TypeInfo instance;
3103 instance.GetChildPropertyIndex(arg1);
3104 DALI_TEST_CHECK(false); // Should not get here
3108 DALI_TEST_CHECK(true); // We expect an assert
3113 int UtcDaliTypeInfoGetChildPropertyIndicesNegative(void)
3115 TestApplication application;
3116 Dali::TypeInfo instance;
3119 Dali::Vector<int> arg1;
3120 instance.GetChildPropertyIndices(arg1);
3121 DALI_TEST_CHECK(false); // Should not get here
3125 DALI_TEST_CHECK(true); // We expect an assert
3130 int UtcDaliTypeInfoGetNameNegative(void)
3132 TestApplication application;
3133 Dali::TypeInfo instance;
3137 DALI_TEST_CHECK(false); // Should not get here
3141 DALI_TEST_CHECK(true); // We expect an assert
3146 int UtcDaliTypeRegistryGetTypeInfoNegative01(void)
3148 TestApplication application;
3149 Dali::TypeRegistry instance;
3153 instance.GetTypeInfo(arg1);
3154 DALI_TEST_CHECK(false); // Should not get here
3158 DALI_TEST_CHECK(true); // We expect an assert
3163 int UtcDaliTypeRegistryGetTypeInfoNegative02(void)
3165 TestApplication application;
3166 Dali::TypeRegistry instance;
3169 instance.GetTypeInfo(typeid(unsigned int));
3170 DALI_TEST_CHECK(false); // Should not get here
3174 DALI_TEST_CHECK(true); // We expect an assert
3179 int UtcDaliTypeRegistryGetTypeNameNegative(void)
3181 TestApplication application;
3182 Dali::TypeRegistry instance;
3185 unsigned long arg1(0u);
3186 instance.GetTypeName(arg1);
3187 DALI_TEST_CHECK(false); // Should not get here
3191 DALI_TEST_CHECK(true); // We expect an assert
3196 int UtcDaliTypeRegistryGetTypeNameCountNegative(void)
3198 TestApplication application;
3199 Dali::TypeRegistry instance;
3202 instance.GetTypeNameCount();
3203 DALI_TEST_CHECK(false); // Should not get here
3207 DALI_TEST_CHECK(true); // We expect an assert