Files
XCEngine/tests/RHI/OpenGL/unit/test_device.cpp
ssdfasd 7a66913f2b refactor(RHI): 将窗口职责从RHI移到Platform层
- RHIDeviceDesc 删除 windowHandle/width/height/appName
- SwapChainDesc 添加 windowHandle 字段
- RHISwapChain 删除 PollEvents/ShouldClose/SetFullscreen 等窗口相关接口
- OpenGLDevice 删除 CreateRenderWindow,改用 InitializeWithExistingWindow
- 更新所有集成测试使用新API
- 273个单元测试 + 8个集成测试全部通过
2026-03-24 23:00:49 +08:00

35 lines
930 B
C++

#include "fixtures/OpenGLTestFixture.h"
#include "XCEngine/RHI/OpenGL/OpenGLDevice.h"
using namespace XCEngine::RHI;
TEST_F(OpenGLTestFixture, Device_InitializeWithExistingWindow) {
OpenGLDevice device;
HWND existingWindow = GetWindow();
bool result = device.InitializeWithExistingWindow(existingWindow);
ASSERT_TRUE(result);
}
TEST_F(OpenGLTestFixture, Device_GetDeviceInfo_ReturnsValid) {
OpenGLDevice device;
device.InitializeWithExistingWindow(GetWindow());
const auto& info = device.GetDeviceInfo();
EXPECT_FALSE(info.vendor.empty());
EXPECT_FALSE(info.renderer.empty());
EXPECT_GE(info.majorVersion, 3);
EXPECT_GE(info.minorVersion, 0);
}
TEST_F(OpenGLTestFixture, Device_SwapBuffers_NoErrors) {
OpenGLDevice device;
device.InitializeWithExistingWindow(GetWindow());
device.SwapBuffers();
GLenum error = glGetError();
EXPECT_EQ(error, GL_NO_ERROR);
}