Nikolay Sivov : shell32: Properly fail for unsupported interfaces in IShellView::GetItemObject.
Alexandre Julliard
julliard at winehq.org
Mon Mar 22 11:12:05 CDT 2010
Module: wine
Branch: master
Commit: 1168b79266bdf372f1865959c8efb1c743ff9ead
URL: http://source.winehq.org/git/wine.git/?a=commit;h=1168b79266bdf372f1865959c8efb1c743ff9ead
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Sat Mar 20 21:46:41 2010 +0300
shell32: Properly fail for unsupported interfaces in IShellView::GetItemObject.
---
dlls/shell32/shlview.c | 42 ++++++++++++++++++++++++++----------------
dlls/shell32/tests/shlview.c | 42 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 68 insertions(+), 16 deletions(-)
diff --git a/dlls/shell32/shlview.c b/dlls/shell32/shlview.c
index 7809344..bf8f979 100644
--- a/dlls/shell32/shlview.c
+++ b/dlls/shell32/shlview.c
@@ -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)
diff --git a/dlls/shell32/tests/shlview.c b/dlls/shell32/tests/shlview.c
index 31f47c1..e941ff4 100644
--- a/dlls/shell32/tests/shlview.c
+++ b/dlls/shell32/tests/shlview.c
@@ -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();
}
More information about the wine-cvs
mailing list