[PATCH 02/10] ddraw/tests: New attachment/flipping tests for back buffers. (try 3)

Oldřich Jedlička oldium.pro at seznam.cz
Tue Aug 3 14:26:15 CDT 2010


Test attaching of back buffers to front buffer. Also try to flip the surfaces.
---
 dlls/ddraw/tests/dsurface.c |  118 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 118 insertions(+), 0 deletions(-)

diff --git a/dlls/ddraw/tests/dsurface.c b/dlls/ddraw/tests/dsurface.c
index b5f6f2c..76bfc7e 100644
--- a/dlls/ddraw/tests/dsurface.c
+++ b/dlls/ddraw/tests/dsurface.c
@@ -3452,6 +3452,123 @@ static void BackBufferCreateSurfaceTest(void)
     IDirectDraw7_Release(dd7);
 }
 
+static void BackBufferAttachmentFlipTest(void)
+{
+    HRESULT hr;
+    IDirectDrawSurface *surface1, *surface2, *surface3, *surface4;
+    DDSURFACEDESC ddsd;
+    HWND window = CreateWindow( "static", "ddraw_test", WS_OVERLAPPEDWINDOW, 100, 100, 160, 160, NULL, NULL, NULL, NULL );
+
+    hr = IDirectDraw_SetCooperativeLevel(lpDD, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+    ok(hr == DD_OK, "SetCooperativeLevel returned %08x\n", hr);
+
+    /* Perform attachment tests on a back-buffer */
+    memset(&ddsd, 0, sizeof(ddsd));
+    ddsd.dwSize = sizeof(ddsd);
+    ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
+    ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER;
+    ddsd.dwWidth = GetSystemMetrics(SM_CXSCREEN);
+    ddsd.dwHeight = GetSystemMetrics(SM_CYSCREEN);
+    hr = IDirectDraw_CreateSurface(lpDD, &ddsd, &surface2, NULL);
+    todo_wine ok(SUCCEEDED(hr), "CreateSurface returned: %x\n",hr);
+
+    if (surface2 != NULL)
+    {
+        /* Try a single primary and a two back buffers */
+        memset(&ddsd, 0, sizeof(ddsd));
+        ddsd.dwSize = sizeof(ddsd);
+        ddsd.dwFlags = DDSD_CAPS;
+        ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
+        hr = IDirectDraw_CreateSurface(lpDD, &ddsd, &surface1, NULL);
+        ok(hr==DD_OK,"CreateSurface returned: %x\n",hr);
+
+        memset(&ddsd, 0, sizeof(ddsd));
+        ddsd.dwSize = sizeof(ddsd);
+        ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
+        ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER;
+        ddsd.dwWidth = GetSystemMetrics(SM_CXSCREEN);
+        ddsd.dwHeight = GetSystemMetrics(SM_CYSCREEN);
+        hr = IDirectDraw_CreateSurface(lpDD, &ddsd, &surface3, NULL);
+        ok(hr==DD_OK,"CreateSurface returned: %x\n",hr);
+
+        /* This one has a different size */
+        memset(&ddsd, 0, sizeof(ddsd));
+        ddsd.dwSize = sizeof(ddsd);
+        ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
+        ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER;
+        ddsd.dwWidth = 128;
+        ddsd.dwHeight = 128;
+        hr = IDirectDraw_CreateSurface(lpDD, &ddsd, &surface4, NULL);
+        ok(hr==DD_OK,"CreateSurface returned: %x\n",hr);
+
+        hr = IDirectDrawSurface_AddAttachedSurface(surface1, surface2);
+        todo_wine ok(hr == DD_OK || broken(hr == DDERR_CANNOTATTACHSURFACE),
+           "Attaching a back buffer to a front buffer returned %08x\n", hr);
+        if(SUCCEEDED(hr))
+        {
+            /* Try flipping the surfaces */
+            hr = IDirectDrawSurface_Flip(surface1, NULL, DDFLIP_WAIT);
+            todo_wine ok(hr == DD_OK, "IDirectDrawSurface_Flip returned 0x%08x\n", hr);
+            hr = IDirectDrawSurface_Flip(surface2, NULL, DDFLIP_WAIT);
+            todo_wine ok(hr == DDERR_NOTFLIPPABLE, "IDirectDrawSurface_Flip returned 0x%08x\n", hr);
+
+            /* Try the reverse without detaching first */
+            hr = IDirectDrawSurface_AddAttachedSurface(surface2, surface1);
+            ok(hr == DDERR_SURFACEALREADYATTACHED, "Attaching an attached surface to its attachee returned %08x\n", hr);
+            hr = IDirectDrawSurface_DeleteAttachedSurface(surface1, 0, surface2);
+            ok(hr == DD_OK, "DeleteAttachedSurface failed with %08x\n", hr);
+        }
+        hr = IDirectDrawSurface_AddAttachedSurface(surface2, surface1);
+        todo_wine ok(hr == DD_OK || broken(hr == DDERR_CANNOTATTACHSURFACE),
+           "Attaching a front buffer to a back buffer returned %08x\n", hr);
+        if(SUCCEEDED(hr))
+        {
+            /* Try flipping the surfaces */
+            hr = IDirectDrawSurface_Flip(surface1, NULL, DDFLIP_WAIT);
+            todo_wine ok(hr == DD_OK, "IDirectDrawSurface_Flip returned 0x%08x\n", hr);
+            hr = IDirectDrawSurface_Flip(surface2, NULL, DDFLIP_WAIT);
+            todo_wine ok(hr == DDERR_NOTFLIPPABLE, "IDirectDrawSurface_Flip returned 0x%08x\n", hr);
+
+            /* Try to detach reversed */
+            hr = IDirectDrawSurface_DeleteAttachedSurface(surface1, 0, surface2);
+            ok(hr == DDERR_CANNOTDETACHSURFACE, "DeleteAttachedSurface returned %08x\n", hr);
+            /* Now the proper detach */
+            hr = IDirectDrawSurface_DeleteAttachedSurface(surface2, 0, surface1);
+            ok(hr == DD_OK, "DeleteAttachedSurface failed with %08x\n", hr);
+        }
+        hr = IDirectDrawSurface_AddAttachedSurface(surface2, surface3);
+        todo_wine ok(hr == DD_OK || broken(hr == DDERR_CANNOTATTACHSURFACE),
+           "Attaching a back buffer to another back buffer returned %08x\n", hr);
+        if(SUCCEEDED(hr))
+        {
+            /* Try flipping the surfaces */
+            hr = IDirectDrawSurface_Flip(surface3, NULL, DDFLIP_WAIT);
+            todo_wine ok(hr == DD_OK, "IDirectDrawSurface_Flip returned 0x%08x\n", hr);
+            hr = IDirectDrawSurface_Flip(surface2, NULL, DDFLIP_WAIT);
+            todo_wine ok(hr == DDERR_NOTFLIPPABLE, "IDirectDrawSurface_Flip returned 0x%08x\n", hr);
+            hr = IDirectDrawSurface_Flip(surface1, NULL, DDFLIP_WAIT);
+            ok(hr == DDERR_NOTFLIPPABLE, "IDirectDrawSurface_Flip returned 0x%08x\n", hr);
+
+            hr = IDirectDrawSurface_DeleteAttachedSurface(surface2, 0, surface3);
+            ok(hr == DD_OK, "DeleteAttachedSurface failed with %08x\n", hr);
+        }
+        hr = IDirectDrawSurface_AddAttachedSurface(surface1, surface4);
+        ok(hr == DDERR_CANNOTATTACHSURFACE, "Attaching a back buffer to a front buffer of different size returned %08x\n", hr);
+        hr = IDirectDrawSurface_AddAttachedSurface(surface4, surface1);
+        ok(hr == DDERR_CANNOTATTACHSURFACE, "Attaching a front buffer to a back buffer of different size returned %08x\n", hr);
+
+        IDirectDrawSurface_Release(surface4);
+        IDirectDrawSurface_Release(surface3);
+        IDirectDrawSurface_Release(surface2);
+        IDirectDrawSurface_Release(surface1);
+    }
+
+    hr =IDirectDraw_SetCooperativeLevel(lpDD, NULL, DDSCL_NORMAL);
+    ok(hr == DD_OK, "SetCooperativeLevel returned %08x\n", hr);
+
+    DestroyWindow(window);
+}
+
 START_TEST(dsurface)
 {
     HRESULT ret;
@@ -3506,5 +3623,6 @@ START_TEST(dsurface)
     GetDCTest();
     GetDCFormatTest();
     BackBufferCreateSurfaceTest();
+    BackBufferAttachmentFlipTest();
     ReleaseDirectDraw();
 }
-- 
1.7.2




More information about the wine-patches mailing list