2 * Unit test suite for comdlg32 API functions: printer dialogs
4 * Copyright 2006 Detlef Riekenberg
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
34 #include "wine/test.h"
39 static void test_PageSetupDlgA(void)
44 pDlg
= HeapAlloc(GetProcessHeap(), 0, (sizeof(PAGESETUPDLGA
)) * 2);
47 SetLastError(0xdeadbeef);
48 res
= PageSetupDlgA(NULL
);
49 ok( !res
&& (CommDlgExtendedError() == CDERR_INITIALIZATION
),
50 "returned %u with %u and 0x%x (expected '0' and "
51 "CDERR_INITIALIZATION)\n", res
, GetLastError(), CommDlgExtendedError());
53 ZeroMemory(pDlg
, sizeof(PAGESETUPDLGA
));
54 pDlg
->lStructSize
= sizeof(PAGESETUPDLGA
) -1;
55 SetLastError(0xdeadbeef);
56 res
= PageSetupDlgA(pDlg
);
57 ok( !res
&& (CommDlgExtendedError() == CDERR_STRUCTSIZE
),
58 "returned %u with %u and 0x%x (expected '0' and "
59 "CDERR_STRUCTSIZE)\n", res
, GetLastError(), CommDlgExtendedError());
62 ZeroMemory(pDlg
, sizeof(PAGESETUPDLGA
));
63 pDlg
->lStructSize
= sizeof(PAGESETUPDLGA
);
64 pDlg
->Flags
= PSD_RETURNDEFAULT
;
65 SetLastError(0xdeadbeef);
66 res
= PageSetupDlgA(pDlg
);
67 ok( res
|| (CommDlgExtendedError() == PDERR_NODEFAULTPRN
),
68 "returned %u with %u and 0x%x (expected '!= 0' or '0' and "
69 "PDERR_NODEFAULTPRN)\n", res
, GetLastError(), CommDlgExtendedError());
71 ok( pDlg
->hDevMode
&& pDlg
->hDevNames
,
72 "got %p and %p (expected '!= NULL' for both)\n",
73 pDlg
->hDevMode
, pDlg
->hDevNames
);
75 GlobalFree(pDlg
->hDevMode
);
76 GlobalFree(pDlg
->hDevNames
);
78 HeapFree(GetProcessHeap(), 0, pDlg
);
84 static void test_PrintDlgA(void)
90 pDlg
= HeapAlloc(GetProcessHeap(), 0, (sizeof(PRINTDLGA
)) * 2);
94 /* will crash with unpatched wine */
95 SetLastError(0xdeadbeef);
96 res
= PrintDlgA(NULL
);
97 ok( !res
&& (CommDlgExtendedError() == CDERR_INITIALIZATION
),
98 "returned %d with 0x%x and 0x%x (expected '0' and "
99 "CDERR_INITIALIZATION)\n", res
, GetLastError(), CommDlgExtendedError());
101 ZeroMemory(pDlg
, sizeof(PRINTDLGA
));
102 pDlg
->lStructSize
= sizeof(PRINTDLGA
) - 1;
103 SetLastError(0xdeadbeef);
104 res
= PrintDlgA(pDlg
);
105 ok( !res
&& (CommDlgExtendedError() == CDERR_STRUCTSIZE
),
106 "returned %d with 0x%x and 0x%x (expected '0' and "
107 "CDERR_STRUCTSIZE)\n", res
, GetLastError(), CommDlgExtendedError());
110 ZeroMemory(pDlg
, sizeof(PRINTDLGA
));
111 pDlg
->lStructSize
= sizeof(PRINTDLGA
);
112 pDlg
->Flags
= PD_RETURNDEFAULT
;
113 SetLastError(0xdeadbeef);
114 res
= PrintDlgA(pDlg
);
115 ok( res
|| (CommDlgExtendedError() == PDERR_NODEFAULTPRN
),
116 "returned %d with 0x%x and 0x%x (expected '!= 0' or '0' and "
117 "PDERR_NODEFAULTPRN)\n", res
, GetLastError(), CommDlgExtendedError());
119 HeapFree(GetProcessHeap(), 0, pDlg
);
126 test_PageSetupDlgA();