[PATCH 2/2] winspool/tests: Add tests for ClosePrinter
Detlef Riekenberg
wine.dev at web.de
Tue Nov 1 17:21:42 CDT 2016
--
bye bye ... Detlef
Signed-off-by: Detlef Riekenberg <wine.dev at web.de>
---
dlls/winspool.drv/tests/info.c | 49 ++++++++++++++++++++++++++++++++++++++++--
1 file changed, 47 insertions(+), 2 deletions(-)
diff --git a/dlls/winspool.drv/tests/info.c b/dlls/winspool.drv/tests/info.c
index ffa31ed..f6527c5 100644
--- a/dlls/winspool.drv/tests/info.c
+++ b/dlls/winspool.drv/tests/info.c
@@ -672,6 +672,50 @@ static void test_ConfigurePort(void)
/* ########################### */
+static void test_ClosePrinter(void)
+{
+ HANDLE printer = 0;
+ BOOL res;
+
+ /* NULL is handled */
+ SetLastError(0xdeadbeef);
+ res = ClosePrinter(NULL);
+ ok(!res && (GetLastError() == ERROR_INVALID_HANDLE),
+ "got %d with %d (expected FALSE with ERROR_INVALID_HANDLE)\n",
+ res, GetLastError());
+
+ /* A random value as HANDLE is handled */
+ SetLastError(0xdeadbeef);
+ res = ClosePrinter( (void *) -1);
+ if (is_spooler_deactivated(res, GetLastError())) return;
+ ok(!res && (GetLastError() == ERROR_INVALID_HANDLE),
+ "got %d with %d (expected FALSE with ERROR_INVALID_HANDLE)\n",
+ res, GetLastError());
+
+
+ /* Normal use (The Spooler service is needed) */
+ SetLastError(0xdeadbeef);
+ res = OpenPrinterA(default_printer, &printer, NULL);
+ if (is_spooler_deactivated(res, GetLastError())) return;
+ if (res)
+ {
+ SetLastError(0xdeadbeef);
+ res = ClosePrinter(printer);
+ ok(res, "got %d with %d (expected TRUE)\n", res, GetLastError());
+
+
+ /* double free is handled */
+ SetLastError(0xdeadbeef);
+ res = ClosePrinter(printer);
+ ok(!res && (GetLastError() == ERROR_INVALID_HANDLE),
+ "got %d with %d (expected FALSE with ERROR_INVALID_HANDLE)\n",
+ res, GetLastError());
+
+ }
+}
+
+/* ########################### */
+
static void test_DeleteMonitor(void)
{
MONITOR_INFO_2A mi2a;
@@ -3023,6 +3067,7 @@ START_TEST(info)
test_AddPort();
test_AddPortEx();
test_ConfigurePort();
+ test_ClosePrinter();
test_DeleteMonitor();
test_DeletePort();
test_DeviceCapabilities();
@@ -3037,7 +3082,9 @@ START_TEST(info)
test_GetDefaultPrinter();
test_GetPrinterDriverDirectory();
test_GetPrintProcessorDirectory();
+ test_IsValidDevmodeW();
test_OpenPrinter();
+ test_OpenPrinter_defaults();
test_GetPrinter();
test_GetPrinterData();
test_GetPrinterDataEx();
@@ -3045,8 +3092,6 @@ START_TEST(info)
test_SetDefaultPrinter();
test_XcvDataW_MonitorUI();
test_XcvDataW_PortIsValid();
- test_IsValidDevmodeW();
- test_OpenPrinter_defaults();
/* Cleanup our temporary file */
DeleteFileA(tempfileA);
--
2.7.4
More information about the wine-patches
mailing list