Detlef Riekenberg : winspool/tests:
Tests for EnumForms and set an error value in our stub.
Alexandre Julliard
julliard at wine.codeweavers.com
Wed Jun 21 08:02:19 CDT 2006
Module: wine
Branch: refs/heads/master
Commit: 89ed2d973dc9b6b44cdf713025e1574dca6bb3f8
URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=89ed2d973dc9b6b44cdf713025e1574dca6bb3f8
Author: Detlef Riekenberg <wine.dev at web.de>
Date: Fri Jun 16 09:54:55 2006 +0200
winspool/tests: Tests for EnumForms and set an error value in our stub.
---
dlls/winspool.drv/info.c | 2 +
dlls/winspool.drv/tests/info.c | 110 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 111 insertions(+), 1 deletions(-)
diff --git a/dlls/winspool.drv/info.c b/dlls/winspool.drv/info.c
index 00852f2..bf91f9e 100644
--- a/dlls/winspool.drv/info.c
+++ b/dlls/winspool.drv/info.c
@@ -5430,6 +5430,7 @@ BOOL WINAPI EnumFormsA( HANDLE hPrinter,
DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned )
{
FIXME("%p %lx %p %lx %p %p\n", hPrinter, Level, pForm, cbBuf, pcbNeeded, pcReturned);
+ SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}
@@ -5440,6 +5441,7 @@ BOOL WINAPI EnumFormsW( HANDLE hPrinter,
DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned )
{
FIXME("%p %lx %p %lx %p %p\n", hPrinter, Level, pForm, cbBuf, pcbNeeded, pcReturned);
+ SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}
diff --git a/dlls/winspool.drv/tests/info.c b/dlls/winspool.drv/tests/info.c
index ca65021..2eff80e 100644
--- a/dlls/winspool.drv/tests/info.c
+++ b/dlls/winspool.drv/tests/info.c
@@ -400,6 +400,110 @@ static void test_DeleteMonitor(void)
DeleteMonitorA(NULL, entry->env, winetest_monitor);
}
+/* ######## */
+
+static void test_EnumForms(LPSTR pName)
+{
+ DWORD res;
+ HANDLE hprinter = 0;
+ LPBYTE buffer;
+ DWORD cbBuf;
+ DWORD pcbNeeded;
+ DWORD pcReturned;
+ DWORD level;
+
+
+ res = OpenPrinter(pName, &hprinter, NULL);
+ RETURN_ON_DEACTIVATED_SPOOLER(res)
+ if (!res || !hprinter)
+ {
+ /* Open the local Prinserver is not supported on win9x */
+ if (pName) trace("Failed to open '%s', skiping the test\n", pName);
+ return;
+ }
+
+ /* valid levels are 1 and 2 */
+ for(level = 0; level < 4; level++) {
+ cbBuf = 0xdeadbeef;
+ pcReturned = 0xdeadbeef;
+ SetLastError(0xdeadbeef);
+ res = EnumFormsA(hprinter, level, NULL, 0, &cbBuf, &pcReturned);
+
+ /* EnumForms is not implemented in win9x */
+ if (!res && (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)) continue;
+
+ /* EnumForms for the Server not implemented on all NT-Versions */
+ if (!res && (GetLastError() == ERROR_INVALID_HANDLE) && !pName) continue;
+
+ /* Level 2 for EnumForms is not supported on all systems */
+ if (!res && (GetLastError() == ERROR_INVALID_LEVEL) && (level == 2)) continue;
+
+ /* use only a short test, when we test with an invalid level */
+ if(!level || (level > 2)) {
+ ok( (!res && (GetLastError() == ERROR_INVALID_LEVEL)) ||
+ (res && (pcReturned == 0)),
+ "(%ld) returned %ld with %ld and 0x%08lx (expected '0' with " \
+ "ERROR_INVALID_LEVEL or '!=0' and 0x0)\n",
+ level, res, GetLastError(), pcReturned);
+ continue;
+ }
+
+ ok((!res) && (GetLastError() == ERROR_INSUFFICIENT_BUFFER),
+ "(%ld) returned %ld with %ld (expected '0' with " \
+ "ERROR_INSUFFICIENT_BUFFER)\n", level, res, GetLastError());
+
+ buffer = HeapAlloc(GetProcessHeap(), 0, cbBuf *2);
+ if (buffer == NULL) continue;
+
+ SetLastError(0xdeadbeef);
+ res = EnumFormsA(hprinter, level, buffer, cbBuf, &pcbNeeded, &pcReturned);
+ ok(res, "(%ld) returned %ld with %ld (expected '!=0')\n",
+ level, res, GetLastError());
+ /* We can dump the returned Data here */
+
+
+ SetLastError(0xdeadbeef);
+ res = EnumFormsA(hprinter, level, buffer, cbBuf+1, &pcbNeeded, &pcReturned);
+ ok( res, "(%ld) returned %ld with %ld (expected '!=0')\n",
+ level, res, GetLastError());
+
+ SetLastError(0xdeadbeef);
+ res = EnumFormsA(hprinter, level, buffer, cbBuf-1, &pcbNeeded, &pcReturned);
+ ok( !res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER),
+ "(%ld) returned %ld with %ld (expected '0' with " \
+ "ERROR_INSUFFICIENT_BUFFER)\n", level, res, GetLastError());
+
+
+ SetLastError(0xdeadbeef);
+ res = EnumFormsA(hprinter, level, NULL, cbBuf, &pcbNeeded, &pcReturned);
+ ok( !res && (GetLastError() == ERROR_INVALID_USER_BUFFER) ,
+ "(%ld) returned %ld with %ld (expected '0' with "\
+ "ERROR_INVALID_USER_BUFFER)\n", level, res, GetLastError());
+
+
+ SetLastError(0xdeadbeef);
+ res = EnumFormsA(hprinter, level, buffer, cbBuf, NULL, &pcReturned);
+ ok( !res && (GetLastError() == RPC_X_NULL_REF_POINTER) ,
+ "(%ld) returned %ld with %ld (expected '0' with "\
+ "RPC_X_NULL_REF_POINTER)\n", level, res, GetLastError());
+
+ SetLastError(0xdeadbeef);
+ res = EnumFormsA(hprinter, level, buffer, cbBuf, &pcbNeeded, NULL);
+ ok( !res && (GetLastError() == RPC_X_NULL_REF_POINTER) ,
+ "(%ld) returned %ld with %ld (expected '0' with "\
+ "RPC_X_NULL_REF_POINTER)\n", level, res, GetLastError());
+
+ SetLastError(0xdeadbeef);
+ res = EnumFormsA(0, level, buffer, cbBuf, &pcbNeeded, &pcReturned);
+ ok( !res && (GetLastError() == ERROR_INVALID_HANDLE) ,
+ "(%ld) returned %ld with %ld (expected '0' with "\
+ "ERROR_INVALID_HANDLE)\n", level, res, GetLastError());
+
+ HeapFree(GetProcessHeap(), 0, buffer);
+ } /* for(level ... */
+
+ ClosePrinter(hprinter);
+}
/* ########################### */
@@ -1288,15 +1392,19 @@ static void test_DocumentProperties(void
START_TEST(info)
{
+ LPSTR default_printer;
+
hwinspool = GetModuleHandleA("winspool.drv");
pGetDefaultPrinterA = (void *) GetProcAddress(hwinspool, "GetDefaultPrinterA");
pSetDefaultPrinterA = (void *) GetProcAddress(hwinspool, "SetDefaultPrinterA");
- find_default_printer();
+ default_printer = find_default_printer();
test_AddMonitor();
test_DeleteMonitor();
test_DocumentProperties();
+ test_EnumForms(NULL);
+ if (default_printer) test_EnumForms(default_printer);
test_EnumMonitors();
test_GetDefaultPrinter();
test_GetPrinterDriverDirectory();
More information about the wine-cvs
mailing list