sync shell32_winetest with wine 1.1.27

svn path=/trunk/; revision=42559
This commit is contained in:
Christoph von Wittich 2009-08-09 12:49:55 +00:00
parent a5dfb6bd53
commit 2127bca655
6 changed files with 156 additions and 36 deletions

View file

@ -48,6 +48,7 @@ static fnSHILCreateFromPath pSHILCreateFromPath;
static fnSHDefExtractIconA pSHDefExtractIconA;
static DWORD (WINAPI *pGetLongPathNameA)(LPCSTR, LPSTR, DWORD);
static DWORD (WINAPI *pGetShortPathNameA)(LPCSTR, LPSTR, DWORD);
static const GUID _IID_IShellLinkDataList = {
0x45e2b4ae, 0xb1c3, 0x11d0,
@ -223,6 +224,7 @@ static void test_get_set(void)
r = IShellLinkA_SetPath(sl, "\"c:\\nonexistent\\file\"");
ok(r==S_FALSE || r == S_OK, "SetPath failed (0x%08x)\n", r);
strcpy(buffer,"garbage");
r = IShellLinkA_GetPath(sl, buffer, sizeof(buffer), NULL, SLGP_RAWPATH);
ok(r==S_OK, "GetPath failed (0x%08x)\n", r);
ok(!lstrcmp(buffer, "C:\\nonexistent\\file") ||
@ -615,6 +617,25 @@ static void test_load_save(void)
create_lnk(lnkfile, &desc, 0);
check_lnk(lnkfile, &desc, 0x0);
r=pGetShortPathNameA(mydir, mypath, sizeof(mypath));
strcpy(realpath, mypath);
strcat(realpath, "\\test.txt");
strcat(mypath, "\\\\test.txt");
/* Overwrite the existing lnk file and test link to a short path with double backslashes */
desc.description="non-executable file";
desc.workdir=mydir;
desc.path=mypath;
desc.pidl=NULL;
desc.arguments="";
desc.showcmd=SW_SHOWNORMAL;
desc.icon=mypath;
desc.icon_id=0;
desc.hotkey=0x1234;
create_lnk(lnkfile, &desc, 0);
desc.path=realpath;
check_lnk(lnkfile, &desc, 0x0);
r = DeleteFileA(mypath);
ok(r, "failed to delete file %s (%d)\n", mypath, GetLastError());
@ -750,6 +771,7 @@ START_TEST(shelllink)
pSHDefExtractIconA = (fnSHDefExtractIconA) GetProcAddress(hmod, "SHDefExtractIconA");
pGetLongPathNameA = (void *)GetProcAddress(hkernel32, "GetLongPathNameA");
pGetShortPathNameA = (void *)GetProcAddress(hkernel32, "GetShortPathNameA");
r = CoInitialize(NULL);
ok(SUCCEEDED(r), "CoInitialize failed (0x%08x)\n", r);

View file

@ -89,6 +89,7 @@ static HRESULT (WINAPI *pSHGetSpecialFolderLocation)(HWND, int, LPITEMIDLIST *);
static LPITEMIDLIST (WINAPI *pILFindLastID)(LPCITEMIDLIST);
static int (WINAPI *pSHFileOperationA)(LPSHFILEOPSTRUCTA);
static HRESULT (WINAPI *pSHGetMalloc)(LPMALLOC *);
static UINT (WINAPI *pGetSystemWow64DirectoryA)(LPSTR,UINT);
static DLLVERSIONINFO shellVersion = { 0 };
static LPMALLOC pMalloc;
static const BYTE guidType[] = { PT_GUID };
@ -684,10 +685,17 @@ static void testSystemDir(void)
"GetSystemDirectory returns %s SHGetSpecialFolderPath returns %s\n",
systemDir, systemShellPath);
}
/* CSIDL_SYSTEMX86 isn't checked in the same way, since it's different
* on Win64 (and non-x86 Windows systems, if there are any still in
* existence) than on Win32.
*/
if (!pGetSystemWow64DirectoryA || !pGetSystemWow64DirectoryA(systemDir, sizeof(systemDir)))
GetSystemDirectoryA(systemDir, sizeof(systemDir));
myPathRemoveBackslashA(systemDir);
if (pSHGetSpecialFolderPathA(NULL, systemShellPath, CSIDL_SYSTEMX86, FALSE))
{
myPathRemoveBackslashA(systemShellPath);
ok(!lstrcmpiA(systemDir, systemShellPath),
"GetSystemDirectory returns %s SHGetSpecialFolderPath returns %s\n",
systemDir, systemShellPath);
}
}
/* Globals used by subprocesses */
@ -871,6 +879,8 @@ START_TEST(shellpath)
if (!init()) return;
loadShell32();
pGetSystemWow64DirectoryA = (void *)GetProcAddress( GetModuleHandleA("kernel32.dll"),
"GetSystemWow64DirectoryA" );
if (myARGC >= 3)
doChild(myARGV[2]);

