Commit 0666950b authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

ddrawex/tests: Simplify refcount helper.

parent 5a0f4836
...@@ -37,10 +37,11 @@ static IDirectDraw *createDDraw(void) ...@@ -37,10 +37,11 @@ static IDirectDraw *createDDraw(void)
return SUCCEEDED(hr) ? dd : NULL; return SUCCEEDED(hr) ? dd : NULL;
} }
static ULONG get_ref(IUnknown *o) static ULONG get_refcount(void *iface)
{ {
IUnknown_AddRef(o); IUnknown *unknown = iface;
return IUnknown_Release(o); IUnknown_AddRef(unknown);
return IUnknown_Release(unknown);
} }
static void RefCountTest(void) static void RefCountTest(void)
...@@ -52,11 +53,11 @@ static void RefCountTest(void) ...@@ -52,11 +53,11 @@ static void RefCountTest(void)
HRESULT hr; HRESULT hr;
ULONG ref; ULONG ref;
ref = get_ref((IUnknown *) dd1); ref = get_refcount(dd1);
ok(ref == 1, "Unexpected refcount %lu.\n", ref); ok(ref == 1, "Unexpected refcount %lu.\n", ref);
IDirectDraw_AddRef(dd1); IDirectDraw_AddRef(dd1);
ref = get_ref((IUnknown *) dd1); ref = get_refcount(dd1);
if (ref == 1) if (ref == 1)
{ {
win_skip("Refcounting is broken\n"); win_skip("Refcounting is broken\n");
...@@ -65,15 +66,15 @@ static void RefCountTest(void) ...@@ -65,15 +66,15 @@ static void RefCountTest(void)
} }
ok(ref == 2, "Unexpected refcount %lu.\n", ref); ok(ref == 2, "Unexpected refcount %lu.\n", ref);
IDirectDraw_Release(dd1); IDirectDraw_Release(dd1);
ref = get_ref((IUnknown *) dd1); ref = get_refcount(dd1);
ok(ref == 1, "Unexpected refcount %lu.\n", ref); ok(ref == 1, "Unexpected refcount %lu.\n", ref);
IDirectDraw_QueryInterface(dd1, &IID_IDirectDraw2, (void **) &dd2); IDirectDraw_QueryInterface(dd1, &IID_IDirectDraw2, (void **) &dd2);
ref = get_ref((IUnknown *) dd2); ref = get_refcount(dd2);
ok(ref == 2, "Unexpected refcount %lu.\n", ref); ok(ref == 2, "Unexpected refcount %lu.\n", ref);
IDirectDraw_QueryInterface(dd1, &IID_IDirectDraw3, (void **) &dd3); IDirectDraw_QueryInterface(dd1, &IID_IDirectDraw3, (void **) &dd3);
ref = get_ref((IUnknown *) dd3); ref = get_refcount(dd3);
ok(ref == 3, "Unexpected refcount %lu.\n", ref); ok(ref == 3, "Unexpected refcount %lu.\n", ref);
hr = IDirectDraw_QueryInterface(dd1, &IID_IDirectDraw4, (void **) &dd4); hr = IDirectDraw_QueryInterface(dd1, &IID_IDirectDraw4, (void **) &dd4);
...@@ -85,14 +86,14 @@ static void RefCountTest(void) ...@@ -85,14 +86,14 @@ static void RefCountTest(void)
IDirectDraw3_Release(dd3); IDirectDraw3_Release(dd3);
return; return;
} }
ref = get_ref((IUnknown *) dd4); ref = get_refcount(dd4);
ok(ref == 4, "Unexpected refcount %lu.\n", ref); ok(ref == 4, "Unexpected refcount %lu.\n", ref);
IDirectDraw_Release(dd1); IDirectDraw_Release(dd1);
IDirectDraw2_Release(dd2); IDirectDraw2_Release(dd2);
IDirectDraw3_Release(dd3); IDirectDraw3_Release(dd3);
ref = get_ref((IUnknown *) dd4); ref = get_refcount(dd4);
ok(ref == 1, "Unexpected refcount %lu.\n", ref); ok(ref == 1, "Unexpected refcount %lu.\n", ref);
IDirectDraw4_Release(dd4); IDirectDraw4_Release(dd4);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment