Detlef Riekenberg : winspool/tests: Add tests for EnumPrintProcessors.
Alexandre Julliard
julliard at winehq.org
Thu Oct 15 08:54:28 CDT 2009
Module: wine
Branch: master
Commit: 289ed3ada76030fb24ed7042309f2b4d9060e303
URL: http://source.winehq.org/git/wine.git/?a=commit;h=289ed3ada76030fb24ed7042309f2b4d9060e303
Author: Detlef Riekenberg <wine.dev at web.de>
Date: Wed Oct 14 23:50:49 2009 +0200
winspool/tests: Add tests for EnumPrintProcessors.
---
dlls/winspool.drv/tests/info.c | 121 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 121 insertions(+), 0 deletions(-)
diff --git a/dlls/winspool.drv/tests/info.c b/dlls/winspool.drv/tests/info.c
index 9a7acf6..f7e6ed5 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();
More information about the wine-cvs
mailing list