/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
#include <iostream>
#include <stdlib.h>
+#include <limits>
#include <dali/public-api/dali-core.h>
#include <dali-test-suite-utils.h>
#include <dali/integration-api/events/long-press-gesture-event.h>
typedef Signal< void ()> SignalType;
typedef Signal< void (float)> SignalTypeFloat;
- MyTestCustomActor() : CustomActorImpl( true ) // requires touch
+ MyTestCustomActor() : CustomActorImpl( ActorFlags( REQUIRES_TOUCH_EVENTS ) )
{ }
virtual ~MyTestCustomActor()
}
// From CustomActorImpl
- virtual void OnStageConnection()
+ virtual void OnStageConnection( int depth )
{
}
virtual void OnStageDisconnection()
{
return true;
}
- virtual bool OnMouseWheelEvent(const MouseWheelEvent& event)
+ virtual bool OnWheelEvent(const WheelEvent& event)
{
return true;
}
virtual void OnKeyInputFocusLost()
{
}
- virtual Actor GetChildByAlias(const std::string& actorAlias)
+ virtual Vector3 GetNaturalSize()
{
- return Actor::New();
+ return Vector3( 0.0f, 0.0f, 0.0f );
}
- virtual Vector3 GetNaturalSize()
+ virtual float GetHeightForWidth( float width )
+ {
+ return 0.0f;
+ }
+
+ virtual float GetWidthForHeight( float height )
+ {
+ return 0.0f;
+ }
+
+ virtual void OnRelayout( const Vector2& size, RelayoutContainer& container )
+ {
+ }
+
+ virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
+ {
+ }
+
+ virtual void OnCalculateRelayoutSize( Dimension::Type dimension )
{
- return Vector3( 0.0f, 0.0f, 0.0f );
+ }
+
+ virtual float CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension )
+ {
+ return 0.0f;
+ }
+
+ virtual void OnLayoutNegotiated( float size, Dimension::Type dimension )
+ {
+ }
+
+ virtual bool RelayoutDependentOnChildren( Dimension::Type dimension = Dimension::ALL_DIMENSIONS )
+ {
+ return false;
}
public:
}
static std::string lastActionCustom;
-bool DoActionCustom(BaseObject* object, const std::string& actionName, const std::vector<Property::Value>& attributes)
+bool DoActionCustom(BaseObject* object, const std::string& actionName, const Property::Map& /*attributes*/)
{
lastActionCustom = actionName;
return true;
}
TypeRegistration namedActorType( "MyNamedActor", typeid(Dali::Actor), CreateNamedActorType );
-PropertyRegistration namedActorPropertyOne( namedActorType, "prop-name", PROPERTY_REGISTRATION_START_INDEX, Property::BOOLEAN, &SetProperty, &GetProperty );
+PropertyRegistration namedActorPropertyOne( namedActorType, "propName", PROPERTY_REGISTRATION_START_INDEX, Property::BOOLEAN, &SetProperty, &GetProperty );
} // Anonymous namespace
+// Note: No negative test case for UtcDaliTypeRegistryGet can be implemented.
+int UtcDaliTypeRegistryGetP(void)
+{
+ TestApplication application;
+
+ TypeRegistry registry = TypeRegistry::Get();
+ DALI_TEST_CHECK( registry );
+
+ END_TEST;
+}
+
+// Note: No negative test case for UtcDaliTypeRegistryConstructor can be implemented.
+int UtcDaliTypeRegistryConstructorP(void)
+{
+ TestApplication application;
+
+ TypeRegistry registry;
+ DALI_TEST_CHECK( !registry );
+ END_TEST;
+}
-// Positive test case for a method
-int UtcDaliTypeRegistryCreateDaliObjects(void)
+// Note: No negative test case for UtcDaliTypeRegistryCopyConstructor can be implemented.
+int UtcDaliTypeRegistryCopyConstructorP(void)
{
TestApplication application;
- TypeRegistry registry; // like this for ctor test coverage
- registry = TypeRegistry::Get();
+ TypeRegistry registry = TypeRegistry::Get();
+ DALI_TEST_CHECK( registry );
- TypeInfo type;
+ TypeRegistry copy( registry );
+ DALI_TEST_CHECK( copy );
- type = registry.GetTypeInfo( "ImageActor" );
- DALI_TEST_CHECK( type );
- DALI_TEST_CHECK( type.GetCreator() );
- DALI_TEST_CHECK( ImageActor::DownCast( type.GetCreator()() ) );
- ImageActor ia = ImageActor::DownCast(type.CreateInstance());
- DALI_TEST_CHECK( ia );
- Stage::GetCurrent().Add( ia );
- application.Render();
+ DALI_TEST_CHECK( registry.GetTypeInfo( "Actor" ).GetName() == copy.GetTypeInfo( "Actor" ).GetName() );
+
+ END_TEST;
+}
+
+// Note: No negative test case for UtcDaliTypeRegistryAssignmentOperator can be implemented.
+int UtcDaliTypeRegistryAssignmentOperatorP(void)
+{
+ TestApplication application;
+
+ TypeRegistry registry = TypeRegistry::Get();
+ DALI_TEST_CHECK( registry );
+
+ TypeRegistry copy = registry;
+ DALI_TEST_CHECK( copy );
+ DALI_TEST_CHECK( registry == copy );
+
+ DALI_TEST_CHECK( registry.GetTypeInfo( "Actor" ).GetName() == copy.GetTypeInfo( "Actor" ).GetName() );
+
+ END_TEST;
+}
+
+int UtcDaliTypeRegistryAssignP(void)
+{
+ TestApplication application;
+
+ TypeRegistry registry = TypeRegistry::Get();
+ TypeRegistry registry2;
+ registry2 = registry;
+ DALI_TEST_CHECK( registry2 );
+
+ DALI_TEST_CHECK( registry2.GetTypeInfo( "Actor" ).GetName() == registry2.GetTypeInfo( "Actor" ).GetName() );
+
+ END_TEST;
+}
+
+int UtcDaliTypeRegistryGetTypeInfoFromTypeNameP(void)
+{
+ TestApplication application;
+
+ TypeRegistry registry = TypeRegistry::Get();
+ TypeInfo type;
+
+ // camera actor
type = registry.GetTypeInfo( "CameraActor" );
DALI_TEST_CHECK( type );
CameraActor ca = CameraActor::DownCast(type.CreateInstance());
Stage::GetCurrent().Add( ca );
application.Render();
- type = registry.GetTypeInfo( "LightActor" );
- DALI_TEST_CHECK( type );
- LightActor la = LightActor::DownCast(type.CreateInstance());
- DALI_TEST_CHECK( la );
- Stage::GetCurrent().Add( la );
- application.Render();
-
// animations
type = registry.GetTypeInfo( "Animation" );
DALI_TEST_CHECK( type );
an.Play();
application.Render();
- //
- type = registry.GetTypeInfo( "ShaderEffect" );
- DALI_TEST_CHECK( type );
- ShaderEffect ef = ShaderEffect::DownCast(type.CreateInstance());
- DALI_TEST_CHECK( ef );
- application.Render();
-
END_TEST;
}
-/*******************************************************************************
- *
- * Action through the base handle
- *
- ******************************************************************************/
-int UtcDaliTypeRegistryActionViaBaseHandle(void)
+int UtcDaliTypeRegistryGetTypeInfoFromTypeNameN(void)
{
TestApplication application;
+ TypeRegistry registry = TypeRegistry::Get();
+
TypeInfo type;
- type = TypeRegistry::Get().GetTypeInfo( "Actor" );
- DALI_TEST_CHECK( type );
+ type = registry.GetTypeInfo( "MyDummyActor" );
+ DALI_TEST_CHECK( !type );
- BaseHandle hdl = type.CreateInstance();
- DALI_TEST_CHECK( hdl );
+ END_TEST;
+}
- Actor a = Actor::DownCast(hdl);
- DALI_TEST_CHECK( a );
+int UtcDaliTypeRegistryGetTypeInfoFromTypeIdP(void)
+{
+ TypeInfo named_type = TypeRegistry::Get().GetTypeInfo( "CameraActor" );
+ TypeInfo typeinfo_type = TypeRegistry::Get().GetTypeInfo( typeid(Dali::CameraActor) );
- a.SetVisible(false);
+ DALI_TEST_CHECK( named_type );
+ DALI_TEST_CHECK( typeinfo_type );
- application.SendNotification();
- application.Render(0);
- DALI_TEST_CHECK(!a.IsVisible());
+ // Check named and typeid are equivalent
+ DALI_TEST_CHECK( named_type == typeinfo_type );
+
+ DALI_TEST_CHECK( named_type.GetName() == typeinfo_type.GetName() );
+ DALI_TEST_CHECK( named_type.GetBaseName() == typeinfo_type.GetBaseName() );
- std::vector<Property::Value> attributes;
+ END_TEST;
+}
- DALI_TEST_CHECK(hdl.DoAction("show", attributes));
+int UtcDaliTypeRegistryGetTypeInfoFromTypeIdN(void)
+{
+ TestApplication application;
+ TypeRegistry typeRegistry = TypeRegistry::Get();
- application.SendNotification();
- application.Render(0);
- DALI_TEST_CHECK(a.IsVisible());
+ TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(Vector2) );
+ DALI_TEST_CHECK( !typeInfo );
- DALI_TEST_CHECK(!hdl.DoAction("unknown-action", attributes));
END_TEST;
}
-int UtcDaliTypeRegistryNames(void)
+int UtcDaliTypeRegistryGetTypeNameCountP(void)
{
TestApplication application;
-
+ TypeRegistry typeRegistry = TypeRegistry::Get();
TypeInfo type;
- TypeRegistry::NameContainer names = TypeRegistry::Get().GetTypeNames();
-
- for(TypeRegistry::NameContainer::iterator iter = names.begin();
- iter != names.end(); ++iter)
+ for(size_t i = 0; i < typeRegistry.GetTypeNameCount(); i++)
{
- type = TypeRegistry::Get().GetTypeInfo( *iter );
+ type = typeRegistry.GetTypeInfo( typeRegistry.GetTypeName(i) );
DALI_TEST_CHECK( type );
}
END_TEST;
}
-// Check named and typeid are equivalent
-int UtcDaliTypeRegistryNameEquivalence(void)
-{
- TypeInfo named_type = TypeRegistry::Get().GetTypeInfo( "ImageActor" );
- TypeInfo typeinfo_type = TypeRegistry::Get().GetTypeInfo( typeid(Dali::ImageActor) );
-
- DALI_TEST_CHECK( named_type );
- DALI_TEST_CHECK( typeinfo_type );
- DALI_TEST_CHECK( named_type == typeinfo_type );
+int UtcDaliTypeRegistryGetTypeNamesP(void)
+{
+ TestApplication application;
+ TypeRegistry typeRegistry = TypeRegistry::Get();
+ TypeInfo type;
- DALI_TEST_CHECK( named_type.GetName() == typeinfo_type.GetName() );
- DALI_TEST_CHECK( named_type.GetBaseName() == typeinfo_type.GetBaseName() );
+ for(size_t i = 0; i < typeRegistry.GetTypeNameCount(); i++)
+ {
+ type = typeRegistry.GetTypeInfo( typeRegistry.GetTypeName(i) );
+ DALI_TEST_CHECK( type );
+ }
END_TEST;
}
-int UtcDaliTypeRegistryCustomActor(void)
+// Note: No negative test case for UtcDaliTypeRegistryTypeRegistration can be implemented.
+int UtcDaliTypeRegistryTypeRegistrationNotCallingCreateOnInitP(void)
{
ResetFunctorCounts();
MyTestCustomActor customHandle = MyTestCustomActor::DownCast( handle );
DALI_TEST_CHECK( customHandle );
- TypeInfo::NameContainer names;
- type.GetActions(names);
- TypeInfo::NameContainer baseNames;
- baseType.GetActions(baseNames);
- DALI_TEST_EQUALS( names.size(), TEST_ACTION_COUNT + baseNames.size(), TEST_LOCATION );
+ DALI_TEST_EQUALS( type.GetActionCount(), TEST_ACTION_COUNT + baseType.GetActionCount(), TEST_LOCATION );
- names.clear();
- type.GetSignals(names);
-
- baseNames.clear();
- baseType.GetSignals(baseNames);
-
- DALI_TEST_EQUALS( names.size(), TEST_SIGNAL_COUNT + baseNames.size(), TEST_LOCATION );
+ DALI_TEST_EQUALS( type.GetSignalCount(), TEST_SIGNAL_COUNT + baseType.GetSignalCount(), TEST_LOCATION );
{
TestConnectionTracker tracker;
DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
- std::vector<Property::Value> attributes;
+ Property::Map attributes;
handle.DoAction("act1", attributes);
DALI_TEST_CHECK( lastActionCustom == "act1" );
END_TEST;
}
-int UtcDaliTypeRegistryCustomSignalFailure(void)
+// Note: No negative test case for UtcDaliTypeRegistryTypeRegistration can be implemented.
+int UtcDaliTypeRegistryTypeRegistrationCallingCreateOnInitP(void)
{
- // Test what happens when signal connnector (DoConnectSignalFailure method) returns false
+ TestApplication application;
- ResetFunctorCounts();
+ DALI_TEST_CHECK( "MyTestCustomActor2" == customTypeInit.RegisteredName() );
+
+ DALI_TEST_CHECK( true == CreateCustomInitCalled );
+ TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor2" );
+ DALI_TEST_CHECK( type );
+ END_TEST;
+}
+// Note: No negative test case for UtcDaliTypeRegistryTypeRegistration can be implemented.
+int UtcDaliTypeRegistryTypeRegistrationForNamedTypeP(void)
+{
TestApplication application;
- TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
+ // Create Named Actor Type
+ TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyNamedActor" );
DALI_TEST_CHECK( type );
- TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( "CustomActor" );
+ BaseHandle namedHandle = type.CreateInstance();
+ DALI_TEST_CHECK( namedHandle );
+ Actor namedActor( Actor::DownCast( namedHandle ) );
+ DALI_TEST_CHECK( namedActor );
+
+ DALI_TEST_CHECK( namedActor.GetName() == "NamedActor" );
+ DALI_TEST_CHECK( type.GetName() == "MyNamedActor" );
+ DALI_TEST_CHECK( type.GetBaseName() == "Actor" );
+
+ END_TEST;
+}
+
+// Note: No negative test case for UtcDaliTypeRegistryRegisteredName can be implemented.
+int UtcDaliTypeRegistryRegisteredNameP(void)
+{
+ TestApplication application;
+
+ DALI_TEST_CHECK( scriptedName == scriptedType.RegisteredName() );
+
+ TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( scriptedName );
DALI_TEST_CHECK( baseType );
+ BaseHandle handle = baseType.CreateInstance();
+
+ DALI_TEST_CHECK( true == CreateCustomNamedInitCalled );
+ TypeInfo type = TypeRegistry::Get().GetTypeInfo( scriptedName );
+ DALI_TEST_CHECK( type );
+ END_TEST;
+}
+
+int UtcDaliTypeRegistrySignalConnectorTypeP(void)
+{
+ ResetFunctorCounts();
+
+ TestApplication application;
+
+ TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
+ DALI_TEST_CHECK( type );
+
BaseHandle handle = type.CreateInstance();
DALI_TEST_CHECK( handle );
MyTestCustomActor customHandle = MyTestCustomActor::DownCast( handle );
DALI_TEST_CHECK( customHandle );
- TypeInfo::NameContainer names;
- TypeInfo::NameContainer baseNames;
+ {
+ TestConnectionTracker tracker;
+
+ bool connected = handle.ConnectSignal( &tracker, "sig1", CustomTestFunctor() );
+ DALI_TEST_EQUALS( connected, true, TEST_LOCATION );
+ DALI_TEST_CHECK( lastSignalConnectionCustom == "sig1" );
+ DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
+ DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
+ customHandle.GetCustomSignal().Emit();
+ DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION );
+ DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
+ DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION );
+ }
+ // tracker should automatically disconnect here
+ DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
+ DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
+
+ // Test that functor is disconnected
+ DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION );
+ customHandle.GetCustomSignal().Emit();
+ DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1/*not incremented*/, TEST_LOCATION );
+ DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
+ DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliTypeRegistrySignalConnectorTypeN(void)
+{
+ // Test what happens when signal connnector (DoConnectSignalFailure method) returns false
+
+ ResetFunctorCounts();
+
+ TestApplication application;
+
+ TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
+ DALI_TEST_CHECK( type );
- type.GetActions(names);
- baseType.GetActions(baseNames);
+ TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( "CustomActor" );
+ DALI_TEST_CHECK( baseType );
- DALI_TEST_EQUALS( names.size(), TEST_ACTION_COUNT + baseNames.size(), TEST_LOCATION );
+ BaseHandle handle = type.CreateInstance();
+ DALI_TEST_CHECK( handle );
- names.clear();
- baseNames.clear();
+ MyTestCustomActor customHandle = MyTestCustomActor::DownCast( handle );
+ DALI_TEST_CHECK( customHandle );
- type.GetSignals(names);
- baseType.GetSignals(baseNames);
+ DALI_TEST_EQUALS( type.GetActionCount(), TEST_ACTION_COUNT + baseType.GetActionCount(), TEST_LOCATION );
- DALI_TEST_EQUALS( names.size(), TEST_SIGNAL_COUNT + baseNames.size(), TEST_LOCATION );
+ DALI_TEST_EQUALS( type.GetSignalCount(), TEST_SIGNAL_COUNT + baseType.GetSignalCount(), TEST_LOCATION );
{
TestConnectionTracker tracker;
END_TEST;
}
-
-
-int UtcDaliTypeRegistryInitFunctions(void)
+int UtcDaliTypeRegistryTypeActionP(void)
{
- TestApplication application;
+ ResetFunctorCounts();
- DALI_TEST_CHECK( "MyTestCustomActor2" == customTypeInit.RegisteredName() );
+ TestApplication application;
- DALI_TEST_CHECK( true == CreateCustomInitCalled );
- TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor2" );
+ TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
DALI_TEST_CHECK( type );
- END_TEST;
-}
+ BaseHandle handle = type.CreateInstance();
+ DALI_TEST_CHECK( handle );
+ Property::Map attributes;
+ DALI_TEST_CHECK( handle.DoAction("act1", attributes) );
+ DALI_TEST_CHECK( lastActionCustom == "act1" );
+ END_TEST;
+}
-int UtcDaliTypeRegistryNameInitFunctions(void)
+int UtcDaliTypeRegistryTypeActionN(void)
{
+ ResetFunctorCounts();
+
TestApplication application;
- DALI_TEST_CHECK( scriptedName == scriptedType.RegisteredName() );
+ TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
+ DALI_TEST_CHECK( type );
- TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( scriptedName );
- DALI_TEST_CHECK( baseType );
+ BaseHandle handle = type.CreateInstance();
+ DALI_TEST_CHECK( handle );
- BaseHandle handle = baseType.CreateInstance();
+ Property::Map attributes;
+ DALI_TEST_CHECK( !handle.DoAction( "unknownAction", attributes ) );
- DALI_TEST_CHECK( true == CreateCustomNamedInitCalled );
- TypeInfo type = TypeRegistry::Get().GetTypeInfo( scriptedName );
- DALI_TEST_CHECK( type );
END_TEST;
}
-
-int UtcDaliPropertyRegistration(void)
+int UtcDaliTypeRegistryPropertyRegistrationP(void)
{
TestApplication application;
TypeRegistry typeRegistry = TypeRegistry::Get();
DALI_TEST_CHECK( customActor );
unsigned int initialPropertyCount( customActor.GetPropertyCount() );
- std::string propertyName( "prop-1" );
+ std::string propertyName( "prop1" );
int propertyIndex( PROPERTY_REGISTRATION_START_INDEX );
Property::Type propertyType( Property::BOOLEAN );
PropertyRegistration property1( customType1, propertyName, propertyIndex, propertyType, &SetProperty, &GetProperty );
DALI_TEST_EQUALS( initialPropertyCount + 1u, postRegistrationPropertyCount, TEST_LOCATION );
// Add custom property and check property count
- customActor.RegisterProperty( "custom-prop-1", true );
+ customActor.RegisterProperty( "customProp1", true );
unsigned int customPropertyCount( customActor.GetPropertyCount() );
DALI_TEST_EQUALS( postRegistrationPropertyCount + 1u, customPropertyCount, TEST_LOCATION );
// 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(), 1u, TEST_LOCATION );
// Ensure indices returned from actor and customActor differ by two
Actor actor = Actor::New();
actor.GetPropertyIndices( indices );
- unsigned int actorIndices = indices.size();
+ unsigned int actorIndices = indices.Size();
customActor.GetPropertyIndices( indices );
- unsigned int customActorIndices = indices.size();
+ unsigned int customActorIndices = indices.Size();
DALI_TEST_EQUALS( actorIndices + 2u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
END_TEST;
}
-int UtcDaliPropertyRegistrationIndexOutOfBounds(void)
+int UtcDaliTypeRegistryPropertyRegistrationN(void)
{
TestApplication application;
TypeRegistry typeRegistry = TypeRegistry::Get();
// Attempt to register a property type out-of-bounds index (less than)
try
{
- PropertyRegistration property1( customType1, "prop-name", PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN, &SetProperty, &GetProperty );
+ PropertyRegistration property1( customType1, "propName", PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN, &SetProperty, &GetProperty );
tet_result( TET_FAIL );
}
catch ( DaliException& e )
// Attempt to register a property type out-of-bounds index (greater than)
try
{
- PropertyRegistration property1( customType1, "prop-name", PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN, &SetProperty, &GetProperty );
+ PropertyRegistration property1( customType1, "propName", PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN, &SetProperty, &GetProperty );
tet_result( TET_FAIL );
}
catch ( DaliException& e )
{
DALI_TEST_ASSERT( e, "( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
}
+
END_TEST;
}
-int UtcDaliPropertyRegistrationFunctions(void)
+int UtcDaliTypeRegistryAnimatablePropertyRegistrationP(void)
{
TestApplication application;
- int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 10;
+ TypeRegistry typeRegistry = TypeRegistry::Get();
- // Attempt to register a property without a setter
- try
- {
- PropertyRegistration property1( customType1, "prop-name", propertyIndex++, Property::BOOLEAN, NULL, &GetProperty );
- tet_result( TET_PASS );
- }
- catch ( DaliException& e )
- {
- tet_result( TET_FAIL );
+ // 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 );
+ Stage::GetCurrent().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 );
+
+ // Check property count after registration
+ DALI_TEST_EQUALS( customPropertyCount + 1u, customActor.GetPropertyCount(), TEST_LOCATION );
+
+ // Set the animatable property value
+ customActor.SetProperty( animatablePropertyIndex, 25.0f );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Check the animatable property value
+ DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 25.f, TEST_LOCATION );
+
+ // Check the animatable property name
+ DALI_TEST_EQUALS( customActor.GetPropertyName( animatablePropertyIndex ), animatablePropertyName, TEST_LOCATION );
+
+ // Check the animatable property index
+ DALI_TEST_EQUALS( customActor.GetPropertyIndex( animatablePropertyName ), animatablePropertyIndex, TEST_LOCATION );
+
+ // Check the animatable property type
+ DALI_TEST_EQUALS( customActor.GetPropertyType( animatablePropertyIndex ), animatablePropertyType, TEST_LOCATION );
+
+ // Check property count of type-info is 1
+ Property::IndexContainer indices;
+ typeInfo.GetPropertyIndices( indices );
+ DALI_TEST_EQUALS( indices.Size(), 1u, TEST_LOCATION );
+
+ // Ensure indices returned from actor and customActor differ by one
+ Actor actor = Actor::New();
+ actor.GetPropertyIndices( indices );
+ unsigned int actorIndices = indices.Size();
+ customActor.GetPropertyIndices( indices );
+ unsigned int customActorIndices = indices.Size();
+ DALI_TEST_EQUALS( actorIndices + 1u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
+
+ // check that the property is animatable
+ Animation animation = Animation::New(0.2f);
+ animation.AnimateTo( Property( customActor, animatablePropertyIndex ), 15.f, AlphaFunction::LINEAR );
+ animation.Play();
+ // 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.GetProperty< float >( animatablePropertyIndex ), 22.5f, TEST_LOCATION );
+ // 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.GetProperty< float >( animatablePropertyIndex ), 17.5f, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliTypeRegistryAnimatablePropertyRegistrationN(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 );
+ 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 );
+ 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 UtcDaliTypeRegistryAnimatablePropertyRegistrationWithDefaultP(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 );
+ Stage::GetCurrent().Add(customActor);
+
+ unsigned int customPropertyCount( customActor.GetPropertyCount() );
+
+ // Register animatable property
+ std::string animatablePropertyName( "animatableProp1" );
+ int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
+ AnimatablePropertyRegistration animatableProperty1( customType1, animatablePropertyName, animatablePropertyIndex, 10.f );
+
+ // Check property count after registration
+ DALI_TEST_EQUALS( customPropertyCount + 1u, customActor.GetPropertyCount(), TEST_LOCATION );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Check the animatable property value
+ DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 10.f, TEST_LOCATION );
+
+ // Check the animatable property name
+ DALI_TEST_EQUALS( customActor.GetPropertyName( animatablePropertyIndex ), animatablePropertyName, TEST_LOCATION );
+
+ // Check the animatable property index
+ DALI_TEST_EQUALS( customActor.GetPropertyIndex( animatablePropertyName ), animatablePropertyIndex, TEST_LOCATION );
+
+ // Check the animatable property type
+ DALI_TEST_EQUALS( customActor.GetPropertyType( animatablePropertyIndex ), Property::FLOAT, TEST_LOCATION );
+
+ // Check property count of type-info is 1
+ Property::IndexContainer indices;
+ typeInfo.GetPropertyIndices( indices );
+ DALI_TEST_EQUALS( indices.Size(), 1u, TEST_LOCATION );
+
+ // Ensure indices returned from actor and customActor differ by one
+ Actor actor = Actor::New();
+ actor.GetPropertyIndices( indices );
+ unsigned int actorIndices = indices.Size();
+ customActor.GetPropertyIndices( indices );
+ unsigned int customActorIndices = indices.Size();
+ DALI_TEST_EQUALS( actorIndices + 1u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
+
+ // check that the property is animatable
+ Animation animation = Animation::New(0.2f);
+ animation.AnimateTo( Property( customActor, animatablePropertyIndex ), 20.f, AlphaFunction::LINEAR );
+ animation.Play();
+ // 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.GetProperty< float >( animatablePropertyIndex ), 12.5f, TEST_LOCATION );
+ // 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.GetProperty< float >( animatablePropertyIndex ), 17.5f, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliTypeRegistryAnimatablePropertyRegistrationWithDefaultN(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, false );
+ 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, true );
+ 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 UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationP(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 );
+
+ unsigned int customPropertyCount( customActor.GetPropertyCount() );
+
+ // Register animatable property
+ std::string animatablePropertyName( "animatableProp1" );
+ int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
+ Property::Type animatablePropertyType( Property::VECTOR2 );
+ AnimatablePropertyRegistration animatableProperty1( customType1, animatablePropertyName, animatablePropertyIndex, animatablePropertyType );
+
+ // Check property count after registration
+ DALI_TEST_EQUALS( customPropertyCount + 1u, customActor.GetPropertyCount(), TEST_LOCATION );
+
+ // Set the animatable property value
+ customActor.SetProperty( animatablePropertyIndex, Vector2(25.0f, 50.0f) );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Check the animatable property value
+ DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( animatablePropertyIndex ), Vector2(25.0f, 50.0f), TEST_LOCATION );
+
+ // Check the animatable property name
+ DALI_TEST_EQUALS( customActor.GetPropertyName( animatablePropertyIndex ), animatablePropertyName, TEST_LOCATION );
+
+ // Check the animatable property index
+ DALI_TEST_EQUALS( customActor.GetPropertyIndex( animatablePropertyName ), animatablePropertyIndex, TEST_LOCATION );
+
+ // Check the animatable property type
+ DALI_TEST_EQUALS( customActor.GetPropertyType( animatablePropertyIndex ), animatablePropertyType, TEST_LOCATION );
+
+ // Check property count of type-info is 1
+ Property::IndexContainer indices;
+ typeInfo.GetPropertyIndices( indices );
+ DALI_TEST_EQUALS( indices.Size(), 1u, TEST_LOCATION );
+
+ // Register animatable property components
+ std::string animatablePropertyComponentName1( "animatableProp1X" );
+ int animatablePropertyComponentIndex1( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1 );
+ AnimatablePropertyComponentRegistration animatablePropertyComponent1( customType1, animatablePropertyComponentName1, animatablePropertyComponentIndex1, animatablePropertyIndex, 0 );
+
+ std::string animatablePropertyComponentName2( "animatableProp1Y" );
+ int animatablePropertyComponentIndex2( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2 );
+ AnimatablePropertyComponentRegistration animatablePropertyComponent2( customType1, animatablePropertyComponentName2, animatablePropertyComponentIndex2, animatablePropertyIndex, 1 );
+
+ // Check property count after registration
+ DALI_TEST_EQUALS( customPropertyCount + 3u, customActor.GetPropertyCount(), TEST_LOCATION );
+
+ // Check the animatable property component value
+ DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex1 ), 25.0f, TEST_LOCATION );
+ DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex2 ), 50.0f, TEST_LOCATION );
+
+ // Set the animatable property component value
+ customActor.SetProperty( animatablePropertyComponentIndex1, 150.0f );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Check the animatable property value
+ DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( animatablePropertyIndex ), Vector2(150.0f, 50.0f), TEST_LOCATION );
+ DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex1 ), 150.0f, TEST_LOCATION );
+ DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex2 ), 50.0f, TEST_LOCATION );
+
+ // Set the animatable property component value
+ customActor.SetProperty( animatablePropertyComponentIndex2, 225.0f );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Check the animatable property value
+ DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( animatablePropertyIndex ), Vector2(150.0f, 225.0f), TEST_LOCATION );
+ DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex1 ), 150.0f, TEST_LOCATION );
+ DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex2 ), 225.0f, TEST_LOCATION );
+
+ // Ensure indices returned from actor and customActor differ by three
+ Actor actor = Actor::New();
+ actor.GetPropertyIndices( indices );
+ unsigned int actorIndices = indices.Size();
+ customActor.GetPropertyIndices( indices );
+ unsigned int customActorIndices = indices.Size();
+ DALI_TEST_EQUALS( actorIndices + 3u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
+
+ END_TEST;
+}
+
+int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationN(void)
+{
+ TestApplication application;
+ TypeRegistry typeRegistry = TypeRegistry::Get();
+
+ // Register animatable property with the type of Vector2
+ int animatablePropertyIndex1( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
+ AnimatablePropertyRegistration animatableProperty1( customType1, "animatableProp1", animatablePropertyIndex1, Property::VECTOR2 );
+
+ // Attempt to register an animatable property component out-of-bounds index (less than)
+ try
+ {
+ AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp1X", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX - 1, animatablePropertyIndex1, 0 );
+ 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 component out-of-bounds index (greater than)
+ try
+ {
+ AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp1X", ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX + 1, animatablePropertyIndex1, 0 );
+ 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 );
+ }
+
+ // Register an animatable property component
+ AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp1X", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1, animatablePropertyIndex1, 0 );
+
+ // Attempt to register another animatable property component with the same component index
+ try
+ {
+ AnimatablePropertyComponentRegistration propertyComponent2( customType1, "animatableProp1Y", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2, animatablePropertyIndex1, 0 );
+ tet_result( TET_FAIL );
+ }
+ catch ( DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "Property component already registered", TEST_LOCATION );
+ }
+
+ // Register animatable property with the type of boolean
+ int animatablePropertyIndex2( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2 );
+ AnimatablePropertyRegistration animatableProperty2( customType1, "animatableProp2", animatablePropertyIndex2, Property::BOOLEAN );
+
+ // Attempt to register an animatable property component for the above property with boolean type
+ try
+ {
+ AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp2X", animatablePropertyIndex2 + 1, animatablePropertyIndex2, 0 );
+ tet_result( TET_FAIL );
+ }
+ catch ( DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "Base property does not support component", TEST_LOCATION );
+ }
+
+ END_TEST;
+}
+
+int UtcDaliTypeRegistryChildPropertyRegistrationP(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 );
+ unsigned int initialPropertyCount( customActor.GetPropertyCount() );
+
+ // Register child properties to the parent
+ std::string propertyName( "childProp1" );
+ int propertyIndex( CHILD_PROPERTY_REGISTRATION_START_INDEX );
+ Property::Type propertyType( Property::BOOLEAN );
+ ChildPropertyRegistration childProperty1( customType1, propertyName, propertyIndex, propertyType );
+
+ std::string propertyName2( "childProp2" );
+ int propertyIndex2( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1 );
+ Property::Type propertyType2( Property::INTEGER );
+ ChildPropertyRegistration childProperty2( customType1, propertyName2, propertyIndex2, propertyType2 );
+
+ std::string propertyName3( "childProp3" );
+ int propertyIndex3( CHILD_PROPERTY_REGISTRATION_START_INDEX + 2 );
+ Property::Type propertyType3( Property::FLOAT );
+ ChildPropertyRegistration childProperty3( customType1, propertyName3, propertyIndex3, propertyType3 );
+
+ std::string propertyName4( "childProp4" );
+ int propertyIndex4( CHILD_PROPERTY_REGISTRATION_START_INDEX + 3 );
+ Property::Type propertyType4( Property::INTEGER );
+ ChildPropertyRegistration childProperty4( customType1, propertyName4, propertyIndex4, propertyType4 );
+
+ // Check property count are not changed because the child properties will not be created for the parent
+ DALI_TEST_EQUALS( initialPropertyCount, customActor.GetPropertyCount(), TEST_LOCATION );
+
+ // Create a child actor
+ Actor childActor = Actor::New();
+ DALI_TEST_CHECK( childActor );
+ unsigned int initialChildActorPropertyCount( childActor.GetPropertyCount() );
+
+ // The type of child properties should be Property::None as the child hasn't registered any child property yet.
+ DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex ), Property::NONE, TEST_LOCATION );
+ DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex2 ), Property::NONE, TEST_LOCATION );
+ DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex3 ), Property::NONE, TEST_LOCATION );
+ DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex4 ), Property::NONE, TEST_LOCATION );
+
+ // Set the value for the first child property when the child actor doesn't have a parent yet
+ childActor.SetProperty(propertyIndex, true);
+
+ // Check that the first child property is dynamically created
+ DALI_TEST_EQUALS( initialChildActorPropertyCount + 1u, childActor.GetPropertyCount(), TEST_LOCATION );
+
+ // Check the first child property value
+ DALI_TEST_EQUALS( childActor.GetProperty< bool >( propertyIndex ), true, TEST_LOCATION );
+
+ // Check the first child property type
+ DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex ), propertyType, TEST_LOCATION );
+
+ // Check that the first child property have no name, as it doesn't have a parent yet.
+ DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex ), "", TEST_LOCATION );
+
+ // Check that the first property can't be accessed through its name, as it doesn't have a parent yet.
+ DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName ), Property::INVALID_INDEX, TEST_LOCATION );
+
+ // Create a custom property for the child with the same name as the second child property registered to the parent
+ Property::Index customPropertyIndex = childActor.RegisterProperty(propertyName2, 100, Property::READ_WRITE);
+
+ // Check that the custom property is created
+ DALI_TEST_EQUALS( initialChildActorPropertyCount + 2u, childActor.GetPropertyCount(), TEST_LOCATION );
+
+ // Check the property value
+ DALI_TEST_EQUALS( childActor.GetProperty< int >( customPropertyIndex ), 100, TEST_LOCATION );
+
+ // Check the property index
+ DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName2 ), customPropertyIndex, TEST_LOCATION );
+
+ // Check the property type
+ DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex ), propertyType2, TEST_LOCATION );
+
+ // Check the property name
+ DALI_TEST_EQUALS( childActor.GetPropertyName( customPropertyIndex ), propertyName2, TEST_LOCATION );
+
+ // Now add the child actor to the parent
+ customActor.Add( childActor );
+
+ // Check that the first child property now has the correct name as previously registered to the parent
+ DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
+
+ // Check that the child property index for the first child property can now be retrieved through its child property name
+ DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName ), propertyIndex, TEST_LOCATION );
+
+ // Check that the second child property now has the correct index as previously registered to the parent
+ DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex2 ), propertyName2, TEST_LOCATION );
+
+ // Check that the second child property can be accessed through both its custom property index and its child property index
+ DALI_TEST_EQUALS( childActor.GetProperty< int >( customPropertyIndex ), 100, TEST_LOCATION );
+ DALI_TEST_EQUALS( childActor.GetProperty< int >( propertyIndex2 ), 100, TEST_LOCATION );
+ DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex ), propertyType2, TEST_LOCATION );
+ DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex2 ), propertyType2, TEST_LOCATION );
+
+ // Check that the child property index for the second child property can now be retrieved through its child property name
+ DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName2 ), propertyIndex2, TEST_LOCATION );
+
+ // Set the value for the third child property when the child actor is already added to the parent
+ childActor.SetProperty(propertyIndex3, 0.15f);
+
+ // Check that the third child property is dynamically created
+ DALI_TEST_EQUALS( initialChildActorPropertyCount + 3u, childActor.GetPropertyCount(), TEST_LOCATION );
+
+ // Check the third child property value
+ DALI_TEST_EQUALS( childActor.GetProperty< float >( propertyIndex3 ), 0.15f, TEST_LOCATION );
+
+ // Check the third child property type
+ DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex3 ), propertyType3, TEST_LOCATION );
+
+ // Check the third child property name
+ DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex3 ), propertyName3, TEST_LOCATION );
+
+ // Check the third child property index.
+ DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName3 ), propertyIndex3, TEST_LOCATION );
+
+ // Create a custom property for the child with the same name as the fourth child property registered to the parent
+ Property::Index customPropertyIndex2 = childActor.RegisterProperty(propertyName4, 20, Property::READ_WRITE);
+
+ // Check that the custom property is created
+ DALI_TEST_EQUALS( initialChildActorPropertyCount + 4u, childActor.GetPropertyCount(), TEST_LOCATION );
+
+ // Check the fourth child property value
+ DALI_TEST_EQUALS( childActor.GetProperty< int >( propertyIndex4 ), 20, TEST_LOCATION );
+ DALI_TEST_EQUALS( childActor.GetProperty< int >( customPropertyIndex2 ), 20, TEST_LOCATION );
+
+ // Check the fourth child property type
+ DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex4 ), propertyType4, TEST_LOCATION );
+ DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex2 ), propertyType4, TEST_LOCATION );
+
+ // Check the fourth child property name
+ DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex4 ), propertyName4, TEST_LOCATION );
+ DALI_TEST_EQUALS( childActor.GetPropertyName( customPropertyIndex2 ), propertyName4, TEST_LOCATION );
+
+ // Check the fourth child property index.
+ DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName4 ), propertyIndex4, TEST_LOCATION );
+
+ // Now create another parent actor with different child properties registered
+ TypeInfo typeInfo2 = typeRegistry.GetTypeInfo( "MyNamedActor" );
+ DALI_TEST_CHECK( typeInfo2 );
+ BaseHandle handle2 = typeInfo2.CreateInstance();
+ DALI_TEST_CHECK( handle2 );
+ Actor customActor2 = Actor::DownCast( handle2 );
+ DALI_TEST_CHECK( customActor2 );
+
+ // Register child properties to the new parent
+ std::string newPropertyName( "newChildProp" );
+ int newPropertyIndex( CHILD_PROPERTY_REGISTRATION_START_INDEX ); // The same index as the first child property "childProp1" in the old parent
+ Property::Type newPropertyType( Property::VECTOR2 );
+ ChildPropertyRegistration newChildProperty( namedActorType, newPropertyName, newPropertyIndex, newPropertyType );
+
+ std::string newPropertyName2( "childProp3" ); // The same name as the third child property in the old parent
+ int newPropertyIndex2( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1 ); // The same index as the second child property "childProp2" in the old parent
+ Property::Type newPropertyType2( Property::FLOAT ); // The same type as the third child property in the old parent
+ ChildPropertyRegistration newChildProperty2( namedActorType, newPropertyName2, newPropertyIndex2, newPropertyType2 );
+
+ // Now move the child actor to the new parent
+ customActor2.Add( childActor );
+
+ // "childProp1" is not a valid child property supported by the new parent, so nothing changed
+ DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex ), propertyType, TEST_LOCATION );
+ DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
+ DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName ), propertyIndex, TEST_LOCATION );
+
+ // "childProp3" is a valid child property supported by the new parent
+ // So it should get its new child property index and should just work
+ DALI_TEST_EQUALS( childActor.GetPropertyType( newPropertyIndex2 ), newPropertyType2, TEST_LOCATION );
+ DALI_TEST_EQUALS( childActor.GetPropertyName( newPropertyIndex2 ), newPropertyName2, TEST_LOCATION );
+ DALI_TEST_EQUALS( childActor.GetPropertyIndex( newPropertyName2 ), newPropertyIndex2, TEST_LOCATION );
+ DALI_TEST_EQUALS( childActor.GetProperty< float >( newPropertyIndex2 ), 0.15f, TEST_LOCATION );
+
+ // Now register a custom property called "newChildProp"
+ Property::Index customPropertyIndex3 = childActor.RegisterProperty("newChildProp", Vector2( 10.0f, 10.0f ), Property::READ_WRITE);
+
+ // Check that the custom property is created
+ DALI_TEST_EQUALS( initialChildActorPropertyCount + 5u, childActor.GetPropertyCount(), TEST_LOCATION );
+
+ // This is a valid child property registered to the new parent
+ // So should be able to access it through both its custom property index and its registered child property index
+ DALI_TEST_EQUALS( childActor.GetPropertyType( newPropertyIndex ), newPropertyType, TEST_LOCATION );
+ DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex3 ), newPropertyType, TEST_LOCATION );
+ DALI_TEST_EQUALS( childActor.GetPropertyName( newPropertyIndex ), newPropertyName, TEST_LOCATION ); // This should return the new name, although the child property index remains the same
+ DALI_TEST_EQUALS( childActor.GetPropertyName( customPropertyIndex3 ), newPropertyName, TEST_LOCATION );
+ DALI_TEST_EQUALS( childActor.GetProperty< Vector2 >( newPropertyIndex ), Vector2( 10.0f, 10.0f ), TEST_LOCATION );
+ DALI_TEST_EQUALS( childActor.GetProperty< Vector2 >( customPropertyIndex3 ), Vector2( 10.0f, 10.0f ), TEST_LOCATION );
+
+ // Should return the child property index by given its name
+ DALI_TEST_EQUALS( childActor.GetPropertyIndex( newPropertyName ), newPropertyIndex, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliTypeRegistryChildPropertyRegistrationN(void)
+{
+ TestApplication application;
+ TypeRegistry typeRegistry = TypeRegistry::Get();
+
+ // Attempt to register a child property type out-of-bounds index (less than)
+ try
+ {
+ ChildPropertyRegistration property1( customType1, "propName", CHILD_PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN );
+ tet_result( TET_FAIL );
+ }
+ catch ( DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "( index >= CHILD_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
+ }
+
+ // Attempt to register a child property type out-of-bounds index (greater than)
+ try
+ {
+ ChildPropertyRegistration property1( customType1, "propName", CHILD_PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN );
+ tet_result( TET_FAIL );
+ }
+ catch ( DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "( index >= CHILD_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
+ }
+
+ END_TEST;
+}
+
+
+/*******************************************************************************
+ *
+ * Action through the base handle
+ *
+ ******************************************************************************/
+int UtcDaliTypeRegistryActionViaBaseHandle(void)
+{
+ TestApplication application;
+
+ TypeInfo type;
+
+ type = TypeRegistry::Get().GetTypeInfo( "Actor" );
+ DALI_TEST_CHECK( type );
+
+ BaseHandle hdl = type.CreateInstance();
+ DALI_TEST_CHECK( hdl );
+
+ Actor a = Actor::DownCast(hdl);
+ DALI_TEST_CHECK( a );
+
+ a.SetVisible(false);
+
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_CHECK(!a.IsVisible());
+
+ Property::Map attributes;
+
+ DALI_TEST_CHECK(hdl.DoAction("show", attributes));
+
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_CHECK(a.IsVisible());
+
+ DALI_TEST_CHECK(!hdl.DoAction("unknownAction", attributes));
+ END_TEST;
+}
+
+int UtcDaliPropertyRegistrationFunctions(void)
+{
+ TestApplication application;
+ int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 10;
+
+ // Attempt to register a property without a setter
+ try
+ {
+ PropertyRegistration property1( customType1, "propName", propertyIndex++, Property::BOOLEAN, NULL, &GetProperty );
+ tet_result( TET_PASS );
+ }
+ catch ( DaliException& e )
+ {
+ tet_result( TET_FAIL );
}
// Attempt to register a property without a getter
try
{
- PropertyRegistration property1( customType1, "prop-name", propertyIndex++, Property::BOOLEAN, NULL, NULL );
+ PropertyRegistration property1( customType1, "propName", propertyIndex++, Property::BOOLEAN, NULL, NULL );
tet_result( TET_FAIL );
}
catch ( DaliException& e )
int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 100;
// Add one property with a valid property index
- PropertyRegistration property1( customType1, "prop-name", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
+ PropertyRegistration property1( customType1, "propName", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
// Attempt to add another property with the same index
try
{
- PropertyRegistration property2( customType1, "prop-name-2", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
+ PropertyRegistration property2( customType1, "propName2", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
+ }
+ catch ( DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "! \"Property index already added", TEST_LOCATION );
+ }
+
+ int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 100;
+
+ // Add one property with a valid property index
+ AnimatablePropertyRegistration property3( customType1, "animPropName", animatablePropertyIndex, Property::BOOLEAN );
+
+ // Attempt to add another property with the same index
+ try
+ {
+ AnimatablePropertyRegistration property4( customType1, "animPropName2", animatablePropertyIndex, Property::BOOLEAN );
}
catch ( DaliException& e )
{
int propertyIndex2 = PROPERTY_REGISTRATION_START_INDEX + 201;
// Add two properties, one with SetProperty, one without
- PropertyRegistration property1( customType1, "prop-name-readwrite", propertyIndex1, Property::BOOLEAN, &SetProperty, &GetProperty );
- PropertyRegistration property2( customType1, "prop-name-readonly", propertyIndex2, Property::BOOLEAN, NULL, &GetProperty );
+ PropertyRegistration property1( customType1, "propNameReadwrite", propertyIndex1, Property::BOOLEAN, &SetProperty, &GetProperty );
+ PropertyRegistration property2( customType1, "propNameReadonly", propertyIndex2, Property::BOOLEAN, NULL, &GetProperty );
// Create custom-actor
TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
{
TestApplication application;
int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 400;
+ int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 400;
// These properties are not animatable
- PropertyRegistration property1( customType1, "prop-name", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
+ PropertyRegistration property1( customType1, "propName", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
+
+ // These properties are animatable
+ AnimatablePropertyRegistration property2( customType1, "animPropName", animatablePropertyIndex, Property::BOOLEAN );
// Create custom-actor
TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
// Check if animatable
DALI_TEST_CHECK( ! customActor.IsPropertyAnimatable( propertyIndex ) );
+ DALI_TEST_CHECK( customActor.IsPropertyAnimatable( animatablePropertyIndex ) );
+
+ // Create another instance of custom-actor
+ BaseHandle handle2 = typeInfo.CreateInstance();
+ DALI_TEST_CHECK( handle2 );
+ Actor customActor2 = Actor::DownCast( handle2 );
+ DALI_TEST_CHECK( customActor2 );
+
+ // Check if animatable
+ DALI_TEST_CHECK( ! customActor2.IsPropertyAnimatable( propertyIndex ) );
+ DALI_TEST_CHECK( customActor2.IsPropertyAnimatable( animatablePropertyIndex ) );
END_TEST;
}
{
TestApplication application;
int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 2000;
+ int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2000;
// Create custom-actor
TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
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 get an index that hasn't been added
try
{
{
DALI_TEST_ASSERT( e, "! \"Cannot find property index", 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;
}
-
int UtcDaliLongPressGestureDetectorTypeRegistry(void)
{
TestApplication application;
detector.Attach(actor);
// Connect to signal through type
- handle.ConnectSignal( &application, "long-press-detected", functor );
+ handle.ConnectSignal( &application, "longPressDetected", functor );
// Render and notify
application.SendNotification();
detector.Attach(actor);
// Connect to signal through type
- handle.ConnectSignal( &application, "pan-detected", functor );
+ handle.ConnectSignal( &application, "panDetected", functor );
// Render and notify
application.SendNotification();
detector.Attach(actor);
// Connect to signal through type
- handle.ConnectSignal( &application, "pinch-detected", functor );
+ handle.ConnectSignal( &application, "pinchDetected", functor );
// Render and notify
application.SendNotification();
detector.Attach(actor);
// Connect to signal through type
- handle.ConnectSignal( &application, "tap-detected", functor );
+ handle.ConnectSignal( &application, "tapDetected", functor );
// Render and notify
application.SendNotification();
DALI_TEST_CHECK( namedActorPropertyCount > actorPropertyCount );
END_TEST;
}
+
+int UtcDaliTypeInfoGetActionNameP(void)
+{
+ TestApplication application;
+ TypeRegistry typeRegistry = TypeRegistry::Get();
+
+ TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
+ DALI_TEST_CHECK( typeInfo );
+
+ DALI_TEST_CHECK( 0 != typeInfo.GetActionCount() );
+
+ std::string name = typeInfo.GetActionName(0);
+
+ DALI_TEST_EQUALS( name, "show", TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliTypeInfoGetActionNameN(void)
+{
+ TestApplication application;
+ TypeRegistry typeRegistry = TypeRegistry::Get();
+
+ TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
+ DALI_TEST_CHECK( typeInfo );
+
+ DALI_TEST_CHECK( 0 != typeInfo.GetActionCount() );
+
+ std::string name = typeInfo.GetActionName(std::numeric_limits<size_t>::max());
+
+ DALI_TEST_EQUALS( 0u, name.size(), TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliTypeInfoGetSignalNameP(void)
+{
+ TestApplication application;
+ TypeRegistry typeRegistry = TypeRegistry::Get();
+
+ TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
+ DALI_TEST_CHECK( typeInfo );
+
+ DALI_TEST_CHECK( 0 != typeInfo.GetSignalCount() );
+
+ std::string name = typeInfo.GetSignalName(0);
+
+ DALI_TEST_EQUALS( name, "touched", TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliTypeInfoGetSignalNameN(void)
+{
+ TestApplication application;
+ TypeRegistry typeRegistry = TypeRegistry::Get();
+
+ TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
+ DALI_TEST_CHECK( typeInfo );
+
+ DALI_TEST_CHECK( 0 != typeInfo.GetSignalCount() );
+
+ std::string name = typeInfo.GetSignalName(std::numeric_limits<size_t>::max());
+
+ DALI_TEST_EQUALS( 0u, name.size(), TEST_LOCATION );
+
+ END_TEST;
+}