2 * Unit tests for the Common Item Dialog
4 * Copyright 2010,2011 David Hedberg
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
22 #define WIN32_NO_STATUS
24 #define COM_NO_WINDOWS_H
26 #include <wine/test.h>
33 static HRESULT (WINAPI
*pSHCreateShellItem
)(LPCITEMIDLIST
,IShellFolder
*,LPCITEMIDLIST
,IShellItem
**);
34 static HRESULT (WINAPI
*pSHGetIDListFromObject
)(IUnknown
*, PIDLIST_ABSOLUTE
*);
35 static HRESULT (WINAPI
*pSHCreateItemFromParsingName
)(PCWSTR
,IBindCtx
*,REFIID
,void**);
37 static void init_function_pointers(void)
39 HMODULE hmod
= GetModuleHandleA("shell32.dll");
41 #define MAKEFUNC(f) (p##f = (void*)GetProcAddress(hmod, #f))
42 MAKEFUNC(SHCreateShellItem
);
43 MAKEFUNC(SHGetIDListFromObject
);
44 MAKEFUNC(SHCreateItemFromParsingName
);
49 DEFINE_GUID(IID_IFileDialogCustomizeAlt
, 0x8016B7B3, 0x3D49, 0x4504, 0xA0,0xAA, 0x2A,0x37,0x49,0x4E,0x60,0x6F);
51 /**************************************************************************
52 * IFileDialogEvents implementation
55 IFileDialogEvents IFileDialogEvents_iface
;
58 LONG OnFileOk
, OnFolderChanging
, OnFolderChange
;
59 LONG OnSelectionChange
, OnShareViolation
, OnTypeChange
;
62 BOOL set_filename_tried
;
64 } IFileDialogEventsImpl
;
66 static inline IFileDialogEventsImpl
*impl_from_IFileDialogEvents(IFileDialogEvents
*iface
)
68 return CONTAINING_RECORD(iface
, IFileDialogEventsImpl
, IFileDialogEvents_iface
);
71 static HRESULT WINAPI
IFileDialogEvents_fnQueryInterface(IFileDialogEvents
*iface
, REFIID riid
, void **ppv
)
74 ok(0, "Unexpectedly called.\n");
78 static ULONG WINAPI
IFileDialogEvents_fnAddRef(IFileDialogEvents
*iface
)
80 IFileDialogEventsImpl
*This
= impl_from_IFileDialogEvents(iface
);
81 return InterlockedIncrement(&This
->ref
);
84 static ULONG WINAPI
IFileDialogEvents_fnRelease(IFileDialogEvents
*iface
)
86 IFileDialogEventsImpl
*This
= impl_from_IFileDialogEvents(iface
);
87 LONG ref
= InterlockedDecrement(&This
->ref
);
90 HeapFree(GetProcessHeap(), 0, This
);
95 static HRESULT WINAPI
IFileDialogEvents_fnOnFileOk(IFileDialogEvents
*iface
, IFileDialog
*pfd
)
97 IFileDialogEventsImpl
*This
= impl_from_IFileDialogEvents(iface
);
102 static HRESULT WINAPI
IFileDialogEvents_fnOnFolderChanging(IFileDialogEvents
*iface
,
104 IShellItem
*psiFolder
)
106 IFileDialogEventsImpl
*This
= impl_from_IFileDialogEvents(iface
);
107 This
->OnFolderChanging
++;
111 static void test_customize_onfolderchange(IFileDialog
*pfd
);
113 static LRESULT CALLBACK
test_customize_dlgproc(HWND hwnd
, UINT message
, LPARAM lparam
, WPARAM wparam
)
115 WNDPROC oldwndproc
= GetPropA(hwnd
, "WT_OLDWC");
117 if(message
== WM_USER
+0x1234)
119 IFileDialog
*pfd
= (IFileDialog
*)lparam
;
120 test_customize_onfolderchange(pfd
);
123 return CallWindowProcW(oldwndproc
, hwnd
, message
, lparam
, wparam
);
126 static HRESULT WINAPI
IFileDialogEvents_fnOnFolderChange(IFileDialogEvents
*iface
, IFileDialog
*pfd
)
128 IFileDialogEventsImpl
*This
= impl_from_IFileDialogEvents(iface
);
133 This
->OnFolderChange
++;
135 if(This
->set_filename
)
137 hr
= IFileDialog_QueryInterface(pfd
, &IID_IOleWindow
, (void**)&pow
);
138 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
140 hr
= IOleWindow_GetWindow(pow
, &dlg_hwnd
);
141 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
142 ok(dlg_hwnd
!= NULL
, "Got NULL.\n");
144 IOleWindow_Release(pow
);
146 hr
= IFileDialog_SetFileName(pfd
, This
->set_filename
);
147 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
149 if(!This
->set_filename_tried
)
151 br
= PostMessageW(dlg_hwnd
, WM_COMMAND
, IDOK
, 0);
153 This
->set_filename_tried
= TRUE
;
160 hr
= IFileDialog_QueryInterface(pfd
, &IID_IOleWindow
, (void**)&pow
);
161 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
163 hr
= IOleWindow_GetWindow(pow
, &dlg_hwnd
);
164 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
165 ok(dlg_hwnd
!= NULL
, "Got NULL.\n");
167 IOleWindow_Release(pow
);
169 /* On Vista, the custom control area of the dialog is not
170 * fully set up when the first OnFolderChange event is
172 oldwndproc
= (WNDPROC
)GetWindowLongPtrW(dlg_hwnd
, GWLP_WNDPROC
);
173 SetPropA(dlg_hwnd
, "WT_OLDWC", (HANDLE
)oldwndproc
);
174 SetWindowLongPtrW(dlg_hwnd
, GWLP_WNDPROC
, (LPARAM
)test_customize_dlgproc
);
176 br
= PostMessageW(dlg_hwnd
, WM_USER
+0x1234, (LPARAM
)pfd
, 0);
183 static HRESULT WINAPI
IFileDialogEvents_fnOnSelectionChange(IFileDialogEvents
*iface
, IFileDialog
*pfd
)
185 IFileDialogEventsImpl
*This
= impl_from_IFileDialogEvents(iface
);
186 This
->OnSelectionChange
++;
190 static HRESULT WINAPI
IFileDialogEvents_fnOnShareViolation(IFileDialogEvents
*iface
,
193 FDE_SHAREVIOLATION_RESPONSE
*pResponse
)
195 IFileDialogEventsImpl
*This
= impl_from_IFileDialogEvents(iface
);
196 This
->OnShareViolation
++;
200 static HRESULT WINAPI
IFileDialogEvents_fnOnTypeChange(IFileDialogEvents
*iface
, IFileDialog
*pfd
)
202 IFileDialogEventsImpl
*This
= impl_from_IFileDialogEvents(iface
);
203 This
->OnTypeChange
++;
207 static HRESULT WINAPI
IFileDialogEvents_fnOnOverwrite(IFileDialogEvents
*iface
,
210 FDE_OVERWRITE_RESPONSE
*pResponse
)
212 IFileDialogEventsImpl
*This
= impl_from_IFileDialogEvents(iface
);
217 static const IFileDialogEventsVtbl vt_IFileDialogEvents
= {
218 IFileDialogEvents_fnQueryInterface
,
219 IFileDialogEvents_fnAddRef
,
220 IFileDialogEvents_fnRelease
,
221 IFileDialogEvents_fnOnFileOk
,
222 IFileDialogEvents_fnOnFolderChanging
,
223 IFileDialogEvents_fnOnFolderChange
,
224 IFileDialogEvents_fnOnSelectionChange
,
225 IFileDialogEvents_fnOnShareViolation
,
226 IFileDialogEvents_fnOnTypeChange
,
227 IFileDialogEvents_fnOnOverwrite
230 static IFileDialogEvents
*IFileDialogEvents_Constructor(void)
232 IFileDialogEventsImpl
*This
;
234 This
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IFileDialogEventsImpl
));
235 This
->IFileDialogEvents_iface
.lpVtbl
= &vt_IFileDialogEvents
;
238 return &This
->IFileDialogEvents_iface
;
241 static BOOL
test_instantiation(void)
244 IFileOpenDialog
*pfod
;
245 IFileSaveDialog
*pfsd
;
246 IServiceProvider
*psp
;
252 /* Instantiate FileOpenDialog */
253 hr
= CoCreateInstance(&CLSID_FileOpenDialog
, NULL
, CLSCTX_INPROC_SERVER
,
254 &IID_IFileOpenDialog
, (void**)&pfod
);
257 skip("Could not instantiate the FileOpenDialog.\n");
260 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
262 hr
= IFileOpenDialog_QueryInterface(pfod
, &IID_IFileDialog
, (void**)&pfd
);
263 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
264 if(SUCCEEDED(hr
)) IFileDialog_Release(pfd
);
266 hr
= IFileOpenDialog_QueryInterface(pfod
, &IID_IFileDialogCustomize
, (void**)&punk
);
267 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
268 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
270 hr
= IFileOpenDialog_QueryInterface(pfod
, &IID_IFileDialogCustomizeAlt
, (void**)&punk
);
271 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
272 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
274 hr
= IFileOpenDialog_QueryInterface(pfod
, &IID_IFileSaveDialog
, (void**)&pfsd
);
275 ok(hr
== E_NOINTERFACE
, "got 0x%08x.\n", hr
);
276 if(SUCCEEDED(hr
)) IFileSaveDialog_Release(pfsd
);
278 hr
= IFileOpenDialog_QueryInterface(pfod
, &IID_IServiceProvider
, (void**)&psp
);
279 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
282 IExplorerBrowser
*peb
;
285 hr
= IServiceProvider_QueryService(psp
, &SID_SExplorerBrowserFrame
, &IID_ICommDlgBrowser
, (void**)&punk
);
286 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
287 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
289 /* since win8, the result is E_NOTIMPL for all other services */
290 hr
= IServiceProvider_QueryService(psp
, &SID_STopLevelBrowser
, &IID_IExplorerBrowser
, (void**)&peb
);
291 ok(hr
== E_NOTIMPL
|| broken(hr
== E_FAIL
), "got 0x%08x (expected E_NOTIMPL)\n", hr
);
292 if(SUCCEEDED(hr
)) IExplorerBrowser_Release(peb
);
293 hr
= IServiceProvider_QueryService(psp
, &SID_STopLevelBrowser
, &IID_IShellBrowser
, (void**)&psb
);
294 ok(hr
== E_NOTIMPL
|| broken(hr
== E_FAIL
), "got 0x%08x (expected E_NOTIMPL)\n", hr
);
295 if(SUCCEEDED(hr
)) IShellBrowser_Release(psb
);
296 hr
= IServiceProvider_QueryService(psp
, &SID_STopLevelBrowser
, &IID_ICommDlgBrowser
, (void**)&punk
);
297 ok(hr
== E_NOTIMPL
|| broken(hr
== E_FAIL
), "got 0x%08x (expected E_NOTIMPL)\n", hr
);
298 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
300 hr
= IServiceProvider_QueryService(psp
, &SID_STopLevelBrowser
, &IID_IUnknown
, (void**)&punk
);
301 ok(hr
== E_NOTIMPL
|| broken(hr
== E_FAIL
), "got 0x%08x (expected E_NOTIMPL)\n", hr
);
302 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
303 hr
= IServiceProvider_QueryService(psp
, &IID_IUnknown
, &IID_IUnknown
, (void**)&punk
);
304 ok(hr
== E_NOTIMPL
|| broken(hr
== E_FAIL
), "got 0x%08x (expected E_NOTIMPL)\n", hr
);
305 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
307 IServiceProvider_Release(psp
);
310 hr
= IFileOpenDialog_QueryInterface(pfod
, &IID_IFileDialogEvents
, (void**)&punk
);
311 ok(hr
== E_NOINTERFACE
, "got 0x%08x.\n", hr
);
312 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
314 hr
= IFileOpenDialog_QueryInterface(pfod
, &IID_IExplorerBrowser
, (void**)&punk
);
315 ok(hr
== E_NOINTERFACE
, "got 0x%08x.\n", hr
);
316 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
318 hr
= IFileOpenDialog_QueryInterface(pfod
, &IID_IExplorerBrowserEvents
, (void**)&punk
);
319 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
320 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
322 hr
= IFileOpenDialog_QueryInterface(pfod
, &IID_ICommDlgBrowser3
, (void**)&punk
);
323 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
324 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
326 hr
= IFileOpenDialog_QueryInterface(pfod
, &IID_IShellBrowser
, (void**)&punk
);
327 ok(hr
== E_NOINTERFACE
, "got 0x%08x.\n", hr
);
328 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
330 hr
= IFileOpenDialog_QueryInterface(pfod
, &IID_IOleWindow
, (void**)&pow
);
331 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
336 hr
= IOleWindow_ContextSensitiveHelp(pow
, TRUE
);
337 todo_wine
ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
339 hr
= IOleWindow_ContextSensitiveHelp(pow
, FALSE
);
340 todo_wine
ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
344 /* Crashes on win7 */
345 IOleWindow_GetWindow(pow
, NULL
);
348 hr
= IOleWindow_GetWindow(pow
, &hwnd
);
349 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
350 ok(hwnd
== NULL
, "Got %p\n", hwnd
);
352 IOleWindow_Release(pow
);
355 ref
= IFileOpenDialog_Release(pfod
);
356 ok(!ref
, "Got refcount %d, should have been released.\n", ref
);
358 /* Instantiate FileSaveDialog */
359 hr
= CoCreateInstance(&CLSID_FileSaveDialog
, NULL
, CLSCTX_INPROC_SERVER
,
360 &IID_IFileSaveDialog
, (void**)&pfsd
);
363 skip("Could not instantiate the FileSaveDialog.\n");
366 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
368 hr
= IFileSaveDialog_QueryInterface(pfsd
, &IID_IFileDialog
, (void**)&pfd
);
369 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
370 if(SUCCEEDED(hr
)) IFileDialog_Release(pfd
);
372 hr
= IFileSaveDialog_QueryInterface(pfsd
, &IID_IFileDialogCustomize
, (void**)&punk
);
373 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
374 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
376 hr
= IFileSaveDialog_QueryInterface(pfsd
, &IID_IFileDialogCustomizeAlt
, (void**)&punk
);
377 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
378 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
380 hr
= IFileSaveDialog_QueryInterface(pfsd
, &IID_IFileOpenDialog
, (void**)&pfod
);
381 ok(hr
== E_NOINTERFACE
, "got 0x%08x.\n", hr
);
382 if(SUCCEEDED(hr
)) IFileOpenDialog_Release(pfod
);
384 hr
= IFileSaveDialog_QueryInterface(pfsd
, &IID_IFileDialogEvents
, (void**)&punk
);
385 ok(hr
== E_NOINTERFACE
, "got 0x%08x.\n", hr
);
386 if(SUCCEEDED(hr
)) IFileDialog_Release(pfd
);
388 hr
= IFileSaveDialog_QueryInterface(pfsd
, &IID_IExplorerBrowser
, (void**)&punk
);
389 ok(hr
== E_NOINTERFACE
, "got 0x%08x.\n", hr
);
390 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
392 hr
= IFileSaveDialog_QueryInterface(pfsd
, &IID_IExplorerBrowserEvents
, (void**)&punk
);
393 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
394 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
396 hr
= IFileSaveDialog_QueryInterface(pfsd
, &IID_ICommDlgBrowser3
, (void**)&punk
);
397 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
398 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
400 hr
= IFileSaveDialog_QueryInterface(pfsd
, &IID_IShellBrowser
, (void**)&punk
);
401 ok(hr
== E_NOINTERFACE
, "got 0x%08x.\n", hr
);
402 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
404 hr
= IFileSaveDialog_QueryInterface(pfsd
, &IID_IOleWindow
, (void**)&pow
);
405 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
410 hr
= IOleWindow_ContextSensitiveHelp(pow
, TRUE
);
411 todo_wine
ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
413 hr
= IOleWindow_ContextSensitiveHelp(pow
, FALSE
);
414 todo_wine
ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
418 /* Crashes on win7 */
419 IOleWindow_GetWindow(pow
, NULL
);
422 hr
= IOleWindow_GetWindow(pow
, &hwnd
);
423 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
424 ok(hwnd
== NULL
, "Got %p\n", hwnd
);
426 IOleWindow_Release(pow
);
430 ref
= IFileSaveDialog_Release(pfsd
);
431 ok(!ref
, "Got refcount %d, should have been released.\n", ref
);
435 static void test_basics(void)
437 IFileOpenDialog
*pfod
;
438 IFileSaveDialog
*pfsd
;
440 FILEOPENDIALOGOPTIONS fdoptions
;
441 IShellFolder
*psfdesktop
;
442 IShellItem
*psi
, *psidesktop
, *psi_original
;
443 IShellItemArray
*psia
;
450 const WCHAR txt
[] = {'t','x','t', 0};
451 const WCHAR null
[] = {0};
452 const WCHAR fname1
[] = {'f','n','a','m','e','1', 0};
453 const WCHAR fspec1
[] = {'*','.','t','x','t',0};
454 const WCHAR fname2
[] = {'f','n','a','m','e','2', 0};
455 const WCHAR fspec2
[] = {'*','.','e','x','e',0};
456 COMDLG_FILTERSPEC filterspec
[2] = {{fname1
, fspec1
}, {fname2
, fspec2
}};
458 /* This should work on every platform with IFileDialog */
459 SHGetDesktopFolder(&psfdesktop
);
460 hr
= pSHGetIDListFromObject((IUnknown
*)psfdesktop
, &pidl
);
463 hr
= pSHCreateShellItem(NULL
, NULL
, pidl
, &psidesktop
);
466 IShellFolder_Release(psfdesktop
);
469 skip("Failed to get ShellItem from DesktopFolder, skipping tests.\n");
474 /* Instantiate FileOpenDialog and FileSaveDialog */
475 hr
= CoCreateInstance(&CLSID_FileOpenDialog
, NULL
, CLSCTX_INPROC_SERVER
,
476 &IID_IFileOpenDialog
, (void**)&pfod
);
477 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
478 hr
= CoCreateInstance(&CLSID_FileSaveDialog
, NULL
, CLSCTX_INPROC_SERVER
,
479 &IID_IFileSaveDialog
, (void**)&pfsd
);
480 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
482 /* ClearClientData */
485 hr
= IFileOpenDialog_ClearClientData(pfod
);
486 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
487 hr
= IFileSaveDialog_ClearClientData(pfsd
);
488 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
492 hr
= IFileOpenDialog_GetOptions(pfod
, NULL
);
493 ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
494 hr
= IFileSaveDialog_GetOptions(pfsd
, NULL
);
495 ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
497 /* Check default options */
498 hr
= IFileOpenDialog_GetOptions(pfod
, &fdoptions
);
499 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
500 ok(fdoptions
== (FOS_PATHMUSTEXIST
| FOS_FILEMUSTEXIST
| FOS_NOCHANGEDIR
),
501 "Unexpected default options: 0x%08x\n", fdoptions
);
502 hr
= IFileSaveDialog_GetOptions(pfsd
, &fdoptions
);
503 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
504 ok(fdoptions
== (FOS_OVERWRITEPROMPT
| FOS_NOREADONLYRETURN
| FOS_PATHMUSTEXIST
| FOS_NOCHANGEDIR
),
505 "Unexpected default options: 0x%08x\n", fdoptions
);
508 hr
= IFileOpenDialog_GetResult(pfod
, NULL
);
509 ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
510 hr
= IFileSaveDialog_GetResult(pfsd
, NULL
);
511 ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
513 psi
= (void*)0xdeadbeef;
514 hr
= IFileOpenDialog_GetResult(pfod
, &psi
);
515 ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
516 ok(psi
== (void*)0xdeadbeef, "got %p.\n", psi
);
517 psi
= (void*)0xdeadbeef;
518 hr
= IFileSaveDialog_GetResult(pfsd
, &psi
);
519 ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
520 ok(psi
== (void*)0xdeadbeef, "got %p.\n", psi
);
522 /* GetCurrentSelection */
524 /* Crashes on Vista/W2K8. Tests below passes on Windows 7 */
525 hr
= IFileOpenDialog_GetCurrentSelection(pfod
, NULL
);
526 ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
527 hr
= IFileSaveDialog_GetCurrentSelection(pfsd
, NULL
);
528 ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
529 hr
= IFileOpenDialog_GetCurrentSelection(pfod
, &psi
);
530 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
531 hr
= IFileSaveDialog_GetCurrentSelection(pfsd
, &psi
);
532 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
536 hr
= IFileOpenDialog_GetFileName(pfod
, NULL
);
537 ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
538 filename
= (void*)0xdeadbeef;
539 hr
= IFileOpenDialog_GetFileName(pfod
, &filename
);
540 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
541 ok(filename
== NULL
, "got %p\n", filename
);
542 hr
= IFileSaveDialog_GetFileName(pfsd
, NULL
);
543 ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
544 filename
= (void*)0xdeadbeef;
545 hr
= IFileSaveDialog_GetFileName(pfsd
, &filename
);
546 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
547 ok(filename
== NULL
, "got %p\n", filename
);
549 /* GetFileTypeIndex */
550 hr
= IFileOpenDialog_GetFileTypeIndex(pfod
, NULL
);
551 ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
553 hr
= IFileOpenDialog_GetFileTypeIndex(pfod
, &filetype
);
554 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
555 ok(filetype
== 0, "got %d.\n", filetype
);
556 hr
= IFileSaveDialog_GetFileTypeIndex(pfsd
, NULL
);
557 ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
559 hr
= IFileSaveDialog_GetFileTypeIndex(pfsd
, &filetype
);
560 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
561 ok(filetype
== 0, "got %d.\n", filetype
);
563 /* SetFileTypes / SetFileTypeIndex */
564 hr
= IFileOpenDialog_SetFileTypes(pfod
, 0, NULL
);
565 ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
566 hr
= IFileOpenDialog_SetFileTypes(pfod
, 0, filterspec
);
567 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
569 hr
= IFileOpenDialog_SetFileTypeIndex(pfod
, -1);
570 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
571 hr
= IFileOpenDialog_SetFileTypeIndex(pfod
, 0);
572 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
573 hr
= IFileOpenDialog_SetFileTypeIndex(pfod
, 1);
574 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
575 hr
= IFileOpenDialog_SetFileTypes(pfod
, 1, filterspec
);
576 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
577 hr
= IFileOpenDialog_SetFileTypes(pfod
, 0, filterspec
);
578 ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
579 hr
= IFileOpenDialog_SetFileTypeIndex(pfod
, 0);
580 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
581 hr
= IFileOpenDialog_SetFileTypeIndex(pfod
, 100);
582 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
583 hr
= IFileOpenDialog_SetFileTypes(pfod
, 1, filterspec
);
584 ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
585 hr
= IFileOpenDialog_SetFileTypes(pfod
, 1, &filterspec
[1]);
586 ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
588 hr
= IFileSaveDialog_SetFileTypeIndex(pfsd
, -1);
589 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
590 hr
= IFileSaveDialog_SetFileTypeIndex(pfsd
, 0);
591 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
592 hr
= IFileSaveDialog_SetFileTypeIndex(pfsd
, 1);
593 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
594 hr
= IFileSaveDialog_SetFileTypes(pfsd
, 1, filterspec
);
595 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
596 hr
= IFileSaveDialog_SetFileTypeIndex(pfsd
, 0);
597 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
598 hr
= IFileSaveDialog_SetFileTypeIndex(pfsd
, 100);
599 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
600 hr
= IFileSaveDialog_SetFileTypes(pfsd
, 1, filterspec
);
601 ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
602 hr
= IFileSaveDialog_SetFileTypes(pfsd
, 1, &filterspec
[1]);
603 ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
608 hr
= IFileOpenDialog_SetFilter(pfod
, NULL
);
609 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
610 hr
= IFileSaveDialog_SetFilter(pfsd
, NULL
);
611 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
615 hr
= IFileOpenDialog_SetFolder(pfod
, NULL
);
616 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
617 hr
= IFileSaveDialog_SetFolder(pfsd
, NULL
);
618 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
620 /* SetDefaultExtension */
621 hr
= IFileOpenDialog_SetDefaultExtension(pfod
, NULL
);
622 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
623 hr
= IFileOpenDialog_SetDefaultExtension(pfod
, txt
);
624 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
625 hr
= IFileOpenDialog_SetDefaultExtension(pfod
, null
);
626 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
628 hr
= IFileSaveDialog_SetDefaultExtension(pfsd
, NULL
);
629 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
630 hr
= IFileSaveDialog_SetDefaultExtension(pfsd
, txt
);
631 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
632 hr
= IFileSaveDialog_SetDefaultExtension(pfsd
, null
);
633 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
635 /* SetDefaultFolder */
636 hr
= IFileOpenDialog_SetDefaultFolder(pfod
, NULL
);
637 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
638 hr
= IFileSaveDialog_SetDefaultFolder(pfsd
, NULL
);
639 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
641 hr
= IFileOpenDialog_SetDefaultFolder(pfod
, psidesktop
);
642 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
643 hr
= IFileSaveDialog_SetDefaultFolder(pfsd
, psidesktop
);
644 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
648 /* Crashes under Windows 7 */
649 IFileOpenDialog_SetDefaultFolder(pfod
, (void*)0x1234);
650 IFileSaveDialog_SetDefaultFolder(pfsd
, (void*)0x1234);
653 /* GetFolder / SetFolder */
654 hr
= IFileOpenDialog_GetFolder(pfod
, NULL
);
655 ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
657 hr
= IFileOpenDialog_GetFolder(pfod
, &psi_original
);
658 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
661 hr
= IFileOpenDialog_SetFolder(pfod
, psidesktop
);
662 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
663 hr
= IFileOpenDialog_SetFolder(pfod
, psi_original
);
664 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
665 IShellItem_Release(psi_original
);
668 hr
= IFileSaveDialog_GetFolder(pfsd
, &psi_original
);
669 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
672 hr
= IFileSaveDialog_SetFolder(pfsd
, psidesktop
);
673 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
674 hr
= IFileSaveDialog_SetFolder(pfsd
, psi_original
);
675 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
676 IShellItem_Release(psi_original
);
682 /* Crashes under Windows 7 */
683 IFileOpenDialog_AddPlace(pfod
, NULL
, 0);
684 IFileSaveDialog_AddPlace(pfsd
, NULL
, 0);
689 hr
= IFileOpenDialog_AddPlace(pfod
, psidesktop
, FDAP_TOP
+ 1);
690 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
691 hr
= IFileOpenDialog_AddPlace(pfod
, psidesktop
, FDAP_BOTTOM
);
692 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
693 hr
= IFileOpenDialog_AddPlace(pfod
, psidesktop
, FDAP_TOP
);
694 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
696 hr
= IFileSaveDialog_AddPlace(pfsd
, psidesktop
, FDAP_TOP
+ 1);
697 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
698 hr
= IFileSaveDialog_AddPlace(pfsd
, psidesktop
, FDAP_BOTTOM
);
699 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
700 hr
= IFileSaveDialog_AddPlace(pfsd
, psidesktop
, FDAP_TOP
);
701 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
705 hr
= IFileOpenDialog_SetFileName(pfod
, NULL
);
706 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
707 hr
= IFileOpenDialog_SetFileName(pfod
, null
);
708 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
709 hr
= IFileOpenDialog_SetFileName(pfod
, txt
);
710 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
711 hr
= IFileOpenDialog_GetFileName(pfod
, &filename
);
712 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
713 ok(!lstrcmpW(filename
, txt
), "Strings do not match.\n");
714 CoTaskMemFree(filename
);
716 hr
= IFileSaveDialog_SetFileName(pfsd
, NULL
);
717 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
718 hr
= IFileSaveDialog_SetFileName(pfsd
, null
);
719 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
720 hr
= IFileSaveDialog_SetFileName(pfsd
, txt
);
721 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
722 hr
= IFileSaveDialog_GetFileName(pfsd
, &filename
);
723 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
724 ok(!lstrcmpW(filename
, txt
), "Strings do not match.\n");
725 CoTaskMemFree(filename
);
727 /* SetFileNameLabel */
728 hr
= IFileOpenDialog_SetFileNameLabel(pfod
, NULL
);
729 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
730 hr
= IFileOpenDialog_SetFileNameLabel(pfod
, null
);
731 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
732 hr
= IFileOpenDialog_SetFileNameLabel(pfod
, txt
);
733 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
735 hr
= IFileSaveDialog_SetFileNameLabel(pfsd
, NULL
);
736 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
737 hr
= IFileSaveDialog_SetFileNameLabel(pfsd
, null
);
738 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
739 hr
= IFileSaveDialog_SetFileNameLabel(pfsd
, txt
);
740 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
743 hr
= IFileOpenDialog_Close(pfod
, S_FALSE
);
744 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
745 hr
= IFileSaveDialog_Close(pfsd
, S_FALSE
);
746 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
748 /* SetOkButtonLabel */
749 hr
= IFileOpenDialog_SetOkButtonLabel(pfod
, NULL
);
750 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
751 hr
= IFileOpenDialog_SetOkButtonLabel(pfod
, null
);
752 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
753 hr
= IFileOpenDialog_SetOkButtonLabel(pfod
, txt
);
754 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
755 hr
= IFileSaveDialog_SetOkButtonLabel(pfsd
, NULL
);
756 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
757 hr
= IFileSaveDialog_SetOkButtonLabel(pfsd
, null
);
758 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
759 hr
= IFileSaveDialog_SetOkButtonLabel(pfsd
, txt
);
760 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
763 hr
= IFileOpenDialog_SetTitle(pfod
, NULL
);
764 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
765 hr
= IFileOpenDialog_SetTitle(pfod
, null
);
766 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
767 hr
= IFileOpenDialog_SetTitle(pfod
, txt
);
768 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
769 hr
= IFileSaveDialog_SetTitle(pfsd
, NULL
);
770 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
771 hr
= IFileSaveDialog_SetTitle(pfsd
, null
);
772 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
773 hr
= IFileSaveDialog_SetTitle(pfsd
, txt
);
774 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
776 /** IFileOpenDialog specific **/
781 /* Crashes under Windows 7 */
782 IFileOpenDialog_GetResults(pfod
, NULL
);
784 psia
= (void*)0xdeadbeef;
785 hr
= IFileOpenDialog_GetResults(pfod
, &psia
);
786 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
787 ok(psia
== NULL
, "got %p.\n", psia
);
789 /* GetSelectedItems */
792 /* Crashes under W2K8 */
793 hr
= IFileOpenDialog_GetSelectedItems(pfod
, NULL
);
794 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
795 psia
= (void*)0xdeadbeef;
796 hr
= IFileOpenDialog_GetSelectedItems(pfod
, &psia
);
797 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
798 ok(psia
== (void*)0xdeadbeef, "got %p.\n", psia
);
801 /** IFileSaveDialog specific **/
803 /* ApplyProperties */
806 /* Crashes under windows 7 */
807 IFileSaveDialog_ApplyProperties(pfsd
, NULL
, NULL
, NULL
, NULL
);
808 IFileSaveDialog_ApplyProperties(pfsd
, psidesktop
, NULL
, NULL
, NULL
);
812 hr
= IFileSaveDialog_GetProperties(pfsd
, NULL
);
813 todo_wine
ok(hr
== E_UNEXPECTED
, "got 0x%08x\n", hr
);
814 pps
= (void*)0xdeadbeef;
815 hr
= IFileSaveDialog_GetProperties(pfsd
, &pps
);
816 todo_wine
ok(hr
== E_UNEXPECTED
, "got 0x%08x\n", hr
);
817 ok(pps
== (void*)0xdeadbeef, "got %p\n", pps
);
822 /* Crashes under W2K8 */
823 hr
= IFileSaveDialog_SetProperties(pfsd
, NULL
);
824 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
827 /* SetCollectedProperties */
830 hr
= IFileSaveDialog_SetCollectedProperties(pfsd
, NULL
, TRUE
);
831 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
832 hr
= IFileSaveDialog_SetCollectedProperties(pfsd
, NULL
, FALSE
);
833 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
839 hr
= IFileSaveDialog_SetSaveAsItem(pfsd
, NULL
);
840 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
841 hr
= IFileSaveDialog_SetSaveAsItem(pfsd
, psidesktop
);
842 ok(hr
== MK_E_NOOBJECT
, "got 0x%08x\n", hr
);
847 hr
= IFileOpenDialog_QueryInterface(pfod
, &IID_IFileDialog2
, (void**)&pfd2
);
848 ok((hr
== S_OK
) || broken(hr
== E_NOINTERFACE
), "got 0x%08x\n", hr
);
851 /* SetCancelButtonLabel */
852 hr
= IFileDialog2_SetOkButtonLabel(pfd2
, NULL
);
853 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
854 hr
= IFileDialog2_SetOkButtonLabel(pfd2
, null
);
855 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
856 hr
= IFileDialog2_SetOkButtonLabel(pfd2
, txt
);
857 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
859 /* SetNavigationRoot */
862 hr
= IFileDialog2_SetNavigationRoot(pfd2
, NULL
);
863 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
864 hr
= IFileDialog2_SetNavigationRoot(pfd2
, psidesktop
);
865 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
868 IFileDialog2_Release(pfd2
);
871 hr
= IFileSaveDialog_QueryInterface(pfsd
, &IID_IFileDialog2
, (void**)&pfd2
);
872 ok((hr
== S_OK
) || broken(hr
== E_NOINTERFACE
), "got 0x%08x\n", hr
);
875 /* SetCancelButtonLabel */
876 hr
= IFileDialog2_SetOkButtonLabel(pfd2
, NULL
);
877 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
878 hr
= IFileDialog2_SetOkButtonLabel(pfd2
, null
);
879 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
880 hr
= IFileDialog2_SetOkButtonLabel(pfd2
, txt
);
881 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
883 /* SetNavigationRoot */
886 hr
= IFileDialog2_SetNavigationRoot(pfd2
, NULL
);
887 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
888 hr
= IFileDialog2_SetNavigationRoot(pfd2
, psidesktop
);
889 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
892 IFileDialog2_Release(pfd2
);
896 IShellItem_Release(psidesktop
);
897 ref
= IFileOpenDialog_Release(pfod
);
898 ok(!ref
, "Got refcount %d, should have been released.\n", ref
);
899 ref
= IFileSaveDialog_Release(pfsd
);
900 ok(!ref
, "Got refcount %d, should have been released.\n", ref
);
903 static void ensure_zero_events_(const char *file
, int line
, IFileDialogEventsImpl
*impl
)
905 ok_(file
, line
)(!impl
->OnFileOk
, "OnFileOk: %d\n", impl
->OnFileOk
);
906 ok_(file
, line
)(!impl
->OnFolderChanging
, "OnFolderChanging: %d\n", impl
->OnFolderChanging
);
907 ok_(file
, line
)(!impl
->OnFolderChange
, "OnFolderChange: %d\n", impl
->OnFolderChange
);
908 ok_(file
, line
)(!impl
->OnSelectionChange
, "OnSelectionChange: %d\n", impl
->OnSelectionChange
);
909 ok_(file
, line
)(!impl
->OnShareViolation
, "OnShareViolation: %d\n", impl
->OnShareViolation
);
910 ok_(file
, line
)(!impl
->OnTypeChange
, "OnTypeChange: %d\n", impl
->OnTypeChange
);
911 ok_(file
, line
)(!impl
->OnOverwrite
, "OnOverwrite: %d\n", impl
->OnOverwrite
);
912 impl
->OnFileOk
= impl
->OnFolderChanging
= impl
->OnFolderChange
= 0;
913 impl
->OnSelectionChange
= impl
->OnShareViolation
= impl
->OnTypeChange
= 0;
914 impl
->OnOverwrite
= 0;
916 #define ensure_zero_events(impl) ensure_zero_events_(__FILE__, __LINE__, impl)
918 static void test_advise_helper(IFileDialog
*pfd
)
920 IFileDialogEventsImpl
*pfdeimpl
;
921 IFileDialogEvents
*pfde
;
926 pfde
= IFileDialogEvents_Constructor();
927 pfdeimpl
= impl_from_IFileDialogEvents(pfde
);
929 hr
= IFileDialog_Advise(pfd
, NULL
, NULL
);
930 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
931 hr
= IFileDialog_Advise(pfd
, pfde
, NULL
);
932 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
933 hr
= IFileDialog_Advise(pfd
, NULL
, &cookie
[0]);
934 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
935 ok(pfdeimpl
->ref
== 1, "got ref %d\n", pfdeimpl
->ref
);
936 ensure_zero_events(pfdeimpl
);
938 hr
= IFileDialog_Unadvise(pfd
, 0);
939 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
940 for(i
= 0; i
< 10; i
++) {
941 hr
= IFileDialog_Advise(pfd
, pfde
, &cookie
[i
]);
942 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
943 ok(cookie
[i
] == i
+1, "Got cookie: %d\n", cookie
[i
]);
945 ok(pfdeimpl
->ref
== 10+1, "got ref %d\n", pfdeimpl
->ref
);
946 ensure_zero_events(pfdeimpl
);
948 for(i
= 3; i
< 7; i
++) {
949 hr
= IFileDialog_Unadvise(pfd
, cookie
[i
]);
950 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
952 ok(pfdeimpl
->ref
== 6+1, "got ref %d\n", pfdeimpl
->ref
);
953 ensure_zero_events(pfdeimpl
);
955 for(i
= 0; i
< 3; i
++) {
956 hr
= IFileDialog_Unadvise(pfd
, cookie
[i
]);
957 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
959 ok(pfdeimpl
->ref
== 3+1, "got ref %d\n", pfdeimpl
->ref
);
960 ensure_zero_events(pfdeimpl
);
962 for(i
= 7; i
< 10; i
++) {
963 hr
= IFileDialog_Unadvise(pfd
, cookie
[i
]);
964 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
966 ok(pfdeimpl
->ref
== 1, "got ref %d\n", pfdeimpl
->ref
);
967 ensure_zero_events(pfdeimpl
);
969 hr
= IFileDialog_Unadvise(pfd
, cookie
[9]+1);
970 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
971 ok(pfdeimpl
->ref
== 1, "got ref %d\n", pfdeimpl
->ref
);
972 ensure_zero_events(pfdeimpl
);
974 hr
= IFileDialog_Advise(pfd
, pfde
, &cookie
[0]);
975 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
976 todo_wine
ok(cookie
[0] == 1, "got cookie: %d\n", cookie
[0]);
977 ok(pfdeimpl
->ref
== 1+1, "got ref %d\n", pfdeimpl
->ref
);
978 ensure_zero_events(pfdeimpl
);
980 hr
= IFileDialog_Unadvise(pfd
, cookie
[0]);
984 /* Unadvising already unadvised cookies crashes on
986 IFileDialog_Unadvise(pfd
, cookie
[0]);
990 IFileDialogEvents_Release(pfde
);
993 static void test_advise(void)
999 trace("Testing FileOpenDialog (advise)\n");
1000 hr
= CoCreateInstance(&CLSID_FileOpenDialog
, NULL
, CLSCTX_INPROC_SERVER
,
1001 &IID_IFileDialog
, (void**)&pfd
);
1002 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1003 test_advise_helper(pfd
);
1004 ref
= IFileDialog_Release(pfd
);
1005 ok(!ref
, "Got refcount %d, should have been released.\n", ref
);
1007 trace("Testing FileSaveDialog (advise)\n");
1008 hr
= CoCreateInstance(&CLSID_FileSaveDialog
, NULL
, CLSCTX_INPROC_SERVER
,
1009 &IID_IFileDialog
, (void**)&pfd
);
1010 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1011 test_advise_helper(pfd
);
1012 ref
= IFileDialog_Release(pfd
);
1013 ok(!ref
, "Got refcount %d, should have been released.\n", ref
);
1016 static void touch_file(LPCWSTR filename
)
1019 file
= CreateFileW(filename
, GENERIC_WRITE
, 0, NULL
, CREATE_NEW
, FILE_ATTRIBUTE_NORMAL
, NULL
);
1020 ok(file
!= INVALID_HANDLE_VALUE
, "Failed to create file.\n");
1024 static void test_filename_savedlg_(LPCWSTR set_filename
, LPCWSTR defext
,
1025 const COMDLG_FILTERSPEC
*filterspec
, UINT fs_count
,
1026 LPCWSTR exp_filename
, const char *file
, int line
)
1028 IFileSaveDialog
*pfsd
;
1029 IFileDialogEventsImpl
*pfdeimpl
;
1030 IFileDialogEvents
*pfde
;
1037 hr
= CoCreateInstance(&CLSID_FileSaveDialog
, NULL
, CLSCTX_INPROC_SERVER
,
1038 &IID_IFileSaveDialog
, (void**)&pfsd
);
1039 ok_(file
,line
)(hr
== S_OK
, "Got 0x%08x\n", hr
);
1043 hr
= IFileSaveDialog_SetFileTypes(pfsd
, fs_count
, filterspec
);
1044 ok_(file
,line
)(hr
== S_OK
, "SetFileTypes failed: Got 0x%08x\n", hr
);
1049 hr
= IFileSaveDialog_SetDefaultExtension(pfsd
, defext
);
1050 ok_(file
,line
)(hr
== S_OK
, "SetDefaultExtensions failed: Got 0x%08x\n", hr
);
1053 pfde
= IFileDialogEvents_Constructor();
1054 pfdeimpl
= impl_from_IFileDialogEvents(pfde
);
1055 pfdeimpl
->set_filename
= set_filename
;
1056 hr
= IFileSaveDialog_Advise(pfsd
, pfde
, &cookie
);
1057 ok_(file
,line
)(hr
== S_OK
, "Advise failed: Got 0x%08x\n", hr
);
1059 hr
= IFileSaveDialog_Show(pfsd
, NULL
);
1060 ok_(file
,line
)(hr
== S_OK
, "Show failed: Got 0x%08x\n", hr
);
1062 hr
= IFileSaveDialog_GetFileName(pfsd
, &filename
);
1063 ok_(file
,line
)(hr
== S_OK
, "GetFileName failed: Got 0x%08x\n", hr
);
1064 ok_(file
,line
)(!lstrcmpW(filename
, set_filename
), "Got %s\n", wine_dbgstr_w(filename
));
1065 CoTaskMemFree(filename
);
1067 hr
= IFileSaveDialog_GetResult(pfsd
, &psi
);
1068 ok_(file
,line
)(hr
== S_OK
, "GetResult failed: Got 0x%08x\n", hr
);
1070 hr
= IShellItem_GetDisplayName(psi
, SIGDN_PARENTRELATIVEPARSING
, &filename
);
1071 ok_(file
,line
)(hr
== S_OK
, "GetDisplayName failed: Got 0x%08x\n", hr
);
1072 ok_(file
,line
)(!lstrcmpW(filename
, exp_filename
), "(GetDisplayName) Got %s\n", wine_dbgstr_w(filename
));
1073 CoTaskMemFree(filename
);
1074 IShellItem_Release(psi
);
1076 hr
= IFileSaveDialog_Unadvise(pfsd
, cookie
);
1077 ok_(file
,line
)(hr
== S_OK
, "Unadvise failed: Got 0x%08x\n", hr
);
1079 ref
= IFileSaveDialog_Release(pfsd
);
1080 ok_(file
,line
)(!ref
, "Got refcount %d, should have been released.\n", ref
);
1082 IFileDialogEvents_Release(pfde
);
1084 #define test_filename_savedlg(set_filename, defext, filterspec, fs_count, exp_filename) \
1085 test_filename_savedlg_(set_filename, defext, filterspec, fs_count, exp_filename, __FILE__, __LINE__)
1087 static void test_filename_opendlg_(LPCWSTR set_filename
, IShellItem
*psi_current
, LPCWSTR defext
,
1088 const COMDLG_FILTERSPEC
*filterspec
, UINT fs_count
,
1089 LPCWSTR exp_filename
, const char *file
, int line
)
1091 IFileOpenDialog
*pfod
;
1092 IFileDialogEventsImpl
*pfdeimpl
;
1093 IFileDialogEvents
*pfde
;
1096 IShellItemArray
*psia
;
1101 hr
= CoCreateInstance(&CLSID_FileOpenDialog
, NULL
, CLSCTX_INPROC_SERVER
,
1102 &IID_IFileOpenDialog
, (void**)&pfod
);
1103 ok_(file
,line
)(hr
== S_OK
, "CoCreateInstance failed: Got 0x%08x\n", hr
);
1107 hr
= IFileOpenDialog_SetDefaultExtension(pfod
, defext
);
1108 ok_(file
,line
)(hr
== S_OK
, "SetDefaultExtensions failed: Got 0x%08x\n", hr
);
1113 hr
= IFileOpenDialog_SetFileTypes(pfod
, 2, filterspec
);
1114 ok_(file
,line
)(hr
== S_OK
, "SetFileTypes failed: Got 0x%08x\n", hr
);
1117 hr
= IFileOpenDialog_SetFolder(pfod
, psi_current
);
1118 ok_(file
,line
)(hr
== S_OK
, "SetFolder failed: Got 0x%08x\n", hr
);
1120 pfde
= IFileDialogEvents_Constructor();
1121 pfdeimpl
= impl_from_IFileDialogEvents(pfde
);
1122 pfdeimpl
->set_filename
= set_filename
;
1123 pfdeimpl
->set_filename_tried
= FALSE
;
1124 hr
= IFileOpenDialog_Advise(pfod
, pfde
, &cookie
);
1125 ok_(file
,line
)(hr
== S_OK
, "Advise failed: Got 0x%08x\n", hr
);
1127 hr
= IFileOpenDialog_Show(pfod
, NULL
);
1128 ok_(file
,line
)(hr
== S_OK
|| (!exp_filename
&& hr
== HRESULT_FROM_WIN32(ERROR_CANCELLED
)),
1129 "Show failed: Got 0x%08x\n", hr
);
1132 hr
= IFileOpenDialog_GetResult(pfod
, &psi
);
1133 ok_(file
,line
)(hr
== S_OK
, "GetResult failed: Got 0x%08x\n", hr
);
1135 hr
= IShellItem_GetDisplayName(psi
, SIGDN_PARENTRELATIVEPARSING
, &filename
);
1136 ok_(file
,line
)(hr
== S_OK
, "GetDisplayName(Result) failed: Got 0x%08x\n", hr
);
1137 ok_(file
,line
)(!lstrcmpW(filename
, exp_filename
), "(GetResult) Got %s\n", wine_dbgstr_w(filename
));
1138 CoTaskMemFree(filename
);
1139 IShellItem_Release(psi
);
1141 hr
= IFileOpenDialog_GetResults(pfod
, &psia
);
1142 ok_(file
,line
)(hr
== S_OK
, "GetResults failed: Got 0x%08x\n", hr
);
1143 hr
= IShellItemArray_GetItemAt(psia
, 0, &psi
);
1144 ok_(file
,line
)(hr
== S_OK
, "GetItemAt failed: Got 0x%08x\n", hr
);
1146 hr
= IShellItem_GetDisplayName(psi
, SIGDN_PARENTRELATIVEPARSING
, &filename
);
1147 ok_(file
,line
)(hr
== S_OK
, "GetDisplayName(Results) failed: Got 0x%08x\n", hr
);
1148 ok_(file
,line
)(!lstrcmpW(filename
, exp_filename
), "(GetResults) Got %s\n", wine_dbgstr_w(filename
));
1149 CoTaskMemFree(filename
);
1151 IShellItem_Release(psi
);
1152 IShellItemArray_Release(psia
);
1156 hr
= IFileOpenDialog_GetResult(pfod
, &psi
);
1157 ok_(file
,line
)(hr
== E_UNEXPECTED
, "GetResult: Got 0x%08x\n", hr
);
1159 hr
= IFileOpenDialog_GetResults(pfod
, &psia
);
1160 ok_(file
,line
)(hr
== E_FAIL
, "GetResults: Got 0x%08x\n", hr
);
1163 hr
= IFileOpenDialog_GetFileName(pfod
, &filename
);
1164 ok_(file
,line
)(hr
== S_OK
, "GetFileName failed: Got 0x%08x\n", hr
);
1165 ok_(file
,line
)(!lstrcmpW(filename
, set_filename
), "(GetFileName) Got %s\n", wine_dbgstr_w(filename
));
1166 CoTaskMemFree(filename
);
1169 hr
= IFileOpenDialog_Unadvise(pfod
, cookie
);
1170 ok_(file
,line
)(hr
== S_OK
, "Unadvise failed: Got 0x%08x\n", hr
);
1172 ref
= IFileOpenDialog_Release(pfod
);
1173 ok_(file
,line
)(!ref
, "Got refcount %d, should have been released.\n", ref
);
1175 IFileDialogEvents_Release(pfde
);
1177 #define test_filename_opendlg(set_filename, psi, defext, filterspec, fs_count, exp_filename) \
1178 test_filename_opendlg_(set_filename, psi, defext, filterspec, fs_count, exp_filename, __FILE__, __LINE__)
1180 static void test_filename(void)
1182 IShellItem
*psi_current
;
1184 WCHAR buf
[MAX_PATH
];
1186 static const WCHAR filename_noextW
[] = {'w','i','n','e','t','e','s','t',0};
1187 static const WCHAR filename_dotextW
[] = {'w','i','n','e','t','e','s','t','.',0};
1188 static const WCHAR filename_dotanddefW
[] = {'w','i','n','e','t','e','s','t','.','.','w','t','e',0};
1189 static const WCHAR filename_defextW
[] = {'w','i','n','e','t','e','s','t','.','w','t','e',0};
1190 static const WCHAR filename_ext1W
[] = {'w','i','n','e','t','e','s','t','.','w','t','1',0};
1191 static const WCHAR filename_ext2W
[] = {'w','i','n','e','t','e','s','t','.','w','t','2',0};
1192 static const WCHAR filename_ext1anddefW
[] =
1193 {'w','i','n','e','t','e','s','t','.','w','t','1','.','w','t','e',0};
1194 static const WCHAR defextW
[] = {'w','t','e',0};
1195 static const WCHAR desc1
[] = {'d','e','s','c','r','i','p','t','i','o','n','1',0};
1196 static const WCHAR desc2
[] = {'d','e','s','c','r','i','p','t','i','o','n','2',0};
1197 static const WCHAR descdef
[] = {'d','e','f','a','u','l','t',' ','d','e','s','c',0};
1198 static const WCHAR ext1
[] = {'*','.','w','t','1',0};
1199 static const WCHAR ext2
[] = {'*','.','w','t','2',0};
1200 static const WCHAR extdef
[] = {'*','.','w','t','e',0};
1201 static const WCHAR complexext
[] = {'*','.','w','t','2',';','*','.','w','t','1',0};
1203 static const COMDLG_FILTERSPEC filterspec
[] = {
1204 { desc1
, ext1
}, { desc2
, ext2
}, { descdef
, extdef
}
1206 static const COMDLG_FILTERSPEC filterspec2
[] = {
1207 { desc1
, complexext
}
1211 test_filename_savedlg(filename_noextW
, NULL
, NULL
, 0, filename_noextW
);
1212 /* Default extension */
1213 test_filename_savedlg(filename_noextW
, defextW
, NULL
, 0, filename_defextW
);
1214 /* Default extension on filename ending with a . */
1215 test_filename_savedlg(filename_dotextW
, defextW
, NULL
, 0, filename_dotanddefW
);
1216 /* Default extension on filename with default extension */
1217 test_filename_savedlg(filename_defextW
, defextW
, NULL
, 0, filename_defextW
);
1218 /* Default extension on filename with another extension */
1219 test_filename_savedlg(filename_ext1W
, defextW
, NULL
, 0, filename_ext1anddefW
);
1220 /* Default extension, filterspec without default extension */
1221 test_filename_savedlg(filename_noextW
, defextW
, filterspec
, 2, filename_ext1W
);
1222 /* Default extension, filterspec with default extension */
1223 test_filename_savedlg(filename_noextW
, defextW
, filterspec
, 3, filename_ext1W
);
1224 /* Default extension, filterspec with "complex" extension */
1225 test_filename_savedlg(filename_noextW
, defextW
, filterspec2
, 1, filename_ext2W
);
1227 GetCurrentDirectoryW(MAX_PATH
, buf
);
1228 ok(!!pSHCreateItemFromParsingName
, "SHCreateItemFromParsingName is missing.\n");
1229 hr
= pSHCreateItemFromParsingName(buf
, NULL
, &IID_IShellItem
, (void**)&psi_current
);
1230 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
1232 touch_file(filename_noextW
);
1233 touch_file(filename_defextW
);
1234 touch_file(filename_ext2W
);
1236 /* IFileOpenDialog, default extension */
1237 test_filename_opendlg(filename_noextW
, psi_current
, defextW
, NULL
, 0, filename_noextW
);
1238 /* IFileOpenDialog, default extension and filterspec */
1239 test_filename_opendlg(filename_noextW
, psi_current
, defextW
, filterspec
, 2, filename_noextW
);
1241 DeleteFileW(filename_noextW
);
1242 /* IFileOpenDialog, default extension, noextW deleted */
1243 test_filename_opendlg(filename_noextW
, psi_current
, defextW
, NULL
, 0, filename_defextW
);
1244 if(0) /* Interactive */
1246 /* IFileOpenDialog, filterspec, no default extension, noextW deleted */
1247 test_filename_opendlg(filename_noextW
, psi_current
, NULL
, filterspec
, 2, NULL
);
1250 IShellItem_Release(psi_current
);
1251 DeleteFileW(filename_defextW
);
1252 DeleteFileW(filename_ext2W
);
1255 static const WCHAR label
[] = {'l','a','b','e','l',0};
1256 static const WCHAR label2
[] = {'t','e','s','t',0};
1257 static const WCHAR menuW
[] = {'m','e','n','u','_','i','t','e','m',0};
1258 static const WCHAR pushbutton1W
[] = {'p','u','s','h','b','u','t','t','o','n','_','i','t','e','m',0};
1259 static const WCHAR pushbutton2W
[] = {'p','u','s','h','b','u','t','t','o','n','2','_','i','t','e','m',0};
1260 static const WCHAR comboboxitem1W
[] = {'c','o','m','b','o','b','o','x','1','_','i','t','e','m',0};
1261 static const WCHAR comboboxitem2W
[] = {'c','o','m','b','o','b','o','x','2','_','i','t','e','m',0};
1262 static const WCHAR radiobutton1W
[] = {'r','a','d','i','o','b','u','t','t','o','n','1','_','i','t','e','m',0};
1263 static const WCHAR radiobutton2W
[] = {'r','a','d','i','o','b','u','t','t','o','n','2','_','i','t','e','m',0};
1264 static const WCHAR checkbutton1W
[] = {'c','h','e','c','k','b','u','t','t','o','n','1','_','i','t','e','m',0};
1265 static const WCHAR checkbutton2W
[] = {'c','h','e','c','k','b','u','t','t','o','n','2','_','i','t','e','m',0};
1266 static const WCHAR editbox1W
[] = {'e','d','i','t','b','o','x','W','1','_','i','t','e','m',0};
1267 static const WCHAR editbox2W
[] = {'e','d','i','t','b','o','x','W','2','_','i','t','e','m',0};
1268 static const WCHAR textW
[] = {'t','e','x','t','_','i','t','e','m',0};
1269 static const WCHAR text2W
[] = {'t','e','x','t','2','_','i','t','e','m',0};
1270 static const WCHAR separatorW
[] = {'s','e','p','a','r','a','t','o','r','_','i','t','e','m',0};
1271 static const WCHAR visualgroup1W
[] = {'v','i','s','u','a','l','g','r','o','u','p','1',0};
1272 static const WCHAR visualgroup2W
[] = {'v','i','s','u','a','l','g','r','o','u','p','2',0};
1274 static const WCHAR floatnotifysinkW
[] = {'F','l','o','a','t','N','o','t','i','f','y','S','i','n','k',0};
1275 static const WCHAR RadioButtonListW
[] = {'R','a','d','i','o','B','u','t','t','o','n','L','i','s','t',0};
1278 LPCWSTR
class, text
;
1281 static BOOL CALLBACK
find_window_callback(HWND hwnd
, LPARAM lparam
)
1283 struct fw_arg
*arg
= (struct fw_arg
*)lparam
;
1288 GetClassNameW(hwnd
, buf
, 1024);
1289 if(lstrcmpW(buf
, arg
->class))
1295 GetWindowTextW(hwnd
, buf
, 1024);
1296 if(lstrcmpW(buf
, arg
->text
))
1300 arg
->hwnd_res
= hwnd
;
1304 static HWND
find_window(HWND parent
, LPCWSTR
class, LPCWSTR text
)
1306 struct fw_arg arg
= {class, text
, NULL
};
1308 EnumChildWindows(parent
, find_window_callback
, (LPARAM
)&arg
);
1309 return arg
.hwnd_res
;
1312 static void test_customize_onfolderchange(IFileDialog
*pfd
)
1315 HWND dlg_hwnd
, item
, item_parent
;
1322 hr
= IFileDialog_QueryInterface(pfd
, &IID_IOleWindow
, (void**)&pow
);
1323 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
1324 hr
= IOleWindow_GetWindow(pow
, &dlg_hwnd
);
1325 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
1326 ok(dlg_hwnd
!= NULL
, "Got NULL.\n");
1327 IOleWindow_Release(pow
);
1329 item
= find_window(dlg_hwnd
, NULL
, checkbutton2W
);
1330 ok(item
!= NULL
, "Failed to find item.\n");
1331 item_parent
= GetParent(item
);
1332 GetClassNameW(item_parent
, buf
, 1024);
1333 ok(!lstrcmpW(buf
, floatnotifysinkW
), "Got %s\n", wine_dbgstr_w(buf
));
1334 item
= find_window(dlg_hwnd
, NULL
, text2W
);
1335 ok(item
!= NULL
, "Failed to find item.\n");
1336 item_parent
= GetParent(item
);
1337 GetClassNameW(item_parent
, buf
, 1024);
1338 ok(!lstrcmpW(buf
, floatnotifysinkW
), "Got %s\n", wine_dbgstr_w(buf
));
1339 item
= find_window(dlg_hwnd
, NULL
, radiobutton1W
);
1340 todo_wine
ok(item
!= NULL
, "Failed to find item.\n");
1341 item_parent
= GetParent(item
);
1342 GetClassNameW(item_parent
, buf
, 1024);
1343 todo_wine
ok(!lstrcmpW(buf
, RadioButtonListW
), "Got %s\n", wine_dbgstr_w(buf
));
1344 item_parent
= GetParent(item_parent
);
1345 GetClassNameW(item_parent
, buf
, 1024);
1346 ok(!lstrcmpW(buf
, floatnotifysinkW
), "Got %s\n", wine_dbgstr_w(buf
));
1348 item
= find_window(dlg_hwnd
, NULL
, pushbutton1W
);
1349 ok(item
== NULL
, "Found item: %p\n", item
);
1350 item
= find_window(dlg_hwnd
, NULL
, pushbutton2W
);
1351 ok(item
== NULL
, "Found item: %p\n", item
);
1352 item
= find_window(dlg_hwnd
, NULL
, comboboxitem1W
);
1353 ok(item
== NULL
, "Found item: %p\n", item
);
1354 item
= find_window(dlg_hwnd
, NULL
, comboboxitem2W
);
1355 ok(item
== NULL
, "Found item: %p\n", item
);
1356 item
= find_window(dlg_hwnd
, NULL
, radiobutton2W
);
1357 ok(item
== NULL
, "Found item: %p\n", item
);
1358 item
= find_window(dlg_hwnd
, NULL
, checkbutton1W
);
1359 ok(item
== NULL
, "Found item: %p\n", item
);
1360 item
= find_window(dlg_hwnd
, NULL
, editbox1W
);
1361 ok(item
== NULL
, "Found item: %p\n", item
);
1362 item
= find_window(dlg_hwnd
, NULL
, editbox2W
);
1363 ok(item
== NULL
, "Found item: %p\n", item
);
1364 item
= find_window(dlg_hwnd
, NULL
, textW
);
1365 ok(item
== NULL
, "Found item: %p\n", item
);
1366 item
= find_window(dlg_hwnd
, NULL
, separatorW
);
1367 ok(item
== NULL
, "Found item: %p\n", item
);
1368 item
= find_window(dlg_hwnd
, NULL
, visualgroup1W
);
1369 ok(item
== NULL
, "Found item: %p\n", item
);
1370 item
= find_window(dlg_hwnd
, NULL
, visualgroup2W
);
1371 ok(item
== NULL
, "Found item: %p\n", item
);
1373 br
= PostMessageW(dlg_hwnd
, WM_COMMAND
, IDCANCEL
, 0);
1377 static void test_customize(void)
1380 IFileDialogCustomize
*pfdc
;
1381 IFileDialogEventsImpl
*pfdeimpl
;
1382 IFileDialogEvents
*pfde
;
1384 CDCONTROLSTATEF cdstate
;
1391 hr
= CoCreateInstance(&CLSID_FileOpenDialog
, NULL
, CLSCTX_INPROC_SERVER
,
1392 &IID_IFileDialog
, (void**)&pfod
);
1393 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1395 hr
= IFileDialog_QueryInterface(pfod
, &IID_IFileDialogCustomize
, (void**)&pfdc
);
1396 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1399 skip("Skipping IFileDialogCustomize tests.\n");
1400 IFileDialog_Release(pfod
);
1405 hr
= IFileDialogCustomize_AddPushButton(pfdc
, i
, pushbutton1W
);
1406 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1407 hr
= IFileDialogCustomize_AddPushButton(pfdc
, i
, pushbutton1W
);
1408 ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
1410 hr
= IFileDialog_QueryInterface(pfod
, &IID_IOleWindow
, (void**)&pow
);
1411 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
1412 hr
= IOleWindow_GetWindow(pow
, &dlg_hwnd
);
1413 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
1414 ok(dlg_hwnd
== NULL
, "NULL\n");
1415 IOleWindow_Release(pow
);
1417 cdstate
= 0xdeadbeef;
1418 hr
= IFileDialogCustomize_GetControlState(pfdc
, i
, &cdstate
);
1419 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1420 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1422 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, 0, label
);
1423 ok(hr
== E_NOINTERFACE
, "got 0x%08x.\n", hr
);
1425 hr
= IFileDialogCustomize_SetControlLabel(pfdc
, i
, label2
);
1426 ok(hr
== S_OK
, "got 0x%08x (control: %d).\n", hr
, i
);
1428 hr
= IFileDialogCustomize_EnableOpenDropDown(pfdc
, i
);
1429 todo_wine
ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
1430 hr
= IFileDialogCustomize_EnableOpenDropDown(pfdc
, ++i
);
1431 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1433 cdstate
= 0xdeadbeef;
1434 hr
= IFileDialogCustomize_GetControlState(pfdc
, i
, &cdstate
);
1435 ok(hr
== E_NOTIMPL
, "got 0x%08x.\n", hr
);
1436 ok(cdstate
== 0xdeadbeef, "got 0x%08x.\n", cdstate
);
1438 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, 0, label
);
1439 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1440 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, 0, label
);
1441 todo_wine
ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
1443 cdstate
= 0xdeadbeef;
1444 hr
= IFileDialogCustomize_GetControlItemState(pfdc
, i
, 0, &cdstate
);
1445 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1446 todo_wine
ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1447 hr
= IFileDialogCustomize_SetControlItemState(pfdc
, i
, 0, 0);
1448 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1449 cdstate
= 0xdeadbeef;
1450 hr
= IFileDialogCustomize_GetControlItemState(pfdc
, i
, 0, &cdstate
);
1451 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1452 todo_wine
ok(!cdstate
, "got 0x%08x.\n", cdstate
);
1453 hr
= IFileDialogCustomize_SetControlItemState(pfdc
, i
, 0, CDCS_ENABLEDVISIBLE
);
1454 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1455 cdstate
= 0xdeadbeef;
1456 hr
= IFileDialogCustomize_GetControlItemState(pfdc
, i
, 0, &cdstate
);
1457 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1458 todo_wine
ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1460 hr
= IFileDialogCustomize_SetControlLabel(pfdc
, i
, label2
);
1461 todo_wine
ok(hr
== E_NOTIMPL
, "got 0x%08x (control: %d).\n", hr
, i
);
1463 hr
= IFileDialogCustomize_AddMenu(pfdc
, i
, menuW
);
1464 todo_wine
ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
1465 hr
= IFileDialogCustomize_AddMenu(pfdc
, ++i
, label
);
1466 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1468 cdstate
= 0xdeadbeef;
1469 hr
= IFileDialogCustomize_GetControlState(pfdc
, i
, &cdstate
);
1470 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1471 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1473 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, 0, label
);
1474 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1475 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, 0, label
);
1476 ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
1478 hr
= IFileDialogCustomize_SetControlLabel(pfdc
, i
, label2
);
1479 ok(hr
== S_OK
, "got 0x%08x (control: %d).\n", hr
, i
);
1481 hr
= IFileDialogCustomize_AddPushButton(pfdc
, i
, pushbutton2W
);
1482 ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
1483 hr
= IFileDialogCustomize_AddPushButton(pfdc
, ++i
, pushbutton2W
);
1484 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1486 cdstate
= 0xdeadbeef;
1487 hr
= IFileDialogCustomize_GetControlState(pfdc
, i
, &cdstate
);
1488 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1489 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1491 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, 0, label
);
1492 ok(hr
== E_NOINTERFACE
, "got 0x%08x.\n", hr
);
1494 hr
= IFileDialogCustomize_SetControlLabel(pfdc
, i
, label2
);
1495 ok(hr
== S_OK
, "got 0x%08x (control: %d).\n", hr
, i
);
1497 hr
= IFileDialogCustomize_AddComboBox(pfdc
, i
);
1498 ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
1499 hr
= IFileDialogCustomize_AddComboBox(pfdc
, ++i
);
1500 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1502 cdstate
= 0xdeadbeef;
1503 hr
= IFileDialogCustomize_GetControlState(pfdc
, i
, &cdstate
);
1504 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1505 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1507 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, 0, label
);
1508 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1509 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, 0, label
);
1510 ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
1512 hr
= IFileDialogCustomize_SetControlLabel(pfdc
, i
, label2
);
1513 ok(hr
== S_OK
, "got 0x%08x (control: %d).\n", hr
, i
);
1515 hr
= IFileDialogCustomize_AddRadioButtonList(pfdc
, i
);
1516 todo_wine
ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
1517 hr
= IFileDialogCustomize_AddRadioButtonList(pfdc
, ++i
);
1518 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1520 cdstate
= 0xdeadbeef;
1521 hr
= IFileDialogCustomize_GetControlState(pfdc
, i
, &cdstate
);
1522 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1523 todo_wine
ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1525 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, 0, radiobutton1W
);
1526 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1527 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, 0, radiobutton1W
);
1528 todo_wine
ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
1530 hr
= IFileDialogCustomize_SetControlLabel(pfdc
, i
, radiobutton2W
);
1531 todo_wine
ok(hr
== S_OK
, "got 0x%08x (control: %d).\n", hr
, i
);
1533 hr
= IFileDialogCustomize_AddCheckButton(pfdc
, i
, label
, TRUE
);
1534 todo_wine
ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
1535 hr
= IFileDialogCustomize_AddCheckButton(pfdc
, ++i
, checkbutton1W
, TRUE
);
1536 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1538 cdstate
= 0xdeadbeef;
1539 hr
= IFileDialogCustomize_GetControlState(pfdc
, i
, &cdstate
);
1540 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1541 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1543 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, 0, label
);
1544 ok(hr
== E_NOINTERFACE
, "got 0x%08x.\n", hr
);
1546 hr
= IFileDialogCustomize_SetControlLabel(pfdc
, i
, checkbutton2W
);
1547 ok(hr
== S_OK
, "got 0x%08x (control: %d).\n", hr
, i
);
1552 hr
= IFileDialogCustomize_GetCheckButtonState(pfdc
, i
, &checked
);
1553 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1554 ok(checked
, "checkbox not checked.\n");
1556 hr
= IFileDialogCustomize_SetCheckButtonState(pfdc
, i
, FALSE
);
1557 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1559 hr
= IFileDialogCustomize_GetCheckButtonState(pfdc
, i
, &checked
);
1560 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1561 ok(!checked
, "checkbox checked.\n");
1563 hr
= IFileDialogCustomize_SetCheckButtonState(pfdc
, i
, TRUE
);
1564 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1566 hr
= IFileDialogCustomize_GetCheckButtonState(pfdc
, i
, &checked
);
1567 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1568 ok(checked
, "checkbox not checked.\n");
1571 hr
= IFileDialogCustomize_AddEditBox(pfdc
, i
, label
);
1572 ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
1573 hr
= IFileDialogCustomize_AddEditBox(pfdc
, ++i
, editbox1W
);
1574 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1576 cdstate
= 0xdeadbeef;
1577 hr
= IFileDialogCustomize_GetControlState(pfdc
, i
, &cdstate
);
1578 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1579 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1581 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, 0, label
);
1582 ok(hr
== E_NOINTERFACE
, "got 0x%08x.\n", hr
);
1584 /* Does not affect the text in the editbox */
1585 hr
= IFileDialogCustomize_SetControlLabel(pfdc
, i
, editbox2W
);
1586 ok(hr
== S_OK
, "got 0x%08x (control: %d).\n", hr
, i
);
1588 hr
= IFileDialogCustomize_GetEditBoxText(pfdc
, i
, &tmpstr
);
1589 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1592 ok(!lstrcmpW(tmpstr
, editbox1W
), "got %s.\n", wine_dbgstr_w(tmpstr
));
1593 CoTaskMemFree(tmpstr
);
1596 hr
= IFileDialogCustomize_SetEditBoxText(pfdc
, i
, label2
);
1597 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1599 hr
= IFileDialogCustomize_GetEditBoxText(pfdc
, i
, &tmpstr
);
1600 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1603 ok(!lstrcmpW(tmpstr
, label2
), "got %s.\n", wine_dbgstr_w(tmpstr
));
1604 CoTaskMemFree(tmpstr
);
1607 hr
= IFileDialogCustomize_AddSeparator(pfdc
, i
);
1608 ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
1609 hr
= IFileDialogCustomize_AddSeparator(pfdc
, ++i
);
1610 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1612 cdstate
= 0xdeadbeef;
1613 hr
= IFileDialogCustomize_GetControlState(pfdc
, i
, &cdstate
);
1614 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1615 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1617 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, 0, label
);
1618 ok(hr
== E_NOINTERFACE
, "got 0x%08x.\n", hr
);
1620 hr
= IFileDialogCustomize_SetControlLabel(pfdc
, i
, separatorW
);
1621 ok(hr
== S_OK
, "got 0x%08x (control: %d).\n", hr
, i
);
1623 hr
= IFileDialogCustomize_AddText(pfdc
, i
, label
);
1624 ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
1625 hr
= IFileDialogCustomize_AddText(pfdc
, ++i
, textW
);
1626 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1628 cdstate
= 0xdeadbeef;
1629 hr
= IFileDialogCustomize_GetControlState(pfdc
, i
, &cdstate
);
1630 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1631 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1633 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, 0, label
);
1634 ok(hr
== E_NOINTERFACE
, "got 0x%08x.\n", hr
);
1636 hr
= IFileDialogCustomize_SetControlLabel(pfdc
, i
, text2W
);
1637 ok(hr
== S_OK
, "got 0x%08x (control: %d).\n", hr
, i
);
1639 hr
= IFileDialogCustomize_StartVisualGroup(pfdc
, i
, label
);
1640 todo_wine
ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
1641 hr
= IFileDialogCustomize_StartVisualGroup(pfdc
, ++i
, visualgroup1W
);
1642 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1644 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, 0, label
);
1645 todo_wine
ok(hr
== E_NOINTERFACE
, "got 0x%08x.\n", hr
);
1647 hr
= IFileDialogCustomize_SetControlLabel(pfdc
, i
, visualgroup2W
);
1648 todo_wine
ok(hr
== S_OK
, "got 0x%08x (control: %d).\n", hr
, i
);
1650 cdstate
= 0xdeadbeef;
1651 hr
= IFileDialogCustomize_GetControlState(pfdc
, i
, &cdstate
);
1652 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1653 todo_wine
ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1655 hr
= IFileDialogCustomize_StartVisualGroup(pfdc
, ++i
, label
);
1656 todo_wine
ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
1657 hr
= IFileDialogCustomize_EndVisualGroup(pfdc
);
1658 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1660 i
++; /* Nonexisting control */
1661 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, 0, label
);
1662 todo_wine
ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
1663 hr
= IFileDialogCustomize_SetControlLabel(pfdc
, i
, label2
);
1664 ok(hr
== E_INVALIDARG
, "got 0x%08x (control: %d).\n", hr
, i
);
1665 cdstate
= 0xdeadbeef;
1666 hr
= IFileDialogCustomize_GetControlState(pfdc
, i
, &cdstate
);
1667 todo_wine
ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
1668 ok(cdstate
== 0xdeadbeef, "got 0x%08x.\n", cdstate
);
1670 pfde
= IFileDialogEvents_Constructor();
1671 pfdeimpl
= impl_from_IFileDialogEvents(pfde
);
1672 pfdeimpl
->cfd_test1
= TRUE
;
1673 hr
= IFileDialog_Advise(pfod
, pfde
, &cookie
);
1674 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
1676 hr
= IFileDialog_Show(pfod
, NULL
);
1677 ok(hr
== HRESULT_FROM_WIN32(ERROR_CANCELLED
), "Got 0x%08x\n", hr
);
1679 hr
= IFileDialog_Unadvise(pfod
, cookie
);
1680 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
1682 IFileDialogEvents_Release(pfde
);
1683 IFileDialogCustomize_Release(pfdc
);
1684 ref
= IFileDialog_Release(pfod
);
1685 ok(!ref
, "Refcount not zero (%d).\n", ref
);
1688 hr
= CoCreateInstance(&CLSID_FileOpenDialog
, NULL
, CLSCTX_INPROC_SERVER
,
1689 &IID_IFileDialog
, (void**)&pfod
);
1690 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1692 hr
= IFileDialog_QueryInterface(pfod
, &IID_IFileDialogCustomize
, (void**)&pfdc
);
1693 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1696 hr
= IFileDialogCustomize_AddMenu(pfdc
, ++i
, label
);
1697 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1703 for(j
= 0; j
< 10; j
++)
1705 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, j
, label
);
1706 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1709 hr
= IFileDialogCustomize_GetSelectedControlItem(pfdc
, i
, &selected
);
1710 ok(hr
== E_NOTIMPL
, "got 0x%08x.\n", hr
);
1712 cdstate
= 0xdeadbeef;
1713 hr
= IFileDialogCustomize_GetControlItemState(pfdc
, i
, 0, &cdstate
);
1714 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1715 todo_wine
ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1716 hr
= IFileDialogCustomize_SetControlItemState(pfdc
, i
, 0, 0);
1717 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1718 cdstate
= 0xdeadbeef;
1719 hr
= IFileDialogCustomize_GetControlItemState(pfdc
, i
, 0, &cdstate
);
1720 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1721 todo_wine
ok(cdstate
== 0, "got 0x%08x.\n", cdstate
);
1722 hr
= IFileDialogCustomize_SetControlItemState(pfdc
, i
, 0, CDCS_ENABLEDVISIBLE
);
1723 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1724 cdstate
= 0xdeadbeef;
1725 hr
= IFileDialogCustomize_GetControlItemState(pfdc
, i
, 0, &cdstate
);
1726 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1727 todo_wine
ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1729 hr
= IFileDialogCustomize_RemoveAllControlItems(pfdc
, i
);
1730 ok(hr
== E_NOTIMPL
, "got 0x%08x.\n", hr
);
1732 for(j
= 0; j
< 10; j
++)
1734 hr
= IFileDialogCustomize_RemoveControlItem(pfdc
, i
, j
);
1735 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1738 hr
= IFileDialogCustomize_AddPushButton(pfdc
, ++i
, label
);
1739 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1740 hr
= IFileDialogCustomize_AddComboBox(pfdc
, ++i
);
1741 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1744 DWORD selected
= -1;
1747 for(j
= 0; j
< 10; j
++)
1749 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, j
, label
);
1750 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1753 hr
= IFileDialogCustomize_GetSelectedControlItem(pfdc
, i
, &selected
);
1754 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
1755 ok(selected
== -1, "got %d.\n", selected
);
1758 cdstate
= 0xdeadbeef;
1759 hr
= IFileDialogCustomize_GetControlItemState(pfdc
, i
, 0, &cdstate
);
1760 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1761 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1762 hr
= IFileDialogCustomize_SetControlItemState(pfdc
, i
, 0, 0);
1763 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1764 cdstate
= 0xdeadbeef;
1765 hr
= IFileDialogCustomize_GetControlItemState(pfdc
, i
, 0, &cdstate
);
1766 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1767 ok(cdstate
== 0, "got 0x%08x.\n", cdstate
);
1768 hr
= IFileDialogCustomize_SetControlItemState(pfdc
, i
, 0, CDCS_ENABLEDVISIBLE
);
1769 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1770 cdstate
= 0xdeadbeef;
1771 hr
= IFileDialogCustomize_GetControlItemState(pfdc
, i
, 0, &cdstate
);
1772 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1773 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1776 for(j
= 0; j
< 10; j
++)
1778 hr
= IFileDialogCustomize_SetSelectedControlItem(pfdc
, i
, j
);
1779 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1780 hr
= IFileDialogCustomize_GetSelectedControlItem(pfdc
, i
, &selected
);
1781 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1782 ok(selected
== j
, "got %d.\n", selected
);
1785 hr
= IFileDialogCustomize_SetSelectedControlItem(pfdc
, i
, j
);
1786 ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
1788 hr
= IFileDialogCustomize_RemoveAllControlItems(pfdc
, i
);
1789 ok(hr
== E_NOTIMPL
, "got 0x%08x.\n", hr
);
1791 for(j
= 0; j
< 10; j
++)
1793 hr
= IFileDialogCustomize_RemoveControlItem(pfdc
, i
, j
);
1794 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1798 hr
= IFileDialogCustomize_AddRadioButtonList(pfdc
, ++i
);
1799 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1802 DWORD selected
= -1;
1805 for(j
= 0; j
< 10; j
++)
1807 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, j
, label
);
1808 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1811 hr
= IFileDialogCustomize_GetSelectedControlItem(pfdc
, i
, &selected
);
1812 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
1813 ok(selected
== -1, "got %d.\n", selected
);
1816 cdstate
= 0xdeadbeef;
1817 hr
= IFileDialogCustomize_GetControlItemState(pfdc
, i
, 0, &cdstate
);
1818 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1819 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1820 hr
= IFileDialogCustomize_SetControlItemState(pfdc
, i
, 0, 0);
1821 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1822 cdstate
= 0xdeadbeef;
1823 hr
= IFileDialogCustomize_GetControlItemState(pfdc
, i
, 0, &cdstate
);
1824 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1825 ok(cdstate
== 0, "got 0x%08x.\n", cdstate
);
1826 hr
= IFileDialogCustomize_SetControlItemState(pfdc
, i
, 0, CDCS_ENABLEDVISIBLE
);
1827 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1828 cdstate
= 0xdeadbeef;
1829 hr
= IFileDialogCustomize_GetControlItemState(pfdc
, i
, 0, &cdstate
);
1830 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1831 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1834 for(j
= 0; j
< 10; j
++)
1836 hr
= IFileDialogCustomize_SetSelectedControlItem(pfdc
, i
, j
);
1837 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1838 hr
= IFileDialogCustomize_GetSelectedControlItem(pfdc
, i
, &selected
);
1839 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1840 ok(selected
== j
, "got %d.\n", selected
);
1843 hr
= IFileDialogCustomize_SetSelectedControlItem(pfdc
, i
, j
);
1844 ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
1846 hr
= IFileDialogCustomize_RemoveAllControlItems(pfdc
, i
);
1847 ok(hr
== E_NOTIMPL
, "got 0x%08x.\n", hr
);
1849 for(j
= 0; j
< 10; j
++)
1851 hr
= IFileDialogCustomize_RemoveControlItem(pfdc
, i
, j
);
1852 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1855 hr
= IFileDialogCustomize_EnableOpenDropDown(pfdc
, ++i
);
1856 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1859 DWORD selected
= -1;
1862 for(j
= 0; j
< 10; j
++)
1864 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, j
, label
);
1865 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1868 hr
= IFileDialogCustomize_GetSelectedControlItem(pfdc
, i
, &selected
);
1869 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1870 ok(selected
== 0, "got %d.\n", selected
);
1872 cdstate
= 0xdeadbeef;
1873 hr
= IFileDialogCustomize_GetControlItemState(pfdc
, i
, 0, &cdstate
);
1874 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1875 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1876 hr
= IFileDialogCustomize_SetControlItemState(pfdc
, i
, 0, 0);
1877 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1878 cdstate
= 0xdeadbeef;
1879 hr
= IFileDialogCustomize_GetControlItemState(pfdc
, i
, 0, &cdstate
);
1880 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1881 ok(cdstate
== 0, "got 0x%08x.\n", cdstate
);
1882 hr
= IFileDialogCustomize_SetControlItemState(pfdc
, i
, 0, CDCS_ENABLEDVISIBLE
);
1883 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1884 cdstate
= 0xdeadbeef;
1885 hr
= IFileDialogCustomize_GetControlItemState(pfdc
, i
, 0, &cdstate
);
1886 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1887 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1888 hr
= IFileDialogCustomize_SetSelectedControlItem(pfdc
, i
, 0);
1889 ok(hr
== E_NOTIMPL
, "got 0x%08x.\n", hr
);
1891 hr
= IFileDialogCustomize_RemoveAllControlItems(pfdc
, i
);
1892 ok(hr
== E_NOTIMPL
, "got 0x%08x.\n", hr
);
1894 for(j
= 0; j
< 10; j
++)
1896 hr
= IFileDialogCustomize_RemoveControlItem(pfdc
, i
, j
);
1897 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1901 IFileDialogCustomize_Release(pfdc
);
1902 ref
= IFileDialog_Release(pfod
);
1903 ok(!ref
, "Refcount not zero (%d).\n", ref
);
1906 static void test_persistent_state(void)
1911 hr
= CoCreateInstance(&CLSID_FileOpenDialog
, NULL
, CLSCTX_INPROC_SERVER
,
1912 &IID_IFileDialog
, (void**)&fd
);
1913 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1917 /* crashes at least on Win8 */
1918 hr
= IFileDialog_SetClientGuid(fd
, NULL
);
1921 hr
= IFileDialog_SetClientGuid(fd
, &IID_IUnknown
);
1922 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1924 hr
= IFileDialog_SetClientGuid(fd
, &IID_NULL
);
1925 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1927 IFileDialog_Release(fd
);
1932 OleInitialize(NULL
);
1933 init_function_pointers();
1935 if(test_instantiation())
1941 test_persistent_state();
1944 skip("Skipping all Item Dialog tests.\n");