From: Zebediah Figura zfigura@codeweavers.com
We do not expect normal CreateWindow() and GetDC() calls to ever fail. --- dlls/ddraw/tests/ddraw1.c | 108 ++++++++++++++------------------------ dlls/ddraw/tests/ddraw2.c | 108 ++++++++++++++------------------------ dlls/ddraw/tests/ddraw4.c | 108 ++++++++++++++------------------------ dlls/ddraw/tests/ddraw7.c | 108 ++++++++++++++------------------------ 4 files changed, 152 insertions(+), 280 deletions(-)
diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c index 5e10db15860..190ff04fe3d 100644 --- a/dlls/ddraw/tests/ddraw1.c +++ b/dlls/ddraw/tests/ddraw1.c @@ -5878,29 +5878,19 @@ static void test_pixel_format(void) IDirectDrawClipper *clipper = NULL; DDSURFACEDESC ddsd; IDirectDrawSurface *primary = NULL, *offscreen; + ULONG refcount; DDBLTFX fx; HRESULT hr;
- window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE, - 100, 100, 160, 160, NULL, NULL, NULL, NULL); - if (!window) - { - skip("Failed to create window\n"); - return; - } - - window2 = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE, - 100, 100, 160, 160, NULL, NULL, NULL, NULL); + window = create_window(); + ok(!!window, "Failed to create window.\n"); + window2 = create_window(); + ok(!!window2, "Failed to create window.\n");
hdc = GetDC(window); - if (!hdc) - { - skip("Failed to get DC\n"); - goto cleanup; - } - - if (window2) - hdc2 = GetDC(window2); + ok(!!hdc, "Failed to get DC.\n"); + hdc2 = GetDC(window2); + ok(!!hdc2, "Failed to get DC.\n");
gl = LoadLibraryA("opengl32.dll"); ok(!!gl, "failed to load opengl32.dll; SetPixelFormat()/GetPixelFormat() may not work right\n"); @@ -5927,14 +5917,10 @@ static void test_pixel_format(void) goto cleanup; }
- if (!hdc2 || !SetPixelFormat(hdc2, format, &pfd) || GetPixelFormat(hdc2) != format) + if (!SetPixelFormat(hdc2, format, &pfd) || GetPixelFormat(hdc2) != format) { skip("failed to set pixel format on second window\n"); - if (hdc2) - { - ReleaseDC(window2, hdc2); - hdc2 = NULL; - } + goto cleanup; }
ddraw = create_ddraw(); @@ -5944,28 +5930,20 @@ static void test_pixel_format(void) ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format);
hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL); - if (FAILED(hr)) - { - skip("Failed to set cooperative level, hr %#lx.\n", hr); - goto cleanup; - } + ok(hr == S_OK, "Got hr %#lx.\n", hr);
test_format = GetPixelFormat(hdc); ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format);
- if (hdc2) - { - hr = IDirectDraw_CreateClipper(ddraw, 0, &clipper, NULL); - ok(SUCCEEDED(hr), "Failed to create clipper, hr %#lx.\n", hr); - hr = IDirectDrawClipper_SetHWnd(clipper, 0, window2); - ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#lx.\n", hr); - - test_format = GetPixelFormat(hdc); - ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format); + hr = IDirectDraw_CreateClipper(ddraw, 0, &clipper, NULL); + ok(SUCCEEDED(hr), "Failed to create clipper, hr %#lx.\n", hr); + hr = IDirectDrawClipper_SetHWnd(clipper, 0, window2); + ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#lx.\n", hr);
- test_format = GetPixelFormat(hdc2); - ok(test_format == format, "second window has pixel format %d, expected %d\n", test_format, format); - } + test_format = GetPixelFormat(hdc); + ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format); + test_format = GetPixelFormat(hdc2); + ok(test_format == format, "second window has pixel format %d, expected %d\n", test_format, format);
memset(&ddsd, 0, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); @@ -5977,24 +5955,16 @@ static void test_pixel_format(void)
test_format = GetPixelFormat(hdc); ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format); + test_format = GetPixelFormat(hdc2); + ok(test_format == format, "second window has pixel format %d, expected %d\n", test_format, format);
- if (hdc2) - { - test_format = GetPixelFormat(hdc2); - ok(test_format == format, "second window has pixel format %d, expected %d\n", test_format, format); - } - - if (clipper) - { - hr = IDirectDrawSurface_SetClipper(primary, clipper); - ok(SUCCEEDED(hr), "Failed to set clipper, hr %#lx.\n", hr); - - test_format = GetPixelFormat(hdc); - ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format); + hr = IDirectDrawSurface_SetClipper(primary, clipper); + ok(SUCCEEDED(hr), "Failed to set clipper, hr %#lx.\n", hr);
- test_format = GetPixelFormat(hdc2); - ok(test_format == format, "second window has pixel format %d, expected %d\n", test_format, format); - } + test_format = GetPixelFormat(hdc); + ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format); + test_format = GetPixelFormat(hdc2); + ok(test_format == format, "second window has pixel format %d, expected %d\n", test_format, format);
memset(&ddsd, 0, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); @@ -6017,24 +5987,22 @@ static void test_pixel_format(void)
test_format = GetPixelFormat(hdc); ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format); - - if (hdc2) - { - test_format = GetPixelFormat(hdc2); - ok(test_format == format, "second window has pixel format %d, expected %d\n", test_format, format); - } + test_format = GetPixelFormat(hdc2); + ok(test_format == format, "second window has pixel format %d, expected %d\n", test_format, format);
IDirectDrawSurface_Release(offscreen); + IDirectDrawSurface_Release(primary); + refcount = IDirectDraw_Release(ddraw); + ok(!refcount, "Got unexpected refcount %lu.\n", refcount); + refcount = IDirectDrawClipper_Release(clipper); + ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
cleanup: - if (primary) IDirectDrawSurface_Release(primary); - if (clipper) IDirectDrawClipper_Release(clipper); - if (ddraw) IDirectDraw_Release(ddraw); - if (gl) FreeLibrary(gl); - if (hdc) ReleaseDC(window, hdc); - if (hdc2) ReleaseDC(window2, hdc2); + FreeLibrary(gl); + ReleaseDC(window2, hdc2); + ReleaseDC(window, hdc); + DestroyWindow(window2); DestroyWindow(window); - if (window2) DestroyWindow(window2); }
static void test_create_surface_pitch(void) diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c index 84f0b82bb96..becd5d1710b 100644 --- a/dlls/ddraw/tests/ddraw2.c +++ b/dlls/ddraw/tests/ddraw2.c @@ -6975,29 +6975,19 @@ static void test_pixel_format(void) IDirectDrawClipper *clipper = NULL; DDSURFACEDESC ddsd; IDirectDrawSurface *primary = NULL, *offscreen; + ULONG refcount; DDBLTFX fx; HRESULT hr;
- window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE, - 100, 100, 160, 160, NULL, NULL, NULL, NULL); - if (!window) - { - skip("Failed to create window\n"); - return; - } - - window2 = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE, - 100, 100, 160, 160, NULL, NULL, NULL, NULL); + window = create_window(); + ok(!!window, "Failed to create window.\n"); + window2 = create_window(); + ok(!!window2, "Failed to create window.\n");
hdc = GetDC(window); - if (!hdc) - { - skip("Failed to get DC\n"); - goto cleanup; - } - - if (window2) - hdc2 = GetDC(window2); + ok(!!hdc, "Failed to get DC.\n"); + hdc2 = GetDC(window2); + ok(!!hdc2, "Failed to get DC.\n");
gl = LoadLibraryA("opengl32.dll"); ok(!!gl, "failed to load opengl32.dll; SetPixelFormat()/GetPixelFormat() may not work right\n"); @@ -7024,14 +7014,10 @@ static void test_pixel_format(void) goto cleanup; }
- if (!hdc2 || !SetPixelFormat(hdc2, format, &pfd) || GetPixelFormat(hdc2) != format) + if (!SetPixelFormat(hdc2, format, &pfd) || GetPixelFormat(hdc2) != format) { skip("failed to set pixel format on second window\n"); - if (hdc2) - { - ReleaseDC(window2, hdc2); - hdc2 = NULL; - } + goto cleanup; }
ddraw = create_ddraw(); @@ -7041,28 +7027,20 @@ static void test_pixel_format(void) ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format);
hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL); - if (FAILED(hr)) - { - skip("Failed to set cooperative level, hr %#lx.\n", hr); - goto cleanup; - } + ok(hr == S_OK, "Got hr %#lx.\n", hr);
test_format = GetPixelFormat(hdc); ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format);
- if (hdc2) - { - hr = IDirectDraw2_CreateClipper(ddraw, 0, &clipper, NULL); - ok(SUCCEEDED(hr), "Failed to create clipper, hr %#lx.\n", hr); - hr = IDirectDrawClipper_SetHWnd(clipper, 0, window2); - ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#lx.\n", hr); - - test_format = GetPixelFormat(hdc); - ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format); + hr = IDirectDraw2_CreateClipper(ddraw, 0, &clipper, NULL); + ok(SUCCEEDED(hr), "Failed to create clipper, hr %#lx.\n", hr); + hr = IDirectDrawClipper_SetHWnd(clipper, 0, window2); + ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#lx.\n", hr);
- test_format = GetPixelFormat(hdc2); - ok(test_format == format, "second window has pixel format %d, expected %d\n", test_format, format); - } + test_format = GetPixelFormat(hdc); + ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format); + test_format = GetPixelFormat(hdc2); + ok(test_format == format, "second window has pixel format %d, expected %d\n", test_format, format);
memset(&ddsd, 0, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); @@ -7074,24 +7052,16 @@ static void test_pixel_format(void)
test_format = GetPixelFormat(hdc); ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format); + test_format = GetPixelFormat(hdc2); + ok(test_format == format, "second window has pixel format %d, expected %d\n", test_format, format);
- if (hdc2) - { - test_format = GetPixelFormat(hdc2); - ok(test_format == format, "second window has pixel format %d, expected %d\n", test_format, format); - } - - if (clipper) - { - hr = IDirectDrawSurface_SetClipper(primary, clipper); - ok(SUCCEEDED(hr), "Failed to set clipper, hr %#lx.\n", hr); - - test_format = GetPixelFormat(hdc); - ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format); + hr = IDirectDrawSurface_SetClipper(primary, clipper); + ok(SUCCEEDED(hr), "Failed to set clipper, hr %#lx.\n", hr);
- test_format = GetPixelFormat(hdc2); - ok(test_format == format, "second window has pixel format %d, expected %d\n", test_format, format); - } + test_format = GetPixelFormat(hdc); + ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format); + test_format = GetPixelFormat(hdc2); + ok(test_format == format, "second window has pixel format %d, expected %d\n", test_format, format);
memset(&ddsd, 0, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); @@ -7114,24 +7084,22 @@ static void test_pixel_format(void)
test_format = GetPixelFormat(hdc); ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format); - - if (hdc2) - { - test_format = GetPixelFormat(hdc2); - ok(test_format == format, "second window has pixel format %d, expected %d\n", test_format, format); - } + test_format = GetPixelFormat(hdc2); + ok(test_format == format, "second window has pixel format %d, expected %d\n", test_format, format);
IDirectDrawSurface_Release(offscreen); + IDirectDrawSurface_Release(primary); + refcount = IDirectDraw2_Release(ddraw); + ok(!refcount, "Got unexpected refcount %lu.\n", refcount); + refcount = IDirectDrawClipper_Release(clipper); + ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
cleanup: - if (primary) IDirectDrawSurface_Release(primary); - if (clipper) IDirectDrawClipper_Release(clipper); - if (ddraw) IDirectDraw2_Release(ddraw); - if (gl) FreeLibrary(gl); - if (hdc) ReleaseDC(window, hdc); - if (hdc2) ReleaseDC(window2, hdc2); + FreeLibrary(gl); + ReleaseDC(window2, hdc2); + ReleaseDC(window, hdc); + DestroyWindow(window2); DestroyWindow(window); - if (window2) DestroyWindow(window2); }
static void test_create_surface_pitch(void) diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c index 02591afc079..4f5bd3b3ef2 100644 --- a/dlls/ddraw/tests/ddraw4.c +++ b/dlls/ddraw/tests/ddraw4.c @@ -8858,29 +8858,19 @@ static void test_pixel_format(void) IDirectDrawClipper *clipper = NULL; DDSURFACEDESC2 ddsd; IDirectDrawSurface4 *primary = NULL, *offscreen; + ULONG refcount; DDBLTFX fx; HRESULT hr;
- window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE, - 100, 100, 160, 160, NULL, NULL, NULL, NULL); - if (!window) - { - skip("Failed to create window\n"); - return; - } - - window2 = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE, - 100, 100, 160, 160, NULL, NULL, NULL, NULL); + window = create_window(); + ok(!!window, "Failed to create window.\n"); + window2 = create_window(); + ok(!!window2, "Failed to create window.\n");
hdc = GetDC(window); - if (!hdc) - { - skip("Failed to get DC\n"); - goto cleanup; - } - - if (window2) - hdc2 = GetDC(window2); + ok(!!hdc, "Failed to get DC.\n"); + hdc2 = GetDC(window2); + ok(!!hdc2, "Failed to get DC.\n");
gl = LoadLibraryA("opengl32.dll"); ok(!!gl, "failed to load opengl32.dll; SetPixelFormat()/GetPixelFormat() may not work right\n"); @@ -8907,14 +8897,10 @@ static void test_pixel_format(void) goto cleanup; }
- if (!hdc2 || !SetPixelFormat(hdc2, format, &pfd) || GetPixelFormat(hdc2) != format) + if (!SetPixelFormat(hdc2, format, &pfd) || GetPixelFormat(hdc2) != format) { skip("failed to set pixel format on second window\n"); - if (hdc2) - { - ReleaseDC(window2, hdc2); - hdc2 = NULL; - } + goto cleanup; }
ddraw = create_ddraw(); @@ -8924,28 +8910,20 @@ static void test_pixel_format(void) ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format);
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL); - if (FAILED(hr)) - { - skip("Failed to set cooperative level, hr %#lx.\n", hr); - goto cleanup; - } + ok(hr == S_OK, "Got hr %#lx.\n", hr);
test_format = GetPixelFormat(hdc); ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format);
- if (hdc2) - { - hr = IDirectDraw4_CreateClipper(ddraw, 0, &clipper, NULL); - ok(SUCCEEDED(hr), "Failed to create clipper, hr %#lx.\n", hr); - hr = IDirectDrawClipper_SetHWnd(clipper, 0, window2); - ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#lx.\n", hr); - - test_format = GetPixelFormat(hdc); - ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format); + hr = IDirectDraw4_CreateClipper(ddraw, 0, &clipper, NULL); + ok(SUCCEEDED(hr), "Failed to create clipper, hr %#lx.\n", hr); + hr = IDirectDrawClipper_SetHWnd(clipper, 0, window2); + ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#lx.\n", hr);
- test_format = GetPixelFormat(hdc2); - ok(test_format == format, "second window has pixel format %d, expected %d\n", test_format, format); - } + test_format = GetPixelFormat(hdc); + ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format); + test_format = GetPixelFormat(hdc2); + ok(test_format == format, "second window has pixel format %d, expected %d\n", test_format, format);
memset(&ddsd, 0, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); @@ -8957,24 +8935,16 @@ static void test_pixel_format(void)
test_format = GetPixelFormat(hdc); ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format); + test_format = GetPixelFormat(hdc2); + ok(test_format == format, "second window has pixel format %d, expected %d\n", test_format, format);
- if (hdc2) - { - test_format = GetPixelFormat(hdc2); - ok(test_format == format, "second window has pixel format %d, expected %d\n", test_format, format); - } - - if (clipper) - { - hr = IDirectDrawSurface4_SetClipper(primary, clipper); - ok(SUCCEEDED(hr), "Failed to set clipper, hr %#lx.\n", hr); - - test_format = GetPixelFormat(hdc); - ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format); + hr = IDirectDrawSurface4_SetClipper(primary, clipper); + ok(SUCCEEDED(hr), "Failed to set clipper, hr %#lx.\n", hr);
- test_format = GetPixelFormat(hdc2); - ok(test_format == format, "second window has pixel format %d, expected %d\n", test_format, format); - } + test_format = GetPixelFormat(hdc); + ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format); + test_format = GetPixelFormat(hdc2); + ok(test_format == format, "second window has pixel format %d, expected %d\n", test_format, format);
memset(&ddsd, 0, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); @@ -8997,24 +8967,22 @@ static void test_pixel_format(void)
test_format = GetPixelFormat(hdc); ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format); - - if (hdc2) - { - test_format = GetPixelFormat(hdc2); - ok(test_format == format, "second window has pixel format %d, expected %d\n", test_format, format); - } + test_format = GetPixelFormat(hdc2); + ok(test_format == format, "second window has pixel format %d, expected %d\n", test_format, format);
IDirectDrawSurface4_Release(offscreen); + IDirectDrawSurface4_Release(primary); + refcount = IDirectDraw4_Release(ddraw); + ok(!refcount, "Got unexpected refcount %lu.\n", refcount); + refcount = IDirectDrawClipper_Release(clipper); + ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
cleanup: - if (primary) IDirectDrawSurface4_Release(primary); - if (clipper) IDirectDrawClipper_Release(clipper); - if (ddraw) IDirectDraw4_Release(ddraw); - if (gl) FreeLibrary(gl); - if (hdc) ReleaseDC(window, hdc); - if (hdc2) ReleaseDC(window2, hdc2); + FreeLibrary(gl); + ReleaseDC(window2, hdc2); + ReleaseDC(window, hdc); + DestroyWindow(window2); DestroyWindow(window); - if (window2) DestroyWindow(window2); }
static void test_create_surface_pitch(void) diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c index 75bc08b0437..d01b195ba3a 100644 --- a/dlls/ddraw/tests/ddraw7.c +++ b/dlls/ddraw/tests/ddraw7.c @@ -8698,29 +8698,19 @@ static void test_pixel_format(void) IDirectDrawClipper *clipper = NULL; DDSURFACEDESC2 ddsd; IDirectDrawSurface7 *primary = NULL, *offscreen; + ULONG refcount; DDBLTFX fx; HRESULT hr;
- window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE, - 100, 100, 160, 160, NULL, NULL, NULL, NULL); - if (!window) - { - skip("Failed to create window\n"); - return; - } - - window2 = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE, - 100, 100, 160, 160, NULL, NULL, NULL, NULL); + window = create_window(); + ok(!!window, "Failed to create window.\n"); + window2 = create_window(); + ok(!!window2, "Failed to create window.\n");
hdc = GetDC(window); - if (!hdc) - { - skip("Failed to get DC\n"); - goto cleanup; - } - - if (window2) - hdc2 = GetDC(window2); + ok(!!hdc, "Failed to get DC.\n"); + hdc2 = GetDC(window2); + ok(!!hdc2, "Failed to get DC.\n");
gl = LoadLibraryA("opengl32.dll"); ok(!!gl, "failed to load opengl32.dll; SetPixelFormat()/GetPixelFormat() may not work right\n"); @@ -8747,14 +8737,10 @@ static void test_pixel_format(void) goto cleanup; }
- if (!hdc2 || !SetPixelFormat(hdc2, format, &pfd) || GetPixelFormat(hdc2) != format) + if (!SetPixelFormat(hdc2, format, &pfd) || GetPixelFormat(hdc2) != format) { skip("failed to set pixel format on second window\n"); - if (hdc2) - { - ReleaseDC(window2, hdc2); - hdc2 = NULL; - } + goto cleanup; }
ddraw = create_ddraw(); @@ -8764,28 +8750,20 @@ static void test_pixel_format(void) ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format);
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL); - if (FAILED(hr)) - { - skip("Failed to set cooperative level, hr %#lx.\n", hr); - goto cleanup; - } + ok(hr == S_OK, "Got hr %#lx.\n", hr);
test_format = GetPixelFormat(hdc); ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format);
- if (hdc2) - { - hr = IDirectDraw7_CreateClipper(ddraw, 0, &clipper, NULL); - ok(SUCCEEDED(hr), "Failed to create clipper, hr %#lx.\n", hr); - hr = IDirectDrawClipper_SetHWnd(clipper, 0, window2); - ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#lx.\n", hr); - - test_format = GetPixelFormat(hdc); - ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format); + hr = IDirectDraw7_CreateClipper(ddraw, 0, &clipper, NULL); + ok(SUCCEEDED(hr), "Failed to create clipper, hr %#lx.\n", hr); + hr = IDirectDrawClipper_SetHWnd(clipper, 0, window2); + ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#lx.\n", hr);
- test_format = GetPixelFormat(hdc2); - ok(test_format == format, "second window has pixel format %d, expected %d\n", test_format, format); - } + test_format = GetPixelFormat(hdc); + ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format); + test_format = GetPixelFormat(hdc2); + ok(test_format == format, "second window has pixel format %d, expected %d\n", test_format, format);
memset(&ddsd, 0, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); @@ -8797,24 +8775,16 @@ static void test_pixel_format(void)
test_format = GetPixelFormat(hdc); ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format); + test_format = GetPixelFormat(hdc2); + ok(test_format == format, "second window has pixel format %d, expected %d\n", test_format, format);
- if (hdc2) - { - test_format = GetPixelFormat(hdc2); - ok(test_format == format, "second window has pixel format %d, expected %d\n", test_format, format); - } - - if (clipper) - { - hr = IDirectDrawSurface7_SetClipper(primary, clipper); - ok(SUCCEEDED(hr), "Failed to set clipper, hr %#lx.\n", hr); - - test_format = GetPixelFormat(hdc); - ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format); + hr = IDirectDrawSurface7_SetClipper(primary, clipper); + ok(SUCCEEDED(hr), "Failed to set clipper, hr %#lx.\n", hr);
- test_format = GetPixelFormat(hdc2); - ok(test_format == format, "second window has pixel format %d, expected %d\n", test_format, format); - } + test_format = GetPixelFormat(hdc); + ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format); + test_format = GetPixelFormat(hdc2); + ok(test_format == format, "second window has pixel format %d, expected %d\n", test_format, format);
memset(&ddsd, 0, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); @@ -8837,24 +8807,22 @@ static void test_pixel_format(void)
test_format = GetPixelFormat(hdc); ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format); - - if (hdc2) - { - test_format = GetPixelFormat(hdc2); - ok(test_format == format, "second window has pixel format %d, expected %d\n", test_format, format); - } + test_format = GetPixelFormat(hdc2); + ok(test_format == format, "second window has pixel format %d, expected %d\n", test_format, format);
IDirectDrawSurface7_Release(offscreen); + IDirectDrawSurface7_Release(primary); + refcount = IDirectDraw7_Release(ddraw); + ok(!refcount, "Got unexpected refcount %lu.\n", refcount); + refcount = IDirectDrawClipper_Release(clipper); + ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
cleanup: - if (primary) IDirectDrawSurface7_Release(primary); - if (clipper) IDirectDrawClipper_Release(clipper); - if (ddraw) IDirectDraw7_Release(ddraw); - if (gl) FreeLibrary(gl); - if (hdc) ReleaseDC(window, hdc); - if (hdc2) ReleaseDC(window2, hdc2); + FreeLibrary(gl); + ReleaseDC(window2, hdc2); + ReleaseDC(window, hdc); + DestroyWindow(window2); DestroyWindow(window); - if (window2) DestroyWindow(window2); }
static void test_create_surface_pitch(void)
From: Zebediah Figura zfigura@codeweavers.com
--- dlls/d3d9/tests/device.c | 72 +++++++++++++++++++++++++++++++++++----- 1 file changed, 64 insertions(+), 8 deletions(-)
diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c index 0a95e819018..0e361b3ac23 100644 --- a/dlls/d3d9/tests/device.c +++ b/dlls/d3d9/tests/device.c @@ -11050,10 +11050,12 @@ static void test_pixel_format(void) PIXELFORMATDESCRIPTOR pfd; IDirect3D9 *d3d9 = NULL; IDirect3DDevice9 *device = NULL; - HWND hwnd, hwnd2; - HDC hdc, hdc2; + HWND hwnd, hwnd2, hwnd3; + HDC hdc, hdc2, hdc3; + ULONG refcount; HMODULE gl; HRESULT hr; + BOOL ret;
static const float point[] = {0.0f, 0.0f, 0.0f};
@@ -11152,14 +11154,68 @@ static void test_pixel_format(void) test_format = GetPixelFormat(hdc2); ok(test_format == format, "second window has pixel format %d, expected %d\n", test_format, format);
-cleanup: - if (device) + refcount = IDirect3DDevice9_Release(device); + ok(!refcount, "Device has %lu references left.\n", refcount); + IDirect3D9_Release(d3d9); + + test_format = GetPixelFormat(hdc); + ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format); + + test_format = GetPixelFormat(hdc2); + ok(test_format == format, "second window has pixel format %d, expected %d\n", test_format, format); + + /* Test that creating a device doesn't set a pixel format on a window which + * never had one. */ + + hwnd3 = create_window(); + hdc3 = GetDC(hwnd3); + + test_format = GetPixelFormat(hdc3); + ok(!test_format, "Expected no format, got %d.\n", test_format); + + d3d9 = Direct3DCreate9(D3D_SDK_VERSION); + ok(!!d3d9, "Failed to create a D3D object.\n"); + if (!(device = create_device(d3d9, hwnd3, NULL))) { - ULONG refcount = IDirect3DDevice9_Release(device); - ok(!refcount, "Device has %lu references left.\n", refcount); + skip("Failed to create device\n"); + goto cleanup; } - if (d3d9) - IDirect3D9_Release(d3d9); + + hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice9_BeginScene(device); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_POINTLIST, 1, point, 3 * sizeof(float)); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice9_EndScene(device); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + test_format = GetPixelFormat(hdc3); + todo_wine ok(!test_format, "Expected no format, got %d.\n", test_format); + + hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + test_format = GetPixelFormat(hdc3); + todo_wine ok(!test_format, "Expected no format, got %d.\n", test_format); + + refcount = IDirect3DDevice9_Release(device); + ok(!refcount, "Device has %lu references left.\n", refcount); + IDirect3D9_Release(d3d9); + + test_format = GetPixelFormat(hdc3); + todo_wine ok(!test_format, "Expected no format, got %d.\n", test_format); + + ret = SetPixelFormat(hdc3, format, &pfd); + ok(ret, "Failed to set pixel format %d.\n", format); + + test_format = GetPixelFormat(hdc3); + ok(test_format == format, "Expected pixel format %d, got %d.\n", format, test_format); + + ReleaseDC(hwnd3, hdc3); + DestroyWindow(hwnd3); + +cleanup: FreeLibrary(gl); ReleaseDC(hwnd2, hdc2); ReleaseDC(hwnd, hdc);
From: Zebediah Figura zfigura@codeweavers.com
--- dlls/d3d8/tests/device.c | 72 +++++++++++++++++++++++++++++++++++----- 1 file changed, 64 insertions(+), 8 deletions(-)
diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c index 59532d0a208..c8f52484054 100644 --- a/dlls/d3d8/tests/device.c +++ b/dlls/d3d8/tests/device.c @@ -7775,10 +7775,12 @@ static void test_pixel_format(void) PIXELFORMATDESCRIPTOR pfd; IDirect3D8 *d3d8 = NULL; IDirect3DDevice8 *device = NULL; - HWND hwnd, hwnd2; - HDC hdc, hdc2; + HWND hwnd, hwnd2, hwnd3; + HDC hdc, hdc2, hdc3; + ULONG refcount; HMODULE gl; HRESULT hr; + BOOL ret;
static const float point[] = {0.0f, 0.0f, 0.0f};
@@ -7877,14 +7879,68 @@ static void test_pixel_format(void) test_format = GetPixelFormat(hdc2); ok(test_format == format, "second window has pixel format %d, expected %d\n", test_format, format);
-cleanup: - if (device) + refcount = IDirect3DDevice8_Release(device); + ok(!refcount, "Device has %lu references left.\n", refcount); + IDirect3D8_Release(d3d8); + + test_format = GetPixelFormat(hdc); + ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format); + + test_format = GetPixelFormat(hdc2); + ok(test_format == format, "second window has pixel format %d, expected %d\n", test_format, format); + + /* Test that creating a device doesn't set a pixel format on a window which + * never had one. */ + + hwnd3 = create_window(); + hdc3 = GetDC(hwnd3); + + test_format = GetPixelFormat(hdc3); + ok(!test_format, "Expected no format, got %d.\n", test_format); + + d3d8 = Direct3DCreate8(D3D_SDK_VERSION); + ok(!!d3d8, "Failed to create a D3D object.\n"); + if (!(device = create_device(d3d8, hwnd3, NULL))) { - UINT refcount = IDirect3DDevice8_Release(device); - ok(!refcount, "Device has %u references left.\n", refcount); + skip("Failed to create device\n"); + goto cleanup; } - if (d3d8) - IDirect3D8_Release(d3d8); + + hr = IDirect3DDevice8_SetVertexShader(device, D3DFVF_XYZ); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice8_BeginScene(device); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_POINTLIST, 1, point, 3 * sizeof(float)); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice8_EndScene(device); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + test_format = GetPixelFormat(hdc3); + todo_wine ok(!test_format, "Expected no format, got %d.\n", test_format); + + hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + test_format = GetPixelFormat(hdc3); + todo_wine ok(!test_format, "Expected no format, got %d.\n", test_format); + + refcount = IDirect3DDevice8_Release(device); + ok(!refcount, "Device has %lu references left.\n", refcount); + IDirect3D8_Release(d3d8); + + test_format = GetPixelFormat(hdc3); + todo_wine ok(!test_format, "Expected no format, got %d.\n", test_format); + + ret = SetPixelFormat(hdc3, format, &pfd); + ok(ret, "Failed to set pixel format %d.\n", format); + + test_format = GetPixelFormat(hdc3); + ok(test_format == format, "Expected pixel format %d, got %d.\n", format, test_format); + + ReleaseDC(hwnd3, hdc3); + DestroyWindow(hwnd3); + +cleanup: FreeLibrary(gl); ReleaseDC(hwnd2, hdc2); ReleaseDC(hwnd, hdc);
From: Zebediah Figura zfigura@codeweavers.com
--- dlls/ddraw/tests/ddraw1.c | 65 +++++++++++++++++++++++++++++++++++++-- dlls/ddraw/tests/ddraw2.c | 65 +++++++++++++++++++++++++++++++++++++-- dlls/ddraw/tests/ddraw4.c | 65 +++++++++++++++++++++++++++++++++++++-- dlls/ddraw/tests/ddraw7.c | 65 +++++++++++++++++++++++++++++++++++++-- 4 files changed, 252 insertions(+), 8 deletions(-)
diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c index 190ff04fe3d..045e8d0bf6c 100644 --- a/dlls/ddraw/tests/ddraw1.c +++ b/dlls/ddraw/tests/ddraw1.c @@ -5869,18 +5869,19 @@ static void test_surface_attachment(void)
static void test_pixel_format(void) { - HWND window, window2 = NULL; - HDC hdc, hdc2 = NULL; + HWND window, window2, window3; HMODULE gl = NULL; int format, test_format; PIXELFORMATDESCRIPTOR pfd; IDirectDraw *ddraw = NULL; IDirectDrawClipper *clipper = NULL; + HDC hdc, hdc2, hdc3; DDSURFACEDESC ddsd; IDirectDrawSurface *primary = NULL, *offscreen; ULONG refcount; DDBLTFX fx; HRESULT hr; + BOOL ret;
window = create_window(); ok(!!window, "Failed to create window.\n"); @@ -5997,6 +5998,66 @@ static void test_pixel_format(void) refcount = IDirectDrawClipper_Release(clipper); ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
+ /* Test that creating a device doesn't set a pixel format on a window which + * never had one. */ + + window3 = create_window(); + hdc3 = GetDC(window3); + + test_format = GetPixelFormat(hdc3); + ok(!test_format, "Expected no format, got %d.\n", test_format); + + ddraw = create_ddraw(); + ok(!!ddraw, "Failed to create a ddraw object.\n"); + hr = IDirectDraw_SetCooperativeLevel(ddraw, window3, DDSCL_NORMAL); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + test_format = GetPixelFormat(hdc3); + todo_wine ok(!test_format, "Expected no format, got %d.\n", test_format); + + memset(&ddsd, 0, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); + ddsd.dwFlags = DDSD_CAPS; + ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; + hr = IDirectDraw_CreateSurface(ddraw, &ddsd, &primary, NULL); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + memset(&ddsd, 0, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); + ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; + ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; + ddsd.dwWidth = ddsd.dwHeight = 64; + hr = IDirectDraw_CreateSurface(ddraw, &ddsd, &offscreen, NULL); + ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr); + + memset(&fx, 0, sizeof(fx)); + fx.dwSize = sizeof(fx); + hr = IDirectDrawSurface_Blt(offscreen, NULL, NULL, NULL, DDBLT_WAIT | DDBLT_COLORFILL, &fx); + ok(SUCCEEDED(hr), "Failed to clear source surface, hr %#lx.\n", hr); + + hr = IDirectDrawSurface_Blt(primary, NULL, offscreen, NULL, DDBLT_WAIT, NULL); + ok(SUCCEEDED(hr), "Failed to blit to primary surface, hr %#lx.\n", hr); + + test_format = GetPixelFormat(hdc3); + todo_wine ok(!test_format, "Expected no format, got %d.\n", test_format); + + IDirectDrawSurface_Release(offscreen); + IDirectDrawSurface_Release(primary); + refcount = IDirectDraw_Release(ddraw); + ok(!refcount, "Got unexpected refcount %lu.\n", refcount); + + test_format = GetPixelFormat(hdc3); + todo_wine ok(!test_format, "Expected no format, got %d.\n", test_format); + + ret = SetPixelFormat(hdc3, format, &pfd); + ok(ret, "Failed to set pixel format %d.\n", format); + + test_format = GetPixelFormat(hdc3); + ok(test_format == format, "Expected pixel format %d, got %d.\n", format, test_format); + + ReleaseDC(window3, hdc3); + DestroyWindow(window3); + cleanup: FreeLibrary(gl); ReleaseDC(window2, hdc2); diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c index becd5d1710b..ab81e1f72ea 100644 --- a/dlls/ddraw/tests/ddraw2.c +++ b/dlls/ddraw/tests/ddraw2.c @@ -6966,18 +6966,19 @@ static void test_surface_attachment(void)
static void test_pixel_format(void) { - HWND window, window2 = NULL; - HDC hdc, hdc2 = NULL; + HWND window, window2, window3; HMODULE gl = NULL; int format, test_format; PIXELFORMATDESCRIPTOR pfd; IDirectDraw2 *ddraw = NULL; IDirectDrawClipper *clipper = NULL; + HDC hdc, hdc2, hdc3; DDSURFACEDESC ddsd; IDirectDrawSurface *primary = NULL, *offscreen; ULONG refcount; DDBLTFX fx; HRESULT hr; + BOOL ret;
window = create_window(); ok(!!window, "Failed to create window.\n"); @@ -7094,6 +7095,66 @@ static void test_pixel_format(void) refcount = IDirectDrawClipper_Release(clipper); ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
+ /* Test that creating a device doesn't set a pixel format on a window which + * never had one. */ + + window3 = create_window(); + hdc3 = GetDC(window3); + + test_format = GetPixelFormat(hdc3); + ok(!test_format, "Expected no format, got %d.\n", test_format); + + ddraw = create_ddraw(); + ok(!!ddraw, "Failed to create a ddraw object.\n"); + hr = IDirectDraw2_SetCooperativeLevel(ddraw, window3, DDSCL_NORMAL); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + test_format = GetPixelFormat(hdc3); + todo_wine ok(!test_format, "Expected no format, got %d.\n", test_format); + + memset(&ddsd, 0, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); + ddsd.dwFlags = DDSD_CAPS; + ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; + hr = IDirectDraw2_CreateSurface(ddraw, &ddsd, &primary, NULL); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + memset(&ddsd, 0, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); + ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; + ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; + ddsd.dwWidth = ddsd.dwHeight = 64; + hr = IDirectDraw2_CreateSurface(ddraw, &ddsd, &offscreen, NULL); + ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr); + + memset(&fx, 0, sizeof(fx)); + fx.dwSize = sizeof(fx); + hr = IDirectDrawSurface_Blt(offscreen, NULL, NULL, NULL, DDBLT_WAIT | DDBLT_COLORFILL, &fx); + ok(SUCCEEDED(hr), "Failed to clear source surface, hr %#lx.\n", hr); + + hr = IDirectDrawSurface_Blt(primary, NULL, offscreen, NULL, DDBLT_WAIT, NULL); + ok(SUCCEEDED(hr), "Failed to blit to primary surface, hr %#lx.\n", hr); + + test_format = GetPixelFormat(hdc3); + todo_wine ok(!test_format, "Expected no format, got %d.\n", test_format); + + IDirectDrawSurface_Release(offscreen); + IDirectDrawSurface_Release(primary); + refcount = IDirectDraw2_Release(ddraw); + ok(!refcount, "Got unexpected refcount %lu.\n", refcount); + + test_format = GetPixelFormat(hdc3); + todo_wine ok(!test_format, "Expected no format, got %d.\n", test_format); + + ret = SetPixelFormat(hdc3, format, &pfd); + ok(ret, "Failed to set pixel format %d.\n", format); + + test_format = GetPixelFormat(hdc3); + ok(test_format == format, "Expected pixel format %d, got %d.\n", format, test_format); + + ReleaseDC(window3, hdc3); + DestroyWindow(window3); + cleanup: FreeLibrary(gl); ReleaseDC(window2, hdc2); diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c index 4f5bd3b3ef2..604adec707d 100644 --- a/dlls/ddraw/tests/ddraw4.c +++ b/dlls/ddraw/tests/ddraw4.c @@ -8849,18 +8849,19 @@ static void test_private_data(void)
static void test_pixel_format(void) { - HWND window, window2 = NULL; - HDC hdc, hdc2 = NULL; + HWND window, window2, window3; HMODULE gl = NULL; int format, test_format; PIXELFORMATDESCRIPTOR pfd; IDirectDraw4 *ddraw = NULL; IDirectDrawClipper *clipper = NULL; DDSURFACEDESC2 ddsd; + HDC hdc, hdc2, hdc3; IDirectDrawSurface4 *primary = NULL, *offscreen; ULONG refcount; DDBLTFX fx; HRESULT hr; + BOOL ret;
window = create_window(); ok(!!window, "Failed to create window.\n"); @@ -8977,6 +8978,66 @@ static void test_pixel_format(void) refcount = IDirectDrawClipper_Release(clipper); ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
+ /* Test that creating a device doesn't set a pixel format on a window which + * never had one. */ + + window3 = create_window(); + hdc3 = GetDC(window3); + + test_format = GetPixelFormat(hdc3); + ok(!test_format, "Expected no format, got %d.\n", test_format); + + ddraw = create_ddraw(); + ok(!!ddraw, "Failed to create a ddraw object.\n"); + hr = IDirectDraw4_SetCooperativeLevel(ddraw, window3, DDSCL_NORMAL); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + test_format = GetPixelFormat(hdc3); + todo_wine ok(!test_format, "Expected no format, got %d.\n", test_format); + + memset(&ddsd, 0, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); + ddsd.dwFlags = DDSD_CAPS; + ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; + hr = IDirectDraw4_CreateSurface(ddraw, &ddsd, &primary, NULL); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + memset(&ddsd, 0, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); + ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; + ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; + ddsd.dwWidth = ddsd.dwHeight = 64; + hr = IDirectDraw4_CreateSurface(ddraw, &ddsd, &offscreen, NULL); + ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr); + + memset(&fx, 0, sizeof(fx)); + fx.dwSize = sizeof(fx); + hr = IDirectDrawSurface4_Blt(offscreen, NULL, NULL, NULL, DDBLT_WAIT | DDBLT_COLORFILL, &fx); + ok(SUCCEEDED(hr), "Failed to clear source surface, hr %#lx.\n", hr); + + hr = IDirectDrawSurface4_Blt(primary, NULL, offscreen, NULL, DDBLT_WAIT, NULL); + ok(SUCCEEDED(hr), "Failed to blit to primary surface, hr %#lx.\n", hr); + + test_format = GetPixelFormat(hdc3); + todo_wine ok(!test_format, "Expected no format, got %d.\n", test_format); + + IDirectDrawSurface4_Release(offscreen); + IDirectDrawSurface4_Release(primary); + refcount = IDirectDraw4_Release(ddraw); + ok(!refcount, "Got unexpected refcount %lu.\n", refcount); + + test_format = GetPixelFormat(hdc3); + todo_wine ok(!test_format, "Expected no format, got %d.\n", test_format); + + ret = SetPixelFormat(hdc3, format, &pfd); + ok(ret, "Failed to set pixel format %d.\n", format); + + test_format = GetPixelFormat(hdc3); + ok(test_format == format, "Expected pixel format %d, got %d.\n", format, test_format); + + ReleaseDC(window3, hdc3); + DestroyWindow(window3); + cleanup: FreeLibrary(gl); ReleaseDC(window2, hdc2); diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c index d01b195ba3a..8aaf5a44aa5 100644 --- a/dlls/ddraw/tests/ddraw7.c +++ b/dlls/ddraw/tests/ddraw7.c @@ -8689,18 +8689,19 @@ static void test_private_data(void)
static void test_pixel_format(void) { - HWND window, window2 = NULL; - HDC hdc, hdc2 = NULL; + HWND window, window2, window3; HMODULE gl = NULL; int format, test_format; PIXELFORMATDESCRIPTOR pfd; IDirectDraw7 *ddraw = NULL; IDirectDrawClipper *clipper = NULL; DDSURFACEDESC2 ddsd; + HDC hdc, hdc2, hdc3; IDirectDrawSurface7 *primary = NULL, *offscreen; ULONG refcount; DDBLTFX fx; HRESULT hr; + BOOL ret;
window = create_window(); ok(!!window, "Failed to create window.\n"); @@ -8817,6 +8818,66 @@ static void test_pixel_format(void) refcount = IDirectDrawClipper_Release(clipper); ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
+ /* Test that creating a device doesn't set a pixel format on a window which + * never had one. */ + + window3 = create_window(); + hdc3 = GetDC(window3); + + test_format = GetPixelFormat(hdc3); + ok(!test_format, "Expected no format, got %d.\n", test_format); + + ddraw = create_ddraw(); + ok(!!ddraw, "Failed to create a ddraw object.\n"); + hr = IDirectDraw7_SetCooperativeLevel(ddraw, window3, DDSCL_NORMAL); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + test_format = GetPixelFormat(hdc3); + todo_wine ok(!test_format, "Expected no format, got %d.\n", test_format); + + memset(&ddsd, 0, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); + ddsd.dwFlags = DDSD_CAPS; + ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; + hr = IDirectDraw7_CreateSurface(ddraw, &ddsd, &primary, NULL); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + memset(&ddsd, 0, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); + ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; + ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; + ddsd.dwWidth = ddsd.dwHeight = 64; + hr = IDirectDraw7_CreateSurface(ddraw, &ddsd, &offscreen, NULL); + ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr); + + memset(&fx, 0, sizeof(fx)); + fx.dwSize = sizeof(fx); + hr = IDirectDrawSurface7_Blt(offscreen, NULL, NULL, NULL, DDBLT_WAIT | DDBLT_COLORFILL, &fx); + ok(SUCCEEDED(hr), "Failed to clear source surface, hr %#lx.\n", hr); + + hr = IDirectDrawSurface7_Blt(primary, NULL, offscreen, NULL, DDBLT_WAIT, NULL); + ok(SUCCEEDED(hr), "Failed to blit to primary surface, hr %#lx.\n", hr); + + test_format = GetPixelFormat(hdc3); + todo_wine ok(!test_format, "Expected no format, got %d.\n", test_format); + + IDirectDrawSurface7_Release(offscreen); + IDirectDrawSurface7_Release(primary); + refcount = IDirectDraw7_Release(ddraw); + ok(!refcount, "Got unexpected refcount %lu.\n", refcount); + + test_format = GetPixelFormat(hdc3); + todo_wine ok(!test_format, "Expected no format, got %d.\n", test_format); + + ret = SetPixelFormat(hdc3, format, &pfd); + ok(ret, "Failed to set pixel format %d.\n", format); + + test_format = GetPixelFormat(hdc3); + ok(test_format == format, "Expected pixel format %d, got %d.\n", format, test_format); + + ReleaseDC(window3, hdc3); + DestroyWindow(window3); + cleanup: FreeLibrary(gl); ReleaseDC(window2, hdc2);
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=128919
Your paranoid android.
=== w7u_2qxl (32 bit report) ===
ddraw: 077c:ddraw1: unhandled exception c0000005 at 0041F2F5
=== w7u_adm (32 bit report) ===
ddraw: 087c:ddraw1: unhandled exception c0000005 at 0041F2F5
=== w7u_el (32 bit report) ===
ddraw: 0a68:ddraw1: unhandled exception c0000005 at 0041F2F5
=== w8 (32 bit report) ===
ddraw: 0aac:ddraw1: unhandled exception c0000005 at 0041F2F5
=== w1064v1507 (32 bit report) ===
ddraw: 0c50:ddraw1: unhandled exception c0000005 at 0041F2F5
=== w1064v1809 (32 bit report) ===
ddraw: 1304:ddraw1: unhandled exception c0000005 at 0041F2F5
=== w1064_tsign (32 bit report) ===
ddraw: 15d4:ddraw1: unhandled exception c0000005 at 0041F2F5
=== w10pro64 (32 bit report) ===
ddraw: 1f34:ddraw1: unhandled exception c0000005 at 0041F2F5
=== w864 (64 bit report) ===
ddraw: 0bc0:ddraw1: unhandled exception c0000005 at 000000000041AD59
=== w1064v1507 (64 bit report) ===
ddraw: 09e8:ddraw1: unhandled exception c0000005 at 000000000041AD5C
=== w1064v1809 (64 bit report) ===
ddraw: 1cc0:ddraw1: unhandled exception c0000005 at 000000000041AD59
=== w1064_2qxl (64 bit report) ===
ddraw: 1da4:ddraw1: unhandled exception c0000005 at 000000000041AD5C
=== w1064_adm (64 bit report) ===
ddraw: 1c84:ddraw1: unhandled exception c0000005 at 000000000041AD5C
=== w1064_tsign (64 bit report) ===
ddraw: 10e8:ddraw1: unhandled exception c0000005 at 000000000041AD5C
=== w10pro64 (64 bit report) ===
ddraw: 1ce8:ddraw1: unhandled exception c0000005 at 000000000041AD5C
=== w10pro64_en_AE_u8 (64 bit report) ===
ddraw: 19d8:ddraw1: unhandled exception c0000005 at 000000000041AD5C
=== w10pro64_ar (64 bit report) ===
ddraw: 1244:ddraw1: unhandled exception c0000005 at 000000000041AD5C
=== w10pro64_ja (64 bit report) ===
ddraw: 206c:ddraw1: unhandled exception c0000005 at 000000000041AD5C
=== w10pro64_zh_CN (64 bit report) ===
ddraw: 20b4:ddraw1: unhandled exception c0000005 at 000000000041AD5C
=== w7u_2qxl (32 bit report) ===
ddraw: 07dc:ddraw2: unhandled exception c0000005 at 0046BC8B
=== w7u_adm (32 bit report) ===
ddraw: 0860:ddraw2: unhandled exception c0000005 at 0046BC8B
=== w7u_el (32 bit report) ===
ddraw: 0a68:ddraw2: unhandled exception c0000005 at 0046BC8B
=== w1064v1507 (32 bit report) ===
ddraw: 0978:ddraw2: unhandled exception c0000005 at 0046BC8B
=== w1064v1809 (32 bit report) ===
ddraw: 0fac:ddraw2: unhandled exception c0000005 at 00000000
=== w1064_tsign (32 bit report) ===
ddraw: 1b20:ddraw2: unhandled exception c0000005 at 0046BC8B
=== w10pro64 (32 bit report) ===
ddraw: 0b00:ddraw2: unhandled exception c0000005 at 0046BC8B
=== w1064v1507 (64 bit report) ===
ddraw: 0c60:ddraw2: unhandled exception c0000005 at 000000000045DAAA
=== w1064v1809 (64 bit report) ===
ddraw: 0fa4:ddraw2: unhandled exception c0000005 at 000000000045DAAA
=== w1064_2qxl (64 bit report) ===
ddraw: 1d94:ddraw2: unhandled exception c0000005 at 000000000045DAAD
=== w1064_adm (64 bit report) ===
ddraw: 0f14:ddraw2: unhandled exception c0000005 at 000000000045DAAD
=== w1064_tsign (64 bit report) ===
ddraw: 104c:ddraw2: unhandled exception c0000005 at 000000000045DAAD
=== w10pro64 (64 bit report) ===
ddraw: 07c8:ddraw2: unhandled exception c0000005 at 000000000045DAAD
=== w10pro64_en_AE_u8 (64 bit report) ===
ddraw: 2248:ddraw2: unhandled exception c0000005 at 000000000045DAAD
=== w10pro64_ar (64 bit report) ===
ddraw: 01e4:ddraw2: unhandled exception c0000005 at 000000000045DAAD
=== w10pro64_ja (64 bit report) ===
ddraw: 1c5c:ddraw2: unhandled exception c0000005 at 000000000045DAAD
=== w10pro64_zh_CN (64 bit report) ===
ddraw: 20d8:ddraw2: unhandled exception c0000005 at 000000000045DAAD
=== w7u_2qxl (32 bit report) ===
ddraw: ddraw4.c:8977: Test failed: Got unexpected refcount 1.
=== w7u_adm (32 bit report) ===
ddraw: ddraw4.c:8977: Test failed: Got unexpected refcount 1.
=== w7u_el (32 bit report) ===
ddraw: ddraw4.c:8977: Test failed: Got unexpected refcount 1.
=== w8 (32 bit report) ===
ddraw: ddraw4.c:8977: Test failed: Got unexpected refcount 1.
=== w8adm (32 bit report) ===
ddraw: ddraw4.c:8977: Test failed: Got unexpected refcount 1.
=== w864 (32 bit report) ===
ddraw: ddraw4.c:8977: Test failed: Got unexpected refcount 1.
=== w1064v1507 (32 bit report) ===
ddraw: ddraw4.c:8977: Test failed: Got unexpected refcount 1.
=== w1064v1809 (32 bit report) ===
ddraw: ddraw4.c:8977: Test failed: Got unexpected refcount 1.
=== w1064_tsign (32 bit report) ===
ddraw: ddraw4.c:8977: Test failed: Got unexpected refcount 1.
=== w10pro64 (32 bit report) ===
ddraw: ddraw4.c:8977: Test failed: Got unexpected refcount 1.
=== w864 (64 bit report) ===
ddraw: ddraw4.c:8977: Test failed: Got unexpected refcount 1.
=== w1064v1507 (64 bit report) ===
ddraw: ddraw4.c:8977: Test failed: Got unexpected refcount 1.
=== w1064v1809 (64 bit report) ===
ddraw: ddraw4.c:8977: Test failed: Got unexpected refcount 1.
=== w1064_2qxl (64 bit report) ===
ddraw: ddraw4.c:8977: Test failed: Got unexpected refcount 1.
=== w1064_adm (64 bit report) ===
ddraw: ddraw4.c:8977: Test failed: Got unexpected refcount 1.
=== w1064_tsign (64 bit report) ===
ddraw: ddraw4.c:8977: Test failed: Got unexpected refcount 1.
=== w10pro64 (64 bit report) ===
ddraw: ddraw4.c:8977: Test failed: Got unexpected refcount 1.
=== w10pro64_en_AE_u8 (64 bit report) ===
ddraw: ddraw4.c:8977: Test failed: Got unexpected refcount 1.
=== w10pro64_ar (64 bit report) ===
ddraw: ddraw4.c:8977: Test failed: Got unexpected refcount 1.
=== w10pro64_ja (64 bit report) ===
ddraw: ddraw4.c:8977: Test failed: Got unexpected refcount 1.
=== w10pro64_zh_CN (64 bit report) ===
ddraw: ddraw4.c:8977: Test failed: Got unexpected refcount 1.
=== w7u_2qxl (32 bit report) ===
ddraw: ddraw7.c:8817: Test failed: Got unexpected refcount 1.
=== w7u_adm (32 bit report) ===
ddraw: ddraw7.c:8817: Test failed: Got unexpected refcount 1.
=== w7u_el (32 bit report) ===
ddraw: ddraw7.c:8817: Test failed: Got unexpected refcount 1.
=== w8 (32 bit report) ===
ddraw: ddraw7.c:8817: Test failed: Got unexpected refcount 1.
=== w8adm (32 bit report) ===
ddraw: ddraw7.c:8817: Test failed: Got unexpected refcount 1.
=== w864 (32 bit report) ===
ddraw: ddraw7.c:8817: Test failed: Got unexpected refcount 1. ddraw7.c:19000: Test failed: Got unexpected color 0x0000ff00.
=== w1064v1507 (32 bit report) ===
ddraw: ddraw7.c:8817: Test failed: Got unexpected refcount 1.
=== w1064v1809 (32 bit report) ===
ddraw: ddraw7.c:8817: Test failed: Got unexpected refcount 1.
=== w1064_tsign (32 bit report) ===
ddraw: ddraw7.c:8817: Test failed: Got unexpected refcount 1.
=== w10pro64 (32 bit report) ===
ddraw: ddraw7.c:8817: Test failed: Got unexpected refcount 1. ddraw7.c:17144: Test failed: WM_KILLFOCUS was not received. ddraw7.c:17306: Test failed: Got unexpected hr 0x887600e1. ddraw7.c:17309: Test failed: Got unexpected hr 0x887600ff. 1344:ddraw7: unhandled exception c0000005 at 0050965A
=== w864 (64 bit report) ===
ddraw: ddraw7.c:8817: Test failed: Got unexpected refcount 1.
=== w1064v1507 (64 bit report) ===
ddraw: ddraw7.c:8817: Test failed: Got unexpected refcount 1.
=== w1064v1809 (64 bit report) ===
ddraw: ddraw7.c:8817: Test failed: Got unexpected refcount 1.
=== w1064_2qxl (64 bit report) ===
ddraw: ddraw7.c:8817: Test failed: Got unexpected refcount 1.
=== w1064_adm (64 bit report) ===
ddraw: ddraw7.c:8817: Test failed: Got unexpected refcount 1.
=== w1064_tsign (64 bit report) ===
ddraw: ddraw7.c:8817: Test failed: Got unexpected refcount 1.
=== w10pro64 (64 bit report) ===
ddraw: ddraw7.c:8817: Test failed: Got unexpected refcount 1.
=== w10pro64_en_AE_u8 (64 bit report) ===
ddraw: ddraw7.c:8817: Test failed: Got unexpected refcount 1.
=== w10pro64_ar (64 bit report) ===
ddraw: ddraw7.c:8817: Test failed: Got unexpected refcount 1.
=== w10pro64_ja (64 bit report) ===
ddraw: ddraw7.c:8817: Test failed: Got unexpected refcount 1.
=== w10pro64_zh_CN (64 bit report) ===
ddraw: ddraw7.c:8817: Test failed: Got unexpected refcount 1.
=== debian11 (32 bit fr report) ===
d3d8: Unhandled exception: floating point underflow in 32-bit code (0x7e6c738f).
d3d9: Unhandled exception: floating point underflow in 32-bit code (0x7e75238f).
=== debian11 (32 bit he:IL report) ===
d3d8: Unhandled exception: floating point underflow in 32-bit code (0x7e78b38f).
d3d9: Unhandled exception: floating point underflow in 32-bit code (0x7e78b38f).
=== debian11 (32 bit hi:IN report) ===
d3d8: Unhandled exception: floating point underflow in 32-bit code (0x7e73338f).
d3d9: Unhandled exception: floating point underflow in 32-bit code (0x7e73338f).
=== debian11 (32 bit ja:JP report) ===
d3d8: Unhandled exception: floating point underflow in 32-bit code (0x7e8ff38f).
d3d9: Unhandled exception: floating point underflow in 32-bit code (0x7e8ff38f).
=== debian11 (32 bit zh:CN report) ===
d3d8: Unhandled exception: floating point underflow in 32-bit code (0x7e70138f).
d3d9: Unhandled exception: floating point underflow in 32-bit code (0x7e6c738f).