X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali%2Futc-Dali-TextureSet.cpp;h=c8d91b940bd38483dff4840de2ea5699bbec0ec5;hb=6264fca88e12b3f64730f1ab7a50f25b95b06b27;hp=334a2bf02e80ba6ac60354ee07d3ff25caf0630a;hpb=0ded984694c9954fba82b058adb9f9b8deb901a3;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/automated-tests/src/dali/utc-Dali-TextureSet.cpp b/automated-tests/src/dali/utc-Dali-TextureSet.cpp index 334a2bf..c8d91b9 100644 --- a/automated-tests/src/dali/utc-Dali-TextureSet.cpp +++ b/automated-tests/src/dali/utc-Dali-TextureSet.cpp @@ -24,6 +24,46 @@ #include using namespace Dali; + +namespace +{ + +enum SetSampler +{ + SET_SAMPLER, + DONT_SET_SAMPLER +}; + +Actor CreateActor( SetSampler setSamplerOption ) +{ + Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, 64, 64 ); + + Shader shader = CreateShader(); + TextureSet textureSet = CreateTextureSet(); + + Sampler sampler = Sampler::New(); + sampler.SetFilterMode( FilterMode::NEAREST, FilterMode::NEAREST ); + textureSet.SetTexture( 0u, texture ); + if( setSamplerOption == SET_SAMPLER ) + { + textureSet.SetSampler( 0u, sampler ); + } + + Geometry geometry = CreateQuadGeometry(); + Renderer renderer = Renderer::New( geometry, shader ); + renderer.SetTextures( textureSet ); + + Actor actor = Actor::New(); + actor.AddRenderer(renderer); + actor.SetParentOrigin( ParentOrigin::CENTER ); + actor.SetSize(400, 400); + + return actor; +} + +} // namespace + + void texture_set_test_startup(void) { test_return_value = TET_UNDEF; @@ -108,20 +148,7 @@ int UtcDaliTextureSetTexture01(void) { TestApplication application; - Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, 64, 64 ); - - Shader shader = CreateShader(); - TextureSet textureSet = CreateTextureSet(); - textureSet.SetTexture( 0u, texture ); - - Geometry geometry = CreateQuadGeometry(); - Renderer renderer = Renderer::New( geometry, shader ); - renderer.SetTextures( textureSet ); - - Actor actor = Actor::New(); - actor.AddRenderer(renderer); - actor.SetParentOrigin( ParentOrigin::CENTER ); - actor.SetSize(400, 400); + Actor actor = CreateActor( DONT_SET_SAMPLER ); Stage::GetCurrent().Add( actor ); @@ -151,26 +178,42 @@ int UtcDaliTextureSetTexture02(void) { TestApplication application; - Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, 64, 64 ); + Actor actor = CreateActor(SET_SAMPLER); - Shader shader = CreateShader(); - TextureSet textureSet = CreateTextureSet(); + Stage::GetCurrent().Add( actor ); - Sampler sampler = Sampler::New(); - sampler.SetFilterMode( FilterMode::NEAREST, FilterMode::NEAREST ); - textureSet.SetTexture( 0u, texture ); - textureSet.SetSampler( 0u, sampler ); + TestGlAbstraction& gl = application.GetGlAbstraction(); - Geometry geometry = CreateQuadGeometry(); - Renderer renderer = Renderer::New( geometry, shader ); - renderer.SetTextures( textureSet ); + TraceCallStack& texParameterTrace = gl.GetTexParameterTrace(); + texParameterTrace.Reset(); + texParameterTrace.Enable( true ); + application.SendNotification(); + application.Render(); - Actor actor = Actor::New(); - actor.AddRenderer(renderer); - actor.SetParentOrigin( ParentOrigin::CENTER ); - actor.SetSize(400, 400); + int textureUnit=-1; + DALI_TEST_CHECK( gl.GetUniformValue( "sTexture", textureUnit ) ); + DALI_TEST_EQUALS( textureUnit, 0, TEST_LOCATION ); - Stage::GetCurrent().Add( actor ); + texParameterTrace.Enable( false ); + + // Verify gl state + // There are four calls to TexParameteri when the texture is first created + // Texture minification and magnification filters are now different than default so + //there should have been two extra TexParameteri calls to set the new filter mode + DALI_TEST_EQUALS( texParameterTrace.CountMethod( "TexParameteri" ), 6, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliTextureSetMultiple(void) +{ + TestApplication application; + + Actor actor1 = CreateActor(SET_SAMPLER); + Actor actor2 = CreateActor(SET_SAMPLER); + + Stage::GetCurrent().Add( actor1 ); + Stage::GetCurrent().Add( actor2 ); TestGlAbstraction& gl = application.GetGlAbstraction(); @@ -187,13 +230,14 @@ int UtcDaliTextureSetTexture02(void) texParameterTrace.Enable( false ); // Verify gl state - // There are four calls to TexParameteri when the texture is first created + // For each actor there are four calls to TexParameteri when the texture is first created // Texture minification and magnification filters are now different than default so //there should have been two extra TexParameteri calls to set the new filter mode - DALI_TEST_EQUALS( texParameterTrace.CountMethod( "TexParameteri" ), 6, TEST_LOCATION); + DALI_TEST_EQUALS( texParameterTrace.CountMethod( "TexParameteri" ), 2 * 6, TEST_LOCATION); END_TEST; } + int UtcDaliTextureSetSetSampler(void) { TestApplication application; @@ -231,7 +275,7 @@ int UtcDaliTextureSetSetSampler(void) // Verify gl state // There are 4 calls to TexParameteri when the texture is first created // as the texture is using default sampling parametrers there shouldn't be any more calls to TexParameteri - DALI_TEST_EQUALS( texParameterTrace.CountMethod( "TexParameteri" ), 3, TEST_LOCATION); + DALI_TEST_EQUALS( texParameterTrace.CountMethod( "TexParameteri" ), 4, TEST_LOCATION); texParameterTrace.Reset(); texParameterTrace.Enable( true ); @@ -313,7 +357,7 @@ int UtcDaliTextureSetGetSampler(void) END_TEST; } -int UtcDaliTextureSetGetTextureCount(void) +int UtcDaliTextureSetGetTextureCount0(void) { TestApplication application; @@ -327,8 +371,41 @@ int UtcDaliTextureSetGetTextureCount(void) TextureSetImage( textureSet, 1u, image ); DALI_TEST_EQUALS( textureSet.GetTextureCount(), 2u, TEST_LOCATION ); - textureSet.SetSampler( 2u, Sampler::New() ); + Sampler sampler = Sampler::New(); + sampler.SetFilterMode( FilterMode::NEAREST, FilterMode::NEAREST ); + textureSet.SetSampler( 2u, sampler ); + DALI_TEST_EQUALS( textureSet.GetTextureCount(), 2u, TEST_LOCATION ); + + TextureSetImage( textureSet, 2u, image ); + DALI_TEST_EQUALS( textureSet.GetTextureCount(), 3u, TEST_LOCATION ); + DALI_TEST_EQUALS( textureSet.GetSampler(2u), sampler, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliTextureSetGetTextureCount1(void) +{ + TestApplication application; + + TextureSet textureSet = CreateTextureSet(); + DALI_TEST_EQUALS( textureSet.GetTextureCount(), 0u, TEST_LOCATION ); + + Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, 64, 64 ); + textureSet.SetTexture( 0u, texture ); + DALI_TEST_EQUALS( textureSet.GetTextureCount(), 1u, TEST_LOCATION ); + + textureSet.SetTexture( 1u, texture ); + DALI_TEST_EQUALS( textureSet.GetTextureCount(), 2u, TEST_LOCATION ); + + Sampler sampler = Sampler::New(); + sampler.SetFilterMode( FilterMode::NEAREST, FilterMode::NEAREST ); + textureSet.SetSampler( 2u, sampler ); + DALI_TEST_EQUALS( textureSet.GetTextureCount(), 2u, TEST_LOCATION ); + + textureSet.SetTexture( 2u, texture ); DALI_TEST_EQUALS( textureSet.GetTextureCount(), 3u, TEST_LOCATION ); + DALI_TEST_EQUALS( textureSet.GetSampler(2u), sampler, TEST_LOCATION ); + END_TEST; }