Module: wine Branch: master Commit: 02e5560d99c326d44324be078bf349275f6e3452 URL: http://source.winehq.org/git/wine.git/?a=commit;h=02e5560d99c326d44324be078b...
Author: Józef Kucia jkucia@codeweavers.com Date: Tue Apr 12 12:29:41 2016 +0200
dxgi/tests: Add test for IDXGISwapChain_GetContainingOutput().
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
---
dlls/dxgi/tests/device.c | 115 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+)
diff --git a/dlls/dxgi/tests/device.c b/dlls/dxgi/tests/device.c index 837618a..d8b1dd6 100644 --- a/dlls/dxgi/tests/device.c +++ b/dlls/dxgi/tests/device.c @@ -560,6 +560,120 @@ static void test_create_swapchain(void) DestroyWindow(creation_desc.OutputWindow); }
+static void test_get_containing_output(void) +{ + DXGI_OUTPUT_DESC output_desc, output_desc2; + DXGI_SWAP_CHAIN_DESC swapchain_desc; + IDXGIOutput *output, *output2; + unsigned int output_count; + IDXGISwapChain *swapchain; + IDXGIFactory *factory; + IDXGIAdapter *adapter; + IDXGIDevice *device; + ULONG refcount; + HRESULT hr; + + 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 = 800; + swapchain_desc.BufferDesc.Height = 600; + 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", 0, 0, 0, 0, 0, 0, 0, 0, 0); + swapchain_desc.Windowed = TRUE; + swapchain_desc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; + swapchain_desc.Flags = 0; + + output_count = 0; + while (IDXGIAdapter_EnumOutputs(adapter, output_count, &output) != DXGI_ERROR_NOT_FOUND) + { + ok(SUCCEEDED(hr), "Failed to enumarate output %u, hr %#x.\n", output_count, hr); + IDXGIOutput_Release(output); + ++output_count; + } + + if (output_count != 1) + { + skip("Adapter has %u outputs.\n", output_count); + goto done; + } + + hr = IDXGIAdapter_EnumOutputs(adapter, 0, &output); + ok(SUCCEEDED(hr), "EnumOutputs failed, hr %#x.\n", hr); + + refcount = get_refcount((IUnknown *)output); + todo_wine ok(refcount == 1, "Got unexpected refcount %u.\n", refcount); + + hr = IDXGIFactory_CreateSwapChain(factory, (IUnknown *)device, &swapchain_desc, &swapchain); + ok(SUCCEEDED(hr), "CreateSwapChain failed, hr %#x.\n", hr); + + hr = IDXGISwapChain_GetContainingOutput(swapchain, &output2); + ok(SUCCEEDED(hr) || broken(hr == DXGI_ERROR_UNSUPPORTED) /* Win 7 testbot */, + "GetContainingOutput failed, hr %#x.\n", hr); + if (hr == DXGI_ERROR_UNSUPPORTED) + { + IDXGISwapChain_Release(swapchain); + IDXGIOutput_Release(output); + goto done; + } + + refcount = get_refcount((IUnknown *)output); + todo_wine ok(refcount == 1, "Got unexpected refcount %u.\n", refcount); + refcount = get_refcount((IUnknown *)output2); + todo_wine ok(refcount == 1, "Got unexpected refcount %u.\n", refcount); + + hr = IDXGIOutput_GetDesc(output, &output_desc); + ok(SUCCEEDED(hr), "GetDesc failed, hr %#x.\n", hr); + hr = IDXGIOutput_GetDesc(output2, &output_desc2); + ok(SUCCEEDED(hr), "GetDesc failed, hr %#x.\n", hr); + + ok(!lstrcmpW(output_desc.DeviceName, output_desc2.DeviceName), + "Got unexpected device name %s, expected %s.\n", + wine_dbgstr_w(output_desc.DeviceName), wine_dbgstr_w(output_desc2.DeviceName)); + ok(!memcmp(&output_desc.DesktopCoordinates, &output_desc2.DesktopCoordinates, + sizeof(output_desc.DesktopCoordinates)), + "Got unexpected desktop coordinates {%d, %d, %d, %d}, expected {%d, %d, %d, %d}.\n", + output_desc.DesktopCoordinates.left, output_desc.DesktopCoordinates.top, + output_desc.DesktopCoordinates.right, output_desc.DesktopCoordinates.bottom, + output_desc2.DesktopCoordinates.left, output_desc2.DesktopCoordinates.top, + output_desc2.DesktopCoordinates.right, output_desc2.DesktopCoordinates.bottom); + + refcount = IDXGIOutput_Release(output2); + todo_wine ok(!refcount, "IDXGIOuput has %u references left.\n", refcount); + + refcount = IDXGISwapChain_Release(swapchain); + ok(!refcount, "IDXGISwapChain has %u references left.\n", refcount); + + refcount = IDXGIOutput_Release(output); + todo_wine ok(!refcount, "IDXGIOuput has %u references left.\n", refcount); + +done: + refcount = IDXGIDevice_Release(device); + ok(!refcount, "Device has %u references left.\n", refcount); + refcount = IDXGIAdapter_Release(adapter); + todo_wine 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) { IDXGIFactory1 *factory; @@ -1412,6 +1526,7 @@ START_TEST(device) test_parents(); test_output(); test_create_swapchain(); + test_get_containing_output(); test_create_factory(); test_private_data(); test_swapchain_resize();