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 BOOL (WINAPI * pBuildOtherNamesFromMachineName)(LPWSTR **, LPDWORD);
37 static DWORD (WINAPI * pSplInitializeWinSpoolDrv)(LPVOID *);
39 #define WINSPOOL_TABLESIZE 16
41 static LPVOID fn_spl[WINSPOOL_TABLESIZE];
42 static LPVOID fn_w2k[WINSPOOL_TABLESIZE];
43 static LPVOID fn_xp[WINSPOOL_TABLESIZE];
45 /* ########################### */
47 static LPCSTR load_functions(void)
52 hspl = LoadLibraryA(ptr);
53 if (!hspl) return ptr;
55 ptr = "BuildOtherNamesFromMachineName";
56 pBuildOtherNamesFromMachineName = (void *) GetProcAddress(hspl, ptr);
57 if (!pBuildOtherNamesFromMachineName) return ptr;
59 ptr = "SplInitializeWinSpoolDrv";
60 pSplInitializeWinSpoolDrv = (void *) GetProcAddress(hspl, ptr);
61 if (!pSplInitializeWinSpoolDrv) return ptr;
65 hwinspool = LoadLibraryA(ptr);
66 if (!hwinspool) return ptr;
68 memset(fn_w2k, 0xff, sizeof(fn_w2k));
69 fn_w2k[0] = (void *) GetProcAddress(hwinspool, "OpenPrinterW");
70 fn_w2k[1] = (void *) GetProcAddress(hwinspool, "ClosePrinter");
71 fn_w2k[2] = (void *) GetProcAddress(hwinspool, "SpoolerDevQueryPrintW");
72 fn_w2k[3] = (void *) GetProcAddress(hwinspool, "SpoolerPrinterEvent");
73 fn_w2k[4] = (void *) GetProcAddress(hwinspool, "DocumentPropertiesW");
74 fn_w2k[5] = (void *) GetProcAddress(hwinspool, (LPSTR) 212); /* LoadPrinterDriver */
75 fn_w2k[6] = (void *) GetProcAddress(hwinspool, "SetDefaultPrinterW");
76 fn_w2k[7] = (void *) GetProcAddress(hwinspool, "GetDefaultPrinterW");
77 fn_w2k[8] = (void *) GetProcAddress(hwinspool, (LPSTR) 213); /* RefCntLoadDriver */
78 fn_w2k[9] = (void *) GetProcAddress(hwinspool, (LPSTR) 214); /* RefCntUnloadDriver */
79 fn_w2k[10] = (void *) GetProcAddress(hwinspool, (LPSTR) 215); /* ForceUnloadDriver */
81 memset(fn_xp, 0xff, sizeof(fn_xp));
82 fn_xp[0] = (void *) GetProcAddress(hwinspool, "OpenPrinterW");
83 fn_xp[1] = (void *) GetProcAddress(hwinspool, "ClosePrinter");
84 fn_xp[2] = (void *) GetProcAddress(hwinspool, "SpoolerDevQueryPrintW");
85 fn_xp[3] = (void *) GetProcAddress(hwinspool, "SpoolerPrinterEvent");
86 fn_xp[4] = (void *) GetProcAddress(hwinspool, "DocumentPropertiesW");
87 fn_xp[5] = (void *) GetProcAddress(hwinspool, (LPSTR) 212); /* LoadPrinterDriver */
88 fn_xp[6] = (void *) GetProcAddress(hwinspool, (LPSTR) 213); /* RefCntLoadDriver */
89 fn_xp[7] = (void *) GetProcAddress(hwinspool, (LPSTR) 214); /* RefCntUnloadDriver */
90 fn_xp[8] = (void *) GetProcAddress(hwinspool, (LPSTR) 215); /* ForceUnloadDriver */
96 /* ########################### */
98 static void test_BuildOtherNamesFromMachineName(void)
107 SetLastError(0xdeadbeef);
108 res = pBuildOtherNamesFromMachineName(&buffers, &numentries);
110 /* An array with 3 stringpointer is returned:
111 entry_#0: "" (empty String)
112 entry_#1: <hostname> (this is the same as the computernam)
113 entry_#2: <ip-address> (string with the ip-address of <hostname>)
116 ok( res && (buffers != NULL) && (numentries == 3) && (buffers[0] != NULL) && (buffers[0][0] == '\0'),
117 "got %u with %u and %p,%u (%p:%d)\n", res, GetLastError(), buffers, numentries,
118 ((numentries > 0) && buffers) ? buffers[0] : NULL,
119 ((numentries > 0) && buffers && buffers[0]) ? lstrlenW(buffers[0]) : -1);
123 /* ########################### */
125 static void test_SplInitializeWinSpoolDrv(VOID)
131 memset(fn_spl, 0xff, sizeof(fn_spl));
132 SetLastError(0xdeadbeef);
133 res = pSplInitializeWinSpoolDrv(fn_spl);
134 ok(res, "got %u with %u (expected '!= 0')\n", res, GetLastError());
136 /* functions 0 to 5 are the same with "spoolss.dll" from w2k and xp */
137 is_xp = (fn_spl[6] == fn_xp[6]);
139 while (id < WINSPOOL_TABLESIZE) {
140 ok( fn_spl[id] == (is_xp ? fn_xp[id] : fn_w2k[id]),
141 "(#%02u) spoolss: %p, xp: %p, w2k: %p\n", id, fn_spl[id], fn_xp[id], fn_w2k[id]);
146 /* ########################### */
152 /* spoolss.dll does not exist on win9x */
153 ptr = load_functions();
155 skip("%s not found\n", ptr);
159 test_BuildOtherNamesFromMachineName();
160 test_SplInitializeWinSpoolDrv();