View file

@ -46,7 +46,6 @@ static void test_parse_for_entire_network(void)
LPITEMIDLIST pidl;
DWORD attr = ~0;
DWORD expected_attr;
DWORD alter_attr;
hr = SHGetDesktopFolder(&psfDesktop);
ok(hr == S_OK, "SHGetDesktopFolder failed with error 0x%x\n", hr);
@ -70,7 +69,9 @@ static void test_parse_for_entire_network(void)
attr = ~0;
hr = IShellFolder_ParseDisplayName(psfDesktop, NULL, NULL, entire_network_path, &eaten, &pidl, &attr);
if (hr == HRESULT_FROM_WIN32(ERROR_BAD_NET_NAME) || hr == HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER))
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))
{
win_skip("'EntireNetwork' is not available on Win9x, NT4 and Vista\n");
return;
@ -78,12 +79,12 @@ static void test_parse_for_entire_network(void)
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_STORAGEANCESTOR|SFGAO_HASPROPSHEET|SFGAO_CANLINK;
alter_attr = (expected_attr & (~SFGAO_STORAGEANCESTOR)) | SFGAO_STREAM;
expected_attr = SFGAO_HASSUBFOLDER|SFGAO_FOLDER|SFGAO_FILESYSANCESTOR|SFGAO_HASPROPSHEET|SFGAO_CANLINK;
todo_wine
ok(attr == expected_attr ||
attr == alter_attr, /* win2k */
"attr should be 0x%x or 0x%x, not 0x%x\n", expected_attr, alter_attr, attr);
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);
ILFree(pidl);
}

View file

