[PATCH 3/5] ddraw/tests: Add a test for primary surface capabilities.

Henri Verbeet hverbeet at codeweavers.com
Thu Dec 5 03:34:16 CST 2013


---
 dlls/ddraw/tests/ddraw1.c |  157 +++++++++++++++++++++++++++++++++++++++++++++
 dlls/ddraw/tests/ddraw2.c |  157 +++++++++++++++++++++++++++++++++++++++++++++
 dlls/ddraw/tests/ddraw4.c |  157 +++++++++++++++++++++++++++++++++++++++++++++
 dlls/ddraw/tests/ddraw7.c |  157 +++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 628 insertions(+)

diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c
index 46e1239..77f43a0 100644
--- a/dlls/ddraw/tests/ddraw1.c
+++ b/dlls/ddraw/tests/ddraw1.c
@@ -3322,6 +3322,162 @@ done:
     DestroyWindow(window);
 }
 
+static void test_primary_caps(void)
+{
+    const DWORD placement = DDSCAPS_LOCALVIDMEM | DDSCAPS_VIDEOMEMORY | DDSCAPS_SYSTEMMEMORY;
+    IDirectDrawSurface *surface;
+    DDSURFACEDESC surface_desc;
+    IDirectDraw *ddraw;
+    unsigned int i;
+    ULONG refcount;
+    HWND window;
+    HRESULT hr;
+
+    static const struct
+    {
+        DWORD coop_level;
+        DWORD caps_in;
+        DWORD back_buffer_count;
+        HRESULT hr;
+        DWORD caps_out;
+    }
+    test_data[] =
+    {
+        {
+            DDSCL_NORMAL,
+            DDSCAPS_PRIMARYSURFACE,
+            ~0u,
+            DD_OK,
+            DDSCAPS_VISIBLE | DDSCAPS_PRIMARYSURFACE,
+        },
+        {
+            DDSCL_NORMAL,
+            DDSCAPS_PRIMARYSURFACE | DDSCAPS_TEXTURE,
+            ~0u,
+            DDERR_INVALIDCAPS,
+            ~0u,
+        },
+        {
+            DDSCL_NORMAL,
+            DDSCAPS_PRIMARYSURFACE | DDSCAPS_FRONTBUFFER,
+            ~0u,
+            DD_OK,
+            DDSCAPS_VISIBLE | DDSCAPS_PRIMARYSURFACE | DDSCAPS_FRONTBUFFER,
+        },
+        {
+            DDSCL_NORMAL,
+            DDSCAPS_PRIMARYSURFACE | DDSCAPS_BACKBUFFER,
+            ~0u,
+            DDERR_INVALIDCAPS,
+            ~0u,
+        },
+        {
+            DDSCL_NORMAL,
+            DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP,
+            ~0u,
+            DDERR_INVALIDCAPS,
+            ~0u,
+        },
+        {
+            DDSCL_NORMAL,
+            DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX,
+            ~0u,
+            DDERR_INVALIDCAPS,
+            ~0u,
+        },
+        {
+            DDSCL_NORMAL,
+            DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP,
+            ~0u,
+            DDERR_INVALIDCAPS,
+            ~0u,
+        },
+        {
+            DDSCL_NORMAL,
+            DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP,
+            0,
+            DDERR_INVALIDCAPS,
+            ~0u,
+        },
+        {
+            DDSCL_NORMAL,
+            DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP,
+            1,
+            DDERR_NOEXCLUSIVEMODE,
+            ~0u,
+        },
+        {
+            DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN,
+            DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP,
+            0,
+            DDERR_INVALIDCAPS,
+            ~0u,
+        },
+        {
+            DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN,
+            DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP,
+            1,
+            DD_OK,
+            DDSCAPS_VISIBLE | DDSCAPS_PRIMARYSURFACE | DDSCAPS_FRONTBUFFER | DDSCAPS_FLIP | DDSCAPS_COMPLEX,
+        },
+        {
+            DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN,
+            DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_FRONTBUFFER,
+            1,
+            DDERR_INVALIDCAPS,
+            ~0u,
+        },
+        {
+            DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN,
+            DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_BACKBUFFER,
+            1,
+            DDERR_INVALIDCAPS,
+            ~0u,
+        },
+    };
+
+    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);
+
+    for (i = 0; i < sizeof(test_data) / sizeof(*test_data); ++i)
+    {
+        hr = IDirectDraw_SetCooperativeLevel(ddraw, window, test_data[i].coop_level);
+        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;
+        if (test_data[i].back_buffer_count != ~0u)
+            surface_desc.dwFlags |= DDSD_BACKBUFFERCOUNT;
+        surface_desc.ddsCaps.dwCaps = test_data[i].caps_in;
+        surface_desc.dwBackBufferCount = test_data[i].back_buffer_count;
+        hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
+        ok(hr == test_data[i].hr, "Test %u: Got unexpected hr %#x, expected %#x.\n", i, hr, test_data[i].hr);
+        if (FAILED(hr))
+            continue;
+
+        memset(&surface_desc, 0, sizeof(surface_desc));
+        surface_desc.dwSize = sizeof(surface_desc);
+        hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc);
+        ok(SUCCEEDED(hr), "Test %u: Failed to get surface desc, hr %#x.\n", i, hr);
+        ok((surface_desc.ddsCaps.dwCaps & ~placement) == test_data[i].caps_out,
+                "Test %u: Got unexpected caps %#x, expected %#x.\n",
+                i, surface_desc.ddsCaps.dwCaps, test_data[i].caps_out);
+
+        IDirectDrawSurface_Release(surface);
+    }
+
+    refcount = IDirectDraw_Release(ddraw);
+    ok(refcount == 0, "The ddraw object was not properly freed, refcount %u.\n", refcount);
+    DestroyWindow(window);
+}
+
 static void test_surface_lock(void)
 {
     IDirectDraw *ddraw;
@@ -3741,6 +3897,7 @@ START_TEST(ddraw1)
     test_coop_level_activateapp();
     test_unsupported_formats();
     test_rt_caps();
+    test_primary_caps();
     test_surface_lock();
     test_surface_discard();
     test_flip();
diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c
index 80c86ff..879ee39 100644
--- a/dlls/ddraw/tests/ddraw2.c
+++ b/dlls/ddraw/tests/ddraw2.c
@@ -4004,6 +4004,162 @@ done:
     DestroyWindow(window);
 }
 
