X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali%2Futc-Dali-Shader.cpp;h=3336e20e5bcf61b7d9639c1f18b9761d74d0bea4;hb=c5015fd94aa766b0c8aa652dbfc7ad3e24758199;hp=cf419bea7a6fa66b2fac1381397697653c5ece7a;hpb=7f12510950d4463804f541f038769101afc9d9a3;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/automated-tests/src/dali/utc-Dali-Shader.cpp b/automated-tests/src/dali/utc-Dali-Shader.cpp index cf419be..3336e20 100644 --- a/automated-tests/src/dali/utc-Dali-Shader.cpp +++ b/automated-tests/src/dali/utc-Dali-Shader.cpp @@ -116,6 +116,25 @@ int UtcDaliShaderDownCast02(void) END_TEST; } +int UtcDaliShaderDefaultProperties(void) +{ + TestApplication application; +// from shader-impl.cpp +// DALI_PROPERTY( "program", MAP, true, false, false, Dali::Shader::Property::PROGRAM ) + + Shader shader = Shader::New(VertexSource, FragmentSource); + DALI_TEST_EQUALS( shader.GetPropertyCount(), 1, TEST_LOCATION ); + + DALI_TEST_EQUALS( shader.GetPropertyName( Shader::Property::PROGRAM ), "program", TEST_LOCATION ); + DALI_TEST_EQUALS( shader.GetPropertyIndex( "program" ), (Property::Index)Shader::Property::PROGRAM, TEST_LOCATION ); + DALI_TEST_EQUALS( shader.GetPropertyType( Shader::Property::PROGRAM ), Property::MAP, TEST_LOCATION ); + DALI_TEST_EQUALS( shader.IsPropertyWritable( Shader::Property::PROGRAM ), true, TEST_LOCATION ); + DALI_TEST_EQUALS( shader.IsPropertyAnimatable( Shader::Property::PROGRAM ), false, TEST_LOCATION ); + DALI_TEST_EQUALS( shader.IsPropertyAConstraintInput( Shader::Property::PROGRAM ), false, TEST_LOCATION ); + + END_TEST; +} + int UtcDaliShaderConstraint01(void) { TestApplication application; @@ -128,7 +147,7 @@ int UtcDaliShaderConstraint01(void) Actor actor = Actor::New(); actor.AddRenderer(renderer); - actor.SetSize(400, 400); + actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) ); Stage::GetCurrent().Add(actor); Vector4 initialColor = Color::WHITE; @@ -170,7 +189,7 @@ int UtcDaliShaderConstraint02(void) Actor actor = Actor::New(); actor.AddRenderer(renderer); - actor.SetSize(400, 400); + actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) ); Stage::GetCurrent().Add(actor); application.SendNotification(); application.Render(0); @@ -224,7 +243,7 @@ int UtcDaliShaderAnimatedProperty01(void) Actor actor = Actor::New(); actor.AddRenderer(renderer); - actor.SetSize(400, 400); + actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) ); Stage::GetCurrent().Add(actor); Vector4 initialColor = Color::WHITE; @@ -265,7 +284,7 @@ int UtcDaliShaderAnimatedProperty02(void) Actor actor = Actor::New(); actor.AddRenderer(renderer); - actor.SetSize(400, 400); + actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) ); Stage::GetCurrent().Add(actor); application.SendNotification(); application.Render(0); @@ -299,6 +318,28 @@ int UtcDaliShaderAnimatedProperty02(void) DALI_TEST_CHECK( gl.GetUniformValue( "uFadeColor", actualValue ) ); DALI_TEST_EQUALS( actualValue, Color::TRANSPARENT, TEST_LOCATION ); + // change shader program + Property::Map map; + map["vertex"] = VertexSource; + map["fragment"] = FragmentSource; + map["hints"] = "MODIFIES_GEOMETRY"; + shader.SetProperty( Shader::Property::PROGRAM, Property::Value(map) ); + application.SendNotification(); + application.Render(100); + + // register another custom property as well + Property::Index customIndex = shader.RegisterProperty( "uCustom", Vector3(1,2,3) ); + DALI_TEST_EQUALS( shader.GetProperty( customIndex ), Vector3(1,2,3), TEST_LOCATION ); + + application.SendNotification(); + application.Render(100); + + DALI_TEST_CHECK( gl.GetUniformValue( "uFadeColor", actualValue ) ); + DALI_TEST_EQUALS( actualValue, Color::TRANSPARENT, TEST_LOCATION ); + + Vector3 customValue; + DALI_TEST_CHECK( gl.GetUniformValue( "uCustom", customValue ) ); + DALI_TEST_EQUALS( customValue, Vector3(1,2,3), TEST_LOCATION ); END_TEST; } @@ -317,6 +358,9 @@ int UtcDaliShaderProgramProperty(void) map["hints"] = hintSet; shader.SetProperty( Shader::Property::PROGRAM, Property::Value(map) ); + // register a custom property as well + Property::Index customIndex = shader.RegisterProperty( "custom", Vector3(1,2,3) ); + DALI_TEST_EQUALS( shader.GetProperty( customIndex ), Vector3(1,2,3), TEST_LOCATION ); Property::Value value = shader.GetProperty(Shader::Property::PROGRAM); DALI_TEST_CHECK( value.GetType() == Property::MAP); @@ -333,6 +377,15 @@ int UtcDaliShaderProgramProperty(void) value = shader.GetCurrentProperty( Shader::Property::PROGRAM ); DALI_TEST_CHECK( value.GetType() == Property::MAP); outMap = value.GetMap(); + // check that changing the shader did not cause us to loose custom property + DALI_TEST_EQUALS( shader.GetProperty( customIndex ), Vector3(1,2,3), TEST_LOCATION ); + using Dali::Animation; + Animation animation = Animation::New( 0.1f ); + animation.AnimateTo( Property( shader, customIndex ), Vector3(4,5,6) ); + animation.Play(); + application.SendNotification(); + application.Render(100); + DALI_TEST_EQUALS( shader.GetProperty( customIndex ), Vector3(4,5,6), TEST_LOCATION ); v = (*outMap)["vertex"].Get(); f = (*outMap)["fragment"].Get();