2 * Copyright (c) 2021 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/common/const-string.h>
22 #include <dali/internal/event/common/type-info-impl.h>
23 #include <dali/public-api/dali-core.h>
33 // Stores data that is populated in the callback and will be read by the Test cases
37 : functorCalled(false),
38 voidFunctorCalled(false),
46 functorCalled = false;
47 voidFunctorCalled = false;
49 receivedGesture.Reset();
55 bool voidFunctorCalled;
56 LongPressGesture receivedGesture;
60 // Functor that sets the data when called
61 struct GestureReceivedFunctor
63 GestureReceivedFunctor(SignalData& data)
68 void operator()(Actor actor, LongPressGesture longPress)
70 signalData.functorCalled = true;
71 signalData.receivedGesture = longPress;
72 signalData.pressedActor = actor;
77 signalData.voidFunctorCalled = true;
80 SignalData& signalData;
84 // Create function as Init function called
86 static bool CreateCustomInitCalled = false;
87 BaseHandle CreateCustomInit(void)
89 CreateCustomInitCalled = true;
93 static bool CreateCustomNamedInitCalled = false;
94 BaseHandle CreateCustomNamedInit(void)
96 CreateCustomNamedInitCalled = true;
100 const std::string scriptedName("PopupStyle");
101 static TypeRegistration scriptedType(scriptedName, typeid(Dali::CustomActor), CreateCustomNamedInit);
103 // Property Registration
104 bool setPropertyCalled = false;
105 bool getPropertyCalled = false;
106 void SetProperty(BaseObject* object, Property::Index propertyIndex, const Property::Value& value)
108 setPropertyCalled = true;
110 Property::Value GetProperty(BaseObject* object, Property::Index propertyIndex)
112 getPropertyCalled = true;
113 return Property::Value(true);
116 /*******************************************************************************
120 ******************************************************************************/
123 struct MyTestCustomActor : public CustomActorImpl
125 typedef Signal<void()> SignalType;
126 typedef Signal<void(float)> SignalTypeFloat;
129 : CustomActorImpl(ActorFlags())
133 virtual ~MyTestCustomActor()
137 void ResetCallStack()
141 // From CustomActorImpl
142 virtual void OnSceneConnection(int depth)
145 virtual void OnSceneDisconnection()
148 virtual void OnChildAdd(Actor& child)
151 virtual void OnChildRemove(Actor& child)
154 virtual void OnSizeSet(const Vector3& targetSize)
157 virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize)
160 virtual void OnKeyInputFocusGained()
163 virtual void OnKeyInputFocusLost()
166 virtual Vector3 GetNaturalSize()
168 return Vector3(0.0f, 0.0f, 0.0f);
171 virtual float GetHeightForWidth(float width)
176 virtual float GetWidthForHeight(float height)
181 virtual void OnRelayout(const Vector2& size, RelayoutContainer& container)
185 virtual void OnSetResizePolicy(ResizePolicy::Type policy, Dimension::Type dimension)
189 virtual void OnCalculateRelayoutSize(Dimension::Type dimension)
193 virtual float CalculateChildSize(const Dali::Actor& child, Dimension::Type dimension)
198 virtual void OnLayoutNegotiated(float size, Dimension::Type dimension)
202 virtual bool RelayoutDependentOnChildren(Dimension::Type dimension = Dimension::ALL_DIMENSIONS)
213 class MyTestCustomActor : public CustomActor
216 typedef Signal<void()> SignalType;
217 typedef Signal<void(float)> SignalTypeFloat;
223 static MyTestCustomActor New()
225 Impl::MyTestCustomActor* p = new Impl::MyTestCustomActor;
226 return MyTestCustomActor(*p); // takes ownership
229 virtual ~MyTestCustomActor()
233 static MyTestCustomActor DownCast(BaseHandle handle)
235 MyTestCustomActor result;
237 CustomActor custom = Dali::CustomActor::DownCast(handle);
240 CustomActorImpl& customImpl = custom.GetImplementation();
242 Impl::MyTestCustomActor* impl = dynamic_cast<Impl::MyTestCustomActor*>(&customImpl);
246 result = MyTestCustomActor(customImpl.GetOwner());
253 SignalType& GetCustomSignal()
255 Dali::RefObject& obj = GetImplementation();
256 return static_cast<Impl::MyTestCustomActor&>(obj).mSignal;
260 MyTestCustomActor(Internal::CustomActor* internal)
261 : CustomActor(internal)
265 MyTestCustomActor(Impl::MyTestCustomActor& impl)
271 class MyTestCustomActor2 : public CustomActor
278 P1 = Dali::PROPERTY_REGISTRATION_START_INDEX,
287 static MyTestCustomActor2 New()
289 return MyTestCustomActor2(); // takes ownership
292 virtual ~MyTestCustomActor2()
296 static MyTestCustomActor2 DownCast(BaseHandle handle)
298 MyTestCustomActor2 result;
300 CustomActor custom = Dali::CustomActor::DownCast(handle);
303 CustomActorImpl& customImpl = custom.GetImplementation();
305 Impl::MyTestCustomActor* impl = dynamic_cast<Impl::MyTestCustomActor*>(&customImpl);
309 result = MyTestCustomActor2(customImpl.GetOwner());
317 MyTestCustomActor2(Internal::CustomActor* internal)
318 : CustomActor(internal)
322 MyTestCustomActor2(Impl::MyTestCustomActor& impl)
328 static TypeRegistration customTypeInit(typeid(MyTestCustomActor2), typeid(Dali::CustomActor), CreateCustomInit, true);
330 PropertyRegistration P1(customTypeInit, "propertyOne", MyTestCustomActor2::Property::P1, Property::INTEGER, &SetProperty, &GetProperty);
331 PropertyRegistration P2(customTypeInit, "propertyTwo", MyTestCustomActor2::Property::P2, Property::STRING, &SetProperty, &GetProperty);
333 class MyTestCustomActor3 : public CustomActor
340 static MyTestCustomActor3 New()
342 return MyTestCustomActor3(); // takes ownership
345 virtual ~MyTestCustomActor3()
349 static MyTestCustomActor3 DownCast(BaseHandle handle)
351 MyTestCustomActor3 result;
353 CustomActor custom = Dali::CustomActor::DownCast(handle);
356 CustomActorImpl& customImpl = custom.GetImplementation();
358 Impl::MyTestCustomActor* impl = dynamic_cast<Impl::MyTestCustomActor*>(&customImpl);
362 result = MyTestCustomActor3(customImpl.GetOwner());
370 MyTestCustomActor3(Internal::CustomActor* internal)
371 : CustomActor(internal)
375 MyTestCustomActor3(Impl::MyTestCustomActor& impl)
381 static TypeRegistration customTypeBadInit(typeid(MyTestCustomActor3), typeid(Dali::CustomActor), NULL, false);
383 BaseHandle CreateCustom(void)
385 return MyTestCustomActor::New();
388 static std::string lastSignalConnectionCustom;
390 bool DoConnectSignalCustom(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor)
392 lastSignalConnectionCustom = signalName;
394 bool connected(true);
396 Dali::BaseHandle handle(object);
397 MyTestCustomActor customActor = MyTestCustomActor::DownCast(handle);
399 if("sig1" == signalName)
401 customActor.GetCustomSignal().Connect(tracker, functor);
405 // signalName does not match any signal
412 bool DoConnectSignalCustomFailure(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor)
414 lastSignalConnectionCustom = "failed";
416 return false; // This is supposed to fail
419 struct CustomTestFunctor
423 ++mTotalInstanceCount;
424 ++mCurrentInstanceCount;
427 CustomTestFunctor(const CustomTestFunctor& copyMe)
429 ++mTotalInstanceCount;
430 ++mCurrentInstanceCount;
435 --mCurrentInstanceCount;
443 static int mTotalInstanceCount;
444 static int mCurrentInstanceCount;
445 static int mCallbackCount;
448 int CustomTestFunctor::mTotalInstanceCount = 0;
449 int CustomTestFunctor::mCurrentInstanceCount = 0;
450 int CustomTestFunctor::mCallbackCount = 0;
452 static void ResetFunctorCounts()
454 CustomTestFunctor::mTotalInstanceCount = 0;
455 CustomTestFunctor::mCurrentInstanceCount = 0;
456 CustomTestFunctor::mCallbackCount = 0;
459 static std::string lastActionCustom;
460 bool DoActionCustom(BaseObject* object, const std::string& actionName, const Property::Map& /*attributes*/)
462 lastActionCustom = actionName;
466 // Custom type registration
467 static TypeRegistration customType1(typeid(MyTestCustomActor), typeid(Dali::CustomActor), CreateCustom);
470 static SignalConnectorType customSignalConnector1(customType1, "sig1", DoConnectSignalCustom);
471 static SignalConnectorType customSignalConnector2(customType1, "sig2", DoConnectSignalCustomFailure);
472 static const int TEST_SIGNAL_COUNT = 2;
475 static TypeAction customAction1(customType1, "act1", DoActionCustom);
476 static const int TEST_ACTION_COUNT = 1;
478 class TestConnectionTracker : public ConnectionTracker
481 TestConnectionTracker()
486 BaseHandle CreateNamedActorType()
488 Actor actor = Actor::New();
489 actor.SetProperty(Actor::Property::NAME, "NamedActor");
493 TypeRegistration namedActorType("MyNamedActor", typeid(Dali::Actor), CreateNamedActorType);
494 PropertyRegistration namedActorPropertyOne(namedActorType, "propName", PROPERTY_REGISTRATION_START_INDEX, Property::BOOLEAN, &SetProperty, &GetProperty);
496 } // Anonymous namespace
498 // Note: No negative test case for UtcDaliTypeRegistryGet can be implemented.
499 int UtcDaliTypeRegistryGetP(void)
501 TestApplication application;
503 TypeRegistry registry = TypeRegistry::Get();
504 DALI_TEST_CHECK(registry);
509 // Note: No negative test case for UtcDaliTypeRegistryConstructor can be implemented.
510 int UtcDaliTypeRegistryConstructorP(void)
512 TestApplication application;
514 TypeRegistry registry;
515 DALI_TEST_CHECK(!registry);
519 // Note: No negative test case for UtcDaliTypeRegistryCopyConstructor can be implemented.
520 int UtcDaliTypeRegistryCopyConstructorP(void)
522 TestApplication application;
524 TypeRegistry registry = TypeRegistry::Get();
525 DALI_TEST_CHECK(registry);
527 TypeRegistry copy(registry);
528 DALI_TEST_CHECK(copy);
530 DALI_TEST_CHECK(registry.GetTypeInfo("Actor").GetName() == copy.GetTypeInfo("Actor").GetName());
535 // Note: No negative test case for UtcDaliTypeRegistryAssignmentOperator can be implemented.
536 int UtcDaliTypeRegistryAssignmentOperatorP(void)
538 TestApplication application;
540 TypeRegistry registry = TypeRegistry::Get();
541 DALI_TEST_CHECK(registry);
543 TypeRegistry copy = registry;
544 DALI_TEST_CHECK(copy);
545 DALI_TEST_CHECK(registry == copy);
547 DALI_TEST_CHECK(registry.GetTypeInfo("Actor").GetName() == copy.GetTypeInfo("Actor").GetName());
552 int UtcDaliTypeRegistryMoveConstructor(void)
554 TestApplication application;
556 TypeRegistry registry = TypeRegistry::Get();
557 DALI_TEST_CHECK(registry);
558 DALI_TEST_EQUALS(16, registry.GetBaseObject().ReferenceCount(), TEST_LOCATION);
559 DALI_TEST_CHECK(registry.GetTypeInfo("Actor").GetName() == "Actor");
561 TypeRegistry movedRegistry = std::move(registry);
562 DALI_TEST_CHECK(movedRegistry);
563 DALI_TEST_EQUALS(16, movedRegistry.GetBaseObject().ReferenceCount(), TEST_LOCATION);
564 DALI_TEST_CHECK(movedRegistry.GetTypeInfo("Actor").GetName() == "Actor");
565 DALI_TEST_CHECK(!registry);
567 Dali::TypeInfo info = movedRegistry.GetTypeInfo("Actor");
568 DALI_TEST_CHECK(info);
569 DALI_TEST_EQUALS(2, info.GetBaseObject().ReferenceCount(), TEST_LOCATION);
570 DALI_TEST_CHECK(info.GetName() == "Actor");
572 Dali::TypeInfo movedInfo = std::move(info);
573 DALI_TEST_CHECK(movedInfo);
574 DALI_TEST_EQUALS(2, movedInfo.GetBaseObject().ReferenceCount(), TEST_LOCATION);
575 DALI_TEST_CHECK(movedInfo.GetName() == "Actor");
576 DALI_TEST_CHECK(!info);
581 int UtcDaliTypeRegistryMoveAssignment(void)
583 TestApplication application;
585 TypeRegistry registry = TypeRegistry::Get();
586 DALI_TEST_CHECK(registry);
587 DALI_TEST_EQUALS(16, registry.GetBaseObject().ReferenceCount(), TEST_LOCATION);
588 DALI_TEST_CHECK(registry.GetTypeInfo("Actor").GetName() == "Actor");
590 TypeRegistry movedRegistry;
591 movedRegistry = std::move(registry);
592 DALI_TEST_CHECK(movedRegistry);
593 DALI_TEST_EQUALS(16, movedRegistry.GetBaseObject().ReferenceCount(), TEST_LOCATION);
594 DALI_TEST_CHECK(movedRegistry.GetTypeInfo("Actor").GetName() == "Actor");
595 DALI_TEST_CHECK(!registry);
597 Dali::TypeInfo info = movedRegistry.GetTypeInfo("Actor");
598 DALI_TEST_CHECK(info);
599 DALI_TEST_EQUALS(2, info.GetBaseObject().ReferenceCount(), TEST_LOCATION);
600 DALI_TEST_CHECK(info.GetName() == "Actor");
602 Dali::TypeInfo movedInfo;
603 movedInfo = std::move(info);
604 DALI_TEST_CHECK(movedInfo);
605 DALI_TEST_EQUALS(2, movedInfo.GetBaseObject().ReferenceCount(), TEST_LOCATION);
606 DALI_TEST_CHECK(movedInfo.GetName() == "Actor");
607 DALI_TEST_CHECK(!info);
612 int UtcDaliTypeRegistryAssignP(void)
614 TestApplication application;
616 TypeRegistry registry = TypeRegistry::Get();
617 TypeRegistry registry2;
618 registry2 = registry;
619 DALI_TEST_CHECK(registry2);
621 DALI_TEST_CHECK(registry2.GetTypeInfo("Actor").GetName() == registry2.GetTypeInfo("Actor").GetName());
626 int UtcDaliTypeRegistryGetTypeInfoFromTypeNameP(void)
628 TestApplication application;
630 TypeRegistry registry = TypeRegistry::Get();
635 type = registry.GetTypeInfo("CameraActor");
636 DALI_TEST_CHECK(type);
637 CameraActor ca = CameraActor::DownCast(type.CreateInstance());
639 application.GetScene().Add(ca);
640 application.Render();
643 type = registry.GetTypeInfo("Animation");
644 DALI_TEST_CHECK(type);
645 Animation an = Animation::DownCast(type.CreateInstance());
648 application.Render();
653 int UtcDaliTypeRegistryGetTypeInfoFromTypeNameN(void)
655 TestApplication application;
657 TypeRegistry registry = TypeRegistry::Get();
661 type = registry.GetTypeInfo("MyDummyActor");
662 DALI_TEST_CHECK(!type);
667 int UtcDaliTypeRegistryGetTypeInfoFromTypeIdP(void)
669 TypeInfo named_type = TypeRegistry::Get().GetTypeInfo("CameraActor");
670 TypeInfo typeinfo_type = TypeRegistry::Get().GetTypeInfo(typeid(Dali::CameraActor));
672 DALI_TEST_CHECK(named_type);
673 DALI_TEST_CHECK(typeinfo_type);
675 // Check named and typeid are equivalent
676 DALI_TEST_CHECK(named_type == typeinfo_type);
678 DALI_TEST_CHECK(named_type.GetName() == typeinfo_type.GetName());
679 DALI_TEST_CHECK(named_type.GetBaseName() == typeinfo_type.GetBaseName());
684 int UtcDaliTypeRegistryGetTypeInfoFromTypeIdN(void)
686 TestApplication application;
687 TypeRegistry typeRegistry = TypeRegistry::Get();
689 TypeInfo typeInfo = typeRegistry.GetTypeInfo(typeid(Vector2));
690 DALI_TEST_CHECK(!typeInfo);
695 int UtcDaliTypeRegistryGetTypeNameCountP(void)
697 TestApplication application;
698 TypeRegistry typeRegistry = TypeRegistry::Get();
701 for(size_t i = 0; i < typeRegistry.GetTypeNameCount(); i++)
703 type = typeRegistry.GetTypeInfo(typeRegistry.GetTypeName(i));
704 DALI_TEST_CHECK(type);
710 int UtcDaliTypeRegistryGetTypeNamesP(void)
712 TestApplication application;
713 TypeRegistry typeRegistry = TypeRegistry::Get();
716 for(size_t i = 0; i < typeRegistry.GetTypeNameCount(); i++)
718 type = typeRegistry.GetTypeInfo(typeRegistry.GetTypeName(i));
719 DALI_TEST_CHECK(type);
725 // Note: No negative test case for UtcDaliTypeRegistryTypeRegistration can be implemented.
726 int UtcDaliTypeRegistryTypeRegistrationNotCallingCreateOnInitP(void)
728 ResetFunctorCounts();
730 TestApplication application;
732 TypeInfo type = TypeRegistry::Get().GetTypeInfo("MyTestCustomActor");
733 DALI_TEST_CHECK(type);
735 TypeInfo baseType = TypeRegistry::Get().GetTypeInfo("CustomActor");
736 DALI_TEST_CHECK(baseType);
738 BaseHandle handle = type.CreateInstance();
739 DALI_TEST_CHECK(handle);
741 MyTestCustomActor customHandle = MyTestCustomActor::DownCast(handle);
742 DALI_TEST_CHECK(customHandle);
744 DALI_TEST_EQUALS(type.GetActionCount(), TEST_ACTION_COUNT + baseType.GetActionCount(), TEST_LOCATION);
746 DALI_TEST_EQUALS(type.GetSignalCount(), TEST_SIGNAL_COUNT + baseType.GetSignalCount(), TEST_LOCATION);
749 TestConnectionTracker tracker;
751 bool connected = handle.ConnectSignal(&tracker, "sig1", CustomTestFunctor());
752 DALI_TEST_EQUALS(connected, true, TEST_LOCATION);
753 DALI_TEST_CHECK(lastSignalConnectionCustom == "sig1");
754 DALI_TEST_EQUALS(CustomTestFunctor::mTotalInstanceCount, 2 /*temporary copy + FunctorDelegate copy*/, TEST_LOCATION);
755 DALI_TEST_EQUALS(CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION);
757 DALI_TEST_EQUALS(CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION);
758 customHandle.GetCustomSignal().Emit();
759 DALI_TEST_EQUALS(CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION);
760 DALI_TEST_EQUALS(CustomTestFunctor::mTotalInstanceCount, 2 /*temporary copy + FunctorDelegate copy*/, TEST_LOCATION);
761 DALI_TEST_EQUALS(CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION);
763 // tracker should automatically disconnect here
764 DALI_TEST_EQUALS(CustomTestFunctor::mTotalInstanceCount, 2 /*temporary copy + FunctorDelegate copy*/, TEST_LOCATION);
765 DALI_TEST_EQUALS(CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION);
767 // Test that functor is disconnected
768 DALI_TEST_EQUALS(CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION);
769 customHandle.GetCustomSignal().Emit();
770 DALI_TEST_EQUALS(CustomTestFunctor::mCallbackCount, 1 /*not incremented*/, TEST_LOCATION);
771 DALI_TEST_EQUALS(CustomTestFunctor::mTotalInstanceCount, 2 /*temporary copy + FunctorDelegate copy*/, TEST_LOCATION);
772 DALI_TEST_EQUALS(CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION);
774 Property::Map attributes;
775 handle.DoAction("act1", attributes);
776 DALI_TEST_CHECK(lastActionCustom == "act1");
780 // Note: No negative test case for UtcDaliTypeRegistryTypeRegistration can be implemented.
781 int UtcDaliTypeRegistryTypeRegistrationCallingCreateOnInitP(void)
783 TestApplication application;
785 DALI_TEST_CHECK("MyTestCustomActor2" == customTypeInit.RegisteredName());
787 DALI_TEST_CHECK(true == CreateCustomInitCalled);
788 TypeInfo type = TypeRegistry::Get().GetTypeInfo("MyTestCustomActor2");
789 DALI_TEST_CHECK(type);
793 // Note: No negative test case for UtcDaliTypeRegistryTypeRegistration can be implemented.
794 int UtcDaliTypeRegistryTypeRegistrationForNamedTypeP(void)
796 TestApplication application;
798 // Create Named Actor Type
799 TypeInfo type = TypeRegistry::Get().GetTypeInfo("MyNamedActor");
800 DALI_TEST_CHECK(type);
802 BaseHandle namedHandle = type.CreateInstance();
803 DALI_TEST_CHECK(namedHandle);
804 Actor namedActor(Actor::DownCast(namedHandle));
805 DALI_TEST_CHECK(namedActor);
807 DALI_TEST_CHECK(namedActor.GetProperty<std::string>(Actor::Property::NAME) == "NamedActor");
808 DALI_TEST_CHECK(type.GetName() == "MyNamedActor");
809 DALI_TEST_CHECK(type.GetBaseName() == "Actor");
814 int UtcDaliTypeRegistryRegisteredNameP(void)
816 TestApplication application;
818 DALI_TEST_CHECK(scriptedName == scriptedType.RegisteredName());
820 TypeInfo baseType = TypeRegistry::Get().GetTypeInfo(scriptedName);
821 DALI_TEST_CHECK(baseType);
823 BaseHandle handle = baseType.CreateInstance();
825 DALI_TEST_CHECK(true == CreateCustomNamedInitCalled);
826 TypeInfo type = TypeRegistry::Get().GetTypeInfo(scriptedName);
827 DALI_TEST_CHECK(type);
831 int UtcDaliTypeRegistryRegisteredNameN(void)
833 TestApplication application;
835 DALI_TEST_CHECK(scriptedName == scriptedType.RegisteredName());
837 TypeInfo baseType = TypeRegistry::Get().GetTypeInfo(scriptedName);
838 DALI_TEST_CHECK(baseType);
840 // should cause an assert because we're registering same type twice
841 // once statically at the start of this file, then again now
844 TypeRegistration scriptedType(scriptedName, typeid(Dali::CustomActor), CreateCustomNamedInit);
845 tet_result(TET_FAIL);
847 catch(DaliException& e)
849 DALI_TEST_ASSERT(e, "Duplicate type name in Type Registration", TEST_LOCATION);
855 int UtcDaliTypeRegistrySignalConnectorTypeP(void)
857 ResetFunctorCounts();
859 TestApplication application;
861 TypeInfo type = TypeRegistry::Get().GetTypeInfo("MyTestCustomActor");
862 DALI_TEST_CHECK(type);
864 BaseHandle handle = type.CreateInstance();
865 DALI_TEST_CHECK(handle);
867 MyTestCustomActor customHandle = MyTestCustomActor::DownCast(handle);
868 DALI_TEST_CHECK(customHandle);
871 TestConnectionTracker tracker;
873 bool connected = handle.ConnectSignal(&tracker, "sig1", CustomTestFunctor());
874 DALI_TEST_EQUALS(connected, true, TEST_LOCATION);
875 DALI_TEST_CHECK(lastSignalConnectionCustom == "sig1");
876 DALI_TEST_EQUALS(CustomTestFunctor::mTotalInstanceCount, 2 /*temporary copy + FunctorDelegate copy*/, TEST_LOCATION);
877 DALI_TEST_EQUALS(CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION);
879 DALI_TEST_EQUALS(CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION);
880 customHandle.GetCustomSignal().Emit();
881 DALI_TEST_EQUALS(CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION);
882 DALI_TEST_EQUALS(CustomTestFunctor::mTotalInstanceCount, 2 /*temporary copy + FunctorDelegate copy*/, TEST_LOCATION);
883 DALI_TEST_EQUALS(CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION);
885 // tracker should automatically disconnect here
886 DALI_TEST_EQUALS(CustomTestFunctor::mTotalInstanceCount, 2 /*temporary copy + FunctorDelegate copy*/, TEST_LOCATION);
887 DALI_TEST_EQUALS(CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION);
889 // Test that functor is disconnected
890 DALI_TEST_EQUALS(CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION);
891 customHandle.GetCustomSignal().Emit();
892 DALI_TEST_EQUALS(CustomTestFunctor::mCallbackCount, 1 /*not incremented*/, TEST_LOCATION);
893 DALI_TEST_EQUALS(CustomTestFunctor::mTotalInstanceCount, 2 /*temporary copy + FunctorDelegate copy*/, TEST_LOCATION);
894 DALI_TEST_EQUALS(CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION);
899 int UtcDaliTypeRegistrySignalConnectorTypeN(void)
901 // Test what happens when signal connnector (DoConnectSignalFailure method) returns false
903 ResetFunctorCounts();
905 TestApplication application;
907 TypeInfo type = TypeRegistry::Get().GetTypeInfo("MyTestCustomActor");
908 DALI_TEST_CHECK(type);
910 TypeInfo baseType = TypeRegistry::Get().GetTypeInfo("CustomActor");
911 DALI_TEST_CHECK(baseType);
913 BaseHandle handle = type.CreateInstance();
914 DALI_TEST_CHECK(handle);
916 MyTestCustomActor customHandle = MyTestCustomActor::DownCast(handle);
917 DALI_TEST_CHECK(customHandle);
919 DALI_TEST_EQUALS(type.GetActionCount(), TEST_ACTION_COUNT + baseType.GetActionCount(), TEST_LOCATION);
921 DALI_TEST_EQUALS(type.GetSignalCount(), TEST_SIGNAL_COUNT + baseType.GetSignalCount(), TEST_LOCATION);
924 TestConnectionTracker tracker;
926 bool connected = handle.ConnectSignal(&tracker, "sig2", CustomTestFunctor());
927 DALI_TEST_EQUALS(connected, false /*This is supposed to fail*/, TEST_LOCATION);
928 DALI_TEST_CHECK(lastSignalConnectionCustom == "failed");
929 DALI_TEST_EQUALS(CustomTestFunctor::mTotalInstanceCount, 2 /*temporary copy + FunctorDelegate copy*/, TEST_LOCATION);
930 DALI_TEST_EQUALS(CustomTestFunctor::mCurrentInstanceCount, 0 /*deleted along with FunctorDelegate*/, TEST_LOCATION);
933 DALI_TEST_EQUALS(CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION);
934 customHandle.GetCustomSignal().Emit();
935 DALI_TEST_EQUALS(CustomTestFunctor::mCallbackCount, 0 /*never called*/, TEST_LOCATION);
937 // tracker should have nothing to disconnect here
940 DALI_TEST_EQUALS(CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION);
941 customHandle.GetCustomSignal().Emit();
942 DALI_TEST_EQUALS(CustomTestFunctor::mCallbackCount, 0 /*never called*/, TEST_LOCATION);
946 int UtcDaliTypeRegistryTypeActionP(void)
948 ResetFunctorCounts();
950 TestApplication application;
952 TypeInfo type = TypeRegistry::Get().GetTypeInfo("MyTestCustomActor");
953 DALI_TEST_CHECK(type);
955 BaseHandle handle = type.CreateInstance();
956 DALI_TEST_CHECK(handle);
958 Property::Map attributes;
959 DALI_TEST_CHECK(handle.DoAction("act1", attributes));
960 DALI_TEST_CHECK(lastActionCustom == "act1");
965 int UtcDaliTypeRegistryTypeActionN(void)
967 ResetFunctorCounts();
969 TestApplication application;
971 TypeInfo type = TypeRegistry::Get().GetTypeInfo("MyTestCustomActor");
972 DALI_TEST_CHECK(type);
974 BaseHandle handle = type.CreateInstance();
975 DALI_TEST_CHECK(handle);
977 Property::Map attributes;
978 DALI_TEST_CHECK(!handle.DoAction("unknownAction", attributes));
983 int UtcDaliTypeRegistryPropertyRegistrationP(void)
985 TestApplication application;
986 TypeRegistry typeRegistry = TypeRegistry::Get();
988 // Check property count before property registration
989 TypeInfo typeInfo = typeRegistry.GetTypeInfo(typeid(MyTestCustomActor));
990 DALI_TEST_CHECK(typeInfo);
991 BaseHandle handle = typeInfo.CreateInstance();
992 DALI_TEST_CHECK(handle);
993 Actor customActor = Actor::DownCast(handle);
994 DALI_TEST_CHECK(customActor);
995 unsigned int initialPropertyCount(customActor.GetPropertyCount());
997 std::string propertyName("prop1");
998 int propertyIndex(PROPERTY_REGISTRATION_START_INDEX);
999 Property::Type propertyType(Property::BOOLEAN);
1000 PropertyRegistration property1(customType1, propertyName, propertyIndex, propertyType, &SetProperty, &GetProperty);
1002 // Check property count after registration
1003 unsigned int postRegistrationPropertyCount(customActor.GetPropertyCount());
1004 DALI_TEST_EQUALS(initialPropertyCount + 1u, postRegistrationPropertyCount, TEST_LOCATION);
1006 // Add custom property and check property count
1007 customActor.RegisterProperty("customProp1", true);
1008 unsigned int customPropertyCount(customActor.GetPropertyCount());
1009 DALI_TEST_EQUALS(postRegistrationPropertyCount + 1u, customPropertyCount, TEST_LOCATION);
1011 // Set the property, ensure SetProperty called
1012 DALI_TEST_CHECK(!setPropertyCalled);
1013 customActor.SetProperty(propertyIndex, false);
1014 DALI_TEST_CHECK(setPropertyCalled);
1016 // Get the property, ensure GetProperty called
1017 DALI_TEST_CHECK(!getPropertyCalled);
1018 (void)customActor.GetProperty<bool>(propertyIndex);
1019 DALI_TEST_CHECK(getPropertyCalled);
1021 // Get the property using GetCurrentProperty and ensure GetProperty is called
1022 getPropertyCalled = false;
1023 DALI_TEST_CHECK(!getPropertyCalled);
1024 customActor.GetCurrentProperty<bool>(propertyIndex);
1025 DALI_TEST_CHECK(getPropertyCalled);
1027 // Check the property name
1028 DALI_TEST_EQUALS(customActor.GetPropertyName(propertyIndex), propertyName, TEST_LOCATION);
1029 DALI_TEST_EQUALS(typeInfo.GetPropertyName(propertyIndex), propertyName, TEST_LOCATION);
1031 // Check the property index
1032 DALI_TEST_EQUALS(customActor.GetPropertyIndex(propertyName), propertyIndex, TEST_LOCATION);
1034 // Check the property type
1035 DALI_TEST_EQUALS(customActor.GetPropertyType(propertyIndex), propertyType, TEST_LOCATION);
1037 // Check property count of type-info is 1
1038 Property::IndexContainer indices;
1039 typeInfo.GetPropertyIndices(indices);
1041 size_t typePropertyCount = typeInfo.GetPropertyCount();
1042 DALI_TEST_EQUALS(indices.Size(), Actor::New().GetPropertyCount() + 1u, TEST_LOCATION);
1043 DALI_TEST_EQUALS(indices.Size(), typePropertyCount, TEST_LOCATION);
1045 // Ensure indices returned from actor and customActor differ by two
1046 Actor actor = Actor::New();
1047 actor.GetPropertyIndices(indices);
1048 unsigned int actorIndices = indices.Size();
1049 customActor.GetPropertyIndices(indices);
1050 unsigned int customActorIndices = indices.Size();
1051 DALI_TEST_EQUALS(actorIndices + 2u, customActorIndices, TEST_LOCATION); // Custom property + registered property
1055 int UtcDaliTypeRegistryPropertyRegistrationN(void)
1057 TestApplication application;
1058 TypeRegistry typeRegistry = TypeRegistry::Get();
1060 // Attempt to register a property type out-of-bounds index (less than)
1063 PropertyRegistration property1(customType1, "propName", PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN, &SetProperty, &GetProperty);
1064 tet_result(TET_FAIL);
1066 catch(DaliException& e)
1068 DALI_TEST_ASSERT(e, "(index >= PROPERTY_REGISTRATION_START_INDEX) && (index <= PROPERTY_REGISTRATION_MAX_INDEX)", TEST_LOCATION);
1071 // Attempt to register a property type out-of-bounds index (greater than)
1074 PropertyRegistration property1(customType1, "propName", PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN, &SetProperty, &GetProperty);
1075 tet_result(TET_FAIL);
1077 catch(DaliException& e)
1079 DALI_TEST_ASSERT(e, "(index >= PROPERTY_REGISTRATION_START_INDEX) && (index <= PROPERTY_REGISTRATION_MAX_INDEX)", TEST_LOCATION);
1085 int UtcDaliTypeRegistryAnimatablePropertyRegistrationP(void)
1087 TestApplication application;
1088 TypeRegistry typeRegistry = TypeRegistry::Get();
1090 // Check property count before property registration
1091 TypeInfo typeInfo = typeRegistry.GetTypeInfo(typeid(MyTestCustomActor));
1092 DALI_TEST_CHECK(typeInfo);
1093 BaseHandle handle = typeInfo.CreateInstance();
1094 DALI_TEST_CHECK(handle);
1095 Actor customActor = Actor::DownCast(handle);
1096 DALI_TEST_CHECK(customActor);
1097 application.GetScene().Add(customActor);
1099 unsigned int customPropertyCount(customActor.GetPropertyCount());
1101 // Register animatable property
1102 std::string animatablePropertyName("animatableProp1");
1103 int animatablePropertyIndex(ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX);
1104 Property::Type animatablePropertyType(Property::FLOAT);
1105 AnimatablePropertyRegistration animatableProperty(customType1, animatablePropertyName, animatablePropertyIndex, animatablePropertyType);
1107 // Check property count after registration
1108 DALI_TEST_EQUALS(customPropertyCount + 1u, customActor.GetPropertyCount(), TEST_LOCATION);
1110 // Set the animatable property value
1111 customActor.SetProperty(animatablePropertyIndex, 25.0f);
1113 // Render and notify
1114 application.SendNotification();
1115 application.Render();
1117 // Check the animatable property value
1118 DALI_TEST_EQUALS(customActor.GetProperty<float>(animatablePropertyIndex), 25.f, TEST_LOCATION);
1120 // Check the animatable property name
1121 DALI_TEST_EQUALS(customActor.GetPropertyName(animatablePropertyIndex), animatablePropertyName, TEST_LOCATION);
1123 // Check the animatable property index
1124 DALI_TEST_EQUALS(customActor.GetPropertyIndex(animatablePropertyName), animatablePropertyIndex, TEST_LOCATION);
1126 // Check the animatable property type
1127 DALI_TEST_EQUALS(customActor.GetPropertyType(animatablePropertyIndex), animatablePropertyType, TEST_LOCATION);
1129 // Check property count of type-info is 1
1130 Property::IndexContainer indices;
1131 typeInfo.GetPropertyIndices(indices);
1132 DALI_TEST_EQUALS(indices.Size(), customActor.GetPropertyCount(), TEST_LOCATION);
1134 // Ensure indices returned from actor and customActor differ by one
1135 Actor actor = Actor::New();
1136 actor.GetPropertyIndices(indices);
1137 unsigned int actorIndices = indices.Size();
1138 customActor.GetPropertyIndices(indices);
1139 unsigned int customActorIndices = indices.Size();
1140 DALI_TEST_EQUALS(actorIndices + 1u, customActorIndices, TEST_LOCATION); // Custom property + registered property
1142 // check that the property is animatable
1143 Animation animation = Animation::New(0.2f);
1144 animation.AnimateTo(Property(customActor, animatablePropertyIndex), 15.f, AlphaFunction::LINEAR);
1147 // Target value should change straight away
1148 DALI_TEST_EQUALS(customActor.GetProperty<float>(animatablePropertyIndex), 15.0f, TEST_LOCATION);
1150 // Render and notify, animation play for 0.05 seconds
1151 application.SendNotification();
1152 application.Render(50);
1153 DALI_TEST_EQUALS(0.25f, animation.GetCurrentProgress(), TEST_LOCATION);
1154 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(animatablePropertyIndex), 22.5f, TEST_LOCATION);
1156 // Render and notify, animation play for another 0.1 seconds
1157 application.SendNotification();
1158 application.Render(100);
1159 DALI_TEST_EQUALS(0.75f, animation.GetCurrentProgress(), TEST_LOCATION);
1160 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(animatablePropertyIndex), 17.5f, TEST_LOCATION);
1165 int UtcDaliTypeRegistryAnimatablePropertyRegistrationN(void)
1167 TestApplication application;
1168 TypeRegistry typeRegistry = TypeRegistry::Get();
1170 // Attempt to register an animatable property type out-of-bounds index (less than)
1173 AnimatablePropertyRegistration property1(customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN);
1174 tet_result(TET_FAIL);
1176 catch(DaliException& e)
1178 DALI_TEST_ASSERT(e, "(index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX) && (index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX)", TEST_LOCATION);
1181 // Attempt to register an animatable property type out-of-bounds index (greater than)
1184 AnimatablePropertyRegistration property1(customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN);
1185 tet_result(TET_FAIL);
1187 catch(DaliException& e)
1189 DALI_TEST_ASSERT(e, "(index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX) && (index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX)", TEST_LOCATION);
1195 int UtcDaliTypeRegistryAnimatablePropertyRegistrationWithDefaultP(void)
1197 TestApplication application;
1198 TypeRegistry typeRegistry = TypeRegistry::Get();
1200 // Check property count before property registration
1201 TypeInfo typeInfo = typeRegistry.GetTypeInfo(typeid(MyTestCustomActor));
1202 DALI_TEST_CHECK(typeInfo);
1203 BaseHandle handle = typeInfo.CreateInstance();
1204 DALI_TEST_CHECK(handle);
1205 Actor customActor = Actor::DownCast(handle);
1206 DALI_TEST_CHECK(customActor);
1207 application.GetScene().Add(customActor);
1209 unsigned int customPropertyCount(customActor.GetPropertyCount());
1211 // Register animatable property
1212 std::string animatablePropertyName("animatableProp1");
1213 int animatablePropertyIndex(ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX);
1214 AnimatablePropertyRegistration animatableProperty1(customType1, animatablePropertyName, animatablePropertyIndex, 10.f);
1216 // Check property count after registration
1217 DALI_TEST_EQUALS(customPropertyCount + 1u, customActor.GetPropertyCount(), TEST_LOCATION);
1219 // Render and notify
1220 application.SendNotification();
1221 application.Render();
1223 // Check the animatable property value
1224 DALI_TEST_EQUALS(customActor.GetProperty<float>(animatablePropertyIndex), 10.f, TEST_LOCATION);
1226 // Check the animatable property name
1227 DALI_TEST_EQUALS(customActor.GetPropertyName(animatablePropertyIndex), animatablePropertyName, TEST_LOCATION);
1229 // Check the animatable property index
1230 DALI_TEST_EQUALS(customActor.GetPropertyIndex(animatablePropertyName), animatablePropertyIndex, TEST_LOCATION);
1232 // Check the animatable property type
1233 DALI_TEST_EQUALS(customActor.GetPropertyType(animatablePropertyIndex), Property::FLOAT, TEST_LOCATION);
1235 // Check property count of type-info
1236 Property::IndexContainer indices;
1237 typeInfo.GetPropertyIndices(indices);
1238 DALI_TEST_EQUALS(indices.Size(), customActor.GetPropertyCount(), TEST_LOCATION);
1240 // Ensure indices returned from actor and customActor differ by one
1241 Actor actor = Actor::New();
1242 actor.GetPropertyIndices(indices);
1243 unsigned int actorIndices = indices.Size();
1244 customActor.GetPropertyIndices(indices);
1245 unsigned int customActorIndices = indices.Size();
1246 DALI_TEST_EQUALS(actorIndices + 1u, customActorIndices, TEST_LOCATION); // Custom property + registered property
1248 // check that the property is animatable
1249 Animation animation = Animation::New(0.2f);
1250 animation.AnimateTo(Property(customActor, animatablePropertyIndex), 20.f, AlphaFunction::LINEAR);
1253 // Target value should change straight away
1254 DALI_TEST_EQUALS(customActor.GetProperty<float>(animatablePropertyIndex), 20.0f, TEST_LOCATION);
1256 // Render and notify, animation play for 0.05 seconds
1257 application.SendNotification();
1258 application.Render(50);
1259 DALI_TEST_EQUALS(0.25f, animation.GetCurrentProgress(), TEST_LOCATION);
1260 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(animatablePropertyIndex), 12.5f, TEST_LOCATION);
1262 // Render and notify, animation play for another 0.1 seconds
1263 application.SendNotification();
1264 application.Render(100);
1265 DALI_TEST_EQUALS(0.75f, animation.GetCurrentProgress(), TEST_LOCATION);
1266 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(animatablePropertyIndex), 17.5f, TEST_LOCATION);
1271 int UtcDaliTypeRegistryAnimatablePropertyRegistrationWithDefaultN(void)
1273 TestApplication application;
1274 TypeRegistry typeRegistry = TypeRegistry::Get();
1276 // Attempt to register an animatable property type out-of-bounds index (less than)
1279 AnimatablePropertyRegistration property1(customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX - 1, false);
1280 tet_result(TET_FAIL);
1282 catch(DaliException& e)
1284 DALI_TEST_ASSERT(e, "(index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX) && (index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX)", TEST_LOCATION);
1287 // Attempt to register an animatable property type out-of-bounds index (greater than)
1290 AnimatablePropertyRegistration property1(customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX + 1, true);
1291 tet_result(TET_FAIL);
1293 catch(DaliException& e)
1295 DALI_TEST_ASSERT(e, "(index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX) && (index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX)", TEST_LOCATION);
1301 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationP(void)
1303 TestApplication application;
1304 TypeRegistry typeRegistry = TypeRegistry::Get();
1306 // Check property count before property registration
1307 TypeInfo typeInfo = typeRegistry.GetTypeInfo(typeid(MyTestCustomActor));
1308 DALI_TEST_CHECK(typeInfo);
1309 BaseHandle handle = typeInfo.CreateInstance();
1310 DALI_TEST_CHECK(handle);
1311 Actor customActor = Actor::DownCast(handle);
1312 DALI_TEST_CHECK(customActor);
1314 unsigned int customPropertyCount(customActor.GetPropertyCount());
1316 // Register animatable property
1317 std::string animatablePropertyName("animatableProp1");
1318 int animatablePropertyIndex(ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX);
1319 Property::Type animatablePropertyType(Property::VECTOR2);
1320 AnimatablePropertyRegistration animatableProperty1(customType1, animatablePropertyName, animatablePropertyIndex, animatablePropertyType);
1322 // Check property count after registration
1323 DALI_TEST_EQUALS(customPropertyCount + 1u, customActor.GetPropertyCount(), TEST_LOCATION);
1325 // Set the animatable property value
1326 customActor.SetProperty(animatablePropertyIndex, Vector2(25.0f, 50.0f));
1328 // Render and notify
1329 application.SendNotification();
1330 application.Render();
1332 // Check the animatable property value
1333 DALI_TEST_EQUALS(customActor.GetProperty<Vector2>(animatablePropertyIndex), Vector2(25.0f, 50.0f), TEST_LOCATION);
1335 // Check the animatable property name
1336 DALI_TEST_EQUALS(customActor.GetPropertyName(animatablePropertyIndex), animatablePropertyName, TEST_LOCATION);
1338 // Check the animatable property index
1339 DALI_TEST_EQUALS(customActor.GetPropertyIndex(animatablePropertyName), animatablePropertyIndex, TEST_LOCATION);
1341 // Check the animatable property type
1342 DALI_TEST_EQUALS(customActor.GetPropertyType(animatablePropertyIndex), animatablePropertyType, TEST_LOCATION);
1344 // Check property count of type-info
1345 Property::IndexContainer indices;
1346 typeInfo.GetPropertyIndices(indices);
1347 DALI_TEST_EQUALS(indices.Size(), customActor.GetPropertyCount(), TEST_LOCATION);
1349 // Register animatable property components
1350 std::string animatablePropertyComponentName1("animatableProp1X");
1351 int animatablePropertyComponentIndex1(ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1);
1352 AnimatablePropertyComponentRegistration animatablePropertyComponent1(customType1, animatablePropertyComponentName1, animatablePropertyComponentIndex1, animatablePropertyIndex, 0);
1354 std::string animatablePropertyComponentName2("animatableProp1Y");
1355 int animatablePropertyComponentIndex2(ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2);
1356 AnimatablePropertyComponentRegistration animatablePropertyComponent2(customType1, animatablePropertyComponentName2, animatablePropertyComponentIndex2, animatablePropertyIndex, 1);
1358 // Check property count after registration
1359 DALI_TEST_EQUALS(customPropertyCount + 3u, customActor.GetPropertyCount(), TEST_LOCATION);
1361 // Check the animatable property component value
1362 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(animatablePropertyComponentIndex1), 25.0f, TEST_LOCATION);
1363 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(animatablePropertyComponentIndex2), 50.0f, TEST_LOCATION);
1365 // Set the animatable property component value
1366 customActor.SetProperty(animatablePropertyComponentIndex1, 150.0f);
1368 // Render and notify
1369 application.SendNotification();
1370 application.Render();
1372 // Check the animatable property value
1373 DALI_TEST_EQUALS(customActor.GetCurrentProperty<Vector2>(animatablePropertyIndex), Vector2(150.0f, 50.0f), TEST_LOCATION);
1374 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(animatablePropertyComponentIndex1), 150.0f, TEST_LOCATION);
1375 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(animatablePropertyComponentIndex2), 50.0f, TEST_LOCATION);
1377 // Set the animatable property component value
1378 customActor.SetProperty(animatablePropertyComponentIndex2, 225.0f);
1380 // Render and notify
1381 application.SendNotification();
1382 application.Render();
1384 // Check the animatable property value
1385 DALI_TEST_EQUALS(customActor.GetCurrentProperty<Vector2>(animatablePropertyIndex), Vector2(150.0f, 225.0f), TEST_LOCATION);
1386 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(animatablePropertyComponentIndex1), 150.0f, TEST_LOCATION);
1387 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(animatablePropertyComponentIndex2), 225.0f, TEST_LOCATION);
1389 // Ensure indices returned from actor and customActor differ by three
1390 Actor actor = Actor::New();
1391 actor.GetPropertyIndices(indices);
1392 unsigned int actorIndices = indices.Size();
1393 customActor.GetPropertyIndices(indices);
1394 unsigned int customActorIndices = indices.Size();
1395 DALI_TEST_EQUALS(actorIndices + 3u, customActorIndices, TEST_LOCATION); // Custom property + registered property
1397 application.GetScene().Add(customActor);
1399 // Attempt to animate component property, it should not crash
1400 Animation animation = Animation::New(1.0f);
1401 animation.AnimateTo(Property(customActor, animatablePropertyComponentIndex1), 200.0f);
1404 // Check the property value
1405 DALI_TEST_EQUALS(customActor.GetProperty<Vector2>(animatablePropertyIndex), Vector2(200.0f, 225.0f), TEST_LOCATION);
1406 DALI_TEST_EQUALS(customActor.GetProperty<float>(animatablePropertyComponentIndex1), 200.0f, TEST_LOCATION);
1407 DALI_TEST_EQUALS(customActor.GetProperty<float>(animatablePropertyComponentIndex2), 225.0f, TEST_LOCATION);
1412 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationVector2AnimateByP(void)
1414 TestApplication application;
1415 TypeRegistry typeRegistry = TypeRegistry::Get();
1417 TypeInfo typeInfo = typeRegistry.GetTypeInfo(typeid(MyTestCustomActor));
1418 DALI_TEST_CHECK(typeInfo);
1419 BaseHandle handle = typeInfo.CreateInstance();
1420 DALI_TEST_CHECK(handle);
1421 Actor customActor = Actor::DownCast(handle);
1422 application.GetScene().Add(customActor);
1423 DALI_TEST_CHECK(customActor);
1425 const unsigned int index = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX;
1426 const unsigned int xComponentIndex = index + 1;
1427 const unsigned int yComponentIndex = index + 2;
1428 const Vector2 initialValue(20.0f, 40.0f);
1430 // Register animatable property & its components
1431 AnimatablePropertyRegistration animatableProperty1(customType1, "animatableProp1", index, initialValue);
1432 AnimatablePropertyComponentRegistration animatablePropertyComponent1(customType1, "animatableProp1X", xComponentIndex, index, 0);
1433 AnimatablePropertyComponentRegistration animatablePropertyComponent2(customType1, "animatableProp1Y", yComponentIndex, index, 1);
1435 // Check the animatable property value
1436 DALI_TEST_EQUALS(customActor.GetProperty<Vector2>(index), initialValue, TEST_LOCATION);
1437 DALI_TEST_EQUALS(customActor.GetProperty<float>(xComponentIndex), initialValue.x, TEST_LOCATION);
1438 DALI_TEST_EQUALS(customActor.GetProperty<float>(yComponentIndex), initialValue.y, TEST_LOCATION);
1440 // Render and notify
1441 application.SendNotification();
1442 application.Render();
1444 // Check the animatable property current value
1445 DALI_TEST_EQUALS(customActor.GetCurrentProperty<Vector2>(index), initialValue, TEST_LOCATION);
1446 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(xComponentIndex), initialValue.x, TEST_LOCATION);
1447 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(yComponentIndex), initialValue.y, TEST_LOCATION);
1450 const Vector2 targetValue(45.0f, 53.0f);
1451 const Vector2 relativeValue(targetValue - initialValue);
1453 Animation animation = Animation::New(1.0f);
1454 animation.AnimateBy(Property(customActor, xComponentIndex), relativeValue.x);
1455 animation.AnimateBy(Property(customActor, yComponentIndex), relativeValue.y);
1458 // Target values should change straight away
1459 DALI_TEST_EQUALS(customActor.GetProperty<Vector2>(index), targetValue, TEST_LOCATION);
1460 DALI_TEST_EQUALS(customActor.GetProperty<float>(xComponentIndex), targetValue.x, TEST_LOCATION);
1461 DALI_TEST_EQUALS(customActor.GetProperty<float>(yComponentIndex), targetValue.y, TEST_LOCATION);
1466 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationVector3AnimateByP(void)
1468 TestApplication application;
1469 TypeRegistry typeRegistry = TypeRegistry::Get();
1471 TypeInfo typeInfo = typeRegistry.GetTypeInfo(typeid(MyTestCustomActor));
1472 DALI_TEST_CHECK(typeInfo);
1473 BaseHandle handle = typeInfo.CreateInstance();
1474 DALI_TEST_CHECK(handle);
1475 Actor customActor = Actor::DownCast(handle);
1476 application.GetScene().Add(customActor);
1477 DALI_TEST_CHECK(customActor);
1479 const unsigned int index = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX;
1480 const unsigned int xComponentIndex = index + 1;
1481 const unsigned int yComponentIndex = index + 2;
1482 const unsigned int zComponentIndex = index + 3;
1483 const Vector3 initialValue(20.0f, 40.0f, 50.0f);
1485 // Register animatable property & its components
1486 AnimatablePropertyRegistration animatableProperty1(customType1, "animatableProp1", index, initialValue);
1487 AnimatablePropertyComponentRegistration animatablePropertyComponent1(customType1, "animatableProp1X", xComponentIndex, index, 0);
1488 AnimatablePropertyComponentRegistration animatablePropertyComponent2(customType1, "animatableProp1Y", yComponentIndex, index, 1);
1489 AnimatablePropertyComponentRegistration animatablePropertyComponent3(customType1, "animatableProp1Z", zComponentIndex, index, 2);
1491 // Check the animatable property value
1492 DALI_TEST_EQUALS(customActor.GetProperty<Vector3>(index), initialValue, TEST_LOCATION);
1493 DALI_TEST_EQUALS(customActor.GetProperty<float>(xComponentIndex), initialValue.x, TEST_LOCATION);
1494 DALI_TEST_EQUALS(customActor.GetProperty<float>(yComponentIndex), initialValue.y, TEST_LOCATION);
1495 DALI_TEST_EQUALS(customActor.GetProperty<float>(zComponentIndex), initialValue.z, TEST_LOCATION);
1497 // Render and notify
1498 application.SendNotification();
1499 application.Render();
1501 // Check the animatable property current value
1502 DALI_TEST_EQUALS(customActor.GetCurrentProperty<Vector3>(index), initialValue, TEST_LOCATION);
1503 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(xComponentIndex), initialValue.x, TEST_LOCATION);
1504 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(yComponentIndex), initialValue.y, TEST_LOCATION);
1505 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(zComponentIndex), initialValue.z, TEST_LOCATION);
1508 const Vector3 targetValue(45.0f, 53.0f, 25.0f);
1509 const Vector3 relativeValue(targetValue - initialValue);
1511 Animation animation = Animation::New(1.0f);
1512 animation.AnimateBy(Property(customActor, xComponentIndex), relativeValue.x);
1513 animation.AnimateBy(Property(customActor, yComponentIndex), relativeValue.y);
1514 animation.AnimateBy(Property(customActor, zComponentIndex), relativeValue.z);
1517 // Target values should change straight away
1518 DALI_TEST_EQUALS(customActor.GetProperty<Vector3>(index), targetValue, TEST_LOCATION);
1519 DALI_TEST_EQUALS(customActor.GetProperty<float>(xComponentIndex), targetValue.x, TEST_LOCATION);
1520 DALI_TEST_EQUALS(customActor.GetProperty<float>(yComponentIndex), targetValue.y, TEST_LOCATION);
1521 DALI_TEST_EQUALS(customActor.GetProperty<float>(zComponentIndex), targetValue.z, TEST_LOCATION);
1526 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationVector4AnimateByP(void)
1528 TestApplication application;
1529 TypeRegistry typeRegistry = TypeRegistry::Get();
1531 TypeInfo typeInfo = typeRegistry.GetTypeInfo(typeid(MyTestCustomActor));
1532 DALI_TEST_CHECK(typeInfo);
1533 BaseHandle handle = typeInfo.CreateInstance();
1534 DALI_TEST_CHECK(handle);
1535 Actor customActor = Actor::DownCast(handle);
1536 application.GetScene().Add(customActor);
1537 DALI_TEST_CHECK(customActor);
1539 const unsigned int index = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX;
1540 const unsigned int xComponentIndex = index + 1;
1541 const unsigned int yComponentIndex = index + 2;
1542 const unsigned int zComponentIndex = index + 3;
1543 const unsigned int wComponentIndex = index + 4;
1544 const Vector4 initialValue(20.0f, 40.0f, 50.0f, 60.0f);
1546 // Register animatable property & its components
1547 AnimatablePropertyRegistration animatableProperty1(customType1, "animatableProp1", index, initialValue);
1548 AnimatablePropertyComponentRegistration animatablePropertyComponent1(customType1, "animatableProp1X", xComponentIndex, index, 0);
1549 AnimatablePropertyComponentRegistration animatablePropertyComponent2(customType1, "animatableProp1Y", yComponentIndex, index, 1);
1550 AnimatablePropertyComponentRegistration animatablePropertyComponent3(customType1, "animatableProp1Z", zComponentIndex, index, 2);
1551 AnimatablePropertyComponentRegistration animatablePropertyComponent4(customType1, "animatableProp1W", wComponentIndex, index, 3);
1553 // Check the animatable property value
1554 DALI_TEST_EQUALS(customActor.GetProperty<Vector4>(index), initialValue, TEST_LOCATION);
1555 DALI_TEST_EQUALS(customActor.GetProperty<float>(xComponentIndex), initialValue.x, TEST_LOCATION);
1556 DALI_TEST_EQUALS(customActor.GetProperty<float>(yComponentIndex), initialValue.y, TEST_LOCATION);
1557 DALI_TEST_EQUALS(customActor.GetProperty<float>(zComponentIndex), initialValue.z, TEST_LOCATION);
1558 DALI_TEST_EQUALS(customActor.GetProperty<float>(wComponentIndex), initialValue.w, TEST_LOCATION);
1560 // Render and notify
1561 application.SendNotification();
1562 application.Render();
1564 // Check the animatable property current value
1565 DALI_TEST_EQUALS(customActor.GetCurrentProperty<Vector4>(index), initialValue, TEST_LOCATION);
1566 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(xComponentIndex), initialValue.x, TEST_LOCATION);
1567 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(yComponentIndex), initialValue.y, TEST_LOCATION);
1568 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(zComponentIndex), initialValue.z, TEST_LOCATION);
1569 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(wComponentIndex), initialValue.w, TEST_LOCATION);
1572 const Vector4 targetValue(45.0f, 53.0f, 25.0f, 13.0f);
1573 const Vector4 relativeValue(targetValue - initialValue);
1575 Animation animation = Animation::New(1.0f);
1576 animation.AnimateBy(Property(customActor, xComponentIndex), relativeValue.x);
1577 animation.AnimateBy(Property(customActor, yComponentIndex), relativeValue.y);
1578 animation.AnimateBy(Property(customActor, zComponentIndex), relativeValue.z);
1579 animation.AnimateBy(Property(customActor, wComponentIndex), relativeValue.w);
1582 // Target values should change straight away
1583 DALI_TEST_EQUALS(customActor.GetProperty<Vector4>(index), targetValue, TEST_LOCATION);
1584 DALI_TEST_EQUALS(customActor.GetProperty<float>(xComponentIndex), targetValue.x, TEST_LOCATION);
1585 DALI_TEST_EQUALS(customActor.GetProperty<float>(yComponentIndex), targetValue.y, TEST_LOCATION);
1586 DALI_TEST_EQUALS(customActor.GetProperty<float>(zComponentIndex), targetValue.z, TEST_LOCATION);
1587 DALI_TEST_EQUALS(customActor.GetProperty<float>(wComponentIndex), targetValue.w, TEST_LOCATION);
1592 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationN(void)
1594 TestApplication application;
1595 TypeRegistry typeRegistry = TypeRegistry::Get();
1597 // Register animatable property with the type of Vector2
1598 int animatablePropertyIndex1(ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX);
1599 AnimatablePropertyRegistration animatableProperty1(customType1, "animatableProp1", animatablePropertyIndex1, Property::VECTOR2);
1601 // Attempt to register an animatable property component out-of-bounds index (less than)
1604 AnimatablePropertyComponentRegistration propertyComponent1(customType1, "animatableProp1X", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX - 1, animatablePropertyIndex1, 0);
1605 tet_result(TET_FAIL);
1607 catch(DaliException& e)
1609 DALI_TEST_ASSERT(e, "(index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX) && (index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX)", TEST_LOCATION);
1612 // Attempt to register an animatable property component out-of-bounds index (greater than)
1615 AnimatablePropertyComponentRegistration propertyComponent1(customType1, "animatableProp1X", ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX + 1, animatablePropertyIndex1, 0);
1616 tet_result(TET_FAIL);
1618 catch(DaliException& e)
1620 DALI_TEST_ASSERT(e, "(index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX) && (index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX)", TEST_LOCATION);
1623 // Register an animatable property component
1624 AnimatablePropertyComponentRegistration propertyComponent1(customType1, "animatableProp1X", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1, animatablePropertyIndex1, 0);
1626 // Attempt to register another animatable property component with the same component index
1629 AnimatablePropertyComponentRegistration propertyComponent2(customType1, "animatableProp1Y", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2, animatablePropertyIndex1, 0);
1630 tet_result(TET_FAIL);
1632 catch(DaliException& e)
1634 DALI_TEST_ASSERT(e, "Property component already registered", TEST_LOCATION);
1637 // Register animatable property with the type of boolean
1638 int animatablePropertyIndex2(ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2);
1639 AnimatablePropertyRegistration animatableProperty2(customType1, "animatableProp2", animatablePropertyIndex2, Property::BOOLEAN);
1641 // Attempt to register an animatable property component for the above property with boolean type
1644 AnimatablePropertyComponentRegistration propertyComponent1(customType1, "animatableProp2X", animatablePropertyIndex2 + 1, animatablePropertyIndex2, 0);
1645 tet_result(TET_FAIL);
1647 catch(DaliException& e)
1649 DALI_TEST_ASSERT(e, "Base property does not support component", TEST_LOCATION);
1655 int UtcDaliTypeRegistryChildPropertyRegistrationP(void)
1657 TestApplication application;
1658 TypeRegistry typeRegistry = TypeRegistry::Get();
1660 // Check property count before property registration
1661 TypeInfo typeInfo = typeRegistry.GetTypeInfo(typeid(MyTestCustomActor));
1662 DALI_TEST_CHECK(typeInfo);
1663 BaseHandle handle = typeInfo.CreateInstance();
1664 DALI_TEST_CHECK(handle);
1665 Actor customActor = Actor::DownCast(handle);
1666 DALI_TEST_CHECK(customActor);
1667 unsigned int initialPropertyCount(customActor.GetPropertyCount());
1669 // Register child properties to the parent
1670 std::string propertyName("childProp1");
1671 int propertyIndex(CHILD_PROPERTY_REGISTRATION_START_INDEX);
1672 Property::Type propertyType(Property::BOOLEAN);
1673 ChildPropertyRegistration childProperty1(customType1, propertyName, propertyIndex, propertyType);
1675 std::string propertyName2("childProp2");
1676 int propertyIndex2(CHILD_PROPERTY_REGISTRATION_START_INDEX + 1);
1677 Property::Type propertyType2(Property::INTEGER);
1678 ChildPropertyRegistration childProperty2(customType1, propertyName2, propertyIndex2, propertyType2);
1680 std::string propertyName3("childProp3");
1681 int propertyIndex3(CHILD_PROPERTY_REGISTRATION_START_INDEX + 2);
1682 Property::Type propertyType3(Property::FLOAT);
1683 ChildPropertyRegistration childProperty3(customType1, propertyName3, propertyIndex3, propertyType3);
1685 std::string propertyName4("childProp4");
1686 int propertyIndex4(CHILD_PROPERTY_REGISTRATION_START_INDEX + 3);
1687 Property::Type propertyType4(Property::INTEGER);
1688 ChildPropertyRegistration childProperty4(customType1, propertyName4, propertyIndex4, propertyType4);
1690 // Check property count are not changed because the child properties will not be created for the parent
1691 DALI_TEST_EQUALS(initialPropertyCount, customActor.GetPropertyCount(), TEST_LOCATION);
1693 // check the child property type
1694 Internal::TypeInfo& typeInfoImpl = GetImplementation(typeInfo);
1695 Property::Type type = typeInfoImpl.GetChildPropertyType(typeInfoImpl.GetChildPropertyIndex(Dali::Internal::ConstString("childProp4")));
1696 DALI_TEST_EQUALS(type, Property::INTEGER, TEST_LOCATION);
1698 std::string unRegisteredChildName(typeInfoImpl.GetChildPropertyName(CHILD_PROPERTY_REGISTRATION_START_INDEX + 4));
1699 DALI_TEST_EQUALS(unRegisteredChildName, "", TEST_LOCATION);
1701 // Create a child actor
1702 Actor childActor = Actor::New();
1703 DALI_TEST_CHECK(childActor);
1704 unsigned int initialChildActorPropertyCount(childActor.GetPropertyCount());
1706 // The type of child properties should be Property::None as the child hasn't registered any child property yet.
1707 DALI_TEST_EQUALS(childActor.GetPropertyType(propertyIndex), Property::NONE, TEST_LOCATION);
1708 DALI_TEST_EQUALS(childActor.GetPropertyType(propertyIndex2), Property::NONE, TEST_LOCATION);
1709 DALI_TEST_EQUALS(childActor.GetPropertyType(propertyIndex3), Property::NONE, TEST_LOCATION);
1710 DALI_TEST_EQUALS(childActor.GetPropertyType(propertyIndex4), Property::NONE, TEST_LOCATION);
1712 // Set the value for the first child property when the child actor doesn't have a parent yet
1713 childActor.SetProperty(propertyIndex, true);
1715 // Check that the first child property is dynamically created
1716 DALI_TEST_EQUALS(initialChildActorPropertyCount + 1u, childActor.GetPropertyCount(), TEST_LOCATION);
1718 // Check the first child property value
1719 DALI_TEST_EQUALS(childActor.GetProperty<bool>(propertyIndex), true, TEST_LOCATION);
1721 // Check the first child property type
1722 DALI_TEST_EQUALS(childActor.GetPropertyType(propertyIndex), propertyType, TEST_LOCATION);
1724 // Check that the first child property have no name, as it doesn't have a parent yet.
1725 DALI_TEST_EQUALS(childActor.GetPropertyName(propertyIndex), "", TEST_LOCATION);
1727 // Check that the first property can't be accessed through its name, as it doesn't have a parent yet.
1728 DALI_TEST_EQUALS(childActor.GetPropertyIndex(propertyName), Property::INVALID_INDEX, TEST_LOCATION);
1730 // Create a custom property for the child with the same name as the second child property registered to the parent
1731 Property::Index customPropertyIndex = childActor.RegisterProperty(propertyName2, 100, Property::READ_WRITE);
1733 // Check that the custom property is created
1734 DALI_TEST_EQUALS(initialChildActorPropertyCount + 2u, childActor.GetPropertyCount(), TEST_LOCATION);
1736 // Check the property value
1737 DALI_TEST_EQUALS(childActor.GetProperty<int>(customPropertyIndex), 100, TEST_LOCATION);
1739 // Check the property index
1740 DALI_TEST_EQUALS(childActor.GetPropertyIndex(propertyName2), customPropertyIndex, TEST_LOCATION);
1742 // Check the property type
1743 DALI_TEST_EQUALS(childActor.GetPropertyType(customPropertyIndex), propertyType2, TEST_LOCATION);
1745 // Check the property name
1746 DALI_TEST_EQUALS(childActor.GetPropertyName(customPropertyIndex), propertyName2, TEST_LOCATION);
1748 // Now add the child actor to the parent
1749 customActor.Add(childActor);
1751 // Check that the first child property now has the correct name as previously registered to the parent
1752 DALI_TEST_EQUALS(childActor.GetPropertyName(propertyIndex), propertyName, TEST_LOCATION);
1754 // Check that the child property index for the first child property can now be retrieved through its child property name
1755 DALI_TEST_EQUALS(childActor.GetPropertyIndex(propertyName), propertyIndex, TEST_LOCATION);
1757 // Check that the second child property now has the correct index as previously registered to the parent
1758 DALI_TEST_EQUALS(childActor.GetPropertyName(propertyIndex2), propertyName2, TEST_LOCATION);
1760 // Check that the second child property can be accessed through both its custom property index and its child property index
1761 DALI_TEST_EQUALS(childActor.GetProperty<int>(customPropertyIndex), 100, TEST_LOCATION);
1762 DALI_TEST_EQUALS(childActor.GetProperty<int>(propertyIndex2), 100, TEST_LOCATION);
1763 DALI_TEST_EQUALS(childActor.GetPropertyType(customPropertyIndex), propertyType2, TEST_LOCATION);
1764 DALI_TEST_EQUALS(childActor.GetPropertyType(propertyIndex2), propertyType2, TEST_LOCATION);
1766 // Check that the child property index for the second child property can now be retrieved through its child property name
1767 DALI_TEST_EQUALS(childActor.GetPropertyIndex(propertyName2), propertyIndex2, TEST_LOCATION);
1769 // Set the value for the third child property when the child actor is already added to the parent
1770 childActor.SetProperty(propertyIndex3, 0.15f);
1772 // Check that the third child property is dynamically created
1773 DALI_TEST_EQUALS(initialChildActorPropertyCount + 3u, childActor.GetPropertyCount(), TEST_LOCATION);
1775 // Check the third child property value
1776 DALI_TEST_EQUALS(childActor.GetProperty<float>(propertyIndex3), 0.15f, TEST_LOCATION);
1778 // Check the third child property type
1779 DALI_TEST_EQUALS(childActor.GetPropertyType(propertyIndex3), propertyType3, TEST_LOCATION);
1781 // Check the third child property name
1782 DALI_TEST_EQUALS(childActor.GetPropertyName(propertyIndex3), propertyName3, TEST_LOCATION);
1784 // Check the third child property index.
1785 DALI_TEST_EQUALS(childActor.GetPropertyIndex(propertyName3), propertyIndex3, TEST_LOCATION);
1787 // Create a custom property for the child with the same name as the fourth child property registered to the parent
1788 Property::Index customPropertyIndex2 = childActor.RegisterProperty(propertyName4, 20, Property::READ_WRITE);
1790 // Check that the custom property is created
1791 DALI_TEST_EQUALS(initialChildActorPropertyCount + 4u, childActor.GetPropertyCount(), TEST_LOCATION);
1793 // Check the fourth child property value
1794 DALI_TEST_EQUALS(childActor.GetProperty<int>(propertyIndex4), 20, TEST_LOCATION);
1795 DALI_TEST_EQUALS(childActor.GetProperty<int>(customPropertyIndex2), 20, TEST_LOCATION);
1797 // Check the fourth child property type
1798 DALI_TEST_EQUALS(childActor.GetPropertyType(propertyIndex4), propertyType4, TEST_LOCATION);
1799 DALI_TEST_EQUALS(childActor.GetPropertyType(customPropertyIndex2), propertyType4, TEST_LOCATION);
1801 // Check the fourth child property name
1802 DALI_TEST_EQUALS(childActor.GetPropertyName(propertyIndex4), propertyName4, TEST_LOCATION);
1803 DALI_TEST_EQUALS(childActor.GetPropertyName(customPropertyIndex2), propertyName4, TEST_LOCATION);
1805 // Check the fourth child property index.
1806 DALI_TEST_EQUALS(childActor.GetPropertyIndex(propertyName4), propertyIndex4, TEST_LOCATION);
1808 // Now create another parent actor with different child properties registered
1809 TypeInfo typeInfo2 = typeRegistry.GetTypeInfo("MyNamedActor");
1810 DALI_TEST_CHECK(typeInfo2);
1811 BaseHandle handle2 = typeInfo2.CreateInstance();
1812 DALI_TEST_CHECK(handle2);
1813 Actor customActor2 = Actor::DownCast(handle2);
1814 DALI_TEST_CHECK(customActor2);
1816 // Register child properties to the new parent
1817 std::string newPropertyName("newChildProp");
1818 int newPropertyIndex(CHILD_PROPERTY_REGISTRATION_START_INDEX); // The same index as the first child property "childProp1" in the old parent
1819 Property::Type newPropertyType(Property::VECTOR2);
1820 ChildPropertyRegistration newChildProperty(namedActorType, newPropertyName, newPropertyIndex, newPropertyType);
1822 std::string newPropertyName2("childProp3"); // The same name as the third child property in the old parent
1823 int newPropertyIndex2(CHILD_PROPERTY_REGISTRATION_START_INDEX + 1); // The same index as the second child property "childProp2" in the old parent
1824 Property::Type newPropertyType2(Property::FLOAT); // The same type as the third child property in the old parent
1825 ChildPropertyRegistration newChildProperty2(namedActorType, newPropertyName2, newPropertyIndex2, newPropertyType2);
1827 // Now move the child actor to the new parent
1828 customActor2.Add(childActor);
1830 // "childProp1" is not a valid child property supported by the new parent, so nothing changed
1831 DALI_TEST_EQUALS(childActor.GetPropertyType(propertyIndex), propertyType, TEST_LOCATION);
1832 DALI_TEST_EQUALS(childActor.GetPropertyName(propertyIndex), propertyName, TEST_LOCATION);
1833 DALI_TEST_EQUALS(childActor.GetPropertyIndex(propertyName), propertyIndex, TEST_LOCATION);
1835 // "childProp3" is a valid child property supported by the new parent
1836 // So it should get its new child property index and should just work
1837 DALI_TEST_EQUALS(childActor.GetPropertyType(newPropertyIndex2), newPropertyType2, TEST_LOCATION);
1838 DALI_TEST_EQUALS(childActor.GetPropertyName(newPropertyIndex2), newPropertyName2, TEST_LOCATION);
1839 DALI_TEST_EQUALS(childActor.GetPropertyIndex(newPropertyName2), newPropertyIndex2, TEST_LOCATION);
1840 DALI_TEST_EQUALS(childActor.GetProperty<float>(newPropertyIndex2), 0.15f, TEST_LOCATION);
1842 // Now register a custom property called "newChildProp"
1843 Property::Index customPropertyIndex3 = childActor.RegisterProperty("newChildProp", Vector2(10.0f, 10.0f), Property::READ_WRITE);
1845 // Check that the custom property is created
1846 DALI_TEST_EQUALS(initialChildActorPropertyCount + 5u, childActor.GetPropertyCount(), TEST_LOCATION);
1848 // This is a valid child property registered to the new parent
1849 // So should be able to access it through both its custom property index and its registered child property index
1850 DALI_TEST_EQUALS(childActor.GetPropertyType(newPropertyIndex), newPropertyType, TEST_LOCATION);
1851 DALI_TEST_EQUALS(childActor.GetPropertyType(customPropertyIndex3), newPropertyType, TEST_LOCATION);
1852 DALI_TEST_EQUALS(childActor.GetPropertyName(newPropertyIndex), newPropertyName, TEST_LOCATION); // This should return the new name, although the child property index remains the same
1853 DALI_TEST_EQUALS(childActor.GetPropertyName(customPropertyIndex3), newPropertyName, TEST_LOCATION);
1854 DALI_TEST_EQUALS(childActor.GetProperty<Vector2>(newPropertyIndex), Vector2(10.0f, 10.0f), TEST_LOCATION);
1855 DALI_TEST_EQUALS(childActor.GetProperty<Vector2>(customPropertyIndex3), Vector2(10.0f, 10.0f), TEST_LOCATION);
1857 // Should return the child property index by given its name
1858 DALI_TEST_EQUALS(childActor.GetPropertyIndex(newPropertyName), newPropertyIndex, TEST_LOCATION);
1863 int UtcDaliTypeRegistryChildPropertyRegistrationN(void)
1865 TestApplication application;
1866 TypeRegistry typeRegistry = TypeRegistry::Get();
1868 // Attempt to register a child property type out-of-bounds index (less than)
1871 ChildPropertyRegistration property1(customType1, "propName", CHILD_PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN);
1872 tet_result(TET_FAIL);
1874 catch(DaliException& e)
1876 DALI_TEST_ASSERT(e, "(index >= CHILD_PROPERTY_REGISTRATION_START_INDEX) && (index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX)", TEST_LOCATION);
1879 // Attempt to register a child property type out-of-bounds index (greater than)
1882 ChildPropertyRegistration property1(customType1, "propName", CHILD_PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN);
1883 tet_result(TET_FAIL);
1885 catch(DaliException& e)
1887 DALI_TEST_ASSERT(e, "(index >= CHILD_PROPERTY_REGISTRATION_START_INDEX) && (index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX)", TEST_LOCATION);
1893 /*******************************************************************************
1895 * Action through the base handle
1897 ******************************************************************************/
1898 int UtcDaliTypeRegistryActionViaBaseHandle(void)
1900 TestApplication application;
1904 type = TypeRegistry::Get().GetTypeInfo("Actor");
1905 DALI_TEST_CHECK(type);
1907 BaseHandle hdl = type.CreateInstance();
1908 DALI_TEST_CHECK(hdl);
1910 Actor a = Actor::DownCast(hdl);
1913 a.SetProperty(Actor::Property::VISIBLE, false);
1915 application.SendNotification();
1916 application.Render(0);
1917 DALI_TEST_CHECK(!a.GetCurrentProperty<bool>(Actor::Property::VISIBLE));
1919 Property::Map attributes;
1921 DALI_TEST_CHECK(hdl.DoAction("show", attributes));
1923 application.SendNotification();
1924 application.Render(0);
1925 DALI_TEST_CHECK(a.GetCurrentProperty<bool>(Actor::Property::VISIBLE));
1927 DALI_TEST_CHECK(!hdl.DoAction("unknownAction", attributes));
1931 int UtcDaliPropertyRegistrationFunctions(void)
1933 TestApplication application;
1934 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 10;
1936 // Attempt to register a property without a setter
1939 PropertyRegistration property1(customType1, "propName", propertyIndex++, Property::BOOLEAN, NULL, &GetProperty);
1940 tet_result(TET_PASS);
1942 catch(DaliException& e)
1944 tet_result(TET_FAIL);
1947 // Attempt to register a property without a getter
1950 PropertyRegistration property1(customType1, "propName", propertyIndex++, Property::BOOLEAN, NULL, NULL);
1951 tet_result(TET_FAIL);
1953 catch(DaliException& e)
1955 DALI_TEST_ASSERT(e, "!\"GetProperty", TEST_LOCATION);
1960 int UtcDaliPropertyRegistrationAddSameIndex(void)
1962 TestApplication application;
1963 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 100;
1965 // Add one property with a valid property index
1966 PropertyRegistration property1(customType1, "propName", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty);
1968 // Attempt to add another property with the same index
1971 PropertyRegistration property2(customType1, "propName2", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty);
1973 catch(DaliException& e)
1975 DALI_TEST_ASSERT(e, "!\"Property index already added", TEST_LOCATION);
1978 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 100;
1980 // Add one property with a valid property index
1981 AnimatablePropertyRegistration property3(customType1, "animPropName", animatablePropertyIndex, Property::BOOLEAN);
1983 // Attempt to add another property with the same index
1986 AnimatablePropertyRegistration property4(customType1, "animPropName2", animatablePropertyIndex, Property::BOOLEAN);
1988 catch(DaliException& e)
1990 DALI_TEST_ASSERT(e, "!\"Property index already added", TEST_LOCATION);
1995 int UtcDaliPropertyRegistrationPropertyWritableP(void)
1997 TestApplication application;
1998 int propertyIndex1 = PROPERTY_REGISTRATION_START_INDEX + 200;
1999 int propertyIndex2 = PROPERTY_REGISTRATION_START_INDEX + 201;
2001 // Add two properties, one with SetProperty, one without
2002 PropertyRegistration property1(customType1, "propNameReadwrite", propertyIndex1, Property::BOOLEAN, &SetProperty, &GetProperty);
2003 PropertyRegistration property2(customType1, "propNameReadonly", propertyIndex2, Property::BOOLEAN, NULL, &GetProperty);
2005 // Create custom-actor
2006 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo(typeid(MyTestCustomActor));
2007 DALI_TEST_CHECK(typeInfo);
2008 BaseHandle handle = typeInfo.CreateInstance();
2009 DALI_TEST_CHECK(handle);
2010 Actor customActor = Actor::DownCast(handle);
2011 DALI_TEST_CHECK(customActor);
2013 // Check whether properties are writable
2014 DALI_TEST_CHECK(customActor.IsPropertyWritable(propertyIndex1));
2015 DALI_TEST_CHECK(!customActor.IsPropertyWritable(propertyIndex2));
2017 // Check the property is writable in the type registry
2018 Internal::TypeInfo& typeInfoImpl = GetImplementation(typeInfo);
2020 DALI_TEST_EQUALS(typeInfoImpl.IsPropertyWritable(propertyIndex1), true, TEST_LOCATION);
2025 int UtcDaliPropertyRegistrationPropertyWritableN(void)
2027 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo(typeid(MyTestCustomActor));
2028 Internal::TypeInfo& typeInfoImpl = GetImplementation(typeInfo);
2030 DALI_TEST_EQUALS(typeInfoImpl.IsPropertyWritable(Actor::Property::COLOR), true, TEST_LOCATION);
2035 int UtcDaliPropertyRegistrationPropertyAnimatable(void)
2037 TestApplication application;
2038 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 400;
2039 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 400;
2041 // These properties are not animatable
2042 PropertyRegistration property1(customType1, "propName", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty);
2044 // These properties are animatable
2045 AnimatablePropertyRegistration property2(customType1, "animPropName", animatablePropertyIndex, Property::BOOLEAN);
2047 // Create custom-actor
2048 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo(typeid(MyTestCustomActor));
2049 DALI_TEST_CHECK(typeInfo);
2050 BaseHandle handle = typeInfo.CreateInstance();
2051 DALI_TEST_CHECK(handle);
2052 Actor customActor = Actor::DownCast(handle);
2053 DALI_TEST_CHECK(customActor);
2055 // Check if animatable
2056 DALI_TEST_CHECK(!customActor.IsPropertyAnimatable(propertyIndex));
2057 DALI_TEST_CHECK(customActor.IsPropertyAnimatable(animatablePropertyIndex));
2059 // Create another instance of custom-actor
2060 BaseHandle handle2 = typeInfo.CreateInstance();
2061 DALI_TEST_CHECK(handle2);
2062 Actor customActor2 = Actor::DownCast(handle2);
2063 DALI_TEST_CHECK(customActor2);
2065 // Check if animatable
2066 DALI_TEST_CHECK(!customActor2.IsPropertyAnimatable(propertyIndex));
2067 DALI_TEST_CHECK(customActor2.IsPropertyAnimatable(animatablePropertyIndex));
2071 int UtcDaliPropertyRegistrationUnregisteredGetAndSet(void)
2073 TestApplication application;
2074 int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 2000;
2075 int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2000;
2077 // Create custom-actor
2078 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo(typeid(MyTestCustomActor));
2079 DALI_TEST_CHECK(typeInfo);
2080 BaseHandle handle = typeInfo.CreateInstance();
2081 DALI_TEST_CHECK(handle);
2082 Actor customActor = Actor::DownCast(handle);
2083 DALI_TEST_CHECK(customActor);
2085 // Try to set an index that hasn't been registered, this is a no-op for now, to be fixed in future
2086 customActor.SetProperty(propertyIndex, true);
2087 // DALI_TEST_EQUALS( true, customActor.GetProperty( propertyIndex ).Get<bool>(), TEST_LOCATION);
2089 // Try to set an index that hasn't been registered
2090 customActor.SetProperty(animatablePropertyIndex, true);
2091 DALI_TEST_EQUALS(true, customActor.GetProperty(animatablePropertyIndex).Get<bool>(), TEST_LOCATION);
2096 int UtcDaliLongPressGestureDetectorTypeRegistry(void)
2098 TestApplication application;
2100 Actor actor = Actor::New();
2101 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2102 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2103 application.GetScene().Add(actor);
2107 type = TypeRegistry::Get().GetTypeInfo("LongPressGestureDetector");
2108 DALI_TEST_CHECK(type);
2109 BaseHandle handle = type.CreateInstance();
2110 DALI_TEST_CHECK(handle);
2111 LongPressGestureDetector detector = LongPressGestureDetector::DownCast(handle);
2112 DALI_TEST_CHECK(detector);
2114 // Attach actor to detector
2116 GestureReceivedFunctor functor(data);
2117 detector.Attach(actor);
2119 // Connect to signal through type
2120 handle.ConnectSignal(&application, "longPressDetected", functor);
2122 // Render and notify
2123 application.SendNotification();
2124 application.Render();
2127 TestGenerateLongPress(application, 50.0f, 10.0f);
2128 TestEndLongPress(application, 50.0f, 10.0f);
2130 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2134 int UtcDaliPanGestureDetectorTypeRegistry(void)
2136 TestApplication application;
2138 Actor actor = Actor::New();
2139 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2140 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2141 application.GetScene().Add(actor);
2145 type = TypeRegistry::Get().GetTypeInfo("PanGestureDetector");
2146 DALI_TEST_CHECK(type);
2147 BaseHandle handle = type.CreateInstance();
2148 DALI_TEST_CHECK(handle);
2149 PanGestureDetector detector = PanGestureDetector::DownCast(handle);
2150 DALI_TEST_CHECK(detector);
2152 // Attach actor to detector
2154 GestureReceivedFunctor functor(data);
2155 detector.Attach(actor);
2157 // Connect to signal through type
2158 handle.ConnectSignal(&application, "panDetected", functor);
2160 // Render and notify
2161 application.SendNotification();
2162 application.Render();
2165 TestGenerateMiniPan(application);
2166 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2170 int UtcDaliPinchGestureDetectorTypeRegistry(void)
2172 TestApplication application;
2174 Actor actor = Actor::New();
2175 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2176 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2177 application.GetScene().Add(actor);
2181 type = TypeRegistry::Get().GetTypeInfo("PinchGestureDetector");
2182 DALI_TEST_CHECK(type);
2183 BaseHandle handle = type.CreateInstance();
2184 DALI_TEST_CHECK(handle);
2185 PinchGestureDetector detector = PinchGestureDetector::DownCast(handle);
2186 DALI_TEST_CHECK(detector);
2188 // Attach actor to detector
2190 GestureReceivedFunctor functor(data);
2191 detector.Attach(actor);
2193 // Connect to signal through type
2194 handle.ConnectSignal(&application, "pinchDetected", functor);
2196 // Render and notify
2197 application.SendNotification();
2198 application.Render();
2201 TestGeneratePinch(application);
2203 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2207 int UtcDaliRotationGestureDetectorTypeRegistry(void)
2209 TestApplication application;
2211 Actor actor = Actor::New();
2212 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2213 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2214 application.GetScene().Add(actor);
2218 type = TypeRegistry::Get().GetTypeInfo("RotationGestureDetector");
2219 DALI_TEST_CHECK(type);
2220 BaseHandle handle = type.CreateInstance();
2221 DALI_TEST_CHECK(handle);
2222 RotationGestureDetector detector = RotationGestureDetector::DownCast(handle);
2223 DALI_TEST_CHECK(detector);
2225 // Attach actor to detector
2227 GestureReceivedFunctor functor(data);
2228 detector.Attach(actor);
2230 // Connect to signal through type
2231 handle.ConnectSignal(&application, "rotationDetected", functor);
2233 // Render and notify
2234 application.SendNotification();
2235 application.Render();
2238 TestGenerateRotation(application);
2240 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2244 int UtcDaliTapGestureDetectorTypeRegistry(void)
2246 TestApplication application;
2248 Actor actor = Actor::New();
2249 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2250 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2251 application.GetScene().Add(actor);
2255 type = TypeRegistry::Get().GetTypeInfo("TapGestureDetector");
2256 DALI_TEST_CHECK(type);
2257 BaseHandle handle = type.CreateInstance();
2258 DALI_TEST_CHECK(handle);
2259 TapGestureDetector detector = TapGestureDetector::DownCast(handle);
2260 DALI_TEST_CHECK(detector);
2262 // Attach actor to detector
2264 GestureReceivedFunctor functor(data);
2265 detector.Attach(actor);
2267 // Connect to signal through type
2268 handle.ConnectSignal(&application, "tapDetected", functor);
2270 // Render and notify
2271 application.SendNotification();
2272 application.Render();
2275 TestGenerateTap(application, 50.0, 10.0, 100);
2277 DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2281 int UtcDaliTypeRegistryNamedType(void)
2283 TestApplication application;
2284 TypeRegistry typeRegistry = TypeRegistry::Get();
2286 // Create a normal actor
2287 BaseHandle actorHandle = typeRegistry.GetTypeInfo("Actor").CreateInstance();
2288 DALI_TEST_CHECK(actorHandle);
2289 Actor actor(Actor::DownCast(actorHandle));
2290 DALI_TEST_CHECK(actor);
2291 unsigned int actorPropertyCount(actor.GetPropertyCount());
2293 // Create Named Actor Type
2294 BaseHandle namedHandle = typeRegistry.GetTypeInfo("MyNamedActor").CreateInstance();
2295 DALI_TEST_CHECK(namedHandle);
2296 Actor namedActor(Actor::DownCast(namedHandle));
2297 DALI_TEST_CHECK(namedActor);
2298 unsigned int namedActorPropertyCount(namedActor.GetPropertyCount());
2300 DALI_TEST_CHECK(namedActorPropertyCount > actorPropertyCount);
2304 int UtcDaliTypeInfoGetActionNameP(void)
2306 TestApplication application;
2307 TypeRegistry typeRegistry = TypeRegistry::Get();
2309 TypeInfo typeInfo = typeRegistry.GetTypeInfo("Actor");
2310 DALI_TEST_CHECK(typeInfo);
2312 DALI_TEST_CHECK(0 != typeInfo.GetActionCount());
2314 std::string name = typeInfo.GetActionName(0);
2316 DALI_TEST_EQUALS(name, "show", TEST_LOCATION);
2318 TypeInfo typeInfo2 = typeRegistry.GetTypeInfo("MyTestCustomActor");
2320 // search for show action in base class, given a derived class
2321 bool foundChildAction = false;
2322 for(std::size_t i = 0; i < typeInfo2.GetActionCount(); i++)
2324 std::string name = typeInfo2.GetActionName(i);
2327 foundChildAction = true;
2331 DALI_TEST_EQUALS(foundChildAction, true, TEST_LOCATION);
2336 int UtcDaliTypeInfoGetActionNameN(void)
2338 TestApplication application;
2339 TypeRegistry typeRegistry = TypeRegistry::Get();
2341 TypeInfo typeInfo = typeRegistry.GetTypeInfo("Actor");
2342 DALI_TEST_CHECK(typeInfo);
2344 DALI_TEST_CHECK(0 != typeInfo.GetActionCount());
2346 std::string name = typeInfo.GetActionName(std::numeric_limits<size_t>::max());
2348 DALI_TEST_EQUALS(0u, name.size(), TEST_LOCATION);
2353 int UtcDaliTypeInfoGetSignalNameP(void)
2355 TestApplication application;
2356 TypeRegistry typeRegistry = TypeRegistry::Get();
2358 TypeInfo typeInfo = typeRegistry.GetTypeInfo("Actor");
2359 DALI_TEST_CHECK(typeInfo);
2361 DALI_TEST_CHECK(0 != typeInfo.GetSignalCount());
2363 std::string name = typeInfo.GetSignalName(0);
2365 DALI_TEST_EQUALS(name, "hovered", TEST_LOCATION);
2367 TypeInfo typeInfo2 = typeRegistry.GetTypeInfo("MyTestCustomActor");
2369 // search for signal in base class, given a derived class
2370 bool foundSignal = false;
2371 for(std::size_t i = 0; i < typeInfo2.GetSignalCount(); i++)
2373 std::string name = typeInfo2.GetSignalName(i);
2374 if(name == "hovered")
2380 DALI_TEST_EQUALS(foundSignal, true, TEST_LOCATION);
2385 int UtcDaliTypeInfoGetSignalNameN(void)
2387 TestApplication application;
2388 TypeRegistry typeRegistry = TypeRegistry::Get();
2390 TypeInfo typeInfo = typeRegistry.GetTypeInfo("Actor");
2391 DALI_TEST_CHECK(typeInfo);
2393 DALI_TEST_CHECK(0 != typeInfo.GetSignalCount());
2395 std::string name = typeInfo.GetSignalName(std::numeric_limits<size_t>::max());
2397 DALI_TEST_EQUALS(0u, name.size(), TEST_LOCATION);
2402 int UtcDaliTypeInfoGetCreatorP(void)
2404 TestApplication application;
2405 TypeRegistry typeRegistry = TypeRegistry::Get();
2407 TypeInfo typeInfo = typeRegistry.GetTypeInfo("Actor");
2408 DALI_TEST_CHECK(typeInfo);
2410 TypeInfo::CreateFunction createFn = typeInfo.GetCreator();
2411 DALI_TEST_EQUALS(createFn != NULL, true, TEST_LOCATION);
2415 BaseHandle handle = createFn();
2416 DALI_TEST_EQUALS((bool)handle, true, TEST_LOCATION);
2422 int UtcDaliTypeInfoGetCreatorN(void)
2424 TestApplication application;
2425 TypeRegistry typeRegistry = TypeRegistry::Get();
2427 TypeInfo typeInfo = typeRegistry.GetTypeInfo("MyTestCustomActor3");
2428 DALI_TEST_CHECK(typeInfo);
2430 TypeInfo::CreateFunction createFn = typeInfo.GetCreator();
2431 DALI_TEST_EQUALS(createFn == NULL, true, TEST_LOCATION);
2436 int UtcDaliTypeInfoGetPropertyCountP1(void)
2438 TestApplication application;
2439 TypeRegistry typeRegistry = TypeRegistry::Get();
2441 TypeInfo typeInfo = typeRegistry.GetTypeInfo("Actor");
2442 DALI_TEST_CHECK(typeInfo);
2443 size_t actorPropertyCount = typeInfo.GetPropertyCount();
2445 DALI_TEST_EQUALS(actorPropertyCount, Actor::New().GetPropertyCount(), TEST_LOCATION); // No event only props
2449 int UtcDaliTypeInfoGetPropertyCountP2(void)
2451 TestApplication application;
2452 TypeRegistry typeRegistry = TypeRegistry::Get();
2454 TypeInfo typeInfo = typeRegistry.GetTypeInfo("MyTestCustomActor2");
2455 DALI_TEST_CHECK(typeInfo);
2456 size_t propertyCount = typeInfo.GetPropertyCount();
2457 Property::IndexContainer indices;
2458 typeInfo.GetPropertyIndices(indices);
2460 DALI_TEST_EQUALS(propertyCount > 0 && propertyCount <= indices.Size(), true, TEST_LOCATION);
2461 DALI_TEST_EQUALS(propertyCount, Actor::New().GetPropertyCount() + 2, TEST_LOCATION);
2466 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGet01(void)
2468 TestApplication application;
2469 TypeRegistry typeRegistry = TypeRegistry::Get();
2471 tet_infoline("Register a type registered animatable property and ensure set/get behaviour works synchronously");
2473 // Register animatable property
2474 const int animatablePropertyIndex(ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX);
2475 AnimatablePropertyRegistration animatableProperty(customType1, "animatableProp1", animatablePropertyIndex, Property::FLOAT);
2477 // Check property count before property registration
2478 TypeInfo typeInfo = typeRegistry.GetTypeInfo(typeid(MyTestCustomActor));
2479 DALI_TEST_CHECK(typeInfo);
2480 BaseHandle handle = typeInfo.CreateInstance();
2481 DALI_TEST_CHECK(handle);
2482 Actor customActor = Actor::DownCast(handle);
2483 DALI_TEST_CHECK(customActor);
2484 application.GetScene().Add(customActor);
2486 tet_infoline("Set the value and ensure it changes straight away");
2487 DALI_TEST_EQUALS(customActor.GetProperty<float>(animatablePropertyIndex), 0.0f, TEST_LOCATION);
2488 customActor.SetProperty(animatablePropertyIndex, 25.0f);
2489 DALI_TEST_EQUALS(customActor.GetProperty<float>(animatablePropertyIndex), 25.0f, TEST_LOCATION);
2491 tet_infoline("Check latest scene-graph value is unchanged");
2492 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(animatablePropertyIndex), 0.0f, TEST_LOCATION);
2494 // Render and notify
2495 application.SendNotification();
2496 application.Render();
2498 tet_infoline("Check values after rendering and both retrieval methods should return the latest");
2500 DALI_TEST_EQUALS(customActor.GetProperty<float>(animatablePropertyIndex), 25.0f, TEST_LOCATION);
2501 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(animatablePropertyIndex), 25.0f, TEST_LOCATION);
2506 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGetWithComponentsVector2(void)
2508 TestApplication application;
2509 TypeRegistry typeRegistry = TypeRegistry::Get();
2511 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");
2513 // Register the animatable propeties
2514 const int basePropertyIndex(ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX);
2515 const int componentZeroPropertyIndex(basePropertyIndex + 1);
2516 const int componentOnePropertyIndex(componentZeroPropertyIndex + 1);
2517 AnimatablePropertyRegistration baseAnimatableProperty(customType1, "baseProp", basePropertyIndex, Vector2(13.0f, 24.0f));
2518 AnimatablePropertyComponentRegistration componentZeroAnimatableProperty(customType1, "componentZeroProp", componentZeroPropertyIndex, basePropertyIndex, 0);
2519 AnimatablePropertyComponentRegistration componentOneAnimatableProperty(customType1, "componentOneProp", componentOnePropertyIndex, basePropertyIndex, 1);
2521 // Check property count before property registration
2522 TypeInfo typeInfo = typeRegistry.GetTypeInfo(typeid(MyTestCustomActor));
2523 DALI_TEST_CHECK(typeInfo);
2524 BaseHandle handle = typeInfo.CreateInstance();
2525 DALI_TEST_CHECK(handle);
2526 Actor customActor = Actor::DownCast(handle);
2527 DALI_TEST_CHECK(customActor);
2528 application.GetScene().Add(customActor);
2530 tet_infoline("Get the component values, they should be the default value of the base-property");
2531 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentZeroPropertyIndex), 13.0f, TEST_LOCATION);
2532 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentOnePropertyIndex), 24.0f, TEST_LOCATION);
2533 DALI_TEST_EQUALS(customActor.GetProperty<Vector2>(basePropertyIndex), Vector2(13.0f, 24.0f), TEST_LOCATION);
2535 tet_infoline("Set a component value and ensure it changes for the base property as well");
2536 customActor.SetProperty(componentZeroPropertyIndex, 125.0f);
2537 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentZeroPropertyIndex), 125.0f, TEST_LOCATION);
2538 DALI_TEST_EQUALS(customActor.GetProperty<Vector2>(basePropertyIndex), Vector2(125.0f, 24.0f), TEST_LOCATION);
2540 customActor.SetProperty(componentOnePropertyIndex, 225.0f);
2541 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentOnePropertyIndex), 225.0f, TEST_LOCATION);
2542 DALI_TEST_EQUALS(customActor.GetProperty<Vector2>(basePropertyIndex), Vector2(125.0f, 225.0f), TEST_LOCATION);
2544 tet_infoline("Check latest scene-graph value is unchanged");
2545 DALI_TEST_EQUALS(customActor.GetCurrentProperty<Vector2>(basePropertyIndex), Vector2(13.0f, 24.0f), TEST_LOCATION);
2546 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentZeroPropertyIndex), 13.0f, TEST_LOCATION);
2547 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentOnePropertyIndex), 24.0f, TEST_LOCATION);
2549 // Render and notify
2550 application.SendNotification();
2551 application.Render();
2553 tet_infoline("Check values after rendering and both retrieval methods should return the latest");
2554 DALI_TEST_EQUALS(customActor.GetProperty<Vector2>(basePropertyIndex), Vector2(125.0f, 225.0f), TEST_LOCATION);
2555 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentZeroPropertyIndex), 125.0f, TEST_LOCATION);
2556 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentOnePropertyIndex), 225.0f, TEST_LOCATION);
2558 DALI_TEST_EQUALS(customActor.GetCurrentProperty<Vector2>(basePropertyIndex), Vector2(125.0f, 225.0f), TEST_LOCATION);
2559 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentZeroPropertyIndex), 125.0f, TEST_LOCATION);
2560 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentOnePropertyIndex), 225.0f, TEST_LOCATION);
2562 tet_infoline("Set the base property value and ensure the component values reflect the change");
2563 customActor.SetProperty(basePropertyIndex, Vector2(1.0f, 2.0f));
2564 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentZeroPropertyIndex), 1.0f, TEST_LOCATION);
2565 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentOnePropertyIndex), 2.0f, TEST_LOCATION);
2566 DALI_TEST_EQUALS(customActor.GetProperty<Vector2>(basePropertyIndex), Vector2(1.0f, 2.0f), TEST_LOCATION);
2571 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGetWithComponentsVector3(void)
2573 TestApplication application;
2574 TypeRegistry typeRegistry = TypeRegistry::Get();
2576 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");
2578 // Register the animatable propeties
2579 const int basePropertyIndex(ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX);
2580 const int componentZeroPropertyIndex(basePropertyIndex + 1);
2581 const int componentOnePropertyIndex(componentZeroPropertyIndex + 1);
2582 const int componentTwoPropertyIndex(componentOnePropertyIndex + 1);
2583 AnimatablePropertyRegistration baseAnimatableProperty(customType1, "baseProp", basePropertyIndex, Vector3(13.0f, 24.0f, 35.0));
2584 AnimatablePropertyComponentRegistration componentZeroAnimatableProperty(customType1, "componentZeroProp", componentZeroPropertyIndex, basePropertyIndex, 0);
2585 AnimatablePropertyComponentRegistration componentOneAnimatableProperty(customType1, "componentOneProp", componentOnePropertyIndex, basePropertyIndex, 1);
2586 AnimatablePropertyComponentRegistration componentTwoAnimatableProperty(customType1, "componentTwoProp", componentTwoPropertyIndex, basePropertyIndex, 2);
2588 // Check property count before property registration
2589 TypeInfo typeInfo = typeRegistry.GetTypeInfo(typeid(MyTestCustomActor));
2590 DALI_TEST_CHECK(typeInfo);
2591 BaseHandle handle = typeInfo.CreateInstance();
2592 DALI_TEST_CHECK(handle);
2593 Actor customActor = Actor::DownCast(handle);
2594 DALI_TEST_CHECK(customActor);
2595 application.GetScene().Add(customActor);
2597 tet_infoline("Get the component values, they should be the default value of the base-property");
2598 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentZeroPropertyIndex), 13.0f, TEST_LOCATION);
2599 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentOnePropertyIndex), 24.0f, TEST_LOCATION);
2600 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentTwoPropertyIndex), 35.0f, TEST_LOCATION);
2601 DALI_TEST_EQUALS(customActor.GetProperty<Vector3>(basePropertyIndex), Vector3(13.0f, 24.0f, 35.0f), TEST_LOCATION);
2603 tet_infoline("Set a component value and ensure it changes for the base property as well");
2604 customActor.SetProperty(componentZeroPropertyIndex, 125.0f);
2605 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentZeroPropertyIndex), 125.0f, TEST_LOCATION);
2606 DALI_TEST_EQUALS(customActor.GetProperty<Vector3>(basePropertyIndex), Vector3(125.0f, 24.0f, 35.0f), TEST_LOCATION);
2608 customActor.SetProperty(componentOnePropertyIndex, 225.0f);
2609 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentOnePropertyIndex), 225.0f, TEST_LOCATION);
2610 DALI_TEST_EQUALS(customActor.GetProperty<Vector3>(basePropertyIndex), Vector3(125.0f, 225.0f, 35.0f), TEST_LOCATION);
2612 customActor.SetProperty(componentTwoPropertyIndex, 325.0f);
2613 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentTwoPropertyIndex), 325.0f, TEST_LOCATION);
2614 DALI_TEST_EQUALS(customActor.GetProperty<Vector3>(basePropertyIndex), Vector3(125.0f, 225.0f, 325.0f), TEST_LOCATION);
2616 tet_infoline("Check latest scene-graph value is unchanged");
2617 DALI_TEST_EQUALS(customActor.GetCurrentProperty<Vector3>(basePropertyIndex), Vector3(13.0f, 24.0f, 35.0f), TEST_LOCATION);
2618 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentZeroPropertyIndex), 13.0f, TEST_LOCATION);
2619 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentOnePropertyIndex), 24.0f, TEST_LOCATION);
2620 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentTwoPropertyIndex), 35.0f, TEST_LOCATION);
2622 // Render and notify
2623 application.SendNotification();
2624 application.Render();
2626 tet_infoline("Check values after rendering and both retrieval methods should return the latest");
2627 DALI_TEST_EQUALS(customActor.GetProperty<Vector3>(basePropertyIndex), Vector3(125.0f, 225.0f, 325.0f), TEST_LOCATION);
2628 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentZeroPropertyIndex), 125.0f, TEST_LOCATION);
2629 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentOnePropertyIndex), 225.0f, TEST_LOCATION);
2630 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentTwoPropertyIndex), 325.0f, TEST_LOCATION);
2632 DALI_TEST_EQUALS(customActor.GetCurrentProperty<Vector3>(basePropertyIndex), Vector3(125.0f, 225.0f, 325.0f), TEST_LOCATION);
2633 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentZeroPropertyIndex), 125.0f, TEST_LOCATION);
2634 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentOnePropertyIndex), 225.0f, TEST_LOCATION);
2635 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentTwoPropertyIndex), 325.0f, TEST_LOCATION);
2637 tet_infoline("Set the base property value and ensure the component values reflect the change");
2638 customActor.SetProperty(basePropertyIndex, Vector3(1.0f, 2.0f, 3.0f));
2639 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentZeroPropertyIndex), 1.0f, TEST_LOCATION);
2640 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentOnePropertyIndex), 2.0f, TEST_LOCATION);
2641 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentTwoPropertyIndex), 3.0f, TEST_LOCATION);
2642 DALI_TEST_EQUALS(customActor.GetProperty<Vector3>(basePropertyIndex), Vector3(1.0f, 2.0f, 3.0f), TEST_LOCATION);
2647 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGetWithComponentsVector4(void)
2649 TestApplication application;
2650 TypeRegistry typeRegistry = TypeRegistry::Get();
2652 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");
2654 // Register the animatable propeties
2655 const int basePropertyIndex(ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX);
2656 const int componentZeroPropertyIndex(basePropertyIndex + 1);
2657 const int componentOnePropertyIndex(componentZeroPropertyIndex + 1);
2658 const int componentTwoPropertyIndex(componentOnePropertyIndex + 1);
2659 const int componentThreePropertyIndex(componentTwoPropertyIndex + 1);
2660 AnimatablePropertyRegistration baseAnimatableProperty(customType1, "baseProp", basePropertyIndex, Vector4(13.0f, 24.0f, 35.0, 47.0f));
2661 AnimatablePropertyComponentRegistration componentZeroAnimatableProperty(customType1, "componentZeroProp", componentZeroPropertyIndex, basePropertyIndex, 0);
2662 AnimatablePropertyComponentRegistration componentOneAnimatableProperty(customType1, "componentOneProp", componentOnePropertyIndex, basePropertyIndex, 1);
2663 AnimatablePropertyComponentRegistration componentTwoAnimatableProperty(customType1, "componentTwoProp", componentTwoPropertyIndex, basePropertyIndex, 2);
2664 AnimatablePropertyComponentRegistration componentThreeAnimatableProperty(customType1, "componentThreeProp", componentThreePropertyIndex, basePropertyIndex, 3);
2666 // Check property count before property registration
2667 TypeInfo typeInfo = typeRegistry.GetTypeInfo(typeid(MyTestCustomActor));
2668 DALI_TEST_CHECK(typeInfo);
2669 BaseHandle handle = typeInfo.CreateInstance();
2670 DALI_TEST_CHECK(handle);
2671 Actor customActor = Actor::DownCast(handle);
2672 DALI_TEST_CHECK(customActor);
2673 application.GetScene().Add(customActor);
2675 tet_infoline("Get the component values, they should be the default value of the base-property");
2676 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentZeroPropertyIndex), 13.0f, TEST_LOCATION);
2677 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentOnePropertyIndex), 24.0f, TEST_LOCATION);
2678 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentTwoPropertyIndex), 35.0f, TEST_LOCATION);
2679 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentThreePropertyIndex), 47.0f, TEST_LOCATION);
2680 DALI_TEST_EQUALS(customActor.GetProperty<Vector4>(basePropertyIndex), Vector4(13.0f, 24.0f, 35.0f, 47.0f), TEST_LOCATION);
2682 tet_infoline("Set a component value and ensure it changes for the base property as well");
2683 customActor.SetProperty(componentZeroPropertyIndex, 125.0f);
2684 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentZeroPropertyIndex), 125.0f, TEST_LOCATION);
2685 DALI_TEST_EQUALS(customActor.GetProperty<Vector4>(basePropertyIndex), Vector4(125.0f, 24.0f, 35.0f, 47.0f), TEST_LOCATION);
2687 customActor.SetProperty(componentOnePropertyIndex, 225.0f);
2688 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentOnePropertyIndex), 225.0f, TEST_LOCATION);
2689 DALI_TEST_EQUALS(customActor.GetProperty<Vector4>(basePropertyIndex), Vector4(125.0f, 225.0f, 35.0f, 47.0f), TEST_LOCATION);
2691 customActor.SetProperty(componentTwoPropertyIndex, 325.0f);
2692 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentTwoPropertyIndex), 325.0f, TEST_LOCATION);
2693 DALI_TEST_EQUALS(customActor.GetProperty<Vector4>(basePropertyIndex), Vector4(125.0f, 225.0f, 325.0f, 47.0f), TEST_LOCATION);
2695 customActor.SetProperty(componentThreePropertyIndex, 435.0f);
2696 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentThreePropertyIndex), 435.0f, TEST_LOCATION);
2697 DALI_TEST_EQUALS(customActor.GetProperty<Vector4>(basePropertyIndex), Vector4(125.0f, 225.0f, 325.0f, 435.0f), TEST_LOCATION);
2699 tet_infoline("Check latest scene-graph value is unchanged");
2700 DALI_TEST_EQUALS(customActor.GetCurrentProperty<Vector4>(basePropertyIndex), Vector4(13.0f, 24.0f, 35.0f, 47.0f), TEST_LOCATION);
2701 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentZeroPropertyIndex), 13.0f, TEST_LOCATION);
2702 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentOnePropertyIndex), 24.0f, TEST_LOCATION);
2703 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentTwoPropertyIndex), 35.0f, TEST_LOCATION);
2704 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentThreePropertyIndex), 47.0f, TEST_LOCATION);
2706 // Render and notify
2707 application.SendNotification();
2708 application.Render();
2710 tet_infoline("Check values after rendering and both retrieval methods should return the latest");
2711 DALI_TEST_EQUALS(customActor.GetProperty<Vector4>(basePropertyIndex), Vector4(125.0f, 225.0f, 325.0f, 435.0f), TEST_LOCATION);
2712 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentZeroPropertyIndex), 125.0f, TEST_LOCATION);
2713 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentOnePropertyIndex), 225.0f, TEST_LOCATION);
2714 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentTwoPropertyIndex), 325.0f, TEST_LOCATION);
2715 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentThreePropertyIndex), 435.0f, TEST_LOCATION);
2717 DALI_TEST_EQUALS(customActor.GetCurrentProperty<Vector4>(basePropertyIndex), Vector4(125.0f, 225.0f, 325.0f, 435.0f), TEST_LOCATION);
2718 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentZeroPropertyIndex), 125.0f, TEST_LOCATION);
2719 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentOnePropertyIndex), 225.0f, TEST_LOCATION);
2720 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentTwoPropertyIndex), 325.0f, TEST_LOCATION);
2721 DALI_TEST_EQUALS(customActor.GetCurrentProperty<float>(componentThreePropertyIndex), 435.0f, TEST_LOCATION);
2723 tet_infoline("Set the base property value and ensure the component values reflect the change");
2724 customActor.SetProperty(basePropertyIndex, Vector4(1.0f, 2.0f, 3.0f, 4.0f));
2725 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentZeroPropertyIndex), 1.0f, TEST_LOCATION);
2726 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentOnePropertyIndex), 2.0f, TEST_LOCATION);
2727 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentTwoPropertyIndex), 3.0f, TEST_LOCATION);
2728 DALI_TEST_EQUALS(customActor.GetProperty<float>(componentThreePropertyIndex), 4.0f, TEST_LOCATION);
2729 DALI_TEST_EQUALS(customActor.GetProperty<Vector4>(basePropertyIndex), Vector4(1.0f, 2.0f, 3.0f, 4.0f), TEST_LOCATION);
2734 int UtcDaliTypeInfoRegisterChildProperties01(void)
2736 TestApplication application;
2737 TypeRegistry typeRegistry = TypeRegistry::Get();
2739 tet_infoline("Register child properties on a type via name");
2741 auto customActorTypeInfo = typeRegistry.GetTypeInfo(typeid(CustomActor));
2742 auto myCustomTypeInfo = typeRegistry.GetTypeInfo(typeid(MyTestCustomActor));
2743 DALI_TEST_CHECK(customActorTypeInfo);
2744 DALI_TEST_CHECK(myCustomTypeInfo);
2746 const Property::Index WIDTH_SPECIFICATION(CHILD_PROPERTY_REGISTRATION_START_INDEX);
2747 const Property::Index HEIGHT_SPECIFICATION(CHILD_PROPERTY_REGISTRATION_START_INDEX + 1);
2748 const Property::Index MARGIN_SPECIFICATION(CHILD_PROPERTY_REGISTRATION_START_INDEX + 100);
2750 ChildPropertyRegistration(customActorTypeInfo.GetName(), "widthSpecification", WIDTH_SPECIFICATION, Property::INTEGER);
2751 ChildPropertyRegistration(customActorTypeInfo.GetName(), "heightSpecification", HEIGHT_SPECIFICATION, Property::INTEGER);
2752 ChildPropertyRegistration(myCustomTypeInfo.GetName(), "marginSpecification", MARGIN_SPECIFICATION, Property::EXTENTS);
2754 auto customActor = MyTestCustomActor::New();
2755 application.GetScene().Add(customActor);
2756 auto child = Actor::New();
2757 customActor.Add(child);
2759 child.SetProperty(WIDTH_SPECIFICATION, 33);
2761 auto value = child.GetProperty(WIDTH_SPECIFICATION);
2762 DALI_TEST_EQUALS(value, Property::Value(33), TEST_LOCATION);
2764 child.SetProperty(HEIGHT_SPECIFICATION, 44);
2765 value = child.GetProperty(HEIGHT_SPECIFICATION);
2766 DALI_TEST_EQUALS(value, Property::Value(44), TEST_LOCATION);
2768 child.SetProperty(MARGIN_SPECIFICATION, Extents(10, 10, 10, 10));
2769 value = child.GetProperty(MARGIN_SPECIFICATION);
2770 DALI_TEST_EQUALS(value, Property::Value(Extents(10, 10, 10, 10)), TEST_LOCATION);
2775 int UtcDaliTypeInfoRegisterChildProperties02(void)
2777 TestApplication application;
2778 TypeRegistry typeRegistry = TypeRegistry::Get();
2780 tet_infoline("Register child properties on a type via name");
2782 auto customActorTypeInfo = typeRegistry.GetTypeInfo(typeid(CustomActor));
2783 auto myCustomTypeInfo = typeRegistry.GetTypeInfo(typeid(MyTestCustomActor));
2784 DALI_TEST_CHECK(customActorTypeInfo);
2785 DALI_TEST_CHECK(myCustomTypeInfo);
2787 const Property::Index WIDTH_SPECIFICATION(CHILD_PROPERTY_REGISTRATION_START_INDEX);
2788 const Property::Index HEIGHT_SPECIFICATION(CHILD_PROPERTY_REGISTRATION_START_INDEX + 1);
2789 const Property::Index MARGIN_SPECIFICATION(CHILD_PROPERTY_REGISTRATION_START_INDEX + 100);
2791 ChildPropertyRegistration(customActorTypeInfo.GetName(), "widthSpecification", WIDTH_SPECIFICATION, Property::INTEGER);
2792 ChildPropertyRegistration(customActorTypeInfo.GetName(), "heightSpecification", HEIGHT_SPECIFICATION, Property::INTEGER);
2793 ChildPropertyRegistration(myCustomTypeInfo.GetName(), "marginSpecification", MARGIN_SPECIFICATION, Property::EXTENTS);
2795 auto index = customActorTypeInfo.GetChildPropertyIndex("widthSpecification");
2796 DALI_TEST_EQUALS(index, WIDTH_SPECIFICATION, TEST_LOCATION);
2798 index = customActorTypeInfo.GetChildPropertyIndex("heightSpecification");
2799 DALI_TEST_EQUALS(index, HEIGHT_SPECIFICATION, TEST_LOCATION);
2801 index = customActorTypeInfo.GetChildPropertyIndex("marginSpecification");
2802 DALI_TEST_EQUALS(index, Property::INVALID_INDEX, TEST_LOCATION);
2804 index = myCustomTypeInfo.GetChildPropertyIndex("marginSpecification");
2805 DALI_TEST_EQUALS(index, MARGIN_SPECIFICATION, TEST_LOCATION);
2807 auto name = customActorTypeInfo.GetChildPropertyName(WIDTH_SPECIFICATION);
2808 DALI_TEST_EQUALS(name, "widthSpecification", TEST_LOCATION);
2810 name = customActorTypeInfo.GetChildPropertyName(HEIGHT_SPECIFICATION);
2811 DALI_TEST_EQUALS(name, "heightSpecification", TEST_LOCATION);
2813 name = myCustomTypeInfo.GetChildPropertyName(MARGIN_SPECIFICATION);
2814 DALI_TEST_EQUALS(name, "marginSpecification", TEST_LOCATION);
2816 auto type = customActorTypeInfo.GetChildPropertyType(WIDTH_SPECIFICATION);
2817 DALI_TEST_EQUALS(type, Property::INTEGER, TEST_LOCATION);
2819 type = customActorTypeInfo.GetChildPropertyType(HEIGHT_SPECIFICATION);
2820 DALI_TEST_EQUALS(type, Property::INTEGER, TEST_LOCATION);
2822 type = myCustomTypeInfo.GetChildPropertyType(MARGIN_SPECIFICATION);
2823 DALI_TEST_EQUALS(type, Property::EXTENTS, TEST_LOCATION);
2828 int UtcDaliTypeInfoRegisterChildProperties03(void)
2830 TestApplication application;
2831 TypeRegistry typeRegistry = TypeRegistry::Get();
2833 tet_infoline("Check registered child properties can be retrieved");
2835 auto customActorTypeInfo = typeRegistry.GetTypeInfo(typeid(CustomActor));
2836 auto myCustomTypeInfo = typeRegistry.GetTypeInfo(typeid(MyTestCustomActor));
2837 DALI_TEST_CHECK(customActorTypeInfo);
2838 DALI_TEST_CHECK(myCustomTypeInfo);
2840 const Property::Index WIDTH_SPECIFICATION(CHILD_PROPERTY_REGISTRATION_START_INDEX);
2841 const Property::Index HEIGHT_SPECIFICATION(CHILD_PROPERTY_REGISTRATION_START_INDEX + 1);
2842 const Property::Index MARGIN_SPECIFICATION(CHILD_PROPERTY_REGISTRATION_START_INDEX + 100);
2844 ChildPropertyRegistration(customActorTypeInfo.GetName(), "widthSpecification", WIDTH_SPECIFICATION, Property::INTEGER);
2845 ChildPropertyRegistration(customActorTypeInfo.GetName(), "heightSpecification", HEIGHT_SPECIFICATION, Property::INTEGER);
2846 ChildPropertyRegistration(myCustomTypeInfo.GetName(), "marginSpecification", MARGIN_SPECIFICATION, Property::EXTENTS);
2848 Property::IndexContainer indices;
2849 myCustomTypeInfo.GetChildPropertyIndices(indices);
2851 auto result = std::find(indices.Begin(), indices.End(), WIDTH_SPECIFICATION);
2852 DALI_TEST_EQUALS(result != indices.End(), true, TEST_LOCATION);
2854 result = std::find(indices.Begin(), indices.End(), HEIGHT_SPECIFICATION);
2855 DALI_TEST_EQUALS(result != indices.End(), true, TEST_LOCATION);
2857 result = std::find(indices.Begin(), indices.End(), MARGIN_SPECIFICATION);
2858 DALI_TEST_EQUALS(result != indices.End(), true, TEST_LOCATION);
2863 int UtcDaliTypeInfoGetActionNameNegative(void)
2865 TestApplication application;
2866 Dali::TypeInfo instance;
2869 unsigned long arg1(0u);
2870 instance.GetActionName(arg1);
2871 DALI_TEST_CHECK(false); // Should not get here
2875 DALI_TEST_CHECK(true); // We expect an assert
2880 int UtcDaliTypeInfoGetSignalNameNegative(void)
2882 TestApplication application;
2883 Dali::TypeInfo instance;
2886 unsigned long arg1(0u);
2887 instance.GetSignalName(arg1);
2888 DALI_TEST_CHECK(false); // Should not get here
2892 DALI_TEST_CHECK(true); // We expect an assert
2897 int UtcDaliTypeInfoGetCreatorNegative(void)
2899 TestApplication application;
2900 Dali::TypeInfo instance;
2903 instance.GetCreator();
2904 DALI_TEST_CHECK(false); // Should not get here
2908 DALI_TEST_CHECK(true); // We expect an assert
2913 int UtcDaliTypeInfoGetBaseNameNegative(void)
2915 TestApplication application;
2916 Dali::TypeInfo instance;
2919 instance.GetBaseName();
2920 DALI_TEST_CHECK(false); // Should not get here
2924 DALI_TEST_CHECK(true); // We expect an assert
2929 int UtcDaliTypeInfoCreateInstanceNegative(void)
2931 TestApplication application;
2932 Dali::TypeInfo instance;
2935 instance.CreateInstance();
2936 DALI_TEST_CHECK(false); // Should not get here
2940 DALI_TEST_CHECK(true); // We expect an assert
2945 int UtcDaliTypeInfoGetActionCountNegative(void)
2947 TestApplication application;
2948 Dali::TypeInfo instance;
2951 instance.GetActionCount();
2952 DALI_TEST_CHECK(false); // Should not get here
2956 DALI_TEST_CHECK(true); // We expect an assert
2961 int UtcDaliTypeInfoGetSignalCountNegative(void)
2963 TestApplication application;
2964 Dali::TypeInfo instance;
2967 instance.GetSignalCount();
2968 DALI_TEST_CHECK(false); // Should not get here
2972 DALI_TEST_CHECK(true); // We expect an assert
2977 int UtcDaliTypeInfoGetPropertyNameNegative(void)
2979 TestApplication application;
2980 Dali::TypeInfo instance;
2984 instance.GetPropertyName(arg1);
2985 DALI_TEST_CHECK(false); // Should not get here
2989 DALI_TEST_CHECK(true); // We expect an assert
2994 int UtcDaliTypeInfoGetPropertyCountNegative(void)
2996 TestApplication application;
2997 Dali::TypeInfo instance;
3000 instance.GetPropertyCount();
3001 DALI_TEST_CHECK(false); // Should not get here
3005 DALI_TEST_CHECK(true); // We expect an assert
3010 int UtcDaliTypeInfoGetPropertyIndicesNegative(void)
3012 TestApplication application;
3013 Dali::TypeInfo instance;
3016 Dali::Vector<int> arg1;
3017 instance.GetPropertyIndices(arg1);
3018 DALI_TEST_CHECK(false); // Should not get here
3022 DALI_TEST_CHECK(true); // We expect an assert
3027 int UtcDaliTypeInfoGetChildPropertyNameNegative(void)
3029 TestApplication application;
3030 Dali::TypeInfo instance;
3034 instance.GetChildPropertyName(arg1);
3035 DALI_TEST_CHECK(false); // Should not get here
3039 DALI_TEST_CHECK(true); // We expect an assert
3044 int UtcDaliTypeInfoGetChildPropertyTypeNegative(void)
3046 TestApplication application;
3047 Dali::TypeInfo instance;
3051 instance.GetChildPropertyType(arg1);
3052 DALI_TEST_CHECK(false); // Should not get here
3056 DALI_TEST_CHECK(true); // We expect an assert
3061 int UtcDaliTypeInfoGetChildPropertyIndexNegative(void)
3063 TestApplication application;
3064 Dali::TypeInfo instance;
3068 instance.GetChildPropertyIndex(arg1);
3069 DALI_TEST_CHECK(false); // Should not get here
3073 DALI_TEST_CHECK(true); // We expect an assert
3078 int UtcDaliTypeInfoGetChildPropertyIndicesNegative(void)
3080 TestApplication application;
3081 Dali::TypeInfo instance;
3084 Dali::Vector<int> arg1;
3085 instance.GetChildPropertyIndices(arg1);
3086 DALI_TEST_CHECK(false); // Should not get here
3090 DALI_TEST_CHECK(true); // We expect an assert
3095 int UtcDaliTypeInfoGetNameNegative(void)
3097 TestApplication application;
3098 Dali::TypeInfo instance;
3102 DALI_TEST_CHECK(false); // Should not get here
3106 DALI_TEST_CHECK(true); // We expect an assert
3111 int UtcDaliTypeRegistryGetTypeInfoNegative01(void)
3113 TestApplication application;
3114 Dali::TypeRegistry instance;
3118 instance.GetTypeInfo(arg1);
3119 DALI_TEST_CHECK(false); // Should not get here
3123 DALI_TEST_CHECK(true); // We expect an assert
3128 int UtcDaliTypeRegistryGetTypeInfoNegative02(void)
3130 TestApplication application;
3131 Dali::TypeRegistry instance;
3134 instance.GetTypeInfo(typeid(unsigned int));
3135 DALI_TEST_CHECK(false); // Should not get here
3139 DALI_TEST_CHECK(true); // We expect an assert
3144 int UtcDaliTypeRegistryGetTypeNameNegative(void)
3146 TestApplication application;
3147 Dali::TypeRegistry instance;
3150 unsigned long arg1(0u);
3151 instance.GetTypeName(arg1);
3152 DALI_TEST_CHECK(false); // Should not get here
3156 DALI_TEST_CHECK(true); // We expect an assert
3161 int UtcDaliTypeRegistryGetTypeNameCountNegative(void)
3163 TestApplication application;
3164 Dali::TypeRegistry instance;
3167 instance.GetTypeNameCount();
3168 DALI_TEST_CHECK(false); // Should not get here
3172 DALI_TEST_CHECK(true); // We expect an assert