[PATCH] spoolss/tests: Add tests for SplInitializeWinSpoolDrv
Detlef Riekenberg
wine.dev at web.de
Tue Oct 2 18:01:12 CDT 2007
---
dlls/spoolss/tests/Makefile.in | 13 ++++
dlls/spoolss/tests/spoolss.c | 129 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 142 insertions(+), 0 deletions(-)
diff --git a/dlls/spoolss/tests/Makefile.in b/dlls/spoolss/tests/Makefile.in
new file mode 100644
index 0000000..f0e56ba
--- /dev/null
+++ b/dlls/spoolss/tests/Makefile.in
@@ -0,0 +1,13 @@
+TOPSRCDIR = @top_srcdir@
+TOPOBJDIR = ../../..
+SRCDIR = @srcdir@
+VPATH = @srcdir@
+TESTDLL = spoolss.dll
+IMPORTS = kernel32
+
+CTESTS = \
+ spoolss.c
+
+ at MAKE_TEST_RULES@
+
+ at DEPENDENCIES@ # everything below this line is overwritten by make depend
diff --git a/dlls/spoolss/tests/spoolss.c b/dlls/spoolss/tests/spoolss.c
new file mode 100644
index 0000000..3797785
--- /dev/null
+++ b/dlls/spoolss/tests/spoolss.c
@@ -0,0 +1,129 @@
+/*
+ * Unit test suite for the Spooler-Service helper DLL
+ *
+ * Copyright 2007 Detlef Riekenberg
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ *
+ */
+
+#include <stdarg.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "winerror.h"
+#include "wine/test.h"
+
+
+
+/* ##### */
+
+static HMODULE hwinspool;
+
+static HMODULE hspl;
+static DWORD (WINAPI * pSplInitializeWinSpoolDrv)(LPVOID *);
+
+#define WINSPOOL_TABLESIZE 16
+
+static LPVOID fn_spl[WINSPOOL_TABLESIZE];
+static LPVOID fn_w2k[WINSPOOL_TABLESIZE];
+static LPVOID fn_xp[WINSPOOL_TABLESIZE];
+
+/* ########################### */
+
+static LPCSTR load_functions(void)
+{
+ LPCSTR ptr;
+
+ ptr = "spoolss.dll";
+ hspl = LoadLibraryA(ptr);
+ if (!hspl) return ptr;
+
+ ptr = "SplInitializeWinSpoolDrv";
+ pSplInitializeWinSpoolDrv = (void *) GetProcAddress(hspl, ptr);
+ if (!pSplInitializeWinSpoolDrv) return ptr;
+
+
+ ptr = "winspool.drv";
+ hwinspool = LoadLibraryA(ptr);
+ if (!hwinspool) return ptr;
+
+ memset(fn_w2k, 0xff, sizeof(fn_w2k));
+ fn_w2k[0] = (void *) GetProcAddress(hwinspool, "OpenPrinterW");
+ fn_w2k[1] = (void *) GetProcAddress(hwinspool, "ClosePrinter");
+ fn_w2k[2] = (void *) GetProcAddress(hwinspool, "SpoolerDevQueryPrintW");
+ fn_w2k[3] = (void *) GetProcAddress(hwinspool, "SpoolerPrinterEvent");
+ fn_w2k[4] = (void *) GetProcAddress(hwinspool, "DocumentPropertiesW");
+ fn_w2k[5] = (void *) GetProcAddress(hwinspool, (LPSTR) 212); /* LoadPrinterDriver */
+ fn_w2k[6] = (void *) GetProcAddress(hwinspool, "SetDefaultPrinterW");
+ fn_w2k[7] = (void *) GetProcAddress(hwinspool, "GetDefaultPrinterW");
+ fn_w2k[8] = (void *) GetProcAddress(hwinspool, (LPSTR) 213); /* RefCntLoadDriver */
+ fn_w2k[9] = (void *) GetProcAddress(hwinspool, (LPSTR) 214); /* RefCntUnloadDriver */
+ fn_w2k[10] = (void *) GetProcAddress(hwinspool, (LPSTR) 215); /* ForceUnloadDriver */
+
+ memset(fn_xp, 0xff, sizeof(fn_xp));
+ fn_xp[0] = (void *) GetProcAddress(hwinspool, "OpenPrinterW");
+ fn_xp[1] = (void *) GetProcAddress(hwinspool, "ClosePrinter");
+ fn_xp[2] = (void *) GetProcAddress(hwinspool, "SpoolerDevQueryPrintW");
+ fn_xp[3] = (void *) GetProcAddress(hwinspool, "SpoolerPrinterEvent");
+ fn_xp[4] = (void *) GetProcAddress(hwinspool, "DocumentPropertiesW");
+ fn_xp[5] = (void *) GetProcAddress(hwinspool, (LPSTR) 212); /* LoadPrinterDriver */
+ fn_xp[6] = (void *) GetProcAddress(hwinspool, (LPSTR) 213); /* RefCntLoadDriver */
+ fn_xp[7] = (void *) GetProcAddress(hwinspool, (LPSTR) 214); /* RefCntUnloadDriver */
+ fn_xp[8] = (void *) GetProcAddress(hwinspool, (LPSTR) 215); /* ForceUnloadDriver */
+
+ return NULL;
+
+}
+
+/* ########################### */
+
+static void test_SplInitializeWinSpoolDrv(VOID)
+{
+ DWORD res;
+ LONG id;
+ BOOL is_xp;
+
+ memset(fn_spl, 0xff, sizeof(fn_spl));
+ SetLastError(0xdeadbeef);
+ res = pSplInitializeWinSpoolDrv(fn_spl);
+ ok(res, "got %u with %u (expected '!= 0')\n", res, GetLastError());
+
+ /* functions 0 to 5 are the same with "spoolss.dll" from w2k and xp */
+ is_xp = (fn_spl[6] == fn_xp[6]);
+ id = 0;
+ while (id < WINSPOOL_TABLESIZE) {
+ ok( fn_spl[id] == (is_xp ? fn_xp[id] : fn_w2k[id]),
+ "(#%02u) spoolss: %p, xp: %p, w2k: %p\n", id, fn_spl[id], fn_xp[id], fn_w2k[id]);
+ id++;
+ }
+}
+
+/* ########################### */
+
+START_TEST(spoolss)
+{
+ LPCSTR ptr;
+
+ /* spoolss.dll does not exist on win9x */
+ ptr = load_functions();
+ if (ptr) {
+ skip("%s not found\n", ptr);
+ return;
+ }
+
+ test_SplInitializeWinSpoolDrv();
+
+}
--
1.4.1
--=-du/eV9nPHIiKmyjr0ATm--
More information about the wine-patches
mailing list