ReactOS 0.4.16-dev-1946-g52006dd
SHParseDisplayName.cpp File Reference
#include "shelltest.h"
Include dependency graph for SHParseDisplayName.cpp:

Go to the source code of this file.

Classes

struct  test_data
 

Macros

#define T_ALL   0x0
 
#define T_WIN2K   0x1
 
#define T_WINXP   0x2
 
#define T_WIN2K3   0x4
 
#define T_VISTA   0x8
 
#define T_WIN7   0x10
 
#define T_WIN8   0x20
 
#define T_WIN10   0x40
 
#define T_PRE_VISTA   (T_WIN2K | T_WINXP | T_WIN2K3)
 
#define T_PRE_WIN7   (T_PRE_VISTA | T_VISTA)
 
#define T_PRE_WIN8   (T_PRE_WIN7 | T_WIN7)
 
#define T_WIN8_PLUS   (T_WIN8 | T_WIN10)
 
#define T_WIN7_PLUS   (T_WIN7 | T_WIN8_PLUS)
 
#define T_VISTA_PLUS   (T_VISTA | T_WIN7_PLUS)
 

Functions

UINT get_host_os_flag ()
 
 START_TEST (SHParseDisplayName)
 

Variables

struct test_data Tests []
 

Macro Definition Documentation

◆ T_ALL

#define T_ALL   0x0

Definition at line 11 of file SHParseDisplayName.cpp.

◆ T_PRE_VISTA

#define T_PRE_VISTA   (T_WIN2K | T_WINXP | T_WIN2K3)

Definition at line 20 of file SHParseDisplayName.cpp.

◆ T_PRE_WIN7

#define T_PRE_WIN7   (T_PRE_VISTA | T_VISTA)

Definition at line 21 of file SHParseDisplayName.cpp.

◆ T_PRE_WIN8

#define T_PRE_WIN8   (T_PRE_WIN7 | T_WIN7)

Definition at line 22 of file SHParseDisplayName.cpp.

◆ T_VISTA

#define T_VISTA   0x8

Definition at line 15 of file SHParseDisplayName.cpp.

◆ T_VISTA_PLUS

#define T_VISTA_PLUS   (T_VISTA | T_WIN7_PLUS)

Definition at line 26 of file SHParseDisplayName.cpp.

◆ T_WIN10

#define T_WIN10   0x40

Definition at line 18 of file SHParseDisplayName.cpp.

◆ T_WIN2K

#define T_WIN2K   0x1

Definition at line 12 of file SHParseDisplayName.cpp.

◆ T_WIN2K3

#define T_WIN2K3   0x4

Definition at line 14 of file SHParseDisplayName.cpp.

◆ T_WIN7

#define T_WIN7   0x10

Definition at line 16 of file SHParseDisplayName.cpp.

◆ T_WIN7_PLUS

#define T_WIN7_PLUS   (T_WIN7 | T_WIN8_PLUS)

Definition at line 25 of file SHParseDisplayName.cpp.

◆ T_WIN8

#define T_WIN8   0x20

Definition at line 17 of file SHParseDisplayName.cpp.

◆ T_WIN8_PLUS

#define T_WIN8_PLUS   (T_WIN8 | T_WIN10)

Definition at line 24 of file SHParseDisplayName.cpp.

◆ T_WINXP

#define T_WINXP   0x2

Definition at line 13 of file SHParseDisplayName.cpp.

Function Documentation

◆ get_host_os_flag()

UINT get_host_os_flag ( )

Definition at line 133 of file SHParseDisplayName.cpp.

134{
135 switch (GetNTVersion())
136 {
137 case _WIN32_WINNT_WIN2K: return T_WIN2K;
138 case _WIN32_WINNT_WINXP: return T_WINXP;
139 case _WIN32_WINNT_WS03: return T_WIN2K3;
140 case _WIN32_WINNT_VISTA: return T_VISTA;
141 case _WIN32_WINNT_WIN7: return T_WIN7;
142 case _WIN32_WINNT_WIN8: return T_WIN8;
143 case _WIN32_WINNT_WINBLUE: return T_WIN8;
144 case _WIN32_WINNT_WIN10: return T_WIN10;
145 }
146
147 return 0;
148}
#define T_WIN8
#define T_WIN10
#define T_WIN7
#define T_WINXP
#define T_WIN2K3
#define T_WIN2K
#define T_VISTA
#define GetNTVersion()
Definition: apitest.h:17
#define _WIN32_WINNT_WIN10
Definition: sdkddkver.h:32
#define _WIN32_WINNT_WS03
Definition: sdkddkver.h:23
#define _WIN32_WINNT_WINBLUE
Definition: sdkddkver.h:30
#define _WIN32_WINNT_WIN8
Definition: sdkddkver.h:29
#define _WIN32_WINNT_WINXP
Definition: sdkddkver.h:22
#define _WIN32_WINNT_WIN7
Definition: sdkddkver.h:28
#define _WIN32_WINNT_WIN2K
Definition: sdkddkver.h:21
#define _WIN32_WINNT_VISTA
Definition: sdkddkver.h:25

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( SHParseDisplayName  )

