2 * Unit test suite for the Spooler-Service helper DLL
4 * Copyright 2007 Detlef Riekenberg
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #include "wine/test.h"
33 static HMODULE hwinspool;
36 static DWORD (WINAPI * pSplInitializeWinSpoolDrv)(LPVOID *);
38 #define WINSPOOL_TABLESIZE 16
40 static LPVOID fn_spl[WINSPOOL_TABLESIZE];
41 static LPVOID fn_w2k[WINSPOOL_TABLESIZE];
42 static LPVOID fn_xp[WINSPOOL_TABLESIZE];
44 /* ########################### */
46 static LPCSTR load_functions(void)
51 hspl = LoadLibraryA(ptr);
52 if (!hspl) return ptr;
54 ptr = "SplInitializeWinSpoolDrv";
55 pSplInitializeWinSpoolDrv = (void *) GetProcAddress(hspl, ptr);
56 if (!pSplInitializeWinSpoolDrv) return ptr;
60 hwinspool = LoadLibraryA(ptr);
61 if (!hwinspool) return ptr;
63 memset(fn_w2k, 0xff, sizeof(fn_w2k));
64 fn_w2k[0] = (void *) GetProcAddress(hwinspool, "OpenPrinterW");
65 fn_w2k[1] = (void *) GetProcAddress(hwinspool, "ClosePrinter");
66 fn_w2k[2] = (void *) GetProcAddress(hwinspool, "SpoolerDevQueryPrintW");
67 fn_w2k[3] = (void *) GetProcAddress(hwinspool, "SpoolerPrinterEvent");
68 fn_w2k[4] = (void *) GetProcAddress(hwinspool, "DocumentPropertiesW");
69 fn_w2k[5] = (void *) GetProcAddress(hwinspool, (LPSTR) 212); /* LoadPrinterDriver */
70 fn_w2k[6] = (void *) GetProcAddress(hwinspool, "SetDefaultPrinterW");
71 fn_w2k[7] = (void *) GetProcAddress(hwinspool, "GetDefaultPrinterW");
72 fn_w2k[8] = (void *) GetProcAddress(hwinspool, (LPSTR) 213); /* RefCntLoadDriver */
73 fn_w2k[9] = (void *) GetProcAddress(hwinspool, (LPSTR) 214); /* RefCntUnloadDriver */
74 fn_w2k[10] = (void *) GetProcAddress(hwinspool, (LPSTR) 215); /* ForceUnloadDriver */
76 memset(fn_xp, 0xff, sizeof(fn_xp));
77 fn_xp[0] = (void *) GetProcAddress(hwinspool, "OpenPrinterW");
78 fn_xp[1] = (void *) GetProcAddress(hwinspool, "ClosePrinter");
79 fn_xp[2] = (void *) GetProcAddress(hwinspool, "SpoolerDevQueryPrintW");
80 fn_xp[3] = (void *) GetProcAddress(hwinspool, "SpoolerPrinterEvent");
81 fn_xp[4] = (void *) GetProcAddress(hwinspool, "DocumentPropertiesW");
82 fn_xp[5] = (void *) GetProcAddress(hwinspool, (LPSTR) 212); /* LoadPrinterDriver */
83 fn_xp[6] = (void *) GetProcAddress(hwinspool, (LPSTR) 213); /* RefCntLoadDriver */
84 fn_xp[7] = (void *) GetProcAddress(hwinspool, (LPSTR) 214); /* RefCntUnloadDriver */
85 fn_xp[8] = (void *) GetProcAddress(hwinspool, (LPSTR) 215); /* ForceUnloadDriver */
91 /* ########################### */
93 static void test_SplInitializeWinSpoolDrv(VOID)
99 memset(fn_spl, 0xff, sizeof(fn_spl));
100 SetLastError(0xdeadbeef);
101 res = pSplInitializeWinSpoolDrv(fn_spl);
102 ok(res, "got %u with %u (expected '!= 0')\n", res, GetLastError());
104 /* functions 0 to 5 are the same with "spoolss.dll" from w2k and xp */
105 is_xp = (fn_spl[6] == fn_xp[6]);
107 while (id < WINSPOOL_TABLESIZE) {
108 ok( fn_spl[id] == (is_xp ? fn_xp[id] : fn_w2k[id]),
109 "(#%02u) spoolss: %p, xp: %p, w2k: %p\n", id, fn_spl[id], fn_xp[id], fn_w2k[id]);
114 /* ########################### */
120 /* spoolss.dll does not exist on win9x */
121 ptr = load_functions();
123 skip("%s not found\n", ptr);
127 test_SplInitializeWinSpoolDrv();