@ -587,7 +587,79 @@ static int _okChildInt(const char* file, int line, const char* key, int expected
#define okChildPath(key, expected) _okChildPath(__FILE__, __LINE__, (key), (expected))
#define okChildInt(key, expected) _okChildInt(__FILE__, __LINE__, (key), (expected))
/***
*
* GetLongPathNameA equivalent that supports Win95 and WinNT
*
***/
static DWORD get_long_path_name(const char* shortpath, char* longpath, DWORD longlen)
{
char tmplongpath[MAX_PATH];
const char* p;
DWORD sp = 0, lp = 0;
DWORD tmplen;
WIN32_FIND_DATAA wfd;
HANDLE goit;
if (!shortpath || !shortpath[0])
return 0;
if (shortpath[1] == ':')
{
tmplongpath[0] = shortpath[0];
tmplongpath[1] = ':';
lp = sp = 2;
}
while (shortpath[sp])
{
/* check for path delimiters and reproduce them */
if (shortpath[sp] == '\\' || shortpath[sp] == '/')
{
if (!lp || tmplongpath[lp-1] != '\\')
{
/* strip double "\\" */
tmplongpath[lp++] = '\\';
}
tmplongpath[lp] = 0; /* terminate string */
sp++;
continue;
}
p = shortpath + sp;
if (sp == 0 && p[0] == '.' && (p[1] == '/' || p[1] == '\\'))
{
tmplongpath[lp++] = *p++;
tmplongpath[lp++] = *p++;
}
for (; *p && *p != '/' && *p != '\\'; p++);
tmplen = p - (shortpath + sp);
lstrcpyn(tmplongpath + lp, shortpath + sp, tmplen + 1);
/* Check if the file exists and use the existing file name */
goit = FindFirstFileA(tmplongpath, &wfd);
if (goit == INVALID_HANDLE_VALUE)
return 0;
FindClose(goit);
strcpy(tmplongpath + lp, wfd.cFileName);
lp += strlen(tmplongpath + lp);
sp += tmplen;
}
tmplen = strlen(shortpath) - 1;
if ((shortpath[tmplen] == '/' || shortpath[tmplen] == '\\') &&
(tmplongpath[lp - 1] != '/' && tmplongpath[lp - 1] != '\\'))
tmplongpath[lp++] = shortpath[tmplen];
tmplongpath[lp] = 0;
tmplen = strlen(tmplongpath) + 1;
if (tmplen <= longlen)
{
strcpy(longpath, tmplongpath);
tmplen--; /* length without 0 */
}
return tmplen;
}
/***
*
@ -864,8 +936,7 @@ static void test_find_executable(void)
ok(rc == SE_ERR_NOASSOC /* >= win2000 */ || rc > 32 /* win98, nt4 */, "FindExecutable(NULL) returned %ld\n", rc);
ok(strcmp(command, "your word") != 0, "FindExecutable(NULL) returned command=[%s]\n", command);
/* Win95 can't cope with double backslashes in FindExecutableA (tmpdir has a trailing backslash) */
sprintf(filename, "%stest file.sfe", tmpdir);
sprintf(filename, "%s\\test file.sfe", tmpdir);
rc=(INT_PTR)FindExecutableA(filename, NULL, command);
ok(rc > 32, "FindExecutable(%s) returned %ld\n", filename, rc);
/* Depending on the platform, command could be '%1' or 'test file.sfe' */
@ -911,10 +982,6 @@ static void test_find_executable(void)
test=filename_tests;
while (test->basename)
{
/* Win95 can't cope with double slashes/backslashes in FindExecutableA */
if (tmpdir[strlen(tmpdir) - 1] == '\\')
tmpdir[strlen(tmpdir) - 1] = 0;
sprintf(filename, test->basename, tmpdir);
if (strchr(filename, '/'))
{
@ -991,7 +1058,8 @@ static void test_lnks(void)
GetLastError());
okChildInt("argcA", 5);
okChildString("argvA3", "Open");
sprintf(filename, "%s\\test file.shlexec", tmpdir);
sprintf(params, "%s\\test file.shlexec", tmpdir);
get_long_path_name(params, filename, sizeof(filename));
okChildPath("argvA4", filename);
sprintf(filename, "%s\\test_shortcut_exe.lnk", tmpdir);
@ -1527,8 +1595,13 @@ static void init_test(void)
"unable to find argv0!\n");
}
GetTempPathA(sizeof(tmpdir)/sizeof(*tmpdir), tmpdir);
assert(GetTempFileNameA(tmpdir, "wt", 0, child_file)!=0);
GetTempPathA(sizeof(filename), filename);
GetTempFileNameA(filename, "wt", 0, tmpdir);
DeleteFileA( tmpdir );
rc = CreateDirectoryA( tmpdir, NULL );
ok( rc, "failed to create %s err %u\n", tmpdir, GetLastError() );
rc = GetTempFileNameA(tmpdir, "wt", 0, child_file);
assert(rc != 0);
init_event(child_file);
/* Set up the test files */
@ -1608,6 +1681,7 @@ static void cleanup_test(void)
testfile++;
}
DeleteFile(child_file);
RemoveDirectoryA(tmpdir);
/* Delete the test association */
delete_test_association(".shlexec");

View file

