ddraw/tests: LONG/ULONG and error checking fixes.

This commit is contained in:
Stefan Dösinger 2012-02-27 12:11:15 +01:00 committed by Alexandre Julliard
parent 6ee15adf4d
commit f8d6d0300b
3 changed files with 36 additions and 34 deletions

View file

@ -884,7 +884,7 @@ static void test_coop_level_threaded(void)
destroy_window_thread(&p);
}
static LONG get_refcount(IUnknown *test_iface)
static ULONG get_refcount(IUnknown *test_iface)
{
IUnknown_AddRef(test_iface);
return IUnknown_Release(test_iface);
@ -895,7 +895,7 @@ static void test_viewport_interfaces(void)
IDirectDraw *ddraw;
IDirect3D *d3d;
HRESULT hr;
LONG ref;
ULONG ref;
IDirect3DViewport *viewport;
IDirect3DViewport2 *viewport2;
IDirect3DViewport3 *viewport3;
@ -921,9 +921,9 @@ static void test_viewport_interfaces(void)
hr = IDirect3D_CreateViewport(d3d, &viewport, NULL);
ok(SUCCEEDED(hr), "Failed to create viewport, hr %#x.\n", hr);
ref = get_refcount((IUnknown *)viewport);
ok(ref == 1, "Initial IDirect3DViewport refcount is %d\n", ref);
ok(ref == 1, "Initial IDirect3DViewport refcount is %u\n", ref);
ref = get_refcount((IUnknown *)d3d);
ok(ref == 2, "IDirect3D refcount is %d\n", ref);
ok(ref == 2, "IDirect3D refcount is %u\n", ref);
/* E_FAIL return values are returned by Winetestbot Windows NT machines. While not supporting
* newer interfaces is legitimate for old ddraw versions, E_FAIL violates Microsoft's rules
@ -936,25 +936,27 @@ static void test_viewport_interfaces(void)
/* NULL iid: Segfaults */
hr = IDirect3DViewport_QueryInterface(viewport, &IID_IDirect3DViewport2, (void **)&viewport2);
ok(SUCCEEDED(hr) || broken(hr == E_FAIL), "Failed to QI IDirect3DViewport2, hr %#x.\n", hr);
ok(SUCCEEDED(hr) || hr == E_NOINTERFACE || broken(hr == E_FAIL),
"Failed to QI IDirect3DViewport2, hr %#x.\n", hr);
if (viewport2)
{
ref = get_refcount((IUnknown *)viewport);
ok(ref == 2, "IDirect3DViewport refcount is %d\n", ref);
ok(ref == 2, "IDirect3DViewport refcount is %u\n", ref);
ref = get_refcount((IUnknown *)viewport2);
ok(ref == 2, "IDirect3DViewport2 refcount is %d\n", ref);
ok(ref == 2, "IDirect3DViewport2 refcount is %u\n", ref);
IDirect3DViewport2_Release(viewport2);
viewport2 = NULL;
}
hr = IDirect3DViewport_QueryInterface(viewport, &IID_IDirect3DViewport3, (void **)&viewport3);
ok(SUCCEEDED(hr) || broken(hr == E_FAIL), "Failed to QI IDirect3DViewport3, hr %#x.\n", hr);
ok(SUCCEEDED(hr) || hr == E_NOINTERFACE || broken(hr == E_FAIL),
"Failed to QI IDirect3DViewport3, hr %#x.\n", hr);
if (viewport3)
{
ref = get_refcount((IUnknown *)viewport);
ok(ref == 2, "IDirect3DViewport refcount is %d\n", ref);
ok(ref == 2, "IDirect3DViewport refcount is %u\n", ref);
ref = get_refcount((IUnknown *)viewport3);
ok(ref == 2, "IDirect3DViewport3 refcount is %d\n", ref);
ok(ref == 2, "IDirect3DViewport3 refcount is %u\n", ref);
IDirect3DViewport3_Release(viewport3);
}
@ -963,9 +965,9 @@ static void test_viewport_interfaces(void)
if (unknown)
{
ref = get_refcount((IUnknown *)viewport);
ok(ref == 2, "IDirect3DViewport refcount is %d\n", ref);
ok(ref == 2, "IDirect3DViewport refcount is %u\n", ref);
ref = get_refcount(unknown);
ok(ref == 2, "IUnknown refcount is %d\n", ref);
ok(ref == 2, "IUnknown refcount is %u\n", ref);
IUnknown_Release(unknown);
}

View file

@ -1179,7 +1179,7 @@ done:
if (ddraw) IDirectDraw2_Release(ddraw);
}
static LONG get_refcount(IUnknown *test_iface)
static ULONG get_refcount(IUnknown *test_iface)
{
IUnknown_AddRef(test_iface);
return IUnknown_Release(test_iface);
@ -1190,7 +1190,7 @@ static void test_viewport_interfaces(void)
IDirectDraw2 *ddraw;
IDirect3D2 *d3d;
HRESULT hr;
LONG ref, old_d3d_ref;
ULONG ref, old_d3d_ref;
IDirect3DViewport *viewport;
IDirect3DViewport2 *viewport2;
IDirect3DViewport3 *viewport3;
@ -1216,9 +1216,9 @@ static void test_viewport_interfaces(void)
hr = IDirect3D2_CreateViewport(d3d, &viewport2, NULL);
ok(SUCCEEDED(hr), "Failed to create viewport, hr %#x.\n", hr);
ref = get_refcount((IUnknown *)viewport2);
ok(ref == 1, "Initial IDirect3DViewport2 refcount is %d\n", ref);
ok(ref == 1, "Initial IDirect3DViewport2 refcount is %u\n", ref);
ref = get_refcount((IUnknown *)d3d);
ok(ref == old_d3d_ref, "IDirect3D2 refcount is %d\n", ref);
ok(ref == old_d3d_ref, "IDirect3D2 refcount is %u\n", ref);
gamma = (IDirectDrawGammaControl *)0xdeadbeef;
hr = IDirect3DViewport2_QueryInterface(viewport2, &IID_IDirectDrawGammaControl, (void **)&gamma);
@ -1232,21 +1232,21 @@ static void test_viewport_interfaces(void)
if (viewport)
{
ref = get_refcount((IUnknown *)viewport);
ok(ref == 2, "IDirect3DViewport refcount is %d\n", ref);
ok(ref == 2, "IDirect3DViewport refcount is %u\n", ref);
ref = get_refcount((IUnknown *)viewport2);
ok(ref == 2, "IDirect3DViewport2 refcount is %d\n", ref);
ok(ref == 2, "IDirect3DViewport2 refcount is %u\n", ref);
IDirect3DViewport_Release(viewport);
viewport = NULL;
}
hr = IDirect3DViewport2_QueryInterface(viewport2, &IID_IDirect3DViewport3, (void **)&viewport3);
ok(SUCCEEDED(hr), "Failed to QI IDirect3DViewport3, hr %#x.\n", hr);
ok(SUCCEEDED(hr) || hr == E_NOINTERFACE, "Failed to QI IDirect3DViewport3, hr %#x.\n", hr);
if (viewport3)
{
ref = get_refcount((IUnknown *)viewport2);
ok(ref == 2, "IDirect3DViewport2 refcount is %d\n", ref);
ok(ref == 2, "IDirect3DViewport2 refcount is %u\n", ref);
ref = get_refcount((IUnknown *)viewport3);
ok(ref == 2, "IDirect3DViewport3 refcount is %d\n", ref);
ok(ref == 2, "IDirect3DViewport3 refcount is %u\n", ref);
IDirect3DViewport3_Release(viewport3);
}
@ -1255,9 +1255,9 @@ static void test_viewport_interfaces(void)
if (unknown)
{
ref = get_refcount((IUnknown *)viewport2);
ok(ref == 2, "IDirect3DViewport2 refcount is %d\n", ref);
ok(ref == 2, "IDirect3DViewport2 refcount is %u\n", ref);
ref = get_refcount(unknown);
ok(ref == 2, "IUnknown refcount is %d\n", ref);
ok(ref == 2, "IUnknown refcount is %u\n", ref);
IUnknown_Release(unknown);
}

View file

@ -1310,7 +1310,7 @@ static void test_texture_load_ckey(void)
IDirectDraw4_Release(ddraw);
}
static LONG get_refcount(IUnknown *test_iface)
static ULONG get_refcount(IUnknown *test_iface)
{
IUnknown_AddRef(test_iface);
return IUnknown_Release(test_iface);
@ -1321,7 +1321,7 @@ static void test_viewport_interfaces(void)
IDirectDraw4 *ddraw;
IDirect3D3 *d3d;
HRESULT hr, old_d3d_ref;
LONG ref;
ULONG ref;
IDirect3DViewport *viewport;
IDirect3DViewport2 *viewport2;
IDirect3DViewport3 *viewport3;
@ -1346,9 +1346,9 @@ static void test_viewport_interfaces(void)
hr = IDirect3D3_CreateViewport(d3d, &viewport3, NULL);
ok(SUCCEEDED(hr), "Failed to create viewport, hr %#x.\n", hr);
ref = get_refcount((IUnknown *)viewport3);
ok(ref == 1, "Initial IDirect3DViewport3 refcount is %d\n", ref);
ok(ref == 1, "Initial IDirect3DViewport3 refcount is %u\n", ref);
ref = get_refcount((IUnknown *)d3d);
ok(ref == old_d3d_ref, "IDirect3D3 refcount is %d\n", ref);
ok(ref == old_d3d_ref, "IDirect3D3 refcount is %u\n", ref);
gamma = (IDirectDrawGammaControl *)0xdeadbeef;
hr = IDirect3DViewport2_QueryInterface(viewport3, &IID_IDirectDrawGammaControl, (void **)&gamma);
@ -1362,9 +1362,9 @@ static void test_viewport_interfaces(void)
if (viewport)
{
ref = get_refcount((IUnknown *)viewport);
ok(ref == 2, "IDirect3DViewport refcount is %d\n", ref);
ok(ref == 2, "IDirect3DViewport refcount is %u\n", ref);
ref = get_refcount((IUnknown *)viewport3);
ok(ref == 2, "IDirect3DViewport3 refcount is %d\n", ref);
ok(ref == 2, "IDirect3DViewport3 refcount is %u\n", ref);
IDirect3DViewport_Release(viewport);
viewport = NULL;
}
@ -1374,20 +1374,20 @@ static void test_viewport_interfaces(void)
if (viewport2)
{
ref = get_refcount((IUnknown *)viewport2);
ok(ref == 2, "IDirect3DViewport2 refcount is %d\n", ref);
ok(ref == 2, "IDirect3DViewport2 refcount is %u\n", ref);
ref = get_refcount((IUnknown *)viewport3);
ok(ref == 2, "IDirect3DViewport3 refcount is %d\n", ref);
ok(ref == 2, "IDirect3DViewport3 refcount is %u\n", ref);
IDirect3DViewport3_Release(viewport2);
}
hr = IDirect3DViewport3_QueryInterface(viewport2, &IID_IUnknown, (void **)&unknown);
hr = IDirect3DViewport3_QueryInterface(viewport3, &IID_IUnknown, (void **)&unknown);
ok(SUCCEEDED(hr), "Failed to QI IUnknown, hr %#x.\n", hr);
if (unknown)
{
ref = get_refcount((IUnknown *)viewport3);
ok(ref == 2, "IDirect3DViewport3 refcount is %d\n", ref);
ok(ref == 2, "IDirect3DViewport3 refcount is %u\n", ref);
ref = get_refcount(unknown);
ok(ref == 2, "IUnknown refcount is %d\n", ref);
ok(ref == 2, "IUnknown refcount is %u\n", ref);
IUnknown_Release(unknown);
}