X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali%2Futc-Dali-Handle.cpp;h=cf49f4a40da6e0f291be241ebd67fd79f3168425;hb=44ee0cc4fac620903fdf198867f645a2d5dbf075;hp=858742025237448e44c76e1a60f6a6e4d6cfbda2;hpb=9d3d4965d110517e962a608ec6413612a9e57ccc;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/automated-tests/src/dali/utc-Dali-Handle.cpp b/automated-tests/src/dali/utc-Dali-Handle.cpp index 8587420..cf49f4a 100644 --- a/automated-tests/src/dali/utc-Dali-Handle.cpp +++ b/automated-tests/src/dali/utc-Dali-Handle.cpp @@ -36,6 +36,15 @@ void handle_test_cleanup(void) namespace { +/// Allows the creation of a BaseObject +class BaseObjectType : public BaseObject +{ +public: + BaseObjectType() + { + } +}; + Handle ImplicitCopyConstructor(Handle passedByValue) { // object + copy + passedByValue, ref count == 3 @@ -405,12 +414,13 @@ int UtcDaliHandleIsPropertyAConstraintInput(void) 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; } @@ -435,6 +445,7 @@ int UtcDaliHandleGetPropertyType(void) // Register some dynamic properties Property::Index boolIndex = actor.RegisterProperty( "bool-property", bool(true) ); Property::Index floatIndex = actor.RegisterProperty( "float-property", float(123.0f) ); + Property::Index intIndex = actor.RegisterProperty( "int-property", 123 ); Property::Index vector2Index = actor.RegisterProperty( "vector2-property", Vector2(1.0f, 2.0f) ); Property::Index vector3Index = actor.RegisterProperty( "vector3-property", Vector3(1.0f, 2.0f, 3.0f) ); Property::Index vector4Index = actor.RegisterProperty( "vector4-property", Vector4(1.0f, 2.0f, 3.0f, 4.0f) ); @@ -442,6 +453,7 @@ int UtcDaliHandleGetPropertyType(void) DALI_TEST_CHECK( Property::BOOLEAN == actor.GetPropertyType( boolIndex ) ); DALI_TEST_CHECK( Property::FLOAT == actor.GetPropertyType( floatIndex ) ); + DALI_TEST_CHECK( Property::INTEGER == actor.GetPropertyType( intIndex ) ); DALI_TEST_CHECK( Property::VECTOR2 == actor.GetPropertyType( vector2Index ) ); DALI_TEST_CHECK( Property::VECTOR3 == actor.GetPropertyType( vector3Index ) ); DALI_TEST_CHECK( Property::VECTOR4 == actor.GetPropertyType( vector4Index ) ); @@ -454,6 +466,7 @@ int UtcDaliHandleGetPropertyType(void) Property::Index nonAnimV4Index = actor.RegisterProperty( "v4", Vector4(1.f, 2.f, 3.f, 4.f), Property::READ_WRITE); Property::Index nonAnimBooleanIndex = actor.RegisterProperty( "bool", true, Property::READ_WRITE); Property::Index nonAnimFloatIndex = actor.RegisterProperty( "float", 0.f, Property::READ_WRITE); + Property::Index nonAnimIntegerIndex = actor.RegisterProperty( "int", 0, Property::READ_WRITE); Property::Index nonAnimUnsignedIntIndex = actor.RegisterProperty( "unsinged-int", unsingedIntTest, Property::READ_WRITE); DALI_TEST_CHECK( nonAnimStringIndex != Property::INVALID_INDEX ); @@ -462,6 +475,7 @@ int UtcDaliHandleGetPropertyType(void) DALI_TEST_CHECK( nonAnimV4Index != Property::INVALID_INDEX ); DALI_TEST_CHECK( nonAnimBooleanIndex != Property::INVALID_INDEX ); DALI_TEST_CHECK( nonAnimFloatIndex != Property::INVALID_INDEX ); + DALI_TEST_CHECK( nonAnimIntegerIndex != Property::INVALID_INDEX ); DALI_TEST_CHECK( nonAnimUnsignedIntIndex != Property::INVALID_INDEX ); DALI_TEST_CHECK( Property::STRING == actor.GetPropertyType( nonAnimStringIndex ) ); @@ -470,6 +484,7 @@ int UtcDaliHandleGetPropertyType(void) DALI_TEST_CHECK( Property::VECTOR4 == actor.GetPropertyType( nonAnimV4Index ) ); DALI_TEST_CHECK( Property::BOOLEAN == actor.GetPropertyType( nonAnimBooleanIndex ) ); DALI_TEST_CHECK( Property::FLOAT == actor.GetPropertyType( nonAnimFloatIndex ) ); + DALI_TEST_CHECK( Property::INTEGER == actor.GetPropertyType( nonAnimIntegerIndex ) ); DALI_TEST_CHECK( Property::UNSIGNED_INTEGER == actor.GetPropertyType( nonAnimUnsignedIntIndex ) ); DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimStringIndex ) ); @@ -478,6 +493,7 @@ int UtcDaliHandleGetPropertyType(void) DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimV4Index ) ); DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimBooleanIndex ) ); DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimFloatIndex ) ); + DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimIntegerIndex ) ); DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimUnsignedIntIndex ) ); DALI_TEST_EQUALS( "yes" , actor.GetProperty( nonAnimStringIndex ).Get(), TEST_LOCATION ); @@ -486,6 +502,7 @@ int UtcDaliHandleGetPropertyType(void) DALI_TEST_EQUALS( Vector4(1.f, 2.f, 3.f, 4.f) , actor.GetProperty( nonAnimV4Index ).Get(), TEST_LOCATION ); DALI_TEST_EQUALS( true, actor.GetProperty( nonAnimBooleanIndex ).Get(), TEST_LOCATION ); DALI_TEST_EQUALS( 0.f, actor.GetProperty( nonAnimFloatIndex ).Get(), TEST_LOCATION ); + DALI_TEST_EQUALS( 0, actor.GetProperty( nonAnimIntegerIndex ).Get(), TEST_LOCATION ); DALI_TEST_EQUALS( unsingedIntTest, actor.GetProperty( nonAnimUnsignedIntIndex ).Get(), TEST_LOCATION ); END_TEST; @@ -528,7 +545,7 @@ int UtcDaliHandleNonAnimtableProperties(void) 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(), TEST_LOCATION ); @@ -615,7 +632,7 @@ int UtcDaliHandleNonAnimtableCompositeProperties(void) 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); @@ -627,8 +644,8 @@ int UtcDaliHandleNonAnimtableCompositeProperties(void) valueMap.SetItem(0, Property::Value("a string")); valueMap.SetItem(1, Property::Value(5.f)); - DALI_TEST_EQUALS( 5.f, valueMap.GetValue("2key").Get(), TEST_LOCATION); - DALI_TEST_EQUALS( "a string", valueMap.GetValue("key").Get(), TEST_LOCATION); + DALI_TEST_EQUALS( 5.f, valueMap.GetValue("2key").Get(), TEST_LOCATION); + DALI_TEST_EQUALS( "a string", valueMap.GetValue("key").Get(), TEST_LOCATION); // ordered map valueMap = Property::Value(Property::MAP); @@ -650,7 +667,7 @@ int UtcDaliHandleNonAnimtableCompositeProperties(void) 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); @@ -708,16 +725,8 @@ int UtcDaliHandleSetProperty02(void) 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; } @@ -772,6 +781,22 @@ int UtcDaliHandleDownCast(void) 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; @@ -948,7 +973,7 @@ int UtcDaliHandleGetPropertyGet(void) 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; } @@ -965,3 +990,82 @@ int UtcDaliHandleGetPropertyIndices(void) 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(), 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(index) == startValue ); + + application.SendNotification(); + application.Render(0); + DALI_TEST_CHECK( handle.GetProperty(index) == startValue ); + application.Render(0); + DALI_TEST_CHECK( handle.GetProperty(index) == startValue ); + + handle.SetProperty( index, 5.0f ); + + application.SendNotification(); + application.Render(0); + DALI_TEST_CHECK( handle.GetProperty(index) == 5.0f ); + application.Render(0); + DALI_TEST_CHECK( handle.GetProperty(index) == 5.0f ); + END_TEST; +}