ReactOS 0.4.15-dev-8434-g155a7c7
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_VISTA_PLUS   T_VISTA|T_WIN7|T_WIN8|T_WIN10
 

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_VISTA

#define T_VISTA   0x8

Definition at line 15 of file SHParseDisplayName.cpp.

◆ T_VISTA_PLUS

#define T_VISTA_PLUS   T_VISTA|T_WIN7|T_WIN8|T_WIN10

Definition at line 21 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_WIN8

#define T_WIN8   0x20

Definition at line 17 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 128 of file SHParseDisplayName.cpp.

129{
130 switch (LOWORD(GetVersion()))
131 {
132 case 5: return T_WIN2K;
133 case (5 | (1 << 8)): return T_WINXP;
134 case (5 | (2 << 8)): return T_WIN2K3;
135 case 6: return T_VISTA;
136 case (6 | (1 << 8)): return T_WIN7;
137 case (6 | (2 << 8)): return T_WIN8;
138 case 10: return T_WIN10;
139 }
140
141 return 0;
142}
#define T_WIN8
#define T_WIN10
#define T_WIN7
#define T_WINXP
#define T_WIN2K3
#define T_WIN2K
#define T_VISTA
#define LOWORD(l)
Definition: pedump.c:82
DWORD WINAPI GetVersion()
Definition: redirtest.c:5

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( SHParseDisplayName  )

Definition at line 144 of file SHParseDisplayName.cpp.

145{
146 HRESULT hr;
147 WCHAR winDir[MAX_PATH];
148 UINT os_flag = get_host_os_flag();
149 ok (os_flag != 0, "Incompatible os version %d!", os_flag);
150 if (os_flag == 0)
151 return;
152
153 IShellFolder *psfDesktop;
154 hr = SHGetDesktopFolder(&psfDesktop);
155 ok(hr == S_OK, "hr = %lx\n", hr);
156
157 GetWindowsDirectoryW(winDir, _countof(winDir));
158 SetCurrentDirectoryW(winDir);
159
160 for (UINT i = 0; i < _countof(Tests); i ++)
161 {
162 if (Tests[i].ValidForVersion && !(Tests[i].ValidForVersion & os_flag))
163 continue;
164
165 PIDLIST_ABSOLUTE pidl;
166 HRESULT hr = SHParseDisplayName(Tests[i].wszPathToParse, NULL, &pidl, 0, NULL);
167 ok(hr == Tests[i].hResult, "%d: Expected error 0x%lx, got 0x%lx\n", Tests[i].testline, Tests[i].hResult, hr);
168
169 if (Tests[i].wszExpectedDisplayName == NULL && Tests[i].nExpectedCSIDL == 0)
170 {
171 ok(pidl == NULL, "%d: Expected no pidl\n", Tests[i].testline);
172 continue;
173 }
174
175 ok(pidl != NULL, "%d: Expected pidl on success\n", Tests[i].testline);
176 if(!pidl)
177 continue;
178
179 STRRET strret;
180 hr = psfDesktop->GetDisplayNameOf(pidl, SHGDN_FORPARSING, &strret);
181 ok(hr == S_OK, "%d: hr = %lx\n", Tests[i].testline, hr);
182
183 ok(strret.uType == STRRET_WSTR, "%d: Expected STRRET_WSTR\n", Tests[i].testline);
184
185 if (Tests[i].wszExpectedDisplayName)
186 {
187 ok(!wcscmp(strret.pOleStr, Tests[i].wszExpectedDisplayName), "%d: expected %S got %S\n", Tests[i].testline, Tests[i].wszExpectedDisplayName, strret.pOleStr);
188 }
189 else
190 {
191 PIDLIST_ABSOLUTE pidlSpecial;
192 hr = SHGetSpecialFolderLocation(NULL, Tests[i].nExpectedCSIDL, &pidlSpecial);
193 ok(hr == S_OK, "%d: hr = %lx\n", Tests[i].testline, hr);
194
195 STRRET strretSpecial;
196 hr = psfDesktop->GetDisplayNameOf(pidlSpecial, SHGDN_FORPARSING, &strretSpecial);
197 ok(hr == S_OK, "%d: hr = %lx\n", Tests[i].testline, hr);
198
199 ok(strret.uType == STRRET_WSTR, "%d: Expected STRRET_WSTR\n", Tests[i].testline);
200
201 ok(!wcscmp(strret.pOleStr, strretSpecial.pOleStr), "%d: expected %S got %S\n", Tests[i].testline, strretSpecial.pOleStr, strret.pOleStr);
202 }
203 }
204
206}
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:3260
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:1394
_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 33 of file SHParseDisplayName.cpp.

Referenced by START_TEST().