winspool/tests: Add tests for EnumPrintProcessors.

This commit is contained in:
Detlef Riekenberg 2009-10-14 23:50:49 +02:00 committed by Alexandre Julliard
parent 353fe2ed15
commit 289ed3ada7
1 changed files with 121 additions and 0 deletions

View File

@ -1238,6 +1238,126 @@ static void test_EnumPrinterDrivers(void)
/* ########################### */
static void test_EnumPrintProcessors(void)
{
DWORD res;
LPBYTE buffer;
DWORD cbBuf;
DWORD pcbNeeded;
DWORD pcReturned;
cbBuf = 0xdeadbeef;
pcReturned = 0xdeadbeef;
SetLastError(0xdeadbeef);
res = EnumPrintProcessorsA(NULL, NULL, 1, NULL, 0, &cbBuf, &pcReturned);
RETURN_ON_DEACTIVATED_SPOOLER(res)
if (res && !cbBuf) {
skip("No Printprocessor installed\n");
return;
}
ok((!res) && (GetLastError() == ERROR_INSUFFICIENT_BUFFER),
"got %u with %u (expected '0' with ERROR_INSUFFICIENT_BUFFER)\n",
res, GetLastError());
buffer = HeapAlloc(GetProcessHeap(), 0, cbBuf + 4);
if (buffer == NULL)
return;
SetLastError(0xdeadbeef);
pcbNeeded = 0xdeadbeef;
res = EnumPrintProcessorsA(NULL, NULL, 1, buffer, cbBuf, &pcbNeeded, &pcReturned);
ok(res, "got %u with %u (expected '!=0')\n", res, GetLastError());
/* validate the returned Data here. */
SetLastError(0xdeadbeef);
pcReturned = 0xdeadbeef;
pcbNeeded = 0xdeadbeef;
res = EnumPrintProcessorsA(NULL, NULL, 1, buffer, cbBuf+1, &pcbNeeded, &pcReturned);
ok(res, "got %u with %u (expected '!=0')\n", res, GetLastError());
SetLastError(0xdeadbeef);
pcbNeeded = 0xdeadbeef;
res = EnumPrintProcessorsA(NULL, NULL, 1, buffer, cbBuf-1, &pcbNeeded, &pcReturned);
ok( !res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER),
"got %u with %u (expected '0' with ERROR_INSUFFICIENT_BUFFER)\n",
res, GetLastError());
/* only level 1 is valid */
if (0) {
/* both tests crash on win98se */
SetLastError(0xdeadbeef);
pcbNeeded = 0xdeadbeef;
pcReturned = 0xdeadbeef;
res = EnumPrintProcessorsA(NULL, NULL, 0, buffer, cbBuf, &pcbNeeded, &pcReturned);
ok( !res && (GetLastError() == ERROR_INVALID_LEVEL),
"got %u with %u (expected '0' with ERROR_INVALID_LEVEL)\n",
res, GetLastError());
SetLastError(0xdeadbeef);
pcbNeeded = 0xdeadbeef;
res = EnumPrintProcessorsA(NULL, NULL, 2, buffer, cbBuf, &pcbNeeded, &pcReturned);
ok( !res && (GetLastError() == ERROR_INVALID_LEVEL),
"got %u with %u (expected '0' with ERROR_INVALID_LEVEL)\n",
res, GetLastError());
}
/* an empty environment is ignored */
SetLastError(0xdeadbeef);
pcbNeeded = 0xdeadbeef;
res = EnumPrintProcessorsA(NULL, empty, 1, buffer, cbBuf, &pcbNeeded, &pcReturned);
ok(res, "got %u with %u (expected '!=0')\n", res, GetLastError());
/* the environment is checked */
SetLastError(0xdeadbeef);
pcbNeeded = 0xdeadbeef;
res = EnumPrintProcessorsA(NULL, invalid_env, 1, buffer, cbBuf, &pcbNeeded, &pcReturned);
/* NT5: ERROR_INVALID_ENVIRONMENT, 9x: ERROR_INVALID_PARAMETER */
ok( !res && ((GetLastError() == ERROR_INVALID_ENVIRONMENT) ||
(GetLastError() == ERROR_INVALID_PARAMETER)),
"got %u with %u (expected '0' with ERROR_INVALID_ENVIRONMENT or "
"ERROR_INVALID_PARAMETER)\n", res, GetLastError());
/* failure-Codes for NULL */
if (0) {
/* this test crash on win98se */
SetLastError(0xdeadbeef);
pcbNeeded = 0xdeadbeef;
pcReturned = 0xdeadbeef;
res = EnumPrintProcessorsA(NULL, NULL, 1, NULL, cbBuf, &pcbNeeded, &pcReturned);
ok( !res && (GetLastError() == ERROR_INVALID_USER_BUFFER) ,
"got %u with %u (expected '0' with ERROR_INVALID_USER_BUFFER)\n",
res, GetLastError());
}
SetLastError(0xdeadbeef);
pcbNeeded = 0xdeadbeef;
pcReturned = 0xdeadbeef;
res = EnumPrintProcessorsA(NULL, NULL, 1, buffer, cbBuf, NULL, &pcReturned);
/* the NULL is ignored on win9x */
ok( broken(res) || (!res && (GetLastError() == RPC_X_NULL_REF_POINTER)),
"got %u with %u (expected '0' with RPC_X_NULL_REF_POINTER)\n",
res, GetLastError());
pcbNeeded = 0xdeadbeef;
pcReturned = 0xdeadbeef;
SetLastError(0xdeadbeef);
res = EnumPrintProcessorsA(NULL, NULL, 1, buffer, cbBuf, &pcbNeeded, NULL);
/* the NULL is ignored on win9x */
ok( broken(res) || (!res && (GetLastError() == RPC_X_NULL_REF_POINTER)),
"got %u with %u (expected '0' with RPC_X_NULL_REF_POINTER)\n",
res, GetLastError());
HeapFree(GetProcessHeap(), 0, buffer);
}
/* ########################### */
static void test_GetDefaultPrinter(void)
{
BOOL retval;
@ -2426,6 +2546,7 @@ START_TEST(info)
test_EnumPorts();
test_EnumPrinterDrivers();
test_EnumPrinters();
test_EnumPrintProcessors();
test_GetDefaultPrinter();
test_GetPrinterDriverDirectory();
test_GetPrintProcessorDirectory();