2 * PROJECT: ReactOS Print Spooler DLL API Tests
3 * LICENSE: GNU GPLv2 or any later version as published by the Free Software Foundation
4 * PURPOSE: Tests for GetPrintProcessorDirectoryA/GetPrintProcessorDirectoryW
5 * COPYRIGHT: Copyright 2015-2016 Colin Finck <colin@reactos.org>
10 #define WIN32_NO_STATUS
16 START_TEST(GetPrintProcessorDirectoryA
)
22 // Try with an invalid level, this needs to be caught first.
23 SetLastError(0xDEADBEEF);
24 cbNeeded
= 0xDEADBEEF;
25 ok(!GetPrintProcessorDirectoryA(NULL
, NULL
, 0, NULL
, 0, &cbNeeded
), "GetPrintProcessorDirectoryA returns TRUE!\n");
26 ok(GetLastError() == ERROR_INVALID_LEVEL
, "GetPrintProcessorDirectoryA returns error %lu!\n", GetLastError());
27 ok(cbNeeded
== 0xDEADBEEF, "cbNeeded is %lu!\n", cbNeeded
);
29 // Now try with valid level, but no pcbNeeded.
30 SetLastError(0xDEADBEEF);
31 ok(!GetPrintProcessorDirectoryA(NULL
, NULL
, 1, NULL
, 0, NULL
), "GetPrintProcessorDirectoryA returns TRUE!\n");
32 ok(GetLastError() == RPC_X_NULL_REF_POINTER
, "GetPrintProcessorDirectoryA returns error %lu!\n", GetLastError());
34 // Try with an invalid environment as well.
35 SetLastError(0xDEADBEEF);
36 cbNeeded
= 0xDEADBEEF;
37 ok(!GetPrintProcessorDirectoryA(NULL
, "invalid", 1, NULL
, 0, &cbNeeded
), "GetPrintProcessorDirectoryA returns TRUE!\n");
38 ok(GetLastError() == ERROR_INVALID_ENVIRONMENT
, "GetPrintProcessorDirectoryA returns error %lu!\n", GetLastError());
39 ok(cbNeeded
== 0, "cbNeeded is %lu!\n", cbNeeded
);
41 // Now get the required buffer size by supplying pcbNeeded. This needs to fail with ERROR_INSUFFICIENT_BUFFER.
42 // Note for GetPrintProcessorDirectoryA: cbNeeded will be the same as for GetPrintProcessorDirectoryW, even though the ANSI string only needs half of it!
43 SetLastError(0xDEADBEEF);
45 ok(!GetPrintProcessorDirectoryA(NULL
, NULL
, 1, NULL
, 0, &cbNeeded
), "GetPrintProcessorDirectoryA returns TRUE!\n");
46 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "GetPrintProcessorDirectoryA returns error %lu!\n", GetLastError());
47 ok(cbNeeded
> 0, "cbNeeded is 0!\n");
49 // Now provide the demanded size, but no buffer.
50 SetLastError(0xDEADBEEF);
52 ok(!GetPrintProcessorDirectoryA(NULL
, NULL
, 1, NULL
, cbNeeded
, &cbTemp
), "GetPrintProcessorDirectoryA returns TRUE!\n");
53 ok(GetLastError() == ERROR_INVALID_USER_BUFFER
, "GetPrintProcessorDirectoryA returns error %lu!\n", GetLastError());
54 ok(cbTemp
== 0, "cbTemp is %lu!\n", cbTemp
);
56 // Same error has to occur with a size too small.
57 SetLastError(0xDEADBEEF);
59 ok(!GetPrintProcessorDirectoryA(NULL
, NULL
, 1, NULL
, 1, &cbTemp
), "GetPrintProcessorDirectoryA returns TRUE!\n");
60 ok(GetLastError() == ERROR_INVALID_USER_BUFFER
, "GetPrintProcessorDirectoryA returns error %lu!\n", GetLastError());
61 ok(cbTemp
== 0, "cbTemp is %lu!\n", cbTemp
);
63 // Finally use the function as intended and aim for success!
64 pszBuffer
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, cbNeeded
);
65 SetLastError(0xDEADBEEF);
66 ok(GetPrintProcessorDirectoryA(NULL
, NULL
, 1, (PBYTE
)pszBuffer
, cbNeeded
, &cbTemp
), "GetPrintProcessorDirectoryA returns FALSE!\n");
67 ok(GetLastError() == ERROR_SUCCESS
, "GetPrintProcessorDirectoryA returns error %lu!\n", GetLastError());
69 // Note for GetPrintProcessorDirectoryA: cbNeeded is the same as for GetPrintProcessorDirectoryW!
70 ok(strlen(pszBuffer
) == cbNeeded
/ sizeof(WCHAR
) - 1, "GetPrintProcessorDirectoryA string is %Iu characters long, but %lu characters expected!\n", strlen(pszBuffer
), cbNeeded
/ sizeof(WCHAR
) - 1);
71 HeapFree(GetProcessHeap(), 0, pszBuffer
);
74 START_TEST(GetPrintProcessorDirectoryW
)
80 // Try with an invalid level, this needs to be caught first.
81 SetLastError(0xDEADBEEF);
82 cbNeeded
= 0xDEADBEEF;
83 ok(!GetPrintProcessorDirectoryW(NULL
, NULL
, 0, NULL
, 0, &cbNeeded
), "GetPrintProcessorDirectoryW returns TRUE!\n");
84 ok(GetLastError() == ERROR_INVALID_LEVEL
, "GetPrintProcessorDirectoryW returns error %lu!\n", GetLastError());
85 ok(cbNeeded
== 0xDEADBEEF, "cbNeeded is %lu!\n", cbNeeded
);
87 // Now try with valid level, but no pcbNeeded.
88 SetLastError(0xDEADBEEF);
89 ok(!GetPrintProcessorDirectoryW(NULL
, NULL
, 1, NULL
, 0, NULL
), "GetPrintProcessorDirectoryW returns TRUE!\n");
90 ok(GetLastError() == RPC_X_NULL_REF_POINTER
, "GetPrintProcessorDirectoryW returns error %lu!\n", GetLastError());
92 // Try with an invalid environment as well.
93 SetLastError(0xDEADBEEF);
94 cbNeeded
= 0xDEADBEEF;
95 ok(!GetPrintProcessorDirectoryW(NULL
, L
"invalid", 1, NULL
, 0, &cbNeeded
), "GetPrintProcessorDirectoryW returns TRUE!\n");
96 ok(GetLastError() == ERROR_INVALID_ENVIRONMENT
, "GetPrintProcessorDirectoryW returns error %lu!\n", GetLastError());
97 ok(cbNeeded
== 0, "cbNeeded is %lu!\n", cbNeeded
);
99 // Now get the required buffer size by supplying pcbNeeded. This needs to fail with ERROR_INSUFFICIENT_BUFFER.
100 SetLastError(0xDEADBEEF);
102 ok(!GetPrintProcessorDirectoryW(NULL
, NULL
, 1, NULL
, 0, &cbNeeded
), "GetPrintProcessorDirectoryW returns TRUE!\n");
103 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "GetPrintProcessorDirectoryW returns error %lu!\n", GetLastError());
104 ok(cbNeeded
> 0, "cbNeeded is 0!\n");
106 // Now provide the demanded size, but no buffer.
107 SetLastError(0xDEADBEEF);
109 ok(!GetPrintProcessorDirectoryW(NULL
, NULL
, 1, NULL
, cbNeeded
, &cbTemp
), "GetPrintProcessorDirectoryW returns TRUE!\n");
110 ok(GetLastError() == ERROR_INVALID_USER_BUFFER
, "GetPrintProcessorDirectoryW returns error %lu!\n", GetLastError());
111 ok(cbTemp
== 0, "cbTemp is %lu!\n", cbTemp
);
113 // Same error has to occur with a size too small.
114 SetLastError(0xDEADBEEF);
116 ok(!GetPrintProcessorDirectoryW(NULL
, NULL
, 1, NULL
, 1, &cbTemp
), "GetPrintProcessorDirectoryW returns TRUE!\n");
117 ok(GetLastError() == ERROR_INVALID_USER_BUFFER
, "GetPrintProcessorDirectoryW returns error %lu!\n", GetLastError());
118 ok(cbTemp
== 0, "cbTemp is %lu!\n", cbTemp
);
120 // Finally use the function as intended and aim for success!
121 pwszBuffer
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, cbNeeded
);
122 SetLastError(0xDEADBEEF);
123 ok(GetPrintProcessorDirectoryW(NULL
, NULL
, 1, (PBYTE
)pwszBuffer
, cbNeeded
, &cbTemp
), "GetPrintProcessorDirectoryW returns FALSE!\n");
124 ok(GetLastError() == ERROR_SUCCESS
, "GetPrintProcessorDirectoryW returns error %lu!\n", GetLastError());
125 ok(wcslen(pwszBuffer
) == cbNeeded
/ sizeof(WCHAR
) - 1, "GetPrintProcessorDirectoryW string is %Iu characters long, but %lu characters expected!\n", wcslen(pwszBuffer
), cbNeeded
/ sizeof(WCHAR
) - 1);
126 HeapFree(GetProcessHeap(), 0, pwszBuffer
);