d3d: Make sure the device is properly released when exiting the tests.

This commit is contained in:
Henri Verbeet 2008-12-29 09:14:29 +01:00 committed by Alexandre Julliard
parent a394dbec13
commit 664b58dc6f
10 changed files with 52 additions and 2 deletions

View File

@ -324,6 +324,7 @@ START_TEST(surface)
{
HMODULE d3d8_handle;
IDirect3DDevice8 *device_ptr;
ULONG refcount;
d3d8_handle = LoadLibraryA("d3d8.dll");
if (!d3d8_handle)
@ -339,4 +340,7 @@ START_TEST(surface)
test_surface_get_container(device_ptr);
test_lockrect_invalid(device_ptr);
test_private_data(device_ptr);
refcount = IDirect3DDevice8_Release(device_ptr);
ok(!refcount, "Device has %u references left\n", refcount);
}

View File

@ -135,6 +135,7 @@ START_TEST(texture)
D3DCAPS8 caps;
HMODULE d3d8_handle;
IDirect3DDevice8 *device_ptr;
ULONG refcount;
d3d8_handle = LoadLibraryA("d3d8.dll");
if (!d3d8_handle)
@ -150,4 +151,7 @@ START_TEST(texture)
test_texture_stage_states(device_ptr, caps.MaxTextureBlendStages);
test_cube_textures(device_ptr, caps.TextureCaps);
refcount = IDirect3DDevice8_Release(device_ptr);
ok(!refcount, "Device has %u references left\n", refcount);
}

View File

@ -1345,8 +1345,11 @@ START_TEST(visual)
cleanup:
if(device_ptr) {
D3DDEVICE_CREATION_PARAMETERS creation_parameters;
ULONG refcount;
IDirect3DDevice8_GetCreationParameters(device_ptr, &creation_parameters);
IDirect3DDevice8_Release(device_ptr);
refcount = IDirect3DDevice8_Release(device_ptr);
ok(!refcount, "Device has %u references left\n", refcount);
DestroyWindow(creation_parameters.hFocusWindow);
}
}

View File

@ -128,6 +128,7 @@ START_TEST(volume)
{
HMODULE d3d8_handle;
IDirect3DDevice8 *device_ptr;
ULONG refcount;
D3DCAPS8 caps;
d3d8_handle = LoadLibraryA("d3d8.dll");
@ -147,4 +148,7 @@ START_TEST(volume)
}
test_volume_get_container(device_ptr);
refcount = IDirect3DDevice8_Release(device_ptr);
ok(!refcount, "Device has %u references left\n", refcount);
}

View File

@ -110,6 +110,9 @@ static void test_get_set_vertex_shader(IDirect3DDevice9 *device_ptr)
ok(hret == D3D_OK && shader_refcount == i && current_shader_ptr == shader_ptr,
"GetVertexShader returned: hret 0x%x, current_shader_ptr %p refcount %d. "
"Expected hret 0x%x, current_shader_ptr %p, refcount %d.\n", hret, current_shader_ptr, shader_refcount, D3D_OK, shader_ptr, i);
IDirect3DVertexShader9_Release(current_shader_ptr);
IDirect3DVertexShader9_Release(shader_ptr);
}
static void test_vertex_shader_constant(IDirect3DDevice9 *device_ptr, DWORD consts)
@ -174,6 +177,9 @@ static void test_get_set_pixel_shader(IDirect3DDevice9 *device_ptr)
ok(hret == D3D_OK && shader_refcount == i && current_shader_ptr == shader_ptr,
"GetPixelShader returned: hret 0x%x, current_shader_ptr %p refcount %d. "
"Expected hret 0x%x, current_shader_ptr %p, refcount %d.\n", hret, current_shader_ptr, shader_refcount, D3D_OK, shader_ptr, i);
IDirect3DPixelShader9_Release(current_shader_ptr);
IDirect3DPixelShader9_Release(shader_ptr);
}
static void test_pixel_shader_constant(IDirect3DDevice9 *device_ptr)
@ -207,6 +213,7 @@ START_TEST(shader)
{
D3DCAPS9 caps;
IDirect3DDevice9 *device_ptr;
ULONG refcount;
d3d9_handle = LoadLibraryA("d3d9.dll");
if (!d3d9_handle)
@ -234,4 +241,7 @@ START_TEST(shader)
test_pixel_shader_constant(device_ptr);
}
else skip("No pixel shader support\n");
refcount = IDirect3DDevice9_Release(device_ptr);
ok(!refcount, "Device has %u references left\n", refcount);
}

View File