@ -189,7 +189,7 @@ static void test_get_file_info(void)
/* Test whether fields of SHFILEINFOA are always cleared */
memset(&shfi, 0xcf, sizeof(shfi));
rc=SHGetFileInfoA("", 0, &shfi, sizeof(shfi), 0);
ok(rc, "SHGetFileInfoA('' | 0) should not fail\n");
ok(rc == 1, "SHGetFileInfoA('' | 0) should return 1, got 0x%x\n", rc);
todo_wine ok(shfi.hIcon == 0, "SHGetFileInfoA('' | 0) did not clear hIcon\n");
todo_wine ok(shfi.szDisplayName[0] == 0, "SHGetFileInfoA('' | 0) did not clear szDisplayName[0]\n");
todo_wine ok(shfi.szTypeName[0] == 0, "SHGetFileInfoA('' | 0) did not clear szTypeName[0]\n");
@ -225,7 +225,7 @@ static void test_get_file_info(void)
rc=SHGetFileInfoA("c:\\nonexistent", FILE_ATTRIBUTE_DIRECTORY,
&shfi, sizeof(shfi),
SHGFI_ATTRIBUTES | SHGFI_USEFILEATTRIBUTES);
ok(rc, "SHGetFileInfoA(c:\\nonexistent | SHGFI_ATTRIBUTES) failed\n");
ok(rc == 1, "SHGetFileInfoA(c:\\nonexistent | SHGFI_ATTRIBUTES) should return 1, got 0x%x\n", rc);
if (rc)
ok(shfi.dwAttributes != 0xcfcfcfcf, "dwFileAttributes is not set\n");
todo_wine ok(shfi.hIcon == 0, "SHGetFileInfoA(c:\\nonexistent | SHGFI_ATTRIBUTES) did not clear hIcon\n");
@ -238,7 +238,7 @@ static void test_get_file_info(void)
rc=SHGetFileInfoA("c:\\nonexistent", FILE_ATTRIBUTE_DIRECTORY,
&shfi, sizeof(shfi),
SHGFI_EXETYPE | SHGFI_USEFILEATTRIBUTES);
todo_wine ok(rc == 1, "SHGetFileInfoA(c:\\nonexistent | SHGFI_EXETYPE) returned %d\n", rc);
todo_wine ok(rc == 1, "SHGetFileInfoA(c:\\nonexistent | SHGFI_EXETYPE) should return 1, got 0x%x\n", rc);
/* Test SHGFI_USEFILEATTRIBUTES support */
strcpy(shfi.szDisplayName, "dummy");
@ -246,7 +246,7 @@ static void test_get_file_info(void)
rc=SHGetFileInfoA("c:\\nonexistent", FILE_ATTRIBUTE_DIRECTORY,
&shfi, sizeof(shfi),
SHGFI_ICONLOCATION | SHGFI_USEFILEATTRIBUTES);
ok(rc, "SHGetFileInfoA(c:\\nonexistent) failed\n");
ok(rc == 1, "SHGetFileInfoA(c:\\nonexistent) should return 1, got 0x%x\n", rc);
if (rc)
{
ok(strcpy(shfi.szDisplayName, "dummy") != 0, "SHGetFileInfoA(c:\\nonexistent) displayname is not set\n");
@ -263,13 +263,13 @@ static void test_get_file_info(void)
rc=SHGetFileInfoA(notepad, GetFileAttributes(notepad),
&shfi, sizeof(shfi),
SHGFI_ICONLOCATION | SHGFI_USEFILEATTRIBUTES);
ok(rc, "SHGetFileInfoA(%s, SHGFI_USEFILEATTRIBUTES) failed\n", notepad);
ok(rc == 1, "SHGetFileInfoA(%s, SHGFI_USEFILEATTRIBUTES) should return 1, got 0x%x\n", notepad, rc);
strcpy(shfi2.szDisplayName, "dummy");
shfi2.iIcon=0xdeadbeef;
rc2=SHGetFileInfoA(notepad, 0,
&shfi2, sizeof(shfi2),
SHGFI_ICONLOCATION);
ok(rc2, "SHGetFileInfoA(%s) failed\n", notepad);
ok(rc2 == 1, "SHGetFileInfoA(%s) failed %x\n", notepad, rc2);
if (rc && rc2)
{
ok(lstrcmpi(shfi2.szDisplayName, shfi.szDisplayName) == 0, "wrong display name %s != %s\n", shfi.szDisplayName, shfi2.szDisplayName);
@ -283,18 +283,31 @@ static void test_get_file_info(void)
rc=SHGetFileInfoA("test4.txt", GetFileAttributes("test4.txt"),
&shfi, sizeof(shfi),
SHGFI_ICONLOCATION | SHGFI_USEFILEATTRIBUTES);
ok(rc, "SHGetFileInfoA(test4.txt/, SHGFI_USEFILEATTRIBUTES) failed\n");
ok(rc == 1, "SHGetFileInfoA(test4.txt/, SHGFI_USEFILEATTRIBUTES) should return 1, got 0x%x\n", rc);
strcpy(shfi2.szDisplayName, "dummy");
shfi2.iIcon=0xdeadbeef;
rc2=SHGetFileInfoA("test4.txt", 0,
&shfi2, sizeof(shfi2),
SHGFI_ICONLOCATION);
ok(rc2, "SHGetFileInfoA(test4.txt/) failed\n");
ok(rc2 == 1, "SHGetFileInfoA(test4.txt/) should return 1, got 0x%x\n", rc2);
if (rc && rc2)
{
ok(lstrcmpi(shfi2.szDisplayName, shfi.szDisplayName) == 0, "wrong display name %s != %s\n", shfi.szDisplayName, shfi2.szDisplayName);
ok(shfi2.iIcon == shfi.iIcon, "wrong icon index %d != %d\n", shfi.iIcon, shfi2.iIcon);
}
/* with drive root directory */
strcpy(shfi.szDisplayName, "dummy");
strcpy(shfi.szTypeName, "dummy");
shfi.hIcon=(HICON) 0xdeadbeef;
shfi.iIcon=0xdeadbeef;
shfi.dwAttributes=0xdeadbeef;
rc=SHGetFileInfoA("c:\\", 0, &shfi, sizeof(shfi),
SHGFI_TYPENAME | SHGFI_DISPLAYNAME | SHGFI_ICON | SHGFI_SMALLICON);
ok(rc == 1, "SHGetFileInfoA(c:\\) should return 1, got 0x%x\n", rc);
ok(lstrcmp(shfi.szDisplayName, "dummy") != 0, "display name was expected to change\n");
ok(lstrcmp(shfi.szTypeName, "dummy") != 0, "type name was expected to change\n");
ok(shfi.hIcon != (HICON) 0xdeadbeef, "hIcon was expected to change\n");
ok(shfi.iIcon != 0xdeadbeef, "iIcon was expected to change\n");
}
static void test_get_file_info_iconlist(void)
@ -318,7 +331,7 @@ static void test_get_file_info_iconlist(void)
hSysImageList = (HIMAGELIST) SHGetFileInfoA((const char *)pidList, 0,
&shInfoa, sizeof(shInfoa),
SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_PIDL);
ok(hSysImageList != INVALID_HANDLE_VALUE, "Can't get handle for CSIDL_DESKTOP imagelist\n");
ok((hSysImageList != INVALID_HANDLE_VALUE) && (hSysImageList > (HIMAGELIST) 0xffff), "Can't get handle for CSIDL_DESKTOP imagelist\n");
todo_wine ok(shInfoa.hIcon == 0, "SHGetFileInfoA(CSIDL_DESKTOP, SHGFI_SYSICONINDEX|SHGFI_SMALLICON|SHGFI_PIDL) did not clear hIcon\n");
todo_wine ok(shInfoa.szTypeName[0] == 0, "SHGetFileInfoA(CSIDL_DESKTOP, SHGFI_SYSICONINDEX|SHGFI_SMALLICON|SHGFI_PIDL) did not clear szTypeName[0]\n");
ok(shInfoa.iIcon != 0xcfcfcfcf, "SHGetFileInfoA(CSIDL_DESKTOP, SHGFI_SYSICONINDEX|SHGFI_SMALLICON|SHGFI_PIDL) should set iIcon\n");
@ -344,7 +357,7 @@ static void test_get_file_info_iconlist(void)
win_skip("SHGetFileInfoW is not implemented\n");
return;
}
ok(hSysImageList != INVALID_HANDLE_VALUE, "Can't get handle for CSIDL_DESKTOP imagelist\n");
ok((hSysImageList != INVALID_HANDLE_VALUE) && (hSysImageList > (HIMAGELIST) 0xffff), "Can't get handle for CSIDL_DESKTOP imagelist\n");
todo_wine ok(shInfow.hIcon == 0, "SHGetFileInfoW(CSIDL_DESKTOP, SHGFI_SYSICONINDEX|SHGFI_SMALLICON|SHGFI_PIDL) did not clear hIcon\n");
ok(shInfow.szTypeName[0] == 0, "SHGetFileInfoW(CSIDL_DESKTOP, SHGFI_SYSICONINDEX|SHGFI_SMALLICON|SHGFI_PIDL) did not clear szTypeName[0]\n");
ok(shInfow.iIcon != 0xcfcfcfcf, "SHGetFileInfoW(CSIDL_DESKTOP, SHGFI_SYSICONINDEX|SHGFI_SMALLICON|SHGFI_PIDL) should set iIcon\n");

