ddraw/tests: Add a ddraw7 vertex buffer refcount test.
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
444475fb4a
commit
d2fe7bfd7c
|
@ -13059,6 +13059,74 @@ done:
|
|||
DestroyWindow(window);
|
||||
}
|
||||
|
||||
static void test_vb_refcount(void)
|
||||
{
|
||||
ULONG prev_d3d_refcount, prev_device_refcount;
|
||||
ULONG cur_d3d_refcount, cur_device_refcount;
|
||||
IDirect3DVertexBuffer7 *vb, *vb7;
|
||||
D3DVERTEXBUFFERDESC vb_desc;
|
||||
IDirect3DVertexBuffer *vb1;
|
||||
IDirect3DDevice7 *device;
|
||||
IDirect3D7 *d3d;
|
||||
ULONG refcount;
|
||||
IUnknown *unk;
|
||||
HWND window;
|
||||
HRESULT hr;
|
||||
|
||||
window = CreateWindowA("static", "d3d7_test", WS_OVERLAPPEDWINDOW,
|
||||
0, 0, 640, 480, 0, 0, 0, 0);
|
||||
if (!(device = create_device(window, DDSCL_NORMAL)))
|
||||
{
|
||||
skip("Failed to create a 3D device, skipping test.\n");
|
||||
DestroyWindow(window);
|
||||
return;
|
||||
}
|
||||
|
||||
hr = IDirect3DDevice7_GetDirect3D(device, &d3d);
|
||||
ok(SUCCEEDED(hr), "Failed to get Direct3D7 interface, hr %#x.\n", hr);
|
||||
|
||||
prev_d3d_refcount = get_refcount((IUnknown *)d3d);
|
||||
prev_device_refcount = get_refcount((IUnknown *)device);
|
||||
|
||||
memset(&vb_desc, 0, sizeof(vb_desc));
|
||||
vb_desc.dwSize = sizeof(vb_desc);
|
||||
vb_desc.dwFVF = D3DFVF_XYZ;
|
||||
vb_desc.dwNumVertices = 4;
|
||||
hr = IDirect3D7_CreateVertexBuffer(d3d, &vb_desc, &vb, 0);
|
||||
ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#x.\n", hr);
|
||||
|
||||
cur_d3d_refcount = get_refcount((IUnknown *)d3d);
|
||||
cur_device_refcount = get_refcount((IUnknown *)device);
|
||||
ok(cur_d3d_refcount > prev_d3d_refcount, "D3D object refcount didn't change from %u.\n", prev_d3d_refcount);
|
||||
ok(cur_device_refcount == prev_device_refcount, "Device refcount changed from %u to %u.\n",
|
||||
prev_device_refcount, cur_device_refcount);
|
||||
|
||||
prev_d3d_refcount = cur_d3d_refcount;
|
||||
hr = IDirect3DVertexBuffer7_QueryInterface(vb, &IID_IDirect3DVertexBuffer7, (void **)&vb7);
|
||||
ok(hr == DD_OK, "Failed to query IDirect3DVertexBuffer7, hr %#x.\n", hr);
|
||||
cur_d3d_refcount = get_refcount((IUnknown *)d3d);
|
||||
ok(cur_d3d_refcount == prev_d3d_refcount, "D3D object refcount changed from %u to %u.\n",
|
||||
prev_d3d_refcount, cur_d3d_refcount);
|
||||
IDirect3DVertexBuffer7_Release(vb7);
|
||||
|
||||
hr = IDirect3DVertexBuffer7_QueryInterface(vb, &IID_IDirect3DVertexBuffer, (void **)&vb1);
|
||||
ok(hr == E_NOINTERFACE, "Querying IDirect3DVertexBuffer returned unexpected hr %#x.\n", hr);
|
||||
|
||||
hr = IDirect3DVertexBuffer_QueryInterface(vb, &IID_IUnknown, (void **)&unk);
|
||||
ok(hr == DD_OK, "Failed to query IUnknown, hr %#x.\n", hr);
|
||||
ok((IUnknown *)vb == unk,
|
||||
"IDirect3DVertexBuffer7 and IUnknown interface pointers don't match, %p != %p.\n", vb, unk);
|
||||
IUnknown_Release(unk);
|
||||
|
||||
refcount = IDirect3DVertexBuffer7_Release(vb);
|
||||
ok(!refcount, "Vertex buffer has %u references left.\n", refcount);
|
||||
|
||||
IDirect3D7_Release(d3d);
|
||||
refcount = IDirect3DDevice7_Release(device);
|
||||
ok(!refcount, "Device has %u references left.\n", refcount);
|
||||
DestroyWindow(window);
|
||||
}
|
||||
|
||||
START_TEST(ddraw7)
|
||||
{
|
||||
HMODULE module = GetModuleHandleA("ddraw.dll");
|
||||
|
@ -13173,4 +13241,5 @@ START_TEST(ddraw7)
|
|||
test_surface_desc_size();
|
||||
test_get_surface_from_dc();
|
||||
test_ck_operation();
|
||||
test_vb_refcount();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue