mirror of
https://github.com/reactos/reactos.git
synced 2025-01-01 03:54:02 +00:00
[SHELL32_APITEST]
- Add a test for SHParseDisplayName CORE-10434 svn path=/trunk/; revision=71216
This commit is contained in:
parent
ce192c47ea
commit
c1a1365490
3 changed files with 162 additions and 0 deletions
|
@ -8,6 +8,7 @@ add_executable(shell32_apitest
|
|||
CShellDesktop.cpp
|
||||
menu.cpp
|
||||
shelltest.cpp
|
||||
SHParseDisplayName.cpp
|
||||
testlist.c)
|
||||
target_link_libraries(shell32_apitest wine uuid ${PSEH_LIB})
|
||||
set_module_type(shell32_apitest win32cui)
|
||||
|
|
159
rostests/apitests/shell32/SHParseDisplayName.cpp
Normal file
159
rostests/apitests/shell32/SHParseDisplayName.cpp
Normal file
|
@ -0,0 +1,159 @@
|
|||
/*
|
||||
* PROJECT: ReactOS API tests
|
||||
* LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory
|
||||
* PURPOSE: Test for SHParseDisplayName
|
||||
* PROGRAMMERS: Thomas Faber <thomas.faber@reactos.org>
|
||||
*/
|
||||
|
||||
#include "shelltest.h"
|
||||
#include "apitest.h"
|
||||
#include <ndk/umtypes.h>
|
||||
#include <strsafe.h>
|
||||
|
||||
START_TEST(SHParseDisplayName)
|
||||
{
|
||||
HRESULT hr;
|
||||
PIDLIST_ABSOLUTE pidl;
|
||||
WCHAR systemDir[MAX_PATH];
|
||||
WCHAR path[MAX_PATH];
|
||||
WCHAR resultPath[MAX_PATH];
|
||||
BOOL winv6 = LOBYTE(LOWORD(GetVersion())) >= 6;
|
||||
|
||||
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
|
||||
|
||||
GetSystemDirectoryW(systemDir, RTL_NUMBER_OF(systemDir));
|
||||
SetCurrentDirectoryW(systemDir);
|
||||
|
||||
/* The code below relies on these properties */
|
||||
ok(systemDir[1] == L':', "systemDir = %ls\n", systemDir);
|
||||
ok(systemDir[2] == L'\\', "systemDir = %ls\n", systemDir);
|
||||
ok(systemDir[wcslen(systemDir) - 1] != L'\\', "systemDir = %ls\n", systemDir);
|
||||
ok(wcschr(systemDir + 3, L'\\') != NULL, "systemDir = %ls\n", systemDir);
|
||||
|
||||
/* NULL */
|
||||
pidl = NULL;
|
||||
StartSeh()
|
||||
hr = SHParseDisplayName(NULL, NULL, &pidl, 0, NULL);
|
||||
EndSeh(STATUS_SUCCESS);
|
||||
ok(hr == E_OUTOFMEMORY || hr == E_INVALIDARG, "hr = %lx\n", hr);
|
||||
ok(pidl == NULL, "pidl = %p\n", pidl);
|
||||
if (pidl) CoTaskMemFree(pidl);
|
||||
|
||||
/* empty string */
|
||||
pidl = NULL;
|
||||
hr = SHParseDisplayName(L"", NULL, &pidl, 0, NULL);
|
||||
ok(hr == S_OK, "hr = %lx\n", hr);
|
||||
ok(pidl != NULL, "pidl = %p\n", pidl);
|
||||
resultPath[0] = UNICODE_NULL;
|
||||
SHGetPathFromIDListW(pidl, resultPath);
|
||||
ok_wstr(resultPath, L"");
|
||||
if (pidl) CoTaskMemFree(pidl);
|
||||
|
||||
/* C: */
|
||||
path[0] = systemDir[0];
|
||||
path[1] = L':';
|
||||
path[2] = UNICODE_NULL;
|
||||
pidl = NULL;
|
||||
hr = SHParseDisplayName(path, NULL, &pidl, 0, NULL);
|
||||
if (winv6)
|
||||
{
|
||||
/* Win7 accepts this and returns C:\ */
|
||||
ok(hr == S_OK, "hr = %lx\n", hr);
|
||||
ok(pidl != NULL, "pidl = %p\n", pidl);
|
||||
resultPath[0] = UNICODE_NULL;
|
||||
SHGetPathFromIDListW(pidl, resultPath);
|
||||
path[2] = L'\\';
|
||||
path[3] = UNICODE_NULL;
|
||||
ok(!wcsicmp(resultPath, path), "Got %ls, expected %ls\n", resultPath, path);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Win2003 fails this */
|
||||
ok(hr == E_INVALIDARG, "hr = %lx\n", hr);
|
||||
ok(pidl == NULL, "pidl = %p\n", pidl);
|
||||
}
|
||||
if (pidl) CoTaskMemFree(pidl);
|
||||
|
||||
/* C:\ */
|
||||
path[0] = systemDir[0];
|
||||
path[1] = L':';
|
||||
path[2] = L'\\';
|
||||
path[3] = UNICODE_NULL;
|
||||
pidl = NULL;
|
||||
hr = SHParseDisplayName(path, NULL, &pidl, 0, NULL);
|
||||
ok(hr == S_OK, "hr = %lx\n", hr);
|
||||
ok(pidl != NULL, "pidl = %p\n", pidl);
|
||||
resultPath[0] = UNICODE_NULL;
|
||||
SHGetPathFromIDListW(pidl, resultPath);
|
||||
ok(!wcsicmp(resultPath, path), "Got %ls, expected %ls\n", resultPath, path);
|
||||
if (pidl) CoTaskMemFree(pidl);
|
||||
|
||||
/* C:\\ */
|
||||
path[0] = systemDir[0];
|
||||
path[1] = L':';
|
||||
path[2] = L'\\';
|
||||
path[3] = L'\\';
|
||||
path[4] = UNICODE_NULL;
|
||||
pidl = NULL;
|
||||
hr = SHParseDisplayName(path, NULL, &pidl, 0, NULL);
|
||||
ok(hr == E_INVALIDARG, "hr = %lx\n", hr);
|
||||
ok(pidl == NULL, "pidl = %p\n", pidl);
|
||||
if (pidl) CoTaskMemFree(pidl);
|
||||
|
||||
/* C:\ReactOS */
|
||||
StringCbCopyW(path, sizeof(path), systemDir);
|
||||
wcschr(path + 3, L'\\')[0] = UNICODE_NULL;
|
||||
pidl = NULL;
|
||||
hr = SHParseDisplayName(path, NULL, &pidl, 0, NULL);
|
||||
ok(hr == S_OK, "hr = %lx\n", hr);
|
||||
ok(pidl != NULL, "pidl = %p\n", pidl);
|
||||
resultPath[0] = UNICODE_NULL;
|
||||
SHGetPathFromIDListW(pidl, resultPath);
|
||||
ok(!wcsicmp(resultPath, path), "Got %ls, expected %ls\n", resultPath, path);
|
||||
if (pidl) CoTaskMemFree(pidl);
|
||||
|
||||
/* C:\ReactOS\ */
|
||||
StringCbCopyW(path, sizeof(path), systemDir);
|
||||
wcschr(path + 3, L'\\')[1] = UNICODE_NULL;
|
||||
pidl = NULL;
|
||||
hr = SHParseDisplayName(path, NULL, &pidl, 0, NULL);
|
||||
ok(hr == S_OK, "hr = %lx\n", hr);
|
||||
ok(pidl != NULL, "pidl = %p\n", pidl);
|
||||
resultPath[0] = UNICODE_NULL;
|
||||
SHGetPathFromIDListW(pidl, resultPath);
|
||||
path[wcslen(path) - 1] = UNICODE_NULL;
|
||||
ok(!wcsicmp(resultPath, path), "Got %ls, expected %ls\n", resultPath, path);
|
||||
if (pidl) CoTaskMemFree(pidl);
|
||||
|
||||
/* C:\ReactOS\system32 */
|
||||
StringCbCopyW(path, sizeof(path), systemDir);
|
||||
pidl = NULL;
|
||||
hr = SHParseDisplayName(path, NULL, &pidl, 0, NULL);
|
||||
ok(hr == S_OK, "hr = %lx\n", hr);
|
||||
ok(pidl != NULL, "pidl = %p\n", pidl);
|
||||
resultPath[0] = UNICODE_NULL;
|
||||
SHGetPathFromIDListW(pidl, resultPath);
|
||||
ok(!wcsicmp(resultPath, path), "Got %ls, expected %ls\n", resultPath, path);
|
||||
if (pidl) CoTaskMemFree(pidl);
|
||||
|
||||
/* C:ntoskrnl.exe */
|
||||
path[0] = systemDir[0];
|
||||
path[1] = L':';
|
||||
path[2] = UNICODE_NULL;
|
||||
StringCbCatW(path, sizeof(path), L"ntoskrnl.exe");
|
||||
pidl = NULL;
|
||||
hr = SHParseDisplayName(path, NULL, &pidl, 0, NULL);
|
||||
ok(hr == E_INVALIDARG, "hr = %lx\n", hr);
|
||||
ok(pidl == NULL, "pidl = %p\n", pidl);
|
||||
if (pidl) CoTaskMemFree(pidl);
|
||||
|
||||
/* ntoskrnl.exe */
|
||||
StringCbCopyW(path, sizeof(path), L"ntoskrnl.exe");
|
||||
pidl = NULL;
|
||||
hr = SHParseDisplayName(path, NULL, &pidl, 0, NULL);
|
||||
ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "hr = %lx\n", hr);
|
||||
ok(pidl == NULL, "pidl = %p\n", pidl);
|
||||
if (pidl) CoTaskMemFree(pidl);
|
||||
|
||||
CoUninitialize();
|
||||
}
|
|
@ -6,11 +6,13 @@
|
|||
extern void func_CMyComputer(void);
|
||||
extern void func_CShellDesktop(void);
|
||||
extern void func_menu(void);
|
||||
extern void func_SHParseDisplayName(void);
|
||||
|
||||
const struct test winetest_testlist[] =
|
||||
{
|
||||
{ "CMyComputer", func_CMyComputer },
|
||||
{ "CShellDesktop", func_CShellDesktop },
|
||||
{ "menu", func_menu },
|
||||
{ "SHParseDisplayName", func_SHParseDisplayName },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue