Commit 156a2aa0 authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

ddraw/tests: Add readback tests to test_palette_gdi.

The changed SetDisplayMode / SetCooperativeLevel order is necessary to make this test pass reliably on native. Otherwise my Windows 7 box returns a color of 0x00000000 from GetDC about 25% of the time. Signed-off-by: 's avatarStefan Dösinger <stefandoesinger@gmx.at> Signed-off-by: 's avatarHenri Verbeet <hverbeet@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 0c0c86a8
......@@ -5921,6 +5921,9 @@ static void test_palette_gdi(void)
PALETTEENTRY palette_entries[256];
UINT i;
HDC dc;
DDBLTFX fx;
RECT r;
COLORREF color;
/* On the Windows 8 testbot palette index 0 of the onscreen palette is forced to
* r = 0, g = 0, b = 0. Do not attempt to set it to something else as this is
* not the point of this test. */
......@@ -6064,6 +6067,8 @@ static void test_palette_gdi(void)
refcount = IDirectDrawSurface_Release(surface);
ok(!refcount, "Got unexpected refcount %u.\n", refcount);
hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE);
ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
if (FAILED(IDirectDraw_SetDisplayMode(ddraw, 640, 480, 8)))
{
win_skip("Failed to set 8 bpp display mode, skipping test.\n");
......@@ -6073,8 +6078,6 @@ static void test_palette_gdi(void)
return;
}
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE);
ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
......@@ -6083,10 +6086,27 @@ static void test_palette_gdi(void)
hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &primary, NULL);
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
memset(&fx, 0, sizeof(fx));
fx.dwSize = sizeof(fx);
fx.dwFillColor = 3;
SetRect(&r, 0, 0, 319, 479);
hr = IDirectDrawSurface_Blt(primary, &r, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
ok(SUCCEEDED(hr), "Failed to clear surface, hr %#x.\n", hr);
SetRect(&r, 320, 0, 639, 479);
fx.dwFillColor = 4;
hr = IDirectDrawSurface_Blt(primary, &r, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
ok(SUCCEEDED(hr), "Failed to clear surface, hr %#x.\n", hr);
hr = IDirectDrawSurface_SetPalette(primary, palette);
ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
hr = IDirectDrawSurface_GetDC(primary, &dc);
ok(SUCCEEDED(hr), "Failed to get DC, hr %#x.\n", hr);
color = GetPixel(dc, 160, 240);
ok(color == 0x00030000, "Clear index 3: Got unexpected color 0x%08x.\n", color);
color = GetPixel(dc, 480, 240);
ok(color == 0x00252423, "Clear index 4: Got unexpected color 0x%08x.\n", color);
ddraw_palette_handle = SelectPalette(dc, GetStockObject(DEFAULT_PALETTE), FALSE);
/* Windows 2000 on the testbot assigns a different palette to the primary. Refrast? */
ok(ddraw_palette_handle == GetStockObject(DEFAULT_PALETTE) || broken(TRUE),
......
......@@ -7167,6 +7167,9 @@ static void test_palette_gdi(void)
PALETTEENTRY palette_entries[256];
UINT i;
HDC dc;
DDBLTFX fx;
RECT r;
COLORREF color;
/* On the Windows 8 testbot palette index 0 of the onscreen palette is forced to
* r = 0, g = 0, b = 0. Do not attempt to set it to something else as this is
* not the point of this test. */
......@@ -7310,6 +7313,8 @@ static void test_palette_gdi(void)
refcount = IDirectDrawSurface_Release(surface);
ok(!refcount, "Got unexpected refcount %u.\n", refcount);
hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE);
ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
if (FAILED(IDirectDraw2_SetDisplayMode(ddraw, 640, 480, 8, 0, 0)))
{
win_skip("Failed to set 8 bpp display mode, skipping test.\n");
......@@ -7319,8 +7324,6 @@ static void test_palette_gdi(void)
return;
}
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE);
ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
......@@ -7329,10 +7332,27 @@ static void test_palette_gdi(void)
hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &primary, NULL);
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
memset(&fx, 0, sizeof(fx));
fx.dwSize = sizeof(fx);
fx.dwFillColor = 3;
SetRect(&r, 0, 0, 319, 479);
hr = IDirectDrawSurface_Blt(primary, &r, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
ok(SUCCEEDED(hr), "Failed to clear surface, hr %#x.\n", hr);
SetRect(&r, 320, 0, 639, 479);
fx.dwFillColor = 4;
hr = IDirectDrawSurface_Blt(primary, &r, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
ok(SUCCEEDED(hr), "Failed to clear surface, hr %#x.\n", hr);
hr = IDirectDrawSurface_SetPalette(primary, palette);
ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
hr = IDirectDrawSurface_GetDC(primary, &dc);
ok(SUCCEEDED(hr), "Failed to get DC, hr %#x.\n", hr);
color = GetPixel(dc, 160, 240);
ok(color == 0x00030000, "Clear index 3: Got unexpected color 0x%08x.\n", color);
color = GetPixel(dc, 480, 240);
ok(color == 0x00252423, "Clear index 4: Got unexpected color 0x%08x.\n", color);
ddraw_palette_handle = SelectPalette(dc, GetStockObject(DEFAULT_PALETTE), FALSE);
/* Windows 2000 on the testbot assigns a different palette to the primary. Refrast? */
ok(ddraw_palette_handle == GetStockObject(DEFAULT_PALETTE) || broken(TRUE),
......
......@@ -8172,6 +8172,9 @@ static void test_palette_gdi(void)
PALETTEENTRY palette_entries[256];
UINT i;
HDC dc;
DDBLTFX fx;
RECT r;
COLORREF color;
/* On the Windows 8 testbot palette index 0 of the onscreen palette is forced to
* r = 0, g = 0, b = 0. Do not attempt to set it to something else as this is
* not the point of this test. */
......@@ -8315,6 +8318,8 @@ static void test_palette_gdi(void)
refcount = IDirectDrawSurface4_Release(surface);
ok(!refcount, "Got unexpected refcount %u.\n", refcount);
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE);
ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
if (FAILED(IDirectDraw4_SetDisplayMode(ddraw, 640, 480, 8, 0, 0)))
{
win_skip("Failed to set 8 bpp display mode, skipping test.\n");
......@@ -8324,8 +8329,6 @@ static void test_palette_gdi(void)
return;
}
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE);
ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
......@@ -8334,10 +8337,27 @@ static void test_palette_gdi(void)
hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &primary, NULL);
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
memset(&fx, 0, sizeof(fx));
fx.dwSize = sizeof(fx);
fx.dwFillColor = 3;
SetRect(&r, 0, 0, 319, 479);
hr = IDirectDrawSurface4_Blt(primary, &r, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
ok(SUCCEEDED(hr), "Failed to clear surface, hr %#x.\n", hr);
SetRect(&r, 320, 0, 639, 479);
fx.dwFillColor = 4;
hr = IDirectDrawSurface4_Blt(primary, &r, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
ok(SUCCEEDED(hr), "Failed to clear surface, hr %#x.\n", hr);
hr = IDirectDrawSurface4_SetPalette(primary, palette);
ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
hr = IDirectDrawSurface4_GetDC(primary, &dc);
ok(SUCCEEDED(hr), "Failed to get DC, hr %#x.\n", hr);
color = GetPixel(dc, 160, 240);
ok(color == 0x00030000, "Clear index 3: Got unexpected color 0x%08x.\n", color);
color = GetPixel(dc, 480, 240);
ok(color == 0x00252423, "Clear index 4: Got unexpected color 0x%08x.\n", color);
ddraw_palette_handle = SelectPalette(dc, GetStockObject(DEFAULT_PALETTE), FALSE);
/* Windows 2000 on the testbot assigns a different palette to the primary. Refrast? */
ok(ddraw_palette_handle == GetStockObject(DEFAULT_PALETTE) || broken(TRUE),
......
......@@ -7976,6 +7976,9 @@ static void test_palette_gdi(void)
PALETTEENTRY palette_entries[256];
UINT i;
HDC dc;
DDBLTFX fx;
RECT r;
COLORREF color;
/* On the Windows 8 testbot palette index 0 of the onscreen palette is forced to
* r = 0, g = 0, b = 0. Do not attempt to set it to something else as this is
* not the point of this test. */
......@@ -8119,6 +8122,8 @@ static void test_palette_gdi(void)
refcount = IDirectDrawSurface7_Release(surface);
ok(!refcount, "Got unexpected refcount %u.\n", refcount);
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE);
ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
if (FAILED(IDirectDraw7_SetDisplayMode(ddraw, 640, 480, 8, 0, 0)))
{
win_skip("Failed to set 8 bpp display mode, skipping test.\n");
......@@ -8128,8 +8133,6 @@ static void test_palette_gdi(void)
return;
}
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE);
ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
......@@ -8138,10 +8141,27 @@ static void test_palette_gdi(void)
hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &primary, NULL);
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
memset(&fx, 0, sizeof(fx));
fx.dwSize = sizeof(fx);
fx.dwFillColor = 3;
SetRect(&r, 0, 0, 319, 479);
hr = IDirectDrawSurface7_Blt(primary, &r, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
ok(SUCCEEDED(hr), "Failed to clear surface, hr %#x.\n", hr);
SetRect(&r, 320, 0, 639, 479);
fx.dwFillColor = 4;
hr = IDirectDrawSurface7_Blt(primary, &r, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
ok(SUCCEEDED(hr), "Failed to clear surface, hr %#x.\n", hr);
hr = IDirectDrawSurface7_SetPalette(primary, palette);
ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
hr = IDirectDrawSurface7_GetDC(primary, &dc);
ok(SUCCEEDED(hr), "Failed to get DC, hr %#x.\n", hr);
color = GetPixel(dc, 160, 240);
ok(color == 0x00030000, "Clear index 3: Got unexpected color 0x%08x.\n", color);
color = GetPixel(dc, 480, 240);
ok(color == 0x00252423, "Clear index 4: Got unexpected color 0x%08x.\n", color);
ddraw_palette_handle = SelectPalette(dc, GetStockObject(DEFAULT_PALETTE), FALSE);
/* Windows 2000 on the testbot assigns a different palette to the primary. Refrast? */
ok(ddraw_palette_handle == GetStockObject(DEFAULT_PALETTE) || broken(TRUE),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment