Module: wine Branch: master Commit: 6061d909ad99502bae8223e6d6ef289d8e1b7926 URL: http://source.winehq.org/git/wine.git/?a=commit;h=6061d909ad99502bae8223e6d6...
Author: Józef Kucia jkucia@codeweavers.com Date: Tue Apr 12 12:29:36 2016 +0200
dxgi/tests: Add tests for reference counting.
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 | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-)
diff --git a/dlls/dxgi/tests/device.c b/dlls/dxgi/tests/device.c index 1e4022e..b92d3cc 100644 --- a/dlls/dxgi/tests/device.c +++ b/dlls/dxgi/tests/device.c @@ -1284,11 +1284,12 @@ static void test_maximum_frame_latency(void)
static void test_output_desc(void) { + IDXGIAdapter *adapter, *adapter2; + IDXGIOutput *output, *output2; DXGI_OUTPUT_DESC desc; IDXGIFactory *factory; - IDXGIAdapter *adapter; - IDXGIOutput *output; unsigned int i, j; + ULONG refcount; HRESULT hr;
hr = CreateDXGIFactory(&IID_IDXGIFactory, (void **)&factory); @@ -1301,6 +1302,18 @@ static void test_output_desc(void) break; ok(SUCCEEDED(hr), "Failed to enumerate adapter %u, hr %#x.\n", i, hr);
+ hr = IDXGIFactory_EnumAdapters(factory, i, &adapter2); + ok(SUCCEEDED(hr), "Failed to enumerate adapter %u, hr %#x.\n", i, hr); + todo_wine ok(adapter != adapter2, "Expected to get new instance of IDXGIAdapter, %p == %p.\n", adapter, adapter2); + refcount = get_refcount((IUnknown *)adapter); + todo_wine ok(refcount == 1, "Get unexpected refcount %u for adapter %u.\n", refcount, i); + IDXGIAdapter_Release(adapter2); + + refcount = get_refcount((IUnknown *)factory); + todo_wine ok(refcount == 2, "Get unexpected refcount %u.\n", refcount); + refcount = get_refcount((IUnknown *)adapter); + todo_wine ok(refcount == 1, "Get unexpected refcount %u for adapter %u.\n", refcount, i); + for (j = 0; ; ++j) { MONITORINFOEXW monitor_info; @@ -1311,6 +1324,20 @@ static void test_output_desc(void) break; ok(SUCCEEDED(hr), "Failed to enumerate output %u on adapter %u, hr %#x.\n", j, i, hr);
+ hr = IDXGIAdapter_EnumOutputs(adapter, j, &output2); + ok(SUCCEEDED(hr), "Failed to enumerate output %u on adapter %u, hr %#x.\n", j, i, hr); + todo_wine ok(output != output2, "Expected to get new instance of IDXGIOuput, %p == %p.\n", output, output2); + refcount = get_refcount((IUnknown *)output); + todo_wine ok(refcount == 1, "Get unexpected refcount %u for output %u, adapter %u.\n", refcount, j, i); + IDXGIOutput_Release(output2); + + refcount = get_refcount((IUnknown *)factory); + todo_wine ok(refcount == 2, "Get unexpected refcount %u.\n", refcount); + refcount = get_refcount((IUnknown *)adapter); + ok(refcount == 2, "Get unexpected refcount %u for adapter %u.\n", refcount, i); + refcount = get_refcount((IUnknown *)output); + todo_wine ok(refcount == 1, "Get unexpected refcount %u for output %u, adapter %u.\n", refcount, j, i); + hr = IDXGIOutput_GetDesc(output, NULL); ok(hr == E_INVALIDARG, "Got unexpected hr %#x for output %u on adapter %u.\n", hr, j, i); hr = IDXGIOutput_GetDesc(output, &desc); @@ -1329,12 +1356,17 @@ static void test_output_desc(void) monitor_info.rcMonitor.right, monitor_info.rcMonitor.bottom);
IDXGIOutput_Release(output); + refcount = get_refcount((IUnknown *)adapter); + todo_wine ok(refcount == 1, "Get unexpected refcount %u for adapter %u.\n", refcount, i); }
IDXGIAdapter_Release(adapter); + refcount = get_refcount((IUnknown *)factory); + ok(refcount == 1, "Get unexpected refcount %u.\n", refcount); }
- IDXGIFactory_Release(factory); + refcount = IDXGIFactory_Release(factory); + ok(!refcount, "IDXGIFactory has %u references left.\n", refcount); }
START_TEST(device)