~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/spoolss/tests/spoolss.c

Version: ~ [ wine-1.5.30 ] ~ [ wine-1.5.29 ] ~ [ wine-1.5.28 ] ~ [ wine-1.5.27 ] ~ [ wine-1.5.26 ] ~ [ wine-1.5.25 ] ~ [ wine-1.5.24 ] ~ [ wine-1.5.23 ] ~ [ wine-1.5.22 ] ~ [ wine-1.5.21 ] ~ [ wine-1.5.20 ] ~ [ wine-1.5.19 ] ~ [ wine-1.5.18 ] ~ [ wine-1.5.17 ] ~ [ wine-1.5.16 ] ~ [ wine-1.5.15 ] ~ [ wine-1.5.14 ] ~ [ wine-1.5.13 ] ~ [ wine-1.5.12 ] ~ [ wine-1.5.11 ] ~ [ wine-1.5.10 ] ~ [ wine-1.5.9 ] ~ [ wine-1.5.8 ] ~ [ wine-1.5.7 ] ~ [ wine-1.4.1 ] ~ [ wine-1.5.6 ] ~ [ wine-1.5.5 ] ~ [ wine-1.5.4 ] ~ [ wine-1.5.3 ] ~ [ wine-1.5.2 ] ~ [ wine-1.5.1 ] ~ [ wine-1.5.0 ] ~ [ wine-1.4 ] ~ [ wine-1.4-rc6 ] ~ [ wine-1.4-rc5 ] ~ [ wine-1.4-rc4 ] ~ [ wine-1.4-rc3 ] ~ [ wine-1.4-rc2 ] ~ [ wine-1.4-rc1 ] ~ [ wine-1.3.37 ] ~ [ wine-1.3.36 ] ~ [ wine-1.3.35 ] ~ [ wine-1.3.34 ] ~ [ wine-1.3.33 ] ~ [ wine-1.3.32 ] ~ [ wine-1.3.31 ] ~ [ wine-1.3.30 ] ~ [ wine-1.3.29 ] ~ [ wine-1.3.28 ] ~ [ wine-1.3.27 ] ~ [ wine-1.3.26 ] ~ [ wine-1.3.25 ] ~ [ wine-1.3.24 ] ~ [ wine-1.3.23 ] ~ [ wine-1.3.22 ] ~ [ wine-1.3.21 ] ~ [ wine-1.3.20 ] ~ [ wine-1.3.19 ] ~ [ wine-1.3.18 ] ~ [ wine-1.2.3 ] ~ [ wine-1.3.17 ] ~ [ wine-1.3.16 ] ~ [ wine-1.3.15 ] ~ [ wine-1.3.14 ] ~ [ wine-1.3.13 ] ~ [ wine-1.3.12 ] ~ [ wine-1.3.11 ] ~ [ wine-1.3.10 ] ~ [ wine-1.3.9 ] ~ [ wine-1.2.2 ] ~ [ wine-1.3.8 ] ~ [ wine-1.3.7 ] ~ [ wine-1.3.6 ] ~ [ wine-1.3.5 ] ~ [ wine-1.2.1 ] ~ [ wine-1.3.4 ] ~ [ wine-1.3.3 ] ~ [ wine-1.3.2 ] ~ [ wine-1.3.1 ] ~ [ wine-1.3.0 ] ~ [ wine-1.2 ] ~ [ wine-1.2-rc7 ] ~ [ wine-1.2-rc6 ] ~ [ wine-1.2-rc5 ] ~ [ wine-1.2-rc4 ] ~ [ wine-1.2-rc3 ] ~ [ wine-1.2-rc2 ] ~ [ wine-1.2-rc1 ] ~ [ wine-1.1.44 ] ~ [ wine-1.1.43 ] ~ [ wine-1.1.42 ] ~ [ wine-1.1.41 ] ~ [ wine-1.1.40 ] ~ [ wine-1.1.39 ] ~ [ wine-1.1.38 ] ~ [ wine-1.1.37 ] ~ [ wine-1.1.36 ] ~ [ wine-1.1.35 ] ~ [ wine-1.1.34 ] ~ [ wine-1.1.33 ] ~ [ wine-1.1.32 ] ~ [ wine-1.1.31 ] ~ [ wine-1.1.30 ] ~ [ wine-1.1.29 ] ~ [ wine-1.1.28 ] ~ [ wine-1.1.27 ] ~ [ wine-1.1.26 ] ~ [ wine-1.1.25 ] ~ [ wine-1.1.24 ] ~ [ wine-1.1.23 ] ~ [ wine-1.1.22 ] ~ [ wine-1.1.21 ] ~ [ wine-1.1.20 ] ~ [ wine-1.1.19 ] ~ [ wine-1.1.18 ] ~ [ wine-1.1.17 ] ~ [ wine-1.1.16 ] ~ [ wine-1.1.15 ] ~ [ wine-1.1.14 ] ~ [ wine-1.1.13 ] ~ [ wine-1.1.12 ] ~ [ wine-1.1.11 ] ~ [ wine-1.1.10 ] ~ [ wine-1.1.9 ] ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~

  1 /*
  2  * Unit test suite for the Spooler-Service helper DLL
  3  *
  4  * Copyright 2007 Detlef Riekenberg
  5  *
  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.
 10  *
 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.
 15  *
 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
 19  *
 20  */
 21 
 22 #include <stdarg.h>
 23 
 24 #include "windef.h"
 25 #include "winbase.h"
 26 #include "winerror.h"
 27 #include "wine/test.h"
 28 
 29 
 30 
 31 /* ##### */
 32 
 33 static HMODULE hwinspool;
 34 
 35 static HMODULE hspl;
 36 static BOOL   (WINAPI * pBuildOtherNamesFromMachineName)(LPWSTR **, LPDWORD);
 37 static DWORD  (WINAPI * pSplInitializeWinSpoolDrv)(LPVOID *);
 38 
 39 #define WINSPOOL_TABLESIZE   16
 40 
 41 static LPVOID fn_spl[WINSPOOL_TABLESIZE];
 42 static LPVOID fn_w2k[WINSPOOL_TABLESIZE];
 43 static LPVOID fn_xp[WINSPOOL_TABLESIZE];
 44 static LPVOID fn_v[WINSPOOL_TABLESIZE];
 45 
 46 /* ########################### */
 47 
 48 static LPCSTR load_functions(void)
 49 {
 50     LPCSTR  ptr;
 51 
 52     ptr = "spoolss.dll";
 53     hspl = LoadLibraryA(ptr);
 54     if (!hspl) return ptr;
 55 
 56     ptr = "BuildOtherNamesFromMachineName";
 57     pBuildOtherNamesFromMachineName = (void *) GetProcAddress(hspl, ptr);
 58     if (!pBuildOtherNamesFromMachineName) return ptr;
 59 
 60     ptr = "SplInitializeWinSpoolDrv";
 61     pSplInitializeWinSpoolDrv = (void *) GetProcAddress(hspl, ptr);
 62     if (!pSplInitializeWinSpoolDrv) return ptr;
 63 
 64 
 65     ptr = "winspool.drv";
 66     hwinspool = LoadLibraryA(ptr);
 67     if (!hwinspool) return ptr;
 68 
 69     memset(fn_w2k, 0xff, sizeof(fn_w2k));
 70     fn_w2k[0]  = (void *) GetProcAddress(hwinspool, "OpenPrinterW");
 71     fn_w2k[1]  = (void *) GetProcAddress(hwinspool, "ClosePrinter");
 72     fn_w2k[2]  = (void *) GetProcAddress(hwinspool, "SpoolerDevQueryPrintW");
 73     fn_w2k[3]  = (void *) GetProcAddress(hwinspool, "SpoolerPrinterEvent");
 74     fn_w2k[4]  = (void *) GetProcAddress(hwinspool, "DocumentPropertiesW");
 75     fn_w2k[5]  = (void *) GetProcAddress(hwinspool, (LPSTR) 212);  /* LoadPrinterDriver */
 76     fn_w2k[6]  = (void *) GetProcAddress(hwinspool, "SetDefaultPrinterW");
 77     fn_w2k[7]  = (void *) GetProcAddress(hwinspool, "GetDefaultPrinterW");
 78     fn_w2k[8]  = (void *) GetProcAddress(hwinspool, (LPSTR) 213);  /* RefCntLoadDriver */
 79     fn_w2k[9]  = (void *) GetProcAddress(hwinspool, (LPSTR) 214);  /* RefCntUnloadDriver */
 80     fn_w2k[10] = (void *) GetProcAddress(hwinspool, (LPSTR) 215);  /* ForceUnloadDriver */
 81 
 82     memset(fn_xp,  0xff, sizeof(fn_xp));
 83     fn_xp[0] = (void *) GetProcAddress(hwinspool, "OpenPrinterW");
 84     fn_xp[1] = (void *) GetProcAddress(hwinspool, "ClosePrinter");
 85     fn_xp[2] = (void *) GetProcAddress(hwinspool, "SpoolerDevQueryPrintW");
 86     fn_xp[3] = (void *) GetProcAddress(hwinspool, "SpoolerPrinterEvent");
 87     fn_xp[4] = (void *) GetProcAddress(hwinspool, "DocumentPropertiesW");
 88     fn_xp[5] = (void *) GetProcAddress(hwinspool, (LPSTR) 212);  /* LoadPrinterDriver */
 89     fn_xp[6] = (void *) GetProcAddress(hwinspool, (LPSTR) 213);  /* RefCntLoadDriver */
 90     fn_xp[7] = (void *) GetProcAddress(hwinspool, (LPSTR) 214);  /* RefCntUnloadDriver */
 91     fn_xp[8] = (void *) GetProcAddress(hwinspool, (LPSTR) 215);  /* ForceUnloadDriver */
 92 
 93     memset(fn_v,  0xff, sizeof(fn_v));
 94     fn_v[0] = (void *) GetProcAddress(hwinspool, "OpenPrinterW");
 95     fn_v[1] = (void *) GetProcAddress(hwinspool, "ClosePrinter");
 96     fn_v[2] = (void *) GetProcAddress(hwinspool, "SpoolerDevQueryPrintW");
 97     fn_v[3] = (void *) GetProcAddress(hwinspool, "SpoolerPrinterEvent");
 98     fn_v[4] = (void *) GetProcAddress(hwinspool, "DocumentPropertiesW");
 99     fn_v[5] = (void *) GetProcAddress(hwinspool, (LPSTR) 212);  /* LoadPrinterDriver */
100     fn_v[6] = (void *) GetProcAddress(hwinspool, (LPSTR) 213);  /* RefCntLoadDriver */
101     fn_v[7] = (void *) GetProcAddress(hwinspool, (LPSTR) 214);  /* RefCntUnloadDriver */
102     fn_v[8] = (void *) GetProcAddress(hwinspool, (LPSTR) 215);  /* ForceUnloadDriver */
103     fn_v[9] = (void *) GetProcAddress(hwinspool, (LPSTR) 251);  /* 0xfb */
104 
105     return NULL;
106 
107 }
108 
109 /* ########################### */
110 
111 static void test_BuildOtherNamesFromMachineName(void)
112 {
113     LPWSTR *buffers;
114     DWORD   numentries;
115     DWORD   res;
116 
117     buffers = NULL;
118     numentries = 0;
119 
120     SetLastError(0xdeadbeef);
121     res = pBuildOtherNamesFromMachineName(&buffers, &numentries);
122 
123     /* An array with a number of stringpointers is returned (minimum of 3):
124       entry_#0: "" (empty String)
125       entry_#1: <hostname> (this is the same as the computername)
126       1 entry per Ethernet adapter : <ip-address> (string with a IPv4 ip-address)
127 
128       As of Vista:
129 
130       IPv6 fully disabled (lan interfaces, connections, tunnel interfaces and loopback interfaces)
131       entry_#0: "" (empty String)
132       entry_#1: <hostname> (this is the same as the computername)
133       1 entry per Ethernet adapter : <ip-address> (string with a IPv4 ip-address)
134       entry_#x: "::1"
135 
136       IPv6 partly disabled (lan interfaces, connections):
137       entry_#0: "" (empty String)
138       entry_#1: <hostname> (this is the same as the computername)
139       entry_#2: "::1"
140       1 entry per Ethernet adapter : <ip-address> (string with a IPv4 ip-address)
141 
142       IPv6 fully enabled but not on all lan interfaces:
143       entry_#0: "" (empty String)
144       entry_#1: <hostname> (this is the same as the computername)
145       1 entry per IPv6 enabled Ethernet adapter : <ip-address> (string with a Link-local IPv6 ip-address)
146       1 entry per IPv4 enabled Ethernet adapter : <ip-address> (string with a IPv4 ip-address)
147 
148       IPv6 fully enabled on all lan interfaces:
149       entry_#0: "" (empty String)
150       entry_#1: <hostname> (this is the same as the computername)
151       1 entry per IPv6 enabled Ethernet adapter : <ip-address> (string with a Link-local IPv6 ip-address)
152       entry_#x: <ip-address> Tunnel adapter (string with a Link-local IPv6 ip-address)
153       1 entry per IPv4 enabled Ethernet adapter : <ip-address> (string with a IPv4 ip-address)
154       entry_#y: <ip-address> Tunnel adapter (string with a IPv6 ip-address)
155     */
156 
157     todo_wine
158     ok( res && (buffers != NULL) && (numentries >= 3) && (buffers[0] != NULL) && (buffers[0][0] == '\0'),
159         "got %u with %u and %p,%u (%p:%d)\n", res, GetLastError(), buffers, numentries,
160         ((numentries > 0) && buffers) ? buffers[0] : NULL,
161         ((numentries > 0) && buffers && buffers[0]) ? lstrlenW(buffers[0]) : -1);
162 
163 }
164 
165 /* ########################### */
166 
167 static void test_SplInitializeWinSpoolDrv(VOID)
168 {
169     LPVOID *fn_ref = fn_xp;
170     DWORD   res;
171     LONG    id;
172 
173     memset(fn_spl, 0xff, sizeof(fn_spl));
174     SetLastError(0xdeadbeef);
175     res = pSplInitializeWinSpoolDrv(fn_spl);
176     ok(res, "got %u with %u (expected '!= 0')\n", res, GetLastError());
177 
178     /* functions 0 to 5 are the same in "spoolss.dll" from w2k and above */
179     if (fn_spl[6] == fn_w2k[6]) {
180         fn_ref = fn_w2k;
181     }
182     if (fn_spl[9] == fn_v[9]) {
183         fn_ref = fn_v;
184     }
185 
186     id = 0;
187     while (id < WINSPOOL_TABLESIZE) {
188         ok( fn_spl[id] == fn_ref[id],
189             "(#%02u) spoolss: %p (vista: %p,  xp: %p,  w2k: %p)\n",
190             id, fn_spl[id], fn_v[id], fn_xp[id], fn_w2k[id]);
191         id++;
192     }
193 }
194 
195 /* ########################### */
196 
197 START_TEST(spoolss)
198 {
199     LPCSTR ptr;
200 
201     /* spoolss.dll does not exist on win9x */
202     ptr = load_functions();
203     if (ptr) {
204         skip("%s not found\n", ptr);
205         return;
206     }
207 
208     test_BuildOtherNamesFromMachineName();
209     test_SplInitializeWinSpoolDrv();
210 
211 }
212 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.