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"
36 static HRESULT (WINAPI
*pSHCreateShellItem
)(LPCITEMIDLIST
,IShellFolder
*,LPCITEMIDLIST
,IShellItem
**);
38 static void init_function_pointers(void)
42 hmod
= GetModuleHandleA("shell32.dll");
43 pSHCreateShellItem
= (void*)GetProcAddress(hmod
, "SHCreateShellItem");
46 /*********************************************************************
49 static HRESULT
ebrowser_instantiate(IExplorerBrowser
**peb
)
51 return CoCreateInstance(&CLSID_ExplorerBrowser
, NULL
, CLSCTX_INPROC_SERVER
,
52 &IID_IExplorerBrowser
, (void**)peb
);
55 static HRESULT
ebrowser_initialize(IExplorerBrowser
*peb
)
58 SetRect(&rc
, 0, 0, 500, 500);
59 return IExplorerBrowser_Initialize(peb
, hwnd
, &rc
, NULL
);
62 static HRESULT
ebrowser_browse_to_desktop(IExplorerBrowser
*peb
)
64 LPITEMIDLIST pidl_desktop
;
66 SHGetSpecialFolderLocation (hwnd
, CSIDL_DESKTOP
, &pidl_desktop
);
67 hr
= IExplorerBrowser_BrowseToIDList(peb
, pidl_desktop
, 0);
72 /* Process some messages */
73 static void process_msgs(void)
76 while(PeekMessageA( &msg
, NULL
, 0, 0, PM_REMOVE
))
78 TranslateMessage(&msg
);
79 DispatchMessageA(&msg
);
83 /*********************************************************************
84 * IExplorerBrowserEvents implementation
87 IExplorerBrowserEvents IExplorerBrowserEvents_iface
;
89 UINT pending
, created
, completed
, failed
;
90 } IExplorerBrowserEventsImpl
;
92 static IExplorerBrowserEventsImpl ebev
;
94 static inline IExplorerBrowserEventsImpl
*impl_from_IExplorerBrowserEvents(IExplorerBrowserEvents
*iface
)
96 return CONTAINING_RECORD(iface
, IExplorerBrowserEventsImpl
, IExplorerBrowserEvents_iface
);
99 static HRESULT WINAPI
IExplorerBrowserEvents_fnQueryInterface(IExplorerBrowserEvents
*iface
,
100 REFIID riid
, void **ppvObj
)
102 ok(0, "Never called.\n");
103 return E_NOINTERFACE
;
106 static ULONG WINAPI
IExplorerBrowserEvents_fnAddRef(IExplorerBrowserEvents
*iface
)
108 IExplorerBrowserEventsImpl
*This
= impl_from_IExplorerBrowserEvents(iface
);
109 return InterlockedIncrement(&This
->ref
);
112 static ULONG WINAPI
IExplorerBrowserEvents_fnRelease(IExplorerBrowserEvents
*iface
)
114 IExplorerBrowserEventsImpl
*This
= impl_from_IExplorerBrowserEvents(iface
);
115 return InterlockedDecrement(&This
->ref
);
118 static HRESULT WINAPI
IExplorerBrowserEvents_fnOnNavigationPending(IExplorerBrowserEvents
*iface
,
119 PCIDLIST_ABSOLUTE pidlFolder
)
121 IExplorerBrowserEventsImpl
*This
= impl_from_IExplorerBrowserEvents(iface
);
126 static HRESULT WINAPI
IExplorerBrowserEvents_fnOnNavigationComplete(IExplorerBrowserEvents
*iface
,
127 PCIDLIST_ABSOLUTE pidlFolder
)
129 IExplorerBrowserEventsImpl
*This
= impl_from_IExplorerBrowserEvents(iface
);
133 static HRESULT WINAPI
IExplorerBrowserEvents_fnOnNavigationFailed(IExplorerBrowserEvents
*iface
,
134 PCIDLIST_ABSOLUTE pidlFolder
)
136 IExplorerBrowserEventsImpl
*This
= impl_from_IExplorerBrowserEvents(iface
);
140 static HRESULT WINAPI
IExplorerBrowserEvents_fnOnViewCreated(IExplorerBrowserEvents
*iface
,
143 IExplorerBrowserEventsImpl
*This
= impl_from_IExplorerBrowserEvents(iface
);
148 static const IExplorerBrowserEventsVtbl ebevents
=
150 IExplorerBrowserEvents_fnQueryInterface
,
151 IExplorerBrowserEvents_fnAddRef
,
152 IExplorerBrowserEvents_fnRelease
,
153 IExplorerBrowserEvents_fnOnNavigationPending
,
154 IExplorerBrowserEvents_fnOnViewCreated
,
155 IExplorerBrowserEvents_fnOnNavigationComplete
,
156 IExplorerBrowserEvents_fnOnNavigationFailed
159 /*********************************************************************
160 * IExplorerPaneVisibility implementation
164 IExplorerPaneVisibility IExplorerPaneVisibility_iface
;
167 LONG np
, cp
, cp_o
, cp_v
, dp
, pp
, qp
, aqp
, unk
; /* The panes */
168 } IExplorerPaneVisibilityImpl
;
170 static inline IExplorerPaneVisibilityImpl
*impl_from_IExplorerPaneVisibility(IExplorerPaneVisibility
*iface
)
172 return CONTAINING_RECORD(iface
, IExplorerPaneVisibilityImpl
, IExplorerPaneVisibility_iface
);
175 static HRESULT WINAPI
IExplorerPaneVisibility_fnQueryInterface(IExplorerPaneVisibility
*iface
,
176 REFIID riid
, LPVOID
*ppvObj
)
178 ok(0, "unexpected, %s\n", wine_dbgstr_guid(riid
));
180 return E_NOINTERFACE
;
183 static ULONG WINAPI
IExplorerPaneVisibility_fnAddRef(IExplorerPaneVisibility
*iface
)
185 IExplorerPaneVisibilityImpl
*This
= impl_from_IExplorerPaneVisibility(iface
);
186 return InterlockedIncrement(&This
->ref
);
189 static ULONG WINAPI
IExplorerPaneVisibility_fnRelease(IExplorerPaneVisibility
*iface
)
191 IExplorerPaneVisibilityImpl
*This
= impl_from_IExplorerPaneVisibility(iface
);
192 ULONG ref
= InterlockedDecrement(&This
->ref
);
200 static HRESULT WINAPI
IExplorerPaneVisibility_fnGetPaneState(IExplorerPaneVisibility
*iface
,
202 EXPLORERPANESTATE
*peps
)
204 IExplorerPaneVisibilityImpl
*This
= impl_from_IExplorerPaneVisibility(iface
);
207 ok(ep
!= NULL
, "ep is NULL.\n");
208 ok(peps
!= NULL
, "peps is NULL.\n");
209 ok(*peps
== 0, "got %ld\n", *peps
);
212 if(IsEqualGUID(&EP_NavPane
, ep
)) This
->np
++;
213 else if(IsEqualGUID(&EP_Commands
, ep
)) This
->cp
++;
214 else if(IsEqualGUID(&EP_Commands_Organize
, ep
)) This
->cp_o
++;
215 else if(IsEqualGUID(&EP_Commands_View
, ep
)) This
->cp_v
++;
216 else if(IsEqualGUID(&EP_DetailsPane
, ep
)) This
->dp
++;
217 else if(IsEqualGUID(&EP_PreviewPane
, ep
)) This
->pp
++;
218 else if(IsEqualGUID(&EP_QueryPane
, ep
)) This
->qp
++;
219 else if(IsEqualGUID(&EP_AdvQueryPane
, ep
)) This
->aqp
++;
222 trace("Unknown explorer pane: %s\n", wine_dbgstr_guid(ep
));
229 static const IExplorerPaneVisibilityVtbl epvvt
=
231 IExplorerPaneVisibility_fnQueryInterface
,
232 IExplorerPaneVisibility_fnAddRef
,
233 IExplorerPaneVisibility_fnRelease
,
234 IExplorerPaneVisibility_fnGetPaneState
237 static IExplorerPaneVisibilityImpl
*create_explorerpanevisibility(void)
239 IExplorerPaneVisibilityImpl
*epv
;
241 epv
= calloc(1, sizeof(*epv
));
242 epv
->IExplorerPaneVisibility_iface
.lpVtbl
= &epvvt
;
248 /*********************************************************************
249 * ICommDlgBrowser3 implementation
253 ICommDlgBrowser3 ICommDlgBrowser3_iface
;
255 UINT OnDefaultCommand
, OnStateChange
, IncludeObject
;
256 UINT Notify
, GetDefaultMenuText
, GetViewFlags
;
257 UINT OnColumnClicked
, GetCurrentFilter
, OnPreviewCreated
;
258 } ICommDlgBrowser3Impl
;
260 static inline ICommDlgBrowser3Impl
*impl_from_ICommDlgBrowser3(ICommDlgBrowser3
*iface
)
262 return CONTAINING_RECORD(iface
, ICommDlgBrowser3Impl
, ICommDlgBrowser3_iface
);
265 static HRESULT WINAPI
ICommDlgBrowser3_fnQueryInterface(ICommDlgBrowser3
*iface
, REFIID riid
, LPVOID
*ppvObj
)
267 ok(0, "unexpected %s\n", wine_dbgstr_guid(riid
));
269 return E_NOINTERFACE
;
272 static ULONG WINAPI
ICommDlgBrowser3_fnAddRef(ICommDlgBrowser3
*iface
)
274 ICommDlgBrowser3Impl
*This
= impl_from_ICommDlgBrowser3(iface
);
275 return InterlockedIncrement(&This
->ref
);
278 static ULONG WINAPI
ICommDlgBrowser3_fnRelease(ICommDlgBrowser3
*iface
)
280 ICommDlgBrowser3Impl
*This
= impl_from_ICommDlgBrowser3(iface
);
281 ULONG ref
= InterlockedDecrement(&This
->ref
);
289 static HRESULT WINAPI
ICommDlgBrowser3_fnOnDefaultCommand(ICommDlgBrowser3
* iface
, IShellView
*shv
)
291 ICommDlgBrowser3Impl
*This
= impl_from_ICommDlgBrowser3(iface
);
292 This
->OnDefaultCommand
++;
296 static HRESULT WINAPI
ICommDlgBrowser3_fnOnStateChange(
297 ICommDlgBrowser3
* iface
,
301 ICommDlgBrowser3Impl
*This
= impl_from_ICommDlgBrowser3(iface
);
302 This
->OnStateChange
++;
306 static HRESULT WINAPI
ICommDlgBrowser3_fnIncludeObject(
307 ICommDlgBrowser3
* iface
,
311 ICommDlgBrowser3Impl
*This
= impl_from_ICommDlgBrowser3(iface
);
312 This
->IncludeObject
++;
316 static HRESULT WINAPI
ICommDlgBrowser3_fnNotify(
317 ICommDlgBrowser3
* iface
,
321 ICommDlgBrowser3Impl
*This
= impl_from_ICommDlgBrowser3(iface
);
326 static HRESULT WINAPI
ICommDlgBrowser3_fnGetDefaultMenuText(
327 ICommDlgBrowser3
* iface
,
332 ICommDlgBrowser3Impl
*This
= impl_from_ICommDlgBrowser3(iface
);
333 This
->GetDefaultMenuText
++;
337 static HRESULT WINAPI
ICommDlgBrowser3_fnGetViewFlags(
338 ICommDlgBrowser3
* iface
,
341 ICommDlgBrowser3Impl
*This
= impl_from_ICommDlgBrowser3(iface
);
342 This
->GetViewFlags
++;
346 static HRESULT WINAPI
ICommDlgBrowser3_fnOnColumnClicked(
347 ICommDlgBrowser3
* iface
,
351 ICommDlgBrowser3Impl
*This
= impl_from_ICommDlgBrowser3(iface
);
352 This
->OnColumnClicked
++;
356 static HRESULT WINAPI
ICommDlgBrowser3_fnGetCurrentFilter(
357 ICommDlgBrowser3
* iface
,
361 ICommDlgBrowser3Impl
*This
= impl_from_ICommDlgBrowser3(iface
);
362 This
->GetCurrentFilter
++;
366 static HRESULT WINAPI
ICommDlgBrowser3_fnOnPreviewCreated(
367 ICommDlgBrowser3
* iface
,
370 ICommDlgBrowser3Impl
*This
= impl_from_ICommDlgBrowser3(iface
);
371 This
->OnPreviewCreated
++;
375 static const ICommDlgBrowser3Vtbl cdbvtbl
=
377 ICommDlgBrowser3_fnQueryInterface
,
378 ICommDlgBrowser3_fnAddRef
,
379 ICommDlgBrowser3_fnRelease
,
380 ICommDlgBrowser3_fnOnDefaultCommand
,
381 ICommDlgBrowser3_fnOnStateChange
,
382 ICommDlgBrowser3_fnIncludeObject
,
383 ICommDlgBrowser3_fnNotify
,
384 ICommDlgBrowser3_fnGetDefaultMenuText
,
385 ICommDlgBrowser3_fnGetViewFlags
,
386 ICommDlgBrowser3_fnOnColumnClicked
,
387 ICommDlgBrowser3_fnGetCurrentFilter
,
388 ICommDlgBrowser3_fnOnPreviewCreated
391 static ICommDlgBrowser3Impl
*create_commdlgbrowser3(void)
393 ICommDlgBrowser3Impl
*cdb
;
395 cdb
= calloc(1, sizeof(*cdb
));
396 cdb
->ICommDlgBrowser3_iface
.lpVtbl
= &cdbvtbl
;
402 /*********************************************************************
403 * IServiceProvider Implementation
406 IServiceProvider IServiceProvider_iface
;
413 } IServiceProviderImpl
;
415 static inline IServiceProviderImpl
*impl_from_IServiceProvider(IServiceProvider
*iface
)
417 return CONTAINING_RECORD(iface
, IServiceProviderImpl
, IServiceProvider_iface
);
420 static HRESULT WINAPI
IServiceProvider_fnQueryInterface(IServiceProvider
*iface
, REFIID riid
, LPVOID
*ppvObj
)
423 if(IsEqualIID(riid
, &IID_IServiceProvider
))
426 IServiceProvider_AddRef(iface
);
430 if(IsEqualIID(riid
, &IID_IOleCommandTarget
))
433 return E_NOINTERFACE
;
436 ok(0, "Unexpected interface requested, %s\n", wine_dbgstr_guid(riid
));
437 return E_NOINTERFACE
;
440 static ULONG WINAPI
IServiceProvider_fnAddRef(IServiceProvider
*iface
)
442 IServiceProviderImpl
*This
= impl_from_IServiceProvider(iface
);
443 return InterlockedIncrement(&This
->ref
);
446 static ULONG WINAPI
IServiceProvider_fnRelease(IServiceProvider
*iface
)
448 IServiceProviderImpl
*This
= impl_from_IServiceProvider(iface
);
449 LONG ref
= InterlockedDecrement(&This
->ref
);
457 static HRESULT WINAPI
IServiceProvider_fnQueryService(IServiceProvider
*iface
,
462 IServiceProviderImpl
*This
= impl_from_IServiceProvider(iface
);
465 if (winetest_debug
> 1)
466 trace("QueryService(service %s, iid %s)\n", debugstr_guid(guidService
), debugstr_guid(riid
));
468 for(i
= 0; This
->interfaces
[i
].service
!= NULL
; i
++)
470 if(IsEqualGUID(This
->interfaces
[i
].service
, guidService
) &&
471 IsEqualIID(This
->interfaces
[i
].id
, riid
))
473 *ppv
= This
->interfaces
[i
].punk
;
474 IUnknown_AddRef((IUnknown
*)*ppv
);
480 return E_NOINTERFACE
;
483 static const IServiceProviderVtbl spvtbl
=
485 IServiceProvider_fnQueryInterface
,
486 IServiceProvider_fnAddRef
,
487 IServiceProvider_fnRelease
,
488 IServiceProvider_fnQueryService
491 static IServiceProviderImpl
*create_serviceprovider(void)
493 IServiceProviderImpl
*sp
= malloc(sizeof(*sp
));
494 sp
->IServiceProvider_iface
.lpVtbl
= &spvtbl
;
499 static void test_QueryInterface(void)
501 IExplorerBrowser
*peb
;
506 hr
= ebrowser_instantiate(&peb
);
507 ok(hr
== S_OK
, "Got 0x%08lx\n", hr
);
509 #define test_qinterface(iid, exp) \
511 hr = IExplorerBrowser_QueryInterface(peb, &iid, (void**)&punk); \
512 ok(hr == exp, "(%s:)Expected (0x%08lx), got (0x%08lx)\n", \
514 if(SUCCEEDED(hr)) IUnknown_Release(punk); \
517 test_qinterface(IID_IUnknown
, S_OK
);
518 test_qinterface(IID_IExplorerBrowser
, S_OK
);
519 test_qinterface(IID_IShellBrowser
, S_OK
);
520 test_qinterface(IID_IOleWindow
, S_OK
);
521 test_qinterface(IID_ICommDlgBrowser
, S_OK
);
522 test_qinterface(IID_ICommDlgBrowser2
, S_OK
);
523 test_qinterface(IID_ICommDlgBrowser3
, S_OK
);
524 todo_wine
test_qinterface(IID_IServiceProvider
, S_OK
);
525 test_qinterface(IID_IObjectWithSite
, S_OK
);
526 todo_wine
test_qinterface(IID_IConnectionPointContainer
, S_OK
);
527 test_qinterface(IID_IOleObject
, E_NOINTERFACE
);
528 test_qinterface(IID_IViewObject
, E_NOINTERFACE
);
529 test_qinterface(IID_IViewObject2
, E_NOINTERFACE
);
530 test_qinterface(IID_IViewObjectEx
, E_NOINTERFACE
);
531 test_qinterface(IID_IConnectionPoint
, E_NOINTERFACE
);
532 test_qinterface(IID_IShellView
, E_NOINTERFACE
);
533 test_qinterface(IID_INameSpaceTreeControlEvents
, E_NOINTERFACE
);
535 #undef test_qinterface
537 lres
= IExplorerBrowser_Release(peb
);
538 ok(lres
== 0, "Got %ld\n", lres
);
541 static void test_SB_misc(void)
543 IExplorerBrowser
*peb
;
551 ebrowser_instantiate(&peb
);
552 hr
= IExplorerBrowser_QueryInterface(peb
, &IID_IShellBrowser
, (void**)&psb
);
553 ok(hr
== S_OK
, "Got 0x%08lx\n", hr
);
556 skip("Failed to get IShellBrowser interface.\n");
560 /* Some unimplemented methods */
561 retHwnd
= (HWND
)0xdeadbeef;
562 hr
= IShellBrowser_GetControlWindow(psb
, FCW_TOOLBAR
, &retHwnd
);
563 ok(hr
== E_NOTIMPL
, "got (0x%08lx)\n", hr
);
564 ok(retHwnd
== NULL
|| broken(retHwnd
== (HWND
)0xdeadbeef), "got %p\n", retHwnd
);
566 retHwnd
= (HWND
)0xdeadbeef;
567 hr
= IShellBrowser_GetControlWindow(psb
, FCW_STATUS
, &retHwnd
);
568 ok(hr
== E_NOTIMPL
, "got (0x%08lx)\n", hr
);
569 ok(retHwnd
== NULL
|| broken(retHwnd
== (HWND
)0xdeadbeef), "got %p\n", retHwnd
);
571 retHwnd
= (HWND
)0xdeadbeef;
572 hr
= IShellBrowser_GetControlWindow(psb
, FCW_TREE
, &retHwnd
);
573 ok(hr
== E_NOTIMPL
, "got (0x%08lx)\n", hr
);
574 ok(retHwnd
== NULL
|| broken(retHwnd
== (HWND
)0xdeadbeef), "got %p\n", retHwnd
);
576 retHwnd
= (HWND
)0xdeadbeef;
577 hr
= IShellBrowser_GetControlWindow(psb
, FCW_PROGRESS
, &retHwnd
);
578 ok(hr
== E_NOTIMPL
, "got (0x%08lx)\n", hr
);
579 ok(retHwnd
== NULL
|| broken(retHwnd
== (HWND
)0xdeadbeef), "got %p\n", retHwnd
);
582 hr
= IShellBrowser_InsertMenusSB(psb
, NULL
, NULL
);
583 ok(hr
== E_NOTIMPL
, "got (0x%08lx)\n", hr
);
585 /* ::RemoveMenusSB */
586 hr
= IShellBrowser_RemoveMenusSB(psb
, NULL
);
587 ok(hr
== E_NOTIMPL
, "got (0x%08lx)\n", hr
);
590 hr
= IShellBrowser_SetMenuSB(psb
, NULL
, NULL
, NULL
);
591 ok(hr
== E_NOTIMPL
, "got (0x%08lx)\n", hr
);
593 /***** Before EB::Initialize *****/
596 retHwnd
= (HWND
)0xDEADBEEF;
597 hr
= IShellBrowser_GetWindow(psb
, &retHwnd
);
598 ok(hr
== E_FAIL
, "got (0x%08lx)\n", hr
);
599 ok(retHwnd
== (HWND
)0xDEADBEEF, "HWND overwritten\n");
604 /* ::SendControlMsg */
606 hr
= IShellBrowser_SendControlMsg(psb
, FCW_STATUS
, 0, 0, 0, &lres
);
607 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
608 ok(lres
== 0, "lres was %Id\n", lres
);
611 hr
= IShellBrowser_SendControlMsg(psb
, FCW_TOOLBAR
, TB_CHECKBUTTON
,
612 FCIDM_TB_SMALLICON
, TRUE
, &lres
);
613 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
614 ok(lres
== 0, "lres was %Id\n", lres
);
616 hr
= IShellBrowser_SendControlMsg(psb
, FCW_STATUS
, 0, 0, 0, NULL
);
617 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
619 hr
= IShellBrowser_SendControlMsg(psb
, FCW_TREE
, 0, 0, 0, NULL
);
620 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
622 hr
= IShellBrowser_SendControlMsg(psb
, FCW_PROGRESS
, 0, 0, 0, NULL
);
623 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
626 /* ::QueryActiveShellView */
627 hr
= IShellBrowser_QueryActiveShellView(psb
, (IShellView
**)&punk
);
628 ok(hr
== E_FAIL
, "got (0x%08lx)\n", hr
);
630 /* Initialize ExplorerBrowser */
631 ebrowser_initialize(peb
);
633 /***** After EB::Initialize *****/
636 hr
= IShellBrowser_GetWindow(psb
, &retHwnd
);
637 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
638 ok(GetParent(retHwnd
) == hwnd
, "The HWND returned is not our child.\n");
642 /* ::SendControlMsg */
643 hr
= IShellBrowser_SendControlMsg(psb
, FCW_STATUS
, 0, 0, 0, NULL
);
644 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
647 hr
= IShellBrowser_SendControlMsg(psb
, FCW_TOOLBAR
, 0, 0, 0, &lres
);
648 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
649 ok(lres
== 0, "lres was %Id\n", lres
);
652 hr
= IShellBrowser_SendControlMsg(psb
, FCW_STATUS
, 0, 0, 0, &lres
);
653 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
654 ok(lres
== 0, "lres was %Id\n", lres
);
657 hr
= IShellBrowser_SendControlMsg(psb
, 1234, 0, 0, 0, &lres
);
658 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
659 ok(lres
== 0, "lres was %Id\n", lres
);
662 hr
= IShellBrowser_SetStatusTextSB(psb
, NULL
);
663 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
665 hr
= IShellBrowser_ContextSensitiveHelp(psb
, FALSE
);
666 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
668 hr
= IShellBrowser_EnableModelessSB(psb
, TRUE
);
669 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
671 hr
= IShellBrowser_SetToolbarItems(psb
, NULL
, 1, 1);
672 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
675 hr
= IShellBrowser_QueryActiveShellView(psb
, (IShellView
**)&punk
);
676 ok(hr
== E_FAIL
, "got (0x%08lx)\n", hr
);
678 IShellBrowser_Release(psb
);
679 IExplorerBrowser_Destroy(peb
);
680 IExplorerBrowser_Release(peb
);
682 /* Browse to the desktop. */
683 ebrowser_instantiate(&peb
);
684 ebrowser_initialize(peb
);
685 IExplorerBrowser_QueryInterface(peb
, &IID_IShellBrowser
, (void**)&psb
);
688 hr
= ebrowser_browse_to_desktop(peb
);
689 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
692 /****** After Browsing *****/
694 hr
= IShellBrowser_QueryActiveShellView(psb
, (IShellView
**)&punk
);
695 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
696 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
698 IShellBrowser_Release(psb
);
699 IExplorerBrowser_Destroy(peb
);
700 ref
= IExplorerBrowser_Release(peb
);
701 ok(ref
== 0, "Got %ld\n", ref
);
704 static void test_initialization(void)
706 IExplorerBrowser
*peb
;
714 ebrowser_instantiate(&peb
);
718 /* Crashes on Windows 7 */
719 IExplorerBrowser_Initialize(peb
, NULL
, NULL
, NULL
);
720 IExplorerBrowser_Initialize(peb
, hwnd
, NULL
, NULL
);
723 ZeroMemory(&rc
, sizeof(RECT
));
725 hr
= IExplorerBrowser_Initialize(peb
, NULL
, &rc
, NULL
);
726 ok(hr
== E_INVALIDARG
, "got (0x%08lx)\n", hr
);
728 hr
= IExplorerBrowser_Initialize(peb
, hwnd
, &rc
, NULL
);
729 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
731 /* Initialize twice */
732 hr
= IExplorerBrowser_Initialize(peb
, hwnd
, &rc
, NULL
);
733 ok(hr
== E_UNEXPECTED
, "got (0x%08lx)\n", hr
);
735 hr
= IExplorerBrowser_Destroy(peb
);
736 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
738 /* Initialize again */
739 hr
= IExplorerBrowser_Initialize(peb
, hwnd
, &rc
, NULL
);
740 ok(hr
== E_UNEXPECTED
, "got (0x%08lx)\n", hr
);
743 hr
= IExplorerBrowser_Destroy(peb
);
744 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
745 lres
= IExplorerBrowser_Release(peb
);
746 ok(lres
== 0, "Got %ld\n", lres
);
748 /* Initialize with a few different rectangles */
750 ebrowser_instantiate(&peb
);
751 SetRect(&rc
, 50, 20, 100, 80);
752 hr
= IExplorerBrowser_Initialize(peb
, hwnd
, &rc
, NULL
);
753 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
754 hr
= IExplorerBrowser_QueryInterface(peb
, &IID_IShellBrowser
, (void**)&psb
);
755 ok(hr
== S_OK
, "Got 0x%08lx\n", hr
);
761 static const RECT exp_rc
= {0, 0, 48, 58};
763 hr
= IShellBrowser_GetWindow(psb
, &eb_hwnd
);
764 ok(hr
== S_OK
, "Got 0x%08lx\n", hr
);
766 GetClientRect(eb_hwnd
, &eb_rc
);
767 ok(EqualRect(&eb_rc
, &exp_rc
), "Got client rect %s\n", wine_dbgstr_rect(&eb_rc
));
769 GetWindowRect(eb_hwnd
, &eb_rc
);
770 ok(eb_rc
.right
- eb_rc
.left
== 50, "Got window width %ld\n", eb_rc
.right
- eb_rc
.left
);
771 ok(eb_rc
.bottom
- eb_rc
.top
== 60, "Got window height %ld\n", eb_rc
.bottom
- eb_rc
.top
);
774 GetClassNameA(eb_hwnd
, buf
, 1024);
775 ok(!lstrcmpA(buf
, "ExplorerBrowserControl"), "Unexpected classname %s\n", buf
);
777 expected_style
= WS_CHILD
| WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_CLIPCHILDREN
| WS_BORDER
;
778 style
= GetWindowLongPtrW(eb_hwnd
, GWL_STYLE
);
779 todo_wine
ok(style
== expected_style
, "Got style 0x%08lx, expected 0x%08lx\n", style
, expected_style
);
781 expected_style
= WS_EX_CONTROLPARENT
;
782 style
= GetWindowLongPtrW(eb_hwnd
, GWL_EXSTYLE
);
783 ok(style
== expected_style
, "Got exstyle 0x%08lx, expected 0x%08lx\n", style
, expected_style
);
785 ok(GetParent(eb_hwnd
) == hwnd
, "GetParent returns %p\n", GetParent(eb_hwnd
));
787 /* ::Destroy() destroys the window. */
788 ok(IsWindow(eb_hwnd
), "eb_hwnd invalid.\n");
789 IExplorerBrowser_Destroy(peb
);
790 ok(!IsWindow(eb_hwnd
), "eb_hwnd valid.\n");
792 IShellBrowser_Release(psb
);
793 lres
= IExplorerBrowser_Release(peb
);
794 ok(lres
== 0, "Got refcount %ld\n", lres
);
798 skip("Skipping some tests.\n");
800 IExplorerBrowser_Destroy(peb
);
801 lres
= IExplorerBrowser_Release(peb
);
802 ok(lres
== 0, "Got refcount %ld\n", lres
);
805 /* check window style with EBO_NOBORDER */
806 ebrowser_instantiate(&peb
);
807 hr
= IExplorerBrowser_SetOptions(peb
, EBO_NOBORDER
);
808 ok(hr
== S_OK
, "got 0x%08lx\n", hr
);
809 SetRect(&rc
, 50, 20, 100, 80);
811 hr
= IExplorerBrowser_Initialize(peb
, hwnd
, &rc
, NULL
);
812 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
814 hr
= IExplorerBrowser_QueryInterface(peb
, &IID_IShellBrowser
, (void**)&psb
);
815 ok(hr
== S_OK
, "Got 0x%08lx\n", hr
);
817 hr
= IShellBrowser_GetWindow(psb
, &eb_hwnd
);
818 ok(hr
== S_OK
, "Got 0x%08lx\n", hr
);
820 style
= GetWindowLongPtrW(eb_hwnd
, GWL_STYLE
);
821 ok(!(style
& WS_BORDER
) || broken(style
& WS_BORDER
) /* before win8 */, "got style 0x%08lx\n", style
);
823 IShellBrowser_Release(psb
);
824 IExplorerBrowser_Destroy(peb
);
825 IExplorerBrowser_Release(peb
);
827 /* empty rectangle */
828 ebrowser_instantiate(&peb
);
830 hr
= IExplorerBrowser_Initialize(peb
, hwnd
, &rc
, NULL
);
831 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
832 IExplorerBrowser_Destroy(peb
);
833 lres
= IExplorerBrowser_Release(peb
);
834 ok(lres
== 0, "Got refcount %ld\n", lres
);
836 ebrowser_instantiate(&peb
);
837 SetRect(&rc
, -1, -1, 1, 1);
838 hr
= IExplorerBrowser_Initialize(peb
, hwnd
, &rc
, NULL
);
839 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
840 IExplorerBrowser_Destroy(peb
);
841 lres
= IExplorerBrowser_Release(peb
);
842 ok(lres
== 0, "Got refcount %ld\n", lres
);
844 ebrowser_instantiate(&peb
);
845 SetRect(&rc
, 10, 10, 5, 5);
846 hr
= IExplorerBrowser_Initialize(peb
, hwnd
, &rc
, NULL
);
847 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
848 IExplorerBrowser_Destroy(peb
);
849 lres
= IExplorerBrowser_Release(peb
);
850 ok(lres
== 0, "Got refcount %ld\n", lres
);
852 ebrowser_instantiate(&peb
);
853 SetRect(&rc
, 10, 10, 5, 5);
854 hr
= IExplorerBrowser_Initialize(peb
, hwnd
, &rc
, NULL
);
855 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
856 IExplorerBrowser_Destroy(peb
);
857 lres
= IExplorerBrowser_Release(peb
);
858 ok(lres
== 0, "Got refcount %ld\n", lres
);
861 static void test_SetSite(void)
863 IExplorerBrowser
*peb
;
864 IServiceProviderImpl
*spimpl
= create_serviceprovider();
865 ICommDlgBrowser3Impl
*cdbimpl
= create_commdlgbrowser3();
866 IExplorerPaneVisibilityImpl
*epvimpl
= create_explorerpanevisibility();
867 IObjectWithSite
*pow
;
871 struct services expected
[] =
873 {&SID_STopLevelBrowser
, &IID_ICommDlgBrowser2
, cdbimpl
},
874 {&SID_ExplorerPaneVisibility
, &IID_IExplorerPaneVisibility
, epvimpl
},
875 {&SID_SExplorerBrowserFrame
, &IID_ICommDlgBrowser2
, cdbimpl
},
876 {&SID_SExplorerBrowserFrame
, &IID_ICommDlgBrowser3
, cdbimpl
},
877 {&IID_ICommDlgBrowser
, &IID_ICommDlgBrowser
, cdbimpl
},
881 ebrowser_instantiate(&peb
);
882 IExplorerBrowser_SetOptions(peb
, EBO_SHOWFRAMES
);
884 hr
= IExplorerBrowser_QueryInterface(peb
, &IID_IObjectWithSite
, (void**)&pow
);
885 ok(hr
== S_OK
, "Got 0x%08lx\n", hr
);
888 spimpl
->interfaces
= expected
;
890 hr
= IObjectWithSite_SetSite(pow
, (IUnknown
*)&spimpl
->IServiceProvider_iface
);
891 ok(hr
== S_OK
, "Got 0x%08lx\n", hr
);
894 IObjectWithSite_Release(pow
);
899 skip("Failed to set site.\n");
901 IServiceProvider_Release(&spimpl
->IServiceProvider_iface
);
902 ICommDlgBrowser3_Release(&cdbimpl
->ICommDlgBrowser3_iface
);
903 IExplorerPaneVisibility_Release(&epvimpl
->IExplorerPaneVisibility_iface
);
904 IExplorerBrowser_Destroy(peb
);
905 ref
= IExplorerBrowser_Release(peb
);
906 ok(ref
== 0, "Got ref %ld\n", ref
);
911 ShowWindow(hwnd
, TRUE
);
912 ebrowser_initialize(peb
);
913 ebrowser_browse_to_desktop(peb
);
915 for(i
= 0; i
< 10; i
++)
920 ShowWindow(hwnd
, FALSE
);
922 /* ICommDlgBrowser3 */
923 ok(!cdbimpl
->OnDefaultCommand
, "Got %d\n", cdbimpl
->OnDefaultCommand
);
924 todo_wine
ok(cdbimpl
->OnStateChange
, "Got %d\n", cdbimpl
->OnStateChange
);
925 ok(cdbimpl
->IncludeObject
, "Got %d\n", cdbimpl
->IncludeObject
);
926 ok(!cdbimpl
->Notify
, "Got %d\n", cdbimpl
->Notify
);
927 ok(!cdbimpl
->GetDefaultMenuText
, "Got %d\n", cdbimpl
->GetDefaultMenuText
);
928 todo_wine
ok(cdbimpl
->GetViewFlags
, "Got %d\n", cdbimpl
->GetViewFlags
);
929 ok(!cdbimpl
->OnColumnClicked
, "Got %d\n", cdbimpl
->OnColumnClicked
);
930 ok(!cdbimpl
->GetCurrentFilter
, "Got %d\n", cdbimpl
->GetCurrentFilter
);
931 todo_wine
ok(cdbimpl
->OnPreviewCreated
, "Got %d\n", cdbimpl
->OnPreviewCreated
);
933 /* IExplorerPaneVisibility */
934 ok(epvimpl
->np
, "Got %ld\n", epvimpl
->np
);
935 todo_wine
ok(epvimpl
->cp
, "Got %ld\n", epvimpl
->cp
);
936 todo_wine
ok(epvimpl
->cp_o
, "Got %ld\n", epvimpl
->cp_o
);
937 todo_wine
ok(epvimpl
->cp_v
, "Got %ld\n", epvimpl
->cp_v
);
938 todo_wine
ok(epvimpl
->dp
, "Got %ld\n", epvimpl
->dp
);
939 todo_wine
ok(epvimpl
->pp
, "Got %ld\n", epvimpl
->pp
);
940 ok(!epvimpl
->qp
, "Got %ld\n", epvimpl
->qp
);
941 ok(!epvimpl
->aqp
, "Got %ld\n", epvimpl
->aqp
);
942 ok(!epvimpl
->unk
, "Got %ld\n", epvimpl
->unk
);
944 /* Test when IServiceProvider is released. */
945 IServiceProvider_AddRef(&spimpl
->IServiceProvider_iface
);
946 ref
= IServiceProvider_Release(&spimpl
->IServiceProvider_iface
);
947 ok(ref
== 2, "Got ref %ld\n", ref
);
949 hr
= IObjectWithSite_SetSite(pow
, NULL
);
950 ok(hr
== S_OK
, "Got 0x%08lx\n", hr
);
952 IServiceProvider_AddRef(&spimpl
->IServiceProvider_iface
);
953 ref
= IServiceProvider_Release(&spimpl
->IServiceProvider_iface
);
954 ok(ref
== 1, "Got ref %ld\n", ref
);
956 hr
= IObjectWithSite_SetSite(pow
, (IUnknown
*)&spimpl
->IServiceProvider_iface
);
957 ok(hr
== S_OK
, "Got 0x%08lx\n", hr
);
959 IServiceProvider_AddRef(&spimpl
->IServiceProvider_iface
);
960 ref
= IServiceProvider_Release(&spimpl
->IServiceProvider_iface
);
961 ok(ref
== 2, "Got ref %ld\n", ref
);
963 IExplorerBrowser_Destroy(peb
);
965 IServiceProvider_AddRef(&spimpl
->IServiceProvider_iface
);
966 ref
= IServiceProvider_Release(&spimpl
->IServiceProvider_iface
);
967 ok(ref
== 2, "Got ref %ld\n", ref
);
969 IObjectWithSite_Release(pow
);
970 ref
= IExplorerBrowser_Release(peb
);
971 ok(ref
== 0, "Got ref %ld\n", ref
);
973 ref
= IServiceProvider_Release(&spimpl
->IServiceProvider_iface
);
974 ok(ref
== 0, "Got ref %ld\n", ref
);
976 ref
= ICommDlgBrowser3_Release(&cdbimpl
->ICommDlgBrowser3_iface
);
977 ok(ref
== 0, "Got ref %ld\n", ref
);
978 ref
= IExplorerPaneVisibility_Release(&epvimpl
->IExplorerPaneVisibility_iface
);
979 ok(ref
== 0, "Got ref %ld\n", ref
);
982 static void test_basics(void)
984 IExplorerBrowser
*peb
;
987 EXPLORER_BROWSER_OPTIONS flags
;
991 static const WCHAR winetest
[] = {'W','i','n','e','T','e','s','t',0};
993 ebrowser_instantiate(&peb
);
994 ebrowser_initialize(peb
);
998 hr
= IExplorerBrowser_SetRect(peb
, NULL
, rc
);
999 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
1001 SetRect(&rc
, 100, 100, 10, 10);
1002 hr
= IExplorerBrowser_SetRect(peb
, NULL
, rc
);
1003 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
1005 /* SetRect with DeferWindowPos */
1006 SetRect(&rc
, 0, 0, 10, 10);
1007 hdwp
= BeginDeferWindowPos(1);
1008 hr
= IExplorerBrowser_SetRect(peb
, &hdwp
, rc
);
1009 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
1010 lres
= EndDeferWindowPos(hdwp
);
1011 ok(lres
, "EndDeferWindowPos failed.\n");
1014 hr
= IExplorerBrowser_SetRect(peb
, &hdwp
, rc
);
1015 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
1016 ok(hdwp
== NULL
, "got %p\n", hdwp
);
1017 lres
= EndDeferWindowPos(hdwp
);
1018 ok(!lres
, "EndDeferWindowPos succeeded unexpectedly.\n");
1020 /* Test positioning */
1021 SetRect(&rc
, 10, 20, 50, 50);
1022 hr
= IExplorerBrowser_SetRect(peb
, NULL
, rc
);
1023 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
1024 hr
= IExplorerBrowser_QueryInterface(peb
, &IID_IShellBrowser
, (void**)&psb
);
1025 ok(hr
== S_OK
, "Got 0x%08lx\n", hr
);
1030 static const RECT exp_rc
= {11, 21, 49, 49};
1031 static const RECT exp_rc2
= {11, 21, 49, 24};
1033 hr
= IShellBrowser_GetWindow(psb
, &eb_hwnd
);
1034 ok(hr
== S_OK
, "Got 0x%08lx\n", hr
);
1036 GetClientRect(eb_hwnd
, &eb_rc
);
1037 MapWindowPoints(eb_hwnd
, hwnd
, (POINT
*)&eb_rc
, 2);
1038 ok(EqualRect(&eb_rc
, &exp_rc
), "Got rect %s\n", wine_dbgstr_rect(&eb_rc
));
1040 /* Try resizing with invalid hdwp */
1042 hdwp
= (HDWP
)0xdeadbeef;
1043 hr
= IExplorerBrowser_SetRect(peb
, &hdwp
, rc
);
1044 ok(hr
== E_FAIL
, "Got 0x%08lx\n", hr
);
1045 GetClientRect(eb_hwnd
, &eb_rc
);
1046 MapWindowPoints(eb_hwnd
, hwnd
, (POINT
*)&eb_rc
, 2);
1047 ok(EqualRect(&eb_rc
, &exp_rc
), "Got rect %s\n", wine_dbgstr_rect(&eb_rc
));
1050 hr
= IExplorerBrowser_SetRect(peb
, &hdwp
, rc
);
1051 ok(hr
== S_OK
, "Got 0x%08lx\n", hr
);
1052 GetClientRect(eb_hwnd
, &eb_rc
);
1053 MapWindowPoints(eb_hwnd
, hwnd
, (POINT
*)&eb_rc
, 2);
1054 ok(EqualRect(&eb_rc
, &exp_rc2
), "Got rect %s\n", wine_dbgstr_rect(&eb_rc
));
1056 IShellBrowser_Release(psb
);
1059 IExplorerBrowser_Destroy(peb
);
1060 IExplorerBrowser_Release(peb
);
1062 /* GetOptions/SetOptions*/
1063 ebrowser_instantiate(&peb
);
1066 /* Crashes on Windows 7 */
1067 IExplorerBrowser_GetOptions(peb
, NULL
);
1070 hr
= IExplorerBrowser_GetOptions(peb
, &flags
);
1071 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
1072 ok(flags
== 0, "got (0x%08x)\n", flags
);
1074 /* Settings preserved through Initialize. */
1075 hr
= IExplorerBrowser_SetOptions(peb
, 0xDEADBEEF);
1076 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
1078 ebrowser_initialize(peb
);
1080 hr
= IExplorerBrowser_GetOptions(peb
, &flags
);
1081 ok(flags
== 0xDEADBEEF, "got (0x%08x)\n", flags
);
1082 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
1084 IExplorerBrowser_Destroy(peb
);
1085 IExplorerBrowser_Release(peb
);
1087 ebrowser_instantiate(&peb
);
1088 ebrowser_initialize(peb
);
1090 /* SetPropertyBag */
1091 hr
= IExplorerBrowser_SetPropertyBag(peb
, NULL
);
1092 ok(hr
== E_INVALIDARG
, "Got 0x%08lx\n", hr
);
1093 hr
= IExplorerBrowser_SetPropertyBag(peb
, winetest
);
1094 ok(hr
== S_OK
, "Got 0x%08lx\n", hr
);
1096 /* TODO: Test after browsing somewhere. */
1098 IExplorerBrowser_Destroy(peb
);
1099 lres
= IExplorerBrowser_Release(peb
);
1100 ok(lres
== 0, "Got %ld\n", lres
);
1103 static void test_Advise(void)
1105 IExplorerBrowser
*peb
;
1106 IExplorerBrowserEvents
*pebe
;
1111 /* Set up our IExplorerBrowserEvents implementation */
1112 ebev
.IExplorerBrowserEvents_iface
.lpVtbl
= &ebevents
;
1113 pebe
= &ebev
.IExplorerBrowserEvents_iface
;
1115 ebrowser_instantiate(&peb
);
1119 /* Crashes on Windows 7 */
1120 IExplorerBrowser_Advise(peb
, pebe
, NULL
);
1121 IExplorerBrowser_Advise(peb
, NULL
, &cookies
[0]);
1124 /* Using Unadvise with a cookie that has yet to be given out
1125 * results in E_INVALIDARG */
1126 hr
= IExplorerBrowser_Unadvise(peb
, 11);
1127 ok(hr
== E_INVALIDARG
, "got (0x%08lx)\n", hr
);
1129 /* Add some before initialization */
1130 for(i
= 0; i
< 5; i
++)
1132 hr
= IExplorerBrowser_Advise(peb
, pebe
, &cookies
[i
]);
1133 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
1136 ebrowser_initialize(peb
);
1138 /* Add some after initialization */
1139 for(i
= 5; i
< 10; i
++)
1141 hr
= IExplorerBrowser_Advise(peb
, pebe
, &cookies
[i
]);
1142 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
1145 ok(ebev
.ref
== 10, "Got %ld\n", ebev
.ref
);
1148 ebrowser_browse_to_desktop(peb
);
1150 ok(ebev
.completed
== 10, "Got %d\n", ebev
.completed
);
1152 /* Remove a bunch somewhere in the middle */
1153 for(i
= 4; i
< 8; i
++)
1155 hr
= IExplorerBrowser_Unadvise(peb
, cookies
[i
]);
1156 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
1160 ebrowser_browse_to_desktop(peb
);
1162 ok(ebev
.completed
== 6, "Got %d\n", ebev
.completed
);
1166 /* Using unadvise with a previously unadvised cookie results
1168 IExplorerBrowser_Unadvise(peb
, cookies
[5]);
1171 /* Remove the rest. */
1172 for(i
= 0; i
< 10; i
++)
1176 hr
= IExplorerBrowser_Unadvise(peb
, cookies
[i
]);
1177 ok(hr
== S_OK
, "%d: got (0x%08lx)\n", i
, hr
);
1181 ok(ebev
.ref
== 0, "Got %ld\n", ebev
.ref
);
1184 ebrowser_browse_to_desktop(peb
);
1186 ok(ebev
.completed
== 0, "Got %d\n", ebev
.completed
);
1188 /* ::Destroy implies ::Unadvise. */
1189 hr
= IExplorerBrowser_Advise(peb
, pebe
, &cookies
[0]);
1190 ok(hr
== S_OK
, "Got 0x%08lx\n", hr
);
1191 ok(ebev
.ref
== 1, "Got %ld\n", ebev
.ref
);
1193 hr
= IExplorerBrowser_Destroy(peb
);
1194 ok(hr
== S_OK
, "Got 0x%08lx\n", hr
);
1195 ok(ebev
.ref
== 0, "Got %ld\n", ebev
.ref
);
1197 ref
= IExplorerBrowser_Release(peb
);
1198 ok(!ref
, "Got %d\n", ref
);
1201 /* Based on PathAddBackslashW from dlls/shlwapi/path.c */
1202 static LPWSTR
myPathAddBackslashW( LPWSTR lpszPath
)
1206 if (!lpszPath
|| (iLen
= lstrlenW(lpszPath
)) >= MAX_PATH
)
1212 if (lpszPath
[-1] != '\\')
1221 static void test_browse_pidl_(IExplorerBrowser
*peb
, IExplorerBrowserEventsImpl
*ebev
,
1222 LPITEMIDLIST pidl
, UINT uFlags
,
1223 HRESULT hr_exp
, UINT pending
, UINT created
, UINT failed
, UINT completed
,
1224 const char *file
, int line
)
1227 ebev
->completed
= ebev
->created
= ebev
->pending
= ebev
->failed
= 0;
1229 hr
= IExplorerBrowser_BrowseToIDList(peb
, pidl
, uFlags
);
1230 ok_(file
, line
) (hr
== hr_exp
, "BrowseToIDList returned 0x%08lx\n", hr
);
1234 (ebev
->pending
== pending
&& ebev
->created
== created
&&
1235 ebev
->failed
== failed
&& ebev
->completed
== completed
,
1236 "Events occurred: %d, %d, %d, %d\n",
1237 ebev
->pending
, ebev
->created
, ebev
->failed
, ebev
->completed
);
1239 #define test_browse_pidl(peb, ebev, pidl, uFlags, hr, p, cr, f, co) \
1240 test_browse_pidl_(peb, ebev, pidl, uFlags, hr, p, cr, f, co, __FILE__, __LINE__)
1242 static void test_browse_pidl_sb_(IExplorerBrowser
*peb
, IExplorerBrowserEventsImpl
*ebev
,
1243 LPITEMIDLIST pidl
, UINT uFlags
,
1244 HRESULT hr_exp
, UINT pending
, UINT created
, UINT failed
, UINT completed
,
1245 const char *file
, int line
)
1250 hr
= IExplorerBrowser_QueryInterface(peb
, &IID_IShellBrowser
, (void**)&psb
);
1251 ok_(file
, line
) (hr
== S_OK
, "QueryInterface returned 0x%08lx\n", hr
);
1254 ebev
->completed
= ebev
->created
= ebev
->pending
= ebev
->failed
= 0;
1256 hr
= IShellBrowser_BrowseObject(psb
, pidl
, uFlags
);
1257 ok_(file
, line
) (hr
== hr_exp
, "BrowseObject returned 0x%08lx\n", hr
);
1261 (ebev
->pending
== pending
&& ebev
->created
== created
&&
1262 ebev
->failed
== failed
&& ebev
->completed
== completed
,
1263 "Events occurred: %d, %d, %d, %d\n",
1264 ebev
->pending
, ebev
->created
, ebev
->failed
, ebev
->completed
);
1266 IShellBrowser_Release(psb
);
1269 #define test_browse_pidl_sb(peb, ebev, pidl, uFlags, hr, p, cr, f, co) \
1270 test_browse_pidl_sb_(peb, ebev, pidl, uFlags, hr, p, cr, f, co, __FILE__, __LINE__)
1272 static void test_navigation(void)
1274 IExplorerBrowser
*peb
, *peb2
;
1278 LPITEMIDLIST pidl_current
, pidl_child
;
1279 DWORD cookie
, cookie2
;
1282 WCHAR current_path
[MAX_PATH
];
1283 WCHAR child_path
[MAX_PATH
];
1284 static const WCHAR testfolderW
[] =
1285 {'w','i','n','e','t','e','s','t','f','o','l','d','e','r','\0'};
1287 ok(pSHCreateShellItem
!= NULL
, "pSHCreateShellItem unexpectedly missing.\n");
1289 GetCurrentDirectoryW(MAX_PATH
, current_path
);
1290 if(!current_path
[0])
1292 skip("Failed to create test-directory.\n");
1296 lstrcpyW(child_path
, current_path
);
1297 myPathAddBackslashW(child_path
);
1298 lstrcatW(child_path
, testfolderW
);
1300 CreateDirectoryW(child_path
, NULL
);
1302 hr
= SHParseDisplayName(current_path
, NULL
, &pidl_current
, 0, NULL
);
1303 ok(hr
== S_OK
, "Failed to parse a path, hr %#lx.\n", hr
);
1304 hr
= SHParseDisplayName(child_path
, NULL
, &pidl_child
, 0, NULL
);
1305 ok(hr
== S_OK
, "Failed to parse a path, hr %#lx.\n", hr
);
1307 ebrowser_instantiate(&peb
);
1308 ebrowser_initialize(peb
);
1310 ebrowser_instantiate(&peb2
);
1311 ebrowser_initialize(peb2
);
1313 /* Set up our IExplorerBrowserEvents implementation */
1314 ebev
.IExplorerBrowserEvents_iface
.lpVtbl
= &ebevents
;
1316 IExplorerBrowser_Advise(peb
, &ebev
.IExplorerBrowserEvents_iface
, &cookie
);
1317 IExplorerBrowser_Advise(peb2
, &ebev
.IExplorerBrowserEvents_iface
, &cookie2
);
1319 /* These should all fail */
1320 test_browse_pidl(peb
, &ebev
, 0, SBSP_ABSOLUTE
| SBSP_RELATIVE
, E_FAIL
, 0, 0, 0, 0);
1321 test_browse_pidl_sb(peb2
, &ebev
, 0, SBSP_ABSOLUTE
| SBSP_RELATIVE
, E_FAIL
, 0, 0, 0, 0);
1322 test_browse_pidl(peb
, &ebev
, 0, SBSP_ABSOLUTE
, E_INVALIDARG
, 0, 0, 0, 0);
1323 test_browse_pidl_sb(peb2
, &ebev
, 0, SBSP_ABSOLUTE
, E_INVALIDARG
, 0, 0, 0, 0);
1324 test_browse_pidl(peb
, &ebev
, 0, SBSP_RELATIVE
, E_FAIL
, 0, 0, 0, 0);
1325 test_browse_pidl_sb(peb2
, &ebev
, 0, SBSP_RELATIVE
, E_FAIL
, 0, 0, 0, 0);
1326 test_browse_pidl(peb
, &ebev
, 0, SBSP_PARENT
, E_FAIL
, 0, 0, 0, 0);
1327 test_browse_pidl_sb(peb2
, &ebev
, 0, SBSP_PARENT
, E_FAIL
, 0, 0, 0, 0);
1328 test_browse_pidl(peb
, &ebev
, 0, SBSP_NAVIGATEFORWARD
, E_FAIL
, 0, 0, 0, 0);
1329 test_browse_pidl_sb(peb2
, &ebev
, 0, SBSP_NAVIGATEFORWARD
, E_FAIL
, 0, 0, 0, 0);
1330 test_browse_pidl(peb
, &ebev
, 0, SBSP_NAVIGATEBACK
, E_FAIL
, 0, 0, 0, 0);
1331 test_browse_pidl_sb(peb2
, &ebev
, 0, SBSP_NAVIGATEBACK
, E_FAIL
, 0, 0, 0, 0);
1333 /* "The first browse is synchronous" */
1334 test_browse_pidl(peb
, &ebev
, pidl_child
, SBSP_ABSOLUTE
, S_OK
, 1, 1, 0, 1);
1335 test_browse_pidl_sb(peb2
, &ebev
, pidl_child
, SBSP_ABSOLUTE
, S_OK
, 1, 1, 0, 1);
1337 /* Navigate empty history */
1338 test_browse_pidl(peb
, &ebev
, 0, SBSP_NAVIGATEFORWARD
, S_OK
, 0, 0, 0, 0);
1339 test_browse_pidl_sb(peb2
, &ebev
, 0, SBSP_NAVIGATEFORWARD
, S_OK
, 0, 0, 0, 0);
1340 test_browse_pidl(peb
, &ebev
, 0, SBSP_NAVIGATEBACK
, S_OK
, 0, 0, 0, 0);
1341 test_browse_pidl_sb(peb2
, &ebev
, 0, SBSP_NAVIGATEBACK
, S_OK
, 0, 0, 0, 0);
1343 /* Navigate history */
1344 test_browse_pidl(peb
, &ebev
, 0, SBSP_PARENT
, S_OK
, 1, 1, 0, 1);
1345 test_browse_pidl_sb(peb2
, &ebev
, 0, SBSP_PARENT
, S_OK
, 1, 1, 0, 1);
1346 test_browse_pidl(peb
, &ebev
, 0, SBSP_NAVIGATEBACK
, S_OK
, 1, 1, 0, 1);
1347 test_browse_pidl_sb(peb2
, &ebev
, 0, SBSP_NAVIGATEBACK
, S_OK
, 1, 1, 0, 1);
1348 test_browse_pidl(peb
, &ebev
, 0, SBSP_NAVIGATEFORWARD
, S_OK
, 1, 1, 0, 1);
1349 test_browse_pidl_sb(peb2
, &ebev
, 0, SBSP_NAVIGATEFORWARD
, S_OK
, 1, 1, 0, 1);
1350 test_browse_pidl(peb
, &ebev
, 0, SBSP_ABSOLUTE
, S_OK
, 0, 0, 0, 0);
1351 test_browse_pidl_sb(peb2
, &ebev
, 0, SBSP_ABSOLUTE
, S_OK
, 0, 0, 0, 0);
1353 /* Relative navigation */
1354 test_browse_pidl(peb
, &ebev
, pidl_current
, SBSP_ABSOLUTE
, S_OK
, 1, 0, 0, 1);
1355 test_browse_pidl_sb(peb2
, &ebev
, pidl_current
, SBSP_ABSOLUTE
, S_OK
, 1, 0, 0, 1);
1357 hr
= IExplorerBrowser_GetCurrentView(peb
, &IID_IFolderView
, (void**)&pfv
);
1358 ok(hr
== S_OK
, "Got 0x%08lx\n", hr
);
1361 LPITEMIDLIST pidl_relative
;
1363 hr
= IFolderView_GetFolder(pfv
, &IID_IShellFolder
, (void**)&psf
);
1364 ok(hr
== S_OK
, "Got 0x%08lx\n", hr
);
1365 hr
= IShellFolder_ParseDisplayName(psf
, NULL
, NULL
, (LPWSTR
)testfolderW
,
1366 NULL
, &pidl_relative
, NULL
);
1367 ok(hr
== S_OK
, "Got 0x%08lx\n", hr
);
1369 /* Browsing to another location here before using the
1370 * pidl_relative would make ExplorerBrowser in Windows 7 show a
1371 * not-available dialog. Also, passing a relative pidl without
1372 * specifying SBSP_RELATIVE makes it look for the pidl on the
1376 test_browse_pidl(peb
, &ebev
, pidl_relative
, SBSP_RELATIVE
, S_OK
, 1, 1, 0, 1);
1377 test_browse_pidl_sb(peb2
, &ebev
, pidl_relative
, SBSP_RELATIVE
, S_OK
, 1, 1, 0, 1);
1379 ILFree(pidl_relative
);
1380 IShellFolder_Release(psf
);
1381 IFolderView_Release(pfv
);
1385 test_browse_pidl(peb
, &ebev
, NULL
, SBSP_ABSOLUTE
, S_OK
, 0, 0, 0, 0);
1386 test_browse_pidl_sb(peb2
, &ebev
, NULL
, SBSP_ABSOLUTE
, S_OK
, 0, 0, 0, 0);
1387 test_browse_pidl(peb
, &ebev
, NULL
, SBSP_DEFBROWSER
, S_OK
, 0, 0, 0, 0);
1388 test_browse_pidl_sb(peb2
, &ebev
, NULL
, SBSP_DEFBROWSER
, S_OK
, 0, 0, 0, 0);
1389 test_browse_pidl(peb
, &ebev
, pidl_current
, SBSP_SAMEBROWSER
, S_OK
, 1, 1, 0, 1);
1390 test_browse_pidl_sb(peb2
, &ebev
, pidl_current
, SBSP_SAMEBROWSER
, S_OK
, 1, 1, 0, 1);
1391 test_browse_pidl(peb
, &ebev
, pidl_current
, SBSP_SAMEBROWSER
, S_OK
, 1, 0, 0, 1);
1392 test_browse_pidl_sb(peb2
, &ebev
, pidl_current
, SBSP_SAMEBROWSER
, S_OK
, 1, 0, 0, 1);
1394 test_browse_pidl(peb
, &ebev
, pidl_current
, SBSP_EXPLOREMODE
, E_INVALIDARG
, 0, 0, 0, 0);
1395 test_browse_pidl_sb(peb2
, &ebev
, pidl_current
, SBSP_EXPLOREMODE
, E_INVALIDARG
, 0, 0, 0, 0);
1396 test_browse_pidl(peb
, &ebev
, pidl_current
, SBSP_OPENMODE
, S_OK
, 1, 0, 0, 1);
1397 test_browse_pidl_sb(peb2
, &ebev
, pidl_current
, SBSP_OPENMODE
, S_OK
, 1, 0, 0, 1);
1399 /* SBSP_NEWBROWSER will return E_INVALIDARG, claims MSDN, but in
1400 * reality it works as one would expect (Windows 7 only?).
1404 IExplorerBrowser_BrowseToIDList(peb
, NULL
, SBSP_NEWBROWSER
);
1407 hr
= IExplorerBrowser_Unadvise(peb
, cookie
);
1408 ok(hr
== S_OK
, "Got 0x%08lx\n", hr
);
1409 IExplorerBrowser_Destroy(peb
);
1411 hr
= IExplorerBrowser_Unadvise(peb2
, cookie2
);
1412 ok(hr
== S_OK
, "Got 0x%08lx\n", hr
);
1413 IExplorerBrowser_Destroy(peb2
);
1416 /* Attempt browsing after destroyed */
1417 test_browse_pidl(peb
, &ebev
, pidl_child
, SBSP_ABSOLUTE
, HRESULT_FROM_WIN32(ERROR_BUSY
), 0, 0, 0, 0);
1418 test_browse_pidl_sb(peb2
, &ebev
, pidl_child
, SBSP_ABSOLUTE
, HRESULT_FROM_WIN32(ERROR_BUSY
), 0, 0, 0, 0);
1420 lres
= IExplorerBrowser_Release(peb
);
1421 ok(lres
== 0, "Got lres %ld\n", lres
);
1422 lres
= IExplorerBrowser_Release(peb2
);
1423 ok(lres
== 0, "Got lres %ld\n", lres
);
1425 /******************************************/
1426 /* Test some options that affect browsing */
1428 ebrowser_instantiate(&peb
);
1429 hr
= IExplorerBrowser_Advise(peb
, &ebev
.IExplorerBrowserEvents_iface
, &cookie
);
1430 ok(hr
== S_OK
, "Got 0x%08lx\n", hr
);
1431 hr
= IExplorerBrowser_SetOptions(peb
, EBO_NAVIGATEONCE
);
1432 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
1433 ebrowser_initialize(peb
);
1435 test_browse_pidl(peb
, &ebev
, pidl_current
, 0, S_OK
, 1, 1, 0, 1);
1436 test_browse_pidl(peb
, &ebev
, pidl_current
, 0, E_FAIL
, 0, 0, 0, 0);
1438 hr
= IExplorerBrowser_SetOptions(peb
, 0);
1439 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
1441 test_browse_pidl(peb
, &ebev
, pidl_current
, 0, S_OK
, 1, 0, 0, 1);
1442 test_browse_pidl(peb
, &ebev
, pidl_current
, 0, S_OK
, 1, 0, 0, 1);
1444 /* Difference in behavior lies where? */
1445 hr
= IExplorerBrowser_SetOptions(peb
, EBO_ALWAYSNAVIGATE
);
1446 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
1448 test_browse_pidl(peb
, &ebev
, pidl_current
, 0, S_OK
, 1, 0, 0, 1);
1449 test_browse_pidl(peb
, &ebev
, pidl_current
, 0, S_OK
, 1, 0, 0, 1);
1451 hr
= IExplorerBrowser_Unadvise(peb
, cookie
);
1452 ok(hr
== S_OK
, "Got 0x%08lx\n", hr
);
1454 IExplorerBrowser_Destroy(peb
);
1455 lres
= IExplorerBrowser_Release(peb
);
1456 ok(lres
== 0, "Got lres %ld\n", lres
);
1458 /* BrowseToObject tests */
1459 ebrowser_instantiate(&peb
);
1460 ebrowser_initialize(peb
);
1462 /* Browse to the desktop by passing an IShellFolder */
1463 hr
= SHGetDesktopFolder(&psf
);
1464 ok(hr
== S_OK
, "Got 0x%08lx\n", hr
);
1467 hr
= IExplorerBrowser_BrowseToObject(peb
, (IUnknown
*)psf
, SBSP_DEFBROWSER
);
1468 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
1469 if(hr
== S_OK
) process_msgs();
1471 IShellFolder_Release(psf
);
1474 /* Browse to the current directory by passing a ShellItem */
1475 hr
= pSHCreateShellItem(NULL
, NULL
, pidl_current
, &psi
);
1476 ok(hr
== S_OK
, "Got 0x%08lx\n", hr
);
1479 hr
= IExplorerBrowser_BrowseToObject(peb
, (IUnknown
*)psi
, SBSP_DEFBROWSER
);
1480 ok(hr
== S_OK
, "got (0x%08lx)\n", hr
);
1483 IShellItem_Release(psi
);
1486 IExplorerBrowser_Destroy(peb
);
1487 lres
= IExplorerBrowser_Release(peb
);
1488 ok(lres
== 0, "Got lres %ld\n", lres
);
1491 RemoveDirectoryW(child_path
);
1492 ILFree(pidl_current
);
1496 static void test_GetCurrentView(void)
1498 IExplorerBrowser
*peb
;
1502 /* GetCurrentView */
1503 ebrowser_instantiate(&peb
);
1507 /* Crashes under Windows 7 */
1508 IExplorerBrowser_GetCurrentView(peb
, NULL
, NULL
);
1510 hr
= IExplorerBrowser_GetCurrentView(peb
, NULL
, (void**)&punk
);
1511 ok(hr
== E_FAIL
, "Got 0x%08lx\n", hr
);
1513 #define test_gcv(iid, exp) \
1515 hr = IExplorerBrowser_GetCurrentView(peb, &iid, (void**)&punk); \
1516 ok(hr == exp, "(%s:)Expected (0x%08lx), got: (0x%08lx)\n", \
1518 if(SUCCEEDED(hr)) IUnknown_Release(punk); \
1521 test_gcv(IID_IUnknown
, E_FAIL
);
1522 test_gcv(IID_IUnknown
, E_FAIL
);
1523 test_gcv(IID_IShellView
, E_FAIL
);
1524 test_gcv(IID_IShellView2
, E_FAIL
);
1525 test_gcv(IID_IFolderView
, E_FAIL
);
1526 test_gcv(IID_IPersistFolder
, E_FAIL
);
1527 test_gcv(IID_IPersistFolder2
, E_FAIL
);
1528 test_gcv(IID_ICommDlgBrowser
, E_FAIL
);
1529 test_gcv(IID_ICommDlgBrowser2
, E_FAIL
);
1530 test_gcv(IID_ICommDlgBrowser3
, E_FAIL
);
1532 ebrowser_initialize(peb
);
1533 ebrowser_browse_to_desktop(peb
);
1535 test_gcv(IID_IUnknown
, S_OK
);
1536 test_gcv(IID_IUnknown
, S_OK
);
1537 test_gcv(IID_IShellView
, S_OK
);
1538 test_gcv(IID_IShellView2
, S_OK
);
1539 test_gcv(IID_IFolderView
, S_OK
);
1540 todo_wine
test_gcv(IID_IPersistFolder
, S_OK
);
1541 test_gcv(IID_IPersistFolder2
, E_NOINTERFACE
);
1542 test_gcv(IID_ICommDlgBrowser
, E_NOINTERFACE
);
1543 test_gcv(IID_ICommDlgBrowser2
, E_NOINTERFACE
);
1544 test_gcv(IID_ICommDlgBrowser3
, E_NOINTERFACE
);
1548 IExplorerBrowser_Destroy(peb
);
1549 IExplorerBrowser_Release(peb
);
1552 static void test_InputObject(void)
1554 IExplorerBrowser
*peb
;
1560 WPARAM supported_key_accels_mode1
[] = {
1561 VK_BACK
, VK_TAB
, VK_RETURN
, VK_PRIOR
, VK_NEXT
, VK_END
, VK_HOME
,
1562 VK_LEFT
, VK_UP
, VK_RIGHT
, VK_DOWN
, VK_DELETE
, VK_F1
, VK_F2
,
1563 VK_F5
, VK_F6
, VK_F10
, 0 };
1564 WPARAM supported_key_accels_mode2
[] = {
1565 VK_RETURN
, VK_PRIOR
, VK_NEXT
, VK_END
, VK_HOME
,
1566 VK_LEFT
, VK_UP
, VK_RIGHT
, VK_DOWN
, VK_DELETE
, VK_F1
, VK_F2
,
1577 ebrowser_instantiate(&peb
);
1578 hr
= IExplorerBrowser_QueryInterface(peb
, &IID_IInputObject
, (void**)&pio
);
1579 ok(hr
== S_OK
, "Got 0x%08lx\n", hr
);
1582 win_skip("IInputObject not supported.\n");
1586 /* Before initializing */
1587 hr
= IInputObject_TranslateAcceleratorIO(pio
, &msg_a
);
1588 todo_wine
ok(hr
== E_FAIL
, "Got 0x%08lx\n", hr
);
1590 hr
= IInputObject_HasFocusIO(pio
);
1591 todo_wine
ok(hr
== E_FAIL
, "Got 0x%08lx\n", hr
);
1593 hr
= IInputObject_UIActivateIO(pio
, TRUE
, &msg_a
);
1594 todo_wine
ok(hr
== S_OK
, "Got 0x%08lx\n", hr
);
1596 hr
= IInputObject_HasFocusIO(pio
);
1597 todo_wine
ok(hr
== E_FAIL
, "Got 0x%08lx\n", hr
);
1599 hr
= IInputObject_TranslateAcceleratorIO(pio
, &msg_a
);
1600 todo_wine
ok(hr
== E_FAIL
, "Got 0x%08lx\n", hr
);
1602 SetRect(&rc
, 0, 0, 100, 100);
1603 hr
= IExplorerBrowser_Initialize(peb
, hwnd
, &rc
, NULL
);
1604 ok(hr
== S_OK
, "Got 0x%08lx\n", hr
);
1606 hr
= IInputObject_HasFocusIO(pio
);
1607 todo_wine
ok(hr
== E_FAIL
, "Got 0x%08lx\n", hr
);
1609 hr
= IInputObject_TranslateAcceleratorIO(pio
, &msg_a
);
1610 todo_wine
ok(hr
== E_FAIL
, "Got 0x%08lx\n", hr
);
1612 /* Browse to the desktop */
1613 SHGetDesktopFolder(&psf
);
1614 hr
= IExplorerBrowser_BrowseToObject(peb
, (IUnknown
*)psf
, SBSP_DEFBROWSER
);
1615 ok(hr
== S_OK
, "Got 0x%08lx\n", hr
);
1616 IShellFolder_Release(psf
);
1618 hr
= IInputObject_UIActivateIO(pio
, TRUE
, &msg_a
);
1619 todo_wine
ok(hr
== S_OK
, "Got 0x%08lx\n", hr
);
1621 hr
= IInputObject_HasFocusIO(pio
);
1622 todo_wine
ok(hr
== S_OK
, "Got 0x%08lx\n", hr
);
1624 hr
= IInputObject_UIActivateIO(pio
, FALSE
, &msg_a
);
1625 todo_wine
ok(hr
== S_OK
, "Got 0x%08lx\n", hr
);
1627 hr
= IInputObject_HasFocusIO(pio
);
1628 todo_wine
ok(hr
== S_OK
, "Got 0x%08lx\n", hr
);
1630 hr
= IInputObject_TranslateAcceleratorIO(pio
, &msg_a
);
1632 key_accels
= supported_key_accels_mode1
;
1634 key_accels
= supported_key_accels_mode2
;
1636 for(i
= 0; i
< 0x100; i
++)
1640 for(j
= 0; key_accels
[j
] != 0; j
++)
1641 if(key_accels
[j
] == i
)
1649 hr
= IInputObject_TranslateAcceleratorIO(pio
, &msg_a
);
1650 todo_wine
ok(hr
== (found
? S_OK
: S_FALSE
), "Got 0x%08lx (%04x)\n", hr
, i
);
1652 Sleep(1000); /* Needed for w2k8 (64bit) */
1657 IInputObject_Release(pio
);
1658 IExplorerBrowser_Destroy(peb
);
1659 IExplorerBrowser_Release(peb
);
1662 static BOOL
test_instantiate_control(void)
1664 IExplorerBrowser
*peb
;
1667 hr
= ebrowser_instantiate(&peb
);
1668 ok(hr
== S_OK
|| hr
== REGDB_E_CLASSNOTREG
, "Got (0x%08lx)\n", hr
);
1672 IExplorerBrowser_Release(peb
);
1676 static void setup_window(void)
1679 static const WCHAR ebtestW
[] = {'e','b','t','e','s','t',0};
1681 ZeroMemory(&wc
, sizeof(WNDCLASSW
));
1682 wc
.lpfnWndProc
= DefWindowProcW
;
1683 wc
.lpszClassName
= ebtestW
;
1684 RegisterClassW(&wc
);
1685 hwnd
= CreateWindowExW(0, ebtestW
, NULL
, 0,
1688 ok(hwnd
!= NULL
, "Failed to create window for tests.\n");
1691 static void test_folder_settings(void)
1693 IExplorerBrowser
*browser
;
1694 FOLDERSETTINGS settings
;
1697 ebrowser_instantiate(&browser
);
1698 ebrowser_initialize(browser
);
1700 hr
= IExplorerBrowser_SetFolderSettings(browser
, NULL
);
1701 ok(hr
== E_INVALIDARG
, "Got hr %#lx.\n", hr
);
1703 settings
.ViewMode
= 0; settings
.fFlags
= FWF_NONE
;
1704 hr
= IExplorerBrowser_SetFolderSettings(browser
, &settings
);
1705 todo_wine
ok(hr
== E_INVALIDARG
, "Got hr %#lx.\n", hr
);
1707 IExplorerBrowser_Release(browser
);
1710 START_TEST(ebrowser
)
1712 OleInitialize(NULL
);
1714 if(!test_instantiate_control())
1716 win_skip("No ExplorerBrowser control..\n");
1722 init_function_pointers();
1724 test_QueryInterface();
1726 test_initialization();
1730 test_GetCurrentView();
1733 test_folder_settings();
1735 DestroyWindow(hwnd
);