[PATCH] winspool/tests: Add tests for AddForm
Marcel Partap
mpartap at gmx.net
Sat Apr 12 11:15:31 CDT 2008
---
dlls/winspool.drv/tests/info.c | 113 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 113 insertions(+), 0 deletions(-)
diff --git a/dlls/winspool.drv/tests/info.c b/dlls/winspool.drv/tests/info.c
index cd93f16..be1affc 100644
--- a/dlls/winspool.drv/tests/info.c
+++ b/dlls/winspool.drv/tests/info.c
@@ -43,6 +43,7 @@ static CHAR does_not_exist[] = "does_not_exist";
static CHAR empty[] = "";
static CHAR env_x86[] = "Windows NT x86";
static CHAR env_win9x_case[] = "windowS 4.0";
+static CHAR form_name[] = "WineTestForm";
static CHAR illegal_name[] = "illegal,name";
static CHAR invalid_env[] = "invalid_env";
static CHAR LocalPortA[] = "Local Port";
@@ -288,6 +289,117 @@ static void find_tempfile(VOID)
/* ########################### */
+static void test_AddForm(void)
+{
+ /* fixme: level 2 not yet supported */
+ FORM_INFO_1A fi1a;
+ DWORD res;
+ HANDLE hprinter = NULL;
+
+ SetLastError(MAGIC_DEAD);
+ res = AddFormA(NULL, 0, NULL);
+ RETURN_ON_DEACTIVATED_SPOOLER(res);
+ ok( !res && (GetLastError() == ERROR_INVALID_LEVEL),
+ "returned %d with %d (expected '0' with ERROR_INVALID_LEVEL)\n", res, GetLastError());
+
+ SetLastError(MAGIC_DEAD);
+ res = AddFormA((HANDLE)MAGIC_DEAD, 1, NULL);
+ RETURN_ON_DEACTIVATED_SPOOLER(res);
+ ok( !res && (GetLastError() == ERROR_INVALID_HANDLE),
+ "returned %d with %d (expected '0' with ERROR_INVALID_HANDLE)\n", res, GetLastError());
+
+ /* get handle for default printer */
+ if (default_printer)
+ OpenPrinter(default_printer, &hprinter, NULL);
+ if (!hprinter)
+ return;
+
+ SetLastError(MAGIC_DEAD);
+ res = AddFormA(hprinter, 1, NULL);
+ RETURN_ON_DEACTIVATED_SPOOLER(res);
+ ok( !res && (GetLastError() == ERROR_INVALID_PARAMETER),
+ "returned %d with %d (expected '0' with ERROR_INVALID_PARAMETER)\n", res, GetLastError());
+
+ /* first attempt with empty form structure */
+ memset(&fi1a, 0, sizeof(fi1a));
+ SetLastError(MAGIC_DEAD);
+ res = AddFormA(hprinter, 1, (LPBYTE)&fi1a);
+ RETURN_ON_DEACTIVATED_SPOOLER(res);
+ ok( !res && (GetLastError() == ERROR_INVALID_FORM_NAME),
+ "returned %d with %d (expected '0' with ERROR_INVALID_FORM_NAME)\n", res, GetLastError());
+
+ fi1a.pName = empty;
+ SetLastError(MAGIC_DEAD);
+ res = AddFormA(hprinter, 1, (LPBYTE)&fi1a);
+ RETURN_ON_DEACTIVATED_SPOOLER(res);
+ ok( !res && (GetLastError() == ERROR_INVALID_FORM_NAME),
+ "returned %d with %d (expected '0' with ERROR_INVALID_FORM_NAME)\n", res, GetLastError());
+
+ fi1a.pName = form_name;
+ fi1a.Flags = FORM_PRINTER;
+ SetLastError(MAGIC_DEAD);
+ res = AddFormA(hprinter, 1, (LPBYTE)&fi1a);
+ RETURN_ON_DEACTIVATED_SPOOLER(res);
+ ok( !res && (GetLastError() == ERROR_INVALID_FORM_SIZE),
+ "returned %d with %d (expected '0' with ERROR_INVALID_FORM_SIZE)\n", res, GetLastError());
+
+ /* Size and ImageableArea are tested to both be > 0 on NT */
+ fi1a.ImageableArea.left = 1;
+ fi1a.ImageableArea.top = 2;
+ fi1a.ImageableArea.right = 3;
+ fi1a.ImageableArea.bottom = 4;
+ SetLastError(MAGIC_DEAD);
+ res = AddFormA(hprinter, 1, (LPBYTE)&fi1a);
+ RETURN_ON_DEACTIVATED_SPOOLER(res);
+ ok( !res && (GetLastError() == ERROR_INVALID_FORM_SIZE),
+ "returned %d with %d (expected '0' with ERROR_INVALID_FORM_SIZE)\n", res, GetLastError());
+
+ memset(&fi1a.ImageableArea, 0, sizeof(RECTL));
+ fi1a.Size.cx = 1;
+ fi1a.Size.cy = 1;
+ SetLastError(MAGIC_DEAD);
+ res = AddFormA(hprinter, 1, (LPBYTE)&fi1a);
+ RETURN_ON_DEACTIVATED_SPOOLER(res);
+ ok( !res && (GetLastError() == ERROR_INVALID_FORM_SIZE),
+ "returned %d with %d (expected '0' with ERROR_INVALID_FORM_SIZE)\n", res, GetLastError());
+
+ fi1a.ImageableArea.right = -500;
+ fi1a.ImageableArea.bottom = -500;
+ SetLastError(MAGIC_DEAD);
+ res = AddFormA(hprinter, 1, (LPBYTE)&fi1a);
+ RETURN_ON_DEACTIVATED_SPOOLER(res);
+ ok( !res && (GetLastError() == ERROR_INVALID_FORM_SIZE),
+ "returned %d with %d (expected '0' with ERROR_INVALID_FORM_SIZE)\n", res, GetLastError());
+
+ fi1a.ImageableArea.right = 500;
+ fi1a.ImageableArea.bottom = 500;
+ fi1a.Size.cx = -1;
+ fi1a.Size.cy = -1;
+ SetLastError(MAGIC_DEAD);
+ res = AddFormA(hprinter, 1, (LPBYTE)&fi1a);
+ RETURN_ON_DEACTIVATED_SPOOLER(res);
+ ok( !res && (GetLastError() == ERROR_INVALID_FORM_SIZE),
+ "returned %d with %d (expected '0' with ERROR_INVALID_FORM_SIZE)\n", res, GetLastError());
+
+ fi1a.Size.cx = 1;
+ fi1a.Size.cy = 1;
+ SetLastError(MAGIC_DEAD);
+ res = AddFormA(hprinter, 1, (LPBYTE)&fi1a);
+ RETURN_ON_DEACTIVATED_SPOOLER(res);
+ ok( res, "returned %d with %d (expected '1')\n", res, GetLastError());
+
+ SetLastError(MAGIC_DEAD);
+ res = AddFormA(hprinter, 1, (LPBYTE)&fi1a);
+ RETURN_ON_DEACTIVATED_SPOOLER(res);
+ ok( !res && (GetLastError() == ERROR_FILE_EXISTS),
+ "returned %d with %d (expected '0' with ERROR_FILE_EXISTS)\n", res, GetLastError());
+
+ /* clean up */
+ DeleteForm(hprinter, form_name);
+}
+
+/* ########################### */
+
static void test_AddMonitor(void)
{
MONITOR_INFO_2A mi2a;
@@ -2377,6 +2489,7 @@ START_TEST(info)
find_local_server();
find_tempfile();
+ test_AddForm();
test_AddMonitor();
test_AddPort();
test_AddPortEx();
--
1.5.4.5
--------------040709040909070507010701--
More information about the wine-patches
mailing list