[PATCH 3/5] ddraw/tests: Add readback tests to test_palette_gdi.
Stefan Dösinger
stefandoesinger at gmx.at
Sun Jun 5 13:45:14 CDT 2016
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: Stefan Dösinger <stefandoesinger at gmx.at>
---
This is a part of p8_primary_test that doesn't have a direct equivalent
in any of the newer tests. But I am open to the argument that with the
existing ddraw-gdi interaction tests and gdi tests this stuff should be
covered already. Just skip this patch in this case.
---
dlls/ddraw/tests/ddraw1.c | 24 ++++++++++++++++++++++--
dlls/ddraw/tests/ddraw2.c | 24 ++++++++++++++++++++++--
dlls/ddraw/tests/ddraw4.c | 24 ++++++++++++++++++++++--
dlls/ddraw/tests/ddraw7.c | 24 ++++++++++++++++++++++--
4 files changed, 88 insertions(+), 8 deletions(-)
diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c
index 954123d..6ae9cdf 100644
--- a/dlls/ddraw/tests/ddraw1.c
+++ b/dlls/ddraw/tests/ddraw1.c
@@ -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),
diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c
index f0cb241..984ed40 100644
--- a/dlls/ddraw/tests/ddraw2.c
+++ b/dlls/ddraw/tests/ddraw2.c
@@ -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),
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c
index 0877437..16a2625 100644
--- a/dlls/ddraw/tests/ddraw4.c
+++ b/dlls/ddraw/tests/ddraw4.c
@@ -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),
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index 3c7a736..2c4e619 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -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),
--
2.7.3
More information about the wine-patches
mailing list