[SHELL32_WINETEST]

sync shell32_winetest to wine 1.1.40

svn path=/trunk/; revision=45977
This commit is contained in:
Christoph von Wittich 2010-03-07 07:34:02 +00:00
parent 2b61353ce2
commit fbff905ed2
4 changed files with 155 additions and 39 deletions

View file

@ -126,9 +126,8 @@ START_TEST(autocomplete)
return;
createMainWnd();
if(!ok(hMainWnd != NULL, "Failed to create parent window. Tests aborted.\n"))
return;
ok(hMainWnd != NULL, "Failed to create parent window. Tests aborted.\n");
if (!hMainWnd) return;
ac = test_init();
if (!ac)

View file

@ -672,28 +672,28 @@ static int StrCmpPath(const char* s1, const char* s2)
return 0;
}
static int _okChildString(const char* file, int line, const char* key, const char* expected)
static void _okChildString(const char* file, int line, const char* key, const char* expected)
{
char* result;
result=getChildString("Arguments", key);
return ok_(file, line)(lstrcmpiA(result, expected) == 0,
"%s expected '%s', got '%s'\n", key, expected, result);
ok_(file, line)(lstrcmpiA(result, expected) == 0,
"%s expected '%s', got '%s'\n", key, expected, result);
}
static int _okChildPath(const char* file, int line, const char* key, const char* expected)
static void _okChildPath(const char* file, int line, const char* key, const char* expected)
{
char* result;
result=getChildString("Arguments", key);
return ok_(file, line)(StrCmpPath(result, expected) == 0,
"%s expected '%s', got '%s'\n", key, expected, result);
ok_(file, line)(StrCmpPath(result, expected) == 0,
"%s expected '%s', got '%s'\n", key, expected, result);
}
static int _okChildInt(const char* file, int line, const char* key, int expected)
static void _okChildInt(const char* file, int line, const char* key, int expected)
{
INT result;
result=GetPrivateProfileIntA("Arguments", key, expected, child_file);
return ok_(file, line)(result == expected,
"%s expected %d, but got %d\n", key, expected, result);
ok_(file, line)(result == expected,
"%s expected %d, but got %d\n", key, expected, result);
}
#define okChildString(key, expected) _okChildString(__FILE__, __LINE__, (key), (expected))

View file

@ -965,6 +965,26 @@ static void test_copy(void)
ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
ok(file_exists("testdir2\\test1.txt"), "Expected testdir2\\test1 to exist\n");
/* try to overwrite an existing write protected file */
clean_after_shfo_tests();
init_shfo_tests();
tmp_flags = shfo.fFlags;
shfo.pFrom = "test1.txt\0";
shfo.pTo = "test2.txt\0";
/* suppress the error-dialog in win9x here */
shfo.fFlags = FOF_NOERRORUI | FOF_NOCONFIRMATION | FOF_SILENT;
ok(SetFileAttributesA(shfo.pTo, FILE_ATTRIBUTE_READONLY),
"Failure to set file attributes (error %x)\n", GetLastError());
retval = CopyFileA(shfo.pFrom, shfo.pTo, FALSE);
ok(!retval && GetLastError() == ERROR_ACCESS_DENIED, "CopyFileA should have fail with ERROR_ACCESS_DENIED\n");
retval = SHFileOperationA(&shfo);
/* Does not work on Win95, Win95B, NT4WS and NT4SRV */
ok(!retval || broken(retval == DE_OPCANCELLED), "SHFileOperationA failed to copy (error %x)\n", retval);
/* Set back normal attributes to make the file deletion succeed */
ok(SetFileAttributesA(shfo.pTo, FILE_ATTRIBUTE_NORMAL),
"Failure to set file attributes (error %x)\n", GetLastError());
shfo.fFlags = tmp_flags;
/* try to copy files to a file */
clean_after_shfo_tests();
init_shfo_tests();

View file

