#pragma once #include #include #include #include "XCEngine/RHI/OpenGL/OpenGLDevice.h" namespace XCEngine { namespace RHI { class OpenGLTestFixture : public ::testing::Test { protected: static void SetUpTestSuite(); static void TearDownTestSuite(); 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: static GLFWwindow* m_window; static bool m_contextInitialized; static OpenGLDevice* m_device; }; } // 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)