From 99c0f53f9e58b9dedcf5f180e4b916b06da2f12e Mon Sep 17 00:00:00 2001 From: Tom Robinson Date: Fri, 15 Jul 2016 12:05:38 +0100 Subject: [PATCH] 100% Coverage for Rendering API Change-Id: I051bf96c0f1488b1a5bb9f2d8586cd981a77d83f --- automated-tests/src/dali/utc-Dali-Sampler.cpp | 69 ++++++++++++++++++++++++++- automated-tests/src/dali/utc-Dali-Texture.cpp | 17 +++++++ 2 files changed, 84 insertions(+), 2 deletions(-) diff --git a/automated-tests/src/dali/utc-Dali-Sampler.cpp b/automated-tests/src/dali/utc-Dali-Sampler.cpp index fdfe4b9..ba71e7c 100644 --- a/automated-tests/src/dali/utc-Dali-Sampler.cpp +++ b/automated-tests/src/dali/utc-Dali-Sampler.cpp @@ -19,6 +19,7 @@ #include #include #include +#include // INTERNAL INCLUDES #include @@ -74,7 +75,6 @@ int UtcDaliSamplerCopyConstructor(void) END_TEST; } - int UtcDaliSamplerDownCast01(void) { TestApplication application; @@ -248,7 +248,7 @@ int UtcSamplerSetFilterMode(void) END_TEST; } -int UtcSamplerSetWrapMode(void) +int UtcSamplerSetWrapMode1(void) { TestApplication application; @@ -316,3 +316,68 @@ int UtcSamplerSetWrapMode(void) END_TEST; } + +int UtcSamplerSetWrapMode2(void) +{ + TestApplication application; + + // Create a cube-map texture. + unsigned int width = 8u; + unsigned int height = 8u; + Texture texture = Texture::New( TextureType::TEXTURE_CUBE, Pixel::RGBA8888, width, height ); + + // Create source image data. + unsigned int bufferSize( width * height * 4 ); + unsigned char* buffer= new unsigned char[ bufferSize ]; + memset( buffer, 0u, bufferSize ); + + PixelData pixelData = PixelData::New( buffer, bufferSize, width, height, Pixel::RGBA8888, PixelData::DELETE_ARRAY ); + + // Upload the source image data to all 6 sides of our cube-map. + texture.Upload( pixelData, CubeMapLayer::POSITIVE_X, 0u, 0u, 0u, width, height ); + texture.Upload( pixelData, CubeMapLayer::NEGATIVE_X, 0u, 0u, 0u, width, height ); + texture.Upload( pixelData, CubeMapLayer::POSITIVE_Y, 0u, 0u, 0u, width, height ); + texture.Upload( pixelData, CubeMapLayer::NEGATIVE_Y, 0u, 0u, 0u, width, height ); + texture.Upload( pixelData, CubeMapLayer::POSITIVE_Z, 0u, 0u, 0u, width, height ); + texture.Upload( pixelData, CubeMapLayer::NEGATIVE_Z, 0u, 0u, 0u, width, height ); + + // Finalize the cube-map setup. + TextureSet textureSet = TextureSet::New(); + textureSet.SetTexture( 0u, texture ); + + Sampler sampler = Sampler::New(); + textureSet.SetSampler( 0u, sampler ); + + Shader shader = CreateShader(); + 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 ); + Stage::GetCurrent().Add( actor ); + + TestGlAbstraction& gl = application.GetGlAbstraction(); + + application.SendNotification(); + application.Render(); + + TraceCallStack& texParameterTrace = gl.GetTexParameterTrace(); + texParameterTrace.Reset(); + texParameterTrace.Enable( true ); + + // Call the 3 dimensional wrap mode API. + sampler.SetWrapMode( WrapMode::CLAMP_TO_EDGE, WrapMode::CLAMP_TO_EDGE, WrapMode::CLAMP_TO_EDGE ); + + application.SendNotification(); + application.Render(); + + texParameterTrace.Enable( false ); + + // Verify that 3 TexParameteri calls occurred. + DALI_TEST_EQUALS( texParameterTrace.CountMethod( "TexParameteri" ), 3u, TEST_LOCATION ); + + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-Texture.cpp b/automated-tests/src/dali/utc-Dali-Texture.cpp index 436bcdc..1eada6c 100644 --- a/automated-tests/src/dali/utc-Dali-Texture.cpp +++ b/automated-tests/src/dali/utc-Dali-Texture.cpp @@ -17,6 +17,7 @@ #include #include +#include using namespace Dali; @@ -52,6 +53,22 @@ int UtcDaliTextureNew02(void) END_TEST; } +int UtcDaliTextureNew03(void) +{ + TestApplication application; + + // Create a native image source. + TestNativeImageNoExtPointer testNativeImage = TestNativeImageNoExt::New( 64u, 64u ); + + // Create a texture from the native image source. + Texture nativeTexture = Texture::New( *testNativeImage ); + + // Check the texture was created OK. + DALI_TEST_CHECK( nativeTexture ); + + END_TEST; +} + int UtcDaliTextureCopyConstructor(void) { TestApplication application; -- 2.7.4