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);