[PATCH 3/3] winspool/tests: Add tests for EnumPrintProcessors

Detlef Riekenberg wine.dev at web.de
Wed Oct 14 16:50:49 CDT 2009


---
 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();
-- 
1.5.4.3


--=-C2fdXulfLDHz/7vO+IrV--




More information about the wine-patches mailing list