Commit 1168b792 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

shell32: Properly fail for unsupported interfaces in IShellView::GetItemObject.

parent afb1a08b
......@@ -1989,28 +1989,38 @@ static HRESULT WINAPI IShellView_fnSelectItem(
static HRESULT WINAPI IShellView_fnGetItemObject(IShellView2 * iface, UINT uItem, REFIID riid, LPVOID *ppvOut)
{
IShellViewImpl *This = (IShellViewImpl *)iface;
IShellViewImpl *This = (IShellViewImpl *)iface;
HRESULT hr = E_NOINTERFACE;
TRACE("(%p)->(uItem=0x%08x,\n\tIID=%s, ppv=%p)\n",This, uItem, debugstr_guid(riid), ppvOut);
TRACE("(%p)->(0x%08x, %s, %p)\n",This, uItem, debugstr_guid(riid), ppvOut);
*ppvOut = NULL;
*ppvOut = NULL;
switch(uItem)
{
case SVGIO_BACKGROUND:
*ppvOut = ISvBgCm_Constructor(This->pSFParent, FALSE);
break;
switch(uItem)
{
case SVGIO_BACKGROUND:
case SVGIO_SELECTION:
ShellView_GetSelections(This);
IShellFolder_GetUIObjectOf(This->pSFParent, This->hWnd, This->cidl, (LPCITEMIDLIST*)This->apidl, riid, 0, ppvOut);
break;
}
TRACE("-- (%p)->(interface=%p)\n",This, *ppvOut);
if (IsEqualIID(&IID_IContextMenu, riid))
{
*ppvOut = ISvBgCm_Constructor(This->pSFParent, FALSE);
hr = S_OK;
}
else
FIXME("unsupported interface requested %s\n", debugstr_guid(riid));
if(!*ppvOut) return E_OUTOFMEMORY;
break;
return S_OK;
case SVGIO_SELECTION:
ShellView_GetSelections(This);
hr = IShellFolder_GetUIObjectOf(This->pSFParent, This->hWnd, This->cidl, (LPCITEMIDLIST*)This->apidl, riid, 0, ppvOut);
break;
default:
FIXME("unimplemented for uItem = 0x%08x\n", uItem);
}
TRACE("-- (%p)->(interface=%p)\n",This, *ppvOut);
return hr;
}
static HRESULT WINAPI IShellView2_fnGetView(IShellView2* iface, SHELLVIEWID *view_guid, ULONG view_type)
......
......@@ -36,6 +36,8 @@
#include "ocidl.h"
#include "oleauto.h"
#include "initguid.h"
#include "wine/test.h"
#include "msg.h"
......@@ -43,6 +45,8 @@
#define LISTVIEW_SEQ_INDEX 0
#define NUM_MSG_SEQUENCES 1
DEFINE_GUID(IID_IPersistHistory, 0x91a565c1, 0xe38f, 0x11d0, 0x94, 0xbf, 0x00, 0xa0, 0xc9, 0x05, 0x5c, 0xbf);
static struct msg_sequence *sequences[NUM_MSG_SEQUENCES];
static LRESULT WINAPI listview_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
......@@ -501,6 +505,43 @@ if (0)
IShellFolder_Release(desktop);
}
static void test_GetItemObject(void)
{
IShellFolder *desktop;
IShellView *view;
IUnknown *unk;
HRESULT hr;
hr = SHGetDesktopFolder(&desktop);
ok(hr == S_OK, "got (0x%08x)\n", hr);
hr = IShellFolder_CreateViewObject(desktop, NULL, &IID_IShellView, (void**)&view);
ok(hr == S_OK, "got (0x%08x)\n", hr);
/* from documentation three interfaces are supported for SVGIO_BACKGROUND:
IContextMenu, IDispatch, IPersistHistory */
hr = IShellView_GetItemObject(view, SVGIO_BACKGROUND, &IID_IContextMenu, (void**)&unk);
ok(hr == S_OK, "got (0x%08x)\n", hr);
IUnknown_Release(unk);
unk = NULL;
hr = IShellView_GetItemObject(view, SVGIO_BACKGROUND, &IID_IDispatch, (void**)&unk);
todo_wine ok(hr == S_OK || broken(hr == E_NOTIMPL) /* NT4 */, "got (0x%08x)\n", hr);
if (unk) IUnknown_Release(unk);
unk = NULL;
hr = IShellView_GetItemObject(view, SVGIO_BACKGROUND, &IID_IPersistHistory, (void**)&unk);
todo_wine ok(hr == S_OK || broken(hr == E_NOTIMPL) /* W9x, NT4 */, "got (0x%08x)\n", hr);
if (unk) IUnknown_Release(unk);
/* example of unsupported interface, base for IPersistHistory */
hr = IShellView_GetItemObject(view, SVGIO_BACKGROUND, &IID_IPersist, (void**)&unk);
ok(hr == E_NOINTERFACE || broken(hr == E_NOTIMPL) /* W2K */, "got (0x%08x)\n", hr);
IShellView_Release(view);
IShellFolder_Release(desktop);
}
START_TEST(shlview)
{
OleInitialize(NULL);
......@@ -509,6 +550,7 @@ START_TEST(shlview)
test_IShellView_CreateViewWindow();
test_IFolderView();
test_GetItemObject();
OleUninitialize();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment