Remove unneeded headers to reduce unneeded rebuilds.
[wine] / dlls / shlwapi / tests / clsid.c
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  */
19
20 #include <stdlib.h>
21 #include <stdio.h>
22
23 #define INITGUID
24 #include "wine/test.h"
25 #include "winbase.h"
26 #include "winerror.h"
27 #include "winnls.h"
28 #include "winuser.h"
29 #include "shlguid.h"
30 #include "shobjidl.h"
31
32 /* Function ptrs for ordinal calls */
33 static HMODULE hShlwapi = 0;
34 static BOOL (WINAPI *pSHLWAPI_269)(LPCSTR, CLSID *) = 0;
35 static DWORD (WINAPI *pSHLWAPI_23)(REFGUID, LPSTR, INT) = 0;
36
37 /* GUIDs to test */
38 const GUID * TEST_guids[] = {
39   &CLSID_ShellDesktop,
40   &CLSID_ShellLink,
41   &CATID_BrowsableShellExt,
42   &CATID_BrowseInPlace,
43   &CATID_DeskBand,
44   &CATID_InfoBand,
45   &CATID_CommBand,
46   &FMTID_Intshcut,
47   &FMTID_InternetSite,
48   &CGID_Explorer,
49   &CGID_ShellDocView,
50   &CGID_ShellServiceObject,
51   &CGID_ExplorerBarDoc,
52   &IID_INewShortcutHookA,
53   &IID_IShellIcon,
54   &IID_IShellFolder,
55   &IID_IShellExtInit,
56   &IID_IShellPropSheetExt,
57   &IID_IPersistFolder,
58   &IID_IExtractIconA,
59   &IID_IShellDetails,
60   &IID_IDelayedRelease,
61   &IID_IShellLinkA,
62   &IID_IShellCopyHookA,
63   &IID_IFileViewerA,
64   &IID_ICommDlgBrowser,
65   &IID_IEnumIDList,
66   &IID_IFileViewerSite,
67   &IID_IContextMenu2,
68   &IID_IShellExecuteHookA,
69   &IID_IPropSheetPage,
70   &IID_INewShortcutHookW,
71   &IID_IFileViewerW,
72   &IID_IShellLinkW,
73   &IID_IExtractIconW,
74   &IID_IShellExecuteHookW,
75   &IID_IShellCopyHookW,
76   &IID_IRemoteComputer,
77   &IID_IQueryInfo,
78   &IID_IDockingWindow,
79   &IID_IDockingWindowSite,
80   &CLSID_NetworkPlaces,
81   &CLSID_NetworkDomain,
82   &CLSID_NetworkServer,
83   &CLSID_NetworkShare,
84   &CLSID_MyComputer,
85   &CLSID_Internet,
86   &CLSID_ShellFSFolder,
87   &CLSID_RecycleBin,
88   &CLSID_ControlPanel,
89   &CLSID_Printers,
90   &CLSID_MyDocuments,
91   NULL
92 };
93
94 DEFINE_GUID(IID_Endianess, 0x01020304, 0x0506, 0x0708, 0x09, 0x0A, 0x0B,
95             0x0C, 0x0D, 0x0E, 0x0F, 0x0A);
96
97 static void test_ClassIDs(void)
98 {
99   const GUID **guids = TEST_guids;
100   char szBuff[256];
101   GUID guid;
102   DWORD dwLen;
103   BOOL bRet;
104   int i = 0;
105
106   if (!pSHLWAPI_269 || !pSHLWAPI_23)
107     return;
108
109   while (*guids)
110   {
111     dwLen = pSHLWAPI_23(*guids, szBuff, 256);
112     ok(dwLen == 39, "wrong size for id %d\n", i);
113
114     bRet = pSHLWAPI_269(szBuff, &guid);
115     ok(bRet != FALSE, "created invalid string '%s'\n", szBuff);
116
117     if (bRet)
118       ok(IsEqualGUID(*guids, &guid), "GUID created wrong %d\n", i);
119
120     guids++;
121     i++;
122   }
123
124   /* Test endianess */
125   dwLen = pSHLWAPI_23(&IID_Endianess, szBuff, 256);
126   ok(dwLen == 39, "wrong size for IID_Endianess\n");
127
128   ok(!strcmp(szBuff, "{01020304-0506-0708-090A-0B0C0D0E0F0A}"),
129      "Endianess Broken, got '%s'\n", szBuff);
130
131   /* test lengths */
132   szBuff[0] = ':';
133   dwLen = pSHLWAPI_23(&IID_Endianess, szBuff, 0);
134   ok(dwLen == 0, "accepted bad length\n");
135   ok(szBuff[0] == ':', "wrote to buffer with no length\n");
136
137   szBuff[0] = ':';
138   dwLen = pSHLWAPI_23(&IID_Endianess, szBuff, 38);
139   ok(dwLen == 0, "accepted bad length\n");
140   ok(szBuff[0] == ':', "wrote to buffer with no length\n");
141
142   szBuff[0] = ':';
143   dwLen = pSHLWAPI_23(&IID_Endianess, szBuff, 39);
144   ok(dwLen == 39, "rejected ok length\n");
145   ok(szBuff[0] == '{', "Didn't write to buffer with ok length\n");
146
147   /* Test string */
148   strcpy(szBuff, "{xxx-");
149   bRet = pSHLWAPI_269(szBuff, &guid);
150   ok(bRet == FALSE, "accepted invalid string\n");
151
152   dwLen = pSHLWAPI_23(&IID_Endianess, szBuff, 39);
153   ok(dwLen == 39, "rejected ok length\n");
154   ok(szBuff[0] == '{', "Didn't write to buffer with ok length\n");
155 }
156
157
158 START_TEST(clsid)
159 {
160   hShlwapi = LoadLibraryA("shlwapi.dll");
161   ok(hShlwapi != 0, "LoadLibraryA failed\n");
162   if (hShlwapi)
163   {
164     pSHLWAPI_269 = (void*)GetProcAddress(hShlwapi, (LPSTR)269);
165     pSHLWAPI_23 = (void*)GetProcAddress(hShlwapi, (LPSTR)23);
166   }
167
168   test_ClassIDs();
169
170   if (hShlwapi)
171     FreeLibrary(hShlwapi);
172 }