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=35e2784707fd01f75ac551990d010517699a267d;hpb=7e8106c4c6f4912f1a4528b7bb9df4359f66f21a;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 35e2784..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 @@ -208,17 +210,17 @@ int UtcDaliHandleGetPropertyIndex02(void) const float withFlake(99.f); Property::Index index1 = actor.RegisterProperty( "MyPropertyOne", Vector3::ONE ); - Property::Index index2 = actor.RegisterProperty( key1, "sideColor", testColor); + Property::Index index2 = DevelHandle::RegisterProperty( actor, key1, "sideColor", testColor); Property::Index index3 = actor.RegisterProperty( "MyPropertyTwo", Vector3::ONE ); - Property::Index index4 = actor.RegisterProperty( key2, "iceCream", withFlake ); + 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 = actor.GetPropertyIndex( key1 ); - Property::Index testIndex2 = actor.GetPropertyIndex( key2 ); + 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 ); @@ -248,15 +250,15 @@ int UtcDaliHandleGetPropertyIndex03(void) std::string myName("croydon"); Property::Index intKey = CORE_PROPERTY_MAX_INDEX+1; Property::Value value( Color::GREEN ); - Property::Index myIndex = actor.RegisterProperty( intKey, myName, value ); + Property::Index myIndex = DevelHandle::RegisterProperty( actor, intKey, myName, value ); - DALI_TEST_EQUALS( myIndex, actor.GetPropertyIndex( intKey ), TEST_LOCATION ); + DALI_TEST_EQUALS( myIndex, DevelHandle::GetPropertyIndex( actor, intKey ), TEST_LOCATION ); Property::Key key1(myName); Property::Key key2(intKey); - DALI_TEST_EQUALS( myIndex, actor.GetPropertyIndex( key1 ), TEST_LOCATION ); - DALI_TEST_EQUALS( myIndex, actor.GetPropertyIndex( key2 ), TEST_LOCATION ); + DALI_TEST_EQUALS( myIndex, DevelHandle::GetPropertyIndex( actor, key1 ), TEST_LOCATION ); + DALI_TEST_EQUALS( myIndex, DevelHandle::GetPropertyIndex( actor, key2 ), TEST_LOCATION ); END_TEST; } @@ -296,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 ) ); @@ -344,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 ) ); @@ -391,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 ) ); @@ -490,24 +495,17 @@ int UtcDaliHandleGetPropertyType(void) 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( "manFromDelmonte", 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() ); @@ -517,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 ); @@ -537,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; - } - - DALI_TEST_CHECK(!exception); + actor.SetProperty( write_anim, Property::Value(1.f) ); - //// 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; @@ -726,8 +698,8 @@ int UtcDaliHandleRegisterProperty02(void) const float withFlake(99.f); Property::Index index1 = actor.RegisterProperty( "MyPropertyOne", Vector3::ONE ); - Property::Index index2 = actor.RegisterProperty( key1, "sideColor", testColor); - Property::Index index3 = actor.RegisterProperty( key2, "iceCream", withFlake ); + Property::Index index2 = DevelHandle::RegisterProperty( actor, key1, "sideColor", testColor); + Property::Index index3 = DevelHandle::RegisterProperty( actor, key2, "iceCream", withFlake ); application.SendNotification(); application.Render(); @@ -828,9 +800,9 @@ int UtcDaliHandleGetPropertyIndices(void) Property::Index key2 = CORE_PROPERTY_MAX_INDEX+2; actor.RegisterProperty( "MyPropertyOne", Vector3::ONE ); - actor.RegisterProperty( key1, "sideColor", testColor); + DevelHandle::RegisterProperty( actor, key1, "sideColor", testColor); actor.RegisterProperty( "MyPropertyTwo", 1234 ); - Property::Index index4 = actor.RegisterProperty( key2, "iceCream", withFlake ); + Property::Index index4 = DevelHandle::RegisterProperty( actor, key2, "iceCream", withFlake ); actor.RegisterProperty( "MyPropertyThree", Vector2(.2f,.7f) ); actor.GetPropertyIndices( indices ); @@ -924,8 +896,143 @@ 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; }