-- v2: ddraw/tests: Test that presenting does not set the pixel format on a window without one. d3d8/tests: Test that presenting does not set the pixel format on a window without one. d3d9/tests: Test that presenting does not set the pixel format on a window without one. ddraw/tests: Remove unnecessary skips and conditionals from test_pixel_format().
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..134ba0ea675 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 = IDirectDrawClipper_Release(clipper); + ok(!refcount, "Got unexpected refcount %lu.\n", refcount); + refcount = IDirectDraw_Release(ddraw); + 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..69d36ad6a80 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 = IDirectDrawClipper_Release(clipper); + ok(!refcount, "Got unexpected refcount %lu.\n", refcount); + refcount = IDirectDraw2_Release(ddraw); + 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..24c9a156ab5 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 = IDirectDrawClipper_Release(clipper); + ok(!refcount, "Got unexpected refcount %lu.\n", refcount); + refcount = IDirectDraw4_Release(ddraw); + 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..39f86e4d9d3 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 = IDirectDrawClipper_Release(clipper); + ok(!refcount, "Got unexpected refcount %lu.\n", refcount); + refcount = IDirectDraw7_Release(ddraw); + 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 134ba0ea675..71c60db3804 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 = IDirectDraw_Release(ddraw); 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 69d36ad6a80..eddf846e54b 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 = IDirectDraw2_Release(ddraw); 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 24c9a156ab5..a658de37b94 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 = IDirectDraw4_Release(ddraw); 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 39f86e4d9d3..a1c791a9116 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 = IDirectDraw7_Release(ddraw); 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=129021
Your paranoid android.
=== w10pro64 (64 bit report) ===
ddraw: ddraw1.c:8039: Test failed: Failed to set foreground window. ddraw1.c:8041: Test failed: Got unexpected hr 0. ddraw1.c:8043: Test failed: Got unexpected hr 0. ddraw1.c:8045: Test failed: Got unexpected hr 0. ddraw1.c:8047: Test failed: Got unexpected hr 0. ddraw1.c:8057: Test failed: Got unexpected hr 0. ddraw1.c:8059: Test failed: Got unexpected hr 0. ddraw1.c:8061: Test failed: Got unexpected hr 0. ddraw1.c:8065: Test failed: Failed to set foreground window. ddraw1.c:8067: Test failed: Got unexpected hr 0. ddraw1.c:8069: Test failed: Got unexpected hr 0. ddraw1.c:8075: Test failed: Got unexpected hr 0. ddraw1.c:8123: Test failed: Failed to set foreground window. ddraw1.c:8135: Test failed: Failed to set foreground window. ddraw1.c:13658: Test failed: WM_KILLFOCUS was not received. ddraw1.c:13694: Test failed: Got unexpected hr 0x887600e1. ddraw1.c:13697: Test failed: Got unexpected hr 0x887600ff. 01d0:ddraw1: unhandled exception c0000005 at 0000000000414D30
=== w10pro64 (32 bit report) ===
ddraw: ddraw2.c:14663: Test failed: WM_KILLFOCUS was not received. ddraw2.c:14699: Test failed: Got unexpected hr 0x887600e1. ddraw2.c:14702: Test failed: Got unexpected hr 0x887600ff. 19fc:ddraw2: unhandled exception c0000005 at 0046228E
=== w8adm (32 bit report) ===
ddraw: 0aa4:ddraw4: unhandled exception c0000005 at 004EE484
=== w1064v1507 (32 bit report) ===
ddraw: ddraw7.c:19000: Test failed: Got unexpected color 0x0000ff00.
=== w10pro64 (64 bit report) ===
ddraw: ddraw7.c:10156: Test failed: Failed to set foreground window. ddraw7.c:10158: Test failed: Got unexpected hr 0. ddraw7.c:10160: Test failed: Got unexpected hr 0. ddraw7.c:10162: Test failed: Got unexpected hr 0. ddraw7.c:10164: Test failed: Got unexpected hr 0. ddraw7.c:10166: Test failed: Got unexpected hr 0. ddraw7.c:10176: Test failed: Got unexpected hr 0. ddraw7.c:10178: Test failed: Got unexpected hr 0. ddraw7.c:10180: Test failed: Got unexpected hr 0. ddraw7.c:10184: Test failed: Failed to set foreground window. ddraw7.c:10188: Test failed: Got unexpected hr 0. ddraw7.c:10190: Test failed: Got unexpected hr 0. ddraw7.c:10196: Test failed: Got unexpected hr 0. ddraw7.c:10220: Test failed: Got unexpected hr 0. ddraw7.c:10222: Test failed: Got unexpected hr 0x887600e1. ddraw7.c:10228: Test failed: Got unexpected hr 0. ddraw7.c:10258: Test failed: Failed to set foreground window. ddraw7.c:10272: Test failed: Failed to set foreground window. 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. 021c:ddraw7: unhandled exception c0000005 at 00000000004E45B0
=== debian11 (32 bit fr report) ===
d3d8: Unhandled exception: floating point underflow in 32-bit code (0x7e74c38f).
d3d9: Unhandled exception: floating point underflow in 32-bit code (0x7e75438f).
=== 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 (0x7e6f738f).
=== 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 (0x7e9fd38f).
d3d9: Unhandled exception: floating point underflow in 32-bit code (0x7e70138f).
That was a failure to release objects in the right order; fixed in v2.