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:
49
tests/RHI/OpenGL/unit/fixtures/OpenGLTestFixture.h
Normal file
49
tests/RHI/OpenGL/unit/fixtures/OpenGLTestFixture.h
Normal file
@@ -0,0 +1,49 @@
|
||||
#pragma once
|
||||
|
||||
#include <glad/glad.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "XCEngine/RHI/OpenGL/OpenGLDevice.h"
|
||||
|
||||
namespace XCEngine {
|
||||
namespace RHI {
|
||||
|
||||
class OpenGLTestFixture : public ::testing::Test {
|
||||
protected:
|
||||
void SetUp() override;
|
||||
void TearDown() override;
|
||||
|
||||
GLFWwindow* GetWindow() { return m_window; }
|
||||
void MakeContextCurrent();
|
||||
void DoneContextCurrent();
|
||||
|
||||
void ClearGLErrors();
|
||||
bool CheckGLError(const char* file, int line);
|
||||
const char* GetGLErrorString(GLenum error);
|
||||
void ResetGLState();
|
||||
|
||||
private:
|
||||
GLFWwindow* m_window = nullptr;
|
||||
OpenGLDevice* m_device = nullptr;
|
||||
};
|
||||
|
||||
} // namespace RHI
|
||||
} // namespace XCEngine
|
||||
|
||||
#define GL_CLEAR_ERRORS() \
|
||||
do { while (glGetError() != GL_NO_ERROR); } while(0)
|
||||
|
||||
#define GL_CHECK(call) \
|
||||
do { \
|
||||
call; \
|
||||
ASSERT_TRUE(XCEngine::RHI::OpenGLTestFixture::CheckGLError(__FILE__, __LINE__)) \
|
||||
<< "GL error after " << #call; \
|
||||
} while(0)
|
||||
|
||||
#define GL_EXPECT_SUCCESS(call) \
|
||||
do { \
|
||||
call; \
|
||||
EXPECT_EQ(glGetError(), GL_NO_ERROR) \
|
||||
<< "GL error after " << #call; \
|
||||
} while(0)
|
||||
Reference in New Issue
Block a user