2008-04-10 13:01:38 +02:00
|
|
|
/*
|
2008-06-23 21:08:01 +02:00
|
|
|
* Tests for special shell folders
|
2008-04-10 13:01:38 +02:00
|
|
|
*
|
|
|
|
* Copyright 2008 Robert Shearman for CodeWeavers
|
2008-06-23 21:08:15 +02:00
|
|
|
* Copyright 2008 Owen Rudge
|
2008-04-10 13:01:38 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#define COBJMACROS
|
2010-04-18 16:00:31 +02:00
|
|
|
#define NONAMELESSUNION
|
|
|
|
#define NONAMELESSSTRUCT
|
|
|
|
|
2008-04-10 13:01:38 +02:00
|
|
|
#define WIN32_LEAN_AND_MEAN
|
|
|
|
#include <windows.h>
|
|
|
|
#include "shellapi.h"
|
2019-01-23 16:27:16 +01:00
|
|
|
#include "shlwapi.h"
|
2008-04-10 13:01:38 +02:00
|
|
|
#include "shlobj.h"
|
|
|
|
|
|
|
|
#include "wine/test.h"
|
|
|
|
|
2010-04-18 16:48:58 +02:00
|
|
|
static inline BOOL SHELL_OsIsUnicode(void)
|
|
|
|
{
|
|
|
|
return !(GetVersion() & 0x80000000);
|
|
|
|
}
|
|
|
|
|
2008-06-23 21:08:01 +02:00
|
|
|
/* Tests for My Network Places */
|
2008-04-10 13:01:38 +02:00
|
|
|
static void test_parse_for_entire_network(void)
|
|
|
|
{
|
2008-12-02 08:50:49 +01:00
|
|
|
static WCHAR my_network_places_path[] = {
|
|
|
|
':',':','{','2','0','8','D','2','C','6','0','-','3','A','E','A','-',
|
|
|
|
'1','0','6','9','-','A','2','D','7','-','0','8','0','0','2','B','3','0','3','0','9','D','}', 0 };
|
2008-12-02 08:25:20 +01:00
|
|
|
static WCHAR entire_network_path[] = {
|
2008-04-10 13:01:38 +02:00
|
|
|
':',':','{','2','0','8','D','2','C','6','0','-','3','A','E','A','-',
|
|
|
|
'1','0','6','9','-','A','2','D','7','-','0','8','0','0','2','B','3','0','3','0','9','D',
|
|
|
|
'}','\\','E','n','t','i','r','e','N','e','t','w','o','r','k',0 };
|
|
|
|
IShellFolder *psfDesktop;
|
|
|
|
HRESULT hr;
|
|
|
|
DWORD eaten = 0xdeadbeef;
|
|
|
|
LPITEMIDLIST pidl;
|
|
|
|
DWORD attr = ~0;
|
|
|
|
DWORD expected_attr;
|
|
|
|
|
|
|
|
hr = SHGetDesktopFolder(&psfDesktop);
|
|
|
|
ok(hr == S_OK, "SHGetDesktopFolder failed with error 0x%x\n", hr);
|
|
|
|
|
2008-12-02 08:50:49 +01:00
|
|
|
hr = IShellFolder_ParseDisplayName(psfDesktop, NULL, NULL, my_network_places_path, &eaten, &pidl, &attr);
|
|
|
|
ok(hr == S_OK, "IShellFolder_ParseDisplayName failed with error 0x%x\n", hr);
|
|
|
|
todo_wine
|
|
|
|
ok(eaten == 0xdeadbeef, "eaten should not have been set to %u\n", eaten);
|
|
|
|
expected_attr = SFGAO_HASSUBFOLDER|SFGAO_FOLDER|SFGAO_FILESYSANCESTOR|SFGAO_DROPTARGET|SFGAO_HASPROPSHEET|SFGAO_CANRENAME|SFGAO_CANLINK;
|
|
|
|
todo_wine
|
|
|
|
ok((attr == expected_attr) || /* Win9x, NT4 */
|
|
|
|
(attr == (expected_attr | SFGAO_STREAM)) || /* W2K */
|
|
|
|
(attr == (expected_attr | SFGAO_CANDELETE)) || /* XP, W2K3 */
|
|
|
|
(attr == (expected_attr | SFGAO_CANDELETE | SFGAO_NONENUMERATED)), /* Vista */
|
|
|
|
"Unexpected attributes : %08x\n", attr);
|
|
|
|
|
|
|
|
ILFree(pidl);
|
|
|
|
|
|
|
|
/* Start clean again */
|
|
|
|
eaten = 0xdeadbeef;
|
|
|
|
attr = ~0;
|
|
|
|
|
2008-12-02 08:25:20 +01:00
|
|
|
hr = IShellFolder_ParseDisplayName(psfDesktop, NULL, NULL, entire_network_path, &eaten, &pidl, &attr);
|
2015-06-26 20:43:22 +02:00
|
|
|
IShellFolder_Release(psfDesktop);
|
2009-07-24 11:44:41 +02:00
|
|
|
if (hr == HRESULT_FROM_WIN32(ERROR_BAD_NET_NAME) ||
|
|
|
|
hr == HRESULT_FROM_WIN32(ERROR_NO_NET_OR_BAD_PATH) ||
|
|
|
|
hr == HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER))
|
2008-12-02 08:50:49 +01:00
|
|
|
{
|
|
|
|
win_skip("'EntireNetwork' is not available on Win9x, NT4 and Vista\n");
|
|
|
|
return;
|
|
|
|
}
|
2008-04-10 13:01:38 +02:00
|
|
|
ok(hr == S_OK, "IShellFolder_ParseDisplayName failed with error 0x%x\n", hr);
|
|
|
|
todo_wine
|
|
|
|
ok(eaten == 0xdeadbeef, "eaten should not have been set to %u\n", eaten);
|
2009-07-24 11:44:41 +02:00
|
|
|
expected_attr = SFGAO_HASSUBFOLDER|SFGAO_FOLDER|SFGAO_FILESYSANCESTOR|SFGAO_HASPROPSHEET|SFGAO_CANLINK;
|
2008-04-10 13:01:38 +02:00
|
|
|
todo_wine
|
2009-07-24 11:44:41 +02:00
|
|
|
ok(attr == expected_attr || /* winme, nt4 */
|
|
|
|
attr == (expected_attr | SFGAO_STREAM) || /* win2k */
|
|
|
|
attr == (expected_attr | SFGAO_STORAGEANCESTOR), /* others */
|
|
|
|
"attr should be 0x%x, not 0x%x\n", expected_attr, attr);
|
2008-04-10 13:01:38 +02:00
|
|
|
|
|
|
|
ILFree(pidl);
|
|
|
|
}
|
|
|
|
|
2008-06-23 21:08:15 +02:00
|
|
|
/* Tests for Control Panel */
|
|
|
|
static void test_parse_for_control_panel(void)
|
|
|
|
{
|
|
|
|
/* path of My Computer\Control Panel */
|
2008-12-02 08:25:20 +01:00
|
|
|
static WCHAR control_panel_path[] = {
|
2008-06-23 21:08:15 +02:00
|
|
|
':',':','{','2','0','D','0','4','F','E','0','-','3','A','E','A','-','1','0','6','9','-','A','2','D','8','-','0','8','0','0','2','B','3','0','3','0','9','D','}','\\',
|
|
|
|
':',':','{','2','1','E','C','2','0','2','0','-','3','A','E','A','-','1','0','6','9','-','A','2','D','D','-','0','8','0','0','2','B','3','0','3','0','9','D','}', 0 };
|
|
|
|
IShellFolder *psfDesktop;
|
|
|
|
HRESULT hr;
|
|
|
|
DWORD eaten = 0xdeadbeef;
|
|
|
|
LPITEMIDLIST pidl;
|
|
|
|
DWORD attr = ~0;
|
|
|
|
|
|
|
|
hr = SHGetDesktopFolder(&psfDesktop);
|
|
|
|
ok(hr == S_OK, "SHGetDesktopFolder failed with error 0x%x\n", hr);
|
|
|
|
|
2008-12-02 08:25:20 +01:00
|
|
|
hr = IShellFolder_ParseDisplayName(psfDesktop, NULL, NULL, control_panel_path, &eaten, &pidl, &attr);
|
2008-06-23 21:08:15 +02:00
|
|
|
ok(hr == S_OK, "IShellFolder_ParseDisplayName failed with error 0x%x\n", hr);
|
|
|
|
todo_wine ok(eaten == 0xdeadbeef, "eaten should not have been set to %u\n", eaten);
|
2008-12-04 11:39:09 +01:00
|
|
|
todo_wine
|
|
|
|
ok((attr == (SFGAO_CANLINK | SFGAO_FOLDER)) || /* Win9x, NT4 */
|
|
|
|
(attr == (SFGAO_CANLINK | SFGAO_FOLDER | SFGAO_HASSUBFOLDER | SFGAO_STREAM)) || /* W2K */
|
|
|
|
(attr == (SFGAO_CANLINK | SFGAO_FOLDER | SFGAO_HASSUBFOLDER)) || /* W2K, XP, W2K3 */
|
|
|
|
(attr == (SFGAO_CANLINK | SFGAO_NONENUMERATED)) || /* Vista */
|
|
|
|
(attr == SFGAO_CANLINK), /* Vista, W2K8 */
|
|
|
|
"Unexpected attributes : %08x\n", attr);
|
2008-06-23 21:08:15 +02:00
|
|
|
|
|
|
|
ILFree(pidl);
|
2015-06-26 20:43:22 +02:00
|
|
|
IShellFolder_Release(psfDesktop);
|
2008-06-23 21:08:15 +02:00
|
|
|
}
|
|
|
|
|
2010-04-18 16:00:31 +02:00
|
|
|
static void test_printers_folder(void)
|
|
|
|
{
|
|
|
|
IShellFolder2 *folder;
|
2010-04-18 16:14:47 +02:00
|
|
|
IPersistFolder2 *pf;
|
2010-04-18 16:00:31 +02:00
|
|
|
SHELLDETAILS details;
|
|
|
|
SHCOLSTATEF state;
|
2010-04-18 16:14:47 +02:00
|
|
|
LPITEMIDLIST pidl1, pidl2;
|
2010-04-18 16:00:31 +02:00
|
|
|
HRESULT hr;
|
2010-04-18 16:48:58 +02:00
|
|
|
INT i;
|
2010-04-18 16:00:31 +02:00
|
|
|
|
|
|
|
CoInitialize( NULL );
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_Printers, NULL, CLSCTX_INPROC_SERVER, &IID_IShellFolder2, (void**)&folder);
|
|
|
|
if (hr != S_OK)
|
|
|
|
{
|
|
|
|
win_skip("Failed to created IShellFolder2 for Printers folder\n");
|
|
|
|
CoUninitialize();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (0)
|
|
|
|
{
|
|
|
|
/* crashes on XP */
|
2011-02-10 22:28:20 +01:00
|
|
|
IShellFolder2_GetDetailsOf(folder, NULL, 0, NULL);
|
|
|
|
IShellFolder2_GetDefaultColumnState(folder, 0, NULL);
|
|
|
|
IPersistFolder2_GetCurFolder(pf, NULL);
|
2010-04-18 16:00:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* 5 columns defined */
|
|
|
|
hr = IShellFolder2_GetDetailsOf(folder, NULL, 6, &details);
|
|
|
|
ok(hr == E_NOTIMPL, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IShellFolder2_GetDefaultColumnState(folder, 6, &state);
|
|
|
|
ok(broken(hr == E_NOTIMPL) || hr == E_INVALIDARG /* Win7 */, "got 0x%08x\n", hr);
|
|
|
|
|
2011-01-15 19:29:08 +01:00
|
|
|
details.str.u.pOleStr = NULL;
|
2010-04-20 00:57:09 +02:00
|
|
|
hr = IShellFolder2_GetDetailsOf(folder, NULL, 0, &details);
|
2016-09-08 11:23:38 +02:00
|
|
|
ok(hr == S_OK || broken(hr == E_NOTIMPL) /* W2K */, "got 0x%08x\n", hr);
|
2011-01-15 19:29:08 +01:00
|
|
|
if (SHELL_OsIsUnicode()) SHFree(details.str.u.pOleStr);
|
|
|
|
|
2010-04-20 00:57:09 +02:00
|
|
|
/* test every column if method is implemented */
|
|
|
|
if (hr == S_OK)
|
2010-04-18 16:00:31 +02:00
|
|
|
{
|
2010-04-20 00:57:09 +02:00
|
|
|
ok(details.str.uType == STRRET_WSTR, "got %d\n", details.str.uType);
|
|
|
|
|
|
|
|
for(i = 0; i < 6; i++)
|
|
|
|
{
|
|
|
|
hr = IShellFolder2_GetDetailsOf(folder, NULL, i, &details);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
/* all columns are left-aligned */
|
|
|
|
ok(details.fmt == LVCFMT_LEFT, "got 0x%x\n", details.fmt);
|
|
|
|
/* can't be on w9x at this point, IShellFolder2 unsupported there,
|
|
|
|
check present for running Wine with w9x setup */
|
|
|
|
if (SHELL_OsIsUnicode()) SHFree(details.str.u.pOleStr);
|
|
|
|
|
|
|
|
hr = IShellFolder2_GetDefaultColumnState(folder, i, &state);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
/* all columns are string except document count */
|
|
|
|
if (i == 1)
|
|
|
|
ok(state == (SHCOLSTATE_TYPE_INT | SHCOLSTATE_ONBYDEFAULT), "got 0x%x\n", state);
|
|
|
|
else
|
|
|
|
ok(state == (SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT), "got 0x%x\n", state);
|
|
|
|
}
|
2010-04-18 16:00:31 +02:00
|
|
|
}
|
|
|
|
|
2010-04-18 16:14:47 +02:00
|
|
|
/* default pidl */
|
|
|
|
hr = IShellFolder2_QueryInterface(folder, &IID_IPersistFolder2, (void**)&pf);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
/* not initialized */
|
|
|
|
pidl1 = (void*)0xdeadbeef;
|
|
|
|
hr = IPersistFolder2_GetCurFolder(pf, &pidl1);
|
|
|
|
ok(hr == S_FALSE, "got 0x%08x\n", hr);
|
|
|
|
ok(pidl1 == NULL, "got %p\n", pidl1);
|
|
|
|
|
|
|
|
hr = SHGetSpecialFolderLocation(NULL, CSIDL_PRINTERS, &pidl2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IPersistFolder2_Initialize(pf, pidl2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IPersistFolder2_GetCurFolder(pf, &pidl1);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
ok(ILIsEqual(pidl1, pidl2), "expected same PIDL\n");
|
|
|
|
IPersistFolder2_Release(pf);
|
|
|
|
|
|
|
|
ILFree(pidl1);
|
|
|
|
ILFree(pidl2);
|
2010-04-18 16:00:31 +02:00
|
|
|
IShellFolder2_Release(folder);
|
|
|
|
|
|
|
|
CoUninitialize();
|
|
|
|
}
|
2008-04-10 13:01:38 +02:00
|
|
|
|
2015-06-27 12:40:11 +02:00
|
|
|
static void test_desktop_folder(void)
|
|
|
|
{
|
|
|
|
IShellFolder *psf;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = SHGetDesktopFolder(&psf);
|
|
|
|
ok(hr == S_OK, "Got %x\n", hr);
|
|
|
|
|
|
|
|
hr = IShellFolder_QueryInterface(psf, &IID_IShellFolder, NULL);
|
|
|
|
ok(hr == E_POINTER, "Got %x\n", hr);
|
|
|
|
|
|
|
|
IShellFolder_Release(psf);
|
|
|
|
}
|
|
|
|
|
2019-01-23 16:27:16 +01:00
|
|
|
static void test_desktop_displaynameof(void)
|
|
|
|
{
|
|
|
|
static WCHAR MyComputer[] = { ':',':','{','2','0','D','0','4','F','E','0','-','3','A','E','A','-','1','0','6','9','-','A','2','D','8','-','0','8','0','0','2','B','3','0','3','0','9','D','}', 0 };
|
|
|
|
static WCHAR MyDocuments[] = { ':',':','{','4','5','0','D','8','F','B','A','-','A','D','2','5','-','1','1','D','0','-','9','8','A','8','-','0','8','0','0','3','6','1','B','1','1','0','3','}', 0 };
|
|
|
|
static WCHAR RecycleBin[] = { ':',':','{','6','4','5','F','F','0','4','0','-','5','0','8','1','-','1','0','1','B','-','9','F','0','8','-','0','0','A','A','0','0','2','F','9','5','4','E','}', 0 };
|
|
|
|
static WCHAR ControlPanel[]= { ':',':','{','2','0','D','0','4','F','E','0','-','3','A','E','A','-','1','0','6','9','-','A','2','D','8','-','0','8','0','0','2','B','3','0','3','0','9','D','}','\\',
|
|
|
|
':',':','{','2','1','E','C','2','0','2','0','-','3','A','E','A','-','1','0','6','9','-','A','2','D','D','-','0','8','0','0','2','B','3','0','3','0','9','D','}', 0 };
|
|
|
|
static WCHAR *folders[] = { MyComputer, MyDocuments, RecycleBin, ControlPanel };
|
|
|
|
IShellFolder *desktop;
|
|
|
|
ITEMIDLIST *pidl;
|
|
|
|
STRRET strret;
|
|
|
|
DWORD eaten;
|
|
|
|
HRESULT hr;
|
|
|
|
UINT i;
|
|
|
|
|
|
|
|
hr = SHGetDesktopFolder(&desktop);
|
|
|
|
ok(hr == S_OK, "SHGetDesktopFolder failed with error 0x%08x\n", hr);
|
|
|
|
if (FAILED(hr)) return;
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(folders); i++)
|
|
|
|
{
|
|
|
|
WCHAR name1[MAX_PATH], name2[MAX_PATH];
|
|
|
|
|
|
|
|
hr = IShellFolder_ParseDisplayName(desktop, NULL, NULL, folders[i], &eaten, &pidl, NULL);
|
|
|
|
ok(hr == S_OK, "IShellFolder::ParseDisplayName failed with error 0x%08x\n", hr);
|
|
|
|
if (FAILED(hr)) continue;
|
|
|
|
|
|
|
|
hr = IShellFolder_GetDisplayNameOf(desktop, pidl, SHGDN_INFOLDER, &strret);
|
|
|
|
ok(hr == S_OK, "IShellFolder::GetDisplayNameOf failed with error 0x%08x\n", hr);
|
|
|
|
hr = StrRetToBufW(&strret, pidl, name1, ARRAY_SIZE(name1));
|
|
|
|
ok(hr == S_OK, "StrRetToBuf failed with error 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IShellFolder_GetDisplayNameOf(desktop, pidl, SHGDN_INFOLDER | SHGDN_FORPARSING | SHGDN_FORADDRESSBAR, &strret);
|
|
|
|
ok(hr == S_OK, "IShellFolder::GetDisplayNameOf failed with error 0x%08x\n", hr);
|
|
|
|
hr = StrRetToBufW(&strret, pidl, name2, ARRAY_SIZE(name2));
|
|
|
|
ok(hr == S_OK, "StrRetToBuf failed with error 0x%08x\n", hr);
|
|
|
|
|
|
|
|
ok(!lstrcmpW(name1, name2), "the display names are not equal: %s vs %s\n", wine_dbgstr_w(name1), wine_dbgstr_w(name2));
|
|
|
|
ok(name1[0] != ':' || name1[1] != ':', "display name is a GUID: %s\n", wine_dbgstr_w(name1));
|
|
|
|
|
|
|
|
hr = IShellFolder_GetDisplayNameOf(desktop, pidl, SHGDN_INFOLDER | SHGDN_FORPARSING, &strret);
|
|
|
|
ok(hr == S_OK, "IShellFolder::GetDisplayNameOf failed with error 0x%08x\n", hr);
|
|
|
|
hr = StrRetToBufW(&strret, pidl, name1, ARRAY_SIZE(name1));
|
|
|
|
ok(hr == S_OK, "StrRetToBuf failed with error 0x%08x\n", hr);
|
|
|
|
|
|
|
|
ok(lstrcmpW(name1, name2), "the display names are equal: %s\n", wine_dbgstr_w(name1));
|
|
|
|
ok(name1[0] == ':' && name1[1] == ':', "display name is not a GUID: %s\n", wine_dbgstr_w(name1));
|
|
|
|
|
|
|
|
ILFree(pidl);
|
|
|
|
}
|
|
|
|
IShellFolder_Release(desktop);
|
|
|
|
}
|
|
|
|
|
2008-06-23 21:08:01 +02:00
|
|
|
START_TEST(shfldr_special)
|
2008-04-10 13:01:38 +02:00
|
|
|
{
|
|
|
|
test_parse_for_entire_network();
|
2008-06-23 21:08:15 +02:00
|
|
|
test_parse_for_control_panel();
|
2010-04-18 16:00:31 +02:00
|
|
|
test_printers_folder();
|
2015-06-27 12:40:11 +02:00
|
|
|
test_desktop_folder();
|
2019-01-23 16:27:16 +01:00
|
|
|
test_desktop_displaynameof();
|
2008-04-10 13:01:38 +02:00
|
|
|
}
|