2 * PROJECT: ReactOS Local Spooler API Tests Injected DLL
3 * LICENSE: GNU GPLv2 or any later version as published by the Free Software Foundation
4 * PURPOSE: Tests for fpGetPrintProcessorDirectory
5 * COPYRIGHT: Copyright 2016 Colin Finck <colin@reactos.org>
10 #define WIN32_NO_STATUS
18 #include "../localspl_apitest.h"
21 extern BOOL
GetLocalsplFuncs(LPPRINTPROVIDOR pp
);
23 START_TEST(fpGetPrintProcessorDirectory
)
31 if (!GetLocalsplFuncs(&pp
))
34 // In contrast to GetPrintProcessorDirectoryW, fpGetPrintProcessorDirectory needs an environment and doesn't just accept NULL.
35 SetLastError(0xDEADBEEF);
36 ok(!pp
.fpGetPrintProcessorDirectory(NULL
, NULL
, 0, NULL
, 0, NULL
), "fpGetPrintProcessorDirectory returns TRUE!\n");
37 ok(GetLastError() == ERROR_INVALID_ENVIRONMENT
, "fpGetPrintProcessorDirectory returns error %lu!\n", GetLastError());
39 // Try with an invalid environment as well.
40 SetLastError(0xDEADBEEF);
41 ok(!pp
.fpGetPrintProcessorDirectory(NULL
, L
"invalid", 0, NULL
, 0, NULL
), "fpGetPrintProcessorDirectory returns TRUE!\n");
42 ok(GetLastError() == ERROR_INVALID_ENVIRONMENT
, "fpGetPrintProcessorDirectory returns error %lu!\n", GetLastError());
44 // Now provide a valid environment and prove that it is checked case-insensitively.
45 // In contrast to GetPrintProcessorDirectoryW, the level isn't the next thing checked here, but fpGetPrintProcessorDirectory
46 // already tries to access the non-supplied pcbNeeded variable.
50 pp
.fpGetPrintProcessorDirectory(NULL
, L
"wIndows nt x86", 0, NULL
, 0, NULL
);
52 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
54 dwReturned
= _SEH2_GetExceptionCode();
58 ok(dwReturned
== EXCEPTION_ACCESS_VIOLATION
, "dwReturned is %lu!\n", dwReturned
);
60 // fpGetPrintProcessorDirectory doesn't care about the supplied level at all. Prove this here.
61 // With no buffer given, this needs to fail with ERROR_INSUFFICIENT_BUFFER.
62 SetLastError(0xDEADBEEF);
64 ok(!pp
.fpGetPrintProcessorDirectory(NULL
, L
"wIndows nt x86", 1337, NULL
, 0, &cbNeeded
), "fpGetPrintProcessorDirectory returns TRUE!\n");
65 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "fpGetPrintProcessorDirectory returns error %lu!\n", GetLastError());
66 ok(cbNeeded
> 0, "cbNeeded is %lu!\n", cbNeeded
);
68 // Now provide the demanded size, but no buffer.
69 // Unlike GetPrintProcessorDirectoryW, fpGetPrintProcessorDirectory doesn't check for this case and tries to access the buffer.
73 pp
.fpGetPrintProcessorDirectory(NULL
, L
"wIndows nt x86", 1, NULL
, cbNeeded
, &cbTemp
);
75 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
77 dwReturned
= _SEH2_GetExceptionCode();
81 ok(dwReturned
== EXCEPTION_ACCESS_VIOLATION
, "dwReturned is %lu!\n", dwReturned
);
83 // Finally use the function as intended and aim for success!
84 // We only check success by the boolean return value though. GetLastError doesn't return anything meaningful here.
85 pwszBuffer
= DllAllocSplMem(cbNeeded
);
86 SetLastError(0xDEADBEEF);
87 ok(pp
.fpGetPrintProcessorDirectory(NULL
, L
"wIndows nt x86", 1, (PBYTE
)pwszBuffer
, cbNeeded
, &cbTemp
), "fpGetPrintProcessorDirectory returns FALSE!\n");
88 ok(wcslen(pwszBuffer
) == cbNeeded
/ sizeof(WCHAR
) - 1, "fpGetPrintProcessorDirectory string is %Iu characters long, but %lu characters expected!\n", wcslen(pwszBuffer
), cbNeeded
/ sizeof(WCHAR
) - 1);
89 DllFreeSplMem(pwszBuffer
);