Definition at line 150 of file SHParseDisplayName.cpp.

151{
152 HRESULT hr;
153 WCHAR winDir[MAX_PATH];
154 UINT os_flag = get_host_os_flag();
155 ok (os_flag != 0, "Incompatible os version %d!", os_flag);
156 if (os_flag == 0)
157 return;
158
159 IShellFolder *psfDesktop;
160 hr = SHGetDesktopFolder(&psfDesktop);
161 ok(hr == S_OK, "hr = %lx\n", hr);
162
163 GetWindowsDirectoryW(winDir, _countof(winDir));
164 SetCurrentDirectoryW(winDir);
165
166 for (UINT i = 0; i < _countof(Tests); i ++)
167 {
168 if (Tests[i].ValidForVersion && !(Tests[i].ValidForVersion & os_flag))
169 continue;
170
171 PIDLIST_ABSOLUTE pidl;
172 HRESULT hr = SHParseDisplayName(Tests[i].wszPathToParse, NULL, &pidl, 0, NULL);
173 ok(hr == Tests[i].hResult, "%d: Expected error 0x%lx, got 0x%lx\n", Tests[i].testline, Tests[i].hResult, hr);
174
175 if (Tests[i].wszExpectedDisplayName == NULL && Tests[i].nExpectedCSIDL == 0)
176 {
177 ok(pidl == NULL, "%d: Expected no pidl\n", Tests[i].testline);
178 continue;
179 }
180
181 ok(pidl != NULL, "%d: Expected pidl on success\n", Tests[i].testline);
182 if(!pidl)
183 continue;
184
185 STRRET strret;
186 hr = psfDesktop->GetDisplayNameOf(pidl, SHGDN_FORPARSING, &strret);
187 ok(hr == S_OK, "%d: hr = %lx\n", Tests[i].testline, hr);
188
189 ok(strret.uType == STRRET_WSTR, "%d: Expected STRRET_WSTR\n", Tests[i].testline);
190
191 if (Tests[i].wszExpectedDisplayName)
192 {
193 ok(!wcscmp(strret.pOleStr, Tests[i].wszExpectedDisplayName), "%d: expected %S got %S\n", Tests[i].testline, Tests[i].wszExpectedDisplayName, strret.pOleStr);
194 }
195 else
196 {
197 PIDLIST_ABSOLUTE pidlSpecial;
198 hr = SHGetSpecialFolderLocation(NULL, Tests[i].nExpectedCSIDL, &pidlSpecial);
199 ok(hr == S_OK, "%d: hr = %lx\n", Tests[i].testline, hr);
200
201 STRRET strretSpecial;
202 hr = psfDesktop->GetDisplayNameOf(pidlSpecial, SHGDN_FORPARSING, &strretSpecial);
203 ok(hr == S_OK, "%d: hr = %lx\n", Tests[i].testline, hr);
204
205 ok(strret.uType == STRRET_WSTR, "%d: Expected STRRET_WSTR\n", Tests[i].testline);
206
207 ok(!wcscmp(strret.pOleStr, strretSpecial.pOleStr), "%d: expected %S got %S\n", Tests[i].testline, strretSpecial.pOleStr, strret.pOleStr);
208 }
209 }
210
212}
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
UINT get_host_os_flag()
struct test_data Tests[]
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define MAX_PATH
Definition: compat.h:34
BOOL WINAPI SetCurrentDirectoryW(IN LPCWSTR lpPathName)
Definition: path.c:2249
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2352
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
HRESULT WINAPI SHGetSpecialFolderLocation(HWND hwndOwner, INT nFolder, LPITEMIDLIST *ppidl)
Definition: shellpath.c:3384
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
HRESULT GetDisplayNameOf([in] PCUITEMID_CHILD pidl, [in] SHGDNF uFlags, [out] STRRET *lpName)
#define S_OK
Definition: intsafe.h:52
unsigned int UINT
Definition: ndis.h:50
HRESULT WINAPI SHParseDisplayName(LPCWSTR pszName, IBindCtx *pbc, LPITEMIDLIST *ppidl, SFGAOF sfgaoIn, SFGAOF *psfgaoOut)
Definition: pidl.c:1542
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
HRESULT hr
Definition: shlfolder.c:183
@ STRRET_WSTR
Definition: shtypes.idl:85
#define _countof(array)
Definition: sndvol32.h:70
UINT uType
Definition: shtypes.idl:93
LPWSTR pOleStr
Definition: shtypes.idl:96
__wchar_t WCHAR
Definition: xmlstorage.h:180

Variable Documentation

◆ Tests

struct test_data Tests[]

Definition at line 38 of file SHParseDisplayName.cpp.

Referenced by START_TEST().