2003-10-01 03:10:56 +00:00
|
|
|
/* Unit test suite for SHLWAPI Class ID functions
|
|
|
|
*
|
|
|
|
* Copyright 2003 Jon Griffiths
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 12:49:52 +00:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2003-10-01 03:10:56 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "wine/test.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winerror.h"
|
|
|
|
#include "winnls.h"
|
|
|
|
#include "winuser.h"
|
2008-07-08 14:17:17 +00:00
|
|
|
#include "initguid.h"
|
2003-10-01 03:10:56 +00:00
|
|
|
#include "shlguid.h"
|
|
|
|
#include "shobjidl.h"
|
2007-01-06 16:05:58 +00:00
|
|
|
#include "olectl.h"
|
|
|
|
|
2008-07-08 14:17:17 +00:00
|
|
|
DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
|
2003-10-01 03:10:56 +00:00
|
|
|
|
2007-05-27 11:37:37 +00:00
|
|
|
/* This GUID has been removed from the PSDK */
|
|
|
|
DEFINE_OLEGUID(WINE_IID_IDelayedRelease, 0x000214EDL, 0, 0);
|
|
|
|
|
2003-10-01 03:10:56 +00:00
|
|
|
/* Function ptrs for ordinal calls */
|
|
|
|
static HMODULE hShlwapi = 0;
|
|
|
|
static BOOL (WINAPI *pSHLWAPI_269)(LPCSTR, CLSID *) = 0;
|
|
|
|
static DWORD (WINAPI *pSHLWAPI_23)(REFGUID, LPSTR, INT) = 0;
|
|
|
|
|
|
|
|
/* GUIDs to test */
|
|
|
|
const GUID * TEST_guids[] = {
|
|
|
|
&CLSID_ShellDesktop,
|
|
|
|
&CLSID_ShellLink,
|
|
|
|
&CATID_BrowsableShellExt,
|
|
|
|
&CATID_BrowseInPlace,
|
|
|
|
&CATID_DeskBand,
|
|
|
|
&CATID_InfoBand,
|
|
|
|
&CATID_CommBand,
|
|
|
|
&FMTID_Intshcut,
|
|
|
|
&FMTID_InternetSite,
|
|
|
|
&CGID_Explorer,
|
|
|
|
&CGID_ShellDocView,
|
|
|
|
&CGID_ShellServiceObject,
|
|
|
|
&CGID_ExplorerBarDoc,
|
|
|
|
&IID_INewShortcutHookA,
|
|
|
|
&IID_IShellIcon,
|
|
|
|
&IID_IShellFolder,
|
|
|
|
&IID_IShellExtInit,
|
|
|
|
&IID_IShellPropSheetExt,
|
|
|
|
&IID_IPersistFolder,
|
|
|
|
&IID_IExtractIconA,
|
|
|
|
&IID_IShellDetails,
|
2007-05-27 11:37:37 +00:00
|
|
|
&WINE_IID_IDelayedRelease,
|
2003-10-01 03:10:56 +00:00
|
|
|
&IID_IShellLinkA,
|
|
|
|
&IID_IShellCopyHookA,
|
|
|
|
&IID_IFileViewerA,
|
|
|
|
&IID_ICommDlgBrowser,
|
|
|
|
&IID_IEnumIDList,
|
|
|
|
&IID_IFileViewerSite,
|
|
|
|
&IID_IContextMenu2,
|
|
|
|
&IID_IShellExecuteHookA,
|
|
|
|
&IID_IPropSheetPage,
|
|
|
|
&IID_INewShortcutHookW,
|
|
|
|
&IID_IFileViewerW,
|
|
|
|
&IID_IShellLinkW,
|
|
|
|
&IID_IExtractIconW,
|
|
|
|
&IID_IShellExecuteHookW,
|
|
|
|
&IID_IShellCopyHookW,
|
|
|
|
&IID_IRemoteComputer,
|
|
|
|
&IID_IQueryInfo,
|
|
|
|
&IID_IDockingWindow,
|
|
|
|
&IID_IDockingWindowSite,
|
|
|
|
&CLSID_NetworkPlaces,
|
|
|
|
&CLSID_NetworkDomain,
|
|
|
|
&CLSID_NetworkServer,
|
|
|
|
&CLSID_NetworkShare,
|
|
|
|
&CLSID_MyComputer,
|
|
|
|
&CLSID_Internet,
|
|
|
|
&CLSID_ShellFSFolder,
|
|
|
|
&CLSID_RecycleBin,
|
|
|
|
&CLSID_ControlPanel,
|
|
|
|
&CLSID_Printers,
|
|
|
|
&CLSID_MyDocuments,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2004-01-16 02:02:03 +00:00
|
|
|
DEFINE_GUID(IID_Endianess, 0x01020304, 0x0506, 0x0708, 0x09, 0x0A, 0x0B,
|
|
|
|
0x0C, 0x0D, 0x0E, 0x0F, 0x0A);
|
|
|
|
|
2003-10-01 03:10:56 +00:00
|
|
|
static void test_ClassIDs(void)
|
|
|
|
{
|
|
|
|
const GUID **guids = TEST_guids;
|
|
|
|
char szBuff[256];
|
|
|
|
GUID guid;
|
|
|
|
DWORD dwLen;
|
|
|
|
BOOL bRet;
|
|
|
|
int i = 0;
|
2008-09-17 14:23:19 +00:00
|
|
|
int is_vista = 0;
|
2003-10-01 03:10:56 +00:00
|
|
|
|
|
|
|
if (!pSHLWAPI_269 || !pSHLWAPI_23)
|
|
|
|
return;
|
|
|
|
|
|
|
|
while (*guids)
|
|
|
|
{
|
|
|
|
dwLen = pSHLWAPI_23(*guids, szBuff, 256);
|
2008-09-17 14:23:19 +00:00
|
|
|
if (!i && dwLen == S_OK) is_vista = 1; /* seems to return an HRESULT on vista */
|
|
|
|
ok(dwLen == (is_vista ? S_OK : 39), "wrong size %u for id %d\n", dwLen, i);
|
2003-10-01 03:10:56 +00:00
|
|
|
|
|
|
|
bRet = pSHLWAPI_269(szBuff, &guid);
|
2004-01-27 20:13:03 +00:00
|
|
|
ok(bRet != FALSE, "created invalid string '%s'\n", szBuff);
|
2003-10-01 03:10:56 +00:00
|
|
|
|
|
|
|
if (bRet)
|
2004-01-27 20:13:03 +00:00
|
|
|
ok(IsEqualGUID(*guids, &guid), "GUID created wrong %d\n", i);
|
2003-10-01 03:10:56 +00:00
|
|
|
|
|
|
|
guids++;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Test endianess */
|
|
|
|
dwLen = pSHLWAPI_23(&IID_Endianess, szBuff, 256);
|
2008-09-17 14:23:19 +00:00
|
|
|
ok(dwLen == (is_vista ? S_OK : 39), "wrong size %u for IID_Endianess\n", dwLen);
|
2003-10-01 03:10:56 +00:00
|
|
|
|
|
|
|
ok(!strcmp(szBuff, "{01020304-0506-0708-090A-0B0C0D0E0F0A}"),
|
2004-01-27 20:13:03 +00:00
|
|
|
"Endianess Broken, got '%s'\n", szBuff);
|
2003-10-01 03:10:56 +00:00
|
|
|
|
|
|
|
/* test lengths */
|
|
|
|
szBuff[0] = ':';
|
|
|
|
dwLen = pSHLWAPI_23(&IID_Endianess, szBuff, 0);
|
2008-09-17 14:23:19 +00:00
|
|
|
ok(dwLen == (is_vista ? E_FAIL : 0), "accepted bad length\n");
|
2004-01-27 20:13:03 +00:00
|
|
|
ok(szBuff[0] == ':', "wrote to buffer with no length\n");
|
2003-10-01 03:10:56 +00:00
|
|
|
|
|
|
|
szBuff[0] = ':';
|
|
|
|
dwLen = pSHLWAPI_23(&IID_Endianess, szBuff, 38);
|
2008-09-17 14:23:19 +00:00
|
|
|
ok(dwLen == (is_vista ? E_FAIL : 0), "accepted bad length\n");
|
2004-01-27 20:13:03 +00:00
|
|
|
ok(szBuff[0] == ':', "wrote to buffer with no length\n");
|
2003-10-01 03:10:56 +00:00
|
|
|
|
|
|
|
szBuff[0] = ':';
|
|
|
|
dwLen = pSHLWAPI_23(&IID_Endianess, szBuff, 39);
|
2008-09-17 14:23:19 +00:00
|
|
|
ok(dwLen == (is_vista ? S_OK : 39), "rejected ok length\n");
|
2004-01-27 20:13:03 +00:00
|
|
|
ok(szBuff[0] == '{', "Didn't write to buffer with ok length\n");
|
2003-10-01 03:10:56 +00:00
|
|
|
|
|
|
|
/* Test string */
|
|
|
|
strcpy(szBuff, "{xxx-");
|
|
|
|
bRet = pSHLWAPI_269(szBuff, &guid);
|
2004-01-27 20:13:03 +00:00
|
|
|
ok(bRet == FALSE, "accepted invalid string\n");
|
2003-10-01 03:10:56 +00:00
|
|
|
|
|
|
|
dwLen = pSHLWAPI_23(&IID_Endianess, szBuff, 39);
|
2008-09-17 14:23:19 +00:00
|
|
|
ok(dwLen == (is_vista ? S_OK : 39), "rejected ok length\n");
|
2004-01-27 20:13:03 +00:00
|
|
|
ok(szBuff[0] == '{', "Didn't write to buffer with ok length\n");
|
2003-10-01 03:10:56 +00:00
|
|
|
}
|
|
|
|
|
2007-01-06 16:05:58 +00:00
|
|
|
static void test_CLSIDFromProgIDWrap(void)
|
|
|
|
{
|
|
|
|
HRESULT (WINAPI *pCLSIDFromProgIDWrap)(LPCOLESTR,LPCLSID);
|
|
|
|
CLSID clsid = IID_NULL;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
static const WCHAR wszStdPicture[] = {'S','t','d','P','i','c','t','u','r','e',0};
|
|
|
|
|
|
|
|
pCLSIDFromProgIDWrap = (void*)GetProcAddress(hShlwapi,(char*)435);
|
|
|
|
|
|
|
|
hres = pCLSIDFromProgIDWrap(wszStdPicture, &clsid);
|
|
|
|
ok(hres == S_OK, "CLSIDFromProgIDWrap failed: %08x\n", hres);
|
|
|
|
ok(IsEqualGUID(&CLSID_StdPicture, &clsid), "wrong clsid\n");
|
|
|
|
|
|
|
|
hres = pCLSIDFromProgIDWrap(NULL, &clsid);
|
|
|
|
ok(hres == E_INVALIDARG, "CLSIDFromProgIDWrap failed: %08x, expected E_INVALIDARG\n", hres);
|
|
|
|
|
|
|
|
hres = pCLSIDFromProgIDWrap(wszStdPicture, NULL);
|
|
|
|
ok(hres == E_INVALIDARG, "CLSIDFromProgIDWrap failed: %08x, expected E_INVALIDARG\n", hres);
|
|
|
|
}
|
2003-10-01 03:10:56 +00:00
|
|
|
|
|
|
|
START_TEST(clsid)
|
|
|
|
{
|
2007-08-07 13:16:32 +00:00
|
|
|
hShlwapi = GetModuleHandleA("shlwapi.dll");
|
|
|
|
pSHLWAPI_269 = (void*)GetProcAddress(hShlwapi, (LPSTR)269);
|
|
|
|
pSHLWAPI_23 = (void*)GetProcAddress(hShlwapi, (LPSTR)23);
|
2003-10-01 03:10:56 +00:00
|
|
|
|
|
|
|
test_ClassIDs();
|
2007-01-06 16:05:58 +00:00
|
|
|
test_CLSIDFromProgIDWrap();
|
2003-10-01 03:10:56 +00:00
|
|
|
}
|