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 );
1182 // Render and notify, animation play for 0.05 seconds
1183 application.SendNotification();
1184 application.Render(50);
1185 DALI_TEST_EQUALS( 0.25f, animation.GetCurrentProgress(), TEST_LOCATION );
1186 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, animatablePropertyIndex ), 22.5f, TEST_LOCATION );
1187 // Render and notify, animation play for another 0.1 seconds
1188 application.SendNotification();
1189 application.Render(100);
1190 DALI_TEST_EQUALS( 0.75f, animation.GetCurrentProgress(), TEST_LOCATION );
1191 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, animatablePropertyIndex ), 17.5f, TEST_LOCATION );
1196 int UtcDaliTypeRegistryAnimatablePropertyRegistrationN(void)
1198 TestApplication application;
1199 TypeRegistry typeRegistry = TypeRegistry::Get();
1201 // Attempt to register an animatable property type out-of-bounds index (less than)
1204 AnimatablePropertyRegistration property1( customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN );
1205 tet_result( TET_FAIL );
1207 catch ( DaliException& e )
1209 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1212 // Attempt to register an animatable property type out-of-bounds index (greater than)
1215 AnimatablePropertyRegistration property1( customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN );
1216 tet_result( TET_FAIL );
1218 catch ( DaliException& e )
1220 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1226 int UtcDaliTypeRegistryAnimatablePropertyRegistrationWithDefaultP(void)
1228 TestApplication application;
1229 TypeRegistry typeRegistry = TypeRegistry::Get();
1231 // Check property count before property registration
1232 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1233 DALI_TEST_CHECK( typeInfo );
1234 BaseHandle handle = typeInfo.CreateInstance();
1235 DALI_TEST_CHECK( handle );
1236 Actor customActor = Actor::DownCast( handle );
1237 DALI_TEST_CHECK( customActor );
1238 Stage::GetCurrent().Add(customActor);
1240 unsigned int customPropertyCount( customActor.GetPropertyCount() );
1242 // Register animatable property
1243 std::string animatablePropertyName( "animatableProp1" );
1244 int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1245 AnimatablePropertyRegistration animatableProperty1( customType1, animatablePropertyName, animatablePropertyIndex, 10.f );
1247 // Check property count after registration
1248 DALI_TEST_EQUALS( customPropertyCount + 1u, customActor.GetPropertyCount(), TEST_LOCATION );
1250 // Render and notify
1251 application.SendNotification();
1252 application.Render();
1254 // Check the animatable property value
1255 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 10.f, TEST_LOCATION );
1257 // Check the animatable property name
1258 DALI_TEST_EQUALS( customActor.GetPropertyName( animatablePropertyIndex ), animatablePropertyName, TEST_LOCATION );
1260 // Check the animatable property index
1261 DALI_TEST_EQUALS( customActor.GetPropertyIndex( animatablePropertyName ), animatablePropertyIndex, TEST_LOCATION );
1263 // Check the animatable property type
1264 DALI_TEST_EQUALS( customActor.GetPropertyType( animatablePropertyIndex ), Property::FLOAT, TEST_LOCATION );
1266 // Check property count of type-info is 1
1267 Property::IndexContainer indices;
1268 typeInfo.GetPropertyIndices( indices );
1269 DALI_TEST_EQUALS( indices.Size(), 1u, TEST_LOCATION );
1271 // Ensure indices returned from actor and customActor differ by one
1272 Actor actor = Actor::New();
1273 actor.GetPropertyIndices( indices );
1274 unsigned int actorIndices = indices.Size();
1275 customActor.GetPropertyIndices( indices );
1276 unsigned int customActorIndices = indices.Size();
1277 DALI_TEST_EQUALS( actorIndices + 1u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1279 // check that the property is animatable
1280 Animation animation = Animation::New(0.2f);
1281 animation.AnimateTo( Property( customActor, animatablePropertyIndex ), 20.f, AlphaFunction::LINEAR );
1283 // Render and notify, animation play for 0.05 seconds
1284 application.SendNotification();
1285 application.Render(50);
1286 DALI_TEST_EQUALS( 0.25f, animation.GetCurrentProgress(), TEST_LOCATION );
1287 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, animatablePropertyIndex ), 12.5f, TEST_LOCATION );
1288 // Render and notify, animation play for another 0.1 seconds
1289 application.SendNotification();
1290 application.Render(100);
1291 DALI_TEST_EQUALS( 0.75f, animation.GetCurrentProgress(), TEST_LOCATION );
1292 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, animatablePropertyIndex ), 17.5f, TEST_LOCATION );
1297 int UtcDaliTypeRegistryAnimatablePropertyRegistrationWithDefaultN(void)
1299 TestApplication application;
1300 TypeRegistry typeRegistry = TypeRegistry::Get();
1302 // Attempt to register an animatable property type out-of-bounds index (less than)
1305 AnimatablePropertyRegistration property1( customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX - 1, false );
1306 tet_result( TET_FAIL );
1308 catch ( DaliException& e )
1310 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1313 // Attempt to register an animatable property type out-of-bounds index (greater than)
1316 AnimatablePropertyRegistration property1( customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX + 1, true );
1317 tet_result( TET_FAIL );
1319 catch ( DaliException& e )
1321 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1327 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationP(void)
1329 TestApplication application;
1330 TypeRegistry typeRegistry = TypeRegistry::Get();
1332 // Check property count before property registration
1333 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1334 DALI_TEST_CHECK( typeInfo );
1335 BaseHandle handle = typeInfo.CreateInstance();
1336 DALI_TEST_CHECK( handle );
1337 Actor customActor = Actor::DownCast( handle );
1338 DALI_TEST_CHECK( customActor );
1340 unsigned int customPropertyCount( customActor.GetPropertyCount() );
1342 // Register animatable property
1343 std::string animatablePropertyName( "animatableProp1" );
1344 int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1345 Property::Type animatablePropertyType( Property::VECTOR2 );
1346 AnimatablePropertyRegistration animatableProperty1( customType1, animatablePropertyName, animatablePropertyIndex, animatablePropertyType );
1348 // Check property count after registration
1349 DALI_TEST_EQUALS( customPropertyCount + 1u, customActor.GetPropertyCount(), TEST_LOCATION );
1351 // Set the animatable property value
1352 customActor.SetProperty( animatablePropertyIndex, Vector2(25.0f, 50.0f) );
1354 // Render and notify
1355 application.SendNotification();
1356 application.Render();
1358 // Check the animatable property value
1359 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( animatablePropertyIndex ), Vector2(25.0f, 50.0f), TEST_LOCATION );
1361 // Check the animatable property name
1362 DALI_TEST_EQUALS( customActor.GetPropertyName( animatablePropertyIndex ), animatablePropertyName, TEST_LOCATION );
1364 // Check the animatable property index
1365 DALI_TEST_EQUALS( customActor.GetPropertyIndex( animatablePropertyName ), animatablePropertyIndex, TEST_LOCATION );
1367 // Check the animatable property type
1368 DALI_TEST_EQUALS( customActor.GetPropertyType( animatablePropertyIndex ), animatablePropertyType, TEST_LOCATION );
1370 // Check property count of type-info is 1
1371 Property::IndexContainer indices;
1372 typeInfo.GetPropertyIndices( indices );
1373 DALI_TEST_EQUALS( indices.Size(), 1u, TEST_LOCATION );
1375 // Register animatable property components
1376 std::string animatablePropertyComponentName1( "animatableProp1X" );
1377 int animatablePropertyComponentIndex1( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1 );
1378 AnimatablePropertyComponentRegistration animatablePropertyComponent1( customType1, animatablePropertyComponentName1, animatablePropertyComponentIndex1, animatablePropertyIndex, 0 );
1380 std::string animatablePropertyComponentName2( "animatableProp1Y" );
1381 int animatablePropertyComponentIndex2( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2 );
1382 AnimatablePropertyComponentRegistration animatablePropertyComponent2( customType1, animatablePropertyComponentName2, animatablePropertyComponentIndex2, animatablePropertyIndex, 1 );
1384 // Check property count after registration
1385 DALI_TEST_EQUALS( customPropertyCount + 3u, customActor.GetPropertyCount(), TEST_LOCATION );
1387 // Check the animatable property component value
1388 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, animatablePropertyComponentIndex1 ), 25.0f, TEST_LOCATION );
1389 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, animatablePropertyComponentIndex2 ), 50.0f, TEST_LOCATION );
1391 // Set the animatable property component value
1392 customActor.SetProperty( animatablePropertyComponentIndex1, 150.0f );
1394 // Render and notify
1395 application.SendNotification();
1396 application.Render();
1398 // Check the animatable property value
1399 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector2 >( customActor, animatablePropertyIndex ), Vector2(150.0f, 50.0f), TEST_LOCATION );
1400 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, animatablePropertyComponentIndex1 ), 150.0f, TEST_LOCATION );
1401 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, animatablePropertyComponentIndex2 ), 50.0f, TEST_LOCATION );
1403 // Set the animatable property component value
1404 customActor.SetProperty( animatablePropertyComponentIndex2, 225.0f );
1406 // Render and notify
1407 application.SendNotification();
1408 application.Render();
1410 // Check the animatable property value
1411 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector2 >( customActor, animatablePropertyIndex ), Vector2(150.0f, 225.0f), TEST_LOCATION );
1412 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, animatablePropertyComponentIndex1 ), 150.0f, TEST_LOCATION );
1413 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, animatablePropertyComponentIndex2 ), 225.0f, TEST_LOCATION );
1415 // Ensure indices returned from actor and customActor differ by three
1416 Actor actor = Actor::New();
1417 actor.GetPropertyIndices( indices );
1418 unsigned int actorIndices = indices.Size();
1419 customActor.GetPropertyIndices( indices );
1420 unsigned int customActorIndices = indices.Size();
1421 DALI_TEST_EQUALS( actorIndices + 3u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1426 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationN(void)
1428 TestApplication application;
1429 TypeRegistry typeRegistry = TypeRegistry::Get();
1431 // Register animatable property with the type of Vector2
1432 int animatablePropertyIndex1( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1433 AnimatablePropertyRegistration animatableProperty1( customType1, "animatableProp1", animatablePropertyIndex1, Property::VECTOR2 );
1435 // Attempt to register an animatable property component out-of-bounds index (less than)
1438 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp1X", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX - 1, animatablePropertyIndex1, 0 );
1439 tet_result( TET_FAIL );
1441 catch ( DaliException& e )
1443 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1446 // Attempt to register an animatable property component out-of-bounds index (greater than)
1449 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp1X", ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX + 1, animatablePropertyIndex1, 0 );
1450 tet_result( TET_FAIL );
1452 catch ( DaliException& e )
1454 DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1457 // Register an animatable property component
1458 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp1X", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1, animatablePropertyIndex1, 0 );
1460 // Attempt to register another animatable property component with the same component index
1463 AnimatablePropertyComponentRegistration propertyComponent2( customType1, "animatableProp1Y", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2, animatablePropertyIndex1, 0 );
1464 tet_result( TET_FAIL );
1466 catch ( DaliException& e )
1468 DALI_TEST_ASSERT( e, "Property component already registered", TEST_LOCATION );
1471 // Register animatable property with the type of boolean
1472 int animatablePropertyIndex2( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2 );
1473 AnimatablePropertyRegistration animatableProperty2( customType1, "animatableProp2", animatablePropertyIndex2, Property::BOOLEAN );
1475 // Attempt to register an animatable property component for the above property with boolean type
1478 AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp2X", animatablePropertyIndex2 + 1, animatablePropertyIndex2, 0 );
1479 tet_result( TET_FAIL );
1481 catch ( DaliException& e )
1483 DALI_TEST_ASSERT( e, "Base property does not support component", TEST_LOCATION );
1489 int UtcDaliTypeRegistryChildPropertyRegistrationP(void)
1491 TestApplication application;
1492 TypeRegistry typeRegistry = TypeRegistry::Get();
1494 // Check property count before property registration
1495 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1496 DALI_TEST_CHECK( typeInfo );
1497 BaseHandle handle = typeInfo.CreateInstance();
1498 DALI_TEST_CHECK( handle );
1499 Actor customActor = Actor::DownCast( handle );
1500 DALI_TEST_CHECK( customActor );
1501 unsigned int initialPropertyCount( customActor.GetPropertyCount() );
1503 // Register child properties to the parent
1504 std::string propertyName( "childProp1" );
1505 int propertyIndex( CHILD_PROPERTY_REGISTRATION_START_INDEX );
1506 Property::Type propertyType( Property::BOOLEAN );
1507 ChildPropertyRegistration childProperty1( customType1, propertyName, propertyIndex, propertyType );
1509 std::string propertyName2( "childProp2" );
1510 int propertyIndex2( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1 );
1511 Property::Type propertyType2( Property::INTEGER );
1512 ChildPropertyRegistration childProperty2( customType1, propertyName2, propertyIndex2, propertyType2 );
1514 std::string propertyName3( "childProp3" );
1515 int propertyIndex3( CHILD_PROPERTY_REGISTRATION_START_INDEX + 2 );
1516 Property::Type propertyType3( Property::FLOAT );
1517 ChildPropertyRegistration childProperty3( customType1, propertyName3, propertyIndex3, propertyType3 );
1519 std::string propertyName4( "childProp4" );
1520 int propertyIndex4( CHILD_PROPERTY_REGISTRATION_START_INDEX + 3 );
1521 Property::Type propertyType4( Property::INTEGER );
1522 ChildPropertyRegistration childProperty4( customType1, propertyName4, propertyIndex4, propertyType4 );
1524 // Check property count are not changed because the child properties will not be created for the parent
1525 DALI_TEST_EQUALS( initialPropertyCount, customActor.GetPropertyCount(), TEST_LOCATION );
1527 // check the child property type
1528 Internal::TypeInfo& typeInfoImpl = GetImplementation( typeInfo );
1529 Property::Type type = typeInfoImpl.GetChildPropertyType( typeInfoImpl.GetChildPropertyIndex("childProp4") );
1530 DALI_TEST_EQUALS( type, Property::INTEGER, TEST_LOCATION );
1533 // Create a child actor
1534 Actor childActor = Actor::New();
1535 DALI_TEST_CHECK( childActor );
1536 unsigned int initialChildActorPropertyCount( childActor.GetPropertyCount() );
1538 // The type of child properties should be Property::None as the child hasn't registered any child property yet.
1539 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex ), Property::NONE, TEST_LOCATION );
1540 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex2 ), Property::NONE, TEST_LOCATION );
1541 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex3 ), Property::NONE, TEST_LOCATION );
1542 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex4 ), Property::NONE, TEST_LOCATION );
1544 // Set the value for the first child property when the child actor doesn't have a parent yet
1545 childActor.SetProperty(propertyIndex, true);
1547 // Check that the first child property is dynamically created
1548 DALI_TEST_EQUALS( initialChildActorPropertyCount + 1u, childActor.GetPropertyCount(), TEST_LOCATION );
1550 // Check the first child property value
1551 DALI_TEST_EQUALS( childActor.GetProperty< bool >( propertyIndex ), true, TEST_LOCATION );
1553 // Check the first child property type
1554 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex ), propertyType, TEST_LOCATION );
1556 // Check that the first child property have no name, as it doesn't have a parent yet.
1557 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex ), "", TEST_LOCATION );
1559 // Check that the first property can't be accessed through its name, as it doesn't have a parent yet.
1560 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName ), Property::INVALID_INDEX, TEST_LOCATION );
1562 // Create a custom property for the child with the same name as the second child property registered to the parent
1563 Property::Index customPropertyIndex = childActor.RegisterProperty(propertyName2, 100, Property::READ_WRITE);
1565 // Check that the custom property is created
1566 DALI_TEST_EQUALS( initialChildActorPropertyCount + 2u, childActor.GetPropertyCount(), TEST_LOCATION );
1568 // Check the property value
1569 DALI_TEST_EQUALS( childActor.GetProperty< int >( customPropertyIndex ), 100, TEST_LOCATION );
1571 // Check the property index
1572 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName2 ), customPropertyIndex, TEST_LOCATION );
1574 // Check the property type
1575 DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex ), propertyType2, TEST_LOCATION );
1577 // Check the property name
1578 DALI_TEST_EQUALS( childActor.GetPropertyName( customPropertyIndex ), propertyName2, TEST_LOCATION );
1580 // Now add the child actor to the parent
1581 customActor.Add( childActor );
1583 // Check that the first child property now has the correct name as previously registered to the parent
1584 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
1586 // Check that the child property index for the first child property can now be retrieved through its child property name
1587 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName ), propertyIndex, TEST_LOCATION );
1589 // Check that the second child property now has the correct index as previously registered to the parent
1590 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex2 ), propertyName2, TEST_LOCATION );
1592 // Check that the second child property can be accessed through both its custom property index and its child property index
1593 DALI_TEST_EQUALS( childActor.GetProperty< int >( customPropertyIndex ), 100, TEST_LOCATION );
1594 DALI_TEST_EQUALS( childActor.GetProperty< int >( propertyIndex2 ), 100, TEST_LOCATION );
1595 DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex ), propertyType2, TEST_LOCATION );
1596 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex2 ), propertyType2, TEST_LOCATION );
1598 // Check that the child property index for the second child property can now be retrieved through its child property name
1599 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName2 ), propertyIndex2, TEST_LOCATION );
1601 // Set the value for the third child property when the child actor is already added to the parent
1602 childActor.SetProperty(propertyIndex3, 0.15f);
1604 // Check that the third child property is dynamically created
1605 DALI_TEST_EQUALS( initialChildActorPropertyCount + 3u, childActor.GetPropertyCount(), TEST_LOCATION );
1607 // Check the third child property value
1608 DALI_TEST_EQUALS( childActor.GetProperty< float >( propertyIndex3 ), 0.15f, TEST_LOCATION );
1610 // Check the third child property type
1611 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex3 ), propertyType3, TEST_LOCATION );
1613 // Check the third child property name
1614 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex3 ), propertyName3, TEST_LOCATION );
1616 // Check the third child property index.
1617 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName3 ), propertyIndex3, TEST_LOCATION );
1619 // Create a custom property for the child with the same name as the fourth child property registered to the parent
1620 Property::Index customPropertyIndex2 = childActor.RegisterProperty(propertyName4, 20, Property::READ_WRITE);
1622 // Check that the custom property is created
1623 DALI_TEST_EQUALS( initialChildActorPropertyCount + 4u, childActor.GetPropertyCount(), TEST_LOCATION );
1625 // Check the fourth child property value
1626 DALI_TEST_EQUALS( childActor.GetProperty< int >( propertyIndex4 ), 20, TEST_LOCATION );
1627 DALI_TEST_EQUALS( childActor.GetProperty< int >( customPropertyIndex2 ), 20, TEST_LOCATION );
1629 // Check the fourth child property type
1630 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex4 ), propertyType4, TEST_LOCATION );
1631 DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex2 ), propertyType4, TEST_LOCATION );
1633 // Check the fourth child property name
1634 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex4 ), propertyName4, TEST_LOCATION );
1635 DALI_TEST_EQUALS( childActor.GetPropertyName( customPropertyIndex2 ), propertyName4, TEST_LOCATION );
1637 // Check the fourth child property index.
1638 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName4 ), propertyIndex4, TEST_LOCATION );
1640 // Now create another parent actor with different child properties registered
1641 TypeInfo typeInfo2 = typeRegistry.GetTypeInfo( "MyNamedActor" );
1642 DALI_TEST_CHECK( typeInfo2 );
1643 BaseHandle handle2 = typeInfo2.CreateInstance();
1644 DALI_TEST_CHECK( handle2 );
1645 Actor customActor2 = Actor::DownCast( handle2 );
1646 DALI_TEST_CHECK( customActor2 );
1648 // Register child properties to the new parent
1649 std::string newPropertyName( "newChildProp" );
1650 int newPropertyIndex( CHILD_PROPERTY_REGISTRATION_START_INDEX ); // The same index as the first child property "childProp1" in the old parent
1651 Property::Type newPropertyType( Property::VECTOR2 );
1652 ChildPropertyRegistration newChildProperty( namedActorType, newPropertyName, newPropertyIndex, newPropertyType );
1654 std::string newPropertyName2( "childProp3" ); // The same name as the third child property in the old parent
1655 int newPropertyIndex2( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1 ); // The same index as the second child property "childProp2" in the old parent
1656 Property::Type newPropertyType2( Property::FLOAT ); // The same type as the third child property in the old parent
1657 ChildPropertyRegistration newChildProperty2( namedActorType, newPropertyName2, newPropertyIndex2, newPropertyType2 );
1659 // Now move the child actor to the new parent
1660 customActor2.Add( childActor );
1662 // "childProp1" is not a valid child property supported by the new parent, so nothing changed
1663 DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex ), propertyType, TEST_LOCATION );
1664 DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
1665 DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName ), propertyIndex, TEST_LOCATION );
1667 // "childProp3" is a valid child property supported by the new parent
1668 // So it should get its new child property index and should just work
1669 DALI_TEST_EQUALS( childActor.GetPropertyType( newPropertyIndex2 ), newPropertyType2, TEST_LOCATION );
1670 DALI_TEST_EQUALS( childActor.GetPropertyName( newPropertyIndex2 ), newPropertyName2, TEST_LOCATION );
1671 DALI_TEST_EQUALS( childActor.GetPropertyIndex( newPropertyName2 ), newPropertyIndex2, TEST_LOCATION );
1672 DALI_TEST_EQUALS( childActor.GetProperty< float >( newPropertyIndex2 ), 0.15f, TEST_LOCATION );
1674 // Now register a custom property called "newChildProp"
1675 Property::Index customPropertyIndex3 = childActor.RegisterProperty("newChildProp", Vector2( 10.0f, 10.0f ), Property::READ_WRITE);
1677 // Check that the custom property is created
1678 DALI_TEST_EQUALS( initialChildActorPropertyCount + 5u, childActor.GetPropertyCount(), TEST_LOCATION );
1680 // This is a valid child property registered to the new parent
1681 // So should be able to access it through both its custom property index and its registered child property index
1682 DALI_TEST_EQUALS( childActor.GetPropertyType( newPropertyIndex ), newPropertyType, TEST_LOCATION );
1683 DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex3 ), newPropertyType, TEST_LOCATION );
1684 DALI_TEST_EQUALS( childActor.GetPropertyName( newPropertyIndex ), newPropertyName, TEST_LOCATION ); // This should return the new name, although the child property index remains the same
1685 DALI_TEST_EQUALS( childActor.GetPropertyName( customPropertyIndex3 ), newPropertyName, TEST_LOCATION );
1686 DALI_TEST_EQUALS( childActor.GetProperty< Vector2 >( newPropertyIndex ), Vector2( 10.0f, 10.0f ), TEST_LOCATION );
1687 DALI_TEST_EQUALS( childActor.GetProperty< Vector2 >( customPropertyIndex3 ), Vector2( 10.0f, 10.0f ), TEST_LOCATION );
1689 // Should return the child property index by given its name
1690 DALI_TEST_EQUALS( childActor.GetPropertyIndex( newPropertyName ), newPropertyIndex, TEST_LOCATION );
1696 int UtcDaliTypeRegistryChildPropertyRegistrationN(void)
1698 TestApplication application;
1699 TypeRegistry typeRegistry = TypeRegistry::Get();
1701 // Attempt to register a child property type out-of-bounds index (less than)
1704 ChildPropertyRegistration property1( customType1, "propName", CHILD_PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN );
1705 tet_result( TET_FAIL );
1707 catch ( DaliException& e )
1709 DALI_TEST_ASSERT( e, "( index >= CHILD_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1712 // Attempt to register a child property type out-of-bounds index (greater than)
1715 ChildPropertyRegistration property1( customType1, "propName", CHILD_PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN );
1716 tet_result( TET_FAIL );
1718 catch ( DaliException& e )
1720 DALI_TEST_ASSERT( e, "( index >= CHILD_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1727 /*******************************************************************************
1729 * Action through the base handle
1731 ******************************************************************************/
1732 int UtcDaliTypeRegistryActionViaBaseHandle(void)
1734 TestApplication application;
1738 type = TypeRegistry::Get().GetTypeInfo( "Actor" );
1739 DALI_TEST_CHECK( type );
1741 BaseHandle hdl = type.CreateInstance();
1742 DALI_TEST_CHECK( hdl );
1744 Actor a = Actor::DownCast(hdl);
1745 DALI_TEST_CHECK( a );
1747 a.SetVisible(false);
1749 application.SendNotification();
1750 application.Render(0);
1751 DALI_TEST_CHECK(!a.IsVisible());
1753 Property::Map attributes;
1755 DALI_TEST_CHECK(hdl.DoAction("show", attributes));
1757 application.SendNotification();
1758 application.Render(0);
1759 DALI_TEST_CHECK(a.IsVisible());
1761 DALI_TEST_CHECK(!hdl.DoAction("unknownAction", attributes));
1765 int UtcDaliPropertyRegistrationFunctions(void)
1767 TestApplication application;
1768 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 10;
1770 // Attempt to register a property without a setter
1773 PropertyRegistration property1( customType1, "propName", propertyIndex++, Property::BOOLEAN, NULL, &GetProperty );
1774 tet_result( TET_PASS );
1776 catch ( DaliException& e )
1778 tet_result( TET_FAIL );
1781 // Attempt to register a property without a getter
1784 PropertyRegistration property1( customType1, "propName", propertyIndex++, Property::BOOLEAN, NULL, NULL );
1785 tet_result( TET_FAIL );
1787 catch ( DaliException& e )
1789 DALI_TEST_ASSERT( e, "! \"GetProperty", TEST_LOCATION );
1794 int UtcDaliPropertyRegistrationAddSameIndex(void)
1796 TestApplication application;
1797 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 100;
1799 // Add one property with a valid property index
1800 PropertyRegistration property1( customType1, "propName", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
1802 // Attempt to add another property with the same index
1805 PropertyRegistration property2( customType1, "propName2", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
1807 catch ( DaliException& e )
1809 DALI_TEST_ASSERT( e, "! \"Property index already added", TEST_LOCATION );
1812 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 100;
1814 // Add one property with a valid property index
1815 AnimatablePropertyRegistration property3( customType1, "animPropName", animatablePropertyIndex, Property::BOOLEAN );
1817 // Attempt to add another property with the same index
1820 AnimatablePropertyRegistration property4( customType1, "animPropName2", animatablePropertyIndex, Property::BOOLEAN );
1822 catch ( DaliException& e )
1824 DALI_TEST_ASSERT( e, "! \"Property index already added", TEST_LOCATION );
1829 int UtcDaliPropertyRegistrationPropertyWritableP(void)
1831 TestApplication application;
1832 int propertyIndex1 = PROPERTY_REGISTRATION_START_INDEX + 200;
1833 int propertyIndex2 = PROPERTY_REGISTRATION_START_INDEX + 201;
1835 // Add two properties, one with SetProperty, one without
1836 PropertyRegistration property1( customType1, "propNameReadwrite", propertyIndex1, Property::BOOLEAN, &SetProperty, &GetProperty );
1837 PropertyRegistration property2( customType1, "propNameReadonly", propertyIndex2, Property::BOOLEAN, NULL, &GetProperty );
1839 // Create custom-actor
1840 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
1841 DALI_TEST_CHECK( typeInfo );
1842 BaseHandle handle = typeInfo.CreateInstance();
1843 DALI_TEST_CHECK( handle );
1844 Actor customActor = Actor::DownCast( handle );
1845 DALI_TEST_CHECK( customActor );
1847 // Check whether properties are writable
1848 DALI_TEST_CHECK( customActor.IsPropertyWritable( propertyIndex1 ) );
1849 DALI_TEST_CHECK( ! customActor.IsPropertyWritable( propertyIndex2 ) );
1852 // Check the property is writable in the type registry
1853 Internal::TypeInfo& typeInfoImpl = GetImplementation( typeInfo );
1855 DALI_TEST_EQUALS( typeInfoImpl.IsPropertyWritable( propertyIndex1 ), true, TEST_LOCATION );
1860 int UtcDaliPropertyRegistrationPropertyWritableN(void)
1862 // Currently Actors don't register properties with the type registry
1864 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
1865 Internal::TypeInfo& typeInfoImpl = GetImplementation( typeInfo );
1869 typeInfoImpl.IsPropertyWritable( Actor::Property::COLOR);
1870 tet_result( TET_FAIL );
1873 catch ( DaliException& e )
1875 DALI_TEST_ASSERT( e, "Cannot find property index", TEST_LOCATION );
1880 int UtcDaliPropertyRegistrationPropertyAnimatable(void)
1882 TestApplication application;
1883 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 400;
1884 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 400;
1886 // These properties are not animatable
1887 PropertyRegistration property1( customType1, "propName", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
1889 // These properties are animatable
1890 AnimatablePropertyRegistration property2( customType1, "animPropName", animatablePropertyIndex, Property::BOOLEAN );
1892 // Create custom-actor
1893 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
1894 DALI_TEST_CHECK( typeInfo );
1895 BaseHandle handle = typeInfo.CreateInstance();
1896 DALI_TEST_CHECK( handle );
1897 Actor customActor = Actor::DownCast( handle );
1898 DALI_TEST_CHECK( customActor );
1900 // Check if animatable
1901 DALI_TEST_CHECK( ! customActor.IsPropertyAnimatable( propertyIndex ) );
1902 DALI_TEST_CHECK( customActor.IsPropertyAnimatable( animatablePropertyIndex ) );
1904 // Create another instance of custom-actor
1905 BaseHandle handle2 = typeInfo.CreateInstance();
1906 DALI_TEST_CHECK( handle2 );
1907 Actor customActor2 = Actor::DownCast( handle2 );
1908 DALI_TEST_CHECK( customActor2 );
1910 // Check if animatable
1911 DALI_TEST_CHECK( ! customActor2.IsPropertyAnimatable( propertyIndex ) );
1912 DALI_TEST_CHECK( customActor2.IsPropertyAnimatable( animatablePropertyIndex ) );
1916 int UtcDaliPropertyRegistrationInvalidGetAndSet(void)
1918 TestApplication application;
1919 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 2000;
1920 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2000;
1922 // Create custom-actor
1923 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
1924 DALI_TEST_CHECK( typeInfo );
1925 BaseHandle handle = typeInfo.CreateInstance();
1926 DALI_TEST_CHECK( handle );
1927 Actor customActor = Actor::DownCast( handle );
1928 DALI_TEST_CHECK( customActor );
1930 // Try to set an index that hasn't been added
1933 customActor.SetProperty( propertyIndex, true );
1934 tet_result( TET_FAIL );
1936 catch ( DaliException& e )
1938 DALI_TEST_ASSERT( e, "! \"Cannot find property index", TEST_LOCATION );
1943 customActor.SetProperty( animatablePropertyIndex, true );
1944 tet_result( TET_FAIL );
1946 catch ( DaliException& e )
1948 DALI_TEST_ASSERT( e, "! \"Cannot find property index", TEST_LOCATION );
1951 // Try to get an index that hasn't been added
1954 (void) customActor.GetProperty< bool >( propertyIndex );
1955 tet_result( TET_FAIL );
1957 catch ( DaliException& e )
1959 DALI_TEST_ASSERT( e, "! \"Cannot find property index", TEST_LOCATION );
1964 (void) customActor.GetProperty< bool >( animatablePropertyIndex );
1965 tet_result( TET_FAIL );
1967 catch ( DaliException& e )
1969 DALI_TEST_ASSERT( e, "! \"Cannot find property index", TEST_LOCATION );
1975 int UtcDaliLongPressGestureDetectorTypeRegistry(void)
1977 TestApplication application;
1979 Actor actor = Actor::New();
1980 actor.SetSize(100.0f, 100.0f);
1981 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1982 Stage::GetCurrent().Add(actor);
1986 type = TypeRegistry::Get().GetTypeInfo( "LongPressGestureDetector" );
1987 DALI_TEST_CHECK( type );
1988 BaseHandle handle = type.CreateInstance();
1989 DALI_TEST_CHECK( handle );
1990 LongPressGestureDetector detector = LongPressGestureDetector::DownCast( handle );
1991 DALI_TEST_CHECK( detector );
1993 // Attach actor to detector
1995 GestureReceivedFunctor functor( data );
1996 detector.Attach(actor);
1998 // Connect to signal through type
1999 handle.ConnectSignal( &application, "longPressDetected", functor );
2001 // Render and notify
2002 application.SendNotification();
2003 application.Render();
2006 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f)));
2007 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f)));
2008 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f)));
2009 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2013 int UtcDaliPanGestureDetectorTypeRegistry(void)
2015 TestApplication application;
2017 Actor actor = Actor::New();
2018 actor.SetSize(100.0f, 100.0f);
2019 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2020 Stage::GetCurrent().Add(actor);
2024 type = TypeRegistry::Get().GetTypeInfo( "PanGestureDetector" );
2025 DALI_TEST_CHECK( type );
2026 BaseHandle handle = type.CreateInstance();
2027 DALI_TEST_CHECK( handle );
2028 PanGestureDetector detector = PanGestureDetector::DownCast( handle );
2029 DALI_TEST_CHECK( detector );
2031 // Attach actor to detector
2033 GestureReceivedFunctor functor( data );
2034 detector.Attach(actor);
2036 // Connect to signal through type
2037 handle.ConnectSignal( &application, "panDetected", functor );
2039 // Render and notify
2040 application.SendNotification();
2041 application.Render();
2044 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
2045 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
2046 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
2047 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2051 int UtcDaliPinchGestureDetectorTypeRegistry(void)
2053 TestApplication application;
2055 Actor actor = Actor::New();
2056 actor.SetSize(100.0f, 100.0f);
2057 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2058 Stage::GetCurrent().Add(actor);
2062 type = TypeRegistry::Get().GetTypeInfo( "PinchGestureDetector" );
2063 DALI_TEST_CHECK( type );
2064 BaseHandle handle = type.CreateInstance();
2065 DALI_TEST_CHECK( handle );
2066 PinchGestureDetector detector = PinchGestureDetector::DownCast( handle );
2067 DALI_TEST_CHECK( detector );
2069 // Attach actor to detector
2071 GestureReceivedFunctor functor( data );
2072 detector.Attach(actor);
2074 // Connect to signal through type
2075 handle.ConnectSignal( &application, "pinchDetected", functor );
2077 // Render and notify
2078 application.SendNotification();
2079 application.Render();
2082 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
2083 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2087 int UtcDaliTapGestureDetectorTypeRegistry(void)
2089 TestApplication application;
2091 Actor actor = Actor::New();
2092 actor.SetSize(100.0f, 100.0f);
2093 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2094 Stage::GetCurrent().Add(actor);
2098 type = TypeRegistry::Get().GetTypeInfo( "TapGestureDetector" );
2099 DALI_TEST_CHECK( type );
2100 BaseHandle handle = type.CreateInstance();
2101 DALI_TEST_CHECK( handle );
2102 TapGestureDetector detector = TapGestureDetector::DownCast( handle );
2103 DALI_TEST_CHECK( detector );
2105 // Attach actor to detector
2107 GestureReceivedFunctor functor( data );
2108 detector.Attach(actor);
2110 // Connect to signal through type
2111 handle.ConnectSignal( &application, "tapDetected", functor );
2113 // Render and notify
2114 application.SendNotification();
2115 application.Render();
2118 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
2119 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
2120 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2124 int UtcDaliTypeRegistryNamedType(void)
2126 TestApplication application;
2127 TypeRegistry typeRegistry = TypeRegistry::Get();
2129 // Create a normal actor
2130 BaseHandle actorHandle = typeRegistry.GetTypeInfo( "Actor" ).CreateInstance();
2131 DALI_TEST_CHECK( actorHandle );
2132 Actor actor( Actor::DownCast( actorHandle ) );
2133 DALI_TEST_CHECK( actor );
2134 unsigned int actorPropertyCount( actor.GetPropertyCount() );
2136 // Create Named Actor Type
2137 BaseHandle namedHandle = typeRegistry.GetTypeInfo( "MyNamedActor" ).CreateInstance();
2138 DALI_TEST_CHECK( namedHandle );
2139 Actor namedActor( Actor::DownCast( namedHandle ) );
2140 DALI_TEST_CHECK( namedActor );
2141 unsigned int namedActorPropertyCount( namedActor.GetPropertyCount() );
2143 DALI_TEST_CHECK( namedActorPropertyCount > actorPropertyCount );
2147 int UtcDaliTypeInfoGetActionNameP(void)
2149 TestApplication application;
2150 TypeRegistry typeRegistry = TypeRegistry::Get();
2152 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2153 DALI_TEST_CHECK( typeInfo );
2155 DALI_TEST_CHECK( 0 != typeInfo.GetActionCount() );
2157 std::string name = typeInfo.GetActionName(0);
2159 DALI_TEST_EQUALS( name, "show", TEST_LOCATION );
2162 TypeInfo typeInfo2 = typeRegistry.GetTypeInfo( "MyTestCustomActor" );
2164 // search for show action in base class, given a derived class
2165 bool foundChildAction = false;
2166 for( std::size_t i = 0; i < typeInfo2.GetActionCount(); i++ )
2169 std::string name = typeInfo2.GetActionName( i );
2172 foundChildAction = true;
2177 DALI_TEST_EQUALS( foundChildAction, true, TEST_LOCATION );
2183 int UtcDaliTypeInfoGetActionNameN(void)
2185 TestApplication application;
2186 TypeRegistry typeRegistry = TypeRegistry::Get();
2188 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2189 DALI_TEST_CHECK( typeInfo );
2191 DALI_TEST_CHECK( 0 != typeInfo.GetActionCount() );
2193 std::string name = typeInfo.GetActionName(std::numeric_limits<size_t>::max());
2195 DALI_TEST_EQUALS( 0u, name.size(), TEST_LOCATION );
2200 int UtcDaliTypeInfoGetSignalNameP(void)
2202 TestApplication application;
2203 TypeRegistry typeRegistry = TypeRegistry::Get();
2205 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2206 DALI_TEST_CHECK( typeInfo );
2208 DALI_TEST_CHECK( 0 != typeInfo.GetSignalCount() );
2210 std::string name = typeInfo.GetSignalName(0);
2212 DALI_TEST_EQUALS( name, "touched", TEST_LOCATION );
2214 TypeInfo typeInfo2 = typeRegistry.GetTypeInfo( "MyTestCustomActor" );
2216 // search for signal in base class, given a derived class
2217 bool foundSignal = false;
2218 for( std::size_t i = 0; i < typeInfo2.GetSignalCount(); i++ )
2221 std::string name = typeInfo2.GetSignalName( i );
2222 if( name == "touched")
2229 DALI_TEST_EQUALS( foundSignal, true, TEST_LOCATION );
2234 int UtcDaliTypeInfoGetSignalNameN(void)
2236 TestApplication application;
2237 TypeRegistry typeRegistry = TypeRegistry::Get();
2239 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2240 DALI_TEST_CHECK( typeInfo );
2242 DALI_TEST_CHECK( 0 != typeInfo.GetSignalCount() );
2244 std::string name = typeInfo.GetSignalName(std::numeric_limits<size_t>::max());
2246 DALI_TEST_EQUALS( 0u, name.size(), TEST_LOCATION );
2252 int UtcDaliTypeInfoGetCreatorP(void)
2254 TestApplication application;
2255 TypeRegistry typeRegistry = TypeRegistry::Get();
2257 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2258 DALI_TEST_CHECK( typeInfo );
2260 TypeInfo::CreateFunction createFn = typeInfo.GetCreator();
2261 DALI_TEST_EQUALS( createFn != NULL, true, TEST_LOCATION );
2265 BaseHandle handle = createFn();
2266 DALI_TEST_EQUALS( (bool)handle, true, TEST_LOCATION );
2272 int UtcDaliTypeInfoGetCreatorN(void)
2274 TestApplication application;
2275 TypeRegistry typeRegistry = TypeRegistry::Get();
2277 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "MyTestCustomActor3" );
2278 DALI_TEST_CHECK( typeInfo );
2280 TypeInfo::CreateFunction createFn = typeInfo.GetCreator();
2281 DALI_TEST_EQUALS( createFn == NULL, true, TEST_LOCATION );
2286 int UtcDaliTypeInfoGetPropertyCountP1(void)
2288 TestApplication application;
2289 TypeRegistry typeRegistry = TypeRegistry::Get();
2291 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2292 DALI_TEST_CHECK( typeInfo );
2293 size_t actorPropertyCount = typeInfo.GetPropertyCount();
2295 DALI_TEST_EQUALS( actorPropertyCount == 0 , true, TEST_LOCATION ); // No event only props
2299 int UtcDaliTypeInfoGetPropertyCountP2(void)
2301 TestApplication application;
2302 TypeRegistry typeRegistry = TypeRegistry::Get();
2304 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "MyTestCustomActor2" );
2305 DALI_TEST_CHECK( typeInfo );
2306 size_t propertyCount = typeInfo.GetPropertyCount();
2307 Property::IndexContainer indices;
2308 typeInfo.GetPropertyIndices( indices );
2310 DALI_TEST_EQUALS( propertyCount > 0 && propertyCount <= indices.Size(), true, TEST_LOCATION );
2311 DALI_TEST_EQUALS( propertyCount == 2, true, TEST_LOCATION );
2316 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGet01(void)
2318 TestApplication application;
2319 TypeRegistry typeRegistry = TypeRegistry::Get();
2321 tet_infoline( "Register a type registered animatable property and ensure set/get behaviour works synchronously" );
2323 // Register animatable property
2324 const int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
2325 AnimatablePropertyRegistration animatableProperty( customType1, "animatableProp1", animatablePropertyIndex, Property::FLOAT );
2327 // Check property count before property registration
2328 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2329 DALI_TEST_CHECK( typeInfo );
2330 BaseHandle handle = typeInfo.CreateInstance();
2331 DALI_TEST_CHECK( handle );
2332 Actor customActor = Actor::DownCast( handle );
2333 DALI_TEST_CHECK( customActor );
2334 Stage::GetCurrent().Add(customActor);
2336 tet_infoline( "Set the value and ensure it changes straight away" );
2337 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 0.0f, TEST_LOCATION );
2338 customActor.SetProperty( animatablePropertyIndex, 25.0f );
2339 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 25.0f, TEST_LOCATION );
2341 tet_infoline( "Check latest scene-graph value is unchanged" );
2342 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, animatablePropertyIndex ), 0.0f, TEST_LOCATION );
2344 // Render and notify
2345 application.SendNotification();
2346 application.Render();
2348 tet_infoline( "Check values after rendering and both retrieval methods should return the latest" );
2350 DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 25.0f, TEST_LOCATION );
2351 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, animatablePropertyIndex ), 25.0f, TEST_LOCATION );
2356 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGetWithComponentsVector2(void)
2358 TestApplication application;
2359 TypeRegistry typeRegistry = TypeRegistry::Get();
2361 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" );
2363 // Register the animatable propeties
2364 const int basePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
2365 const int componentZeroPropertyIndex( basePropertyIndex + 1 );
2366 const int componentOnePropertyIndex( componentZeroPropertyIndex + 1 );
2367 AnimatablePropertyRegistration baseAnimatableProperty( customType1, "baseProp", basePropertyIndex, Vector2( 13.0f, 24.0f ) );
2368 AnimatablePropertyComponentRegistration componentZeroAnimatableProperty( customType1, "componentZeroProp", componentZeroPropertyIndex, basePropertyIndex, 0 );
2369 AnimatablePropertyComponentRegistration componentOneAnimatableProperty( customType1, "componentOneProp", componentOnePropertyIndex, basePropertyIndex, 1 );
2371 // Check property count before property registration
2372 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2373 DALI_TEST_CHECK( typeInfo );
2374 BaseHandle handle = typeInfo.CreateInstance();
2375 DALI_TEST_CHECK( handle );
2376 Actor customActor = Actor::DownCast( handle );
2377 DALI_TEST_CHECK( customActor );
2378 Stage::GetCurrent().Add(customActor);
2380 tet_infoline( "Get the component values, they should be the default value of the base-property" );
2381 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2382 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2383 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 13.0f, 24.0f ), TEST_LOCATION );
2385 tet_infoline( "Set a component value and ensure it changes for the base property as well" );
2386 customActor.SetProperty( componentZeroPropertyIndex, 125.0f );
2387 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2388 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 125.0f, 24.0f ), TEST_LOCATION );
2390 customActor.SetProperty( componentOnePropertyIndex, 225.0f );
2391 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2392 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 125.0f, 225.0f ), TEST_LOCATION );
2394 tet_infoline( "Check latest scene-graph value is unchanged" );
2395 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector2 >( customActor, basePropertyIndex ), Vector2( 13.0f, 24.0f ), TEST_LOCATION );
2396 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2397 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2399 // Render and notify
2400 application.SendNotification();
2401 application.Render();
2403 tet_infoline( "Check values after rendering and both retrieval methods should return the latest" );
2404 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 125.0f, 225.0f ), TEST_LOCATION );
2405 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2406 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2408 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector2 >( customActor, basePropertyIndex ), Vector2( 125.0f, 225.0f ), TEST_LOCATION );
2409 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2410 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2412 tet_infoline( "Set the base property value and ensure the component values reflect the change" );
2413 customActor.SetProperty( basePropertyIndex, Vector2( 1.0f, 2.0f ) );
2414 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 1.0f, TEST_LOCATION );
2415 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 2.0f, TEST_LOCATION );
2416 DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 1.0f, 2.0f ), TEST_LOCATION );
2421 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGetWithComponentsVector3(void)
2423 TestApplication application;
2424 TypeRegistry typeRegistry = TypeRegistry::Get();
2426 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" );
2428 // Register the animatable propeties
2429 const int basePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
2430 const int componentZeroPropertyIndex( basePropertyIndex + 1 );
2431 const int componentOnePropertyIndex( componentZeroPropertyIndex + 1 );
2432 const int componentTwoPropertyIndex( componentOnePropertyIndex + 1 );
2433 AnimatablePropertyRegistration baseAnimatableProperty( customType1, "baseProp", basePropertyIndex, Vector3( 13.0f, 24.0f, 35.0 ) );
2434 AnimatablePropertyComponentRegistration componentZeroAnimatableProperty( customType1, "componentZeroProp", componentZeroPropertyIndex, basePropertyIndex, 0 );
2435 AnimatablePropertyComponentRegistration componentOneAnimatableProperty( customType1, "componentOneProp", componentOnePropertyIndex, basePropertyIndex, 1 );
2436 AnimatablePropertyComponentRegistration componentTwoAnimatableProperty( customType1, "componentTwoProp", componentTwoPropertyIndex, basePropertyIndex, 2 );
2438 // Check property count before property registration
2439 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2440 DALI_TEST_CHECK( typeInfo );
2441 BaseHandle handle = typeInfo.CreateInstance();
2442 DALI_TEST_CHECK( handle );
2443 Actor customActor = Actor::DownCast( handle );
2444 DALI_TEST_CHECK( customActor );
2445 Stage::GetCurrent().Add(customActor);
2447 tet_infoline( "Get the component values, they should be the default value of the base-property" );
2448 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2449 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2450 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 35.0f, TEST_LOCATION );
2451 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 13.0f, 24.0f, 35.0f ), TEST_LOCATION );
2453 tet_infoline( "Set a component value and ensure it changes for the base property as well" );
2454 customActor.SetProperty( componentZeroPropertyIndex, 125.0f );
2455 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2456 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 24.0f, 35.0f ), TEST_LOCATION );
2458 customActor.SetProperty( componentOnePropertyIndex, 225.0f );
2459 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2460 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 225.0f, 35.0f ), TEST_LOCATION );
2462 customActor.SetProperty( componentTwoPropertyIndex, 325.0f );
2463 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2464 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 225.0f, 325.0f ), TEST_LOCATION );
2466 tet_infoline( "Check latest scene-graph value is unchanged" );
2467 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector3 >( customActor, basePropertyIndex ), Vector3( 13.0f, 24.0f, 35.0f ), TEST_LOCATION );
2468 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2469 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2470 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, componentTwoPropertyIndex ), 35.0f, TEST_LOCATION );
2472 // Render and notify
2473 application.SendNotification();
2474 application.Render();
2476 tet_infoline( "Check values after rendering and both retrieval methods should return the latest" );
2477 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 225.0f, 325.0f ), TEST_LOCATION );
2478 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2479 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2480 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2482 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector3 >( customActor, basePropertyIndex ), Vector3( 125.0f, 225.0f, 325.0f ), TEST_LOCATION );
2483 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2484 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2485 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2487 tet_infoline( "Set the base property value and ensure the component values reflect the change" );
2488 customActor.SetProperty( basePropertyIndex, Vector3( 1.0f, 2.0f, 3.0f ) );
2489 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 1.0f, TEST_LOCATION );
2490 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 2.0f, TEST_LOCATION );
2491 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 3.0f, TEST_LOCATION );
2492 DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 1.0f, 2.0f, 3.0f ), TEST_LOCATION );
2497 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGetWithComponentsVector4(void)
2499 TestApplication application;
2500 TypeRegistry typeRegistry = TypeRegistry::Get();
2502 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" );
2504 // Register the animatable propeties
2505 const int basePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
2506 const int componentZeroPropertyIndex( basePropertyIndex + 1 );
2507 const int componentOnePropertyIndex( componentZeroPropertyIndex + 1 );
2508 const int componentTwoPropertyIndex( componentOnePropertyIndex + 1 );
2509 const int componentThreePropertyIndex( componentTwoPropertyIndex + 1 );
2510 AnimatablePropertyRegistration baseAnimatableProperty( customType1, "baseProp", basePropertyIndex, Vector4( 13.0f, 24.0f, 35.0, 47.0f ) );
2511 AnimatablePropertyComponentRegistration componentZeroAnimatableProperty( customType1, "componentZeroProp", componentZeroPropertyIndex, basePropertyIndex, 0 );
2512 AnimatablePropertyComponentRegistration componentOneAnimatableProperty( customType1, "componentOneProp", componentOnePropertyIndex, basePropertyIndex, 1 );
2513 AnimatablePropertyComponentRegistration componentTwoAnimatableProperty( customType1, "componentTwoProp", componentTwoPropertyIndex, basePropertyIndex, 2 );
2514 AnimatablePropertyComponentRegistration componentThreeAnimatableProperty( customType1, "componentThreeProp", componentThreePropertyIndex, basePropertyIndex, 3 );
2516 // Check property count before property registration
2517 TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2518 DALI_TEST_CHECK( typeInfo );
2519 BaseHandle handle = typeInfo.CreateInstance();
2520 DALI_TEST_CHECK( handle );
2521 Actor customActor = Actor::DownCast( handle );
2522 DALI_TEST_CHECK( customActor );
2523 Stage::GetCurrent().Add(customActor);
2525 tet_infoline( "Get the component values, they should be the default value of the base-property" );
2526 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2527 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2528 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 35.0f, TEST_LOCATION );
2529 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentThreePropertyIndex ), 47.0f, TEST_LOCATION );
2530 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 13.0f, 24.0f, 35.0f, 47.0f ), TEST_LOCATION );
2532 tet_infoline( "Set a component value and ensure it changes for the base property as well" );
2533 customActor.SetProperty( componentZeroPropertyIndex, 125.0f );
2534 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2535 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 24.0f, 35.0f, 47.0f ), TEST_LOCATION );
2537 customActor.SetProperty( componentOnePropertyIndex, 225.0f );
2538 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2539 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 35.0f, 47.0f ), TEST_LOCATION );
2541 customActor.SetProperty( componentTwoPropertyIndex, 325.0f );
2542 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2543 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 325.0f, 47.0f ), TEST_LOCATION );
2545 customActor.SetProperty( componentThreePropertyIndex, 435.0f );
2546 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentThreePropertyIndex ), 435.0f, TEST_LOCATION );
2547 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 325.0f, 435.0f ), TEST_LOCATION );
2549 tet_infoline( "Check latest scene-graph value is unchanged" );
2550 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector4 >( customActor, basePropertyIndex ), Vector4( 13.0f, 24.0f, 35.0f, 47.0f ), TEST_LOCATION );
2551 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2552 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2553 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, componentTwoPropertyIndex ), 35.0f, TEST_LOCATION );
2554 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, componentThreePropertyIndex ), 47.0f, TEST_LOCATION );
2556 // Render and notify
2557 application.SendNotification();
2558 application.Render();
2560 tet_infoline( "Check values after rendering and both retrieval methods should return the latest" );
2561 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 325.0f, 435.0f ), TEST_LOCATION );
2562 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2563 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2564 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2565 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentThreePropertyIndex ), 435.0f, TEST_LOCATION );
2567 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector4 >( customActor, basePropertyIndex ), Vector4( 125.0f, 225.0f, 325.0f, 435.0f ), TEST_LOCATION );
2568 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2569 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2570 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2571 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( customActor, componentThreePropertyIndex ), 435.0f, TEST_LOCATION );
2573 tet_infoline( "Set the base property value and ensure the component values reflect the change" );
2574 customActor.SetProperty( basePropertyIndex, Vector4( 1.0f, 2.0f, 3.0f, 4.0f ) );
2575 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 1.0f, TEST_LOCATION );
2576 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 2.0f, TEST_LOCATION );
2577 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 3.0f, TEST_LOCATION );
2578 DALI_TEST_EQUALS( customActor.GetProperty< float >( componentThreePropertyIndex ), 4.0f, TEST_LOCATION );
2579 DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 1.0f, 2.0f, 3.0f, 4.0f ), TEST_LOCATION );