From 1cb64e7df88ab724c9c3955f0ef3f607c91eb3aa Mon Sep 17 00:00:00 2001 From: Adeel Kazmi Date: Mon, 7 Jul 2014 17:12:01 +0100 Subject: [PATCH] (LightActor) Fixed it reporting an incorrect type for one of its properties The enable property reported that it was a Vector2 and then assert when trying to set it as it's actually expecting a bool. Change-Id: I92db4dc28816c2e2b618b8d4b5b01b9612eff2ff Signed-off-by: Adeel Kazmi --- .../src/dali-unmanaged/utc-Dali-LightActor.cpp | 48 ++++++++++++++++++++++ dali/internal/event/actors/light-actor-impl.cpp | 40 +++++++----------- dali/public-api/actors/light-actor.h | 2 +- 3 files changed, 63 insertions(+), 27 deletions(-) diff --git a/automated-tests/src/dali-unmanaged/utc-Dali-LightActor.cpp b/automated-tests/src/dali-unmanaged/utc-Dali-LightActor.cpp index ea9cbe9..ab6da2f 100644 --- a/automated-tests/src/dali-unmanaged/utc-Dali-LightActor.cpp +++ b/automated-tests/src/dali-unmanaged/utc-Dali-LightActor.cpp @@ -303,3 +303,51 @@ int UtcDaliLightActorPropertyIndices(void) DALI_TEST_EQUALS( indices.size(), light.GetPropertyCount(), TEST_LOCATION ); END_TEST; } + +namespace +{ + +struct PropertyDetails +{ + Property::Index index; + std::string name; + Property::Type type; +}; + +const PropertyDetails DEFAULT_LIGHT_ACTOR_PROPERTY_DETAILS[] = +{ + // Index Name Type + { LightActor::LIGHT_TYPE, "light-type", Property::STRING }, + { LightActor::ENABLE, "enable", Property::BOOLEAN }, + { LightActor::FALL_OFF, "fall-off", Property::VECTOR2 }, + { LightActor::SPOT_ANGLE, "spot-angle", Property::VECTOR2 }, + { LightActor::AMBIENT_COLOR, "ambient-color", Property::VECTOR3 }, + { LightActor::DIFFUSE_COLOR, "diffuse-color", Property::VECTOR3 }, + { LightActor::SPECULAR_COLOR, "specular-color", Property::VECTOR3 }, + { LightActor::DIRECTION, "direction", Property::VECTOR3 }, +}; +const int DEFAULT_LIGHT_ACTOR_PROPERTY_COUNT = sizeof( DEFAULT_LIGHT_ACTOR_PROPERTY_DETAILS ) / sizeof( PropertyDetails ); +} // unnamed namespace + +int UtcDaliLightActorProperties(void) +{ + TestApplication application; + Actor basicActor = Actor::New(); + LightActor light = LightActor::New(); + + Property::IndexContainer indices; + light.GetPropertyIndices( indices ); + DALI_TEST_EQUALS( DEFAULT_LIGHT_ACTOR_PROPERTY_COUNT, indices.size() - basicActor.GetPropertyCount(), TEST_LOCATION ); + + for ( int i = 0; i < DEFAULT_LIGHT_ACTOR_PROPERTY_COUNT; ++i ) + { + tet_printf( "Checking: %s\n", DEFAULT_LIGHT_ACTOR_PROPERTY_DETAILS[i].name.c_str() ); + DALI_TEST_EQUALS( light.GetPropertyIndex( DEFAULT_LIGHT_ACTOR_PROPERTY_DETAILS[i].name ), DEFAULT_LIGHT_ACTOR_PROPERTY_DETAILS[i].index, TEST_LOCATION ); + DALI_TEST_EQUALS( light.GetPropertyName( DEFAULT_LIGHT_ACTOR_PROPERTY_DETAILS[i].index ), DEFAULT_LIGHT_ACTOR_PROPERTY_DETAILS[i].name, TEST_LOCATION ); + DALI_TEST_EQUALS( light.GetPropertyType( DEFAULT_LIGHT_ACTOR_PROPERTY_DETAILS[i].index ), DEFAULT_LIGHT_ACTOR_PROPERTY_DETAILS[i].type, TEST_LOCATION ); + DALI_TEST_EQUALS( light.IsPropertyWritable( DEFAULT_LIGHT_ACTOR_PROPERTY_DETAILS[i].index ), true, TEST_LOCATION ); + DALI_TEST_EQUALS( light.IsPropertyAnimatable( DEFAULT_LIGHT_ACTOR_PROPERTY_DETAILS[i].index ), false, TEST_LOCATION ); + DALI_TEST_EQUALS( light.IsPropertyAConstraintInput( DEFAULT_LIGHT_ACTOR_PROPERTY_DETAILS[i].index ), true, TEST_LOCATION ); + } + END_TEST; +} diff --git a/dali/internal/event/actors/light-actor-impl.cpp b/dali/internal/event/actors/light-actor-impl.cpp index 0969dc9..2c5f562 100644 --- a/dali/internal/event/actors/light-actor-impl.cpp +++ b/dali/internal/event/actors/light-actor-impl.cpp @@ -50,31 +50,19 @@ BaseHandle Create() TypeRegistration mType( typeid(Dali::LightActor), typeid(Dali::Actor), Create ); -const std::string DEFAULT_LIGHT_ACTOR_PROPERTY_NAMES[] = +const Internal::PropertyDetails DEFAULT_LIGHT_ACTOR_PROPERTY_DETAILS[] = { - "light-type", - "enable", - "fall-off", - "spot-angle", - "ambient-color", - "diffuse-color", - "specular-color", - "direction" + // Name Type writable animatable constraint-input + { "light-type", Property::STRING, true, false, true }, // LIGHT_TYPE + { "enable", Property::BOOLEAN, true, false, true }, // ENABLE + { "fall-off", Property::VECTOR2, true, false, true }, // FALL_OFF + { "spot-angle", Property::VECTOR2, true, false, true }, // SPOT_ANGLE + { "ambient-color", Property::VECTOR3, true, false, true }, // AMBIENT_COLOR + { "diffuse-color", Property::VECTOR3, true, false, true }, // DIFFUSE_COLOR + { "specular-color", Property::VECTOR3, true, false, true }, // SPECULAR_COLOR + { "direction", Property::VECTOR3, true, false, true }, // DIRECTION }; -const int DEFAULT_LIGHT_ACTOR_PROPERTY_COUNT = sizeof( DEFAULT_LIGHT_ACTOR_PROPERTY_NAMES ) / sizeof( std::string ); - -const Property::Type DEFAULT_LIGHT_ACTOR_PROPERTY_TYPES[DEFAULT_LIGHT_ACTOR_PROPERTY_COUNT] = -{ - Property::STRING, // "light-type", - Property::VECTOR2, // "enable", - Property::VECTOR2, // "fall-off", - Property::VECTOR2, // "spot-angle", - Property::VECTOR3, // "ambient-color", - Property::VECTOR3, // "diffuse-color", - Property::VECTOR3, // "specular-color", - Property::VECTOR3, // "direction", -}; - +const int DEFAULT_LIGHT_ACTOR_PROPERTY_COUNT = sizeof( DEFAULT_LIGHT_ACTOR_PROPERTY_DETAILS ) / sizeof( Internal::PropertyDetails ); LightType LightTypeEnum(const std::string &stringValue) { @@ -164,7 +152,7 @@ void LightActor::OnInitialize() const int start = DEFAULT_ACTOR_PROPERTY_MAX_COUNT; for ( int i = 0; i < DEFAULT_LIGHT_ACTOR_PROPERTY_COUNT; ++i ) { - (*mDefaultLightActorPropertyLookup)[DEFAULT_LIGHT_ACTOR_PROPERTY_NAMES[i]] = i + start; + (*mDefaultLightActorPropertyLookup)[DEFAULT_LIGHT_ACTOR_PROPERTY_DETAILS[i].name] = i + start; } LightActor::mFirstInstance = false ; } @@ -267,7 +255,7 @@ Property::Type LightActor::GetDefaultPropertyType( Property::Index index ) const if ( ( index >= 0 ) && ( index < DEFAULT_LIGHT_ACTOR_PROPERTY_COUNT ) ) { - return DEFAULT_LIGHT_ACTOR_PROPERTY_TYPES[index]; + return DEFAULT_LIGHT_ACTOR_PROPERTY_DETAILS[index].type; } else { @@ -289,7 +277,7 @@ const std::string& LightActor::GetDefaultPropertyName( Property::Index index ) c if ( ( index >= 0 ) && ( index < DEFAULT_LIGHT_ACTOR_PROPERTY_COUNT ) ) { - return DEFAULT_LIGHT_ACTOR_PROPERTY_NAMES[index]; + return DEFAULT_LIGHT_ACTOR_PROPERTY_DETAILS[index].name; } else { diff --git a/dali/public-api/actors/light-actor.h b/dali/public-api/actors/light-actor.h index a057a78..4264c96 100644 --- a/dali/public-api/actors/light-actor.h +++ b/dali/public-api/actors/light-actor.h @@ -43,7 +43,7 @@ public: // Default Properties additional to Actor static const Property::Index LIGHT_TYPE; ///< name "light-type", type STRING - static const Property::Index ENABLE; ///< name "enable", type VECTOR2 + static const Property::Index ENABLE; ///< name "enable", type BOOLEAN static const Property::Index FALL_OFF; ///< name "fall-off", type VECTOR2 static const Property::Index SPOT_ANGLE; ///< name "spot-angle", type VECTOR2 static const Property::Index AMBIENT_COLOR; ///< name "ambient-color", type VECTOR3 -- 2.7.4