[SHELL32_WINETEST] Sync with Wine Staging 1.7.37. CORE-9246

svn path=/trunk/; revision=67432
This commit is contained in:
Amine Khaldi 2015-04-26 11:27:59 +00:00
parent 135c8b4904
commit e7264e00c5
9 changed files with 739 additions and 76 deletions

View file

@ -101,6 +101,7 @@ static UINT (WINAPI *pGetSystemWow64DirectoryA)(LPSTR,UINT);
static HRESULT (WINAPI *pSHGetKnownFolderPath)(REFKNOWNFOLDERID, DWORD, HANDLE, PWSTR *);
static HRESULT (WINAPI *pSHSetKnownFolderPath)(REFKNOWNFOLDERID, DWORD, HANDLE, PWSTR);
static HRESULT (WINAPI *pSHGetFolderPathEx)(REFKNOWNFOLDERID, DWORD, HANDLE, LPWSTR, DWORD);
static BOOL (WINAPI *pPathYetAnotherMakeUniqueName)(PWSTR, PCWSTR, PCWSTR, PCWSTR);
static DLLVERSIONINFO shellVersion = { 0 };
static LPMALLOC pMalloc;
@ -207,6 +208,7 @@ static void loadShell32(void)
pILFindLastID = (void *)GetProcAddress(hShell32, (LPCSTR)16);
GET_PROC(SHFileOperationA)
GET_PROC(SHGetMalloc)
GET_PROC(PathYetAnotherMakeUniqueName)
ok(pSHGetMalloc != NULL, "shell32 is missing SHGetMalloc\n");
if (pSHGetMalloc)
@ -859,6 +861,11 @@ if (0) { /* crashes */
ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
ok(path != NULL, "expected path != NULL\n");
path = NULL;
hr = pSHGetKnownFolderPath(&FOLDERID_Desktop, KF_FLAG_DEFAULT_PATH, NULL, &path);
ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
ok(path != NULL, "expected path != NULL\n");
hr = pSHGetFolderPathEx(&FOLDERID_Desktop, 0, NULL, buffer, MAX_PATH);
ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
ok(!lstrcmpiW(path, buffer), "expected equal paths\n");
@ -876,7 +883,7 @@ if (0) { /* crashes */
ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
}
hr = pSHGetFolderPathEx(&FOLDERID_Desktop, 0, NULL, buffer, len);
ok(hr == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), "expected 0x8007007a, got 0x%08x\n", hr);
ok(hr == E_NOT_SUFFICIENT_BUFFER, "expected E_NOT_SUFFICIENT_BUFFER, got 0x%08x\n", hr);
hr = pSHGetFolderPathEx(&FOLDERID_Desktop, 0, NULL, buffer, len + 1);
ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
@ -2631,6 +2638,85 @@ static void test_DoEnvironmentSubst(void)
}
}
static void test_PathYetAnotherMakeUniqueName(void)
{
static const WCHAR shortW[] = {'f','i','l','e','.','t','s','t',0};
static const WCHAR short2W[] = {'f','i','l','e',' ','(','2',')','.','t','s','t',0};
static const WCHAR tmpW[] = {'t','m','p',0};
static const WCHAR longW[] = {'n','a','m','e',0};
static const WCHAR long2W[] = {'n','a','m','e',' ','(','2',')',0};
WCHAR nameW[MAX_PATH], buffW[MAX_PATH], pathW[MAX_PATH];
HANDLE file;
BOOL ret;
if (!pPathYetAnotherMakeUniqueName)
{
win_skip("PathYetAnotherMakeUniqueName() is not available.\n");
return;
}
if (0)
{
/* crashes on Windows */
ret = pPathYetAnotherMakeUniqueName(NULL, NULL, NULL, NULL);
ok(!ret, "got %d\n", ret);
ret = pPathYetAnotherMakeUniqueName(nameW, NULL, NULL, NULL);
ok(!ret, "got %d\n", ret);
}
GetTempPathW(sizeof(pathW)/sizeof(WCHAR), pathW);
/* Using short name only first */
nameW[0] = 0;
ret = pPathYetAnotherMakeUniqueName(nameW, pathW, shortW, NULL);
ok(ret, "got %d\n", ret);
lstrcpyW(buffW, pathW);
lstrcatW(buffW, shortW);
ok(!lstrcmpW(nameW, buffW), "got %s, expected %s\n", wine_dbgstr_w(nameW), wine_dbgstr_w(buffW));
/* now create a file with this name and get next name */
file = CreateFileW(nameW, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_FLAG_DELETE_ON_CLOSE, NULL);
ok(file != NULL, "got %p\n", file);
nameW[0] = 0;
ret = pPathYetAnotherMakeUniqueName(nameW, pathW, shortW, NULL);
ok(ret, "got %d\n", ret);
lstrcpyW(buffW, pathW);
lstrcatW(buffW, short2W);
ok(!lstrcmpW(nameW, buffW), "got %s, expected %s\n", wine_dbgstr_w(nameW), wine_dbgstr_w(buffW));
CloseHandle(file);
/* Using short and long */
nameW[0] = 0;
ret = pPathYetAnotherMakeUniqueName(nameW, pathW, tmpW, longW);
ok(ret, "got %d\n", ret);
lstrcpyW(buffW, pathW);
lstrcatW(buffW, longW);
ok(!lstrcmpW(nameW, buffW), "got %s, expected %s\n", wine_dbgstr_w(nameW), wine_dbgstr_w(buffW));
file = CreateFileW(nameW, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_FLAG_DELETE_ON_CLOSE, NULL);
ok(file != NULL, "got %p\n", file);
nameW[0] = 0;
ret = pPathYetAnotherMakeUniqueName(nameW, pathW, tmpW, longW);
ok(ret, "got %d\n", ret);
lstrcpyW(buffW, pathW);
lstrcatW(buffW, long2W);
ok(!lstrcmpW(nameW, buffW), "got %s, expected %s\n", wine_dbgstr_w(nameW), wine_dbgstr_w(buffW));
CloseHandle(file);
/* Using long only */
nameW[0] = 0;
ret = pPathYetAnotherMakeUniqueName(nameW, pathW, NULL, longW);
ok(ret, "got %d\n", ret);
lstrcpyW(buffW, pathW);
lstrcatW(buffW, longW);
ok(!lstrcmpW(nameW, buffW), "got %s, expected %s\n", wine_dbgstr_w(nameW), wine_dbgstr_w(buffW));
}
START_TEST(shellpath)
{
if (!init()) return;
@ -2659,5 +2745,6 @@ START_TEST(shellpath)
test_SHGetFolderPathEx();
test_knownFolders();
test_DoEnvironmentSubst();
test_PathYetAnotherMakeUniqueName();
}
}