+static void test_primary_caps(void)
+{
+    const DWORD placement = DDSCAPS_LOCALVIDMEM | DDSCAPS_VIDEOMEMORY | DDSCAPS_SYSTEMMEMORY;
+    IDirectDrawSurface *surface;
+    DDSURFACEDESC surface_desc;
+    IDirectDraw2 *ddraw;
+    unsigned int i;
+    ULONG refcount;
+    HWND window;
+    HRESULT hr;
+
+    static const struct
+    {
+        DWORD coop_level;
+        DWORD caps_in;
+        DWORD back_buffer_count;
+        HRESULT hr;
+        DWORD caps_out;
+    }
+    test_data[] =
+    {
+        {
+            DDSCL_NORMAL,
+            DDSCAPS_PRIMARYSURFACE,
+            ~0u,
+            DD_OK,
+            DDSCAPS_VISIBLE | DDSCAPS_PRIMARYSURFACE,
+        },
+        {
+            DDSCL_NORMAL,
+            DDSCAPS_PRIMARYSURFACE | DDSCAPS_TEXTURE,
+            ~0u,
+            DDERR_INVALIDCAPS,
+            ~0u,
+        },
+        {
+            DDSCL_NORMAL,
+            DDSCAPS_PRIMARYSURFACE | DDSCAPS_FRONTBUFFER,
+            ~0u,
+            DDERR_INVALIDCAPS,
+            ~0u,
+        },
+        {
+            DDSCL_NORMAL,
+            DDSCAPS_PRIMARYSURFACE | DDSCAPS_BACKBUFFER,
+            ~0u,
+            DDERR_INVALIDCAPS,
+            ~0u,
+        },
+        {
+            DDSCL_NORMAL,
+            DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP,
+            ~0u,
+            DDERR_INVALIDCAPS,
+            ~0u,
+        },
+        {
+            DDSCL_NORMAL,
+            DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX,
+            ~0u,
+            DDERR_INVALIDCAPS,
+            ~0u,
+        },
+        {
+            DDSCL_NORMAL,
+            DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP,
+            ~0u,
+            DDERR_INVALIDCAPS,
+            ~0u,
+        },
+        {
+            DDSCL_NORMAL,
+            DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP,
+            0,
+            DDERR_INVALIDCAPS,
+            ~0u,
+        },
+        {
+            DDSCL_NORMAL,
+            DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP,
+            1,
+            DDERR_NOEXCLUSIVEMODE,
+            ~0u,
+        },
+        {
+            DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN,
+            DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP,
+            0,
+            DDERR_INVALIDCAPS,
+            ~0u,
+        },
+        {
+            DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN,
+            DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP,
+            1,
+            DD_OK,
+            DDSCAPS_VISIBLE | DDSCAPS_PRIMARYSURFACE | DDSCAPS_FRONTBUFFER | DDSCAPS_FLIP | DDSCAPS_COMPLEX,
+        },
+        {
+            DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN,
+            DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_FRONTBUFFER,
+            1,
+            DDERR_INVALIDCAPS,
+            ~0u,
+        },
+        {
+            DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN,
+            DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_BACKBUFFER,
+            1,
+            DDERR_INVALIDCAPS,
+            ~0u,
+        },
+    };
+
+    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);
+
+    for (i = 0; i < sizeof(test_data) / sizeof(*test_data); ++i)
+    {
+        hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, test_data[i].coop_level);
+        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;
+        if (test_data[i].back_buffer_count != ~0u)
+            surface_desc.dwFlags |= DDSD_BACKBUFFERCOUNT;
+        surface_desc.ddsCaps.dwCaps = test_data[i].caps_in;
+        surface_desc.dwBackBufferCount = test_data[i].back_buffer_count;
+        hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
+        ok(hr == test_data[i].hr, "Test %u: Got unexpected hr %#x, expected %#x.\n", i, hr, test_data[i].hr);
+        if (FAILED(hr))
+            continue;
+
+        memset(&surface_desc, 0, sizeof(surface_desc));
+        surface_desc.dwSize = sizeof(surface_desc);
+        hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc);
+        ok(SUCCEEDED(hr), "Test %u: Failed to get surface desc, hr %#x.\n", i, hr);
+        ok((surface_desc.ddsCaps.dwCaps & ~placement) == test_data[i].caps_out,
+                "Test %u: Got unexpected caps %#x, expected %#x.\n",
+                i, surface_desc.ddsCaps.dwCaps, test_data[i].caps_out);
+
+        IDirectDrawSurface_Release(surface);
+    }
+
+    refcount = IDirectDraw2_Release(ddraw);
+    ok(refcount == 0, "The ddraw object was not properly freed, refcount %u.\n", refcount);
+    DestroyWindow(window);
+}
+
 static void test_surface_lock(void)
 {
     IDirectDraw2 *ddraw;
@@ -4735,6 +4891,7 @@ START_TEST(ddraw2)
     test_coop_level_activateapp();
     test_unsupported_formats();
     test_rt_caps();
+    test_primary_caps();
     test_surface_lock();
     test_surface_discard();
     test_flip();
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c
index 489dfe7..b7e07cb 100644
--- a/dlls/ddraw/tests/ddraw4.c
+++ b/dlls/ddraw/tests/ddraw4.c
@@ -4569,6 +4569,162 @@ done:
     DestroyWindow(window);
 }
 
+static void test_primary_caps(void)
+{
+    const DWORD placement = DDSCAPS_LOCALVIDMEM | DDSCAPS_VIDEOMEMORY | DDSCAPS_SYSTEMMEMORY;
+    IDirectDrawSurface4 *surface;
+    DDSURFACEDESC2 surface_desc;
+    IDirectDraw4 *ddraw;
+    unsigned int i;
+    ULONG refcount;
+    HWND window;
+    HRESULT hr;
+
+    static const struct
+    {
+        DWORD coop_level;
+        DWORD caps_in;
+        DWORD back_buffer_count;
+        HRESULT hr;
+        DWORD caps_out;
+    }
+    test_data[] =
+    {
+        {
+            DDSCL_NORMAL,
+            DDSCAPS_PRIMARYSURFACE,
+            ~0u,
+            DD_OK,
+            DDSCAPS_VISIBLE | DDSCAPS_PRIMARYSURFACE,
+        },
+        {
+            DDSCL_NORMAL,
+            DDSCAPS_PRIMARYSURFACE | DDSCAPS_TEXTURE,
+            ~0u,
+            DDERR_INVALIDCAPS,
+            ~0u,
+        },
+        {
+            DDSCL_NORMAL,
+            DDSCAPS_PRIMARYSURFACE | DDSCAPS_FRONTBUFFER,
+            ~0u,
+            DDERR_INVALIDCAPS,
+            ~0u,
+        },
+        {
+            DDSCL_NORMAL,
+            DDSCAPS_PRIMARYSURFACE | DDSCAPS_BACKBUFFER,
+            ~0u,
+            DDERR_INVALIDCAPS,
+            ~0u,
+        },
+        {
+            DDSCL_NORMAL,
+            DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP,
+            ~0u,
+            DDERR_INVALIDCAPS,
+            ~0u,
+        },
+        {
+            DDSCL_NORMAL,
+            DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX,
+            ~0u,
+            DDERR_INVALIDCAPS,
+            ~0u,
+        },
+        {
+            DDSCL_NORMAL,
+            DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP,
+            ~0u,
+            DDERR_INVALIDCAPS,
+            ~0u,
+        },
+        {
+            DDSCL_NORMAL,
+            DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP,
+            0,
+            DDERR_INVALIDCAPS,
+            ~0u,
+        },
+        {
+            DDSCL_NORMAL,
+            DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP,
+            1,
+            DDERR_NOEXCLUSIVEMODE,
+            ~0u,
+        },
+        {
+            DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN,
+            DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP,
+            0,
+            DDERR_INVALIDCAPS,
+            ~0u,
+        },
+        {
+            DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN,
+            DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP,
+            1,
+            DD_OK,
+            DDSCAPS_VISIBLE | DDSCAPS_PRIMARYSURFACE | DDSCAPS_FRONTBUFFER | DDSCAPS_FLIP | DDSCAPS_COMPLEX,
+        },
+        {
+            DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN,
+            DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_FRONTBUFFER,
+            1,
+            DDERR_INVALIDCAPS,
+            ~0u,
+        },
+        {
+            DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN,
+            DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_BACKBUFFER,
+            1,
+            DDERR_INVALIDCAPS,
+            ~0u,
+        },
+    };
+
+    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);
+
+    for (i = 0; i < sizeof(test_data) / sizeof(*test_data); ++i)
+    {
+        hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, test_data[i].coop_level);
+        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;
+        if (test_data[i].back_buffer_count != ~0u)
+            surface_desc.dwFlags |= DDSD_BACKBUFFERCOUNT;
+        surface_desc.ddsCaps.dwCaps = test_data[i].caps_in;
+        surface_desc.dwBackBufferCount = test_data[i].back_buffer_count;
+        hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
+        ok(hr == test_data[i].hr, "Test %u: Got unexpected hr %#x, expected %#x.\n", i, hr, test_data[i].hr);
+        if (FAILED(hr))
+            continue;
+
+        memset(&surface_desc, 0, sizeof(surface_desc));
+        surface_desc.dwSize = sizeof(surface_desc);
+        hr = IDirectDrawSurface4_GetSurfaceDesc(surface, &surface_desc);
+        ok(SUCCEEDED(hr), "Test %u: Failed to get surface desc, hr %#x.\n", i, hr);
+        ok((surface_desc.ddsCaps.dwCaps & ~placement) == test_data[i].caps_out,
+                "Test %u: Got unexpected caps %#x, expected %#x.\n",
+                i, surface_desc.ddsCaps.dwCaps, test_data[i].caps_out);
+
+        IDirectDrawSurface4_Release(surface);
+    }
+
+    refcount = IDirectDraw4_Release(ddraw);
+    ok(refcount == 0, "The ddraw object was not properly freed, refcount %u.\n", refcount);
+    DestroyWindow(window);
+}
+
 static void test_surface_lock(void)
 {
     IDirectDraw4 *ddraw;
@@ -5342,6 +5498,7 @@ START_TEST(ddraw4)
     test_block_formats_creation();
     test_unsupported_formats();
     test_rt_caps();
+    test_primary_caps();
     test_surface_lock();
     test_surface_discard();
     test_flip();
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index 8818828..ca702d9 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -4390,6 +4390,162 @@ done:
     DestroyWindow(window);
 }
 