@ -54,7 +54,7 @@ static void (WINAPI *pILFree)(LPITEMIDLIST);
static BOOL (WINAPI *pILIsEqual)(LPCITEMIDLIST, LPCITEMIDLIST);
static HRESULT (WINAPI *pSHCreateShellItem)(LPCITEMIDLIST,IShellFolder*,LPCITEMIDLIST,IShellItem**);
static LPITEMIDLIST (WINAPI *pILCombine)(LPCITEMIDLIST,LPCITEMIDLIST);
static HRESULT (WINAPI *pSHParseDisplayName)(LPCWSTR,IBindCtx*,LPITEMIDLIST*,SFGAOF,SFGAOF*);
static void init_function_pointers(void)
{
@ -62,17 +62,24 @@ static void init_function_pointers(void)
HRESULT hr;
hmod = GetModuleHandleA("shell32.dll");
pSHBindToParent = (void*)GetProcAddress(hmod, "SHBindToParent");
pSHGetFolderPathA = (void*)GetProcAddress(hmod, "SHGetFolderPathA");
pSHGetFolderPathAndSubDirA = (void*)GetProcAddress(hmod, "SHGetFolderPathAndSubDirA");
pSHGetPathFromIDListW = (void*)GetProcAddress(hmod, "SHGetPathFromIDListW");
pSHGetSpecialFolderPathA = (void*)GetProcAddress(hmod, "SHGetSpecialFolderPathA");
pSHGetSpecialFolderPathW = (void*)GetProcAddress(hmod, "SHGetSpecialFolderPathW");
pILFindLastID = (void *)GetProcAddress(hmod, (LPCSTR)16);
pILFree = (void*)GetProcAddress(hmod, (LPSTR)155);
pILIsEqual = (void*)GetProcAddress(hmod, (LPSTR)21);
pSHCreateShellItem = (void*)GetProcAddress(hmod, "SHCreateShellItem");
pILCombine = (void*)GetProcAddress(hmod, (LPSTR)25);
#define MAKEFUNC(f) (p##f = (void*)GetProcAddress(hmod, #f))
MAKEFUNC(SHBindToParent);
MAKEFUNC(SHCreateShellItem);
MAKEFUNC(SHGetFolderPathA);
MAKEFUNC(SHGetFolderPathAndSubDirA);
MAKEFUNC(SHGetPathFromIDListW);
MAKEFUNC(SHGetSpecialFolderPathA);
MAKEFUNC(SHGetSpecialFolderPathW);
MAKEFUNC(SHParseDisplayName);
#undef MAKEFUNC
#define MAKEFUNC_ORD(f, ord) (p##f = (void*)GetProcAddress(hmod, (LPSTR)(ord)))
MAKEFUNC_ORD(ILFindLastID, 16);
MAKEFUNC_ORD(ILIsEqual, 21);
MAKEFUNC_ORD(ILCombine, 25);
MAKEFUNC_ORD(ILFree, 155);
#undef MAKEFUNC_ORD
hmod = GetModuleHandleA("shlwapi.dll");
pStrRetToBufW = (void*)GetProcAddress(hmod, "StrRetToBufW");
@ -97,6 +104,24 @@ static void test_ParseDisplayName(void)
hr = SHGetDesktopFolder(&IDesktopFolder);
if(hr != S_OK) return;
/* Tests crash on W2K and below (SHCreateShellItem available as of XP) */
if (pSHCreateShellItem)
{
/* null name and pidl */
hr = IShellFolder_ParseDisplayName(IDesktopFolder,
NULL, NULL, NULL, NULL, NULL, 0);
ok(hr == E_INVALIDARG, "returned %08x, expected E_INVALIDARG\n", hr);
/* null name */
newPIDL = (ITEMIDLIST*)0xdeadbeef;
hr = IShellFolder_ParseDisplayName(IDesktopFolder,
NULL, NULL, NULL, NULL, &newPIDL, 0);
ok(newPIDL == 0, "expected null, got %p\n", newPIDL);
ok(hr == E_INVALIDARG, "returned %08x, expected E_INVALIDARG\n", hr);
}
else
win_skip("Tests would crash on W2K and below\n");
MultiByteToWideChar(CP_ACP, 0, cInetTestA, -1, cTestDirW, MAX_PATH);
hr = IShellFolder_ParseDisplayName(IDesktopFolder,
NULL, NULL, cTestDirW, NULL, &newPIDL, 0);
@ -331,11 +356,12 @@ static void test_BindToObject(void)
hr = IShellFolder_BindToObject(psfMyComputer, pidlEmpty, NULL, &IID_IShellFolder, (LPVOID*)&psfChild);
ok (hr == E_INVALIDARG, "MyComputers's BindToObject should fail, when called with empty pidl! hr = %08x\n", hr);
#if 0
if (0)
{
/* this call segfaults on 98SE */
hr = IShellFolder_BindToObject(psfMyComputer, NULL, NULL, &IID_IShellFolder, (LPVOID*)&psfChild);
ok (hr == E_INVALIDARG, "MyComputers's BindToObject should fail, when called with NULL pidl! hr = %08x\n", hr);
#endif
}
cChars = GetSystemDirectoryA(szSystemDir, MAX_PATH);
ok (cChars > 0 && cChars < MAX_PATH, "GetSystemDirectoryA failed! LastError: %u\n", GetLastError());
@ -361,13 +387,14 @@ static void test_BindToObject(void)
hr = IShellFolder_BindToObject(psfSystemDir, pidlEmpty, NULL, &IID_IShellFolder, (LPVOID*)&psfChild);
ok (hr == E_INVALIDARG,
"FileSystem ShellFolder's BindToObject should fail, when called with empty pidl! hr = %08x\n", hr);
#if 0
if (0)
{
/* this call segfaults on 98SE */
hr = IShellFolder_BindToObject(psfSystemDir, NULL, NULL, &IID_IShellFolder, (LPVOID*)&psfChild);
ok (hr == E_INVALIDARG,
ok (hr == E_INVALIDARG,
"FileSystem ShellFolder's BindToObject should fail, when called with NULL pidl! hr = %08x\n", hr);
#endif
}
IShellFolder_Release(psfSystemDir);
}
@ -1564,7 +1591,7 @@ static void test_ITEMIDLIST_format(void) {
IShellFolder_Release(psfPersonal);
}
static void testSHGetFolderPathAndSubDirA(void)
static void test_SHGetFolderPathAndSubDirA(void)
{
HRESULT ret;
BOOL delret;
@ -1576,6 +1603,12 @@ static void testSHGetFolderPathAndSubDirA(void)
static char testpath[MAX_PATH];
static char toolongpath[MAX_PATH+1];
if(!pSHGetFolderPathAndSubDirA)
{
win_skip("SHGetFolderPathAndSubDirA not present!\n");
return;
}
if(!pSHGetFolderPathA) {
win_skip("SHGetFolderPathA not present!\n");
return;
@ -1797,6 +1830,12 @@ static void test_SHCreateShellItem(void)
GetCurrentDirectoryA(MAX_PATH, curdirA);
if (!pSHCreateShellItem)
{
win_skip("SHCreateShellItem isn't available\n");
return;
}
if (!lstrlenA(curdirA))
{
win_skip("GetCurrentDirectoryA returned empty string, skipping test_SHCreateShellItem\n");
@ -1942,6 +1981,69 @@ static void test_SHCreateShellItem(void)
IShellFolder_Release(desktopfolder);
}
static void test_SHParseDisplayName(void)
{
static const WCHAR prefixW[] = {'w','t',0};
LPITEMIDLIST pidl1, pidl2;
IShellFolder *desktop;
WCHAR dirW[MAX_PATH];
WCHAR nameW[10];
HRESULT hr;
BOOL ret;
if (!pSHParseDisplayName)
{
win_skip("SHParseDisplayName isn't available\n");
return;
}
if (0)
{
/* crashes on native */
hr = pSHParseDisplayName(NULL, NULL, NULL, 0, NULL);
nameW[0] = 0;
hr = pSHParseDisplayName(nameW, NULL, NULL, 0, NULL);
}
pidl1 = (LPITEMIDLIST)0xdeadbeef;
hr = pSHParseDisplayName(NULL, NULL, &pidl1, 0, NULL);
ok(broken(hr == E_OUTOFMEMORY) /* < Vista */ ||
hr == E_INVALIDARG, "failed %08x\n", hr);
ok(pidl1 == 0, "expected null ptr, got %p\n", pidl1);
/* dummy name */
nameW[0] = 0;
hr = pSHParseDisplayName(nameW, NULL, &pidl1, 0, NULL);
ok(hr == S_OK, "failed %08x\n", hr);
hr = SHGetDesktopFolder(&desktop);
ok(hr == S_OK, "failed %08x\n", hr);
hr = IShellFolder_ParseDisplayName(desktop, NULL, NULL, nameW, NULL, &pidl2, NULL);
ok(hr == S_OK, "failed %08x\n", hr);
ret = pILIsEqual(pidl1, pidl2);
ok(ret == TRUE, "expected equal idls\n");
pILFree(pidl1);
pILFree(pidl2);
/* with path */
GetTempPathW(sizeof(dirW)/sizeof(WCHAR), dirW);
GetTempFileNameW(dirW, prefixW, 0, dirW);
CreateFileW(dirW, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
hr = pSHParseDisplayName(dirW, NULL, &pidl1, 0, NULL);
ok(hr == S_OK, "failed %08x\n", hr);
hr = IShellFolder_ParseDisplayName(desktop, NULL, NULL, dirW, NULL, &pidl2, NULL);
ok(hr == S_OK, "failed %08x\n", hr);
ret = pILIsEqual(pidl1, pidl2);
ok(ret == TRUE, "expected equal idls\n");
pILFree(pidl1);
pILFree(pidl2);
DeleteFileW(dirW);
IShellFolder_Release(desktop);
}
START_TEST(shlfolder)
{
init_function_pointers();
@ -1950,6 +2052,7 @@ START_TEST(shlfolder)
OleInitialize(NULL);
test_ParseDisplayName();
test_SHParseDisplayName();
test_BindToObject();
test_EnumObjects_and_CompareIDs();
test_GetDisplayName();
@ -1958,15 +2061,9 @@ START_TEST(shlfolder)
test_CallForAttributes();
test_FolderShortcut();
test_ITEMIDLIST_format();
if(pSHGetFolderPathAndSubDirA)
testSHGetFolderPathAndSubDirA();
else
win_skip("SHGetFolderPathAndSubDirA not present\n");
test_SHGetFolderPathAndSubDirA();
test_LocalizedNames();
if(pSHCreateShellItem)
test_SHCreateShellItem();
else
win_skip("SHCreateShellItem not present\n");
test_SHCreateShellItem();
OleUninitialize();
}