Ensure Animatable component properties can be animated 79/145779/3
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Wed, 23 Aug 2017 18:35:47 +0000 (19:35 +0100)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Thu, 24 Aug 2017 09:50:39 +0000 (09:50 +0000)
Before this patch, when we tried to animate a component of a registered animatable property, there would be an assert.

Change-Id: I4abd6627c340c513154a351bce8c36a83038a8f4

automated-tests/src/dali/utc-Dali-TypeRegistry.cpp
dali/internal/event/common/type-info-impl.cpp

index f184936..feabd0e 100644 (file)
@@ -1429,6 +1429,16 @@ int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationP(void)
   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;
 }
 
index c8dadae..e3f8d79 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -715,7 +715,15 @@ Property::Type TypeInfo::GetPropertyType( Property::Index index ) const
 
   if ( iter != mRegisteredProperties.end() )
   {
-    type = iter->second.type;
+    if( iter->second.componentIndex == Property::INVALID_COMPONENT_INDEX )
+    {
+      type = iter->second.type;
+    }
+    else
+    {
+      // If component index is set, then we should return FLOAT
+      type = Property::FLOAT;
+    }
   }
   else
   {