From cf18ba1dc4e76172839965a7e85aba757cd72d2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= Date: Fri, 9 Oct 2015 03:19:14 +0200 Subject: [PATCH] d3d11/tests: Add test for ID3D11Device::GetImmediateContext(). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Józef Kucia Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/d3d11/tests/d3d11.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c index bcd370de65c..2fb13814c7e 100644 --- a/dlls/d3d11/tests/d3d11.c +++ b/dlls/d3d11/tests/d3d11.c @@ -292,6 +292,43 @@ static void test_device_interfaces(void) } } +static void test_get_immediate_context(void) +{ + ID3D11DeviceContext *immediate_context, *previous_immediate_context; + ULONG expected_refcount, refcount; + ID3D11Device *device; + + if (!(device = create_device(NULL))) + { + skip("Failed to create device.\n"); + return; + } + + expected_refcount = get_refcount((IUnknown *)device) + 1; + ID3D11Device_GetImmediateContext(device, &immediate_context); + refcount = get_refcount((IUnknown *)device); + ok(refcount == expected_refcount, "Got unexpected refcount %u.\n", refcount); + previous_immediate_context = immediate_context; + + ID3D11Device_GetImmediateContext(device, &immediate_context); + ok(immediate_context == previous_immediate_context, "Got different immediate device context objects.\n"); + refcount = get_refcount((IUnknown *)device); + ok(refcount == expected_refcount, "Got unexpected refcount %u.\n", refcount); + + refcount = ID3D11DeviceContext_Release(previous_immediate_context); + ok(refcount == 1, "Got unexpected refcount %u.\n", refcount); + refcount = ID3D11DeviceContext_Release(immediate_context); + ok(!refcount, "Got unexpected refcount %u.\n", refcount); + + ID3D11Device_GetImmediateContext(device, &immediate_context); + ok(immediate_context == previous_immediate_context, "Got different immediate device context objects.\n"); + refcount = ID3D11DeviceContext_Release(immediate_context); + ok(!refcount, "Got unexpected refcount %u.\n", refcount); + + refcount = ID3D11Device_Release(device); + ok(!refcount, "Device has %u references left.\n", refcount); +} + static void test_create_texture2d(void) { ULONG refcount, expected_refcount; @@ -2125,6 +2162,7 @@ START_TEST(d3d11) { test_create_device(); test_device_interfaces(); + test_get_immediate_context(); test_create_texture2d(); test_texture2d_interfaces(); test_create_texture3d();