Commit bac369eb authored by Jactry Zeng's avatar Jactry Zeng Committed by Alexandre Julliard

shell32/tests: Move interfaces creation to a function.

parent e5c3a111
......@@ -619,6 +619,22 @@ static const IShellBrowserVtbl shellbrowservtbl = {
static IShellBrowser test_shellbrowser = { &shellbrowservtbl };
static void create_interfaces(IShellFolder **desktop, IShellView **view)
{
HRESULT hr;
hr = SHGetDesktopFolder(desktop);
ok(hr == S_OK, "Got hr %#lx.\n", hr);
hr = IShellFolder_CreateViewObject(*desktop, NULL, &IID_IShellView, (void **)view);
ok(hr == S_OK, "Got hr %#lx.\n", hr);
}
static void destroy_interfaces(IShellFolder *desktop, IShellView *view)
{
IShellFolder_Release(desktop);
IShellView_Release(view);
}
static void test_CreateViewWindow(void)
{
IShellFolder *desktop;
......@@ -631,11 +647,7 @@ static void test_CreateViewWindow(void)
ULONG ref1, ref2;
IUnknown *unk;
hr = SHGetDesktopFolder(&desktop);
ok(hr == S_OK, "got (0x%08lx)\n", hr);
hr = IShellFolder_CreateViewObject(desktop, NULL, &IID_IShellView, (void**)&view);
ok(hr == S_OK, "got (0x%08lx)\n", hr);
create_interfaces(&desktop, &view);
hr = IShellView_QueryInterface(view, &IID_CDefView, (void **)&unk);
ok(hr == S_OK, "got (0x%08lx)\n", hr);
......@@ -719,18 +731,13 @@ static void test_IFolderView(void)
POINT pt;
RECT r;
hr = SHGetDesktopFolder(&desktop);
ok(hr == S_OK, "got (0x%08lx)\n", hr);
hr = IShellFolder_CreateViewObject(desktop, NULL, &IID_IShellView, (void**)&view);
ok(hr == S_OK, "got (0x%08lx)\n", hr);
create_interfaces(&desktop, &view);
hr = IShellView_QueryInterface(view, &IID_IFolderView, (void**)&fv);
if (hr != S_OK)
{
win_skip("IFolderView not supported by desktop folder\n");
IShellView_Release(view);
IShellFolder_Release(desktop);
destroy_interfaces(desktop, view);
return;
}
......@@ -772,8 +779,7 @@ if (0)
win_skip("Failed to subclass ListView control\n");
IShellBrowser_Release(browser);
IFolderView_Release(fv);
IShellView_Release(view);
IShellFolder_Release(desktop);
destroy_interfaces(desktop, view);
return;
}
......@@ -863,8 +869,7 @@ if (0)
IShellBrowser_Release(browser);
IFolderView_Release(fv);
IShellView_Release(view);
IShellFolder_Release(desktop);
destroy_interfaces(desktop, view);
}
static void test_GetItemObject(void)
......@@ -874,11 +879,7 @@ static void test_GetItemObject(void)
IUnknown *unk;
HRESULT hr;
hr = SHGetDesktopFolder(&desktop);
ok(hr == S_OK, "got (0x%08lx)\n", hr);
hr = IShellFolder_CreateViewObject(desktop, NULL, &IID_IShellView, (void**)&view);
ok(hr == S_OK, "got (0x%08lx)\n", hr);
create_interfaces(&desktop, &view);
/* from documentation three interfaces are supported for SVGIO_BACKGROUND:
IContextMenu, IDispatch, IPersistHistory */
......@@ -900,8 +901,7 @@ static void test_GetItemObject(void)
hr = IShellView_GetItemObject(view, SVGIO_BACKGROUND, &IID_IPersist, (void**)&unk);
ok(hr == E_NOINTERFACE || broken(hr == E_NOTIMPL) /* W2K */, "got (0x%08lx)\n", hr);
IShellView_Release(view);
IShellFolder_Release(desktop);
destroy_interfaces(desktop, view);
}
static void test_IShellFolderView(void)
......@@ -913,18 +913,13 @@ static void test_IShellFolderView(void)
UINT i;
HRESULT hr;
hr = SHGetDesktopFolder(&desktop);
ok(hr == S_OK, "got (0x%08lx)\n", hr);
hr = IShellFolder_CreateViewObject(desktop, NULL, &IID_IShellView, (void**)&view);
ok(hr == S_OK, "got (0x%08lx)\n", hr);
create_interfaces(&desktop, &view);
hr = IShellView_QueryInterface(view, &IID_IShellFolderView, (void**)&folderview);
if (hr != S_OK)
{
win_skip("IShellView doesn't provide IShellFolderView on this platform\n");
IShellView_Release(view);
IShellFolder_Release(desktop);
destroy_interfaces(desktop, view);
return;
}
......@@ -955,8 +950,7 @@ static void test_IShellFolderView(void)
IShellFolderView_Release(folderview);
IShellView_Release(view);
IShellFolder_Release(desktop);
destroy_interfaces(desktop, view);
}
static void test_IOleWindow(void)
......@@ -966,11 +960,7 @@ static void test_IOleWindow(void)
IOleWindow *wnd;
HRESULT hr;
hr = SHGetDesktopFolder(&desktop);
ok(hr == S_OK, "got (0x%08lx)\n", hr);
hr = IShellFolder_CreateViewObject(desktop, NULL, &IID_IShellView, (void**)&view);
ok(hr == S_OK, "got (0x%08lx)\n", hr);
create_interfaces(&desktop, &view);
hr = IShellView_QueryInterface(view, &IID_IOleWindow, (void**)&wnd);
ok(hr == E_NOINTERFACE, "got (0x%08lx)\n", hr);
......@@ -981,8 +971,7 @@ static void test_IOleWindow(void)
hr = IShellView_ContextSensitiveHelp(view, FALSE);
ok(hr == E_NOTIMPL, "got (0x%08lx)\n", hr);
IShellView_Release(view);
IShellFolder_Release(desktop);
destroy_interfaces(desktop, view);
}
static const struct message folderview_setcurrentviewmode1_2_prevista[] = {
......@@ -1088,11 +1077,7 @@ static void test_GetSetCurrentViewMode(void)
static const int vista_res[11] = {0, 1, 5, 3, 4, 5, 6, 7, 7, 0, 0};
static const int win7_res[11] = {1, 1, 1, 3, 4, 1, 6, 1, 8, 8, 8};
hr = SHGetDesktopFolder(&desktop);
ok(hr == S_OK, "got (0x%08lx)\n", hr);
hr = IShellFolder_CreateViewObject(desktop, NULL, &IID_IShellView, (void**)&sview);
ok(hr == S_OK, "got (0x%08lx)\n", hr);
create_interfaces(&desktop, &sview);
hr = IShellView_QueryInterface(sview, &IID_IFolderView, (void **)&fview);
ok(hr == S_OK, "Got hr %#lx.\n", hr);
......@@ -1290,8 +1275,7 @@ static void test_GetSetCurrentViewMode(void)
IShellBrowser_Release(browser);
IShellView_DestroyViewWindow(sview);
IShellView_Release(sview);
IShellFolder_Release(desktop);
destroy_interfaces(desktop, sview);
}
static void test_IOleCommandTarget(void)
......
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