100% Coverage for Rendering API 50/80250/1
authorTom Robinson <tom.robinson@samsung.com>
Fri, 15 Jul 2016 11:05:38 +0000 (12:05 +0100)
committerTom Robinson <tom.robinson@samsung.com>
Fri, 15 Jul 2016 11:05:38 +0000 (12:05 +0100)
Change-Id: I051bf96c0f1488b1a5bb9f2d8586cd981a77d83f

automated-tests/src/dali/utc-Dali-Sampler.cpp
automated-tests/src/dali/utc-Dali-Texture.cpp

index fdfe4b9..ba71e7c 100644 (file)
@@ -19,6 +19,7 @@
 #include <dali/public-api/dali-core.h>
 #include <dali/devel-api/images/texture-set-image.h>
 #include <unistd.h>
+#include <string.h>
 
 // INTERNAL INCLUDES
 #include <dali-test-suite-utils.h>
@@ -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;
+}
index 436bcdc..1eada6c 100644 (file)
@@ -17,6 +17,7 @@
 
 #include <dali/public-api/dali-core.h>
 #include <dali-test-suite-utils.h>
+#include <test-native-image.h>
 
 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;