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 // Attempt to animate component property, it should not crash
1397 Animation animation = Animation::New(1.0f);
1398 animation.AnimateTo(Property(customActor, animatablePropertyComponentIndex1), 200.0f);
1401 // Check the property value
1402 DALI_TEST_EQUALS(customActor.GetProperty<Vector2>(animatablePropertyIndex), Vector2(200.0f, 225.0f), TEST_LOCATION);
1403 DALI_TEST_EQUALS(customActor.GetProperty<float>(animatablePropertyComponentIndex1), 200.0f, TEST_LOCATION);
1404 DALI_TEST_EQUALS(customActor.GetProperty<float>(animatablePropertyComponentIndex2), 225.0f, TEST_LOCATION);
1409 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationVector2AnimateByP(void)
1411 TestApplication application;
1412 TypeRegistry typeRegistry = TypeRegistry::Get();
1414 TypeInfo typeInfo = typeRegistry.GetTypeInfo(typeid(MyTestCustomActor));
1415 DALI_TEST_CHECK(typeInfo);
1416 BaseHandle handle = typeInfo.CreateInstance();
1417 DALI_TEST_CHECK(handle);
1418 Actor customActor = Actor::DownCast(handle);
1419 DALI_TEST_CHECK(customActor);
1421 const unsigned int index = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX;
1422 const unsigned int xComponentIndex = index + 1;
1423 const unsigned int yComponentIndex = index + 2;
1424 const Vector2 initialValue(20.0f, 40.0f);
1426 // Register animatable property & its components
1427 AnimatablePropertyRegistration animatableProperty1(customType1, "animatableProp1", index, initialValue);
1428 AnimatablePropertyComponentRegistration animatablePropertyComponent1(customType1, "animatableProp1X", xComponentIndex, index, 0);
1429 AnimatablePropertyComponentRegistration animatablePropertyComponent2(customType1, "animatableProp1Y", yComponentIndex, index, 1);
1431 // Check the animatable property value
1432 DALI_TEST_EQUALS(customActor.GetProperty<Vector2>(index), initialValue, TEST_LOCATION);
1433 DALI_TEST_EQUALS(customActor.GetProperty<float>(xComponentIndex), initialValue.x, TEST_LOCATION);
1434 DALI_TEST_EQUALS(customActor.GetProperty<float>(yComponentIndex), initialValue.y, TEST_LOCATION);
1436 // Render and notify
1437 application.SendNotification();
1438 application.Render();
1440 // Check the animatable property current value
1441 DALI_TEST_EQUALS(customActor.GetCurrentProperty<Vector2>(index), initialValue, TEST_LOCATION);
1442 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(xComponentIndex), initialValue.x, TEST_LOCATION);
1443 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(yComponentIndex), initialValue.y, TEST_LOCATION);
1446 const Vector2 targetValue(45.0f, 53.0f);
1447 const Vector2 relativeValue(targetValue - initialValue);
1449 Animation animation = Animation::New(1.0f);
1450 animation.AnimateBy(Property(customActor, xComponentIndex), relativeValue.x);
1451 animation.AnimateBy(Property(customActor, yComponentIndex), relativeValue.y);
1454 // Target values should change straight away
1455 DALI_TEST_EQUALS(customActor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION);
1456 DALI_TEST_EQUALS(customActor.GetProperty<float>(xComponentIndex), targetValue.x, TEST_LOCATION);
1457 DALI_TEST_EQUALS(customActor.GetProperty<float>(yComponentIndex), targetValue.y, TEST_LOCATION);
1462 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationVector3AnimateByP(void)
1464 TestApplication application;
1465 TypeRegistry typeRegistry = TypeRegistry::Get();
1467 TypeInfo typeInfo = typeRegistry.GetTypeInfo(typeid(MyTestCustomActor));
1468 DALI_TEST_CHECK(typeInfo);
1469 BaseHandle handle = typeInfo.CreateInstance();
1470 DALI_TEST_CHECK(handle);
1471 Actor customActor = Actor::DownCast(handle);
1472 DALI_TEST_CHECK(customActor);
1474 const unsigned int index = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX;
1475 const unsigned int xComponentIndex = index + 1;
1476 const unsigned int yComponentIndex = index + 2;
1477 const unsigned int zComponentIndex = index + 3;
1478 const Vector3 initialValue(20.0f, 40.0f, 50.0f);
1480 // Register animatable property & its components
1481 AnimatablePropertyRegistration animatableProperty1(customType1, "animatableProp1", index, initialValue);
1482 AnimatablePropertyComponentRegistration animatablePropertyComponent1(customType1, "animatableProp1X", xComponentIndex, index, 0);
1483 AnimatablePropertyComponentRegistration animatablePropertyComponent2(customType1, "animatableProp1Y", yComponentIndex, index, 1);
1484 AnimatablePropertyComponentRegistration animatablePropertyComponent3(customType1, "animatableProp1Z", zComponentIndex, index, 2);
1486 // Check the animatable property value
1487 DALI_TEST_EQUALS(customActor.GetProperty<Vector3>(index), initialValue, TEST_LOCATION);
1488 DALI_TEST_EQUALS(customActor.GetProperty<float>(xComponentIndex), initialValue.x, TEST_LOCATION);
1489 DALI_TEST_EQUALS(customActor.GetProperty<float>(yComponentIndex), initialValue.y, TEST_LOCATION);
1490 DALI_TEST_EQUALS(customActor.GetProperty<float>(zComponentIndex), initialValue.z, TEST_LOCATION);
1492 // Render and notify
1493 application.SendNotification();
1494 application.Render();
1496 // Check the animatable property current value
1497 DALI_TEST_EQUALS(customActor.GetCurrentProperty<Vector3>(index), initialValue, TEST_LOCATION);
1498 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(xComponentIndex), initialValue.x, TEST_LOCATION);
1499 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(yComponentIndex), initialValue.y, TEST_LOCATION);
1500 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(zComponentIndex), initialValue.z, TEST_LOCATION);
1503 const Vector3 targetValue(45.0f, 53.0f, 25.0f);
1504 const Vector3 relativeValue(targetValue - initialValue);
1506 Animation animation = Animation::New(1.0f);
1507 animation.AnimateBy(Property(customActor, xComponentIndex), relativeValue.x);
1508 animation.AnimateBy(Property(customActor, yComponentIndex), relativeValue.y);
1509 animation.AnimateBy(Property(customActor, zComponentIndex), relativeValue.z);
1512 // Target values should change straight away
1513 DALI_TEST_EQUALS(customActor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION);
1514 DALI_TEST_EQUALS(customActor.GetProperty<float>(xComponentIndex), targetValue.x, TEST_LOCATION);
1515 DALI_TEST_EQUALS(customActor.GetProperty<float>(yComponentIndex), targetValue.y, TEST_LOCATION);
1516 DALI_TEST_EQUALS(customActor.GetProperty<float>(zComponentIndex), targetValue.z, TEST_LOCATION);
1521 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationVector4AnimateByP(void)
1523 TestApplication application;
1524 TypeRegistry typeRegistry = TypeRegistry::Get();
1526 TypeInfo typeInfo = typeRegistry.GetTypeInfo(typeid(MyTestCustomActor));
1527 DALI_TEST_CHECK(typeInfo);
1528 BaseHandle handle = typeInfo.CreateInstance();
1529 DALI_TEST_CHECK(handle);
1530 Actor customActor = Actor::DownCast(handle);
1531 DALI_TEST_CHECK(customActor);
1533 const unsigned int index = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX;
1534 const unsigned int xComponentIndex = index + 1;
1535 const unsigned int yComponentIndex = index + 2;
1536 const unsigned int zComponentIndex = index + 3;
1537 const unsigned int wComponentIndex = index + 4;
1538 const Vector4 initialValue(20.0f, 40.0f, 50.0f, 60.0f);
1540 // Register animatable property & its components
1541 AnimatablePropertyRegistration animatableProperty1(customType1, "animatableProp1", index, initialValue);
1542 AnimatablePropertyComponentRegistration animatablePropertyComponent1(customType1, "animatableProp1X", xComponentIndex, index, 0);
1543 AnimatablePropertyComponentRegistration animatablePropertyComponent2(customType1, "animatableProp1Y", yComponentIndex, index, 1);
1544 AnimatablePropertyComponentRegistration animatablePropertyComponent3(customType1, "animatableProp1Z", zComponentIndex, index, 2);
1545 AnimatablePropertyComponentRegistration animatablePropertyComponent4(customType1, "animatableProp1W", wComponentIndex, index, 3);
1547 // Check the animatable property value
1548 DALI_TEST_EQUALS(customActor.GetProperty<Vector4>(index), initialValue, TEST_LOCATION);
1549 DALI_TEST_EQUALS(customActor.GetProperty<float>(xComponentIndex), initialValue.x, TEST_LOCATION);
1550 DALI_TEST_EQUALS(customActor.GetProperty<float>(yComponentIndex), initialValue.y, TEST_LOCATION);
1551 DALI_TEST_EQUALS(customActor.GetProperty<float>(zComponentIndex), initialValue.z, TEST_LOCATION);
1552 DALI_TEST_EQUALS(customActor.GetProperty<float>(wComponentIndex), initialValue.w, TEST_LOCATION);
1554 // Render and notify
1555 application.SendNotification();
1556 application.Render();
1558 // Check the animatable property current value
1559 DALI_TEST_EQUALS(customActor.GetCurrentProperty<Vector4>(index), initialValue, TEST_LOCATION);
1560 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(xComponentIndex), initialValue.x, TEST_LOCATION);
1561 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(yComponentIndex), initialValue.y, TEST_LOCATION);
1562 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(zComponentIndex), initialValue.z, TEST_LOCATION);
1563 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(wComponentIndex), initialValue.w, TEST_LOCATION);
1566 const Vector4 targetValue(45.0f, 53.0f, 25.0f, 13.0f);
1567 const Vector4 relativeValue(targetValue - initialValue);
1569 Animation animation = Animation::New(1.0f);
1570 animation.AnimateBy(Property(customActor, xComponentIndex), relativeValue.x);
1571 animation.AnimateBy(Property(customActor, yComponentIndex), relativeValue.y);
1572 animation.AnimateBy(Property(customActor, zComponentIndex), relativeValue.z);
1573 animation.AnimateBy(Property(customActor, wComponentIndex), relativeValue.w);
1576 // Target values should change straight away
1577 DALI_TEST_EQUALS(customActor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION);
1578 DALI_TEST_EQUALS(customActor.GetProperty<float>(xComponentIndex), targetValue.x, TEST_LOCATION);
1579 DALI_TEST_EQUALS(customActor.GetProperty<float>(yComponentIndex), targetValue.y, TEST_LOCATION);
1580 DALI_TEST_EQUALS(customActor.GetProperty<float>(zComponentIndex), targetValue.z, TEST_LOCATION);
1581 DALI_TEST_EQUALS(customActor.GetProperty<float>(wComponentIndex), targetValue.w, TEST_LOCATION);
1586 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationN(void)
1588 TestApplication application;
1589 TypeRegistry typeRegistry = TypeRegistry::Get();
1591 // Register animatable property with the type of Vector2
1592 int animatablePropertyIndex1(ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX);
1593 AnimatablePropertyRegistration animatableProperty1(customType1, "animatableProp1", animatablePropertyIndex1, Property::VECTOR2);
1595 // Attempt to register an animatable property component out-of-bounds index (less than)
1598 AnimatablePropertyComponentRegistration propertyComponent1(customType1, "animatableProp1X", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX - 1, animatablePropertyIndex1, 0);
1599 tet_result(TET_FAIL);
1601 catch(DaliException& e)
1603 DALI_TEST_ASSERT(e, "(index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX) && (index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX)", TEST_LOCATION);
1606 // Attempt to register an animatable property component out-of-bounds index (greater than)
1609 AnimatablePropertyComponentRegistration propertyComponent1(customType1, "animatableProp1X", ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX + 1, animatablePropertyIndex1, 0);
1610 tet_result(TET_FAIL);
1612 catch(DaliException& e)
1614 DALI_TEST_ASSERT(e, "(index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX) && (index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX)", TEST_LOCATION);
1617 // Register an animatable property component
1618 AnimatablePropertyComponentRegistration propertyComponent1(customType1, "animatableProp1X", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1, animatablePropertyIndex1, 0);
1620 // Attempt to register another animatable property component with the same component index
1623 AnimatablePropertyComponentRegistration propertyComponent2(customType1, "animatableProp1Y", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2, animatablePropertyIndex1, 0);
1624 tet_result(TET_FAIL);
1626 catch(DaliException& e)
1628 DALI_TEST_ASSERT(e, "Property component already registered", TEST_LOCATION);
1631 // Register animatable property with the type of boolean
1632 int animatablePropertyIndex2(ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2);
1633 AnimatablePropertyRegistration animatableProperty2(customType1, "animatableProp2", animatablePropertyIndex2, Property::BOOLEAN);
1635 // Attempt to register an animatable property component for the above property with boolean type
1638 AnimatablePropertyComponentRegistration propertyComponent1(customType1, "animatableProp2X", animatablePropertyIndex2 + 1, animatablePropertyIndex2, 0);
1639 tet_result(TET_FAIL);
1641 catch(DaliException& e)
1643 DALI_TEST_ASSERT(e, "Base property does not support component", TEST_LOCATION);
1649 int UtcDaliTypeRegistryChildPropertyRegistrationP(void)
1651 TestApplication application;
1652 TypeRegistry typeRegistry = TypeRegistry::Get();
1654 // Check property count before property registration
1655 TypeInfo typeInfo = typeRegistry.GetTypeInfo(typeid(MyTestCustomActor));
1656 DALI_TEST_CHECK(typeInfo);
1657 BaseHandle handle = typeInfo.CreateInstance();
1658 DALI_TEST_CHECK(handle);
1659 Actor customActor = Actor::DownCast(handle);
1660 DALI_TEST_CHECK(customActor);
1661 unsigned int initialPropertyCount(customActor.GetPropertyCount());
1663 // Register child properties to the parent
1664 std::string propertyName("childProp1");
1665 int propertyIndex(CHILD_PROPERTY_REGISTRATION_START_INDEX);
1666 Property::Type propertyType(Property::BOOLEAN);
1667 ChildPropertyRegistration childProperty1(customType1, propertyName, propertyIndex, propertyType);
1669 std::string propertyName2("childProp2");
1670 int propertyIndex2(CHILD_PROPERTY_REGISTRATION_START_INDEX + 1);
1671 Property::Type propertyType2(Property::INTEGER);
1672 ChildPropertyRegistration childProperty2(customType1, propertyName2, propertyIndex2, propertyType2);
1674 std::string propertyName3("childProp3");
1675 int propertyIndex3(CHILD_PROPERTY_REGISTRATION_START_INDEX + 2);
1676 Property::Type propertyType3(Property::FLOAT);
1677 ChildPropertyRegistration childProperty3(customType1, propertyName3, propertyIndex3, propertyType3);
1679 std::string propertyName4("childProp4");
1680 int propertyIndex4(CHILD_PROPERTY_REGISTRATION_START_INDEX + 3);
1681 Property::Type propertyType4(Property::INTEGER);
1682 ChildPropertyRegistration childProperty4(customType1, propertyName4, propertyIndex4, propertyType4);
1684 // Check property count are not changed because the child properties will not be created for the parent
1685 DALI_TEST_EQUALS(initialPropertyCount, customActor.GetPropertyCount(), TEST_LOCATION);
1687 // check the child property type
1688 Internal::TypeInfo& typeInfoImpl = GetImplementation(typeInfo);
1689 Property::Type type = typeInfoImpl.GetChildPropertyType(typeInfoImpl.GetChildPropertyIndex("childProp4"));
1690 DALI_TEST_EQUALS(type, Property::INTEGER, TEST_LOCATION);
1692 std::string unRegisteredChildName(typeInfoImpl.GetChildPropertyName(CHILD_PROPERTY_REGISTRATION_START_INDEX + 4));
1693 DALI_TEST_EQUALS(unRegisteredChildName, "", TEST_LOCATION);
1695 // Create a child actor
1696 Actor childActor = Actor::New();
1697 DALI_TEST_CHECK(childActor);
1698 unsigned int initialChildActorPropertyCount(childActor.GetPropertyCount());
1700 // The type of child properties should be Property::None as the child hasn't registered any child property yet.
1701 DALI_TEST_EQUALS(childActor.GetPropertyType(propertyIndex), Property::NONE, TEST_LOCATION);
1702 DALI_TEST_EQUALS(childActor.GetPropertyType(propertyIndex2), Property::NONE, TEST_LOCATION);
1703 DALI_TEST_EQUALS(childActor.GetPropertyType(propertyIndex3), Property::NONE, TEST_LOCATION);
1704 DALI_TEST_EQUALS(childActor.GetPropertyType(propertyIndex4), Property::NONE, TEST_LOCATION);
1706 // Set the value for the first child property when the child actor doesn't have a parent yet
1707 childActor.SetProperty(propertyIndex, true);
1709 // Check that the first child property is dynamically created
1710 DALI_TEST_EQUALS(initialChildActorPropertyCount + 1u, childActor.GetPropertyCount(), TEST_LOCATION);
1712 // Check the first child property value
1713 DALI_TEST_EQUALS(childActor.GetProperty<bool>(propertyIndex), true, TEST_LOCATION);
1715 // Check the first child property type
1716 DALI_TEST_EQUALS(childActor.GetPropertyType(propertyIndex), propertyType, TEST_LOCATION);
1718 // Check that the first child property have no name, as it doesn't have a parent yet.
1719 DALI_TEST_EQUALS(childActor.GetPropertyName(propertyIndex), "", TEST_LOCATION);
1721 // Check that the first property can't be accessed through its name, as it doesn't have a parent yet.
1722 DALI_TEST_EQUALS(childActor.GetPropertyIndex(propertyName), Property::INVALID_INDEX, TEST_LOCATION);
1724 // Create a custom property for the child with the same name as the second child property registered to the parent
1725 Property::Index customPropertyIndex = childActor.RegisterProperty(propertyName2, 100, Property::READ_WRITE);
1727 // Check that the custom property is created
1728 DALI_TEST_EQUALS(initialChildActorPropertyCount + 2u, childActor.GetPropertyCount(), TEST_LOCATION);
1730 // Check the property value
1731 DALI_TEST_EQUALS(childActor.GetProperty<int>(customPropertyIndex), 100, TEST_LOCATION);
1733 // Check the property index
1734 DALI_TEST_EQUALS(childActor.GetPropertyIndex(propertyName2), customPropertyIndex, TEST_LOCATION);
1736 // Check the property type
1737 DALI_TEST_EQUALS(childActor.GetPropertyType(customPropertyIndex), propertyType2, TEST_LOCATION);
1739 // Check the property name
1740 DALI_TEST_EQUALS(childActor.GetPropertyName(customPropertyIndex), propertyName2, TEST_LOCATION);
1742 // Now add the child actor to the parent
1743 customActor.Add(childActor);
1745 // Check that the first child property now has the correct name as previously registered to the parent
1746 DALI_TEST_EQUALS(childActor.GetPropertyName(propertyIndex), propertyName, TEST_LOCATION);
1748 // Check that the child property index for the first child property can now be retrieved through its child property name
1749 DALI_TEST_EQUALS(childActor.GetPropertyIndex(propertyName), propertyIndex, TEST_LOCATION);
1751 // Check that the second child property now has the correct index as previously registered to the parent
1752 DALI_TEST_EQUALS(childActor.GetPropertyName(propertyIndex2), propertyName2, TEST_LOCATION);
1754 // Check that the second child property can be accessed through both its custom property index and its child property index
1755 DALI_TEST_EQUALS(childActor.GetProperty<int>(customPropertyIndex), 100, TEST_LOCATION);
1756 DALI_TEST_EQUALS(childActor.GetProperty<int>(propertyIndex2), 100, TEST_LOCATION);
1757 DALI_TEST_EQUALS(childActor.GetPropertyType(customPropertyIndex), propertyType2, TEST_LOCATION);
1758 DALI_TEST_EQUALS(childActor.GetPropertyType(propertyIndex2), propertyType2, TEST_LOCATION);
1760 // Check that the child property index for the second child property can now be retrieved through its child property name
1761 DALI_TEST_EQUALS(childActor.GetPropertyIndex(propertyName2), propertyIndex2, TEST_LOCATION);
1763 // Set the value for the third child property when the child actor is already added to the parent
1764 childActor.SetProperty(propertyIndex3, 0.15f);
1766 // Check that the third child property is dynamically created
1767 DALI_TEST_EQUALS(initialChildActorPropertyCount + 3u, childActor.GetPropertyCount(), TEST_LOCATION);
1769 // Check the third child property value
1770 DALI_TEST_EQUALS(childActor.GetProperty<float>(propertyIndex3), 0.15f, TEST_LOCATION);
1772 // Check the third child property type
1773 DALI_TEST_EQUALS(childActor.GetPropertyType(propertyIndex3), propertyType3, TEST_LOCATION);
1775 // Check the third child property name
1776 DALI_TEST_EQUALS(childActor.GetPropertyName(propertyIndex3), propertyName3, TEST_LOCATION);
1778 // Check the third child property index.
1779 DALI_TEST_EQUALS(childActor.GetPropertyIndex(propertyName3), propertyIndex3, TEST_LOCATION);
1781 // Create a custom property for the child with the same name as the fourth child property registered to the parent
1782 Property::Index customPropertyIndex2 = childActor.RegisterProperty(propertyName4, 20, Property::READ_WRITE);
1784 // Check that the custom property is created
1785 DALI_TEST_EQUALS(initialChildActorPropertyCount + 4u, childActor.GetPropertyCount(), TEST_LOCATION);
1787 // Check the fourth child property value
1788 DALI_TEST_EQUALS(childActor.GetProperty<int>(propertyIndex4), 20, TEST_LOCATION);
1789 DALI_TEST_EQUALS(childActor.GetProperty<int>(customPropertyIndex2), 20, TEST_LOCATION);
1791 // Check the fourth child property type
1792 DALI_TEST_EQUALS(childActor.GetPropertyType(propertyIndex4), propertyType4, TEST_LOCATION);
1793 DALI_TEST_EQUALS(childActor.GetPropertyType(customPropertyIndex2), propertyType4, TEST_LOCATION);
1795 // Check the fourth child property name
1796 DALI_TEST_EQUALS(childActor.GetPropertyName(propertyIndex4), propertyName4, TEST_LOCATION);
1797 DALI_TEST_EQUALS(childActor.GetPropertyName(customPropertyIndex2), propertyName4, TEST_LOCATION);
1799 // Check the fourth child property index.
1800 DALI_TEST_EQUALS(childActor.GetPropertyIndex(propertyName4), propertyIndex4, TEST_LOCATION);
1802 // Now create another parent actor with different child properties registered
1803 TypeInfo typeInfo2 = typeRegistry.GetTypeInfo("MyNamedActor");
1804 DALI_TEST_CHECK(typeInfo2);
1805 BaseHandle handle2 = typeInfo2.CreateInstance();
1806 DALI_TEST_CHECK(handle2);
1807 Actor customActor2 = Actor::DownCast(handle2);
1808 DALI_TEST_CHECK(customActor2);
1810 // Register child properties to the new parent
1811 std::string newPropertyName("newChildProp");
1812 int newPropertyIndex(CHILD_PROPERTY_REGISTRATION_START_INDEX); // The same index as the first child property "childProp1" in the old parent
1813 Property::Type newPropertyType(Property::VECTOR2);
1814 ChildPropertyRegistration newChildProperty(namedActorType, newPropertyName, newPropertyIndex, newPropertyType);
1816 std::string newPropertyName2("childProp3"); // The same name as the third child property in the old parent
1817 int newPropertyIndex2(CHILD_PROPERTY_REGISTRATION_START_INDEX + 1); // The same index as the second child property "childProp2" in the old parent
1818 Property::Type newPropertyType2(Property::FLOAT); // The same type as the third child property in the old parent
1819 ChildPropertyRegistration newChildProperty2(namedActorType, newPropertyName2, newPropertyIndex2, newPropertyType2);
1821 // Now move the child actor to the new parent
1822 customActor2.Add(childActor);
1824 // "childProp1" is not a valid child property supported by the new parent, so nothing changed
1825 DALI_TEST_EQUALS(childActor.GetPropertyType(propertyIndex), propertyType, TEST_LOCATION);
1826 DALI_TEST_EQUALS(childActor.GetPropertyName(propertyIndex), propertyName, TEST_LOCATION);
1827 DALI_TEST_EQUALS(childActor.GetPropertyIndex(propertyName), propertyIndex, TEST_LOCATION);
1829 // "childProp3" is a valid child property supported by the new parent
1830 // So it should get its new child property index and should just work
1831 DALI_TEST_EQUALS(childActor.GetPropertyType(newPropertyIndex2), newPropertyType2, TEST_LOCATION);
1832 DALI_TEST_EQUALS(childActor.GetPropertyName(newPropertyIndex2), newPropertyName2, TEST_LOCATION);
1833 DALI_TEST_EQUALS(childActor.GetPropertyIndex(newPropertyName2), newPropertyIndex2, TEST_LOCATION);
1834 DALI_TEST_EQUALS(childActor.GetProperty<float>(newPropertyIndex2), 0.15f, TEST_LOCATION);
1836 // Now register a custom property called "newChildProp"
1837 Property::Index customPropertyIndex3 = childActor.RegisterProperty("newChildProp", Vector2(10.0f, 10.0f), Property::READ_WRITE);
1839 // Check that the custom property is created
1840 DALI_TEST_EQUALS(initialChildActorPropertyCount + 5u, childActor.GetPropertyCount(), TEST_LOCATION);
1842 // This is a valid child property registered to the new parent
1843 // So should be able to access it through both its custom property index and its registered child property index
1844 DALI_TEST_EQUALS(childActor.GetPropertyType(newPropertyIndex), newPropertyType, TEST_LOCATION);
1845 DALI_TEST_EQUALS(childActor.GetPropertyType(customPropertyIndex3), newPropertyType, TEST_LOCATION);
1846 DALI_TEST_EQUALS(childActor.GetPropertyName(newPropertyIndex), newPropertyName, TEST_LOCATION); // This should return the new name, although the child property index remains the same
1847 DALI_TEST_EQUALS(childActor.GetPropertyName(customPropertyIndex3), newPropertyName, TEST_LOCATION);
1848 DALI_TEST_EQUALS(childActor.GetProperty<Vector2>(newPropertyIndex), Vector2(10.0f, 10.0f), TEST_LOCATION);
1849 DALI_TEST_EQUALS(childActor.GetProperty<Vector2>(customPropertyIndex3), Vector2(10.0f, 10.0f), TEST_LOCATION);
1851 // Should return the child property index by given its name
1852 DALI_TEST_EQUALS(childActor.GetPropertyIndex(newPropertyName), newPropertyIndex, TEST_LOCATION);
1857 int UtcDaliTypeRegistryChildPropertyRegistrationN(void)
1859 TestApplication application;
1860 TypeRegistry typeRegistry = TypeRegistry::Get();
1862 // Attempt to register a child property type out-of-bounds index (less than)
1865 ChildPropertyRegistration property1(customType1, "propName", CHILD_PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN);
1866 tet_result(TET_FAIL);
1868 catch(DaliException& e)
1870 DALI_TEST_ASSERT(e, "(index >= CHILD_PROPERTY_REGISTRATION_START_INDEX) && (index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX)", TEST_LOCATION);
1873 // Attempt to register a child property type out-of-bounds index (greater than)
1876 ChildPropertyRegistration property1(customType1, "propName", CHILD_PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN);
1877 tet_result(TET_FAIL);
1879 catch(DaliException& e)
1881 DALI_TEST_ASSERT(e, "(index >= CHILD_PROPERTY_REGISTRATION_START_INDEX) && (index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX)", TEST_LOCATION);
1887 /*******************************************************************************
1889 * Action through the base handle
1891 ******************************************************************************/
1892 int UtcDaliTypeRegistryActionViaBaseHandle(void)
1894 TestApplication application;
1898 type = TypeRegistry::Get().GetTypeInfo("Actor");
1899 DALI_TEST_CHECK(type);
1901 BaseHandle hdl = type.CreateInstance();
1902 DALI_TEST_CHECK(hdl);
1904 Actor a = Actor::DownCast(hdl);
1907 a.SetProperty(Actor::Property::VISIBLE, false);
1909 application.SendNotification();
1910 application.Render(0);
1911 DALI_TEST_CHECK(!a.GetCurrentProperty<bool>(Actor::Property::VISIBLE));
1913 Property::Map attributes;
1915 DALI_TEST_CHECK(hdl.DoAction("show", attributes));
1917 application.SendNotification();
1918 application.Render(0);
1919 DALI_TEST_CHECK(a.GetCurrentProperty<bool>(Actor::Property::VISIBLE));
1921 DALI_TEST_CHECK(!hdl.DoAction("unknownAction", attributes));
1925 int UtcDaliPropertyRegistrationFunctions(void)
1927 TestApplication application;
1928 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 10;
1930 // Attempt to register a property without a setter
1933 PropertyRegistration property1(customType1, "propName", propertyIndex++, Property::BOOLEAN, NULL, &GetProperty);
1934 tet_result(TET_PASS);
1936 catch(DaliException& e)
1938 tet_result(TET_FAIL);
1941 // Attempt to register a property without a getter
1944 PropertyRegistration property1(customType1, "propName", propertyIndex++, Property::BOOLEAN, NULL, NULL);
1945 tet_result(TET_FAIL);
1947 catch(DaliException& e)
1949 DALI_TEST_ASSERT(e, "! \"GetProperty", TEST_LOCATION);
1954 int UtcDaliPropertyRegistrationAddSameIndex(void)
1956 TestApplication application;
1957 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 100;
1959 // Add one property with a valid property index
1960 PropertyRegistration property1(customType1, "propName", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty);
1962 // Attempt to add another property with the same index
1965 PropertyRegistration property2(customType1, "propName2", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty);
1967 catch(DaliException& e)
1969 DALI_TEST_ASSERT(e, "! \"Property index already added", TEST_LOCATION);
1972 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 100;
1974 // Add one property with a valid property index
1975 AnimatablePropertyRegistration property3(customType1, "animPropName", animatablePropertyIndex, Property::BOOLEAN);
1977 // Attempt to add another property with the same index
1980 AnimatablePropertyRegistration property4(customType1, "animPropName2", animatablePropertyIndex, Property::BOOLEAN);
1982 catch(DaliException& e)
1984 DALI_TEST_ASSERT(e, "! \"Property index already added", TEST_LOCATION);
1989 int UtcDaliPropertyRegistrationPropertyWritableP(void)
1991 TestApplication application;
1992 int propertyIndex1 = PROPERTY_REGISTRATION_START_INDEX + 200;
1993 int propertyIndex2 = PROPERTY_REGISTRATION_START_INDEX + 201;
1995 // Add two properties, one with SetProperty, one without
1996 PropertyRegistration property1(customType1, "propNameReadwrite", propertyIndex1, Property::BOOLEAN, &SetProperty, &GetProperty);
1997 PropertyRegistration property2(customType1, "propNameReadonly", propertyIndex2, Property::BOOLEAN, NULL, &GetProperty);
1999 // Create custom-actor
2000 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo(typeid(MyTestCustomActor));
2001 DALI_TEST_CHECK(typeInfo);
2002 BaseHandle handle = typeInfo.CreateInstance();
2003 DALI_TEST_CHECK(handle);
2004 Actor customActor = Actor::DownCast(handle);
2005 DALI_TEST_CHECK(customActor);
2007 // Check whether properties are writable
2008 DALI_TEST_CHECK(customActor.IsPropertyWritable(propertyIndex1));
2009 DALI_TEST_CHECK(!customActor.IsPropertyWritable(propertyIndex2));
2011 // Check the property is writable in the type registry
2012 Internal::TypeInfo& typeInfoImpl = GetImplementation(typeInfo);
2014 DALI_TEST_EQUALS(typeInfoImpl.IsPropertyWritable(propertyIndex1), true, TEST_LOCATION);
2019 int UtcDaliPropertyRegistrationPropertyWritableN(void)
2021 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo(typeid(MyTestCustomActor));
2022 Internal::TypeInfo& typeInfoImpl = GetImplementation(typeInfo);
2024 DALI_TEST_EQUALS(typeInfoImpl.IsPropertyWritable(Actor::Property::COLOR), true, TEST_LOCATION);
2029 int UtcDaliPropertyRegistrationPropertyAnimatable(void)
2031 TestApplication application;
2032 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 400;
2033 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 400;
2035 // These properties are not animatable
2036 PropertyRegistration property1(customType1, "propName", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty);
2038 // These properties are animatable
2039 AnimatablePropertyRegistration property2(customType1, "animPropName", animatablePropertyIndex, Property::BOOLEAN);
2041 // Create custom-actor
2042 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo(typeid(MyTestCustomActor));
2043 DALI_TEST_CHECK(typeInfo);
2044 BaseHandle handle = typeInfo.CreateInstance();
2045 DALI_TEST_CHECK(handle);
2046 Actor customActor = Actor::DownCast(handle);
2047 DALI_TEST_CHECK(customActor);
2049 // Check if animatable
2050 DALI_TEST_CHECK(!customActor.IsPropertyAnimatable(propertyIndex));
2051 DALI_TEST_CHECK(customActor.IsPropertyAnimatable(animatablePropertyIndex));
2053 // Create another instance of custom-actor
2054 BaseHandle handle2 = typeInfo.CreateInstance();
2055 DALI_TEST_CHECK(handle2);
2056 Actor customActor2 = Actor::DownCast(handle2);
2057 DALI_TEST_CHECK(customActor2);
2059 // Check if animatable
2060 DALI_TEST_CHECK(!customActor2.IsPropertyAnimatable(propertyIndex));
2061 DALI_TEST_CHECK(customActor2.IsPropertyAnimatable(animatablePropertyIndex));
2065 int UtcDaliPropertyRegistrationUnregisteredGetAndSet(void)
2067 TestApplication application;
2068 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 2000;
2069 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2000;
2071 // Create custom-actor
2072 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo(typeid(MyTestCustomActor));
2073 DALI_TEST_CHECK(typeInfo);
2074 BaseHandle handle = typeInfo.CreateInstance();
2075 DALI_TEST_CHECK(handle);
2076 Actor customActor = Actor::DownCast(handle);
2077 DALI_TEST_CHECK(customActor);
2079 // Try to set an index that hasn't been registered, this is a no-op for now, to be fixed in future
2080 customActor.SetProperty(propertyIndex, true);
2081 // DALI_TEST_EQUALS( true, customActor.GetProperty( propertyIndex ).Get<bool>(), TEST_LOCATION);
2083 // Try to set an index that hasn't been registered
2084 customActor.SetProperty(animatablePropertyIndex, true);
2085 DALI_TEST_EQUALS(true, customActor.GetProperty(animatablePropertyIndex).Get<bool>(), TEST_LOCATION);
2090 int UtcDaliLongPressGestureDetectorTypeRegistry(void)
2092 TestApplication application;
2094 Actor actor = Actor::New();
2095 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2096 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2097 application.GetScene().Add(actor);
2101 type = TypeRegistry::Get().GetTypeInfo("LongPressGestureDetector");
2102 DALI_TEST_CHECK(type);
2103 BaseHandle handle = type.CreateInstance();
2104 DALI_TEST_CHECK(handle);
2105 LongPressGestureDetector detector = LongPressGestureDetector::DownCast(handle);
2106 DALI_TEST_CHECK(detector);
2108 // Attach actor to detector
2110 GestureReceivedFunctor functor(data);
2111 detector.Attach(actor);
2113 // Connect to signal through type
2114 handle.ConnectSignal(&application, "longPressDetected", functor);
2116 // Render and notify
2117 application.SendNotification();
2118 application.Render();
2121 TestGenerateLongPress(application, 50.0f, 10.0f);
2122 TestEndLongPress(application, 50.0f, 10.0f);
2124 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2128 int UtcDaliPanGestureDetectorTypeRegistry(void)
2130 TestApplication application;
2132 Actor actor = Actor::New();
2133 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2134 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2135 application.GetScene().Add(actor);
2139 type = TypeRegistry::Get().GetTypeInfo("PanGestureDetector");
2140 DALI_TEST_CHECK(type);
2141 BaseHandle handle = type.CreateInstance();
2142 DALI_TEST_CHECK(handle);
2143 PanGestureDetector detector = PanGestureDetector::DownCast(handle);
2144 DALI_TEST_CHECK(detector);
2146 // Attach actor to detector
2148 GestureReceivedFunctor functor(data);
2149 detector.Attach(actor);
2151 // Connect to signal through type
2152 handle.ConnectSignal(&application, "panDetected", functor);
2154 // Render and notify
2155 application.SendNotification();
2156 application.Render();
2159 TestGenerateMiniPan(application);
2160 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2164 int UtcDaliPinchGestureDetectorTypeRegistry(void)
2166 TestApplication application;
2168 Actor actor = Actor::New();
2169 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2170 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2171 application.GetScene().Add(actor);
2175 type = TypeRegistry::Get().GetTypeInfo("PinchGestureDetector");
2176 DALI_TEST_CHECK(type);
2177 BaseHandle handle = type.CreateInstance();
2178 DALI_TEST_CHECK(handle);
2179 PinchGestureDetector detector = PinchGestureDetector::DownCast(handle);
2180 DALI_TEST_CHECK(detector);
2182 // Attach actor to detector
2184 GestureReceivedFunctor functor(data);
2185 detector.Attach(actor);
2187 // Connect to signal through type
2188 handle.ConnectSignal(&application, "pinchDetected", functor);
2190 // Render and notify
2191 application.SendNotification();
2192 application.Render();
2195 TestGeneratePinch(application);
2197 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2201 int UtcDaliRotationGestureDetectorTypeRegistry(void)
2203 TestApplication application;
2205 Actor actor = Actor::New();
2206 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2207 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2208 application.GetScene().Add(actor);
2212 type = TypeRegistry::Get().GetTypeInfo("RotationGestureDetector");
2213 DALI_TEST_CHECK(type);
2214 BaseHandle handle = type.CreateInstance();
2215 DALI_TEST_CHECK(handle);
2216 RotationGestureDetector detector = RotationGestureDetector::DownCast(handle);
2217 DALI_TEST_CHECK(detector);
2219 // Attach actor to detector
2221 GestureReceivedFunctor functor(data);
2222 detector.Attach(actor);
2224 // Connect to signal through type
2225 handle.ConnectSignal(&application, "rotationDetected", functor);
2227 // Render and notify
2228 application.SendNotification();
2229 application.Render();
2232 TestGenerateRotation(application);
2234 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2238 int UtcDaliTapGestureDetectorTypeRegistry(void)
2240 TestApplication application;
2242 Actor actor = Actor::New();
2243 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2244 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2245 application.GetScene().Add(actor);
2249 type = TypeRegistry::Get().GetTypeInfo("TapGestureDetector");
2250 DALI_TEST_CHECK(type);
2251 BaseHandle handle = type.CreateInstance();
2252 DALI_TEST_CHECK(handle);
2253 TapGestureDetector detector = TapGestureDetector::DownCast(handle);
2254 DALI_TEST_CHECK(detector);
2256 // Attach actor to detector
2258 GestureReceivedFunctor functor(data);
2259 detector.Attach(actor);
2261 // Connect to signal through type
2262 handle.ConnectSignal(&application, "tapDetected", functor);
2264 // Render and notify
2265 application.SendNotification();
2266 application.Render();
2269 TestGenerateTap(application, 50.0, 10.0, 100);
2271 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2275 int UtcDaliTypeRegistryNamedType(void)
2277 TestApplication application;
2278 TypeRegistry typeRegistry = TypeRegistry::Get();
2280 // Create a normal actor
2281 BaseHandle actorHandle = typeRegistry.GetTypeInfo("Actor").CreateInstance();
2282 DALI_TEST_CHECK(actorHandle);
2283 Actor actor(Actor::DownCast(actorHandle));
2284 DALI_TEST_CHECK(actor);
2285 unsigned int actorPropertyCount(actor.GetPropertyCount());
2287 // Create Named Actor Type
2288 BaseHandle namedHandle = typeRegistry.GetTypeInfo("MyNamedActor").CreateInstance();
2289 DALI_TEST_CHECK(namedHandle);
2290 Actor namedActor(Actor::DownCast(namedHandle));
2291 DALI_TEST_CHECK(namedActor);
2292 unsigned int namedActorPropertyCount(namedActor.GetPropertyCount());
2294 DALI_TEST_CHECK(namedActorPropertyCount > actorPropertyCount);
2298 int UtcDaliTypeInfoGetActionNameP(void)
2300 TestApplication application;
2301 TypeRegistry typeRegistry = TypeRegistry::Get();
2303 TypeInfo typeInfo = typeRegistry.GetTypeInfo("Actor");
2304 DALI_TEST_CHECK(typeInfo);
2306 DALI_TEST_CHECK(0 != typeInfo.GetActionCount());
2308 std::string name = typeInfo.GetActionName(0);
2310 DALI_TEST_EQUALS(name, "show", TEST_LOCATION);
2312 TypeInfo typeInfo2 = typeRegistry.GetTypeInfo("MyTestCustomActor");
2314 // search for show action in base class, given a derived class
2315 bool foundChildAction = false;
2316 for(std::size_t i = 0; i < typeInfo2.GetActionCount(); i++)
2318 std::string name = typeInfo2.GetActionName(i);
2321 foundChildAction = true;
2325 DALI_TEST_EQUALS(foundChildAction, true, TEST_LOCATION);
2330 int UtcDaliTypeInfoGetActionNameN(void)
2332 TestApplication application;
2333 TypeRegistry typeRegistry = TypeRegistry::Get();
2335 TypeInfo typeInfo = typeRegistry.GetTypeInfo("Actor");
2336 DALI_TEST_CHECK(typeInfo);
2338 DALI_TEST_CHECK(0 != typeInfo.GetActionCount());
2340 std::string name = typeInfo.GetActionName(std::numeric_limits<size_t>::max());
2342 DALI_TEST_EQUALS(0u, name.size(), TEST_LOCATION);
2347 int UtcDaliTypeInfoGetSignalNameP(void)
2349 TestApplication application;
2350 TypeRegistry typeRegistry = TypeRegistry::Get();
2352 TypeInfo typeInfo = typeRegistry.GetTypeInfo("Actor");
2353 DALI_TEST_CHECK(typeInfo);
2355 DALI_TEST_CHECK(0 != typeInfo.GetSignalCount());
2357 std::string name = typeInfo.GetSignalName(0);
2359 DALI_TEST_EQUALS(name, "hovered", TEST_LOCATION);
2361 TypeInfo typeInfo2 = typeRegistry.GetTypeInfo("MyTestCustomActor");
2363 // search for signal in base class, given a derived class
2364 bool foundSignal = false;
2365 for(std::size_t i = 0; i < typeInfo2.GetSignalCount(); i++)
2367 std::string name = typeInfo2.GetSignalName(i);
2368 if(name == "hovered")
2374 DALI_TEST_EQUALS(foundSignal, true, TEST_LOCATION);
2379 int UtcDaliTypeInfoGetSignalNameN(void)
2381 TestApplication application;
2382 TypeRegistry typeRegistry = TypeRegistry::Get();
2384 TypeInfo typeInfo = typeRegistry.GetTypeInfo("Actor");
2385 DALI_TEST_CHECK(typeInfo);
2387 DALI_TEST_CHECK(0 != typeInfo.GetSignalCount());
2389 std::string name = typeInfo.GetSignalName(std::numeric_limits<size_t>::max());
2391 DALI_TEST_EQUALS(0u, name.size(), TEST_LOCATION);
2396 int UtcDaliTypeInfoGetCreatorP(void)
2398 TestApplication application;
2399 TypeRegistry typeRegistry = TypeRegistry::Get();
2401 TypeInfo typeInfo = typeRegistry.GetTypeInfo("Actor");
2402 DALI_TEST_CHECK(typeInfo);
2404 TypeInfo::CreateFunction createFn = typeInfo.GetCreator();
2405 DALI_TEST_EQUALS(createFn != NULL, true, TEST_LOCATION);
2409 BaseHandle handle = createFn();
2410 DALI_TEST_EQUALS((bool)handle, true, TEST_LOCATION);
2416 int UtcDaliTypeInfoGetCreatorN(void)
2418 TestApplication application;
2419 TypeRegistry typeRegistry = TypeRegistry::Get();
2421 TypeInfo typeInfo = typeRegistry.GetTypeInfo("MyTestCustomActor3");
2422 DALI_TEST_CHECK(typeInfo);
2424 TypeInfo::CreateFunction createFn = typeInfo.GetCreator();
2425 DALI_TEST_EQUALS(createFn == NULL, true, TEST_LOCATION);
2430 int UtcDaliTypeInfoGetPropertyCountP1(void)
2432 TestApplication application;
2433 TypeRegistry typeRegistry = TypeRegistry::Get();
2435 TypeInfo typeInfo = typeRegistry.GetTypeInfo("Actor");
2436 DALI_TEST_CHECK(typeInfo);
2437 size_t actorPropertyCount = typeInfo.GetPropertyCount();
2439 DALI_TEST_EQUALS(actorPropertyCount, Actor::New().GetPropertyCount(), TEST_LOCATION); // No event only props
2443 int UtcDaliTypeInfoGetPropertyCountP2(void)
2445 TestApplication application;
2446 TypeRegistry typeRegistry = TypeRegistry::Get();
2448 TypeInfo typeInfo = typeRegistry.GetTypeInfo("MyTestCustomActor2");
2449 DALI_TEST_CHECK(typeInfo);
2450 size_t propertyCount = typeInfo.GetPropertyCount();
2451 Property::IndexContainer indices;
2452 typeInfo.GetPropertyIndices(indices);
2454 DALI_TEST_EQUALS(propertyCount > 0 && propertyCount <= indices.Size(), true, TEST_LOCATION);
2455 DALI_TEST_EQUALS(propertyCount, Actor::New().GetPropertyCount() + 2, TEST_LOCATION);
2460 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGet01(void)
2462 TestApplication application;
2463 TypeRegistry typeRegistry = TypeRegistry::Get();
2465 tet_infoline("Register a type registered animatable property and ensure set/get behaviour works synchronously");
2467 // Register animatable property
2468 const int animatablePropertyIndex(ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX);
2469 AnimatablePropertyRegistration animatableProperty(customType1, "animatableProp1", animatablePropertyIndex, Property::FLOAT);
2471 // Check property count before property registration
2472 TypeInfo typeInfo = typeRegistry.GetTypeInfo(typeid(MyTestCustomActor));
2473 DALI_TEST_CHECK(typeInfo);
2474 BaseHandle handle = typeInfo.CreateInstance();
2475 DALI_TEST_CHECK(handle);
2476 Actor customActor = Actor::DownCast(handle);
2477 DALI_TEST_CHECK(customActor);
2478 application.GetScene().Add(customActor);
2480 tet_infoline("Set the value and ensure it changes straight away");
2481 DALI_TEST_EQUALS(customActor.GetProperty<float>(animatablePropertyIndex), 0.0f, TEST_LOCATION);
2482 customActor.SetProperty(animatablePropertyIndex, 25.0f);
2483 DALI_TEST_EQUALS(customActor.GetProperty<float>(animatablePropertyIndex), 25.0f, TEST_LOCATION);
2485 tet_infoline("Check latest scene-graph value is unchanged");
2486 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(animatablePropertyIndex), 0.0f, TEST_LOCATION);
2488 // Render and notify
2489 application.SendNotification();
2490 application.Render();
2492 tet_infoline("Check values after rendering and both retrieval methods should return the latest");
2494 DALI_TEST_EQUALS(customActor.GetProperty<float>(animatablePropertyIndex), 25.0f, TEST_LOCATION);
2495 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(animatablePropertyIndex), 25.0f, TEST_LOCATION);
2500 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGetWithComponentsVector2(void)
2502 TestApplication application;
2503 TypeRegistry typeRegistry = TypeRegistry::Get();
2505 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");
2507 // Register the animatable propeties
2508 const int basePropertyIndex(ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX);
2509 const int componentZeroPropertyIndex(basePropertyIndex + 1);
2510 const int componentOnePropertyIndex(componentZeroPropertyIndex + 1);
2511 AnimatablePropertyRegistration baseAnimatableProperty(customType1, "baseProp", basePropertyIndex, Vector2(13.0f, 24.0f));
2512 AnimatablePropertyComponentRegistration componentZeroAnimatableProperty(customType1, "componentZeroProp", componentZeroPropertyIndex, basePropertyIndex, 0);
2513 AnimatablePropertyComponentRegistration componentOneAnimatableProperty(customType1, "componentOneProp", componentOnePropertyIndex, basePropertyIndex, 1);
2515 // Check property count before property registration
2516 TypeInfo typeInfo = typeRegistry.GetTypeInfo(typeid(MyTestCustomActor));
2517 DALI_TEST_CHECK(typeInfo);
2518 BaseHandle handle = typeInfo.CreateInstance();
2519 DALI_TEST_CHECK(handle);
2520 Actor customActor = Actor::DownCast(handle);
2521 DALI_TEST_CHECK(customActor);
2522 application.GetScene().Add(customActor);
2524 tet_infoline("Get the component values, they should be the default value of the base-property");
2525 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentZeroPropertyIndex), 13.0f, TEST_LOCATION);
2526 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentOnePropertyIndex), 24.0f, TEST_LOCATION);
2527 DALI_TEST_EQUALS(customActor.GetProperty<Vector2>(basePropertyIndex), Vector2(13.0f, 24.0f), TEST_LOCATION);
2529 tet_infoline("Set a component value and ensure it changes for the base property as well");
2530 customActor.SetProperty(componentZeroPropertyIndex, 125.0f);
2531 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentZeroPropertyIndex), 125.0f, TEST_LOCATION);
2532 DALI_TEST_EQUALS(customActor.GetProperty<Vector2>(basePropertyIndex), Vector2(125.0f, 24.0f), TEST_LOCATION);
2534 customActor.SetProperty(componentOnePropertyIndex, 225.0f);
2535 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentOnePropertyIndex), 225.0f, TEST_LOCATION);
2536 DALI_TEST_EQUALS(customActor.GetProperty<Vector2>(basePropertyIndex), Vector2(125.0f, 225.0f), TEST_LOCATION);
2538 tet_infoline("Check latest scene-graph value is unchanged");
2539 DALI_TEST_EQUALS(customActor.GetCurrentProperty<Vector2>(basePropertyIndex), Vector2(13.0f, 24.0f), TEST_LOCATION);
2540 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentZeroPropertyIndex), 13.0f, TEST_LOCATION);
2541 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentOnePropertyIndex), 24.0f, TEST_LOCATION);
2543 // Render and notify
2544 application.SendNotification();
2545 application.Render();
2547 tet_infoline("Check values after rendering and both retrieval methods should return the latest");
2548 DALI_TEST_EQUALS(customActor.GetProperty<Vector2>(basePropertyIndex), Vector2(125.0f, 225.0f), TEST_LOCATION);
2549 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentZeroPropertyIndex), 125.0f, TEST_LOCATION);
2550 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentOnePropertyIndex), 225.0f, TEST_LOCATION);
2552 DALI_TEST_EQUALS(customActor.GetCurrentProperty<Vector2>(basePropertyIndex), Vector2(125.0f, 225.0f), TEST_LOCATION);
2553 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentZeroPropertyIndex), 125.0f, TEST_LOCATION);
2554 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentOnePropertyIndex), 225.0f, TEST_LOCATION);
2556 tet_infoline("Set the base property value and ensure the component values reflect the change");
2557 customActor.SetProperty(basePropertyIndex, Vector2(1.0f, 2.0f));
2558 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentZeroPropertyIndex), 1.0f, TEST_LOCATION);
2559 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentOnePropertyIndex), 2.0f, TEST_LOCATION);
2560 DALI_TEST_EQUALS(customActor.GetProperty<Vector2>(basePropertyIndex), Vector2(1.0f, 2.0f), TEST_LOCATION);
2565 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGetWithComponentsVector3(void)
2567 TestApplication application;
2568 TypeRegistry typeRegistry = TypeRegistry::Get();
2570 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");
2572 // Register the animatable propeties
2573 const int basePropertyIndex(ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX);
2574 const int componentZeroPropertyIndex(basePropertyIndex + 1);
2575 const int componentOnePropertyIndex(componentZeroPropertyIndex + 1);
2576 const int componentTwoPropertyIndex(componentOnePropertyIndex + 1);
2577 AnimatablePropertyRegistration baseAnimatableProperty(customType1, "baseProp", basePropertyIndex, Vector3(13.0f, 24.0f, 35.0));
2578 AnimatablePropertyComponentRegistration componentZeroAnimatableProperty(customType1, "componentZeroProp", componentZeroPropertyIndex, basePropertyIndex, 0);
2579 AnimatablePropertyComponentRegistration componentOneAnimatableProperty(customType1, "componentOneProp", componentOnePropertyIndex, basePropertyIndex, 1);
2580 AnimatablePropertyComponentRegistration componentTwoAnimatableProperty(customType1, "componentTwoProp", componentTwoPropertyIndex, basePropertyIndex, 2);
2582 // Check property count before property registration
2583 TypeInfo typeInfo = typeRegistry.GetTypeInfo(typeid(MyTestCustomActor));
2584 DALI_TEST_CHECK(typeInfo);
2585 BaseHandle handle = typeInfo.CreateInstance();
2586 DALI_TEST_CHECK(handle);
2587 Actor customActor = Actor::DownCast(handle);
2588 DALI_TEST_CHECK(customActor);
2589 application.GetScene().Add(customActor);
2591 tet_infoline("Get the component values, they should be the default value of the base-property");
2592 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentZeroPropertyIndex), 13.0f, TEST_LOCATION);
2593 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentOnePropertyIndex), 24.0f, TEST_LOCATION);
2594 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentTwoPropertyIndex), 35.0f, TEST_LOCATION);
2595 DALI_TEST_EQUALS(customActor.GetProperty<Vector3>(basePropertyIndex), Vector3(13.0f, 24.0f, 35.0f), TEST_LOCATION);
2597 tet_infoline("Set a component value and ensure it changes for the base property as well");
2598 customActor.SetProperty(componentZeroPropertyIndex, 125.0f);
2599 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentZeroPropertyIndex), 125.0f, TEST_LOCATION);
2600 DALI_TEST_EQUALS(customActor.GetProperty<Vector3>(basePropertyIndex), Vector3(125.0f, 24.0f, 35.0f), TEST_LOCATION);
2602 customActor.SetProperty(componentOnePropertyIndex, 225.0f);
2603 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentOnePropertyIndex), 225.0f, TEST_LOCATION);
2604 DALI_TEST_EQUALS(customActor.GetProperty<Vector3>(basePropertyIndex), Vector3(125.0f, 225.0f, 35.0f), TEST_LOCATION);
2606 customActor.SetProperty(componentTwoPropertyIndex, 325.0f);
2607 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentTwoPropertyIndex), 325.0f, TEST_LOCATION);
2608 DALI_TEST_EQUALS(customActor.GetProperty<Vector3>(basePropertyIndex), Vector3(125.0f, 225.0f, 325.0f), TEST_LOCATION);
2610 tet_infoline("Check latest scene-graph value is unchanged");
2611 DALI_TEST_EQUALS(customActor.GetCurrentProperty<Vector3>(basePropertyIndex), Vector3(13.0f, 24.0f, 35.0f), TEST_LOCATION);
2612 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentZeroPropertyIndex), 13.0f, TEST_LOCATION);
2613 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentOnePropertyIndex), 24.0f, TEST_LOCATION);
2614 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentTwoPropertyIndex), 35.0f, TEST_LOCATION);
2616 // Render and notify
2617 application.SendNotification();
2618 application.Render();
2620 tet_infoline("Check values after rendering and both retrieval methods should return the latest");
2621 DALI_TEST_EQUALS(customActor.GetProperty<Vector3>(basePropertyIndex), Vector3(125.0f, 225.0f, 325.0f), TEST_LOCATION);
2622 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentZeroPropertyIndex), 125.0f, TEST_LOCATION);
2623 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentOnePropertyIndex), 225.0f, TEST_LOCATION);
2624 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentTwoPropertyIndex), 325.0f, TEST_LOCATION);
2626 DALI_TEST_EQUALS(customActor.GetCurrentProperty<Vector3>(basePropertyIndex), Vector3(125.0f, 225.0f, 325.0f), TEST_LOCATION);
2627 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentZeroPropertyIndex), 125.0f, TEST_LOCATION);
2628 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentOnePropertyIndex), 225.0f, TEST_LOCATION);
2629 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentTwoPropertyIndex), 325.0f, TEST_LOCATION);
2631 tet_infoline("Set the base property value and ensure the component values reflect the change");
2632 customActor.SetProperty(basePropertyIndex, Vector3(1.0f, 2.0f, 3.0f));
2633 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentZeroPropertyIndex), 1.0f, TEST_LOCATION);
2634 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentOnePropertyIndex), 2.0f, TEST_LOCATION);
2635 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentTwoPropertyIndex), 3.0f, TEST_LOCATION);
2636 DALI_TEST_EQUALS(customActor.GetProperty<Vector3>(basePropertyIndex), Vector3(1.0f, 2.0f, 3.0f), TEST_LOCATION);
2641 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGetWithComponentsVector4(void)
2643 TestApplication application;
2644 TypeRegistry typeRegistry = TypeRegistry::Get();
2646 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");
2648 // Register the animatable propeties
2649 const int basePropertyIndex(ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX);
2650 const int componentZeroPropertyIndex(basePropertyIndex + 1);
2651 const int componentOnePropertyIndex(componentZeroPropertyIndex + 1);
2652 const int componentTwoPropertyIndex(componentOnePropertyIndex + 1);
2653 const int componentThreePropertyIndex(componentTwoPropertyIndex + 1);
2654 AnimatablePropertyRegistration baseAnimatableProperty(customType1, "baseProp", basePropertyIndex, Vector4(13.0f, 24.0f, 35.0, 47.0f));
2655 AnimatablePropertyComponentRegistration componentZeroAnimatableProperty(customType1, "componentZeroProp", componentZeroPropertyIndex, basePropertyIndex, 0);
2656 AnimatablePropertyComponentRegistration componentOneAnimatableProperty(customType1, "componentOneProp", componentOnePropertyIndex, basePropertyIndex, 1);
2657 AnimatablePropertyComponentRegistration componentTwoAnimatableProperty(customType1, "componentTwoProp", componentTwoPropertyIndex, basePropertyIndex, 2);
2658 AnimatablePropertyComponentRegistration componentThreeAnimatableProperty(customType1, "componentThreeProp", componentThreePropertyIndex, basePropertyIndex, 3);
2660 // Check property count before property registration
2661 TypeInfo typeInfo = typeRegistry.GetTypeInfo(typeid(MyTestCustomActor));
2662 DALI_TEST_CHECK(typeInfo);
2663 BaseHandle handle = typeInfo.CreateInstance();
2664 DALI_TEST_CHECK(handle);
2665 Actor customActor = Actor::DownCast(handle);
2666 DALI_TEST_CHECK(customActor);
2667 application.GetScene().Add(customActor);
2669 tet_infoline("Get the component values, they should be the default value of the base-property");
2670 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentZeroPropertyIndex), 13.0f, TEST_LOCATION);
2671 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentOnePropertyIndex), 24.0f, TEST_LOCATION);
2672 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentTwoPropertyIndex), 35.0f, TEST_LOCATION);
2673 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentThreePropertyIndex), 47.0f, TEST_LOCATION);
2674 DALI_TEST_EQUALS(customActor.GetProperty<Vector4>(basePropertyIndex), Vector4(13.0f, 24.0f, 35.0f, 47.0f), TEST_LOCATION);
2676 tet_infoline("Set a component value and ensure it changes for the base property as well");
2677 customActor.SetProperty(componentZeroPropertyIndex, 125.0f);
2678 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentZeroPropertyIndex), 125.0f, TEST_LOCATION);
2679 DALI_TEST_EQUALS(customActor.GetProperty<Vector4>(basePropertyIndex), Vector4(125.0f, 24.0f, 35.0f, 47.0f), TEST_LOCATION);
2681 customActor.SetProperty(componentOnePropertyIndex, 225.0f);
2682 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentOnePropertyIndex), 225.0f, TEST_LOCATION);
2683 DALI_TEST_EQUALS(customActor.GetProperty<Vector4>(basePropertyIndex), Vector4(125.0f, 225.0f, 35.0f, 47.0f), TEST_LOCATION);
2685 customActor.SetProperty(componentTwoPropertyIndex, 325.0f);
2686 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentTwoPropertyIndex), 325.0f, TEST_LOCATION);
2687 DALI_TEST_EQUALS(customActor.GetProperty<Vector4>(basePropertyIndex), Vector4(125.0f, 225.0f, 325.0f, 47.0f), TEST_LOCATION);
2689 customActor.SetProperty(componentThreePropertyIndex, 435.0f);
2690 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentThreePropertyIndex), 435.0f, TEST_LOCATION);
2691 DALI_TEST_EQUALS(customActor.GetProperty<Vector4>(basePropertyIndex), Vector4(125.0f, 225.0f, 325.0f, 435.0f), TEST_LOCATION);
2693 tet_infoline("Check latest scene-graph value is unchanged");
2694 DALI_TEST_EQUALS(customActor.GetCurrentProperty<Vector4>(basePropertyIndex), Vector4(13.0f, 24.0f, 35.0f, 47.0f), TEST_LOCATION);
2695 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentZeroPropertyIndex), 13.0f, TEST_LOCATION);
2696 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentOnePropertyIndex), 24.0f, TEST_LOCATION);
2697 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentTwoPropertyIndex), 35.0f, TEST_LOCATION);
2698 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentThreePropertyIndex), 47.0f, TEST_LOCATION);
2700 // Render and notify
2701 application.SendNotification();
2702 application.Render();
2704 tet_infoline("Check values after rendering and both retrieval methods should return the latest");
2705 DALI_TEST_EQUALS(customActor.GetProperty<Vector4>(basePropertyIndex), Vector4(125.0f, 225.0f, 325.0f, 435.0f), TEST_LOCATION);
2706 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentZeroPropertyIndex), 125.0f, TEST_LOCATION);
2707 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentOnePropertyIndex), 225.0f, TEST_LOCATION);
2708 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentTwoPropertyIndex), 325.0f, TEST_LOCATION);
2709 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentThreePropertyIndex), 435.0f, TEST_LOCATION);
2711 DALI_TEST_EQUALS(customActor.GetCurrentProperty<Vector4>(basePropertyIndex), Vector4(125.0f, 225.0f, 325.0f, 435.0f), TEST_LOCATION);
2712 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentZeroPropertyIndex), 125.0f, TEST_LOCATION);
2713 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentOnePropertyIndex), 225.0f, TEST_LOCATION);
2714 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentTwoPropertyIndex), 325.0f, TEST_LOCATION);
2715 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentThreePropertyIndex), 435.0f, TEST_LOCATION);
2717 tet_infoline("Set the base property value and ensure the component values reflect the change");
2718 customActor.SetProperty(basePropertyIndex, Vector4(1.0f, 2.0f, 3.0f, 4.0f));
2719 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentZeroPropertyIndex), 1.0f, TEST_LOCATION);
2720 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentOnePropertyIndex), 2.0f, TEST_LOCATION);
2721 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentTwoPropertyIndex), 3.0f, TEST_LOCATION);
2722 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentThreePropertyIndex), 4.0f, TEST_LOCATION);
2723 DALI_TEST_EQUALS(customActor.GetProperty<Vector4>(basePropertyIndex), Vector4(1.0f, 2.0f, 3.0f, 4.0f), TEST_LOCATION);
2728 int UtcDaliTypeInfoRegisterChildProperties01(void)
2730 TestApplication application;
2731 TypeRegistry typeRegistry = TypeRegistry::Get();
2733 tet_infoline("Register child properties on a type via name");
2735 auto customActorTypeInfo = typeRegistry.GetTypeInfo(typeid(CustomActor));
2736 auto myCustomTypeInfo = typeRegistry.GetTypeInfo(typeid(MyTestCustomActor));
2737 DALI_TEST_CHECK(customActorTypeInfo);
2738 DALI_TEST_CHECK(myCustomTypeInfo);
2740 const Property::Index WIDTH_SPECIFICATION(CHILD_PROPERTY_REGISTRATION_START_INDEX);
2741 const Property::Index HEIGHT_SPECIFICATION(CHILD_PROPERTY_REGISTRATION_START_INDEX + 1);
2742 const Property::Index MARGIN_SPECIFICATION(CHILD_PROPERTY_REGISTRATION_START_INDEX + 100);
2744 ChildPropertyRegistration(customActorTypeInfo.GetName(), "widthSpecification", WIDTH_SPECIFICATION, Property::INTEGER);
2745 ChildPropertyRegistration(customActorTypeInfo.GetName(), "heightSpecification", HEIGHT_SPECIFICATION, Property::INTEGER);
2746 ChildPropertyRegistration(myCustomTypeInfo.GetName(), "marginSpecification", MARGIN_SPECIFICATION, Property::EXTENTS);
2748 auto customActor = MyTestCustomActor::New();
2749 application.GetScene().Add(customActor);
2750 auto child = Actor::New();
2751 customActor.Add(child);
2753 child.SetProperty(WIDTH_SPECIFICATION, 33);
2755 auto value = child.GetProperty(WIDTH_SPECIFICATION);
2756 DALI_TEST_EQUALS(value, Property::Value(33), TEST_LOCATION);
2758 child.SetProperty(HEIGHT_SPECIFICATION, 44);
2759 value = child.GetProperty(HEIGHT_SPECIFICATION);
2760 DALI_TEST_EQUALS(value, Property::Value(44), TEST_LOCATION);
2762 child.SetProperty(MARGIN_SPECIFICATION, Extents(10, 10, 10, 10));
2763 value = child.GetProperty(MARGIN_SPECIFICATION);
2764 DALI_TEST_EQUALS(value, Property::Value(Extents(10, 10, 10, 10)), TEST_LOCATION);
2769 int UtcDaliTypeInfoRegisterChildProperties02(void)
2771 TestApplication application;
2772 TypeRegistry typeRegistry = TypeRegistry::Get();
2774 tet_infoline("Register child properties on a type via name");
2776 auto customActorTypeInfo = typeRegistry.GetTypeInfo(typeid(CustomActor));
2777 auto myCustomTypeInfo = typeRegistry.GetTypeInfo(typeid(MyTestCustomActor));
2778 DALI_TEST_CHECK(customActorTypeInfo);
2779 DALI_TEST_CHECK(myCustomTypeInfo);
2781 const Property::Index WIDTH_SPECIFICATION(CHILD_PROPERTY_REGISTRATION_START_INDEX);
2782 const Property::Index HEIGHT_SPECIFICATION(CHILD_PROPERTY_REGISTRATION_START_INDEX + 1);
2783 const Property::Index MARGIN_SPECIFICATION(CHILD_PROPERTY_REGISTRATION_START_INDEX + 100);
2785 ChildPropertyRegistration(customActorTypeInfo.GetName(), "widthSpecification", WIDTH_SPECIFICATION, Property::INTEGER);
2786 ChildPropertyRegistration(customActorTypeInfo.GetName(), "heightSpecification", HEIGHT_SPECIFICATION, Property::INTEGER);
2787 ChildPropertyRegistration(myCustomTypeInfo.GetName(), "marginSpecification", MARGIN_SPECIFICATION, Property::EXTENTS);
2789 auto index = customActorTypeInfo.GetChildPropertyIndex("widthSpecification");
2790 DALI_TEST_EQUALS(index, WIDTH_SPECIFICATION, TEST_LOCATION);
2792 index = customActorTypeInfo.GetChildPropertyIndex("heightSpecification");
2793 DALI_TEST_EQUALS(index, HEIGHT_SPECIFICATION, TEST_LOCATION);
2795 index = customActorTypeInfo.GetChildPropertyIndex("marginSpecification");
2796 DALI_TEST_EQUALS(index, Property::INVALID_INDEX, TEST_LOCATION);
2798 index = myCustomTypeInfo.GetChildPropertyIndex("marginSpecification");
2799 DALI_TEST_EQUALS(index, MARGIN_SPECIFICATION, TEST_LOCATION);
2801 auto name = customActorTypeInfo.GetChildPropertyName(WIDTH_SPECIFICATION);
2802 DALI_TEST_EQUALS(name, "widthSpecification", TEST_LOCATION);
2804 name = customActorTypeInfo.GetChildPropertyName(HEIGHT_SPECIFICATION);
2805 DALI_TEST_EQUALS(name, "heightSpecification", TEST_LOCATION);
2807 name = myCustomTypeInfo.GetChildPropertyName(MARGIN_SPECIFICATION);
2808 DALI_TEST_EQUALS(name, "marginSpecification", TEST_LOCATION);
2810 auto type = customActorTypeInfo.GetChildPropertyType(WIDTH_SPECIFICATION);
2811 DALI_TEST_EQUALS(type, Property::INTEGER, TEST_LOCATION);
2813 type = customActorTypeInfo.GetChildPropertyType(HEIGHT_SPECIFICATION);
2814 DALI_TEST_EQUALS(type, Property::INTEGER, TEST_LOCATION);
2816 type = myCustomTypeInfo.GetChildPropertyType(MARGIN_SPECIFICATION);
2817 DALI_TEST_EQUALS(type, Property::EXTENTS, TEST_LOCATION);
2822 int UtcDaliTypeInfoRegisterChildProperties03(void)
2824 TestApplication application;
2825 TypeRegistry typeRegistry = TypeRegistry::Get();
2827 tet_infoline("Check registered child properties can be retrieved");
2829 auto customActorTypeInfo = typeRegistry.GetTypeInfo(typeid(CustomActor));
2830 auto myCustomTypeInfo = typeRegistry.GetTypeInfo(typeid(MyTestCustomActor));
2831 DALI_TEST_CHECK(customActorTypeInfo);
2832 DALI_TEST_CHECK(myCustomTypeInfo);
2834 const Property::Index WIDTH_SPECIFICATION(CHILD_PROPERTY_REGISTRATION_START_INDEX);
2835 const Property::Index HEIGHT_SPECIFICATION(CHILD_PROPERTY_REGISTRATION_START_INDEX + 1);
2836 const Property::Index MARGIN_SPECIFICATION(CHILD_PROPERTY_REGISTRATION_START_INDEX + 100);
2838 ChildPropertyRegistration(customActorTypeInfo.GetName(), "widthSpecification", WIDTH_SPECIFICATION, Property::INTEGER);
2839 ChildPropertyRegistration(customActorTypeInfo.GetName(), "heightSpecification", HEIGHT_SPECIFICATION, Property::INTEGER);
2840 ChildPropertyRegistration(myCustomTypeInfo.GetName(), "marginSpecification", MARGIN_SPECIFICATION, Property::EXTENTS);
2842 Property::IndexContainer indices;
2843 myCustomTypeInfo.GetChildPropertyIndices(indices);
2845 auto result = std::find(indices.Begin(), indices.End(), WIDTH_SPECIFICATION);
2846 DALI_TEST_EQUALS(result != indices.End(), true, TEST_LOCATION);
2848 result = std::find(indices.Begin(), indices.End(), HEIGHT_SPECIFICATION);
2849 DALI_TEST_EQUALS(result != indices.End(), true, TEST_LOCATION);
2851 result = std::find(indices.Begin(), indices.End(), MARGIN_SPECIFICATION);
2852 DALI_TEST_EQUALS(result != indices.End(), true, TEST_LOCATION);
2857 int UtcDaliTypeInfoGetActionNameNegative(void)
2859 TestApplication application;
2860 Dali::TypeInfo instance;
2863 unsigned long arg1(0u);
2864 instance.GetActionName(arg1);
2865 DALI_TEST_CHECK(false); // Should not get here
2869 DALI_TEST_CHECK(true); // We expect an assert
2874 int UtcDaliTypeInfoGetSignalNameNegative(void)
2876 TestApplication application;
2877 Dali::TypeInfo instance;
2880 unsigned long arg1(0u);
2881 instance.GetSignalName(arg1);
2882 DALI_TEST_CHECK(false); // Should not get here
2886 DALI_TEST_CHECK(true); // We expect an assert
2891 int UtcDaliTypeInfoGetCreatorNegative(void)
2893 TestApplication application;
2894 Dali::TypeInfo instance;
2897 instance.GetCreator();
2898 DALI_TEST_CHECK(false); // Should not get here
2902 DALI_TEST_CHECK(true); // We expect an assert
2907 int UtcDaliTypeInfoGetBaseNameNegative(void)
2909 TestApplication application;
2910 Dali::TypeInfo instance;
2913 instance.GetBaseName();
2914 DALI_TEST_CHECK(false); // Should not get here
2918 DALI_TEST_CHECK(true); // We expect an assert
2923 int UtcDaliTypeInfoCreateInstanceNegative(void)
2925 TestApplication application;
2926 Dali::TypeInfo instance;
2929 instance.CreateInstance();
2930 DALI_TEST_CHECK(false); // Should not get here
2934 DALI_TEST_CHECK(true); // We expect an assert
2939 int UtcDaliTypeInfoGetActionCountNegative(void)
2941 TestApplication application;
2942 Dali::TypeInfo instance;
2945 instance.GetActionCount();
2946 DALI_TEST_CHECK(false); // Should not get here
2950 DALI_TEST_CHECK(true); // We expect an assert
2955 int UtcDaliTypeInfoGetSignalCountNegative(void)
2957 TestApplication application;
2958 Dali::TypeInfo instance;
2961 instance.GetSignalCount();
2962 DALI_TEST_CHECK(false); // Should not get here
2966 DALI_TEST_CHECK(true); // We expect an assert
2971 int UtcDaliTypeInfoGetPropertyNameNegative(void)
2973 TestApplication application;
2974 Dali::TypeInfo instance;
2978 instance.GetPropertyName(arg1);
2979 DALI_TEST_CHECK(false); // Should not get here
2983 DALI_TEST_CHECK(true); // We expect an assert
2988 int UtcDaliTypeInfoGetPropertyCountNegative(void)
2990 TestApplication application;
2991 Dali::TypeInfo instance;
2994 instance.GetPropertyCount();
2995 DALI_TEST_CHECK(false); // Should not get here
2999 DALI_TEST_CHECK(true); // We expect an assert
3004 int UtcDaliTypeInfoGetPropertyIndicesNegative(void)
3006 TestApplication application;
3007 Dali::TypeInfo instance;
3010 Dali::Vector<int> arg1;
3011 instance.GetPropertyIndices(arg1);
3012 DALI_TEST_CHECK(false); // Should not get here
3016 DALI_TEST_CHECK(true); // We expect an assert
3021 int UtcDaliTypeInfoGetChildPropertyNameNegative(void)
3023 TestApplication application;
3024 Dali::TypeInfo instance;
3028 instance.GetChildPropertyName(arg1);
3029 DALI_TEST_CHECK(false); // Should not get here
3033 DALI_TEST_CHECK(true); // We expect an assert
3038 int UtcDaliTypeInfoGetChildPropertyTypeNegative(void)
3040 TestApplication application;
3041 Dali::TypeInfo instance;
3045 instance.GetChildPropertyType(arg1);
3046 DALI_TEST_CHECK(false); // Should not get here
3050 DALI_TEST_CHECK(true); // We expect an assert
3055 int UtcDaliTypeInfoGetChildPropertyIndexNegative(void)
3057 TestApplication application;
3058 Dali::TypeInfo instance;
3062 instance.GetChildPropertyIndex(arg1);
3063 DALI_TEST_CHECK(false); // Should not get here
3067 DALI_TEST_CHECK(true); // We expect an assert
3072 int UtcDaliTypeInfoGetChildPropertyIndicesNegative(void)
3074 TestApplication application;
3075 Dali::TypeInfo instance;
3078 Dali::Vector<int> arg1;
3079 instance.GetChildPropertyIndices(arg1);
3080 DALI_TEST_CHECK(false); // Should not get here
3084 DALI_TEST_CHECK(true); // We expect an assert
3089 int UtcDaliTypeInfoGetNameNegative(void)
3091 TestApplication application;
3092 Dali::TypeInfo instance;
3096 DALI_TEST_CHECK(false); // Should not get here
3100 DALI_TEST_CHECK(true); // We expect an assert
3105 int UtcDaliTypeRegistryGetTypeInfoNegative01(void)
3107 TestApplication application;
3108 Dali::TypeRegistry instance;
3112 instance.GetTypeInfo(arg1);
3113 DALI_TEST_CHECK(false); // Should not get here
3117 DALI_TEST_CHECK(true); // We expect an assert
3122 int UtcDaliTypeRegistryGetTypeInfoNegative02(void)
3124 TestApplication application;
3125 Dali::TypeRegistry instance;
3128 instance.GetTypeInfo(typeid(unsigned int));
3129 DALI_TEST_CHECK(false); // Should not get here
3133 DALI_TEST_CHECK(true); // We expect an assert
3138 int UtcDaliTypeRegistryGetTypeNameNegative(void)
3140 TestApplication application;
3141 Dali::TypeRegistry instance;
3144 unsigned long arg1(0u);
3145 instance.GetTypeName(arg1);
3146 DALI_TEST_CHECK(false); // Should not get here
3150 DALI_TEST_CHECK(true); // We expect an assert
3155 int UtcDaliTypeRegistryGetTypeNameCountNegative(void)
3157 TestApplication application;
3158 Dali::TypeRegistry instance;
3161 instance.GetTypeNameCount();
3162 DALI_TEST_CHECK(false); // Should not get here
3166 DALI_TEST_CHECK(true); // We expect an assert