ReactOS 0.4.15-dev-8222-g9164419
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 124 of file SHParseDisplayName.cpp.

125{
126 switch (LOWORD(GetVersion()))
127 {
128 case 5: return T_WIN2K;
129 case (5 | (1 << 8)): return T_WINXP;
130 case (5 | (2 << 8)): return T_WIN2K3;
131 case 6: return T_VISTA;
132 case (6 | (1 << 8)): return T_WIN7;
133 case (6 | (2 << 8)): return T_WIN8;
134 case 10: return T_WIN10;
135 }
136
137 return 0;
138}
#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 140 of file SHParseDisplayName.cpp.

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