ntdll: Block async signals during process init and thread creation.
[wine] / dlls / comdlg32 / tests / printdlg.c
1 /* 
2  * Unit test suite for comdlg32 API functions: printer dialogs
3  *
4  * Copyright 2006 Detlef Riekenberg
5  *
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.
10  *
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.
15  *
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
19  *
20  */
21
22 #include <stdarg.h>
23
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winerror.h"
27 #include "wingdi.h"
28 #include "wingdi.h"
29 #include "winuser.h"
30
31 #include "cderr.h"
32 #include "commdlg.h"
33
34 #include "wine/test.h"
35
36
37 /* ##### */
38
39 static void test_PrintDlgA(void)
40 {
41     DWORD       res;
42     LPPRINTDLGA pDlg;
43
44
45     pDlg = HeapAlloc(GetProcessHeap(), 0, (sizeof(PRINTDLGA)) * 2);
46     if (!pDlg) return;
47
48
49     /* will crash with unpatched wine */
50     SetLastError(0xdeadbeef);
51     res = PrintDlgA(NULL);
52     ok( !res && (CommDlgExtendedError() == CDERR_INITIALIZATION),
53         "returned %d with 0x%x and 0x%x (expected '0' and "
54         "CDERR_INITIALIZATION)\n", res, GetLastError(), CommDlgExtendedError());
55
56     ZeroMemory(pDlg, sizeof(PRINTDLGA));
57     pDlg->lStructSize = sizeof(PRINTDLGA) - 1;
58     SetLastError(0xdeadbeef);
59     res = PrintDlgA(pDlg);
60     ok( !res && (CommDlgExtendedError() == CDERR_STRUCTSIZE),
61         "returned %d with 0x%x and 0x%x (expected '0' and "
62         "CDERR_STRUCTSIZE)\n", res, GetLastError(), CommDlgExtendedError());
63
64
65     ZeroMemory(pDlg, sizeof(PRINTDLGA));
66     pDlg->lStructSize = sizeof(PRINTDLGA);
67     pDlg->Flags = PD_RETURNDEFAULT;
68     SetLastError(0xdeadbeef);
69     res = PrintDlgA(pDlg);
70     ok( res || (CommDlgExtendedError() == PDERR_NODEFAULTPRN),
71         "returned %d with 0x%x and 0x%x (expected '!= 0' or '0' and "
72         "PDERR_NODEFAULTPRN)\n", res, GetLastError(), CommDlgExtendedError());
73
74     HeapFree(GetProcessHeap(), 0, pDlg);
75
76 }
77
78
79 START_TEST(printdlg)
80 {
81     test_PrintDlgA();
82
83 }