namespace
{
+/// Allows the creation of a BaseObject
+class BaseObjectType : public BaseObject
+{
+public:
+ BaseObjectType()
+ {
+ }
+};
+
Handle ImplicitCopyConstructor(Handle passedByValue)
{
// object + copy + passedByValue, ref count == 3
DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::NAME ) );
DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::SENSITIVE ) );
DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::LEAVE_REQUIRED ) );
- DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::INHERIT_SHADER_EFFECT ) );
DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::INHERIT_ROTATION ) );
DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::INHERIT_SCALE ) );
DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::COLOR_MODE ) );
DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::POSITION_INHERITANCE ) );
DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::DRAW_MODE ) );
+ DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::SIZE_MODE ) );
+ DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::SIZE_MODE_FACTOR ) );
END_TEST;
}
exception = true;
}
- DALI_TEST_CHECK(exception);
+ DALI_TEST_CHECK(!exception);// trying to set a read-only property is a no-op
DALI_TEST_EQUALS( 0.f, actor.GetProperty( readonly ).Get<float>(), TEST_LOCATION );
valueMap.SetValue("key", 5.f);
valueMap.SetValue("2key", "a string");
- DALI_TEST_EQUALS( true, valueMap.HasKey("key"), TEST_LOCATION);
+ DALI_TEST_EQUALS( true, valueMap.HasKey("key"), TEST_LOCATION);
DALI_TEST_EQUALS( "key", valueMap.GetKey(0), TEST_LOCATION);
DALI_TEST_EQUALS( true, valueMap.HasKey("2key"), TEST_LOCATION);
valueMap.SetItem(0, Property::Value("a string"));
valueMap.SetItem(1, Property::Value(5.f));
- DALI_TEST_EQUALS( 5.f, valueMap.GetValue("2key").Get<float>(), TEST_LOCATION);
- DALI_TEST_EQUALS( "a string", valueMap.GetValue("key").Get<std::string>(), TEST_LOCATION);
+ DALI_TEST_EQUALS( 5.f, valueMap.GetValue("2key").Get<float>(), TEST_LOCATION);
+ DALI_TEST_EQUALS( "a string", valueMap.GetValue("key").Get<std::string>(), TEST_LOCATION);
// ordered map
valueMap = Property::Value(Property::MAP);
catch (Dali::DaliException& e)
{
exception = true;
- tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
+ DALI_TEST_PRINT_ASSERT( e );
}
DALI_TEST_EQUALS(exception, true, TEST_LOCATION);
DALI_TEST_CHECK( !actor.IsPropertyWritable( Actor::WORLD_POSITION ) );
- try
- {
- // World position is not writable
- actor.SetProperty( Actor::WORLD_POSITION, Vector3(1,2,3) );
- }
- catch (Dali::DaliException& e)
- {
- tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
- DALI_TEST_ASSERT(e, "IsDefaultPropertyWritable(index) && \"Property is read-only\"", TEST_LOCATION);
- }
+ // World position is not writable so this is a no-op and should not crash
+ actor.SetProperty( Actor::WORLD_POSITION, Vector3(1,2,3) );
END_TEST;
}
END_TEST;
}
+int UtcDaliHandleDownCastNegative(void)
+{
+ TestApplication application;
+
+ // BaseObject is NOT an Object, so this DownCast should fail
+ BaseHandle handle( new BaseObjectType );
+ Handle customHandle1 = Handle::DownCast( handle );
+ DALI_TEST_CHECK( ! customHandle1 );
+
+ // A DownCast on an empty handle will also fail
+ Handle empty;
+ Handle customHandle2 = Handle::DownCast( empty );
+ DALI_TEST_CHECK( ! customHandle2 );
+ END_TEST;
+}
+
int UtcDaliHandleCreateProperty(void)
{
TestApplication application;
value = Property::Value(Property::MAP);
value.SetValue("key", "value");
value.Get(map);
- DALI_TEST_CHECK( map[0].first == "key" );
+ DALI_TEST_CHECK( map.GetKey(0) == "key" );
END_TEST;
}
DALI_TEST_EQUALS( indices.size(), actor.GetPropertyCount(), TEST_LOCATION );
END_TEST;
}
+
+int UtcDaliHandleRegisterPropertyTypes(void)
+{
+ TestApplication application;
+
+ struct PropertyTypeAnimatable
+ {
+ const char * name;
+ Property::Value value;
+ bool animatable;
+ };
+
+ Property::Array array;
+ Property::Map map;
+
+ PropertyTypeAnimatable properties[] =
+ {
+ { "Property::BOOLEAN", true, true },
+ { "Property::FLOAT", 1.0f, true },
+ { "Property::INTEGER", 1, true },
+ { "Property::UNSIGNED_INTEGER", 1u, false },
+ { "Property::VECTOR2", Vector2::ONE, true },
+ { "Property::VECTOR3", Vector3::ONE, true },
+ { "Property::VECTOR4", Vector4::ONE, true },
+ { "Property::MATRIX3", Matrix3::IDENTITY, true },
+ { "Property::MATRIX", Matrix::IDENTITY, true },
+ { "Property::RECTANGLE", Rect<int>(), false },
+ { "Property::ROTATION", AngleAxis(), true },
+ { "Property::STRING", std::string("Me"), false },
+ { "Property::ARRAY", array, false },
+ { "Property::MAP", map, false },
+ };
+ unsigned int numOfProperties( sizeof( properties ) / sizeof( properties[0] ) );
+
+ for ( unsigned int i = 0; i < numOfProperties; ++i )
+ {
+ tet_printf( "Testing: %s\n", properties[i].name );
+
+ bool exception = false;
+ try
+ {
+ Actor actor = Actor::New();
+ actor.RegisterProperty( "man-from-delmonte", properties[i].value );
+ }
+ catch (Dali::DaliException& e)
+ {
+ exception = true;
+ }
+
+ DALI_TEST_CHECK( properties[i].animatable != exception );
+ }
+ END_TEST;
+}
+
+int UtcDaliHandleCustomProperty(void)
+{
+ TestApplication application;
+
+ Handle handle = Handle::New();
+
+ float startValue(1.0f);
+ Property::Index index = handle.RegisterProperty( "test-property", startValue );
+ DALI_TEST_CHECK( handle.GetProperty<float>(index) == startValue );
+
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_CHECK( handle.GetProperty<float>(index) == startValue );
+ application.Render(0);
+ DALI_TEST_CHECK( handle.GetProperty<float>(index) == startValue );
+
+ handle.SetProperty( index, 5.0f );
+
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_CHECK( handle.GetProperty<float>(index) == 5.0f );
+ application.Render(0);
+ DALI_TEST_CHECK( handle.GetProperty<float>(index) == 5.0f );
+ END_TEST;
+}