2 * Unit tests for the Explorer Browser control
4 * Copyright 2010 David Hedberg
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
29 #include "wine/test.h"
34 /**********************************************************************
35 * Some IIDs for test_SetSite.
37 DEFINE_GUID(IID_IBrowserSettings
, 0xDD1E21CC, 0xE2C7, 0x402C, 0xBF,0x05, 0x10,0x32,0x8D,0x3F,0x6B,0xAD);
38 DEFINE_GUID(IID_IShellBrowserService
, 0xDFBC7E30, 0xF9E5, 0x455F, 0x88,0xF8, 0xFA,0x98,0xC1,0xE4,0x94,0xCA);
39 DEFINE_GUID(IID_IShellTaskScheduler
, 0x6CCB7BE0, 0x6807, 0x11D0, 0xB8,0x10, 0x00,0xC0,0x4F,0xD7,0x06,0xEC);
40 DEFINE_GUID(IID_IBrowserWithActivationNotification
,
41 0x6DB89131, 0x7B4C, 0x4E1C, 0x8B,0x01, 0x5D,0x31,0x2C,0x9C,0x73,0x88);
42 DEFINE_GUID(IID_ILayoutModifier
, 0x90B4135A, 0x95BA, 0x46EA, 0x8C,0xAA, 0xE0,0x5B,0x45,0xCD,0x80,0x1E);
43 DEFINE_GUID(CLSID_Desktop
, 0x00021400, 0x0000, 0x0000, 0xC0,0x00, 0x00,0x00,0x00,0x00,0x00,0x46);
44 DEFINE_GUID(IID_IFileDialogPrivate
, 0xAC92FFC5, 0xF0E9, 0x455A, 0x90,0x6B, 0x4A,0x83,0xE7,0x4A,0x80,0x3B);
45 DEFINE_GUID(IID_IWebbrowserApp
, 0x0002df05, 0x0000, 0x0000, 0xc0,0x00, 0x00,0x00,0x00,0x00,0x00,0x46);
46 DEFINE_GUID(IID_IBrowserSettings_Vista
, 0xF81B80BC, 0x29D1, 0x4734, 0xB5,0x15, 0x77,0x24,0xBF,0xF1,0x60,0x01);
47 DEFINE_GUID(IID_IFolderTypeModifier
, 0x04BA120E, 0xAD52, 0x4A2D, 0x98,0x07, 0x2D,0xA1,0x78,0xD0,0xC3,0xE1);
48 DEFINE_GUID(IID_IShellBrowserService_Vista
, 0xF5A24314, 0x5B8B, 0x44FA, 0xBC,0x2E, 0x31,0x28,0x55,0x44,0xB5,0x20);
49 DEFINE_GUID(IID_IFileDialogPrivate_Vista
, 0x2539E31C, 0x857F, 0x43C4, 0x88,0x72, 0x45,0xBD,0x6A,0x02,0x48,0x92);
50 DEFINE_GUID(SID_SMenuBandParent
, 0x8C278EEC, 0x3EAB, 0x11D1, 0x8C,0xB0 ,0x00,0xC0,0x4F,0xD9,0x18,0xD0);
51 DEFINE_GUID(SID_SMenuPopup
, 0xD1E7AFEB, 0x6A2E, 0x11D0, 0x8C,0x78, 0x00,0xC0,0x4F,0xD9,0x18,0xB4);
52 DEFINE_GUID(IID_IShellMenu
, 0xEE1F7637, 0xE138, 0x11D1, 0x83,0x79, 0x00,0xC0,0x4F,0xD9,0x18,0xD0);
54 DEFINE_GUID(IID_UnknownInterface1
, 0x3934E4C2, 0x8143, 0x4E4C, 0xA1,0xDC, 0x71,0x8F,0x85,0x63,0xF3,0x37);
55 DEFINE_GUID(IID_UnknownInterface2
, 0x3E24A11C, 0x15B2, 0x4F71, 0xB8,0x1E, 0x00,0x8F,0x77,0x99,0x8E,0x9F);
56 DEFINE_GUID(IID_UnknownInterface3
, 0xE38FE0F3, 0x3DB0, 0x47EE, 0xA3,0x14, 0x25,0xCF,0x7F,0x4B,0xF5,0x21);
57 DEFINE_GUID(IID_UnknownInterface4
, 0xFAD451C2, 0xAF58, 0x4161, 0xB9,0xFF, 0x57,0xAF,0xBB,0xED,0x0A,0xD2);
58 DEFINE_GUID(IID_UnknownInterface5
, 0xF80C2137, 0x5829, 0x4CE9, 0x9F,0x81, 0xA9,0x5E,0x15,0x9D,0xD8,0xD5);
59 DEFINE_GUID(IID_UnknownInterface6
, 0xD7F81F62, 0x491F, 0x49BC, 0x89,0x1D, 0x56,0x65,0x08,0x5D,0xF9,0x69);
60 DEFINE_GUID(IID_UnknownInterface7
, 0x68A4FDBA, 0xA48A, 0x4A86, 0xA3,0x29, 0x1B,0x69,0xB9,0xB1,0x9E,0x89);
61 DEFINE_GUID(IID_UnknownInterface8
, 0xD3B1CAF5, 0xEC4F, 0x4B2E, 0xBC,0xB0, 0x60,0xD7,0x15,0xC9,0x3C,0xB2);
62 DEFINE_GUID(IID_UnknownInterface9
, 0x9536CA39, 0x1ACB, 0x4AE6, 0xAD,0x27, 0x24,0x03,0xD0,0x4C,0xA2,0x8F);
63 DEFINE_GUID(IID_UnknownInterface10
, 0xB722BE00, 0x4E68, 0x101B, 0xA2,0xBC, 0x00,0xAA,0x00,0x40,0x47,0x70);
64 DEFINE_GUID(IID_UnknownInterface11
, 0x691ecf9f, 0x6b9c, 0x4311, 0xa1,0x7b, 0xad,0x15,0x4c,0x30,0xe9,0x1f);
65 DEFINE_GUID(IID_UnknownInterface12
, 0x7e3159f5, 0x21ca, 0x4ec2, 0x8f,0xbe, 0x66,0x2d,0x08,0x2c,0xa3,0xeb);
66 DEFINE_GUID(IID_UnknownInterface13
, 0xa36a3ace, 0x8332, 0x45ce, 0xaa,0x29, 0x50,0x3c,0xb7,0x6b,0x25,0x87);
67 DEFINE_GUID(IID_UnknownInterface14
, 0x16770868, 0x239c, 0x445b, 0xa0,0x1d, 0xf2,0x6c,0x7f,0xbb,0xf2,0x6c);
68 DEFINE_GUID(IID_UnknownInterface15
, 0x05a89298, 0x6246, 0x4c63, 0xbb,0x0d, 0x9b,0xda,0xf1,0x40,0xbf,0x3b);
69 DEFINE_GUID(IID_UnknownInterface16
, 0x35094a87, 0x8bb1, 0x4237, 0x96,0xc6, 0xc4,0x17,0xee,0xbd,0xb0,0x78);
70 DEFINE_GUID(IID_UnknownInterface17
, 0x3d5d8c60, 0x21e4, 0x4b03, 0x83,0xb8, 0xc7,0x3f,0x8c,0x94,0x00,0x78);
71 DEFINE_GUID(IID_UnknownInterface18
, 0x1fc45c07, 0x9e35, 0x4276, 0xad,0x7f, 0x08,0x60,0x3a,0xa0,0xf6,0x0f);
72 DEFINE_GUID(IID_UnknownInterface19
, 0xacd9b67a, 0xceab, 0x4c6c, 0x90,0xa1, 0xe8,0x57,0xc6,0x59,0xe3,0x9d);
73 DEFINE_GUID(IID_UnknownInterface20
, 0xd0fe6f62, 0xdea4, 0x46c9, 0x9d,0xae, 0x36,0xcb,0x13,0x99,0x78,0xfa);
77 static HRESULT (WINAPI
*pSHCreateShellItem
)(LPCITEMIDLIST
,IShellFolder
*,LPCITEMIDLIST
,IShellItem
**);
78 static HRESULT (WINAPI
*pSHParseDisplayName
)(LPCWSTR
,IBindCtx
*,LPITEMIDLIST
*,SFGAOF
,SFGAOF
*);
80 static void init_function_pointers(void)
84 hmod
= GetModuleHandleA("shell32.dll");
85 pSHCreateShellItem
= (void*)GetProcAddress(hmod
, "SHCreateShellItem");
86 pSHParseDisplayName
= (void*)GetProcAddress(hmod
, "SHParseDisplayName");
89 /*********************************************************************
92 static HRESULT
ebrowser_instantiate(IExplorerBrowser
**peb
)
94 return CoCreateInstance(&CLSID_ExplorerBrowser
, NULL
, CLSCTX_INPROC_SERVER
,
95 &IID_IExplorerBrowser
, (void**)peb
);
98 static HRESULT
ebrowser_initialize(IExplorerBrowser
*peb
)
101 rc
.top
= rc
.left
= 0; rc
.bottom
= rc
.right
= 500;
102 return IExplorerBrowser_Initialize(peb
, hwnd
, &rc
, NULL
);
105 static HRESULT
ebrowser_browse_to_desktop(IExplorerBrowser
*peb
)
107 LPITEMIDLIST pidl_desktop
;
109 SHGetSpecialFolderLocation (hwnd
, CSIDL_DESKTOP
, &pidl_desktop
);
110 hr
= IExplorerBrowser_BrowseToIDList(peb
, pidl_desktop
, 0);
111 ILFree(pidl_desktop
);
115 /* Process some messages */
116 static void process_msgs(void)
119 while(PeekMessageA( &msg
, NULL
, 0, 0, PM_REMOVE
))
121 TranslateMessage(&msg
);
122 DispatchMessageA(&msg
);
126 /*********************************************************************
127 * IExplorerBrowserEvents implementation
130 IExplorerBrowserEvents IExplorerBrowserEvents_iface
;
132 UINT pending
, created
, completed
, failed
;
133 } IExplorerBrowserEventsImpl
;
135 static IExplorerBrowserEventsImpl ebev
;
137 static inline IExplorerBrowserEventsImpl
*impl_from_IExplorerBrowserEvents(IExplorerBrowserEvents
*iface
)
139 return CONTAINING_RECORD(iface
, IExplorerBrowserEventsImpl
, IExplorerBrowserEvents_iface
);
142 static HRESULT WINAPI
IExplorerBrowserEvents_fnQueryInterface(IExplorerBrowserEvents
*iface
,
143 REFIID riid
, void **ppvObj
)
145 ok(0, "Never called.\n");
146 return E_NOINTERFACE
;
149 static ULONG WINAPI
IExplorerBrowserEvents_fnAddRef(IExplorerBrowserEvents
*iface
)
151 IExplorerBrowserEventsImpl
*This
= impl_from_IExplorerBrowserEvents(iface
);
152 return InterlockedIncrement(&This
->ref
);
155 static ULONG WINAPI
IExplorerBrowserEvents_fnRelease(IExplorerBrowserEvents
*iface
)
157 IExplorerBrowserEventsImpl
*This
= impl_from_IExplorerBrowserEvents(iface
);
158 return InterlockedDecrement(&This
->ref
);
161 static HRESULT WINAPI
IExplorerBrowserEvents_fnOnNavigationPending(IExplorerBrowserEvents
*iface
,
162 PCIDLIST_ABSOLUTE pidlFolder
)
164 IExplorerBrowserEventsImpl
*This
= impl_from_IExplorerBrowserEvents(iface
);
169 static HRESULT WINAPI
IExplorerBrowserEvents_fnOnNavigationComplete(IExplorerBrowserEvents
*iface
,
170 PCIDLIST_ABSOLUTE pidlFolder
)
172 IExplorerBrowserEventsImpl
*This
= impl_from_IExplorerBrowserEvents(iface
);
176 static HRESULT WINAPI
IExplorerBrowserEvents_fnOnNavigationFailed(IExplorerBrowserEvents
*iface
,
177 PCIDLIST_ABSOLUTE pidlFolder
)
179 IExplorerBrowserEventsImpl
*This
= impl_from_IExplorerBrowserEvents(iface
);
183 static HRESULT WINAPI
IExplorerBrowserEvents_fnOnViewCreated(IExplorerBrowserEvents
*iface
,
186 IExplorerBrowserEventsImpl
*This
= impl_from_IExplorerBrowserEvents(iface
);
191 static const IExplorerBrowserEventsVtbl ebevents
=
193 IExplorerBrowserEvents_fnQueryInterface
,
194 IExplorerBrowserEvents_fnAddRef
,
195 IExplorerBrowserEvents_fnRelease
,
196 IExplorerBrowserEvents_fnOnNavigationPending
,
197 IExplorerBrowserEvents_fnOnViewCreated
,
198 IExplorerBrowserEvents_fnOnNavigationComplete
,
199 IExplorerBrowserEvents_fnOnNavigationFailed
202 /*********************************************************************
203 * IExplorerPaneVisibility implementation
207 IExplorerPaneVisibility IExplorerPaneVisibility_iface
;
210 LONG np
, cp
, cp_o
, cp_v
, dp
, pp
, qp
, aqp
, unk
; /* The panes */
211 } IExplorerPaneVisibilityImpl
;
213 static inline IExplorerPaneVisibilityImpl
*impl_from_IExplorerPaneVisibility(IExplorerPaneVisibility
*iface
)
215 return CONTAINING_RECORD(iface
, IExplorerPaneVisibilityImpl
, IExplorerPaneVisibility_iface
);
218 static HRESULT WINAPI
IExplorerPaneVisibility_fnQueryInterface(IExplorerPaneVisibility
*iface
,
219 REFIID riid
, LPVOID
*ppvObj
)
221 ok(0, "unexpected, %s\n", wine_dbgstr_guid(riid
));
223 return E_NOINTERFACE
;
226 static ULONG WINAPI
IExplorerPaneVisibility_fnAddRef(IExplorerPaneVisibility
*iface
)
228 IExplorerPaneVisibilityImpl
*This
= impl_from_IExplorerPaneVisibility(iface
);
229 return InterlockedIncrement(&This
->ref
);
232 static ULONG WINAPI
IExplorerPaneVisibility_fnRelease(IExplorerPaneVisibility
*iface
)
234 IExplorerPaneVisibilityImpl
*This
= impl_from_IExplorerPaneVisibility(iface
);
235 ULONG ref
= InterlockedDecrement(&This
->ref
);
238 HeapFree(GetProcessHeap(), 0, This
);
243 static HRESULT WINAPI
IExplorerPaneVisibility_fnGetPaneState(IExplorerPaneVisibility
*iface
,
245 EXPLORERPANESTATE
*peps
)
247 IExplorerPaneVisibilityImpl
*This
= impl_from_IExplorerPaneVisibility(iface
);
250 ok(ep
!= NULL
, "ep is NULL.\n");
251 ok(peps
!= NULL
, "peps is NULL.\n");
252 ok(*peps
== 0, "got %d\n", *peps
);
255 if(IsEqualGUID(&EP_NavPane
, ep
)) This
->np
++;
256 else if(IsEqualGUID(&EP_Commands
, ep
)) This
->cp
++;
257 else if(IsEqualGUID(&EP_Commands_Organize
, ep
)) This
->cp_o
++;
258 else if(IsEqualGUID(&EP_Commands_View
, ep
)) This
->cp_v
++;
259 else if(IsEqualGUID(&EP_DetailsPane
, ep
)) This
->dp
++;
260 else if(IsEqualGUID(&EP_PreviewPane
, ep
)) This
->pp
++;
261 else if(IsEqualGUID(&EP_QueryPane
, ep
)) This
->qp
++;
262 else if(IsEqualGUID(&EP_AdvQueryPane
, ep
)) This
->aqp
++;
265 trace("Unknown explorer pane: %s\n", wine_dbgstr_guid(ep
));
272 static const IExplorerPaneVisibilityVtbl epvvt
=
274 IExplorerPaneVisibility_fnQueryInterface
,
275 IExplorerPaneVisibility_fnAddRef
,
276 IExplorerPaneVisibility_fnRelease
,
277 IExplorerPaneVisibility_fnGetPaneState
280 static IExplorerPaneVisibilityImpl
*create_explorerpanevisibility(void)
282 IExplorerPaneVisibilityImpl
*epv
;
284 epv
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IExplorerPaneVisibilityImpl
));
285 epv
->IExplorerPaneVisibility_iface
.lpVtbl
= &epvvt
;
291 /*********************************************************************
292 * ICommDlgBrowser3 implementation
296 ICommDlgBrowser3 ICommDlgBrowser3_iface
;
298 UINT OnDefaultCommand
, OnStateChange
, IncludeObject
;
299 UINT Notify
, GetDefaultMenuText
, GetViewFlags
;
300 UINT OnColumnClicked
, GetCurrentFilter
, OnPreviewCreated
;
301 } ICommDlgBrowser3Impl
;
303 static inline ICommDlgBrowser3Impl
*impl_from_ICommDlgBrowser3(ICommDlgBrowser3
*iface
)
305 return CONTAINING_RECORD(iface
, ICommDlgBrowser3Impl
, ICommDlgBrowser3_iface
);
308 static HRESULT WINAPI
ICommDlgBrowser3_fnQueryInterface(ICommDlgBrowser3
*iface
, REFIID riid
, LPVOID
*ppvObj
)
310 ok(0, "unexpected %s\n", wine_dbgstr_guid(riid
));
312 return E_NOINTERFACE
;
315 static ULONG WINAPI
ICommDlgBrowser3_fnAddRef(ICommDlgBrowser3
*iface
)
317 ICommDlgBrowser3Impl
*This
= impl_from_ICommDlgBrowser3(iface
);
318 return InterlockedIncrement(&This
->ref
);
321 static ULONG WINAPI
ICommDlgBrowser3_fnRelease(ICommDlgBrowser3
*iface
)
323 ICommDlgBrowser3Impl
*This
= impl_from_ICommDlgBrowser3(iface
);
324 ULONG ref
= InterlockedDecrement(&This
->ref
);
327 HeapFree(GetProcessHeap(), 0, This
);
332 static HRESULT WINAPI
ICommDlgBrowser3_fnOnDefaultCommand(ICommDlgBrowser3
* iface
, IShellView
*shv
)
334 ICommDlgBrowser3Impl
*This
= impl_from_ICommDlgBrowser3(iface
);
335 This
->OnDefaultCommand
++;
339 static HRESULT WINAPI
ICommDlgBrowser3_fnOnStateChange(
340 ICommDlgBrowser3
* iface
,
344 ICommDlgBrowser3Impl
*This
= impl_from_ICommDlgBrowser3(iface
);
345 This
->OnStateChange
++;
349 static HRESULT WINAPI
ICommDlgBrowser3_fnIncludeObject(
350 ICommDlgBrowser3
* iface
,
354 ICommDlgBrowser3Impl
*This
= impl_from_ICommDlgBrowser3(iface
);
355 This
->IncludeObject
++;
359 static HRESULT WINAPI
ICommDlgBrowser3_fnNotify(
360 ICommDlgBrowser3
* iface
,
364 ICommDlgBrowser3Impl
*This
= impl_from_ICommDlgBrowser3(iface
);
369 static HRESULT WINAPI
ICommDlgBrowser3_fnGetDefaultMenuText(
370 ICommDlgBrowser3
* iface
,
375 ICommDlgBrowser3Impl
*This
= impl_from_ICommDlgBrowser3(iface
);
376 This
->GetDefaultMenuText
++;
380 static HRESULT WINAPI
ICommDlgBrowser3_fnGetViewFlags(
381 ICommDlgBrowser3
* iface
,
384 ICommDlgBrowser3Impl
*This
= impl_from_ICommDlgBrowser3(iface
);
385 This
->GetViewFlags
++;
389 static HRESULT WINAPI
ICommDlgBrowser3_fnOnColumnClicked(
390 ICommDlgBrowser3
* iface
,
394 ICommDlgBrowser3Impl
*This
= impl_from_ICommDlgBrowser3(iface
);
395 This
->OnColumnClicked
++;
399 static HRESULT WINAPI
ICommDlgBrowser3_fnGetCurrentFilter(
400 ICommDlgBrowser3
* iface
,
404 ICommDlgBrowser3Impl
*This
= impl_from_ICommDlgBrowser3(iface
);
405 This
->GetCurrentFilter
++;
409 static HRESULT WINAPI
ICommDlgBrowser3_fnOnPreviewCreated(
410 ICommDlgBrowser3
* iface
,
413 ICommDlgBrowser3Impl
*This
= impl_from_ICommDlgBrowser3(iface
);
414 This
->OnPreviewCreated
++;
418 static const ICommDlgBrowser3Vtbl cdbvtbl
=
420 ICommDlgBrowser3_fnQueryInterface
,
421 ICommDlgBrowser3_fnAddRef
,
422 ICommDlgBrowser3_fnRelease
,
423 ICommDlgBrowser3_fnOnDefaultCommand
,
424 ICommDlgBrowser3_fnOnStateChange
,
425 ICommDlgBrowser3_fnIncludeObject
,
426 ICommDlgBrowser3_fnNotify
,
427 ICommDlgBrowser3_fnGetDefaultMenuText
,
428 ICommDlgBrowser3_fnGetViewFlags
,
429 ICommDlgBrowser3_fnOnColumnClicked
,
430 ICommDlgBrowser3_fnGetCurrentFilter
,
431 ICommDlgBrowser3_fnOnPreviewCreated
434 static ICommDlgBrowser3Impl
*create_commdlgbrowser3(void)
436 ICommDlgBrowser3Impl
*cdb
;
438 cdb
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(ICommDlgBrowser3Impl
));
439 cdb
->ICommDlgBrowser3_iface
.lpVtbl
= &cdbvtbl
;
445 /*********************************************************************
446 * IServiceProvider Implementation
449 IServiceProvider IServiceProvider_iface
;
457 } IServiceProviderImpl
;
459 static inline IServiceProviderImpl
*impl_from_IServiceProvider(IServiceProvider
*iface
)
461 return CONTAINING_RECORD(iface
, IServiceProviderImpl
, IServiceProvider_iface
);
464 static HRESULT WINAPI
IServiceProvider_fnQueryInterface(IServiceProvider
*iface
, REFIID riid
, LPVOID
*ppvObj
)
467 if(IsEqualIID(riid
, &IID_IServiceProvider
))
470 IServiceProvider_AddRef(iface
);
474 if(IsEqualIID(riid
, &IID_IOleCommandTarget
))
477 return E_NOINTERFACE
;
480 ok(0, "Unexpected interface requested, %s\n", wine_dbgstr_guid(riid
));
481 return E_NOINTERFACE
;
484 static ULONG WINAPI
IServiceProvider_fnAddRef(IServiceProvider
*iface
)
486 IServiceProviderImpl
*This
= impl_from_IServiceProvider(iface
);
487 return InterlockedIncrement(&This
->ref
);
490 static ULONG WINAPI
IServiceProvider_fnRelease(IServiceProvider
*iface
)
492 IServiceProviderImpl
*This
= impl_from_IServiceProvider(iface
);
493 LONG ref
= InterlockedDecrement(&This
->ref
);
496 HeapFree(GetProcessHeap(), 0, This
);
501 static HRESULT WINAPI
IServiceProvider_fnQueryService(IServiceProvider
*iface
,
506 IServiceProviderImpl
*This
= impl_from_IServiceProvider(iface
);
507 BOOL was_in_list
= FALSE
;
508 IUnknown
*punk
= NULL
;
512 for(i
= 0; This
->interfaces
[i
].service
!= NULL
; i
++)
514 if(IsEqualGUID(This
->interfaces
[i
].service
, guidService
) &&
515 IsEqualIID(This
->interfaces
[i
].id
, riid
))
518 This
->interfaces
[i
].count
++;
519 punk
= This
->interfaces
[i
].punk
;
524 ok(was_in_list
, "unknown service, serviceID: %s, riid: %s\n", wine_dbgstr_guid(guidService
), wine_dbgstr_guid(riid
));
526 /* Give back an interface, if any. */
530 IUnknown_AddRef(punk
);
534 return E_NOINTERFACE
;
537 static const IServiceProviderVtbl spvtbl
=
539 IServiceProvider_fnQueryInterface
,
540 IServiceProvider_fnAddRef
,
541 IServiceProvider_fnRelease
,
542 IServiceProvider_fnQueryService
545 static IServiceProviderImpl
*create_serviceprovider(void)
547 IServiceProviderImpl
*sp
= HeapAlloc(GetProcessHeap(), 0, sizeof(IServiceProviderImpl
));
548 sp
->IServiceProvider_iface
.lpVtbl
= &spvtbl
;
553 static void test_QueryInterface(void)
555 IExplorerBrowser
*peb
;
560 hr
= ebrowser_instantiate(&peb
);
561 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
563 #define test_qinterface(iid, exp) \
565 hr = IExplorerBrowser_QueryInterface(peb, &iid, (void**)&punk); \
566 ok(hr == exp, "(%s:)Expected (0x%08x), got (0x%08x)\n", \
568 if(SUCCEEDED(hr)) IUnknown_Release(punk); \
571 test_qinterface(IID_IUnknown
, S_OK
);
572 test_qinterface(IID_IExplorerBrowser
, S_OK
);
573 test_qinterface(IID_IShellBrowser
, S_OK
);
574 todo_wine
test_qinterface(IID_IOleWindow
, S_OK
);
575 test_qinterface(IID_ICommDlgBrowser
, S_OK
);
576 test_qinterface(IID_ICommDlgBrowser2
, S_OK
);
577 test_qinterface(IID_ICommDlgBrowser3
, S_OK
);
578 todo_wine
test_qinterface(IID_IServiceProvider
, S_OK
);
579 test_qinterface(IID_IObjectWithSite
, S_OK
);
580 todo_wine
test_qinterface(IID_IConnectionPointContainer
, S_OK
);
581 test_qinterface(IID_IOleObject
, E_NOINTERFACE
);
582 test_qinterface(IID_IViewObject
, E_NOINTERFACE
);
583 test_qinterface(IID_IViewObject2
, E_NOINTERFACE
);
584 test_qinterface(IID_IViewObjectEx
, E_NOINTERFACE
);
585 test_qinterface(IID_IConnectionPoint
, E_NOINTERFACE
);
586 test_qinterface(IID_IShellView
, E_NOINTERFACE
);
587 test_qinterface(IID_INameSpaceTreeControlEvents
, E_NOINTERFACE
);
589 #undef test_qinterface
591 lres
= IExplorerBrowser_Release(peb
);
592 ok(lres
== 0, "Got %d\n", lres
);
595 static void test_SB_misc(void)
597 IExplorerBrowser
*peb
;
605 ebrowser_instantiate(&peb
);
606 hr
= IExplorerBrowser_QueryInterface(peb
, &IID_IShellBrowser
, (void**)&psb
);
607 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
610 skip("Failed to get IShellBrowser interface.\n");
614 /* Some unimplemented methods */
615 retHwnd
= (HWND
)0xdeadbeef;
616 hr
= IShellBrowser_GetControlWindow(psb
, FCW_TOOLBAR
, &retHwnd
);
617 ok(hr
== E_NOTIMPL
, "got (0x%08x)\n", hr
);
618 ok(retHwnd
== NULL
|| broken(retHwnd
== (HWND
)0xdeadbeef), "got %p\n", retHwnd
);
620 retHwnd
= (HWND
)0xdeadbeef;
621 hr
= IShellBrowser_GetControlWindow(psb
, FCW_STATUS
, &retHwnd
);
622 ok(hr
== E_NOTIMPL
, "got (0x%08x)\n", hr
);
623 ok(retHwnd
== NULL
|| broken(retHwnd
== (HWND
)0xdeadbeef), "got %p\n", retHwnd
);
625 retHwnd
= (HWND
)0xdeadbeef;
626 hr
= IShellBrowser_GetControlWindow(psb
, FCW_TREE
, &retHwnd
);
627 ok(hr
== E_NOTIMPL
, "got (0x%08x)\n", hr
);
628 ok(retHwnd
== NULL
|| broken(retHwnd
== (HWND
)0xdeadbeef), "got %p\n", retHwnd
);
630 retHwnd
= (HWND
)0xdeadbeef;
631 hr
= IShellBrowser_GetControlWindow(psb
, FCW_PROGRESS
, &retHwnd
);
632 ok(hr
== E_NOTIMPL
, "got (0x%08x)\n", hr
);
633 ok(retHwnd
== NULL
|| broken(retHwnd
== (HWND
)0xdeadbeef), "got %p\n", retHwnd
);
636 hr
= IShellBrowser_InsertMenusSB(psb
, NULL
, NULL
);
637 ok(hr
== E_NOTIMPL
, "got (0x%08x)\n", hr
);
639 /* ::RemoveMenusSB */
640 hr
= IShellBrowser_RemoveMenusSB(psb
, NULL
);
641 ok(hr
== E_NOTIMPL
, "got (0x%08x)\n", hr
);
644 hr
= IShellBrowser_SetMenuSB(psb
, NULL
, NULL
, NULL
);
645 ok(hr
== E_NOTIMPL
, "got (0x%08x)\n", hr
);
647 /***** Before EB::Initialize *****/
650 retHwnd
= (HWND
)0xDEADBEEF;
651 hr
= IShellBrowser_GetWindow(psb
, &retHwnd
);
652 ok(hr
== E_FAIL
, "got (0x%08x)\n", hr
);
653 ok(retHwnd
== (HWND
)0xDEADBEEF, "HWND overwritten\n");
658 /* ::SendControlMsg */
660 hr
= IShellBrowser_SendControlMsg(psb
, FCW_STATUS
, 0, 0, 0, &lres
);
661 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
662 ok(lres
== 0, "lres was %ld\n", lres
);
665 hr
= IShellBrowser_SendControlMsg(psb
, FCW_TOOLBAR
, TB_CHECKBUTTON
,
666 FCIDM_TB_SMALLICON
, TRUE
, &lres
);
667 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
668 ok(lres
== 0, "lres was %ld\n", lres
);
670 hr
= IShellBrowser_SendControlMsg(psb
, FCW_STATUS
, 0, 0, 0, NULL
);
671 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
673 hr
= IShellBrowser_SendControlMsg(psb
, FCW_TREE
, 0, 0, 0, NULL
);
674 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
676 hr
= IShellBrowser_SendControlMsg(psb
, FCW_PROGRESS
, 0, 0, 0, NULL
);
677 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
680 /* ::QueryActiveShellView */
681 hr
= IShellBrowser_QueryActiveShellView(psb
, (IShellView
**)&punk
);
682 ok(hr
== E_FAIL
, "got (0x%08x)\n", hr
);
684 /* Initialize ExplorerBrowser */
685 ebrowser_initialize(peb
);
687 /***** After EB::Initialize *****/
690 hr
= IShellBrowser_GetWindow(psb
, &retHwnd
);
691 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
692 ok(GetParent(retHwnd
) == hwnd
, "The HWND returned is not our child.\n");
696 /* ::SendControlMsg */
697 hr
= IShellBrowser_SendControlMsg(psb
, FCW_STATUS
, 0, 0, 0, NULL
);
698 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
701 hr
= IShellBrowser_SendControlMsg(psb
, FCW_TOOLBAR
, 0, 0, 0, &lres
);
702 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
703 ok(lres
== 0, "lres was %ld\n", lres
);
706 hr
= IShellBrowser_SendControlMsg(psb
, FCW_STATUS
, 0, 0, 0, &lres
);
707 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
708 ok(lres
== 0, "lres was %ld\n", lres
);
711 hr
= IShellBrowser_SendControlMsg(psb
, 1234, 0, 0, 0, &lres
);
712 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
713 ok(lres
== 0, "lres was %ld\n", lres
);
716 hr
= IShellBrowser_SetStatusTextSB(psb
, NULL
);
717 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
719 hr
= IShellBrowser_ContextSensitiveHelp(psb
, FALSE
);
720 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
722 hr
= IShellBrowser_EnableModelessSB(psb
, TRUE
);
723 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
725 hr
= IShellBrowser_SetToolbarItems(psb
, NULL
, 1, 1);
726 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
729 hr
= IShellBrowser_QueryActiveShellView(psb
, (IShellView
**)&punk
);
730 ok(hr
== E_FAIL
, "got (0x%08x)\n", hr
);
732 IShellBrowser_Release(psb
);
733 IExplorerBrowser_Destroy(peb
);
734 IExplorerBrowser_Release(peb
);
736 /* Browse to the desktop. */
737 ebrowser_instantiate(&peb
);
738 ebrowser_initialize(peb
);
739 IExplorerBrowser_QueryInterface(peb
, &IID_IShellBrowser
, (void**)&psb
);
742 hr
= ebrowser_browse_to_desktop(peb
);
743 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
746 /****** After Browsing *****/
748 hr
= IShellBrowser_QueryActiveShellView(psb
, (IShellView
**)&punk
);
749 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
750 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
752 IShellBrowser_Release(psb
);
753 IExplorerBrowser_Destroy(peb
);
754 ref
= IExplorerBrowser_Release(peb
);
755 ok(ref
== 0, "Got %d\n", ref
);
758 static void test_initialization(void)
760 IExplorerBrowser
*peb
;
766 ebrowser_instantiate(&peb
);
770 /* Crashes on Windows 7 */
771 IExplorerBrowser_Initialize(peb
, NULL
, NULL
, NULL
);
772 IExplorerBrowser_Initialize(peb
, hwnd
, NULL
, NULL
);
775 ZeroMemory(&rc
, sizeof(RECT
));
777 hr
= IExplorerBrowser_Initialize(peb
, NULL
, &rc
, NULL
);
778 ok(hr
== E_INVALIDARG
, "got (0x%08x)\n", hr
);
780 hr
= IExplorerBrowser_Initialize(peb
, hwnd
, &rc
, NULL
);
781 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
783 /* Initialize twice */
784 hr
= IExplorerBrowser_Initialize(peb
, hwnd
, &rc
, NULL
);
785 ok(hr
== E_UNEXPECTED
, "got (0x%08x)\n", hr
);
787 hr
= IExplorerBrowser_Destroy(peb
);
788 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
790 /* Initialize again */
791 hr
= IExplorerBrowser_Initialize(peb
, hwnd
, &rc
, NULL
);
792 ok(hr
== E_UNEXPECTED
, "got (0x%08x)\n", hr
);
795 hr
= IExplorerBrowser_Destroy(peb
);
796 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
797 lres
= IExplorerBrowser_Release(peb
);
798 ok(lres
== 0, "Got %d\n", lres
);
800 /* Initialize with a few different rectangles */
802 ebrowser_instantiate(&peb
);
803 rc
.left
= 50; rc
.top
= 20; rc
.right
= 100; rc
.bottom
= 80;
804 hr
= IExplorerBrowser_Initialize(peb
, hwnd
, &rc
, NULL
);
805 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
806 hr
= IExplorerBrowser_QueryInterface(peb
, &IID_IShellBrowser
, (void**)&psb
);
807 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
813 LONG style
, expected_style
;
814 static const RECT exp_rc
= {0, 0, 48, 58};
816 hr
= IShellBrowser_GetWindow(psb
, &eb_hwnd
);
817 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
819 GetClientRect(eb_hwnd
, &eb_rc
);
820 ok(EqualRect(&eb_rc
, &exp_rc
), "Got client rect (%d, %d)-(%d, %d)\n",
821 eb_rc
.left
, eb_rc
.top
, eb_rc
.right
, eb_rc
.bottom
);
823 GetWindowRect(eb_hwnd
, &eb_rc
);
824 ok(eb_rc
.right
- eb_rc
.left
== 50, "Got window width %d\n", eb_rc
.right
- eb_rc
.left
);
825 ok(eb_rc
.bottom
- eb_rc
.top
== 60, "Got window height %d\n", eb_rc
.bottom
- eb_rc
.top
);
828 GetClassNameA(eb_hwnd
, buf
, 1024);
829 ok(!lstrcmpA(buf
, "ExplorerBrowserControl"), "Unexpected classname %s\n", buf
);
831 expected_style
= WS_CHILD
| WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_CLIPCHILDREN
| WS_BORDER
;
832 style
= GetWindowLongPtrW(eb_hwnd
, GWL_STYLE
);
833 todo_wine
ok(style
== expected_style
, "Got style 0x%08x, expected 0x%08x\n", style
, expected_style
);
835 expected_style
= WS_EX_CONTROLPARENT
;
836 style
= GetWindowLongPtrW(eb_hwnd
, GWL_EXSTYLE
);
837 ok(style
== expected_style
, "Got exstyle 0x%08x, expected 0x%08x\n", style
, expected_style
);
839 ok(GetParent(eb_hwnd
) == hwnd
, "GetParent returns %p\n", GetParent(eb_hwnd
));
841 /* ::Destroy() destroys the window. */
842 ok(IsWindow(eb_hwnd
), "eb_hwnd invalid.\n");
843 IExplorerBrowser_Destroy(peb
);
844 ok(!IsWindow(eb_hwnd
), "eb_hwnd valid.\n");
846 IShellBrowser_Release(psb
);
847 lres
= IExplorerBrowser_Release(peb
);
848 ok(lres
== 0, "Got refcount %d\n", lres
);
852 skip("Skipping some tests.\n");
854 IExplorerBrowser_Destroy(peb
);
855 lres
= IExplorerBrowser_Release(peb
);
856 ok(lres
== 0, "Got refcount %d\n", lres
);
859 ebrowser_instantiate(&peb
);
860 rc
.left
= 0; rc
.top
= 0; rc
.right
= 0; rc
.bottom
= 0;
861 hr
= IExplorerBrowser_Initialize(peb
, hwnd
, &rc
, NULL
);
862 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
863 IExplorerBrowser_Destroy(peb
);
864 lres
= IExplorerBrowser_Release(peb
);
865 ok(lres
== 0, "Got refcount %d\n", lres
);
867 ebrowser_instantiate(&peb
);
868 rc
.left
= -1; rc
.top
= -1; rc
.right
= 1; rc
.bottom
= 1;
869 hr
= IExplorerBrowser_Initialize(peb
, hwnd
, &rc
, NULL
);
870 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
871 IExplorerBrowser_Destroy(peb
);
872 lres
= IExplorerBrowser_Release(peb
);
873 ok(lres
== 0, "Got refcount %d\n", lres
);
875 ebrowser_instantiate(&peb
);
876 rc
.left
= 10; rc
.top
= 10; rc
.right
= 5; rc
.bottom
= 5;
877 hr
= IExplorerBrowser_Initialize(peb
, hwnd
, &rc
, NULL
);
878 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
879 IExplorerBrowser_Destroy(peb
);
880 lres
= IExplorerBrowser_Release(peb
);
881 ok(lres
== 0, "Got refcount %d\n", lres
);
883 ebrowser_instantiate(&peb
);
884 rc
.left
= 10; rc
.top
= 10; rc
.right
= 5; rc
.bottom
= 5;
885 hr
= IExplorerBrowser_Initialize(peb
, hwnd
, &rc
, NULL
);
886 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
887 IExplorerBrowser_Destroy(peb
);
888 lres
= IExplorerBrowser_Release(peb
);
889 ok(lres
== 0, "Got refcount %d\n", lres
);
892 static void test_SetSite(void)
894 IExplorerBrowser
*peb
;
895 IServiceProviderImpl
*spimpl
= create_serviceprovider();
896 ICommDlgBrowser3Impl
*cdbimpl
= create_commdlgbrowser3();
897 IExplorerPaneVisibilityImpl
*epvimpl
= create_explorerpanevisibility();
898 IObjectWithSite
*pow
;
902 struct services expected
[] = {
904 { &SID_STopLevelBrowser
, &IID_ICommDlgBrowser2
, 0, cdbimpl
},
905 { &SID_STopLevelBrowser
, &IID_IShellBrowserService
, 0, NULL
},
906 { &SID_STopLevelBrowser
, &IID_IShellBrowser
, 0, NULL
},
907 { &SID_STopLevelBrowser
, &IID_UnknownInterface8
, 0, NULL
},
908 { &SID_STopLevelBrowser
, &IID_IConnectionPointContainer
, 0, NULL
},
909 { &SID_STopLevelBrowser
, &IID_IProfferService
, 0, NULL
},
910 { &SID_STopLevelBrowser
, &IID_UnknownInterface9
, 0, NULL
},
911 { &SID_ExplorerPaneVisibility
, &IID_IExplorerPaneVisibility
, 0, epvimpl
},
912 { &SID_SExplorerBrowserFrame
, &IID_ICommDlgBrowser2
, 0, cdbimpl
},
913 { &SID_SExplorerBrowserFrame
, &IID_ICommDlgBrowser3
, 0, cdbimpl
},
914 { &IID_IFileDialogPrivate
, &IID_IFileDialogPrivate
, 0, NULL
},
915 { &IID_IFileDialogPrivate
, &IID_IFileDialog
, 0, NULL
},
916 { &IID_IShellTaskScheduler
, &IID_IShellTaskScheduler
, 0, NULL
},
917 { &IID_IShellTaskScheduler
, &IID_UnknownInterface2
, 0, NULL
},
918 { &IID_IWebbrowserApp
, &IID_IConnectionPointContainer
, 0, NULL
},
919 { &IID_IFolderView
, &IID_IFolderView
, 0, NULL
},
920 { &IID_ILayoutModifier
, &IID_ILayoutModifier
, 0, NULL
},
921 { &IID_IBrowserSettings
, &IID_IBrowserSettings
, 0, NULL
},
922 { &CLSID_Desktop
, &IID_IUnknown
, 0, NULL
},
923 { &IID_UnknownInterface1
, &IID_UnknownInterface1
, 0, NULL
},
924 { &IID_UnknownInterface3
, &IID_UnknownInterface3
, 0, NULL
},
925 { &IID_UnknownInterface4
, &IID_IUnknown
, 0, NULL
},
926 { &IID_UnknownInterface6
, &IID_UnknownInterface7
, 0, NULL
},
927 { &IID_IBrowserWithActivationNotification
, &IID_IBrowserWithActivationNotification
, 0, NULL
},
929 { &IID_ICommDlgBrowser
, &IID_UnknownInterface11
, 0, NULL
},
930 { &IID_ICommDlgBrowser
, &IID_UnknownInterface12
, 0, NULL
},
931 { &IID_ICommDlgBrowser
, &IID_UnknownInterface20
, 0, NULL
},
932 { &IID_UnknownInterface13
, &IID_IUnknown
, 0, NULL
},
933 { &IID_UnknownInterface13
, &IID_UnknownInterface13
, 0, NULL
},
934 { &IID_UnknownInterface13
, &IID_UnknownInterface18
, 0, NULL
},
935 { &IID_UnknownInterface14
, &IID_UnknownInterface14
, 0, NULL
},
936 { &IID_UnknownInterface15
, &IID_UnknownInterface15
, 0, NULL
},
937 { &IID_UnknownInterface16
, &IID_UnknownInterface16
, 0, NULL
},
938 { &IID_UnknownInterface17
, &IID_UnknownInterface17
, 0, NULL
},
939 { &IID_UnknownInterface17
, &IID_UnknownInterface19
, 0, NULL
},
941 /* Other services requested in Vista, Windows 2008 but not in Windows 7 */
942 { &IID_IBrowserSettings_Vista
, &IID_IBrowserSettings_Vista
, 0, NULL
},
943 { &IID_IFolderTypeModifier
, &IID_IFolderTypeModifier
, 0, NULL
},
944 { &SID_STopLevelBrowser
, &IID_IShellBrowserService_Vista
, 0, NULL
},
945 { &IID_UnknownInterface5
, &IID_UnknownInterface5
, 0, NULL
},
946 { &IID_ICommDlgBrowser
, &IID_ICommDlgBrowser
, 0, cdbimpl
},
947 { &IID_IFileDialogPrivate_Vista
,&IID_IFileDialogPrivate_Vista
, 0, NULL
},
948 { &IID_IFileDialogPrivate_Vista
,&IID_IFileDialog
, 0, NULL
},
949 { &IID_UnknownInterface10
, &IID_IHTMLDocument2
, 0, NULL
},
950 { &SID_SMenuBandParent
, &IID_IOleCommandTarget
, 0, NULL
},
951 { &SID_SMenuBandParent
, &IID_IShellMenu
, 0, NULL
},
952 { &SID_STopLevelBrowser
, &IID_IOleWindow
, 0, NULL
},
953 { &SID_SMenuPopup
, &IID_IOleCommandTarget
, 0, NULL
},
957 ebrowser_instantiate(&peb
);
958 IExplorerBrowser_SetOptions(peb
, EBO_SHOWFRAMES
);
960 hr
= IExplorerBrowser_QueryInterface(peb
, &IID_IObjectWithSite
, (void**)&pow
);
961 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
964 spimpl
->interfaces
= expected
;
966 hr
= IObjectWithSite_SetSite(pow
, (IUnknown
*)&spimpl
->IServiceProvider_iface
);
967 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
970 IObjectWithSite_Release(pow
);
975 skip("Failed to set site.\n");
977 IServiceProvider_Release(&spimpl
->IServiceProvider_iface
);
978 ICommDlgBrowser3_Release(&cdbimpl
->ICommDlgBrowser3_iface
);
979 IExplorerPaneVisibility_Release(&epvimpl
->IExplorerPaneVisibility_iface
);
980 IExplorerBrowser_Destroy(peb
);
981 ref
= IExplorerBrowser_Release(peb
);
982 ok(ref
== 0, "Got ref %d\n", ref
);
987 ShowWindow(hwnd
, TRUE
);
988 ebrowser_initialize(peb
);
989 ebrowser_browse_to_desktop(peb
);
991 for(i
= 0; i
< 10; i
++)
996 ShowWindow(hwnd
, FALSE
);
998 /* ICommDlgBrowser3 */
999 ok(!cdbimpl
->OnDefaultCommand
, "Got %d\n", cdbimpl
->OnDefaultCommand
);
1000 todo_wine
ok(cdbimpl
->OnStateChange
, "Got %d\n", cdbimpl
->OnStateChange
);
1001 ok(cdbimpl
->IncludeObject
, "Got %d\n", cdbimpl
->IncludeObject
);
1002 ok(!cdbimpl
->Notify
, "Got %d\n", cdbimpl
->Notify
);
1003 ok(!cdbimpl
->GetDefaultMenuText
, "Got %d\n", cdbimpl
->GetDefaultMenuText
);
1004 todo_wine
ok(cdbimpl
->GetViewFlags
, "Got %d\n", cdbimpl
->GetViewFlags
);
1005 ok(!cdbimpl
->OnColumnClicked
, "Got %d\n", cdbimpl
->OnColumnClicked
);
1006 ok(!cdbimpl
->GetCurrentFilter
, "Got %d\n", cdbimpl
->GetCurrentFilter
);
1007 todo_wine
ok(cdbimpl
->OnPreviewCreated
, "Got %d\n", cdbimpl
->OnPreviewCreated
);
1009 /* IExplorerPaneVisibility */
1010 ok(epvimpl
->np
, "Got %d\n", epvimpl
->np
);
1011 todo_wine
ok(epvimpl
->cp
, "Got %d\n", epvimpl
->cp
);
1012 todo_wine
ok(epvimpl
->cp_o
, "Got %d\n", epvimpl
->cp_o
);
1013 todo_wine
ok(epvimpl
->cp_v
, "Got %d\n", epvimpl
->cp_v
);
1014 todo_wine
ok(epvimpl
->dp
, "Got %d\n", epvimpl
->dp
);
1015 todo_wine
ok(epvimpl
->pp
, "Got %d\n", epvimpl
->pp
);
1016 ok(!epvimpl
->qp
, "Got %d\n", epvimpl
->qp
);
1017 ok(!epvimpl
->aqp
, "Got %d\n", epvimpl
->aqp
);
1018 ok(!epvimpl
->unk
, "Got %d\n", epvimpl
->unk
);
1022 for(i
= 0; expected
[i
].service
!= NULL
; i
++)
1023 if(!expected
[i
].count
) trace("count %d was 0.\n", i
);
1026 /* Test when IServiceProvider is released. */
1027 IServiceProvider_AddRef(&spimpl
->IServiceProvider_iface
);
1028 ref
= IServiceProvider_Release(&spimpl
->IServiceProvider_iface
);
1029 ok(ref
== 2, "Got ref %d\n", ref
);
1031 hr
= IObjectWithSite_SetSite(pow
, NULL
);
1032 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
1034 IServiceProvider_AddRef(&spimpl
->IServiceProvider_iface
);
1035 ref
= IServiceProvider_Release(&spimpl
->IServiceProvider_iface
);
1036 ok(ref
== 1, "Got ref %d\n", ref
);
1038 hr
= IObjectWithSite_SetSite(pow
, (IUnknown
*)&spimpl
->IServiceProvider_iface
);
1039 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
1041 IServiceProvider_AddRef(&spimpl
->IServiceProvider_iface
);
1042 ref
= IServiceProvider_Release(&spimpl
->IServiceProvider_iface
);
1043 ok(ref
== 2, "Got ref %d\n", ref
);
1045 IExplorerBrowser_Destroy(peb
);
1047 IServiceProvider_AddRef(&spimpl
->IServiceProvider_iface
);
1048 ref
= IServiceProvider_Release(&spimpl
->IServiceProvider_iface
);
1049 ok(ref
== 2, "Got ref %d\n", ref
);
1051 IObjectWithSite_Release(pow
);
1052 ref
= IExplorerBrowser_Release(peb
);
1053 ok(ref
== 0, "Got ref %d\n", ref
);
1055 ref
= IServiceProvider_Release(&spimpl
->IServiceProvider_iface
);
1056 ok(ref
== 0, "Got ref %d\n", ref
);
1058 ref
= ICommDlgBrowser3_Release(&cdbimpl
->ICommDlgBrowser3_iface
);
1059 ok(ref
== 0, "Got ref %d\n", ref
);
1060 ref
= IExplorerPaneVisibility_Release(&epvimpl
->IExplorerPaneVisibility_iface
);
1061 ok(ref
== 0, "Got ref %d\n", ref
);
1064 static void test_basics(void)
1066 IExplorerBrowser
*peb
;
1074 static const WCHAR winetest
[] = {'W','i','n','e','T','e','s','t',0};
1076 ebrowser_instantiate(&peb
);
1077 ebrowser_initialize(peb
);
1080 rc
.left
= 0; rc
.top
= 0; rc
.right
= 0; rc
.bottom
= 0;
1081 hr
= IExplorerBrowser_SetRect(peb
, NULL
, rc
);
1082 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
1084 rc
.left
= 100; rc
.top
= 100; rc
.right
= 10; rc
.bottom
= 10;
1085 hr
= IExplorerBrowser_SetRect(peb
, NULL
, rc
);
1086 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
1088 /* SetRect with DeferWindowPos */
1089 rc
.left
= rc
.top
= 0; rc
.right
= rc
.bottom
= 10;
1090 hdwp
= BeginDeferWindowPos(1);
1091 hr
= IExplorerBrowser_SetRect(peb
, &hdwp
, rc
);
1092 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
1093 lres
= EndDeferWindowPos(hdwp
);
1094 ok(lres
, "EndDeferWindowPos failed.\n");
1097 hr
= IExplorerBrowser_SetRect(peb
, &hdwp
, rc
);
1098 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
1099 ok(hdwp
== NULL
, "got %p\n", hdwp
);
1100 lres
= EndDeferWindowPos(hdwp
);
1101 ok(!lres
, "EndDeferWindowPos succeeded unexpectedly.\n");
1103 /* Test positioning */
1104 rc
.left
= 10; rc
.top
= 20; rc
.right
= 50; rc
.bottom
= 50;
1105 hr
= IExplorerBrowser_SetRect(peb
, NULL
, rc
);
1106 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
1107 hr
= IExplorerBrowser_QueryInterface(peb
, &IID_IShellBrowser
, (void**)&psb
);
1108 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
1113 static const RECT exp_rc
= {11, 21, 49, 49};
1114 static const RECT exp_rc2
= {11, 21, 49, 24};
1116 hr
= IShellBrowser_GetWindow(psb
, &eb_hwnd
);
1117 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
1119 GetClientRect(eb_hwnd
, &eb_rc
);
1120 MapWindowPoints(eb_hwnd
, hwnd
, (POINT
*)&eb_rc
, 2);
1121 ok(EqualRect(&eb_rc
, &exp_rc
), "Got rect (%d, %d) - (%d, %d)\n",
1122 eb_rc
.left
, eb_rc
.top
, eb_rc
.right
, eb_rc
.bottom
);
1124 /* Try resizing with invalid hdwp */
1126 hdwp
= (HDWP
)0xdeadbeef;
1127 hr
= IExplorerBrowser_SetRect(peb
, &hdwp
, rc
);
1128 ok(hr
== E_FAIL
, "Got 0x%08x\n", hr
);
1129 GetClientRect(eb_hwnd
, &eb_rc
);
1130 MapWindowPoints(eb_hwnd
, hwnd
, (POINT
*)&eb_rc
, 2);
1131 ok(EqualRect(&eb_rc
, &exp_rc
), "Got rect (%d, %d) - (%d, %d)\n",
1132 eb_rc
.left
, eb_rc
.top
, eb_rc
.right
, eb_rc
.bottom
);
1135 hr
= IExplorerBrowser_SetRect(peb
, &hdwp
, rc
);
1136 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
1137 GetClientRect(eb_hwnd
, &eb_rc
);
1138 MapWindowPoints(eb_hwnd
, hwnd
, (POINT
*)&eb_rc
, 2);
1139 ok(EqualRect(&eb_rc
, &exp_rc2
), "Got rect (%d, %d) - (%d, %d)\n",
1140 eb_rc
.left
, eb_rc
.top
, eb_rc
.right
, eb_rc
.bottom
);
1142 IShellBrowser_Release(psb
);
1145 IExplorerBrowser_Destroy(peb
);
1146 IExplorerBrowser_Release(peb
);
1148 /* GetOptions/SetOptions*/
1149 ebrowser_instantiate(&peb
);
1152 /* Crashes on Windows 7 */
1153 IExplorerBrowser_GetOptions(peb
, NULL
);
1156 hr
= IExplorerBrowser_GetOptions(peb
, &flags
);
1157 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
1158 ok(flags
== 0, "got (0x%08x)\n", flags
);
1160 /* Settings preserved through Initialize. */
1161 hr
= IExplorerBrowser_SetOptions(peb
, 0xDEADBEEF);
1162 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
1164 ebrowser_initialize(peb
);
1166 hr
= IExplorerBrowser_GetOptions(peb
, &flags
);
1167 ok(flags
== 0xDEADBEEF, "got (0x%08x)\n", flags
);
1168 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
1170 IExplorerBrowser_Destroy(peb
);
1171 IExplorerBrowser_Release(peb
);
1173 ebrowser_instantiate(&peb
);
1174 ebrowser_initialize(peb
);
1176 /* SetFolderSettings */
1177 hr
= IExplorerBrowser_SetFolderSettings(peb
, NULL
);
1178 ok(hr
== E_INVALIDARG
, "got (0x%08x)\n", hr
);
1179 fs
.ViewMode
= 0; fs
.fFlags
= 0;
1180 hr
= IExplorerBrowser_SetFolderSettings(peb
, &fs
);
1181 todo_wine
ok(hr
== E_INVALIDARG
, "got (0x%08x)\n", hr
);
1183 /* SetPropertyBag */
1184 hr
= IExplorerBrowser_SetPropertyBag(peb
, NULL
);
1185 ok(hr
== E_INVALIDARG
, "Got 0x%08x\n", hr
);
1186 hr
= IExplorerBrowser_SetPropertyBag(peb
, winetest
);
1187 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
1189 /* TODO: Test after browsing somewhere. */
1191 IExplorerBrowser_Destroy(peb
);
1192 lres
= IExplorerBrowser_Release(peb
);
1193 ok(lres
== 0, "Got %d\n", lres
);
1196 static void test_Advise(void)
1198 IExplorerBrowser
*peb
;
1199 IExplorerBrowserEvents
*pebe
;
1204 /* Set up our IExplorerBrowserEvents implementation */
1205 ebev
.IExplorerBrowserEvents_iface
.lpVtbl
= &ebevents
;
1206 pebe
= &ebev
.IExplorerBrowserEvents_iface
;
1208 ebrowser_instantiate(&peb
);
1212 /* Crashes on Windows 7 */
1213 IExplorerBrowser_Advise(peb
, pebe
, NULL
);
1214 IExplorerBrowser_Advise(peb
, NULL
, &cookies
[0]);
1217 /* Using Unadvise with a cookie that has yet to be given out
1218 * results in E_INVALIDARG */
1219 hr
= IExplorerBrowser_Unadvise(peb
, 11);
1220 ok(hr
== E_INVALIDARG
, "got (0x%08x)\n", hr
);
1222 /* Add some before initialization */
1223 for(i
= 0; i
< 5; i
++)
1225 hr
= IExplorerBrowser_Advise(peb
, pebe
, &cookies
[i
]);
1226 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
1229 ebrowser_initialize(peb
);
1231 /* Add some after initialization */
1232 for(i
= 5; i
< 10; i
++)
1234 hr
= IExplorerBrowser_Advise(peb
, pebe
, &cookies
[i
]);
1235 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
1238 ok(ebev
.ref
== 10, "Got %d\n", ebev
.ref
);
1241 ebrowser_browse_to_desktop(peb
);
1243 ok(ebev
.completed
== 10, "Got %d\n", ebev
.completed
);
1245 /* Remove a bunch somewhere in the middle */
1246 for(i
= 4; i
< 8; i
++)
1248 hr
= IExplorerBrowser_Unadvise(peb
, cookies
[i
]);
1249 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
1253 ebrowser_browse_to_desktop(peb
);
1255 ok(ebev
.completed
== 6, "Got %d\n", ebev
.completed
);
1259 /* Using unadvise with a previously unadvised cookie results
1261 IExplorerBrowser_Unadvise(peb
, cookies
[5]);
1264 /* Remove the rest. */
1265 for(i
= 0; i
< 10; i
++)
1269 hr
= IExplorerBrowser_Unadvise(peb
, cookies
[i
]);
1270 ok(hr
== S_OK
, "%d: got (0x%08x)\n", i
, hr
);
1274 ok(ebev
.ref
== 0, "Got %d\n", ebev
.ref
);
1277 ebrowser_browse_to_desktop(peb
);
1279 ok(ebev
.completed
== 0, "Got %d\n", ebev
.completed
);
1281 /* ::Destroy implies ::Unadvise. */
1282 hr
= IExplorerBrowser_Advise(peb
, pebe
, &cookies
[0]);
1283 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
1284 ok(ebev
.ref
== 1, "Got %d\n", ebev
.ref
);
1286 hr
= IExplorerBrowser_Destroy(peb
);
1287 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
1288 ok(ebev
.ref
== 0, "Got %d\n", ebev
.ref
);
1290 ref
= IExplorerBrowser_Release(peb
);
1291 ok(!ref
, "Got %d\n", ref
);
1294 /* Based on PathAddBackslashW from dlls/shlwapi/path.c */
1295 static LPWSTR
myPathAddBackslashW( LPWSTR lpszPath
)
1299 if (!lpszPath
|| (iLen
= lstrlenW(lpszPath
)) >= MAX_PATH
)
1305 if (lpszPath
[-1] != '\\')
1314 static void test_browse_pidl_(IExplorerBrowser
*peb
, IExplorerBrowserEventsImpl
*ebev
,
1315 LPITEMIDLIST pidl
, UINT uFlags
,
1316 HRESULT hr_exp
, UINT pending
, UINT created
, UINT failed
, UINT completed
,
1317 const char *file
, int line
)
1320 ebev
->completed
= ebev
->created
= ebev
->pending
= ebev
->failed
= 0;
1322 hr
= IExplorerBrowser_BrowseToIDList(peb
, pidl
, uFlags
);
1323 ok_(file
, line
) (hr
== hr_exp
, "BrowseToIDList returned 0x%08x\n", hr
);
1327 (ebev
->pending
== pending
&& ebev
->created
== created
&&
1328 ebev
->failed
== failed
&& ebev
->completed
== completed
,
1329 "Events occurred: %d, %d, %d, %d\n",
1330 ebev
->pending
, ebev
->created
, ebev
->failed
, ebev
->completed
);
1332 #define test_browse_pidl(peb, ebev, pidl, uFlags, hr, p, cr, f, co) \
1333 test_browse_pidl_(peb, ebev, pidl, uFlags, hr, p, cr, f, co, __FILE__, __LINE__)
1335 static void test_browse_pidl_sb_(IExplorerBrowser
*peb
, IExplorerBrowserEventsImpl
*ebev
,
1336 LPITEMIDLIST pidl
, UINT uFlags
,
1337 HRESULT hr_exp
, UINT pending
, UINT created
, UINT failed
, UINT completed
,
1338 const char *file
, int line
)
1343 hr
= IExplorerBrowser_QueryInterface(peb
, &IID_IShellBrowser
, (void**)&psb
);
1344 ok_(file
, line
) (hr
== S_OK
, "QueryInterface returned 0x%08x\n", hr
);
1347 ebev
->completed
= ebev
->created
= ebev
->pending
= ebev
->failed
= 0;
1349 hr
= IShellBrowser_BrowseObject(psb
, pidl
, uFlags
);
1350 ok_(file
, line
) (hr
== hr_exp
, "BrowseObject returned 0x%08x\n", hr
);
1354 (ebev
->pending
== pending
&& ebev
->created
== created
&&
1355 ebev
->failed
== failed
&& ebev
->completed
== completed
,
1356 "Events occurred: %d, %d, %d, %d\n",
1357 ebev
->pending
, ebev
->created
, ebev
->failed
, ebev
->completed
);
1359 IShellBrowser_Release(psb
);
1362 #define test_browse_pidl_sb(peb, ebev, pidl, uFlags, hr, p, cr, f, co) \
1363 test_browse_pidl_sb_(peb, ebev, pidl, uFlags, hr, p, cr, f, co, __FILE__, __LINE__)
1365 static void test_navigation(void)
1367 IExplorerBrowser
*peb
, *peb2
;
1371 LPITEMIDLIST pidl_current
, pidl_child
;
1372 DWORD cookie
, cookie2
;
1375 WCHAR current_path
[MAX_PATH
];
1376 WCHAR child_path
[MAX_PATH
];
1377 static const WCHAR testfolderW
[] =
1378 {'w','i','n','e','t','e','s','t','f','o','l','d','e','r','\0'};
1380 ok(pSHParseDisplayName
!= NULL
, "pSHParseDisplayName unexpectedly missing.\n");
1381 ok(pSHCreateShellItem
!= NULL
, "pSHCreateShellItem unexpectedly missing.\n");
1383 GetCurrentDirectoryW(MAX_PATH
, current_path
);
1384 if(!lstrlenW(current_path
))
1386 skip("Failed to create test-directory.\n");
1390 lstrcpyW(child_path
, current_path
);
1391 myPathAddBackslashW(child_path
);
1392 lstrcatW(child_path
, testfolderW
);
1394 CreateDirectoryW(child_path
, NULL
);
1396 pSHParseDisplayName(current_path
, NULL
, &pidl_current
, 0, NULL
);
1397 pSHParseDisplayName(child_path
, NULL
, &pidl_child
, 0, NULL
);
1399 ebrowser_instantiate(&peb
);
1400 ebrowser_initialize(peb
);
1402 ebrowser_instantiate(&peb2
);
1403 ebrowser_initialize(peb2
);
1405 /* Set up our IExplorerBrowserEvents implementation */
1406 ebev
.IExplorerBrowserEvents_iface
.lpVtbl
= &ebevents
;
1408 IExplorerBrowser_Advise(peb
, &ebev
.IExplorerBrowserEvents_iface
, &cookie
);
1409 IExplorerBrowser_Advise(peb2
, &ebev
.IExplorerBrowserEvents_iface
, &cookie2
);
1411 /* These should all fail */
1412 test_browse_pidl(peb
, &ebev
, 0, SBSP_ABSOLUTE
| SBSP_RELATIVE
, E_FAIL
, 0, 0, 0, 0);
1413 test_browse_pidl_sb(peb2
, &ebev
, 0, SBSP_ABSOLUTE
| SBSP_RELATIVE
, E_FAIL
, 0, 0, 0, 0);
1414 test_browse_pidl(peb
, &ebev
, 0, SBSP_ABSOLUTE
, E_INVALIDARG
, 0, 0, 0, 0);
1415 test_browse_pidl_sb(peb2
, &ebev
, 0, SBSP_ABSOLUTE
, E_INVALIDARG
, 0, 0, 0, 0);
1416 test_browse_pidl(peb
, &ebev
, 0, SBSP_RELATIVE
, E_FAIL
, 0, 0, 0, 0);
1417 test_browse_pidl_sb(peb2
, &ebev
, 0, SBSP_RELATIVE
, E_FAIL
, 0, 0, 0, 0);
1418 test_browse_pidl(peb
, &ebev
, 0, SBSP_PARENT
, E_FAIL
, 0, 0, 0, 0);
1419 test_browse_pidl_sb(peb2
, &ebev
, 0, SBSP_PARENT
, E_FAIL
, 0, 0, 0, 0);
1420 test_browse_pidl(peb
, &ebev
, 0, SBSP_NAVIGATEFORWARD
, E_FAIL
, 0, 0, 0, 0);
1421 test_browse_pidl_sb(peb2
, &ebev
, 0, SBSP_NAVIGATEFORWARD
, E_FAIL
, 0, 0, 0, 0);
1422 test_browse_pidl(peb
, &ebev
, 0, SBSP_NAVIGATEBACK
, E_FAIL
, 0, 0, 0, 0);
1423 test_browse_pidl_sb(peb2
, &ebev
, 0, SBSP_NAVIGATEBACK
, E_FAIL
, 0, 0, 0, 0);
1425 /* "The first browse is synchronous" */
1426 test_browse_pidl(peb
, &ebev
, pidl_child
, SBSP_ABSOLUTE
, S_OK
, 1, 1, 0, 1);
1427 test_browse_pidl_sb(peb2
, &ebev
, pidl_child
, SBSP_ABSOLUTE
, S_OK
, 1, 1, 0, 1);
1429 /* Navigate empty history */
1430 test_browse_pidl(peb
, &ebev
, 0, SBSP_NAVIGATEFORWARD
, S_OK
, 0, 0, 0, 0);
1431 test_browse_pidl_sb(peb2
, &ebev
, 0, SBSP_NAVIGATEFORWARD
, S_OK
, 0, 0, 0, 0);
1432 test_browse_pidl(peb
, &ebev
, 0, SBSP_NAVIGATEBACK
, S_OK
, 0, 0, 0, 0);
1433 test_browse_pidl_sb(peb2
, &ebev
, 0, SBSP_NAVIGATEBACK
, S_OK
, 0, 0, 0, 0);
1435 /* Navigate history */
1436 test_browse_pidl(peb
, &ebev
, 0, SBSP_PARENT
, S_OK
, 1, 1, 0, 1);
1437 test_browse_pidl_sb(peb2
, &ebev
, 0, SBSP_PARENT
, S_OK
, 1, 1, 0, 1);
1438 test_browse_pidl(peb
, &ebev
, 0, SBSP_NAVIGATEBACK
, S_OK
, 1, 1, 0, 1);
1439 test_browse_pidl_sb(peb2
, &ebev
, 0, SBSP_NAVIGATEBACK
, S_OK
, 1, 1, 0, 1);
1440 test_browse_pidl(peb
, &ebev
, 0, SBSP_NAVIGATEFORWARD
, S_OK
, 1, 1, 0, 1);
1441 test_browse_pidl_sb(peb2
, &ebev
, 0, SBSP_NAVIGATEFORWARD
, S_OK
, 1, 1, 0, 1);
1442 test_browse_pidl(peb
, &ebev
, 0, SBSP_ABSOLUTE
, S_OK
, 0, 0, 0, 0);
1443 test_browse_pidl_sb(peb2
, &ebev
, 0, SBSP_ABSOLUTE
, S_OK
, 0, 0, 0, 0);
1445 /* Relative navigation */
1446 test_browse_pidl(peb
, &ebev
, pidl_current
, SBSP_ABSOLUTE
, S_OK
, 1, 0, 0, 1);
1447 test_browse_pidl_sb(peb2
, &ebev
, pidl_current
, SBSP_ABSOLUTE
, S_OK
, 1, 0, 0, 1);
1449 hr
= IExplorerBrowser_GetCurrentView(peb
, &IID_IFolderView
, (void**)&pfv
);
1450 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
1453 LPITEMIDLIST pidl_relative
;
1455 hr
= IFolderView_GetFolder(pfv
, &IID_IShellFolder
, (void**)&psf
);
1456 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
1457 hr
= IShellFolder_ParseDisplayName(psf
, NULL
, NULL
, (LPWSTR
)testfolderW
,
1458 NULL
, &pidl_relative
, NULL
);
1459 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
1461 /* Browsing to another location here before using the
1462 * pidl_relative would make ExplorerBrowser in Windows 7 show a
1463 * not-available dialog. Also, passing a relative pidl without
1464 * specifying SBSP_RELATIVE makes it look for the pidl on the
1468 test_browse_pidl(peb
, &ebev
, pidl_relative
, SBSP_RELATIVE
, S_OK
, 1, 1, 0, 1);
1469 test_browse_pidl_sb(peb2
, &ebev
, pidl_relative
, SBSP_RELATIVE
, S_OK
, 1, 1, 0, 1);
1471 ILFree(pidl_relative
);
1472 /* IShellFolder_Release(psf); */
1473 IFolderView_Release(pfv
);
1477 test_browse_pidl(peb
, &ebev
, NULL
, SBSP_ABSOLUTE
, S_OK
, 0, 0, 0, 0);
1478 test_browse_pidl_sb(peb2
, &ebev
, NULL
, SBSP_ABSOLUTE
, S_OK
, 0, 0, 0, 0);
1479 test_browse_pidl(peb
, &ebev
, NULL
, SBSP_DEFBROWSER
, S_OK
, 0, 0, 0, 0);
1480 test_browse_pidl_sb(peb2
, &ebev
, NULL
, SBSP_DEFBROWSER
, S_OK
, 0, 0, 0, 0);
1481 test_browse_pidl(peb
, &ebev
, pidl_current
, SBSP_SAMEBROWSER
, S_OK
, 1, 1, 0, 1);
1482 test_browse_pidl_sb(peb2
, &ebev
, pidl_current
, SBSP_SAMEBROWSER
, S_OK
, 1, 1, 0, 1);
1483 test_browse_pidl(peb
, &ebev
, pidl_current
, SBSP_SAMEBROWSER
, S_OK
, 1, 0, 0, 1);
1484 test_browse_pidl_sb(peb2
, &ebev
, pidl_current
, SBSP_SAMEBROWSER
, S_OK
, 1, 0, 0, 1);
1486 test_browse_pidl(peb
, &ebev
, pidl_current
, SBSP_EXPLOREMODE
, E_INVALIDARG
, 0, 0, 0, 0);
1487 test_browse_pidl_sb(peb2
, &ebev
, pidl_current
, SBSP_EXPLOREMODE
, E_INVALIDARG
, 0, 0, 0, 0);
1488 test_browse_pidl(peb
, &ebev
, pidl_current
, SBSP_OPENMODE
, S_OK
, 1, 0, 0, 1);
1489 test_browse_pidl_sb(peb2
, &ebev
, pidl_current
, SBSP_OPENMODE
, S_OK
, 1, 0, 0, 1);
1491 /* SBSP_NEWBROWSER will return E_INVALIDARG, claims MSDN, but in
1492 * reality it works as one would expect (Windows 7 only?).
1496 IExplorerBrowser_BrowseToIDList(peb
, NULL
, SBSP_NEWBROWSER
);
1499 hr
= IExplorerBrowser_Unadvise(peb
, cookie
);
1500 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
1501 IExplorerBrowser_Destroy(peb
);
1503 hr
= IExplorerBrowser_Unadvise(peb2
, cookie2
);
1504 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
1505 IExplorerBrowser_Destroy(peb2
);
1508 /* Attempt browsing after destroyed */
1509 test_browse_pidl(peb
, &ebev
, pidl_child
, SBSP_ABSOLUTE
, HRESULT_FROM_WIN32(ERROR_BUSY
), 0, 0, 0, 0);
1510 test_browse_pidl_sb(peb2
, &ebev
, pidl_child
, SBSP_ABSOLUTE
, HRESULT_FROM_WIN32(ERROR_BUSY
), 0, 0, 0, 0);
1512 lres
= IExplorerBrowser_Release(peb
);
1513 ok(lres
== 0, "Got lres %d\n", lres
);
1514 lres
= IExplorerBrowser_Release(peb2
);
1515 ok(lres
== 0, "Got lres %d\n", lres
);
1517 /******************************************/
1518 /* Test some options that affect browsing */
1520 ebrowser_instantiate(&peb
);
1521 hr
= IExplorerBrowser_Advise(peb
, &ebev
.IExplorerBrowserEvents_iface
, &cookie
);
1522 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
1523 hr
= IExplorerBrowser_SetOptions(peb
, EBO_NAVIGATEONCE
);
1524 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
1525 ebrowser_initialize(peb
);
1527 test_browse_pidl(peb
, &ebev
, pidl_current
, 0, S_OK
, 1, 1, 0, 1);
1528 test_browse_pidl(peb
, &ebev
, pidl_current
, 0, E_FAIL
, 0, 0, 0, 0);
1530 hr
= IExplorerBrowser_SetOptions(peb
, 0);
1531 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
1533 test_browse_pidl(peb
, &ebev
, pidl_current
, 0, S_OK
, 1, 0, 0, 1);
1534 test_browse_pidl(peb
, &ebev
, pidl_current
, 0, S_OK
, 1, 0, 0, 1);
1536 /* Difference in behavior lies where? */
1537 hr
= IExplorerBrowser_SetOptions(peb
, EBO_ALWAYSNAVIGATE
);
1538 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
1540 test_browse_pidl(peb
, &ebev
, pidl_current
, 0, S_OK
, 1, 0, 0, 1);
1541 test_browse_pidl(peb
, &ebev
, pidl_current
, 0, S_OK
, 1, 0, 0, 1);
1543 hr
= IExplorerBrowser_Unadvise(peb
, cookie
);
1544 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
1546 IExplorerBrowser_Destroy(peb
);
1547 lres
= IExplorerBrowser_Release(peb
);
1548 ok(lres
== 0, "Got lres %d\n", lres
);
1550 /* BrowseToObject tests */
1551 ebrowser_instantiate(&peb
);
1552 ebrowser_initialize(peb
);
1554 /* Browse to the desktop by passing an IShellFolder */
1555 hr
= SHGetDesktopFolder(&psf
);
1556 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
1559 hr
= IExplorerBrowser_BrowseToObject(peb
, (IUnknown
*)psf
, SBSP_DEFBROWSER
);
1560 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
1561 if(hr
== S_OK
) process_msgs();
1563 IShellFolder_Release(psf
);
1566 /* Browse to the current directory by passing a ShellItem */
1567 hr
= pSHCreateShellItem(NULL
, NULL
, pidl_current
, &psi
);
1568 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
1571 hr
= IExplorerBrowser_BrowseToObject(peb
, (IUnknown
*)psi
, SBSP_DEFBROWSER
);
1572 ok(hr
== S_OK
, "got (0x%08x)\n", hr
);
1575 IShellItem_Release(psi
);
1578 IExplorerBrowser_Destroy(peb
);
1579 lres
= IExplorerBrowser_Release(peb
);
1580 ok(lres
== 0, "Got lres %d\n", lres
);
1583 RemoveDirectoryW(child_path
);
1584 ILFree(pidl_current
);
1588 static void test_GetCurrentView(void)
1590 IExplorerBrowser
*peb
;
1594 /* GetCurrentView */
1595 ebrowser_instantiate(&peb
);
1599 /* Crashes under Windows 7 */
1600 IExplorerBrowser_GetCurrentView(peb
, NULL
, NULL
);
1602 hr
= IExplorerBrowser_GetCurrentView(peb
, NULL
, (void**)&punk
);
1603 ok(hr
== E_FAIL
, "Got 0x%08x\n", hr
);
1605 #define test_gcv(iid, exp) \
1607 hr = IExplorerBrowser_GetCurrentView(peb, &iid, (void**)&punk); \
1608 ok(hr == exp, "(%s:)Expected (0x%08x), got: (0x%08x)\n", \
1610 if(SUCCEEDED(hr)) IUnknown_Release(punk); \
1613 test_gcv(IID_IUnknown
, E_FAIL
);
1614 test_gcv(IID_IUnknown
, E_FAIL
);
1615 test_gcv(IID_IShellView
, E_FAIL
);
1616 test_gcv(IID_IShellView2
, E_FAIL
);
1617 test_gcv(IID_IFolderView
, E_FAIL
);
1618 test_gcv(IID_IPersistFolder
, E_FAIL
);
1619 test_gcv(IID_IPersistFolder2
, E_FAIL
);
1620 test_gcv(IID_ICommDlgBrowser
, E_FAIL
);
1621 test_gcv(IID_ICommDlgBrowser2
, E_FAIL
);
1622 test_gcv(IID_ICommDlgBrowser3
, E_FAIL
);
1624 ebrowser_initialize(peb
);
1625 ebrowser_browse_to_desktop(peb
);
1627 test_gcv(IID_IUnknown
, S_OK
);
1628 test_gcv(IID_IUnknown
, S_OK
);
1629 test_gcv(IID_IShellView
, S_OK
);
1630 test_gcv(IID_IShellView2
, S_OK
);
1631 test_gcv(IID_IFolderView
, S_OK
);
1632 todo_wine
test_gcv(IID_IPersistFolder
, S_OK
);
1633 test_gcv(IID_IPersistFolder2
, E_NOINTERFACE
);
1634 test_gcv(IID_ICommDlgBrowser
, E_NOINTERFACE
);
1635 test_gcv(IID_ICommDlgBrowser2
, E_NOINTERFACE
);
1636 test_gcv(IID_ICommDlgBrowser3
, E_NOINTERFACE
);
1640 IExplorerBrowser_Destroy(peb
);
1641 IExplorerBrowser_Release(peb
);
1644 static void test_InputObject(void)
1646 IExplorerBrowser
*peb
;
1652 WPARAM supported_key_accels_mode1
[] = {
1653 VK_BACK
, VK_TAB
, VK_RETURN
, VK_PRIOR
, VK_NEXT
, VK_END
, VK_HOME
,
1654 VK_LEFT
, VK_UP
, VK_RIGHT
, VK_DOWN
, VK_DELETE
, VK_F1
, VK_F2
,
1655 VK_F5
, VK_F6
, VK_F10
, 0 };
1656 WPARAM supported_key_accels_mode2
[] = {
1657 VK_RETURN
, VK_PRIOR
, VK_NEXT
, VK_END
, VK_HOME
,
1658 VK_LEFT
, VK_UP
, VK_RIGHT
, VK_DOWN
, VK_DELETE
, VK_F1
, VK_F2
,
1669 ebrowser_instantiate(&peb
);
1670 hr
= IExplorerBrowser_QueryInterface(peb
, &IID_IInputObject
, (void**)&pio
);
1671 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
1674 win_skip("IInputObject not supported.\n");
1678 /* Before initializing */
1679 hr
= IInputObject_TranslateAcceleratorIO(pio
, &msg_a
);
1680 todo_wine
ok(hr
== E_FAIL
, "Got 0x%08x\n", hr
);
1682 hr
= IInputObject_HasFocusIO(pio
);
1683 todo_wine
ok(hr
== E_FAIL
, "Got 0x%08x\n", hr
);
1685 hr
= IInputObject_UIActivateIO(pio
, TRUE
, &msg_a
);
1686 todo_wine
ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
1688 hr
= IInputObject_HasFocusIO(pio
);
1689 todo_wine
ok(hr
== E_FAIL
, "Got 0x%08x\n", hr
);
1691 hr
= IInputObject_TranslateAcceleratorIO(pio
, &msg_a
);
1692 todo_wine
ok(hr
== E_FAIL
, "Got 0x%08x\n", hr
);
1694 rc
.left
= 0; rc
.top
= 0; rc
.right
= 100; rc
.bottom
= 100;
1695 hr
= IExplorerBrowser_Initialize(peb
, hwnd
, &rc
, NULL
);
1696 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
1698 hr
= IInputObject_HasFocusIO(pio
);
1699 todo_wine
ok(hr
== E_FAIL
, "Got 0x%08x\n", hr
);
1701 hr
= IInputObject_TranslateAcceleratorIO(pio
, &msg_a
);
1702 todo_wine
ok(hr
== E_FAIL
, "Got 0x%08x\n", hr
);
1704 /* Browse to the desktop */
1705 SHGetDesktopFolder(&psf
);
1706 hr
= IExplorerBrowser_BrowseToObject(peb
, (IUnknown
*)psf
, SBSP_DEFBROWSER
);
1707 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
1708 IShellFolder_Release(psf
);
1710 hr
= IInputObject_UIActivateIO(pio
, TRUE
, &msg_a
);
1711 todo_wine
ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
1713 hr
= IInputObject_HasFocusIO(pio
);
1714 todo_wine
ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
1716 hr
= IInputObject_UIActivateIO(pio
, FALSE
, &msg_a
);
1717 todo_wine
ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
1719 hr
= IInputObject_HasFocusIO(pio
);
1720 todo_wine
ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
1722 hr
= IInputObject_TranslateAcceleratorIO(pio
, &msg_a
);
1724 key_accels
= supported_key_accels_mode1
;
1726 key_accels
= supported_key_accels_mode2
;
1728 for(i
= 0; i
< 0x100; i
++)
1732 for(j
= 0; key_accels
[j
] != 0; j
++)
1733 if(key_accels
[j
] == i
)
1741 hr
= IInputObject_TranslateAcceleratorIO(pio
, &msg_a
);
1742 todo_wine
ok(hr
== (found
? S_OK
: S_FALSE
), "Got 0x%08x (%04x)\n", hr
, i
);
1744 Sleep(1000); /* Needed for w2k8 (64bit) */
1749 IInputObject_Release(pio
);
1750 IExplorerBrowser_Destroy(peb
);
1751 IExplorerBrowser_Release(peb
);
1754 static BOOL
test_instantiate_control(void)
1756 IExplorerBrowser
*peb
;
1759 hr
= ebrowser_instantiate(&peb
);
1760 ok(hr
== S_OK
|| hr
== REGDB_E_CLASSNOTREG
, "Got (0x%08x)\n", hr
);
1764 IExplorerBrowser_Release(peb
);
1768 static void setup_window(void)
1771 static const WCHAR ebtestW
[] = {'e','b','t','e','s','t',0};
1773 ZeroMemory(&wc
, sizeof(WNDCLASSW
));
1774 wc
.lpfnWndProc
= DefWindowProcW
;
1775 wc
.lpszClassName
= ebtestW
;
1776 RegisterClassW(&wc
);
1777 hwnd
= CreateWindowExW(0, ebtestW
, NULL
, 0,
1780 ok(hwnd
!= NULL
, "Failed to create window for tests.\n");
1783 START_TEST(ebrowser
)
1785 OleInitialize(NULL
);
1787 if(!test_instantiate_control())
1789 win_skip("No ExplorerBrowser control..\n");
1795 init_function_pointers();
1797 test_QueryInterface();
1799 test_initialization();
1803 test_GetCurrentView();
1807 DestroyWindow(hwnd
);