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/heap.h"
42 #include "wine/test.h"
47 #include <reactos/undocshell.h>
50 #define LISTVIEW_SEQ_INDEX 0
51 #define NUM_MSG_SEQUENCES 1
53 DEFINE_GUID(IID_IPersistHistory
, 0x91a565c1, 0xe38f, 0x11d0, 0x94, 0xbf, 0x00, 0xa0, 0xc9, 0x05, 0x5c, 0xbf);
55 static struct msg_sequence
*sequences
[NUM_MSG_SEQUENCES
];
57 static LRESULT WINAPI
listview_subclass_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
59 WNDPROC oldproc
= (WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_USERDATA
);
60 static LONG defwndproc_counter
= 0;
61 struct message msg
= { 0 };
64 msg
.message
= message
;
65 msg
.flags
= sent
|wparam
|lparam
;
66 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
69 add_message(sequences
, LISTVIEW_SEQ_INDEX
, &msg
);
72 ret
= CallWindowProcA(oldproc
, hwnd
, message
, wParam
, lParam
);
77 static HWND
subclass_listview(HWND hwnd
)
82 /* listview is a first child */
83 listview
= FindWindowExA(hwnd
, NULL
, WC_LISTVIEWA
, NULL
);
86 /* .. except for some versions of Windows XP, where things
87 are slightly more complicated. */
89 hwnd_tmp
= FindWindowExA(hwnd
, NULL
, "DUIViewWndClassName", NULL
);
90 hwnd_tmp
= FindWindowExA(hwnd_tmp
, NULL
, "DirectUIHWND", NULL
);
91 hwnd_tmp
= FindWindowExA(hwnd_tmp
, NULL
, "CtrlNotifySink", NULL
);
92 listview
= FindWindowExA(hwnd_tmp
, NULL
, WC_LISTVIEWA
, NULL
);
95 oldproc
= (WNDPROC
)SetWindowLongPtrA(listview
, GWLP_WNDPROC
,
96 (LONG_PTR
)listview_subclass_proc
);
97 SetWindowLongPtrA(listview
, GWLP_USERDATA
, (LONG_PTR
)oldproc
);
102 static UINT
get_msg_count(struct msg_sequence
**seq
, int sequence_index
, UINT message
)
104 struct msg_sequence
*msg_seq
= seq
[sequence_index
];
107 for(i
= 0; i
< msg_seq
->count
; i
++)
108 if(msg_seq
->sequence
[i
].message
== message
)
114 /* Checks that every message in the sequence seq is also present in
115 * the UINT array msgs */
116 static void verify_msgs_in_(struct msg_sequence
*seq
, const UINT
*msgs
,
117 const char *file
, int line
)
119 UINT i
, j
, msg
, failcount
= 0;
120 for(i
= 0; i
< seq
->count
; i
++)
123 msg
= seq
->sequence
[i
].message
;
124 for(j
= 0; msgs
[j
] != 0; j
++)
125 if(msgs
[j
] == msg
) found
= TRUE
;
130 trace("Unexpected message %d\n", msg
);
133 ok_(file
, line
) (!failcount
, "%d failures.\n", failcount
);
134 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
137 #define verify_msgs_in(seq, msgs) \
138 verify_msgs_in_(seq, msgs, __FILE__, __LINE__)
140 /* dummy IDataObject implementation */
142 IDataObject IDataObject_iface
;
146 static const IDataObjectVtbl IDataObjectImpl_Vtbl
;
148 static inline IDataObjectImpl
*impl_from_IDataObject(IDataObject
*iface
)
150 return CONTAINING_RECORD(iface
, IDataObjectImpl
, IDataObject_iface
);
153 static IDataObject
* IDataObjectImpl_Construct(void)
155 IDataObjectImpl
*obj
;
157 obj
= heap_alloc(sizeof(*obj
));
158 obj
->IDataObject_iface
.lpVtbl
= &IDataObjectImpl_Vtbl
;
161 return &obj
->IDataObject_iface
;
164 static HRESULT WINAPI
IDataObjectImpl_QueryInterface(IDataObject
*iface
, REFIID riid
, void **ppvObj
)
166 IDataObjectImpl
*This
= impl_from_IDataObject(iface
);
168 if (IsEqualIID(riid
, &IID_IUnknown
) ||
169 IsEqualIID(riid
, &IID_IDataObject
))
171 *ppvObj
= &This
->IDataObject_iface
;
176 IDataObject_AddRef(iface
);
180 return E_NOINTERFACE
;
183 static ULONG WINAPI
IDataObjectImpl_AddRef(IDataObject
* iface
)
185 IDataObjectImpl
*This
= impl_from_IDataObject(iface
);
186 return InterlockedIncrement(&This
->ref
);
189 static ULONG WINAPI
IDataObjectImpl_Release(IDataObject
* iface
)
191 IDataObjectImpl
*This
= impl_from_IDataObject(iface
);
192 ULONG ref
= InterlockedDecrement(&This
->ref
);
200 static HRESULT WINAPI
IDataObjectImpl_GetData(IDataObject
*iface
, FORMATETC
*pformat
, STGMEDIUM
*pmedium
)
205 static HRESULT WINAPI
IDataObjectImpl_GetDataHere(IDataObject
*iface
, FORMATETC
*pformat
, STGMEDIUM
*pmedium
)
210 static HRESULT WINAPI
IDataObjectImpl_QueryGetData(IDataObject
*iface
, FORMATETC
*pformat
)
215 static HRESULT WINAPI
IDataObjectImpl_GetCanonicalFormatEtc(
216 IDataObject
*iface
, FORMATETC
*pformatIn
, FORMATETC
*pformatOut
)
221 static HRESULT WINAPI
IDataObjectImpl_SetData(
222 IDataObject
*iface
, FORMATETC
*pformat
, STGMEDIUM
*pmedium
, BOOL release
)
227 static HRESULT WINAPI
IDataObjectImpl_EnumFormatEtc(
228 IDataObject
*iface
, DWORD direction
, IEnumFORMATETC
**ppenumFormatEtc
)
233 static HRESULT WINAPI
IDataObjectImpl_DAdvise(
234 IDataObject
*iface
, FORMATETC
*pformatetc
, DWORD advf
, IAdviseSink
*pSink
, DWORD
*pConnection
)
239 static HRESULT WINAPI
IDataObjectImpl_DUnadvise(IDataObject
*iface
, DWORD connection
)
244 static HRESULT WINAPI
IDataObjectImpl_EnumDAdvise(IDataObject
*iface
, IEnumSTATDATA
**ppenumAdvise
)
249 static const IDataObjectVtbl IDataObjectImpl_Vtbl
=
251 IDataObjectImpl_QueryInterface
,
252 IDataObjectImpl_AddRef
,
253 IDataObjectImpl_Release
,
254 IDataObjectImpl_GetData
,
255 IDataObjectImpl_GetDataHere
,
256 IDataObjectImpl_QueryGetData
,
257 IDataObjectImpl_GetCanonicalFormatEtc
,
258 IDataObjectImpl_SetData
,
259 IDataObjectImpl_EnumFormatEtc
,
260 IDataObjectImpl_DAdvise
,
261 IDataObjectImpl_DUnadvise
,
262 IDataObjectImpl_EnumDAdvise
265 /* dummy IShellBrowser implementation */
267 IShellBrowser IShellBrowser_iface
;
271 static const IShellBrowserVtbl IShellBrowserImpl_Vtbl
;
273 static inline IShellBrowserImpl
*impl_from_IShellBrowser(IShellBrowser
*iface
)
275 return CONTAINING_RECORD(iface
, IShellBrowserImpl
, IShellBrowser_iface
);
278 static IShellBrowser
* IShellBrowserImpl_Construct(void)
280 IShellBrowserImpl
*browser
;
282 browser
= heap_alloc(sizeof(*browser
));
283 browser
->IShellBrowser_iface
.lpVtbl
= &IShellBrowserImpl_Vtbl
;
286 return &browser
->IShellBrowser_iface
;
289 static HRESULT WINAPI
IShellBrowserImpl_QueryInterface(IShellBrowser
*iface
,
293 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
297 if(IsEqualIID(riid
, &IID_IUnknown
) ||
298 IsEqualIID(riid
, &IID_IOleWindow
) ||
299 IsEqualIID(riid
, &IID_IShellBrowser
))
301 *ppvObj
= &This
->IShellBrowser_iface
;
306 IShellBrowser_AddRef(iface
);
310 return E_NOINTERFACE
;
313 static ULONG WINAPI
IShellBrowserImpl_AddRef(IShellBrowser
* iface
)
315 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
316 return InterlockedIncrement(&This
->ref
);
319 static ULONG WINAPI
IShellBrowserImpl_Release(IShellBrowser
* iface
)
321 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
322 ULONG ref
= InterlockedDecrement(&This
->ref
);
330 static HRESULT WINAPI
IShellBrowserImpl_GetWindow(IShellBrowser
*iface
,
333 if (phwnd
) *phwnd
= GetDesktopWindow();
337 static HRESULT WINAPI
IShellBrowserImpl_ContextSensitiveHelp(IShellBrowser
*iface
,
343 static HRESULT WINAPI
IShellBrowserImpl_BrowseObject(IShellBrowser
*iface
,
350 static HRESULT WINAPI
IShellBrowserImpl_EnableModelessSB(IShellBrowser
*iface
,
357 static HRESULT WINAPI
IShellBrowserImpl_GetControlWindow(IShellBrowser
*iface
,
365 static HRESULT WINAPI
IShellBrowserImpl_GetViewStateStream(IShellBrowser
*iface
,
373 static HRESULT WINAPI
IShellBrowserImpl_InsertMenusSB(IShellBrowser
*iface
,
375 LPOLEMENUGROUPWIDTHS lpMenuWidths
)
381 static HRESULT WINAPI
IShellBrowserImpl_OnViewWindowActive(IShellBrowser
*iface
,
388 static HRESULT WINAPI
IShellBrowserImpl_QueryActiveShellView(IShellBrowser
*iface
,
395 static HRESULT WINAPI
IShellBrowserImpl_RemoveMenusSB(IShellBrowser
*iface
,
402 static HRESULT WINAPI
IShellBrowserImpl_SendControlMsg(IShellBrowser
*iface
,
413 static HRESULT WINAPI
IShellBrowserImpl_SetMenuSB(IShellBrowser
*iface
,
415 HOLEMENU holemenuReserved
,
416 HWND hwndActiveObject
)
422 static HRESULT WINAPI
IShellBrowserImpl_SetStatusTextSB(IShellBrowser
*iface
,
423 LPCOLESTR lpszStatusText
)
429 static HRESULT WINAPI
IShellBrowserImpl_SetToolbarItems(IShellBrowser
*iface
,
430 LPTBBUTTON lpButtons
,
438 static HRESULT WINAPI
IShellBrowserImpl_TranslateAcceleratorSB(IShellBrowser
*iface
,
446 static const IShellBrowserVtbl IShellBrowserImpl_Vtbl
=
448 IShellBrowserImpl_QueryInterface
,
449 IShellBrowserImpl_AddRef
,
450 IShellBrowserImpl_Release
,
451 IShellBrowserImpl_GetWindow
,
452 IShellBrowserImpl_ContextSensitiveHelp
,
453 IShellBrowserImpl_InsertMenusSB
,
454 IShellBrowserImpl_SetMenuSB
,
455 IShellBrowserImpl_RemoveMenusSB
,
456 IShellBrowserImpl_SetStatusTextSB
,
457 IShellBrowserImpl_EnableModelessSB
,
458 IShellBrowserImpl_TranslateAcceleratorSB
,
459 IShellBrowserImpl_BrowseObject
,
460 IShellBrowserImpl_GetViewStateStream
,
461 IShellBrowserImpl_GetControlWindow
,
462 IShellBrowserImpl_SendControlMsg
,
463 IShellBrowserImpl_QueryActiveShellView
,
464 IShellBrowserImpl_OnViewWindowActive
,
465 IShellBrowserImpl_SetToolbarItems
468 static const struct message empty_seq
[] = {
472 static const struct message folderview_getspacing_seq
[] = {
473 { LVM_GETITEMSPACING
, wparam
|sent
, FALSE
},
477 static const struct message folderview_getselectionmarked_seq
[] = {
478 { LVM_GETSELECTIONMARK
, sent
},
482 static const struct message folderview_getfocused_seq
[] = {
483 { LVM_GETNEXTITEM
, sent
|wparam
|lparam
|optional
, -1, LVNI_FOCUSED
},
487 static HRESULT WINAPI
shellbrowser_QueryInterface(IShellBrowser
*iface
, REFIID riid
, void **ppv
)
491 if (IsEqualGUID(&IID_IShellBrowser
, riid
) ||
492 IsEqualGUID(&IID_IOleWindow
, riid
) ||
493 IsEqualGUID(&IID_IUnknown
, riid
))
500 IUnknown_AddRef((IUnknown
*)*ppv
);
504 return E_NOINTERFACE
;
507 static ULONG WINAPI
shellbrowser_AddRef(IShellBrowser
*iface
)
512 static ULONG WINAPI
shellbrowser_Release(IShellBrowser
*iface
)
517 static HRESULT WINAPI
shellbrowser_GetWindow(IShellBrowser
*iface
, HWND
*phwnd
)
519 *phwnd
= GetDesktopWindow();
523 static HRESULT WINAPI
shellbrowser_ContextSensitiveHelp(IShellBrowser
*iface
, BOOL mode
)
525 ok(0, "unexpected\n");
529 static HRESULT WINAPI
shellbrowser_InsertMenusSB(IShellBrowser
*iface
, HMENU hmenuShared
,
530 OLEMENUGROUPWIDTHS
*menuwidths
)
535 static HRESULT WINAPI
shellbrowser_SetMenuSB(IShellBrowser
*iface
, HMENU hmenuShared
,
536 HOLEMENU holemenuReserved
, HWND hwndActiveObject
)
541 static HRESULT WINAPI
shellbrowser_RemoveMenusSB(IShellBrowser
*iface
, HMENU hmenuShared
)
546 static HRESULT WINAPI
shellbrowser_SetStatusTextSB(IShellBrowser
*iface
, LPCOLESTR text
)
548 ok(0, "unexpected\n");
552 static HRESULT WINAPI
shellbrowser_EnableModelessSB(IShellBrowser
*iface
, BOOL enable
)
554 ok(0, "unexpected\n");
558 static HRESULT WINAPI
shellbrowser_TranslateAcceleratorSB(IShellBrowser
*iface
, MSG
*pmsg
, WORD wID
)
560 ok(0, "unexpected\n");
564 static HRESULT WINAPI
shellbrowser_BrowseObject(IShellBrowser
*iface
, LPCITEMIDLIST pidl
, UINT flags
)
566 ok(0, "unexpected\n");
570 static HRESULT WINAPI
shellbrowser_GetViewStateStream(IShellBrowser
*iface
, DWORD mode
, IStream
**stream
)
575 static HRESULT WINAPI
shellbrowser_GetControlWindow(IShellBrowser
*iface
, UINT id
, HWND
*phwnd
)
580 static HRESULT WINAPI
shellbrowser_SendControlMsg(IShellBrowser
*iface
, UINT id
, UINT uMsg
,
581 WPARAM wParam
, LPARAM lParam
, LRESULT
*pret
)
586 static HRESULT WINAPI
shellbrowser_QueryActiveShellView(IShellBrowser
*iface
, IShellView
**view
)
588 ok(0, "unexpected\n");
592 static HRESULT WINAPI
shellbrowser_OnViewWindowActive(IShellBrowser
*iface
, IShellView
*view
)
594 ok(0, "unexpected\n");
598 static HRESULT WINAPI
shellbrowser_SetToolbarItems(IShellBrowser
*iface
, LPTBBUTTONSB buttons
,
599 UINT count
, UINT flags
)
604 static const IShellBrowserVtbl shellbrowservtbl
= {
605 shellbrowser_QueryInterface
,
607 shellbrowser_Release
,
608 shellbrowser_GetWindow
,
609 shellbrowser_ContextSensitiveHelp
,
610 shellbrowser_InsertMenusSB
,
611 shellbrowser_SetMenuSB
,
612 shellbrowser_RemoveMenusSB
,
613 shellbrowser_SetStatusTextSB
,
614 shellbrowser_EnableModelessSB
,
615 shellbrowser_TranslateAcceleratorSB
,
616 shellbrowser_BrowseObject
,
617 shellbrowser_GetViewStateStream
,
618 shellbrowser_GetControlWindow
,
619 shellbrowser_SendControlMsg
,
620 shellbrowser_QueryActiveShellView
,
621 shellbrowser_OnViewWindowActive
,
622 shellbrowser_SetToolbarItems
625 static IShellBrowser test_shellbrowser
= { &shellbrowservtbl
};
627 static void test_CreateViewWindow(void)
629 IShellFolder
*desktop
;
630 HWND hwnd_view
, hwnd2
;
631 FOLDERSETTINGS settings
;
639 hr
= SHGetDesktopFolder(&desktop
);
640 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
642 hr
= IShellFolder_CreateViewObject(desktop
, NULL
, &IID_IShellView
, (void**)&view
);
643 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
645 hr
= IShellView_QueryInterface(view
, &IID_CDefView
, (void **)&unk
);
646 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
647 ok(unk
== (IUnknown
*)view
, "got %p\n", unk
);
648 IUnknown_Release(unk
);
652 /* crashes on native */
653 IShellView_CreateViewWindow(view
, NULL
, &settings
, NULL
, NULL
, NULL
);
656 settings
.ViewMode
= FVM_ICON
;
658 hwnd_view
= (HWND
)0xdeadbeef;
659 hr
= IShellView_CreateViewWindow(view
, NULL
, &settings
, NULL
, NULL
, &hwnd_view
);
660 ok(hr
== E_UNEXPECTED
, "got (0x%08x)\n", hr
);
661 ok(hwnd_view
== 0, "got %p\n", hwnd_view
);
663 hwnd_view
= (HWND
)0xdeadbeef;
664 hr
= IShellView_CreateViewWindow(view
, NULL
, &settings
, NULL
, &r
, &hwnd_view
);
665 ok(hr
== E_UNEXPECTED
, "got (0x%08x)\n", hr
);
666 ok(hwnd_view
== 0, "got %p\n", hwnd_view
);
669 hr
= IShellView_CreateViewWindow(view
, NULL
, &settings
, &test_shellbrowser
, &r
, &hwnd_view
);
670 ok(hr
== S_OK
|| broken(hr
== S_FALSE
), "got (0x%08x)\n", hr
);
671 ok(hwnd_view
!= 0, "got %p\n", hwnd_view
);
673 hwnd2
= (HWND
)0xdeadbeef;
674 hr
= IShellView_CreateViewWindow(view
, NULL
, &settings
, &test_shellbrowser
, &r
, &hwnd2
);
675 ok(hr
== E_UNEXPECTED
, "got (0x%08x)\n", hr
);
676 ok(hwnd2
== NULL
, "got %p\n", hwnd2
);
678 /* ::DragLeave without drag operation */
679 hr
= IShellView_QueryInterface(view
, &IID_IDropTarget
, (void**)&dt
);
680 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
681 hr
= IDropTarget_DragLeave(dt
);
682 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
683 IDropTarget_Release(dt
);
685 IShellView_AddRef(view
);
686 ref1
= IShellView_Release(view
);
687 hr
= IShellView_DestroyViewWindow(view
);
688 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
689 ok(!IsWindow(hwnd_view
), "hwnd %p still valid\n", hwnd_view
);
690 ref2
= IShellView_Release(view
);
691 ok(ref1
> ref2
, "expected %u > %u\n", ref1
, ref2
);
694 /* Show that releasing the shell view does not destroy the window */
695 hr
= IShellFolder_CreateViewObject(desktop
, NULL
, &IID_IShellView
, (void**)&view
);
696 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
698 hr
= IShellView_CreateViewWindow(view
, NULL
, &settings
, &test_shellbrowser
, &r
, &hwnd_view
);
699 ok(hr
== S_OK
|| broken(hr
== S_FALSE
), "got (0x%08x)\n", hr
);
700 ok(hwnd_view
!= NULL
, "got %p\n", hwnd_view
);
701 ok(IsWindow(hwnd_view
), "hwnd %p still valid\n", hwnd_view
);
702 ref2
= IShellView_Release(view
);
703 ok(ref2
!= 0, "ref2 = %u\n", ref2
);
704 ok(ref2
> ref1
, "expected %u > %u\n", ref2
, ref1
);
705 ok(IsWindow(hwnd_view
), "hwnd %p still valid\n", hwnd_view
);
706 DestroyWindow(hwnd_view
);
708 IShellFolder_Release(desktop
);
711 static void test_IFolderView(void)
713 IShellFolder
*desktop
, *folder
;
714 FOLDERSETTINGS settings
;
716 IShellBrowser
*browser
;
720 HWND hwnd_view
, hwnd_list
;
727 hr
= SHGetDesktopFolder(&desktop
);
728 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
730 hr
= IShellFolder_CreateViewObject(desktop
, NULL
, &IID_IShellView
, (void**)&view
);
731 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
733 hr
= IShellView_QueryInterface(view
, &IID_IFolderView
, (void**)&fv
);
736 win_skip("IFolderView not supported by desktop folder\n");
737 IShellView_Release(view
);
738 IShellFolder_Release(desktop
);
742 /* call methods before window creation */
743 hr
= IFolderView_GetSpacing(fv
, NULL
);
744 ok(hr
== S_FALSE
|| broken(hr
== S_OK
) /* win7 */, "got (0x%08x)\n", hr
);
746 pidl
= (void*)0xdeadbeef;
747 hr
= IFolderView_Item(fv
, 0, &pidl
);
748 ok(hr
== E_INVALIDARG
|| broken(hr
== E_FAIL
) /* < Vista */, "got (0x%08x)\n", hr
);
749 ok(pidl
== 0 || broken(pidl
== (void*)0xdeadbeef) /* < Vista */, "got %p\n", pidl
);
753 /* crashes on Vista and Win2k8 - List not created yet case */
754 IFolderView_GetSpacing(fv
, &pt
);
757 IFolderView_GetSelectionMarkedItem(fv
, NULL
);
758 IFolderView_GetFocusedItem(fv
, NULL
);
760 /* crashes on Vista+ */
761 IFolderView_Item(fv
, 0, NULL
);
764 browser
= IShellBrowserImpl_Construct();
766 settings
.ViewMode
= FVM_ICON
;
768 hwnd_view
= (HWND
)0xdeadbeef;
769 SetRect(&r
, 0, 0, 100, 100);
770 hr
= IShellView_CreateViewWindow(view
, NULL
, &settings
, browser
, &r
, &hwnd_view
);
771 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
772 ok(IsWindow(hwnd_view
), "got %p\n", hwnd_view
);
774 hwnd_list
= subclass_listview(hwnd_view
);
777 win_skip("Failed to subclass ListView control\n");
778 IShellBrowser_Release(browser
);
779 IFolderView_Release(fv
);
780 IShellView_Release(view
);
781 IShellFolder_Release(desktop
);
785 /* IFolderView::GetSpacing */
786 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
787 hr
= IFolderView_GetSpacing(fv
, NULL
);
788 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
789 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, empty_seq
, "IFolderView::GetSpacing, empty", FALSE
);
791 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
792 hr
= IFolderView_GetSpacing(fv
, &pt
);
793 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
794 /* fails with empty sequence on win7 for unknown reason */
795 if (sequences
[LISTVIEW_SEQ_INDEX
]->count
)
797 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, folderview_getspacing_seq
, "IFolderView::GetSpacing", FALSE
);
798 ok(pt
.x
> 0, "got %d\n", pt
.x
);
799 ok(pt
.y
> 0, "got %d\n", pt
.y
);
800 ret
= SendMessageA(hwnd_list
, LVM_GETITEMSPACING
, 0, 0);
801 ok(pt
.x
== LOWORD(ret
) && pt
.y
== HIWORD(ret
), "got (%d, %d)\n", LOWORD(ret
), HIWORD(ret
));
804 /* IFolderView::ItemCount */
808 IFolderView_ItemCount(fv
, SVGIO_ALLVIEW
, NULL
);
811 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
812 IFolderView_ItemCount(fv
, SVGIO_ALLVIEW
, &count
);
814 /* IFolderView::GetSelectionMarkedItem */
818 IFolderView_GetSelectionMarkedItem(fv
, NULL
);
821 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
822 hr
= IFolderView_GetSelectionMarkedItem(fv
, &ret
);
824 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
826 ok(hr
== S_FALSE
, "got (0x%08x)\n", hr
);
827 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, folderview_getselectionmarked_seq
,
828 "IFolderView::GetSelectionMarkedItem", FALSE
);
830 /* IFolderView::GetFocusedItem */
831 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
832 hr
= IFolderView_GetFocusedItem(fv
, &ret
);
834 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
836 ok(hr
== S_FALSE
, "got (0x%08x)\n", hr
);
837 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, folderview_getfocused_seq
,
838 "IFolderView::GetFocusedItem", FALSE
);
840 /* IFolderView::GetFolder, just return pointer */
844 IFolderView_GetFolder(fv
, NULL
, (void**)&folder
);
845 IFolderView_GetFolder(fv
, NULL
, NULL
);
848 hr
= IFolderView_GetFolder(fv
, &IID_IShellFolder
, NULL
);
849 ok(hr
== E_POINTER
, "got (0x%08x)\n", hr
);
851 hr
= IFolderView_GetFolder(fv
, &IID_IShellFolder
, (void**)&folder
);
852 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
853 ok(desktop
== folder
, "\n");
854 if (folder
) IShellFolder_Release(folder
);
856 hr
= IFolderView_GetFolder(fv
, &IID_IUnknown
, (void**)&unk
);
857 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
858 if (unk
) IUnknown_Release(unk
);
860 hr
= IFolderView_QueryInterface(fv
, &IID_IFolderView2
, (void**)&fv2
);
862 win_skip("IFolderView2 is not supported.\n");
863 if (fv2
) IFolderView2_Release(fv2
);
865 hr
= IShellView_DestroyViewWindow(view
);
866 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
867 ok(!IsWindow(hwnd_view
), "hwnd %p still valid\n", hwnd_view
);
869 IShellBrowser_Release(browser
);
870 IFolderView_Release(fv
);
871 IShellView_Release(view
);
872 IShellFolder_Release(desktop
);
875 static void test_GetItemObject(void)
877 IShellFolder
*desktop
;
882 hr
= SHGetDesktopFolder(&desktop
);
883 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
885 hr
= IShellFolder_CreateViewObject(desktop
, NULL
, &IID_IShellView
, (void**)&view
);
886 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
888 /* from documentation three interfaces are supported for SVGIO_BACKGROUND:
889 IContextMenu, IDispatch, IPersistHistory */
890 hr
= IShellView_GetItemObject(view
, SVGIO_BACKGROUND
, &IID_IContextMenu
, (void**)&unk
);
891 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
892 IUnknown_Release(unk
);
895 hr
= IShellView_GetItemObject(view
, SVGIO_BACKGROUND
, &IID_IDispatch
, (void**)&unk
);
896 ok(hr
== S_OK
|| broken(hr
== E_NOTIMPL
) /* NT4 */, "got (0x%08x)\n", hr
);
897 if (unk
) IUnknown_Release(unk
);
900 hr
= IShellView_GetItemObject(view
, SVGIO_BACKGROUND
, &IID_IPersistHistory
, (void**)&unk
);
901 todo_wine
ok(hr
== S_OK
|| broken(hr
== E_NOTIMPL
) /* W9x, NT4 */, "got (0x%08x)\n", hr
);
902 if (unk
) IUnknown_Release(unk
);
904 /* example of unsupported interface, base for IPersistHistory */
905 hr
= IShellView_GetItemObject(view
, SVGIO_BACKGROUND
, &IID_IPersist
, (void**)&unk
);
906 ok(hr
== E_NOINTERFACE
|| broken(hr
== E_NOTIMPL
) /* W2K */, "got (0x%08x)\n", hr
);
908 IShellView_Release(view
);
909 IShellFolder_Release(desktop
);
912 static void test_IShellFolderView(void)
914 IShellFolderView
*folderview
;
915 IShellFolder
*desktop
;
921 hr
= SHGetDesktopFolder(&desktop
);
922 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
924 hr
= IShellFolder_CreateViewObject(desktop
, NULL
, &IID_IShellView
, (void**)&view
);
925 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
927 hr
= IShellView_QueryInterface(view
, &IID_IShellFolderView
, (void**)&folderview
);
930 win_skip("IShellView doesn't provide IShellFolderView on this platform\n");
931 IShellView_Release(view
);
932 IShellFolder_Release(desktop
);
937 obj
= IDataObjectImpl_Construct();
938 hr
= IShellFolderView_MoveIcons(folderview
, obj
);
939 ok(hr
== E_NOTIMPL
|| broken(hr
== S_OK
) /* W98 */, "got (0x%08x)\n", hr
);
940 IDataObject_Release(obj
);
942 /* ::SetRedraw without list created */
943 hr
= IShellFolderView_SetRedraw(folderview
, TRUE
);
944 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
947 hr
= IShellFolderView_QuerySupport(folderview
, NULL
);
948 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
950 hr
= IShellFolderView_QuerySupport(folderview
, &i
);
951 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
952 ok(i
== 0xdeadbeef, "got %d\n", i
);
956 hr
= IShellFolderView_RemoveObject(folderview
, NULL
, &i
);
957 ok(hr
== S_OK
|| hr
== E_FAIL
, "got (0x%08x)\n", hr
);
958 if (hr
== S_OK
) ok(i
== 0 || broken(i
== 0xdeadbeef) /* Vista, 2k8 */,
961 IShellFolderView_Release(folderview
);
963 IShellView_Release(view
);
964 IShellFolder_Release(desktop
);
967 static void test_IOleWindow(void)
969 IShellFolder
*desktop
;
974 hr
= SHGetDesktopFolder(&desktop
);
975 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
977 hr
= IShellFolder_CreateViewObject(desktop
, NULL
, &IID_IShellView
, (void**)&view
);
978 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
980 hr
= IShellView_QueryInterface(view
, &IID_IOleWindow
, (void**)&wnd
);
981 ok(hr
== E_NOINTERFACE
, "got (0x%08x)\n", hr
);
983 /* IShellView::ContextSensitiveHelp */
984 hr
= IShellView_ContextSensitiveHelp(view
, TRUE
);
985 ok(hr
== E_NOTIMPL
, "got (0x%08x)\n", hr
);
986 hr
= IShellView_ContextSensitiveHelp(view
, FALSE
);
987 ok(hr
== E_NOTIMPL
, "got (0x%08x)\n", hr
);
989 IShellView_Release(view
);
990 IShellFolder_Release(desktop
);
993 static const struct message folderview_setcurrentviewmode1_2_prevista
[] = {
994 { LVM_SETVIEW
, sent
|wparam
, LV_VIEW_ICON
},
995 { LVM_SETIMAGELIST
, sent
|wparam
, 0},
996 { LVM_SETIMAGELIST
, sent
|wparam
, 1},
998 { LVM_SETBKIMAGEW
, sent
|optional
}, /* w2k3 */
999 { LVM_GETBKCOLOR
, sent
|optional
}, /* w2k3 */
1000 { LVM_GETTEXTBKCOLOR
, sent
|optional
}, /* w2k3 */
1001 { LVM_GETTEXTCOLOR
, sent
|optional
}, /* w2k3 */
1002 { LVM_SETEXTENDEDLISTVIEWSTYLE
, sent
|optional
|wparam
, 0xc8}, /* w2k3 */
1003 { LVM_ARRANGE
, sent
},
1004 { LVM_ARRANGE
, sent
|optional
}, /* WinXP */
1008 static const struct message folderview_setcurrentviewmode3_prevista
[] = {
1009 { LVM_SETVIEW
, sent
|wparam
, LV_VIEW_LIST
},
1010 { LVM_SETIMAGELIST
, sent
|wparam
, 0},
1011 { LVM_SETIMAGELIST
, sent
|wparam
, 1},
1013 { LVM_SETBKIMAGEW
, sent
|optional
}, /* w2k3 */
1014 { LVM_GETBKCOLOR
, sent
|optional
}, /* w2k3 */
1015 { LVM_GETTEXTBKCOLOR
, sent
|optional
}, /* w2k3 */
1016 { LVM_GETTEXTCOLOR
, sent
|optional
}, /* w2k3 */
1017 { LVM_SETEXTENDEDLISTVIEWSTYLE
, sent
|optional
|wparam
, 0xc8}, /* w2k3 */
1021 static const struct message folderview_setcurrentviewmode4_prevista
[] = {
1022 { LVM_GETHEADER
, sent
},
1023 { LVM_GETITEMCOUNT
, sent
|optional
},
1024 { LVM_SETSELECTEDCOLUMN
, sent
},
1025 { WM_NOTIFY
, sent
},
1026 { WM_NOTIFY
, sent
},
1027 { WM_NOTIFY
, sent
},
1028 { WM_NOTIFY
, sent
},
1029 { LVM_SETVIEW
, sent
|wparam
, LV_VIEW_DETAILS
},
1030 { LVM_SETIMAGELIST
, sent
|wparam
, 0},
1031 { LVM_SETIMAGELIST
, sent
|wparam
, 1},
1033 { LVM_SETBKIMAGEW
, sent
|optional
}, /* w2k3 */
1034 { LVM_GETBKCOLOR
, sent
|optional
}, /* w2k3 */
1035 { LVM_GETTEXTBKCOLOR
, sent
|optional
}, /* w2k3 */
1036 { LVM_GETTEXTCOLOR
, sent
|optional
}, /* w2k3 */
1037 { LVM_SETEXTENDEDLISTVIEWSTYLE
, sent
|optional
|wparam
, 0xc8}, /* w2k3 */
1041 /* XP, SetCurrentViewMode(5)
1042 108e - LVM_SETVIEW (LV_VIEW_ICON);
1043 1036 - LVM_SETEXTEDEDLISTVIEWSTYLE (0x8000, 0)
1044 100c/104c repeated X times
1045 1003 - LVM_SETIMAGELIST
1046 1035 - LVM_SETICONSPACING
1047 1004 - LVM_GETITEMCOUNT
1053 /* XP, SetCurrentViewMode(6)
1054 1036 - LVM_SETEXTENDEDLISTVIEWSTYLE (0x8000, 0)
1055 1035 - LVM_SETICONSPACING
1056 1003 - LVM_SETIMAGELIST
1057 1003 - LVM_SETIMAGELIST
1058 100c/104c repeated X times
1059 10a2 - LVM_SETTILEVIEWINFO
1060 108e - LVM_SETVIEW (LV_VIEW_TILE)
1061 1003 - LVM_SETIMAGELIST
1067 /* XP, SetCurrentViewMode (7)
1068 10a2 - LVM_SETTILEVIEWINFO
1069 108e - LVM_SETVIEW (LV_VIEW_ICON)
1070 1004/10a4 (LVM_GETITEMCOUNT/LVM_SETTILEINFO) X times
1074 LVM_SETEXTENDEDLISTVIEWSTYLE (0x40000, 0x40000)
1076 LVM_SETEXTENDEDLISTVIEWSTYLE (0x8000, 0x8000)
1079 static void test_GetSetCurrentViewMode(void)
1081 IShellFolder
*desktop
;
1084 IShellBrowser
*browser
;
1088 RECT rc
= {0, 0, 10, 10};
1091 static const int winxp_res
[11] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
1092 static const int win2k3_res
[11] = {0, 1, 2, 3, 4, 5, 6, 5, 8, 0, 0};
1093 static const int vista_res
[11] = {0, 1, 5, 3, 4, 5, 6, 7, 7, 0, 0};
1094 static const int win7_res
[11] = {1, 1, 1, 3, 4, 1, 6, 1, 8, 8, 8};
1096 hr
= SHGetDesktopFolder(&desktop
);
1097 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
1099 hr
= IShellFolder_CreateViewObject(desktop
, NULL
, &IID_IShellView
, (void**)&sview
);
1100 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
1104 browser
= IShellBrowserImpl_Construct();
1105 hr
= IShellView_CreateViewWindow(sview
, NULL
, &fs
, browser
, &rc
, &hwnd
);
1106 ok(hr
== S_OK
|| broken(hr
== S_FALSE
/*Win2k*/ ), "got (0x%08x)\n", hr
);
1108 hr
= IShellView_QueryInterface(sview
, &IID_IFolderView
, (void**)&fview
);
1109 ok(hr
== S_OK
|| broken(hr
== E_NOINTERFACE
), "got (0x%08x)\n", hr
);
1117 /* Crashes under Win7/WinXP */
1118 IFolderView_GetCurrentViewMode(fview
, NULL
);
1121 hr
= IFolderView_GetCurrentViewMode(fview
, &viewmode
);
1122 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
1123 ok(viewmode
== 1, "ViewMode was %d\n", viewmode
);
1125 hr
= IFolderView_SetCurrentViewMode(fview
, FVM_AUTO
);
1126 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
1128 hr
= IFolderView_SetCurrentViewMode(fview
, 0);
1129 ok(hr
== E_INVALIDARG
|| broken(hr
== S_OK
),
1130 "got (0x%08x)\n", hr
);
1132 hr
= IFolderView_GetCurrentViewMode(fview
, &viewmode
);
1133 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
1135 for(i
= 1; i
< 9; i
++)
1137 hr
= IFolderView_SetCurrentViewMode(fview
, i
);
1138 ok(hr
== S_OK
|| (i
== 8 && hr
== E_INVALIDARG
/*Vista*/),
1139 "(%d) got (0x%08x)\n", i
, hr
);
1141 hr
= IFolderView_GetCurrentViewMode(fview
, &viewmode
);
1142 ok(hr
== S_OK
, "(%d) got (0x%08x)\n", i
, hr
);
1144 /* Wine currently behaves like winxp here. */
1145 ok((viewmode
== win7_res
[i
]) || (viewmode
== vista_res
[i
]) ||
1146 (viewmode
== win2k3_res
[i
]) || (viewmode
== winxp_res
[i
]),
1147 "(%d) got %d\n",i
, viewmode
);
1150 hr
= IFolderView_SetCurrentViewMode(fview
, 9);
1151 ok(hr
== E_INVALIDARG
|| broken(hr
== S_OK
),
1152 "got (0x%08x)\n", hr
);
1155 hwnd_lv
= subclass_listview(hwnd
);
1156 ok(hwnd_lv
!= NULL
, "Failed to subclass listview\n");
1159 /* Vista seems to set the viewmode by other means than
1160 sending messages. At least no related messages are
1161 captured by subclassing.
1163 BOOL vista_plus
= FALSE
;
1164 static const UINT vista_plus_msgs
[] = {
1165 WM_SETREDRAW
, WM_NOTIFY
, WM_NOTIFYFORMAT
, WM_QUERYUISTATE
,
1166 WM_MENUCHAR
, WM_WINDOWPOSCHANGING
, WM_NCCALCSIZE
, WM_WINDOWPOSCHANGED
,
1167 WM_PARENTNOTIFY
, LVM_GETHEADER
, 0 };
1169 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1170 hr
= IFolderView_SetCurrentViewMode(fview
, 1);
1171 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1173 /* WM_SETREDRAW is not sent in versions before Vista. */
1174 vista_plus
= get_msg_count(sequences
, LISTVIEW_SEQ_INDEX
, WM_SETREDRAW
);
1176 verify_msgs_in(sequences
[LISTVIEW_SEQ_INDEX
], vista_plus_msgs
);
1178 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, folderview_setcurrentviewmode1_2_prevista
,
1179 "IFolderView::SetCurrentViewMode(1)", TRUE
);
1181 hr
= IFolderView_SetCurrentViewMode(fview
, 2);
1182 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1184 verify_msgs_in(sequences
[LISTVIEW_SEQ_INDEX
], vista_plus_msgs
);
1186 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, folderview_setcurrentviewmode1_2_prevista
,
1187 "IFolderView::SetCurrentViewMode(2)", TRUE
);
1189 hr
= IFolderView_SetCurrentViewMode(fview
, 3);
1190 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1192 verify_msgs_in(sequences
[LISTVIEW_SEQ_INDEX
], vista_plus_msgs
);
1194 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, folderview_setcurrentviewmode3_prevista
,
1195 "IFolderView::SetCurrentViewMode(3)", TRUE
);
1197 hr
= IFolderView_SetCurrentViewMode(fview
, 4);
1198 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1200 verify_msgs_in(sequences
[LISTVIEW_SEQ_INDEX
], vista_plus_msgs
);
1202 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, folderview_setcurrentviewmode4_prevista
,
1203 "IFolderView::SetCurrentViewMode(4)", TRUE
);
1205 hr
= IFolderView_SetCurrentViewMode(fview
, 5);
1206 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1211 verify_msgs_in(sequences
[LISTVIEW_SEQ_INDEX
], vista_plus_msgs
);
1215 count
= get_msg_count(sequences
, LISTVIEW_SEQ_INDEX
, LVM_SETVIEW
);
1216 ok(count
== 1, "LVM_SETVIEW sent %d times.\n", count
);
1217 count
= get_msg_count(sequences
, LISTVIEW_SEQ_INDEX
, LVM_SETEXTENDEDLISTVIEWSTYLE
);
1218 ok(count
== 1 || count
== 2, "LVM_SETEXTENDEDLISTVIEWSTYLE sent %d times.\n", count
);
1219 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1223 hr
= IFolderView_SetCurrentViewMode(fview
, 6);
1224 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1229 verify_msgs_in(sequences
[LISTVIEW_SEQ_INDEX
], vista_plus_msgs
);
1233 count
= get_msg_count(sequences
, LISTVIEW_SEQ_INDEX
, LVM_SETVIEW
);
1234 ok(count
== 1, "LVM_SETVIEW sent %d times.\n", count
);
1235 count
= get_msg_count(sequences
, LISTVIEW_SEQ_INDEX
, LVM_SETEXTENDEDLISTVIEWSTYLE
);
1236 ok(count
== 1 || count
== 2, "LVM_SETEXTENDEDLISTVIEWSTYLE sent %d times.\n", count
);
1237 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1241 hr
= IFolderView_SetCurrentViewMode(fview
, 7);
1242 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1247 verify_msgs_in(sequences
[LISTVIEW_SEQ_INDEX
], vista_plus_msgs
);
1251 count
= get_msg_count(sequences
, LISTVIEW_SEQ_INDEX
, LVM_SETVIEW
);
1252 ok(count
== 1, "LVM_SETVIEW sent %d times.\n", count
);
1253 count
= get_msg_count(sequences
, LISTVIEW_SEQ_INDEX
, LVM_SETEXTENDEDLISTVIEWSTYLE
);
1254 ok(count
== 2, "LVM_SETEXTENDEDLISTVIEWSTYLE sent %d times.\n", count
);
1255 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1259 hr
= IFolderView_SetCurrentViewMode(fview
, 8);
1260 ok(hr
== S_OK
|| broken(hr
== E_INVALIDARG
/* Vista */), "got 0x%08x\n", hr
);
1265 verify_msgs_in(sequences
[LISTVIEW_SEQ_INDEX
], vista_plus_msgs
);
1269 count
= get_msg_count(sequences
, LISTVIEW_SEQ_INDEX
, LVM_SETVIEW
);
1270 ok(count
== 1, "LVM_SETVIEW sent %d times.\n", count
);
1271 count
= get_msg_count(sequences
, LISTVIEW_SEQ_INDEX
, LVM_SETEXTENDEDLISTVIEWSTYLE
);
1272 ok(count
== 2, "LVM_SETEXTENDEDLISTVIEWSTYLE sent %d times.\n", count
);
1273 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1277 hr
= IFolderView_GetCurrentViewMode(fview
, &viewmode
);
1278 ok(hr
== S_OK
, "Failed to get current viewmode.\n");
1279 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, empty_seq
,
1280 "IFolderView::GetCurrentViewMode", FALSE
);
1283 IFolderView_Release(fview
);
1287 skip("No IFolderView for the desktop folder.\n");
1290 IShellBrowser_Release(browser
);
1291 IShellView_DestroyViewWindow(sview
);
1292 IShellView_Release(sview
);
1293 IShellFolder_Release(desktop
);
1296 static void test_IOleCommandTarget(void)
1298 IShellFolder
*psf_desktop
;
1300 IOleCommandTarget
*poct
;
1303 hr
= SHGetDesktopFolder(&psf_desktop
);
1304 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
1306 hr
= IShellFolder_CreateViewObject(psf_desktop
, NULL
, &IID_IShellView
, (void**)&psv
);
1307 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
1310 hr
= IShellView_QueryInterface(psv
, &IID_IOleCommandTarget
, (void**)&poct
);
1311 ok(hr
== S_OK
|| broken(hr
== E_NOINTERFACE
) /* Win95/NT4 */, "Got 0x%08x\n", hr
);
1316 hr
= IOleCommandTarget_QueryStatus(poct
, NULL
, 0, NULL
, NULL
);
1317 ok(hr
== E_INVALIDARG
, "Got 0x%08x\n", hr
);
1320 hr
= IOleCommandTarget_QueryStatus(poct
, NULL
, 0, &oc
, NULL
);
1321 ok(hr
== OLECMDERR_E_UNKNOWNGROUP
, "Got 0x%08x\n", hr
);
1324 hr
= IOleCommandTarget_QueryStatus(poct
, NULL
, 1, &oc
, NULL
);
1325 ok(hr
== OLECMDERR_E_UNKNOWNGROUP
, "Got 0x%08x\n", hr
);
1327 hr
= IOleCommandTarget_Exec(poct
, NULL
, 0, 0, NULL
, NULL
);
1328 ok(hr
== OLECMDERR_E_UNKNOWNGROUP
, "Got 0x%08x\n", hr
);
1330 IOleCommandTarget_Release(poct
);
1333 IShellView_Release(psv
);
1336 IShellFolder_Release(psf_desktop
);
1339 static void test_SHCreateShellFolderView(void)
1341 IShellFolder
*desktop
;
1348 hr
= SHGetDesktopFolder(&desktop
);
1349 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
1354 SHCreateShellFolderView(NULL
, NULL
);
1357 psv
= (void *)0xdeadbeef;
1358 hr
= SHCreateShellFolderView(NULL
, &psv
);
1359 ok(hr
== E_INVALIDARG
, "Got 0x%08x\n", hr
);
1360 ok(psv
== NULL
, "psv = %p\n", psv
);
1362 memset(&sfvc
, 0, sizeof(sfvc
));
1363 psv
= (void *)0xdeadbeef;
1364 hr
= SHCreateShellFolderView(&sfvc
, &psv
);
1365 ok(hr
== E_INVALIDARG
, "Got 0x%08x\n", hr
);
1366 ok(psv
== NULL
, "psv = %p\n", psv
);
1368 memset(&sfvc
, 0, sizeof(sfvc
));
1369 sfvc
.cbSize
= sizeof(sfvc
) - 1;
1370 psv
= (void *)0xdeadbeef;
1371 hr
= SHCreateShellFolderView(&sfvc
, &psv
);
1372 ok(hr
== E_INVALIDARG
, "Got 0x%08x\n", hr
);
1373 ok(psv
== NULL
, "psv = %p\n", psv
);
1375 memset(&sfvc
, 0, sizeof(sfvc
));
1376 sfvc
.cbSize
= sizeof(sfvc
) + 1;
1377 psv
= (void *)0xdeadbeef;
1378 hr
= SHCreateShellFolderView(&sfvc
, &psv
);
1379 ok(hr
== E_INVALIDARG
, "Got 0x%08x\n", hr
);
1380 ok(psv
== NULL
, "psv = %p\n", psv
);
1384 /* Crashes on NULL 'pshf' on XP/2k3 */
1385 memset(&sfvc
, 0, sizeof(sfvc
));
1386 sfvc
.cbSize
= sizeof(sfvc
);
1387 psv
= (void *)0xdeadbeef;
1388 hr
= SHCreateShellFolderView(&sfvc
, &psv
);
1389 ok(hr
== E_UNEXPECTED
, "Got 0x%08x\n", hr
);
1390 ok(psv
== NULL
, "psv = %p\n", psv
);
1392 memset(&sfvc
, 0, sizeof(sfvc
));
1393 sfvc
.cbSize
= sizeof(sfvc
) - 1;
1394 sfvc
.pshf
= desktop
;
1395 psv
= (void *)0xdeadbeef;
1396 hr
= SHCreateShellFolderView(&sfvc
, &psv
);
1397 ok(hr
== E_INVALIDARG
, "Got 0x%08x\n", hr
);
1398 ok(psv
== NULL
, "psv = %p\n", psv
);
1400 memset(&sfvc
, 0, sizeof(sfvc
));
1401 sfvc
.cbSize
= sizeof(sfvc
);
1402 sfvc
.pshf
= desktop
;
1404 hr
= SHCreateShellFolderView(&sfvc
, &psv
);
1405 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
1406 ok(psv
!= NULL
, "psv = %p\n", psv
);
1408 hr
= IShellView_QueryInterface(psv
, &IID_CDefView
, (void **)&unk
);
1409 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
1410 ok(unk
== (IUnknown
*)psv
, "got %p\n", unk
);
1411 IUnknown_Release(unk
);
1413 refCount
= IShellView_Release(psv
);
1414 ok(refCount
== 0, "refCount = %u\n", refCount
);
1416 IShellFolder_Release(desktop
);
1419 static void test_SHCreateShellFolderViewEx(void)
1421 IShellFolder
*desktop
;
1428 hr
= SHGetDesktopFolder(&desktop
);
1429 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
1434 SHCreateShellFolderViewEx(NULL
, NULL
);
1435 SHCreateShellFolderViewEx(NULL
, &psv
);
1436 SHCreateShellFolderViewEx(&csfv
, NULL
);
1439 memset(&csfv
, 0, sizeof(csfv
));
1440 csfv
.pshf
= desktop
;
1442 hr
= SHCreateShellFolderViewEx(&csfv
, &psv
);
1443 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
1444 ok(psv
!= NULL
, "psv = %p\n", psv
);
1446 hr
= IShellView_QueryInterface(psv
, &IID_CDefView
, (void **)&unk
);
1447 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
1448 ok(unk
== (IUnknown
*)psv
, "got %p\n", unk
);
1449 IUnknown_Release(unk
);
1451 refCount
= IShellView_Release(psv
);
1452 ok(refCount
== 0, "refCount = %u\n", refCount
);
1456 /* Crashes on null shellfolder, on XP/2k3 */
1457 memset(&csfv
, 0, sizeof(csfv
));
1459 psv
= (void *)0xdeadbeef;
1460 hr
= SHCreateShellFolderViewEx(&csfv
, &psv
);
1461 ok(hr
== E_UNEXPECTED
, "Got 0x%08x\n", hr
);
1462 ok(psv
== NULL
, "psv = %p\n", psv
);
1464 memset(&csfv
, 0, sizeof(csfv
));
1465 csfv
.cbSize
= sizeof(csfv
);
1466 csfv
.pshf
= desktop
;
1468 hr
= SHCreateShellFolderViewEx(&csfv
, &psv
);
1469 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
1470 ok(psv
!= NULL
, "psv = %p\n", psv
);
1473 refCount
= IShellView_Release(psv
);
1474 ok(refCount
== 0, "refCount = %u\n", refCount
);
1477 IShellFolder_Release(desktop
);
1480 static void test_newmenu(void)
1482 IUnknown
*unk
, *unk2
;
1485 hr
= CoCreateInstance(&CLSID_NewMenu
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IUnknown
, (void **)&unk
);
1486 ok(hr
== S_OK
, "Failed to create NewMenu object, hr %#x.\n", hr
);
1489 skip("NewMenu is not supported.\n");
1493 hr
= IUnknown_QueryInterface(unk
, &IID_IShellExtInit
, (void **)&unk2
);
1494 ok(hr
== S_OK
, "Failed to get IShellExtInit, hr %#x.\n", hr
);
1495 IUnknown_Release(unk2
);
1497 hr
= IUnknown_QueryInterface(unk
, &IID_IContextMenu
, (void **)&unk2
);
1498 ok(hr
== S_OK
, "Failed to get IContextMenu, hr %#x.\n", hr
);
1499 IUnknown_Release(unk2
);
1501 hr
= IUnknown_QueryInterface(unk
, &IID_IContextMenu2
, (void **)&unk2
);
1502 ok(hr
== S_OK
, "Failed to get IContextMenu2, hr %#x.\n", hr
);
1503 IUnknown_Release(unk2
);
1505 hr
= IUnknown_QueryInterface(unk
, &IID_IContextMenu3
, (void **)&unk2
);
1506 ok(hr
== S_OK
, "Failed to get IContextMenu3, hr %#x.\n", hr
);
1507 IUnknown_Release(unk2
);
1509 hr
= IUnknown_QueryInterface(unk
, &IID_IObjectWithSite
, (void **)&unk2
);
1510 ok(hr
== S_OK
, "Failed to get IObjectWithSite, hr %#x.\n", hr
);
1511 IUnknown_Release(unk2
);
1513 IUnknown_Release(unk
);
1518 OleInitialize(NULL
);
1520 init_msg_sequences(sequences
, NUM_MSG_SEQUENCES
);
1522 test_CreateViewWindow();
1524 test_GetItemObject();
1525 test_IShellFolderView();
1527 test_GetSetCurrentViewMode();
1528 test_IOleCommandTarget();
1529 test_SHCreateShellFolderView();
1530 test_SHCreateShellFolderViewEx();