2 * Unit test of the IShellView
4 * Copyright 2010 Nikolay Sivov for CodeWeavers
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
41 #include "wine/test.h"
45 #define LISTVIEW_SEQ_INDEX 0
46 #define NUM_MSG_SEQUENCES 1
48 DEFINE_GUID(IID_IPersistHistory
, 0x91a565c1, 0xe38f, 0x11d0, 0x94, 0xbf, 0x00, 0xa0, 0xc9, 0x05, 0x5c, 0xbf);
50 static struct msg_sequence
*sequences
[NUM_MSG_SEQUENCES
];
52 static LRESULT WINAPI
listview_subclass_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
54 WNDPROC oldproc
= (WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_USERDATA
);
55 static LONG defwndproc_counter
= 0;
56 struct message msg
= { 0 };
59 msg
.message
= message
;
60 msg
.flags
= sent
|wparam
|lparam
;
61 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
64 add_message(sequences
, LISTVIEW_SEQ_INDEX
, &msg
);
67 ret
= CallWindowProcA(oldproc
, hwnd
, message
, wParam
, lParam
);
72 static HWND
subclass_listview(HWND hwnd
)
77 /* listview is a first child */
78 listview
= FindWindowExA(hwnd
, NULL
, WC_LISTVIEWA
, NULL
);
81 /* .. except for some versions of Windows XP, where things
82 are slightly more complicated. */
84 hwnd_tmp
= FindWindowExA(hwnd
, NULL
, "DUIViewWndClassName", NULL
);
85 hwnd_tmp
= FindWindowExA(hwnd_tmp
, NULL
, "DirectUIHWND", NULL
);
86 hwnd_tmp
= FindWindowExA(hwnd_tmp
, NULL
, "CtrlNotifySink", NULL
);
87 listview
= FindWindowExA(hwnd_tmp
, NULL
, WC_LISTVIEWA
, NULL
);
90 oldproc
= (WNDPROC
)SetWindowLongPtrA(listview
, GWLP_WNDPROC
,
91 (LONG_PTR
)listview_subclass_proc
);
92 SetWindowLongPtrA(listview
, GWLP_USERDATA
, (LONG_PTR
)oldproc
);
97 static UINT
get_msg_count(struct msg_sequence
**seq
, int sequence_index
, UINT message
)
99 struct msg_sequence
*msg_seq
= seq
[sequence_index
];
102 for(i
= 0; i
< msg_seq
->count
; i
++)
103 if(msg_seq
->sequence
[i
].message
== message
)
109 /* Checks that every message in the sequence seq is also present in
110 * the UINT array msgs */
111 static void verify_msgs_in_(struct msg_sequence
*seq
, const UINT
*msgs
,
112 const char *file
, int line
)
114 UINT i
, j
, msg
, failcount
= 0;
115 for(i
= 0; i
< seq
->count
; i
++)
118 msg
= seq
->sequence
[i
].message
;
119 for(j
= 0; msgs
[j
] != 0; j
++)
120 if(msgs
[j
] == msg
) found
= TRUE
;
125 trace("Unexpected message %d\n", msg
);
128 ok_(file
, line
) (!failcount
, "%d failures.\n", failcount
);
129 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
132 #define verify_msgs_in(seq, msgs) \
133 verify_msgs_in_(seq, msgs, __FILE__, __LINE__)
135 /* dummy IDataObject implementation */
137 IDataObject IDataObject_iface
;
141 static const IDataObjectVtbl IDataObjectImpl_Vtbl
;
143 static inline IDataObjectImpl
*impl_from_IDataObject(IDataObject
*iface
)
145 return CONTAINING_RECORD(iface
, IDataObjectImpl
, IDataObject_iface
);
148 static IDataObject
* IDataObjectImpl_Construct(void)
150 IDataObjectImpl
*obj
;
152 obj
= malloc(sizeof(*obj
));
153 obj
->IDataObject_iface
.lpVtbl
= &IDataObjectImpl_Vtbl
;
156 return &obj
->IDataObject_iface
;
159 static HRESULT WINAPI
IDataObjectImpl_QueryInterface(IDataObject
*iface
, REFIID riid
, void **ppvObj
)
161 IDataObjectImpl
*This
= impl_from_IDataObject(iface
);
163 if (IsEqualIID(riid
, &IID_IUnknown
) ||
164 IsEqualIID(riid
, &IID_IDataObject
))
166 *ppvObj
= &This
->IDataObject_iface
;
171 IDataObject_AddRef(iface
);
175 return E_NOINTERFACE
;
178 static ULONG WINAPI
IDataObjectImpl_AddRef(IDataObject
* iface
)
180 IDataObjectImpl
*This
= impl_from_IDataObject(iface
);
181 return InterlockedIncrement(&This
->ref
);
184 static ULONG WINAPI
IDataObjectImpl_Release(IDataObject
* iface
)
186 IDataObjectImpl
*This
= impl_from_IDataObject(iface
);
187 ULONG ref
= InterlockedDecrement(&This
->ref
);
195 static HRESULT WINAPI
IDataObjectImpl_GetData(IDataObject
*iface
, FORMATETC
*pformat
, STGMEDIUM
*pmedium
)
200 static HRESULT WINAPI
IDataObjectImpl_GetDataHere(IDataObject
*iface
, FORMATETC
*pformat
, STGMEDIUM
*pmedium
)
205 static HRESULT WINAPI
IDataObjectImpl_QueryGetData(IDataObject
*iface
, FORMATETC
*pformat
)
210 static HRESULT WINAPI
IDataObjectImpl_GetCanonicalFormatEtc(
211 IDataObject
*iface
, FORMATETC
*pformatIn
, FORMATETC
*pformatOut
)
216 static HRESULT WINAPI
IDataObjectImpl_SetData(
217 IDataObject
*iface
, FORMATETC
*pformat
, STGMEDIUM
*pmedium
, BOOL release
)
222 static HRESULT WINAPI
IDataObjectImpl_EnumFormatEtc(
223 IDataObject
*iface
, DWORD direction
, IEnumFORMATETC
**ppenumFormatEtc
)
228 static HRESULT WINAPI
IDataObjectImpl_DAdvise(
229 IDataObject
*iface
, FORMATETC
*pformatetc
, DWORD advf
, IAdviseSink
*pSink
, DWORD
*pConnection
)
234 static HRESULT WINAPI
IDataObjectImpl_DUnadvise(IDataObject
*iface
, DWORD connection
)
239 static HRESULT WINAPI
IDataObjectImpl_EnumDAdvise(IDataObject
*iface
, IEnumSTATDATA
**ppenumAdvise
)
244 static const IDataObjectVtbl IDataObjectImpl_Vtbl
=
246 IDataObjectImpl_QueryInterface
,
247 IDataObjectImpl_AddRef
,
248 IDataObjectImpl_Release
,
249 IDataObjectImpl_GetData
,
250 IDataObjectImpl_GetDataHere
,
251 IDataObjectImpl_QueryGetData
,
252 IDataObjectImpl_GetCanonicalFormatEtc
,
253 IDataObjectImpl_SetData
,
254 IDataObjectImpl_EnumFormatEtc
,
255 IDataObjectImpl_DAdvise
,
256 IDataObjectImpl_DUnadvise
,
257 IDataObjectImpl_EnumDAdvise
260 /* dummy IShellBrowser implementation */
262 IShellBrowser IShellBrowser_iface
;
266 static const IShellBrowserVtbl IShellBrowserImpl_Vtbl
;
268 static inline IShellBrowserImpl
*impl_from_IShellBrowser(IShellBrowser
*iface
)
270 return CONTAINING_RECORD(iface
, IShellBrowserImpl
, IShellBrowser_iface
);
273 static IShellBrowser
* IShellBrowserImpl_Construct(void)
275 IShellBrowserImpl
*browser
;
277 browser
= malloc(sizeof(*browser
));
278 browser
->IShellBrowser_iface
.lpVtbl
= &IShellBrowserImpl_Vtbl
;
281 return &browser
->IShellBrowser_iface
;
284 static HRESULT WINAPI
IShellBrowserImpl_QueryInterface(IShellBrowser
*iface
,
288 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
292 if(IsEqualIID(riid
, &IID_IUnknown
) ||
293 IsEqualIID(riid
, &IID_IOleWindow
) ||
294 IsEqualIID(riid
, &IID_IShellBrowser
))
296 *ppvObj
= &This
->IShellBrowser_iface
;
301 IShellBrowser_AddRef(iface
);
305 return E_NOINTERFACE
;
308 static ULONG WINAPI
IShellBrowserImpl_AddRef(IShellBrowser
* iface
)
310 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
311 return InterlockedIncrement(&This
->ref
);
314 static ULONG WINAPI
IShellBrowserImpl_Release(IShellBrowser
* iface
)
316 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
317 ULONG ref
= InterlockedDecrement(&This
->ref
);
325 static HRESULT WINAPI
IShellBrowserImpl_GetWindow(IShellBrowser
*iface
,
328 if (phwnd
) *phwnd
= GetDesktopWindow();
332 static HRESULT WINAPI
IShellBrowserImpl_ContextSensitiveHelp(IShellBrowser
*iface
,
338 static HRESULT WINAPI
IShellBrowserImpl_BrowseObject(IShellBrowser
*iface
,
345 static HRESULT WINAPI
IShellBrowserImpl_EnableModelessSB(IShellBrowser
*iface
,
352 static HRESULT WINAPI
IShellBrowserImpl_GetControlWindow(IShellBrowser
*iface
,
360 static HRESULT WINAPI
IShellBrowserImpl_GetViewStateStream(IShellBrowser
*iface
,
368 static HRESULT WINAPI
IShellBrowserImpl_InsertMenusSB(IShellBrowser
*iface
,
370 LPOLEMENUGROUPWIDTHS lpMenuWidths
)
376 static HRESULT WINAPI
IShellBrowserImpl_OnViewWindowActive(IShellBrowser
*iface
,
383 static HRESULT WINAPI
IShellBrowserImpl_QueryActiveShellView(IShellBrowser
*iface
,
390 static HRESULT WINAPI
IShellBrowserImpl_RemoveMenusSB(IShellBrowser
*iface
,
397 static HRESULT WINAPI
IShellBrowserImpl_SendControlMsg(IShellBrowser
*iface
,
408 static HRESULT WINAPI
IShellBrowserImpl_SetMenuSB(IShellBrowser
*iface
,
410 HOLEMENU holemenuReserved
,
411 HWND hwndActiveObject
)
417 static HRESULT WINAPI
IShellBrowserImpl_SetStatusTextSB(IShellBrowser
*iface
,
418 LPCOLESTR lpszStatusText
)
424 static HRESULT WINAPI
IShellBrowserImpl_SetToolbarItems(IShellBrowser
*iface
,
425 LPTBBUTTON lpButtons
,
433 static HRESULT WINAPI
IShellBrowserImpl_TranslateAcceleratorSB(IShellBrowser
*iface
,
441 static const IShellBrowserVtbl IShellBrowserImpl_Vtbl
=
443 IShellBrowserImpl_QueryInterface
,
444 IShellBrowserImpl_AddRef
,
445 IShellBrowserImpl_Release
,
446 IShellBrowserImpl_GetWindow
,
447 IShellBrowserImpl_ContextSensitiveHelp
,
448 IShellBrowserImpl_InsertMenusSB
,
449 IShellBrowserImpl_SetMenuSB
,
450 IShellBrowserImpl_RemoveMenusSB
,
451 IShellBrowserImpl_SetStatusTextSB
,
452 IShellBrowserImpl_EnableModelessSB
,
453 IShellBrowserImpl_TranslateAcceleratorSB
,
454 IShellBrowserImpl_BrowseObject
,
455 IShellBrowserImpl_GetViewStateStream
,
456 IShellBrowserImpl_GetControlWindow
,
457 IShellBrowserImpl_SendControlMsg
,
458 IShellBrowserImpl_QueryActiveShellView
,
459 IShellBrowserImpl_OnViewWindowActive
,
460 IShellBrowserImpl_SetToolbarItems
463 static const struct message empty_seq
[] = {
467 static const struct message folderview_getspacing_seq
[] = {
468 { LVM_GETITEMSPACING
, wparam
|sent
, FALSE
},
472 static const struct message folderview_getselectionmarked_seq
[] = {
473 { LVM_GETSELECTIONMARK
, sent
},
477 static const struct message folderview_getfocused_seq
[] = {
478 { LVM_GETNEXTITEM
, sent
|wparam
|lparam
|optional
, -1, LVNI_FOCUSED
},
482 static HRESULT WINAPI
shellbrowser_QueryInterface(IShellBrowser
*iface
, REFIID riid
, void **ppv
)
486 if (IsEqualGUID(&IID_IShellBrowser
, riid
) ||
487 IsEqualGUID(&IID_IOleWindow
, riid
) ||
488 IsEqualGUID(&IID_IUnknown
, riid
))
495 IUnknown_AddRef((IUnknown
*)*ppv
);
499 return E_NOINTERFACE
;
502 static ULONG WINAPI
shellbrowser_AddRef(IShellBrowser
*iface
)
507 static ULONG WINAPI
shellbrowser_Release(IShellBrowser
*iface
)
512 static HRESULT WINAPI
shellbrowser_GetWindow(IShellBrowser
*iface
, HWND
*phwnd
)
514 *phwnd
= GetDesktopWindow();
518 static HRESULT WINAPI
shellbrowser_ContextSensitiveHelp(IShellBrowser
*iface
, BOOL mode
)
520 ok(0, "unexpected\n");
524 static HRESULT WINAPI
shellbrowser_InsertMenusSB(IShellBrowser
*iface
, HMENU hmenuShared
,
525 OLEMENUGROUPWIDTHS
*menuwidths
)
530 static HRESULT WINAPI
shellbrowser_SetMenuSB(IShellBrowser
*iface
, HMENU hmenuShared
,
531 HOLEMENU holemenuReserved
, HWND hwndActiveObject
)
536 static HRESULT WINAPI
shellbrowser_RemoveMenusSB(IShellBrowser
*iface
, HMENU hmenuShared
)
541 static HRESULT WINAPI
shellbrowser_SetStatusTextSB(IShellBrowser
*iface
, LPCOLESTR text
)
543 ok(0, "unexpected\n");
547 static HRESULT WINAPI
shellbrowser_EnableModelessSB(IShellBrowser
*iface
, BOOL enable
)
549 ok(0, "unexpected\n");
553 static HRESULT WINAPI
shellbrowser_TranslateAcceleratorSB(IShellBrowser
*iface
, MSG
*pmsg
, WORD wID
)
555 ok(0, "unexpected\n");
559 static HRESULT WINAPI
shellbrowser_BrowseObject(IShellBrowser
*iface
, LPCITEMIDLIST pidl
, UINT flags
)
561 ok(0, "unexpected\n");
565 static HRESULT WINAPI
shellbrowser_GetViewStateStream(IShellBrowser
*iface
, DWORD mode
, IStream
**stream
)
570 static HRESULT WINAPI
shellbrowser_GetControlWindow(IShellBrowser
*iface
, UINT id
, HWND
*phwnd
)
575 static HRESULT WINAPI
shellbrowser_SendControlMsg(IShellBrowser
*iface
, UINT id
, UINT uMsg
,
576 WPARAM wParam
, LPARAM lParam
, LRESULT
*pret
)
581 static HRESULT WINAPI
shellbrowser_QueryActiveShellView(IShellBrowser
*iface
, IShellView
**view
)
583 ok(0, "unexpected\n");
587 static HRESULT WINAPI
shellbrowser_OnViewWindowActive(IShellBrowser
*iface
, IShellView
*view
)
589 ok(0, "unexpected\n");
593 static HRESULT WINAPI
shellbrowser_SetToolbarItems(IShellBrowser
*iface
, LPTBBUTTONSB buttons
,
594 UINT count
, UINT flags
)
599 static const IShellBrowserVtbl shellbrowservtbl
= {
600 shellbrowser_QueryInterface
,
602 shellbrowser_Release
,
603 shellbrowser_GetWindow
,
604 shellbrowser_ContextSensitiveHelp
,
605 shellbrowser_InsertMenusSB
,
606 shellbrowser_SetMenuSB
,
607 shellbrowser_RemoveMenusSB
,
608 shellbrowser_SetStatusTextSB
,
609 shellbrowser_EnableModelessSB
,
610 shellbrowser_TranslateAcceleratorSB
,
611 shellbrowser_BrowseObject
,
612 shellbrowser_GetViewStateStream
,
613 shellbrowser_GetControlWindow
,
614 shellbrowser_SendControlMsg
,
615 shellbrowser_QueryActiveShellView
,
616 shellbrowser_OnViewWindowActive
,
617 shellbrowser_SetToolbarItems
620 static IShellBrowser test_shellbrowser
= { &shellbrowservtbl
};
622 static void test_CreateViewWindow(void)
624 IShellFolder
*desktop
;
625 HWND hwnd_view
, hwnd2
;
626 FOLDERSETTINGS settings
;
634 hr
= SHGetDesktopFolder(&desktop
);
635 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
637 hr
= IShellFolder_CreateViewObject(desktop
, NULL
, &IID_IShellView
, (void**)&view
);
638 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
640 hr
= IShellView_QueryInterface(view
, &IID_CDefView
, (void **)&unk
);
641 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
642 ok(unk
== (IUnknown
*)view
, "got %p\n", unk
);
643 IUnknown_Release(unk
);
647 /* crashes on native */
648 IShellView_CreateViewWindow(view
, NULL
, &settings
, NULL
, NULL
, NULL
);
651 settings
.ViewMode
= FVM_ICON
;
653 hwnd_view
= (HWND
)0xdeadbeef;
654 hr
= IShellView_CreateViewWindow(view
, NULL
, &settings
, NULL
, NULL
, &hwnd_view
);
655 ok(hr
== E_UNEXPECTED
, "got (0x%08lx)\n", hr
);
656 ok(hwnd_view
== 0, "got %p\n", hwnd_view
);
658 hwnd_view
= (HWND
)0xdeadbeef;
659 hr
= IShellView_CreateViewWindow(view
, NULL
, &settings
, NULL
, &r
, &hwnd_view
);
660 ok(hr
== E_UNEXPECTED
, "got (0x%08lx)\n", hr
);
661 ok(hwnd_view
== 0, "got %p\n", hwnd_view
);
664 hr
= IShellView_CreateViewWindow(view
, NULL
, &settings
, &test_shellbrowser
, &r
, &hwnd_view
);
665 ok(hr
== S_OK
|| broken(hr
== S_FALSE
), "got (0x%08lx)\n", hr
);
666 ok(hwnd_view
!= 0, "got %p\n", hwnd_view
);
668 hwnd2
= (HWND
)0xdeadbeef;
669 hr
= IShellView_CreateViewWindow(view
, NULL
, &settings
, &test_shellbrowser
, &r
, &hwnd2
);
670 ok(hr
== E_UNEXPECTED
, "got (0x%08lx)\n", hr
);
671 ok(hwnd2
== NULL
, "got %p\n", hwnd2
);
673 /* ::DragLeave without drag operation */
674 hr
= IShellView_QueryInterface(view
, &IID_IDropTarget
, (void**)&dt
);
675 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
676 hr
= IDropTarget_DragLeave(dt
);
677 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
678 IDropTarget_Release(dt
);
680 IShellView_AddRef(view
);
681 ref1
= IShellView_Release(view
);
682 hr
= IShellView_DestroyViewWindow(view
);
683 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
684 ok(!IsWindow(hwnd_view
), "hwnd %p still valid\n", hwnd_view
);
685 ref2
= IShellView_Release(view
);
686 ok(ref1
> ref2
, "expected %lu > %lu\n", ref1
, ref2
);
689 /* Show that releasing the shell view does not destroy the window */
690 hr
= IShellFolder_CreateViewObject(desktop
, NULL
, &IID_IShellView
, (void**)&view
);
691 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
693 hr
= IShellView_CreateViewWindow(view
, NULL
, &settings
, &test_shellbrowser
, &r
, &hwnd_view
);
694 ok(hr
== S_OK
|| broken(hr
== S_FALSE
), "got (0x%08lx)\n", hr
);
695 ok(hwnd_view
!= NULL
, "got %p\n", hwnd_view
);
696 ok(IsWindow(hwnd_view
), "hwnd %p still valid\n", hwnd_view
);
697 ref2
= IShellView_Release(view
);
698 ok(ref2
!= 0, "ref2 = %lu\n", ref2
);
699 ok(ref2
> ref1
, "expected %lu > %lu\n", ref2
, ref1
);
700 ok(IsWindow(hwnd_view
), "hwnd %p still valid\n", hwnd_view
);
701 DestroyWindow(hwnd_view
);
703 IShellFolder_Release(desktop
);
706 static void test_IFolderView(void)
708 IShellFolder
*desktop
, *folder
;
709 FOLDERSETTINGS settings
;
711 IShellBrowser
*browser
;
715 HWND hwnd_view
, hwnd_list
;
722 hr
= SHGetDesktopFolder(&desktop
);
723 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
725 hr
= IShellFolder_CreateViewObject(desktop
, NULL
, &IID_IShellView
, (void**)&view
);
726 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
728 hr
= IShellView_QueryInterface(view
, &IID_IFolderView
, (void**)&fv
);
731 win_skip("IFolderView not supported by desktop folder\n");
732 IShellView_Release(view
);
733 IShellFolder_Release(desktop
);
737 /* call methods before window creation */
738 hr
= IFolderView_GetSpacing(fv
, NULL
);
739 ok(hr
== S_FALSE
|| broken(hr
== S_OK
) /* win7 */, "got (0x%08lx)\n", hr
);
741 pidl
= (void*)0xdeadbeef;
742 hr
= IFolderView_Item(fv
, 0, &pidl
);
743 ok(hr
== E_INVALIDARG
|| broken(hr
== E_FAIL
) /* < Vista */, "got (0x%08lx)\n", hr
);
744 ok(pidl
== 0 || broken(pidl
== (void*)0xdeadbeef) /* < Vista */, "got %p\n", pidl
);
748 /* crashes on Vista and Win2k8 - List not created yet case */
749 IFolderView_GetSpacing(fv
, &pt
);
752 IFolderView_GetSelectionMarkedItem(fv
, NULL
);
753 IFolderView_GetFocusedItem(fv
, NULL
);
755 /* crashes on Vista+ */
756 IFolderView_Item(fv
, 0, NULL
);
759 browser
= IShellBrowserImpl_Construct();
761 settings
.ViewMode
= FVM_ICON
;
763 hwnd_view
= (HWND
)0xdeadbeef;
764 SetRect(&r
, 0, 0, 100, 100);
765 hr
= IShellView_CreateViewWindow(view
, NULL
, &settings
, browser
, &r
, &hwnd_view
);
766 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
767 ok(IsWindow(hwnd_view
), "got %p\n", hwnd_view
);
769 hwnd_list
= subclass_listview(hwnd_view
);
772 win_skip("Failed to subclass ListView control\n");
773 IShellBrowser_Release(browser
);
774 IFolderView_Release(fv
);
775 IShellView_Release(view
);
776 IShellFolder_Release(desktop
);
780 /* IFolderView::GetSpacing */
781 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
782 hr
= IFolderView_GetSpacing(fv
, NULL
);
783 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
784 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, empty_seq
, "IFolderView::GetSpacing, empty", FALSE
);
786 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
787 hr
= IFolderView_GetSpacing(fv
, &pt
);
788 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
789 /* fails with empty sequence on win7 for unknown reason */
790 if (sequences
[LISTVIEW_SEQ_INDEX
]->count
)
792 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, folderview_getspacing_seq
, "IFolderView::GetSpacing", FALSE
);
793 ok(pt
.x
> 0, "got %ld\n", pt
.x
);
794 ok(pt
.y
> 0, "got %ld\n", pt
.y
);
795 ret
= SendMessageA(hwnd_list
, LVM_GETITEMSPACING
, 0, 0);
796 ok(pt
.x
== LOWORD(ret
) && pt
.y
== HIWORD(ret
), "got (%d, %d)\n", LOWORD(ret
), HIWORD(ret
));
799 /* IFolderView::ItemCount */
803 IFolderView_ItemCount(fv
, SVGIO_ALLVIEW
, NULL
);
806 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
807 IFolderView_ItemCount(fv
, SVGIO_ALLVIEW
, &count
);
809 /* IFolderView::GetSelectionMarkedItem */
813 IFolderView_GetSelectionMarkedItem(fv
, NULL
);
816 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
817 hr
= IFolderView_GetSelectionMarkedItem(fv
, &ret
);
819 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
821 ok(hr
== S_FALSE
, "got (0x%08lx)\n", hr
);
822 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, folderview_getselectionmarked_seq
,
823 "IFolderView::GetSelectionMarkedItem", FALSE
);
825 /* IFolderView::GetFocusedItem */
826 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
827 hr
= IFolderView_GetFocusedItem(fv
, &ret
);
829 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
831 ok(hr
== S_FALSE
, "got (0x%08lx)\n", hr
);
832 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, folderview_getfocused_seq
,
833 "IFolderView::GetFocusedItem", FALSE
);
835 /* IFolderView::GetFolder, just return pointer */
839 IFolderView_GetFolder(fv
, NULL
, (void**)&folder
);
840 IFolderView_GetFolder(fv
, NULL
, NULL
);
843 hr
= IFolderView_GetFolder(fv
, &IID_IShellFolder
, NULL
);
844 ok(hr
== E_POINTER
, "got (0x%08lx)\n", hr
);
846 hr
= IFolderView_GetFolder(fv
, &IID_IShellFolder
, (void**)&folder
);
847 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
848 ok(desktop
== folder
, "\n");
849 if (folder
) IShellFolder_Release(folder
);
851 hr
= IFolderView_GetFolder(fv
, &IID_IUnknown
, (void**)&unk
);
852 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
853 if (unk
) IUnknown_Release(unk
);
855 hr
= IFolderView_QueryInterface(fv
, &IID_IFolderView2
, (void**)&fv2
);
857 win_skip("IFolderView2 is not supported.\n");
858 if (fv2
) IFolderView2_Release(fv2
);
860 hr
= IShellView_DestroyViewWindow(view
);
861 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
862 ok(!IsWindow(hwnd_view
), "hwnd %p still valid\n", hwnd_view
);
864 IShellBrowser_Release(browser
);
865 IFolderView_Release(fv
);
866 IShellView_Release(view
);
867 IShellFolder_Release(desktop
);
870 static void test_GetItemObject(void)
872 IShellFolder
*desktop
;
877 hr
= SHGetDesktopFolder(&desktop
);
878 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
880 hr
= IShellFolder_CreateViewObject(desktop
, NULL
, &IID_IShellView
, (void**)&view
);
881 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
883 /* from documentation three interfaces are supported for SVGIO_BACKGROUND:
884 IContextMenu, IDispatch, IPersistHistory */
885 hr
= IShellView_GetItemObject(view
, SVGIO_BACKGROUND
, &IID_IContextMenu
, (void**)&unk
);
886 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
887 IUnknown_Release(unk
);
890 hr
= IShellView_GetItemObject(view
, SVGIO_BACKGROUND
, &IID_IDispatch
, (void**)&unk
);
891 ok(hr
== S_OK
|| broken(hr
== E_NOTIMPL
) /* NT4 */, "got (0x%08lx)\n", hr
);
892 if (unk
) IUnknown_Release(unk
);
895 hr
= IShellView_GetItemObject(view
, SVGIO_BACKGROUND
, &IID_IPersistHistory
, (void**)&unk
);
896 todo_wine
ok(hr
== S_OK
|| broken(hr
== E_NOTIMPL
) /* W9x, NT4 */, "got (0x%08lx)\n", hr
);
897 if (unk
) IUnknown_Release(unk
);
899 /* example of unsupported interface, base for IPersistHistory */
900 hr
= IShellView_GetItemObject(view
, SVGIO_BACKGROUND
, &IID_IPersist
, (void**)&unk
);
901 ok(hr
== E_NOINTERFACE
|| broken(hr
== E_NOTIMPL
) /* W2K */, "got (0x%08lx)\n", hr
);
903 IShellView_Release(view
);
904 IShellFolder_Release(desktop
);
907 static void test_IShellFolderView(void)
909 IShellFolderView
*folderview
;
910 IShellFolder
*desktop
;
916 hr
= SHGetDesktopFolder(&desktop
);
917 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
919 hr
= IShellFolder_CreateViewObject(desktop
, NULL
, &IID_IShellView
, (void**)&view
);
920 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
922 hr
= IShellView_QueryInterface(view
, &IID_IShellFolderView
, (void**)&folderview
);
925 win_skip("IShellView doesn't provide IShellFolderView on this platform\n");
926 IShellView_Release(view
);
927 IShellFolder_Release(desktop
);
932 obj
= IDataObjectImpl_Construct();
933 hr
= IShellFolderView_MoveIcons(folderview
, obj
);
934 ok(hr
== E_NOTIMPL
|| broken(hr
== S_OK
) /* W98 */, "got (0x%08lx)\n", hr
);
935 IDataObject_Release(obj
);
937 /* ::SetRedraw without list created */
938 hr
= IShellFolderView_SetRedraw(folderview
, TRUE
);
939 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
942 hr
= IShellFolderView_QuerySupport(folderview
, NULL
);
943 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
945 hr
= IShellFolderView_QuerySupport(folderview
, &i
);
946 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
947 ok(i
== 0xdeadbeef, "got %d\n", i
);
951 hr
= IShellFolderView_RemoveObject(folderview
, NULL
, &i
);
952 ok(hr
== S_OK
|| hr
== E_FAIL
, "got (0x%08lx)\n", hr
);
953 if (hr
== S_OK
) ok(i
== 0 || broken(i
== 0xdeadbeef) /* Vista, 2k8 */,
956 IShellFolderView_Release(folderview
);
958 IShellView_Release(view
);
959 IShellFolder_Release(desktop
);
962 static void test_IOleWindow(void)
964 IShellFolder
*desktop
;
969 hr
= SHGetDesktopFolder(&desktop
);
970 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
972 hr
= IShellFolder_CreateViewObject(desktop
, NULL
, &IID_IShellView
, (void**)&view
);
973 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
975 hr
= IShellView_QueryInterface(view
, &IID_IOleWindow
, (void**)&wnd
);
976 ok(hr
== E_NOINTERFACE
, "got (0x%08lx)\n", hr
);
978 /* IShellView::ContextSensitiveHelp */
979 hr
= IShellView_ContextSensitiveHelp(view
, TRUE
);
980 ok(hr
== E_NOTIMPL
, "got (0x%08lx)\n", hr
);
981 hr
= IShellView_ContextSensitiveHelp(view
, FALSE
);
982 ok(hr
== E_NOTIMPL
, "got (0x%08lx)\n", hr
);
984 IShellView_Release(view
);
985 IShellFolder_Release(desktop
);
988 static const struct message folderview_setcurrentviewmode1_2_prevista
[] = {
989 { LVM_SETVIEW
, sent
|wparam
, LV_VIEW_ICON
},
990 { LVM_SETIMAGELIST
, sent
|wparam
, 0},
991 { LVM_SETIMAGELIST
, sent
|wparam
, 1},
993 { LVM_SETBKIMAGEW
, sent
|optional
}, /* w2k3 */
994 { LVM_GETBKCOLOR
, sent
|optional
}, /* w2k3 */
995 { LVM_GETTEXTBKCOLOR
, sent
|optional
}, /* w2k3 */
996 { LVM_GETTEXTCOLOR
, sent
|optional
}, /* w2k3 */
997 { LVM_SETEXTENDEDLISTVIEWSTYLE
, sent
|optional
|wparam
, 0xc8}, /* w2k3 */
998 { LVM_ARRANGE
, sent
},
999 { LVM_ARRANGE
, sent
|optional
}, /* WinXP */
1003 static const struct message folderview_setcurrentviewmode3_prevista
[] = {
1004 { LVM_SETVIEW
, sent
|wparam
, LV_VIEW_LIST
},
1005 { LVM_SETIMAGELIST
, sent
|wparam
, 0},
1006 { LVM_SETIMAGELIST
, sent
|wparam
, 1},
1008 { LVM_SETBKIMAGEW
, sent
|optional
}, /* w2k3 */
1009 { LVM_GETBKCOLOR
, sent
|optional
}, /* w2k3 */
1010 { LVM_GETTEXTBKCOLOR
, sent
|optional
}, /* w2k3 */
1011 { LVM_GETTEXTCOLOR
, sent
|optional
}, /* w2k3 */
1012 { LVM_SETEXTENDEDLISTVIEWSTYLE
, sent
|optional
|wparam
, 0xc8}, /* w2k3 */
1016 static const struct message folderview_setcurrentviewmode4_prevista
[] = {
1017 { LVM_GETHEADER
, sent
},
1018 { LVM_GETITEMCOUNT
, sent
|optional
},
1019 { LVM_SETSELECTEDCOLUMN
, sent
},
1020 { WM_NOTIFY
, sent
},
1021 { WM_NOTIFY
, sent
},
1022 { WM_NOTIFY
, sent
},
1023 { WM_NOTIFY
, sent
},
1024 { LVM_SETVIEW
, sent
|wparam
, LV_VIEW_DETAILS
},
1025 { LVM_SETIMAGELIST
, sent
|wparam
, 0},
1026 { LVM_SETIMAGELIST
, sent
|wparam
, 1},
1028 { LVM_SETBKIMAGEW
, sent
|optional
}, /* w2k3 */
1029 { LVM_GETBKCOLOR
, sent
|optional
}, /* w2k3 */
1030 { LVM_GETTEXTBKCOLOR
, sent
|optional
}, /* w2k3 */
1031 { LVM_GETTEXTCOLOR
, sent
|optional
}, /* w2k3 */
1032 { LVM_SETEXTENDEDLISTVIEWSTYLE
, sent
|optional
|wparam
, 0xc8}, /* w2k3 */
1036 /* XP, SetCurrentViewMode(5)
1037 108e - LVM_SETVIEW (LV_VIEW_ICON);
1038 1036 - LVM_SETEXTEDEDLISTVIEWSTYLE (0x8000, 0)
1039 100c/104c repeated X times
1040 1003 - LVM_SETIMAGELIST
1041 1035 - LVM_SETICONSPACING
1042 1004 - LVM_GETITEMCOUNT
1048 /* XP, SetCurrentViewMode(6)
1049 1036 - LVM_SETEXTENDEDLISTVIEWSTYLE (0x8000, 0)
1050 1035 - LVM_SETICONSPACING
1051 1003 - LVM_SETIMAGELIST
1052 1003 - LVM_SETIMAGELIST
1053 100c/104c repeated X times
1054 10a2 - LVM_SETTILEVIEWINFO
1055 108e - LVM_SETVIEW (LV_VIEW_TILE)
1056 1003 - LVM_SETIMAGELIST
1062 /* XP, SetCurrentViewMode (7)
1063 10a2 - LVM_SETTILEVIEWINFO
1064 108e - LVM_SETVIEW (LV_VIEW_ICON)
1065 1004/10a4 (LVM_GETITEMCOUNT/LVM_SETTILEINFO) X times
1069 LVM_SETEXTENDEDLISTVIEWSTYLE (0x40000, 0x40000)
1071 LVM_SETEXTENDEDLISTVIEWSTYLE (0x8000, 0x8000)
1074 static void test_GetSetCurrentViewMode(void)
1076 IShellFolder
*desktop
;
1079 IShellBrowser
*browser
;
1083 RECT rc
= {0, 0, 10, 10};
1086 static const int winxp_res
[11] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
1087 static const int win2k3_res
[11] = {0, 1, 2, 3, 4, 5, 6, 5, 8, 0, 0};
1088 static const int vista_res
[11] = {0, 1, 5, 3, 4, 5, 6, 7, 7, 0, 0};
1089 static const int win7_res
[11] = {1, 1, 1, 3, 4, 1, 6, 1, 8, 8, 8};
1091 hr
= SHGetDesktopFolder(&desktop
);
1092 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
1094 hr
= IShellFolder_CreateViewObject(desktop
, NULL
, &IID_IShellView
, (void**)&sview
);
1095 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
1097 hr
= IShellView_QueryInterface(sview
, &IID_IFolderView
, (void **)&fview
);
1098 ok(hr
== S_OK
, "Got hr %#lx.\n", hr
);
1100 viewmode
= 0xdeadbeef;
1101 hr
= IFolderView_GetCurrentViewMode(fview
, &viewmode
);
1102 ok(hr
== S_OK
, "Got hr %#lx.\n", hr
);
1103 ok(viewmode
== FVM_TILE
|| broken(viewmode
== 0) /* pre win7 */, "Got view mode %u.\n", viewmode
);
1107 browser
= IShellBrowserImpl_Construct();
1108 hr
= IShellView_CreateViewWindow(sview
, NULL
, &fs
, browser
, &rc
, &hwnd
);
1109 ok(hr
== S_OK
|| broken(hr
== S_FALSE
/*Win2k*/ ), "got (0x%08lx)\n", hr
);
1118 /* Crashes under Win7/WinXP */
1119 IFolderView_GetCurrentViewMode(fview
, NULL
);
1122 hr
= IFolderView_GetCurrentViewMode(fview
, &viewmode
);
1123 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
1124 ok(viewmode
== 1, "ViewMode was %d\n", viewmode
);
1126 hr
= IFolderView_SetCurrentViewMode(fview
, FVM_AUTO
);
1127 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
1129 hr
= IFolderView_SetCurrentViewMode(fview
, 0);
1130 ok(hr
== E_INVALIDARG
|| broken(hr
== S_OK
),
1131 "got (0x%08lx)\n", hr
);
1133 hr
= IFolderView_GetCurrentViewMode(fview
, &viewmode
);
1134 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
1136 for(i
= 1; i
< 9; i
++)
1138 hr
= IFolderView_SetCurrentViewMode(fview
, i
);
1139 ok(hr
== S_OK
|| (i
== 8 && hr
== E_INVALIDARG
/*Vista*/),
1140 "(%d) got (0x%08lx)\n", i
, hr
);
1142 hr
= IFolderView_GetCurrentViewMode(fview
, &viewmode
);
1143 ok(hr
== S_OK
, "(%d) got (0x%08lx)\n", i
, hr
);
1145 /* Wine currently behaves like winxp here. */
1146 ok((viewmode
== win7_res
[i
]) || (viewmode
== vista_res
[i
]) ||
1147 (viewmode
== win2k3_res
[i
]) || (viewmode
== winxp_res
[i
]),
1148 "(%d) got %d\n",i
, viewmode
);
1151 hr
= IFolderView_SetCurrentViewMode(fview
, 9);
1152 ok(hr
== E_INVALIDARG
|| broken(hr
== S_OK
),
1153 "got (0x%08lx)\n", hr
);
1156 hwnd_lv
= subclass_listview(hwnd
);
1157 ok(hwnd_lv
!= NULL
, "Failed to subclass listview\n");
1160 /* Vista seems to set the viewmode by other means than
1161 sending messages. At least no related messages are
1162 captured by subclassing.
1164 BOOL vista_plus
= FALSE
;
1165 static const UINT vista_plus_msgs
[] = {
1166 WM_SETREDRAW
, WM_NOTIFY
, WM_NOTIFYFORMAT
, WM_QUERYUISTATE
,
1167 WM_MENUCHAR
, WM_WINDOWPOSCHANGING
, WM_NCCALCSIZE
, WM_WINDOWPOSCHANGED
,
1168 WM_PARENTNOTIFY
, LVM_GETHEADER
, 0 };
1170 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1171 hr
= IFolderView_SetCurrentViewMode(fview
, 1);
1172 ok(hr
== S_OK
, "got 0x%08lx\n", hr
);
1174 /* WM_SETREDRAW is not sent in versions before Vista. */
1175 vista_plus
= get_msg_count(sequences
, LISTVIEW_SEQ_INDEX
, WM_SETREDRAW
);
1177 verify_msgs_in(sequences
[LISTVIEW_SEQ_INDEX
], vista_plus_msgs
);
1179 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, folderview_setcurrentviewmode1_2_prevista
,
1180 "IFolderView::SetCurrentViewMode(1)", TRUE
);
1182 hr
= IFolderView_SetCurrentViewMode(fview
, 2);
1183 ok(hr
== S_OK
, "got 0x%08lx\n", hr
);
1185 verify_msgs_in(sequences
[LISTVIEW_SEQ_INDEX
], vista_plus_msgs
);
1187 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, folderview_setcurrentviewmode1_2_prevista
,
1188 "IFolderView::SetCurrentViewMode(2)", TRUE
);
1190 hr
= IFolderView_SetCurrentViewMode(fview
, 3);
1191 ok(hr
== S_OK
, "got 0x%08lx\n", hr
);
1193 verify_msgs_in(sequences
[LISTVIEW_SEQ_INDEX
], vista_plus_msgs
);
1195 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, folderview_setcurrentviewmode3_prevista
,
1196 "IFolderView::SetCurrentViewMode(3)", TRUE
);
1198 hr
= IFolderView_SetCurrentViewMode(fview
, 4);
1199 ok(hr
== S_OK
, "got 0x%08lx\n", hr
);
1201 verify_msgs_in(sequences
[LISTVIEW_SEQ_INDEX
], vista_plus_msgs
);
1203 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, folderview_setcurrentviewmode4_prevista
,
1204 "IFolderView::SetCurrentViewMode(4)", TRUE
);
1206 hr
= IFolderView_SetCurrentViewMode(fview
, 5);
1207 ok(hr
== S_OK
, "got 0x%08lx\n", hr
);
1212 verify_msgs_in(sequences
[LISTVIEW_SEQ_INDEX
], vista_plus_msgs
);
1216 count
= get_msg_count(sequences
, LISTVIEW_SEQ_INDEX
, LVM_SETVIEW
);
1217 ok(count
== 1, "LVM_SETVIEW sent %d times.\n", count
);
1218 count
= get_msg_count(sequences
, LISTVIEW_SEQ_INDEX
, LVM_SETEXTENDEDLISTVIEWSTYLE
);
1219 ok(count
== 1 || count
== 2, "LVM_SETEXTENDEDLISTVIEWSTYLE sent %d times.\n", count
);
1220 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1224 hr
= IFolderView_SetCurrentViewMode(fview
, 6);
1225 ok(hr
== S_OK
, "got 0x%08lx\n", hr
);
1230 verify_msgs_in(sequences
[LISTVIEW_SEQ_INDEX
], vista_plus_msgs
);
1234 count
= get_msg_count(sequences
, LISTVIEW_SEQ_INDEX
, LVM_SETVIEW
);
1235 ok(count
== 1, "LVM_SETVIEW sent %d times.\n", count
);
1236 count
= get_msg_count(sequences
, LISTVIEW_SEQ_INDEX
, LVM_SETEXTENDEDLISTVIEWSTYLE
);
1237 ok(count
== 1 || count
== 2, "LVM_SETEXTENDEDLISTVIEWSTYLE sent %d times.\n", count
);
1238 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1242 hr
= IFolderView_SetCurrentViewMode(fview
, 7);
1243 ok(hr
== S_OK
, "got 0x%08lx\n", hr
);
1248 verify_msgs_in(sequences
[LISTVIEW_SEQ_INDEX
], vista_plus_msgs
);
1252 count
= get_msg_count(sequences
, LISTVIEW_SEQ_INDEX
, LVM_SETVIEW
);
1253 ok(count
== 1, "LVM_SETVIEW sent %d times.\n", count
);
1254 count
= get_msg_count(sequences
, LISTVIEW_SEQ_INDEX
, LVM_SETEXTENDEDLISTVIEWSTYLE
);
1255 ok(count
== 2, "LVM_SETEXTENDEDLISTVIEWSTYLE sent %d times.\n", count
);
1256 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1260 hr
= IFolderView_SetCurrentViewMode(fview
, 8);
1261 ok(hr
== S_OK
|| broken(hr
== E_INVALIDARG
/* Vista */), "got 0x%08lx\n", hr
);
1266 verify_msgs_in(sequences
[LISTVIEW_SEQ_INDEX
], vista_plus_msgs
);
1270 count
= get_msg_count(sequences
, LISTVIEW_SEQ_INDEX
, LVM_SETVIEW
);
1271 ok(count
== 1, "LVM_SETVIEW sent %d times.\n", count
);
1272 count
= get_msg_count(sequences
, LISTVIEW_SEQ_INDEX
, LVM_SETEXTENDEDLISTVIEWSTYLE
);
1273 ok(count
== 2, "LVM_SETEXTENDEDLISTVIEWSTYLE sent %d times.\n", count
);
1274 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1278 hr
= IFolderView_GetCurrentViewMode(fview
, &viewmode
);
1279 ok(hr
== S_OK
, "Failed to get current viewmode.\n");
1280 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, empty_seq
,
1281 "IFolderView::GetCurrentViewMode", FALSE
);
1284 IFolderView_Release(fview
);
1288 skip("No IFolderView for the desktop folder.\n");
1291 IShellBrowser_Release(browser
);
1292 IShellView_DestroyViewWindow(sview
);
1293 IShellView_Release(sview
);
1294 IShellFolder_Release(desktop
);
1297 static void test_IOleCommandTarget(void)
1299 IShellFolder
*psf_desktop
;
1301 IOleCommandTarget
*poct
;
1304 hr
= SHGetDesktopFolder(&psf_desktop
);
1305 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
1307 hr
= IShellFolder_CreateViewObject(psf_desktop
, NULL
, &IID_IShellView
, (void**)&psv
);
1308 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
1311 hr
= IShellView_QueryInterface(psv
, &IID_IOleCommandTarget
, (void**)&poct
);
1312 ok(hr
== S_OK
|| broken(hr
== E_NOINTERFACE
) /* Win95/NT4 */, "Got 0x%08lx\n", hr
);
1317 hr
= IOleCommandTarget_QueryStatus(poct
, NULL
, 0, NULL
, NULL
);
1318 ok(hr
== E_INVALIDARG
, "Got 0x%08lx\n", hr
);
1321 hr
= IOleCommandTarget_QueryStatus(poct
, NULL
, 0, &oc
, NULL
);
1322 ok(hr
== OLECMDERR_E_UNKNOWNGROUP
, "Got 0x%08lx\n", hr
);
1325 hr
= IOleCommandTarget_QueryStatus(poct
, NULL
, 1, &oc
, NULL
);
1326 ok(hr
== OLECMDERR_E_UNKNOWNGROUP
, "Got 0x%08lx\n", hr
);
1328 hr
= IOleCommandTarget_Exec(poct
, NULL
, 0, 0, NULL
, NULL
);
1329 ok(hr
== OLECMDERR_E_UNKNOWNGROUP
, "Got 0x%08lx\n", hr
);
1331 IOleCommandTarget_Release(poct
);
1334 IShellView_Release(psv
);
1337 IShellFolder_Release(psf_desktop
);
1340 static void test_SHCreateShellFolderView(void)
1342 IShellFolder
*desktop
;
1349 hr
= SHGetDesktopFolder(&desktop
);
1350 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
1355 SHCreateShellFolderView(NULL
, NULL
);
1358 psv
= (void *)0xdeadbeef;
1359 hr
= SHCreateShellFolderView(NULL
, &psv
);
1360 ok(hr
== E_INVALIDARG
, "Got 0x%08lx\n", hr
);
1361 ok(psv
== NULL
, "psv = %p\n", psv
);
1363 memset(&sfvc
, 0, sizeof(sfvc
));
1364 psv
= (void *)0xdeadbeef;
1365 hr
= SHCreateShellFolderView(&sfvc
, &psv
);
1366 ok(hr
== E_INVALIDARG
, "Got 0x%08lx\n", hr
);
1367 ok(psv
== NULL
, "psv = %p\n", psv
);
1369 memset(&sfvc
, 0, sizeof(sfvc
));
1370 sfvc
.cbSize
= sizeof(sfvc
) - 1;
1371 psv
= (void *)0xdeadbeef;
1372 hr
= SHCreateShellFolderView(&sfvc
, &psv
);
1373 ok(hr
== E_INVALIDARG
, "Got 0x%08lx\n", hr
);
1374 ok(psv
== NULL
, "psv = %p\n", psv
);
1376 memset(&sfvc
, 0, sizeof(sfvc
));
1377 sfvc
.cbSize
= sizeof(sfvc
) + 1;
1378 psv
= (void *)0xdeadbeef;
1379 hr
= SHCreateShellFolderView(&sfvc
, &psv
);
1380 ok(hr
== E_INVALIDARG
, "Got 0x%08lx\n", hr
);
1381 ok(psv
== NULL
, "psv = %p\n", psv
);
1385 /* Crashes on NULL 'pshf' on XP/2k3 */
1386 memset(&sfvc
, 0, sizeof(sfvc
));
1387 sfvc
.cbSize
= sizeof(sfvc
);
1388 psv
= (void *)0xdeadbeef;
1389 hr
= SHCreateShellFolderView(&sfvc
, &psv
);
1390 ok(hr
== E_UNEXPECTED
, "Got 0x%08lx\n", hr
);
1391 ok(psv
== NULL
, "psv = %p\n", psv
);
1393 memset(&sfvc
, 0, sizeof(sfvc
));
1394 sfvc
.cbSize
= sizeof(sfvc
) - 1;
1395 sfvc
.pshf
= desktop
;
1396 psv
= (void *)0xdeadbeef;
1397 hr
= SHCreateShellFolderView(&sfvc
, &psv
);
1398 ok(hr
== E_INVALIDARG
, "Got 0x%08lx\n", hr
);
1399 ok(psv
== NULL
, "psv = %p\n", psv
);
1401 memset(&sfvc
, 0, sizeof(sfvc
));
1402 sfvc
.cbSize
= sizeof(sfvc
);
1403 sfvc
.pshf
= desktop
;
1405 hr
= SHCreateShellFolderView(&sfvc
, &psv
);
1406 ok(hr
== S_OK
, "Got 0x%08lx\n", hr
);
1407 ok(psv
!= NULL
, "psv = %p\n", psv
);
1409 hr
= IShellView_QueryInterface(psv
, &IID_CDefView
, (void **)&unk
);
1410 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
1411 ok(unk
== (IUnknown
*)psv
, "got %p\n", unk
);
1412 IUnknown_Release(unk
);
1414 refCount
= IShellView_Release(psv
);
1415 ok(refCount
== 0, "refCount = %lu\n", refCount
);
1417 IShellFolder_Release(desktop
);
1420 static void test_SHCreateShellFolderViewEx(void)
1422 IShellFolder
*desktop
;
1429 hr
= SHGetDesktopFolder(&desktop
);
1430 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
1435 SHCreateShellFolderViewEx(NULL
, NULL
);
1436 SHCreateShellFolderViewEx(NULL
, &psv
);
1437 SHCreateShellFolderViewEx(&csfv
, NULL
);
1440 memset(&csfv
, 0, sizeof(csfv
));
1441 csfv
.pshf
= desktop
;
1443 hr
= SHCreateShellFolderViewEx(&csfv
, &psv
);
1444 ok(hr
== S_OK
, "Got 0x%08lx\n", hr
);
1445 ok(psv
!= NULL
, "psv = %p\n", psv
);
1447 hr
= IShellView_QueryInterface(psv
, &IID_CDefView
, (void **)&unk
);
1448 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
1449 ok(unk
== (IUnknown
*)psv
, "got %p\n", unk
);
1450 IUnknown_Release(unk
);
1452 refCount
= IShellView_Release(psv
);
1453 ok(refCount
== 0, "refCount = %lu\n", refCount
);
1457 /* Crashes on null shellfolder, on XP/2k3 */
1458 memset(&csfv
, 0, sizeof(csfv
));
1460 psv
= (void *)0xdeadbeef;
1461 hr
= SHCreateShellFolderViewEx(&csfv
, &psv
);
1462 ok(hr
== E_UNEXPECTED
, "Got 0x%08lx\n", hr
);
1463 ok(psv
== NULL
, "psv = %p\n", psv
);
1465 memset(&csfv
, 0, sizeof(csfv
));
1466 csfv
.cbSize
= sizeof(csfv
);
1467 csfv
.pshf
= desktop
;
1469 hr
= SHCreateShellFolderViewEx(&csfv
, &psv
);
1470 ok(hr
== S_OK
, "Got 0x%08lx\n", hr
);
1471 ok(psv
!= NULL
, "psv = %p\n", psv
);
1474 refCount
= IShellView_Release(psv
);
1475 ok(refCount
== 0, "refCount = %lu\n", refCount
);
1478 IShellFolder_Release(desktop
);
1481 static void test_newmenu(void)
1483 IUnknown
*unk
, *unk2
;
1486 hr
= CoCreateInstance(&CLSID_NewMenu
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IUnknown
, (void **)&unk
);
1488 ok(hr
== S_OK
, "Failed to create NewMenu object, hr %#lx.\n", hr
);
1491 skip("NewMenu is not supported.\n");
1495 hr
= IUnknown_QueryInterface(unk
, &IID_IShellExtInit
, (void **)&unk2
);
1496 ok(hr
== S_OK
, "Failed to get IShellExtInit, hr %#lx.\n", hr
);
1497 IUnknown_Release(unk2
);
1499 hr
= IUnknown_QueryInterface(unk
, &IID_IContextMenu3
, (void **)&unk2
);
1500 ok(hr
== S_OK
, "Failed to get IContextMenu3, hr %#lx.\n", hr
);
1501 IUnknown_Release(unk2
);
1503 hr
= IUnknown_QueryInterface(unk
, &IID_IObjectWithSite
, (void **)&unk2
);
1504 ok(hr
== S_OK
, "Failed to get IObjectWithSite, hr %#lx.\n", hr
);
1505 IUnknown_Release(unk2
);
1507 IUnknown_Release(unk
);
1512 OleInitialize(NULL
);
1514 init_msg_sequences(sequences
, NUM_MSG_SEQUENCES
);
1516 test_CreateViewWindow();
1518 test_GetItemObject();
1519 test_IShellFolderView();
1521 test_GetSetCurrentViewMode();
1522 test_IOleCommandTarget();
1523 test_SHCreateShellFolderView();
1524 test_SHCreateShellFolderViewEx();