/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
}
catch ( DaliException& e )
{
- DALI_TEST_ASSERT( e, "Duplicate type name for Type Registation", TEST_LOCATION );
+ DALI_TEST_ASSERT( e, "Duplicate type name in Type Registration", TEST_LOCATION );
}
END_TEST;
typeInfo.GetPropertyIndices( indices );
size_t typePropertyCount = typeInfo.GetPropertyCount();
- DALI_TEST_EQUALS( indices.Size(), 1u, TEST_LOCATION );
+ DALI_TEST_EQUALS( indices.Size(), Actor::New().GetPropertyCount() + 1u, TEST_LOCATION );
DALI_TEST_EQUALS( indices.Size(), typePropertyCount, TEST_LOCATION );
// Ensure indices returned from actor and customActor differ by two
// Check property count of type-info is 1
Property::IndexContainer indices;
typeInfo.GetPropertyIndices( indices );
- DALI_TEST_EQUALS( indices.Size(), 1u, TEST_LOCATION );
+ DALI_TEST_EQUALS( indices.Size(), customActor.GetPropertyCount(), TEST_LOCATION );
// Ensure indices returned from actor and customActor differ by one
Actor actor = Actor::New();
// Check the animatable property type
DALI_TEST_EQUALS( customActor.GetPropertyType( animatablePropertyIndex ), Property::FLOAT, TEST_LOCATION );
- // Check property count of type-info is 1
+ // Check property count of type-info
Property::IndexContainer indices;
typeInfo.GetPropertyIndices( indices );
- DALI_TEST_EQUALS( indices.Size(), 1u, TEST_LOCATION );
+ DALI_TEST_EQUALS( indices.Size(), customActor.GetPropertyCount(), TEST_LOCATION );
// Ensure indices returned from actor and customActor differ by one
Actor actor = Actor::New();
// Check the animatable property type
DALI_TEST_EQUALS( customActor.GetPropertyType( animatablePropertyIndex ), animatablePropertyType, TEST_LOCATION );
- // Check property count of type-info is 1
+ // Check property count of type-info
Property::IndexContainer indices;
typeInfo.GetPropertyIndices( indices );
- DALI_TEST_EQUALS( indices.Size(), 1u, TEST_LOCATION );
+ DALI_TEST_EQUALS( indices.Size(), customActor.GetPropertyCount(), TEST_LOCATION );
// Register animatable property components
std::string animatablePropertyComponentName1( "animatableProp1X" );
unsigned int customActorIndices = indices.Size();
DALI_TEST_EQUALS( actorIndices + 3u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
+ // Attempt to animate component property, it should not crash
+ Animation animation = Animation::New( 1.0f );
+ animation.AnimateTo( Property( customActor, animatablePropertyComponentIndex1 ), 200.0f );
+ animation.Play();
+
+ // Check the property value
+ DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( animatablePropertyIndex ), Vector2(200.0f, 225.0f), TEST_LOCATION );
+ DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex1 ), 200.0f, TEST_LOCATION );
+ DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex2 ), 225.0f, TEST_LOCATION );
+
END_TEST;
}
Property::Type type = typeInfoImpl.GetChildPropertyType( typeInfoImpl.GetChildPropertyIndex("childProp4") );
DALI_TEST_EQUALS( type, Property::INTEGER, TEST_LOCATION );
+ std::string unRegisteredChildName( typeInfoImpl.GetChildPropertyName( CHILD_PROPERTY_REGISTRATION_START_INDEX + 4 ) );
+ DALI_TEST_EQUALS( unRegisteredChildName, "", TEST_LOCATION );
// Create a child actor
Actor childActor = Actor::New();
int UtcDaliPropertyRegistrationPropertyWritableN(void)
{
- // Currently Actors don't register properties with the type registry
-
TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
Internal::TypeInfo& typeInfoImpl = GetImplementation( typeInfo );
- try
- {
- typeInfoImpl.IsPropertyWritable( Actor::Property::COLOR);
- tet_result( TET_FAIL );
+ DALI_TEST_EQUALS( typeInfoImpl.IsPropertyWritable( Actor::Property::COLOR), true, TEST_LOCATION );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "Cannot find property index", TEST_LOCATION );
- }
END_TEST;
-
}
+
int UtcDaliPropertyRegistrationPropertyAnimatable(void)
{
TestApplication application;
END_TEST;
}
-int UtcDaliPropertyRegistrationInvalidGetAndSet(void)
+int UtcDaliPropertyRegistrationUnregisteredGetAndSet(void)
{
TestApplication application;
int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 2000;
Actor customActor = Actor::DownCast( handle );
DALI_TEST_CHECK( customActor );
- // Try to set an index that hasn't been added
- try
- {
- customActor.SetProperty( propertyIndex, true );
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "! \"Cannot find property index", TEST_LOCATION );
- }
-
- try
- {
- customActor.SetProperty( animatablePropertyIndex, true );
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "! \"Cannot find property index", TEST_LOCATION );
- }
+ // Try to set an index that hasn't been registered, this is a no-op for now, to be fixed in future
+ customActor.SetProperty( propertyIndex, true );
+// DALI_TEST_EQUALS( true, customActor.GetProperty( propertyIndex ).Get<bool>(), TEST_LOCATION);
- // Try to get an index that hasn't been added
- try
- {
- (void) customActor.GetProperty< bool >( propertyIndex );
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "! \"Cannot find property index", TEST_LOCATION );
- }
+ // Try to set an index that hasn't been registered
+ customActor.SetProperty( animatablePropertyIndex, true );
+ DALI_TEST_EQUALS( true, customActor.GetProperty( animatablePropertyIndex ).Get<bool>(), TEST_LOCATION);
- try
- {
- (void) customActor.GetProperty< bool >( animatablePropertyIndex );
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "! \"Cannot find property index", TEST_LOCATION );
- }
END_TEST;
}
DALI_TEST_CHECK( typeInfo );
size_t actorPropertyCount = typeInfo.GetPropertyCount();
- DALI_TEST_EQUALS( actorPropertyCount == 0 , true, TEST_LOCATION ); // No event only props
+ DALI_TEST_EQUALS( actorPropertyCount, Actor::New().GetPropertyCount(), TEST_LOCATION ); // No event only props
END_TEST;
}
typeInfo.GetPropertyIndices( indices );
DALI_TEST_EQUALS( propertyCount > 0 && propertyCount <= indices.Size(), true, TEST_LOCATION );
- DALI_TEST_EQUALS( propertyCount == 2, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( propertyCount, Actor::New().GetPropertyCount() + 2, TEST_LOCATION );
END_TEST;
}
END_TEST;
}
+
+
+int UtcDaliTypeInfoRegisterChildProperties01(void)
+{
+ TestApplication application;
+ TypeRegistry typeRegistry = TypeRegistry::Get();
+
+ tet_infoline( "Register child properties on a type via name" );
+
+ auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(CustomActor) );
+ auto myCustomTypeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
+ DALI_TEST_CHECK( customActorTypeInfo );
+ DALI_TEST_CHECK( myCustomTypeInfo );
+
+ const Property::Index WIDTH_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX );
+ const Property::Index HEIGHT_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1);
+ const Property::Index MARGIN_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 100);
+
+ ChildPropertyRegistration( customActorTypeInfo.GetName(), "widthSpecification", WIDTH_SPECIFICATION, Property::INTEGER );
+ ChildPropertyRegistration( customActorTypeInfo.GetName(), "heightSpecification", HEIGHT_SPECIFICATION, Property::INTEGER );
+ ChildPropertyRegistration( myCustomTypeInfo.GetName(), "marginSpecification", MARGIN_SPECIFICATION, Property::EXTENTS );
+
+ auto customActor = MyTestCustomActor::New();
+ Stage::GetCurrent().Add( customActor );
+ auto child = Actor::New();
+ customActor.Add( child );
+
+ child.SetProperty( WIDTH_SPECIFICATION, 33 );
+
+ auto value = child.GetProperty( WIDTH_SPECIFICATION );
+ DALI_TEST_EQUALS( value, Property::Value(33), TEST_LOCATION );
+
+ child.SetProperty( HEIGHT_SPECIFICATION, 44 );
+ value = child.GetProperty( HEIGHT_SPECIFICATION );
+ DALI_TEST_EQUALS( value, Property::Value(44), TEST_LOCATION );
+
+ child.SetProperty( MARGIN_SPECIFICATION, Extents(10, 10, 10, 10) );
+ value = child.GetProperty( MARGIN_SPECIFICATION );
+ DALI_TEST_EQUALS( value, Property::Value(Extents(10,10,10,10)), TEST_LOCATION );
+
+ END_TEST;
+}
+
+
+int UtcDaliTypeInfoRegisterChildProperties02(void)
+{
+ TestApplication application;
+ TypeRegistry typeRegistry = TypeRegistry::Get();
+
+ tet_infoline( "Register child properties on a type via name" );
+
+ auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(CustomActor) );
+ auto myCustomTypeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
+ DALI_TEST_CHECK( customActorTypeInfo );
+ DALI_TEST_CHECK( myCustomTypeInfo );
+
+ const Property::Index WIDTH_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX );
+ const Property::Index HEIGHT_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1);
+ const Property::Index MARGIN_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 100);
+
+ ChildPropertyRegistration( customActorTypeInfo.GetName(), "widthSpecification", WIDTH_SPECIFICATION, Property::INTEGER );
+ ChildPropertyRegistration( customActorTypeInfo.GetName(), "heightSpecification", HEIGHT_SPECIFICATION, Property::INTEGER );
+ ChildPropertyRegistration( myCustomTypeInfo.GetName(), "marginSpecification", MARGIN_SPECIFICATION, Property::EXTENTS );
+
+
+ auto index = customActorTypeInfo.GetChildPropertyIndex( "widthSpecification" );
+ DALI_TEST_EQUALS( index, WIDTH_SPECIFICATION, TEST_LOCATION );
+
+ index = customActorTypeInfo.GetChildPropertyIndex( "heightSpecification" );
+ DALI_TEST_EQUALS( index, HEIGHT_SPECIFICATION, TEST_LOCATION );
+
+ index = customActorTypeInfo.GetChildPropertyIndex( "marginSpecification" );
+ DALI_TEST_EQUALS( index, Property::INVALID_INDEX, TEST_LOCATION );
+
+ index = myCustomTypeInfo.GetChildPropertyIndex( "marginSpecification" );
+ DALI_TEST_EQUALS( index, MARGIN_SPECIFICATION, TEST_LOCATION );
+
+
+ auto name = customActorTypeInfo.GetChildPropertyName( WIDTH_SPECIFICATION );
+ DALI_TEST_EQUALS( name, "widthSpecification", TEST_LOCATION );
+
+ name = customActorTypeInfo.GetChildPropertyName( HEIGHT_SPECIFICATION );
+ DALI_TEST_EQUALS( name, "heightSpecification", TEST_LOCATION );
+
+ name = myCustomTypeInfo.GetChildPropertyName( MARGIN_SPECIFICATION );
+ DALI_TEST_EQUALS( name, "marginSpecification", TEST_LOCATION );
+
+
+ auto type = customActorTypeInfo.GetChildPropertyType( WIDTH_SPECIFICATION );
+ DALI_TEST_EQUALS( type, Property::INTEGER, TEST_LOCATION );
+
+ type = customActorTypeInfo.GetChildPropertyType( HEIGHT_SPECIFICATION );
+ DALI_TEST_EQUALS( type, Property::INTEGER, TEST_LOCATION );
+
+ type = myCustomTypeInfo.GetChildPropertyType( MARGIN_SPECIFICATION );
+ DALI_TEST_EQUALS( type, Property::EXTENTS, TEST_LOCATION );
+
+
+ END_TEST;
+}
+
+
+int UtcDaliTypeInfoRegisterChildProperties03(void)
+{
+ TestApplication application;
+ TypeRegistry typeRegistry = TypeRegistry::Get();
+
+ tet_infoline( "Check registered child properties can be retrieved" );
+
+ auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(CustomActor) );
+ auto myCustomTypeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
+ DALI_TEST_CHECK( customActorTypeInfo );
+ DALI_TEST_CHECK( myCustomTypeInfo );
+
+ const Property::Index WIDTH_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX );
+ const Property::Index HEIGHT_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1);
+ const Property::Index MARGIN_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 100);
+
+ ChildPropertyRegistration( customActorTypeInfo.GetName(), "widthSpecification", WIDTH_SPECIFICATION, Property::INTEGER );
+ ChildPropertyRegistration( customActorTypeInfo.GetName(), "heightSpecification", HEIGHT_SPECIFICATION, Property::INTEGER );
+ ChildPropertyRegistration( myCustomTypeInfo.GetName(), "marginSpecification", MARGIN_SPECIFICATION, Property::EXTENTS );
+
+ Property::IndexContainer indices;
+ myCustomTypeInfo.GetChildPropertyIndices( indices );
+
+ auto result = std::find( indices.Begin(), indices.End(), WIDTH_SPECIFICATION );
+ DALI_TEST_EQUALS( result != indices.End(), true, TEST_LOCATION );
+
+ result = std::find( indices.Begin(), indices.End(), HEIGHT_SPECIFICATION );
+ DALI_TEST_EQUALS( result != indices.End(), true, TEST_LOCATION );
+
+ result = std::find( indices.Begin(), indices.End(), MARGIN_SPECIFICATION );
+ DALI_TEST_EQUALS( result != indices.End(), true, TEST_LOCATION );
+
+ END_TEST;
+}