[PATCH] DDrawex: start some tests=0A=

Stefan Doesinger stefan at codeweavers.com
Tue Dec 16 20:54:02 CST 2008


=0A=
Nothing special in them. There's another switch that feels like a =
backdoor to=0A=
make this test behave different=0A=
from ddraw.dll=0A=
---=0A=
 configure.ac                   |    1 +=0A=
 dlls/ddrawex/tests/Makefile.in |   13 +++=0A=
 dlls/ddrawex/tests/surface.c   |  182 =
++++++++++++++++++++++++++++++++++++++++=0A=
 3 files changed, 196 insertions(+), 0 deletions(-)=0A=
 create mode 100644 dlls/ddrawex/tests/Makefile.in=0A=
 create mode 100644 dlls/ddrawex/tests/surface.c=0A=
=0A=
diff --git a/configure.ac b/configure.ac=0A=
index 784107e..8ac0ff6 100644=0A=
--- a/configure.ac=0A=
+++ b/configure.ac=0A=
@@ -1822,6 +1822,7 @@ =
WINE_CONFIG_MAKEFILE([dlls/dciman32/Makefile],[dlls/Makedll.rules],[dlls]=
,[ALL_D=0A=
 =
WINE_CONFIG_MAKEFILE([dlls/ddraw/Makefile],[dlls/Makedll.rules],[dlls],[A=
LL_DLL_DIRS])=0A=
 =
WINE_CONFIG_MAKEFILE([dlls/ddraw/tests/Makefile],[dlls/Maketest.rules],[d=
lls],[ALL_TEST_DIRS],[enable_tests])=0A=
 =
WINE_CONFIG_MAKEFILE([dlls/ddrawex/Makefile],[dlls/Makedll.rules],[dlls],=
[ALL_DLL_DIRS])=0A=
+WINE_CONFIG_MAKEFILE([dlls/ddrawex/tests/Makefile],[dlls/Maketest.rules]=
,[dlls],[ALL_TEST_DIRS],[enable_tests])=0A=
 =
WINE_CONFIG_MAKEFILE([dlls/devenum/Makefile],[dlls/Makedll.rules],[dlls],=
[ALL_DLL_DIRS])=0A=
 =
WINE_CONFIG_MAKEFILE([dlls/dinput/Makefile],[dlls/Makedll.rules],[dlls],[=
ALL_DLL_DIRS])=0A=
 =
WINE_CONFIG_MAKEFILE([dlls/dinput/tests/Makefile],[dlls/Maketest.rules],[=
dlls],[ALL_TEST_DIRS],[enable_tests])=0A=
diff --git a/dlls/ddrawex/tests/Makefile.in =
b/dlls/ddrawex/tests/Makefile.in=0A=
new file mode 100644=0A=
index 0000000..a945c81=0A=
--- /dev/null=0A=
+++ b/dlls/ddrawex/tests/Makefile.in=0A=
@@ -0,0 +1,13 @@=0A=
+TOPSRCDIR =3D @top_srcdir@=0A=
+TOPOBJDIR =3D ../../..=0A=
+SRCDIR    =3D @srcdir@=0A=
+VPATH     =3D @srcdir@=0A=
+TESTDLL   =3D ddrawex.dll=0A=
+IMPORTS   =3D user32 gdi32 kernel32=0A=
+=0A=
+CTESTS =3D \=0A=
+	surface.c=0A=
+=0A=
+ at MAKE_TEST_RULES@=0A=
+=0A=
+ at DEPENDENCIES@  # everything below this line is overwritten by make =
depend=0A=
diff --git a/dlls/ddrawex/tests/surface.c b/dlls/ddrawex/tests/surface.c=0A=
new file mode 100644=0A=
index 0000000..b39e84e=0A=
--- /dev/null=0A=
+++ b/dlls/ddrawex/tests/surface.c=0A=
@@ -0,0 +1,182 @@=0A=
+/*=0A=
+ * Unit tests for ddrawex surfaces=0A=
+ *=0A=
+ * This library is free software; you can redistribute it and/or=0A=
+ * modify it under the terms of the GNU Lesser General Public=0A=
+ * License as published by the Free Software Foundation; either=0A=
+ * version 2.1 of the License, or (at your option) any later version.=0A=
+ *=0A=
+ * This library is distributed in the hope that it will be useful,=0A=
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of=0A=
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU=0A=
+ * Lesser General Public License for more details.=0A=
+ *=0A=
+ * You should have received a copy of the GNU Lesser General Public=0A=
+ * License along with this library; if not, write to the Free Software=0A=
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA =
02110-1301, USA=0A=
+ */=0A=
+#define COBJMACROS=0A=
+/* For IID_IDirectDraw3 - it is not in dxguid.dll */=0A=
+#define INITGUID=0A=
+=0A=
+#include <assert.h>=0A=
+#include "wine/test.h"=0A=
+#include "windef.h"=0A=
+#include "winbase.h"=0A=
+#include "ddraw.h"=0A=
+#include "ddrawex_private.h"=0A=
+#include "unknwn.h"=0A=
+=0A=
+IDirectDrawFactory *factory;=0A=
+HRESULT (WINAPI *pDllGetClassObject)(REFCLSID rclsid, REFIID riid, =
LPVOID *ppv);=0A=
+=0A=
+static IDirectDraw *createDD()=0A=
+{=0A=
+    HRESULT hr;=0A=
+    IDirectDraw *dd;=0A=
+=0A=
+    hr =3D IDirectDrawFactory_CreateDirectDraw(factory, NULL, NULL, =
DDSCL_NORMAL, 0,=0A=
+                                             0, &dd);=0A=
+    ok(hr =3D=3D DD_OK, "Failed to create an IDirectDraw interface, hr =
=3D 0x%08x\n", hr);=0A=
+    return SUCCEEDED(hr) ? dd : NULL;=0A=
+}=0A=
+=0A=
+static void dctest_surf(IDirectDrawSurface *surf, int ddsdver) {=0A=
+    HRESULT hr;=0A=
+    HDC dc, dc2 =3D (HDC) 0x1234;=0A=
+    DDSURFACEDESC ddsd;=0A=
+    DDSURFACEDESC2 ddsd2;=0A=
+=0A=
+    memset(&ddsd, 0, sizeof(ddsd));=0A=
+    ddsd.dwSize =3D sizeof(ddsd);=0A=
+    memset(&ddsd2, 0, sizeof(ddsd2));=0A=
+    ddsd2.dwSize =3D sizeof(ddsd2);=0A=
+=0A=
+    hr =3D IDirectDrawSurface_GetDC(surf, &dc);=0A=
+    ok(hr =3D=3D DD_OK, "IDirectDrawSurface_GetDC failed: 0x%08x\n", =
hr);=0A=
+=0A=
+    hr =3D IDirectDrawSurface_GetDC(surf, &dc);=0A=
+    ok(hr =3D=3D DDERR_DCALREADYCREATED, "IDirectDrawSurface_GetDC =
failed: 0x%08x\n", hr);=0A=
+    ok(dc2 =3D=3D (HDC) 0x1234, "The failed GetDC call changed the dc: =
%p\n", dc2);=0A=
+=0A=
+    hr =3D IDirectDrawSurface_Lock(surf, NULL, ddsdver =3D=3D 1 ? &ddsd =
: ((DDSURFACEDESC *) &ddsd2), 0, NULL);=0A=
+    ok(hr =3D=3D DDERR_SURFACEBUSY, "IDirectDrawSurface_Lock returned =
0x%08x, expected DDERR_ALREADYLOCKED\n", hr);=0A=
+=0A=
+    hr =3D IDirectDrawSurface_ReleaseDC(surf, dc);=0A=
+    ok(hr =3D=3D DD_OK, "IDirectDrawSurface_ReleaseDC failed: =
0x%08x\n", hr);=0A=
+    hr =3D IDirectDrawSurface_ReleaseDC(surf, dc);=0A=
+    ok(hr =3D=3D DDERR_NODC, "IDirectDrawSurface_ReleaseDC returned =
0x%08x, expected DDERR_NODC\n", hr);=0A=
+}=0A=
+=0A=
+static void GetDCTest(void)=0A=
+{=0A=
+    DDSURFACEDESC ddsd;=0A=
+    DDSURFACEDESC2 ddsd2;=0A=
+    IDirectDrawSurface *surf;=0A=
+    IDirectDrawSurface2 *surf2;=0A=
+    IDirectDrawSurface2 *surf3;=0A=
+    IDirectDrawSurface4 *surf4;=0A=
+    HRESULT hr;=0A=
+    IDirectDraw  *dd1 =3D createDD();=0A=
+    IDirectDraw2 *dd2;=0A=
+    IDirectDraw3 *dd3;=0A=
+    IDirectDraw4 *dd4;=0A=
+=0A=
+    memset(&ddsd, 0, sizeof(ddsd));=0A=
+    ddsd.dwSize =3D sizeof(ddsd);=0A=
+    ddsd.dwFlags =3D DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;=0A=
+    ddsd.dwWidth =3D 64;=0A=
+    ddsd.dwHeight =3D 64;=0A=
+    ddsd.ddsCaps.dwCaps =3D DDSCAPS_OFFSCREENPLAIN;=0A=
+    memset(&ddsd2, 0, sizeof(ddsd2));=0A=
+    ddsd2.dwSize =3D sizeof(ddsd2);=0A=
+    ddsd2.dwFlags =3D DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;=0A=
+    ddsd2.dwWidth =3D 64;=0A=
+    ddsd2.dwHeight =3D 64;=0A=
+    ddsd2.ddsCaps.dwCaps =3D DDSCAPS_OFFSCREENPLAIN;=0A=
+=0A=
+    hr =3D IDirectDraw_CreateSurface(dd1, &ddsd, &surf, NULL);=0A=
+    ok(hr =3D=3D DD_OK, "IDirectDraw_CreateSurface failed: 0x%08x\n", =
hr);=0A=
+    dctest_surf(surf, 1);=0A=
+    IDirectDrawSurface_Release(surf);=0A=
+=0A=
+    hr =3D IDirectDraw_QueryInterface(dd1, &IID_IDirectDraw2, (void **) =
&dd2);=0A=
+    ok(hr =3D=3D DD_OK, "IDirectDraw_QueryInterface failed: 0x%08x\n", =
hr);=0A=
+=0A=
+    hr =3D IDirectDraw2_CreateSurface(dd2, &ddsd, &surf, NULL);=0A=
+    ok(hr =3D=3D DD_OK, "IDirectDraw2_CreateSurface failed: 0x%08x\n", =
hr);=0A=
+    dctest_surf(surf, 1);=0A=
+=0A=
+    hr =3D IDirectDrawSurface_QueryInterface(surf, =
&IID_IDirectDrawSurface2, (void **) &surf2);=0A=
+    ok(hr =3D=3D DD_OK, "IDirectDrawSurface_QueryInterface failed: =
0x%08x\n", hr);=0A=
+    dctest_surf((IDirectDrawSurface *) surf2, 1);=0A=
+=0A=
+    IDirectDrawSurface2_Release(surf2);=0A=
+    IDirectDrawSurface_Release(surf);=0A=
+    IDirectDraw2_Release(dd2);=0A=
+=0A=
+    hr =3D IDirectDraw_QueryInterface(dd1, &IID_IDirectDraw3, (void **) =
&dd3);=0A=
+    todo_wine ok(hr =3D=3D DD_OK, "IDirectDraw_QueryInterface failed: =
0x%08x\n", hr);=0A=
+=0A=
+    if(SUCCEEDED(hr))=0A=
+    {=0A=
+        hr =3D IDirectDraw3_CreateSurface(dd3, &ddsd, &surf, NULL);=0A=
+        ok(hr =3D=3D DD_OK, "IDirectDraw3_CreateSurface failed: =
0x%08x\n", hr);=0A=
+        dctest_surf(surf, 1);=0A=
+=0A=
+        hr =3D IDirectDrawSurface_QueryInterface(surf, =
&IID_IDirectDrawSurface3, (void **) &surf3);=0A=
+        ok(hr =3D=3D DD_OK, "IDirectDrawSurface_QueryInterface failed: =
0x%08x\n", hr);=0A=
+        dctest_surf((IDirectDrawSurface *) surf3, 1);=0A=
+=0A=
+        IDirectDrawSurface3_Release(surf3);=0A=
+        IDirectDrawSurface_Release(surf);=0A=
+        IDirectDraw3_Release(dd3);=0A=
+    }=0A=
+=0A=
+    hr =3D IDirectDraw_QueryInterface(dd1, &IID_IDirectDraw4, (void **) =
&dd4);=0A=
+    ok(hr =3D=3D DD_OK, "IDirectDraw_QueryInterface failed: 0x%08x\n", =
hr);=0A=
+=0A=
+    surf =3D NULL;=0A=
+    hr =3D IDirectDraw4_CreateSurface(dd4, &ddsd2, &surf4, NULL);=0A=
+    ok(hr =3D=3D DD_OK, "IDirectDraw4_CreateSurface failed: 0x%08x\n", =
hr);=0A=
+    dctest_surf((IDirectDrawSurface *) surf4, 2);=0A=
+=0A=
+    IDirectDrawSurface4_Release(surf4);=0A=
+    IDirectDraw4_Release(dd4);=0A=
+=0A=
+    IDirectDraw_Release(dd1);=0A=
+}=0A=
+=0A=
+START_TEST(surface)=0A=
+{=0A=
+    IClassFactory *classfactory =3D NULL;=0A=
+    ULONG ref;=0A=
+    HRESULT hr;=0A=
+    HMODULE hmod =3D LoadLibrary("ddrawex.dll");=0A=
+    if(hmod =3D=3D NULL) {=0A=
+        skip("Failed to load ddrawex.dll\n");=0A=
+        return;=0A=
+    }=0A=
+    pDllGetClassObject =3D (void*)GetProcAddress(hmod, =
"DllGetClassObject");=0A=
+    if(pDllGetClassObject =3D=3D NULL) {=0A=
+        skip("Failed to get DllGetClassObject\n");=0A=
+        return;=0A=
+    }=0A=
+=0A=
+    hr =3D pDllGetClassObject(&CLSID_DirectDrawFactory, =
&IID_IClassFactory, (void **) &classfactory);=0A=
+    ok(hr =3D=3D S_OK, "Failed to create a IClassFactory\n");=0A=
+    hr =3D IClassFactory_CreateInstance(classfactory, NULL, =
&IID_IDirectDrawFactory, (void **) &factory);=0A=
+    ok(hr =3D=3D S_OK, "Failed to create a IDirectDrawFactory\n");=0A=
+=0A=
+    GetDCTest();=0A=
+=0A=
+    if(factory) {=0A=
+        ref =3D IDirectDrawFactory_Release(factory);=0A=
+        ok(ref =3D=3D 0, "IDirectDrawFactory not cleanly released\n");=0A=
+    }=0A=
+    if(classfactory) {=0A=
+        ref =3D IClassFactory_Release(classfactory);=0A=
+        /* Seems broken: Windows always returns 1 here */=0A=
+        todo_wine ok(ref =3D=3D 1, "IClassFactory refcount wrong, ref =
=3D %u\n", ref);=0A=
+    }=0A=
+}=0A=
-- =0A=
1.6.0.6=0A=
=0A=

------=_NextPart_000_0005_01C96C80.4ACC5A90--




More information about the wine-patches mailing list