Author: cfinck
Date: Thu Jun 4 12:19:06 2015
New Revision: 68007
URL:
http://svn.reactos.org/svn/reactos?rev=68007&view=rev
Log:
[WINSPOOL_APITEST]
- Add tests for EnumPrinters
- Fix a test for EnumPrintProcessorDatatypes
Added:
branches/colins-printing-for-freedom/rostests/apitests/winspool/EnumPrinters.c (with
props)
Modified:
branches/colins-printing-for-freedom/rostests/apitests/winspool/CMakeLists.txt
branches/colins-printing-for-freedom/rostests/apitests/winspool/EnumPrintProcessorDatatypes.c
branches/colins-printing-for-freedom/rostests/apitests/winspool/testlist.c
Modified: branches/colins-printing-for-freedom/rostests/apitests/winspool/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/ros…
==============================================================================
---
branches/colins-printing-for-freedom/rostests/apitests/winspool/CMakeLists.txt [iso-8859-1]
(original)
+++
branches/colins-printing-for-freedom/rostests/apitests/winspool/CMakeLists.txt [iso-8859-1]
Thu Jun 4 12:19:06 2015
@@ -1,6 +1,7 @@
list(APPEND SOURCE
ClosePrinter.c
+ EnumPrinters.c
EnumPrintProcessorDatatypes.c
GetPrintProcessorDirectory.c
OpenPrinter.c
Modified:
branches/colins-printing-for-freedom/rostests/apitests/winspool/EnumPrintProcessorDatatypes.c
URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/ros…
==============================================================================
---
branches/colins-printing-for-freedom/rostests/apitests/winspool/EnumPrintProcessorDatatypes.c [iso-8859-1]
(original)
+++
branches/colins-printing-for-freedom/rostests/apitests/winspool/EnumPrintProcessorDatatypes.c [iso-8859-1]
Thu Jun 4 12:19:06 2015
@@ -48,6 +48,13 @@
ok(cbNeeded > 0, "cbNeeded is 0!\n");
ok(dwReturned == 0, "dwReturned is %lu!\n", dwReturned);
+ // Same error has to occur with a size to small.
+ SetLastError(0xDEADBEEF);
+ ok(!EnumPrintProcessorDatatypesW(NULL, L"wInPrInT", 1, NULL, 1,
&cbNeeded, &dwReturned), "EnumPrintProcessorDatatypesW returns
TRUE!\n");
+ ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "EnumPrintersW returns error
%lu!\n", GetLastError());
+ ok(cbNeeded > 0, "cbNeeded is 0!\n");
+ ok(dwReturned == 0, "dwReturned is %lu!\n", dwReturned);
+
// Now provide the demanded size, but no buffer.
SetLastError(0xDEADBEEF);
ok(!EnumPrintProcessorDatatypesW(NULL, L"wInPrInT", 1, NULL, cbNeeded,
&cbTemp, &dwReturned), "EnumPrintProcessorDatatypesW returns TRUE!\n");
@@ -62,13 +69,6 @@
ok(cbTemp == 0, "cbTemp is %lu!\n", cbTemp);
ok(dwReturned == 0, "dwReturned is %lu!\n", dwReturned);
- // Same error has to occur with a valid Print Processor, but a size too small.
- SetLastError(0xDEADBEEF);
- ok(!EnumPrintProcessorDatatypesW(NULL, L"wInPrInT", 1, NULL, cbNeeded,
&cbTemp, &dwReturned), "EnumPrintProcessorDatatypesW returns TRUE!\n");
- ok(GetLastError() == ERROR_INVALID_USER_BUFFER, "EnumPrintProcessorDatatypesW
returns error %lu!\n", GetLastError());
- ok(cbTemp == 0, "cbTemp is %lu!\n", cbTemp);
- ok(dwReturned == 0, "dwReturned is %lu!\n", dwReturned);
-
// Finally use the function as intended and aim for success!
pDatatypesInfo1 = HeapAlloc(GetProcessHeap(), 0, cbNeeded);
SetLastError(0xDEADBEEF);
Added: branches/colins-printing-for-freedom/rostests/apitests/winspool/EnumPrinters.c
URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/ros…
==============================================================================
---
branches/colins-printing-for-freedom/rostests/apitests/winspool/EnumPrinters.c (added)
+++
branches/colins-printing-for-freedom/rostests/apitests/winspool/EnumPrinters.c [iso-8859-1]
Thu Jun 4 12:19:06 2015
@@ -0,0 +1,93 @@
+/*
+ * PROJECT: ReactOS Print Spooler DLL API Tests
+ * LICENSE: GNU GPLv2 or any later version as published by the Free Software
Foundation
+ * PURPOSE: Tests for EnumPrintersA/EnumPrintersW
+ * COPYRIGHT: Copyright 2015 Colin Finck <colin(a)reactos.org>
+ */
+
+#include <apitest.h>
+
+#define WIN32_NO_STATUS
+#include <windef.h>
+#include <winbase.h>
+#include <wingdi.h>
+#include <winspool.h>
+
+START_TEST(EnumPrinters)
+{
+ DWORD cbNeeded;
+ DWORD cbTemp;
+ DWORD dwReturned;
+ PVOID pMem;
+ DWORD i;
+ DWORD dwValidLevels[] = { 0, 1, 2, 4, 5 };
+
+ // Level 5 is the highest supported under Windows Server 2003. Higher levels need to
fail and leave the variables untouched!
+ cbNeeded = 0xDEADBEEF;
+ dwReturned = 0xDEADBEEF;
+ SetLastError(0xDEADBEEF);
+ ok(!EnumPrintersW(0, NULL, 6, NULL, 0, &cbNeeded, &dwReturned),
"EnumPrintersW returns TRUE!\n");
+ ok(GetLastError() == ERROR_INVALID_LEVEL, "EnumPrintersW returns error
%lu!\n", GetLastError());
+ ok(cbNeeded == 0xDEADBEEF, "cbNeeded is %lu!\n", cbNeeded);
+ ok(dwReturned == 0xDEADBEEF, "dwReturned is %lu!\n", dwReturned);
+
+ // Same goes for level 3.
+ cbNeeded = 0xDEADBEEF;
+ dwReturned = 0xDEADBEEF;
+ SetLastError(0xDEADBEEF);
+ ok(!EnumPrintersW(0, NULL, 3, NULL, 0, &cbNeeded, &dwReturned),
"EnumPrintersW returns TRUE!\n");
+ ok(GetLastError() == ERROR_INVALID_LEVEL, "EnumPrintersW returns error
%lu!\n", GetLastError());
+ ok(cbNeeded == 0xDEADBEEF, "cbNeeded is %lu!\n", cbNeeded);
+ ok(dwReturned == 0xDEADBEEF, "dwReturned is %lu!\n", dwReturned);
+
+ // Try for all valid levels. Level 0 is valid here and returns the
PRINTER_INFO_STRESS structure (documented in MS-RPRN).
+ for (i = 0; i < sizeof(dwValidLevels) / sizeof(DWORD); i++)
+ {
+ // Try with no valid arguments at all.
+ SetLastError(0xDEADBEEF);
+ ok(!EnumPrintersW(0, NULL, dwValidLevels[i], NULL, 0, NULL, NULL),
"EnumPrintersW returns TRUE for Level %lu!\n", dwValidLevels[i]);
+ ok(GetLastError() == RPC_X_NULL_REF_POINTER, "EnumPrintersW returns error
%lu for Level %lu!\n", GetLastError(), dwValidLevels[i]);
+
+ // It has to succeed if we supply the required pointers and query no
information.
+ SetLastError(0xDEADBEEF);
+ ok(EnumPrintersW(0, NULL, dwValidLevels[i], NULL, 0, &cbNeeded,
&dwReturned), "EnumPrintersW returns FALSE for Level %lu!\n",
dwValidLevels[i]);
+ ok(GetLastError() == ERROR_SUCCESS, "EnumPrintersW returns error %lu for
Level %lu!\n", GetLastError(), dwValidLevels[i]);
+ ok(cbNeeded == 0, "cbNeeded is %lu for Level %lu!\n", cbNeeded,
dwValidLevels[i]);
+ ok(dwReturned == 0, "dwReturned is %lu for Level %lu!\n", dwReturned,
dwValidLevels[i]);
+
+ // This constant is from Windows 9x/ME times and mustn't work anymore.
+ SetLastError(0xDEADBEEF);
+ ok(EnumPrintersW(PRINTER_ENUM_DEFAULT, NULL, dwValidLevels[i], NULL, 0,
&cbNeeded, &dwReturned), "EnumPrintersW returns FALSE for Level %lu!\n",
dwValidLevels[i]);
+ ok(GetLastError() == ERROR_SUCCESS, "EnumPrintersW returns error %lu for
Level %lu!\n", GetLastError(), dwValidLevels[i]);
+ ok(cbNeeded == 0, "cbNeeded is %lu for Level %lu!\n", cbNeeded,
dwValidLevels[i]);
+ ok(dwReturned == 0, "dwReturned is %lu for Level %lu!\n", dwReturned,
dwValidLevels[i]);
+
+ // Now things get interesting. Let's query the buffer size for information
about the local printers.
+ SetLastError(0xDEADBEEF);
+ ok(!EnumPrintersW(PRINTER_ENUM_LOCAL, NULL, dwValidLevels[i], NULL, 0,
&cbNeeded, &dwReturned), "EnumPrintersW returns TRUE for Level %lu!\n",
dwValidLevels[i]);
+ ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "EnumPrintersW returns error
%lu for Level %lu!\n", GetLastError(), dwValidLevels[i]);
+ ok(cbNeeded > 0, "cbNeeded is 0 for Level %lu!\n",
dwValidLevels[i]);
+ ok(dwReturned == 0, "dwReturned is %lu for Level %lu!\n", dwReturned,
dwValidLevels[i]);
+
+ // Same error has to occur with a size to small.
+ SetLastError(0xDEADBEEF);
+ ok(!EnumPrintersW(PRINTER_ENUM_LOCAL, NULL, dwValidLevels[i], NULL, 1,
&cbNeeded, &dwReturned), "EnumPrintersW returns TRUE for Level %lu!\n",
dwValidLevels[i]);
+ ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "EnumPrintersW returns error
%lu for Level %lu!\n", GetLastError(), dwValidLevels[i]);
+ ok(cbNeeded > 0, "cbNeeded is 0 for Level %lu!\n",
dwValidLevels[i]);
+ ok(dwReturned == 0, "dwReturned is %lu for Level %lu!\n", dwReturned,
dwValidLevels[i]);
+
+ // Now provide the demanded size, but no buffer.
+ SetLastError(0xDEADBEEF);
+ ok(!EnumPrintersW(PRINTER_ENUM_LOCAL, NULL, dwValidLevels[i], NULL, cbNeeded,
&cbTemp, &dwReturned), "EnumPrintersW returns TRUE for Level %lu!\n",
dwValidLevels[i]);
+ ok(GetLastError() == ERROR_INVALID_USER_BUFFER, "EnumPrintersW returns error
%lu for Level %lu!\n", GetLastError(), dwValidLevels[i]);
+ ok(cbTemp == 0, "cbTemp is %lu for Level %lu!\n", cbTemp,
dwValidLevels[i]);
+ ok(dwReturned == 0, "dwReturned is %lu for Level %lu!\n", dwReturned,
dwValidLevels[i]);
+
+ // Finally use the function as intended and aim for success!
+ pMem = HeapAlloc(GetProcessHeap(), 0, cbNeeded);
+ SetLastError(0xDEADBEEF);
+ ok(EnumPrintersW(PRINTER_ENUM_LOCAL, NULL, dwValidLevels[i], pMem, cbNeeded,
&cbTemp, &dwReturned), "EnumPrintersW returns FALSE for Level %lu!\n",
dwValidLevels[i]);
+ ok(GetLastError() == ERROR_SUCCESS, "EnumPrintersW returns error %lu for
Level %lu!\n", GetLastError(), dwValidLevels[i]);
+ HeapFree(GetProcessHeap(), 0, pMem);
+ }
+}
Propchange:
branches/colins-printing-for-freedom/rostests/apitests/winspool/EnumPrinters.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: branches/colins-printing-for-freedom/rostests/apitests/winspool/testlist.c
URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/ros…
==============================================================================
---
branches/colins-printing-for-freedom/rostests/apitests/winspool/testlist.c [iso-8859-1]
(original)
+++
branches/colins-printing-for-freedom/rostests/apitests/winspool/testlist.c [iso-8859-1]
Thu Jun 4 12:19:06 2015
@@ -11,6 +11,7 @@
#include <apitest.h>
extern void func_ClosePrinter(void);
+extern void func_EnumPrinters(void);
extern void func_EnumPrintProcessorDatatypes(void);
extern void func_GetPrintProcessorDirectory(void);
extern void func_OpenPrinter(void);
@@ -19,6 +20,7 @@
const struct test winetest_testlist[] =
{
{ "ClosePrinter", func_ClosePrinter },
+ { "EnumPrinters", func_EnumPrinters },
{ "EnumPrintProcessorDatatypes", func_EnumPrintProcessorDatatypes },
{ "GetPrintProcessorDirectory", func_GetPrintProcessorDirectory },
{ "OpenPrinter", func_OpenPrinter },