getPropertyCalled = true;
return Property::Value(true);
}
+Property::Value GetPropertyWithEmptyValueReturn(BaseObject* object, Property::Index propertyIndex)
+{
+ getPropertyCalled = true;
+ return Property::Value();
+}
/*******************************************************************************
*
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<float>(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<float>(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<float>(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<float>(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;
void TypeInfo::SetAnimatableProperty(BaseObject* object, Property::Index index, Property::Value value) const
{
const auto& iter = mRegisteredProperties.Get(static_cast<std::uint32_t>(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))
{
Property::Value TypeInfo::GetAnimatableProperty(const BaseObject* object, Property::Index index) const
{
const auto& iter = mRegisteredProperties.Get(static_cast<std::uint32_t>(index));
- if(iter != mRegisteredProperties.end() && iter->second.getFunc)
+ if(iter != mRegisteredProperties.end())
{
- return iter->second.getFunc(const_cast<BaseObject*>(object), index);
+ if(iter->second.getFunc)
+ {
+ return iter->second.getFunc(const_cast<BaseObject*>(object), index);
+ }
}
else if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{