+static void test_primary_caps(void)
+{
+    const DWORD placement = DDSCAPS_LOCALVIDMEM | DDSCAPS_VIDEOMEMORY | DDSCAPS_SYSTEMMEMORY;
+    IDirectDrawSurface7 *surface;
+    DDSURFACEDESC2 surface_desc;
+    IDirectDraw7 *ddraw;
+    unsigned int i;
+    ULONG refcount;
+    HWND window;
+    HRESULT hr;
+
+    static const struct
+    {
+        DWORD coop_level;
+        DWORD caps_in;
+        DWORD back_buffer_count;
+        HRESULT hr;
+        DWORD caps_out;
+    }
+    test_data[] =
+    {
+        {
+            DDSCL_NORMAL,
+            DDSCAPS_PRIMARYSURFACE,
+            ~0u,
+            DD_OK,
+            DDSCAPS_VISIBLE | DDSCAPS_PRIMARYSURFACE,
+        },
+        {
+            DDSCL_NORMAL,
+            DDSCAPS_PRIMARYSURFACE | DDSCAPS_TEXTURE,
+            ~0u,
+            DDERR_INVALIDCAPS,
+            ~0u,
+        },
+        {
+            DDSCL_NORMAL,
+            DDSCAPS_PRIMARYSURFACE | DDSCAPS_FRONTBUFFER,
+            ~0u,
+            DDERR_INVALIDCAPS,
+            ~0u,
+        },
+        {
+            DDSCL_NORMAL,
+            DDSCAPS_PRIMARYSURFACE | DDSCAPS_BACKBUFFER,
+            ~0u,
+            DDERR_INVALIDCAPS,
+            ~0u,
+        },
+        {
+            DDSCL_NORMAL,
+            DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP,
+            ~0u,
+            DDERR_INVALIDCAPS,
+            ~0u,
+        },
+        {
+            DDSCL_NORMAL,
+            DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX,
+            ~0u,
+            DDERR_INVALIDCAPS,
+            ~0u,
+        },
+        {
+            DDSCL_NORMAL,
+            DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP,
+            ~0u,
+            DDERR_INVALIDCAPS,
+            ~0u,
+        },
+        {
+            DDSCL_NORMAL,
+            DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP,
+            0,
+            DDERR_INVALIDCAPS,
+            ~0u,
+        },
+        {
+            DDSCL_NORMAL,
+            DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP,
+            1,
+            DDERR_NOEXCLUSIVEMODE,
+            ~0u,
+        },
+        {
+            DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN,
+            DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP,
+            0,
+            DDERR_INVALIDCAPS,
+            ~0u,
+        },
+        {
+            DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN,
+            DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP,
+            1,
+            DD_OK,
+            DDSCAPS_VISIBLE | DDSCAPS_PRIMARYSURFACE | DDSCAPS_FRONTBUFFER | DDSCAPS_FLIP | DDSCAPS_COMPLEX,
+        },
+        {
+            DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN,
+            DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_FRONTBUFFER,
+            1,
+            DDERR_INVALIDCAPS,
+            ~0u,
+        },
+        {
+            DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN,
+            DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_BACKBUFFER,
+            1,
+            DDERR_INVALIDCAPS,
+            ~0u,
+        },
+    };
+
+    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);
+
+    for (i = 0; i < sizeof(test_data) / sizeof(*test_data); ++i)
+    {
+        hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, test_data[i].coop_level);
+        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;
+        if (test_data[i].back_buffer_count != ~0u)
+            surface_desc.dwFlags |= DDSD_BACKBUFFERCOUNT;
+        surface_desc.ddsCaps.dwCaps = test_data[i].caps_in;
+        surface_desc.dwBackBufferCount = test_data[i].back_buffer_count;
+        hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
+        ok(hr == test_data[i].hr, "Test %u: Got unexpected hr %#x, expected %#x.\n", i, hr, test_data[i].hr);
+        if (FAILED(hr))
+            continue;
+
+        memset(&surface_desc, 0, sizeof(surface_desc));
+        surface_desc.dwSize = sizeof(surface_desc);
+        hr = IDirectDrawSurface7_GetSurfaceDesc(surface, &surface_desc);
+        ok(SUCCEEDED(hr), "Test %u: Failed to get surface desc, hr %#x.\n", i, hr);
+        ok((surface_desc.ddsCaps.dwCaps & ~placement) == test_data[i].caps_out,
+                "Test %u: Got unexpected caps %#x, expected %#x.\n",
+                i, surface_desc.ddsCaps.dwCaps, test_data[i].caps_out);
+
+        IDirectDrawSurface7_Release(surface);
+    }
+
+    refcount = IDirectDraw7_Release(ddraw);
+    ok(refcount == 0, "The ddraw object was not properly freed, refcount %u.\n", refcount);
+    DestroyWindow(window);
+}
+
 static void test_surface_lock(void)
 {
     IDirectDraw7 *ddraw;
@@ -5238,6 +5394,7 @@ START_TEST(ddraw7)
     test_block_formats_creation();
     test_unsupported_formats();
     test_rt_caps();
+    test_primary_caps();
     test_surface_lock();
     test_surface_discard();
     test_flip();
-- 
1.7.10.4




More information about the wine-patches mailing list