#include "RHITestFixture.h" #include #include #include #include "XCEngine/RHI/D3D12/D3D12Device.h" #include "XCEngine/RHI/OpenGL/OpenGLDevice.h" namespace XCEngine { namespace RHI { INSTANTIATE_TEST_SUITE_P(D3D12, RHITestFixture, ::testing::Values(RHIType::D3D12)); INSTANTIATE_TEST_SUITE_P(OpenGL, RHITestFixture, ::testing::Values(RHIType::OpenGL)); void RHITestFixture::SetUpTestSuite() { } void RHITestFixture::TearDownTestSuite() { } void RHITestFixture::SetUp() { mDevice = RHIFactory::CreateRHIDevice(GetParam()); ASSERT_NE(mDevice, nullptr); WNDCLASSEXW wc = {}; wc.cbSize = sizeof(WNDCLASSEXW); wc.lpfnWndProc = DefWindowProcW; wc.hInstance = GetModuleHandle(nullptr); wc.lpszClassName = L"RHIUnitTestClass"; RegisterClassExW(&wc); mWindow = CreateWindowExW(0, L"RHIUnitTestClass", L"RHIUnitTest", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 800, 600, nullptr, nullptr, GetModuleHandle(nullptr), nullptr); bool initResult = false; if (GetParam() == RHIType::D3D12) { RHIDeviceDesc desc = {}; desc.enableDebugLayer = false; initResult = mDevice->Initialize(desc); } else if (GetParam() == RHIType::OpenGL) { auto* oglDevice = static_cast(mDevice); initResult = oglDevice->InitializeWithExistingWindow(mWindow); } ASSERT_TRUE(initResult); } void RHITestFixture::TearDown() { if (mDevice != nullptr) { mDevice->Shutdown(); delete mDevice; mDevice = nullptr; } if (mWindow) { DestroyWindow(mWindow); mWindow = nullptr; } } } // namespace RHI } // namespace XCEngine