Add Phase 3: Shader, PipelineState, VertexArray tests (11 tests)

- Add Shader tests: VertexFragment, Geometry, InvalidSource, SetUniforms
- Add PipelineState tests: DepthStencilState, BlendState, Viewport/Scissor
- Add VertexArray tests: Initialize, AddVertexBuffer, SetIndexBuffer, Bind/Unbind
This commit is contained in:
2026-03-17 12:31:05 +08:00
parent 1d181f1109
commit 276a9c476a
4 changed files with 260 additions and 0 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();
}