OpenGL: Restructure tests similar to D3D12 layout
- Move old test files to new unit/integration structure - Add OpenGL Test Fixture - Update CMakeLists.txt for new layout - Add OpenGL_Test_Restructuring_Plan.md
This commit is contained in:
68
tests/RHI/OpenGL/unit/test_pipeline_state.cpp
Normal file
68
tests/RHI/OpenGL/unit/test_pipeline_state.cpp
Normal file
@@ -0,0 +1,68 @@
|
||||
#include "fixtures/OpenGLTestFixture.h"
|
||||
#include "XCEngine/RHI/OpenGL/OpenGLPipelineState.h"
|
||||
|
||||
using namespace XCEngine::RHI;
|
||||
|
||||
TEST_F(OpenGLTestFixture, PipelineState_SetDepthStencilState) {
|
||||
OpenGLPipelineState pipeline;
|
||||
|
||||
OpenGLDepthStencilState state;
|
||||
state.depthTestEnable = true;
|
||||
state.depthWriteEnable = true;
|
||||
state.depthFunc = ComparisonFunc::Less;
|
||||
|
||||
pipeline.SetDepthStencilState(state);
|
||||
pipeline.ApplyDepthStencil();
|
||||
|
||||
GLint depthTest = 0;
|
||||
glGetIntegerv(GL_DEPTH_TEST, &depthTest);
|
||||
EXPECT_EQ(depthTest, 1);
|
||||
|
||||
GLint depthMask = 0;
|
||||
glGetIntegerv(GL_DEPTH_WRITEMASK, &depthMask);
|
||||
EXPECT_EQ(depthMask, 1);
|
||||
}
|
||||
|
||||
TEST_F(OpenGLTestFixture, PipelineState_SetBlendState) {
|
||||
OpenGLPipelineState pipeline;
|
||||
|
||||
OpenGLBlendState state;
|
||||
state.blendEnable = true;
|
||||
state.srcBlend = BlendFactor::SrcAlpha;
|
||||
state.dstBlend = BlendFactor::InvSrcAlpha;
|
||||
|
||||
pipeline.SetBlendState(state);
|
||||
pipeline.ApplyBlend();
|
||||
|
||||
GLint blend = 0;
|
||||
glGetIntegerv(GL_BLEND, &blend);
|
||||
EXPECT_EQ(blend, 1);
|
||||
}
|
||||
|
||||
TEST_F(OpenGLTestFixture, PipelineState_SetViewport_SetScissor) {
|
||||
OpenGLPipelineState pipeline;
|
||||
|
||||
ViewportState viewport;
|
||||
viewport.x = 0;
|
||||
viewport.y = 0;
|
||||
viewport.width = 800;
|
||||
viewport.height = 600;
|
||||
|
||||
ScissorState scissor;
|
||||
scissor.enable = true;
|
||||
scissor.x = 0;
|
||||
scissor.y = 0;
|
||||
scissor.width = 800;
|
||||
scissor.height = 600;
|
||||
|
||||
pipeline.SetViewport(viewport);
|
||||
pipeline.SetScissor(scissor);
|
||||
pipeline.ApplyViewport();
|
||||
|
||||
GLint viewportArr[4] = {};
|
||||
glGetIntegerv(GL_VIEWPORT, viewportArr);
|
||||
EXPECT_EQ(viewportArr[0], 0);
|
||||
EXPECT_EQ(viewportArr[1], 0);
|
||||
EXPECT_EQ(viewportArr[2], 800);
|
||||
EXPECT_EQ(viewportArr[3], 600);
|
||||
}
|
||||
Reference in New Issue
Block a user