@ -91,6 +91,7 @@ static void test_begin_end_state_block(IDirect3DDevice9 *device_ptr)
ok(hret == D3D_OK && state_block_ptr != 0 && state_block_ptr != (IDirect3DStateBlock9 *)0xdeadbeef,
"EndStateBlock returned: hret 0x%x, state_block_ptr %p. "
"Expected hret 0x%x, state_block_ptr != %p, state_block_ptr != 0xdeadbeef.\n", hret, state_block_ptr, D3D_OK, NULL);
IDirect3DStateBlock9_Release(state_block_ptr);
/* Calling EndStateBlock while not recording should return D3DERR_INVALIDCALL. state_block_ptr should not be touched. */
state_block_ptr = (IDirect3DStateBlock9 *)0xdeadbeef;
@ -1583,5 +1584,9 @@ START_TEST(stateblock)
test_state_management(device_ptr, &device_pparams);
test_shader_constant_apply(device_ptr);
if (device_ptr) IUnknown_Release(device_ptr);
if (device_ptr)
{
ULONG refcount = IDirect3DDevice9_Release(device_ptr);
ok(!refcount, "Device has %u references left\n", refcount);
}
}

View File

@ -382,6 +382,7 @@ START_TEST(surface)
{
HMODULE d3d9_handle;
IDirect3DDevice9 *device_ptr;
ULONG refcount;
d3d9_handle = LoadLibraryA("d3d9.dll");
if (!d3d9_handle)
@ -398,4 +399,7 @@ START_TEST(surface)
test_lockrect_offset(device_ptr);
test_lockrect_invalid(device_ptr);
test_private_data(device_ptr);
refcount = IDirect3DDevice9_Release(device_ptr);
ok(!refcount, "Device has %u references left\n", refcount);
}

View File

@ -321,6 +321,7 @@ static void test_filter(IDirect3DDevice9 *device) {
}
hr = IDirect3DDevice9_SetTexture(device, 0, NULL);
IDirect3DTexture9_Release(texture);
out:
IDirect3D9_Release(d3d9);
@ -342,6 +343,7 @@ START_TEST(texture)
D3DCAPS9 caps;
HMODULE d3d9_handle;
IDirect3DDevice9 *device_ptr;
ULONG refcount;
d3d9_handle = LoadLibraryA("d3d9.dll");
if (!d3d9_handle)
@ -360,4 +362,7 @@ START_TEST(texture)
test_mipmap_gen(device_ptr);
test_filter(device_ptr);
test_gettexture(device_ptr);
refcount = IDirect3DDevice9_Release(device_ptr);
ok(!refcount, "Device has %u references left\n", refcount);
}

View File

@ -183,6 +183,7 @@ static void test_get_set_vertex_declaration(IDirect3DDevice9 *device_ptr, IDirec
ok(hret == D3D_OK && decl_refcount == i && current_decl_ptr == decl_ptr,
"GetVertexDeclaration returned: hret 0x%x, current_decl_ptr %p refcount %d. "
"Expected hret 0x%x, current_decl_ptr %p, refcount %d.\n", hret, current_decl_ptr, decl_refcount, D3D_OK, decl_ptr, i);
IDirect3DVertexDeclaration9_Release(current_decl_ptr);
}
static void test_get_declaration(IDirect3DVertexDeclaration9 *decl_ptr, D3DVERTEXELEMENT9 *vertex_decl, UINT expected_num_elements)
@ -852,6 +853,7 @@ START_TEST(vertexdeclaration)
UINT simple_decl_num_elements = sizeof(simple_decl) / sizeof(*simple_decl);
IDirect3DDevice9 *device_ptr = 0;
IDirect3DVertexDeclaration9 *decl_ptr = 0;
ULONG refcount;
d3d9_handle = LoadLibraryA("d3d9.dll");
if (!d3d9_handle)
@ -880,4 +882,9 @@ START_TEST(vertexdeclaration)
test_fvf_decl_management(device_ptr);
test_vertex_declaration_alignment(device_ptr);
test_unused_type(device_ptr);
IDirect3DVertexDeclaration9_Release(decl_ptr);
refcount = IDirect3DDevice9_Release(device_ptr);
ok(!refcount, "Device has %u references left\n", refcount);
}

View File

@ -125,6 +125,7 @@ START_TEST(volume)
{
HMODULE d3d9_handle;
IDirect3DDevice9 *device_ptr;
ULONG refcount;
D3DCAPS9 caps;
memset(&caps, 0, sizeof(caps));
@ -145,4 +146,7 @@ START_TEST(volume)
}
test_volume_get_container(device_ptr);
refcount = IDirect3DDevice9_Release(device_ptr);
ok(!refcount, "Device has %u references left\n", refcount);
}