[PATCH] Fix to ddtest to fail test if IDirectDraw_CreateSurface failed. Create Surface was failing and setting the handle to the surface to null. So when the free / release was called it threw an exception instead of failing the test.
Chris Ahrendt
celticht32 at aol.com
Sun Oct 12 20:44:21 CDT 2008
---
dlls/ddraw/tests/dsurface.c | 92 ++++++++++++++++++++++++++++++++++---------
1 files changed, 73 insertions(+), 19 deletions(-)
diff --git a/dlls/ddraw/tests/dsurface.c b/dlls/ddraw/tests/dsurface.c
index fc7bb88..4f545d9 100644
--- a/dlls/ddraw/tests/dsurface.c
+++ b/dlls/ddraw/tests/dsurface.c
@@ -198,7 +198,10 @@ static void MipMapCreationTest(void)
ddsd.dwHeight = 32;
rc = IDirectDraw_CreateSurface(lpDD, &ddsd, &lpDDSMipMapTest, NULL);
ok(rc==DDERR_INVALIDPARAMS,"CreateSurface returned: %x\n",rc);
-
+ if (FAILED(rc)) {
+ skip("failed to create surface\n");
+ return;
+ }
/* Destroy the surface. */
if( rc == DD_OK )
IDirectDrawSurface_Release(lpDDSMipMapTest);
@@ -1004,7 +1007,10 @@ static void EnumTest(void)
ddsd.dwHeight = 32;
rc = IDirectDraw_CreateSurface(lpDD, &ddsd, &surface, NULL);
ok(rc==DD_OK,"CreateSurface returned: %x\n",rc);
-
+ if (FAILED(rc)) {
+ skip("failed to create surface\n");
+ return;
+ }
memset(&ctx, 0, sizeof(ctx));
ctx.expected[0] = surface;
rc = IDirectDrawSurface_GetAttachedSurface(ctx.expected[0], &ddsd.ddsCaps, &ctx.expected[1]);
@@ -1055,7 +1061,10 @@ static void AttachmentTest7(void)
ddsd.dwHeight = 128;
hr = IDirectDraw7_CreateSurface(dd7, &ddsd, &surface1, NULL);
ok(hr==DD_OK,"CreateSurface returned: %x\n",hr);
-
+ if (FAILED(hr)) {
+ skip("failed to create surface\n");
+ return;
+ }
/* ROOT */
num = 0;
IDirectDrawSurface7_EnumAttachedSurfaces(surface1, &num, SurfaceCounter);
@@ -1092,7 +1101,10 @@ static void AttachmentTest7(void)
ddsd.dwHeight = 16;
hr = IDirectDraw7_CreateSurface(dd7, &ddsd, &surface2, NULL);
ok(hr==DD_OK,"CreateSurface returned: %x\n",hr);
-
+ if (FAILED(hr)) {
+ skip("failed to create surface2\n");
+ return;
+ }
hr = IDirectDrawSurface7_AddAttachedSurface(surface1, surface2);
ok(hr == DDERR_CANNOTATTACHSURFACE, "Attaching a 16x16 surface to a 128x128 texture root returned %08x\n", hr);
hr = IDirectDrawSurface7_AddAttachedSurface(surface2, surface1);
@@ -1112,7 +1124,10 @@ static void AttachmentTest7(void)
ddsd.dwHeight = 16;
hr = IDirectDraw7_CreateSurface(dd7, &ddsd, &surface2, NULL);
ok(hr==DD_OK,"CreateSurface returned: %x\n",hr);
-
+ if (FAILED(hr)) {
+ skip("failed to create surface\n");
+ return;
+ }
hr = IDirectDrawSurface7_AddAttachedSurface(surface1, surface2);
ok(hr == DDERR_CANNOTATTACHSURFACE, "Attaching a 16x16 offscreen plain surface to a 128x128 texture root returned %08x\n", hr);
hr = IDirectDrawSurface7_AddAttachedSurface(surface2, surface1);
@@ -1136,7 +1151,10 @@ static void AttachmentTest7(void)
ddsd.dwBackBufferCount = 2;
hr = IDirectDraw7_CreateSurface(dd7, &ddsd, &surface1, NULL);
ok(hr==DD_OK,"CreateSurface returned: %x\n",hr);
-
+ if (FAILED(hr)) {
+ skip("failed to create surface\n");
+ return;
+ }
num = 0;
IDirectDrawSurface7_EnumAttachedSurfaces(surface1, &num, SurfaceCounter);
ok(num == 1, "Primary surface has %d surfaces attached, expected 1\n", num);
@@ -1149,13 +1167,20 @@ static void AttachmentTest7(void)
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FRONTBUFFER;
hr = IDirectDraw7_CreateSurface(dd7, &ddsd, &surface1, NULL);
ok(hr==DDERR_INVALIDCAPS,"CreateSurface returned: %x\n",hr);
+ if (FAILED(hr)) {
+ skip("failed to create surface1\n");
+ return;
+ }
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_BACKBUFFER;
hr = IDirectDraw7_CreateSurface(dd7, &ddsd, &surface2, NULL);
ok(hr==DDERR_INVALIDCAPS,"CreateSurface returned: %x\n",hr);
-
+ if (FAILED(hr)) {
+ skip("failed to create surface2\n");
+ return;
+ }
/* Try a single primary and two offscreen plain surfaces */
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
@@ -1163,7 +1188,10 @@ static void AttachmentTest7(void)
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
hr = IDirectDraw7_CreateSurface(dd7, &ddsd, &surface1, NULL);
ok(hr==DD_OK,"CreateSurface returned: %x\n",hr);
-
+ if (FAILED(hr)) {
+ skip("failed to create surface1\n");
+ return;
+ }
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
@@ -1172,7 +1200,10 @@ static void AttachmentTest7(void)
ddsd.dwHeight = GetSystemMetrics(SM_CYSCREEN);
hr = IDirectDraw7_CreateSurface(dd7, &ddsd, &surface2, NULL);
ok(hr==DD_OK,"CreateSurface returned: %x\n",hr);
-
+ if (FAILED(hr)) {
+ skip("failed to create surface2\n");
+ return;
+ }
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
@@ -1181,7 +1212,10 @@ static void AttachmentTest7(void)
ddsd.dwHeight = GetSystemMetrics(SM_CYSCREEN);
hr = IDirectDraw7_CreateSurface(dd7, &ddsd, &surface3, NULL);
ok(hr==DD_OK,"CreateSurface returned: %x\n",hr);
-
+ if (FAILED(hr)) {
+ skip("failed to create surface3\n");
+ return;
+ }
/* This one has a different size */
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
@@ -1191,6 +1225,10 @@ static void AttachmentTest7(void)
ddsd.dwHeight = 128;
hr = IDirectDraw7_CreateSurface(dd7, &ddsd, &surface4, NULL);
ok(hr==DD_OK,"CreateSurface returned: %x\n",hr);
+ if (FAILED(hr)) {
+ skip("failed to create surface4\n");
+ return;
+ }
hr = IDirectDrawSurface7_AddAttachedSurface(surface1, surface2);
ok(hr == DDERR_CANNOTATTACHSURFACE, "Attaching an offscreen plain surface to a front buffer returned %08x\n", hr);
@@ -1334,7 +1372,7 @@ static void AttachmentTest(void)
ddsd.dwFlags = DDSD_CAPS;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FRONTBUFFER;
hr = IDirectDraw_CreateSurface(lpDD, &ddsd, &surface1, NULL);
- ok(hr==DD_OK,"CreateSurface returned: %x\n",hr);
+ ok(hr==DD_OK,"CreateSurface return ed: %x\n",hr);
IDirectDrawSurface_Release(surface1);
/* Try a single primary and two offscreen plain surfaces */
@@ -1344,7 +1382,10 @@ static void AttachmentTest(void)
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
hr = IDirectDraw_CreateSurface(lpDD, &ddsd, &surface1, NULL);
ok(hr==DD_OK,"CreateSurface returned: %x\n",hr);
-
+ if (FAILED(hr)) {
+ skip("failed to create surface1\n");
+ return;
+ }
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
@@ -1353,7 +1394,10 @@ static void AttachmentTest(void)
ddsd.dwHeight = GetSystemMetrics(SM_CYSCREEN);
hr = IDirectDraw_CreateSurface(lpDD, &ddsd, &surface2, NULL);
ok(hr==DD_OK,"CreateSurface returned: %x\n",hr);
-
+ if (FAILED(hr)) {
+ skip("failed to create surface2\n");
+ return;
+ }
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
@@ -1362,7 +1406,10 @@ static void AttachmentTest(void)
ddsd.dwHeight = GetSystemMetrics(SM_CYSCREEN);
hr = IDirectDraw_CreateSurface(lpDD, &ddsd, &surface3, NULL);
ok(hr==DD_OK,"CreateSurface returned: %x\n",hr);
-
+ if (FAILED(hr)) {
+ skip("failed to create surface3\n");
+ return;
+ }
/* This one has a different size */
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
@@ -1372,7 +1419,10 @@ static void AttachmentTest(void)
ddsd.dwHeight = 128;
hr = IDirectDraw_CreateSurface(lpDD, &ddsd, &surface4, NULL);
ok(hr==DD_OK,"CreateSurface returned: %x\n",hr);
-
+ if (FAILED(hr)) {
+ skip("failed to create surface4\n");
+ return;
+ }
hr = IDirectDrawSurface_AddAttachedSurface(surface1, surface2);
ok(hr == DD_OK, "Attaching an offscreen plain surface to a front buffer returned %08x\n", hr);
/* Try the reverse without detaching first */
@@ -2208,6 +2258,10 @@ static void SizeTest(void)
desc.dwWidth = 128; /* Keep them set to check what happens */
ret = IDirectDraw_CreateSurface(lpDD, &desc, &dsurface, NULL);
ok(ret == DD_OK, "Creating a primary surface without width and height info returned %08x\n", ret);
+ if (FAILED(ret)) {
+ skip("failed to create surface\n");
+ return;
+ }
if(dsurface)
{
ret = IDirectDrawSurface_GetSurfaceDesc(dsurface, &desc);
@@ -2491,9 +2545,9 @@ static void PaletteTest(void)
hr = IDirectDraw_CreateSurface(lpDD, &ddsd, &lpSurf, NULL);
ok(hr==DD_OK, "CreateSurface returned: %x\n",hr);
if (FAILED(hr)) {
- skip("failed to create surface\n");
- goto err;
- }
+ skip("failed to create surface\n");
+ return;
+ }
hr = IDirectDrawSurface_SetPalette(lpSurf, palette);
ok(hr == DDERR_INVALIDPIXELFORMAT, "CreateSurface returned: %x\n",hr);
@@ -2503,7 +2557,7 @@ static void PaletteTest(void)
hr = IDirectDrawSurface_GetPalette(lpSurf, &palette);
ok(hr == DDERR_NOPALETTEATTACHED, "CreateSurface returned: %x\n",hr);
-
+
err:
if (lpSurf) IDirectDrawSurface_Release(lpSurf);
--
1.5.5.1
--------------020705070105070208030804--
More information about the wine-patches
mailing list