From 289ed3ada76030fb24ed7042309f2b4d9060e303 Mon Sep 17 00:00:00 2001 From: Detlef Riekenberg Date: Wed, 14 Oct 2009 23:50:49 +0200 Subject: [PATCH] winspool/tests: Add tests for EnumPrintProcessors. --- dlls/winspool.drv/tests/info.c | 121 +++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) diff --git a/dlls/winspool.drv/tests/info.c b/dlls/winspool.drv/tests/info.c index 9a7acf66b48..f7e6ed51764 100644 --- a/dlls/winspool.drv/tests/info.c +++ b/dlls/winspool.drv/tests/info.c @@ -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();