comdlg32/tests: Skip some not implemented functions on win98.
[wine] / dlls / comdlg32 / tests / filedlg.c
1 /*
2  * Unit test suite for comdlg32 API functions: file dialogs
3  *
4  * Copyright 2007 Google (Lei Zhang)
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 <windows.h>
23 #include <wine/test.h>
24
25
26 /* ##### */
27
28 static UINT CALLBACK OFNHookProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
29 {
30     LPNMHDR nmh;
31
32     if( msg == WM_NOTIFY)
33     {
34         nmh = (LPNMHDR) lParam;
35         if( nmh->code == CDN_INITDONE)
36         {
37             PostMessage( GetParent(hDlg), WM_COMMAND, IDCANCEL, FALSE);
38         }
39     }
40
41     return 0;
42 }
43
44 /* bug 6829 */
45 static void test_DialogCancel(void)
46 {
47     OPENFILENAMEA ofn;
48     BOOL result;
49     char szFileName[MAX_PATH] = "";
50
51     ZeroMemory(&ofn, sizeof(ofn));
52
53     ofn.lStructSize = sizeof(ofn);
54     ofn.hwndOwner = NULL;
55     ofn.lpstrFilter = "Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0";
56     ofn.lpstrFile = szFileName;
57     ofn.nMaxFile = MAX_PATH;
58     ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_ENABLEHOOK;
59     ofn.lpstrDefExt = "txt";
60     ofn.lpfnHook = (LPOFNHOOKPROC) OFNHookProc;
61
62     PrintDlgA(NULL);
63     ok(CDERR_INITIALIZATION == CommDlgExtendedError(), "expected %d, got %d\n",
64        CDERR_INITIALIZATION, CommDlgExtendedError());
65
66     result = GetOpenFileNameA(&ofn);
67     ok(0 == result, "expected %d, got %d\n", 0, result);
68     ok(0 == CommDlgExtendedError(), "expected %d, got %d\n", 0,
69        CommDlgExtendedError());
70
71     PrintDlgA(NULL);
72     ok(CDERR_INITIALIZATION == CommDlgExtendedError(), "expected %d, got %d\n",
73               CDERR_INITIALIZATION, CommDlgExtendedError());
74
75     SetLastError(0xdeadbeef);
76     result = GetOpenFileNameW((LPOPENFILENAMEW) &ofn);
77     if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
78         skip("GetOpenFileNameW is not implemented\n");
79     else
80     {
81         ok(0 == result, "expected %d, got %d\n", 0, result);
82         ok(0 == CommDlgExtendedError(), "expected %d, got %d\n", 0,
83            CommDlgExtendedError());
84     }
85
86     PrintDlgA(NULL);
87     ok(CDERR_INITIALIZATION == CommDlgExtendedError(), "expected %d, got %d\n",
88               CDERR_INITIALIZATION, CommDlgExtendedError());
89
90     result = GetSaveFileNameA(&ofn);
91     ok(0 == result, "expected %d, got %d\n", 0, result);
92     ok(0 == CommDlgExtendedError(), "expected %d, got %d\n", 0,
93        CommDlgExtendedError());
94
95     PrintDlgA(NULL);
96     ok(CDERR_INITIALIZATION == CommDlgExtendedError(), "expected %d, got %d\n",
97               CDERR_INITIALIZATION, CommDlgExtendedError());
98
99     SetLastError(0xdeadbeef);
100     result = GetSaveFileNameW((LPOPENFILENAMEW) &ofn);
101     if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
102         skip("GetSaveFileNameW is not implemented\n");
103     else
104     {
105         ok(0 == result, "expected %d, got %d\n", 0, result);
106         ok(0 == CommDlgExtendedError(), "expected %d, got %d\n", 0,
107            CommDlgExtendedError());
108     }
109 }
110
111
112 START_TEST(filedlg)
113 {
114     test_DialogCancel();
115
116 }