From: Eunki Hong Date: Fri, 28 Mar 2025 14:48:11 +0000 (+0900) Subject: Remove error message when we set/get AnimatableProperty X-Git-Tag: accepted/tizen/unified/x/20250402.101948^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=eae66dd892d1d16ff0ecd4607244a0dd2ae3b7ae;p=platform%2Fcore%2Fuifw%2Fdali-core.git Remove error message when we set/get AnimatableProperty We only need to call setFunc/getFunc only if it exist. Until now, it check as error if sefFunc/getFunc not exist. Change-Id: I534e9dd2f7b76e9a50db1935931eea99cc1b70ca Signed-off-by: Eunki Hong --- diff --git a/automated-tests/src/dali/utc-Dali-TypeRegistry.cpp b/automated-tests/src/dali/utc-Dali-TypeRegistry.cpp index c1899a621..3e1eb862f 100644 --- a/automated-tests/src/dali/utc-Dali-TypeRegistry.cpp +++ b/automated-tests/src/dali/utc-Dali-TypeRegistry.cpp @@ -112,6 +112,11 @@ Property::Value GetProperty(BaseObject* object, Property::Index propertyIndex) getPropertyCalled = true; return Property::Value(true); } +Property::Value GetPropertyWithEmptyValueReturn(BaseObject* object, Property::Index propertyIndex) +{ + getPropertyCalled = true; + return Property::Value(); +} /******************************************************************************* * @@ -1698,6 +1703,132 @@ int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationN(void) END_TEST; } +int UtcDaliTypeRegistryAnimatablePropertyRegistrationWithSetGetFunctionP(void) +{ + TestApplication application; + TypeRegistry typeRegistry = TypeRegistry::Get(); + + // Check property count before property registration + TypeInfo typeInfo = typeRegistry.GetTypeInfo(typeid(MyTestCustomActor)); + DALI_TEST_CHECK(typeInfo); + BaseHandle handle = typeInfo.CreateInstance(); + DALI_TEST_CHECK(handle); + Actor customActor = Actor::DownCast(handle); + DALI_TEST_CHECK(customActor); + application.GetScene().Add(customActor); + + unsigned int customPropertyCount(customActor.GetPropertyCount()); + + // Register animatable property + std::string animatablePropertyName("animatableProp1"); + int animatablePropertyIndex(ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX); + Property::Type animatablePropertyType(Property::FLOAT); + AnimatablePropertyRegistration animatableProperty(customType1, animatablePropertyName, animatablePropertyIndex, animatablePropertyType, &SetProperty, &GetPropertyWithEmptyValueReturn); + + // Check property count after registration + DALI_TEST_EQUALS(customPropertyCount + 1u, customActor.GetPropertyCount(), TEST_LOCATION); + + // Set the animatable property value + DALI_TEST_CHECK(!setPropertyCalled); + customActor.SetProperty(animatablePropertyIndex, 25.0f); + DALI_TEST_CHECK(setPropertyCalled); + setPropertyCalled = false; + + // Render and notify + application.SendNotification(); + application.Render(); + + // Check the animatable property value + DALI_TEST_CHECK(!getPropertyCalled); + DALI_TEST_EQUALS(customActor.GetProperty(animatablePropertyIndex), 25.f, TEST_LOCATION); + DALI_TEST_CHECK(getPropertyCalled); + getPropertyCalled = false; + + // check that the property is animatable + Animation animation = Animation::New(0.2f); + animation.AnimateTo(Property(customActor, animatablePropertyIndex), 15.f, AlphaFunction::LINEAR); + animation.Play(); + + // TODO : This behavior might be changed in future! For now, AnimateTo or Play didn't call setFunc/getFunc + DALI_TEST_CHECK(!setPropertyCalled); + DALI_TEST_CHECK(!getPropertyCalled); + + // Target value should change straight away + DALI_TEST_EQUALS(customActor.GetProperty(animatablePropertyIndex), 15.0f, TEST_LOCATION); + DALI_TEST_CHECK(getPropertyCalled); + getPropertyCalled = false; + + // Render and notify, animation play for 0.05 seconds + application.SendNotification(); + application.Render(50); + DALI_TEST_EQUALS(0.25f, animation.GetCurrentProgress(), TEST_LOCATION); + DALI_TEST_EQUALS(customActor.GetCurrentProperty(animatablePropertyIndex), 22.5f, TEST_LOCATION); + + // TODO : This behavior might be changed in future! For now, GetCurrentProperty didn't call getFunc + DALI_TEST_CHECK(!getPropertyCalled); + + // Render and notify, animation play for another 0.1 seconds + application.SendNotification(); + application.Render(100); + DALI_TEST_EQUALS(0.75f, animation.GetCurrentProgress(), TEST_LOCATION); + DALI_TEST_EQUALS(customActor.GetCurrentProperty(animatablePropertyIndex), 17.5f, TEST_LOCATION); + + DALI_TEST_CHECK(!getPropertyCalled); + + END_TEST; +} + +int UtcDaliTypeRegistryAnimatablePropertyRegistrationWithSetGetFunctionN01(void) +{ + TestApplication application; + TypeRegistry typeRegistry = TypeRegistry::Get(); + + // Attempt to register an animatable property type out-of-bounds index (less than) + try + { + AnimatablePropertyRegistration property1(customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN, &SetProperty, &GetProperty); + tet_result(TET_FAIL); + } + catch(DaliException& e) + { + DALI_TEST_ASSERT(e, "(index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX) && (index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX)", TEST_LOCATION); + } + + // Attempt to register an animatable property type out-of-bounds index (greater than) + try + { + AnimatablePropertyRegistration property1(customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN, &SetProperty, &GetProperty); + tet_result(TET_FAIL); + } + catch(DaliException& e) + { + DALI_TEST_ASSERT(e, "(index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX) && (index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX)", TEST_LOCATION); + } + + END_TEST; +} + +int UtcDaliTypeRegistryAnimatablePropertyRegistrationWithSetGetFunctionN02(void) +{ + TestApplication application; + TypeRegistry typeRegistry = TypeRegistry::Get(); + + AnimatablePropertyRegistration property1(customType1, "animPropName", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1, Property::BOOLEAN, &SetProperty, &GetProperty); + + // Attempt to register an animatable property with the same index + try + { + AnimatablePropertyRegistration property1(customType1, "animPropName2", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1, Property::BOOLEAN, &SetProperty, &GetProperty); + tet_result(TET_FAIL); + } + catch(DaliException& e) + { + DALI_TEST_ASSERT(e, "!\"Property index already added to Type\"", TEST_LOCATION); + } + + END_TEST; +} + int UtcDaliTypeRegistryChildPropertyRegistrationP(void) { TestApplication application; diff --git a/dali/internal/event/common/type-info-impl.cpp b/dali/internal/event/common/type-info-impl.cpp index 4a1657c72..434473956 100644 --- a/dali/internal/event/common/type-info-impl.cpp +++ b/dali/internal/event/common/type-info-impl.cpp @@ -895,9 +895,12 @@ Property::Value TypeInfo::GetPropertyDefaultValue(Property::Index index) const void TypeInfo::SetAnimatableProperty(BaseObject* object, Property::Index index, Property::Value value) const { const auto& iter = mRegisteredProperties.Get(static_cast(index)); - if(iter != mRegisteredProperties.end() && iter->second.setFunc) + if(iter != mRegisteredProperties.end()) { - iter->second.setFunc(object, index, value); + if(iter->second.setFunc) + { + iter->second.setFunc(object, index, value); + } } else if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName)) { @@ -988,9 +991,12 @@ void TypeInfo::SetProperty(BaseObject* object, const std::string& name, Property Property::Value TypeInfo::GetAnimatableProperty(const BaseObject* object, Property::Index index) const { const auto& iter = mRegisteredProperties.Get(static_cast(index)); - if(iter != mRegisteredProperties.end() && iter->second.getFunc) + if(iter != mRegisteredProperties.end()) { - return iter->second.getFunc(const_cast(object), index); + if(iter->second.getFunc) + { + return iter->second.getFunc(const_cast(object), index); + } } else if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName)) {