dinput: Clear DIA_APPNOMAP BuildActionMap flag with specific device semantic.
[wine.git] / dlls / shell32 / tests / ebrowser.c
blob9402388f643c67d34544e964c8b4b340807e9001
1 /*
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
21 #include <stdio.h>
23 #define COBJMACROS
24 #define CONST_VTABLE
26 #include "shlobj.h"
27 #include "shlwapi.h"
29 #include "wine/test.h"
31 #include "initguid.h"
32 #include "mshtml.h"
34 static HWND hwnd;
36 static HRESULT (WINAPI *pSHCreateShellItem)(LPCITEMIDLIST,IShellFolder*,LPCITEMIDLIST,IShellItem**);
38 static void init_function_pointers(void)
40 HMODULE hmod;
42 hmod = GetModuleHandleA("shell32.dll");
43 pSHCreateShellItem = (void*)GetProcAddress(hmod, "SHCreateShellItem");
46 /*********************************************************************
47 * Some simple helpers
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)
57 RECT rc;
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;
65 HRESULT hr;
66 SHGetSpecialFolderLocation (hwnd, CSIDL_DESKTOP, &pidl_desktop);
67 hr = IExplorerBrowser_BrowseToIDList(peb, pidl_desktop, 0);
68 ILFree(pidl_desktop);
69 return hr;
72 /* Process some messages */
73 static void process_msgs(void)
75 MSG msg;
76 while(PeekMessageA( &msg, NULL, 0, 0, PM_REMOVE))
78 TranslateMessage(&msg);
79 DispatchMessageA(&msg);
83 /*********************************************************************
84 * IExplorerBrowserEvents implementation
86 typedef struct {
87 IExplorerBrowserEvents IExplorerBrowserEvents_iface;
88 LONG ref;
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);
122 This->pending++;
123 return S_OK;
126 static HRESULT WINAPI IExplorerBrowserEvents_fnOnNavigationComplete(IExplorerBrowserEvents *iface,
127 PCIDLIST_ABSOLUTE pidlFolder)
129 IExplorerBrowserEventsImpl *This = impl_from_IExplorerBrowserEvents(iface);
130 This->completed++;
131 return S_OK;
133 static HRESULT WINAPI IExplorerBrowserEvents_fnOnNavigationFailed(IExplorerBrowserEvents *iface,
134 PCIDLIST_ABSOLUTE pidlFolder)
136 IExplorerBrowserEventsImpl *This = impl_from_IExplorerBrowserEvents(iface);
137 This->failed++;
138 return S_OK;
140 static HRESULT WINAPI IExplorerBrowserEvents_fnOnViewCreated(IExplorerBrowserEvents *iface,
141 IShellView *psv)
143 IExplorerBrowserEventsImpl *This = impl_from_IExplorerBrowserEvents(iface);
144 This->created++;
145 return S_OK;
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
162 typedef struct
164 IExplorerPaneVisibility IExplorerPaneVisibility_iface;
165 LONG ref;
166 LONG count;
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));
179 *ppvObj = NULL;
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);
194 if(!ref)
195 free(This);
197 return ref;
200 static HRESULT WINAPI IExplorerPaneVisibility_fnGetPaneState(IExplorerPaneVisibility *iface,
201 REFEXPLORERPANE ep,
202 EXPLORERPANESTATE *peps)
204 IExplorerPaneVisibilityImpl *This = impl_from_IExplorerPaneVisibility(iface);
205 This->count++;
207 ok(ep != NULL, "ep is NULL.\n");
208 ok(peps != NULL, "peps is NULL.\n");
209 ok(*peps == 0, "got %ld\n", *peps);
211 *peps = EPS_FORCE;
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++;
220 else
222 trace("Unknown explorer pane: %s\n", wine_dbgstr_guid(ep));
223 This->unk++;
226 return S_OK;
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;
243 epv->ref = 1;
245 return epv;
248 /*********************************************************************
249 * ICommDlgBrowser3 implementation
251 typedef struct
253 ICommDlgBrowser3 ICommDlgBrowser3_iface;
254 LONG ref;
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));
268 *ppvObj = NULL;
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);
283 if(!ref)
284 free(This);
286 return ref;
289 static HRESULT WINAPI ICommDlgBrowser3_fnOnDefaultCommand(ICommDlgBrowser3* iface, IShellView *shv)
291 ICommDlgBrowser3Impl *This = impl_from_ICommDlgBrowser3(iface);
292 This->OnDefaultCommand++;
293 return E_NOTIMPL;
296 static HRESULT WINAPI ICommDlgBrowser3_fnOnStateChange(
297 ICommDlgBrowser3* iface,
298 IShellView *shv,
299 ULONG uChange)
301 ICommDlgBrowser3Impl *This = impl_from_ICommDlgBrowser3(iface);
302 This->OnStateChange++;
303 return E_NOTIMPL;
306 static HRESULT WINAPI ICommDlgBrowser3_fnIncludeObject(
307 ICommDlgBrowser3* iface,
308 IShellView *shv,
309 LPCITEMIDLIST pidl)
311 ICommDlgBrowser3Impl *This = impl_from_ICommDlgBrowser3(iface);
312 This->IncludeObject++;
313 return S_OK;
316 static HRESULT WINAPI ICommDlgBrowser3_fnNotify(
317 ICommDlgBrowser3* iface,
318 IShellView *ppshv,
319 DWORD dwNotifyType)
321 ICommDlgBrowser3Impl *This = impl_from_ICommDlgBrowser3(iface);
322 This->Notify++;
323 return E_NOTIMPL;
326 static HRESULT WINAPI ICommDlgBrowser3_fnGetDefaultMenuText(
327 ICommDlgBrowser3* iface,
328 IShellView *ppshv,
329 LPWSTR pszText,
330 int cchMax)
332 ICommDlgBrowser3Impl *This = impl_from_ICommDlgBrowser3(iface);
333 This->GetDefaultMenuText++;
334 return E_NOTIMPL;
337 static HRESULT WINAPI ICommDlgBrowser3_fnGetViewFlags(
338 ICommDlgBrowser3* iface,
339 DWORD *pdwFlags)
341 ICommDlgBrowser3Impl *This = impl_from_ICommDlgBrowser3(iface);
342 This->GetViewFlags++;
343 return E_NOTIMPL;
346 static HRESULT WINAPI ICommDlgBrowser3_fnOnColumnClicked(
347 ICommDlgBrowser3* iface,
348 IShellView *ppshv,
349 int iColumn)
351 ICommDlgBrowser3Impl *This = impl_from_ICommDlgBrowser3(iface);
352 This->OnColumnClicked++;
353 return E_NOTIMPL;
356 static HRESULT WINAPI ICommDlgBrowser3_fnGetCurrentFilter(
357 ICommDlgBrowser3* iface,
358 LPWSTR pszFileSpec,
359 int cchFileSpec)
361 ICommDlgBrowser3Impl *This = impl_from_ICommDlgBrowser3(iface);
362 This->GetCurrentFilter++;
363 return E_NOTIMPL;
366 static HRESULT WINAPI ICommDlgBrowser3_fnOnPreviewCreated(
367 ICommDlgBrowser3* iface,
368 IShellView *ppshv)
370 ICommDlgBrowser3Impl *This = impl_from_ICommDlgBrowser3(iface);
371 This->OnPreviewCreated++;
372 return E_NOTIMPL;
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;
397 cdb->ref = 1;
399 return cdb;
402 /*********************************************************************
403 * IServiceProvider Implementation
405 typedef struct {
406 IServiceProvider IServiceProvider_iface;
407 LONG ref;
408 struct services {
409 REFGUID service;
410 REFIID id;
411 void *punk;
412 } *interfaces;
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)
422 *ppvObj = NULL;
423 if(IsEqualIID(riid, &IID_IServiceProvider))
425 *ppvObj = iface;
426 IServiceProvider_AddRef(iface);
427 return S_OK;
430 if(IsEqualIID(riid, &IID_IOleCommandTarget))
432 /* Windows Vista. */
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);
451 if(!ref)
452 free(This);
454 return ref;
457 static HRESULT WINAPI IServiceProvider_fnQueryService(IServiceProvider *iface,
458 REFGUID guidService,
459 REFIID riid,
460 void **ppv)
462 IServiceProviderImpl *This = impl_from_IServiceProvider(iface);
463 UINT i;
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);
475 return S_OK;
479 *ppv = NULL;
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;
495 sp->ref = 1;
496 return sp;
499 static void test_QueryInterface(void)
501 IExplorerBrowser *peb;
502 IUnknown *punk;
503 HRESULT hr;
504 LONG lres;
506 hr = ebrowser_instantiate(&peb);
507 ok(hr == S_OK, "Got 0x%08lx\n", hr);
509 #define test_qinterface(iid, exp) \
510 do { \
511 hr = IExplorerBrowser_QueryInterface(peb, &iid, (void**)&punk); \
512 ok(hr == exp, "(%s:)Expected (0x%08lx), got (0x%08lx)\n", \
513 #iid, exp, hr); \
514 if(SUCCEEDED(hr)) IUnknown_Release(punk); \
515 } while(0)
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;
544 IShellBrowser *psb;
545 IUnknown *punk;
546 HRESULT hr;
547 HWND retHwnd;
548 LRESULT lres;
549 LONG ref;
551 ebrowser_instantiate(&peb);
552 hr = IExplorerBrowser_QueryInterface(peb, &IID_IShellBrowser, (void**)&psb);
553 ok(hr == S_OK, "Got 0x%08lx\n", hr);
554 if(FAILED(hr))
556 skip("Failed to get IShellBrowser interface.\n");
557 return;
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);
581 /* ::InsertMenuSB */
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);
589 /* ::SetMenuSB */
590 hr = IShellBrowser_SetMenuSB(psb, NULL, NULL, NULL);
591 ok(hr == E_NOTIMPL, "got (0x%08lx)\n", hr);
593 /***** Before EB::Initialize *****/
595 /* ::GetWindow */
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");
601 todo_wine
604 /* ::SendControlMsg */
605 lres = 0xDEADBEEF;
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);
610 lres = 0xDEADBEEF;
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 *****/
635 /* ::GetWindow */
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");
640 todo_wine
642 /* ::SendControlMsg */
643 hr = IShellBrowser_SendControlMsg(psb, FCW_STATUS, 0, 0, 0, NULL);
644 ok(hr == S_OK, "got (0x%08lx)\n", hr);
646 lres = 0xDEADBEEF;
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);
651 lres = 0xDEADBEEF;
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);
656 lres = 0xDEADBEEF;
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);
661 /* Returns S_OK */
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);
687 process_msgs();
688 hr = ebrowser_browse_to_desktop(peb);
689 ok(hr == S_OK, "got (0x%08lx)\n", hr);
690 process_msgs();
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;
707 IShellBrowser *psb;
708 HWND eb_hwnd;
709 HRESULT hr;
710 ULONG lres;
711 LONG style;
712 RECT rc;
714 ebrowser_instantiate(&peb);
716 if(0)
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);
742 /* Destroy again */
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 */
749 peb = NULL;
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);
756 if(SUCCEEDED(hr))
758 RECT eb_rc;
759 char buf[1024];
760 LONG expected_style;
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);
773 buf[0] = '\0';
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);
796 else
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);
829 SetRectEmpty(&rc);
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;
868 HRESULT hr;
869 LONG ref;
870 UINT i;
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},
878 {NULL}
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);
886 if(SUCCEEDED(hr))
888 spimpl->interfaces = expected;
890 hr = IObjectWithSite_SetSite(pow, (IUnknown*)&spimpl->IServiceProvider_iface);
891 ok(hr == S_OK, "Got 0x%08lx\n", hr);
893 if(FAILED(hr))
894 IObjectWithSite_Release(pow);
897 if(FAILED(hr))
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);
908 return;
911 ShowWindow(hwnd, TRUE);
912 ebrowser_initialize(peb);
913 ebrowser_browse_to_desktop(peb);
915 for(i = 0; i < 10; i++)
917 Sleep(100);
918 process_msgs();
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;
985 IShellBrowser *psb;
986 FOLDERSETTINGS fs;
987 ULONG lres;
988 EXPLORER_BROWSER_OPTIONS flags;
989 HDWP hdwp;
990 RECT rc;
991 HRESULT hr;
992 static const WCHAR winetest[] = {'W','i','n','e','T','e','s','t',0};
994 ebrowser_instantiate(&peb);
995 ebrowser_initialize(peb);
997 /* SetRect */
998 SetRectEmpty(&rc);
999 hr = IExplorerBrowser_SetRect(peb, NULL, rc);
1000 ok(hr == S_OK, "got (0x%08lx)\n", hr);
1002 SetRect(&rc, 100, 100, 10, 10);
1003 hr = IExplorerBrowser_SetRect(peb, NULL, rc);
1004 ok(hr == S_OK, "got (0x%08lx)\n", hr);
1006 /* SetRect with DeferWindowPos */
1007 SetRect(&rc, 0, 0, 10, 10);
1008 hdwp = BeginDeferWindowPos(1);
1009 hr = IExplorerBrowser_SetRect(peb, &hdwp, rc);
1010 ok(hr == S_OK, "got (0x%08lx)\n", hr);
1011 lres = EndDeferWindowPos(hdwp);
1012 ok(lres, "EndDeferWindowPos failed.\n");
1014 hdwp = NULL;
1015 hr = IExplorerBrowser_SetRect(peb, &hdwp, rc);
1016 ok(hr == S_OK, "got (0x%08lx)\n", hr);
1017 ok(hdwp == NULL, "got %p\n", hdwp);
1018 lres = EndDeferWindowPos(hdwp);
1019 ok(!lres, "EndDeferWindowPos succeeded unexpectedly.\n");
1021 /* Test positioning */
1022 SetRect(&rc, 10, 20, 50, 50);
1023 hr = IExplorerBrowser_SetRect(peb, NULL, rc);
1024 ok(hr == S_OK, "got (0x%08lx)\n", hr);
1025 hr = IExplorerBrowser_QueryInterface(peb, &IID_IShellBrowser, (void**)&psb);
1026 ok(hr == S_OK, "Got 0x%08lx\n", hr);
1027 if(SUCCEEDED(hr))
1029 HWND eb_hwnd;
1030 RECT eb_rc;
1031 static const RECT exp_rc = {11, 21, 49, 49};
1032 static const RECT exp_rc2 = {11, 21, 49, 24};
1034 hr = IShellBrowser_GetWindow(psb, &eb_hwnd);
1035 ok(hr == S_OK, "Got 0x%08lx\n", hr);
1037 GetClientRect(eb_hwnd, &eb_rc);
1038 MapWindowPoints(eb_hwnd, hwnd, (POINT*)&eb_rc, 2);
1039 ok(EqualRect(&eb_rc, &exp_rc), "Got rect %s\n", wine_dbgstr_rect(&eb_rc));
1041 /* Try resizing with invalid hdwp */
1042 rc.bottom = 25;
1043 hdwp = (HDWP)0xdeadbeef;
1044 hr = IExplorerBrowser_SetRect(peb, &hdwp, rc);
1045 ok(hr == E_FAIL, "Got 0x%08lx\n", hr);
1046 GetClientRect(eb_hwnd, &eb_rc);
1047 MapWindowPoints(eb_hwnd, hwnd, (POINT*)&eb_rc, 2);
1048 ok(EqualRect(&eb_rc, &exp_rc), "Got rect %s\n", wine_dbgstr_rect(&eb_rc));
1050 hdwp = NULL;
1051 hr = IExplorerBrowser_SetRect(peb, &hdwp, rc);
1052 ok(hr == S_OK, "Got 0x%08lx\n", hr);
1053 GetClientRect(eb_hwnd, &eb_rc);
1054 MapWindowPoints(eb_hwnd, hwnd, (POINT*)&eb_rc, 2);
1055 ok(EqualRect(&eb_rc, &exp_rc2), "Got rect %s\n", wine_dbgstr_rect(&eb_rc));
1057 IShellBrowser_Release(psb);
1060 IExplorerBrowser_Destroy(peb);
1061 IExplorerBrowser_Release(peb);
1063 /* GetOptions/SetOptions*/
1064 ebrowser_instantiate(&peb);
1066 if(0) {
1067 /* Crashes on Windows 7 */
1068 IExplorerBrowser_GetOptions(peb, NULL);
1071 hr = IExplorerBrowser_GetOptions(peb, &flags);
1072 ok(hr == S_OK, "got (0x%08lx)\n", hr);
1073 ok(flags == 0, "got (0x%08x)\n", flags);
1075 /* Settings preserved through Initialize. */
1076 hr = IExplorerBrowser_SetOptions(peb, 0xDEADBEEF);
1077 ok(hr == S_OK, "got (0x%08lx)\n", hr);
1079 ebrowser_initialize(peb);
1081 hr = IExplorerBrowser_GetOptions(peb, &flags);
1082 ok(flags == 0xDEADBEEF, "got (0x%08x)\n", flags);
1083 ok(hr == S_OK, "got (0x%08lx)\n", hr);
1085 IExplorerBrowser_Destroy(peb);
1086 IExplorerBrowser_Release(peb);
1088 ebrowser_instantiate(&peb);
1089 ebrowser_initialize(peb);
1091 /* SetFolderSettings */
1092 hr = IExplorerBrowser_SetFolderSettings(peb, NULL);
1093 ok(hr == E_INVALIDARG, "got (0x%08lx)\n", hr);
1094 fs.ViewMode = 0; fs.fFlags = 0;
1095 hr = IExplorerBrowser_SetFolderSettings(peb, &fs);
1096 todo_wine ok(hr == E_INVALIDARG, "got (0x%08lx)\n", hr);
1098 /* SetPropertyBag */
1099 hr = IExplorerBrowser_SetPropertyBag(peb, NULL);
1100 ok(hr == E_INVALIDARG, "Got 0x%08lx\n", hr);
1101 hr = IExplorerBrowser_SetPropertyBag(peb, winetest);
1102 ok(hr == S_OK, "Got 0x%08lx\n", hr);
1104 /* TODO: Test after browsing somewhere. */
1106 IExplorerBrowser_Destroy(peb);
1107 lres = IExplorerBrowser_Release(peb);
1108 ok(lres == 0, "Got %ld\n", lres);
1111 static void test_Advise(void)
1113 IExplorerBrowser *peb;
1114 IExplorerBrowserEvents *pebe;
1115 DWORD cookies[10];
1116 HRESULT hr;
1117 UINT i, ref;
1119 /* Set up our IExplorerBrowserEvents implementation */
1120 ebev.IExplorerBrowserEvents_iface.lpVtbl = &ebevents;
1121 pebe = &ebev.IExplorerBrowserEvents_iface;
1123 ebrowser_instantiate(&peb);
1125 if(0)
1127 /* Crashes on Windows 7 */
1128 IExplorerBrowser_Advise(peb, pebe, NULL);
1129 IExplorerBrowser_Advise(peb, NULL, &cookies[0]);
1132 /* Using Unadvise with a cookie that has yet to be given out
1133 * results in E_INVALIDARG */
1134 hr = IExplorerBrowser_Unadvise(peb, 11);
1135 ok(hr == E_INVALIDARG, "got (0x%08lx)\n", hr);
1137 /* Add some before initialization */
1138 for(i = 0; i < 5; i++)
1140 hr = IExplorerBrowser_Advise(peb, pebe, &cookies[i]);
1141 ok(hr == S_OK, "got (0x%08lx)\n", hr);
1144 ebrowser_initialize(peb);
1146 /* Add some after initialization */
1147 for(i = 5; i < 10; i++)
1149 hr = IExplorerBrowser_Advise(peb, pebe, &cookies[i]);
1150 ok(hr == S_OK, "got (0x%08lx)\n", hr);
1153 ok(ebev.ref == 10, "Got %ld\n", ebev.ref);
1155 ebev.completed = 0;
1156 ebrowser_browse_to_desktop(peb);
1157 process_msgs();
1158 ok(ebev.completed == 10, "Got %d\n", ebev.completed);
1160 /* Remove a bunch somewhere in the middle */
1161 for(i = 4; i < 8; i++)
1163 hr = IExplorerBrowser_Unadvise(peb, cookies[i]);
1164 ok(hr == S_OK, "got (0x%08lx)\n", hr);
1167 ebev.completed = 0;
1168 ebrowser_browse_to_desktop(peb);
1169 process_msgs();
1170 ok(ebev.completed == 6, "Got %d\n", ebev.completed);
1172 if(0)
1174 /* Using unadvise with a previously unadvised cookie results
1175 * in a crash. */
1176 IExplorerBrowser_Unadvise(peb, cookies[5]);
1179 /* Remove the rest. */
1180 for(i = 0; i < 10; i++)
1182 if(i<4||i>7)
1184 hr = IExplorerBrowser_Unadvise(peb, cookies[i]);
1185 ok(hr == S_OK, "%d: got (0x%08lx)\n", i, hr);
1189 ok(ebev.ref == 0, "Got %ld\n", ebev.ref);
1191 ebev.completed = 0;
1192 ebrowser_browse_to_desktop(peb);
1193 process_msgs();
1194 ok(ebev.completed == 0, "Got %d\n", ebev.completed);
1196 /* ::Destroy implies ::Unadvise. */
1197 hr = IExplorerBrowser_Advise(peb, pebe, &cookies[0]);
1198 ok(hr == S_OK, "Got 0x%08lx\n", hr);
1199 ok(ebev.ref == 1, "Got %ld\n", ebev.ref);
1201 hr = IExplorerBrowser_Destroy(peb);
1202 ok(hr == S_OK, "Got 0x%08lx\n", hr);
1203 ok(ebev.ref == 0, "Got %ld\n", ebev.ref);
1205 ref = IExplorerBrowser_Release(peb);
1206 ok(!ref, "Got %d\n", ref);
1209 /* Based on PathAddBackslashW from dlls/shlwapi/path.c */
1210 static LPWSTR myPathAddBackslashW( LPWSTR lpszPath )
1212 size_t iLen;
1214 if (!lpszPath || (iLen = lstrlenW(lpszPath)) >= MAX_PATH)
1215 return NULL;
1217 if (iLen)
1219 lpszPath += iLen;
1220 if (lpszPath[-1] != '\\')
1222 *lpszPath++ = '\\';
1223 *lpszPath = '\0';
1226 return lpszPath;
1229 static void test_browse_pidl_(IExplorerBrowser *peb, IExplorerBrowserEventsImpl *ebev,
1230 LPITEMIDLIST pidl, UINT uFlags,
1231 HRESULT hr_exp, UINT pending, UINT created, UINT failed, UINT completed,
1232 const char *file, int line)
1234 HRESULT hr;
1235 ebev->completed = ebev->created = ebev->pending = ebev->failed = 0;
1237 hr = IExplorerBrowser_BrowseToIDList(peb, pidl, uFlags);
1238 ok_(file, line) (hr == hr_exp, "BrowseToIDList returned 0x%08lx\n", hr);
1239 process_msgs();
1241 ok_(file, line)
1242 (ebev->pending == pending && ebev->created == created &&
1243 ebev->failed == failed && ebev->completed == completed,
1244 "Events occurred: %d, %d, %d, %d\n",
1245 ebev->pending, ebev->created, ebev->failed, ebev->completed);
1247 #define test_browse_pidl(peb, ebev, pidl, uFlags, hr, p, cr, f, co) \
1248 test_browse_pidl_(peb, ebev, pidl, uFlags, hr, p, cr, f, co, __FILE__, __LINE__)
1250 static void test_browse_pidl_sb_(IExplorerBrowser *peb, IExplorerBrowserEventsImpl *ebev,
1251 LPITEMIDLIST pidl, UINT uFlags,
1252 HRESULT hr_exp, UINT pending, UINT created, UINT failed, UINT completed,
1253 const char *file, int line)
1255 IShellBrowser *psb;
1256 HRESULT hr;
1258 hr = IExplorerBrowser_QueryInterface(peb, &IID_IShellBrowser, (void**)&psb);
1259 ok_(file, line) (hr == S_OK, "QueryInterface returned 0x%08lx\n", hr);
1260 if(SUCCEEDED(hr))
1262 ebev->completed = ebev->created = ebev->pending = ebev->failed = 0;
1264 hr = IShellBrowser_BrowseObject(psb, pidl, uFlags);
1265 ok_(file, line) (hr == hr_exp, "BrowseObject returned 0x%08lx\n", hr);
1266 process_msgs();
1268 ok_(file, line)
1269 (ebev->pending == pending && ebev->created == created &&
1270 ebev->failed == failed && ebev->completed == completed,
1271 "Events occurred: %d, %d, %d, %d\n",
1272 ebev->pending, ebev->created, ebev->failed, ebev->completed);
1274 IShellBrowser_Release(psb);
1277 #define test_browse_pidl_sb(peb, ebev, pidl, uFlags, hr, p, cr, f, co) \
1278 test_browse_pidl_sb_(peb, ebev, pidl, uFlags, hr, p, cr, f, co, __FILE__, __LINE__)
1280 static void test_navigation(void)
1282 IExplorerBrowser *peb, *peb2;
1283 IFolderView *pfv;
1284 IShellItem *psi;
1285 IShellFolder *psf;
1286 LPITEMIDLIST pidl_current, pidl_child;
1287 DWORD cookie, cookie2;
1288 HRESULT hr;
1289 LONG lres;
1290 WCHAR current_path[MAX_PATH];
1291 WCHAR child_path[MAX_PATH];
1292 static const WCHAR testfolderW[] =
1293 {'w','i','n','e','t','e','s','t','f','o','l','d','e','r','\0'};
1295 ok(pSHCreateShellItem != NULL, "pSHCreateShellItem unexpectedly missing.\n");
1297 GetCurrentDirectoryW(MAX_PATH, current_path);
1298 if(!current_path[0])
1300 skip("Failed to create test-directory.\n");
1301 return;
1304 lstrcpyW(child_path, current_path);
1305 myPathAddBackslashW(child_path);
1306 lstrcatW(child_path, testfolderW);
1308 CreateDirectoryW(child_path, NULL);
1310 hr = SHParseDisplayName(current_path, NULL, &pidl_current, 0, NULL);
1311 ok(hr == S_OK, "Failed to parse a path, hr %#lx.\n", hr);
1312 hr = SHParseDisplayName(child_path, NULL, &pidl_child, 0, NULL);
1313 ok(hr == S_OK, "Failed to parse a path, hr %#lx.\n", hr);
1315 ebrowser_instantiate(&peb);
1316 ebrowser_initialize(peb);
1318 ebrowser_instantiate(&peb2);
1319 ebrowser_initialize(peb2);
1321 /* Set up our IExplorerBrowserEvents implementation */
1322 ebev.IExplorerBrowserEvents_iface.lpVtbl = &ebevents;
1324 IExplorerBrowser_Advise(peb, &ebev.IExplorerBrowserEvents_iface, &cookie);
1325 IExplorerBrowser_Advise(peb2, &ebev.IExplorerBrowserEvents_iface, &cookie2);
1327 /* These should all fail */
1328 test_browse_pidl(peb, &ebev, 0, SBSP_ABSOLUTE | SBSP_RELATIVE, E_FAIL, 0, 0, 0, 0);
1329 test_browse_pidl_sb(peb2, &ebev, 0, SBSP_ABSOLUTE | SBSP_RELATIVE, E_FAIL, 0, 0, 0, 0);
1330 test_browse_pidl(peb, &ebev, 0, SBSP_ABSOLUTE, E_INVALIDARG, 0, 0, 0, 0);
1331 test_browse_pidl_sb(peb2, &ebev, 0, SBSP_ABSOLUTE, E_INVALIDARG, 0, 0, 0, 0);
1332 test_browse_pidl(peb, &ebev, 0, SBSP_RELATIVE, E_FAIL, 0, 0, 0, 0);
1333 test_browse_pidl_sb(peb2, &ebev, 0, SBSP_RELATIVE, E_FAIL, 0, 0, 0, 0);
1334 test_browse_pidl(peb, &ebev, 0, SBSP_PARENT, E_FAIL, 0, 0, 0, 0);
1335 test_browse_pidl_sb(peb2, &ebev, 0, SBSP_PARENT, E_FAIL, 0, 0, 0, 0);
1336 test_browse_pidl(peb, &ebev, 0, SBSP_NAVIGATEFORWARD, E_FAIL, 0, 0, 0, 0);
1337 test_browse_pidl_sb(peb2, &ebev, 0, SBSP_NAVIGATEFORWARD, E_FAIL, 0, 0, 0, 0);
1338 test_browse_pidl(peb, &ebev, 0, SBSP_NAVIGATEBACK, E_FAIL, 0, 0, 0, 0);
1339 test_browse_pidl_sb(peb2, &ebev, 0, SBSP_NAVIGATEBACK, E_FAIL, 0, 0, 0, 0);
1341 /* "The first browse is synchronous" */
1342 test_browse_pidl(peb, &ebev, pidl_child, SBSP_ABSOLUTE, S_OK, 1, 1, 0, 1);
1343 test_browse_pidl_sb(peb2, &ebev, pidl_child, SBSP_ABSOLUTE, S_OK, 1, 1, 0, 1);
1345 /* Navigate empty history */
1346 test_browse_pidl(peb, &ebev, 0, SBSP_NAVIGATEFORWARD, S_OK, 0, 0, 0, 0);
1347 test_browse_pidl_sb(peb2, &ebev, 0, SBSP_NAVIGATEFORWARD, S_OK, 0, 0, 0, 0);
1348 test_browse_pidl(peb, &ebev, 0, SBSP_NAVIGATEBACK, S_OK, 0, 0, 0, 0);
1349 test_browse_pidl_sb(peb2, &ebev, 0, SBSP_NAVIGATEBACK, S_OK, 0, 0, 0, 0);
1351 /* Navigate history */
1352 test_browse_pidl(peb, &ebev, 0, SBSP_PARENT, S_OK, 1, 1, 0, 1);
1353 test_browse_pidl_sb(peb2, &ebev, 0, SBSP_PARENT, S_OK, 1, 1, 0, 1);
1354 test_browse_pidl(peb, &ebev, 0, SBSP_NAVIGATEBACK, S_OK, 1, 1, 0, 1);
1355 test_browse_pidl_sb(peb2, &ebev, 0, SBSP_NAVIGATEBACK, S_OK, 1, 1, 0, 1);
1356 test_browse_pidl(peb, &ebev, 0, SBSP_NAVIGATEFORWARD, S_OK, 1, 1, 0, 1);
1357 test_browse_pidl_sb(peb2, &ebev, 0, SBSP_NAVIGATEFORWARD, S_OK, 1, 1, 0, 1);
1358 test_browse_pidl(peb, &ebev, 0, SBSP_ABSOLUTE, S_OK, 0, 0, 0, 0);
1359 test_browse_pidl_sb(peb2, &ebev, 0, SBSP_ABSOLUTE, S_OK, 0, 0, 0, 0);
1361 /* Relative navigation */
1362 test_browse_pidl(peb, &ebev, pidl_current, SBSP_ABSOLUTE, S_OK, 1, 0, 0, 1);
1363 test_browse_pidl_sb(peb2, &ebev, pidl_current, SBSP_ABSOLUTE, S_OK, 1, 0, 0, 1);
1365 hr = IExplorerBrowser_GetCurrentView(peb, &IID_IFolderView, (void**)&pfv);
1366 ok(hr == S_OK, "Got 0x%08lx\n", hr);
1367 if(SUCCEEDED(hr))
1369 LPITEMIDLIST pidl_relative;
1371 hr = IFolderView_GetFolder(pfv, &IID_IShellFolder, (void**)&psf);
1372 ok(hr == S_OK, "Got 0x%08lx\n", hr);
1373 hr = IShellFolder_ParseDisplayName(psf, NULL, NULL, (LPWSTR)testfolderW,
1374 NULL, &pidl_relative, NULL);
1375 ok(hr == S_OK, "Got 0x%08lx\n", hr);
1377 /* Browsing to another location here before using the
1378 * pidl_relative would make ExplorerBrowser in Windows 7 show a
1379 * not-available dialog. Also, passing a relative pidl without
1380 * specifying SBSP_RELATIVE makes it look for the pidl on the
1381 * desktop
1384 test_browse_pidl(peb, &ebev, pidl_relative, SBSP_RELATIVE, S_OK, 1, 1, 0, 1);
1385 test_browse_pidl_sb(peb2, &ebev, pidl_relative, SBSP_RELATIVE, S_OK, 1, 1, 0, 1);
1387 ILFree(pidl_relative);
1388 IShellFolder_Release(psf);
1389 IFolderView_Release(pfv);
1392 /* misc **/
1393 test_browse_pidl(peb, &ebev, NULL, SBSP_ABSOLUTE, S_OK, 0, 0, 0, 0);
1394 test_browse_pidl_sb(peb2, &ebev, NULL, SBSP_ABSOLUTE, S_OK, 0, 0, 0, 0);
1395 test_browse_pidl(peb, &ebev, NULL, SBSP_DEFBROWSER, S_OK, 0, 0, 0, 0);
1396 test_browse_pidl_sb(peb2, &ebev, NULL, SBSP_DEFBROWSER, S_OK, 0, 0, 0, 0);
1397 test_browse_pidl(peb, &ebev, pidl_current, SBSP_SAMEBROWSER, S_OK, 1, 1, 0, 1);
1398 test_browse_pidl_sb(peb2, &ebev, pidl_current, SBSP_SAMEBROWSER, S_OK, 1, 1, 0, 1);
1399 test_browse_pidl(peb, &ebev, pidl_current, SBSP_SAMEBROWSER, S_OK, 1, 0, 0, 1);
1400 test_browse_pidl_sb(peb2, &ebev, pidl_current, SBSP_SAMEBROWSER, S_OK, 1, 0, 0, 1);
1402 test_browse_pidl(peb, &ebev, pidl_current, SBSP_EXPLOREMODE, E_INVALIDARG, 0, 0, 0, 0);
1403 test_browse_pidl_sb(peb2, &ebev, pidl_current, SBSP_EXPLOREMODE, E_INVALIDARG, 0, 0, 0, 0);
1404 test_browse_pidl(peb, &ebev, pidl_current, SBSP_OPENMODE, S_OK, 1, 0, 0, 1);
1405 test_browse_pidl_sb(peb2, &ebev, pidl_current, SBSP_OPENMODE, S_OK, 1, 0, 0, 1);
1407 /* SBSP_NEWBROWSER will return E_INVALIDARG, claims MSDN, but in
1408 * reality it works as one would expect (Windows 7 only?).
1410 if(0)
1412 IExplorerBrowser_BrowseToIDList(peb, NULL, SBSP_NEWBROWSER);
1415 hr = IExplorerBrowser_Unadvise(peb, cookie);
1416 ok(hr == S_OK, "Got 0x%08lx\n", hr);
1417 IExplorerBrowser_Destroy(peb);
1418 process_msgs();
1419 hr = IExplorerBrowser_Unadvise(peb2, cookie2);
1420 ok(hr == S_OK, "Got 0x%08lx\n", hr);
1421 IExplorerBrowser_Destroy(peb2);
1422 process_msgs();
1424 /* Attempt browsing after destroyed */
1425 test_browse_pidl(peb, &ebev, pidl_child, SBSP_ABSOLUTE, HRESULT_FROM_WIN32(ERROR_BUSY), 0, 0, 0, 0);
1426 test_browse_pidl_sb(peb2, &ebev, pidl_child, SBSP_ABSOLUTE, HRESULT_FROM_WIN32(ERROR_BUSY), 0, 0, 0, 0);
1428 lres = IExplorerBrowser_Release(peb);
1429 ok(lres == 0, "Got lres %ld\n", lres);
1430 lres = IExplorerBrowser_Release(peb2);
1431 ok(lres == 0, "Got lres %ld\n", lres);
1433 /******************************************/
1434 /* Test some options that affect browsing */
1436 ebrowser_instantiate(&peb);
1437 hr = IExplorerBrowser_Advise(peb, &ebev.IExplorerBrowserEvents_iface, &cookie);
1438 ok(hr == S_OK, "Got 0x%08lx\n", hr);
1439 hr = IExplorerBrowser_SetOptions(peb, EBO_NAVIGATEONCE);
1440 ok(hr == S_OK, "got (0x%08lx)\n", hr);
1441 ebrowser_initialize(peb);
1443 test_browse_pidl(peb, &ebev, pidl_current, 0, S_OK, 1, 1, 0, 1);
1444 test_browse_pidl(peb, &ebev, pidl_current, 0, E_FAIL, 0, 0, 0, 0);
1446 hr = IExplorerBrowser_SetOptions(peb, 0);
1447 ok(hr == S_OK, "got (0x%08lx)\n", hr);
1449 test_browse_pidl(peb, &ebev, pidl_current, 0, S_OK, 1, 0, 0, 1);
1450 test_browse_pidl(peb, &ebev, pidl_current, 0, S_OK, 1, 0, 0, 1);
1452 /* Difference in behavior lies where? */
1453 hr = IExplorerBrowser_SetOptions(peb, EBO_ALWAYSNAVIGATE);
1454 ok(hr == S_OK, "got (0x%08lx)\n", hr);
1456 test_browse_pidl(peb, &ebev, pidl_current, 0, S_OK, 1, 0, 0, 1);
1457 test_browse_pidl(peb, &ebev, pidl_current, 0, S_OK, 1, 0, 0, 1);
1459 hr = IExplorerBrowser_Unadvise(peb, cookie);
1460 ok(hr == S_OK, "Got 0x%08lx\n", hr);
1462 IExplorerBrowser_Destroy(peb);
1463 lres = IExplorerBrowser_Release(peb);
1464 ok(lres == 0, "Got lres %ld\n", lres);
1466 /* BrowseToObject tests */
1467 ebrowser_instantiate(&peb);
1468 ebrowser_initialize(peb);
1470 /* Browse to the desktop by passing an IShellFolder */
1471 hr = SHGetDesktopFolder(&psf);
1472 ok(hr == S_OK, "Got 0x%08lx\n", hr);
1473 if(SUCCEEDED(hr))
1475 hr = IExplorerBrowser_BrowseToObject(peb, (IUnknown*)psf, SBSP_DEFBROWSER);
1476 ok(hr == S_OK, "got (0x%08lx)\n", hr);
1477 if(hr == S_OK) process_msgs();
1479 IShellFolder_Release(psf);
1482 /* Browse to the current directory by passing a ShellItem */
1483 hr = pSHCreateShellItem(NULL, NULL, pidl_current, &psi);
1484 ok(hr == S_OK, "Got 0x%08lx\n", hr);
1485 if(SUCCEEDED(hr))
1487 hr = IExplorerBrowser_BrowseToObject(peb, (IUnknown*)psi, SBSP_DEFBROWSER);
1488 ok(hr == S_OK, "got (0x%08lx)\n", hr);
1489 process_msgs();
1491 IShellItem_Release(psi);
1494 IExplorerBrowser_Destroy(peb);
1495 lres = IExplorerBrowser_Release(peb);
1496 ok(lres == 0, "Got lres %ld\n", lres);
1498 /* Cleanup */
1499 RemoveDirectoryW(child_path);
1500 ILFree(pidl_current);
1501 ILFree(pidl_child);
1504 static void test_GetCurrentView(void)
1506 IExplorerBrowser *peb;
1507 IUnknown *punk;
1508 HRESULT hr;
1510 /* GetCurrentView */
1511 ebrowser_instantiate(&peb);
1513 if(0)
1515 /* Crashes under Windows 7 */
1516 IExplorerBrowser_GetCurrentView(peb, NULL, NULL);
1518 hr = IExplorerBrowser_GetCurrentView(peb, NULL, (void**)&punk);
1519 ok(hr == E_FAIL, "Got 0x%08lx\n", hr);
1521 #define test_gcv(iid, exp) \
1522 do { \
1523 hr = IExplorerBrowser_GetCurrentView(peb, &iid, (void**)&punk); \
1524 ok(hr == exp, "(%s:)Expected (0x%08lx), got: (0x%08lx)\n", \
1525 #iid ,exp, hr); \
1526 if(SUCCEEDED(hr)) IUnknown_Release(punk); \
1527 } while(0)
1529 test_gcv(IID_IUnknown, E_FAIL);
1530 test_gcv(IID_IUnknown, E_FAIL);
1531 test_gcv(IID_IShellView, E_FAIL);
1532 test_gcv(IID_IShellView2, E_FAIL);
1533 test_gcv(IID_IFolderView, E_FAIL);
1534 test_gcv(IID_IPersistFolder, E_FAIL);
1535 test_gcv(IID_IPersistFolder2, E_FAIL);
1536 test_gcv(IID_ICommDlgBrowser, E_FAIL);
1537 test_gcv(IID_ICommDlgBrowser2, E_FAIL);
1538 test_gcv(IID_ICommDlgBrowser3, E_FAIL);
1540 ebrowser_initialize(peb);
1541 ebrowser_browse_to_desktop(peb);
1543 test_gcv(IID_IUnknown, S_OK);
1544 test_gcv(IID_IUnknown, S_OK);
1545 test_gcv(IID_IShellView, S_OK);
1546 test_gcv(IID_IShellView2, S_OK);
1547 test_gcv(IID_IFolderView, S_OK);
1548 todo_wine test_gcv(IID_IPersistFolder, S_OK);
1549 test_gcv(IID_IPersistFolder2, E_NOINTERFACE);
1550 test_gcv(IID_ICommDlgBrowser, E_NOINTERFACE);
1551 test_gcv(IID_ICommDlgBrowser2, E_NOINTERFACE);
1552 test_gcv(IID_ICommDlgBrowser3, E_NOINTERFACE);
1554 #undef test_gcv
1556 IExplorerBrowser_Destroy(peb);
1557 IExplorerBrowser_Release(peb);
1560 static void test_InputObject(void)
1562 IExplorerBrowser *peb;
1563 IShellFolder *psf;
1564 IInputObject *pio;
1565 HRESULT hr;
1566 RECT rc;
1567 UINT i;
1568 WPARAM supported_key_accels_mode1[] = {
1569 VK_BACK, VK_TAB, VK_RETURN, VK_PRIOR, VK_NEXT, VK_END, VK_HOME,
1570 VK_LEFT, VK_UP, VK_RIGHT, VK_DOWN, VK_DELETE, VK_F1, VK_F2,
1571 VK_F5, VK_F6, VK_F10, 0 };
1572 WPARAM supported_key_accels_mode2[] = {
1573 VK_RETURN, VK_PRIOR, VK_NEXT, VK_END, VK_HOME,
1574 VK_LEFT, VK_UP, VK_RIGHT, VK_DOWN, VK_DELETE, VK_F1, VK_F2,
1575 VK_F10, 0 };
1576 WPARAM *key_accels;
1577 MSG msg_a = {
1578 hwnd,
1579 WM_KEYDOWN,
1580 VK_F5, 0,
1581 GetTickCount(),
1582 {5, 2}
1585 ebrowser_instantiate(&peb);
1586 hr = IExplorerBrowser_QueryInterface(peb, &IID_IInputObject, (void**)&pio);
1587 ok(hr == S_OK, "Got 0x%08lx\n", hr);
1588 if(FAILED(hr))
1590 win_skip("IInputObject not supported.\n");
1591 return;
1594 /* Before initializing */
1595 hr = IInputObject_TranslateAcceleratorIO(pio, &msg_a);
1596 todo_wine ok(hr == E_FAIL, "Got 0x%08lx\n", hr);
1598 hr = IInputObject_HasFocusIO(pio);
1599 todo_wine ok(hr == E_FAIL, "Got 0x%08lx\n", hr);
1601 hr = IInputObject_UIActivateIO(pio, TRUE, &msg_a);
1602 todo_wine ok(hr == S_OK, "Got 0x%08lx\n", hr);
1604 hr = IInputObject_HasFocusIO(pio);
1605 todo_wine ok(hr == E_FAIL, "Got 0x%08lx\n", hr);
1607 hr = IInputObject_TranslateAcceleratorIO(pio, &msg_a);
1608 todo_wine ok(hr == E_FAIL, "Got 0x%08lx\n", hr);
1610 SetRect(&rc, 0, 0, 100, 100);
1611 hr = IExplorerBrowser_Initialize(peb, hwnd, &rc, NULL);
1612 ok(hr == S_OK, "Got 0x%08lx\n", hr);
1614 hr = IInputObject_HasFocusIO(pio);
1615 todo_wine ok(hr == E_FAIL, "Got 0x%08lx\n", hr);
1617 hr = IInputObject_TranslateAcceleratorIO(pio, &msg_a);
1618 todo_wine ok(hr == E_FAIL, "Got 0x%08lx\n", hr);
1620 /* Browse to the desktop */
1621 SHGetDesktopFolder(&psf);
1622 hr = IExplorerBrowser_BrowseToObject(peb, (IUnknown*)psf, SBSP_DEFBROWSER);
1623 ok(hr == S_OK, "Got 0x%08lx\n", hr);
1624 IShellFolder_Release(psf);
1626 hr = IInputObject_UIActivateIO(pio, TRUE, &msg_a);
1627 todo_wine ok(hr == S_OK, "Got 0x%08lx\n", hr);
1629 hr = IInputObject_HasFocusIO(pio);
1630 todo_wine ok(hr == S_OK, "Got 0x%08lx\n", hr);
1632 hr = IInputObject_UIActivateIO(pio, FALSE, &msg_a);
1633 todo_wine ok(hr == S_OK, "Got 0x%08lx\n", hr);
1635 hr = IInputObject_HasFocusIO(pio);
1636 todo_wine ok(hr == S_OK, "Got 0x%08lx\n", hr);
1638 hr = IInputObject_TranslateAcceleratorIO(pio, &msg_a);
1639 if(hr == S_OK)
1640 key_accels = supported_key_accels_mode1;
1641 else
1642 key_accels = supported_key_accels_mode2;
1644 for(i = 0; i < 0x100; i++)
1646 BOOL found = FALSE;
1647 UINT j;
1648 for(j = 0; key_accels[j] != 0; j++)
1649 if(key_accels[j] == i)
1651 found = TRUE;
1652 break;
1655 msg_a.wParam = i;
1656 process_msgs();
1657 hr = IInputObject_TranslateAcceleratorIO(pio, &msg_a);
1658 todo_wine ok(hr == (found ? S_OK : S_FALSE), "Got 0x%08lx (%04x)\n", hr, i);
1659 if(i == VK_F5)
1660 Sleep(1000); /* Needed for w2k8 (64bit) */
1663 process_msgs();
1665 IInputObject_Release(pio);
1666 IExplorerBrowser_Destroy(peb);
1667 IExplorerBrowser_Release(peb);
1670 static BOOL test_instantiate_control(void)
1672 IExplorerBrowser *peb;
1673 HRESULT hr;
1675 hr = ebrowser_instantiate(&peb);
1676 ok(hr == S_OK || hr == REGDB_E_CLASSNOTREG, "Got (0x%08lx)\n", hr);
1677 if(FAILED(hr))
1678 return FALSE;
1680 IExplorerBrowser_Release(peb);
1681 return TRUE;
1684 static void setup_window(void)
1686 WNDCLASSW wc;
1687 static const WCHAR ebtestW[] = {'e','b','t','e','s','t',0};
1689 ZeroMemory(&wc, sizeof(WNDCLASSW));
1690 wc.lpfnWndProc = DefWindowProcW;
1691 wc.lpszClassName = ebtestW;
1692 RegisterClassW(&wc);
1693 hwnd = CreateWindowExW(0, ebtestW, NULL, 0,
1694 0, 0, 500, 500,
1695 NULL, 0, 0, NULL);
1696 ok(hwnd != NULL, "Failed to create window for tests.\n");
1699 START_TEST(ebrowser)
1701 OleInitialize(NULL);
1703 if(!test_instantiate_control())
1705 win_skip("No ExplorerBrowser control..\n");
1706 OleUninitialize();
1707 return;
1710 setup_window();
1711 init_function_pointers();
1713 test_QueryInterface();
1714 test_SB_misc();
1715 test_initialization();
1716 test_basics();
1717 test_Advise();
1718 test_navigation();
1719 test_GetCurrentView();
1720 test_SetSite();
1721 test_InputObject();
1723 DestroyWindow(hwnd);
1724 OleUninitialize();