View file

@ -1565,21 +1565,21 @@ static void testSHGetFolderPathAndSubDirA(void)
}
if(FAILED(pSHGetFolderPathA(NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, appdata)))
{
skip("SHGetFolderPathA failed for CSIDL_LOCAL_APPDATA!\n");
win_skip("SHGetFolderPathA failed for CSIDL_LOCAL_APPDATA!\n");
return;
}
sprintf(testpath, "%s\\%s", appdata, winetemp);
delret = RemoveDirectoryA(testpath);
if(!delret && (ERROR_PATH_NOT_FOUND != GetLastError()) ) {
skip("RemoveDirectoryA(%s) failed with error %u\n", testpath, GetLastError());
win_skip("RemoveDirectoryA(%s) failed with error %u\n", testpath, GetLastError());
return;
}
sprintf(testpath, "%s\\%s", appdata, wine);
delret = RemoveDirectoryA(testpath);
if(!delret && (ERROR_PATH_NOT_FOUND != GetLastError()) && (ERROR_FILE_NOT_FOUND != GetLastError())) {
skip("RemoveDirectoryA(%s) failed with error %u\n", testpath, GetLastError());
win_skip("RemoveDirectoryA(%s) failed with error %u\n", testpath, GetLastError());
return;
}
@ -1695,7 +1695,7 @@ static void test_LocalizedNames(void)
len = lstrlenA(cCurrDirA);
if (len == 0) {
trace("GetCurrentDirectoryA returned empty string. Skipping test_LocalizedNames\n");
win_skip("GetCurrentDirectoryA returned empty string. Skipping test_LocalizedNames\n");
goto cleanup;
}
if(cCurrDirA[len-1] == '\\')
@ -1944,12 +1944,12 @@ START_TEST(shlfolder)
if(pSHGetFolderPathAndSubDirA)
testSHGetFolderPathAndSubDirA();
else
skip("SHGetFolderPathAndSubDirA not present\n");
win_skip("SHGetFolderPathAndSubDirA not present\n");
test_LocalizedNames();
if(pSHCreateShellItem)
test_SHCreateShellItem();
else
win_skip("test_SHCreateShellItem not present\n");
win_skip("SHCreateShellItem not present\n");
OleUninitialize();
}