Signed-off-by: Paul Gofman gofmanp@gmail.com --- dlls/ddraw/tests/ddraw4.c | 51 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 4 deletions(-)
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c index 57b51eef45..c38c0b3ce5 100644 --- a/dlls/ddraw/tests/ddraw4.c +++ b/dlls/ddraw/tests/ddraw4.c @@ -9514,6 +9514,7 @@ static void test_vb_writeonly(void) static void test_lost_device(void) { IDirectDrawSurface4 *surface, *back_buffer; + IDirectDrawSurface4 *sysmem_surface; DDSURFACEDESC2 surface_desc; HWND window1, window2; IDirectDraw4 *ddraw; @@ -9529,7 +9530,7 @@ static void test_lost_device(void) ddraw = create_ddraw(); ok(!!ddraw, "Failed to create a ddraw object.\n"); hr = IDirectDraw4_SetCooperativeLevel(ddraw, window1, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); - ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
memset(&surface_desc, 0, sizeof(surface_desc)); surface_desc.dwSize = sizeof(surface_desc); @@ -9537,7 +9538,16 @@ static void test_lost_device(void) surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP; U5(surface_desc).dwBackBufferCount = 1; hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL); - ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + + memset(&surface_desc, 0, sizeof(surface_desc)); + surface_desc.dwSize = sizeof(surface_desc); + surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; + surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY; + surface_desc.dwWidth = 100; + surface_desc.dwHeight = 100; + hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &sysmem_surface, NULL); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw4_TestCooperativeLevel(ddraw); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9545,6 +9555,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
ret = SetForegroundWindow(GetDesktopWindow()); ok(ret, "Failed to set foreground window.\n"); @@ -9554,6 +9566,8 @@ static void test_lost_device(void) ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
ret = SetForegroundWindow(window1); ok(ret, "Failed to set foreground window.\n"); @@ -9563,6 +9577,8 @@ static void test_lost_device(void) ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw4_RestoreAllSurfaces(ddraw); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9572,6 +9588,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window1, DDSCL_NORMAL); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9581,6 +9599,8 @@ static void test_lost_device(void) todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_Flip(surface, NULL, DDFLIP_WAIT); todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
/* Trying to restore the primary will crash, probably because flippable * surfaces can't exist in DDSCL_NORMAL. */ @@ -9590,12 +9610,14 @@ static void test_lost_device(void) surface_desc.dwFlags = DDSD_CAPS; surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL); - ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw4_TestCooperativeLevel(ddraw); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_IsLost(surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
ret = SetForegroundWindow(GetDesktopWindow()); ok(ret, "Failed to set foreground window.\n"); @@ -9603,6 +9625,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_IsLost(surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
ret = SetForegroundWindow(window1); ok(ret, "Failed to set foreground window.\n"); @@ -9610,6 +9634,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_IsLost(surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window1, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9617,6 +9643,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_IsLost(surface); ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw4_RestoreAllSurfaces(ddraw); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9624,6 +9652,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_IsLost(surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
IDirectDrawSurface4_Release(surface); memset(&surface_desc, 0, sizeof(surface_desc)); @@ -9632,7 +9662,7 @@ static void test_lost_device(void) surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP; U5(surface_desc).dwBackBufferCount = 1; hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL); - ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window1, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9642,6 +9672,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window1, DDSCL_NORMAL | DDSCL_FULLSCREEN); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9651,6 +9683,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window1, DDSCL_NORMAL); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9660,6 +9694,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window2, DDSCL_NORMAL); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9669,6 +9705,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window2, DDSCL_NORMAL | DDSCL_FULLSCREEN); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9678,6 +9716,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window2, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9685,6 +9725,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_IsLost(surface); ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDrawSurface4_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); @@ -9702,6 +9744,7 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); IDirectDrawSurface4_Release(back_buffer);
+ IDirectDrawSurface4_Release(sysmem_surface); IDirectDrawSurface4_Release(surface); refcount = IDirectDraw4_Release(ddraw); ok(!refcount, "Got unexpected refcount %u.\n", refcount);