Commit 4814aad7 authored by Detlef Riekenberg's avatar Detlef Riekenberg Committed by Alexandre Julliard

winspool/tests: Add tests for ClosePrinter.

parent b611acc7
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment