shlwapi: Be less strict on which type of IShellFolder can be enumerated.
[wine/hramrach.git] / dlls / shlwapi / tests / clsid.c
blob98a8c6d4c0175d1e4c91ea92dc0d97a4c6517b50
1 /* Unit test suite for SHLWAPI Class ID functions
3 * Copyright 2003 Jon Griffiths
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.
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.
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
20 #include <stdio.h>
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"
32 DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
34 /* This GUID has been removed from the PSDK */
35 DEFINE_OLEGUID(WINE_IID_IDelayedRelease, 0x000214EDL, 0, 0);
37 /* Function ptrs for ordinal calls */
38 static HMODULE hShlwapi = 0;
39 static BOOL (WINAPI *pSHLWAPI_269)(LPCSTR, CLSID *) = 0;
40 static DWORD (WINAPI *pSHLWAPI_23)(REFGUID, LPSTR, INT) = 0;
42 /* GUIDs to test */
43 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
99 DEFINE_GUID(IID_Endianess, 0x01020304, 0x0506, 0x0708, 0x09, 0x0A, 0x0B,
100 0x0C, 0x0D, 0x0E, 0x0F, 0x0A);
102 static void test_ClassIDs(void)
104 const GUID **guids = TEST_guids;
105 char szBuff[256];
106 GUID guid;
107 DWORD dwLen;
108 BOOL bRet;
109 int i = 0;
110 int is_vista = 0;
112 if (!pSHLWAPI_269 || !pSHLWAPI_23)
113 return;
115 while (*guids)
117 dwLen = pSHLWAPI_23(*guids, szBuff, 256);
118 if (!i && dwLen == S_OK) is_vista = 1; /* seems to return an HRESULT on vista */
119 ok(dwLen == (is_vista ? S_OK : 39), "wrong size %u for id %d\n", dwLen, i);
121 bRet = pSHLWAPI_269(szBuff, &guid);
122 ok(bRet != FALSE, "created invalid string '%s'\n", szBuff);
124 if (bRet)
125 ok(IsEqualGUID(*guids, &guid), "GUID created wrong %d\n", i);
127 guids++;
128 i++;
131 /* Test endianess */
132 dwLen = pSHLWAPI_23(&IID_Endianess, szBuff, 256);
133 ok(dwLen == (is_vista ? S_OK : 39), "wrong size %u for IID_Endianess\n", dwLen);
135 ok(!strcmp(szBuff, "{01020304-0506-0708-090A-0B0C0D0E0F0A}"),
136 "Endianess Broken, got '%s'\n", szBuff);
138 /* test lengths */
139 szBuff[0] = ':';
140 dwLen = pSHLWAPI_23(&IID_Endianess, 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");
144 szBuff[0] = ':';
145 dwLen = pSHLWAPI_23(&IID_Endianess, 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");
149 szBuff[0] = ':';
150 dwLen = pSHLWAPI_23(&IID_Endianess, 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");
154 /* Test string */
155 strcpy(szBuff, "{xxx-");
156 bRet = pSHLWAPI_269(szBuff, &guid);
157 ok(bRet == FALSE, "accepted invalid string\n");
159 dwLen = pSHLWAPI_23(&IID_Endianess, szBuff, 39);
160 ok(dwLen == (is_vista ? S_OK : 39), "rejected ok length\n");
161 ok(szBuff[0] == '{', "Didn't write to buffer with ok length\n");
164 static void test_CLSIDFromProgIDWrap(void)
166 HRESULT (WINAPI *pCLSIDFromProgIDWrap)(LPCOLESTR,LPCLSID);
167 CLSID clsid = IID_NULL;
168 HRESULT hres;
170 static const WCHAR wszStdPicture[] = {'S','t','d','P','i','c','t','u','r','e',0};
172 pCLSIDFromProgIDWrap = (void*)GetProcAddress(hShlwapi,(char*)435);
174 hres = pCLSIDFromProgIDWrap(wszStdPicture, &clsid);
175 ok(hres == S_OK, "CLSIDFromProgIDWrap failed: %08x\n", hres);
176 ok(IsEqualGUID(&CLSID_StdPicture, &clsid), "wrong clsid\n");
178 hres = pCLSIDFromProgIDWrap(NULL, &clsid);
179 ok(hres == E_INVALIDARG, "CLSIDFromProgIDWrap failed: %08x, expected E_INVALIDARG\n", hres);
181 hres = pCLSIDFromProgIDWrap(wszStdPicture, NULL);
182 ok(hres == E_INVALIDARG, "CLSIDFromProgIDWrap failed: %08x, expected E_INVALIDARG\n", hres);
185 START_TEST(clsid)
187 hShlwapi = GetModuleHandleA("shlwapi.dll");
188 pSHLWAPI_269 = (void*)GetProcAddress(hShlwapi, (LPSTR)269);
189 pSHLWAPI_23 = (void*)GetProcAddress(hShlwapi, (LPSTR)23);
191 test_ClassIDs();
192 test_CLSIDFromProgIDWrap();