Browse Source

Shaders: these cheats for getting code coverage are not needed anymore.

The testing is *real* now.
pull/364/head
Vladimír Vondruš 7 years ago
parent
commit
000833f86b
  1. 40
      src/Magnum/Shaders/Test/FlatGLTest.cpp
  2. 39
      src/Magnum/Shaders/Test/PhongGLTest.cpp

40
src/Magnum/Shaders/Test/FlatGLTest.cpp

@ -60,13 +60,9 @@ struct FlatGLTest: GL::OpenGLTester {
explicit FlatGLTest();
template<UnsignedInt dimensions> void construct();
template<UnsignedInt dimensions> void constructMove();
template<UnsignedInt dimensions> void bindTexture();
template<UnsignedInt dimensions> void bindTextureNotEnabled();
template<UnsignedInt dimensions> void setAlphaMask();
template<UnsignedInt dimensions> void setAlphaMaskNotEnabled();
void renderSetup();
@ -148,13 +144,8 @@ FlatGLTest::FlatGLTest() {
&FlatGLTest::constructMove<2>,
&FlatGLTest::constructMove<3>,
&FlatGLTest::bindTexture<2>,
&FlatGLTest::bindTexture<3>,
&FlatGLTest::bindTextureNotEnabled<2>,
&FlatGLTest::bindTextureNotEnabled<3>,
&FlatGLTest::setAlphaMask<2>,
&FlatGLTest::setAlphaMask<3>,
&FlatGLTest::setAlphaMaskNotEnabled<2>,
&FlatGLTest::setAlphaMaskNotEnabled<3>});
@ -223,27 +214,6 @@ template<UnsignedInt dimensions> void FlatGLTest::constructMove() {
CORRADE_VERIFY(!b.id());
}
template<UnsignedInt dimensions> void FlatGLTest::bindTexture() {
setTestCaseTemplateName(std::to_string(dimensions));
char data[4];
GL::Texture2D texture;
texture
.setMinificationFilter(SamplerFilter::Linear, SamplerMipmap::Linear)
.setMagnificationFilter(SamplerFilter::Linear)
.setWrapping(SamplerWrapping::ClampToEdge)
.setImage(0, GL::TextureFormat::RGBA, ImageView2D{PixelFormat::RGBA8Unorm, {1, 1}, data});
MAGNUM_VERIFY_NO_GL_ERROR();
/* Test just that no assertion is fired */
Flat<dimensions> shader{Flat<dimensions>::Flag::Textured};
shader.bindTexture(texture);
MAGNUM_VERIFY_NO_GL_ERROR();
}
template<UnsignedInt dimensions> void FlatGLTest::bindTextureNotEnabled() {
setTestCaseTemplateName(std::to_string(dimensions));
@ -257,16 +227,6 @@ template<UnsignedInt dimensions> void FlatGLTest::bindTextureNotEnabled() {
CORRADE_COMPARE(out.str(), "Shaders::Flat::bindTexture(): the shader was not created with texturing enabled\n");
}
template<UnsignedInt dimensions> void FlatGLTest::setAlphaMask() {
setTestCaseTemplateName(std::to_string(dimensions));
/* Test just that no assertion is fired */
Flat<dimensions> shader{Flat<dimensions>::Flag::AlphaMask};
shader.setAlphaMask(0.25f);
MAGNUM_VERIFY_NO_GL_ERROR();
}
template<UnsignedInt dimensions> void FlatGLTest::setAlphaMaskNotEnabled() {
setTestCaseTemplateName(std::to_string(dimensions));

39
src/Magnum/Shaders/Test/PhongGLTest.cpp

@ -63,12 +63,8 @@ struct PhongGLTest: GL::OpenGLTester {
void constructMove();
void bindTextures();
void bindTexturesNotEnabled();
void setAlphaMask();
void setAlphaMaskNotEnabled();
void setWrongLightCount();
void setWrongLightId();
@ -239,12 +235,8 @@ PhongGLTest::PhongGLTest() {
addTests({&PhongGLTest::constructMove,
&PhongGLTest::bindTextures,
&PhongGLTest::bindTexturesNotEnabled,
&PhongGLTest::setAlphaMask,
&PhongGLTest::setAlphaMaskNotEnabled,
&PhongGLTest::setWrongLightCount,
&PhongGLTest::setWrongLightId});
@ -329,29 +321,6 @@ void PhongGLTest::constructMove() {
CORRADE_VERIFY(!b.id());
}
void PhongGLTest::bindTextures() {
char data[4];
GL::Texture2D texture;
texture
.setMinificationFilter(SamplerFilter::Linear, SamplerMipmap::Linear)
.setMagnificationFilter(SamplerFilter::Linear)
.setWrapping(SamplerWrapping::ClampToEdge)
.setImage(0, GL::TextureFormat::RGBA, ImageView2D{PixelFormat::RGBA8Unorm, {1, 1}, data});
MAGNUM_VERIFY_NO_GL_ERROR();
/* Test just that no assertion is fired */
Phong shader{Phong::Flag::AmbientTexture|Phong::Flag::DiffuseTexture|Phong::Flag::SpecularTexture|Phong::Flag::NormalTexture};
shader.bindAmbientTexture(texture)
.bindDiffuseTexture(texture)
.bindSpecularTexture(texture)
.bindNormalTexture(texture)
.bindTextures(&texture, &texture, &texture, &texture);
MAGNUM_VERIFY_NO_GL_ERROR();
}
void PhongGLTest::bindTexturesNotEnabled() {
std::ostringstream out;
Error redirectError{&out};
@ -372,14 +341,6 @@ void PhongGLTest::bindTexturesNotEnabled() {
"Shaders::Phong::bindTextures(): the shader was not created with any textures enabled\n");
}
void PhongGLTest::setAlphaMask() {
/* Test just that no assertion is fired */
Phong shader{Phong::Flag::AlphaMask};
shader.setAlphaMask(0.25f);
MAGNUM_VERIFY_NO_GL_ERROR();
}
void PhongGLTest::setAlphaMaskNotEnabled() {
std::ostringstream out;
Error redirectError{&out};

Loading…
Cancel
Save