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 Colin Finck <colin@reactos.org>
10 #define WIN32_NO_STATUS
16 START_TEST(GetPrintProcessorDirectory
)
22 // Try with an invalid level, this needs to be caught first.
23 SetLastError(0xDEADBEEF);
24 ok(!GetPrintProcessorDirectoryW(NULL
, NULL
, 0, NULL
, 0, NULL
), "GetPrintProcessorDirectoryW returns TRUE!\n");
25 ok(GetLastError() == ERROR_INVALID_LEVEL
, "GetPrintProcessorDirectoryW returns error %lu!\n", GetLastError());
27 // Now try with valid level, but no pcbNeeded.
28 SetLastError(0xDEADBEEF);
29 ok(!GetPrintProcessorDirectoryW(NULL
, NULL
, 1, NULL
, 0, NULL
), "GetPrintProcessorDirectoryW returns TRUE!\n");
30 ok(GetLastError() == RPC_X_NULL_REF_POINTER
, "GetPrintProcessorDirectoryW returns error %lu!\n", GetLastError());
32 // Try with an invalid environment as well.
33 SetLastError(0xDEADBEEF);
34 ok(!GetPrintProcessorDirectoryW(NULL
, L
"invalid", 1, NULL
, 0, &cbNeeded
), "GetPrintProcessorDirectoryW returns TRUE!\n");
35 ok(GetLastError() == ERROR_INVALID_ENVIRONMENT
, "GetPrintProcessorDirectoryW returns error %lu!\n", GetLastError());
36 ok(cbNeeded
== 0, "cbNeeded is %lu!\n", cbNeeded
);
38 // Now get the required buffer size by supplying pcbNeeded. This needs to fail with ERROR_INSUFFICIENT_BUFFER.
39 SetLastError(0xDEADBEEF);
40 ok(!GetPrintProcessorDirectoryW(NULL
, NULL
, 1, NULL
, 0, &cbNeeded
), "GetPrintProcessorDirectoryW returns TRUE!\n");
41 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "GetPrintProcessorDirectoryW returns error %lu!\n", GetLastError());
42 ok(cbNeeded
> 0, "cbNeeded is 0!\n");
44 // Now provide the demanded size, but no buffer.
45 SetLastError(0xDEADBEEF);
46 ok(!GetPrintProcessorDirectoryW(NULL
, NULL
, 1, NULL
, cbNeeded
, &cbTemp
), "GetPrintProcessorDirectoryW returns TRUE!\n");
47 ok(GetLastError() == ERROR_INVALID_USER_BUFFER
, "GetPrintProcessorDirectoryW returns error %lu!\n", GetLastError());
48 ok(cbTemp
== 0, "cbNeeded is %lu!\n", cbNeeded
);
50 // Same error has to occur with a size too small.
51 SetLastError(0xDEADBEEF);
52 ok(!GetPrintProcessorDirectoryW(NULL
, NULL
, 1, NULL
, 1, &cbTemp
), "GetPrintProcessorDirectoryW returns TRUE!\n");
53 ok(GetLastError() == ERROR_INVALID_USER_BUFFER
, "GetPrintProcessorDirectoryW returns error %lu!\n", GetLastError());
54 ok(cbTemp
== 0, "cbNeeded is %lu!\n", cbNeeded
);
56 // Finally use the function as intended and aim for success!
57 pwszBuffer
= HeapAlloc(GetProcessHeap(), 0, cbNeeded
);
58 SetLastError(0xDEADBEEF);
59 ok(GetPrintProcessorDirectoryW(NULL
, NULL
, 1, (PBYTE
)pwszBuffer
, cbNeeded
, &cbNeeded
), "GetPrintProcessorDirectoryW returns FALSE!\n");
60 ok(GetLastError() == ERROR_SUCCESS
, "GetPrintProcessorDirectoryW returns error %lu!\n", GetLastError());
61 HeapFree(GetProcessHeap(), 0, pwszBuffer
);