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:
2026-03-20 17:37:09 +08:00
parent 3cd3b04c7e
commit 0a19fdfb0f
19 changed files with 843 additions and 103 deletions

View File

@@ -0,0 +1,70 @@
#include "fixtures/OpenGLTestFixture.h"
#include "XCEngine/RHI/OpenGL/OpenGLVertexArray.h"
#include "XCEngine/RHI/OpenGL/OpenGLBuffer.h"
using namespace XCEngine::RHI;
TEST_F(OpenGLTestFixture, VertexArray_Initialize_CreatesVAO) {
OpenGLVertexArray vao;
bool result = vao.Initialize();
ASSERT_TRUE(result);
EXPECT_NE(vao.GetID(), 0u);
vao.Shutdown();
}
TEST_F(OpenGLTestFixture, VertexArray_AddVertexBuffer) {
OpenGLVertexArray vao;
vao.Initialize();
OpenGLBuffer buffer;
buffer.InitializeVertexBuffer(nullptr, 64);
VertexAttribute attr;
attr.index = 0;
attr.count = 3;
attr.type = GL_FLOAT;
attr.normalized = false;
attr.stride = sizeof(float) * 3;
attr.offset = 0;
vao.AddVertexBuffer(buffer.GetID(), attr);
EXPECT_EQ(vao.GetID(), 1u);
buffer.Shutdown();
vao.Shutdown();
}
TEST_F(OpenGLTestFixture, VertexArray_SetIndexBuffer) {
OpenGLVertexArray vao;
vao.Initialize();
OpenGLBuffer buffer;
buffer.InitializeIndexBuffer(nullptr, 12);
vao.SetIndexBuffer(buffer.GetID(), GL_UNSIGNED_INT);
EXPECT_NE(vao.GetIndexBuffer(), 0u);
buffer.Shutdown();
vao.Shutdown();
}
TEST_F(OpenGLTestFixture, VertexArray_Bind_Unbind) {
OpenGLVertexArray vao;
vao.Initialize();
vao.Bind();
GLint boundVAO = 0;
glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &boundVAO);
EXPECT_EQ(boundVAO, static_cast<GLint>(vao.GetID()));
vao.Unbind();
glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &boundVAO);
EXPECT_EQ(boundVAO, 0);
vao.Shutdown();
}