test: Add new RHI unit tests for capabilities, views, screenshot, descriptor set and pipeline layout
This commit is contained in:
63
tests/RHI/unit/test_screenshot.cpp
Normal file
63
tests/RHI/unit/test_screenshot.cpp
Normal file
@@ -0,0 +1,63 @@
|
||||
#include "fixtures/RHITestFixture.h"
|
||||
#include "XCEngine/RHI/RHIScreenshot.h"
|
||||
#include "XCEngine/RHI/RHISwapChain.h"
|
||||
|
||||
using namespace XCEngine::RHI;
|
||||
|
||||
TEST_P(RHITestFixture, Screenshot_Create) {
|
||||
RHIScreenshot* screenshot = RHIScreenshot::Create(GetBackendType());
|
||||
if (screenshot != nullptr) {
|
||||
screenshot->Shutdown();
|
||||
delete screenshot;
|
||||
}
|
||||
}
|
||||
|
||||
TEST_P(RHITestFixture, Screenshot_Capture_Basic) {
|
||||
SwapChainDesc desc = {};
|
||||
desc.windowHandle = GetWindowHandle();
|
||||
desc.width = 800;
|
||||
desc.height = 600;
|
||||
desc.bufferCount = 2;
|
||||
desc.format = Format::R8G8B8A8_UNorm;
|
||||
|
||||
RHISwapChain* swapChain = GetDevice()->CreateSwapChain(desc);
|
||||
if (swapChain == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
RHIScreenshot* screenshot = RHIScreenshot::Create(GetBackendType());
|
||||
if (screenshot != nullptr) {
|
||||
screenshot->Capture(GetDevice(), swapChain, "test_capture.ppm");
|
||||
screenshot->Shutdown();
|
||||
delete screenshot;
|
||||
}
|
||||
|
||||
swapChain->Shutdown();
|
||||
delete swapChain;
|
||||
}
|
||||
|
||||
TEST_P(RHITestFixture, Screenshot_Capture_WithPresent) {
|
||||
SwapChainDesc desc = {};
|
||||
desc.windowHandle = GetWindowHandle();
|
||||
desc.width = 800;
|
||||
desc.height = 600;
|
||||
desc.bufferCount = 2;
|
||||
desc.format = Format::R8G8B8A8_UNorm;
|
||||
|
||||
RHISwapChain* swapChain = GetDevice()->CreateSwapChain(desc);
|
||||
if (swapChain == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
swapChain->Present(0, 0);
|
||||
|
||||
RHIScreenshot* screenshot = RHIScreenshot::Create(GetBackendType());
|
||||
if (screenshot != nullptr) {
|
||||
screenshot->Capture(GetDevice(), swapChain, "test_capture2.ppm");
|
||||
screenshot->Shutdown();
|
||||
delete screenshot;
|
||||
}
|
||||
|
||||
swapChain->Shutdown();
|
||||
delete swapChain;
|
||||
}
|
||||
Reference in New Issue
Block a user