dxgi/tests: Add test for default fullscreen target output.

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Józef Kucia 2016-08-03 09:41:47 +02:00 committed by Alexandre Julliard
parent 47430b9264
commit 709ca356cd
1 changed files with 123 additions and 1 deletions

View File

@ -386,7 +386,7 @@ static void test_output(void)
"Failed to list modes, hr %#x.\n", hr); "Failed to list modes, hr %#x.\n", hr);
if (hr == DXGI_ERROR_NOT_CURRENTLY_AVAILABLE) if (hr == DXGI_ERROR_NOT_CURRENTLY_AVAILABLE)
{ {
skip("GetDisplayModeList() not supported, skipping tests.\n"); win_skip("GetDisplayModeList() not supported.\n");
IDXGIOutput_Release(output); IDXGIOutput_Release(output);
IDXGIAdapter_Release(adapter); IDXGIAdapter_Release(adapter);
IDXGIDevice_Release(device); IDXGIDevice_Release(device);
@ -750,6 +750,7 @@ static void test_get_containing_output(void)
"GetContainingOutput failed, hr %#x.\n", hr); "GetContainingOutput failed, hr %#x.\n", hr);
if (hr == DXGI_ERROR_UNSUPPORTED) if (hr == DXGI_ERROR_UNSUPPORTED)
{ {
win_skip("GetContainingOutput() not supported.\n");
IDXGISwapChain_Release(swapchain); IDXGISwapChain_Release(swapchain);
goto done; goto done;
} }
@ -1296,6 +1297,126 @@ done:
ok(!refcount, "Factory has %u references left.\n", refcount); ok(!refcount, "Factory has %u references left.\n", refcount);
} }
static void test_default_fullscreen_target_output(void)
{
IDXGIOutput *output, *containing_output, *target;
DXGI_SWAP_CHAIN_DESC swapchain_desc;
DXGI_OUTPUT_DESC output_desc;
IDXGISwapChain *swapchain;
unsigned int output_idx;
IDXGIFactory *factory;
IDXGIAdapter *adapter;
IDXGIDevice *device;
ULONG refcount;
HRESULT hr;
BOOL ret;
if (!(device = create_device()))
{
skip("Failed to create device.\n");
return;
}
hr = IDXGIDevice_GetAdapter(device, &adapter);
ok(SUCCEEDED(hr), "GetAdapter failed, hr %#x.\n", hr);
hr = IDXGIAdapter_GetParent(adapter, &IID_IDXGIFactory, (void **)&factory);
ok(SUCCEEDED(hr), "GetParent failed, hr %#x.\n", hr);
swapchain_desc.BufferDesc.Width = 100;
swapchain_desc.BufferDesc.Height = 100;
swapchain_desc.BufferDesc.RefreshRate.Numerator = 60;
swapchain_desc.BufferDesc.RefreshRate.Denominator = 60;
swapchain_desc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
swapchain_desc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
swapchain_desc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
swapchain_desc.SampleDesc.Count = 1;
swapchain_desc.SampleDesc.Quality = 0;
swapchain_desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
swapchain_desc.BufferCount = 1;
swapchain_desc.OutputWindow = CreateWindowA("static", "dxgi_test",
WS_OVERLAPPEDWINDOW | WS_VISIBLE, 0, 0, 100, 100, 0, 0, 0, 0);
swapchain_desc.Windowed = TRUE;
swapchain_desc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
swapchain_desc.Flags = 0;
hr = IDXGIFactory_CreateSwapChain(factory, (IUnknown *)device, &swapchain_desc, &swapchain);
ok(SUCCEEDED(hr), "CreateSwapChain failed, hr %#x.\n", hr);
output_idx = 0;
while ((hr = IDXGIAdapter_EnumOutputs(adapter, output_idx, &output)) != DXGI_ERROR_NOT_FOUND)
{
ok(SUCCEEDED(hr), "Failed to enumarate output %u, hr %#x.\n", output_idx, hr);
hr = IDXGIOutput_GetDesc(output, &output_desc);
ok(SUCCEEDED(hr), "GetDesc failed, hr %#x.\n", hr);
/* Move the OutputWindow to the current output. */
ret = SetWindowPos(swapchain_desc.OutputWindow, 0,
output_desc.DesktopCoordinates.left, output_desc.DesktopCoordinates.top,
0, 0, SWP_NOSIZE | SWP_NOZORDER);
ok(ret, "SetWindowPos failed.\n");
hr = IDXGISwapChain_GetContainingOutput(swapchain, &containing_output);
ok(SUCCEEDED(hr) || broken(hr == DXGI_ERROR_UNSUPPORTED) /* Win 7 testbot */,
"GetContainingOutput failed, hr %#x.\n", hr);
if (hr == DXGI_ERROR_UNSUPPORTED)
{
win_skip("GetContainingOutput() not supported.\n");
IDXGIOutput_Release(output);
goto done;
}
hr = IDXGISwapChain_SetFullscreenState(swapchain, TRUE, NULL);
ok(SUCCEEDED(hr) || hr == DXGI_ERROR_NOT_CURRENTLY_AVAILABLE,
"SetFullscreenState failed, hr %#x.\n", hr);
if (hr == DXGI_ERROR_NOT_CURRENTLY_AVAILABLE)
{
skip("Could not change fullscreen state.\n");
IDXGIOutput_Release(containing_output);
IDXGIOutput_Release(output);
goto done;
}
target = NULL;
hr = IDXGISwapChain_GetFullscreenState(swapchain, NULL, &target);
ok(SUCCEEDED(hr), "GetFullscreenState failed, hr %#x.\n", hr);
ok(target != containing_output, "Got unexpected output pointers %p, %p.\n",
target, containing_output);
check_output_equal(target, containing_output);
refcount = IDXGIOutput_Release(containing_output);
ok(!refcount, "IDXGIOutput has %u references left.\n", refcount);
hr = IDXGISwapChain_GetContainingOutput(swapchain, &containing_output);
ok(SUCCEEDED(hr), "GetContainingOutput failed, hr %#x.\n", hr);
ok(containing_output == target, "Got unexpected containing output %p, expected %p.\n",
containing_output, target);
refcount = IDXGIOutput_Release(containing_output);
ok(refcount >= 2, "Got unexpected refcount %u.\n", refcount);
refcount = IDXGIOutput_Release(target);
ok(refcount >= 1, "Got unexpected refcount %u.\n", refcount);
hr = IDXGISwapChain_SetFullscreenState(swapchain, FALSE, NULL);
ok(SUCCEEDED(hr), "SetFullscreenState failed, hr %#x.\n", hr);
IDXGIOutput_Release(output);
++output_idx;
}
done:
refcount = IDXGISwapChain_Release(swapchain);
ok(!refcount, "IDXGISwapChain has %u references left.\n", refcount);
refcount = IDXGIDevice_Release(device);
ok(!refcount, "Device has %u references left.\n", refcount);
refcount = IDXGIAdapter_Release(adapter);
ok(!refcount, "Adapter has %u references left.\n", refcount);
refcount = IDXGIFactory_Release(factory);
ok(!refcount, "Factory has %u references left.\n", refcount);
DestroyWindow(swapchain_desc.OutputWindow);
}
static void test_create_factory(void) static void test_create_factory(void)
{ {
IDXGIFactory1 *factory; IDXGIFactory1 *factory;
@ -2146,6 +2267,7 @@ START_TEST(device)
test_create_swapchain(); test_create_swapchain();
test_get_containing_output(); test_get_containing_output();
test_set_fullscreen(); test_set_fullscreen();
test_default_fullscreen_target_output();
test_create_factory(); test_create_factory();
test_private_data(); test_private_data();
test_swapchain_resize(); test_swapchain_resize();