2 * Copyright (c) 2017 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/devel-api/object/handle-devel.h>
23 #include <dali-test-suite-utils.h>
24 #include <dali/internal/event/common/type-info-impl.h>
25 #include <dali/integration-api/events/long-press-gesture-event.h>
26 #include <dali/integration-api/events/pan-gesture-event.h>
27 #include <dali/integration-api/events/pinch-gesture-event.h>
28 #include <dali/integration-api/events/tap-gesture-event.h>
29 #include <dali/integration-api/events/touch-event-integ.h>
30 #include <dali/integration-api/events/hover-event-integ.h>
38 // Stores data that is populated in the callback and will be read by the Test cases
42 : functorCalled( false ),
43 voidFunctorCalled( false ),
44 receivedGesture( Gesture::Clear ),
50 functorCalled = false;
51 voidFunctorCalled = false;
53 receivedGesture.numberOfTouches = 0u;
54 receivedGesture.screenPoint = Vector2(0.0f, 0.0f);
55 receivedGesture.localPoint = Vector2(0.0f, 0.0f);
61 bool voidFunctorCalled;
62 LongPressGesture receivedGesture;
66 // Functor that sets the data when called
67 struct GestureReceivedFunctor
69 GestureReceivedFunctor(SignalData& data) : signalData(data) { }
71 void operator()(Actor actor, LongPressGesture longPress)
73 signalData.functorCalled = true;
74 signalData.receivedGesture = longPress;
75 signalData.pressedActor = actor;
80 signalData.voidFunctorCalled = true;
83 SignalData& signalData;
86 // Generate a LongPressGestureEvent to send to Core
87 Integration::LongPressGestureEvent GenerateLongPress(
89 unsigned int numberOfTouches,
92 Integration::LongPressGestureEvent longPress( state );
94 longPress.numberOfTouches = numberOfTouches;
95 longPress.point = point;
100 // Generate a PanGestureEvent to send to Core
101 Integration::PanGestureEvent GeneratePan(
102 Gesture::State state,
103 Vector2 previousPosition,
104 Vector2 currentPosition,
105 unsigned long timeDelta,
106 unsigned int numberOfTouches = 1,
107 unsigned int time = 1u)
109 Integration::PanGestureEvent pan(state);
111 pan.previousPosition = previousPosition;
112 pan.currentPosition = currentPosition;
113 pan.timeDelta = timeDelta;
114 pan.numberOfTouches = numberOfTouches;
119 // Generate a PinchGestureEvent to send to Core
120 Integration::PinchGestureEvent GeneratePinch(
121 Gesture::State state,
126 Integration::PinchGestureEvent pinch(state);
130 pinch.centerPoint = centerpoint;
134 // Generate a TapGestureEvent to send to Core
135 Integration::TapGestureEvent GenerateTap(
136 Gesture::State state,
137 unsigned int numberOfTaps,
138 unsigned int numberOfTouches,
141 Integration::TapGestureEvent tap( state );
143 tap.numberOfTaps = numberOfTaps;
144 tap.numberOfTouches = numberOfTouches;
151 // Create function as Init function called
153 static bool CreateCustomInitCalled = false;
154 BaseHandle CreateCustomInit(void)
156 CreateCustomInitCalled = true;
160 static bool CreateCustomNamedInitCalled = false;
161 BaseHandle CreateCustomNamedInit(void)
163 CreateCustomNamedInitCalled = true;
167 const std::string scriptedName("PopupStyle");
168 static TypeRegistration scriptedType( scriptedName, typeid(Dali::CustomActor), CreateCustomNamedInit );
170 // Property Registration
171 bool setPropertyCalled = false;
172 bool getPropertyCalled = false;
173 void SetProperty( BaseObject* object, Property::Index propertyIndex, const Property::Value& value )
175 setPropertyCalled = true;
177 Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex )
179 getPropertyCalled = true;
180 return Property::Value( true );
185 /*******************************************************************************
189 ******************************************************************************/
192 struct MyTestCustomActor : public CustomActorImpl
194 typedef Signal< void ()> SignalType;
195 typedef Signal< void (float)> SignalTypeFloat;
197 MyTestCustomActor() : CustomActorImpl( ActorFlags( REQUIRES_TOUCH_EVENTS ) )
200 virtual ~MyTestCustomActor()
203 void ResetCallStack()
207 // From CustomActorImpl
208 virtual void OnStageConnection( int depth )
211 virtual void OnStageDisconnection()
214 virtual void OnChildAdd(Actor& child)
217 virtual void OnChildRemove(Actor& child)
220 virtual void OnSizeSet(const Vector3& targetSize)
223 virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize)
226 virtual bool OnTouchEvent(const TouchEvent& event)
230 virtual bool OnHoverEvent(const HoverEvent& event)
234 virtual bool OnWheelEvent(const WheelEvent& event)
238 virtual bool OnKeyEvent(const KeyEvent& event)
242 virtual void OnKeyInputFocusGained()
245 virtual void OnKeyInputFocusLost()
248 virtual Vector3 GetNaturalSize()
250 return Vector3( 0.0f, 0.0f, 0.0f );
253 virtual float GetHeightForWidth( float width )
258 virtual float GetWidthForHeight( float height )
263 virtual void OnRelayout( const Vector2& size, RelayoutContainer& container )
267 virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
271 virtual void OnCalculateRelayoutSize( Dimension::Type dimension )
275 virtual float CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension )
280 virtual void OnLayoutNegotiated( float size, Dimension::Type dimension )
284 virtual bool RelayoutDependentOnChildren( Dimension::Type dimension = Dimension::ALL_DIMENSIONS )
296 class MyTestCustomActor : public CustomActor
300 typedef Signal< void ()> SignalType;
301 typedef Signal< void (float)> SignalTypeFloat;
307 static MyTestCustomActor New()
309 Impl::MyTestCustomActor* p = new Impl::MyTestCustomActor;
310 return MyTestCustomActor( *p ); // takes ownership
313 virtual ~MyTestCustomActor()
317 static MyTestCustomActor DownCast( BaseHandle handle )
319 MyTestCustomActor result;
321 CustomActor custom = Dali::CustomActor::DownCast( handle );
324 CustomActorImpl& customImpl = custom.GetImplementation();
326 Impl::MyTestCustomActor* impl = dynamic_cast<Impl::MyTestCustomActor*>(&customImpl);
330 result = MyTestCustomActor(customImpl.GetOwner());
337 SignalType& GetCustomSignal()
339 Dali::RefObject& obj = GetImplementation();
340 return static_cast<Impl::MyTestCustomActor&>( obj ).mSignal;
345 MyTestCustomActor(Internal::CustomActor* internal)
346 : CustomActor(internal)
350 MyTestCustomActor( Impl::MyTestCustomActor& impl )
351 : CustomActor( impl )
357 class MyTestCustomActor2 : public CustomActor
365 P1=Dali::PROPERTY_REGISTRATION_START_INDEX,
375 static MyTestCustomActor2 New()
377 return MyTestCustomActor2(); // takes ownership
380 virtual ~MyTestCustomActor2()
384 static MyTestCustomActor2 DownCast( BaseHandle handle )
386 MyTestCustomActor2 result;
388 CustomActor custom = Dali::CustomActor::DownCast( handle );
391 CustomActorImpl& customImpl = custom.GetImplementation();
393 Impl::MyTestCustomActor* impl = dynamic_cast<Impl::MyTestCustomActor*>(&customImpl);
397 result = MyTestCustomActor2(customImpl.GetOwner());
406 MyTestCustomActor2(Internal::CustomActor* internal)
407 : CustomActor(internal)
411 MyTestCustomActor2( Impl::MyTestCustomActor& impl )
412 : CustomActor( impl )
417 static TypeRegistration customTypeInit( typeid(MyTestCustomActor2), typeid(Dali::CustomActor), CreateCustomInit, true );
419 PropertyRegistration P1( customTypeInit, "propertyOne", MyTestCustomActor2::Property::P1, Property::INTEGER, &SetProperty, &GetProperty );
420 PropertyRegistration P2( customTypeInit, "propertyTwo", MyTestCustomActor2::Property::P2, Property::STRING, &SetProperty, &GetProperty );
423 class MyTestCustomActor3 : public CustomActor
430 static MyTestCustomActor3 New()
432 return MyTestCustomActor3(); // takes ownership
435 virtual ~MyTestCustomActor3()
439 static MyTestCustomActor3 DownCast( BaseHandle handle )
441 MyTestCustomActor3 result;
443 CustomActor custom = Dali::CustomActor::DownCast( handle );
446 CustomActorImpl& customImpl = custom.GetImplementation();
448 Impl::MyTestCustomActor* impl = dynamic_cast<Impl::MyTestCustomActor*>(&customImpl);
452 result = MyTestCustomActor3(customImpl.GetOwner());
461 MyTestCustomActor3(Internal::CustomActor* internal)
462 : CustomActor(internal)
466 MyTestCustomActor3( Impl::MyTestCustomActor& impl )
467 : CustomActor( impl )
472 static TypeRegistration customTypeBadInit( typeid(MyTestCustomActor3), typeid(Dali::CustomActor), NULL, false );
474 BaseHandle CreateCustom(void)
476 return MyTestCustomActor::New();
479 static std::string lastSignalConnectionCustom;
481 bool DoConnectSignalCustom( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
483 lastSignalConnectionCustom = signalName;
485 bool connected( true );
487 Dali::BaseHandle handle(object);
488 MyTestCustomActor customActor = MyTestCustomActor::DownCast(handle);
490 if( "sig1" == signalName )
492 customActor.GetCustomSignal().Connect( tracker, functor );
496 // signalName does not match any signal
503 bool DoConnectSignalCustomFailure( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
505 lastSignalConnectionCustom = "failed";
507 return false; // This is supposed to fail
510 struct CustomTestFunctor
514 ++mTotalInstanceCount;
515 ++mCurrentInstanceCount;
518 CustomTestFunctor( const CustomTestFunctor& copyMe )
520 ++mTotalInstanceCount;
521 ++mCurrentInstanceCount;
526 --mCurrentInstanceCount;
534 static int mTotalInstanceCount;
535 static int mCurrentInstanceCount;
536 static int mCallbackCount;
539 int CustomTestFunctor::mTotalInstanceCount = 0;
540 int CustomTestFunctor::mCurrentInstanceCount = 0;
541 int CustomTestFunctor::mCallbackCount = 0;
543 static void ResetFunctorCounts()
545 CustomTestFunctor::mTotalInstanceCount = 0;
546 CustomTestFunctor::mCurrentInstanceCount = 0;
547 CustomTestFunctor::mCallbackCount = 0;
550 static std::string lastActionCustom;
551 bool DoActionCustom(BaseObject* object, const std::string& actionName, const Property::Map& /*attributes*/)
553 lastActionCustom = actionName;
557 // Custom type registration
558 static TypeRegistration customType1( typeid(MyTestCustomActor), typeid(Dali::CustomActor), CreateCustom );
561 static SignalConnectorType customSignalConnector1( customType1, "sig1", DoConnectSignalCustom );
562 static SignalConnectorType customSignalConnector2( customType1, "sig2", DoConnectSignalCustomFailure );
563 static const int TEST_SIGNAL_COUNT = 2;
566 static TypeAction customAction1( customType1, "act1", DoActionCustom);
567 static const int TEST_ACTION_COUNT = 1;
569 class TestConnectionTracker : public ConnectionTracker
573 TestConnectionTracker()
578 BaseHandle CreateNamedActorType()
580 Actor actor = Actor::New();
581 actor.SetName( "NamedActor" );
585 TypeRegistration namedActorType( "MyNamedActor", typeid(Dali::Actor), CreateNamedActorType );
586 PropertyRegistration namedActorPropertyOne( namedActorType, "propName", PROPERTY_REGISTRATION_START_INDEX, Property::BOOLEAN, &SetProperty, &GetProperty );
588 } // Anonymous namespace
590 // Note: No negative test case for UtcDaliTypeRegistryGet can be implemented.
591 int UtcDaliTypeRegistryGetP(void)
593 TestApplication application;
595 TypeRegistry registry = TypeRegistry::Get();
596 DALI_TEST_CHECK( registry );
601 // Note: No negative test case for UtcDaliTypeRegistryConstructor can be implemented.
602 int UtcDaliTypeRegistryConstructorP(void)
604 TestApplication application;
606 TypeRegistry registry;
607 DALI_TEST_CHECK( !registry );
611 // Note: No negative test case for UtcDaliTypeRegistryCopyConstructor can be implemented.
612 int UtcDaliTypeRegistryCopyConstructorP(void)
614 TestApplication application;
616 TypeRegistry registry = TypeRegistry::Get();
617 DALI_TEST_CHECK( registry );
619 TypeRegistry copy( registry );
620 DALI_TEST_CHECK( copy );
622 DALI_TEST_CHECK( registry.GetTypeInfo( "Actor" ).GetName() == copy.GetTypeInfo( "Actor" ).GetName() );
627 // Note: No negative test case for UtcDaliTypeRegistryAssignmentOperator can be implemented.
628 int UtcDaliTypeRegistryAssignmentOperatorP(void)
630 TestApplication application;
632 TypeRegistry registry = TypeRegistry::Get();
633 DALI_TEST_CHECK( registry );
635 TypeRegistry copy = registry;
636 DALI_TEST_CHECK( copy );
637 DALI_TEST_CHECK( registry == copy );
639 DALI_TEST_CHECK( registry.GetTypeInfo( "Actor" ).GetName() == copy.GetTypeInfo( "Actor" ).GetName() );
644 int UtcDaliTypeRegistryAssignP(void)
646 TestApplication application;
648 TypeRegistry registry = TypeRegistry::Get();
649 TypeRegistry registry2;
650 registry2 = registry;
651 DALI_TEST_CHECK( registry2 );
653 DALI_TEST_CHECK( registry2.GetTypeInfo( "Actor" ).GetName() == registry2.GetTypeInfo( "Actor" ).GetName() );
658 int UtcDaliTypeRegistryGetTypeInfoFromTypeNameP(void)
660 TestApplication application;
662 TypeRegistry registry = TypeRegistry::Get();
667 type = registry.GetTypeInfo( "CameraActor" );
668 DALI_TEST_CHECK( type );
669 CameraActor ca = CameraActor::DownCast(type.CreateInstance());
670 DALI_TEST_CHECK( ca );
671 Stage::GetCurrent().Add( ca );
672 application.Render();
675 type = registry.GetTypeInfo( "Animation" );
676 DALI_TEST_CHECK( type );
677 Animation an = Animation::DownCast(type.CreateInstance());
678 DALI_TEST_CHECK( an );
680 application.Render();
685 int UtcDaliTypeRegistryGetTypeInfoFromTypeNameN(void)
687 TestApplication application;
689 TypeRegistry registry = TypeRegistry::Get();
693 type = registry.GetTypeInfo( "MyDummyActor" );
694 DALI_TEST_CHECK( !type );
699 int UtcDaliTypeRegistryGetTypeInfoFromTypeIdP(void)
701 TypeInfo named_type = TypeRegistry::Get().GetTypeInfo( "CameraActor" );
702 TypeInfo typeinfo_type = TypeRegistry::Get().GetTypeInfo( typeid(Dali::CameraActor) );
704 DALI_TEST_CHECK( named_type );
705 DALI_TEST_CHECK( typeinfo_type );
707 // Check named and typeid are equivalent
708 DALI_TEST_CHECK( named_type == typeinfo_type );
710 DALI_TEST_CHECK( named_type.GetName() == typeinfo_type.GetName() );
711 DALI_TEST_CHECK( named_type.GetBaseName() == typeinfo_type.GetBaseName() );
716 int UtcDaliTypeRegistryGetTypeInfoFromTypeIdN(void)
718 TestApplication application;
719 TypeRegistry typeRegistry = TypeRegistry::Get();
721 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(Vector2) );
722 DALI_TEST_CHECK( !typeInfo );
727 int UtcDaliTypeRegistryGetTypeNameCountP(void)
729 TestApplication application;
730 TypeRegistry typeRegistry = TypeRegistry::Get();
733 for(size_t i = 0; i < typeRegistry.GetTypeNameCount(); i++)
735 type = typeRegistry.GetTypeInfo( typeRegistry.GetTypeName(i) );
736 DALI_TEST_CHECK( type );
743 int UtcDaliTypeRegistryGetTypeNamesP(void)
745 TestApplication application;
746 TypeRegistry typeRegistry = TypeRegistry::Get();
749 for(size_t i = 0; i < typeRegistry.GetTypeNameCount(); i++)
751 type = typeRegistry.GetTypeInfo( typeRegistry.GetTypeName(i) );
752 DALI_TEST_CHECK( type );
759 // Note: No negative test case for UtcDaliTypeRegistryTypeRegistration can be implemented.
760 int UtcDaliTypeRegistryTypeRegistrationNotCallingCreateOnInitP(void)
762 ResetFunctorCounts();
764 TestApplication application;
766 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
767 DALI_TEST_CHECK( type );
769 TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( "CustomActor" );
770 DALI_TEST_CHECK( baseType );
772 BaseHandle handle = type.CreateInstance();
773 DALI_TEST_CHECK( handle );
775 MyTestCustomActor customHandle = MyTestCustomActor::DownCast( handle );
776 DALI_TEST_CHECK( customHandle );
778 DALI_TEST_EQUALS( type.GetActionCount(), TEST_ACTION_COUNT + baseType.GetActionCount(), TEST_LOCATION );
780 DALI_TEST_EQUALS( type.GetSignalCount(), TEST_SIGNAL_COUNT + baseType.GetSignalCount(), TEST_LOCATION );
783 TestConnectionTracker tracker;
785 bool connected = handle.ConnectSignal( &tracker, "sig1", CustomTestFunctor() );
786 DALI_TEST_EQUALS( connected, true, TEST_LOCATION );
787 DALI_TEST_CHECK( lastSignalConnectionCustom == "sig1" );
788 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
789 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION );
791 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
792 customHandle.GetCustomSignal().Emit();
793 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION );
794 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
795 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION );
797 // tracker should automatically disconnect here
798 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
799 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
801 // Test that functor is disconnected
802 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION );
803 customHandle.GetCustomSignal().Emit();
804 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1/*not incremented*/, TEST_LOCATION );
805 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
806 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
808 Property::Map attributes;
809 handle.DoAction("act1", attributes);
810 DALI_TEST_CHECK( lastActionCustom == "act1" );
814 // Note: No negative test case for UtcDaliTypeRegistryTypeRegistration can be implemented.
815 int UtcDaliTypeRegistryTypeRegistrationCallingCreateOnInitP(void)
817 TestApplication application;
819 DALI_TEST_CHECK( "MyTestCustomActor2" == customTypeInit.RegisteredName() );
821 DALI_TEST_CHECK( true == CreateCustomInitCalled );
822 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor2" );
823 DALI_TEST_CHECK( type );
827 // Note: No negative test case for UtcDaliTypeRegistryTypeRegistration can be implemented.
828 int UtcDaliTypeRegistryTypeRegistrationForNamedTypeP(void)
830 TestApplication application;
832 // Create Named Actor Type
833 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyNamedActor" );
834 DALI_TEST_CHECK( type );
836 BaseHandle namedHandle = type.CreateInstance();
837 DALI_TEST_CHECK( namedHandle );
838 Actor namedActor( Actor::DownCast( namedHandle ) );
839 DALI_TEST_CHECK( namedActor );
841 DALI_TEST_CHECK( namedActor.GetName() == "NamedActor" );
842 DALI_TEST_CHECK( type.GetName() == "MyNamedActor" );
843 DALI_TEST_CHECK( type.GetBaseName() == "Actor" );
848 int UtcDaliTypeRegistryRegisteredNameP(void)
850 TestApplication application;
852 DALI_TEST_CHECK( scriptedName == scriptedType.RegisteredName() );
854 TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( scriptedName );
855 DALI_TEST_CHECK( baseType );
857 BaseHandle handle = baseType.CreateInstance();
859 DALI_TEST_CHECK( true == CreateCustomNamedInitCalled );
860 TypeInfo type = TypeRegistry::Get().GetTypeInfo( scriptedName );
861 DALI_TEST_CHECK( type );
866 int UtcDaliTypeRegistryRegisteredNameN(void)
868 TestApplication application;
870 DALI_TEST_CHECK( scriptedName == scriptedType.RegisteredName() );
872 TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( scriptedName );
873 DALI_TEST_CHECK( baseType );
875 // should cause an assert because we're registering same type twice
876 // once statically at the start of this file, then again now
879 TypeRegistration scriptedType( scriptedName, typeid(Dali::CustomActor), CreateCustomNamedInit );
880 tet_result( TET_FAIL );
882 catch ( DaliException& e )
884 DALI_TEST_ASSERT( e, "Duplicate type name for Type Registation", TEST_LOCATION );
891 int UtcDaliTypeRegistrySignalConnectorTypeP(void)
893 ResetFunctorCounts();
895 TestApplication application;
897 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
898 DALI_TEST_CHECK( type );
900 BaseHandle handle = type.CreateInstance();
901 DALI_TEST_CHECK( handle );
903 MyTestCustomActor customHandle = MyTestCustomActor::DownCast( handle );
904 DALI_TEST_CHECK( customHandle );
907 TestConnectionTracker tracker;
909 bool connected = handle.ConnectSignal( &tracker, "sig1", CustomTestFunctor() );
910 DALI_TEST_EQUALS( connected, true, TEST_LOCATION );
911 DALI_TEST_CHECK( lastSignalConnectionCustom == "sig1" );
912 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
913 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION );
915 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
916 customHandle.GetCustomSignal().Emit();
917 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION );
918 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
919 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION );
921 // tracker should automatically disconnect here
922 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
923 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
925 // Test that functor is disconnected
926 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION );
927 customHandle.GetCustomSignal().Emit();
928 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1/*not incremented*/, TEST_LOCATION );
929 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
930 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
935 int UtcDaliTypeRegistrySignalConnectorTypeN(void)
937 // Test what happens when signal connnector (DoConnectSignalFailure method) returns false
939 ResetFunctorCounts();
941 TestApplication application;
943 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
944 DALI_TEST_CHECK( type );
946 TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( "CustomActor" );
947 DALI_TEST_CHECK( baseType );
949 BaseHandle handle = type.CreateInstance();
950 DALI_TEST_CHECK( handle );
952 MyTestCustomActor customHandle = MyTestCustomActor::DownCast( handle );
953 DALI_TEST_CHECK( customHandle );
955 DALI_TEST_EQUALS( type.GetActionCount(), TEST_ACTION_COUNT + baseType.GetActionCount(), TEST_LOCATION );
957 DALI_TEST_EQUALS( type.GetSignalCount(), TEST_SIGNAL_COUNT + baseType.GetSignalCount(), TEST_LOCATION );
960 TestConnectionTracker tracker;
962 bool connected = handle.ConnectSignal( &tracker, "sig2", CustomTestFunctor() );
963 DALI_TEST_EQUALS( connected, false/*This is supposed to fail*/, TEST_LOCATION );
964 DALI_TEST_CHECK( lastSignalConnectionCustom == "failed" );
965 DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
966 DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0/*deleted along with FunctorDelegate*/, TEST_LOCATION );
969 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
970 customHandle.GetCustomSignal().Emit();
971 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0/*never called*/, TEST_LOCATION );
973 // tracker should have nothing to disconnect here
976 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
977 customHandle.GetCustomSignal().Emit();
978 DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0/*never called*/, TEST_LOCATION );
982 int UtcDaliTypeRegistryTypeActionP(void)
984 ResetFunctorCounts();
986 TestApplication application;
988 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
989 DALI_TEST_CHECK( type );
991 BaseHandle handle = type.CreateInstance();
992 DALI_TEST_CHECK( handle );
994 Property::Map attributes;
995 DALI_TEST_CHECK( handle.DoAction("act1", attributes) );
996 DALI_TEST_CHECK( lastActionCustom == "act1" );
1001 int UtcDaliTypeRegistryTypeActionN(void)
1003 ResetFunctorCounts();
1005 TestApplication application;
1007 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
1008 DALI_TEST_CHECK( type );
1010 BaseHandle handle = type.CreateInstance();
1011 DALI_TEST_CHECK( handle );
1013 Property::Map attributes;
1014 DALI_TEST_CHECK( !handle.DoAction( "unknownAction", attributes ) );
1019 int UtcDaliTypeRegistryPropertyRegistrationP(void)
1021 TestApplication application;
1022 TypeRegistry typeRegistry = TypeRegistry::Get();
1024 // Check property count before property registration
1025 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1026 DALI_TEST_CHECK( typeInfo );
1027 BaseHandle handle = typeInfo.CreateInstance();
1028 DALI_TEST_CHECK( handle );
1029 Actor customActor = Actor::DownCast( handle );
1030 DALI_TEST_CHECK( customActor );
1031 unsigned int initialPropertyCount( customActor.GetPropertyCount() );
1033 std::string propertyName( "prop1" );
1034 int propertyIndex( PROPERTY_REGISTRATION_START_INDEX );
1035 Property::Type propertyType( Property::BOOLEAN );
1036 PropertyRegistration property1( customType1, propertyName, propertyIndex, propertyType, &SetProperty, &GetProperty );
1038 // Check property count after registration
1039 unsigned int postRegistrationPropertyCount( customActor.GetPropertyCount() );
1040 DALI_TEST_EQUALS( initialPropertyCount + 1u, postRegistrationPropertyCount, TEST_LOCATION );
1042 // Add custom property and check property count
1043 customActor.RegisterProperty( "customProp1", true );
1044 unsigned int customPropertyCount( customActor.GetPropertyCount() );
1045 DALI_TEST_EQUALS( postRegistrationPropertyCount + 1u, customPropertyCount, TEST_LOCATION );
1047 // Set the property, ensure SetProperty called
1048 DALI_TEST_CHECK( !setPropertyCalled );
1049 customActor.SetProperty( propertyIndex, false );
1050 DALI_TEST_CHECK( setPropertyCalled );
1052 // Get the property, ensure GetProperty called
1053 DALI_TEST_CHECK( !getPropertyCalled );
1054 (void)customActor.GetProperty< bool >( propertyIndex );
1055 DALI_TEST_CHECK( getPropertyCalled );
1057 // Get the property using DevelHandle::GetCurrentProperty and ensure GetProperty is called
1058 getPropertyCalled = false;
1059 DALI_TEST_CHECK( !getPropertyCalled );
1060 (void)DevelHandle::GetCurrentProperty< bool >( customActor, propertyIndex );
1061 DALI_TEST_CHECK( getPropertyCalled );
1063 // Check the property name
1064 DALI_TEST_EQUALS( customActor.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
1065 DALI_TEST_EQUALS( typeInfo.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
1067 // Check the property index
1068 DALI_TEST_EQUALS( customActor.GetPropertyIndex( propertyName ), propertyIndex, TEST_LOCATION );
1070 // Check the property type
1071 DALI_TEST_EQUALS( customActor.GetPropertyType( propertyIndex ), propertyType, TEST_LOCATION );
1073 // Check property count of type-info is 1
1074 Property::IndexContainer indices;
1075 typeInfo.GetPropertyIndices( indices );
1077 size_t typePropertyCount = typeInfo.GetPropertyCount();
1078 DALI_TEST_EQUALS( indices.Size(), 1u, TEST_LOCATION );
1079 DALI_TEST_EQUALS( indices.Size(), typePropertyCount, TEST_LOCATION );
1081 // Ensure indices returned from actor and customActor differ by two
1082 Actor actor = Actor::New();
1083 actor.GetPropertyIndices( indices );
1084 unsigned int actorIndices = indices.Size();
1085 customActor.GetPropertyIndices( indices );
1086 unsigned int customActorIndices = indices.Size();
1087 DALI_TEST_EQUALS( actorIndices + 2u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1091 int UtcDaliTypeRegistryPropertyRegistrationN(void)
1093 TestApplication application;
1094 TypeRegistry typeRegistry = TypeRegistry::Get();
1096 // Attempt to register a property type out-of-bounds index (less than)
1099 PropertyRegistration property1( customType1, "propName", PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN, &SetProperty, &GetProperty );
1100 tet_result( TET_FAIL );
1102 catch ( DaliException& e )
1104 DALI_TEST_ASSERT( e, "( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1107 // Attempt to register a property type out-of-bounds index (greater than)
1110 PropertyRegistration property1( customType1, "propName", PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN, &SetProperty, &GetProperty );
1111 tet_result( TET_FAIL );
1113 catch ( DaliException& e )
1115 DALI_TEST_ASSERT( e, "( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1121 int UtcDaliTypeRegistryAnimatablePropertyRegistrationP(void)
1123 TestApplication application;
1124 TypeRegistry typeRegistry = TypeRegistry::Get();
1126 // Check property count before property registration
1127 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1128 DALI_TEST_CHECK( typeInfo );
1129 BaseHandle handle = typeInfo.CreateInstance();
1130 DALI_TEST_CHECK( handle );
1131 Actor customActor = Actor::DownCast( handle );
1132 DALI_TEST_CHECK( customActor );
1133 Stage::GetCurrent().Add(customActor);
1135 unsigned int customPropertyCount( customActor.GetPropertyCount() );
1137 // Register animatable property
1138 std::string animatablePropertyName( "animatableProp1" );
1139 int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1140 Property::Type animatablePropertyType( Property::FLOAT );
1141 AnimatablePropertyRegistration animatableProperty( customType1, animatablePropertyName, animatablePropertyIndex, animatablePropertyType );
1143 // Check property count after registration
1144 DALI_TEST_EQUALS( customPropertyCount + 1u, customActor.GetPropertyCount(), TEST_LOCATION );
1146 // Set the animatable property value
1147 customActor.SetProperty( animatablePropertyIndex, 25.0f );
1149 // Render and notify
1150 application.SendNotification();
1151 application.Render();
1153 // Check the animatable property value
1154 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 25.f, TEST_LOCATION );
1156 // Check the animatable property name
1157 DALI_TEST_EQUALS( customActor.GetPropertyName( animatablePropertyIndex ), animatablePropertyName, TEST_LOCATION );
1159 // Check the animatable property index
1160 DALI_TEST_EQUALS( customActor.GetPropertyIndex( animatablePropertyName ), animatablePropertyIndex, TEST_LOCATION );
1162 // Check the animatable property type
1163 DALI_TEST_EQUALS( customActor.GetPropertyType( animatablePropertyIndex ), animatablePropertyType, TEST_LOCATION );
1165 // Check property count of type-info is 1
1166 Property::IndexContainer indices;
1167 typeInfo.GetPropertyIndices( indices );
1168 DALI_TEST_EQUALS( indices.Size(), 1u, TEST_LOCATION );
1170 // Ensure indices returned from actor and customActor differ by one
1171 Actor actor = Actor::New();
1172 actor.GetPropertyIndices( indices );
1173 unsigned int actorIndices = indices.Size();
1174 customActor.GetPropertyIndices( indices );
1175 unsigned int customActorIndices = indices.Size();
1176 DALI_TEST_EQUALS( actorIndices + 1u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1178 // check that the property is animatable
1179 Animation animation = Animation::New(0.2f);
1180 animation.AnimateTo( Property( customActor, animatablePropertyIndex ), 15.f, AlphaFunction::LINEAR );
1183 // Target value should change straight away
1184 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 15.0f, TEST_LOCATION );
1186 // Render and notify, animation play for 0.05 seconds
1187 application.SendNotification();
1188 application.Render(50);
1189 DALI_TEST_EQUALS( 0.25f, animation.GetCurrentProgress(), TEST_LOCATION );
1190 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, animatablePropertyIndex ), 22.5f, TEST_LOCATION );
1192 // Render and notify, animation play for another 0.1 seconds
1193 application.SendNotification();
1194 application.Render(100);
1195 DALI_TEST_EQUALS( 0.75f, animation.GetCurrentProgress(), TEST_LOCATION );
1196 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, animatablePropertyIndex ), 17.5f, TEST_LOCATION );
1201 int UtcDaliTypeRegistryAnimatablePropertyRegistrationN(void)
1203 TestApplication application;
1204 TypeRegistry typeRegistry = TypeRegistry::Get();
1206 // Attempt to register an animatable property type out-of-bounds index (less than)
1209 AnimatablePropertyRegistration property1( customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN );
1210 tet_result( TET_FAIL );
1212 catch ( DaliException& e )
1214 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1217 // Attempt to register an animatable property type out-of-bounds index (greater than)
1220 AnimatablePropertyRegistration property1( customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN );
1221 tet_result( TET_FAIL );
1223 catch ( DaliException& e )
1225 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1231 int UtcDaliTypeRegistryAnimatablePropertyRegistrationWithDefaultP(void)
1233 TestApplication application;
1234 TypeRegistry typeRegistry = TypeRegistry::Get();
1236 // Check property count before property registration
1237 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1238 DALI_TEST_CHECK( typeInfo );
1239 BaseHandle handle = typeInfo.CreateInstance();
1240 DALI_TEST_CHECK( handle );
1241 Actor customActor = Actor::DownCast( handle );
1242 DALI_TEST_CHECK( customActor );
1243 Stage::GetCurrent().Add(customActor);
1245 unsigned int customPropertyCount( customActor.GetPropertyCount() );
1247 // Register animatable property
1248 std::string animatablePropertyName( "animatableProp1" );
1249 int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1250 AnimatablePropertyRegistration animatableProperty1( customType1, animatablePropertyName, animatablePropertyIndex, 10.f );
1252 // Check property count after registration
1253 DALI_TEST_EQUALS( customPropertyCount + 1u, customActor.GetPropertyCount(), TEST_LOCATION );
1255 // Render and notify
1256 application.SendNotification();
1257 application.Render();
1259 // Check the animatable property value
1260 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 10.f, TEST_LOCATION );
1262 // Check the animatable property name
1263 DALI_TEST_EQUALS( customActor.GetPropertyName( animatablePropertyIndex ), animatablePropertyName, TEST_LOCATION );
1265 // Check the animatable property index
1266 DALI_TEST_EQUALS( customActor.GetPropertyIndex( animatablePropertyName ), animatablePropertyIndex, TEST_LOCATION );
1268 // Check the animatable property type
1269 DALI_TEST_EQUALS( customActor.GetPropertyType( animatablePropertyIndex ), Property::FLOAT, TEST_LOCATION );
1271 // Check property count of type-info is 1
1272 Property::IndexContainer indices;
1273 typeInfo.GetPropertyIndices( indices );
1274 DALI_TEST_EQUALS( indices.Size(), 1u, TEST_LOCATION );
1276 // Ensure indices returned from actor and customActor differ by one
1277 Actor actor = Actor::New();
1278 actor.GetPropertyIndices( indices );
1279 unsigned int actorIndices = indices.Size();
1280 customActor.GetPropertyIndices( indices );
1281 unsigned int customActorIndices = indices.Size();
1282 DALI_TEST_EQUALS( actorIndices + 1u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1284 // check that the property is animatable
1285 Animation animation = Animation::New(0.2f);
1286 animation.AnimateTo( Property( customActor, animatablePropertyIndex ), 20.f, AlphaFunction::LINEAR );
1289 // Target value should change straight away
1290 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 20.0f, TEST_LOCATION );
1292 // Render and notify, animation play for 0.05 seconds
1293 application.SendNotification();
1294 application.Render(50);
1295 DALI_TEST_EQUALS( 0.25f, animation.GetCurrentProgress(), TEST_LOCATION );
1296 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, animatablePropertyIndex ), 12.5f, TEST_LOCATION );
1298 // Render and notify, animation play for another 0.1 seconds
1299 application.SendNotification();
1300 application.Render(100);
1301 DALI_TEST_EQUALS( 0.75f, animation.GetCurrentProgress(), TEST_LOCATION );
1302 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, animatablePropertyIndex ), 17.5f, TEST_LOCATION );
1307 int UtcDaliTypeRegistryAnimatablePropertyRegistrationWithDefaultN(void)
1309 TestApplication application;
1310 TypeRegistry typeRegistry = TypeRegistry::Get();
1312 // Attempt to register an animatable property type out-of-bounds index (less than)
1315 AnimatablePropertyRegistration property1( customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX - 1, false );
1316 tet_result( TET_FAIL );
1318 catch ( DaliException& e )
1320 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1323 // Attempt to register an animatable property type out-of-bounds index (greater than)
1326 AnimatablePropertyRegistration property1( customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX + 1, true );
1327 tet_result( TET_FAIL );
1329 catch ( DaliException& e )
1331 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1337 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationP(void)
1339 TestApplication application;
1340 TypeRegistry typeRegistry = TypeRegistry::Get();
1342 // Check property count before property registration
1343 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1344 DALI_TEST_CHECK( typeInfo );
1345 BaseHandle handle = typeInfo.CreateInstance();
1346 DALI_TEST_CHECK( handle );
1347 Actor customActor = Actor::DownCast( handle );
1348 DALI_TEST_CHECK( customActor );
1350 unsigned int customPropertyCount( customActor.GetPropertyCount() );
1352 // Register animatable property
1353 std::string animatablePropertyName( "animatableProp1" );
1354 int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1355 Property::Type animatablePropertyType( Property::VECTOR2 );
1356 AnimatablePropertyRegistration animatableProperty1( customType1, animatablePropertyName, animatablePropertyIndex, animatablePropertyType );
1358 // Check property count after registration
1359 DALI_TEST_EQUALS( customPropertyCount + 1u, customActor.GetPropertyCount(), TEST_LOCATION );
1361 // Set the animatable property value
1362 customActor.SetProperty( animatablePropertyIndex, Vector2(25.0f, 50.0f) );
1364 // Render and notify
1365 application.SendNotification();
1366 application.Render();
1368 // Check the animatable property value
1369 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( animatablePropertyIndex ), Vector2(25.0f, 50.0f), TEST_LOCATION );
1371 // Check the animatable property name
1372 DALI_TEST_EQUALS( customActor.GetPropertyName( animatablePropertyIndex ), animatablePropertyName, TEST_LOCATION );
1374 // Check the animatable property index
1375 DALI_TEST_EQUALS( customActor.GetPropertyIndex( animatablePropertyName ), animatablePropertyIndex, TEST_LOCATION );
1377 // Check the animatable property type
1378 DALI_TEST_EQUALS( customActor.GetPropertyType( animatablePropertyIndex ), animatablePropertyType, TEST_LOCATION );
1380 // Check property count of type-info is 1
1381 Property::IndexContainer indices;
1382 typeInfo.GetPropertyIndices( indices );
1383 DALI_TEST_EQUALS( indices.Size(), 1u, TEST_LOCATION );
1385 // Register animatable property components
1386 std::string animatablePropertyComponentName1( "animatableProp1X" );
1387 int animatablePropertyComponentIndex1( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1 );
1388 AnimatablePropertyComponentRegistration animatablePropertyComponent1( customType1, animatablePropertyComponentName1, animatablePropertyComponentIndex1, animatablePropertyIndex, 0 );
1390 std::string animatablePropertyComponentName2( "animatableProp1Y" );
1391 int animatablePropertyComponentIndex2( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2 );
1392 AnimatablePropertyComponentRegistration animatablePropertyComponent2( customType1, animatablePropertyComponentName2, animatablePropertyComponentIndex2, animatablePropertyIndex, 1 );
1394 // Check property count after registration
1395 DALI_TEST_EQUALS( customPropertyCount + 3u, customActor.GetPropertyCount(), TEST_LOCATION );
1397 // Check the animatable property component value
1398 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, animatablePropertyComponentIndex1 ), 25.0f, TEST_LOCATION );
1399 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, animatablePropertyComponentIndex2 ), 50.0f, TEST_LOCATION );
1401 // Set the animatable property component value
1402 customActor.SetProperty( animatablePropertyComponentIndex1, 150.0f );
1404 // Render and notify
1405 application.SendNotification();
1406 application.Render();
1408 // Check the animatable property value
1409 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector2 >( customActor, animatablePropertyIndex ), Vector2(150.0f, 50.0f), TEST_LOCATION );
1410 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, animatablePropertyComponentIndex1 ), 150.0f, TEST_LOCATION );
1411 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, animatablePropertyComponentIndex2 ), 50.0f, TEST_LOCATION );
1413 // Set the animatable property component value
1414 customActor.SetProperty( animatablePropertyComponentIndex2, 225.0f );
1416 // Render and notify
1417 application.SendNotification();
1418 application.Render();
1420 // Check the animatable property value
1421 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector2 >( customActor, animatablePropertyIndex ), Vector2(150.0f, 225.0f), TEST_LOCATION );
1422 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, animatablePropertyComponentIndex1 ), 150.0f, TEST_LOCATION );
1423 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, animatablePropertyComponentIndex2 ), 225.0f, TEST_LOCATION );
1425 // Ensure indices returned from actor and customActor differ by three
1426 Actor actor = Actor::New();
1427 actor.GetPropertyIndices( indices );
1428 unsigned int actorIndices = indices.Size();
1429 customActor.GetPropertyIndices( indices );
1430 unsigned int customActorIndices = indices.Size();
1431 DALI_TEST_EQUALS( actorIndices + 3u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1436 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationN(void)
1438 TestApplication application;
1439 TypeRegistry typeRegistry = TypeRegistry::Get();
1441 // Register animatable property with the type of Vector2
1442 int animatablePropertyIndex1( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1443 AnimatablePropertyRegistration animatableProperty1( customType1, "animatableProp1", animatablePropertyIndex1, Property::VECTOR2 );
1445 // Attempt to register an animatable property component out-of-bounds index (less than)
1448 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp1X", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX - 1, animatablePropertyIndex1, 0 );
1449 tet_result( TET_FAIL );
1451 catch ( DaliException& e )
1453 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1456 // Attempt to register an animatable property component out-of-bounds index (greater than)
1459 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp1X", ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX + 1, animatablePropertyIndex1, 0 );
1460 tet_result( TET_FAIL );
1462 catch ( DaliException& e )
1464 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1467 // Register an animatable property component
1468 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp1X", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1, animatablePropertyIndex1, 0 );
1470 // Attempt to register another animatable property component with the same component index
1473 AnimatablePropertyComponentRegistration propertyComponent2( customType1, "animatableProp1Y", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2, animatablePropertyIndex1, 0 );
1474 tet_result( TET_FAIL );
1476 catch ( DaliException& e )
1478 DALI_TEST_ASSERT( e, "Property component already registered", TEST_LOCATION );
1481 // Register animatable property with the type of boolean
1482 int animatablePropertyIndex2( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2 );
1483 AnimatablePropertyRegistration animatableProperty2( customType1, "animatableProp2", animatablePropertyIndex2, Property::BOOLEAN );
1485 // Attempt to register an animatable property component for the above property with boolean type
1488 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp2X", animatablePropertyIndex2 + 1, animatablePropertyIndex2, 0 );
1489 tet_result( TET_FAIL );
1491 catch ( DaliException& e )
1493 DALI_TEST_ASSERT( e, "Base property does not support component", TEST_LOCATION );
1499 int UtcDaliTypeRegistryChildPropertyRegistrationP(void)
1501 TestApplication application;
1502 TypeRegistry typeRegistry = TypeRegistry::Get();
1504 // Check property count before property registration
1505 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1506 DALI_TEST_CHECK( typeInfo );
1507 BaseHandle handle = typeInfo.CreateInstance();
1508 DALI_TEST_CHECK( handle );
1509 Actor customActor = Actor::DownCast( handle );
1510 DALI_TEST_CHECK( customActor );
1511 unsigned int initialPropertyCount( customActor.GetPropertyCount() );
1513 // Register child properties to the parent
1514 std::string propertyName( "childProp1" );
1515 int propertyIndex( CHILD_PROPERTY_REGISTRATION_START_INDEX );
1516 Property::Type propertyType( Property::BOOLEAN );
1517 ChildPropertyRegistration childProperty1( customType1, propertyName, propertyIndex, propertyType );
1519 std::string propertyName2( "childProp2" );
1520 int propertyIndex2( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1 );
1521 Property::Type propertyType2( Property::INTEGER );
1522 ChildPropertyRegistration childProperty2( customType1, propertyName2, propertyIndex2, propertyType2 );
1524 std::string propertyName3( "childProp3" );
1525 int propertyIndex3( CHILD_PROPERTY_REGISTRATION_START_INDEX + 2 );
1526 Property::Type propertyType3( Property::FLOAT );
1527 ChildPropertyRegistration childProperty3( customType1, propertyName3, propertyIndex3, propertyType3 );
1529 std::string propertyName4( "childProp4" );
1530 int propertyIndex4( CHILD_PROPERTY_REGISTRATION_START_INDEX + 3 );
1531 Property::Type propertyType4( Property::INTEGER );
1532 ChildPropertyRegistration childProperty4( customType1, propertyName4, propertyIndex4, propertyType4 );
1534 // Check property count are not changed because the child properties will not be created for the parent
1535 DALI_TEST_EQUALS( initialPropertyCount, customActor.GetPropertyCount(), TEST_LOCATION );
1537 // check the child property type
1538 Internal::TypeInfo& typeInfoImpl = GetImplementation( typeInfo );
1539 Property::Type type = typeInfoImpl.GetChildPropertyType( typeInfoImpl.GetChildPropertyIndex("childProp4") );
1540 DALI_TEST_EQUALS( type, Property::INTEGER, TEST_LOCATION );
1543 // Create a child actor
1544 Actor childActor = Actor::New();
1545 DALI_TEST_CHECK( childActor );
1546 unsigned int initialChildActorPropertyCount( childActor.GetPropertyCount() );
1548 // The type of child properties should be Property::None as the child hasn't registered any child property yet.
1549 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex ), Property::NONE, TEST_LOCATION );
1550 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex2 ), Property::NONE, TEST_LOCATION );
1551 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex3 ), Property::NONE, TEST_LOCATION );
1552 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex4 ), Property::NONE, TEST_LOCATION );
1554 // Set the value for the first child property when the child actor doesn't have a parent yet
1555 childActor.SetProperty(propertyIndex, true);
1557 // Check that the first child property is dynamically created
1558 DALI_TEST_EQUALS( initialChildActorPropertyCount + 1u, childActor.GetPropertyCount(), TEST_LOCATION );
1560 // Check the first child property value
1561 DALI_TEST_EQUALS( childActor.GetProperty< bool >( propertyIndex ), true, TEST_LOCATION );
1563 // Check the first child property type
1564 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex ), propertyType, TEST_LOCATION );
1566 // Check that the first child property have no name, as it doesn't have a parent yet.
1567 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex ), "", TEST_LOCATION );
1569 // Check that the first property can't be accessed through its name, as it doesn't have a parent yet.
1570 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName ), Property::INVALID_INDEX, TEST_LOCATION );
1572 // Create a custom property for the child with the same name as the second child property registered to the parent
1573 Property::Index customPropertyIndex = childActor.RegisterProperty(propertyName2, 100, Property::READ_WRITE);
1575 // Check that the custom property is created
1576 DALI_TEST_EQUALS( initialChildActorPropertyCount + 2u, childActor.GetPropertyCount(), TEST_LOCATION );
1578 // Check the property value
1579 DALI_TEST_EQUALS( childActor.GetProperty< int >( customPropertyIndex ), 100, TEST_LOCATION );
1581 // Check the property index
1582 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName2 ), customPropertyIndex, TEST_LOCATION );
1584 // Check the property type
1585 DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex ), propertyType2, TEST_LOCATION );
1587 // Check the property name
1588 DALI_TEST_EQUALS( childActor.GetPropertyName( customPropertyIndex ), propertyName2, TEST_LOCATION );
1590 // Now add the child actor to the parent
1591 customActor.Add( childActor );
1593 // Check that the first child property now has the correct name as previously registered to the parent
1594 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
1596 // Check that the child property index for the first child property can now be retrieved through its child property name
1597 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName ), propertyIndex, TEST_LOCATION );
1599 // Check that the second child property now has the correct index as previously registered to the parent
1600 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex2 ), propertyName2, TEST_LOCATION );
1602 // Check that the second child property can be accessed through both its custom property index and its child property index
1603 DALI_TEST_EQUALS( childActor.GetProperty< int >( customPropertyIndex ), 100, TEST_LOCATION );
1604 DALI_TEST_EQUALS( childActor.GetProperty< int >( propertyIndex2 ), 100, TEST_LOCATION );
1605 DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex ), propertyType2, TEST_LOCATION );
1606 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex2 ), propertyType2, TEST_LOCATION );
1608 // Check that the child property index for the second child property can now be retrieved through its child property name
1609 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName2 ), propertyIndex2, TEST_LOCATION );
1611 // Set the value for the third child property when the child actor is already added to the parent
1612 childActor.SetProperty(propertyIndex3, 0.15f);
1614 // Check that the third child property is dynamically created
1615 DALI_TEST_EQUALS( initialChildActorPropertyCount + 3u, childActor.GetPropertyCount(), TEST_LOCATION );
1617 // Check the third child property value
1618 DALI_TEST_EQUALS( childActor.GetProperty< float >( propertyIndex3 ), 0.15f, TEST_LOCATION );
1620 // Check the third child property type
1621 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex3 ), propertyType3, TEST_LOCATION );
1623 // Check the third child property name
1624 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex3 ), propertyName3, TEST_LOCATION );
1626 // Check the third child property index.
1627 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName3 ), propertyIndex3, TEST_LOCATION );
1629 // Create a custom property for the child with the same name as the fourth child property registered to the parent
1630 Property::Index customPropertyIndex2 = childActor.RegisterProperty(propertyName4, 20, Property::READ_WRITE);
1632 // Check that the custom property is created
1633 DALI_TEST_EQUALS( initialChildActorPropertyCount + 4u, childActor.GetPropertyCount(), TEST_LOCATION );
1635 // Check the fourth child property value
1636 DALI_TEST_EQUALS( childActor.GetProperty< int >( propertyIndex4 ), 20, TEST_LOCATION );
1637 DALI_TEST_EQUALS( childActor.GetProperty< int >( customPropertyIndex2 ), 20, TEST_LOCATION );
1639 // Check the fourth child property type
1640 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex4 ), propertyType4, TEST_LOCATION );
1641 DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex2 ), propertyType4, TEST_LOCATION );
1643 // Check the fourth child property name
1644 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex4 ), propertyName4, TEST_LOCATION );
1645 DALI_TEST_EQUALS( childActor.GetPropertyName( customPropertyIndex2 ), propertyName4, TEST_LOCATION );
1647 // Check the fourth child property index.
1648 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName4 ), propertyIndex4, TEST_LOCATION );
1650 // Now create another parent actor with different child properties registered
1651 TypeInfo typeInfo2 = typeRegistry.GetTypeInfo( "MyNamedActor" );
1652 DALI_TEST_CHECK( typeInfo2 );
1653 BaseHandle handle2 = typeInfo2.CreateInstance();
1654 DALI_TEST_CHECK( handle2 );
1655 Actor customActor2 = Actor::DownCast( handle2 );
1656 DALI_TEST_CHECK( customActor2 );
1658 // Register child properties to the new parent
1659 std::string newPropertyName( "newChildProp" );
1660 int newPropertyIndex( CHILD_PROPERTY_REGISTRATION_START_INDEX ); // The same index as the first child property "childProp1" in the old parent
1661 Property::Type newPropertyType( Property::VECTOR2 );
1662 ChildPropertyRegistration newChildProperty( namedActorType, newPropertyName, newPropertyIndex, newPropertyType );
1664 std::string newPropertyName2( "childProp3" ); // The same name as the third child property in the old parent
1665 int newPropertyIndex2( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1 ); // The same index as the second child property "childProp2" in the old parent
1666 Property::Type newPropertyType2( Property::FLOAT ); // The same type as the third child property in the old parent
1667 ChildPropertyRegistration newChildProperty2( namedActorType, newPropertyName2, newPropertyIndex2, newPropertyType2 );
1669 // Now move the child actor to the new parent
1670 customActor2.Add( childActor );
1672 // "childProp1" is not a valid child property supported by the new parent, so nothing changed
1673 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex ), propertyType, TEST_LOCATION );
1674 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
1675 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName ), propertyIndex, TEST_LOCATION );
1677 // "childProp3" is a valid child property supported by the new parent
1678 // So it should get its new child property index and should just work
1679 DALI_TEST_EQUALS( childActor.GetPropertyType( newPropertyIndex2 ), newPropertyType2, TEST_LOCATION );
1680 DALI_TEST_EQUALS( childActor.GetPropertyName( newPropertyIndex2 ), newPropertyName2, TEST_LOCATION );
1681 DALI_TEST_EQUALS( childActor.GetPropertyIndex( newPropertyName2 ), newPropertyIndex2, TEST_LOCATION );
1682 DALI_TEST_EQUALS( childActor.GetProperty< float >( newPropertyIndex2 ), 0.15f, TEST_LOCATION );
1684 // Now register a custom property called "newChildProp"
1685 Property::Index customPropertyIndex3 = childActor.RegisterProperty("newChildProp", Vector2( 10.0f, 10.0f ), Property::READ_WRITE);
1687 // Check that the custom property is created
1688 DALI_TEST_EQUALS( initialChildActorPropertyCount + 5u, childActor.GetPropertyCount(), TEST_LOCATION );
1690 // This is a valid child property registered to the new parent
1691 // So should be able to access it through both its custom property index and its registered child property index
1692 DALI_TEST_EQUALS( childActor.GetPropertyType( newPropertyIndex ), newPropertyType, TEST_LOCATION );
1693 DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex3 ), newPropertyType, TEST_LOCATION );
1694 DALI_TEST_EQUALS( childActor.GetPropertyName( newPropertyIndex ), newPropertyName, TEST_LOCATION ); // This should return the new name, although the child property index remains the same
1695 DALI_TEST_EQUALS( childActor.GetPropertyName( customPropertyIndex3 ), newPropertyName, TEST_LOCATION );
1696 DALI_TEST_EQUALS( childActor.GetProperty< Vector2 >( newPropertyIndex ), Vector2( 10.0f, 10.0f ), TEST_LOCATION );
1697 DALI_TEST_EQUALS( childActor.GetProperty< Vector2 >( customPropertyIndex3 ), Vector2( 10.0f, 10.0f ), TEST_LOCATION );
1699 // Should return the child property index by given its name
1700 DALI_TEST_EQUALS( childActor.GetPropertyIndex( newPropertyName ), newPropertyIndex, TEST_LOCATION );
1706 int UtcDaliTypeRegistryChildPropertyRegistrationN(void)
1708 TestApplication application;
1709 TypeRegistry typeRegistry = TypeRegistry::Get();
1711 // Attempt to register a child property type out-of-bounds index (less than)
1714 ChildPropertyRegistration property1( customType1, "propName", CHILD_PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN );
1715 tet_result( TET_FAIL );
1717 catch ( DaliException& e )
1719 DALI_TEST_ASSERT( e, "( index >= CHILD_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1722 // Attempt to register a child property type out-of-bounds index (greater than)
1725 ChildPropertyRegistration property1( customType1, "propName", CHILD_PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN );
1726 tet_result( TET_FAIL );
1728 catch ( DaliException& e )
1730 DALI_TEST_ASSERT( e, "( index >= CHILD_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1737 /*******************************************************************************
1739 * Action through the base handle
1741 ******************************************************************************/
1742 int UtcDaliTypeRegistryActionViaBaseHandle(void)
1744 TestApplication application;
1748 type = TypeRegistry::Get().GetTypeInfo( "Actor" );
1749 DALI_TEST_CHECK( type );
1751 BaseHandle hdl = type.CreateInstance();
1752 DALI_TEST_CHECK( hdl );
1754 Actor a = Actor::DownCast(hdl);
1755 DALI_TEST_CHECK( a );
1757 a.SetVisible(false);
1759 application.SendNotification();
1760 application.Render(0);
1761 DALI_TEST_CHECK(!a.IsVisible());
1763 Property::Map attributes;
1765 DALI_TEST_CHECK(hdl.DoAction("show", attributes));
1767 application.SendNotification();
1768 application.Render(0);
1769 DALI_TEST_CHECK(a.IsVisible());
1771 DALI_TEST_CHECK(!hdl.DoAction("unknownAction", attributes));
1775 int UtcDaliPropertyRegistrationFunctions(void)
1777 TestApplication application;
1778 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 10;
1780 // Attempt to register a property without a setter
1783 PropertyRegistration property1( customType1, "propName", propertyIndex++, Property::BOOLEAN, NULL, &GetProperty );
1784 tet_result( TET_PASS );
1786 catch ( DaliException& e )
1788 tet_result( TET_FAIL );
1791 // Attempt to register a property without a getter
1794 PropertyRegistration property1( customType1, "propName", propertyIndex++, Property::BOOLEAN, NULL, NULL );
1795 tet_result( TET_FAIL );
1797 catch ( DaliException& e )
1799 DALI_TEST_ASSERT( e, "! \"GetProperty", TEST_LOCATION );
1804 int UtcDaliPropertyRegistrationAddSameIndex(void)
1806 TestApplication application;
1807 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 100;
1809 // Add one property with a valid property index
1810 PropertyRegistration property1( customType1, "propName", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
1812 // Attempt to add another property with the same index
1815 PropertyRegistration property2( customType1, "propName2", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
1817 catch ( DaliException& e )
1819 DALI_TEST_ASSERT( e, "! \"Property index already added", TEST_LOCATION );
1822 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 100;
1824 // Add one property with a valid property index
1825 AnimatablePropertyRegistration property3( customType1, "animPropName", animatablePropertyIndex, Property::BOOLEAN );
1827 // Attempt to add another property with the same index
1830 AnimatablePropertyRegistration property4( customType1, "animPropName2", animatablePropertyIndex, Property::BOOLEAN );
1832 catch ( DaliException& e )
1834 DALI_TEST_ASSERT( e, "! \"Property index already added", TEST_LOCATION );
1839 int UtcDaliPropertyRegistrationPropertyWritableP(void)
1841 TestApplication application;
1842 int propertyIndex1 = PROPERTY_REGISTRATION_START_INDEX + 200;
1843 int propertyIndex2 = PROPERTY_REGISTRATION_START_INDEX + 201;
1845 // Add two properties, one with SetProperty, one without
1846 PropertyRegistration property1( customType1, "propNameReadwrite", propertyIndex1, Property::BOOLEAN, &SetProperty, &GetProperty );
1847 PropertyRegistration property2( customType1, "propNameReadonly", propertyIndex2, Property::BOOLEAN, NULL, &GetProperty );
1849 // Create custom-actor
1850 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
1851 DALI_TEST_CHECK( typeInfo );
1852 BaseHandle handle = typeInfo.CreateInstance();
1853 DALI_TEST_CHECK( handle );
1854 Actor customActor = Actor::DownCast( handle );
1855 DALI_TEST_CHECK( customActor );
1857 // Check whether properties are writable
1858 DALI_TEST_CHECK( customActor.IsPropertyWritable( propertyIndex1 ) );
1859 DALI_TEST_CHECK( ! customActor.IsPropertyWritable( propertyIndex2 ) );
1862 // Check the property is writable in the type registry
1863 Internal::TypeInfo& typeInfoImpl = GetImplementation( typeInfo );
1865 DALI_TEST_EQUALS( typeInfoImpl.IsPropertyWritable( propertyIndex1 ), true, TEST_LOCATION );
1870 int UtcDaliPropertyRegistrationPropertyWritableN(void)
1872 // Currently Actors don't register properties with the type registry
1874 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
1875 Internal::TypeInfo& typeInfoImpl = GetImplementation( typeInfo );
1879 typeInfoImpl.IsPropertyWritable( Actor::Property::COLOR);
1880 tet_result( TET_FAIL );
1883 catch ( DaliException& e )
1885 DALI_TEST_ASSERT( e, "Cannot find property index", TEST_LOCATION );
1890 int UtcDaliPropertyRegistrationPropertyAnimatable(void)
1892 TestApplication application;
1893 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 400;
1894 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 400;
1896 // These properties are not animatable
1897 PropertyRegistration property1( customType1, "propName", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
1899 // These properties are animatable
1900 AnimatablePropertyRegistration property2( customType1, "animPropName", animatablePropertyIndex, Property::BOOLEAN );
1902 // Create custom-actor
1903 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
1904 DALI_TEST_CHECK( typeInfo );
1905 BaseHandle handle = typeInfo.CreateInstance();
1906 DALI_TEST_CHECK( handle );
1907 Actor customActor = Actor::DownCast( handle );
1908 DALI_TEST_CHECK( customActor );
1910 // Check if animatable
1911 DALI_TEST_CHECK( ! customActor.IsPropertyAnimatable( propertyIndex ) );
1912 DALI_TEST_CHECK( customActor.IsPropertyAnimatable( animatablePropertyIndex ) );
1914 // Create another instance of custom-actor
1915 BaseHandle handle2 = typeInfo.CreateInstance();
1916 DALI_TEST_CHECK( handle2 );
1917 Actor customActor2 = Actor::DownCast( handle2 );
1918 DALI_TEST_CHECK( customActor2 );
1920 // Check if animatable
1921 DALI_TEST_CHECK( ! customActor2.IsPropertyAnimatable( propertyIndex ) );
1922 DALI_TEST_CHECK( customActor2.IsPropertyAnimatable( animatablePropertyIndex ) );
1926 int UtcDaliPropertyRegistrationInvalidGetAndSet(void)
1928 TestApplication application;
1929 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 2000;
1930 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2000;
1932 // Create custom-actor
1933 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
1934 DALI_TEST_CHECK( typeInfo );
1935 BaseHandle handle = typeInfo.CreateInstance();
1936 DALI_TEST_CHECK( handle );
1937 Actor customActor = Actor::DownCast( handle );
1938 DALI_TEST_CHECK( customActor );
1940 // Try to set an index that hasn't been added
1943 customActor.SetProperty( propertyIndex, true );
1944 tet_result( TET_FAIL );
1946 catch ( DaliException& e )
1948 DALI_TEST_ASSERT( e, "! \"Cannot find property index", TEST_LOCATION );
1953 customActor.SetProperty( animatablePropertyIndex, true );
1954 tet_result( TET_FAIL );
1956 catch ( DaliException& e )
1958 DALI_TEST_ASSERT( e, "! \"Cannot find property index", TEST_LOCATION );
1961 // Try to get an index that hasn't been added
1964 (void) customActor.GetProperty< bool >( propertyIndex );
1965 tet_result( TET_FAIL );
1967 catch ( DaliException& e )
1969 DALI_TEST_ASSERT( e, "! \"Cannot find property index", TEST_LOCATION );
1974 (void) customActor.GetProperty< bool >( animatablePropertyIndex );
1975 tet_result( TET_FAIL );
1977 catch ( DaliException& e )
1979 DALI_TEST_ASSERT( e, "! \"Cannot find property index", TEST_LOCATION );
1985 int UtcDaliLongPressGestureDetectorTypeRegistry(void)
1987 TestApplication application;
1989 Actor actor = Actor::New();
1990 actor.SetSize(100.0f, 100.0f);
1991 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1992 Stage::GetCurrent().Add(actor);
1996 type = TypeRegistry::Get().GetTypeInfo( "LongPressGestureDetector" );
1997 DALI_TEST_CHECK( type );
1998 BaseHandle handle = type.CreateInstance();
1999 DALI_TEST_CHECK( handle );
2000 LongPressGestureDetector detector = LongPressGestureDetector::DownCast( handle );
2001 DALI_TEST_CHECK( detector );
2003 // Attach actor to detector
2005 GestureReceivedFunctor functor( data );
2006 detector.Attach(actor);
2008 // Connect to signal through type
2009 handle.ConnectSignal( &application, "longPressDetected", functor );
2011 // Render and notify
2012 application.SendNotification();
2013 application.Render();
2016 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f)));
2017 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f)));
2018 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f)));
2019 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2023 int UtcDaliPanGestureDetectorTypeRegistry(void)
2025 TestApplication application;
2027 Actor actor = Actor::New();
2028 actor.SetSize(100.0f, 100.0f);
2029 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2030 Stage::GetCurrent().Add(actor);
2034 type = TypeRegistry::Get().GetTypeInfo( "PanGestureDetector" );
2035 DALI_TEST_CHECK( type );
2036 BaseHandle handle = type.CreateInstance();
2037 DALI_TEST_CHECK( handle );
2038 PanGestureDetector detector = PanGestureDetector::DownCast( handle );
2039 DALI_TEST_CHECK( detector );
2041 // Attach actor to detector
2043 GestureReceivedFunctor functor( data );
2044 detector.Attach(actor);
2046 // Connect to signal through type
2047 handle.ConnectSignal( &application, "panDetected", functor );
2049 // Render and notify
2050 application.SendNotification();
2051 application.Render();
2054 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
2055 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
2056 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
2057 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2061 int UtcDaliPinchGestureDetectorTypeRegistry(void)
2063 TestApplication application;
2065 Actor actor = Actor::New();
2066 actor.SetSize(100.0f, 100.0f);
2067 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2068 Stage::GetCurrent().Add(actor);
2072 type = TypeRegistry::Get().GetTypeInfo( "PinchGestureDetector" );
2073 DALI_TEST_CHECK( type );
2074 BaseHandle handle = type.CreateInstance();
2075 DALI_TEST_CHECK( handle );
2076 PinchGestureDetector detector = PinchGestureDetector::DownCast( handle );
2077 DALI_TEST_CHECK( detector );
2079 // Attach actor to detector
2081 GestureReceivedFunctor functor( data );
2082 detector.Attach(actor);
2084 // Connect to signal through type
2085 handle.ConnectSignal( &application, "pinchDetected", functor );
2087 // Render and notify
2088 application.SendNotification();
2089 application.Render();
2092 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
2093 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2097 int UtcDaliTapGestureDetectorTypeRegistry(void)
2099 TestApplication application;
2101 Actor actor = Actor::New();
2102 actor.SetSize(100.0f, 100.0f);
2103 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2104 Stage::GetCurrent().Add(actor);
2108 type = TypeRegistry::Get().GetTypeInfo( "TapGestureDetector" );
2109 DALI_TEST_CHECK( type );
2110 BaseHandle handle = type.CreateInstance();
2111 DALI_TEST_CHECK( handle );
2112 TapGestureDetector detector = TapGestureDetector::DownCast( handle );
2113 DALI_TEST_CHECK( detector );
2115 // Attach actor to detector
2117 GestureReceivedFunctor functor( data );
2118 detector.Attach(actor);
2120 // Connect to signal through type
2121 handle.ConnectSignal( &application, "tapDetected", functor );
2123 // Render and notify
2124 application.SendNotification();
2125 application.Render();
2128 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
2129 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
2130 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2134 int UtcDaliTypeRegistryNamedType(void)
2136 TestApplication application;
2137 TypeRegistry typeRegistry = TypeRegistry::Get();
2139 // Create a normal actor
2140 BaseHandle actorHandle = typeRegistry.GetTypeInfo( "Actor" ).CreateInstance();
2141 DALI_TEST_CHECK( actorHandle );
2142 Actor actor( Actor::DownCast( actorHandle ) );
2143 DALI_TEST_CHECK( actor );
2144 unsigned int actorPropertyCount( actor.GetPropertyCount() );
2146 // Create Named Actor Type
2147 BaseHandle namedHandle = typeRegistry.GetTypeInfo( "MyNamedActor" ).CreateInstance();
2148 DALI_TEST_CHECK( namedHandle );
2149 Actor namedActor( Actor::DownCast( namedHandle ) );
2150 DALI_TEST_CHECK( namedActor );
2151 unsigned int namedActorPropertyCount( namedActor.GetPropertyCount() );
2153 DALI_TEST_CHECK( namedActorPropertyCount > actorPropertyCount );
2157 int UtcDaliTypeInfoGetActionNameP(void)
2159 TestApplication application;
2160 TypeRegistry typeRegistry = TypeRegistry::Get();
2162 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2163 DALI_TEST_CHECK( typeInfo );
2165 DALI_TEST_CHECK( 0 != typeInfo.GetActionCount() );
2167 std::string name = typeInfo.GetActionName(0);
2169 DALI_TEST_EQUALS( name, "show", TEST_LOCATION );
2172 TypeInfo typeInfo2 = typeRegistry.GetTypeInfo( "MyTestCustomActor" );
2174 // search for show action in base class, given a derived class
2175 bool foundChildAction = false;
2176 for( std::size_t i = 0; i < typeInfo2.GetActionCount(); i++ )
2179 std::string name = typeInfo2.GetActionName( i );
2182 foundChildAction = true;
2187 DALI_TEST_EQUALS( foundChildAction, true, TEST_LOCATION );
2193 int UtcDaliTypeInfoGetActionNameN(void)
2195 TestApplication application;
2196 TypeRegistry typeRegistry = TypeRegistry::Get();
2198 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2199 DALI_TEST_CHECK( typeInfo );
2201 DALI_TEST_CHECK( 0 != typeInfo.GetActionCount() );
2203 std::string name = typeInfo.GetActionName(std::numeric_limits<size_t>::max());
2205 DALI_TEST_EQUALS( 0u, name.size(), TEST_LOCATION );
2210 int UtcDaliTypeInfoGetSignalNameP(void)
2212 TestApplication application;
2213 TypeRegistry typeRegistry = TypeRegistry::Get();
2215 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2216 DALI_TEST_CHECK( typeInfo );
2218 DALI_TEST_CHECK( 0 != typeInfo.GetSignalCount() );
2220 std::string name = typeInfo.GetSignalName(0);
2222 DALI_TEST_EQUALS( name, "touched", TEST_LOCATION );
2224 TypeInfo typeInfo2 = typeRegistry.GetTypeInfo( "MyTestCustomActor" );
2226 // search for signal in base class, given a derived class
2227 bool foundSignal = false;
2228 for( std::size_t i = 0; i < typeInfo2.GetSignalCount(); i++ )
2231 std::string name = typeInfo2.GetSignalName( i );
2232 if( name == "touched")
2239 DALI_TEST_EQUALS( foundSignal, true, TEST_LOCATION );
2244 int UtcDaliTypeInfoGetSignalNameN(void)
2246 TestApplication application;
2247 TypeRegistry typeRegistry = TypeRegistry::Get();
2249 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2250 DALI_TEST_CHECK( typeInfo );
2252 DALI_TEST_CHECK( 0 != typeInfo.GetSignalCount() );
2254 std::string name = typeInfo.GetSignalName(std::numeric_limits<size_t>::max());
2256 DALI_TEST_EQUALS( 0u, name.size(), TEST_LOCATION );
2262 int UtcDaliTypeInfoGetCreatorP(void)
2264 TestApplication application;
2265 TypeRegistry typeRegistry = TypeRegistry::Get();
2267 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2268 DALI_TEST_CHECK( typeInfo );
2270 TypeInfo::CreateFunction createFn = typeInfo.GetCreator();
2271 DALI_TEST_EQUALS( createFn != NULL, true, TEST_LOCATION );
2275 BaseHandle handle = createFn();
2276 DALI_TEST_EQUALS( (bool)handle, true, TEST_LOCATION );
2282 int UtcDaliTypeInfoGetCreatorN(void)
2284 TestApplication application;
2285 TypeRegistry typeRegistry = TypeRegistry::Get();
2287 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "MyTestCustomActor3" );
2288 DALI_TEST_CHECK( typeInfo );
2290 TypeInfo::CreateFunction createFn = typeInfo.GetCreator();
2291 DALI_TEST_EQUALS( createFn == NULL, true, TEST_LOCATION );
2296 int UtcDaliTypeInfoGetPropertyCountP1(void)
2298 TestApplication application;
2299 TypeRegistry typeRegistry = TypeRegistry::Get();
2301 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2302 DALI_TEST_CHECK( typeInfo );
2303 size_t actorPropertyCount = typeInfo.GetPropertyCount();
2305 DALI_TEST_EQUALS( actorPropertyCount == 0 , true, TEST_LOCATION ); // No event only props
2309 int UtcDaliTypeInfoGetPropertyCountP2(void)
2311 TestApplication application;
2312 TypeRegistry typeRegistry = TypeRegistry::Get();
2314 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "MyTestCustomActor2" );
2315 DALI_TEST_CHECK( typeInfo );
2316 size_t propertyCount = typeInfo.GetPropertyCount();
2317 Property::IndexContainer indices;
2318 typeInfo.GetPropertyIndices( indices );
2320 DALI_TEST_EQUALS( propertyCount > 0 && propertyCount <= indices.Size(), true, TEST_LOCATION );
2321 DALI_TEST_EQUALS( propertyCount == 2, true, TEST_LOCATION );
2326 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGet01(void)
2328 TestApplication application;
2329 TypeRegistry typeRegistry = TypeRegistry::Get();
2331 tet_infoline( "Register a type registered animatable property and ensure set/get behaviour works synchronously" );
2333 // Register animatable property
2334 const int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
2335 AnimatablePropertyRegistration animatableProperty( customType1, "animatableProp1", animatablePropertyIndex, Property::FLOAT );
2337 // Check property count before property registration
2338 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2339 DALI_TEST_CHECK( typeInfo );
2340 BaseHandle handle = typeInfo.CreateInstance();
2341 DALI_TEST_CHECK( handle );
2342 Actor customActor = Actor::DownCast( handle );
2343 DALI_TEST_CHECK( customActor );
2344 Stage::GetCurrent().Add(customActor);
2346 tet_infoline( "Set the value and ensure it changes straight away" );
2347 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 0.0f, TEST_LOCATION );
2348 customActor.SetProperty( animatablePropertyIndex, 25.0f );
2349 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 25.0f, TEST_LOCATION );
2351 tet_infoline( "Check latest scene-graph value is unchanged" );
2352 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, animatablePropertyIndex ), 0.0f, TEST_LOCATION );
2354 // Render and notify
2355 application.SendNotification();
2356 application.Render();
2358 tet_infoline( "Check values after rendering and both retrieval methods should return the latest" );
2360 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 25.0f, TEST_LOCATION );
2361 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, animatablePropertyIndex ), 25.0f, TEST_LOCATION );
2366 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGetWithComponentsVector2(void)
2368 TestApplication application;
2369 TypeRegistry typeRegistry = TypeRegistry::Get();
2371 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" );
2373 // Register the animatable propeties
2374 const int basePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
2375 const int componentZeroPropertyIndex( basePropertyIndex + 1 );
2376 const int componentOnePropertyIndex( componentZeroPropertyIndex + 1 );
2377 AnimatablePropertyRegistration baseAnimatableProperty( customType1, "baseProp", basePropertyIndex, Vector2( 13.0f, 24.0f ) );
2378 AnimatablePropertyComponentRegistration componentZeroAnimatableProperty( customType1, "componentZeroProp", componentZeroPropertyIndex, basePropertyIndex, 0 );
2379 AnimatablePropertyComponentRegistration componentOneAnimatableProperty( customType1, "componentOneProp", componentOnePropertyIndex, basePropertyIndex, 1 );
2381 // Check property count before property registration
2382 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2383 DALI_TEST_CHECK( typeInfo );
2384 BaseHandle handle = typeInfo.CreateInstance();
2385 DALI_TEST_CHECK( handle );
2386 Actor customActor = Actor::DownCast( handle );
2387 DALI_TEST_CHECK( customActor );
2388 Stage::GetCurrent().Add(customActor);
2390 tet_infoline( "Get the component values, they should be the default value of the base-property" );
2391 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2392 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2393 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 13.0f, 24.0f ), TEST_LOCATION );
2395 tet_infoline( "Set a component value and ensure it changes for the base property as well" );
2396 customActor.SetProperty( componentZeroPropertyIndex, 125.0f );
2397 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2398 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 125.0f, 24.0f ), TEST_LOCATION );
2400 customActor.SetProperty( componentOnePropertyIndex, 225.0f );
2401 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2402 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 125.0f, 225.0f ), TEST_LOCATION );
2404 tet_infoline( "Check latest scene-graph value is unchanged" );
2405 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector2 >( customActor, basePropertyIndex ), Vector2( 13.0f, 24.0f ), TEST_LOCATION );
2406 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2407 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2409 // Render and notify
2410 application.SendNotification();
2411 application.Render();
2413 tet_infoline( "Check values after rendering and both retrieval methods should return the latest" );
2414 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 125.0f, 225.0f ), TEST_LOCATION );
2415 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2416 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2418 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector2 >( customActor, basePropertyIndex ), Vector2( 125.0f, 225.0f ), TEST_LOCATION );
2419 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2420 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2422 tet_infoline( "Set the base property value and ensure the component values reflect the change" );
2423 customActor.SetProperty( basePropertyIndex, Vector2( 1.0f, 2.0f ) );
2424 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 1.0f, TEST_LOCATION );
2425 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 2.0f, TEST_LOCATION );
2426 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 1.0f, 2.0f ), TEST_LOCATION );
2431 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGetWithComponentsVector3(void)
2433 TestApplication application;
2434 TypeRegistry typeRegistry = TypeRegistry::Get();
2436 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" );
2438 // Register the animatable propeties
2439 const int basePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
2440 const int componentZeroPropertyIndex( basePropertyIndex + 1 );
2441 const int componentOnePropertyIndex( componentZeroPropertyIndex + 1 );
2442 const int componentTwoPropertyIndex( componentOnePropertyIndex + 1 );
2443 AnimatablePropertyRegistration baseAnimatableProperty( customType1, "baseProp", basePropertyIndex, Vector3( 13.0f, 24.0f, 35.0 ) );
2444 AnimatablePropertyComponentRegistration componentZeroAnimatableProperty( customType1, "componentZeroProp", componentZeroPropertyIndex, basePropertyIndex, 0 );
2445 AnimatablePropertyComponentRegistration componentOneAnimatableProperty( customType1, "componentOneProp", componentOnePropertyIndex, basePropertyIndex, 1 );
2446 AnimatablePropertyComponentRegistration componentTwoAnimatableProperty( customType1, "componentTwoProp", componentTwoPropertyIndex, basePropertyIndex, 2 );
2448 // Check property count before property registration
2449 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2450 DALI_TEST_CHECK( typeInfo );
2451 BaseHandle handle = typeInfo.CreateInstance();
2452 DALI_TEST_CHECK( handle );
2453 Actor customActor = Actor::DownCast( handle );
2454 DALI_TEST_CHECK( customActor );
2455 Stage::GetCurrent().Add(customActor);
2457 tet_infoline( "Get the component values, they should be the default value of the base-property" );
2458 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2459 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2460 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 35.0f, TEST_LOCATION );
2461 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 13.0f, 24.0f, 35.0f ), TEST_LOCATION );
2463 tet_infoline( "Set a component value and ensure it changes for the base property as well" );
2464 customActor.SetProperty( componentZeroPropertyIndex, 125.0f );
2465 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2466 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 24.0f, 35.0f ), TEST_LOCATION );
2468 customActor.SetProperty( componentOnePropertyIndex, 225.0f );
2469 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2470 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 225.0f, 35.0f ), TEST_LOCATION );
2472 customActor.SetProperty( componentTwoPropertyIndex, 325.0f );
2473 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2474 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 225.0f, 325.0f ), TEST_LOCATION );
2476 tet_infoline( "Check latest scene-graph value is unchanged" );
2477 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector3 >( customActor, basePropertyIndex ), Vector3( 13.0f, 24.0f, 35.0f ), TEST_LOCATION );
2478 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2479 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2480 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, componentTwoPropertyIndex ), 35.0f, TEST_LOCATION );
2482 // Render and notify
2483 application.SendNotification();
2484 application.Render();
2486 tet_infoline( "Check values after rendering and both retrieval methods should return the latest" );
2487 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 225.0f, 325.0f ), TEST_LOCATION );
2488 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2489 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2490 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2492 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector3 >( customActor, basePropertyIndex ), Vector3( 125.0f, 225.0f, 325.0f ), TEST_LOCATION );
2493 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2494 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2495 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2497 tet_infoline( "Set the base property value and ensure the component values reflect the change" );
2498 customActor.SetProperty( basePropertyIndex, Vector3( 1.0f, 2.0f, 3.0f ) );
2499 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 1.0f, TEST_LOCATION );
2500 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 2.0f, TEST_LOCATION );
2501 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 3.0f, TEST_LOCATION );
2502 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 1.0f, 2.0f, 3.0f ), TEST_LOCATION );
2507 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGetWithComponentsVector4(void)
2509 TestApplication application;
2510 TypeRegistry typeRegistry = TypeRegistry::Get();
2512 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" );
2514 // Register the animatable propeties
2515 const int basePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
2516 const int componentZeroPropertyIndex( basePropertyIndex + 1 );
2517 const int componentOnePropertyIndex( componentZeroPropertyIndex + 1 );
2518 const int componentTwoPropertyIndex( componentOnePropertyIndex + 1 );
2519 const int componentThreePropertyIndex( componentTwoPropertyIndex + 1 );
2520 AnimatablePropertyRegistration baseAnimatableProperty( customType1, "baseProp", basePropertyIndex, Vector4( 13.0f, 24.0f, 35.0, 47.0f ) );
2521 AnimatablePropertyComponentRegistration componentZeroAnimatableProperty( customType1, "componentZeroProp", componentZeroPropertyIndex, basePropertyIndex, 0 );
2522 AnimatablePropertyComponentRegistration componentOneAnimatableProperty( customType1, "componentOneProp", componentOnePropertyIndex, basePropertyIndex, 1 );
2523 AnimatablePropertyComponentRegistration componentTwoAnimatableProperty( customType1, "componentTwoProp", componentTwoPropertyIndex, basePropertyIndex, 2 );
2524 AnimatablePropertyComponentRegistration componentThreeAnimatableProperty( customType1, "componentThreeProp", componentThreePropertyIndex, basePropertyIndex, 3 );
2526 // Check property count before property registration
2527 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2528 DALI_TEST_CHECK( typeInfo );
2529 BaseHandle handle = typeInfo.CreateInstance();
2530 DALI_TEST_CHECK( handle );
2531 Actor customActor = Actor::DownCast( handle );
2532 DALI_TEST_CHECK( customActor );
2533 Stage::GetCurrent().Add(customActor);
2535 tet_infoline( "Get the component values, they should be the default value of the base-property" );
2536 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2537 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2538 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 35.0f, TEST_LOCATION );
2539 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentThreePropertyIndex ), 47.0f, TEST_LOCATION );
2540 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 13.0f, 24.0f, 35.0f, 47.0f ), TEST_LOCATION );
2542 tet_infoline( "Set a component value and ensure it changes for the base property as well" );
2543 customActor.SetProperty( componentZeroPropertyIndex, 125.0f );
2544 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2545 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 24.0f, 35.0f, 47.0f ), TEST_LOCATION );
2547 customActor.SetProperty( componentOnePropertyIndex, 225.0f );
2548 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2549 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 35.0f, 47.0f ), TEST_LOCATION );
2551 customActor.SetProperty( componentTwoPropertyIndex, 325.0f );
2552 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2553 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 325.0f, 47.0f ), TEST_LOCATION );
2555 customActor.SetProperty( componentThreePropertyIndex, 435.0f );
2556 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentThreePropertyIndex ), 435.0f, TEST_LOCATION );
2557 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 325.0f, 435.0f ), TEST_LOCATION );
2559 tet_infoline( "Check latest scene-graph value is unchanged" );
2560 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector4 >( customActor, basePropertyIndex ), Vector4( 13.0f, 24.0f, 35.0f, 47.0f ), TEST_LOCATION );
2561 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2562 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2563 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, componentTwoPropertyIndex ), 35.0f, TEST_LOCATION );
2564 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, componentThreePropertyIndex ), 47.0f, TEST_LOCATION );
2566 // Render and notify
2567 application.SendNotification();
2568 application.Render();
2570 tet_infoline( "Check values after rendering and both retrieval methods should return the latest" );
2571 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 325.0f, 435.0f ), TEST_LOCATION );
2572 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2573 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2574 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2575 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentThreePropertyIndex ), 435.0f, TEST_LOCATION );
2577 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector4 >( customActor, basePropertyIndex ), Vector4( 125.0f, 225.0f, 325.0f, 435.0f ), TEST_LOCATION );
2578 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2579 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2580 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2581 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, componentThreePropertyIndex ), 435.0f, TEST_LOCATION );
2583 tet_infoline( "Set the base property value and ensure the component values reflect the change" );
2584 customActor.SetProperty( basePropertyIndex, Vector4( 1.0f, 2.0f, 3.0f, 4.0f ) );
2585 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 1.0f, TEST_LOCATION );
2586 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 2.0f, TEST_LOCATION );
2587 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 3.0f, TEST_LOCATION );
2588 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentThreePropertyIndex ), 4.0f, TEST_LOCATION );
2589 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 1.0f, 2.0f, 3.0f, 4.0f ), TEST_LOCATION );