[PATCH] winspool/tests: Add tests for AddForm and DeleteForm
Marcel Partap
mpartap at gmx.net
Sun Apr 27 15:08:54 CDT 2008
---
dlls/winspool.drv/tests/info.c | 163 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 163 insertions(+), 0 deletions(-)
diff --git a/dlls/winspool.drv/tests/info.c b/dlls/winspool.drv/tests/info.c
index f0f4754..d5b4274 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 formname_test[] = "WineTestForm";
static CHAR illegal_name[] = "illegal,name";
static CHAR invalid_env[] = "invalid_env";
static CHAR LocalPortA[] = "Local Port";
@@ -288,6 +289,112 @@ 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(0xdeadbeef);
+ res = AddFormA(NULL, 0, NULL);
+ ok(!res && (GetLastError() == ERROR_INVALID_LEVEL),
+ "returned %d with %d (expected '0' with ERROR_INVALID_LEVEL)\n", res, GetLastError());
+
+ SetLastError(0xdeadbeef);
+ res = AddFormA(NULL, 1, NULL);
+ ok(!res && (GetLastError() == ERROR_INVALID_HANDLE),
+ "returned %d with %d (expected '0' with ERROR_INVALID_HANDLE)\n", res, GetLastError());
+
+ SetLastError(0xdeadbeef);
+ res = AddFormA((HANDLE)0xdeadbeef, 1, NULL);
+ 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(0xdeadbeef);
+ res = AddFormA(hprinter, 1, NULL);
+ 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(0xdeadbeef);
+ res = AddFormA(hprinter, 1, (LPBYTE)&fi1a);
+ 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(0xdeadbeef);
+ res = AddFormA(hprinter, 1, (LPBYTE)&fi1a);
+ ok(!res && (GetLastError() == ERROR_INVALID_FORM_NAME),
+ "returned %d with %d (expected '0' with ERROR_INVALID_FORM_NAME)\n", res, GetLastError());
+
+ fi1a.pName = formname_test;
+ fi1a.Flags = FORM_PRINTER;
+ SetLastError(0xdeadbeef);
+ res = AddFormA(hprinter, 1, (LPBYTE)&fi1a);
+ ok(!res && (GetLastError() == ERROR_INVALID_FORM_SIZE),
+ "returned %d with %d (expected '0' with ERROR_INVALID_FORM_SIZE)\n", res, GetLastError());
+
+ /* Size.cx/.cy and ImageableArea.right/.bottom 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(0xdeadbeef);
+ res = AddFormA(hprinter, 1, (LPBYTE)&fi1a);
+ 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(0xdeadbeef);
+ res = AddFormA(hprinter, 1, (LPBYTE)&fi1a);
+ 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(0xdeadbeef);
+ res = AddFormA(hprinter, 1, (LPBYTE)&fi1a);
+ 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(0xdeadbeef);
+ res = AddFormA(hprinter, 1, (LPBYTE)&fi1a);
+ 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(0xdeadbeef);
+ res = AddFormA(hprinter, 1, (LPBYTE)&fi1a);
+ /* needs administrator privileges */
+ RETURN_ON_ACCESS_DENIED(res)
+ ok(res, "returned %d with %d (expected '1')\n", res, GetLastError());
+
+ SetLastError(0xdeadbeef);
+ res = AddFormA(hprinter, 1, (LPBYTE)&fi1a);
+ ok(!res && (GetLastError() == ERROR_FILE_EXISTS),
+ "returned %d with %d (expected '0' with ERROR_FILE_EXISTS)\n", res, GetLastError());
+
+ /* clean up */
+ DeleteForm(hprinter, formname_test);
+}
+
+/* ########################### */
+
static void test_AddMonitor(void)
{
MONITOR_INFO_2A mi2a;
@@ -644,6 +751,60 @@ static void test_ConfigurePort(void)
/* ########################### */
+static void test_DeleteForm(void)
+{
+ FORM_INFO_1A fi;
+ HANDLE hprinter = NULL;
+ DWORD res;
+
+ SetLastError(0xdeadbeef);
+ res = DeleteFormA(NULL, NULL);
+ ok(!res && (GetLastError() == ERROR_INVALID_HANDLE),
+ "returned %d with %d (expected 0 with ERROR_INVALID_HANDLE)\n", res, GetLastError());
+
+ memset(&fi, 0, sizeof(fi));
+ fi.pName = formname_test;
+ fi.Size.cx = 1;
+ fi.Size.cy = 1;
+ fi.ImageableArea.right = 1;
+ fi.ImageableArea.bottom = 1;
+
+ if (default_printer)
+ OpenPrinterA(default_printer, &hprinter, NULL);
+ if (!hprinter)
+ return;
+
+ if (!AddFormA(hprinter, 1, (LPBYTE)&fi))
+ return;
+
+ SetLastError(0xdeadbeef);
+ res = DeleteFormA(NULL, formname_test);
+ ok(!res && (GetLastError() == ERROR_INVALID_HANDLE),
+ "returned %d with %d (expected 0 with ERROR_INVALID_HANDLE)\n", res, GetLastError());
+
+ SetLastError(0xdeadbeef);
+ res = DeleteFormA(hprinter, NULL);
+ ok(!res && (GetLastError() == RPC_X_NULL_REF_POINTER),
+ "returned %d with %d (expected 0 with RPC_X_NULL_REF_POINTER)\n", res, GetLastError());
+
+ SetLastError(0xdeadbeef);
+ res = DeleteFormA(hprinter, empty);
+ ok(!res && (GetLastError() == ERROR_INVALID_FORM_NAME),
+ "returned %d with %d (expected 0 with ERROR_INVALID_FORM_NAME)\n", res, GetLastError());
+
+ SetLastError(0xdeadbeef);
+ res = DeleteFormA(hprinter, formname_test);
+ ok(res, "returned %d with %d (expected 1)\n", res, GetLastError());
+
+ SetLastError(0xdeadbeef);
+ res = DeleteFormA(hprinter, formname_test);
+ ok(!res && (GetLastError() == ERROR_INVALID_FORM_NAME),
+ "returned %d with %d (expected 0 with ERROR_INVALID_FORM_NAME)\n", res, GetLastError());
+
+}
+
+/* ########################### */
+
static void test_DeleteMonitor(void)
{
MONITOR_INFO_2A mi2a;
@@ -2381,10 +2542,12 @@ START_TEST(info)
find_local_server();
find_tempfile();
+ test_AddForm();
test_AddMonitor();
test_AddPort();
test_AddPortEx();
test_ConfigurePort();
+ test_DeleteForm();
test_DeleteMonitor();
test_DeletePort();
test_DeviceCapabilities();
--
1.5.5.1
--------------090503060504070905090901--
More information about the wine-patches
mailing list