X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali%2Futc-Dali-Handle.cpp;h=19e04f680c159cd70b85fb9c25ed44b921d83fef;hb=cdee4f2b3bab6234e43d04aa93df3802d3dc73ba;hp=6727ae15d5b4ab04cd0b7bd83d87fe2da0478e1a;hpb=6e7f48188a239b060512231cc6acbe821c703caa;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 6727ae1..19e04f6 100644 --- a/automated-tests/src/dali/utc-Dali-Handle.cpp +++ b/automated-tests/src/dali/utc-Dali-Handle.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 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. @@ -19,6 +19,8 @@ #include #include +#include +#include #include "dali-test-suite-utils/dali-test-suite-utils.h" #include @@ -150,7 +152,7 @@ int UtcDaliHandleGetPropertyCount(void) int defaultPropertyCount( actor.GetPropertyCount() ); // Register a dynamic property - actor.RegisterProperty( "test-property", float(123.0f) ); + actor.RegisterProperty( "testProperty", float(123.0f) ); DALI_TEST_CHECK( (defaultPropertyCount + 1u) == actor.GetPropertyCount() ); END_TEST; } @@ -161,31 +163,106 @@ int UtcDaliHandleGetPropertyName(void) TestApplication application; Actor actor = Actor::New(); - DALI_TEST_CHECK( "parent-origin" == actor.GetPropertyName( Actor::Property::PARENT_ORIGIN ) ); + DALI_TEST_CHECK( "parentOrigin" == actor.GetPropertyName( Actor::Property::PARENT_ORIGIN ) ); // Register a dynamic property - std::string name("this-name-should-match"); + std::string name("thisNameShouldMatch"); Property::Index index = actor.RegisterProperty( name, float(123.0f) ); DALI_TEST_CHECK( name == actor.GetPropertyName( index ) ); END_TEST; } -int UtcDaliHandleGetPropertyIndex(void) +int UtcDaliHandleGetPropertyIndex01(void) { tet_infoline("Positive Test Dali::Handle::GetPropertyIndex()"); TestApplication application; Actor actor = Actor::New(); - DALI_TEST_CHECK( Actor::Property::PARENT_ORIGIN == actor.GetPropertyIndex("parent-origin") ); + DALI_TEST_CHECK( Actor::Property::PARENT_ORIGIN == actor.GetPropertyIndex("parentOrigin") ); // Register a dynamic property - std::string name("this-name-should-match"); + std::string name("thisNameShouldMatch"); Property::Index index = actor.RegisterProperty( name, float(123.0f) ); DALI_TEST_CHECK( index == actor.GetPropertyIndex( name ) ); END_TEST; } +int UtcDaliHandleGetPropertyIndex02(void) +{ + tet_infoline("Positive Test Dali::Handle::GetPropertyIndex() int key"); + TestApplication application; + + Stage stage = Stage::GetCurrent(); + + Actor actor = Actor::New(); + stage.Add( actor ); + + const unsigned int defaultPropertyCount = actor.GetPropertyCount(); + + application.SendNotification(); + application.Render(); + + Property::Index key1 = CORE_PROPERTY_MAX_INDEX+1; + Property::Index key2 = CORE_PROPERTY_MAX_INDEX+2; + + const Vector4 testColor(0.5f, 0.2f, 0.9f, 1.0f); + const float withFlake(99.f); + + Property::Index index1 = actor.RegisterProperty( "MyPropertyOne", Vector3::ONE ); + Property::Index index2 = DevelHandle::RegisterProperty( actor, key1, "sideColor", testColor); + Property::Index index3 = actor.RegisterProperty( "MyPropertyTwo", Vector3::ONE ); + Property::Index index4 = DevelHandle::RegisterProperty( actor, key2, "iceCream", withFlake ); + Property::Index index5 = actor.RegisterProperty( "MyPropertyThree", Vector3::ONE ); + + application.SendNotification(); + application.Render(); + + // Test that we can get the property index from the integer key + Property::Index testIndex1 = DevelHandle::GetPropertyIndex( actor, key1 ); + Property::Index testIndex2 = DevelHandle::GetPropertyIndex( actor, key2 ); + + DALI_TEST_EQUALS( index2, testIndex1, TEST_LOCATION ); + DALI_TEST_EQUALS( index4, testIndex2, TEST_LOCATION ); + + // Test that we keep the same indices on the named properties + Property::Index testIndex = actor.GetPropertyIndex("MyPropertyOne"); + DALI_TEST_EQUALS(testIndex, index1, TEST_LOCATION); + testIndex = actor.GetPropertyIndex("MyPropertyTwo"); + DALI_TEST_EQUALS(testIndex, index3, TEST_LOCATION); + testIndex = actor.GetPropertyIndex("MyPropertyThree"); + DALI_TEST_EQUALS(testIndex, index5, TEST_LOCATION); + testIndex = actor.GetPropertyIndex("sideColor"); + DALI_TEST_EQUALS(testIndex, index2, TEST_LOCATION); + testIndex = actor.GetPropertyIndex("iceCream"); + DALI_TEST_EQUALS(testIndex, index4, TEST_LOCATION); + + DALI_TEST_EQUALS(defaultPropertyCount+5, actor.GetPropertyCount(), TEST_LOCATION); + END_TEST; +} + +int UtcDaliHandleGetPropertyIndex03(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + std::string myName("croydon"); + Property::Index intKey = CORE_PROPERTY_MAX_INDEX+1; + Property::Value value( Color::GREEN ); + Property::Index myIndex = DevelHandle::RegisterProperty( actor, intKey, myName, value ); + + DALI_TEST_EQUALS( myIndex, DevelHandle::GetPropertyIndex( actor, intKey ), TEST_LOCATION ); + + Property::Key key1(myName); + Property::Key key2(intKey); + + DALI_TEST_EQUALS( myIndex, DevelHandle::GetPropertyIndex( actor, key1 ), TEST_LOCATION ); + DALI_TEST_EQUALS( myIndex, DevelHandle::GetPropertyIndex( actor, key2 ), TEST_LOCATION ); + END_TEST; +} + + int UtcDaliHandleIsPropertyWritable(void) { tet_infoline("Positive Test Dali::Handle::IsPropertyWritable()"); @@ -221,6 +298,7 @@ int UtcDaliHandleIsPropertyWritable(void) DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::COLOR_GREEN ) ); DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::COLOR_BLUE ) ); DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::COLOR_ALPHA ) ); + DALI_TEST_CHECK( true == actor.IsPropertyWritable( DevelActor::Property::OPACITY ) ); // World-properties are not writable: DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::Property::WORLD_POSITION ) ); @@ -269,6 +347,7 @@ int UtcDaliHandleIsPropertyAnimatable(void) DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::COLOR_GREEN ) ); DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::COLOR_BLUE ) ); DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::COLOR_ALPHA ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( DevelActor::Property::OPACITY ) ); // World-properties can not be animated DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::WORLD_POSITION ) ); @@ -316,6 +395,7 @@ int UtcDaliHandleIsPropertyAConstraintInput(void) DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::COLOR_GREEN ) ); DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::COLOR_BLUE ) ); DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::COLOR_ALPHA ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( DevelActor::Property::OPACITY ) ); DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::WORLD_POSITION ) ); DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::WORLD_ORIENTATION ) ); DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::WORLD_SCALE ) ); @@ -343,7 +423,6 @@ int UtcDaliHandleGetPropertyType(void) { tet_infoline("Positive Test Dali::Handle::GetPropertyType()"); TestApplication application; - unsigned int unsingedIntTest = 33; Actor actor = Actor::New(); DALI_TEST_CHECK( Property::VECTOR3 == actor.GetPropertyType( Actor::Property::PARENT_ORIGIN ) ); @@ -356,33 +435,30 @@ int UtcDaliHandleGetPropertyType(void) DALI_TEST_CHECK( Property::VECTOR4 == actor.GetPropertyType( Actor::Property::COLOR ) ); // 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 unsignedIntIndex = actor.RegisterProperty( "unsigned-int-property", 456u ); - 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) ); - Property::Index rotationIndex = actor.RegisterProperty( "rotation-property", AngleAxis(Degree(180.0f), Vector3::YAXIS) ); + Property::Index boolIndex = actor.RegisterProperty( "boolProperty", bool(true) ); + Property::Index floatIndex = actor.RegisterProperty( "floatProperty", float(123.0f) ); + Property::Index intIndex = actor.RegisterProperty( "intProperty", 123 ); + Property::Index vector2Index = actor.RegisterProperty( "vector2Property", Vector2(1.0f, 2.0f) ); + Property::Index vector3Index = actor.RegisterProperty( "vector3Property", Vector3(1.0f, 2.0f, 3.0f) ); + Property::Index vector4Index = actor.RegisterProperty( "vector4Property", Vector4(1.0f, 2.0f, 3.0f, 4.0f) ); + Property::Index rotationIndex = actor.RegisterProperty( "rotationProperty", AngleAxis(Degree(180.0f), Vector3::YAXIS) ); 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::UNSIGNED_INTEGER == actor.GetPropertyType( unsignedIntIndex ) ); DALI_TEST_CHECK( Property::VECTOR2 == actor.GetPropertyType( vector2Index ) ); DALI_TEST_CHECK( Property::VECTOR3 == actor.GetPropertyType( vector3Index ) ); DALI_TEST_CHECK( Property::VECTOR4 == actor.GetPropertyType( vector4Index ) ); DALI_TEST_CHECK( Property::ROTATION == actor.GetPropertyType( rotationIndex ) ); // Non animatable properties - Property::Index nonAnimStringIndex = actor.RegisterProperty( "man-from-delmonte", std::string("yes"), Property::READ_WRITE); + Property::Index nonAnimStringIndex = actor.RegisterProperty( "manFromDelmonte", std::string("yes"), Property::READ_WRITE); Property::Index nonAnimV2Index = actor.RegisterProperty( "v2", Vector2(1.f, 2.f), Property::READ_WRITE); Property::Index nonAnimV3Index = actor.RegisterProperty( "v3", Vector3(1.f, 2.f, 3.f), Property::READ_WRITE); 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 ); DALI_TEST_CHECK( nonAnimV2Index != Property::INVALID_INDEX ); @@ -391,7 +467,6 @@ int UtcDaliHandleGetPropertyType(void) 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 ) ); DALI_TEST_CHECK( Property::VECTOR2 == actor.GetPropertyType( nonAnimV2Index ) ); @@ -400,7 +475,6 @@ int UtcDaliHandleGetPropertyType(void) 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 ) ); DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimV2Index ) ); @@ -409,7 +483,6 @@ int UtcDaliHandleGetPropertyType(void) 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 ); DALI_TEST_EQUALS( Vector2(1.f, 2.f) , actor.GetProperty( nonAnimV2Index ).Get(), TEST_LOCATION ); @@ -418,29 +491,21 @@ int UtcDaliHandleGetPropertyType(void) 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; } -int UtcDaliHandleNonAnimtableProperties(void) +int UtcDaliHandleNonAnimatableProperties(void) { tet_infoline("Test Non Animatable Properties"); TestApplication application; Actor actor = Actor::New(); - Property::Index nonAnimStringIndex = actor.RegisterProperty( "man-from-delmonte", std::string("no"), Property::READ_WRITE); + Property::Index nonAnimStringIndex = actor.RegisterProperty( "manFromDelmonte", std::string("no"), Property::READ_WRITE); //// modify writable? - try - { - actor.SetProperty( nonAnimStringIndex, Property::Value("yes") ); - } - catch (Dali::DaliException& e) - { - DALI_TEST_CHECK(!"exception"); - } + actor.SetProperty( nonAnimStringIndex, Property::Value("yes") ); DALI_TEST_CHECK( "yes" == actor.GetProperty( nonAnimStringIndex ).Get() ); @@ -450,17 +515,8 @@ int UtcDaliHandleNonAnimtableProperties(void) DALI_TEST_CHECK(!actor.IsPropertyAnimatable(readonly)); DALI_TEST_CHECK(!actor.IsPropertyWritable(readonly)); - bool exception = false; - try - { - actor.SetProperty( readonly, Property::Value(1.f) ); - } - catch (Dali::DaliException& e) - { - exception = true; - } - - DALI_TEST_CHECK(!exception);// trying to set a read-only property is a no-op + actor.SetProperty( readonly, Property::Value(1.f) ); + // trying to set a read-only property is a no-op DALI_TEST_EQUALS( 0.f, actor.GetProperty( readonly ).Get(), TEST_LOCATION ); @@ -470,38 +526,21 @@ int UtcDaliHandleNonAnimtableProperties(void) DALI_TEST_CHECK(actor.IsPropertyAnimatable(write_anim)); DALI_TEST_CHECK(actor.IsPropertyWritable(write_anim)); - exception = false; - try - { - actor.SetProperty( write_anim, Property::Value(1.f) ); - } - catch (Dali::DaliException& e) - { - exception = true; - } + actor.SetProperty( write_anim, Property::Value(1.f) ); - DALI_TEST_CHECK(!exception); - - //// animate a non animatable property is a noop? + //// animate a non animatable property throws float durationSeconds(2.0f); Animation animation = Animation::New(durationSeconds); bool relativeValue(true); - - exception = false; - try { animation.AnimateBy(Property(actor, nonAnimStringIndex), relativeValue, AlphaFunction::EASE_IN); - animation.Play(); - application.SendNotification(); - application.Render(static_cast(durationSeconds*0100.0f)/* some progress */); } - catch (Dali::DaliException& e) + catch ( Dali::DaliException& e ) { - exception = true; + DALI_TEST_ASSERT( e, "Animated value and Property type don't match", TEST_LOCATION ); } - DALI_TEST_CHECK(!exception); DALI_TEST_EQUALS( "yes", actor.GetProperty( nonAnimStringIndex ).Get(), TEST_LOCATION ); END_TEST; @@ -522,7 +561,7 @@ int UtcDaliHandleNonAnimtableCompositeProperties(void) array->PushBack( "a string" ); array->PushBack( Property::Value( Vector3(1,2,3) ) ); - DALI_TEST_EQUALS( 3, array->Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( 3u, array->Count(), TEST_LOCATION ); Property::Index propertyIndex = actor.RegisterProperty( "composite", value, Property::READ_WRITE ); @@ -600,17 +639,93 @@ int UtcDaliHandleSetProperty02(void) END_TEST; } -int UtcDaliHandleRegisterProperty(void) +int UtcDaliHandleRegisterProperty01(void) { tet_infoline("Positive Test Dali::Handle::RegisterProperty()"); TestApplication application; + Stage stage = Stage::GetCurrent(); + Actor actor = Actor::New(); - DALI_TEST_CHECK( ParentOrigin::TOP_LEFT == actor.GetProperty( Actor::Property::PARENT_ORIGIN ).Get() ); + stage.Add( actor ); + + const unsigned int defaultPropertyCount = actor.GetPropertyCount(); + + application.SendNotification(); + application.Render(); + + Property::Index index1 = actor.RegisterProperty( "MyProperty", Vector3::ONE ); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( actor.GetPropertyCount(), defaultPropertyCount + 1, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( index1 ), Vector3::ONE, TEST_LOCATION ); + + // No new property should be registered when we call the below function + Property::Index index2 = actor.RegisterProperty( "MyProperty", Vector3::ZAXIS ); + + application.SendNotification(); + application.Render(); + + + DALI_TEST_EQUALS( index1, index2, TEST_LOCATION ); // We should have the same index as per the first registration + DALI_TEST_EQUALS( actor.GetPropertyCount(), defaultPropertyCount + 1, TEST_LOCATION ); // Property count should be the same + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( index2 ), Vector3::ZAXIS, TEST_LOCATION ); // Value should be what we sent on second RegisterProperty call END_TEST; } +int UtcDaliHandleRegisterProperty02(void) +{ + tet_infoline("Positive Test Dali::Handle::RegisterProperty() int key"); + TestApplication application; + + Stage stage = Stage::GetCurrent(); + + Actor actor = Actor::New(); + stage.Add( actor ); + + const unsigned int defaultPropertyCount = actor.GetPropertyCount(); + + application.SendNotification(); + application.Render(); + + Property::Index key1 = CORE_PROPERTY_MAX_INDEX+1; + Property::Index key2 = CORE_PROPERTY_MAX_INDEX+2; + + const Vector4 testColor(0.5f, 0.2f, 0.9f, 1.0f); + const float withFlake(99.f); + + Property::Index index1 = actor.RegisterProperty( "MyPropertyOne", Vector3::ONE ); + Property::Index index2 = DevelHandle::RegisterProperty( actor, key1, "sideColor", testColor); + Property::Index index3 = DevelHandle::RegisterProperty( actor, key2, "iceCream", withFlake ); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( actor.GetPropertyCount(), defaultPropertyCount + 3, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( index1 ), Vector3::ONE, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( index2 ), testColor, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty< float >( index3 ), withFlake, TEST_LOCATION ); + + // No new property should be registered when we call the below functions + Property::Index testIndex2 = actor.RegisterProperty( "iceCream", 2200.f ); + Property::Index testIndex1 = actor.RegisterProperty( "sideColor", Color::BLACK ); + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( index2, testIndex1, TEST_LOCATION ); // We should have the same index as per the first registration + DALI_TEST_EQUALS( index3, testIndex2, TEST_LOCATION ); // We should have the same index as per the first registration + DALI_TEST_EQUALS( actor.GetPropertyCount(), defaultPropertyCount + 3, TEST_LOCATION ); // Property count should be the same + DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( index2 ), Color::BLACK, TEST_LOCATION ); // Value should be what we sent on second RegisterProperty call + DALI_TEST_EQUALS( actor.GetProperty< float >( index3 ), 2200.f, TEST_LOCATION ); + + END_TEST; +} + + + int UtcDaliHandleGetProperty(void) { tet_infoline("Positive Test Dali::Handle::GetProperty()"); @@ -674,8 +789,27 @@ int UtcDaliHandleGetPropertyIndices(void) // Actor Actor actor = Actor::New(); actor.GetPropertyIndices( indices ); - DALI_TEST_CHECK( indices.Size() ); - DALI_TEST_EQUALS( indices.Size(), actor.GetPropertyCount(), TEST_LOCATION ); + int numDefaultProperties = indices.Size(); + DALI_TEST_CHECK( numDefaultProperties > 0 ); + DALI_TEST_EQUALS( numDefaultProperties, actor.GetPropertyCount(), TEST_LOCATION ); + + const Vector4 testColor(0.5f, 0.2f, 0.9f, 1.0f); + const float withFlake(99.f); + + Property::Index key1 = CORE_PROPERTY_MAX_INDEX+1; + Property::Index key2 = CORE_PROPERTY_MAX_INDEX+2; + + actor.RegisterProperty( "MyPropertyOne", Vector3::ONE ); + DevelHandle::RegisterProperty( actor, key1, "sideColor", testColor); + actor.RegisterProperty( "MyPropertyTwo", 1234 ); + Property::Index index4 = DevelHandle::RegisterProperty( actor, key2, "iceCream", withFlake ); + actor.RegisterProperty( "MyPropertyThree", Vector2(.2f,.7f) ); + + actor.GetPropertyIndices( indices ); + + DALI_TEST_EQUALS( indices.Size(), numDefaultProperties + 5, TEST_LOCATION ); + DALI_TEST_EQUALS( indices[indices.Size()-2], index4, TEST_LOCATION ); + END_TEST; } @@ -698,7 +832,6 @@ int UtcDaliHandleRegisterPropertyTypes(void) { "Property::BOOLEAN", true, true }, { "Property::FLOAT", 1.0f, true }, { "Property::INTEGER", 1, true }, - { "Property::UNSIGNED_INTEGER", 1u, true }, { "Property::VECTOR2", Vector2::ONE, true }, { "Property::VECTOR3", Vector3::ONE, true }, { "Property::VECTOR4", Vector4::ONE, true }, @@ -721,7 +854,7 @@ int UtcDaliHandleRegisterPropertyTypes(void) try { Actor actor = Actor::New(); - actor.RegisterProperty( "man-from-delmonte", properties[i].value ); + actor.RegisterProperty( "manFromDelmonte", properties[i].value ); } catch (Dali::DaliException& e) { @@ -740,7 +873,7 @@ int UtcDaliHandleCustomProperty(void) Handle handle = Handle::New(); float startValue(1.0f); - Property::Index index = handle.RegisterProperty( "test-property", startValue ); + Property::Index index = handle.RegisterProperty( "testProperty", startValue ); DALI_TEST_CHECK( handle.GetProperty(index) == startValue ); application.SendNotification(); @@ -758,12 +891,148 @@ int UtcDaliHandleCustomProperty(void) DALI_TEST_CHECK( handle.GetProperty(index) == 5.0f ); END_TEST; } + int UtcDaliHandleWeightNew(void) { TestApplication application; - Handle handle = WeightObject::New();; + Handle handle = WeightObject::New(); DALI_TEST_CHECK( handle.GetProperty(WeightObject::WEIGHT) == 0.0f ); + // process the message so scene object is added to update manager + application.SendNotification(); + application.Render(0); + + // no message to release scene object in this scenario + + END_TEST; +} + +int UtcDaliHandleWeightNew2(void) +{ + TestApplication application; + + // scope for the weight object + { + Handle handle = WeightObject::New(); + DALI_TEST_CHECK( handle.GetProperty(WeightObject::WEIGHT) == 0.0f ); + + // process the message so scene object is added to update manager + application.SendNotification(); + application.Render(0); + } + // handle out of scope so object gets destroyed + // process the message so update manager destroys the scene object + application.SendNotification(); + application.Render(0); + + END_TEST; +} + +int UtcDaliHandleSetTypeInfo(void) +{ + TestApplication application; + TypeRegistry typeRegistry = TypeRegistry::Get(); + + TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" ); + DALI_TEST_CHECK( typeInfo ); + + Actor actor = Actor::DownCast(typeInfo.CreateInstance()); + DALI_TEST_CHECK( actor ); + + DevelHandle::SetTypeInfo(actor, typeInfo); + + TypeInfo newTypeInfo; + bool success = actor.GetTypeInfo( newTypeInfo ); + DALI_TEST_CHECK( success ); + + DALI_TEST_CHECK(typeInfo.GetName() == newTypeInfo.GetName()); + DALI_TEST_CHECK(typeInfo.GetBaseName() == newTypeInfo.GetBaseName()); + + END_TEST; +} + +int UtcDaliHandleCustomPropertySynchronousGetSet(void) +{ + TestApplication application; + + tet_infoline( "Create a custom property and set the value ensuring it can be retrieved synchronously" ); + + Actor actor = Actor::New(); + Stage::GetCurrent().Add( actor ); + + tet_infoline( "Create the custom property with an initial value" ); + float startValue(1.0f); + Property::Index index = actor.RegisterProperty( "testProperty", startValue ); + DALI_TEST_EQUALS( actor.GetProperty< float >( index ), startValue, TEST_LOCATION ); + + tet_infoline( "Set the value, retrieve it and ensure both the synchronous and the async version work" ); + actor.SetProperty( index, 5.0f ); + DALI_TEST_EQUALS( actor.GetProperty< float >( index ), 5.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION ); + + tet_infoline( "Render and retrieve values again" ); + application.SendNotification(); + application.Render(0); + + DALI_TEST_EQUALS( actor.GetProperty< float >( index ), 5.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), 5.0f, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliHandleCustomPropertyGetType(void) +{ + TestApplication application; + + tet_infoline( "Create a custom property and retrieve its type" ); + + Handle handle = Handle::New(); + Property::Index index = handle.RegisterProperty( "testProperty", 1.0f ); + DALI_TEST_EQUALS( handle.GetPropertyType( index ), Property::FLOAT, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliHandleCustomPropertyAccessMode(void) +{ + TestApplication application; + + tet_infoline( "Create a custom property and retrieve whether it's animatable etc." ); + + Handle handle = Handle::New(); + Property::Index index = handle.RegisterProperty( "testProperty", 1.0f ); + DALI_TEST_EQUALS( handle.IsPropertyAnimatable( index ), true, TEST_LOCATION ); + DALI_TEST_EQUALS( handle.IsPropertyWritable( index ), true, TEST_LOCATION ); + + index = handle.RegisterProperty( "testProperty2", 1.0f, Property::READ_ONLY ); + DALI_TEST_EQUALS( handle.IsPropertyAnimatable( index ), false, TEST_LOCATION ); + DALI_TEST_EQUALS( handle.IsPropertyWritable( index ), false, TEST_LOCATION ); + + index = handle.RegisterProperty( "testProperty3", 1.0f, Property::READ_WRITE ); + DALI_TEST_EQUALS( handle.IsPropertyAnimatable( index ), false, TEST_LOCATION ); + DALI_TEST_EQUALS( handle.IsPropertyWritable( index ), true, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliHandleGetCurrentProperty(void) +{ + TestApplication application; + + tet_infoline( "Get a default and non-animatable custom property using the GetCurrentProperty API" ); + + Actor actor = Actor::New(); + Stage::GetCurrent().Add( actor ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION ); + + Property::Index index = actor.RegisterProperty( "testProperty3", 1.0f, Property::READ_WRITE ); + DALI_TEST_EQUALS( actor.GetProperty< float >( index ), 1.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), 1.0f, TEST_LOCATION ); + + actor.SetProperty( index, 2.0f ); + DALI_TEST_EQUALS( actor.GetProperty< float >( index ), 2.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), 2.0f, TEST_LOCATION ); + END_TEST; }