2 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include <dali-test-suite-utils.h>
19 #include <dali/integration-api/events/hover-event-integ.h>
20 #include <dali/integration-api/events/touch-event-integ.h>
21 #include <dali/internal/event/common/type-info-impl.h>
22 #include <dali/public-api/dali-core.h>
32 // Stores data that is populated in the callback and will be read by the Test cases
36 : functorCalled(false),
37 voidFunctorCalled(false),
45 functorCalled = false;
46 voidFunctorCalled = false;
48 receivedGesture.Reset();
54 bool voidFunctorCalled;
55 LongPressGesture receivedGesture;
59 // Functor that sets the data when called
60 struct GestureReceivedFunctor
62 GestureReceivedFunctor(SignalData& data)
67 void operator()(Actor actor, LongPressGesture longPress)
69 signalData.functorCalled = true;
70 signalData.receivedGesture = longPress;
71 signalData.pressedActor = actor;
76 signalData.voidFunctorCalled = true;
79 SignalData& signalData;
83 // Create function as Init function called
85 static bool CreateCustomInitCalled = false;
86 BaseHandle CreateCustomInit(void)
88 CreateCustomInitCalled = true;
92 static bool CreateCustomNamedInitCalled = false;
93 BaseHandle CreateCustomNamedInit(void)
95 CreateCustomNamedInitCalled = true;
99 const std::string scriptedName("PopupStyle");
100 static TypeRegistration scriptedType(scriptedName, typeid(Dali::CustomActor), CreateCustomNamedInit);
102 // Property Registration
103 bool setPropertyCalled = false;
104 bool getPropertyCalled = false;
105 void SetProperty(BaseObject* object, Property::Index propertyIndex, const Property::Value& value)
107 setPropertyCalled = true;
109 Property::Value GetProperty(BaseObject* object, Property::Index propertyIndex)
111 getPropertyCalled = true;
112 return Property::Value(true);
115 /*******************************************************************************
119 ******************************************************************************/
122 struct MyTestCustomActor : public CustomActorImpl
124 typedef Signal<void()> SignalType;
125 typedef Signal<void(float)> SignalTypeFloat;
128 : CustomActorImpl(ActorFlags())
132 virtual ~MyTestCustomActor()
136 void ResetCallStack()
140 // From CustomActorImpl
141 virtual void OnSceneConnection(int depth)
144 virtual void OnSceneDisconnection()
147 virtual void OnChildAdd(Actor& child)
150 virtual void OnChildRemove(Actor& child)
153 virtual void OnSizeSet(const Vector3& targetSize)
156 virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize)
159 virtual void OnKeyInputFocusGained()
162 virtual void OnKeyInputFocusLost()
165 virtual Vector3 GetNaturalSize()
167 return Vector3(0.0f, 0.0f, 0.0f);
170 virtual float GetHeightForWidth(float width)
175 virtual float GetWidthForHeight(float height)
180 virtual void OnRelayout(const Vector2& size, RelayoutContainer& container)
184 virtual void OnSetResizePolicy(ResizePolicy::Type policy, Dimension::Type dimension)
188 virtual void OnCalculateRelayoutSize(Dimension::Type dimension)
192 virtual float CalculateChildSize(const Dali::Actor& child, Dimension::Type dimension)
197 virtual void OnLayoutNegotiated(float size, Dimension::Type dimension)
201 virtual bool RelayoutDependentOnChildren(Dimension::Type dimension = Dimension::ALL_DIMENSIONS)
212 class MyTestCustomActor : public CustomActor
215 typedef Signal<void()> SignalType;
216 typedef Signal<void(float)> SignalTypeFloat;
222 static MyTestCustomActor New()
224 Impl::MyTestCustomActor* p = new Impl::MyTestCustomActor;
225 return MyTestCustomActor(*p); // takes ownership
228 virtual ~MyTestCustomActor()
232 static MyTestCustomActor DownCast(BaseHandle handle)
234 MyTestCustomActor result;
236 CustomActor custom = Dali::CustomActor::DownCast(handle);
239 CustomActorImpl& customImpl = custom.GetImplementation();
241 Impl::MyTestCustomActor* impl = dynamic_cast<Impl::MyTestCustomActor*>(&customImpl);
245 result = MyTestCustomActor(customImpl.GetOwner());
252 SignalType& GetCustomSignal()
254 Dali::RefObject& obj = GetImplementation();
255 return static_cast<Impl::MyTestCustomActor&>(obj).mSignal;
259 MyTestCustomActor(Internal::CustomActor* internal)
260 : CustomActor(internal)
264 MyTestCustomActor(Impl::MyTestCustomActor& impl)
270 class MyTestCustomActor2 : public CustomActor
277 P1 = Dali::PROPERTY_REGISTRATION_START_INDEX,
286 static MyTestCustomActor2 New()
288 return MyTestCustomActor2(); // takes ownership
291 virtual ~MyTestCustomActor2()
295 static MyTestCustomActor2 DownCast(BaseHandle handle)
297 MyTestCustomActor2 result;
299 CustomActor custom = Dali::CustomActor::DownCast(handle);
302 CustomActorImpl& customImpl = custom.GetImplementation();
304 Impl::MyTestCustomActor* impl = dynamic_cast<Impl::MyTestCustomActor*>(&customImpl);
308 result = MyTestCustomActor2(customImpl.GetOwner());
316 MyTestCustomActor2(Internal::CustomActor* internal)
317 : CustomActor(internal)
321 MyTestCustomActor2(Impl::MyTestCustomActor& impl)
327 static TypeRegistration customTypeInit(typeid(MyTestCustomActor2), typeid(Dali::CustomActor), CreateCustomInit, true);
329 PropertyRegistration P1(customTypeInit, "propertyOne", MyTestCustomActor2::Property::P1, Property::INTEGER, &SetProperty, &GetProperty);
330 PropertyRegistration P2(customTypeInit, "propertyTwo", MyTestCustomActor2::Property::P2, Property::STRING, &SetProperty, &GetProperty);
332 class MyTestCustomActor3 : public CustomActor
339 static MyTestCustomActor3 New()
341 return MyTestCustomActor3(); // takes ownership
344 virtual ~MyTestCustomActor3()
348 static MyTestCustomActor3 DownCast(BaseHandle handle)
350 MyTestCustomActor3 result;
352 CustomActor custom = Dali::CustomActor::DownCast(handle);
355 CustomActorImpl& customImpl = custom.GetImplementation();
357 Impl::MyTestCustomActor* impl = dynamic_cast<Impl::MyTestCustomActor*>(&customImpl);
361 result = MyTestCustomActor3(customImpl.GetOwner());
369 MyTestCustomActor3(Internal::CustomActor* internal)
370 : CustomActor(internal)
374 MyTestCustomActor3(Impl::MyTestCustomActor& impl)
380 static TypeRegistration customTypeBadInit(typeid(MyTestCustomActor3), typeid(Dali::CustomActor), NULL, false);
382 BaseHandle CreateCustom(void)
384 return MyTestCustomActor::New();
387 static std::string lastSignalConnectionCustom;
389 bool DoConnectSignalCustom(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor)
391 lastSignalConnectionCustom = signalName;
393 bool connected(true);
395 Dali::BaseHandle handle(object);
396 MyTestCustomActor customActor = MyTestCustomActor::DownCast(handle);
398 if("sig1" == signalName)
400 customActor.GetCustomSignal().Connect(tracker, functor);
404 // signalName does not match any signal
411 bool DoConnectSignalCustomFailure(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor)
413 lastSignalConnectionCustom = "failed";
415 return false; // This is supposed to fail
418 struct CustomTestFunctor
422 ++mTotalInstanceCount;
423 ++mCurrentInstanceCount;
426 CustomTestFunctor(const CustomTestFunctor& copyMe)
428 ++mTotalInstanceCount;
429 ++mCurrentInstanceCount;
434 --mCurrentInstanceCount;
442 static int mTotalInstanceCount;
443 static int mCurrentInstanceCount;
444 static int mCallbackCount;
447 int CustomTestFunctor::mTotalInstanceCount = 0;
448 int CustomTestFunctor::mCurrentInstanceCount = 0;
449 int CustomTestFunctor::mCallbackCount = 0;
451 static void ResetFunctorCounts()
453 CustomTestFunctor::mTotalInstanceCount = 0;
454 CustomTestFunctor::mCurrentInstanceCount = 0;
455 CustomTestFunctor::mCallbackCount = 0;
458 static std::string lastActionCustom;
459 bool DoActionCustom(BaseObject* object, const std::string& actionName, const Property::Map& /*attributes*/)
461 lastActionCustom = actionName;
465 // Custom type registration
466 static TypeRegistration customType1(typeid(MyTestCustomActor), typeid(Dali::CustomActor), CreateCustom);
469 static SignalConnectorType customSignalConnector1(customType1, "sig1", DoConnectSignalCustom);
470 static SignalConnectorType customSignalConnector2(customType1, "sig2", DoConnectSignalCustomFailure);
471 static const int TEST_SIGNAL_COUNT = 2;
474 static TypeAction customAction1(customType1, "act1", DoActionCustom);
475 static const int TEST_ACTION_COUNT = 1;
477 class TestConnectionTracker : public ConnectionTracker
480 TestConnectionTracker()
485 BaseHandle CreateNamedActorType()
487 Actor actor = Actor::New();
488 actor.SetProperty(Actor::Property::NAME, "NamedActor");
492 TypeRegistration namedActorType("MyNamedActor", typeid(Dali::Actor), CreateNamedActorType);
493 PropertyRegistration namedActorPropertyOne(namedActorType, "propName", PROPERTY_REGISTRATION_START_INDEX, Property::BOOLEAN, &SetProperty, &GetProperty);
495 } // Anonymous namespace
497 // Note: No negative test case for UtcDaliTypeRegistryGet can be implemented.
498 int UtcDaliTypeRegistryGetP(void)
500 TestApplication application;
502 TypeRegistry registry = TypeRegistry::Get();
503 DALI_TEST_CHECK(registry);
508 // Note: No negative test case for UtcDaliTypeRegistryConstructor can be implemented.
509 int UtcDaliTypeRegistryConstructorP(void)
511 TestApplication application;
513 TypeRegistry registry;
514 DALI_TEST_CHECK(!registry);
518 // Note: No negative test case for UtcDaliTypeRegistryCopyConstructor can be implemented.
519 int UtcDaliTypeRegistryCopyConstructorP(void)
521 TestApplication application;
523 TypeRegistry registry = TypeRegistry::Get();
524 DALI_TEST_CHECK(registry);
526 TypeRegistry copy(registry);
527 DALI_TEST_CHECK(copy);
529 DALI_TEST_CHECK(registry.GetTypeInfo("Actor").GetName() == copy.GetTypeInfo("Actor").GetName());
534 // Note: No negative test case for UtcDaliTypeRegistryAssignmentOperator can be implemented.
535 int UtcDaliTypeRegistryAssignmentOperatorP(void)
537 TestApplication application;
539 TypeRegistry registry = TypeRegistry::Get();
540 DALI_TEST_CHECK(registry);
542 TypeRegistry copy = registry;
543 DALI_TEST_CHECK(copy);
544 DALI_TEST_CHECK(registry == copy);
546 DALI_TEST_CHECK(registry.GetTypeInfo("Actor").GetName() == copy.GetTypeInfo("Actor").GetName());
551 int UtcDaliTypeRegistryMoveConstructor(void)
553 TestApplication application;
555 TypeRegistry registry = TypeRegistry::Get();
556 DALI_TEST_CHECK(registry);
557 DALI_TEST_EQUALS(16, registry.GetBaseObject().ReferenceCount(), TEST_LOCATION);
558 DALI_TEST_CHECK(registry.GetTypeInfo("Actor").GetName() == "Actor");
560 TypeRegistry movedRegistry = std::move(registry);
561 DALI_TEST_CHECK(movedRegistry);
562 DALI_TEST_EQUALS(16, movedRegistry.GetBaseObject().ReferenceCount(), TEST_LOCATION);
563 DALI_TEST_CHECK(movedRegistry.GetTypeInfo("Actor").GetName() == "Actor");
564 DALI_TEST_CHECK(!registry);
566 Dali::TypeInfo info = movedRegistry.GetTypeInfo("Actor");
567 DALI_TEST_CHECK(info);
568 DALI_TEST_EQUALS(2, info.GetBaseObject().ReferenceCount(), TEST_LOCATION);
569 DALI_TEST_CHECK(info.GetName() == "Actor");
571 Dali::TypeInfo movedInfo = std::move(info);
572 DALI_TEST_CHECK(movedInfo);
573 DALI_TEST_EQUALS(2, movedInfo.GetBaseObject().ReferenceCount(), TEST_LOCATION);
574 DALI_TEST_CHECK(movedInfo.GetName() == "Actor");
575 DALI_TEST_CHECK(!info);
580 int UtcDaliTypeRegistryMoveAssignment(void)
582 TestApplication application;
584 TypeRegistry registry = TypeRegistry::Get();
585 DALI_TEST_CHECK(registry);
586 DALI_TEST_EQUALS(16, registry.GetBaseObject().ReferenceCount(), TEST_LOCATION);
587 DALI_TEST_CHECK(registry.GetTypeInfo("Actor").GetName() == "Actor");
589 TypeRegistry movedRegistry;
590 movedRegistry = std::move(registry);
591 DALI_TEST_CHECK(movedRegistry);
592 DALI_TEST_EQUALS(16, movedRegistry.GetBaseObject().ReferenceCount(), TEST_LOCATION);
593 DALI_TEST_CHECK(movedRegistry.GetTypeInfo("Actor").GetName() == "Actor");
594 DALI_TEST_CHECK(!registry);
596 Dali::TypeInfo info = movedRegistry.GetTypeInfo("Actor");
597 DALI_TEST_CHECK(info);
598 DALI_TEST_EQUALS(2, info.GetBaseObject().ReferenceCount(), TEST_LOCATION);
599 DALI_TEST_CHECK(info.GetName() == "Actor");
601 Dali::TypeInfo movedInfo;
602 movedInfo = std::move(info);
603 DALI_TEST_CHECK(movedInfo);
604 DALI_TEST_EQUALS(2, movedInfo.GetBaseObject().ReferenceCount(), TEST_LOCATION);
605 DALI_TEST_CHECK(movedInfo.GetName() == "Actor");
606 DALI_TEST_CHECK(!info);
611 int UtcDaliTypeRegistryAssignP(void)
613 TestApplication application;
615 TypeRegistry registry = TypeRegistry::Get();
616 TypeRegistry registry2;
617 registry2 = registry;
618 DALI_TEST_CHECK(registry2);
620 DALI_TEST_CHECK(registry2.GetTypeInfo("Actor").GetName() == registry2.GetTypeInfo("Actor").GetName());
625 int UtcDaliTypeRegistryGetTypeInfoFromTypeNameP(void)
627 TestApplication application;
629 TypeRegistry registry = TypeRegistry::Get();
634 type = registry.GetTypeInfo("CameraActor");
635 DALI_TEST_CHECK(type);
636 CameraActor ca = CameraActor::DownCast(type.CreateInstance());
638 application.GetScene().Add(ca);
639 application.Render();
642 type = registry.GetTypeInfo("Animation");
643 DALI_TEST_CHECK(type);
644 Animation an = Animation::DownCast(type.CreateInstance());
647 application.Render();
652 int UtcDaliTypeRegistryGetTypeInfoFromTypeNameN(void)
654 TestApplication application;
656 TypeRegistry registry = TypeRegistry::Get();
660 type = registry.GetTypeInfo("MyDummyActor");
661 DALI_TEST_CHECK(!type);
666 int UtcDaliTypeRegistryGetTypeInfoFromTypeIdP(void)
668 TypeInfo named_type = TypeRegistry::Get().GetTypeInfo("CameraActor");
669 TypeInfo typeinfo_type = TypeRegistry::Get().GetTypeInfo(typeid(Dali::CameraActor));
671 DALI_TEST_CHECK(named_type);
672 DALI_TEST_CHECK(typeinfo_type);
674 // Check named and typeid are equivalent
675 DALI_TEST_CHECK(named_type == typeinfo_type);
677 DALI_TEST_CHECK(named_type.GetName() == typeinfo_type.GetName());
678 DALI_TEST_CHECK(named_type.GetBaseName() == typeinfo_type.GetBaseName());
683 int UtcDaliTypeRegistryGetTypeInfoFromTypeIdN(void)
685 TestApplication application;
686 TypeRegistry typeRegistry = TypeRegistry::Get();
688 TypeInfo typeInfo = typeRegistry.GetTypeInfo(typeid(Vector2));
689 DALI_TEST_CHECK(!typeInfo);
694 int UtcDaliTypeRegistryGetTypeNameCountP(void)
696 TestApplication application;
697 TypeRegistry typeRegistry = TypeRegistry::Get();
700 for(size_t i = 0; i < typeRegistry.GetTypeNameCount(); i++)
702 type = typeRegistry.GetTypeInfo(typeRegistry.GetTypeName(i));
703 DALI_TEST_CHECK(type);
709 int UtcDaliTypeRegistryGetTypeNamesP(void)
711 TestApplication application;
712 TypeRegistry typeRegistry = TypeRegistry::Get();
715 for(size_t i = 0; i < typeRegistry.GetTypeNameCount(); i++)
717 type = typeRegistry.GetTypeInfo(typeRegistry.GetTypeName(i));
718 DALI_TEST_CHECK(type);
724 // Note: No negative test case for UtcDaliTypeRegistryTypeRegistration can be implemented.
725 int UtcDaliTypeRegistryTypeRegistrationNotCallingCreateOnInitP(void)
727 ResetFunctorCounts();
729 TestApplication application;
731 TypeInfo type = TypeRegistry::Get().GetTypeInfo("MyTestCustomActor");
732 DALI_TEST_CHECK(type);
734 TypeInfo baseType = TypeRegistry::Get().GetTypeInfo("CustomActor");
735 DALI_TEST_CHECK(baseType);
737 BaseHandle handle = type.CreateInstance();
738 DALI_TEST_CHECK(handle);
740 MyTestCustomActor customHandle = MyTestCustomActor::DownCast(handle);
741 DALI_TEST_CHECK(customHandle);
743 DALI_TEST_EQUALS(type.GetActionCount(), TEST_ACTION_COUNT + baseType.GetActionCount(), TEST_LOCATION);
745 DALI_TEST_EQUALS(type.GetSignalCount(), TEST_SIGNAL_COUNT + baseType.GetSignalCount(), TEST_LOCATION);
748 TestConnectionTracker tracker;
750 bool connected = handle.ConnectSignal(&tracker, "sig1", CustomTestFunctor());
751 DALI_TEST_EQUALS(connected, true, TEST_LOCATION);
752 DALI_TEST_CHECK(lastSignalConnectionCustom == "sig1");
753 DALI_TEST_EQUALS(CustomTestFunctor::mTotalInstanceCount, 2 /*temporary copy + FunctorDelegate copy*/, TEST_LOCATION);
754 DALI_TEST_EQUALS(CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION);
756 DALI_TEST_EQUALS(CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION);
757 customHandle.GetCustomSignal().Emit();
758 DALI_TEST_EQUALS(CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION);
759 DALI_TEST_EQUALS(CustomTestFunctor::mTotalInstanceCount, 2 /*temporary copy + FunctorDelegate copy*/, TEST_LOCATION);
760 DALI_TEST_EQUALS(CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION);
762 // tracker should automatically disconnect here
763 DALI_TEST_EQUALS(CustomTestFunctor::mTotalInstanceCount, 2 /*temporary copy + FunctorDelegate copy*/, TEST_LOCATION);
764 DALI_TEST_EQUALS(CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION);
766 // Test that functor is disconnected
767 DALI_TEST_EQUALS(CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION);
768 customHandle.GetCustomSignal().Emit();
769 DALI_TEST_EQUALS(CustomTestFunctor::mCallbackCount, 1 /*not incremented*/, TEST_LOCATION);
770 DALI_TEST_EQUALS(CustomTestFunctor::mTotalInstanceCount, 2 /*temporary copy + FunctorDelegate copy*/, TEST_LOCATION);
771 DALI_TEST_EQUALS(CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION);
773 Property::Map attributes;
774 handle.DoAction("act1", attributes);
775 DALI_TEST_CHECK(lastActionCustom == "act1");
779 // Note: No negative test case for UtcDaliTypeRegistryTypeRegistration can be implemented.
780 int UtcDaliTypeRegistryTypeRegistrationCallingCreateOnInitP(void)
782 TestApplication application;
784 DALI_TEST_CHECK("MyTestCustomActor2" == customTypeInit.RegisteredName());
786 DALI_TEST_CHECK(true == CreateCustomInitCalled);
787 TypeInfo type = TypeRegistry::Get().GetTypeInfo("MyTestCustomActor2");
788 DALI_TEST_CHECK(type);
792 // Note: No negative test case for UtcDaliTypeRegistryTypeRegistration can be implemented.
793 int UtcDaliTypeRegistryTypeRegistrationForNamedTypeP(void)
795 TestApplication application;
797 // Create Named Actor Type
798 TypeInfo type = TypeRegistry::Get().GetTypeInfo("MyNamedActor");
799 DALI_TEST_CHECK(type);
801 BaseHandle namedHandle = type.CreateInstance();
802 DALI_TEST_CHECK(namedHandle);
803 Actor namedActor(Actor::DownCast(namedHandle));
804 DALI_TEST_CHECK(namedActor);
806 DALI_TEST_CHECK(namedActor.GetProperty<std::string>(Actor::Property::NAME) == "NamedActor");
807 DALI_TEST_CHECK(type.GetName() == "MyNamedActor");
808 DALI_TEST_CHECK(type.GetBaseName() == "Actor");
813 int UtcDaliTypeRegistryRegisteredNameP(void)
815 TestApplication application;
817 DALI_TEST_CHECK(scriptedName == scriptedType.RegisteredName());
819 TypeInfo baseType = TypeRegistry::Get().GetTypeInfo(scriptedName);
820 DALI_TEST_CHECK(baseType);
822 BaseHandle handle = baseType.CreateInstance();
824 DALI_TEST_CHECK(true == CreateCustomNamedInitCalled);
825 TypeInfo type = TypeRegistry::Get().GetTypeInfo(scriptedName);
826 DALI_TEST_CHECK(type);
830 int UtcDaliTypeRegistryRegisteredNameN(void)
832 TestApplication application;
834 DALI_TEST_CHECK(scriptedName == scriptedType.RegisteredName());
836 TypeInfo baseType = TypeRegistry::Get().GetTypeInfo(scriptedName);
837 DALI_TEST_CHECK(baseType);
839 // should cause an assert because we're registering same type twice
840 // once statically at the start of this file, then again now
843 TypeRegistration scriptedType(scriptedName, typeid(Dali::CustomActor), CreateCustomNamedInit);
844 tet_result(TET_FAIL);
846 catch(DaliException& e)
848 DALI_TEST_ASSERT(e, "Duplicate type name in Type Registration", TEST_LOCATION);
854 int UtcDaliTypeRegistrySignalConnectorTypeP(void)
856 ResetFunctorCounts();
858 TestApplication application;
860 TypeInfo type = TypeRegistry::Get().GetTypeInfo("MyTestCustomActor");
861 DALI_TEST_CHECK(type);
863 BaseHandle handle = type.CreateInstance();
864 DALI_TEST_CHECK(handle);
866 MyTestCustomActor customHandle = MyTestCustomActor::DownCast(handle);
867 DALI_TEST_CHECK(customHandle);
870 TestConnectionTracker tracker;
872 bool connected = handle.ConnectSignal(&tracker, "sig1", CustomTestFunctor());
873 DALI_TEST_EQUALS(connected, true, TEST_LOCATION);
874 DALI_TEST_CHECK(lastSignalConnectionCustom == "sig1");
875 DALI_TEST_EQUALS(CustomTestFunctor::mTotalInstanceCount, 2 /*temporary copy + FunctorDelegate copy*/, TEST_LOCATION);
876 DALI_TEST_EQUALS(CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION);
878 DALI_TEST_EQUALS(CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION);
879 customHandle.GetCustomSignal().Emit();
880 DALI_TEST_EQUALS(CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION);
881 DALI_TEST_EQUALS(CustomTestFunctor::mTotalInstanceCount, 2 /*temporary copy + FunctorDelegate copy*/, TEST_LOCATION);
882 DALI_TEST_EQUALS(CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION);
884 // tracker should automatically disconnect here
885 DALI_TEST_EQUALS(CustomTestFunctor::mTotalInstanceCount, 2 /*temporary copy + FunctorDelegate copy*/, TEST_LOCATION);
886 DALI_TEST_EQUALS(CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION);
888 // Test that functor is disconnected
889 DALI_TEST_EQUALS(CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION);
890 customHandle.GetCustomSignal().Emit();
891 DALI_TEST_EQUALS(CustomTestFunctor::mCallbackCount, 1 /*not incremented*/, TEST_LOCATION);
892 DALI_TEST_EQUALS(CustomTestFunctor::mTotalInstanceCount, 2 /*temporary copy + FunctorDelegate copy*/, TEST_LOCATION);
893 DALI_TEST_EQUALS(CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION);
898 int UtcDaliTypeRegistrySignalConnectorTypeN(void)
900 // Test what happens when signal connnector (DoConnectSignalFailure method) returns false
902 ResetFunctorCounts();
904 TestApplication application;
906 TypeInfo type = TypeRegistry::Get().GetTypeInfo("MyTestCustomActor");
907 DALI_TEST_CHECK(type);
909 TypeInfo baseType = TypeRegistry::Get().GetTypeInfo("CustomActor");
910 DALI_TEST_CHECK(baseType);
912 BaseHandle handle = type.CreateInstance();
913 DALI_TEST_CHECK(handle);
915 MyTestCustomActor customHandle = MyTestCustomActor::DownCast(handle);
916 DALI_TEST_CHECK(customHandle);
918 DALI_TEST_EQUALS(type.GetActionCount(), TEST_ACTION_COUNT + baseType.GetActionCount(), TEST_LOCATION);
920 DALI_TEST_EQUALS(type.GetSignalCount(), TEST_SIGNAL_COUNT + baseType.GetSignalCount(), TEST_LOCATION);
923 TestConnectionTracker tracker;
925 bool connected = handle.ConnectSignal(&tracker, "sig2", CustomTestFunctor());
926 DALI_TEST_EQUALS(connected, false /*This is supposed to fail*/, TEST_LOCATION);
927 DALI_TEST_CHECK(lastSignalConnectionCustom == "failed");
928 DALI_TEST_EQUALS(CustomTestFunctor::mTotalInstanceCount, 2 /*temporary copy + FunctorDelegate copy*/, TEST_LOCATION);
929 DALI_TEST_EQUALS(CustomTestFunctor::mCurrentInstanceCount, 0 /*deleted along with FunctorDelegate*/, TEST_LOCATION);
932 DALI_TEST_EQUALS(CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION);
933 customHandle.GetCustomSignal().Emit();
934 DALI_TEST_EQUALS(CustomTestFunctor::mCallbackCount, 0 /*never called*/, TEST_LOCATION);
936 // tracker should have nothing to disconnect here
939 DALI_TEST_EQUALS(CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION);
940 customHandle.GetCustomSignal().Emit();
941 DALI_TEST_EQUALS(CustomTestFunctor::mCallbackCount, 0 /*never called*/, TEST_LOCATION);
945 int UtcDaliTypeRegistryTypeActionP(void)
947 ResetFunctorCounts();
949 TestApplication application;
951 TypeInfo type = TypeRegistry::Get().GetTypeInfo("MyTestCustomActor");
952 DALI_TEST_CHECK(type);
954 BaseHandle handle = type.CreateInstance();
955 DALI_TEST_CHECK(handle);
957 Property::Map attributes;
958 DALI_TEST_CHECK(handle.DoAction("act1", attributes));
959 DALI_TEST_CHECK(lastActionCustom == "act1");
964 int UtcDaliTypeRegistryTypeActionN(void)
966 ResetFunctorCounts();
968 TestApplication application;
970 TypeInfo type = TypeRegistry::Get().GetTypeInfo("MyTestCustomActor");
971 DALI_TEST_CHECK(type);
973 BaseHandle handle = type.CreateInstance();
974 DALI_TEST_CHECK(handle);
976 Property::Map attributes;
977 DALI_TEST_CHECK(!handle.DoAction("unknownAction", attributes));
982 int UtcDaliTypeRegistryPropertyRegistrationP(void)
984 TestApplication application;
985 TypeRegistry typeRegistry = TypeRegistry::Get();
987 // Check property count before property registration
988 TypeInfo typeInfo = typeRegistry.GetTypeInfo(typeid(MyTestCustomActor));
989 DALI_TEST_CHECK(typeInfo);
990 BaseHandle handle = typeInfo.CreateInstance();
991 DALI_TEST_CHECK(handle);
992 Actor customActor = Actor::DownCast(handle);
993 DALI_TEST_CHECK(customActor);
994 unsigned int initialPropertyCount(customActor.GetPropertyCount());
996 std::string propertyName("prop1");
997 int propertyIndex(PROPERTY_REGISTRATION_START_INDEX);
998 Property::Type propertyType(Property::BOOLEAN);
999 PropertyRegistration property1(customType1, propertyName, propertyIndex, propertyType, &SetProperty, &GetProperty);
1001 // Check property count after registration
1002 unsigned int postRegistrationPropertyCount(customActor.GetPropertyCount());
1003 DALI_TEST_EQUALS(initialPropertyCount + 1u, postRegistrationPropertyCount, TEST_LOCATION);
1005 // Add custom property and check property count
1006 customActor.RegisterProperty("customProp1", true);
1007 unsigned int customPropertyCount(customActor.GetPropertyCount());
1008 DALI_TEST_EQUALS(postRegistrationPropertyCount + 1u, customPropertyCount, TEST_LOCATION);
1010 // Set the property, ensure SetProperty called
1011 DALI_TEST_CHECK(!setPropertyCalled);
1012 customActor.SetProperty(propertyIndex, false);
1013 DALI_TEST_CHECK(setPropertyCalled);
1015 // Get the property, ensure GetProperty called
1016 DALI_TEST_CHECK(!getPropertyCalled);
1017 (void)customActor.GetProperty<bool>(propertyIndex);
1018 DALI_TEST_CHECK(getPropertyCalled);
1020 // Get the property using GetCurrentProperty and ensure GetProperty is called
1021 getPropertyCalled = false;
1022 DALI_TEST_CHECK(!getPropertyCalled);
1023 customActor.GetCurrentProperty<bool>(propertyIndex);
1024 DALI_TEST_CHECK(getPropertyCalled);
1026 // Check the property name
1027 DALI_TEST_EQUALS(customActor.GetPropertyName(propertyIndex), propertyName, TEST_LOCATION);
1028 DALI_TEST_EQUALS(typeInfo.GetPropertyName(propertyIndex), propertyName, TEST_LOCATION);
1030 // Check the property index
1031 DALI_TEST_EQUALS(customActor.GetPropertyIndex(propertyName), propertyIndex, TEST_LOCATION);
1033 // Check the property type
1034 DALI_TEST_EQUALS(customActor.GetPropertyType(propertyIndex), propertyType, TEST_LOCATION);
1036 // Check property count of type-info is 1
1037 Property::IndexContainer indices;
1038 typeInfo.GetPropertyIndices(indices);
1040 size_t typePropertyCount = typeInfo.GetPropertyCount();
1041 DALI_TEST_EQUALS(indices.Size(), Actor::New().GetPropertyCount() + 1u, TEST_LOCATION);
1042 DALI_TEST_EQUALS(indices.Size(), typePropertyCount, TEST_LOCATION);
1044 // Ensure indices returned from actor and customActor differ by two
1045 Actor actor = Actor::New();
1046 actor.GetPropertyIndices(indices);
1047 unsigned int actorIndices = indices.Size();
1048 customActor.GetPropertyIndices(indices);
1049 unsigned int customActorIndices = indices.Size();
1050 DALI_TEST_EQUALS(actorIndices + 2u, customActorIndices, TEST_LOCATION); // Custom property + registered property
1054 int UtcDaliTypeRegistryPropertyRegistrationN(void)
1056 TestApplication application;
1057 TypeRegistry typeRegistry = TypeRegistry::Get();
1059 // Attempt to register a property type out-of-bounds index (less than)
1062 PropertyRegistration property1(customType1, "propName", PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN, &SetProperty, &GetProperty);
1063 tet_result(TET_FAIL);
1065 catch(DaliException& e)
1067 DALI_TEST_ASSERT(e, "(index >= PROPERTY_REGISTRATION_START_INDEX) && (index <= PROPERTY_REGISTRATION_MAX_INDEX)", TEST_LOCATION);
1070 // Attempt to register a property type out-of-bounds index (greater than)
1073 PropertyRegistration property1(customType1, "propName", PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN, &SetProperty, &GetProperty);
1074 tet_result(TET_FAIL);
1076 catch(DaliException& e)
1078 DALI_TEST_ASSERT(e, "(index >= PROPERTY_REGISTRATION_START_INDEX) && (index <= PROPERTY_REGISTRATION_MAX_INDEX)", TEST_LOCATION);
1084 int UtcDaliTypeRegistryAnimatablePropertyRegistrationP(void)
1086 TestApplication application;
1087 TypeRegistry typeRegistry = TypeRegistry::Get();
1089 // Check property count before property registration
1090 TypeInfo typeInfo = typeRegistry.GetTypeInfo(typeid(MyTestCustomActor));
1091 DALI_TEST_CHECK(typeInfo);
1092 BaseHandle handle = typeInfo.CreateInstance();
1093 DALI_TEST_CHECK(handle);
1094 Actor customActor = Actor::DownCast(handle);
1095 DALI_TEST_CHECK(customActor);
1096 application.GetScene().Add(customActor);
1098 unsigned int customPropertyCount(customActor.GetPropertyCount());
1100 // Register animatable property
1101 std::string animatablePropertyName("animatableProp1");
1102 int animatablePropertyIndex(ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX);
1103 Property::Type animatablePropertyType(Property::FLOAT);
1104 AnimatablePropertyRegistration animatableProperty(customType1, animatablePropertyName, animatablePropertyIndex, animatablePropertyType);
1106 // Check property count after registration
1107 DALI_TEST_EQUALS(customPropertyCount + 1u, customActor.GetPropertyCount(), TEST_LOCATION);
1109 // Set the animatable property value
1110 customActor.SetProperty(animatablePropertyIndex, 25.0f);
1112 // Render and notify
1113 application.SendNotification();
1114 application.Render();
1116 // Check the animatable property value
1117 DALI_TEST_EQUALS(customActor.GetProperty<float>(animatablePropertyIndex), 25.f, TEST_LOCATION);
1119 // Check the animatable property name
1120 DALI_TEST_EQUALS(customActor.GetPropertyName(animatablePropertyIndex), animatablePropertyName, TEST_LOCATION);
1122 // Check the animatable property index
1123 DALI_TEST_EQUALS(customActor.GetPropertyIndex(animatablePropertyName), animatablePropertyIndex, TEST_LOCATION);
1125 // Check the animatable property type
1126 DALI_TEST_EQUALS(customActor.GetPropertyType(animatablePropertyIndex), animatablePropertyType, TEST_LOCATION);
1128 // Check property count of type-info is 1
1129 Property::IndexContainer indices;
1130 typeInfo.GetPropertyIndices(indices);
1131 DALI_TEST_EQUALS(indices.Size(), customActor.GetPropertyCount(), TEST_LOCATION);
1133 // Ensure indices returned from actor and customActor differ by one
1134 Actor actor = Actor::New();
1135 actor.GetPropertyIndices(indices);
1136 unsigned int actorIndices = indices.Size();
1137 customActor.GetPropertyIndices(indices);
1138 unsigned int customActorIndices = indices.Size();
1139 DALI_TEST_EQUALS(actorIndices + 1u, customActorIndices, TEST_LOCATION); // Custom property + registered property
1141 // check that the property is animatable
1142 Animation animation = Animation::New(0.2f);
1143 animation.AnimateTo(Property(customActor, animatablePropertyIndex), 15.f, AlphaFunction::LINEAR);
1146 // Target value should change straight away
1147 DALI_TEST_EQUALS(customActor.GetProperty<float>(animatablePropertyIndex), 15.0f, TEST_LOCATION);
1149 // Render and notify, animation play for 0.05 seconds
1150 application.SendNotification();
1151 application.Render(50);
1152 DALI_TEST_EQUALS(0.25f, animation.GetCurrentProgress(), TEST_LOCATION);
1153 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(animatablePropertyIndex), 22.5f, TEST_LOCATION);
1155 // Render and notify, animation play for another 0.1 seconds
1156 application.SendNotification();
1157 application.Render(100);
1158 DALI_TEST_EQUALS(0.75f, animation.GetCurrentProgress(), TEST_LOCATION);
1159 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(animatablePropertyIndex), 17.5f, TEST_LOCATION);
1164 int UtcDaliTypeRegistryAnimatablePropertyRegistrationN(void)
1166 TestApplication application;
1167 TypeRegistry typeRegistry = TypeRegistry::Get();
1169 // Attempt to register an animatable property type out-of-bounds index (less than)
1172 AnimatablePropertyRegistration property1(customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN);
1173 tet_result(TET_FAIL);
1175 catch(DaliException& e)
1177 DALI_TEST_ASSERT(e, "(index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX) && (index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX)", TEST_LOCATION);
1180 // Attempt to register an animatable property type out-of-bounds index (greater than)
1183 AnimatablePropertyRegistration property1(customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN);
1184 tet_result(TET_FAIL);
1186 catch(DaliException& e)
1188 DALI_TEST_ASSERT(e, "(index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX) && (index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX)", TEST_LOCATION);
1194 int UtcDaliTypeRegistryAnimatablePropertyRegistrationWithDefaultP(void)
1196 TestApplication application;
1197 TypeRegistry typeRegistry = TypeRegistry::Get();
1199 // Check property count before property registration
1200 TypeInfo typeInfo = typeRegistry.GetTypeInfo(typeid(MyTestCustomActor));
1201 DALI_TEST_CHECK(typeInfo);
1202 BaseHandle handle = typeInfo.CreateInstance();
1203 DALI_TEST_CHECK(handle);
1204 Actor customActor = Actor::DownCast(handle);
1205 DALI_TEST_CHECK(customActor);
1206 application.GetScene().Add(customActor);
1208 unsigned int customPropertyCount(customActor.GetPropertyCount());
1210 // Register animatable property
1211 std::string animatablePropertyName("animatableProp1");
1212 int animatablePropertyIndex(ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX);
1213 AnimatablePropertyRegistration animatableProperty1(customType1, animatablePropertyName, animatablePropertyIndex, 10.f);
1215 // Check property count after registration
1216 DALI_TEST_EQUALS(customPropertyCount + 1u, customActor.GetPropertyCount(), TEST_LOCATION);
1218 // Render and notify
1219 application.SendNotification();
1220 application.Render();
1222 // Check the animatable property value
1223 DALI_TEST_EQUALS(customActor.GetProperty<float>(animatablePropertyIndex), 10.f, TEST_LOCATION);
1225 // Check the animatable property name
1226 DALI_TEST_EQUALS(customActor.GetPropertyName(animatablePropertyIndex), animatablePropertyName, TEST_LOCATION);
1228 // Check the animatable property index
1229 DALI_TEST_EQUALS(customActor.GetPropertyIndex(animatablePropertyName), animatablePropertyIndex, TEST_LOCATION);
1231 // Check the animatable property type
1232 DALI_TEST_EQUALS(customActor.GetPropertyType(animatablePropertyIndex), Property::FLOAT, TEST_LOCATION);
1234 // Check property count of type-info
1235 Property::IndexContainer indices;
1236 typeInfo.GetPropertyIndices(indices);
1237 DALI_TEST_EQUALS(indices.Size(), customActor.GetPropertyCount(), TEST_LOCATION);
1239 // Ensure indices returned from actor and customActor differ by one
1240 Actor actor = Actor::New();
1241 actor.GetPropertyIndices(indices);
1242 unsigned int actorIndices = indices.Size();
1243 customActor.GetPropertyIndices(indices);
1244 unsigned int customActorIndices = indices.Size();
1245 DALI_TEST_EQUALS(actorIndices + 1u, customActorIndices, TEST_LOCATION); // Custom property + registered property
1247 // check that the property is animatable
1248 Animation animation = Animation::New(0.2f);
1249 animation.AnimateTo(Property(customActor, animatablePropertyIndex), 20.f, AlphaFunction::LINEAR);
1252 // Target value should change straight away
1253 DALI_TEST_EQUALS(customActor.GetProperty<float>(animatablePropertyIndex), 20.0f, TEST_LOCATION);
1255 // Render and notify, animation play for 0.05 seconds
1256 application.SendNotification();
1257 application.Render(50);
1258 DALI_TEST_EQUALS(0.25f, animation.GetCurrentProgress(), TEST_LOCATION);
1259 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(animatablePropertyIndex), 12.5f, TEST_LOCATION);
1261 // Render and notify, animation play for another 0.1 seconds
1262 application.SendNotification();
1263 application.Render(100);
1264 DALI_TEST_EQUALS(0.75f, animation.GetCurrentProgress(), TEST_LOCATION);
1265 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(animatablePropertyIndex), 17.5f, TEST_LOCATION);
1270 int UtcDaliTypeRegistryAnimatablePropertyRegistrationWithDefaultN(void)
1272 TestApplication application;
1273 TypeRegistry typeRegistry = TypeRegistry::Get();
1275 // Attempt to register an animatable property type out-of-bounds index (less than)
1278 AnimatablePropertyRegistration property1(customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX - 1, false);
1279 tet_result(TET_FAIL);
1281 catch(DaliException& e)
1283 DALI_TEST_ASSERT(e, "(index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX) && (index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX)", TEST_LOCATION);
1286 // Attempt to register an animatable property type out-of-bounds index (greater than)
1289 AnimatablePropertyRegistration property1(customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX + 1, true);
1290 tet_result(TET_FAIL);
1292 catch(DaliException& e)
1294 DALI_TEST_ASSERT(e, "(index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX) && (index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX)", TEST_LOCATION);
1300 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationP(void)
1302 TestApplication application;
1303 TypeRegistry typeRegistry = TypeRegistry::Get();
1305 // Check property count before property registration
1306 TypeInfo typeInfo = typeRegistry.GetTypeInfo(typeid(MyTestCustomActor));
1307 DALI_TEST_CHECK(typeInfo);
1308 BaseHandle handle = typeInfo.CreateInstance();
1309 DALI_TEST_CHECK(handle);
1310 Actor customActor = Actor::DownCast(handle);
1311 DALI_TEST_CHECK(customActor);
1313 unsigned int customPropertyCount(customActor.GetPropertyCount());
1315 // Register animatable property
1316 std::string animatablePropertyName("animatableProp1");
1317 int animatablePropertyIndex(ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX);
1318 Property::Type animatablePropertyType(Property::VECTOR2);
1319 AnimatablePropertyRegistration animatableProperty1(customType1, animatablePropertyName, animatablePropertyIndex, animatablePropertyType);
1321 // Check property count after registration
1322 DALI_TEST_EQUALS(customPropertyCount + 1u, customActor.GetPropertyCount(), TEST_LOCATION);
1324 // Set the animatable property value
1325 customActor.SetProperty(animatablePropertyIndex, Vector2(25.0f, 50.0f));
1327 // Render and notify
1328 application.SendNotification();
1329 application.Render();
1331 // Check the animatable property value
1332 DALI_TEST_EQUALS(customActor.GetProperty<Vector2>(animatablePropertyIndex), Vector2(25.0f, 50.0f), TEST_LOCATION);
1334 // Check the animatable property name
1335 DALI_TEST_EQUALS(customActor.GetPropertyName(animatablePropertyIndex), animatablePropertyName, TEST_LOCATION);
1337 // Check the animatable property index
1338 DALI_TEST_EQUALS(customActor.GetPropertyIndex(animatablePropertyName), animatablePropertyIndex, TEST_LOCATION);
1340 // Check the animatable property type
1341 DALI_TEST_EQUALS(customActor.GetPropertyType(animatablePropertyIndex), animatablePropertyType, TEST_LOCATION);
1343 // Check property count of type-info
1344 Property::IndexContainer indices;
1345 typeInfo.GetPropertyIndices(indices);
1346 DALI_TEST_EQUALS(indices.Size(), customActor.GetPropertyCount(), TEST_LOCATION);
1348 // Register animatable property components
1349 std::string animatablePropertyComponentName1("animatableProp1X");
1350 int animatablePropertyComponentIndex1(ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1);
1351 AnimatablePropertyComponentRegistration animatablePropertyComponent1(customType1, animatablePropertyComponentName1, animatablePropertyComponentIndex1, animatablePropertyIndex, 0);
1353 std::string animatablePropertyComponentName2("animatableProp1Y");
1354 int animatablePropertyComponentIndex2(ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2);
1355 AnimatablePropertyComponentRegistration animatablePropertyComponent2(customType1, animatablePropertyComponentName2, animatablePropertyComponentIndex2, animatablePropertyIndex, 1);
1357 // Check property count after registration
1358 DALI_TEST_EQUALS(customPropertyCount + 3u, customActor.GetPropertyCount(), TEST_LOCATION);
1360 // Check the animatable property component value
1361 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(animatablePropertyComponentIndex1), 25.0f, TEST_LOCATION);
1362 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(animatablePropertyComponentIndex2), 50.0f, TEST_LOCATION);
1364 // Set the animatable property component value
1365 customActor.SetProperty(animatablePropertyComponentIndex1, 150.0f);
1367 // Render and notify
1368 application.SendNotification();
1369 application.Render();
1371 // Check the animatable property value
1372 DALI_TEST_EQUALS(customActor.GetCurrentProperty<Vector2>(animatablePropertyIndex), Vector2(150.0f, 50.0f), TEST_LOCATION);
1373 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(animatablePropertyComponentIndex1), 150.0f, TEST_LOCATION);
1374 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(animatablePropertyComponentIndex2), 50.0f, TEST_LOCATION);
1376 // Set the animatable property component value
1377 customActor.SetProperty(animatablePropertyComponentIndex2, 225.0f);
1379 // Render and notify
1380 application.SendNotification();
1381 application.Render();
1383 // Check the animatable property value
1384 DALI_TEST_EQUALS(customActor.GetCurrentProperty<Vector2>(animatablePropertyIndex), Vector2(150.0f, 225.0f), TEST_LOCATION);
1385 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(animatablePropertyComponentIndex1), 150.0f, TEST_LOCATION);
1386 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(animatablePropertyComponentIndex2), 225.0f, TEST_LOCATION);
1388 // Ensure indices returned from actor and customActor differ by three
1389 Actor actor = Actor::New();
1390 actor.GetPropertyIndices(indices);
1391 unsigned int actorIndices = indices.Size();
1392 customActor.GetPropertyIndices(indices);
1393 unsigned int customActorIndices = indices.Size();
1394 DALI_TEST_EQUALS(actorIndices + 3u, customActorIndices, TEST_LOCATION); // Custom property + registered property
1396 application.GetScene().Add(customActor);
1398 // Attempt to animate component property, it should not crash
1399 Animation animation = Animation::New(1.0f);
1400 animation.AnimateTo(Property(customActor, animatablePropertyComponentIndex1), 200.0f);
1403 // Check the property value
1404 DALI_TEST_EQUALS(customActor.GetProperty<Vector2>(animatablePropertyIndex), Vector2(200.0f, 225.0f), TEST_LOCATION);
1405 DALI_TEST_EQUALS(customActor.GetProperty<float>(animatablePropertyComponentIndex1), 200.0f, TEST_LOCATION);
1406 DALI_TEST_EQUALS(customActor.GetProperty<float>(animatablePropertyComponentIndex2), 225.0f, TEST_LOCATION);
1411 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationVector2AnimateByP(void)
1413 TestApplication application;
1414 TypeRegistry typeRegistry = TypeRegistry::Get();
1416 TypeInfo typeInfo = typeRegistry.GetTypeInfo(typeid(MyTestCustomActor));
1417 DALI_TEST_CHECK(typeInfo);
1418 BaseHandle handle = typeInfo.CreateInstance();
1419 DALI_TEST_CHECK(handle);
1420 Actor customActor = Actor::DownCast(handle);
1421 application.GetScene().Add(customActor);
1422 DALI_TEST_CHECK(customActor);
1424 const unsigned int index = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX;
1425 const unsigned int xComponentIndex = index + 1;
1426 const unsigned int yComponentIndex = index + 2;
1427 const Vector2 initialValue(20.0f, 40.0f);
1429 // Register animatable property & its components
1430 AnimatablePropertyRegistration animatableProperty1(customType1, "animatableProp1", index, initialValue);
1431 AnimatablePropertyComponentRegistration animatablePropertyComponent1(customType1, "animatableProp1X", xComponentIndex, index, 0);
1432 AnimatablePropertyComponentRegistration animatablePropertyComponent2(customType1, "animatableProp1Y", yComponentIndex, index, 1);
1434 // Check the animatable property value
1435 DALI_TEST_EQUALS(customActor.GetProperty<Vector2>(index), initialValue, TEST_LOCATION);
1436 DALI_TEST_EQUALS(customActor.GetProperty<float>(xComponentIndex), initialValue.x, TEST_LOCATION);
1437 DALI_TEST_EQUALS(customActor.GetProperty<float>(yComponentIndex), initialValue.y, TEST_LOCATION);
1439 // Render and notify
1440 application.SendNotification();
1441 application.Render();
1443 // Check the animatable property current value
1444 DALI_TEST_EQUALS(customActor.GetCurrentProperty<Vector2>(index), initialValue, TEST_LOCATION);
1445 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(xComponentIndex), initialValue.x, TEST_LOCATION);
1446 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(yComponentIndex), initialValue.y, TEST_LOCATION);
1449 const Vector2 targetValue(45.0f, 53.0f);
1450 const Vector2 relativeValue(targetValue - initialValue);
1452 Animation animation = Animation::New(1.0f);
1453 animation.AnimateBy(Property(customActor, xComponentIndex), relativeValue.x);
1454 animation.AnimateBy(Property(customActor, yComponentIndex), relativeValue.y);
1457 // Target values should change straight away
1458 DALI_TEST_EQUALS(customActor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION);
1459 DALI_TEST_EQUALS(customActor.GetProperty<float>(xComponentIndex), targetValue.x, TEST_LOCATION);
1460 DALI_TEST_EQUALS(customActor.GetProperty<float>(yComponentIndex), targetValue.y, TEST_LOCATION);
1465 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationVector3AnimateByP(void)
1467 TestApplication application;
1468 TypeRegistry typeRegistry = TypeRegistry::Get();
1470 TypeInfo typeInfo = typeRegistry.GetTypeInfo(typeid(MyTestCustomActor));
1471 DALI_TEST_CHECK(typeInfo);
1472 BaseHandle handle = typeInfo.CreateInstance();
1473 DALI_TEST_CHECK(handle);
1474 Actor customActor = Actor::DownCast(handle);
1475 application.GetScene().Add(customActor);
1476 DALI_TEST_CHECK(customActor);
1478 const unsigned int index = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX;
1479 const unsigned int xComponentIndex = index + 1;
1480 const unsigned int yComponentIndex = index + 2;
1481 const unsigned int zComponentIndex = index + 3;
1482 const Vector3 initialValue(20.0f, 40.0f, 50.0f);
1484 // Register animatable property & its components
1485 AnimatablePropertyRegistration animatableProperty1(customType1, "animatableProp1", index, initialValue);
1486 AnimatablePropertyComponentRegistration animatablePropertyComponent1(customType1, "animatableProp1X", xComponentIndex, index, 0);
1487 AnimatablePropertyComponentRegistration animatablePropertyComponent2(customType1, "animatableProp1Y", yComponentIndex, index, 1);
1488 AnimatablePropertyComponentRegistration animatablePropertyComponent3(customType1, "animatableProp1Z", zComponentIndex, index, 2);
1490 // Check the animatable property value
1491 DALI_TEST_EQUALS(customActor.GetProperty<Vector3>(index), initialValue, TEST_LOCATION);
1492 DALI_TEST_EQUALS(customActor.GetProperty<float>(xComponentIndex), initialValue.x, TEST_LOCATION);
1493 DALI_TEST_EQUALS(customActor.GetProperty<float>(yComponentIndex), initialValue.y, TEST_LOCATION);
1494 DALI_TEST_EQUALS(customActor.GetProperty<float>(zComponentIndex), initialValue.z, TEST_LOCATION);
1496 // Render and notify
1497 application.SendNotification();
1498 application.Render();
1500 // Check the animatable property current value
1501 DALI_TEST_EQUALS(customActor.GetCurrentProperty<Vector3>(index), initialValue, TEST_LOCATION);
1502 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(xComponentIndex), initialValue.x, TEST_LOCATION);
1503 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(yComponentIndex), initialValue.y, TEST_LOCATION);
1504 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(zComponentIndex), initialValue.z, TEST_LOCATION);
1507 const Vector3 targetValue(45.0f, 53.0f, 25.0f);
1508 const Vector3 relativeValue(targetValue - initialValue);
1510 Animation animation = Animation::New(1.0f);
1511 animation.AnimateBy(Property(customActor, xComponentIndex), relativeValue.x);
1512 animation.AnimateBy(Property(customActor, yComponentIndex), relativeValue.y);
1513 animation.AnimateBy(Property(customActor, zComponentIndex), relativeValue.z);
1516 // Target values should change straight away
1517 DALI_TEST_EQUALS(customActor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION);
1518 DALI_TEST_EQUALS(customActor.GetProperty<float>(xComponentIndex), targetValue.x, TEST_LOCATION);
1519 DALI_TEST_EQUALS(customActor.GetProperty<float>(yComponentIndex), targetValue.y, TEST_LOCATION);
1520 DALI_TEST_EQUALS(customActor.GetProperty<float>(zComponentIndex), targetValue.z, TEST_LOCATION);
1525 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationVector4AnimateByP(void)
1527 TestApplication application;
1528 TypeRegistry typeRegistry = TypeRegistry::Get();
1530 TypeInfo typeInfo = typeRegistry.GetTypeInfo(typeid(MyTestCustomActor));
1531 DALI_TEST_CHECK(typeInfo);
1532 BaseHandle handle = typeInfo.CreateInstance();
1533 DALI_TEST_CHECK(handle);
1534 Actor customActor = Actor::DownCast(handle);
1535 application.GetScene().Add(customActor);
1536 DALI_TEST_CHECK(customActor);
1538 const unsigned int index = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX;
1539 const unsigned int xComponentIndex = index + 1;
1540 const unsigned int yComponentIndex = index + 2;
1541 const unsigned int zComponentIndex = index + 3;
1542 const unsigned int wComponentIndex = index + 4;
1543 const Vector4 initialValue(20.0f, 40.0f, 50.0f, 60.0f);
1545 // Register animatable property & its components
1546 AnimatablePropertyRegistration animatableProperty1(customType1, "animatableProp1", index, initialValue);
1547 AnimatablePropertyComponentRegistration animatablePropertyComponent1(customType1, "animatableProp1X", xComponentIndex, index, 0);
1548 AnimatablePropertyComponentRegistration animatablePropertyComponent2(customType1, "animatableProp1Y", yComponentIndex, index, 1);
1549 AnimatablePropertyComponentRegistration animatablePropertyComponent3(customType1, "animatableProp1Z", zComponentIndex, index, 2);
1550 AnimatablePropertyComponentRegistration animatablePropertyComponent4(customType1, "animatableProp1W", wComponentIndex, index, 3);
1552 // Check the animatable property value
1553 DALI_TEST_EQUALS(customActor.GetProperty<Vector4>(index), initialValue, TEST_LOCATION);
1554 DALI_TEST_EQUALS(customActor.GetProperty<float>(xComponentIndex), initialValue.x, TEST_LOCATION);
1555 DALI_TEST_EQUALS(customActor.GetProperty<float>(yComponentIndex), initialValue.y, TEST_LOCATION);
1556 DALI_TEST_EQUALS(customActor.GetProperty<float>(zComponentIndex), initialValue.z, TEST_LOCATION);
1557 DALI_TEST_EQUALS(customActor.GetProperty<float>(wComponentIndex), initialValue.w, TEST_LOCATION);
1559 // Render and notify
1560 application.SendNotification();
1561 application.Render();
1563 // Check the animatable property current value
1564 DALI_TEST_EQUALS(customActor.GetCurrentProperty<Vector4>(index), initialValue, TEST_LOCATION);
1565 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(xComponentIndex), initialValue.x, TEST_LOCATION);
1566 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(yComponentIndex), initialValue.y, TEST_LOCATION);
1567 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(zComponentIndex), initialValue.z, TEST_LOCATION);
1568 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(wComponentIndex), initialValue.w, TEST_LOCATION);
1571 const Vector4 targetValue(45.0f, 53.0f, 25.0f, 13.0f);
1572 const Vector4 relativeValue(targetValue - initialValue);
1574 Animation animation = Animation::New(1.0f);
1575 animation.AnimateBy(Property(customActor, xComponentIndex), relativeValue.x);
1576 animation.AnimateBy(Property(customActor, yComponentIndex), relativeValue.y);
1577 animation.AnimateBy(Property(customActor, zComponentIndex), relativeValue.z);
1578 animation.AnimateBy(Property(customActor, wComponentIndex), relativeValue.w);
1581 // Target values should change straight away
1582 DALI_TEST_EQUALS(customActor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION);
1583 DALI_TEST_EQUALS(customActor.GetProperty<float>(xComponentIndex), targetValue.x, TEST_LOCATION);
1584 DALI_TEST_EQUALS(customActor.GetProperty<float>(yComponentIndex), targetValue.y, TEST_LOCATION);
1585 DALI_TEST_EQUALS(customActor.GetProperty<float>(zComponentIndex), targetValue.z, TEST_LOCATION);
1586 DALI_TEST_EQUALS(customActor.GetProperty<float>(wComponentIndex), targetValue.w, TEST_LOCATION);
1591 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationN(void)
1593 TestApplication application;
1594 TypeRegistry typeRegistry = TypeRegistry::Get();
1596 // Register animatable property with the type of Vector2
1597 int animatablePropertyIndex1(ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX);
1598 AnimatablePropertyRegistration animatableProperty1(customType1, "animatableProp1", animatablePropertyIndex1, Property::VECTOR2);
1600 // Attempt to register an animatable property component out-of-bounds index (less than)
1603 AnimatablePropertyComponentRegistration propertyComponent1(customType1, "animatableProp1X", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX - 1, animatablePropertyIndex1, 0);
1604 tet_result(TET_FAIL);
1606 catch(DaliException& e)
1608 DALI_TEST_ASSERT(e, "(index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX) && (index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX)", TEST_LOCATION);
1611 // Attempt to register an animatable property component out-of-bounds index (greater than)
1614 AnimatablePropertyComponentRegistration propertyComponent1(customType1, "animatableProp1X", ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX + 1, animatablePropertyIndex1, 0);
1615 tet_result(TET_FAIL);
1617 catch(DaliException& e)
1619 DALI_TEST_ASSERT(e, "(index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX) && (index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX)", TEST_LOCATION);
1622 // Register an animatable property component
1623 AnimatablePropertyComponentRegistration propertyComponent1(customType1, "animatableProp1X", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1, animatablePropertyIndex1, 0);
1625 // Attempt to register another animatable property component with the same component index
1628 AnimatablePropertyComponentRegistration propertyComponent2(customType1, "animatableProp1Y", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2, animatablePropertyIndex1, 0);
1629 tet_result(TET_FAIL);
1631 catch(DaliException& e)
1633 DALI_TEST_ASSERT(e, "Property component already registered", TEST_LOCATION);
1636 // Register animatable property with the type of boolean
1637 int animatablePropertyIndex2(ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2);
1638 AnimatablePropertyRegistration animatableProperty2(customType1, "animatableProp2", animatablePropertyIndex2, Property::BOOLEAN);
1640 // Attempt to register an animatable property component for the above property with boolean type
1643 AnimatablePropertyComponentRegistration propertyComponent1(customType1, "animatableProp2X", animatablePropertyIndex2 + 1, animatablePropertyIndex2, 0);
1644 tet_result(TET_FAIL);
1646 catch(DaliException& e)
1648 DALI_TEST_ASSERT(e, "Base property does not support component", TEST_LOCATION);
1654 int UtcDaliTypeRegistryChildPropertyRegistrationP(void)
1656 TestApplication application;
1657 TypeRegistry typeRegistry = TypeRegistry::Get();
1659 // Check property count before property registration
1660 TypeInfo typeInfo = typeRegistry.GetTypeInfo(typeid(MyTestCustomActor));
1661 DALI_TEST_CHECK(typeInfo);
1662 BaseHandle handle = typeInfo.CreateInstance();
1663 DALI_TEST_CHECK(handle);
1664 Actor customActor = Actor::DownCast(handle);
1665 DALI_TEST_CHECK(customActor);
1666 unsigned int initialPropertyCount(customActor.GetPropertyCount());
1668 // Register child properties to the parent
1669 std::string propertyName("childProp1");
1670 int propertyIndex(CHILD_PROPERTY_REGISTRATION_START_INDEX);
1671 Property::Type propertyType(Property::BOOLEAN);
1672 ChildPropertyRegistration childProperty1(customType1, propertyName, propertyIndex, propertyType);
1674 std::string propertyName2("childProp2");
1675 int propertyIndex2(CHILD_PROPERTY_REGISTRATION_START_INDEX + 1);
1676 Property::Type propertyType2(Property::INTEGER);
1677 ChildPropertyRegistration childProperty2(customType1, propertyName2, propertyIndex2, propertyType2);
1679 std::string propertyName3("childProp3");
1680 int propertyIndex3(CHILD_PROPERTY_REGISTRATION_START_INDEX + 2);
1681 Property::Type propertyType3(Property::FLOAT);
1682 ChildPropertyRegistration childProperty3(customType1, propertyName3, propertyIndex3, propertyType3);
1684 std::string propertyName4("childProp4");
1685 int propertyIndex4(CHILD_PROPERTY_REGISTRATION_START_INDEX + 3);
1686 Property::Type propertyType4(Property::INTEGER);
1687 ChildPropertyRegistration childProperty4(customType1, propertyName4, propertyIndex4, propertyType4);
1689 // Check property count are not changed because the child properties will not be created for the parent
1690 DALI_TEST_EQUALS(initialPropertyCount, customActor.GetPropertyCount(), TEST_LOCATION);
1692 // check the child property type
1693 Internal::TypeInfo& typeInfoImpl = GetImplementation(typeInfo);
1694 Property::Type type = typeInfoImpl.GetChildPropertyType(typeInfoImpl.GetChildPropertyIndex("childProp4"));
1695 DALI_TEST_EQUALS(type, Property::INTEGER, TEST_LOCATION);
1697 std::string unRegisteredChildName(typeInfoImpl.GetChildPropertyName(CHILD_PROPERTY_REGISTRATION_START_INDEX + 4));
1698 DALI_TEST_EQUALS(unRegisteredChildName, "", TEST_LOCATION);
1700 // Create a child actor
1701 Actor childActor = Actor::New();
1702 DALI_TEST_CHECK(childActor);
1703 unsigned int initialChildActorPropertyCount(childActor.GetPropertyCount());
1705 // The type of child properties should be Property::None as the child hasn't registered any child property yet.
1706 DALI_TEST_EQUALS(childActor.GetPropertyType(propertyIndex), Property::NONE, TEST_LOCATION);
1707 DALI_TEST_EQUALS(childActor.GetPropertyType(propertyIndex2), Property::NONE, TEST_LOCATION);
1708 DALI_TEST_EQUALS(childActor.GetPropertyType(propertyIndex3), Property::NONE, TEST_LOCATION);
1709 DALI_TEST_EQUALS(childActor.GetPropertyType(propertyIndex4), Property::NONE, TEST_LOCATION);
1711 // Set the value for the first child property when the child actor doesn't have a parent yet
1712 childActor.SetProperty(propertyIndex, true);
1714 // Check that the first child property is dynamically created
1715 DALI_TEST_EQUALS(initialChildActorPropertyCount + 1u, childActor.GetPropertyCount(), TEST_LOCATION);
1717 // Check the first child property value
1718 DALI_TEST_EQUALS(childActor.GetProperty<bool>(propertyIndex), true, TEST_LOCATION);
1720 // Check the first child property type
1721 DALI_TEST_EQUALS(childActor.GetPropertyType(propertyIndex), propertyType, TEST_LOCATION);
1723 // Check that the first child property have no name, as it doesn't have a parent yet.
1724 DALI_TEST_EQUALS(childActor.GetPropertyName(propertyIndex), "", TEST_LOCATION);
1726 // Check that the first property can't be accessed through its name, as it doesn't have a parent yet.
1727 DALI_TEST_EQUALS(childActor.GetPropertyIndex(propertyName), Property::INVALID_INDEX, TEST_LOCATION);
1729 // Create a custom property for the child with the same name as the second child property registered to the parent
1730 Property::Index customPropertyIndex = childActor.RegisterProperty(propertyName2, 100, Property::READ_WRITE);
1732 // Check that the custom property is created
1733 DALI_TEST_EQUALS(initialChildActorPropertyCount + 2u, childActor.GetPropertyCount(), TEST_LOCATION);
1735 // Check the property value
1736 DALI_TEST_EQUALS(childActor.GetProperty<int>(customPropertyIndex), 100, TEST_LOCATION);
1738 // Check the property index
1739 DALI_TEST_EQUALS(childActor.GetPropertyIndex(propertyName2), customPropertyIndex, TEST_LOCATION);
1741 // Check the property type
1742 DALI_TEST_EQUALS(childActor.GetPropertyType(customPropertyIndex), propertyType2, TEST_LOCATION);
1744 // Check the property name
1745 DALI_TEST_EQUALS(childActor.GetPropertyName(customPropertyIndex), propertyName2, TEST_LOCATION);
1747 // Now add the child actor to the parent
1748 customActor.Add(childActor);
1750 // Check that the first child property now has the correct name as previously registered to the parent
1751 DALI_TEST_EQUALS(childActor.GetPropertyName(propertyIndex), propertyName, TEST_LOCATION);
1753 // Check that the child property index for the first child property can now be retrieved through its child property name
1754 DALI_TEST_EQUALS(childActor.GetPropertyIndex(propertyName), propertyIndex, TEST_LOCATION);
1756 // Check that the second child property now has the correct index as previously registered to the parent
1757 DALI_TEST_EQUALS(childActor.GetPropertyName(propertyIndex2), propertyName2, TEST_LOCATION);
1759 // Check that the second child property can be accessed through both its custom property index and its child property index
1760 DALI_TEST_EQUALS(childActor.GetProperty<int>(customPropertyIndex), 100, TEST_LOCATION);
1761 DALI_TEST_EQUALS(childActor.GetProperty<int>(propertyIndex2), 100, TEST_LOCATION);
1762 DALI_TEST_EQUALS(childActor.GetPropertyType(customPropertyIndex), propertyType2, TEST_LOCATION);
1763 DALI_TEST_EQUALS(childActor.GetPropertyType(propertyIndex2), propertyType2, TEST_LOCATION);
1765 // Check that the child property index for the second child property can now be retrieved through its child property name
1766 DALI_TEST_EQUALS(childActor.GetPropertyIndex(propertyName2), propertyIndex2, TEST_LOCATION);
1768 // Set the value for the third child property when the child actor is already added to the parent
1769 childActor.SetProperty(propertyIndex3, 0.15f);
1771 // Check that the third child property is dynamically created
1772 DALI_TEST_EQUALS(initialChildActorPropertyCount + 3u, childActor.GetPropertyCount(), TEST_LOCATION);
1774 // Check the third child property value
1775 DALI_TEST_EQUALS(childActor.GetProperty<float>(propertyIndex3), 0.15f, TEST_LOCATION);
1777 // Check the third child property type
1778 DALI_TEST_EQUALS(childActor.GetPropertyType(propertyIndex3), propertyType3, TEST_LOCATION);
1780 // Check the third child property name
1781 DALI_TEST_EQUALS(childActor.GetPropertyName(propertyIndex3), propertyName3, TEST_LOCATION);
1783 // Check the third child property index.
1784 DALI_TEST_EQUALS(childActor.GetPropertyIndex(propertyName3), propertyIndex3, TEST_LOCATION);
1786 // Create a custom property for the child with the same name as the fourth child property registered to the parent
1787 Property::Index customPropertyIndex2 = childActor.RegisterProperty(propertyName4, 20, Property::READ_WRITE);
1789 // Check that the custom property is created
1790 DALI_TEST_EQUALS(initialChildActorPropertyCount + 4u, childActor.GetPropertyCount(), TEST_LOCATION);
1792 // Check the fourth child property value
1793 DALI_TEST_EQUALS(childActor.GetProperty<int>(propertyIndex4), 20, TEST_LOCATION);
1794 DALI_TEST_EQUALS(childActor.GetProperty<int>(customPropertyIndex2), 20, TEST_LOCATION);
1796 // Check the fourth child property type
1797 DALI_TEST_EQUALS(childActor.GetPropertyType(propertyIndex4), propertyType4, TEST_LOCATION);
1798 DALI_TEST_EQUALS(childActor.GetPropertyType(customPropertyIndex2), propertyType4, TEST_LOCATION);
1800 // Check the fourth child property name
1801 DALI_TEST_EQUALS(childActor.GetPropertyName(propertyIndex4), propertyName4, TEST_LOCATION);
1802 DALI_TEST_EQUALS(childActor.GetPropertyName(customPropertyIndex2), propertyName4, TEST_LOCATION);
1804 // Check the fourth child property index.
1805 DALI_TEST_EQUALS(childActor.GetPropertyIndex(propertyName4), propertyIndex4, TEST_LOCATION);
1807 // Now create another parent actor with different child properties registered
1808 TypeInfo typeInfo2 = typeRegistry.GetTypeInfo("MyNamedActor");
1809 DALI_TEST_CHECK(typeInfo2);
1810 BaseHandle handle2 = typeInfo2.CreateInstance();
1811 DALI_TEST_CHECK(handle2);
1812 Actor customActor2 = Actor::DownCast(handle2);
1813 DALI_TEST_CHECK(customActor2);
1815 // Register child properties to the new parent
1816 std::string newPropertyName("newChildProp");
1817 int newPropertyIndex(CHILD_PROPERTY_REGISTRATION_START_INDEX); // The same index as the first child property "childProp1" in the old parent
1818 Property::Type newPropertyType(Property::VECTOR2);
1819 ChildPropertyRegistration newChildProperty(namedActorType, newPropertyName, newPropertyIndex, newPropertyType);
1821 std::string newPropertyName2("childProp3"); // The same name as the third child property in the old parent
1822 int newPropertyIndex2(CHILD_PROPERTY_REGISTRATION_START_INDEX + 1); // The same index as the second child property "childProp2" in the old parent
1823 Property::Type newPropertyType2(Property::FLOAT); // The same type as the third child property in the old parent
1824 ChildPropertyRegistration newChildProperty2(namedActorType, newPropertyName2, newPropertyIndex2, newPropertyType2);
1826 // Now move the child actor to the new parent
1827 customActor2.Add(childActor);
1829 // "childProp1" is not a valid child property supported by the new parent, so nothing changed
1830 DALI_TEST_EQUALS(childActor.GetPropertyType(propertyIndex), propertyType, TEST_LOCATION);
1831 DALI_TEST_EQUALS(childActor.GetPropertyName(propertyIndex), propertyName, TEST_LOCATION);
1832 DALI_TEST_EQUALS(childActor.GetPropertyIndex(propertyName), propertyIndex, TEST_LOCATION);
1834 // "childProp3" is a valid child property supported by the new parent
1835 // So it should get its new child property index and should just work
1836 DALI_TEST_EQUALS(childActor.GetPropertyType(newPropertyIndex2), newPropertyType2, TEST_LOCATION);
1837 DALI_TEST_EQUALS(childActor.GetPropertyName(newPropertyIndex2), newPropertyName2, TEST_LOCATION);
1838 DALI_TEST_EQUALS(childActor.GetPropertyIndex(newPropertyName2), newPropertyIndex2, TEST_LOCATION);
1839 DALI_TEST_EQUALS(childActor.GetProperty<float>(newPropertyIndex2), 0.15f, TEST_LOCATION);
1841 // Now register a custom property called "newChildProp"
1842 Property::Index customPropertyIndex3 = childActor.RegisterProperty("newChildProp", Vector2(10.0f, 10.0f), Property::READ_WRITE);
1844 // Check that the custom property is created
1845 DALI_TEST_EQUALS(initialChildActorPropertyCount + 5u, childActor.GetPropertyCount(), TEST_LOCATION);
1847 // This is a valid child property registered to the new parent
1848 // So should be able to access it through both its custom property index and its registered child property index
1849 DALI_TEST_EQUALS(childActor.GetPropertyType(newPropertyIndex), newPropertyType, TEST_LOCATION);
1850 DALI_TEST_EQUALS(childActor.GetPropertyType(customPropertyIndex3), newPropertyType, TEST_LOCATION);
1851 DALI_TEST_EQUALS(childActor.GetPropertyName(newPropertyIndex), newPropertyName, TEST_LOCATION); // This should return the new name, although the child property index remains the same
1852 DALI_TEST_EQUALS(childActor.GetPropertyName(customPropertyIndex3), newPropertyName, TEST_LOCATION);
1853 DALI_TEST_EQUALS(childActor.GetProperty<Vector2>(newPropertyIndex), Vector2(10.0f, 10.0f), TEST_LOCATION);
1854 DALI_TEST_EQUALS(childActor.GetProperty<Vector2>(customPropertyIndex3), Vector2(10.0f, 10.0f), TEST_LOCATION);
1856 // Should return the child property index by given its name
1857 DALI_TEST_EQUALS(childActor.GetPropertyIndex(newPropertyName), newPropertyIndex, TEST_LOCATION);
1862 int UtcDaliTypeRegistryChildPropertyRegistrationN(void)
1864 TestApplication application;
1865 TypeRegistry typeRegistry = TypeRegistry::Get();
1867 // Attempt to register a child property type out-of-bounds index (less than)
1870 ChildPropertyRegistration property1(customType1, "propName", CHILD_PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN);
1871 tet_result(TET_FAIL);
1873 catch(DaliException& e)
1875 DALI_TEST_ASSERT(e, "(index >= CHILD_PROPERTY_REGISTRATION_START_INDEX) && (index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX)", TEST_LOCATION);
1878 // Attempt to register a child property type out-of-bounds index (greater than)
1881 ChildPropertyRegistration property1(customType1, "propName", CHILD_PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN);
1882 tet_result(TET_FAIL);
1884 catch(DaliException& e)
1886 DALI_TEST_ASSERT(e, "(index >= CHILD_PROPERTY_REGISTRATION_START_INDEX) && (index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX)", TEST_LOCATION);
1892 /*******************************************************************************
1894 * Action through the base handle
1896 ******************************************************************************/
1897 int UtcDaliTypeRegistryActionViaBaseHandle(void)
1899 TestApplication application;
1903 type = TypeRegistry::Get().GetTypeInfo("Actor");
1904 DALI_TEST_CHECK(type);
1906 BaseHandle hdl = type.CreateInstance();
1907 DALI_TEST_CHECK(hdl);
1909 Actor a = Actor::DownCast(hdl);
1912 a.SetProperty(Actor::Property::VISIBLE, false);
1914 application.SendNotification();
1915 application.Render(0);
1916 DALI_TEST_CHECK(!a.GetCurrentProperty<bool>(Actor::Property::VISIBLE));
1918 Property::Map attributes;
1920 DALI_TEST_CHECK(hdl.DoAction("show", attributes));
1922 application.SendNotification();
1923 application.Render(0);
1924 DALI_TEST_CHECK(a.GetCurrentProperty<bool>(Actor::Property::VISIBLE));
1926 DALI_TEST_CHECK(!hdl.DoAction("unknownAction", attributes));
1930 int UtcDaliPropertyRegistrationFunctions(void)
1932 TestApplication application;
1933 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 10;
1935 // Attempt to register a property without a setter
1938 PropertyRegistration property1(customType1, "propName", propertyIndex++, Property::BOOLEAN, NULL, &GetProperty);
1939 tet_result(TET_PASS);
1941 catch(DaliException& e)
1943 tet_result(TET_FAIL);
1946 // Attempt to register a property without a getter
1949 PropertyRegistration property1(customType1, "propName", propertyIndex++, Property::BOOLEAN, NULL, NULL);
1950 tet_result(TET_FAIL);
1952 catch(DaliException& e)
1954 DALI_TEST_ASSERT(e, "! \"GetProperty", TEST_LOCATION);
1959 int UtcDaliPropertyRegistrationAddSameIndex(void)
1961 TestApplication application;
1962 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 100;
1964 // Add one property with a valid property index
1965 PropertyRegistration property1(customType1, "propName", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty);
1967 // Attempt to add another property with the same index
1970 PropertyRegistration property2(customType1, "propName2", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty);
1972 catch(DaliException& e)
1974 DALI_TEST_ASSERT(e, "! \"Property index already added", TEST_LOCATION);
1977 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 100;
1979 // Add one property with a valid property index
1980 AnimatablePropertyRegistration property3(customType1, "animPropName", animatablePropertyIndex, Property::BOOLEAN);
1982 // Attempt to add another property with the same index
1985 AnimatablePropertyRegistration property4(customType1, "animPropName2", animatablePropertyIndex, Property::BOOLEAN);
1987 catch(DaliException& e)
1989 DALI_TEST_ASSERT(e, "! \"Property index already added", TEST_LOCATION);
1994 int UtcDaliPropertyRegistrationPropertyWritableP(void)
1996 TestApplication application;
1997 int propertyIndex1 = PROPERTY_REGISTRATION_START_INDEX + 200;
1998 int propertyIndex2 = PROPERTY_REGISTRATION_START_INDEX + 201;
2000 // Add two properties, one with SetProperty, one without
2001 PropertyRegistration property1(customType1, "propNameReadwrite", propertyIndex1, Property::BOOLEAN, &SetProperty, &GetProperty);
2002 PropertyRegistration property2(customType1, "propNameReadonly", propertyIndex2, Property::BOOLEAN, NULL, &GetProperty);
2004 // Create custom-actor
2005 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo(typeid(MyTestCustomActor));
2006 DALI_TEST_CHECK(typeInfo);
2007 BaseHandle handle = typeInfo.CreateInstance();
2008 DALI_TEST_CHECK(handle);
2009 Actor customActor = Actor::DownCast(handle);
2010 DALI_TEST_CHECK(customActor);
2012 // Check whether properties are writable
2013 DALI_TEST_CHECK(customActor.IsPropertyWritable(propertyIndex1));
2014 DALI_TEST_CHECK(!customActor.IsPropertyWritable(propertyIndex2));
2016 // Check the property is writable in the type registry
2017 Internal::TypeInfo& typeInfoImpl = GetImplementation(typeInfo);
2019 DALI_TEST_EQUALS(typeInfoImpl.IsPropertyWritable(propertyIndex1), true, TEST_LOCATION);
2024 int UtcDaliPropertyRegistrationPropertyWritableN(void)
2026 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo(typeid(MyTestCustomActor));
2027 Internal::TypeInfo& typeInfoImpl = GetImplementation(typeInfo);
2029 DALI_TEST_EQUALS(typeInfoImpl.IsPropertyWritable(Actor::Property::COLOR), true, TEST_LOCATION);
2034 int UtcDaliPropertyRegistrationPropertyAnimatable(void)
2036 TestApplication application;
2037 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 400;
2038 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 400;
2040 // These properties are not animatable
2041 PropertyRegistration property1(customType1, "propName", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty);
2043 // These properties are animatable
2044 AnimatablePropertyRegistration property2(customType1, "animPropName", animatablePropertyIndex, Property::BOOLEAN);
2046 // Create custom-actor
2047 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo(typeid(MyTestCustomActor));
2048 DALI_TEST_CHECK(typeInfo);
2049 BaseHandle handle = typeInfo.CreateInstance();
2050 DALI_TEST_CHECK(handle);
2051 Actor customActor = Actor::DownCast(handle);
2052 DALI_TEST_CHECK(customActor);
2054 // Check if animatable
2055 DALI_TEST_CHECK(!customActor.IsPropertyAnimatable(propertyIndex));
2056 DALI_TEST_CHECK(customActor.IsPropertyAnimatable(animatablePropertyIndex));
2058 // Create another instance of custom-actor
2059 BaseHandle handle2 = typeInfo.CreateInstance();
2060 DALI_TEST_CHECK(handle2);
2061 Actor customActor2 = Actor::DownCast(handle2);
2062 DALI_TEST_CHECK(customActor2);
2064 // Check if animatable
2065 DALI_TEST_CHECK(!customActor2.IsPropertyAnimatable(propertyIndex));
2066 DALI_TEST_CHECK(customActor2.IsPropertyAnimatable(animatablePropertyIndex));
2070 int UtcDaliPropertyRegistrationUnregisteredGetAndSet(void)
2072 TestApplication application;
2073 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 2000;
2074 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2000;
2076 // Create custom-actor
2077 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo(typeid(MyTestCustomActor));
2078 DALI_TEST_CHECK(typeInfo);
2079 BaseHandle handle = typeInfo.CreateInstance();
2080 DALI_TEST_CHECK(handle);
2081 Actor customActor = Actor::DownCast(handle);
2082 DALI_TEST_CHECK(customActor);
2084 // Try to set an index that hasn't been registered, this is a no-op for now, to be fixed in future
2085 customActor.SetProperty(propertyIndex, true);
2086 // DALI_TEST_EQUALS( true, customActor.GetProperty( propertyIndex ).Get<bool>(), TEST_LOCATION);
2088 // Try to set an index that hasn't been registered
2089 customActor.SetProperty(animatablePropertyIndex, true);
2090 DALI_TEST_EQUALS(true, customActor.GetProperty(animatablePropertyIndex).Get<bool>(), TEST_LOCATION);
2095 int UtcDaliLongPressGestureDetectorTypeRegistry(void)
2097 TestApplication application;
2099 Actor actor = Actor::New();
2100 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2101 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2102 application.GetScene().Add(actor);
2106 type = TypeRegistry::Get().GetTypeInfo("LongPressGestureDetector");
2107 DALI_TEST_CHECK(type);
2108 BaseHandle handle = type.CreateInstance();
2109 DALI_TEST_CHECK(handle);
2110 LongPressGestureDetector detector = LongPressGestureDetector::DownCast(handle);
2111 DALI_TEST_CHECK(detector);
2113 // Attach actor to detector
2115 GestureReceivedFunctor functor(data);
2116 detector.Attach(actor);
2118 // Connect to signal through type
2119 handle.ConnectSignal(&application, "longPressDetected", functor);
2121 // Render and notify
2122 application.SendNotification();
2123 application.Render();
2126 TestGenerateLongPress(application, 50.0f, 10.0f);
2127 TestEndLongPress(application, 50.0f, 10.0f);
2129 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2133 int UtcDaliPanGestureDetectorTypeRegistry(void)
2135 TestApplication application;
2137 Actor actor = Actor::New();
2138 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2139 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2140 application.GetScene().Add(actor);
2144 type = TypeRegistry::Get().GetTypeInfo("PanGestureDetector");
2145 DALI_TEST_CHECK(type);
2146 BaseHandle handle = type.CreateInstance();
2147 DALI_TEST_CHECK(handle);
2148 PanGestureDetector detector = PanGestureDetector::DownCast(handle);
2149 DALI_TEST_CHECK(detector);
2151 // Attach actor to detector
2153 GestureReceivedFunctor functor(data);
2154 detector.Attach(actor);
2156 // Connect to signal through type
2157 handle.ConnectSignal(&application, "panDetected", functor);
2159 // Render and notify
2160 application.SendNotification();
2161 application.Render();
2164 TestGenerateMiniPan(application);
2165 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2169 int UtcDaliPinchGestureDetectorTypeRegistry(void)
2171 TestApplication application;
2173 Actor actor = Actor::New();
2174 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2175 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2176 application.GetScene().Add(actor);
2180 type = TypeRegistry::Get().GetTypeInfo("PinchGestureDetector");
2181 DALI_TEST_CHECK(type);
2182 BaseHandle handle = type.CreateInstance();
2183 DALI_TEST_CHECK(handle);
2184 PinchGestureDetector detector = PinchGestureDetector::DownCast(handle);
2185 DALI_TEST_CHECK(detector);
2187 // Attach actor to detector
2189 GestureReceivedFunctor functor(data);
2190 detector.Attach(actor);
2192 // Connect to signal through type
2193 handle.ConnectSignal(&application, "pinchDetected", functor);
2195 // Render and notify
2196 application.SendNotification();
2197 application.Render();
2200 TestGeneratePinch(application);
2202 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2206 int UtcDaliRotationGestureDetectorTypeRegistry(void)
2208 TestApplication application;
2210 Actor actor = Actor::New();
2211 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2212 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2213 application.GetScene().Add(actor);
2217 type = TypeRegistry::Get().GetTypeInfo("RotationGestureDetector");
2218 DALI_TEST_CHECK(type);
2219 BaseHandle handle = type.CreateInstance();
2220 DALI_TEST_CHECK(handle);
2221 RotationGestureDetector detector = RotationGestureDetector::DownCast(handle);
2222 DALI_TEST_CHECK(detector);
2224 // Attach actor to detector
2226 GestureReceivedFunctor functor(data);
2227 detector.Attach(actor);
2229 // Connect to signal through type
2230 handle.ConnectSignal(&application, "rotationDetected", functor);
2232 // Render and notify
2233 application.SendNotification();
2234 application.Render();
2237 TestGenerateRotation(application);
2239 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2243 int UtcDaliTapGestureDetectorTypeRegistry(void)
2245 TestApplication application;
2247 Actor actor = Actor::New();
2248 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2249 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2250 application.GetScene().Add(actor);
2254 type = TypeRegistry::Get().GetTypeInfo("TapGestureDetector");
2255 DALI_TEST_CHECK(type);
2256 BaseHandle handle = type.CreateInstance();
2257 DALI_TEST_CHECK(handle);
2258 TapGestureDetector detector = TapGestureDetector::DownCast(handle);
2259 DALI_TEST_CHECK(detector);
2261 // Attach actor to detector
2263 GestureReceivedFunctor functor(data);
2264 detector.Attach(actor);
2266 // Connect to signal through type
2267 handle.ConnectSignal(&application, "tapDetected", functor);
2269 // Render and notify
2270 application.SendNotification();
2271 application.Render();
2274 TestGenerateTap(application, 50.0, 10.0, 100);
2276 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2280 int UtcDaliTypeRegistryNamedType(void)
2282 TestApplication application;
2283 TypeRegistry typeRegistry = TypeRegistry::Get();
2285 // Create a normal actor
2286 BaseHandle actorHandle = typeRegistry.GetTypeInfo("Actor").CreateInstance();
2287 DALI_TEST_CHECK(actorHandle);
2288 Actor actor(Actor::DownCast(actorHandle));
2289 DALI_TEST_CHECK(actor);
2290 unsigned int actorPropertyCount(actor.GetPropertyCount());
2292 // Create Named Actor Type
2293 BaseHandle namedHandle = typeRegistry.GetTypeInfo("MyNamedActor").CreateInstance();
2294 DALI_TEST_CHECK(namedHandle);
2295 Actor namedActor(Actor::DownCast(namedHandle));
2296 DALI_TEST_CHECK(namedActor);
2297 unsigned int namedActorPropertyCount(namedActor.GetPropertyCount());
2299 DALI_TEST_CHECK(namedActorPropertyCount > actorPropertyCount);
2303 int UtcDaliTypeInfoGetActionNameP(void)
2305 TestApplication application;
2306 TypeRegistry typeRegistry = TypeRegistry::Get();
2308 TypeInfo typeInfo = typeRegistry.GetTypeInfo("Actor");
2309 DALI_TEST_CHECK(typeInfo);
2311 DALI_TEST_CHECK(0 != typeInfo.GetActionCount());
2313 std::string name = typeInfo.GetActionName(0);
2315 DALI_TEST_EQUALS(name, "show", TEST_LOCATION);
2317 TypeInfo typeInfo2 = typeRegistry.GetTypeInfo("MyTestCustomActor");
2319 // search for show action in base class, given a derived class
2320 bool foundChildAction = false;
2321 for(std::size_t i = 0; i < typeInfo2.GetActionCount(); i++)
2323 std::string name = typeInfo2.GetActionName(i);
2326 foundChildAction = true;
2330 DALI_TEST_EQUALS(foundChildAction, true, TEST_LOCATION);
2335 int UtcDaliTypeInfoGetActionNameN(void)
2337 TestApplication application;
2338 TypeRegistry typeRegistry = TypeRegistry::Get();
2340 TypeInfo typeInfo = typeRegistry.GetTypeInfo("Actor");
2341 DALI_TEST_CHECK(typeInfo);
2343 DALI_TEST_CHECK(0 != typeInfo.GetActionCount());
2345 std::string name = typeInfo.GetActionName(std::numeric_limits<size_t>::max());
2347 DALI_TEST_EQUALS(0u, name.size(), TEST_LOCATION);
2352 int UtcDaliTypeInfoGetSignalNameP(void)
2354 TestApplication application;
2355 TypeRegistry typeRegistry = TypeRegistry::Get();
2357 TypeInfo typeInfo = typeRegistry.GetTypeInfo("Actor");
2358 DALI_TEST_CHECK(typeInfo);
2360 DALI_TEST_CHECK(0 != typeInfo.GetSignalCount());
2362 std::string name = typeInfo.GetSignalName(0);
2364 DALI_TEST_EQUALS(name, "hovered", TEST_LOCATION);
2366 TypeInfo typeInfo2 = typeRegistry.GetTypeInfo("MyTestCustomActor");
2368 // search for signal in base class, given a derived class
2369 bool foundSignal = false;
2370 for(std::size_t i = 0; i < typeInfo2.GetSignalCount(); i++)
2372 std::string name = typeInfo2.GetSignalName(i);
2373 if(name == "hovered")
2379 DALI_TEST_EQUALS(foundSignal, true, TEST_LOCATION);
2384 int UtcDaliTypeInfoGetSignalNameN(void)
2386 TestApplication application;
2387 TypeRegistry typeRegistry = TypeRegistry::Get();
2389 TypeInfo typeInfo = typeRegistry.GetTypeInfo("Actor");
2390 DALI_TEST_CHECK(typeInfo);
2392 DALI_TEST_CHECK(0 != typeInfo.GetSignalCount());
2394 std::string name = typeInfo.GetSignalName(std::numeric_limits<size_t>::max());
2396 DALI_TEST_EQUALS(0u, name.size(), TEST_LOCATION);
2401 int UtcDaliTypeInfoGetCreatorP(void)
2403 TestApplication application;
2404 TypeRegistry typeRegistry = TypeRegistry::Get();
2406 TypeInfo typeInfo = typeRegistry.GetTypeInfo("Actor");
2407 DALI_TEST_CHECK(typeInfo);
2409 TypeInfo::CreateFunction createFn = typeInfo.GetCreator();
2410 DALI_TEST_EQUALS(createFn != NULL, true, TEST_LOCATION);
2414 BaseHandle handle = createFn();
2415 DALI_TEST_EQUALS((bool)handle, true, TEST_LOCATION);
2421 int UtcDaliTypeInfoGetCreatorN(void)
2423 TestApplication application;
2424 TypeRegistry typeRegistry = TypeRegistry::Get();
2426 TypeInfo typeInfo = typeRegistry.GetTypeInfo("MyTestCustomActor3");
2427 DALI_TEST_CHECK(typeInfo);
2429 TypeInfo::CreateFunction createFn = typeInfo.GetCreator();
2430 DALI_TEST_EQUALS(createFn == NULL, true, TEST_LOCATION);
2435 int UtcDaliTypeInfoGetPropertyCountP1(void)
2437 TestApplication application;
2438 TypeRegistry typeRegistry = TypeRegistry::Get();
2440 TypeInfo typeInfo = typeRegistry.GetTypeInfo("Actor");
2441 DALI_TEST_CHECK(typeInfo);
2442 size_t actorPropertyCount = typeInfo.GetPropertyCount();
2444 DALI_TEST_EQUALS(actorPropertyCount, Actor::New().GetPropertyCount(), TEST_LOCATION); // No event only props
2448 int UtcDaliTypeInfoGetPropertyCountP2(void)
2450 TestApplication application;
2451 TypeRegistry typeRegistry = TypeRegistry::Get();
2453 TypeInfo typeInfo = typeRegistry.GetTypeInfo("MyTestCustomActor2");
2454 DALI_TEST_CHECK(typeInfo);
2455 size_t propertyCount = typeInfo.GetPropertyCount();
2456 Property::IndexContainer indices;
2457 typeInfo.GetPropertyIndices(indices);
2459 DALI_TEST_EQUALS(propertyCount > 0 && propertyCount <= indices.Size(), true, TEST_LOCATION);
2460 DALI_TEST_EQUALS(propertyCount, Actor::New().GetPropertyCount() + 2, TEST_LOCATION);
2465 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGet01(void)
2467 TestApplication application;
2468 TypeRegistry typeRegistry = TypeRegistry::Get();
2470 tet_infoline("Register a type registered animatable property and ensure set/get behaviour works synchronously");
2472 // Register animatable property
2473 const int animatablePropertyIndex(ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX);
2474 AnimatablePropertyRegistration animatableProperty(customType1, "animatableProp1", animatablePropertyIndex, Property::FLOAT);
2476 // Check property count before property registration
2477 TypeInfo typeInfo = typeRegistry.GetTypeInfo(typeid(MyTestCustomActor));
2478 DALI_TEST_CHECK(typeInfo);
2479 BaseHandle handle = typeInfo.CreateInstance();
2480 DALI_TEST_CHECK(handle);
2481 Actor customActor = Actor::DownCast(handle);
2482 DALI_TEST_CHECK(customActor);
2483 application.GetScene().Add(customActor);
2485 tet_infoline("Set the value and ensure it changes straight away");
2486 DALI_TEST_EQUALS(customActor.GetProperty<float>(animatablePropertyIndex), 0.0f, TEST_LOCATION);
2487 customActor.SetProperty(animatablePropertyIndex, 25.0f);
2488 DALI_TEST_EQUALS(customActor.GetProperty<float>(animatablePropertyIndex), 25.0f, TEST_LOCATION);
2490 tet_infoline("Check latest scene-graph value is unchanged");
2491 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(animatablePropertyIndex), 0.0f, TEST_LOCATION);
2493 // Render and notify
2494 application.SendNotification();
2495 application.Render();
2497 tet_infoline("Check values after rendering and both retrieval methods should return the latest");
2499 DALI_TEST_EQUALS(customActor.GetProperty<float>(animatablePropertyIndex), 25.0f, TEST_LOCATION);
2500 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(animatablePropertyIndex), 25.0f, TEST_LOCATION);
2505 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGetWithComponentsVector2(void)
2507 TestApplication application;
2508 TypeRegistry typeRegistry = TypeRegistry::Get();
2510 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");
2512 // Register the animatable propeties
2513 const int basePropertyIndex(ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX);
2514 const int componentZeroPropertyIndex(basePropertyIndex + 1);
2515 const int componentOnePropertyIndex(componentZeroPropertyIndex + 1);
2516 AnimatablePropertyRegistration baseAnimatableProperty(customType1, "baseProp", basePropertyIndex, Vector2(13.0f, 24.0f));
2517 AnimatablePropertyComponentRegistration componentZeroAnimatableProperty(customType1, "componentZeroProp", componentZeroPropertyIndex, basePropertyIndex, 0);
2518 AnimatablePropertyComponentRegistration componentOneAnimatableProperty(customType1, "componentOneProp", componentOnePropertyIndex, basePropertyIndex, 1);
2520 // Check property count before property registration
2521 TypeInfo typeInfo = typeRegistry.GetTypeInfo(typeid(MyTestCustomActor));
2522 DALI_TEST_CHECK(typeInfo);
2523 BaseHandle handle = typeInfo.CreateInstance();
2524 DALI_TEST_CHECK(handle);
2525 Actor customActor = Actor::DownCast(handle);
2526 DALI_TEST_CHECK(customActor);
2527 application.GetScene().Add(customActor);
2529 tet_infoline("Get the component values, they should be the default value of the base-property");
2530 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentZeroPropertyIndex), 13.0f, TEST_LOCATION);
2531 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentOnePropertyIndex), 24.0f, TEST_LOCATION);
2532 DALI_TEST_EQUALS(customActor.GetProperty<Vector2>(basePropertyIndex), Vector2(13.0f, 24.0f), TEST_LOCATION);
2534 tet_infoline("Set a component value and ensure it changes for the base property as well");
2535 customActor.SetProperty(componentZeroPropertyIndex, 125.0f);
2536 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentZeroPropertyIndex), 125.0f, TEST_LOCATION);
2537 DALI_TEST_EQUALS(customActor.GetProperty<Vector2>(basePropertyIndex), Vector2(125.0f, 24.0f), TEST_LOCATION);
2539 customActor.SetProperty(componentOnePropertyIndex, 225.0f);
2540 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentOnePropertyIndex), 225.0f, TEST_LOCATION);
2541 DALI_TEST_EQUALS(customActor.GetProperty<Vector2>(basePropertyIndex), Vector2(125.0f, 225.0f), TEST_LOCATION);
2543 tet_infoline("Check latest scene-graph value is unchanged");
2544 DALI_TEST_EQUALS(customActor.GetCurrentProperty<Vector2>(basePropertyIndex), Vector2(13.0f, 24.0f), TEST_LOCATION);
2545 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentZeroPropertyIndex), 13.0f, TEST_LOCATION);
2546 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentOnePropertyIndex), 24.0f, TEST_LOCATION);
2548 // Render and notify
2549 application.SendNotification();
2550 application.Render();
2552 tet_infoline("Check values after rendering and both retrieval methods should return the latest");
2553 DALI_TEST_EQUALS(customActor.GetProperty<Vector2>(basePropertyIndex), Vector2(125.0f, 225.0f), TEST_LOCATION);
2554 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentZeroPropertyIndex), 125.0f, TEST_LOCATION);
2555 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentOnePropertyIndex), 225.0f, TEST_LOCATION);
2557 DALI_TEST_EQUALS(customActor.GetCurrentProperty<Vector2>(basePropertyIndex), Vector2(125.0f, 225.0f), TEST_LOCATION);
2558 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentZeroPropertyIndex), 125.0f, TEST_LOCATION);
2559 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentOnePropertyIndex), 225.0f, TEST_LOCATION);
2561 tet_infoline("Set the base property value and ensure the component values reflect the change");
2562 customActor.SetProperty(basePropertyIndex, Vector2(1.0f, 2.0f));
2563 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentZeroPropertyIndex), 1.0f, TEST_LOCATION);
2564 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentOnePropertyIndex), 2.0f, TEST_LOCATION);
2565 DALI_TEST_EQUALS(customActor.GetProperty<Vector2>(basePropertyIndex), Vector2(1.0f, 2.0f), TEST_LOCATION);
2570 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGetWithComponentsVector3(void)
2572 TestApplication application;
2573 TypeRegistry typeRegistry = TypeRegistry::Get();
2575 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");
2577 // Register the animatable propeties
2578 const int basePropertyIndex(ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX);
2579 const int componentZeroPropertyIndex(basePropertyIndex + 1);
2580 const int componentOnePropertyIndex(componentZeroPropertyIndex + 1);
2581 const int componentTwoPropertyIndex(componentOnePropertyIndex + 1);
2582 AnimatablePropertyRegistration baseAnimatableProperty(customType1, "baseProp", basePropertyIndex, Vector3(13.0f, 24.0f, 35.0));
2583 AnimatablePropertyComponentRegistration componentZeroAnimatableProperty(customType1, "componentZeroProp", componentZeroPropertyIndex, basePropertyIndex, 0);
2584 AnimatablePropertyComponentRegistration componentOneAnimatableProperty(customType1, "componentOneProp", componentOnePropertyIndex, basePropertyIndex, 1);
2585 AnimatablePropertyComponentRegistration componentTwoAnimatableProperty(customType1, "componentTwoProp", componentTwoPropertyIndex, basePropertyIndex, 2);
2587 // Check property count before property registration
2588 TypeInfo typeInfo = typeRegistry.GetTypeInfo(typeid(MyTestCustomActor));
2589 DALI_TEST_CHECK(typeInfo);
2590 BaseHandle handle = typeInfo.CreateInstance();
2591 DALI_TEST_CHECK(handle);
2592 Actor customActor = Actor::DownCast(handle);
2593 DALI_TEST_CHECK(customActor);
2594 application.GetScene().Add(customActor);
2596 tet_infoline("Get the component values, they should be the default value of the base-property");
2597 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentZeroPropertyIndex), 13.0f, TEST_LOCATION);
2598 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentOnePropertyIndex), 24.0f, TEST_LOCATION);
2599 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentTwoPropertyIndex), 35.0f, TEST_LOCATION);
2600 DALI_TEST_EQUALS(customActor.GetProperty<Vector3>(basePropertyIndex), Vector3(13.0f, 24.0f, 35.0f), TEST_LOCATION);
2602 tet_infoline("Set a component value and ensure it changes for the base property as well");
2603 customActor.SetProperty(componentZeroPropertyIndex, 125.0f);
2604 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentZeroPropertyIndex), 125.0f, TEST_LOCATION);
2605 DALI_TEST_EQUALS(customActor.GetProperty<Vector3>(basePropertyIndex), Vector3(125.0f, 24.0f, 35.0f), TEST_LOCATION);
2607 customActor.SetProperty(componentOnePropertyIndex, 225.0f);
2608 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentOnePropertyIndex), 225.0f, TEST_LOCATION);
2609 DALI_TEST_EQUALS(customActor.GetProperty<Vector3>(basePropertyIndex), Vector3(125.0f, 225.0f, 35.0f), TEST_LOCATION);
2611 customActor.SetProperty(componentTwoPropertyIndex, 325.0f);
2612 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentTwoPropertyIndex), 325.0f, TEST_LOCATION);
2613 DALI_TEST_EQUALS(customActor.GetProperty<Vector3>(basePropertyIndex), Vector3(125.0f, 225.0f, 325.0f), TEST_LOCATION);
2615 tet_infoline("Check latest scene-graph value is unchanged");
2616 DALI_TEST_EQUALS(customActor.GetCurrentProperty<Vector3>(basePropertyIndex), Vector3(13.0f, 24.0f, 35.0f), TEST_LOCATION);
2617 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentZeroPropertyIndex), 13.0f, TEST_LOCATION);
2618 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentOnePropertyIndex), 24.0f, TEST_LOCATION);
2619 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentTwoPropertyIndex), 35.0f, TEST_LOCATION);
2621 // Render and notify
2622 application.SendNotification();
2623 application.Render();
2625 tet_infoline("Check values after rendering and both retrieval methods should return the latest");
2626 DALI_TEST_EQUALS(customActor.GetProperty<Vector3>(basePropertyIndex), Vector3(125.0f, 225.0f, 325.0f), TEST_LOCATION);
2627 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentZeroPropertyIndex), 125.0f, TEST_LOCATION);
2628 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentOnePropertyIndex), 225.0f, TEST_LOCATION);
2629 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentTwoPropertyIndex), 325.0f, TEST_LOCATION);
2631 DALI_TEST_EQUALS(customActor.GetCurrentProperty<Vector3>(basePropertyIndex), Vector3(125.0f, 225.0f, 325.0f), TEST_LOCATION);
2632 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentZeroPropertyIndex), 125.0f, TEST_LOCATION);
2633 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentOnePropertyIndex), 225.0f, TEST_LOCATION);
2634 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentTwoPropertyIndex), 325.0f, TEST_LOCATION);
2636 tet_infoline("Set the base property value and ensure the component values reflect the change");
2637 customActor.SetProperty(basePropertyIndex, Vector3(1.0f, 2.0f, 3.0f));
2638 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentZeroPropertyIndex), 1.0f, TEST_LOCATION);
2639 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentOnePropertyIndex), 2.0f, TEST_LOCATION);
2640 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentTwoPropertyIndex), 3.0f, TEST_LOCATION);
2641 DALI_TEST_EQUALS(customActor.GetProperty<Vector3>(basePropertyIndex), Vector3(1.0f, 2.0f, 3.0f), TEST_LOCATION);
2646 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGetWithComponentsVector4(void)
2648 TestApplication application;
2649 TypeRegistry typeRegistry = TypeRegistry::Get();
2651 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");
2653 // Register the animatable propeties
2654 const int basePropertyIndex(ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX);
2655 const int componentZeroPropertyIndex(basePropertyIndex + 1);
2656 const int componentOnePropertyIndex(componentZeroPropertyIndex + 1);
2657 const int componentTwoPropertyIndex(componentOnePropertyIndex + 1);
2658 const int componentThreePropertyIndex(componentTwoPropertyIndex + 1);
2659 AnimatablePropertyRegistration baseAnimatableProperty(customType1, "baseProp", basePropertyIndex, Vector4(13.0f, 24.0f, 35.0, 47.0f));
2660 AnimatablePropertyComponentRegistration componentZeroAnimatableProperty(customType1, "componentZeroProp", componentZeroPropertyIndex, basePropertyIndex, 0);
2661 AnimatablePropertyComponentRegistration componentOneAnimatableProperty(customType1, "componentOneProp", componentOnePropertyIndex, basePropertyIndex, 1);
2662 AnimatablePropertyComponentRegistration componentTwoAnimatableProperty(customType1, "componentTwoProp", componentTwoPropertyIndex, basePropertyIndex, 2);
2663 AnimatablePropertyComponentRegistration componentThreeAnimatableProperty(customType1, "componentThreeProp", componentThreePropertyIndex, basePropertyIndex, 3);
2665 // Check property count before property registration
2666 TypeInfo typeInfo = typeRegistry.GetTypeInfo(typeid(MyTestCustomActor));
2667 DALI_TEST_CHECK(typeInfo);
2668 BaseHandle handle = typeInfo.CreateInstance();
2669 DALI_TEST_CHECK(handle);
2670 Actor customActor = Actor::DownCast(handle);
2671 DALI_TEST_CHECK(customActor);
2672 application.GetScene().Add(customActor);
2674 tet_infoline("Get the component values, they should be the default value of the base-property");
2675 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentZeroPropertyIndex), 13.0f, TEST_LOCATION);
2676 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentOnePropertyIndex), 24.0f, TEST_LOCATION);
2677 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentTwoPropertyIndex), 35.0f, TEST_LOCATION);
2678 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentThreePropertyIndex), 47.0f, TEST_LOCATION);
2679 DALI_TEST_EQUALS(customActor.GetProperty<Vector4>(basePropertyIndex), Vector4(13.0f, 24.0f, 35.0f, 47.0f), TEST_LOCATION);
2681 tet_infoline("Set a component value and ensure it changes for the base property as well");
2682 customActor.SetProperty(componentZeroPropertyIndex, 125.0f);
2683 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentZeroPropertyIndex), 125.0f, TEST_LOCATION);
2684 DALI_TEST_EQUALS(customActor.GetProperty<Vector4>(basePropertyIndex), Vector4(125.0f, 24.0f, 35.0f, 47.0f), TEST_LOCATION);
2686 customActor.SetProperty(componentOnePropertyIndex, 225.0f);
2687 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentOnePropertyIndex), 225.0f, TEST_LOCATION);
2688 DALI_TEST_EQUALS(customActor.GetProperty<Vector4>(basePropertyIndex), Vector4(125.0f, 225.0f, 35.0f, 47.0f), TEST_LOCATION);
2690 customActor.SetProperty(componentTwoPropertyIndex, 325.0f);
2691 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentTwoPropertyIndex), 325.0f, TEST_LOCATION);
2692 DALI_TEST_EQUALS(customActor.GetProperty<Vector4>(basePropertyIndex), Vector4(125.0f, 225.0f, 325.0f, 47.0f), TEST_LOCATION);
2694 customActor.SetProperty(componentThreePropertyIndex, 435.0f);
2695 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentThreePropertyIndex), 435.0f, TEST_LOCATION);
2696 DALI_TEST_EQUALS(customActor.GetProperty<Vector4>(basePropertyIndex), Vector4(125.0f, 225.0f, 325.0f, 435.0f), TEST_LOCATION);
2698 tet_infoline("Check latest scene-graph value is unchanged");
2699 DALI_TEST_EQUALS(customActor.GetCurrentProperty<Vector4>(basePropertyIndex), Vector4(13.0f, 24.0f, 35.0f, 47.0f), TEST_LOCATION);
2700 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentZeroPropertyIndex), 13.0f, TEST_LOCATION);
2701 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentOnePropertyIndex), 24.0f, TEST_LOCATION);
2702 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentTwoPropertyIndex), 35.0f, TEST_LOCATION);
2703 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentThreePropertyIndex), 47.0f, TEST_LOCATION);
2705 // Render and notify
2706 application.SendNotification();
2707 application.Render();
2709 tet_infoline("Check values after rendering and both retrieval methods should return the latest");
2710 DALI_TEST_EQUALS(customActor.GetProperty<Vector4>(basePropertyIndex), Vector4(125.0f, 225.0f, 325.0f, 435.0f), TEST_LOCATION);
2711 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentZeroPropertyIndex), 125.0f, TEST_LOCATION);
2712 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentOnePropertyIndex), 225.0f, TEST_LOCATION);
2713 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentTwoPropertyIndex), 325.0f, TEST_LOCATION);
2714 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentThreePropertyIndex), 435.0f, TEST_LOCATION);
2716 DALI_TEST_EQUALS(customActor.GetCurrentProperty<Vector4>(basePropertyIndex), Vector4(125.0f, 225.0f, 325.0f, 435.0f), TEST_LOCATION);
2717 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentZeroPropertyIndex), 125.0f, TEST_LOCATION);
2718 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentOnePropertyIndex), 225.0f, TEST_LOCATION);
2719 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentTwoPropertyIndex), 325.0f, TEST_LOCATION);
2720 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentThreePropertyIndex), 435.0f, TEST_LOCATION);
2722 tet_infoline("Set the base property value and ensure the component values reflect the change");
2723 customActor.SetProperty(basePropertyIndex, Vector4(1.0f, 2.0f, 3.0f, 4.0f));
2724 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentZeroPropertyIndex), 1.0f, TEST_LOCATION);
2725 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentOnePropertyIndex), 2.0f, TEST_LOCATION);
2726 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentTwoPropertyIndex), 3.0f, TEST_LOCATION);
2727 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentThreePropertyIndex), 4.0f, TEST_LOCATION);
2728 DALI_TEST_EQUALS(customActor.GetProperty<Vector4>(basePropertyIndex), Vector4(1.0f, 2.0f, 3.0f, 4.0f), TEST_LOCATION);
2733 int UtcDaliTypeInfoRegisterChildProperties01(void)
2735 TestApplication application;
2736 TypeRegistry typeRegistry = TypeRegistry::Get();
2738 tet_infoline("Register child properties on a type via name");
2740 auto customActorTypeInfo = typeRegistry.GetTypeInfo(typeid(CustomActor));
2741 auto myCustomTypeInfo = typeRegistry.GetTypeInfo(typeid(MyTestCustomActor));
2742 DALI_TEST_CHECK(customActorTypeInfo);
2743 DALI_TEST_CHECK(myCustomTypeInfo);
2745 const Property::Index WIDTH_SPECIFICATION(CHILD_PROPERTY_REGISTRATION_START_INDEX);
2746 const Property::Index HEIGHT_SPECIFICATION(CHILD_PROPERTY_REGISTRATION_START_INDEX + 1);
2747 const Property::Index MARGIN_SPECIFICATION(CHILD_PROPERTY_REGISTRATION_START_INDEX + 100);
2749 ChildPropertyRegistration(customActorTypeInfo.GetName(), "widthSpecification", WIDTH_SPECIFICATION, Property::INTEGER);
2750 ChildPropertyRegistration(customActorTypeInfo.GetName(), "heightSpecification", HEIGHT_SPECIFICATION, Property::INTEGER);
2751 ChildPropertyRegistration(myCustomTypeInfo.GetName(), "marginSpecification", MARGIN_SPECIFICATION, Property::EXTENTS);
2753 auto customActor = MyTestCustomActor::New();
2754 application.GetScene().Add(customActor);
2755 auto child = Actor::New();
2756 customActor.Add(child);
2758 child.SetProperty(WIDTH_SPECIFICATION, 33);
2760 auto value = child.GetProperty(WIDTH_SPECIFICATION);
2761 DALI_TEST_EQUALS(value, Property::Value(33), TEST_LOCATION);
2763 child.SetProperty(HEIGHT_SPECIFICATION, 44);
2764 value = child.GetProperty(HEIGHT_SPECIFICATION);
2765 DALI_TEST_EQUALS(value, Property::Value(44), TEST_LOCATION);
2767 child.SetProperty(MARGIN_SPECIFICATION, Extents(10, 10, 10, 10));
2768 value = child.GetProperty(MARGIN_SPECIFICATION);
2769 DALI_TEST_EQUALS(value, Property::Value(Extents(10, 10, 10, 10)), TEST_LOCATION);
2774 int UtcDaliTypeInfoRegisterChildProperties02(void)
2776 TestApplication application;
2777 TypeRegistry typeRegistry = TypeRegistry::Get();
2779 tet_infoline("Register child properties on a type via name");
2781 auto customActorTypeInfo = typeRegistry.GetTypeInfo(typeid(CustomActor));
2782 auto myCustomTypeInfo = typeRegistry.GetTypeInfo(typeid(MyTestCustomActor));
2783 DALI_TEST_CHECK(customActorTypeInfo);
2784 DALI_TEST_CHECK(myCustomTypeInfo);
2786 const Property::Index WIDTH_SPECIFICATION(CHILD_PROPERTY_REGISTRATION_START_INDEX);
2787 const Property::Index HEIGHT_SPECIFICATION(CHILD_PROPERTY_REGISTRATION_START_INDEX + 1);
2788 const Property::Index MARGIN_SPECIFICATION(CHILD_PROPERTY_REGISTRATION_START_INDEX + 100);
2790 ChildPropertyRegistration(customActorTypeInfo.GetName(), "widthSpecification", WIDTH_SPECIFICATION, Property::INTEGER);
2791 ChildPropertyRegistration(customActorTypeInfo.GetName(), "heightSpecification", HEIGHT_SPECIFICATION, Property::INTEGER);
2792 ChildPropertyRegistration(myCustomTypeInfo.GetName(), "marginSpecification", MARGIN_SPECIFICATION, Property::EXTENTS);
2794 auto index = customActorTypeInfo.GetChildPropertyIndex("widthSpecification");
2795 DALI_TEST_EQUALS(index, WIDTH_SPECIFICATION, TEST_LOCATION);
2797 index = customActorTypeInfo.GetChildPropertyIndex("heightSpecification");
2798 DALI_TEST_EQUALS(index, HEIGHT_SPECIFICATION, TEST_LOCATION);
2800 index = customActorTypeInfo.GetChildPropertyIndex("marginSpecification");
2801 DALI_TEST_EQUALS(index, Property::INVALID_INDEX, TEST_LOCATION);
2803 index = myCustomTypeInfo.GetChildPropertyIndex("marginSpecification");
2804 DALI_TEST_EQUALS(index, MARGIN_SPECIFICATION, TEST_LOCATION);
2806 auto name = customActorTypeInfo.GetChildPropertyName(WIDTH_SPECIFICATION);
2807 DALI_TEST_EQUALS(name, "widthSpecification", TEST_LOCATION);
2809 name = customActorTypeInfo.GetChildPropertyName(HEIGHT_SPECIFICATION);
2810 DALI_TEST_EQUALS(name, "heightSpecification", TEST_LOCATION);
2812 name = myCustomTypeInfo.GetChildPropertyName(MARGIN_SPECIFICATION);
2813 DALI_TEST_EQUALS(name, "marginSpecification", TEST_LOCATION);
2815 auto type = customActorTypeInfo.GetChildPropertyType(WIDTH_SPECIFICATION);
2816 DALI_TEST_EQUALS(type, Property::INTEGER, TEST_LOCATION);
2818 type = customActorTypeInfo.GetChildPropertyType(HEIGHT_SPECIFICATION);
2819 DALI_TEST_EQUALS(type, Property::INTEGER, TEST_LOCATION);
2821 type = myCustomTypeInfo.GetChildPropertyType(MARGIN_SPECIFICATION);
2822 DALI_TEST_EQUALS(type, Property::EXTENTS, TEST_LOCATION);
2827 int UtcDaliTypeInfoRegisterChildProperties03(void)
2829 TestApplication application;
2830 TypeRegistry typeRegistry = TypeRegistry::Get();
2832 tet_infoline("Check registered child properties can be retrieved");
2834 auto customActorTypeInfo = typeRegistry.GetTypeInfo(typeid(CustomActor));
2835 auto myCustomTypeInfo = typeRegistry.GetTypeInfo(typeid(MyTestCustomActor));
2836 DALI_TEST_CHECK(customActorTypeInfo);
2837 DALI_TEST_CHECK(myCustomTypeInfo);
2839 const Property::Index WIDTH_SPECIFICATION(CHILD_PROPERTY_REGISTRATION_START_INDEX);
2840 const Property::Index HEIGHT_SPECIFICATION(CHILD_PROPERTY_REGISTRATION_START_INDEX + 1);
2841 const Property::Index MARGIN_SPECIFICATION(CHILD_PROPERTY_REGISTRATION_START_INDEX + 100);
2843 ChildPropertyRegistration(customActorTypeInfo.GetName(), "widthSpecification", WIDTH_SPECIFICATION, Property::INTEGER);
2844 ChildPropertyRegistration(customActorTypeInfo.GetName(), "heightSpecification", HEIGHT_SPECIFICATION, Property::INTEGER);
2845 ChildPropertyRegistration(myCustomTypeInfo.GetName(), "marginSpecification", MARGIN_SPECIFICATION, Property::EXTENTS);
2847 Property::IndexContainer indices;
2848 myCustomTypeInfo.GetChildPropertyIndices(indices);
2850 auto result = std::find(indices.Begin(), indices.End(), WIDTH_SPECIFICATION);
2851 DALI_TEST_EQUALS(result != indices.End(), true, TEST_LOCATION);
2853 result = std::find(indices.Begin(), indices.End(), HEIGHT_SPECIFICATION);
2854 DALI_TEST_EQUALS(result != indices.End(), true, TEST_LOCATION);
2856 result = std::find(indices.Begin(), indices.End(), MARGIN_SPECIFICATION);
2857 DALI_TEST_EQUALS(result != indices.End(), true, TEST_LOCATION);
2862 int UtcDaliTypeInfoGetActionNameNegative(void)
2864 TestApplication application;
2865 Dali::TypeInfo instance;
2868 unsigned long arg1(0u);
2869 instance.GetActionName(arg1);
2870 DALI_TEST_CHECK(false); // Should not get here
2874 DALI_TEST_CHECK(true); // We expect an assert
2879 int UtcDaliTypeInfoGetSignalNameNegative(void)
2881 TestApplication application;
2882 Dali::TypeInfo instance;
2885 unsigned long arg1(0u);
2886 instance.GetSignalName(arg1);
2887 DALI_TEST_CHECK(false); // Should not get here
2891 DALI_TEST_CHECK(true); // We expect an assert
2896 int UtcDaliTypeInfoGetCreatorNegative(void)
2898 TestApplication application;
2899 Dali::TypeInfo instance;
2902 instance.GetCreator();
2903 DALI_TEST_CHECK(false); // Should not get here
2907 DALI_TEST_CHECK(true); // We expect an assert
2912 int UtcDaliTypeInfoGetBaseNameNegative(void)
2914 TestApplication application;
2915 Dali::TypeInfo instance;
2918 instance.GetBaseName();
2919 DALI_TEST_CHECK(false); // Should not get here
2923 DALI_TEST_CHECK(true); // We expect an assert
2928 int UtcDaliTypeInfoCreateInstanceNegative(void)
2930 TestApplication application;
2931 Dali::TypeInfo instance;
2934 instance.CreateInstance();
2935 DALI_TEST_CHECK(false); // Should not get here
2939 DALI_TEST_CHECK(true); // We expect an assert
2944 int UtcDaliTypeInfoGetActionCountNegative(void)
2946 TestApplication application;
2947 Dali::TypeInfo instance;
2950 instance.GetActionCount();
2951 DALI_TEST_CHECK(false); // Should not get here
2955 DALI_TEST_CHECK(true); // We expect an assert
2960 int UtcDaliTypeInfoGetSignalCountNegative(void)
2962 TestApplication application;
2963 Dali::TypeInfo instance;
2966 instance.GetSignalCount();
2967 DALI_TEST_CHECK(false); // Should not get here
2971 DALI_TEST_CHECK(true); // We expect an assert
2976 int UtcDaliTypeInfoGetPropertyNameNegative(void)
2978 TestApplication application;
2979 Dali::TypeInfo instance;
2983 instance.GetPropertyName(arg1);
2984 DALI_TEST_CHECK(false); // Should not get here
2988 DALI_TEST_CHECK(true); // We expect an assert
2993 int UtcDaliTypeInfoGetPropertyCountNegative(void)
2995 TestApplication application;
2996 Dali::TypeInfo instance;
2999 instance.GetPropertyCount();
3000 DALI_TEST_CHECK(false); // Should not get here
3004 DALI_TEST_CHECK(true); // We expect an assert
3009 int UtcDaliTypeInfoGetPropertyIndicesNegative(void)
3011 TestApplication application;
3012 Dali::TypeInfo instance;
3015 Dali::Vector<int> arg1;
3016 instance.GetPropertyIndices(arg1);
3017 DALI_TEST_CHECK(false); // Should not get here
3021 DALI_TEST_CHECK(true); // We expect an assert
3026 int UtcDaliTypeInfoGetChildPropertyNameNegative(void)
3028 TestApplication application;
3029 Dali::TypeInfo instance;
3033 instance.GetChildPropertyName(arg1);
3034 DALI_TEST_CHECK(false); // Should not get here
3038 DALI_TEST_CHECK(true); // We expect an assert
3043 int UtcDaliTypeInfoGetChildPropertyTypeNegative(void)
3045 TestApplication application;
3046 Dali::TypeInfo instance;
3050 instance.GetChildPropertyType(arg1);
3051 DALI_TEST_CHECK(false); // Should not get here
3055 DALI_TEST_CHECK(true); // We expect an assert
3060 int UtcDaliTypeInfoGetChildPropertyIndexNegative(void)
3062 TestApplication application;
3063 Dali::TypeInfo instance;
3067 instance.GetChildPropertyIndex(arg1);
3068 DALI_TEST_CHECK(false); // Should not get here
3072 DALI_TEST_CHECK(true); // We expect an assert
3077 int UtcDaliTypeInfoGetChildPropertyIndicesNegative(void)
3079 TestApplication application;
3080 Dali::TypeInfo instance;
3083 Dali::Vector<int> arg1;
3084 instance.GetChildPropertyIndices(arg1);
3085 DALI_TEST_CHECK(false); // Should not get here
3089 DALI_TEST_CHECK(true); // We expect an assert
3094 int UtcDaliTypeInfoGetNameNegative(void)
3096 TestApplication application;
3097 Dali::TypeInfo instance;
3101 DALI_TEST_CHECK(false); // Should not get here
3105 DALI_TEST_CHECK(true); // We expect an assert
3110 int UtcDaliTypeRegistryGetTypeInfoNegative01(void)
3112 TestApplication application;
3113 Dali::TypeRegistry instance;
3117 instance.GetTypeInfo(arg1);
3118 DALI_TEST_CHECK(false); // Should not get here
3122 DALI_TEST_CHECK(true); // We expect an assert
3127 int UtcDaliTypeRegistryGetTypeInfoNegative02(void)
3129 TestApplication application;
3130 Dali::TypeRegistry instance;
3133 instance.GetTypeInfo(typeid(unsigned int));
3134 DALI_TEST_CHECK(false); // Should not get here
3138 DALI_TEST_CHECK(true); // We expect an assert
3143 int UtcDaliTypeRegistryGetTypeNameNegative(void)
3145 TestApplication application;
3146 Dali::TypeRegistry instance;
3149 unsigned long arg1(0u);
3150 instance.GetTypeName(arg1);
3151 DALI_TEST_CHECK(false); // Should not get here
3155 DALI_TEST_CHECK(true); // We expect an assert
3160 int UtcDaliTypeRegistryGetTypeNameCountNegative(void)
3162 TestApplication application;
3163 Dali::TypeRegistry instance;
3166 instance.GetTypeNameCount();
3167 DALI_TEST_CHECK(false); // Should not get here
3171 DALI_TEST_CHECK(true); // We expect an assert