Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
e864854c
Commit
e864854c
authored
Mar 06, 2018
by
Zebediah Figura
Committed by
Alexandre Julliard
Mar 06, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
shell32/tests: Clean up and expand tests for IShellFolder_ParseDisplayName().
Signed-off-by:
Zebediah Figura
<
z.figura12@gmail.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
d2cd9a84
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
78 additions
and
81 deletions
+78
-81
shlfolder.c
dlls/shell32/tests/shlfolder.c
+78
-81
No files found.
dlls/shell32/tests/shlfolder.c
View file @
e864854c
...
...
@@ -44,6 +44,8 @@
DEFINE_GUID
(
IID_IParentAndItem
,
0xB3A4B685
,
0xB685
,
0x4805
,
0x99
,
0xD9
,
0x5D
,
0xEA
,
0xD2
,
0x87
,
0x32
,
0x36
);
DEFINE_GUID
(
CLSID_ShellDocObjView
,
0xe7e4bc40
,
0xe76a
,
0x11ce
,
0xa9
,
0xbb
,
0x00
,
0xaa
,
0x00
,
0x4a
,
0xe8
,
0x37
);
#define ARRAY_SIZE(x) ( sizeof(x) / sizeof((x)[0]) )
static
IMalloc
*
ppM
;
static
HRESULT
(
WINAPI
*
pSHCreateItemFromIDList
)(
PCIDLIST_ABSOLUTE
pidl
,
REFIID
riid
,
void
**
ppv
);
...
...
@@ -172,108 +174,103 @@ static LPWSTR myPathAddBackslashW( LPWSTR lpszPath )
return
lpszPath
;
}
static
struct
{
WCHAR
path
[
MAX_PATH
];
HRESULT
hr
;
int
todo
;
}
parse_tests
[]
=
{
{{
'c'
,
':'
,
'\\'
,
0
},
S_OK
},
{{
'c'
,
':'
,
'\\'
,
'\\'
,
0
},
E_INVALIDARG
,
1
},
{{
'c'
,
':'
,
'\\'
,
'f'
,
'a'
,
'k'
,
'e'
,
0
},
0x80070002
},
/* ERROR_FILE_NOT_FOUND */
{{
'c'
,
':'
,
'f'
,
'a'
,
'k'
,
'e'
,
0
},
E_INVALIDARG
,
1
},
{{
'c'
,
':'
,
'/'
,
0
},
E_INVALIDARG
,
1
},
{{
'c'
,
':'
,
'\\'
,
'w'
,
'i'
,
'n'
,
'd'
,
'o'
,
'w'
,
's'
,
0
},
S_OK
},
{{
'c'
,
':'
,
'\\'
,
'w'
,
'i'
,
'n'
,
'd'
,
'o'
,
'w'
,
's'
,
'\\'
,
0
},
S_OK
},
{{
'c'
,
':'
,
'\\'
,
'w'
,
'i'
,
'n'
,
'd'
,
'o'
,
'w'
,
's'
,
'\\'
,
'.'
,
0
},
E_INVALIDARG
,
1
},
{{
'c'
,
':'
,
'\\'
,
'w'
,
'i'
,
'n'
,
'd'
,
'o'
,
'w'
,
's'
,
'\\'
,
'.'
,
'.'
,
0
},
E_INVALIDARG
,
1
},
{{
'.'
,
0
},
E_INVALIDARG
,
1
},
{{
'.'
,
'.'
,
0
},
E_INVALIDARG
,
1
},
{{
't'
,
'e'
,
's'
,
't'
,
0
},
0x80070002
},
{{
't'
,
'e'
,
's'
,
't'
,
'\\'
,
0
},
0x80070002
},
{{
's'
,
'u'
,
'b'
,
'\\'
,
'd'
,
'i'
,
'r'
,
0
},
0x80070002
},
{{
's'
,
'u'
,
'b'
,
'/'
,
'd'
,
'i'
,
'r'
,
0
},
E_INVALIDARG
,
1
},
{{
'h'
,
't'
,
't'
,
'p'
,
':'
,
0
},
S_OK
,
1
},
{{
'h'
,
't'
,
't'
,
'p'
,
':'
,
't'
,
'e'
,
's'
,
't'
,
0
},
S_OK
,
1
},
{{
'h'
,
't'
,
't'
,
'p'
,
':'
,
'\\'
,
't'
,
'e'
,
's'
,
't'
,
0
},
S_OK
,
1
},
{{
'x'
,
'x'
,
':'
,
0
},
S_OK
,
1
},
};
static
void
test_ParseDisplayName
(
void
)
{
static
WCHAR
testdirW
[]
=
{
'p'
,
'a'
,
'r'
,
's'
,
'e'
,
't'
,
'e'
,
's'
,
't'
,
0
};
static
WCHAR
backslashW
[]
=
{
'\\'
,
0
};
WCHAR
buffer
[
MAX_PATH
],
buffer2
[
MAX_PATH
];
IShellFolder
*
desktop
;
ITEMIDLIST
*
pidl
;
HRESULT
hr
;
IShellFolder
*
IDesktopFolder
;
static
const
char
*
cNonExistDir1A
=
"c:
\\
nonexist_subdir"
;
static
const
char
*
cNonExistDir2A
=
"c:
\\\\
nonexist_subdir"
;
static
const
char
*
cInetTestA
=
"http:
\\
yyy"
;
static
const
char
*
cInetTest2A
=
"xx:yyy"
;
DWORD
res
;
WCHAR
cTestDirW
[
MAX_PATH
]
=
{
0
};
ITEMIDLIST
*
newPIDL
;
BOOL
bRes
;
int
i
;
hr
=
SHGetDesktopFolder
(
&
IDesktopFolder
);
hr
=
SHGetDesktopFolder
(
&
desktop
);
ok
(
hr
==
S_OK
,
"Expected SHGetDesktopFolder to return S_OK, got 0x%08x
\n
"
,
hr
);
if
(
hr
!=
S_OK
)
return
;
if
(
pSHCreateShellItem
)
{
if
(
0
)
{
/* null name and pidl, crashes on Windows 8 */
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
(
"SHCreateShellItem requires XP SP1 or later
\n
"
);
MultiByteToWideChar
(
CP_ACP
,
0
,
cInetTestA
,
-
1
,
cTestDirW
,
MAX_PATH
);
hr
=
IShellFolder_ParseDisplayName
(
IDesktopFolder
,
NULL
,
NULL
,
cTestDirW
,
NULL
,
&
newPIDL
,
0
);
todo_wine
ok
(
hr
==
S_OK
,
"ParseDisplayName returned %08x, expected SUCCESS
\n
"
,
hr
);
if
(
hr
==
S_OK
)
{
ok
(
ILFindLastID
(
newPIDL
)
->
mkid
.
abID
[
0
]
==
0x61
,
"Last pidl should be of type "
"PT_IESPECIAL1, but is: %02x
\n
"
,
ILFindLastID
(
newPIDL
)
->
mkid
.
abID
[
0
]);
IMalloc_Free
(
ppM
,
newPIDL
);
}
MultiByteToWideChar
(
CP_ACP
,
0
,
cInetTest2A
,
-
1
,
cTestDirW
,
MAX_PATH
);
hr
=
IShellFolder_ParseDisplayName
(
IDesktopFolder
,
NULL
,
NULL
,
cTestDirW
,
NULL
,
&
newPIDL
,
0
);
todo_wine
ok
(
hr
==
S_OK
,
"ParseDisplayName returned %08x, expected SUCCESS
\n
"
,
hr
);
if
(
hr
==
S_OK
)
{
ok
(
ILFindLastID
(
newPIDL
)
->
mkid
.
abID
[
0
]
==
0x61
,
"Last pidl should be of type "
"PT_IESPECIAL1, but is: %02x
\n
"
,
ILFindLastID
(
newPIDL
)
->
mkid
.
abID
[
0
]);
IMalloc_Free
(
ppM
,
newPIDL
);
}
res
=
GetFileAttributesA
(
cNonExistDir1A
);
if
(
res
!=
INVALID_FILE_ATTRIBUTES
)
{
skip
(
"Test directory unexpectedly exists
\n
"
);
goto
finished
;
}
MultiByteToWideChar
(
CP_ACP
,
0
,
cNonExistDir1A
,
-
1
,
cTestDirW
,
MAX_PATH
);
hr
=
IShellFolder_ParseDisplayName
(
IDesktopFolder
,
NULL
,
NULL
,
cTestDirW
,
NULL
,
&
newPIDL
,
0
);
ok
(
hr
==
HRESULT_FROM_WIN32
(
ERROR_FILE_NOT_FOUND
),
"ParseDisplayName returned %08x, expected 0x80070002
\n
"
,
hr
);
hr
=
IShellFolder_ParseDisplayName
(
desktop
,
NULL
,
NULL
,
NULL
,
NULL
,
&
pidl
,
NULL
);
ok
(
hr
==
E_INVALIDARG
,
"got %#x
\n
"
,
hr
);
res
=
GetFileAttributesA
(
cNonExistDir2A
);
if
(
res
!=
INVALID_FILE_ATTRIBUTES
)
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
parse_tests
);
i
++
)
{
skip
(
"Test directory unexpectedly exists
\n
"
);
goto
finished
;
hr
=
IShellFolder_ParseDisplayName
(
desktop
,
NULL
,
NULL
,
parse_tests
[
i
].
path
,
NULL
,
&
pidl
,
NULL
);
todo_wine_if
(
parse_tests
[
i
].
todo
)
ok
(
hr
==
parse_tests
[
i
].
hr
,
"%s: expected %#x, got %#x
\n
"
,
wine_dbgstr_w
(
parse_tests
[
i
].
path
),
parse_tests
[
i
].
hr
,
hr
);
if
(
SUCCEEDED
(
hr
))
CoTaskMemFree
(
pidl
);
}
MultiByteToWideChar
(
CP_ACP
,
0
,
cNonExistDir2A
,
-
1
,
cTestDirW
,
MAX_PATH
);
hr
=
IShellFolder_ParseDisplayName
(
IDesktopFolder
,
NULL
,
NULL
,
cTestDirW
,
NULL
,
&
newPIDL
,
0
);
todo_wine
ok
(
hr
==
E_INVALIDARG
,
"ParseDisplayName returned %08x, expected E_INVALIDARG
\n
"
,
hr
);
/* I thought that perhaps the DesktopFolder's ParseDisplayName would recognize the
* path corresponding to CSIDL_PERSONAL and return a CLSID_MyDocuments PIDL. Turns
* out it doesn't. The magic seems to happen in the file dialogs, then. */
bRes
=
SHGetSpecialFolderPathW
(
NULL
,
cTestDirW
,
CSIDL_PERSONAL
,
FALSE
);
bRes
=
SHGetSpecialFolderPathW
(
NULL
,
buffer
,
CSIDL_PERSONAL
,
FALSE
);
ok
(
bRes
,
"SHGetSpecialFolderPath(CSIDL_PERSONAL) failed! %u
\n
"
,
GetLastError
());
if
(
!
bRes
)
goto
finished
;
hr
=
IShellFolder_ParseDisplayName
(
IDesktopFolder
,
NULL
,
NULL
,
cTestDirW
,
NULL
,
&
newPIDL
,
0
);
hr
=
IShellFolder_ParseDisplayName
(
desktop
,
NULL
,
NULL
,
buffer
,
NULL
,
&
pidl
,
0
);
ok
(
hr
==
S_OK
,
"DesktopFolder->ParseDisplayName failed. hr = %08x.
\n
"
,
hr
);
if
(
hr
!=
S_OK
)
goto
finished
;
ok
(
ILFindLastID
(
newPIDL
)
->
mkid
.
abID
[
0
]
==
0x31
,
ok
(
ILFindLastID
(
pidl
)
->
mkid
.
abID
[
0
]
==
0x31
,
"Last pidl should be of type PT_FOLDER, but is: %02x
\n
"
,
ILFindLastID
(
newPIDL
)
->
mkid
.
abID
[
0
]);
IMalloc_Free
(
ppM
,
newPIDL
);
ILFindLastID
(
pidl
)
->
mkid
.
abID
[
0
]);
CoTaskMemFree
(
pidl
);
finished:
IShellFolder_Release
(
IDesktopFolder
);
/* Relative paths are interpreted relative to the desktop. */
GetTempPathW
(
sizeof
(
buffer
),
buffer
);
GetLongPathNameW
(
buffer
,
buffer
,
sizeof
(
buffer
));
SetCurrentDirectoryW
(
buffer
);
CreateDirectoryW
(
testdirW
,
NULL
);
hr
=
IShellFolder_ParseDisplayName
(
desktop
,
NULL
,
NULL
,
testdirW
,
NULL
,
&
pidl
,
NULL
);
ok
(
hr
==
0x80070002
,
"got %#x
\n
"
,
hr
);
RemoveDirectoryW
(
testdirW
);
hr
=
SHGetSpecialFolderPathW
(
NULL
,
buffer
,
CSIDL_DESKTOP
,
FALSE
);
ok
(
hr
==
S_FALSE
,
"got %#x
\n
"
,
hr
);
SetCurrentDirectoryW
(
buffer
);
CreateDirectoryW
(
testdirW
,
NULL
);
hr
=
IShellFolder_ParseDisplayName
(
desktop
,
NULL
,
NULL
,
testdirW
,
NULL
,
&
pidl
,
NULL
);
ok
(
hr
==
S_OK
,
"got %#x
\n
"
,
hr
);
ok
(
SHGetPathFromIDListW
(
pidl
,
buffer2
),
"SHGetPathFromIDList failed
\n
"
);
lstrcatW
(
buffer
,
backslashW
);
lstrcatW
(
buffer
,
testdirW
);
ok
(
!
lstrcmpW
(
buffer
,
buffer2
),
"expected %s, got %s
\n
"
,
wine_dbgstr_w
(
buffer
),
wine_dbgstr_w
(
buffer2
));
RemoveDirectoryW
(
testdirW
);
CoTaskMemFree
(
pidl
);
IShellFolder_Release
(
desktop
);
}
/* creates a file with the specified name for tests */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment