Commit 3874c55c authored by Francois Gouget's avatar Francois Gouget Committed by Alexandre Julliard

shell32/tests: Copy the PathRemoveBackslashA() and PathAddBackslashW()…

shell32/tests: Copy the PathRemoveBackslashA() and PathAddBackslashW() implementations because shlwapi.dll is missing on Windows 95.
parent 000fd0ed
......@@ -3,7 +3,7 @@ TOPOBJDIR = ../../..
SRCDIR = @srcdir@
VPATH = @srcdir@
TESTDLL = shell32.dll
IMPORTS = shell32 ole32 oleaut32 shlwapi user32 advapi32 kernel32
IMPORTS = shell32 ole32 oleaut32 user32 advapi32 kernel32
EXTRALIBS = -luuid
CTESTS = \
......
......@@ -642,6 +642,27 @@ static void testEnvVars(void)
matchSpecialFolderPathToEnv(CSIDL_SYSTEM, "winsysdir");
}
/* Loosely based on PathRemoveBackslashA from dlls/shlwapi/path.c */
static BOOL myPathIsRootA(LPCSTR lpszPath)
{
if (lpszPath && *lpszPath &&
lpszPath[1] == ':' && lpszPath[2] == '\\' && lpszPath[3] == '\0')
return TRUE; /* X:\ */
return FALSE;
}
static LPSTR myPathRemoveBackslashA( LPSTR lpszPath )
{
LPSTR szTemp = NULL;
if(lpszPath)
{
szTemp = CharPrevA(lpszPath, lpszPath + strlen(lpszPath));
if (!myPathIsRootA(lpszPath) && *szTemp == '\\')
*szTemp = '\0';
}
return szTemp;
}
/* Verifies the shell path for CSIDL_WINDOWS matches the return from
* GetWindowsDirectory. If SHGetSpecialFolderPath fails, no harm, no foul--not
* every shell32 version supports CSIDL_WINDOWS.
......@@ -654,9 +675,9 @@ static void testWinDir(void)
if (pSHGetSpecialFolderPathA(NULL, windowsShellPath, CSIDL_WINDOWS, FALSE))
{
PathRemoveBackslashA(windowsShellPath);
myPathRemoveBackslashA(windowsShellPath);
GetWindowsDirectoryA(windowsDir, sizeof(windowsDir));
PathRemoveBackslashA(windowsDir);
myPathRemoveBackslashA(windowsDir);
ok(!lstrcmpiA(windowsDir, windowsShellPath),
"GetWindowsDirectory does not match SHGetSpecialFolderPath:\n"
"GetWindowsDirectory returns %s\nSHGetSpecialFolderPath returns %s\n",
......@@ -675,10 +696,10 @@ static void testSystemDir(void)
if (!pSHGetSpecialFolderPathA) return;
GetSystemDirectoryA(systemDir, sizeof(systemDir));
PathRemoveBackslashA(systemDir);
myPathRemoveBackslashA(systemDir);
if (pSHGetSpecialFolderPathA(NULL, systemShellPath, CSIDL_SYSTEM, FALSE))
{
PathRemoveBackslashA(systemShellPath);
myPathRemoveBackslashA(systemShellPath);
ok(!lstrcmpiA(systemDir, systemShellPath),
"GetSystemDirectory does not match SHGetSpecialFolderPath:\n"
"GetSystemDirectory returns %s\nSHGetSpecialFolderPath returns %s\n",
......@@ -689,7 +710,7 @@ static void testSystemDir(void)
*/
if (pSHGetSpecialFolderPathA(NULL, systemShellPath, CSIDL_SYSTEMX86, FALSE))
{
PathRemoveBackslashA(systemShellPath);
myPathRemoveBackslashA(systemShellPath);
ok(!lstrcmpiA(systemDir, systemShellPath),
"GetSystemDirectory does not match SHGetSpecialFolderPath:\n"
"GetSystemDirectory returns %s\nSHGetSpecialFolderPath returns %s\n",
......
......@@ -324,7 +324,27 @@ static void test_BindToObject(void)
IShellFolder_Release(psfSystemDir);
}
/* Based on PathAddBackslashW from dlls/shlwapi/path.c */
static LPWSTR myPathAddBackslashW( LPWSTR lpszPath )
{
size_t iLen;
if (!lpszPath || (iLen = lstrlenW(lpszPath)) >= MAX_PATH)
return NULL;
if (iLen)
{
lpszPath += iLen;
if (lpszPath[-1] != '\\')
{
*lpszPath++ = '\\';
*lpszPath = '\0';
}
}
return lpszPath;
}
static void test_GetDisplayName(void)
{
BOOL result;
......@@ -357,7 +377,7 @@ static void test_GetDisplayName(void)
ok(result, "SHGetSpecialFolderPathW failed! Last error: %u\n", GetLastError());
if (!result) return;
PathAddBackslashW(wszTestDir);
myPathAddBackslashW(wszTestDir);
lstrcatW(wszTestDir, wszDirName);
/* Use ANSI file functions so this works on Windows 9x */
WideCharToMultiByte(CP_ACP, 0, wszTestDir, -1, szTestDir, MAX_PATH, 0, 0);
......@@ -370,7 +390,7 @@ static void test_GetDisplayName(void)
}
lstrcpyW(wszTestFile, wszTestDir);
PathAddBackslashW(wszTestFile);
myPathAddBackslashW(wszTestFile);
lstrcatW(wszTestFile, wszFileName);
WideCharToMultiByte(CP_ACP, 0, wszTestFile, -1, szTestFile, MAX_PATH, 0, 0);
......@@ -824,7 +844,7 @@ static void test_SHGetPathFromIDList(void)
IShellFolder_Release(psfDesktop);
return;
}
PathAddBackslashW(wszFileName);
myPathAddBackslashW(wszFileName);
lstrcatW(wszFileName, wszTestFile);
hTestFile = CreateFileW(wszFileName, GENERIC_WRITE, 0, NULL, CREATE_NEW, 0, NULL);
ok(hTestFile != INVALID_HANDLE_VALUE, "CreateFileW failed! Last error: %u\n", GetLastError());
......@@ -1153,7 +1173,7 @@ static void test_FolderShortcut(void) {
/* Next few lines are meant to show that children of FolderShortcuts are not FolderShortcuts,
* but ShellFSFolders. */
PathAddBackslashW(wszDesktopPath);
myPathAddBackslashW(wszDesktopPath);
lstrcatW(wszDesktopPath, wszSomeSubFolder);
if (!CreateDirectoryW(wszDesktopPath, NULL)) {
IShellFolder_Release(pShellFolder);
......
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