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;
59 trace("listview: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
61 msg
.message
= message
;
62 msg
.flags
= sent
|wparam
|lparam
;
63 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
66 add_message(sequences
, LISTVIEW_SEQ_INDEX
, &msg
);
69 ret
= CallWindowProcA(oldproc
, hwnd
, message
, wParam
, lParam
);
74 static HWND
subclass_listview(HWND hwnd
)
79 /* listview is a first child */
80 listview
= FindWindowExA(hwnd
, NULL
, WC_LISTVIEWA
, NULL
);
83 /* .. except for some versions of Windows XP, where things
84 are slightly more complicated. */
86 hwnd_tmp
= FindWindowExA(hwnd
, NULL
, "DUIViewWndClassName", NULL
);
87 hwnd_tmp
= FindWindowExA(hwnd_tmp
, NULL
, "DirectUIHWND", NULL
);
88 hwnd_tmp
= FindWindowExA(hwnd_tmp
, NULL
, "CtrlNotifySink", NULL
);
89 listview
= FindWindowExA(hwnd_tmp
, NULL
, WC_LISTVIEWA
, NULL
);
92 oldproc
= (WNDPROC
)SetWindowLongPtrA(listview
, GWLP_WNDPROC
,
93 (LONG_PTR
)listview_subclass_proc
);
94 SetWindowLongPtrA(listview
, GWLP_USERDATA
, (LONG_PTR
)oldproc
);
99 static UINT
get_msg_count(struct msg_sequence
**seq
, int sequence_index
, UINT message
)
101 struct msg_sequence
*msg_seq
= seq
[sequence_index
];
104 for(i
= 0; i
< msg_seq
->count
; i
++)
105 if(msg_seq
->sequence
[i
].message
== message
)
111 /* Checks that every message in the sequence seq is also present in
112 * the UINT array msgs */
113 static void verify_msgs_in_(struct msg_sequence
*seq
, const UINT
*msgs
,
114 const char *file
, int line
)
116 UINT i
, j
, msg
, failcount
= 0;
117 for(i
= 0; i
< seq
->count
; i
++)
120 msg
= seq
->sequence
[i
].message
;
121 for(j
= 0; msgs
[j
] != 0; j
++)
122 if(msgs
[j
] == msg
) found
= TRUE
;
127 trace("Unexpected message %d\n", msg
);
130 ok_(file
, line
) (!failcount
, "%d failures.\n", failcount
);
131 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
134 #define verify_msgs_in(seq, msgs) \
135 verify_msgs_in_(seq, msgs, __FILE__, __LINE__)
137 /* dummy IDataObject implementation */
139 IDataObject IDataObject_iface
;
143 static const IDataObjectVtbl IDataObjectImpl_Vtbl
;
145 static inline IDataObjectImpl
*impl_from_IDataObject(IDataObject
*iface
)
147 return CONTAINING_RECORD(iface
, IDataObjectImpl
, IDataObject_iface
);
150 static IDataObject
* IDataObjectImpl_Construct(void)
152 IDataObjectImpl
*obj
;
154 obj
= HeapAlloc(GetProcessHeap(), 0, sizeof(*obj
));
155 obj
->IDataObject_iface
.lpVtbl
= &IDataObjectImpl_Vtbl
;
158 return &obj
->IDataObject_iface
;
161 static HRESULT WINAPI
IDataObjectImpl_QueryInterface(IDataObject
*iface
, REFIID riid
, void **ppvObj
)
163 IDataObjectImpl
*This
= impl_from_IDataObject(iface
);
165 if (IsEqualIID(riid
, &IID_IUnknown
) ||
166 IsEqualIID(riid
, &IID_IDataObject
))
173 IDataObject_AddRef(iface
);
177 return E_NOINTERFACE
;
180 static ULONG WINAPI
IDataObjectImpl_AddRef(IDataObject
* iface
)
182 IDataObjectImpl
*This
= impl_from_IDataObject(iface
);
183 return InterlockedIncrement(&This
->ref
);
186 static ULONG WINAPI
IDataObjectImpl_Release(IDataObject
* iface
)
188 IDataObjectImpl
*This
= impl_from_IDataObject(iface
);
189 ULONG ref
= InterlockedDecrement(&This
->ref
);
193 HeapFree(GetProcessHeap(), 0, This
);
199 static HRESULT WINAPI
IDataObjectImpl_GetData(IDataObject
*iface
, FORMATETC
*pformat
, STGMEDIUM
*pmedium
)
204 static HRESULT WINAPI
IDataObjectImpl_GetDataHere(IDataObject
*iface
, FORMATETC
*pformat
, STGMEDIUM
*pmedium
)
209 static HRESULT WINAPI
IDataObjectImpl_QueryGetData(IDataObject
*iface
, FORMATETC
*pformat
)
214 static HRESULT WINAPI
IDataObjectImpl_GetCanonicalFormatEtc(
215 IDataObject
*iface
, FORMATETC
*pformatIn
, FORMATETC
*pformatOut
)
220 static HRESULT WINAPI
IDataObjectImpl_SetData(
221 IDataObject
*iface
, FORMATETC
*pformat
, STGMEDIUM
*pmedium
, BOOL release
)
226 static HRESULT WINAPI
IDataObjectImpl_EnumFormatEtc(
227 IDataObject
*iface
, DWORD direction
, IEnumFORMATETC
**ppenumFormatEtc
)
232 static HRESULT WINAPI
IDataObjectImpl_DAdvise(
233 IDataObject
*iface
, FORMATETC
*pformatetc
, DWORD advf
, IAdviseSink
*pSink
, DWORD
*pConnection
)
238 static HRESULT WINAPI
IDataObjectImpl_DUnadvise(IDataObject
*iface
, DWORD connection
)
243 static HRESULT WINAPI
IDataObjectImpl_EnumDAdvise(IDataObject
*iface
, IEnumSTATDATA
**ppenumAdvise
)
248 static const IDataObjectVtbl IDataObjectImpl_Vtbl
=
250 IDataObjectImpl_QueryInterface
,
251 IDataObjectImpl_AddRef
,
252 IDataObjectImpl_Release
,
253 IDataObjectImpl_GetData
,
254 IDataObjectImpl_GetDataHere
,
255 IDataObjectImpl_QueryGetData
,
256 IDataObjectImpl_GetCanonicalFormatEtc
,
257 IDataObjectImpl_SetData
,
258 IDataObjectImpl_EnumFormatEtc
,
259 IDataObjectImpl_DAdvise
,
260 IDataObjectImpl_DUnadvise
,
261 IDataObjectImpl_EnumDAdvise
264 /* dummy IShellBrowser implementation */
266 IShellBrowser IShellBrowser_iface
;
270 static const IShellBrowserVtbl IShellBrowserImpl_Vtbl
;
272 static inline IShellBrowserImpl
*impl_from_IShellBrowser(IShellBrowser
*iface
)
274 return CONTAINING_RECORD(iface
, IShellBrowserImpl
, IShellBrowser_iface
);
277 static IShellBrowser
* IShellBrowserImpl_Construct(void)
279 IShellBrowserImpl
*browser
;
281 browser
= HeapAlloc(GetProcessHeap(), 0, sizeof(*browser
));
282 browser
->IShellBrowser_iface
.lpVtbl
= &IShellBrowserImpl_Vtbl
;
285 return &browser
->IShellBrowser_iface
;
288 static HRESULT WINAPI
IShellBrowserImpl_QueryInterface(IShellBrowser
*iface
,
292 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
296 if(IsEqualIID(riid
, &IID_IUnknown
) ||
297 IsEqualIID(riid
, &IID_IOleWindow
) ||
298 IsEqualIID(riid
, &IID_IShellBrowser
))
305 IShellBrowser_AddRef(iface
);
309 return E_NOINTERFACE
;
312 static ULONG WINAPI
IShellBrowserImpl_AddRef(IShellBrowser
* iface
)
314 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
315 return InterlockedIncrement(&This
->ref
);
318 static ULONG WINAPI
IShellBrowserImpl_Release(IShellBrowser
* iface
)
320 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
321 ULONG ref
= InterlockedDecrement(&This
->ref
);
325 HeapFree(GetProcessHeap(), 0, This
);
331 static HRESULT WINAPI
IShellBrowserImpl_GetWindow(IShellBrowser
*iface
,
334 if (phwnd
) *phwnd
= GetDesktopWindow();
338 static HRESULT WINAPI
IShellBrowserImpl_ContextSensitiveHelp(IShellBrowser
*iface
,
344 static HRESULT WINAPI
IShellBrowserImpl_BrowseObject(IShellBrowser
*iface
,
351 static HRESULT WINAPI
IShellBrowserImpl_EnableModelessSB(IShellBrowser
*iface
,
358 static HRESULT WINAPI
IShellBrowserImpl_GetControlWindow(IShellBrowser
*iface
,
366 static HRESULT WINAPI
IShellBrowserImpl_GetViewStateStream(IShellBrowser
*iface
,
374 static HRESULT WINAPI
IShellBrowserImpl_InsertMenusSB(IShellBrowser
*iface
,
376 LPOLEMENUGROUPWIDTHS lpMenuWidths
)
382 static HRESULT WINAPI
IShellBrowserImpl_OnViewWindowActive(IShellBrowser
*iface
,
389 static HRESULT WINAPI
IShellBrowserImpl_QueryActiveShellView(IShellBrowser
*iface
,
396 static HRESULT WINAPI
IShellBrowserImpl_RemoveMenusSB(IShellBrowser
*iface
,
403 static HRESULT WINAPI
IShellBrowserImpl_SendControlMsg(IShellBrowser
*iface
,
414 static HRESULT WINAPI
IShellBrowserImpl_SetMenuSB(IShellBrowser
*iface
,
416 HOLEMENU holemenuReserved
,
417 HWND hwndActiveObject
)
423 static HRESULT WINAPI
IShellBrowserImpl_SetStatusTextSB(IShellBrowser
*iface
,
424 LPCOLESTR lpszStatusText
)
430 static HRESULT WINAPI
IShellBrowserImpl_SetToolbarItems(IShellBrowser
*iface
,
431 LPTBBUTTON lpButtons
,
439 static HRESULT WINAPI
IShellBrowserImpl_TranslateAcceleratorSB(IShellBrowser
*iface
,
447 static const IShellBrowserVtbl IShellBrowserImpl_Vtbl
=
449 IShellBrowserImpl_QueryInterface
,
450 IShellBrowserImpl_AddRef
,
451 IShellBrowserImpl_Release
,
452 IShellBrowserImpl_GetWindow
,
453 IShellBrowserImpl_ContextSensitiveHelp
,
454 IShellBrowserImpl_InsertMenusSB
,
455 IShellBrowserImpl_SetMenuSB
,
456 IShellBrowserImpl_RemoveMenusSB
,
457 IShellBrowserImpl_SetStatusTextSB
,
458 IShellBrowserImpl_EnableModelessSB
,
459 IShellBrowserImpl_TranslateAcceleratorSB
,
460 IShellBrowserImpl_BrowseObject
,
461 IShellBrowserImpl_GetViewStateStream
,
462 IShellBrowserImpl_GetControlWindow
,
463 IShellBrowserImpl_SendControlMsg
,
464 IShellBrowserImpl_QueryActiveShellView
,
465 IShellBrowserImpl_OnViewWindowActive
,
466 IShellBrowserImpl_SetToolbarItems
469 static const struct message empty_seq
[] = {
473 static const struct message folderview_getspacing_seq
[] = {
474 { LVM_GETITEMSPACING
, wparam
|sent
, FALSE
},
478 static const struct message folderview_getselectionmarked_seq
[] = {
479 { LVM_GETSELECTIONMARK
, sent
},
483 static const struct message folderview_getfocused_seq
[] = {
484 { LVM_GETNEXTITEM
, sent
|wparam
|lparam
|optional
, -1, LVNI_FOCUSED
},
488 static void test_IShellView_CreateViewWindow(void)
490 IShellFolder
*desktop
;
491 FOLDERSETTINGS settings
;
498 hr
= SHGetDesktopFolder(&desktop
);
499 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
501 hr
= IShellFolder_CreateViewObject(desktop
, NULL
, &IID_IShellView
, (void**)&view
);
502 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
506 /* crashes on native */
507 IShellView_CreateViewWindow(view
, NULL
, &settings
, NULL
, NULL
, NULL
);
510 settings
.ViewMode
= FVM_ICON
;
512 hwnd_view
= (HWND
)0xdeadbeef;
513 hr
= IShellView_CreateViewWindow(view
, NULL
, &settings
, NULL
, NULL
, &hwnd_view
);
514 ok(hr
== E_UNEXPECTED
, "got (0x%08x)\n", hr
);
515 ok(hwnd_view
== 0, "got %p\n", hwnd_view
);
517 hwnd_view
= (HWND
)0xdeadbeef;
518 hr
= IShellView_CreateViewWindow(view
, NULL
, &settings
, NULL
, &r
, &hwnd_view
);
519 ok(hr
== E_UNEXPECTED
, "got (0x%08x)\n", hr
);
520 ok(hwnd_view
== 0, "got %p\n", hwnd_view
);
522 /* ::DragLeave without drag operation */
523 hr
= IShellView_QueryInterface(view
, &IID_IDropTarget
, (void**)&dt
);
524 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
525 hr
= IDropTarget_DragLeave(dt
);
526 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
527 IDropTarget_Release(dt
);
529 IShellView_Release(view
);
530 IShellFolder_Release(desktop
);
533 static void test_IFolderView(void)
535 IShellFolder
*desktop
, *folder
;
536 FOLDERSETTINGS settings
;
538 IShellBrowser
*browser
;
540 HWND hwnd_view
, hwnd_list
;
548 hr
= SHGetDesktopFolder(&desktop
);
549 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
551 hr
= IShellFolder_CreateViewObject(desktop
, NULL
, &IID_IShellView
, (void**)&view
);
552 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
554 hr
= IShellView_QueryInterface(view
, &IID_IFolderView
, (void**)&fv
);
557 win_skip("IFolderView not supported by desktop folder\n");
558 IShellView_Release(view
);
559 IShellFolder_Release(desktop
);
563 /* call methods before window creation */
564 hr
= IFolderView_GetSpacing(fv
, NULL
);
565 ok(hr
== S_FALSE
|| broken(hr
== S_OK
) /* win7 */, "got (0x%08x)\n", hr
);
567 pidl
= (void*)0xdeadbeef;
568 hr
= IFolderView_Item(fv
, 0, &pidl
);
569 ok(hr
== E_INVALIDARG
|| broken(hr
== E_FAIL
) /* < Vista */, "got (0x%08x)\n", hr
);
570 ok(pidl
== 0 || broken(pidl
== (void*)0xdeadbeef) /* < Vista */, "got %p\n", pidl
);
574 /* crashes on Vista and Win2k8 - List not created yet case */
575 IFolderView_GetSpacing(fv
, &pt
);
578 IFolderView_GetSelectionMarkedItem(fv
, NULL
);
579 IFolderView_GetFocusedItem(fv
, NULL
);
581 /* crashes on Vista+ */
582 IFolderView_Item(fv
, 0, NULL
);
585 browser
= IShellBrowserImpl_Construct();
587 settings
.ViewMode
= FVM_ICON
;
589 hwnd_view
= (HWND
)0xdeadbeef;
591 r
.right
= r
.bottom
= 100;
592 hr
= IShellView_CreateViewWindow(view
, NULL
, &settings
, browser
, &r
, &hwnd_view
);
593 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
594 ok(IsWindow(hwnd_view
), "got %p\n", hwnd_view
);
596 hwnd_list
= subclass_listview(hwnd_view
);
599 win_skip("Failed to subclass ListView control\n");
600 IShellBrowser_Release(browser
);
601 IFolderView_Release(fv
);
602 IShellView_Release(view
);
603 IShellFolder_Release(desktop
);
607 /* IFolderView::GetSpacing */
608 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
609 hr
= IFolderView_GetSpacing(fv
, NULL
);
610 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
611 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, empty_seq
, "IFolderView::GetSpacing, empty", FALSE
);
613 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
614 hr
= IFolderView_GetSpacing(fv
, &pt
);
615 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
616 /* fails with empty sequence on win7 for unknown reason */
617 if (sequences
[LISTVIEW_SEQ_INDEX
]->count
)
619 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, folderview_getspacing_seq
, "IFolderView::GetSpacing", FALSE
);
620 ok(pt
.x
> 0, "got %d\n", pt
.x
);
621 ok(pt
.y
> 0, "got %d\n", pt
.y
);
622 ret
= SendMessageA(hwnd_list
, LVM_GETITEMSPACING
, 0, 0);
623 ok(pt
.x
== LOWORD(ret
) && pt
.y
== HIWORD(ret
), "got (%d, %d)\n", LOWORD(ret
), HIWORD(ret
));
626 /* IFolderView::ItemCount */
630 IFolderView_ItemCount(fv
, SVGIO_ALLVIEW
, NULL
);
633 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
634 IFolderView_ItemCount(fv
, SVGIO_ALLVIEW
, &count
);
636 /* IFolderView::GetSelectionMarkedItem */
640 IFolderView_GetSelectionMarkedItem(fv
, NULL
);
643 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
644 hr
= IFolderView_GetSelectionMarkedItem(fv
, &ret
);
646 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
648 ok(hr
== S_FALSE
, "got (0x%08x)\n", hr
);
649 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, folderview_getselectionmarked_seq
,
650 "IFolderView::GetSelectionMarkedItem", FALSE
);
652 /* IFolderView::GetFocusedItem */
653 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
654 hr
= IFolderView_GetFocusedItem(fv
, &ret
);
656 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
658 ok(hr
== S_FALSE
, "got (0x%08x)\n", hr
);
659 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, folderview_getfocused_seq
,
660 "IFolderView::GetFocusedItem", FALSE
);
662 /* IFolderView::GetFolder, just return pointer */
666 IFolderView_GetFolder(fv
, NULL
, (void**)&folder
);
667 IFolderView_GetFolder(fv
, NULL
, NULL
);
670 hr
= IFolderView_GetFolder(fv
, &IID_IShellFolder
, NULL
);
671 ok(hr
== E_POINTER
, "got (0x%08x)\n", hr
);
673 ref1
= IShellFolder_AddRef(desktop
);
674 IShellFolder_Release(desktop
);
675 hr
= IFolderView_GetFolder(fv
, &IID_IShellFolder
, (void**)&folder
);
676 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
677 ref2
= IShellFolder_AddRef(desktop
);
678 IShellFolder_Release(desktop
);
679 ok(ref1
== ref2
|| ref1
+ 1 == ref2
, /* >= vista */
680 "expected same refcount, got %d\n", ref2
);
681 ok(desktop
== folder
, "\n");
683 IShellBrowser_Release(browser
);
684 IFolderView_Release(fv
);
685 IShellView_Release(view
);
686 IShellFolder_Release(desktop
);
689 static void test_GetItemObject(void)
691 IShellFolder
*desktop
;
696 hr
= SHGetDesktopFolder(&desktop
);
697 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
699 hr
= IShellFolder_CreateViewObject(desktop
, NULL
, &IID_IShellView
, (void**)&view
);
700 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
702 /* from documentation three interfaces are supported for SVGIO_BACKGROUND:
703 IContextMenu, IDispatch, IPersistHistory */
704 hr
= IShellView_GetItemObject(view
, SVGIO_BACKGROUND
, &IID_IContextMenu
, (void**)&unk
);
705 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
706 IUnknown_Release(unk
);
709 hr
= IShellView_GetItemObject(view
, SVGIO_BACKGROUND
, &IID_IDispatch
, (void**)&unk
);
710 todo_wine
ok(hr
== S_OK
|| broken(hr
== E_NOTIMPL
) /* NT4 */, "got (0x%08x)\n", hr
);
711 if (unk
) IUnknown_Release(unk
);
714 hr
= IShellView_GetItemObject(view
, SVGIO_BACKGROUND
, &IID_IPersistHistory
, (void**)&unk
);
715 todo_wine
ok(hr
== S_OK
|| broken(hr
== E_NOTIMPL
) /* W9x, NT4 */, "got (0x%08x)\n", hr
);
716 if (unk
) IUnknown_Release(unk
);
718 /* example of unsupported interface, base for IPersistHistory */
719 hr
= IShellView_GetItemObject(view
, SVGIO_BACKGROUND
, &IID_IPersist
, (void**)&unk
);
720 ok(hr
== E_NOINTERFACE
|| broken(hr
== E_NOTIMPL
) /* W2K */, "got (0x%08x)\n", hr
);
722 IShellView_Release(view
);
723 IShellFolder_Release(desktop
);
726 static void test_IShellFolderView(void)
728 IShellFolderView
*folderview
;
729 IShellFolder
*desktop
;
735 hr
= SHGetDesktopFolder(&desktop
);
736 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
738 hr
= IShellFolder_CreateViewObject(desktop
, NULL
, &IID_IShellView
, (void**)&view
);
739 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
741 hr
= IShellView_QueryInterface(view
, &IID_IShellFolderView
, (void**)&folderview
);
744 win_skip("IShellView doesn't provide IShellFolderView on this platform\n");
745 IShellView_Release(view
);
746 IShellFolder_Release(desktop
);
751 obj
= IDataObjectImpl_Construct();
752 hr
= IShellFolderView_MoveIcons(folderview
, obj
);
753 ok(hr
== E_NOTIMPL
|| broken(hr
== S_OK
) /* W98 */, "got (0x%08x)\n", hr
);
754 IDataObject_Release(obj
);
756 /* ::SetRedraw without list created */
757 hr
= IShellFolderView_SetRedraw(folderview
, TRUE
);
758 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
761 hr
= IShellFolderView_QuerySupport(folderview
, NULL
);
762 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
764 hr
= IShellFolderView_QuerySupport(folderview
, &i
);
765 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
766 ok(i
== 0xdeadbeef, "got %d\n", i
);
770 hr
= IShellFolderView_RemoveObject(folderview
, NULL
, &i
);
771 ok(hr
== S_OK
|| hr
== E_FAIL
, "got (0x%08x)\n", hr
);
772 if (hr
== S_OK
) ok(i
== 0 || broken(i
== 0xdeadbeef) /* Vista, 2k8 */,
775 IShellFolderView_Release(folderview
);
777 IShellView_Release(view
);
778 IShellFolder_Release(desktop
);
781 static void test_IOleWindow(void)
783 IShellFolder
*desktop
;
787 hr
= SHGetDesktopFolder(&desktop
);
788 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
790 hr
= IShellFolder_CreateViewObject(desktop
, NULL
, &IID_IShellView
, (void**)&view
);
791 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
793 /* IShellView::ContextSensitiveHelp */
794 hr
= IShellView_ContextSensitiveHelp(view
, TRUE
);
795 ok(hr
== E_NOTIMPL
, "got (0x%08x)\n", hr
);
796 hr
= IShellView_ContextSensitiveHelp(view
, FALSE
);
797 ok(hr
== E_NOTIMPL
, "got (0x%08x)\n", hr
);
799 IShellView_Release(view
);
800 IShellFolder_Release(desktop
);
803 static const struct message folderview_setcurrentviewmode1_2_prevista
[] = {
804 { LVM_SETVIEW
, sent
|wparam
, LV_VIEW_ICON
},
805 { LVM_SETIMAGELIST
, sent
|wparam
, 0},
806 { LVM_SETIMAGELIST
, sent
|wparam
, 1},
808 { LVM_SETBKIMAGEW
, sent
|optional
}, /* w2k3 */
809 { LVM_GETBKCOLOR
, sent
|optional
}, /* w2k3 */
810 { LVM_GETTEXTBKCOLOR
, sent
|optional
}, /* w2k3 */
811 { LVM_GETTEXTCOLOR
, sent
|optional
}, /* w2k3 */
812 { LVM_SETEXTENDEDLISTVIEWSTYLE
, sent
|optional
|wparam
, 0xc8}, /* w2k3 */
813 { LVM_ARRANGE
, sent
},
814 { LVM_ARRANGE
, sent
|optional
}, /* WinXP */
818 static const struct message folderview_setcurrentviewmode3_prevista
[] = {
819 { LVM_SETVIEW
, sent
|wparam
, LV_VIEW_LIST
},
820 { LVM_SETIMAGELIST
, sent
|wparam
, 0},
821 { LVM_SETIMAGELIST
, sent
|wparam
, 1},
823 { LVM_SETBKIMAGEW
, sent
|optional
}, /* w2k3 */
824 { LVM_GETBKCOLOR
, sent
|optional
}, /* w2k3 */
825 { LVM_GETTEXTBKCOLOR
, sent
|optional
}, /* w2k3 */
826 { LVM_GETTEXTCOLOR
, sent
|optional
}, /* w2k3 */
827 { LVM_SETEXTENDEDLISTVIEWSTYLE
, sent
|optional
|wparam
, 0xc8}, /* w2k3 */
831 static const struct message folderview_setcurrentviewmode4_prevista
[] = {
832 { LVM_GETHEADER
, sent
},
833 { LVM_GETITEMCOUNT
, sent
|optional
},
834 { LVM_SETSELECTEDCOLUMN
, sent
},
839 { LVM_SETVIEW
, sent
|wparam
, LV_VIEW_DETAILS
},
840 { LVM_SETIMAGELIST
, sent
|wparam
, 0},
841 { LVM_SETIMAGELIST
, sent
|wparam
, 1},
843 { LVM_SETBKIMAGEW
, sent
|optional
}, /* w2k3 */
844 { LVM_GETBKCOLOR
, sent
|optional
}, /* w2k3 */
845 { LVM_GETTEXTBKCOLOR
, sent
|optional
}, /* w2k3 */
846 { LVM_GETTEXTCOLOR
, sent
|optional
}, /* w2k3 */
847 { LVM_SETEXTENDEDLISTVIEWSTYLE
, sent
|optional
|wparam
, 0xc8}, /* w2k3 */
851 /* XP, SetCurrentViewMode(5)
852 108e - LVM_SETVIEW (LV_VIEW_ICON);
853 1036 - LVM_SETEXTEDEDLISTVIEWSTYLE (0x8000, 0)
854 100c/104c repeated X times
855 1003 - LVM_SETIMAGELIST
856 1035 - LVM_SETICONSPACING
857 1004 - LVM_GETITEMCOUNT
863 /* XP, SetCurrentViewMode(6)
864 1036 - LVM_SETEXTENDEDLISTVIEWSTYLE (0x8000, 0)
865 1035 - LVM_SETICONSPACING
866 1003 - LVM_SETIMAGELIST
867 1003 - LVM_SETIMAGELIST
868 100c/104c repeated X times
869 10a2 - LVM_SETTILEVIEWINFO
870 108e - LVM_SETVIEW (LV_VIEW_TILE)
871 1003 - LVM_SETIMAGELIST
877 /* XP, SetCurrentViewMode (7)
878 10a2 - LVM_SETTILEVIEWINFO
879 108e - LVM_SETVIEW (LV_VIEW_ICON)
880 1004/10a4 (LVM_GETITEMCOUNT/LVM_SETTILEINFO) X times
884 LVM_SETEXTENDEDLISTVIEWSTYLE (0x40000, 0x40000)
886 LVM_SETEXTENDEDLISTVIEWSTYLE (0x8000, 0x8000)
889 static void test_GetSetCurrentViewMode(void)
891 IShellFolder
*desktop
;
894 IShellBrowser
*browser
;
898 RECT rc
= {0, 0, 10, 10};
901 static const int winxp_res
[11] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
902 static const int win2k3_res
[11] = {0, 1, 2, 3, 4, 5, 6, 5, 8, 0, 0};
903 static const int vista_res
[11] = {0, 1, 5, 3, 4, 5, 6, 7, 7, 0, 0};
904 static const int win7_res
[11] = {1, 1, 1, 3, 4, 1, 6, 1, 8, 8, 8};
906 hr
= SHGetDesktopFolder(&desktop
);
907 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
909 hr
= IShellFolder_CreateViewObject(desktop
, NULL
, &IID_IShellView
, (void**)&sview
);
910 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
914 browser
= IShellBrowserImpl_Construct();
915 hr
= IShellView_CreateViewWindow(sview
, NULL
, &fs
, browser
, &rc
, &hwnd
);
916 ok(hr
== S_OK
|| broken(hr
== S_FALSE
/*Win2k*/ ), "got (0x%08x)\n", hr
);
918 hr
= IShellView_QueryInterface(sview
, &IID_IFolderView
, (void**)&fview
);
919 ok(hr
== S_OK
|| broken(hr
== E_NOINTERFACE
), "got (0x%08x)\n", hr
);
927 /* Crashes under Win7/WinXP */
928 IFolderView_GetCurrentViewMode(fview
, NULL
);
931 hr
= IFolderView_GetCurrentViewMode(fview
, &viewmode
);
932 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
933 ok(viewmode
== 1, "ViewMode was %d\n", viewmode
);
935 hr
= IFolderView_SetCurrentViewMode(fview
, FVM_AUTO
);
936 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
938 hr
= IFolderView_SetCurrentViewMode(fview
, 0);
939 ok(hr
== E_INVALIDARG
|| broken(hr
== S_OK
),
940 "got (0x%08x)\n", hr
);
942 hr
= IFolderView_GetCurrentViewMode(fview
, &viewmode
);
943 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
945 for(i
= 1; i
< 9; i
++)
947 hr
= IFolderView_SetCurrentViewMode(fview
, i
);
948 ok(hr
== S_OK
|| (i
== 8 && hr
== E_INVALIDARG
/*Vista*/),
949 "(%d) got (0x%08x)\n", i
, hr
);
951 hr
= IFolderView_GetCurrentViewMode(fview
, &viewmode
);
952 ok(hr
== S_OK
, "(%d) got (0x%08x)\n", i
, hr
);
954 /* Wine currently behaves like winxp here. */
955 ok((viewmode
== win7_res
[i
]) || (viewmode
== vista_res
[i
]) ||
956 (viewmode
== win2k3_res
[i
]) || (viewmode
== winxp_res
[i
]),
957 "(%d) got %d\n",i
, viewmode
);
960 hr
= IFolderView_SetCurrentViewMode(fview
, 9);
961 ok(hr
== E_INVALIDARG
|| broken(hr
== S_OK
),
962 "got (0x%08x)\n", hr
);
965 hwnd_lv
= subclass_listview(hwnd
);
966 ok(hwnd_lv
!= NULL
, "Failed to subclass listview\n");
969 /* Vista seems to set the viewmode by other means than
970 sending messages. At least no related messages are
971 captured by subclassing.
973 BOOL vista_plus
= FALSE
;
974 static const UINT vista_plus_msgs
[] = {
975 WM_SETREDRAW
, WM_NOTIFY
, WM_NOTIFYFORMAT
, WM_QUERYUISTATE
,
976 WM_MENUCHAR
, WM_WINDOWPOSCHANGING
, WM_NCCALCSIZE
, WM_WINDOWPOSCHANGED
,
977 WM_PARENTNOTIFY
, LVM_GETHEADER
, 0 };
979 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
980 hr
= IFolderView_SetCurrentViewMode(fview
, 1);
981 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
983 /* WM_SETREDRAW is not sent in versions before Vista. */
984 vista_plus
= get_msg_count(sequences
, LISTVIEW_SEQ_INDEX
, WM_SETREDRAW
);
986 verify_msgs_in(sequences
[LISTVIEW_SEQ_INDEX
], vista_plus_msgs
);
988 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, folderview_setcurrentviewmode1_2_prevista
,
989 "IFolderView::SetCurrentViewMode(1)", TRUE
);
991 hr
= IFolderView_SetCurrentViewMode(fview
, 2);
992 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
994 verify_msgs_in(sequences
[LISTVIEW_SEQ_INDEX
], vista_plus_msgs
);
996 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, folderview_setcurrentviewmode1_2_prevista
,
997 "IFolderView::SetCurrentViewMode(2)", TRUE
);
999 hr
= IFolderView_SetCurrentViewMode(fview
, 3);
1000 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1002 verify_msgs_in(sequences
[LISTVIEW_SEQ_INDEX
], vista_plus_msgs
);
1004 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, folderview_setcurrentviewmode3_prevista
,
1005 "IFolderView::SetCurrentViewMode(3)", TRUE
);
1007 hr
= IFolderView_SetCurrentViewMode(fview
, 4);
1008 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1010 verify_msgs_in(sequences
[LISTVIEW_SEQ_INDEX
], vista_plus_msgs
);
1012 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, folderview_setcurrentviewmode4_prevista
,
1013 "IFolderView::SetCurrentViewMode(4)", TRUE
);
1015 hr
= IFolderView_SetCurrentViewMode(fview
, 5);
1016 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1021 verify_msgs_in(sequences
[LISTVIEW_SEQ_INDEX
], vista_plus_msgs
);
1025 count
= get_msg_count(sequences
, LISTVIEW_SEQ_INDEX
, LVM_SETVIEW
);
1026 ok(count
== 1, "LVM_SETVIEW sent %d times.\n", count
);
1027 count
= get_msg_count(sequences
, LISTVIEW_SEQ_INDEX
, LVM_SETEXTENDEDLISTVIEWSTYLE
);
1028 ok(count
== 1 || count
== 2, "LVM_SETEXTENDEDLISTVIEWSTYLE sent %d times.\n", count
);
1029 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1033 hr
= IFolderView_SetCurrentViewMode(fview
, 6);
1034 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1039 verify_msgs_in(sequences
[LISTVIEW_SEQ_INDEX
], vista_plus_msgs
);
1043 count
= get_msg_count(sequences
, LISTVIEW_SEQ_INDEX
, LVM_SETVIEW
);
1044 ok(count
== 1, "LVM_SETVIEW sent %d times.\n", count
);
1045 count
= get_msg_count(sequences
, LISTVIEW_SEQ_INDEX
, LVM_SETEXTENDEDLISTVIEWSTYLE
);
1046 ok(count
== 1 || count
== 2, "LVM_SETEXTENDEDLISTVIEWSTYLE sent %d times.\n", count
);
1047 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1051 hr
= IFolderView_SetCurrentViewMode(fview
, 7);
1052 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1057 verify_msgs_in(sequences
[LISTVIEW_SEQ_INDEX
], vista_plus_msgs
);
1061 count
= get_msg_count(sequences
, LISTVIEW_SEQ_INDEX
, LVM_SETVIEW
);
1062 ok(count
== 1, "LVM_SETVIEW sent %d times.\n", count
);
1063 count
= get_msg_count(sequences
, LISTVIEW_SEQ_INDEX
, LVM_SETEXTENDEDLISTVIEWSTYLE
);
1064 ok(count
== 2, "LVM_SETEXTENDEDLISTVIEWSTYLE sent %d times.\n", count
);
1065 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1069 hr
= IFolderView_SetCurrentViewMode(fview
, 8);
1070 ok(hr
== S_OK
|| broken(hr
== E_INVALIDARG
/* Vista */), "got 0x%08x\n", hr
);
1075 verify_msgs_in(sequences
[LISTVIEW_SEQ_INDEX
], vista_plus_msgs
);
1079 count
= get_msg_count(sequences
, LISTVIEW_SEQ_INDEX
, LVM_SETVIEW
);
1080 ok(count
== 1, "LVM_SETVIEW sent %d times.\n", count
);
1081 count
= get_msg_count(sequences
, LISTVIEW_SEQ_INDEX
, LVM_SETEXTENDEDLISTVIEWSTYLE
);
1082 ok(count
== 2, "LVM_SETEXTENDEDLISTVIEWSTYLE sent %d times.\n", count
);
1083 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1087 hr
= IFolderView_GetCurrentViewMode(fview
, &viewmode
);
1088 ok(hr
== S_OK
, "Failed to get current viewmode.\n");
1089 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, empty_seq
,
1090 "IFolderView::GetCurrentViewMode", FALSE
);
1093 IFolderView_Release(fview
);
1097 skip("No IFolderView for the desktop folder.\n");
1100 IShellBrowser_Release(browser
);
1101 IShellView_DestroyViewWindow(sview
);
1102 IShellView_Release(sview
);
1103 IShellFolder_Release(desktop
);
1106 static void test_IOleCommandTarget(void)
1108 IShellFolder
*psf_desktop
;
1110 IOleCommandTarget
*poct
;
1113 hr
= SHGetDesktopFolder(&psf_desktop
);
1114 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
1116 hr
= IShellFolder_CreateViewObject(psf_desktop
, NULL
, &IID_IShellView
, (void**)&psv
);
1117 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
1120 hr
= IShellView_QueryInterface(psv
, &IID_IOleCommandTarget
, (void**)&poct
);
1121 ok(hr
== S_OK
|| broken(hr
== E_NOINTERFACE
) /* Win95/NT4 */, "Got 0x%08x\n", hr
);
1126 hr
= IOleCommandTarget_QueryStatus(poct
, NULL
, 0, NULL
, NULL
);
1127 ok(hr
== E_INVALIDARG
, "Got 0x%08x\n", hr
);
1130 hr
= IOleCommandTarget_QueryStatus(poct
, NULL
, 0, &oc
, NULL
);
1131 ok(hr
== OLECMDERR_E_UNKNOWNGROUP
, "Got 0x%08x\n", hr
);
1134 hr
= IOleCommandTarget_QueryStatus(poct
, NULL
, 1, &oc
, NULL
);
1135 ok(hr
== OLECMDERR_E_UNKNOWNGROUP
, "Got 0x%08x\n", hr
);
1137 hr
= IOleCommandTarget_Exec(poct
, NULL
, 0, 0, NULL
, NULL
);
1138 ok(hr
== OLECMDERR_E_UNKNOWNGROUP
, "Got 0x%08x\n", hr
);
1140 IOleCommandTarget_Release(poct
);
1143 IShellView_Release(psv
);
1146 IShellFolder_Release(psf_desktop
);
1151 OleInitialize(NULL
);
1153 init_msg_sequences(sequences
, NUM_MSG_SEQUENCES
);
1155 test_IShellView_CreateViewWindow();
1157 test_GetItemObject();
1158 test_IShellFolderView();
1160 test_GetSetCurrentViewMode();
1161 test_IOleCommandTarget();