widl: Get rid of PowerPC support.
[wine.git] / dlls / shell32 / tests / ebrowser.c
blob7aefd14b377ade751d18855d25bc7c40523c31be
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/heap.h"
30 #include "wine/test.h"
32 #include "initguid.h"
33 #include "mshtml.h"
35 static HWND hwnd;
37 static HRESULT (WINAPI *pSHCreateShellItem)(LPCITEMIDLIST,IShellFolder*,LPCITEMIDLIST,IShellItem**);
39 static void init_function_pointers(void)
41 HMODULE hmod;
43 hmod = GetModuleHandleA("shell32.dll");
44 pSHCreateShellItem = (void*)GetProcAddress(hmod, "SHCreateShellItem");
47 /*********************************************************************
48 * Some simple helpers
50 static HRESULT ebrowser_instantiate(IExplorerBrowser **peb)
52 return CoCreateInstance(&CLSID_ExplorerBrowser, NULL, CLSCTX_INPROC_SERVER,
53 &IID_IExplorerBrowser, (void**)peb);
56 static HRESULT ebrowser_initialize(IExplorerBrowser *peb)
58 RECT rc;
59 SetRect(&rc, 0, 0, 500, 500);
60 return IExplorerBrowser_Initialize(peb, hwnd, &rc, NULL);
63 static HRESULT ebrowser_browse_to_desktop(IExplorerBrowser *peb)
65 LPITEMIDLIST pidl_desktop;
66 HRESULT hr;
67 SHGetSpecialFolderLocation (hwnd, CSIDL_DESKTOP, &pidl_desktop);
68 hr = IExplorerBrowser_BrowseToIDList(peb, pidl_desktop, 0);
69 ILFree(pidl_desktop);
70 return hr;
73 /* Process some messages */
74 static void process_msgs(void)
76 MSG msg;
77 while(PeekMessageA( &msg, NULL, 0, 0, PM_REMOVE))
79 TranslateMessage(&msg);
80 DispatchMessageA(&msg);
84 /*********************************************************************
85 * IExplorerBrowserEvents implementation
87 typedef struct {
88 IExplorerBrowserEvents IExplorerBrowserEvents_iface;
89 LONG ref;
90 UINT pending, created, completed, failed;
91 } IExplorerBrowserEventsImpl;
93 static IExplorerBrowserEventsImpl ebev;
95 static inline IExplorerBrowserEventsImpl *impl_from_IExplorerBrowserEvents(IExplorerBrowserEvents *iface)
97 return CONTAINING_RECORD(iface, IExplorerBrowserEventsImpl, IExplorerBrowserEvents_iface);
100 static HRESULT WINAPI IExplorerBrowserEvents_fnQueryInterface(IExplorerBrowserEvents *iface,
101 REFIID riid, void **ppvObj)
103 ok(0, "Never called.\n");
104 return E_NOINTERFACE;
107 static ULONG WINAPI IExplorerBrowserEvents_fnAddRef(IExplorerBrowserEvents *iface)
109 IExplorerBrowserEventsImpl *This = impl_from_IExplorerBrowserEvents(iface);
110 return InterlockedIncrement(&This->ref);
113 static ULONG WINAPI IExplorerBrowserEvents_fnRelease(IExplorerBrowserEvents *iface)
115 IExplorerBrowserEventsImpl *This = impl_from_IExplorerBrowserEvents(iface);
116 return InterlockedDecrement(&This->ref);
119 static HRESULT WINAPI IExplorerBrowserEvents_fnOnNavigationPending(IExplorerBrowserEvents *iface,
120 PCIDLIST_ABSOLUTE pidlFolder)
122 IExplorerBrowserEventsImpl *This = impl_from_IExplorerBrowserEvents(iface);
123 This->pending++;
124 return S_OK;
127 static HRESULT WINAPI IExplorerBrowserEvents_fnOnNavigationComplete(IExplorerBrowserEvents *iface,
128 PCIDLIST_ABSOLUTE pidlFolder)
130 IExplorerBrowserEventsImpl *This = impl_from_IExplorerBrowserEvents(iface);
131 This->completed++;
132 return S_OK;
134 static HRESULT WINAPI IExplorerBrowserEvents_fnOnNavigationFailed(IExplorerBrowserEvents *iface,
135 PCIDLIST_ABSOLUTE pidlFolder)
137 IExplorerBrowserEventsImpl *This = impl_from_IExplorerBrowserEvents(iface);
138 This->failed++;
139 return S_OK;
141 static HRESULT WINAPI IExplorerBrowserEvents_fnOnViewCreated(IExplorerBrowserEvents *iface,
142 IShellView *psv)
144 IExplorerBrowserEventsImpl *This = impl_from_IExplorerBrowserEvents(iface);
145 This->created++;
146 return S_OK;
149 static const IExplorerBrowserEventsVtbl ebevents =
151 IExplorerBrowserEvents_fnQueryInterface,
152 IExplorerBrowserEvents_fnAddRef,
153 IExplorerBrowserEvents_fnRelease,
154 IExplorerBrowserEvents_fnOnNavigationPending,
155 IExplorerBrowserEvents_fnOnViewCreated,
156 IExplorerBrowserEvents_fnOnNavigationComplete,
157 IExplorerBrowserEvents_fnOnNavigationFailed
160 /*********************************************************************
161 * IExplorerPaneVisibility implementation
163 typedef struct
165 IExplorerPaneVisibility IExplorerPaneVisibility_iface;
166 LONG ref;
167 LONG count;
168 LONG np, cp, cp_o, cp_v, dp, pp, qp, aqp, unk; /* The panes */
169 } IExplorerPaneVisibilityImpl;
171 static inline IExplorerPaneVisibilityImpl *impl_from_IExplorerPaneVisibility(IExplorerPaneVisibility *iface)
173 return CONTAINING_RECORD(iface, IExplorerPaneVisibilityImpl, IExplorerPaneVisibility_iface);
176 static HRESULT WINAPI IExplorerPaneVisibility_fnQueryInterface(IExplorerPaneVisibility *iface,
177 REFIID riid, LPVOID *ppvObj)
179 ok(0, "unexpected, %s\n", wine_dbgstr_guid(riid));
180 *ppvObj = NULL;
181 return E_NOINTERFACE;
184 static ULONG WINAPI IExplorerPaneVisibility_fnAddRef(IExplorerPaneVisibility *iface)
186 IExplorerPaneVisibilityImpl *This = impl_from_IExplorerPaneVisibility(iface);
187 return InterlockedIncrement(&This->ref);
190 static ULONG WINAPI IExplorerPaneVisibility_fnRelease(IExplorerPaneVisibility *iface)
192 IExplorerPaneVisibilityImpl *This = impl_from_IExplorerPaneVisibility(iface);
193 ULONG ref = InterlockedDecrement(&This->ref);
195 if(!ref)
196 heap_free(This);
198 return ref;
201 static HRESULT WINAPI IExplorerPaneVisibility_fnGetPaneState(IExplorerPaneVisibility *iface,
202 REFEXPLORERPANE ep,
203 EXPLORERPANESTATE *peps)
205 IExplorerPaneVisibilityImpl *This = impl_from_IExplorerPaneVisibility(iface);
206 This->count++;
208 ok(ep != NULL, "ep is NULL.\n");
209 ok(peps != NULL, "peps is NULL.\n");
210 ok(*peps == 0, "got %d\n", *peps);
212 *peps = EPS_FORCE;
213 if(IsEqualGUID(&EP_NavPane, ep)) This->np++;
214 else if(IsEqualGUID(&EP_Commands, ep)) This->cp++;
215 else if(IsEqualGUID(&EP_Commands_Organize, ep)) This->cp_o++;
216 else if(IsEqualGUID(&EP_Commands_View, ep)) This->cp_v++;
217 else if(IsEqualGUID(&EP_DetailsPane, ep)) This->dp++;
218 else if(IsEqualGUID(&EP_PreviewPane, ep)) This->pp++;
219 else if(IsEqualGUID(&EP_QueryPane, ep)) This->qp++;
220 else if(IsEqualGUID(&EP_AdvQueryPane, ep)) This->aqp++;
221 else
223 trace("Unknown explorer pane: %s\n", wine_dbgstr_guid(ep));
224 This->unk++;
227 return S_OK;
230 static const IExplorerPaneVisibilityVtbl epvvt =
232 IExplorerPaneVisibility_fnQueryInterface,
233 IExplorerPaneVisibility_fnAddRef,
234 IExplorerPaneVisibility_fnRelease,
235 IExplorerPaneVisibility_fnGetPaneState
238 static IExplorerPaneVisibilityImpl *create_explorerpanevisibility(void)
240 IExplorerPaneVisibilityImpl *epv;
242 epv = heap_alloc_zero(sizeof(*epv));
243 epv->IExplorerPaneVisibility_iface.lpVtbl = &epvvt;
244 epv->ref = 1;
246 return epv;
249 /*********************************************************************
250 * ICommDlgBrowser3 implementation
252 typedef struct
254 ICommDlgBrowser3 ICommDlgBrowser3_iface;
255 LONG ref;
256 UINT OnDefaultCommand, OnStateChange, IncludeObject;
257 UINT Notify, GetDefaultMenuText, GetViewFlags;
258 UINT OnColumnClicked, GetCurrentFilter, OnPreviewCreated;
259 } ICommDlgBrowser3Impl;
261 static inline ICommDlgBrowser3Impl *impl_from_ICommDlgBrowser3(ICommDlgBrowser3 *iface)
263 return CONTAINING_RECORD(iface, ICommDlgBrowser3Impl, ICommDlgBrowser3_iface);
266 static HRESULT WINAPI ICommDlgBrowser3_fnQueryInterface(ICommDlgBrowser3 *iface, REFIID riid, LPVOID *ppvObj)
268 ok(0, "unexpected %s\n", wine_dbgstr_guid(riid));
269 *ppvObj = NULL;
270 return E_NOINTERFACE;
273 static ULONG WINAPI ICommDlgBrowser3_fnAddRef(ICommDlgBrowser3 *iface)
275 ICommDlgBrowser3Impl *This = impl_from_ICommDlgBrowser3(iface);
276 return InterlockedIncrement(&This->ref);
279 static ULONG WINAPI ICommDlgBrowser3_fnRelease(ICommDlgBrowser3 *iface)
281 ICommDlgBrowser3Impl *This = impl_from_ICommDlgBrowser3(iface);
282 ULONG ref = InterlockedDecrement(&This->ref);
284 if(!ref)
285 heap_free(This);
287 return ref;
290 static HRESULT WINAPI ICommDlgBrowser3_fnOnDefaultCommand(ICommDlgBrowser3* iface, IShellView *shv)
292 ICommDlgBrowser3Impl *This = impl_from_ICommDlgBrowser3(iface);
293 This->OnDefaultCommand++;
294 return E_NOTIMPL;
297 static HRESULT WINAPI ICommDlgBrowser3_fnOnStateChange(
298 ICommDlgBrowser3* iface,
299 IShellView *shv,
300 ULONG uChange)
302 ICommDlgBrowser3Impl *This = impl_from_ICommDlgBrowser3(iface);
303 This->OnStateChange++;
304 return E_NOTIMPL;
307 static HRESULT WINAPI ICommDlgBrowser3_fnIncludeObject(
308 ICommDlgBrowser3* iface,
309 IShellView *shv,
310 LPCITEMIDLIST pidl)
312 ICommDlgBrowser3Impl *This = impl_from_ICommDlgBrowser3(iface);
313 This->IncludeObject++;
314 return S_OK;
317 static HRESULT WINAPI ICommDlgBrowser3_fnNotify(
318 ICommDlgBrowser3* iface,
319 IShellView *ppshv,
320 DWORD dwNotifyType)
322 ICommDlgBrowser3Impl *This = impl_from_ICommDlgBrowser3(iface);
323 This->Notify++;
324 return E_NOTIMPL;
327 static HRESULT WINAPI ICommDlgBrowser3_fnGetDefaultMenuText(
328 ICommDlgBrowser3* iface,
329 IShellView *ppshv,
330 LPWSTR pszText,
331 int cchMax)
333 ICommDlgBrowser3Impl *This = impl_from_ICommDlgBrowser3(iface);
334 This->GetDefaultMenuText++;
335 return E_NOTIMPL;
338 static HRESULT WINAPI ICommDlgBrowser3_fnGetViewFlags(
339 ICommDlgBrowser3* iface,
340 DWORD *pdwFlags)
342 ICommDlgBrowser3Impl *This = impl_from_ICommDlgBrowser3(iface);
343 This->GetViewFlags++;
344 return E_NOTIMPL;
347 static HRESULT WINAPI ICommDlgBrowser3_fnOnColumnClicked(
348 ICommDlgBrowser3* iface,
349 IShellView *ppshv,
350 int iColumn)
352 ICommDlgBrowser3Impl *This = impl_from_ICommDlgBrowser3(iface);
353 This->OnColumnClicked++;
354 return E_NOTIMPL;
357 static HRESULT WINAPI ICommDlgBrowser3_fnGetCurrentFilter(
358 ICommDlgBrowser3* iface,
359 LPWSTR pszFileSpec,
360 int cchFileSpec)
362 ICommDlgBrowser3Impl *This = impl_from_ICommDlgBrowser3(iface);
363 This->GetCurrentFilter++;
364 return E_NOTIMPL;
367 static HRESULT WINAPI ICommDlgBrowser3_fnOnPreviewCreated(
368 ICommDlgBrowser3* iface,
369 IShellView *ppshv)
371 ICommDlgBrowser3Impl *This = impl_from_ICommDlgBrowser3(iface);
372 This->OnPreviewCreated++;
373 return E_NOTIMPL;
376 static const ICommDlgBrowser3Vtbl cdbvtbl =
378 ICommDlgBrowser3_fnQueryInterface,
379 ICommDlgBrowser3_fnAddRef,
380 ICommDlgBrowser3_fnRelease,
381 ICommDlgBrowser3_fnOnDefaultCommand,
382 ICommDlgBrowser3_fnOnStateChange,
383 ICommDlgBrowser3_fnIncludeObject,
384 ICommDlgBrowser3_fnNotify,
385 ICommDlgBrowser3_fnGetDefaultMenuText,
386 ICommDlgBrowser3_fnGetViewFlags,
387 ICommDlgBrowser3_fnOnColumnClicked,
388 ICommDlgBrowser3_fnGetCurrentFilter,
389 ICommDlgBrowser3_fnOnPreviewCreated
392 static ICommDlgBrowser3Impl *create_commdlgbrowser3(void)
394 ICommDlgBrowser3Impl *cdb;
396 cdb = heap_alloc_zero(sizeof(*cdb));
397 cdb->ICommDlgBrowser3_iface.lpVtbl = &cdbvtbl;
398 cdb->ref = 1;
400 return cdb;
403 /*********************************************************************
404 * IServiceProvider Implementation
406 typedef struct {
407 IServiceProvider IServiceProvider_iface;
408 LONG ref;
409 struct services {
410 REFGUID service;
411 REFIID id;
412 void *punk;
413 } *interfaces;
414 } IServiceProviderImpl;
416 static inline IServiceProviderImpl *impl_from_IServiceProvider(IServiceProvider *iface)
418 return CONTAINING_RECORD(iface, IServiceProviderImpl, IServiceProvider_iface);
421 static HRESULT WINAPI IServiceProvider_fnQueryInterface(IServiceProvider *iface, REFIID riid, LPVOID *ppvObj)
423 *ppvObj = NULL;
424 if(IsEqualIID(riid, &IID_IServiceProvider))
426 *ppvObj = iface;
427 IServiceProvider_AddRef(iface);
428 return S_OK;
431 if(IsEqualIID(riid, &IID_IOleCommandTarget))
433 /* Windows Vista. */
434 return E_NOINTERFACE;
437 ok(0, "Unexpected interface requested, %s\n", wine_dbgstr_guid(riid));
438 return E_NOINTERFACE;
441 static ULONG WINAPI IServiceProvider_fnAddRef(IServiceProvider *iface)
443 IServiceProviderImpl *This = impl_from_IServiceProvider(iface);
444 return InterlockedIncrement(&This->ref);
447 static ULONG WINAPI IServiceProvider_fnRelease(IServiceProvider *iface)
449 IServiceProviderImpl *This = impl_from_IServiceProvider(iface);
450 LONG ref = InterlockedDecrement(&This->ref);
452 if(!ref)
453 heap_free(This);
455 return ref;
458 static HRESULT WINAPI IServiceProvider_fnQueryService(IServiceProvider *iface,
459 REFGUID guidService,
460 REFIID riid,
461 void **ppv)
463 IServiceProviderImpl *This = impl_from_IServiceProvider(iface);
464 UINT i;
466 if (winetest_debug > 1)
467 trace("QueryService(service %s, iid %s)\n", debugstr_guid(guidService), debugstr_guid(riid));
469 for(i = 0; This->interfaces[i].service != NULL; i++)
471 if(IsEqualGUID(This->interfaces[i].service, guidService) &&
472 IsEqualIID(This->interfaces[i].id, riid))
474 *ppv = This->interfaces[i].punk;
475 IUnknown_AddRef((IUnknown *)*ppv);
476 return S_OK;
480 *ppv = NULL;
481 return E_NOINTERFACE;
484 static const IServiceProviderVtbl spvtbl =
486 IServiceProvider_fnQueryInterface,
487 IServiceProvider_fnAddRef,
488 IServiceProvider_fnRelease,
489 IServiceProvider_fnQueryService
492 static IServiceProviderImpl *create_serviceprovider(void)
494 IServiceProviderImpl *sp = heap_alloc(sizeof(*sp));
495 sp->IServiceProvider_iface.lpVtbl = &spvtbl;
496 sp->ref = 1;
497 return sp;
500 static void test_QueryInterface(void)
502 IExplorerBrowser *peb;
503 IUnknown *punk;
504 HRESULT hr;
505 LONG lres;
507 hr = ebrowser_instantiate(&peb);
508 ok(hr == S_OK, "Got 0x%08x\n", hr);
510 #define test_qinterface(iid, exp) \
511 do { \
512 hr = IExplorerBrowser_QueryInterface(peb, &iid, (void**)&punk); \
513 ok(hr == exp, "(%s:)Expected (0x%08x), got (0x%08x)\n", \
514 #iid, exp, hr); \
515 if(SUCCEEDED(hr)) IUnknown_Release(punk); \
516 } while(0)
518 test_qinterface(IID_IUnknown, S_OK);
519 test_qinterface(IID_IExplorerBrowser, S_OK);
520 test_qinterface(IID_IShellBrowser, S_OK);
521 test_qinterface(IID_IOleWindow, S_OK);
522 test_qinterface(IID_ICommDlgBrowser, S_OK);
523 test_qinterface(IID_ICommDlgBrowser2, S_OK);
524 test_qinterface(IID_ICommDlgBrowser3, S_OK);
525 todo_wine test_qinterface(IID_IServiceProvider, S_OK);
526 test_qinterface(IID_IObjectWithSite, S_OK);
527 todo_wine test_qinterface(IID_IConnectionPointContainer, S_OK);
528 test_qinterface(IID_IOleObject, E_NOINTERFACE);
529 test_qinterface(IID_IViewObject, E_NOINTERFACE);
530 test_qinterface(IID_IViewObject2, E_NOINTERFACE);
531 test_qinterface(IID_IViewObjectEx, E_NOINTERFACE);
532 test_qinterface(IID_IConnectionPoint, E_NOINTERFACE);
533 test_qinterface(IID_IShellView, E_NOINTERFACE);
534 test_qinterface(IID_INameSpaceTreeControlEvents, E_NOINTERFACE);
536 #undef test_qinterface
538 lres = IExplorerBrowser_Release(peb);
539 ok(lres == 0, "Got %d\n", lres);
542 static void test_SB_misc(void)
544 IExplorerBrowser *peb;
545 IShellBrowser *psb;
546 IUnknown *punk;
547 HRESULT hr;
548 HWND retHwnd;
549 LRESULT lres;
550 LONG ref;
552 ebrowser_instantiate(&peb);
553 hr = IExplorerBrowser_QueryInterface(peb, &IID_IShellBrowser, (void**)&psb);
554 ok(hr == S_OK, "Got 0x%08x\n", hr);
555 if(FAILED(hr))
557 skip("Failed to get IShellBrowser interface.\n");
558 return;
561 /* Some unimplemented methods */
562 retHwnd = (HWND)0xdeadbeef;
563 hr = IShellBrowser_GetControlWindow(psb, FCW_TOOLBAR, &retHwnd);
564 ok(hr == E_NOTIMPL, "got (0x%08x)\n", hr);
565 ok(retHwnd == NULL || broken(retHwnd == (HWND)0xdeadbeef), "got %p\n", retHwnd);
567 retHwnd = (HWND)0xdeadbeef;
568 hr = IShellBrowser_GetControlWindow(psb, FCW_STATUS, &retHwnd);
569 ok(hr == E_NOTIMPL, "got (0x%08x)\n", hr);
570 ok(retHwnd == NULL || broken(retHwnd == (HWND)0xdeadbeef), "got %p\n", retHwnd);
572 retHwnd = (HWND)0xdeadbeef;
573 hr = IShellBrowser_GetControlWindow(psb, FCW_TREE, &retHwnd);
574 ok(hr == E_NOTIMPL, "got (0x%08x)\n", hr);
575 ok(retHwnd == NULL || broken(retHwnd == (HWND)0xdeadbeef), "got %p\n", retHwnd);
577 retHwnd = (HWND)0xdeadbeef;
578 hr = IShellBrowser_GetControlWindow(psb, FCW_PROGRESS, &retHwnd);
579 ok(hr == E_NOTIMPL, "got (0x%08x)\n", hr);
580 ok(retHwnd == NULL || broken(retHwnd == (HWND)0xdeadbeef), "got %p\n", retHwnd);
582 /* ::InsertMenuSB */
583 hr = IShellBrowser_InsertMenusSB(psb, NULL, NULL);
584 ok(hr == E_NOTIMPL, "got (0x%08x)\n", hr);
586 /* ::RemoveMenusSB */
587 hr = IShellBrowser_RemoveMenusSB(psb, NULL);
588 ok(hr == E_NOTIMPL, "got (0x%08x)\n", hr);
590 /* ::SetMenuSB */
591 hr = IShellBrowser_SetMenuSB(psb, NULL, NULL, NULL);
592 ok(hr == E_NOTIMPL, "got (0x%08x)\n", hr);
594 /***** Before EB::Initialize *****/
596 /* ::GetWindow */
597 retHwnd = (HWND)0xDEADBEEF;
598 hr = IShellBrowser_GetWindow(psb, &retHwnd);
599 ok(hr == E_FAIL, "got (0x%08x)\n", hr);
600 ok(retHwnd == (HWND)0xDEADBEEF, "HWND overwritten\n");
602 todo_wine
605 /* ::SendControlMsg */
606 lres = 0xDEADBEEF;
607 hr = IShellBrowser_SendControlMsg(psb, FCW_STATUS, 0, 0, 0, &lres);
608 ok(hr == S_OK, "got (0x%08x)\n", hr);
609 ok(lres == 0, "lres was %ld\n", lres);
611 lres = 0xDEADBEEF;
612 hr = IShellBrowser_SendControlMsg(psb, FCW_TOOLBAR, TB_CHECKBUTTON,
613 FCIDM_TB_SMALLICON, TRUE, &lres);
614 ok(hr == S_OK, "got (0x%08x)\n", hr);
615 ok(lres == 0, "lres was %ld\n", lres);
617 hr = IShellBrowser_SendControlMsg(psb, FCW_STATUS, 0, 0, 0, NULL);
618 ok(hr == S_OK, "got (0x%08x)\n", hr);
620 hr = IShellBrowser_SendControlMsg(psb, FCW_TREE, 0, 0, 0, NULL);
621 ok(hr == S_OK, "got (0x%08x)\n", hr);
623 hr = IShellBrowser_SendControlMsg(psb, FCW_PROGRESS, 0, 0, 0, NULL);
624 ok(hr == S_OK, "got (0x%08x)\n", hr);
627 /* ::QueryActiveShellView */
628 hr = IShellBrowser_QueryActiveShellView(psb, (IShellView**)&punk);
629 ok(hr == E_FAIL, "got (0x%08x)\n", hr);
631 /* Initialize ExplorerBrowser */
632 ebrowser_initialize(peb);
634 /***** After EB::Initialize *****/
636 /* ::GetWindow */
637 hr = IShellBrowser_GetWindow(psb, &retHwnd);
638 ok(hr == S_OK, "got (0x%08x)\n", hr);
639 ok(GetParent(retHwnd) == hwnd, "The HWND returned is not our child.\n");
641 todo_wine
643 /* ::SendControlMsg */
644 hr = IShellBrowser_SendControlMsg(psb, FCW_STATUS, 0, 0, 0, NULL);
645 ok(hr == S_OK, "got (0x%08x)\n", hr);
647 lres = 0xDEADBEEF;
648 hr = IShellBrowser_SendControlMsg(psb, FCW_TOOLBAR, 0, 0, 0, &lres);
649 ok(hr == S_OK, "got (0x%08x)\n", hr);
650 ok(lres == 0, "lres was %ld\n", lres);
652 lres = 0xDEADBEEF;
653 hr = IShellBrowser_SendControlMsg(psb, FCW_STATUS, 0, 0, 0, &lres);
654 ok(hr == S_OK, "got (0x%08x)\n", hr);
655 ok(lres == 0, "lres was %ld\n", lres);
657 lres = 0xDEADBEEF;
658 hr = IShellBrowser_SendControlMsg(psb, 1234, 0, 0, 0, &lres);
659 ok(hr == S_OK, "got (0x%08x)\n", hr);
660 ok(lres == 0, "lres was %ld\n", lres);
662 /* Returns S_OK */
663 hr = IShellBrowser_SetStatusTextSB(psb, NULL);
664 ok(hr == S_OK, "got (0x%08x)\n", hr);
666 hr = IShellBrowser_ContextSensitiveHelp(psb, FALSE);
667 ok(hr == S_OK, "got (0x%08x)\n", hr);
669 hr = IShellBrowser_EnableModelessSB(psb, TRUE);
670 ok(hr == S_OK, "got (0x%08x)\n", hr);
672 hr = IShellBrowser_SetToolbarItems(psb, NULL, 1, 1);
673 ok(hr == S_OK, "got (0x%08x)\n", hr);
676 hr = IShellBrowser_QueryActiveShellView(psb, (IShellView**)&punk);
677 ok(hr == E_FAIL, "got (0x%08x)\n", hr);
679 IShellBrowser_Release(psb);
680 IExplorerBrowser_Destroy(peb);
681 IExplorerBrowser_Release(peb);
683 /* Browse to the desktop. */
684 ebrowser_instantiate(&peb);
685 ebrowser_initialize(peb);
686 IExplorerBrowser_QueryInterface(peb, &IID_IShellBrowser, (void**)&psb);
688 process_msgs();
689 hr = ebrowser_browse_to_desktop(peb);
690 ok(hr == S_OK, "got (0x%08x)\n", hr);
691 process_msgs();
693 /****** After Browsing *****/
695 hr = IShellBrowser_QueryActiveShellView(psb, (IShellView**)&punk);
696 ok(hr == S_OK, "got (0x%08x)\n", hr);
697 if(SUCCEEDED(hr)) IUnknown_Release(punk);
699 IShellBrowser_Release(psb);
700 IExplorerBrowser_Destroy(peb);
701 ref = IExplorerBrowser_Release(peb);
702 ok(ref == 0, "Got %d\n", ref);
705 static void test_initialization(void)
707 IExplorerBrowser *peb;
708 IShellBrowser *psb;
709 HWND eb_hwnd;
710 HRESULT hr;
711 ULONG lres;
712 LONG style;
713 RECT rc;
715 ebrowser_instantiate(&peb);
717 if(0)
719 /* Crashes on Windows 7 */
720 IExplorerBrowser_Initialize(peb, NULL, NULL, NULL);
721 IExplorerBrowser_Initialize(peb, hwnd, NULL, NULL);
724 ZeroMemory(&rc, sizeof(RECT));
726 hr = IExplorerBrowser_Initialize(peb, NULL, &rc, NULL);
727 ok(hr == E_INVALIDARG, "got (0x%08x)\n", hr);
729 hr = IExplorerBrowser_Initialize(peb, hwnd, &rc, NULL);
730 ok(hr == S_OK, "got (0x%08x)\n", hr);
732 /* Initialize twice */
733 hr = IExplorerBrowser_Initialize(peb, hwnd, &rc, NULL);
734 ok(hr == E_UNEXPECTED, "got (0x%08x)\n", hr);
736 hr = IExplorerBrowser_Destroy(peb);
737 ok(hr == S_OK, "got (0x%08x)\n", hr);
739 /* Initialize again */
740 hr = IExplorerBrowser_Initialize(peb, hwnd, &rc, NULL);
741 ok(hr == E_UNEXPECTED, "got (0x%08x)\n", hr);
743 /* Destroy again */
744 hr = IExplorerBrowser_Destroy(peb);
745 ok(hr == S_OK, "got (0x%08x)\n", hr);
746 lres = IExplorerBrowser_Release(peb);
747 ok(lres == 0, "Got %d\n", lres);
749 /* Initialize with a few different rectangles */
750 peb = NULL;
751 ebrowser_instantiate(&peb);
752 SetRect(&rc, 50, 20, 100, 80);
753 hr = IExplorerBrowser_Initialize(peb, hwnd, &rc, NULL);
754 ok(hr == S_OK, "got (0x%08x)\n", hr);
755 hr = IExplorerBrowser_QueryInterface(peb, &IID_IShellBrowser, (void**)&psb);
756 ok(hr == S_OK, "Got 0x%08x\n", hr);
757 if(SUCCEEDED(hr))
759 RECT eb_rc;
760 char buf[1024];
761 LONG expected_style;
762 static const RECT exp_rc = {0, 0, 48, 58};
764 hr = IShellBrowser_GetWindow(psb, &eb_hwnd);
765 ok(hr == S_OK, "Got 0x%08x\n", hr);
767 GetClientRect(eb_hwnd, &eb_rc);
768 ok(EqualRect(&eb_rc, &exp_rc), "Got client rect %s\n", wine_dbgstr_rect(&eb_rc));
770 GetWindowRect(eb_hwnd, &eb_rc);
771 ok(eb_rc.right - eb_rc.left == 50, "Got window width %d\n", eb_rc.right - eb_rc.left);
772 ok(eb_rc.bottom - eb_rc.top == 60, "Got window height %d\n", eb_rc.bottom - eb_rc.top);
774 buf[0] = '\0';
775 GetClassNameA(eb_hwnd, buf, 1024);
776 ok(!lstrcmpA(buf, "ExplorerBrowserControl"), "Unexpected classname %s\n", buf);
778 expected_style = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_BORDER;
779 style = GetWindowLongPtrW(eb_hwnd, GWL_STYLE);
780 todo_wine ok(style == expected_style, "Got style 0x%08x, expected 0x%08x\n", style, expected_style);
782 expected_style = WS_EX_CONTROLPARENT;
783 style = GetWindowLongPtrW(eb_hwnd, GWL_EXSTYLE);
784 ok(style == expected_style, "Got exstyle 0x%08x, expected 0x%08x\n", style, expected_style);
786 ok(GetParent(eb_hwnd) == hwnd, "GetParent returns %p\n", GetParent(eb_hwnd));
788 /* ::Destroy() destroys the window. */
789 ok(IsWindow(eb_hwnd), "eb_hwnd invalid.\n");
790 IExplorerBrowser_Destroy(peb);
791 ok(!IsWindow(eb_hwnd), "eb_hwnd valid.\n");
793 IShellBrowser_Release(psb);
794 lres = IExplorerBrowser_Release(peb);
795 ok(lres == 0, "Got refcount %d\n", lres);
797 else
799 skip("Skipping some tests.\n");
801 IExplorerBrowser_Destroy(peb);
802 lres = IExplorerBrowser_Release(peb);
803 ok(lres == 0, "Got refcount %d\n", lres);
806 /* check window style with EBO_NOBORDER */
807 ebrowser_instantiate(&peb);
808 hr = IExplorerBrowser_SetOptions(peb, EBO_NOBORDER);
809 ok(hr == S_OK, "got 0x%08x\n", hr);
810 SetRect(&rc, 50, 20, 100, 80);
812 hr = IExplorerBrowser_Initialize(peb, hwnd, &rc, NULL);
813 ok(hr == S_OK, "got (0x%08x)\n", hr);
815 hr = IExplorerBrowser_QueryInterface(peb, &IID_IShellBrowser, (void**)&psb);
816 ok(hr == S_OK, "Got 0x%08x\n", hr);
818 hr = IShellBrowser_GetWindow(psb, &eb_hwnd);
819 ok(hr == S_OK, "Got 0x%08x\n", hr);
821 style = GetWindowLongPtrW(eb_hwnd, GWL_STYLE);
822 ok(!(style & WS_BORDER) || broken(style & WS_BORDER) /* before win8 */, "got style 0x%08x\n", style);
824 IShellBrowser_Release(psb);
825 IExplorerBrowser_Destroy(peb);
826 IExplorerBrowser_Release(peb);
828 /* empty rectangle */
829 ebrowser_instantiate(&peb);
830 SetRectEmpty(&rc);
831 hr = IExplorerBrowser_Initialize(peb, hwnd, &rc, NULL);
832 ok(hr == S_OK, "got (0x%08x)\n", hr);
833 IExplorerBrowser_Destroy(peb);
834 lres = IExplorerBrowser_Release(peb);
835 ok(lres == 0, "Got refcount %d\n", lres);
837 ebrowser_instantiate(&peb);
838 SetRect(&rc, -1, -1, 1, 1);
839 hr = IExplorerBrowser_Initialize(peb, hwnd, &rc, NULL);
840 ok(hr == S_OK, "got (0x%08x)\n", hr);
841 IExplorerBrowser_Destroy(peb);
842 lres = IExplorerBrowser_Release(peb);
843 ok(lres == 0, "Got refcount %d\n", lres);
845 ebrowser_instantiate(&peb);
846 SetRect(&rc, 10, 10, 5, 5);
847 hr = IExplorerBrowser_Initialize(peb, hwnd, &rc, NULL);
848 ok(hr == S_OK, "got (0x%08x)\n", hr);
849 IExplorerBrowser_Destroy(peb);
850 lres = IExplorerBrowser_Release(peb);
851 ok(lres == 0, "Got refcount %d\n", lres);
853 ebrowser_instantiate(&peb);
854 SetRect(&rc, 10, 10, 5, 5);
855 hr = IExplorerBrowser_Initialize(peb, hwnd, &rc, NULL);
856 ok(hr == S_OK, "got (0x%08x)\n", hr);
857 IExplorerBrowser_Destroy(peb);
858 lres = IExplorerBrowser_Release(peb);
859 ok(lres == 0, "Got refcount %d\n", lres);
862 static void test_SetSite(void)
864 IExplorerBrowser *peb;
865 IServiceProviderImpl *spimpl = create_serviceprovider();
866 ICommDlgBrowser3Impl *cdbimpl = create_commdlgbrowser3();
867 IExplorerPaneVisibilityImpl *epvimpl = create_explorerpanevisibility();
868 IObjectWithSite *pow;
869 HRESULT hr;
870 LONG ref;
871 UINT i;
872 struct services expected[] =
874 {&SID_STopLevelBrowser, &IID_ICommDlgBrowser2, cdbimpl},
875 {&SID_ExplorerPaneVisibility, &IID_IExplorerPaneVisibility, epvimpl},
876 {&SID_SExplorerBrowserFrame, &IID_ICommDlgBrowser2, cdbimpl},
877 {&SID_SExplorerBrowserFrame, &IID_ICommDlgBrowser3, cdbimpl},
878 {&IID_ICommDlgBrowser, &IID_ICommDlgBrowser, cdbimpl},
879 {NULL}
882 ebrowser_instantiate(&peb);
883 IExplorerBrowser_SetOptions(peb, EBO_SHOWFRAMES);
885 hr = IExplorerBrowser_QueryInterface(peb, &IID_IObjectWithSite, (void**)&pow);
886 ok(hr == S_OK, "Got 0x%08x\n", hr);
887 if(SUCCEEDED(hr))
889 spimpl->interfaces = expected;
891 hr = IObjectWithSite_SetSite(pow, (IUnknown*)&spimpl->IServiceProvider_iface);
892 ok(hr == S_OK, "Got 0x%08x\n", hr);
894 if(FAILED(hr))
895 IObjectWithSite_Release(pow);
898 if(FAILED(hr))
900 skip("Failed to set site.\n");
902 IServiceProvider_Release(&spimpl->IServiceProvider_iface);
903 ICommDlgBrowser3_Release(&cdbimpl->ICommDlgBrowser3_iface);
904 IExplorerPaneVisibility_Release(&epvimpl->IExplorerPaneVisibility_iface);
905 IExplorerBrowser_Destroy(peb);
906 ref = IExplorerBrowser_Release(peb);
907 ok(ref == 0, "Got ref %d\n", ref);
909 return;
912 ShowWindow(hwnd, TRUE);
913 ebrowser_initialize(peb);
914 ebrowser_browse_to_desktop(peb);
916 for(i = 0; i < 10; i++)
918 Sleep(100);
919 process_msgs();
921 ShowWindow(hwnd, FALSE);
923 /* ICommDlgBrowser3 */
924 ok(!cdbimpl->OnDefaultCommand, "Got %d\n", cdbimpl->OnDefaultCommand);
925 todo_wine ok(cdbimpl->OnStateChange, "Got %d\n", cdbimpl->OnStateChange);
926 ok(cdbimpl->IncludeObject, "Got %d\n", cdbimpl->IncludeObject);
927 ok(!cdbimpl->Notify, "Got %d\n", cdbimpl->Notify);
928 ok(!cdbimpl->GetDefaultMenuText, "Got %d\n", cdbimpl->GetDefaultMenuText);
929 todo_wine ok(cdbimpl->GetViewFlags, "Got %d\n", cdbimpl->GetViewFlags);
930 ok(!cdbimpl->OnColumnClicked, "Got %d\n", cdbimpl->OnColumnClicked);
931 ok(!cdbimpl->GetCurrentFilter, "Got %d\n", cdbimpl->GetCurrentFilter);
932 todo_wine ok(cdbimpl->OnPreviewCreated, "Got %d\n", cdbimpl->OnPreviewCreated);
934 /* IExplorerPaneVisibility */
935 ok(epvimpl->np, "Got %d\n", epvimpl->np);
936 todo_wine ok(epvimpl->cp, "Got %d\n", epvimpl->cp);
937 todo_wine ok(epvimpl->cp_o, "Got %d\n", epvimpl->cp_o);
938 todo_wine ok(epvimpl->cp_v, "Got %d\n", epvimpl->cp_v);
939 todo_wine ok(epvimpl->dp, "Got %d\n", epvimpl->dp);
940 todo_wine ok(epvimpl->pp, "Got %d\n", epvimpl->pp);
941 ok(!epvimpl->qp, "Got %d\n", epvimpl->qp);
942 ok(!epvimpl->aqp, "Got %d\n", epvimpl->aqp);
943 ok(!epvimpl->unk, "Got %d\n", epvimpl->unk);
945 /* Test when IServiceProvider is released. */
946 IServiceProvider_AddRef(&spimpl->IServiceProvider_iface);
947 ref = IServiceProvider_Release(&spimpl->IServiceProvider_iface);
948 ok(ref == 2, "Got ref %d\n", ref);
950 hr = IObjectWithSite_SetSite(pow, NULL);
951 ok(hr == S_OK, "Got 0x%08x\n", hr);
953 IServiceProvider_AddRef(&spimpl->IServiceProvider_iface);
954 ref = IServiceProvider_Release(&spimpl->IServiceProvider_iface);
955 ok(ref == 1, "Got ref %d\n", ref);
957 hr = IObjectWithSite_SetSite(pow, (IUnknown*)&spimpl->IServiceProvider_iface);
958 ok(hr == S_OK, "Got 0x%08x\n", hr);
960 IServiceProvider_AddRef(&spimpl->IServiceProvider_iface);
961 ref = IServiceProvider_Release(&spimpl->IServiceProvider_iface);
962 ok(ref == 2, "Got ref %d\n", ref);
964 IExplorerBrowser_Destroy(peb);
966 IServiceProvider_AddRef(&spimpl->IServiceProvider_iface);
967 ref = IServiceProvider_Release(&spimpl->IServiceProvider_iface);
968 ok(ref == 2, "Got ref %d\n", ref);
970 IObjectWithSite_Release(pow);
971 ref = IExplorerBrowser_Release(peb);
972 ok(ref == 0, "Got ref %d\n", ref);
974 ref = IServiceProvider_Release(&spimpl->IServiceProvider_iface);
975 ok(ref == 0, "Got ref %d\n", ref);
977 ref = ICommDlgBrowser3_Release(&cdbimpl->ICommDlgBrowser3_iface);
978 ok(ref == 0, "Got ref %d\n", ref);
979 ref = IExplorerPaneVisibility_Release(&epvimpl->IExplorerPaneVisibility_iface);
980 ok(ref == 0, "Got ref %d\n", ref);
983 static void test_basics(void)
985 IExplorerBrowser *peb;
986 IShellBrowser *psb;
987 FOLDERSETTINGS fs;
988 ULONG lres;
989 EXPLORER_BROWSER_OPTIONS flags;
990 HDWP hdwp;
991 RECT rc;
992 HRESULT hr;
993 static const WCHAR winetest[] = {'W','i','n','e','T','e','s','t',0};
995 ebrowser_instantiate(&peb);
996 ebrowser_initialize(peb);
998 /* SetRect */
999 SetRectEmpty(&rc);
1000 hr = IExplorerBrowser_SetRect(peb, NULL, rc);
1001 ok(hr == S_OK, "got (0x%08x)\n", hr);
1003 SetRect(&rc, 100, 100, 10, 10);
1004 hr = IExplorerBrowser_SetRect(peb, NULL, rc);
1005 ok(hr == S_OK, "got (0x%08x)\n", hr);
1007 /* SetRect with DeferWindowPos */
1008 SetRect(&rc, 0, 0, 10, 10);
1009 hdwp = BeginDeferWindowPos(1);
1010 hr = IExplorerBrowser_SetRect(peb, &hdwp, rc);
1011 ok(hr == S_OK, "got (0x%08x)\n", hr);
1012 lres = EndDeferWindowPos(hdwp);
1013 ok(lres, "EndDeferWindowPos failed.\n");
1015 hdwp = NULL;
1016 hr = IExplorerBrowser_SetRect(peb, &hdwp, rc);
1017 ok(hr == S_OK, "got (0x%08x)\n", hr);
1018 ok(hdwp == NULL, "got %p\n", hdwp);
1019 lres = EndDeferWindowPos(hdwp);
1020 ok(!lres, "EndDeferWindowPos succeeded unexpectedly.\n");
1022 /* Test positioning */
1023 SetRect(&rc, 10, 20, 50, 50);
1024 hr = IExplorerBrowser_SetRect(peb, NULL, rc);
1025 ok(hr == S_OK, "got (0x%08x)\n", hr);
1026 hr = IExplorerBrowser_QueryInterface(peb, &IID_IShellBrowser, (void**)&psb);
1027 ok(hr == S_OK, "Got 0x%08x\n", hr);
1028 if(SUCCEEDED(hr))
1030 HWND eb_hwnd;
1031 RECT eb_rc;
1032 static const RECT exp_rc = {11, 21, 49, 49};
1033 static const RECT exp_rc2 = {11, 21, 49, 24};
1035 hr = IShellBrowser_GetWindow(psb, &eb_hwnd);
1036 ok(hr == S_OK, "Got 0x%08x\n", hr);
1038 GetClientRect(eb_hwnd, &eb_rc);
1039 MapWindowPoints(eb_hwnd, hwnd, (POINT*)&eb_rc, 2);
1040 ok(EqualRect(&eb_rc, &exp_rc), "Got rect %s\n", wine_dbgstr_rect(&eb_rc));
1042 /* Try resizing with invalid hdwp */
1043 rc.bottom = 25;
1044 hdwp = (HDWP)0xdeadbeef;
1045 hr = IExplorerBrowser_SetRect(peb, &hdwp, rc);
1046 ok(hr == E_FAIL, "Got 0x%08x\n", hr);
1047 GetClientRect(eb_hwnd, &eb_rc);
1048 MapWindowPoints(eb_hwnd, hwnd, (POINT*)&eb_rc, 2);
1049 ok(EqualRect(&eb_rc, &exp_rc), "Got rect %s\n", wine_dbgstr_rect(&eb_rc));
1051 hdwp = NULL;
1052 hr = IExplorerBrowser_SetRect(peb, &hdwp, rc);
1053 ok(hr == S_OK, "Got 0x%08x\n", hr);
1054 GetClientRect(eb_hwnd, &eb_rc);
1055 MapWindowPoints(eb_hwnd, hwnd, (POINT*)&eb_rc, 2);
1056 ok(EqualRect(&eb_rc, &exp_rc2), "Got rect %s\n", wine_dbgstr_rect(&eb_rc));
1058 IShellBrowser_Release(psb);
1061 IExplorerBrowser_Destroy(peb);
1062 IExplorerBrowser_Release(peb);
1064 /* GetOptions/SetOptions*/
1065 ebrowser_instantiate(&peb);
1067 if(0) {
1068 /* Crashes on Windows 7 */
1069 IExplorerBrowser_GetOptions(peb, NULL);
1072 hr = IExplorerBrowser_GetOptions(peb, &flags);
1073 ok(hr == S_OK, "got (0x%08x)\n", hr);
1074 ok(flags == 0, "got (0x%08x)\n", flags);
1076 /* Settings preserved through Initialize. */
1077 hr = IExplorerBrowser_SetOptions(peb, 0xDEADBEEF);
1078 ok(hr == S_OK, "got (0x%08x)\n", hr);
1080 ebrowser_initialize(peb);
1082 hr = IExplorerBrowser_GetOptions(peb, &flags);
1083 ok(flags == 0xDEADBEEF, "got (0x%08x)\n", flags);
1084 ok(hr == S_OK, "got (0x%08x)\n", hr);
1086 IExplorerBrowser_Destroy(peb);
1087 IExplorerBrowser_Release(peb);
1089 ebrowser_instantiate(&peb);
1090 ebrowser_initialize(peb);
1092 /* SetFolderSettings */
1093 hr = IExplorerBrowser_SetFolderSettings(peb, NULL);
1094 ok(hr == E_INVALIDARG, "got (0x%08x)\n", hr);
1095 fs.ViewMode = 0; fs.fFlags = 0;
1096 hr = IExplorerBrowser_SetFolderSettings(peb, &fs);
1097 todo_wine ok(hr == E_INVALIDARG, "got (0x%08x)\n", hr);
1099 /* SetPropertyBag */
1100 hr = IExplorerBrowser_SetPropertyBag(peb, NULL);
1101 ok(hr == E_INVALIDARG, "Got 0x%08x\n", hr);
1102 hr = IExplorerBrowser_SetPropertyBag(peb, winetest);
1103 ok(hr == S_OK, "Got 0x%08x\n", hr);
1105 /* TODO: Test after browsing somewhere. */
1107 IExplorerBrowser_Destroy(peb);
1108 lres = IExplorerBrowser_Release(peb);
1109 ok(lres == 0, "Got %d\n", lres);
1112 static void test_Advise(void)
1114 IExplorerBrowser *peb;
1115 IExplorerBrowserEvents *pebe;
1116 DWORD cookies[10];
1117 HRESULT hr;
1118 UINT i, ref;
1120 /* Set up our IExplorerBrowserEvents implementation */
1121 ebev.IExplorerBrowserEvents_iface.lpVtbl = &ebevents;
1122 pebe = &ebev.IExplorerBrowserEvents_iface;
1124 ebrowser_instantiate(&peb);
1126 if(0)
1128 /* Crashes on Windows 7 */
1129 IExplorerBrowser_Advise(peb, pebe, NULL);
1130 IExplorerBrowser_Advise(peb, NULL, &cookies[0]);
1133 /* Using Unadvise with a cookie that has yet to be given out
1134 * results in E_INVALIDARG */
1135 hr = IExplorerBrowser_Unadvise(peb, 11);
1136 ok(hr == E_INVALIDARG, "got (0x%08x)\n", hr);
1138 /* Add some before initialization */
1139 for(i = 0; i < 5; i++)
1141 hr = IExplorerBrowser_Advise(peb, pebe, &cookies[i]);
1142 ok(hr == S_OK, "got (0x%08x)\n", hr);
1145 ebrowser_initialize(peb);
1147 /* Add some after initialization */
1148 for(i = 5; i < 10; i++)
1150 hr = IExplorerBrowser_Advise(peb, pebe, &cookies[i]);
1151 ok(hr == S_OK, "got (0x%08x)\n", hr);
1154 ok(ebev.ref == 10, "Got %d\n", ebev.ref);
1156 ebev.completed = 0;
1157 ebrowser_browse_to_desktop(peb);
1158 process_msgs();
1159 ok(ebev.completed == 10, "Got %d\n", ebev.completed);
1161 /* Remove a bunch somewhere in the middle */
1162 for(i = 4; i < 8; i++)
1164 hr = IExplorerBrowser_Unadvise(peb, cookies[i]);
1165 ok(hr == S_OK, "got (0x%08x)\n", hr);
1168 ebev.completed = 0;
1169 ebrowser_browse_to_desktop(peb);
1170 process_msgs();
1171 ok(ebev.completed == 6, "Got %d\n", ebev.completed);
1173 if(0)
1175 /* Using unadvise with a previously unadvised cookie results
1176 * in a crash. */
1177 IExplorerBrowser_Unadvise(peb, cookies[5]);
1180 /* Remove the rest. */
1181 for(i = 0; i < 10; i++)
1183 if(i<4||i>7)
1185 hr = IExplorerBrowser_Unadvise(peb, cookies[i]);
1186 ok(hr == S_OK, "%d: got (0x%08x)\n", i, hr);
1190 ok(ebev.ref == 0, "Got %d\n", ebev.ref);
1192 ebev.completed = 0;
1193 ebrowser_browse_to_desktop(peb);
1194 process_msgs();
1195 ok(ebev.completed == 0, "Got %d\n", ebev.completed);
1197 /* ::Destroy implies ::Unadvise. */
1198 hr = IExplorerBrowser_Advise(peb, pebe, &cookies[0]);
1199 ok(hr == S_OK, "Got 0x%08x\n", hr);
1200 ok(ebev.ref == 1, "Got %d\n", ebev.ref);
1202 hr = IExplorerBrowser_Destroy(peb);
1203 ok(hr == S_OK, "Got 0x%08x\n", hr);
1204 ok(ebev.ref == 0, "Got %d\n", ebev.ref);
1206 ref = IExplorerBrowser_Release(peb);
1207 ok(!ref, "Got %d\n", ref);
1210 /* Based on PathAddBackslashW from dlls/shlwapi/path.c */
1211 static LPWSTR myPathAddBackslashW( LPWSTR lpszPath )
1213 size_t iLen;
1215 if (!lpszPath || (iLen = lstrlenW(lpszPath)) >= MAX_PATH)
1216 return NULL;
1218 if (iLen)
1220 lpszPath += iLen;
1221 if (lpszPath[-1] != '\\')
1223 *lpszPath++ = '\\';
1224 *lpszPath = '\0';
1227 return lpszPath;
1230 static void test_browse_pidl_(IExplorerBrowser *peb, IExplorerBrowserEventsImpl *ebev,
1231 LPITEMIDLIST pidl, UINT uFlags,
1232 HRESULT hr_exp, UINT pending, UINT created, UINT failed, UINT completed,
1233 const char *file, int line)
1235 HRESULT hr;
1236 ebev->completed = ebev->created = ebev->pending = ebev->failed = 0;
1238 hr = IExplorerBrowser_BrowseToIDList(peb, pidl, uFlags);
1239 ok_(file, line) (hr == hr_exp, "BrowseToIDList returned 0x%08x\n", hr);
1240 process_msgs();
1242 ok_(file, line)
1243 (ebev->pending == pending && ebev->created == created &&
1244 ebev->failed == failed && ebev->completed == completed,
1245 "Events occurred: %d, %d, %d, %d\n",
1246 ebev->pending, ebev->created, ebev->failed, ebev->completed);
1248 #define test_browse_pidl(peb, ebev, pidl, uFlags, hr, p, cr, f, co) \
1249 test_browse_pidl_(peb, ebev, pidl, uFlags, hr, p, cr, f, co, __FILE__, __LINE__)
1251 static void test_browse_pidl_sb_(IExplorerBrowser *peb, IExplorerBrowserEventsImpl *ebev,
1252 LPITEMIDLIST pidl, UINT uFlags,
1253 HRESULT hr_exp, UINT pending, UINT created, UINT failed, UINT completed,
1254 const char *file, int line)
1256 IShellBrowser *psb;
1257 HRESULT hr;
1259 hr = IExplorerBrowser_QueryInterface(peb, &IID_IShellBrowser, (void**)&psb);
1260 ok_(file, line) (hr == S_OK, "QueryInterface returned 0x%08x\n", hr);
1261 if(SUCCEEDED(hr))
1263 ebev->completed = ebev->created = ebev->pending = ebev->failed = 0;
1265 hr = IShellBrowser_BrowseObject(psb, pidl, uFlags);
1266 ok_(file, line) (hr == hr_exp, "BrowseObject returned 0x%08x\n", hr);
1267 process_msgs();
1269 ok_(file, line)
1270 (ebev->pending == pending && ebev->created == created &&
1271 ebev->failed == failed && ebev->completed == completed,
1272 "Events occurred: %d, %d, %d, %d\n",
1273 ebev->pending, ebev->created, ebev->failed, ebev->completed);
1275 IShellBrowser_Release(psb);
1278 #define test_browse_pidl_sb(peb, ebev, pidl, uFlags, hr, p, cr, f, co) \
1279 test_browse_pidl_sb_(peb, ebev, pidl, uFlags, hr, p, cr, f, co, __FILE__, __LINE__)
1281 static void test_navigation(void)
1283 IExplorerBrowser *peb, *peb2;
1284 IFolderView *pfv;
1285 IShellItem *psi;
1286 IShellFolder *psf;
1287 LPITEMIDLIST pidl_current, pidl_child;
1288 DWORD cookie, cookie2;
1289 HRESULT hr;
1290 LONG lres;
1291 WCHAR current_path[MAX_PATH];
1292 WCHAR child_path[MAX_PATH];
1293 static const WCHAR testfolderW[] =
1294 {'w','i','n','e','t','e','s','t','f','o','l','d','e','r','\0'};
1296 ok(pSHCreateShellItem != NULL, "pSHCreateShellItem unexpectedly missing.\n");
1298 GetCurrentDirectoryW(MAX_PATH, current_path);
1299 if(!current_path[0])
1301 skip("Failed to create test-directory.\n");
1302 return;
1305 lstrcpyW(child_path, current_path);
1306 myPathAddBackslashW(child_path);
1307 lstrcatW(child_path, testfolderW);
1309 CreateDirectoryW(child_path, NULL);
1311 hr = SHParseDisplayName(current_path, NULL, &pidl_current, 0, NULL);
1312 ok(hr == S_OK, "Failed to parse a path, hr %#x.\n", hr);
1313 hr = SHParseDisplayName(child_path, NULL, &pidl_child, 0, NULL);
1314 ok(hr == S_OK, "Failed to parse a path, hr %#x.\n", hr);
1316 ebrowser_instantiate(&peb);
1317 ebrowser_initialize(peb);
1319 ebrowser_instantiate(&peb2);
1320 ebrowser_initialize(peb2);
1322 /* Set up our IExplorerBrowserEvents implementation */
1323 ebev.IExplorerBrowserEvents_iface.lpVtbl = &ebevents;
1325 IExplorerBrowser_Advise(peb, &ebev.IExplorerBrowserEvents_iface, &cookie);
1326 IExplorerBrowser_Advise(peb2, &ebev.IExplorerBrowserEvents_iface, &cookie2);
1328 /* These should all fail */
1329 test_browse_pidl(peb, &ebev, 0, SBSP_ABSOLUTE | SBSP_RELATIVE, E_FAIL, 0, 0, 0, 0);
1330 test_browse_pidl_sb(peb2, &ebev, 0, SBSP_ABSOLUTE | SBSP_RELATIVE, E_FAIL, 0, 0, 0, 0);
1331 test_browse_pidl(peb, &ebev, 0, SBSP_ABSOLUTE, E_INVALIDARG, 0, 0, 0, 0);
1332 test_browse_pidl_sb(peb2, &ebev, 0, SBSP_ABSOLUTE, E_INVALIDARG, 0, 0, 0, 0);
1333 test_browse_pidl(peb, &ebev, 0, SBSP_RELATIVE, E_FAIL, 0, 0, 0, 0);
1334 test_browse_pidl_sb(peb2, &ebev, 0, SBSP_RELATIVE, E_FAIL, 0, 0, 0, 0);
1335 test_browse_pidl(peb, &ebev, 0, SBSP_PARENT, E_FAIL, 0, 0, 0, 0);
1336 test_browse_pidl_sb(peb2, &ebev, 0, SBSP_PARENT, E_FAIL, 0, 0, 0, 0);
1337 test_browse_pidl(peb, &ebev, 0, SBSP_NAVIGATEFORWARD, E_FAIL, 0, 0, 0, 0);
1338 test_browse_pidl_sb(peb2, &ebev, 0, SBSP_NAVIGATEFORWARD, E_FAIL, 0, 0, 0, 0);
1339 test_browse_pidl(peb, &ebev, 0, SBSP_NAVIGATEBACK, E_FAIL, 0, 0, 0, 0);
1340 test_browse_pidl_sb(peb2, &ebev, 0, SBSP_NAVIGATEBACK, E_FAIL, 0, 0, 0, 0);
1342 /* "The first browse is synchronous" */
1343 test_browse_pidl(peb, &ebev, pidl_child, SBSP_ABSOLUTE, S_OK, 1, 1, 0, 1);
1344 test_browse_pidl_sb(peb2, &ebev, pidl_child, SBSP_ABSOLUTE, S_OK, 1, 1, 0, 1);
1346 /* Navigate empty history */
1347 test_browse_pidl(peb, &ebev, 0, SBSP_NAVIGATEFORWARD, S_OK, 0, 0, 0, 0);
1348 test_browse_pidl_sb(peb2, &ebev, 0, SBSP_NAVIGATEFORWARD, S_OK, 0, 0, 0, 0);
1349 test_browse_pidl(peb, &ebev, 0, SBSP_NAVIGATEBACK, S_OK, 0, 0, 0, 0);
1350 test_browse_pidl_sb(peb2, &ebev, 0, SBSP_NAVIGATEBACK, S_OK, 0, 0, 0, 0);
1352 /* Navigate history */
1353 test_browse_pidl(peb, &ebev, 0, SBSP_PARENT, S_OK, 1, 1, 0, 1);
1354 test_browse_pidl_sb(peb2, &ebev, 0, SBSP_PARENT, S_OK, 1, 1, 0, 1);
1355 test_browse_pidl(peb, &ebev, 0, SBSP_NAVIGATEBACK, S_OK, 1, 1, 0, 1);
1356 test_browse_pidl_sb(peb2, &ebev, 0, SBSP_NAVIGATEBACK, S_OK, 1, 1, 0, 1);
1357 test_browse_pidl(peb, &ebev, 0, SBSP_NAVIGATEFORWARD, S_OK, 1, 1, 0, 1);
1358 test_browse_pidl_sb(peb2, &ebev, 0, SBSP_NAVIGATEFORWARD, S_OK, 1, 1, 0, 1);
1359 test_browse_pidl(peb, &ebev, 0, SBSP_ABSOLUTE, S_OK, 0, 0, 0, 0);
1360 test_browse_pidl_sb(peb2, &ebev, 0, SBSP_ABSOLUTE, S_OK, 0, 0, 0, 0);
1362 /* Relative navigation */
1363 test_browse_pidl(peb, &ebev, pidl_current, SBSP_ABSOLUTE, S_OK, 1, 0, 0, 1);
1364 test_browse_pidl_sb(peb2, &ebev, pidl_current, SBSP_ABSOLUTE, S_OK, 1, 0, 0, 1);
1366 hr = IExplorerBrowser_GetCurrentView(peb, &IID_IFolderView, (void**)&pfv);
1367 ok(hr == S_OK, "Got 0x%08x\n", hr);
1368 if(SUCCEEDED(hr))
1370 LPITEMIDLIST pidl_relative;
1372 hr = IFolderView_GetFolder(pfv, &IID_IShellFolder, (void**)&psf);
1373 ok(hr == S_OK, "Got 0x%08x\n", hr);
1374 hr = IShellFolder_ParseDisplayName(psf, NULL, NULL, (LPWSTR)testfolderW,
1375 NULL, &pidl_relative, NULL);
1376 ok(hr == S_OK, "Got 0x%08x\n", hr);
1378 /* Browsing to another location here before using the
1379 * pidl_relative would make ExplorerBrowser in Windows 7 show a
1380 * not-available dialog. Also, passing a relative pidl without
1381 * specifying SBSP_RELATIVE makes it look for the pidl on the
1382 * desktop
1385 test_browse_pidl(peb, &ebev, pidl_relative, SBSP_RELATIVE, S_OK, 1, 1, 0, 1);
1386 test_browse_pidl_sb(peb2, &ebev, pidl_relative, SBSP_RELATIVE, S_OK, 1, 1, 0, 1);
1388 ILFree(pidl_relative);
1389 IShellFolder_Release(psf);
1390 IFolderView_Release(pfv);
1393 /* misc **/
1394 test_browse_pidl(peb, &ebev, NULL, SBSP_ABSOLUTE, S_OK, 0, 0, 0, 0);
1395 test_browse_pidl_sb(peb2, &ebev, NULL, SBSP_ABSOLUTE, S_OK, 0, 0, 0, 0);
1396 test_browse_pidl(peb, &ebev, NULL, SBSP_DEFBROWSER, S_OK, 0, 0, 0, 0);
1397 test_browse_pidl_sb(peb2, &ebev, NULL, SBSP_DEFBROWSER, S_OK, 0, 0, 0, 0);
1398 test_browse_pidl(peb, &ebev, pidl_current, SBSP_SAMEBROWSER, S_OK, 1, 1, 0, 1);
1399 test_browse_pidl_sb(peb2, &ebev, pidl_current, SBSP_SAMEBROWSER, S_OK, 1, 1, 0, 1);
1400 test_browse_pidl(peb, &ebev, pidl_current, SBSP_SAMEBROWSER, S_OK, 1, 0, 0, 1);
1401 test_browse_pidl_sb(peb2, &ebev, pidl_current, SBSP_SAMEBROWSER, S_OK, 1, 0, 0, 1);
1403 test_browse_pidl(peb, &ebev, pidl_current, SBSP_EXPLOREMODE, E_INVALIDARG, 0, 0, 0, 0);
1404 test_browse_pidl_sb(peb2, &ebev, pidl_current, SBSP_EXPLOREMODE, E_INVALIDARG, 0, 0, 0, 0);
1405 test_browse_pidl(peb, &ebev, pidl_current, SBSP_OPENMODE, S_OK, 1, 0, 0, 1);
1406 test_browse_pidl_sb(peb2, &ebev, pidl_current, SBSP_OPENMODE, S_OK, 1, 0, 0, 1);
1408 /* SBSP_NEWBROWSER will return E_INVALIDARG, claims MSDN, but in
1409 * reality it works as one would expect (Windows 7 only?).
1411 if(0)
1413 IExplorerBrowser_BrowseToIDList(peb, NULL, SBSP_NEWBROWSER);
1416 hr = IExplorerBrowser_Unadvise(peb, cookie);
1417 ok(hr == S_OK, "Got 0x%08x\n", hr);
1418 IExplorerBrowser_Destroy(peb);
1419 process_msgs();
1420 hr = IExplorerBrowser_Unadvise(peb2, cookie2);
1421 ok(hr == S_OK, "Got 0x%08x\n", hr);
1422 IExplorerBrowser_Destroy(peb2);
1423 process_msgs();
1425 /* Attempt browsing after destroyed */
1426 test_browse_pidl(peb, &ebev, pidl_child, SBSP_ABSOLUTE, HRESULT_FROM_WIN32(ERROR_BUSY), 0, 0, 0, 0);
1427 test_browse_pidl_sb(peb2, &ebev, pidl_child, SBSP_ABSOLUTE, HRESULT_FROM_WIN32(ERROR_BUSY), 0, 0, 0, 0);
1429 lres = IExplorerBrowser_Release(peb);
1430 ok(lres == 0, "Got lres %d\n", lres);
1431 lres = IExplorerBrowser_Release(peb2);
1432 ok(lres == 0, "Got lres %d\n", lres);
1434 /******************************************/
1435 /* Test some options that affect browsing */
1437 ebrowser_instantiate(&peb);
1438 hr = IExplorerBrowser_Advise(peb, &ebev.IExplorerBrowserEvents_iface, &cookie);
1439 ok(hr == S_OK, "Got 0x%08x\n", hr);
1440 hr = IExplorerBrowser_SetOptions(peb, EBO_NAVIGATEONCE);
1441 ok(hr == S_OK, "got (0x%08x)\n", hr);
1442 ebrowser_initialize(peb);
1444 test_browse_pidl(peb, &ebev, pidl_current, 0, S_OK, 1, 1, 0, 1);
1445 test_browse_pidl(peb, &ebev, pidl_current, 0, E_FAIL, 0, 0, 0, 0);
1447 hr = IExplorerBrowser_SetOptions(peb, 0);
1448 ok(hr == S_OK, "got (0x%08x)\n", hr);
1450 test_browse_pidl(peb, &ebev, pidl_current, 0, S_OK, 1, 0, 0, 1);
1451 test_browse_pidl(peb, &ebev, pidl_current, 0, S_OK, 1, 0, 0, 1);
1453 /* Difference in behavior lies where? */
1454 hr = IExplorerBrowser_SetOptions(peb, EBO_ALWAYSNAVIGATE);
1455 ok(hr == S_OK, "got (0x%08x)\n", hr);
1457 test_browse_pidl(peb, &ebev, pidl_current, 0, S_OK, 1, 0, 0, 1);
1458 test_browse_pidl(peb, &ebev, pidl_current, 0, S_OK, 1, 0, 0, 1);
1460 hr = IExplorerBrowser_Unadvise(peb, cookie);
1461 ok(hr == S_OK, "Got 0x%08x\n", hr);
1463 IExplorerBrowser_Destroy(peb);
1464 lres = IExplorerBrowser_Release(peb);
1465 ok(lres == 0, "Got lres %d\n", lres);
1467 /* BrowseToObject tests */
1468 ebrowser_instantiate(&peb);
1469 ebrowser_initialize(peb);
1471 /* Browse to the desktop by passing an IShellFolder */
1472 hr = SHGetDesktopFolder(&psf);
1473 ok(hr == S_OK, "Got 0x%08x\n", hr);
1474 if(SUCCEEDED(hr))
1476 hr = IExplorerBrowser_BrowseToObject(peb, (IUnknown*)psf, SBSP_DEFBROWSER);
1477 ok(hr == S_OK, "got (0x%08x)\n", hr);
1478 if(hr == S_OK) process_msgs();
1480 IShellFolder_Release(psf);
1483 /* Browse to the current directory by passing a ShellItem */
1484 hr = pSHCreateShellItem(NULL, NULL, pidl_current, &psi);
1485 ok(hr == S_OK, "Got 0x%08x\n", hr);
1486 if(SUCCEEDED(hr))
1488 hr = IExplorerBrowser_BrowseToObject(peb, (IUnknown*)psi, SBSP_DEFBROWSER);
1489 ok(hr == S_OK, "got (0x%08x)\n", hr);
1490 process_msgs();
1492 IShellItem_Release(psi);
1495 IExplorerBrowser_Destroy(peb);
1496 lres = IExplorerBrowser_Release(peb);
1497 ok(lres == 0, "Got lres %d\n", lres);
1499 /* Cleanup */
1500 RemoveDirectoryW(child_path);
1501 ILFree(pidl_current);
1502 ILFree(pidl_child);
1505 static void test_GetCurrentView(void)
1507 IExplorerBrowser *peb;
1508 IUnknown *punk;
1509 HRESULT hr;
1511 /* GetCurrentView */
1512 ebrowser_instantiate(&peb);
1514 if(0)
1516 /* Crashes under Windows 7 */
1517 IExplorerBrowser_GetCurrentView(peb, NULL, NULL);
1519 hr = IExplorerBrowser_GetCurrentView(peb, NULL, (void**)&punk);
1520 ok(hr == E_FAIL, "Got 0x%08x\n", hr);
1522 #define test_gcv(iid, exp) \
1523 do { \
1524 hr = IExplorerBrowser_GetCurrentView(peb, &iid, (void**)&punk); \
1525 ok(hr == exp, "(%s:)Expected (0x%08x), got: (0x%08x)\n", \
1526 #iid ,exp, hr); \
1527 if(SUCCEEDED(hr)) IUnknown_Release(punk); \
1528 } while(0)
1530 test_gcv(IID_IUnknown, E_FAIL);
1531 test_gcv(IID_IUnknown, E_FAIL);
1532 test_gcv(IID_IShellView, E_FAIL);
1533 test_gcv(IID_IShellView2, E_FAIL);
1534 test_gcv(IID_IFolderView, E_FAIL);
1535 test_gcv(IID_IPersistFolder, E_FAIL);
1536 test_gcv(IID_IPersistFolder2, E_FAIL);
1537 test_gcv(IID_ICommDlgBrowser, E_FAIL);
1538 test_gcv(IID_ICommDlgBrowser2, E_FAIL);
1539 test_gcv(IID_ICommDlgBrowser3, E_FAIL);
1541 ebrowser_initialize(peb);
1542 ebrowser_browse_to_desktop(peb);
1544 test_gcv(IID_IUnknown, S_OK);
1545 test_gcv(IID_IUnknown, S_OK);
1546 test_gcv(IID_IShellView, S_OK);
1547 test_gcv(IID_IShellView2, S_OK);
1548 test_gcv(IID_IFolderView, S_OK);
1549 todo_wine test_gcv(IID_IPersistFolder, S_OK);
1550 test_gcv(IID_IPersistFolder2, E_NOINTERFACE);
1551 test_gcv(IID_ICommDlgBrowser, E_NOINTERFACE);
1552 test_gcv(IID_ICommDlgBrowser2, E_NOINTERFACE);
1553 test_gcv(IID_ICommDlgBrowser3, E_NOINTERFACE);
1555 #undef test_gcv
1557 IExplorerBrowser_Destroy(peb);
1558 IExplorerBrowser_Release(peb);
1561 static void test_InputObject(void)
1563 IExplorerBrowser *peb;
1564 IShellFolder *psf;
1565 IInputObject *pio;
1566 HRESULT hr;
1567 RECT rc;
1568 UINT i;
1569 WPARAM supported_key_accels_mode1[] = {
1570 VK_BACK, VK_TAB, VK_RETURN, VK_PRIOR, VK_NEXT, VK_END, VK_HOME,
1571 VK_LEFT, VK_UP, VK_RIGHT, VK_DOWN, VK_DELETE, VK_F1, VK_F2,
1572 VK_F5, VK_F6, VK_F10, 0 };
1573 WPARAM supported_key_accels_mode2[] = {
1574 VK_RETURN, VK_PRIOR, VK_NEXT, VK_END, VK_HOME,
1575 VK_LEFT, VK_UP, VK_RIGHT, VK_DOWN, VK_DELETE, VK_F1, VK_F2,
1576 VK_F10, 0 };
1577 WPARAM *key_accels;
1578 MSG msg_a = {
1579 hwnd,
1580 WM_KEYDOWN,
1581 VK_F5, 0,
1582 GetTickCount(),
1583 {5, 2}
1586 ebrowser_instantiate(&peb);
1587 hr = IExplorerBrowser_QueryInterface(peb, &IID_IInputObject, (void**)&pio);
1588 ok(hr == S_OK, "Got 0x%08x\n", hr);
1589 if(FAILED(hr))
1591 win_skip("IInputObject not supported.\n");
1592 return;
1595 /* Before initializing */
1596 hr = IInputObject_TranslateAcceleratorIO(pio, &msg_a);
1597 todo_wine ok(hr == E_FAIL, "Got 0x%08x\n", hr);
1599 hr = IInputObject_HasFocusIO(pio);
1600 todo_wine ok(hr == E_FAIL, "Got 0x%08x\n", hr);
1602 hr = IInputObject_UIActivateIO(pio, TRUE, &msg_a);
1603 todo_wine ok(hr == S_OK, "Got 0x%08x\n", hr);
1605 hr = IInputObject_HasFocusIO(pio);
1606 todo_wine ok(hr == E_FAIL, "Got 0x%08x\n", hr);
1608 hr = IInputObject_TranslateAcceleratorIO(pio, &msg_a);
1609 todo_wine ok(hr == E_FAIL, "Got 0x%08x\n", hr);
1611 SetRect(&rc, 0, 0, 100, 100);
1612 hr = IExplorerBrowser_Initialize(peb, hwnd, &rc, NULL);
1613 ok(hr == S_OK, "Got 0x%08x\n", hr);
1615 hr = IInputObject_HasFocusIO(pio);
1616 todo_wine ok(hr == E_FAIL, "Got 0x%08x\n", hr);
1618 hr = IInputObject_TranslateAcceleratorIO(pio, &msg_a);
1619 todo_wine ok(hr == E_FAIL, "Got 0x%08x\n", hr);
1621 /* Browse to the desktop */
1622 SHGetDesktopFolder(&psf);
1623 hr = IExplorerBrowser_BrowseToObject(peb, (IUnknown*)psf, SBSP_DEFBROWSER);
1624 ok(hr == S_OK, "Got 0x%08x\n", hr);
1625 IShellFolder_Release(psf);
1627 hr = IInputObject_UIActivateIO(pio, TRUE, &msg_a);
1628 todo_wine ok(hr == S_OK, "Got 0x%08x\n", hr);
1630 hr = IInputObject_HasFocusIO(pio);
1631 todo_wine ok(hr == S_OK, "Got 0x%08x\n", hr);
1633 hr = IInputObject_UIActivateIO(pio, FALSE, &msg_a);
1634 todo_wine ok(hr == S_OK, "Got 0x%08x\n", hr);
1636 hr = IInputObject_HasFocusIO(pio);
1637 todo_wine ok(hr == S_OK, "Got 0x%08x\n", hr);
1639 hr = IInputObject_TranslateAcceleratorIO(pio, &msg_a);
1640 if(hr == S_OK)
1641 key_accels = supported_key_accels_mode1;
1642 else
1643 key_accels = supported_key_accels_mode2;
1645 for(i = 0; i < 0x100; i++)
1647 BOOL found = FALSE;
1648 UINT j;
1649 for(j = 0; key_accels[j] != 0; j++)
1650 if(key_accels[j] == i)
1652 found = TRUE;
1653 break;
1656 msg_a.wParam = i;
1657 process_msgs();
1658 hr = IInputObject_TranslateAcceleratorIO(pio, &msg_a);
1659 todo_wine ok(hr == (found ? S_OK : S_FALSE), "Got 0x%08x (%04x)\n", hr, i);
1660 if(i == VK_F5)
1661 Sleep(1000); /* Needed for w2k8 (64bit) */
1664 process_msgs();
1666 IInputObject_Release(pio);
1667 IExplorerBrowser_Destroy(peb);
1668 IExplorerBrowser_Release(peb);
1671 static BOOL test_instantiate_control(void)
1673 IExplorerBrowser *peb;
1674 HRESULT hr;
1676 hr = ebrowser_instantiate(&peb);
1677 ok(hr == S_OK || hr == REGDB_E_CLASSNOTREG, "Got (0x%08x)\n", hr);
1678 if(FAILED(hr))
1679 return FALSE;
1681 IExplorerBrowser_Release(peb);
1682 return TRUE;
1685 static void setup_window(void)
1687 WNDCLASSW wc;
1688 static const WCHAR ebtestW[] = {'e','b','t','e','s','t',0};
1690 ZeroMemory(&wc, sizeof(WNDCLASSW));
1691 wc.lpfnWndProc = DefWindowProcW;
1692 wc.lpszClassName = ebtestW;
1693 RegisterClassW(&wc);
1694 hwnd = CreateWindowExW(0, ebtestW, NULL, 0,
1695 0, 0, 500, 500,
1696 NULL, 0, 0, NULL);
1697 ok(hwnd != NULL, "Failed to create window for tests.\n");
1700 START_TEST(ebrowser)
1702 OleInitialize(NULL);
1704 if(!test_instantiate_control())
1706 win_skip("No ExplorerBrowser control..\n");
1707 OleUninitialize();
1708 return;
1711 setup_window();
1712 init_function_pointers();
1714 test_QueryInterface();
1715 test_SB_misc();
1716 test_initialization();
1717 test_basics();
1718 test_Advise();
1719 test_navigation();
1720 test_GetCurrentView();
1721 test_SetSite();
1722 test_InputObject();
1724 DestroyWindow(hwnd);
1725 OleUninitialize();