[PATCH 2/5] ddraw/tests: Add a test for palettes on primary surfaces.
Henri Verbeet
hverbeet at codeweavers.com
Fri Dec 13 02:07:46 CST 2013
---
dlls/ddraw/tests/ddraw1.c | 98 ++++++++++++++++++++++++++++++++++++++++++
dlls/ddraw/tests/ddraw2.c | 98 ++++++++++++++++++++++++++++++++++++++++++
dlls/ddraw/tests/ddraw4.c | 98 ++++++++++++++++++++++++++++++++++++++++++
dlls/ddraw/tests/ddraw7.c | 104 +++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 398 insertions(+)
diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c
index 56a74d4..b295766 100644
--- a/dlls/ddraw/tests/ddraw1.c
+++ b/dlls/ddraw/tests/ddraw1.c
@@ -3913,6 +3913,103 @@ static void test_sysmem_overlay(void)
DestroyWindow(window);
}
+static void test_primary_palette(void)
+{
+ DDSCAPS surface_caps = {DDSCAPS_FLIP};
+ IDirectDrawSurface *primary, *backbuffer;
+ PALETTEENTRY palette_entries[256];
+ IDirectDrawPalette *palette, *tmp;
+ DDSURFACEDESC surface_desc;
+ IDirectDraw *ddraw;
+ DWORD palette_caps;
+ ULONG refcount;
+ HWND window;
+ HRESULT hr;
+
+ if (!(ddraw = create_ddraw()))
+ {
+ skip("Failed to create a ddraw object, skipping test.\n");
+ return;
+ }
+
+ window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
+ 0, 0, 640, 480, 0, 0, 0, 0);
+ hr = IDirectDraw_SetDisplayMode(ddraw, 640, 480, 8);
+ ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+ hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ 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);
+ surface_desc.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
+ surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
+ surface_desc.dwBackBufferCount = 1;
+ hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &primary, NULL);
+ ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+ hr = IDirectDrawSurface_GetAttachedSurface(primary, &surface_caps, &backbuffer);
+ ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr);
+
+ memset(palette_entries, 0, sizeof(palette_entries));
+ hr = IDirectDraw_CreatePalette(ddraw, DDPCAPS_8BIT | DDPCAPS_ALLOW256, palette_entries, &palette, NULL);
+ ok(SUCCEEDED(hr), "Failed to create palette, hr %#x.\n", hr);
+ refcount = get_refcount((IUnknown *)palette);
+ ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+
+ hr = IDirectDrawPalette_GetCaps(palette, &palette_caps);
+ ok(SUCCEEDED(hr), "Failed to get palette caps, hr %#x.\n", hr);
+ ok(palette_caps == (DDPCAPS_8BIT | DDPCAPS_ALLOW256), "Got unexpected palette caps %#x.\n", palette_caps);
+
+ hr = IDirectDrawSurface_SetPalette(primary, palette);
+ ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+ refcount = get_refcount((IUnknown *)palette);
+ ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
+
+ hr = IDirectDrawPalette_GetCaps(palette, &palette_caps);
+ ok(SUCCEEDED(hr), "Failed to get palette caps, hr %#x.\n", hr);
+ ok(palette_caps == (DDPCAPS_8BIT | DDPCAPS_PRIMARYSURFACE | DDPCAPS_ALLOW256),
+ "Got unexpected palette caps %#x.\n", palette_caps);
+
+ hr = IDirectDrawSurface_SetPalette(primary, NULL);
+ ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+ refcount = get_refcount((IUnknown *)palette);
+ ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+
+ hr = IDirectDrawPalette_GetCaps(palette, &palette_caps);
+ ok(SUCCEEDED(hr), "Failed to get palette caps, hr %#x.\n", hr);
+ ok(palette_caps == (DDPCAPS_8BIT | DDPCAPS_ALLOW256), "Got unexpected palette caps %#x.\n", palette_caps);
+
+ hr = IDirectDrawSurface_SetPalette(primary, palette);
+ ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+ refcount = get_refcount((IUnknown *)palette);
+ ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
+
+ hr = IDirectDrawSurface_GetPalette(primary, &tmp);
+ ok(SUCCEEDED(hr), "Failed to get palette, hr %#x.\n", hr);
+ ok(tmp == palette, "Got unexpected palette %p, expected %p.\n", tmp, palette);
+ IDirectDrawPalette_Release(tmp);
+ hr = IDirectDrawSurface_GetPalette(backbuffer, &tmp);
+ ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#x.\n", hr);
+
+ refcount = IDirectDrawPalette_Release(palette);
+ ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+ refcount = IDirectDrawPalette_Release(palette);
+ ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+
+ /* Note that this only seems to work when the palette is attached to the
+ * primary surface. When attached to a regular surface, attempting to get
+ * the palette here will cause an access violation. */
+ hr = IDirectDrawSurface_GetPalette(primary, &tmp);
+ ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#x.\n", hr);
+
+ refcount = IDirectDrawSurface_Release(backbuffer);
+ ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+ refcount = IDirectDrawSurface_Release(primary);
+ ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+ refcount = IDirectDraw_Release(ddraw);
+ ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+ DestroyWindow(window);
+}
+
START_TEST(ddraw1)
{
test_coop_level_create_device_window();
@@ -3943,4 +4040,5 @@ START_TEST(ddraw1)
test_surface_discard();
test_flip();
test_sysmem_overlay();
+ test_primary_palette();
}
diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c
index d6d38c8..46882be 100644
--- a/dlls/ddraw/tests/ddraw2.c
+++ b/dlls/ddraw/tests/ddraw2.c
@@ -4972,6 +4972,103 @@ static void test_sysmem_overlay(void)
DestroyWindow(window);
}
+static void test_primary_palette(void)
+{
+ DDSCAPS surface_caps = {DDSCAPS_FLIP};
+ IDirectDrawSurface *primary, *backbuffer;
+ PALETTEENTRY palette_entries[256];
+ IDirectDrawPalette *palette, *tmp;
+ DDSURFACEDESC surface_desc;
+ IDirectDraw2 *ddraw;
+ DWORD palette_caps;
+ ULONG refcount;
+ HWND window;
+ HRESULT hr;
+
+ if (!(ddraw = create_ddraw()))
+ {
+ skip("Failed to create a ddraw object, skipping test.\n");
+ return;
+ }
+
+ window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
+ 0, 0, 640, 480, 0, 0, 0, 0);
+ hr = IDirectDraw2_SetDisplayMode(ddraw, 640, 480, 8, 0, 0);
+ ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+ hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ 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);
+ surface_desc.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
+ surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
+ surface_desc.dwBackBufferCount = 1;
+ hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &primary, NULL);
+ ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+ hr = IDirectDrawSurface_GetAttachedSurface(primary, &surface_caps, &backbuffer);
+ ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr);
+
+ memset(palette_entries, 0, sizeof(palette_entries));
+ hr = IDirectDraw2_CreatePalette(ddraw, DDPCAPS_8BIT | DDPCAPS_ALLOW256, palette_entries, &palette, NULL);
+ ok(SUCCEEDED(hr), "Failed to create palette, hr %#x.\n", hr);
+ refcount = get_refcount((IUnknown *)palette);
+ ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+
+ hr = IDirectDrawPalette_GetCaps(palette, &palette_caps);
+ ok(SUCCEEDED(hr), "Failed to get palette caps, hr %#x.\n", hr);
+ ok(palette_caps == (DDPCAPS_8BIT | DDPCAPS_ALLOW256), "Got unexpected palette caps %#x.\n", palette_caps);
+
+ hr = IDirectDrawSurface_SetPalette(primary, palette);
+ ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+ refcount = get_refcount((IUnknown *)palette);
+ ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
+
+ hr = IDirectDrawPalette_GetCaps(palette, &palette_caps);
+ ok(SUCCEEDED(hr), "Failed to get palette caps, hr %#x.\n", hr);
+ ok(palette_caps == (DDPCAPS_8BIT | DDPCAPS_PRIMARYSURFACE | DDPCAPS_ALLOW256),
+ "Got unexpected palette caps %#x.\n", palette_caps);
+
+ hr = IDirectDrawSurface_SetPalette(primary, NULL);
+ ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+ refcount = get_refcount((IUnknown *)palette);
+ ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+
+ hr = IDirectDrawPalette_GetCaps(palette, &palette_caps);
+ ok(SUCCEEDED(hr), "Failed to get palette caps, hr %#x.\n", hr);
+ ok(palette_caps == (DDPCAPS_8BIT | DDPCAPS_ALLOW256), "Got unexpected palette caps %#x.\n", palette_caps);
+
+ hr = IDirectDrawSurface_SetPalette(primary, palette);
+ ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+ refcount = get_refcount((IUnknown *)palette);
+ ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
+
+ hr = IDirectDrawSurface_GetPalette(primary, &tmp);
+ ok(SUCCEEDED(hr), "Failed to get palette, hr %#x.\n", hr);
+ ok(tmp == palette, "Got unexpected palette %p, expected %p.\n", tmp, palette);
+ IDirectDrawPalette_Release(tmp);
+ hr = IDirectDrawSurface_GetPalette(backbuffer, &tmp);
+ ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#x.\n", hr);
+
+ refcount = IDirectDrawPalette_Release(palette);
+ ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+ refcount = IDirectDrawPalette_Release(palette);
+ ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+
+ /* Note that this only seems to work when the palette is attached to the
+ * primary surface. When attached to a regular surface, attempting to get
+ * the palette here will cause an access violation. */
+ hr = IDirectDrawSurface_GetPalette(primary, &tmp);
+ ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#x.\n", hr);
+
+ refcount = IDirectDrawSurface_Release(backbuffer);
+ ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+ refcount = IDirectDrawSurface_Release(primary);
+ ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+ refcount = IDirectDraw2_Release(ddraw);
+ ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+ DestroyWindow(window);
+}
+
START_TEST(ddraw2)
{
test_coop_level_create_device_window();
@@ -5008,4 +5105,5 @@ START_TEST(ddraw2)
test_set_surface_desc();
test_user_memory_getdc();
test_sysmem_overlay();
+ test_primary_palette();
}
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c
index 6f9160c..f215f12 100644
--- a/dlls/ddraw/tests/ddraw4.c
+++ b/dlls/ddraw/tests/ddraw4.c
@@ -5569,6 +5569,103 @@ static void test_sysmem_overlay(void)
DestroyWindow(window);
}
+static void test_primary_palette(void)
+{
+ DDSCAPS2 surface_caps = {DDSCAPS_FLIP, 0, 0, 0};
+ IDirectDrawSurface4 *primary, *backbuffer;
+ PALETTEENTRY palette_entries[256];
+ IDirectDrawPalette *palette, *tmp;
+ DDSURFACEDESC2 surface_desc;
+ IDirectDraw4 *ddraw;
+ DWORD palette_caps;
+ ULONG refcount;
+ HWND window;
+ HRESULT hr;
+
+ if (!(ddraw = create_ddraw()))
+ {
+ skip("Failed to create a ddraw object, skipping test.\n");
+ return;
+ }
+
+ window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
+ 0, 0, 640, 480, 0, 0, 0, 0);
+ hr = IDirectDraw4_SetDisplayMode(ddraw, 640, 480, 8, 0, 0);
+ ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+ hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ 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);
+ surface_desc.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
+ surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
+ surface_desc.dwBackBufferCount = 1;
+ hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &primary, NULL);
+ ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+ hr = IDirectDrawSurface4_GetAttachedSurface(primary, &surface_caps, &backbuffer);
+ ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr);
+
+ memset(palette_entries, 0, sizeof(palette_entries));
+ hr = IDirectDraw4_CreatePalette(ddraw, DDPCAPS_8BIT | DDPCAPS_ALLOW256, palette_entries, &palette, NULL);
+ ok(SUCCEEDED(hr), "Failed to create palette, hr %#x.\n", hr);
+ refcount = get_refcount((IUnknown *)palette);
+ ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+
+ hr = IDirectDrawPalette_GetCaps(palette, &palette_caps);
+ ok(SUCCEEDED(hr), "Failed to get palette caps, hr %#x.\n", hr);
+ ok(palette_caps == (DDPCAPS_8BIT | DDPCAPS_ALLOW256), "Got unexpected palette caps %#x.\n", palette_caps);
+
+ hr = IDirectDrawSurface4_SetPalette(primary, palette);
+ ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+ refcount = get_refcount((IUnknown *)palette);
+ ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
+
+ hr = IDirectDrawPalette_GetCaps(palette, &palette_caps);
+ ok(SUCCEEDED(hr), "Failed to get palette caps, hr %#x.\n", hr);
+ ok(palette_caps == (DDPCAPS_8BIT | DDPCAPS_PRIMARYSURFACE | DDPCAPS_ALLOW256),
+ "Got unexpected palette caps %#x.\n", palette_caps);
+
+ hr = IDirectDrawSurface4_SetPalette(primary, NULL);
+ ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+ refcount = get_refcount((IUnknown *)palette);
+ ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+
+ hr = IDirectDrawPalette_GetCaps(palette, &palette_caps);
+ ok(SUCCEEDED(hr), "Failed to get palette caps, hr %#x.\n", hr);
+ ok(palette_caps == (DDPCAPS_8BIT | DDPCAPS_ALLOW256), "Got unexpected palette caps %#x.\n", palette_caps);
+
+ hr = IDirectDrawSurface4_SetPalette(primary, palette);
+ ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+ refcount = get_refcount((IUnknown *)palette);
+ ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
+
+ hr = IDirectDrawSurface4_GetPalette(primary, &tmp);
+ ok(SUCCEEDED(hr), "Failed to get palette, hr %#x.\n", hr);
+ ok(tmp == palette, "Got unexpected palette %p, expected %p.\n", tmp, palette);
+ IDirectDrawPalette_Release(tmp);
+ hr = IDirectDrawSurface4_GetPalette(backbuffer, &tmp);
+ ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#x.\n", hr);
+
+ refcount = IDirectDrawPalette_Release(palette);
+ ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+ refcount = IDirectDrawPalette_Release(palette);
+ ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+
+ /* Note that this only seems to work when the palette is attached to the
+ * primary surface. When attached to a regular surface, attempting to get
+ * the palette here will cause an access violation. */
+ hr = IDirectDrawSurface4_GetPalette(primary, &tmp);
+ ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#x.\n", hr);
+
+ refcount = IDirectDrawSurface4_Release(backbuffer);
+ ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+ refcount = IDirectDrawSurface4_Release(primary);
+ ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+ refcount = IDirectDraw4_Release(ddraw);
+ ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+ DestroyWindow(window);
+}
+
START_TEST(ddraw4)
{
test_process_vertices();
@@ -5610,4 +5707,5 @@ START_TEST(ddraw4)
test_set_surface_desc();
test_user_memory_getdc();
test_sysmem_overlay();
+ test_primary_palette();
}
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index 819f4d0..18e1823 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -90,6 +90,12 @@ static BOOL compare_color(D3DCOLOR c1, D3DCOLOR c2, BYTE max_diff)
return TRUE;
}
+static ULONG get_refcount(IUnknown *iface)
+{
+ IUnknown_AddRef(iface);
+ return IUnknown_Release(iface);
+}
+
static DWORD WINAPI create_window_thread_proc(void *param)
{
struct create_window_thread_param *p = param;
@@ -5457,6 +5463,103 @@ static void test_sysmem_overlay(void)
DestroyWindow(window);
}
+static void test_primary_palette(void)
+{
+ DDSCAPS2 surface_caps = {DDSCAPS_FLIP, 0, 0, 0};
+ IDirectDrawSurface7 *primary, *backbuffer;
+ PALETTEENTRY palette_entries[256];
+ IDirectDrawPalette *palette, *tmp;
+ DDSURFACEDESC2 surface_desc;
+ IDirectDraw7 *ddraw;
+ DWORD palette_caps;
+ ULONG refcount;
+ HWND window;
+ HRESULT hr;
+
+ if (!(ddraw = create_ddraw()))
+ {
+ skip("Failed to create a ddraw object, skipping test.\n");
+ return;
+ }
+
+ window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
+ 0, 0, 640, 480, 0, 0, 0, 0);
+ hr = IDirectDraw7_SetDisplayMode(ddraw, 640, 480, 8, 0, 0);
+ ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+ hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ 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);
+ surface_desc.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
+ surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
+ surface_desc.dwBackBufferCount = 1;
+ hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &primary, NULL);
+ ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+ hr = IDirectDrawSurface7_GetAttachedSurface(primary, &surface_caps, &backbuffer);
+ ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr);
+
+ memset(palette_entries, 0, sizeof(palette_entries));
+ hr = IDirectDraw7_CreatePalette(ddraw, DDPCAPS_8BIT | DDPCAPS_ALLOW256, palette_entries, &palette, NULL);
+ ok(SUCCEEDED(hr), "Failed to create palette, hr %#x.\n", hr);
+ refcount = get_refcount((IUnknown *)palette);
+ ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+
+ hr = IDirectDrawPalette_GetCaps(palette, &palette_caps);
+ ok(SUCCEEDED(hr), "Failed to get palette caps, hr %#x.\n", hr);
+ ok(palette_caps == (DDPCAPS_8BIT | DDPCAPS_ALLOW256), "Got unexpected palette caps %#x.\n", palette_caps);
+
+ hr = IDirectDrawSurface7_SetPalette(primary, palette);
+ ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+ refcount = get_refcount((IUnknown *)palette);
+ ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
+
+ hr = IDirectDrawPalette_GetCaps(palette, &palette_caps);
+ ok(SUCCEEDED(hr), "Failed to get palette caps, hr %#x.\n", hr);
+ ok(palette_caps == (DDPCAPS_8BIT | DDPCAPS_PRIMARYSURFACE | DDPCAPS_ALLOW256),
+ "Got unexpected palette caps %#x.\n", palette_caps);
+
+ hr = IDirectDrawSurface7_SetPalette(primary, NULL);
+ ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+ refcount = get_refcount((IUnknown *)palette);
+ ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+
+ hr = IDirectDrawPalette_GetCaps(palette, &palette_caps);
+ ok(SUCCEEDED(hr), "Failed to get palette caps, hr %#x.\n", hr);
+ ok(palette_caps == (DDPCAPS_8BIT | DDPCAPS_ALLOW256), "Got unexpected palette caps %#x.\n", palette_caps);
+
+ hr = IDirectDrawSurface7_SetPalette(primary, palette);
+ ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+ refcount = get_refcount((IUnknown *)palette);
+ ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
+
+ hr = IDirectDrawSurface7_GetPalette(primary, &tmp);
+ ok(SUCCEEDED(hr), "Failed to get palette, hr %#x.\n", hr);
+ ok(tmp == palette, "Got unexpected palette %p, expected %p.\n", tmp, palette);
+ IDirectDrawPalette_Release(tmp);
+ hr = IDirectDrawSurface7_GetPalette(backbuffer, &tmp);
+ ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#x.\n", hr);
+
+ refcount = IDirectDrawPalette_Release(palette);
+ ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+ refcount = IDirectDrawPalette_Release(palette);
+ ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+
+ /* Note that this only seems to work when the palette is attached to the
+ * primary surface. When attached to a regular surface, attempting to get
+ * the palette here will cause an access violation. */
+ hr = IDirectDrawSurface7_GetPalette(primary, &tmp);
+ ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#x.\n", hr);
+
+ refcount = IDirectDrawSurface7_Release(backbuffer);
+ ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+ refcount = IDirectDrawSurface7_Release(primary);
+ ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+ refcount = IDirectDraw7_Release(ddraw);
+ ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+ DestroyWindow(window);
+}
+
START_TEST(ddraw7)
{
HMODULE module = GetModuleHandleA("ddraw.dll");
@@ -5506,4 +5609,5 @@ START_TEST(ddraw7)
test_set_surface_desc();
test_user_memory_getdc();
test_sysmem_overlay();
+ test_primary_palette();
}
--
1.7.10.4
More information about the wine-patches
mailing list