Browse Source

Shaders: turn a construction test into an instanced one.

Got more cases to test for.
pull/432/head
Vladimír Vondruš 6 years ago
parent
commit
6b0d29bec2
  1. 65
      src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp

65
src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp

@ -30,6 +30,7 @@
#include <Corrade/PluginManager/Manager.h> #include <Corrade/PluginManager/Manager.h>
#include <Corrade/Utility/DebugStl.h> #include <Corrade/Utility/DebugStl.h>
#include <Corrade/Utility/Directory.h> #include <Corrade/Utility/Directory.h>
#include <Corrade/Utility/FormatStl.h>
#include "Magnum/DebugTools/CompareImage.h" #include "Magnum/DebugTools/CompareImage.h"
#include "Magnum/GL/Context.h" #include "Magnum/GL/Context.h"
@ -71,8 +72,8 @@ struct MeshVisualizerGLTest: GL::OpenGLTester {
void constructGeometryShader3D(); void constructGeometryShader3D();
#endif #endif
void construct2DNoFeatureEnabled(); void construct2DInvalid();
void construct3DNoFeatureEnabled(); void construct3DInvalid();
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
void construct3DGeometryShaderDisabledButNeeded(); void construct3DGeometryShaderDisabledButNeeded();
void construct3DConflictingBitangentInput(); void construct3DConflictingBitangentInput();
@ -157,6 +158,31 @@ constexpr struct {
}; };
#endif #endif
constexpr struct {
const char* name;
MeshVisualizer2D::Flags flags;
const char* message;
} ConstructInvalidData2D[] {
{"no feature enabled",
MeshVisualizer2D::Flag::NoGeometryShader, /* not a feature flag */
"at least Flag::Wireframe has to be enabled"}
};
constexpr struct {
const char* name;
MeshVisualizer3D::Flags flags;
const char* message;
} ConstructInvalidData3D[] {
{"no feature enabled",
MeshVisualizer3D::Flag::NoGeometryShader, /* not a feature flag */
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
"at least one visualization feature has to be enabled"
#else
"at least Flag::Wireframe has to be enabled"
#endif
}
};
constexpr struct { constexpr struct {
const char* name; const char* name;
MeshVisualizer2D::Flags flags; MeshVisualizer2D::Flags flags;
@ -265,8 +291,12 @@ MeshVisualizerGLTest::MeshVisualizerGLTest() {
Containers::arraySize(ConstructGeometryShaderData3D)); Containers::arraySize(ConstructGeometryShaderData3D));
#endif #endif
addTests({&MeshVisualizerGLTest::construct2DNoFeatureEnabled, addInstancedTests({&MeshVisualizerGLTest::construct2DInvalid},
&MeshVisualizerGLTest::construct3DNoFeatureEnabled, Containers::arraySize(ConstructInvalidData2D));
addInstancedTests({&MeshVisualizerGLTest::construct3DInvalid},
Containers::arraySize(ConstructInvalidData3D));
addTests({
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
&MeshVisualizerGLTest::construct3DGeometryShaderDisabledButNeeded, &MeshVisualizerGLTest::construct3DGeometryShaderDisabledButNeeded,
&MeshVisualizerGLTest::construct3DConflictingBitangentInput, &MeshVisualizerGLTest::construct3DConflictingBitangentInput,
@ -424,27 +454,24 @@ void MeshVisualizerGLTest::constructGeometryShader3D() {
} }
#endif #endif
void MeshVisualizerGLTest::construct2DNoFeatureEnabled() { void MeshVisualizerGLTest::construct2DInvalid() {
auto&& data = ConstructInvalidData2D[testCaseInstanceId()];
setTestCaseDescription(data.name);
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};
/* This isn't a feature flag */ MeshVisualizer2D{data.flags};
MeshVisualizer2D{MeshVisualizer2D::Flag::NoGeometryShader}; CORRADE_COMPARE(out.str(), Utility::formatString("Shaders::MeshVisualizer2D: {}\n", data.message));
CORRADE_COMPARE(out.str(),
"Shaders::MeshVisualizer2D: at least Flag::Wireframe has to be enabled\n");
} }
void MeshVisualizerGLTest::construct3DNoFeatureEnabled() { void MeshVisualizerGLTest::construct3DInvalid() {
auto&& data = ConstructInvalidData3D[testCaseInstanceId()];
setTestCaseDescription(data.name);
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};
/* This isn't a feature flag */ MeshVisualizer3D{data.flags};
MeshVisualizer3D{MeshVisualizer3D::Flag::NoGeometryShader}; CORRADE_COMPARE(out.str(), Utility::formatString("Shaders::MeshVisualizer3D: {}\n", data.message));
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
CORRADE_COMPARE(out.str(),
"Shaders::MeshVisualizer3D: at least one visualization feature has to be enabled\n");
#else
CORRADE_COMPARE(out.str(),
"Shaders::MeshVisualizer3D: at least Flag::Wireframe has to be enabled\n");
#endif
} }
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)

Loading…
Cancel
Save