ReactOS 0.4.16-dev-1946-g52006dd
clsid.c
Go to the documentation of this file.
1/* Unit test suite for SHLWAPI Class ID functions
2 *
3 * Copyright 2003 Jon Griffiths
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18 */
19
20#include <stdio.h>
21
22#include "wine/test.h"
23#include "winbase.h"
24#include "winerror.h"
25#include "winnls.h"
26#include "winuser.h"
27#include "initguid.h"
28#include "shlguid.h"
29#include "shobjidl.h"
30#include "olectl.h"
31
32DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
33
34/* This GUID has been removed from the PSDK */
35DEFINE_OLEGUID(WINE_IID_IDelayedRelease, 0x000214EDL, 0, 0);
36
37/* Function ptrs for ordinal calls */
38static HMODULE hShlwapi = 0;
39static BOOL (WINAPI *pGUIDFromStringA)(LPCSTR, CLSID *) = 0;
40static DWORD (WINAPI *pSHStringFromGUIDA)(REFGUID, LPSTR, INT) = 0;
41
42/* GUIDs to test */
43static const GUID * TEST_guids[] = {
44 &CLSID_ShellDesktop,
45 &CLSID_ShellLink,
46 &CATID_BrowsableShellExt,
47 &CATID_BrowseInPlace,
48 &CATID_DeskBand,
49 &CATID_InfoBand,
50 &CATID_CommBand,
51 &FMTID_Intshcut,
52 &FMTID_InternetSite,
53 &CGID_Explorer,
54 &CGID_ShellDocView,
55 &CGID_ShellServiceObject,
56 &CGID_ExplorerBarDoc,
57 &IID_INewShortcutHookA,
58 &IID_IShellIcon,
59 &IID_IShellFolder,
60 &IID_IShellExtInit,
61 &IID_IShellPropSheetExt,
62 &IID_IPersistFolder,
63 &IID_IExtractIconA,
64 &IID_IShellDetails,
65 &WINE_IID_IDelayedRelease,
66 &IID_IShellLinkA,
67 &IID_IShellCopyHookA,
68 &IID_IFileViewerA,
69 &IID_ICommDlgBrowser,
70 &IID_IEnumIDList,
71 &IID_IFileViewerSite,
72 &IID_IContextMenu2,
73 &IID_IShellExecuteHookA,
74 &IID_IPropSheetPage,
75 &IID_INewShortcutHookW,
76 &IID_IFileViewerW,
77 &IID_IShellLinkW,
78 &IID_IExtractIconW,
79 &IID_IShellExecuteHookW,
80 &IID_IShellCopyHookW,
81 &IID_IRemoteComputer,
82 &IID_IQueryInfo,
83 &IID_IDockingWindow,
84 &IID_IDockingWindowSite,
85 &CLSID_NetworkPlaces,
86 &CLSID_NetworkDomain,
87 &CLSID_NetworkServer,
88 &CLSID_NetworkShare,
89 &CLSID_MyComputer,
90 &CLSID_Internet,
91 &CLSID_ShellFSFolder,
92 &CLSID_RecycleBin,
93 &CLSID_ControlPanel,
94 &CLSID_Printers,
95 &CLSID_MyDocuments,
96 NULL
97};
98
99DEFINE_GUID(IID_Endianness, 0x01020304, 0x0506, 0x0708, 0x09, 0x0A, 0x0B,
100 0x0C, 0x0D, 0x0E, 0x0F, 0x0A);
101
102static void test_ClassIDs(void)
103{
104 const GUID **guids = TEST_guids;
105 char szBuff[256];
106 GUID guid;
107 DWORD dwLen;
108 BOOL bRet;
109 int i = 0;
110 BOOL is_vista = FALSE;
111
112 if (!pGUIDFromStringA || !pSHStringFromGUIDA)
113 return;
114
115 while (*guids)
116 {
117 dwLen = pSHStringFromGUIDA(*guids, szBuff, 256);
118 if (!i && dwLen == S_OK) is_vista = TRUE; /* seems to return an HRESULT on vista */
119 ok(dwLen == (is_vista ? S_OK : 39), "wrong size %lu for id %d\n", dwLen, i);
120
121 bRet = pGUIDFromStringA(szBuff, &guid);
122 ok(bRet != FALSE, "created invalid string '%s'\n", szBuff);
123
124 if (bRet)
125 ok(IsEqualGUID(*guids, &guid), "GUID created wrong %d\n", i);
126
127 guids++;
128 i++;
129 }
130
131 /* Test endianness */
132 dwLen = pSHStringFromGUIDA(&IID_Endianness, szBuff, 256);
133 ok(dwLen == (is_vista ? S_OK : 39), "wrong size %lu for IID_Endianness\n", dwLen);
134
135 ok(!strcmp(szBuff, "{01020304-0506-0708-090A-0B0C0D0E0F0A}"),
136 "Endianness Broken, got '%s'\n", szBuff);
137
138 /* test lengths */
139 szBuff[0] = ':';
140 dwLen = pSHStringFromGUIDA(&IID_Endianness, szBuff, 0);
141 ok(dwLen == (is_vista ? E_FAIL : 0), "accepted bad length\n");
142 ok(szBuff[0] == ':', "wrote to buffer with no length\n");
143
144 szBuff[0] = ':';
145 dwLen = pSHStringFromGUIDA(&IID_Endianness, szBuff, 38);
146 ok(dwLen == (is_vista ? E_FAIL : 0), "accepted bad length\n");
147 ok(szBuff[0] == ':', "wrote to buffer with no length\n");
148
149 szBuff[0] = ':';
150 dwLen = pSHStringFromGUIDA(&IID_Endianness, szBuff, 39);
151 ok(dwLen == (is_vista ? S_OK : 39), "rejected ok length\n");
152 ok(szBuff[0] == '{', "Didn't write to buffer with ok length\n");
153
154 strcpy(szBuff, "{xxx-");
155 bRet = pGUIDFromStringA(szBuff, &guid);
156 ok(bRet == FALSE, "accepted invalid string\n");
157
158 dwLen = pSHStringFromGUIDA(&IID_Endianness, szBuff, 39);
159 ok(dwLen == (is_vista ? S_OK : 39), "rejected ok length\n");
160 ok(szBuff[0] == '{', "Didn't write to buffer with ok length\n");
161}
162
164{
165 HRESULT (WINAPI *pCLSIDFromProgIDWrap)(LPCOLESTR,LPCLSID);
168
169 static const WCHAR wszStdPicture[] = {'S','t','d','P','i','c','t','u','r','e',0};
170
171 pCLSIDFromProgIDWrap = (void*)GetProcAddress(hShlwapi,(char*)435);
172
173 hres = pCLSIDFromProgIDWrap(wszStdPicture, &clsid);
174 ok(hres == S_OK, "CLSIDFromProgIDWrap failed: %08lx\n", hres);
175 ok(IsEqualGUID(&CLSID_StdPicture, &clsid), "wrong clsid\n");
176
177 hres = pCLSIDFromProgIDWrap(NULL, &clsid);
178 ok(hres == E_INVALIDARG, "CLSIDFromProgIDWrap failed: %08lx, expected E_INVALIDARG\n", hres);
179
180 hres = pCLSIDFromProgIDWrap(wszStdPicture, NULL);
181 ok(hres == E_INVALIDARG, "CLSIDFromProgIDWrap failed: %08lx, expected E_INVALIDARG\n", hres);
182}
183
185{
186 hShlwapi = GetModuleHandleA("shlwapi.dll");
187
188 /* SHCreateStreamOnFileEx was introduced in shlwapi v6.0 */
189 if(!GetProcAddress(hShlwapi, "SHCreateStreamOnFileEx")){
190 win_skip("Too old shlwapi version\n");
191 return;
192 }
193
194 pGUIDFromStringA = (void*)GetProcAddress(hShlwapi, (LPSTR)269);
195 pSHStringFromGUIDA = (void*)GetProcAddress(hShlwapi, (LPSTR)23);
196
199}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
static CLSID *static INT
Definition: clsid.c:40
static void test_CLSIDFromProgIDWrap(void)
Definition: clsid.c:163
static void test_ClassIDs(void)
Definition: clsid.c:102
static const GUID * TEST_guids[]
Definition: clsid.c:43
static HMODULE hShlwapi
Definition: clsid.c:38
static CLSID *static LPSTR
Definition: clsid.c:40
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_FAIL
Definition: ddrawi.h:102
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define GetProcAddress(x, y)
Definition: compat.h:753
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
const struct sortguid * guids
Definition: locale.c:420
GUID guid
Definition: version.c:147
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
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
#define S_OK
Definition: intsafe.h:52
#define GUID_NULL
Definition: ks.h:106
#define win_skip
Definition: minitest.h:67
HRESULT hres
Definition: protocol.c:465
const CLSID * clsid
Definition: msctf.cpp:50
#define BOOL
Definition: nt_native.h:43
#define DWORD
Definition: nt_native.h:44
const GUID CLSID_StdPicture
#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8)
Definition: guiddef.h:68
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
GUID * LPCLSID
Definition: guiddef.h:93
#define REFGUID
Definition: guiddef.h:116
#define DEFINE_OLEGUID(name, l, w1, w2)
Definition: guiddef.h:73
#define IID_NULL
Definition: guiddef.h:98
strcpy
Definition: string.h:131
#define HRESULT
Definition: msvc.h:7
#define WINAPI
Definition: msvc.h:6
const char * LPCSTR
Definition: xmlstorage.h:183
__wchar_t WCHAR
Definition: xmlstorage.h:180
char * LPSTR
Definition: xmlstorage.h:182