[2/2] comdlg32: Add a test for nCopies/dmCopies returned by PrintDlg.
Dmitry Timoshkov
dmitry at baikal.ru
Wed May 8 04:16:38 CDT 2013
---
dlls/comdlg32/tests/printdlg.c | 42 ++++++++++++++++++++++++++++++++++++++++--
1 file changed, 40 insertions(+), 2 deletions(-)
diff --git a/dlls/comdlg32/tests/printdlg.c b/dlls/comdlg32/tests/printdlg.c
index d004598..1aac9e7 100644
--- a/dlls/comdlg32/tests/printdlg.c
+++ b/dlls/comdlg32/tests/printdlg.c
@@ -2,6 +2,7 @@
* Unit test suite for comdlg32 API functions: printer dialogs
*
* Copyright 2006-2007 Detlef Riekenberg
+ * Copyright 2013 Dmitry Timoshkov
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -123,6 +124,16 @@ static void test_PageSetupDlgA(void)
/* ########################### */
+static UINT_PTR CALLBACK print_hook_proc(HWND hdlg, UINT msg, WPARAM wp, LPARAM lp)
+{
+ if (msg == WM_INITDIALOG)
+ {
+ SetDlgItemInt(hdlg, edt3, 1234, FALSE);
+ PostMessage(hdlg, WM_COMMAND, IDOK, FALSE);
+ }
+ return 0;
+}
+
static void test_PrintDlgA(void)
{
DWORD res;
@@ -133,7 +144,7 @@ static void test_PrintDlgA(void)
LPCSTR port;
CHAR buffer[MAX_PATH];
LPSTR ptr;
-
+ DEVMODE *dm;
pDlg = HeapAlloc(GetProcessHeap(), 0, (sizeof(PRINTDLGA)) * 2);
if (!pDlg) return;
@@ -219,11 +230,38 @@ static void test_PrintDlgA(void)
}
GlobalUnlock(pDlg->hDevNames);
+ GlobalFree(pDlg->hDevMode);
+ GlobalFree(pDlg->hDevNames);
+ ZeroMemory(pDlg, sizeof(*pDlg));
+ pDlg->lStructSize = sizeof(*pDlg);
+ pDlg->Flags = PD_ENABLEPRINTHOOK;
+ pDlg->lpfnPrintHook = print_hook_proc;
+ res = PrintDlg(pDlg);
+ ok(res, "PrintDlg error %#x\n", CommDlgExtendedError());
+ ok(pDlg->nCopies == 1234, "expected nCopies 1234, got %d\n", pDlg->nCopies);
+ ok(pDlg->hDevMode != 0, "hDevMode should not be 0\n");
+ dm = GlobalLock(pDlg->hDevMode);
+ ok(dm->dmCopies == 1, "expected dm->dmCopies 1, got %d\n", dm->dmCopies);
+ GlobalUnlock(pDlg->hDevMode);
+ GlobalFree(pDlg->hDevMode);
+ GlobalFree(pDlg->hDevNames);
+
+ ZeroMemory(pDlg, sizeof(*pDlg));
+ pDlg->lStructSize = sizeof(*pDlg);
+ pDlg->Flags = PD_ENABLEPRINTHOOK | PD_USEDEVMODECOPIES;
+ pDlg->lpfnPrintHook = print_hook_proc;
+ res = PrintDlg(pDlg);
+ ok(res, "PrintDlg error %#x\n", CommDlgExtendedError());
+ ok(pDlg->nCopies == 1, "expected nCopies 1, got %d\n", pDlg->nCopies);
+ ok(pDlg->hDevMode != 0, "hDevMode should not be 0\n");
+ dm = GlobalLock(pDlg->hDevMode);
+ ok(dm->dmCopies == 1234, "expected dm->dmCopies 1234, got %d\n", dm->dmCopies);
+ GlobalUnlock(pDlg->hDevMode);
GlobalFree(pDlg->hDevMode);
GlobalFree(pDlg->hDevNames);
- HeapFree(GetProcessHeap(), 0, pDlg);
+ HeapFree(GetProcessHeap(), 0, pDlg);
}
/* ########################### */
--
1.8.2.2
More information about the wine-patches
mailing list