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
26 #include "wine/test.h"
28 #define IDT_CHANGEFILETYPE 500
29 #define IDT_CLOSEDIALOG 501
32 IFDEVENT_TEST_NONE
= 0,
36 } FileDialogEventsTest
;
38 static HRESULT (WINAPI
*pSHCreateShellItem
)(LPCITEMIDLIST
,IShellFolder
*,LPCITEMIDLIST
,IShellItem
**);
39 static HRESULT (WINAPI
*pSHGetIDListFromObject
)(IUnknown
*, PIDLIST_ABSOLUTE
*);
40 static HRESULT (WINAPI
*pSHCreateItemFromParsingName
)(PCWSTR
,IBindCtx
*,REFIID
,void**);
42 static void init_function_pointers(void)
44 HMODULE hmod
= GetModuleHandleA("shell32.dll");
46 #define MAKEFUNC(f) (p##f = (void*)GetProcAddress(hmod, #f))
47 MAKEFUNC(SHCreateShellItem
);
48 MAKEFUNC(SHGetIDListFromObject
);
49 MAKEFUNC(SHCreateItemFromParsingName
);
54 DEFINE_GUID(IID_IFileDialogCustomizeAlt
, 0x8016B7B3, 0x3D49, 0x4504, 0xA0,0xAA, 0x2A,0x37,0x49,0x4E,0x60,0x6F);
61 static BOOL CALLBACK
find_window_callback(HWND hwnd
, LPARAM lparam
)
63 struct fw_arg
*arg
= (struct fw_arg
*)lparam
;
68 GetClassNameW(hwnd
, buf
, 1024);
69 if(lstrcmpW(buf
, arg
->class))
75 GetWindowTextW(hwnd
, buf
, 1024);
76 if(lstrcmpW(buf
, arg
->text
))
84 static HWND
find_window(HWND parent
, LPCWSTR
class, LPCWSTR text
)
86 struct fw_arg arg
= {class, text
, NULL
};
88 EnumChildWindows(parent
, find_window_callback
, (LPARAM
)&arg
);
92 static HWND
get_hwnd_from_ifiledialog(IFileDialog
*pfd
)
98 hr
= IFileDialog_QueryInterface(pfd
, &IID_IOleWindow
, (void**)&pow
);
99 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
101 hr
= IOleWindow_GetWindow(pow
, &dlg_hwnd
);
102 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
104 IOleWindow_Release(pow
);
109 static void test_customize_onfolderchange(IFileDialog
*pfd
);
110 static void filedialog_change_filetype(IFileDialog
*pfd
, HWND dlg_hwnd
);
112 /**************************************************************************
113 * IFileDialogEvents implementation
116 IFileDialogEvents IFileDialogEvents_iface
;
119 LONG OnFileOk
, OnFolderChanging
, OnFolderChange
;
120 LONG OnSelectionChange
, OnShareViolation
, OnTypeChange
;
122 LPCWSTR set_filename
;
123 BOOL set_filename_tried
;
124 FileDialogEventsTest events_test
;
125 } IFileDialogEventsImpl
;
127 static inline IFileDialogEventsImpl
*impl_from_IFileDialogEvents(IFileDialogEvents
*iface
)
129 return CONTAINING_RECORD(iface
, IFileDialogEventsImpl
, IFileDialogEvents_iface
);
132 static HRESULT WINAPI
IFileDialogEvents_fnQueryInterface(IFileDialogEvents
*iface
, REFIID riid
, void **ppv
)
135 ok(0, "Unexpectedly called.\n");
136 return E_NOINTERFACE
;
139 static ULONG WINAPI
IFileDialogEvents_fnAddRef(IFileDialogEvents
*iface
)
141 IFileDialogEventsImpl
*This
= impl_from_IFileDialogEvents(iface
);
142 return InterlockedIncrement(&This
->ref
);
145 static ULONG WINAPI
IFileDialogEvents_fnRelease(IFileDialogEvents
*iface
)
147 IFileDialogEventsImpl
*This
= impl_from_IFileDialogEvents(iface
);
148 LONG ref
= InterlockedDecrement(&This
->ref
);
151 HeapFree(GetProcessHeap(), 0, This
);
156 static HRESULT WINAPI
IFileDialogEvents_fnOnFileOk(IFileDialogEvents
*iface
, IFileDialog
*pfd
)
158 IFileDialogEventsImpl
*This
= impl_from_IFileDialogEvents(iface
);
163 static HRESULT WINAPI
IFileDialogEvents_fnOnFolderChanging(IFileDialogEvents
*iface
,
165 IShellItem
*psiFolder
)
167 IFileDialogEventsImpl
*This
= impl_from_IFileDialogEvents(iface
);
168 This
->OnFolderChanging
++;
172 static LRESULT CALLBACK
test_customize_dlgproc(HWND hwnd
, UINT message
, WPARAM wparam
, LPARAM lparam
)
174 WNDPROC oldwndproc
= GetPropA(hwnd
, "WT_OLDWC");
175 IFileDialog
*pfd
= GetPropA(hwnd
, "WT_PFD");
181 test_customize_onfolderchange(pfd
);
186 case IDT_CHANGEFILETYPE
:
187 filedialog_change_filetype(pfd
, hwnd
);
188 KillTimer(hwnd
, IDT_CHANGEFILETYPE
);
189 SetTimer(hwnd
, IDT_CLOSEDIALOG
, 100, 0);
191 case IDT_CLOSEDIALOG
:
192 /* Calling IFileDialog_Close here does not work */
193 br
= PostMessageW(hwnd
, WM_COMMAND
, IDCANCEL
, 0);
199 return CallWindowProcW(oldwndproc
, hwnd
, message
, wparam
, lparam
);
202 static HRESULT WINAPI
IFileDialogEvents_fnOnFolderChange(IFileDialogEvents
*iface
, IFileDialog
*pfd
)
204 IFileDialogEventsImpl
*This
= impl_from_IFileDialogEvents(iface
);
208 This
->OnFolderChange
++;
210 if(This
->set_filename
)
212 dlg_hwnd
= get_hwnd_from_ifiledialog(pfd
);
213 ok(dlg_hwnd
!= NULL
, "Got NULL.\n");
215 hr
= IFileDialog_SetFileName(pfd
, This
->set_filename
);
216 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
218 if(!This
->set_filename_tried
)
220 br
= PostMessageW(dlg_hwnd
, WM_COMMAND
, IDOK
, 0);
222 This
->set_filename_tried
= TRUE
;
226 if(This
->events_test
)
230 dlg_hwnd
= get_hwnd_from_ifiledialog(pfd
);
232 /* On Vista, the custom control area of the dialog is not
233 * fully set up when the first OnFolderChange event is
235 oldwndproc
= (WNDPROC
)GetWindowLongPtrW(dlg_hwnd
, GWLP_WNDPROC
);
236 SetPropA(dlg_hwnd
, "WT_OLDWC", (HANDLE
)oldwndproc
);
237 SetPropA(dlg_hwnd
, "WT_PFD", (HANDLE
)pfd
);
238 SetWindowLongPtrW(dlg_hwnd
, GWLP_WNDPROC
, (LPARAM
)test_customize_dlgproc
);
240 switch(This
->events_test
)
243 br
= PostMessageW(dlg_hwnd
, WM_USER
+0x1234, 0, 0);
247 SetTimer(dlg_hwnd
, IDT_CLOSEDIALOG
, 100, 0);
250 SetTimer(dlg_hwnd
, IDT_CHANGEFILETYPE
, 100, 0);
253 ok(FALSE
, "Should not happen (%d)\n", This
->events_test
);
260 static HRESULT WINAPI
IFileDialogEvents_fnOnSelectionChange(IFileDialogEvents
*iface
, IFileDialog
*pfd
)
262 IFileDialogEventsImpl
*This
= impl_from_IFileDialogEvents(iface
);
263 This
->OnSelectionChange
++;
267 static HRESULT WINAPI
IFileDialogEvents_fnOnShareViolation(IFileDialogEvents
*iface
,
270 FDE_SHAREVIOLATION_RESPONSE
*pResponse
)
272 IFileDialogEventsImpl
*This
= impl_from_IFileDialogEvents(iface
);
273 This
->OnShareViolation
++;
277 static HRESULT WINAPI
IFileDialogEvents_fnOnTypeChange(IFileDialogEvents
*iface
, IFileDialog
*pfd
)
279 IFileDialogEventsImpl
*This
= impl_from_IFileDialogEvents(iface
);
280 This
->OnTypeChange
++;
284 static HRESULT WINAPI
IFileDialogEvents_fnOnOverwrite(IFileDialogEvents
*iface
,
287 FDE_OVERWRITE_RESPONSE
*pResponse
)
289 IFileDialogEventsImpl
*This
= impl_from_IFileDialogEvents(iface
);
294 static const IFileDialogEventsVtbl vt_IFileDialogEvents
= {
295 IFileDialogEvents_fnQueryInterface
,
296 IFileDialogEvents_fnAddRef
,
297 IFileDialogEvents_fnRelease
,
298 IFileDialogEvents_fnOnFileOk
,
299 IFileDialogEvents_fnOnFolderChanging
,
300 IFileDialogEvents_fnOnFolderChange
,
301 IFileDialogEvents_fnOnSelectionChange
,
302 IFileDialogEvents_fnOnShareViolation
,
303 IFileDialogEvents_fnOnTypeChange
,
304 IFileDialogEvents_fnOnOverwrite
307 static IFileDialogEvents
*IFileDialogEvents_Constructor(void)
309 IFileDialogEventsImpl
*This
;
311 This
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IFileDialogEventsImpl
));
312 This
->IFileDialogEvents_iface
.lpVtbl
= &vt_IFileDialogEvents
;
315 return &This
->IFileDialogEvents_iface
;
318 static BOOL
test_instantiation(void)
321 IFileOpenDialog
*pfod
;
322 IFileSaveDialog
*pfsd
;
323 IServiceProvider
*psp
;
329 /* Instantiate FileOpenDialog */
330 hr
= CoCreateInstance(&CLSID_FileOpenDialog
, NULL
, CLSCTX_INPROC_SERVER
,
331 &IID_IFileOpenDialog
, (void**)&pfod
);
334 skip("Could not instantiate the FileOpenDialog.\n");
337 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
339 hr
= IFileOpenDialog_QueryInterface(pfod
, &IID_IFileDialog
, (void**)&pfd
);
340 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
341 if(SUCCEEDED(hr
)) IFileDialog_Release(pfd
);
343 hr
= IFileOpenDialog_QueryInterface(pfod
, &IID_IFileDialogCustomize
, (void**)&punk
);
344 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
345 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
347 hr
= IFileOpenDialog_QueryInterface(pfod
, &IID_IFileDialogCustomizeAlt
, (void**)&punk
);
348 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
349 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
351 hr
= IFileOpenDialog_QueryInterface(pfod
, &IID_IFileSaveDialog
, (void**)&pfsd
);
352 ok(hr
== E_NOINTERFACE
, "got 0x%08x.\n", hr
);
353 if(SUCCEEDED(hr
)) IFileSaveDialog_Release(pfsd
);
355 hr
= IFileOpenDialog_QueryInterface(pfod
, &IID_IServiceProvider
, (void**)&psp
);
356 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
359 IExplorerBrowser
*peb
;
362 hr
= IServiceProvider_QueryService(psp
, &SID_SExplorerBrowserFrame
, &IID_ICommDlgBrowser
, (void**)&punk
);
363 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
364 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
366 /* since win8, the result is E_NOTIMPL for all other services */
367 hr
= IServiceProvider_QueryService(psp
, &SID_STopLevelBrowser
, &IID_IExplorerBrowser
, (void**)&peb
);
368 ok(hr
== E_NOTIMPL
|| broken(hr
== E_FAIL
), "got 0x%08x (expected E_NOTIMPL)\n", hr
);
369 if(SUCCEEDED(hr
)) IExplorerBrowser_Release(peb
);
370 hr
= IServiceProvider_QueryService(psp
, &SID_STopLevelBrowser
, &IID_IShellBrowser
, (void**)&psb
);
371 ok(hr
== E_NOTIMPL
|| broken(hr
== E_FAIL
), "got 0x%08x (expected E_NOTIMPL)\n", hr
);
372 if(SUCCEEDED(hr
)) IShellBrowser_Release(psb
);
373 hr
= IServiceProvider_QueryService(psp
, &SID_STopLevelBrowser
, &IID_ICommDlgBrowser
, (void**)&punk
);
374 ok(hr
== E_NOTIMPL
|| broken(hr
== E_FAIL
), "got 0x%08x (expected E_NOTIMPL)\n", hr
);
375 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
377 hr
= IServiceProvider_QueryService(psp
, &SID_STopLevelBrowser
, &IID_IUnknown
, (void**)&punk
);
378 ok(hr
== E_NOTIMPL
|| broken(hr
== E_FAIL
), "got 0x%08x (expected E_NOTIMPL)\n", hr
);
379 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
380 hr
= IServiceProvider_QueryService(psp
, &IID_IUnknown
, &IID_IUnknown
, (void**)&punk
);
381 ok(hr
== E_NOTIMPL
|| broken(hr
== E_FAIL
), "got 0x%08x (expected E_NOTIMPL)\n", hr
);
382 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
384 IServiceProvider_Release(psp
);
387 hr
= IFileOpenDialog_QueryInterface(pfod
, &IID_IFileDialogEvents
, (void**)&punk
);
388 ok(hr
== E_NOINTERFACE
, "got 0x%08x.\n", hr
);
389 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
391 hr
= IFileOpenDialog_QueryInterface(pfod
, &IID_IExplorerBrowser
, (void**)&punk
);
392 ok(hr
== E_NOINTERFACE
, "got 0x%08x.\n", hr
);
393 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
395 hr
= IFileOpenDialog_QueryInterface(pfod
, &IID_IExplorerBrowserEvents
, (void**)&punk
);
396 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
397 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
399 hr
= IFileOpenDialog_QueryInterface(pfod
, &IID_ICommDlgBrowser3
, (void**)&punk
);
400 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
401 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
403 hr
= IFileOpenDialog_QueryInterface(pfod
, &IID_IShellBrowser
, (void**)&punk
);
404 ok(hr
== E_NOINTERFACE
, "got 0x%08x.\n", hr
);
405 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
407 hr
= IFileOpenDialog_QueryInterface(pfod
, &IID_IOleWindow
, (void**)&pow
);
408 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
413 hr
= IOleWindow_ContextSensitiveHelp(pow
, TRUE
);
414 todo_wine
ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
416 hr
= IOleWindow_ContextSensitiveHelp(pow
, FALSE
);
417 todo_wine
ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
421 /* Crashes on win7 */
422 IOleWindow_GetWindow(pow
, NULL
);
425 hr
= IOleWindow_GetWindow(pow
, &hwnd
);
426 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
427 ok(hwnd
== NULL
, "Got %p\n", hwnd
);
429 IOleWindow_Release(pow
);
432 ref
= IFileOpenDialog_Release(pfod
);
433 ok(!ref
, "Got refcount %d, should have been released.\n", ref
);
435 /* Instantiate FileSaveDialog */
436 hr
= CoCreateInstance(&CLSID_FileSaveDialog
, NULL
, CLSCTX_INPROC_SERVER
,
437 &IID_IFileSaveDialog
, (void**)&pfsd
);
440 skip("Could not instantiate the FileSaveDialog.\n");
443 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
445 hr
= IFileSaveDialog_QueryInterface(pfsd
, &IID_IFileDialog
, (void**)&pfd
);
446 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
447 if(SUCCEEDED(hr
)) IFileDialog_Release(pfd
);
449 hr
= IFileSaveDialog_QueryInterface(pfsd
, &IID_IFileDialogCustomize
, (void**)&punk
);
450 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
451 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
453 hr
= IFileSaveDialog_QueryInterface(pfsd
, &IID_IFileDialogCustomizeAlt
, (void**)&punk
);
454 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
455 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
457 hr
= IFileSaveDialog_QueryInterface(pfsd
, &IID_IFileOpenDialog
, (void**)&pfod
);
458 ok(hr
== E_NOINTERFACE
, "got 0x%08x.\n", hr
);
459 if(SUCCEEDED(hr
)) IFileOpenDialog_Release(pfod
);
461 hr
= IFileSaveDialog_QueryInterface(pfsd
, &IID_IFileDialogEvents
, (void**)&punk
);
462 ok(hr
== E_NOINTERFACE
, "got 0x%08x.\n", hr
);
463 if(SUCCEEDED(hr
)) IFileDialog_Release(pfd
);
465 hr
= IFileSaveDialog_QueryInterface(pfsd
, &IID_IExplorerBrowser
, (void**)&punk
);
466 ok(hr
== E_NOINTERFACE
, "got 0x%08x.\n", hr
);
467 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
469 hr
= IFileSaveDialog_QueryInterface(pfsd
, &IID_IExplorerBrowserEvents
, (void**)&punk
);
470 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
471 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
473 hr
= IFileSaveDialog_QueryInterface(pfsd
, &IID_ICommDlgBrowser3
, (void**)&punk
);
474 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
475 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
477 hr
= IFileSaveDialog_QueryInterface(pfsd
, &IID_IShellBrowser
, (void**)&punk
);
478 ok(hr
== E_NOINTERFACE
, "got 0x%08x.\n", hr
);
479 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
481 hr
= IFileSaveDialog_QueryInterface(pfsd
, &IID_IOleWindow
, (void**)&pow
);
482 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
487 hr
= IOleWindow_ContextSensitiveHelp(pow
, TRUE
);
488 todo_wine
ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
490 hr
= IOleWindow_ContextSensitiveHelp(pow
, FALSE
);
491 todo_wine
ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
495 /* Crashes on win7 */
496 IOleWindow_GetWindow(pow
, NULL
);
499 hr
= IOleWindow_GetWindow(pow
, &hwnd
);
500 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
501 ok(hwnd
== NULL
, "Got %p\n", hwnd
);
503 IOleWindow_Release(pow
);
507 ref
= IFileSaveDialog_Release(pfsd
);
508 ok(!ref
, "Got refcount %d, should have been released.\n", ref
);
512 static void test_basics(void)
514 IFileOpenDialog
*pfod
;
515 IFileSaveDialog
*pfsd
;
517 FILEOPENDIALOGOPTIONS fdoptions
;
518 IShellFolder
*psfdesktop
;
519 IShellItem
*psi
, *psidesktop
, *psi_original
;
520 IShellItemArray
*psia
;
527 const WCHAR txt
[] = {'t','x','t', 0};
528 const WCHAR null
[] = {0};
529 const WCHAR fname1
[] = {'f','n','a','m','e','1', 0};
530 const WCHAR fspec1
[] = {'*','.','t','x','t',0};
531 const WCHAR fname2
[] = {'f','n','a','m','e','2', 0};
532 const WCHAR fspec2
[] = {'*','.','e','x','e',0};
533 COMDLG_FILTERSPEC filterspec
[2] = {{fname1
, fspec1
}, {fname2
, fspec2
}};
535 /* This should work on every platform with IFileDialog */
536 SHGetDesktopFolder(&psfdesktop
);
537 hr
= pSHGetIDListFromObject((IUnknown
*)psfdesktop
, &pidl
);
540 hr
= pSHCreateShellItem(NULL
, NULL
, pidl
, &psidesktop
);
543 IShellFolder_Release(psfdesktop
);
546 skip("Failed to get ShellItem from DesktopFolder, skipping tests.\n");
551 /* Instantiate FileOpenDialog and FileSaveDialog */
552 hr
= CoCreateInstance(&CLSID_FileOpenDialog
, NULL
, CLSCTX_INPROC_SERVER
,
553 &IID_IFileOpenDialog
, (void**)&pfod
);
554 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
555 hr
= CoCreateInstance(&CLSID_FileSaveDialog
, NULL
, CLSCTX_INPROC_SERVER
,
556 &IID_IFileSaveDialog
, (void**)&pfsd
);
557 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
559 /* ClearClientData */
562 hr
= IFileOpenDialog_ClearClientData(pfod
);
563 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
564 hr
= IFileSaveDialog_ClearClientData(pfsd
);
565 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
569 hr
= IFileOpenDialog_GetOptions(pfod
, NULL
);
570 ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
571 hr
= IFileSaveDialog_GetOptions(pfsd
, NULL
);
572 ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
574 /* Check default options */
575 hr
= IFileOpenDialog_GetOptions(pfod
, &fdoptions
);
576 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
577 ok(fdoptions
== (FOS_PATHMUSTEXIST
| FOS_FILEMUSTEXIST
| FOS_NOCHANGEDIR
),
578 "Unexpected default options: 0x%08x\n", fdoptions
);
579 hr
= IFileSaveDialog_GetOptions(pfsd
, &fdoptions
);
580 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
581 ok(fdoptions
== (FOS_OVERWRITEPROMPT
| FOS_NOREADONLYRETURN
| FOS_PATHMUSTEXIST
| FOS_NOCHANGEDIR
),
582 "Unexpected default options: 0x%08x\n", fdoptions
);
585 hr
= IFileOpenDialog_GetResult(pfod
, NULL
);
586 ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
587 hr
= IFileSaveDialog_GetResult(pfsd
, NULL
);
588 ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
590 psi
= (void*)0xdeadbeef;
591 hr
= IFileOpenDialog_GetResult(pfod
, &psi
);
592 ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
593 ok(psi
== (void*)0xdeadbeef, "got %p.\n", psi
);
594 psi
= (void*)0xdeadbeef;
595 hr
= IFileSaveDialog_GetResult(pfsd
, &psi
);
596 ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
597 ok(psi
== (void*)0xdeadbeef, "got %p.\n", psi
);
599 /* GetCurrentSelection */
601 /* Crashes on Vista/W2K8. Tests below passes on Windows 7 */
602 hr
= IFileOpenDialog_GetCurrentSelection(pfod
, NULL
);
603 ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
604 hr
= IFileSaveDialog_GetCurrentSelection(pfsd
, NULL
);
605 ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
606 hr
= IFileOpenDialog_GetCurrentSelection(pfod
, &psi
);
607 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
608 hr
= IFileSaveDialog_GetCurrentSelection(pfsd
, &psi
);
609 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
613 hr
= IFileOpenDialog_GetFileName(pfod
, NULL
);
614 ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
615 filename
= (void*)0xdeadbeef;
616 hr
= IFileOpenDialog_GetFileName(pfod
, &filename
);
617 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
618 ok(filename
== NULL
, "got %p\n", filename
);
619 hr
= IFileSaveDialog_GetFileName(pfsd
, NULL
);
620 ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
621 filename
= (void*)0xdeadbeef;
622 hr
= IFileSaveDialog_GetFileName(pfsd
, &filename
);
623 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
624 ok(filename
== NULL
, "got %p\n", filename
);
626 /* GetFileTypeIndex */
627 hr
= IFileOpenDialog_GetFileTypeIndex(pfod
, NULL
);
628 ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
630 hr
= IFileOpenDialog_GetFileTypeIndex(pfod
, &filetype
);
631 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
632 ok(filetype
== 0, "got %d.\n", filetype
);
633 hr
= IFileSaveDialog_GetFileTypeIndex(pfsd
, NULL
);
634 ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
636 hr
= IFileSaveDialog_GetFileTypeIndex(pfsd
, &filetype
);
637 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
638 ok(filetype
== 0, "got %d.\n", filetype
);
640 /* SetFileTypes / SetFileTypeIndex */
641 hr
= IFileOpenDialog_SetFileTypes(pfod
, 0, NULL
);
642 ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
643 hr
= IFileOpenDialog_SetFileTypes(pfod
, 0, filterspec
);
644 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
646 hr
= IFileOpenDialog_SetFileTypeIndex(pfod
, -1);
647 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
648 hr
= IFileOpenDialog_SetFileTypeIndex(pfod
, 0);
649 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
650 hr
= IFileOpenDialog_SetFileTypeIndex(pfod
, 1);
651 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
652 hr
= IFileOpenDialog_SetFileTypes(pfod
, 1, filterspec
);
653 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
654 hr
= IFileOpenDialog_SetFileTypes(pfod
, 0, filterspec
);
655 ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
656 hr
= IFileOpenDialog_SetFileTypeIndex(pfod
, 0);
657 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
658 hr
= IFileOpenDialog_SetFileTypeIndex(pfod
, 100);
659 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
660 hr
= IFileOpenDialog_SetFileTypes(pfod
, 1, filterspec
);
661 ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
662 hr
= IFileOpenDialog_SetFileTypes(pfod
, 1, &filterspec
[1]);
663 ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
665 hr
= IFileSaveDialog_SetFileTypeIndex(pfsd
, -1);
666 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
667 hr
= IFileSaveDialog_SetFileTypeIndex(pfsd
, 0);
668 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
669 hr
= IFileSaveDialog_SetFileTypeIndex(pfsd
, 1);
670 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
671 hr
= IFileSaveDialog_SetFileTypes(pfsd
, 1, filterspec
);
672 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
673 hr
= IFileSaveDialog_SetFileTypeIndex(pfsd
, 0);
674 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
675 hr
= IFileSaveDialog_SetFileTypeIndex(pfsd
, 100);
676 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
677 hr
= IFileSaveDialog_SetFileTypes(pfsd
, 1, filterspec
);
678 ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
679 hr
= IFileSaveDialog_SetFileTypes(pfsd
, 1, &filterspec
[1]);
680 ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
685 hr
= IFileOpenDialog_SetFilter(pfod
, NULL
);
686 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
687 hr
= IFileSaveDialog_SetFilter(pfsd
, NULL
);
688 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
692 hr
= IFileOpenDialog_SetFolder(pfod
, NULL
);
693 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
694 hr
= IFileSaveDialog_SetFolder(pfsd
, NULL
);
695 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
697 /* SetDefaultExtension */
698 hr
= IFileOpenDialog_SetDefaultExtension(pfod
, NULL
);
699 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
700 hr
= IFileOpenDialog_SetDefaultExtension(pfod
, txt
);
701 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
702 hr
= IFileOpenDialog_SetDefaultExtension(pfod
, null
);
703 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
705 hr
= IFileSaveDialog_SetDefaultExtension(pfsd
, NULL
);
706 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
707 hr
= IFileSaveDialog_SetDefaultExtension(pfsd
, txt
);
708 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
709 hr
= IFileSaveDialog_SetDefaultExtension(pfsd
, null
);
710 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
712 /* SetDefaultFolder */
713 hr
= IFileOpenDialog_SetDefaultFolder(pfod
, NULL
);
714 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
715 hr
= IFileSaveDialog_SetDefaultFolder(pfsd
, NULL
);
716 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
718 hr
= IFileOpenDialog_SetDefaultFolder(pfod
, psidesktop
);
719 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
720 hr
= IFileSaveDialog_SetDefaultFolder(pfsd
, psidesktop
);
721 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
725 /* Crashes under Windows 7 */
726 IFileOpenDialog_SetDefaultFolder(pfod
, (void*)0x1234);
727 IFileSaveDialog_SetDefaultFolder(pfsd
, (void*)0x1234);
730 /* GetFolder / SetFolder */
731 hr
= IFileOpenDialog_GetFolder(pfod
, NULL
);
732 ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
734 hr
= IFileOpenDialog_GetFolder(pfod
, &psi_original
);
735 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
738 hr
= IFileOpenDialog_SetFolder(pfod
, psidesktop
);
739 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
740 hr
= IFileOpenDialog_SetFolder(pfod
, psi_original
);
741 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
742 IShellItem_Release(psi_original
);
745 hr
= IFileSaveDialog_GetFolder(pfsd
, &psi_original
);
746 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
749 hr
= IFileSaveDialog_SetFolder(pfsd
, psidesktop
);
750 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
751 hr
= IFileSaveDialog_SetFolder(pfsd
, psi_original
);
752 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
753 IShellItem_Release(psi_original
);
759 /* Crashes under Windows 7 */
760 IFileOpenDialog_AddPlace(pfod
, NULL
, 0);
761 IFileSaveDialog_AddPlace(pfsd
, NULL
, 0);
766 hr
= IFileOpenDialog_AddPlace(pfod
, psidesktop
, FDAP_TOP
+ 1);
767 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
768 hr
= IFileOpenDialog_AddPlace(pfod
, psidesktop
, FDAP_BOTTOM
);
769 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
770 hr
= IFileOpenDialog_AddPlace(pfod
, psidesktop
, FDAP_TOP
);
771 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
773 hr
= IFileSaveDialog_AddPlace(pfsd
, psidesktop
, FDAP_TOP
+ 1);
774 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
775 hr
= IFileSaveDialog_AddPlace(pfsd
, psidesktop
, FDAP_BOTTOM
);
776 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
777 hr
= IFileSaveDialog_AddPlace(pfsd
, psidesktop
, FDAP_TOP
);
778 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
782 hr
= IFileOpenDialog_SetFileName(pfod
, NULL
);
783 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
784 hr
= IFileOpenDialog_SetFileName(pfod
, null
);
785 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
786 hr
= IFileOpenDialog_SetFileName(pfod
, txt
);
787 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
788 hr
= IFileOpenDialog_GetFileName(pfod
, &filename
);
789 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
790 ok(!lstrcmpW(filename
, txt
), "Strings do not match.\n");
791 CoTaskMemFree(filename
);
793 hr
= IFileSaveDialog_SetFileName(pfsd
, NULL
);
794 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
795 hr
= IFileSaveDialog_SetFileName(pfsd
, null
);
796 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
797 hr
= IFileSaveDialog_SetFileName(pfsd
, txt
);
798 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
799 hr
= IFileSaveDialog_GetFileName(pfsd
, &filename
);
800 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
801 ok(!lstrcmpW(filename
, txt
), "Strings do not match.\n");
802 CoTaskMemFree(filename
);
804 /* SetFileNameLabel */
805 hr
= IFileOpenDialog_SetFileNameLabel(pfod
, NULL
);
806 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
807 hr
= IFileOpenDialog_SetFileNameLabel(pfod
, null
);
808 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
809 hr
= IFileOpenDialog_SetFileNameLabel(pfod
, txt
);
810 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
812 hr
= IFileSaveDialog_SetFileNameLabel(pfsd
, NULL
);
813 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
814 hr
= IFileSaveDialog_SetFileNameLabel(pfsd
, null
);
815 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
816 hr
= IFileSaveDialog_SetFileNameLabel(pfsd
, txt
);
817 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
820 hr
= IFileOpenDialog_Close(pfod
, S_FALSE
);
821 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
822 hr
= IFileSaveDialog_Close(pfsd
, S_FALSE
);
823 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
825 /* SetOkButtonLabel */
826 hr
= IFileOpenDialog_SetOkButtonLabel(pfod
, NULL
);
827 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
828 hr
= IFileOpenDialog_SetOkButtonLabel(pfod
, null
);
829 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
830 hr
= IFileOpenDialog_SetOkButtonLabel(pfod
, txt
);
831 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
832 hr
= IFileSaveDialog_SetOkButtonLabel(pfsd
, NULL
);
833 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
834 hr
= IFileSaveDialog_SetOkButtonLabel(pfsd
, null
);
835 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
836 hr
= IFileSaveDialog_SetOkButtonLabel(pfsd
, txt
);
837 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
840 hr
= IFileOpenDialog_SetTitle(pfod
, NULL
);
841 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
842 hr
= IFileOpenDialog_SetTitle(pfod
, null
);
843 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
844 hr
= IFileOpenDialog_SetTitle(pfod
, txt
);
845 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
846 hr
= IFileSaveDialog_SetTitle(pfsd
, NULL
);
847 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
848 hr
= IFileSaveDialog_SetTitle(pfsd
, null
);
849 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
850 hr
= IFileSaveDialog_SetTitle(pfsd
, txt
);
851 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
853 /** IFileOpenDialog specific **/
858 /* Crashes under Windows 7 */
859 IFileOpenDialog_GetResults(pfod
, NULL
);
861 psia
= (void*)0xdeadbeef;
862 hr
= IFileOpenDialog_GetResults(pfod
, &psia
);
863 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
864 ok(psia
== NULL
, "got %p.\n", psia
);
866 /* GetSelectedItems */
869 /* Crashes under W2K8 */
870 hr
= IFileOpenDialog_GetSelectedItems(pfod
, NULL
);
871 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
872 psia
= (void*)0xdeadbeef;
873 hr
= IFileOpenDialog_GetSelectedItems(pfod
, &psia
);
874 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
875 ok(psia
== (void*)0xdeadbeef, "got %p.\n", psia
);
878 /** IFileSaveDialog specific **/
880 /* ApplyProperties */
883 /* Crashes under windows 7 */
884 IFileSaveDialog_ApplyProperties(pfsd
, NULL
, NULL
, NULL
, NULL
);
885 IFileSaveDialog_ApplyProperties(pfsd
, psidesktop
, NULL
, NULL
, NULL
);
889 hr
= IFileSaveDialog_GetProperties(pfsd
, NULL
);
890 todo_wine
ok(hr
== E_UNEXPECTED
, "got 0x%08x\n", hr
);
891 pps
= (void*)0xdeadbeef;
892 hr
= IFileSaveDialog_GetProperties(pfsd
, &pps
);
893 todo_wine
ok(hr
== E_UNEXPECTED
, "got 0x%08x\n", hr
);
894 ok(pps
== (void*)0xdeadbeef, "got %p\n", pps
);
899 /* Crashes under W2K8 */
900 hr
= IFileSaveDialog_SetProperties(pfsd
, NULL
);
901 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
904 /* SetCollectedProperties */
907 hr
= IFileSaveDialog_SetCollectedProperties(pfsd
, NULL
, TRUE
);
908 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
909 hr
= IFileSaveDialog_SetCollectedProperties(pfsd
, NULL
, FALSE
);
910 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
916 hr
= IFileSaveDialog_SetSaveAsItem(pfsd
, NULL
);
917 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
918 hr
= IFileSaveDialog_SetSaveAsItem(pfsd
, psidesktop
);
919 ok(hr
== MK_E_NOOBJECT
, "got 0x%08x\n", hr
);
924 hr
= IFileOpenDialog_QueryInterface(pfod
, &IID_IFileDialog2
, (void**)&pfd2
);
925 ok((hr
== S_OK
) || broken(hr
== E_NOINTERFACE
), "got 0x%08x\n", hr
);
928 /* SetCancelButtonLabel */
929 hr
= IFileDialog2_SetOkButtonLabel(pfd2
, NULL
);
930 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
931 hr
= IFileDialog2_SetOkButtonLabel(pfd2
, null
);
932 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
933 hr
= IFileDialog2_SetOkButtonLabel(pfd2
, txt
);
934 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
936 /* SetNavigationRoot */
939 hr
= IFileDialog2_SetNavigationRoot(pfd2
, NULL
);
940 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
941 hr
= IFileDialog2_SetNavigationRoot(pfd2
, psidesktop
);
942 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
945 IFileDialog2_Release(pfd2
);
948 hr
= IFileSaveDialog_QueryInterface(pfsd
, &IID_IFileDialog2
, (void**)&pfd2
);
949 ok((hr
== S_OK
) || broken(hr
== E_NOINTERFACE
), "got 0x%08x\n", hr
);
952 /* SetCancelButtonLabel */
953 hr
= IFileDialog2_SetOkButtonLabel(pfd2
, NULL
);
954 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
955 hr
= IFileDialog2_SetOkButtonLabel(pfd2
, null
);
956 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
957 hr
= IFileDialog2_SetOkButtonLabel(pfd2
, txt
);
958 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
960 /* SetNavigationRoot */
963 hr
= IFileDialog2_SetNavigationRoot(pfd2
, NULL
);
964 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
965 hr
= IFileDialog2_SetNavigationRoot(pfd2
, psidesktop
);
966 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
969 IFileDialog2_Release(pfd2
);
973 IShellItem_Release(psidesktop
);
974 ref
= IFileOpenDialog_Release(pfod
);
975 ok(!ref
, "Got refcount %d, should have been released.\n", ref
);
976 ref
= IFileSaveDialog_Release(pfsd
);
977 ok(!ref
, "Got refcount %d, should have been released.\n", ref
);
980 static void ensure_zero_events_(const char *file
, int line
, IFileDialogEventsImpl
*impl
)
982 ok_(file
, line
)(!impl
->OnFileOk
, "OnFileOk: %d\n", impl
->OnFileOk
);
983 ok_(file
, line
)(!impl
->OnFolderChanging
, "OnFolderChanging: %d\n", impl
->OnFolderChanging
);
984 ok_(file
, line
)(!impl
->OnFolderChange
, "OnFolderChange: %d\n", impl
->OnFolderChange
);
985 ok_(file
, line
)(!impl
->OnSelectionChange
, "OnSelectionChange: %d\n", impl
->OnSelectionChange
);
986 ok_(file
, line
)(!impl
->OnShareViolation
, "OnShareViolation: %d\n", impl
->OnShareViolation
);
987 ok_(file
, line
)(!impl
->OnTypeChange
, "OnTypeChange: %d\n", impl
->OnTypeChange
);
988 ok_(file
, line
)(!impl
->OnOverwrite
, "OnOverwrite: %d\n", impl
->OnOverwrite
);
989 impl
->OnFileOk
= impl
->OnFolderChanging
= impl
->OnFolderChange
= 0;
990 impl
->OnSelectionChange
= impl
->OnShareViolation
= impl
->OnTypeChange
= 0;
991 impl
->OnOverwrite
= 0;
993 #define ensure_zero_events(impl) ensure_zero_events_(__FILE__, __LINE__, impl)
995 static void test_advise_helper(IFileDialog
*pfd
)
997 IFileDialogEventsImpl
*pfdeimpl
;
998 IFileDialogEvents
*pfde
;
1003 pfde
= IFileDialogEvents_Constructor();
1004 pfdeimpl
= impl_from_IFileDialogEvents(pfde
);
1006 hr
= IFileDialog_Advise(pfd
, NULL
, NULL
);
1007 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
1008 hr
= IFileDialog_Advise(pfd
, pfde
, NULL
);
1009 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
1010 hr
= IFileDialog_Advise(pfd
, NULL
, &cookie
[0]);
1011 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
1012 ok(pfdeimpl
->ref
== 1, "got ref %d\n", pfdeimpl
->ref
);
1013 ensure_zero_events(pfdeimpl
);
1015 hr
= IFileDialog_Unadvise(pfd
, 0);
1016 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
1017 for(i
= 0; i
< 10; i
++) {
1018 hr
= IFileDialog_Advise(pfd
, pfde
, &cookie
[i
]);
1019 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1020 ok(cookie
[i
] == i
+1, "Got cookie: %d\n", cookie
[i
]);
1022 ok(pfdeimpl
->ref
== 10+1, "got ref %d\n", pfdeimpl
->ref
);
1023 ensure_zero_events(pfdeimpl
);
1025 for(i
= 3; i
< 7; i
++) {
1026 hr
= IFileDialog_Unadvise(pfd
, cookie
[i
]);
1027 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1029 ok(pfdeimpl
->ref
== 6+1, "got ref %d\n", pfdeimpl
->ref
);
1030 ensure_zero_events(pfdeimpl
);
1032 for(i
= 0; i
< 3; i
++) {
1033 hr
= IFileDialog_Unadvise(pfd
, cookie
[i
]);
1034 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1036 ok(pfdeimpl
->ref
== 3+1, "got ref %d\n", pfdeimpl
->ref
);
1037 ensure_zero_events(pfdeimpl
);
1039 for(i
= 7; i
< 10; i
++) {
1040 hr
= IFileDialog_Unadvise(pfd
, cookie
[i
]);
1041 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1043 ok(pfdeimpl
->ref
== 1, "got ref %d\n", pfdeimpl
->ref
);
1044 ensure_zero_events(pfdeimpl
);
1046 hr
= IFileDialog_Unadvise(pfd
, cookie
[9]+1);
1047 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
1048 ok(pfdeimpl
->ref
== 1, "got ref %d\n", pfdeimpl
->ref
);
1049 ensure_zero_events(pfdeimpl
);
1051 hr
= IFileDialog_Advise(pfd
, pfde
, &cookie
[0]);
1052 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1053 todo_wine
ok(cookie
[0] == 1, "got cookie: %d\n", cookie
[0]);
1054 ok(pfdeimpl
->ref
== 1+1, "got ref %d\n", pfdeimpl
->ref
);
1055 ensure_zero_events(pfdeimpl
);
1057 hr
= IFileDialog_Unadvise(pfd
, cookie
[0]);
1061 /* Unadvising already unadvised cookies crashes on
1063 IFileDialog_Unadvise(pfd
, cookie
[0]);
1067 IFileDialogEvents_Release(pfde
);
1070 static void test_advise(void)
1076 trace("Testing FileOpenDialog (advise)\n");
1077 hr
= CoCreateInstance(&CLSID_FileOpenDialog
, NULL
, CLSCTX_INPROC_SERVER
,
1078 &IID_IFileDialog
, (void**)&pfd
);
1079 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1080 test_advise_helper(pfd
);
1081 ref
= IFileDialog_Release(pfd
);
1082 ok(!ref
, "Got refcount %d, should have been released.\n", ref
);
1084 trace("Testing FileSaveDialog (advise)\n");
1085 hr
= CoCreateInstance(&CLSID_FileSaveDialog
, NULL
, CLSCTX_INPROC_SERVER
,
1086 &IID_IFileDialog
, (void**)&pfd
);
1087 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1088 test_advise_helper(pfd
);
1089 ref
= IFileDialog_Release(pfd
);
1090 ok(!ref
, "Got refcount %d, should have been released.\n", ref
);
1093 static void filedialog_change_filetype(IFileDialog
*pfd
, HWND dlg_hwnd
)
1096 const WCHAR filetype1
[] = {'f','n','a','m','e','1',0};
1097 const WCHAR filetype1_broken
[] = {'f','n','a','m','e','1',' ', '(','*','.','t','x','t',')',0};
1099 cb_filetype
= find_window(dlg_hwnd
, NULL
, filetype1
);
1100 ok(cb_filetype
!= NULL
|| broken(cb_filetype
== NULL
), "Could not find combobox on first attempt\n");
1104 /* Not sure when this happens. Some specific version?
1105 * Seen on 32-bit English Vista */
1106 trace("Didn't find combobox on first attempt, trying broken string..\n");
1107 cb_filetype
= find_window(dlg_hwnd
, NULL
, filetype1_broken
);
1108 ok(broken(cb_filetype
!= NULL
), "Failed to find combobox on second attempt\n");
1113 /* Making the combobox send a CBN_SELCHANGE */
1114 SendMessageW( cb_filetype
, CB_SHOWDROPDOWN
, 1, 0 );
1115 SendMessageW( cb_filetype
, CB_SETCURSEL
, 1, 0 );
1116 SendMessageW( cb_filetype
, WM_LBUTTONDOWN
, 0, -1 );
1117 SendMessageW( cb_filetype
, WM_LBUTTONUP
, 0, -1 );
1120 static void test_events(void)
1123 IFileDialogEventsImpl
*pfdeimpl
;
1124 IFileDialogEvents
*pfde
;
1128 const WCHAR fname1
[] = {'f','n','a','m','e','1', 0};
1129 const WCHAR fspec1
[] = {'*','.','t','x','t',0};
1130 const WCHAR fname2
[] = {'f','n','a','m','e','2', 0};
1131 const WCHAR fspec2
[] = {'*','.','e','x','e',0};
1132 COMDLG_FILTERSPEC filterspec
[3] = {{fname1
, fspec1
}, {fname2
, fspec2
}};
1136 * 1. Show the dialog with no filetypes added
1138 hr
= CoCreateInstance(&CLSID_FileOpenDialog
, NULL
, CLSCTX_INPROC_SERVER
,
1139 &IID_IFileDialog
, (void**)&pfd
);
1140 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1142 pfde
= IFileDialogEvents_Constructor();
1143 pfdeimpl
= impl_from_IFileDialogEvents(pfde
);
1144 pfdeimpl
->events_test
= IFDEVENT_TEST2
;
1146 hr
= IFileDialog_Advise(pfd
, pfde
, &cookie
);
1147 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1149 hr
= IFileDialog_Show(pfd
, NULL
);
1150 ok(hr
== HRESULT_FROM_WIN32(ERROR_CANCELLED
), "got 0x%08x.\n", hr
);
1152 ok(pfdeimpl
->OnFolderChanging
== 1, "Got %d\n", pfdeimpl
->OnFolderChanging
);
1153 pfdeimpl
->OnFolderChanging
= 0;
1154 ok(pfdeimpl
->OnFolderChange
== 1, "Got %d\n", pfdeimpl
->OnFolderChange
);
1155 pfdeimpl
->OnFolderChange
= 0;
1156 /* pfdeimpl->OnSelectionChange too unreliable to test. Can be 0, 1 or even 2. */
1157 pfdeimpl
->OnSelectionChange
= 0;
1158 ok(pfdeimpl
->OnTypeChange
== 0, "Got %d\n", pfdeimpl
->OnTypeChange
);
1159 pfdeimpl
->OnTypeChange
= 0;
1161 ensure_zero_events(pfdeimpl
);
1163 hr
= IFileDialog_Unadvise(pfd
, cookie
);
1164 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1166 IFileDialogEvents_Release(pfde
);
1167 ref
= IFileDialog_Release(pfd
);
1168 ok(!ref
|| broken(ref
/* win2008_64 (intermittently) */), "Got %d\n", ref
);
1172 * 2. Show the dialog with filetypes added
1174 hr
= CoCreateInstance(&CLSID_FileOpenDialog
, NULL
, CLSCTX_INPROC_SERVER
,
1175 &IID_IFileDialog
, (void**)&pfd
);
1176 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1178 pfde
= IFileDialogEvents_Constructor();
1179 pfdeimpl
= impl_from_IFileDialogEvents(pfde
);
1180 pfdeimpl
->events_test
= IFDEVENT_TEST2
;
1182 hr
= IFileDialog_Advise(pfd
, pfde
, &cookie
);
1183 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1185 hr
= IFileDialog_SetFileTypes(pfd
, 2, filterspec
);
1186 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1188 ensure_zero_events(pfdeimpl
);
1190 hr
= IFileDialog_Show(pfd
, NULL
);
1191 ok(hr
== HRESULT_FROM_WIN32(ERROR_CANCELLED
), "got 0x%08x.\n", hr
);
1193 ok(pfdeimpl
->OnFolderChanging
== 1, "Got %d\n", pfdeimpl
->OnFolderChanging
);
1194 pfdeimpl
->OnFolderChanging
= 0;
1195 ok(pfdeimpl
->OnFolderChange
== 1, "Got %d\n", pfdeimpl
->OnFolderChange
);
1196 pfdeimpl
->OnFolderChange
= 0;
1197 /* pfdeimpl->OnSelectionChange too unreliable to test. Can be 0, 1 or even 2. */
1198 pfdeimpl
->OnSelectionChange
= 0;
1199 /* Called once just by showing the dialog */
1200 todo_wine
ok(pfdeimpl
->OnTypeChange
== 1, "Got %d\n", pfdeimpl
->OnTypeChange
);
1201 pfdeimpl
->OnTypeChange
= 0;
1203 ensure_zero_events(pfdeimpl
);
1205 hr
= IFileDialog_Unadvise(pfd
, cookie
);
1206 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1208 IFileDialogEvents_Release(pfde
);
1209 ref
= IFileDialog_Release(pfd
);
1210 ok(!ref
|| broken(ref
/* win2008_64 (intermittently) */), "Got %d\n", ref
);
1214 * 3. Show the dialog with filetypes added and simulate manual change of filetype
1216 hr
= CoCreateInstance(&CLSID_FileOpenDialog
, NULL
, CLSCTX_INPROC_SERVER
,
1217 &IID_IFileDialog
, (void**)&pfd
);
1218 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1220 pfde
= IFileDialogEvents_Constructor();
1221 pfdeimpl
= impl_from_IFileDialogEvents(pfde
);
1222 pfdeimpl
->events_test
= IFDEVENT_TEST3
;
1224 hr
= IFileDialog_Advise(pfd
, pfde
, &cookie
);
1225 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1227 hr
= IFileDialog_SetFileTypes(pfd
, 2, filterspec
);
1228 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1230 ensure_zero_events(pfdeimpl
);
1232 hr
= IFileDialog_Show(pfd
, NULL
);
1233 ok(hr
== HRESULT_FROM_WIN32(ERROR_CANCELLED
), "got 0x%08x.\n", hr
);
1235 ok(pfdeimpl
->OnFolderChanging
== 1, "Got %d\n", pfdeimpl
->OnFolderChanging
);
1236 pfdeimpl
->OnFolderChanging
= 0;
1237 ok(pfdeimpl
->OnFolderChange
== 1, "Got %d\n", pfdeimpl
->OnFolderChange
);
1238 pfdeimpl
->OnFolderChange
= 0;
1239 /* pfdeimpl->OnSelectionChange too unreliable to test. Can be 0, 1 or even 2. */
1240 pfdeimpl
->OnSelectionChange
= 0;
1241 /* Called once by showing the dialog and once again when changing the filetype */
1242 todo_wine
ok(pfdeimpl
->OnTypeChange
== 2, "Got %d\n", pfdeimpl
->OnTypeChange
);
1243 pfdeimpl
->OnTypeChange
= 0;
1245 ensure_zero_events(pfdeimpl
);
1247 hr
= IFileDialog_Unadvise(pfd
, cookie
);
1248 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1250 IFileDialogEvents_Release(pfde
);
1251 ref
= IFileDialog_Release(pfd
);
1252 ok(!ref
|| broken(ref
/* win2008_64 (intermittently) */), "Got %d\n", ref
);
1255 static void touch_file(LPCWSTR filename
)
1258 file
= CreateFileW(filename
, GENERIC_WRITE
, 0, NULL
, CREATE_NEW
, FILE_ATTRIBUTE_NORMAL
, NULL
);
1259 ok(file
!= INVALID_HANDLE_VALUE
, "Failed to create file.\n");
1263 static void test_filename_savedlg_(LPCWSTR set_filename
, LPCWSTR defext
,
1264 const COMDLG_FILTERSPEC
*filterspec
, UINT fs_count
,
1265 LPCWSTR exp_filename
, const char *file
, int line
)
1267 IFileSaveDialog
*pfsd
;
1268 IFileDialogEventsImpl
*pfdeimpl
;
1269 IFileDialogEvents
*pfde
;
1276 hr
= CoCreateInstance(&CLSID_FileSaveDialog
, NULL
, CLSCTX_INPROC_SERVER
,
1277 &IID_IFileSaveDialog
, (void**)&pfsd
);
1278 ok_(file
,line
)(hr
== S_OK
, "Got 0x%08x\n", hr
);
1282 hr
= IFileSaveDialog_SetFileTypes(pfsd
, fs_count
, filterspec
);
1283 ok_(file
,line
)(hr
== S_OK
, "SetFileTypes failed: Got 0x%08x\n", hr
);
1288 hr
= IFileSaveDialog_SetDefaultExtension(pfsd
, defext
);
1289 ok_(file
,line
)(hr
== S_OK
, "SetDefaultExtensions failed: Got 0x%08x\n", hr
);
1292 pfde
= IFileDialogEvents_Constructor();
1293 pfdeimpl
= impl_from_IFileDialogEvents(pfde
);
1294 pfdeimpl
->set_filename
= set_filename
;
1295 hr
= IFileSaveDialog_Advise(pfsd
, pfde
, &cookie
);
1296 ok_(file
,line
)(hr
== S_OK
, "Advise failed: Got 0x%08x\n", hr
);
1298 hr
= IFileSaveDialog_Show(pfsd
, NULL
);
1299 ok_(file
,line
)(hr
== S_OK
, "Show failed: Got 0x%08x\n", hr
);
1301 hr
= IFileSaveDialog_GetFileName(pfsd
, &filename
);
1302 ok_(file
,line
)(hr
== S_OK
, "GetFileName failed: Got 0x%08x\n", hr
);
1303 ok_(file
,line
)(!lstrcmpW(filename
, set_filename
), "Got %s\n", wine_dbgstr_w(filename
));
1304 CoTaskMemFree(filename
);
1306 hr
= IFileSaveDialog_GetResult(pfsd
, &psi
);
1307 ok_(file
,line
)(hr
== S_OK
, "GetResult failed: Got 0x%08x\n", hr
);
1309 hr
= IShellItem_GetDisplayName(psi
, SIGDN_PARENTRELATIVEPARSING
, &filename
);
1310 ok_(file
,line
)(hr
== S_OK
, "GetDisplayName failed: Got 0x%08x\n", hr
);
1311 ok_(file
,line
)(!lstrcmpW(filename
, exp_filename
), "(GetDisplayName) Got %s\n", wine_dbgstr_w(filename
));
1312 CoTaskMemFree(filename
);
1313 IShellItem_Release(psi
);
1315 hr
= IFileSaveDialog_Unadvise(pfsd
, cookie
);
1316 ok_(file
,line
)(hr
== S_OK
, "Unadvise failed: Got 0x%08x\n", hr
);
1318 ref
= IFileSaveDialog_Release(pfsd
);
1319 ok_(file
,line
)(!ref
, "Got refcount %d, should have been released.\n", ref
);
1321 IFileDialogEvents_Release(pfde
);
1323 #define test_filename_savedlg(set_filename, defext, filterspec, fs_count, exp_filename) \
1324 test_filename_savedlg_(set_filename, defext, filterspec, fs_count, exp_filename, __FILE__, __LINE__)
1326 static void test_filename_opendlg_(LPCWSTR set_filename
, IShellItem
*psi_current
, LPCWSTR defext
,
1327 const COMDLG_FILTERSPEC
*filterspec
, UINT fs_count
,
1328 LPCWSTR exp_filename
, const char *file
, int line
)
1330 IFileOpenDialog
*pfod
;
1331 IFileDialogEventsImpl
*pfdeimpl
;
1332 IFileDialogEvents
*pfde
;
1335 IShellItemArray
*psia
;
1340 hr
= CoCreateInstance(&CLSID_FileOpenDialog
, NULL
, CLSCTX_INPROC_SERVER
,
1341 &IID_IFileOpenDialog
, (void**)&pfod
);
1342 ok_(file
,line
)(hr
== S_OK
, "CoCreateInstance failed: Got 0x%08x\n", hr
);
1346 hr
= IFileOpenDialog_SetDefaultExtension(pfod
, defext
);
1347 ok_(file
,line
)(hr
== S_OK
, "SetDefaultExtensions failed: Got 0x%08x\n", hr
);
1352 hr
= IFileOpenDialog_SetFileTypes(pfod
, 2, filterspec
);
1353 ok_(file
,line
)(hr
== S_OK
, "SetFileTypes failed: Got 0x%08x\n", hr
);
1356 hr
= IFileOpenDialog_SetFolder(pfod
, psi_current
);
1357 ok_(file
,line
)(hr
== S_OK
, "SetFolder failed: Got 0x%08x\n", hr
);
1359 pfde
= IFileDialogEvents_Constructor();
1360 pfdeimpl
= impl_from_IFileDialogEvents(pfde
);
1361 pfdeimpl
->set_filename
= set_filename
;
1362 pfdeimpl
->set_filename_tried
= FALSE
;
1363 hr
= IFileOpenDialog_Advise(pfod
, pfde
, &cookie
);
1364 ok_(file
,line
)(hr
== S_OK
, "Advise failed: Got 0x%08x\n", hr
);
1366 hr
= IFileOpenDialog_Show(pfod
, NULL
);
1367 ok_(file
,line
)(hr
== S_OK
|| (!exp_filename
&& hr
== HRESULT_FROM_WIN32(ERROR_CANCELLED
)),
1368 "Show failed: Got 0x%08x\n", hr
);
1371 hr
= IFileOpenDialog_GetResult(pfod
, &psi
);
1372 ok_(file
,line
)(hr
== S_OK
, "GetResult failed: Got 0x%08x\n", hr
);
1374 hr
= IShellItem_GetDisplayName(psi
, SIGDN_PARENTRELATIVEPARSING
, &filename
);
1375 ok_(file
,line
)(hr
== S_OK
, "GetDisplayName(Result) failed: Got 0x%08x\n", hr
);
1376 ok_(file
,line
)(!lstrcmpW(filename
, exp_filename
), "(GetResult) Got %s\n", wine_dbgstr_w(filename
));
1377 CoTaskMemFree(filename
);
1378 IShellItem_Release(psi
);
1380 hr
= IFileOpenDialog_GetResults(pfod
, &psia
);
1381 ok_(file
,line
)(hr
== S_OK
, "GetResults failed: Got 0x%08x\n", hr
);
1382 hr
= IShellItemArray_GetItemAt(psia
, 0, &psi
);
1383 ok_(file
,line
)(hr
== S_OK
, "GetItemAt failed: Got 0x%08x\n", hr
);
1385 hr
= IShellItem_GetDisplayName(psi
, SIGDN_PARENTRELATIVEPARSING
, &filename
);
1386 ok_(file
,line
)(hr
== S_OK
, "GetDisplayName(Results) failed: Got 0x%08x\n", hr
);
1387 ok_(file
,line
)(!lstrcmpW(filename
, exp_filename
), "(GetResults) Got %s\n", wine_dbgstr_w(filename
));
1388 CoTaskMemFree(filename
);
1390 IShellItem_Release(psi
);
1391 IShellItemArray_Release(psia
);
1395 hr
= IFileOpenDialog_GetResult(pfod
, &psi
);
1396 ok_(file
,line
)(hr
== E_UNEXPECTED
, "GetResult: Got 0x%08x\n", hr
);
1398 hr
= IFileOpenDialog_GetResults(pfod
, &psia
);
1399 ok_(file
,line
)(hr
== E_FAIL
, "GetResults: Got 0x%08x\n", hr
);
1402 hr
= IFileOpenDialog_GetFileName(pfod
, &filename
);
1403 ok_(file
,line
)(hr
== S_OK
, "GetFileName failed: Got 0x%08x\n", hr
);
1404 ok_(file
,line
)(!lstrcmpW(filename
, set_filename
), "(GetFileName) Got %s\n", wine_dbgstr_w(filename
));
1405 CoTaskMemFree(filename
);
1408 hr
= IFileOpenDialog_Unadvise(pfod
, cookie
);
1409 ok_(file
,line
)(hr
== S_OK
, "Unadvise failed: Got 0x%08x\n", hr
);
1411 ref
= IFileOpenDialog_Release(pfod
);
1412 ok_(file
,line
)(!ref
, "Got refcount %d, should have been released.\n", ref
);
1414 IFileDialogEvents_Release(pfde
);
1416 #define test_filename_opendlg(set_filename, psi, defext, filterspec, fs_count, exp_filename) \
1417 test_filename_opendlg_(set_filename, psi, defext, filterspec, fs_count, exp_filename, __FILE__, __LINE__)
1419 static void test_filename(void)
1421 IShellItem
*psi_current
;
1423 WCHAR buf
[MAX_PATH
];
1425 static const WCHAR filename_noextW
[] = {'w','i','n','e','t','e','s','t',0};
1426 static const WCHAR filename_dotextW
[] = {'w','i','n','e','t','e','s','t','.',0};
1427 static const WCHAR filename_dotanddefW
[] = {'w','i','n','e','t','e','s','t','.','.','w','t','e',0};
1428 static const WCHAR filename_defextW
[] = {'w','i','n','e','t','e','s','t','.','w','t','e',0};
1429 static const WCHAR filename_ext1W
[] = {'w','i','n','e','t','e','s','t','.','w','t','1',0};
1430 static const WCHAR filename_ext2W
[] = {'w','i','n','e','t','e','s','t','.','w','t','2',0};
1431 static const WCHAR filename_ext1anddefW
[] =
1432 {'w','i','n','e','t','e','s','t','.','w','t','1','.','w','t','e',0};
1433 static const WCHAR defextW
[] = {'w','t','e',0};
1434 static const WCHAR desc1
[] = {'d','e','s','c','r','i','p','t','i','o','n','1',0};
1435 static const WCHAR desc2
[] = {'d','e','s','c','r','i','p','t','i','o','n','2',0};
1436 static const WCHAR descdef
[] = {'d','e','f','a','u','l','t',' ','d','e','s','c',0};
1437 static const WCHAR ext1
[] = {'*','.','w','t','1',0};
1438 static const WCHAR ext2
[] = {'*','.','w','t','2',0};
1439 static const WCHAR extdef
[] = {'*','.','w','t','e',0};
1440 static const WCHAR complexext
[] = {'*','.','w','t','2',';','*','.','w','t','1',0};
1442 static const COMDLG_FILTERSPEC filterspec
[] = {
1443 { desc1
, ext1
}, { desc2
, ext2
}, { descdef
, extdef
}
1445 static const COMDLG_FILTERSPEC filterspec2
[] = {
1446 { desc1
, complexext
}
1450 test_filename_savedlg(filename_noextW
, NULL
, NULL
, 0, filename_noextW
);
1451 /* Default extension */
1452 test_filename_savedlg(filename_noextW
, defextW
, NULL
, 0, filename_defextW
);
1453 /* Default extension on filename ending with a . */
1454 test_filename_savedlg(filename_dotextW
, defextW
, NULL
, 0, filename_dotanddefW
);
1455 /* Default extension on filename with default extension */
1456 test_filename_savedlg(filename_defextW
, defextW
, NULL
, 0, filename_defextW
);
1457 /* Default extension on filename with another extension */
1458 test_filename_savedlg(filename_ext1W
, defextW
, NULL
, 0, filename_ext1anddefW
);
1459 /* Default extension, filterspec without default extension */
1460 test_filename_savedlg(filename_noextW
, defextW
, filterspec
, 2, filename_ext1W
);
1461 /* Default extension, filterspec with default extension */
1462 test_filename_savedlg(filename_noextW
, defextW
, filterspec
, 3, filename_ext1W
);
1463 /* Default extension, filterspec with "complex" extension */
1464 test_filename_savedlg(filename_noextW
, defextW
, filterspec2
, 1, filename_ext2W
);
1466 GetCurrentDirectoryW(MAX_PATH
, buf
);
1467 ok(!!pSHCreateItemFromParsingName
, "SHCreateItemFromParsingName is missing.\n");
1468 hr
= pSHCreateItemFromParsingName(buf
, NULL
, &IID_IShellItem
, (void**)&psi_current
);
1469 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
1471 touch_file(filename_noextW
);
1472 touch_file(filename_defextW
);
1473 touch_file(filename_ext2W
);
1475 /* IFileOpenDialog, default extension */
1476 test_filename_opendlg(filename_noextW
, psi_current
, defextW
, NULL
, 0, filename_noextW
);
1477 /* IFileOpenDialog, default extension and filterspec */
1478 test_filename_opendlg(filename_noextW
, psi_current
, defextW
, filterspec
, 2, filename_noextW
);
1480 DeleteFileW(filename_noextW
);
1481 /* IFileOpenDialog, default extension, noextW deleted */
1482 test_filename_opendlg(filename_noextW
, psi_current
, defextW
, NULL
, 0, filename_defextW
);
1483 if(0) /* Interactive */
1485 /* IFileOpenDialog, filterspec, no default extension, noextW deleted */
1486 test_filename_opendlg(filename_noextW
, psi_current
, NULL
, filterspec
, 2, NULL
);
1489 IShellItem_Release(psi_current
);
1490 DeleteFileW(filename_defextW
);
1491 DeleteFileW(filename_ext2W
);
1494 static const WCHAR label
[] = {'l','a','b','e','l',0};
1495 static const WCHAR label2
[] = {'t','e','s','t',0};
1496 static const WCHAR menuW
[] = {'m','e','n','u','_','i','t','e','m',0};
1497 static const WCHAR pushbutton1W
[] = {'p','u','s','h','b','u','t','t','o','n','_','i','t','e','m',0};
1498 static const WCHAR pushbutton2W
[] = {'p','u','s','h','b','u','t','t','o','n','2','_','i','t','e','m',0};
1499 static const WCHAR comboboxitem1W
[] = {'c','o','m','b','o','b','o','x','1','_','i','t','e','m',0};
1500 static const WCHAR comboboxitem2W
[] = {'c','o','m','b','o','b','o','x','2','_','i','t','e','m',0};
1501 static const WCHAR radiobutton1W
[] = {'r','a','d','i','o','b','u','t','t','o','n','1','_','i','t','e','m',0};
1502 static const WCHAR radiobutton2W
[] = {'r','a','d','i','o','b','u','t','t','o','n','2','_','i','t','e','m',0};
1503 static const WCHAR checkbutton1W
[] = {'c','h','e','c','k','b','u','t','t','o','n','1','_','i','t','e','m',0};
1504 static const WCHAR checkbutton2W
[] = {'c','h','e','c','k','b','u','t','t','o','n','2','_','i','t','e','m',0};
1505 static const WCHAR editbox1W
[] = {'e','d','i','t','b','o','x','W','1','_','i','t','e','m',0};
1506 static const WCHAR editbox2W
[] = {'e','d','i','t','b','o','x','W','2','_','i','t','e','m',0};
1507 static const WCHAR textW
[] = {'t','e','x','t','_','i','t','e','m',0};
1508 static const WCHAR text2W
[] = {'t','e','x','t','2','_','i','t','e','m',0};
1509 static const WCHAR separatorW
[] = {'s','e','p','a','r','a','t','o','r','_','i','t','e','m',0};
1510 static const WCHAR visualgroup1W
[] = {'v','i','s','u','a','l','g','r','o','u','p','1',0};
1511 static const WCHAR visualgroup2W
[] = {'v','i','s','u','a','l','g','r','o','u','p','2',0};
1513 static const WCHAR floatnotifysinkW
[] = {'F','l','o','a','t','N','o','t','i','f','y','S','i','n','k',0};
1514 static const WCHAR RadioButtonListW
[] = {'R','a','d','i','o','B','u','t','t','o','n','L','i','s','t',0};
1516 static void test_customize_onfolderchange(IFileDialog
*pfd
)
1518 HWND dlg_hwnd
, item
, item_parent
;
1524 dlg_hwnd
= get_hwnd_from_ifiledialog(pfd
);
1525 ok(dlg_hwnd
!= NULL
, "Got NULL.\n");
1527 item
= find_window(dlg_hwnd
, NULL
, checkbutton2W
);
1528 ok(item
!= NULL
, "Failed to find item.\n");
1529 item_parent
= GetParent(item
);
1530 GetClassNameW(item_parent
, buf
, 1024);
1531 ok(!lstrcmpW(buf
, floatnotifysinkW
), "Got %s\n", wine_dbgstr_w(buf
));
1532 item
= find_window(dlg_hwnd
, NULL
, text2W
);
1533 ok(item
!= NULL
, "Failed to find item.\n");
1534 item_parent
= GetParent(item
);
1535 GetClassNameW(item_parent
, buf
, 1024);
1536 ok(!lstrcmpW(buf
, floatnotifysinkW
), "Got %s\n", wine_dbgstr_w(buf
));
1537 item
= find_window(dlg_hwnd
, NULL
, radiobutton1W
);
1538 todo_wine
ok(item
!= NULL
, "Failed to find item.\n");
1539 item_parent
= GetParent(item
);
1540 GetClassNameW(item_parent
, buf
, 1024);
1541 todo_wine
ok(!lstrcmpW(buf
, RadioButtonListW
), "Got %s\n", wine_dbgstr_w(buf
));
1542 item_parent
= GetParent(item_parent
);
1543 GetClassNameW(item_parent
, buf
, 1024);
1544 ok(!lstrcmpW(buf
, floatnotifysinkW
), "Got %s\n", wine_dbgstr_w(buf
));
1546 item
= find_window(dlg_hwnd
, NULL
, pushbutton1W
);
1547 ok(item
== NULL
, "Found item: %p\n", item
);
1548 item
= find_window(dlg_hwnd
, NULL
, pushbutton2W
);
1549 ok(item
== NULL
, "Found item: %p\n", item
);
1550 item
= find_window(dlg_hwnd
, NULL
, comboboxitem1W
);
1551 ok(item
== NULL
, "Found item: %p\n", item
);
1552 item
= find_window(dlg_hwnd
, NULL
, comboboxitem2W
);
1553 ok(item
== NULL
, "Found item: %p\n", item
);
1554 item
= find_window(dlg_hwnd
, NULL
, radiobutton2W
);
1555 ok(item
== NULL
, "Found item: %p\n", item
);
1556 item
= find_window(dlg_hwnd
, NULL
, checkbutton1W
);
1557 ok(item
== NULL
, "Found item: %p\n", item
);
1558 item
= find_window(dlg_hwnd
, NULL
, editbox1W
);
1559 ok(item
== NULL
, "Found item: %p\n", item
);
1560 item
= find_window(dlg_hwnd
, NULL
, editbox2W
);
1561 ok(item
== NULL
, "Found item: %p\n", item
);
1562 item
= find_window(dlg_hwnd
, NULL
, textW
);
1563 ok(item
== NULL
, "Found item: %p\n", item
);
1564 item
= find_window(dlg_hwnd
, NULL
, separatorW
);
1565 ok(item
== NULL
, "Found item: %p\n", item
);
1566 item
= find_window(dlg_hwnd
, NULL
, visualgroup1W
);
1567 ok(item
== NULL
, "Found item: %p\n", item
);
1568 item
= find_window(dlg_hwnd
, NULL
, visualgroup2W
);
1569 todo_wine
ok(item
== NULL
, "Found item: %p\n", item
);
1571 br
= PostMessageW(dlg_hwnd
, WM_COMMAND
, IDCANCEL
, 0);
1575 static void test_customize(void)
1578 IFileDialogCustomize
*pfdc
;
1579 IFileDialogEventsImpl
*pfdeimpl
;
1580 IFileDialogEvents
*pfde
;
1582 CDCONTROLSTATEF cdstate
;
1586 UINT id_vgroup1
, id_text
, id_editbox1
;
1590 hr
= CoCreateInstance(&CLSID_FileOpenDialog
, NULL
, CLSCTX_INPROC_SERVER
,
1591 &IID_IFileDialog
, (void**)&pfod
);
1592 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1594 hr
= IFileDialog_QueryInterface(pfod
, &IID_IFileDialogCustomize
, (void**)&pfdc
);
1595 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1598 skip("Skipping IFileDialogCustomize tests.\n");
1599 IFileDialog_Release(pfod
);
1604 hr
= IFileDialogCustomize_AddPushButton(pfdc
, i
, pushbutton1W
);
1605 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1606 hr
= IFileDialogCustomize_AddPushButton(pfdc
, i
, pushbutton1W
);
1607 ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
1609 hr
= IFileDialog_QueryInterface(pfod
, &IID_IOleWindow
, (void**)&pow
);
1610 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
1611 hr
= IOleWindow_GetWindow(pow
, &dlg_hwnd
);
1612 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
1613 ok(dlg_hwnd
== NULL
, "NULL\n");
1614 IOleWindow_Release(pow
);
1616 cdstate
= 0xdeadbeef;
1617 hr
= IFileDialogCustomize_GetControlState(pfdc
, i
, &cdstate
);
1618 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1619 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1621 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, 0, label
);
1622 ok(hr
== E_NOINTERFACE
, "got 0x%08x.\n", hr
);
1624 hr
= IFileDialogCustomize_SetControlLabel(pfdc
, i
, label2
);
1625 ok(hr
== S_OK
, "got 0x%08x (control: %d).\n", hr
, i
);
1627 hr
= IFileDialogCustomize_EnableOpenDropDown(pfdc
, i
);
1628 todo_wine
ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
1629 hr
= IFileDialogCustomize_EnableOpenDropDown(pfdc
, ++i
);
1630 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1632 cdstate
= 0xdeadbeef;
1633 hr
= IFileDialogCustomize_GetControlState(pfdc
, i
, &cdstate
);
1634 ok(hr
== E_NOTIMPL
, "got 0x%08x.\n", hr
);
1635 ok(cdstate
== 0xdeadbeef, "got 0x%08x.\n", cdstate
);
1637 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, 0, label
);
1638 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1639 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, 0, label
);
1640 todo_wine
ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
1642 cdstate
= 0xdeadbeef;
1643 hr
= IFileDialogCustomize_GetControlItemState(pfdc
, i
, 0, &cdstate
);
1644 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1645 todo_wine
ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1646 hr
= IFileDialogCustomize_SetControlItemState(pfdc
, i
, 0, 0);
1647 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1648 cdstate
= 0xdeadbeef;
1649 hr
= IFileDialogCustomize_GetControlItemState(pfdc
, i
, 0, &cdstate
);
1650 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1651 todo_wine
ok(!cdstate
, "got 0x%08x.\n", cdstate
);
1652 hr
= IFileDialogCustomize_SetControlItemState(pfdc
, i
, 0, CDCS_ENABLEDVISIBLE
);
1653 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1654 cdstate
= 0xdeadbeef;
1655 hr
= IFileDialogCustomize_GetControlItemState(pfdc
, i
, 0, &cdstate
);
1656 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1657 todo_wine
ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1659 hr
= IFileDialogCustomize_SetControlLabel(pfdc
, i
, label2
);
1660 todo_wine
ok(hr
== E_NOTIMPL
, "got 0x%08x (control: %d).\n", hr
, i
);
1662 hr
= IFileDialogCustomize_AddMenu(pfdc
, i
, menuW
);
1663 todo_wine
ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
1664 hr
= IFileDialogCustomize_AddMenu(pfdc
, ++i
, label
);
1665 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1667 cdstate
= 0xdeadbeef;
1668 hr
= IFileDialogCustomize_GetControlState(pfdc
, i
, &cdstate
);
1669 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1670 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1672 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, 0, label
);
1673 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1674 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, 0, label
);
1675 ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
1677 hr
= IFileDialogCustomize_SetControlLabel(pfdc
, i
, label2
);
1678 ok(hr
== S_OK
, "got 0x%08x (control: %d).\n", hr
, i
);
1680 hr
= IFileDialogCustomize_AddPushButton(pfdc
, i
, pushbutton2W
);
1681 ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
1682 hr
= IFileDialogCustomize_AddPushButton(pfdc
, ++i
, pushbutton2W
);
1683 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1685 cdstate
= 0xdeadbeef;
1686 hr
= IFileDialogCustomize_GetControlState(pfdc
, i
, &cdstate
);
1687 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1688 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1690 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, 0, label
);
1691 ok(hr
== E_NOINTERFACE
, "got 0x%08x.\n", hr
);
1693 hr
= IFileDialogCustomize_SetControlLabel(pfdc
, i
, label2
);
1694 ok(hr
== S_OK
, "got 0x%08x (control: %d).\n", hr
, i
);
1696 hr
= IFileDialogCustomize_AddComboBox(pfdc
, i
);
1697 ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
1698 hr
= IFileDialogCustomize_AddComboBox(pfdc
, ++i
);
1699 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1701 cdstate
= 0xdeadbeef;
1702 hr
= IFileDialogCustomize_GetControlState(pfdc
, i
, &cdstate
);
1703 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1704 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1706 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, 0, label
);
1707 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1708 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, 0, label
);
1709 ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
1711 hr
= IFileDialogCustomize_SetControlLabel(pfdc
, i
, label2
);
1712 ok(hr
== S_OK
, "got 0x%08x (control: %d).\n", hr
, i
);
1714 hr
= IFileDialogCustomize_AddRadioButtonList(pfdc
, i
);
1715 todo_wine
ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
1716 hr
= IFileDialogCustomize_AddRadioButtonList(pfdc
, ++i
);
1717 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1719 cdstate
= 0xdeadbeef;
1720 hr
= IFileDialogCustomize_GetControlState(pfdc
, i
, &cdstate
);
1721 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1722 todo_wine
ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1724 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, 0, radiobutton1W
);
1725 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1726 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, 0, radiobutton1W
);
1727 todo_wine
ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
1729 hr
= IFileDialogCustomize_SetControlLabel(pfdc
, i
, radiobutton2W
);
1730 todo_wine
ok(hr
== S_OK
, "got 0x%08x (control: %d).\n", hr
, i
);
1732 hr
= IFileDialogCustomize_AddCheckButton(pfdc
, i
, label
, TRUE
);
1733 todo_wine
ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
1734 hr
= IFileDialogCustomize_AddCheckButton(pfdc
, ++i
, checkbutton1W
, TRUE
);
1735 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1737 cdstate
= 0xdeadbeef;
1738 hr
= IFileDialogCustomize_GetControlState(pfdc
, i
, &cdstate
);
1739 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1740 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1742 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, 0, label
);
1743 ok(hr
== E_NOINTERFACE
, "got 0x%08x.\n", hr
);
1745 hr
= IFileDialogCustomize_SetControlLabel(pfdc
, i
, checkbutton2W
);
1746 ok(hr
== S_OK
, "got 0x%08x (control: %d).\n", hr
, i
);
1751 hr
= IFileDialogCustomize_GetCheckButtonState(pfdc
, i
, &checked
);
1752 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1753 ok(checked
, "checkbox not checked.\n");
1755 hr
= IFileDialogCustomize_SetCheckButtonState(pfdc
, i
, FALSE
);
1756 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1758 hr
= IFileDialogCustomize_GetCheckButtonState(pfdc
, i
, &checked
);
1759 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1760 ok(!checked
, "checkbox checked.\n");
1762 hr
= IFileDialogCustomize_SetCheckButtonState(pfdc
, i
, TRUE
);
1763 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1765 hr
= IFileDialogCustomize_GetCheckButtonState(pfdc
, i
, &checked
);
1766 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1767 ok(checked
, "checkbox not checked.\n");
1770 hr
= IFileDialogCustomize_AddEditBox(pfdc
, i
, label
);
1771 ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
1772 hr
= IFileDialogCustomize_AddEditBox(pfdc
, ++i
, editbox1W
);
1773 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1775 cdstate
= 0xdeadbeef;
1776 hr
= IFileDialogCustomize_GetControlState(pfdc
, i
, &cdstate
);
1777 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1778 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1780 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, 0, label
);
1781 ok(hr
== E_NOINTERFACE
, "got 0x%08x.\n", hr
);
1783 /* Does not affect the text in the editbox */
1784 hr
= IFileDialogCustomize_SetControlLabel(pfdc
, i
, editbox2W
);
1785 ok(hr
== S_OK
, "got 0x%08x (control: %d).\n", hr
, i
);
1787 hr
= IFileDialogCustomize_GetEditBoxText(pfdc
, i
, &tmpstr
);
1788 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1791 ok(!lstrcmpW(tmpstr
, editbox1W
), "got %s.\n", wine_dbgstr_w(tmpstr
));
1792 CoTaskMemFree(tmpstr
);
1795 hr
= IFileDialogCustomize_SetEditBoxText(pfdc
, i
, label2
);
1796 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1798 hr
= IFileDialogCustomize_GetEditBoxText(pfdc
, i
, &tmpstr
);
1799 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1802 ok(!lstrcmpW(tmpstr
, label2
), "got %s.\n", wine_dbgstr_w(tmpstr
));
1803 CoTaskMemFree(tmpstr
);
1806 hr
= IFileDialogCustomize_AddSeparator(pfdc
, i
);
1807 ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
1808 hr
= IFileDialogCustomize_AddSeparator(pfdc
, ++i
);
1809 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1811 cdstate
= 0xdeadbeef;
1812 hr
= IFileDialogCustomize_GetControlState(pfdc
, i
, &cdstate
);
1813 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1814 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1816 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, 0, label
);
1817 ok(hr
== E_NOINTERFACE
, "got 0x%08x.\n", hr
);
1819 hr
= IFileDialogCustomize_SetControlLabel(pfdc
, i
, separatorW
);
1820 ok(hr
== S_OK
, "got 0x%08x (control: %d).\n", hr
, i
);
1822 hr
= IFileDialogCustomize_AddText(pfdc
, i
, label
);
1823 ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
1824 hr
= IFileDialogCustomize_AddText(pfdc
, ++i
, textW
);
1825 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1827 cdstate
= 0xdeadbeef;
1828 hr
= IFileDialogCustomize_GetControlState(pfdc
, i
, &cdstate
);
1829 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1830 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1832 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, 0, label
);
1833 ok(hr
== E_NOINTERFACE
, "got 0x%08x.\n", hr
);
1835 hr
= IFileDialogCustomize_SetControlLabel(pfdc
, i
, text2W
);
1836 ok(hr
== S_OK
, "got 0x%08x (control: %d).\n", hr
, i
);
1838 hr
= IFileDialogCustomize_StartVisualGroup(pfdc
, i
, label
);
1839 ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
1840 hr
= IFileDialogCustomize_StartVisualGroup(pfdc
, ++i
, visualgroup1W
);
1841 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1843 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, 0, label
);
1844 ok(hr
== E_NOINTERFACE
, "got 0x%08x.\n", hr
);
1846 hr
= IFileDialogCustomize_SetControlLabel(pfdc
, i
, visualgroup2W
);
1847 ok(hr
== S_OK
, "got 0x%08x (control: %d).\n", hr
, i
);
1849 cdstate
= 0xdeadbeef;
1850 hr
= IFileDialogCustomize_GetControlState(pfdc
, i
, &cdstate
);
1851 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1852 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1854 hr
= IFileDialogCustomize_StartVisualGroup(pfdc
, ++i
, label
);
1855 ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
1856 hr
= IFileDialogCustomize_EndVisualGroup(pfdc
);
1857 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1859 i
++; /* Nonexisting control */
1860 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, 0, label
);
1861 todo_wine
ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
1862 hr
= IFileDialogCustomize_SetControlLabel(pfdc
, i
, label2
);
1863 ok(hr
== E_INVALIDARG
, "got 0x%08x (control: %d).\n", hr
, i
);
1864 cdstate
= 0xdeadbeef;
1865 hr
= IFileDialogCustomize_GetControlState(pfdc
, i
, &cdstate
);
1866 todo_wine
ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
1867 ok(cdstate
== 0xdeadbeef, "got 0x%08x.\n", cdstate
);
1869 pfde
= IFileDialogEvents_Constructor();
1870 pfdeimpl
= impl_from_IFileDialogEvents(pfde
);
1871 pfdeimpl
->events_test
= IFDEVENT_TEST1
;
1872 hr
= IFileDialog_Advise(pfod
, pfde
, &cookie
);
1873 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
1875 hr
= IFileDialog_Show(pfod
, NULL
);
1876 ok(hr
== HRESULT_FROM_WIN32(ERROR_CANCELLED
), "Got 0x%08x\n", hr
);
1878 hr
= IFileDialog_Unadvise(pfod
, cookie
);
1879 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
1881 IFileDialogEvents_Release(pfde
);
1882 IFileDialogCustomize_Release(pfdc
);
1883 ref
= IFileDialog_Release(pfod
);
1884 ok(!ref
, "Refcount not zero (%d).\n", ref
);
1887 hr
= CoCreateInstance(&CLSID_FileOpenDialog
, NULL
, CLSCTX_INPROC_SERVER
,
1888 &IID_IFileDialog
, (void**)&pfod
);
1889 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1891 hr
= IFileDialog_QueryInterface(pfod
, &IID_IFileDialogCustomize
, (void**)&pfdc
);
1892 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1895 hr
= IFileDialogCustomize_AddMenu(pfdc
, ++i
, label
);
1896 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1902 for(j
= 0; j
< 10; j
++)
1904 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, j
, label
);
1905 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1908 hr
= IFileDialogCustomize_GetSelectedControlItem(pfdc
, i
, &selected
);
1909 ok(hr
== E_NOTIMPL
, "got 0x%08x.\n", hr
);
1911 cdstate
= 0xdeadbeef;
1912 hr
= IFileDialogCustomize_GetControlItemState(pfdc
, i
, 0, &cdstate
);
1913 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1914 todo_wine
ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1915 hr
= IFileDialogCustomize_SetControlItemState(pfdc
, i
, 0, 0);
1916 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1917 cdstate
= 0xdeadbeef;
1918 hr
= IFileDialogCustomize_GetControlItemState(pfdc
, i
, 0, &cdstate
);
1919 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1920 todo_wine
ok(cdstate
== 0, "got 0x%08x.\n", cdstate
);
1921 hr
= IFileDialogCustomize_SetControlItemState(pfdc
, i
, 0, CDCS_ENABLEDVISIBLE
);
1922 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1923 cdstate
= 0xdeadbeef;
1924 hr
= IFileDialogCustomize_GetControlItemState(pfdc
, i
, 0, &cdstate
);
1925 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1926 todo_wine
ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1928 hr
= IFileDialogCustomize_RemoveAllControlItems(pfdc
, i
);
1929 ok(hr
== E_NOTIMPL
, "got 0x%08x.\n", hr
);
1931 for(j
= 0; j
< 10; j
++)
1933 hr
= IFileDialogCustomize_RemoveControlItem(pfdc
, i
, j
);
1934 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1937 hr
= IFileDialogCustomize_AddPushButton(pfdc
, ++i
, label
);
1938 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1939 hr
= IFileDialogCustomize_AddComboBox(pfdc
, ++i
);
1940 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1943 DWORD selected
= -1;
1946 for(j
= 0; j
< 10; j
++)
1948 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, j
, label
);
1949 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1952 hr
= IFileDialogCustomize_GetSelectedControlItem(pfdc
, i
, &selected
);
1953 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
1954 ok(selected
== -1, "got %d.\n", selected
);
1957 cdstate
= 0xdeadbeef;
1958 hr
= IFileDialogCustomize_GetControlItemState(pfdc
, i
, 0, &cdstate
);
1959 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1960 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1961 hr
= IFileDialogCustomize_SetControlItemState(pfdc
, i
, 0, 0);
1962 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1963 cdstate
= 0xdeadbeef;
1964 hr
= IFileDialogCustomize_GetControlItemState(pfdc
, i
, 0, &cdstate
);
1965 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1966 ok(cdstate
== 0, "got 0x%08x.\n", cdstate
);
1967 hr
= IFileDialogCustomize_SetControlItemState(pfdc
, i
, 0, CDCS_ENABLEDVISIBLE
);
1968 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1969 cdstate
= 0xdeadbeef;
1970 hr
= IFileDialogCustomize_GetControlItemState(pfdc
, i
, 0, &cdstate
);
1971 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1972 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1975 for(j
= 0; j
< 10; j
++)
1977 hr
= IFileDialogCustomize_SetSelectedControlItem(pfdc
, i
, j
);
1978 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1979 hr
= IFileDialogCustomize_GetSelectedControlItem(pfdc
, i
, &selected
);
1980 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1981 ok(selected
== j
, "got %d.\n", selected
);
1984 hr
= IFileDialogCustomize_SetSelectedControlItem(pfdc
, i
, j
);
1985 ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
1987 hr
= IFileDialogCustomize_RemoveAllControlItems(pfdc
, i
);
1988 ok(hr
== E_NOTIMPL
, "got 0x%08x.\n", hr
);
1990 for(j
= 0; j
< 10; j
++)
1992 hr
= IFileDialogCustomize_RemoveControlItem(pfdc
, i
, j
);
1993 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1997 hr
= IFileDialogCustomize_AddRadioButtonList(pfdc
, ++i
);
1998 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
2001 DWORD selected
= -1;
2004 for(j
= 0; j
< 10; j
++)
2006 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, j
, label
);
2007 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
2010 hr
= IFileDialogCustomize_GetSelectedControlItem(pfdc
, i
, &selected
);
2011 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
2012 ok(selected
== -1, "got %d.\n", selected
);
2015 cdstate
= 0xdeadbeef;
2016 hr
= IFileDialogCustomize_GetControlItemState(pfdc
, i
, 0, &cdstate
);
2017 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
2018 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
2019 hr
= IFileDialogCustomize_SetControlItemState(pfdc
, i
, 0, 0);
2020 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
2021 cdstate
= 0xdeadbeef;
2022 hr
= IFileDialogCustomize_GetControlItemState(pfdc
, i
, 0, &cdstate
);
2023 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
2024 ok(cdstate
== 0, "got 0x%08x.\n", cdstate
);
2025 hr
= IFileDialogCustomize_SetControlItemState(pfdc
, i
, 0, CDCS_ENABLEDVISIBLE
);
2026 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
2027 cdstate
= 0xdeadbeef;
2028 hr
= IFileDialogCustomize_GetControlItemState(pfdc
, i
, 0, &cdstate
);
2029 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
2030 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
2033 for(j
= 0; j
< 10; j
++)
2035 hr
= IFileDialogCustomize_SetSelectedControlItem(pfdc
, i
, j
);
2036 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
2037 hr
= IFileDialogCustomize_GetSelectedControlItem(pfdc
, i
, &selected
);
2038 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
2039 ok(selected
== j
, "got %d.\n", selected
);
2042 hr
= IFileDialogCustomize_SetSelectedControlItem(pfdc
, i
, j
);
2043 ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
2045 hr
= IFileDialogCustomize_RemoveAllControlItems(pfdc
, i
);
2046 ok(hr
== E_NOTIMPL
, "got 0x%08x.\n", hr
);
2048 for(j
= 0; j
< 10; j
++)
2050 hr
= IFileDialogCustomize_RemoveControlItem(pfdc
, i
, j
);
2051 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
2054 hr
= IFileDialogCustomize_EnableOpenDropDown(pfdc
, ++i
);
2055 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
2058 DWORD selected
= -1;
2061 for(j
= 0; j
< 10; j
++)
2063 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, j
, label
);
2064 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
2067 hr
= IFileDialogCustomize_GetSelectedControlItem(pfdc
, i
, &selected
);
2068 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
2069 ok(selected
== 0, "got %d.\n", selected
);
2071 cdstate
= 0xdeadbeef;
2072 hr
= IFileDialogCustomize_GetControlItemState(pfdc
, i
, 0, &cdstate
);
2073 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
2074 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
2075 hr
= IFileDialogCustomize_SetControlItemState(pfdc
, i
, 0, 0);
2076 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
2077 cdstate
= 0xdeadbeef;
2078 hr
= IFileDialogCustomize_GetControlItemState(pfdc
, i
, 0, &cdstate
);
2079 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
2080 ok(cdstate
== 0, "got 0x%08x.\n", cdstate
);
2081 hr
= IFileDialogCustomize_SetControlItemState(pfdc
, i
, 0, CDCS_ENABLEDVISIBLE
);
2082 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
2083 cdstate
= 0xdeadbeef;
2084 hr
= IFileDialogCustomize_GetControlItemState(pfdc
, i
, 0, &cdstate
);
2085 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
2086 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
2087 hr
= IFileDialogCustomize_SetSelectedControlItem(pfdc
, i
, 0);
2088 ok(hr
== E_NOTIMPL
, "got 0x%08x.\n", hr
);
2090 hr
= IFileDialogCustomize_RemoveAllControlItems(pfdc
, i
);
2091 ok(hr
== E_NOTIMPL
, "got 0x%08x.\n", hr
);
2093 for(j
= 0; j
< 10; j
++)
2095 hr
= IFileDialogCustomize_RemoveControlItem(pfdc
, i
, j
);
2096 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
2100 IFileDialogCustomize_Release(pfdc
);
2101 ref
= IFileDialog_Release(pfod
);
2102 ok(!ref
, "Refcount not zero (%d).\n", ref
);
2105 /* Some more tests for VisualGroup behavior */
2106 hr
= CoCreateInstance(&CLSID_FileOpenDialog
, NULL
, CLSCTX_INPROC_SERVER
,
2107 &IID_IFileDialog
, (void**)&pfod
);
2108 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
2110 hr
= IFileDialog_QueryInterface(pfod
, &IID_IFileDialogCustomize
, (void**)&pfdc
);
2111 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
2115 hr
= IFileDialogCustomize_StartVisualGroup(pfdc
, id_vgroup1
, visualgroup1W
);
2116 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
2118 cdstate
= 0xdeadbeef;
2119 hr
= IFileDialogCustomize_GetControlState(pfdc
, id_vgroup1
, &cdstate
);
2120 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
2121 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
2124 hr
= IFileDialogCustomize_AddText(pfdc
, id_text
, label
);
2125 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
2127 cdstate
= 0xdeadbeef;
2128 hr
= IFileDialogCustomize_GetControlState(pfdc
, id_text
, &cdstate
);
2129 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
2130 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
2133 hr
= IFileDialogCustomize_AddEditBox(pfdc
, id_editbox1
, editbox1W
);
2134 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
2136 cdstate
= 0xdeadbeef;
2137 hr
= IFileDialogCustomize_GetControlState(pfdc
, id_editbox1
, &cdstate
);
2138 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
2139 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
2142 /* Set all Visible but not Enabled */
2143 hr
= IFileDialogCustomize_SetControlState(pfdc
, id_vgroup1
, CDCS_VISIBLE
);
2144 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
2146 cdstate
= 0xdeadbeef;
2147 hr
= IFileDialogCustomize_GetControlState(pfdc
, id_vgroup1
, &cdstate
);
2148 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
2149 ok(cdstate
== CDCS_VISIBLE
, "got 0x%08x.\n", cdstate
);
2150 cdstate
= 0xdeadbeef;
2152 hr
= IFileDialogCustomize_GetControlState(pfdc
, id_text
, &cdstate
);
2153 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
2154 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
2156 cdstate
= 0xdeadbeef;
2157 hr
= IFileDialogCustomize_GetControlState(pfdc
, id_editbox1
, &cdstate
);
2158 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
2159 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
2161 /* Set text to Visible but not Enabled */
2162 hr
= IFileDialogCustomize_SetControlState(pfdc
, id_text
, CDCS_VISIBLE
);
2163 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
2165 cdstate
= 0xdeadbeef;
2166 hr
= IFileDialogCustomize_GetControlState(pfdc
, id_vgroup1
, &cdstate
);
2167 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
2168 ok(cdstate
== CDCS_VISIBLE
, "got 0x%08x.\n", cdstate
);
2169 cdstate
= 0xdeadbeef;
2171 hr
= IFileDialogCustomize_GetControlState(pfdc
, id_text
, &cdstate
);
2172 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
2173 ok(cdstate
== CDCS_VISIBLE
, "got 0x%08x.\n", cdstate
);
2175 cdstate
= 0xdeadbeef;
2176 hr
= IFileDialogCustomize_GetControlState(pfdc
, id_editbox1
, &cdstate
);
2177 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
2178 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
2180 /* Set vgroup to inactive */
2181 hr
= IFileDialogCustomize_SetControlState(pfdc
, id_vgroup1
, CDCS_INACTIVE
);
2182 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
2184 cdstate
= 0xdeadbeef;
2185 hr
= IFileDialogCustomize_GetControlState(pfdc
, id_vgroup1
, &cdstate
);
2186 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
2187 ok(cdstate
== CDCS_INACTIVE
, "got 0x%08x.\n", cdstate
);
2189 cdstate
= 0xdeadbeef;
2190 hr
= IFileDialogCustomize_GetControlState(pfdc
, id_text
, &cdstate
);
2191 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
2192 ok(cdstate
== CDCS_VISIBLE
, "got 0x%08x.\n", cdstate
);
2194 cdstate
= 0xdeadbeef;
2195 hr
= IFileDialogCustomize_GetControlState(pfdc
, id_editbox1
, &cdstate
);
2196 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
2197 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
2199 /* Set vgroup to Enabled and Visible again */
2200 hr
= IFileDialogCustomize_SetControlState(pfdc
, id_vgroup1
, CDCS_ENABLEDVISIBLE
);
2201 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
2203 cdstate
= 0xdeadbeef;
2204 hr
= IFileDialogCustomize_GetControlState(pfdc
, id_vgroup1
, &cdstate
);
2205 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
2206 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
2208 cdstate
= 0xdeadbeef;
2209 hr
= IFileDialogCustomize_GetControlState(pfdc
, id_text
, &cdstate
);
2210 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
2211 ok(cdstate
== CDCS_VISIBLE
, "got 0x%08x.\n", cdstate
);
2213 cdstate
= 0xdeadbeef;
2214 hr
= IFileDialogCustomize_GetControlState(pfdc
, id_editbox1
, &cdstate
);
2215 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
2216 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
2218 hr
= IFileDialogCustomize_MakeProminent(pfdc
, id_vgroup1
);
2219 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
2221 IFileDialogCustomize_Release(pfdc
);
2222 ref
= IFileDialog_Release(pfod
);
2223 ok(!ref
, "Refcount not zero (%d).\n", ref
);
2226 static void test_persistent_state(void)
2231 hr
= CoCreateInstance(&CLSID_FileOpenDialog
, NULL
, CLSCTX_INPROC_SERVER
,
2232 &IID_IFileDialog
, (void**)&fd
);
2233 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
2237 /* crashes at least on Win8 */
2238 hr
= IFileDialog_SetClientGuid(fd
, NULL
);
2241 hr
= IFileDialog_SetClientGuid(fd
, &IID_IUnknown
);
2242 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
2244 hr
= IFileDialog_SetClientGuid(fd
, &IID_NULL
);
2245 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
2247 IFileDialog_Release(fd
);
2252 OleInitialize(NULL
);
2253 init_function_pointers();
2255 if(test_instantiation())
2262 test_persistent_state();
2265 skip("Skipping all Item Dialog tests.\n");