kernel32: FindExSearchLimitToDirectories has no effect on FindFirstFileEx.
[wine] / dlls / spoolss / tests / spoolss.c
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 DWORD  (WINAPI * pSplInitializeWinSpoolDrv)(LPVOID *);
37
38 #define WINSPOOL_TABLESIZE   16
39
40 static LPVOID fn_spl[WINSPOOL_TABLESIZE];
41 static LPVOID fn_w2k[WINSPOOL_TABLESIZE];
42 static LPVOID fn_xp[WINSPOOL_TABLESIZE];
43
44 /* ########################### */
45
46 static LPCSTR load_functions(void)
47 {
48     LPCSTR  ptr;
49
50     ptr = "spoolss.dll";
51     hspl = LoadLibraryA(ptr);
52     if (!hspl) return ptr;
53
54     ptr = "SplInitializeWinSpoolDrv";
55     pSplInitializeWinSpoolDrv = (void *) GetProcAddress(hspl, ptr);
56     if (!pSplInitializeWinSpoolDrv) return ptr;
57
58
59     ptr = "winspool.drv";
60     hwinspool = LoadLibraryA(ptr);
61     if (!hwinspool) return ptr;
62
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 */
75
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 */
86
87     return NULL;
88
89 }
90
91 /* ########################### */
92
93 static void test_SplInitializeWinSpoolDrv(VOID)
94 {
95     DWORD   res;
96     LONG    id;
97     BOOL    is_xp;
98
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());
103
104     /* functions 0 to 5 are the same with "spoolss.dll" from w2k and xp */
105     is_xp = (fn_spl[6] == fn_xp[6]);
106     id = 0;
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]);
110         id++;
111     }
112 }
113
114 /* ########################### */
115
116 START_TEST(spoolss)
117 {
118     LPCSTR ptr;
119
120     /* spoolss.dll does not exist on win9x */
121     ptr = load_functions();
122     if (ptr) {
123         skip("%s not found\n", ptr);
124         return;
125     }
126
127     test_SplInitializeWinSpoolDrv();
128
129 }