2008-08-03 11:18:26 +02:00
|
|
|
/*
|
|
|
|
* Unit tests to document InternetShortcut's behaviour
|
|
|
|
*
|
|
|
|
* Copyright 2008 Damjan Jovanovic
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winreg.h"
|
|
|
|
#include "winerror.h"
|
|
|
|
|
|
|
|
#include "shlobj.h"
|
|
|
|
#include "shobjidl.h"
|
|
|
|
#include "shlguid.h"
|
|
|
|
#include "ole2.h"
|
2010-11-11 06:52:01 +01:00
|
|
|
#include "mshtml.h"
|
2008-08-03 11:18:26 +02:00
|
|
|
#include "initguid.h"
|
|
|
|
#include "isguids.h"
|
|
|
|
#include "intshcut.h"
|
|
|
|
|
|
|
|
#include "wine/test.h"
|
|
|
|
|
2008-09-07 10:30:32 +02:00
|
|
|
static HRESULT WINAPI Unknown_QueryInterface(IUnknown *pUnknown, REFIID riid, void **ppvObject)
|
2008-08-03 11:18:26 +02:00
|
|
|
{
|
|
|
|
if (IsEqualGUID(&IID_IUnknown, riid))
|
|
|
|
{
|
|
|
|
*ppvObject = pUnknown;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2008-09-07 10:30:32 +02:00
|
|
|
static ULONG WINAPI Unknown_AddRef(IUnknown *pUnknown)
|
2008-08-03 11:18:26 +02:00
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
2008-09-07 10:30:32 +02:00
|
|
|
static ULONG WINAPI Unknown_Release(IUnknown *pUnknown)
|
2008-08-03 11:18:26 +02:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static IUnknownVtbl unknownVtbl = {
|
|
|
|
Unknown_QueryInterface,
|
|
|
|
Unknown_AddRef,
|
|
|
|
Unknown_Release
|
|
|
|
};
|
|
|
|
|
|
|
|
static IUnknown unknown = {
|
|
|
|
&unknownVtbl
|
|
|
|
};
|
|
|
|
|
|
|
|
static void test_Aggregability(void)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IUnknown *pUnknown = NULL;
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_InternetShortcut, NULL, CLSCTX_ALL, &IID_IUnknown, (void**)&pUnknown);
|
2011-04-08 11:59:43 +02:00
|
|
|
ok(hr == S_OK, "could not create instance of CLSID_InternetShortcut with IID_IUnknown, hr = 0x%x\n", hr);
|
2008-08-03 11:18:26 +02:00
|
|
|
if (pUnknown)
|
|
|
|
IUnknown_Release(pUnknown);
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_InternetShortcut, NULL, CLSCTX_ALL, &IID_IUniformResourceLocatorA, (void**)&pUnknown);
|
2011-04-08 11:59:43 +02:00
|
|
|
ok(hr == S_OK, "could not create instance of CLSID_InternetShortcut with IID_IUniformResourceLocatorA, hr = 0x%x\n", hr);
|
2008-08-03 11:18:26 +02:00
|
|
|
if (pUnknown)
|
|
|
|
IUnknown_Release(pUnknown);
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_InternetShortcut, &unknown, CLSCTX_ALL, &IID_IUnknown, (void**)&pUnknown);
|
2011-04-08 11:59:43 +02:00
|
|
|
ok(hr == CLASS_E_NOAGGREGATION, "aggregation didn't fail like it should, hr = 0x%x\n", hr);
|
2008-08-03 11:18:26 +02:00
|
|
|
if (pUnknown)
|
|
|
|
IUnknown_Release(pUnknown);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void can_query_interface(IUnknown *pUnknown, REFIID riid)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IUnknown *newInterface;
|
|
|
|
hr = IUnknown_QueryInterface(pUnknown, riid, (void**)&newInterface);
|
2014-01-25 15:24:32 +01:00
|
|
|
ok(hr == S_OK, "interface %s could not be queried\n", wine_dbgstr_guid(riid));
|
2008-08-03 11:18:26 +02:00
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
IUnknown_Release(newInterface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_QueryInterface(void)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IUnknown *pUnknown;
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_InternetShortcut, NULL, CLSCTX_ALL, &IID_IUnknown, (void**)&pUnknown);
|
2011-04-08 11:58:32 +02:00
|
|
|
ok(hr == S_OK, "Could not create InternetShortcut object: %08x\n", hr);
|
|
|
|
|
|
|
|
can_query_interface(pUnknown, &IID_IUniformResourceLocatorA);
|
|
|
|
can_query_interface(pUnknown, &IID_IUniformResourceLocatorW);
|
|
|
|
can_query_interface(pUnknown, &IID_IPersistFile);
|
|
|
|
IUnknown_Release(pUnknown);
|
2008-08-03 11:18:26 +02:00
|
|
|
}
|
|
|
|
|
2011-04-12 13:27:55 +02:00
|
|
|
#define test_shortcut_url(a,b) _test_shortcut_url(__LINE__,a,b)
|
|
|
|
static void _test_shortcut_url(unsigned line, IUnknown *unk, const char *exurl)
|
|
|
|
{
|
|
|
|
IUniformResourceLocatorA *locator_a;
|
|
|
|
char *url_a;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = IUnknown_QueryInterface(unk, &IID_IUniformResourceLocatorA, (void**)&locator_a);
|
|
|
|
ok_(__FILE__,line)(hres == S_OK, "Could not get IUniformResourceLocatorA iface: %08x\n", hres);
|
|
|
|
|
|
|
|
hres = locator_a->lpVtbl->GetURL(locator_a, &url_a);
|
|
|
|
ok_(__FILE__,line)(hres == S_OK, "GetURL failed: %08x\n", hres);
|
|
|
|
ok_(__FILE__,line)(!strcmp(url_a, exurl), "unexpected URL, got %s, expected %s\n", url_a, exurl);
|
|
|
|
CoTaskMemFree(url_a);
|
|
|
|
|
2012-07-30 10:52:52 +02:00
|
|
|
IUnknown_Release((IUnknown*)locator_a);
|
2011-04-12 13:27:55 +02:00
|
|
|
}
|
|
|
|
|
2011-04-08 11:59:43 +02:00
|
|
|
#define check_string_transform(a,b,c,d,e) _check_string_transform(__LINE__,a,b,c,d,e)
|
|
|
|
static void _check_string_transform(unsigned line, IUniformResourceLocatorA *urlA, LPCSTR input, DWORD flags,
|
|
|
|
LPCSTR expectedOutput, BOOL is_todo)
|
2008-08-03 11:18:26 +02:00
|
|
|
{
|
2011-04-08 11:59:43 +02:00
|
|
|
CHAR *output;
|
2008-08-03 11:18:26 +02:00
|
|
|
HRESULT hr;
|
2011-04-08 11:59:43 +02:00
|
|
|
|
2008-08-03 11:18:26 +02:00
|
|
|
hr = urlA->lpVtbl->SetURL(urlA, input, flags);
|
2011-04-08 11:59:43 +02:00
|
|
|
ok_(__FILE__,line)(hr == S_OK, "SetUrl failed, hr=0x%x\n", hr);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return;
|
2008-08-03 11:18:26 +02:00
|
|
|
|
2011-04-08 11:59:43 +02:00
|
|
|
output = (void*)0xdeadbeef;
|
|
|
|
hr = urlA->lpVtbl->GetURL(urlA, &output);
|
|
|
|
if(expectedOutput) {
|
2016-02-17 21:13:30 +01:00
|
|
|
todo_wine_if(is_todo) {
|
2011-04-08 11:59:43 +02:00
|
|
|
ok_(__FILE__,line)(hr == S_OK, "GetUrl failed, hr=0x%x\n", hr);
|
|
|
|
}
|
|
|
|
todo_wine
|
|
|
|
ok_(__FILE__,line)(!lstrcmpA(output, expectedOutput), "unexpected URL change %s -> %s (expected %s)\n",
|
2008-08-03 11:18:26 +02:00
|
|
|
input, output, expectedOutput);
|
2011-04-08 11:59:43 +02:00
|
|
|
}else {
|
|
|
|
todo_wine
|
|
|
|
ok_(__FILE__,line)(hr == S_FALSE, "GetUrl failed, hr=0x%x\n", hr);
|
|
|
|
todo_wine
|
|
|
|
ok_(__FILE__,line)(!output, "GetUrl returned %s\n", output);
|
2008-08-03 11:18:26 +02:00
|
|
|
}
|
2015-06-21 08:36:39 +02:00
|
|
|
if (hr == S_OK)
|
|
|
|
CoTaskMemFree(output);
|
2008-08-03 11:18:26 +02:00
|
|
|
}
|
|
|
|
|
2010-11-11 06:55:48 +01:00
|
|
|
static void test_ReadAndWriteProperties(void)
|
|
|
|
{
|
2011-04-08 11:58:32 +02:00
|
|
|
int iconIndex = 7;
|
|
|
|
PROPSPEC ps[2];
|
2010-11-11 06:55:48 +01:00
|
|
|
HRESULT hr;
|
|
|
|
IUniformResourceLocatorA *urlA;
|
2010-11-24 22:56:08 +01:00
|
|
|
IUniformResourceLocatorA *urlAFromFile;
|
2010-12-12 13:14:05 +01:00
|
|
|
WCHAR fileNameW[MAX_PATH];
|
2011-04-08 11:58:32 +02:00
|
|
|
|
2010-12-12 13:14:05 +01:00
|
|
|
static const WCHAR shortcutW[] = {'t','e','s','t','s','h','o','r','t','c','u','t','.','u','r','l',0};
|
2010-11-24 22:56:08 +01:00
|
|
|
WCHAR iconPath[] = {'f','i','l','e',':','/','/','/','C',':','/','a','r','b','i','t','r','a','r','y','/','i','c','o','n','/','p','a','t','h',0};
|
|
|
|
char testurl[] = "http://some/bogus/url.html";
|
2011-04-08 11:58:32 +02:00
|
|
|
|
2010-11-24 22:56:08 +01:00
|
|
|
ps[0].ulKind = PRSPEC_PROPID;
|
2011-01-04 15:58:02 +01:00
|
|
|
U(ps[0]).propid = PID_IS_ICONFILE;
|
2010-11-24 22:56:08 +01:00
|
|
|
ps[1].ulKind = PRSPEC_PROPID;
|
2011-01-04 15:58:02 +01:00
|
|
|
U(ps[1]).propid = PID_IS_ICONINDEX;
|
2010-11-11 06:55:48 +01:00
|
|
|
|
2010-12-12 13:14:05 +01:00
|
|
|
/* Make sure we have a valid temporary directory */
|
|
|
|
GetTempPathW(MAX_PATH, fileNameW);
|
|
|
|
lstrcatW(fileNameW, shortcutW);
|
|
|
|
|
2010-11-11 06:55:48 +01:00
|
|
|
hr = CoCreateInstance(&CLSID_InternetShortcut, NULL, CLSCTX_ALL, &IID_IUniformResourceLocatorA, (void**)&urlA);
|
2011-08-03 12:45:42 +02:00
|
|
|
ok(hr == S_OK, "Could not create CLSID_InternetShortcut instance: %08x\n", hr);
|
2010-11-11 06:55:48 +01:00
|
|
|
if (hr == S_OK)
|
|
|
|
{
|
2010-11-24 22:56:08 +01:00
|
|
|
IPersistFile *pf;
|
2010-11-11 06:55:48 +01:00
|
|
|
IPropertyStorage *pPropStgWrite;
|
2010-11-24 22:56:08 +01:00
|
|
|
IPropertySetStorage *pPropSetStg;
|
2010-11-11 06:55:48 +01:00
|
|
|
PROPVARIANT pv[2];
|
2010-12-23 13:19:40 +01:00
|
|
|
|
|
|
|
/* We need to set a URL -- IPersistFile refuses to save without one. */
|
|
|
|
hr = urlA->lpVtbl->SetURL(urlA, testurl, 0);
|
|
|
|
ok(hr == S_OK, "Failed to set a URL. hr=0x%x\n", hr);
|
|
|
|
|
|
|
|
/* Write this shortcut out to a file so that we can test reading it in again. */
|
|
|
|
hr = urlA->lpVtbl->QueryInterface(urlA, &IID_IPersistFile, (void **) &pf);
|
|
|
|
ok(hr == S_OK, "Failed to get the IPersistFile for writing. hr=0x%x\n", hr);
|
|
|
|
|
|
|
|
hr = IPersistFile_Save(pf, fileNameW, TRUE);
|
|
|
|
ok(hr == S_OK, "Failed to save via IPersistFile. hr=0x%x\n", hr);
|
|
|
|
|
|
|
|
IPersistFile_Release(pf);
|
|
|
|
|
2010-11-11 06:55:48 +01:00
|
|
|
pv[0].vt = VT_LPWSTR;
|
2011-01-04 15:58:02 +01:00
|
|
|
U(pv[0]).pwszVal = (void *) iconPath;
|
2010-11-11 06:55:48 +01:00
|
|
|
pv[1].vt = VT_I4;
|
2016-01-01 17:51:59 +01:00
|
|
|
U(pv[1]).lVal = iconIndex;
|
2010-11-11 06:55:48 +01:00
|
|
|
hr = urlA->lpVtbl->QueryInterface(urlA, &IID_IPropertySetStorage, (void **) &pPropSetStg);
|
|
|
|
ok(hr == S_OK, "Unable to get an IPropertySetStorage, hr=0x%x\n", hr);
|
|
|
|
|
|
|
|
hr = IPropertySetStorage_Open(pPropSetStg, &FMTID_Intshcut, STGM_READWRITE | STGM_SHARE_EXCLUSIVE, &pPropStgWrite);
|
|
|
|
ok(hr == S_OK, "Unable to get an IPropertyStorage for writing, hr=0x%x\n", hr);
|
|
|
|
|
|
|
|
hr = IPropertyStorage_WriteMultiple(pPropStgWrite, 2, ps, pv, 0);
|
|
|
|
ok(hr == S_OK, "Unable to set properties, hr=0x%x\n", hr);
|
|
|
|
|
|
|
|
hr = IPropertyStorage_Commit(pPropStgWrite, STGC_DEFAULT);
|
|
|
|
ok(hr == S_OK, "Failed to commit properties, hr=0x%x\n", hr);
|
|
|
|
|
|
|
|
pPropStgWrite->lpVtbl->Release(pPropStgWrite);
|
2010-11-24 22:56:08 +01:00
|
|
|
urlA->lpVtbl->Release(urlA);
|
|
|
|
IPropertySetStorage_Release(pPropSetStg);
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_InternetShortcut, NULL, CLSCTX_ALL, &IID_IUniformResourceLocatorA, (void**)&urlAFromFile);
|
2011-08-03 12:45:42 +02:00
|
|
|
ok(hr == S_OK, "Could not create CLSID_InternetShortcut instance: %08x\n", hr);
|
2010-11-24 22:56:08 +01:00
|
|
|
if (hr == S_OK)
|
|
|
|
{
|
|
|
|
IPropertySetStorage *pPropSetStg;
|
|
|
|
IPropertyStorage *pPropStgRead;
|
|
|
|
PROPVARIANT pvread[2];
|
|
|
|
IPersistFile *pf;
|
|
|
|
LPSTR url = NULL;
|
|
|
|
|
|
|
|
/* Now read that .url file back in. */
|
2010-12-07 10:12:01 +01:00
|
|
|
hr = urlAFromFile->lpVtbl->QueryInterface(urlAFromFile, &IID_IPersistFile, (void **) &pf);
|
2010-11-24 22:56:08 +01:00
|
|
|
ok(hr == S_OK, "Failed to get the IPersistFile for reading. hr=0x%x\n", hr);
|
|
|
|
|
|
|
|
hr = IPersistFile_Load(pf, fileNameW, 0);
|
|
|
|
ok(hr == S_OK, "Failed to load via IPersistFile. hr=0x%x\n", hr);
|
|
|
|
IPersistFile_Release(pf);
|
|
|
|
|
|
|
|
|
2010-12-07 10:12:01 +01:00
|
|
|
hr = urlAFromFile->lpVtbl->GetURL(urlAFromFile, &url);
|
2011-02-05 07:39:18 +01:00
|
|
|
ok(hr == S_OK, "Unable to get url from file, hr=0x%x\n", hr);
|
2013-10-10 12:53:22 +02:00
|
|
|
ok(lstrcmpA(url, testurl) == 0, "Wrong url read from file: %s\n",url);
|
2015-06-21 08:36:39 +02:00
|
|
|
CoTaskMemFree(url);
|
2010-11-24 22:56:08 +01:00
|
|
|
|
2010-12-07 10:12:01 +01:00
|
|
|
hr = urlAFromFile->lpVtbl->QueryInterface(urlAFromFile, &IID_IPropertySetStorage, (void **) &pPropSetStg);
|
2010-11-24 22:56:08 +01:00
|
|
|
ok(hr == S_OK, "Unable to get an IPropertySetStorage, hr=0x%x\n", hr);
|
|
|
|
|
2010-11-11 06:55:48 +01:00
|
|
|
hr = IPropertySetStorage_Open(pPropSetStg, &FMTID_Intshcut, STGM_READ | STGM_SHARE_EXCLUSIVE, &pPropStgRead);
|
|
|
|
ok(hr == S_OK, "Unable to get an IPropertyStorage for reading, hr=0x%x\n", hr);
|
|
|
|
|
2016-01-01 17:51:59 +01:00
|
|
|
memset(pvread, 0, sizeof(pvread));
|
2010-11-11 06:55:48 +01:00
|
|
|
hr = IPropertyStorage_ReadMultiple(pPropStgRead, 2, ps, pvread);
|
2016-01-01 17:51:59 +01:00
|
|
|
todo_wine /* Wine doesn't yet support setting properties after save */
|
|
|
|
{
|
2010-11-11 06:55:48 +01:00
|
|
|
ok(hr == S_OK, "Unable to read properties, hr=0x%x\n", hr);
|
2016-01-01 17:51:59 +01:00
|
|
|
ok(pvread[1].vt == VT_I4, "got %d\n", pvread[1].vt);
|
|
|
|
ok(U(pvread[1]).lVal == iconIndex, "Read wrong icon index: %d\n", U(pvread[1]).iVal);
|
|
|
|
ok(pvread[0].vt == VT_LPWSTR, "got %d\n", pvread[0].vt);
|
|
|
|
ok(lstrcmpW(U(pvread[0]).pwszVal, iconPath) == 0, "Wrong icon path read: %s\n", wine_dbgstr_w(U(pvread[0]).pwszVal));
|
|
|
|
}
|
2010-11-23 10:43:32 +01:00
|
|
|
PropVariantClear(&pvread[0]);
|
|
|
|
PropVariantClear(&pvread[1]);
|
2010-11-11 06:55:48 +01:00
|
|
|
IPropertyStorage_Release(pPropStgRead);
|
|
|
|
IPropertySetStorage_Release(pPropSetStg);
|
2010-12-07 10:12:01 +01:00
|
|
|
urlAFromFile->lpVtbl->Release(urlAFromFile);
|
2010-11-24 22:56:08 +01:00
|
|
|
DeleteFileW(fileNameW);
|
2010-11-11 06:55:48 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-03 11:18:26 +02:00
|
|
|
static void test_NullURLs(void)
|
|
|
|
{
|
2011-04-08 11:58:32 +02:00
|
|
|
LPSTR url = NULL;
|
2008-08-03 11:18:26 +02:00
|
|
|
HRESULT hr;
|
|
|
|
IUniformResourceLocatorA *urlA;
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_InternetShortcut, NULL, CLSCTX_ALL, &IID_IUniformResourceLocatorA, (void**)&urlA);
|
2011-04-08 11:58:32 +02:00
|
|
|
ok(hr == S_OK, "Could not create InternetShortcut object: %08x\n", hr);
|
2008-08-03 11:18:26 +02:00
|
|
|
|
2011-04-08 11:58:32 +02:00
|
|
|
hr = urlA->lpVtbl->GetURL(urlA, &url);
|
2011-04-08 11:59:43 +02:00
|
|
|
ok(hr == S_FALSE, "getting uninitialized URL unexpectedly failed, hr=0x%x\n", hr);
|
2011-04-08 11:58:32 +02:00
|
|
|
ok(url == NULL, "uninitialized URL is not NULL but %s\n", url);
|
2008-08-03 11:18:26 +02:00
|
|
|
|
2011-04-08 11:58:32 +02:00
|
|
|
hr = urlA->lpVtbl->SetURL(urlA, NULL, 0);
|
2011-04-08 11:59:43 +02:00
|
|
|
ok(hr == S_OK, "setting NULL URL unexpectedly failed, hr=0x%x\n", hr);
|
2008-08-03 11:18:26 +02:00
|
|
|
|
2011-04-08 11:58:32 +02:00
|
|
|
hr = urlA->lpVtbl->GetURL(urlA, &url);
|
2011-04-08 11:59:43 +02:00
|
|
|
ok(hr == S_FALSE, "getting NULL URL unexpectedly failed, hr=0x%x\n", hr);
|
2011-04-08 11:58:32 +02:00
|
|
|
ok(url == NULL, "URL unexpectedly not NULL but %s\n", url);
|
2008-08-03 11:18:26 +02:00
|
|
|
|
2011-04-08 11:58:32 +02:00
|
|
|
urlA->lpVtbl->Release(urlA);
|
2008-08-03 11:18:26 +02:00
|
|
|
}
|
|
|
|
|
2011-04-12 13:27:55 +02:00
|
|
|
typedef struct {
|
|
|
|
const char *data;
|
|
|
|
const char *url;
|
|
|
|
} load_test_t;
|
|
|
|
|
|
|
|
static const load_test_t load_tests[] = {
|
|
|
|
{"[InternetShortcut]\n"
|
|
|
|
"URL=http://www.winehq.org/\n"
|
|
|
|
"HotKey=0\n"
|
|
|
|
"IDList=\n"
|
|
|
|
"[{000214A0-0000-0000-C000-000000000046}]\n"
|
|
|
|
"Prop0=1,2\n",
|
|
|
|
|
|
|
|
"http://www.winehq.org/"
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static void test_Load(void)
|
|
|
|
{
|
|
|
|
IPersistFile *persist_file;
|
|
|
|
const load_test_t *test;
|
|
|
|
WCHAR file_path[MAX_PATH];
|
|
|
|
DWORD size;
|
|
|
|
HANDLE file;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
static const WCHAR test_urlW[] = {'t','e','s','t','.','u','r','l',0};
|
|
|
|
|
|
|
|
GetTempPathW(MAX_PATH, file_path);
|
|
|
|
lstrcatW(file_path, test_urlW);
|
|
|
|
|
2018-06-07 23:44:37 +02:00
|
|
|
for(test = load_tests; test < load_tests + ARRAY_SIZE(load_tests); test++) {
|
2016-01-01 17:51:59 +01:00
|
|
|
IPropertySetStorage *propsetstorage;
|
|
|
|
IPropertyStorage *propstorage;
|
|
|
|
PROPVARIANT v;
|
|
|
|
PROPSPEC ps;
|
|
|
|
|
2011-04-12 13:27:55 +02:00
|
|
|
file = CreateFileW(file_path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
ok(file != INVALID_HANDLE_VALUE, "could not create test file\n");
|
|
|
|
if(file == INVALID_HANDLE_VALUE)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
WriteFile(file, test->data, strlen(test->data), &size, NULL);
|
|
|
|
CloseHandle(file);
|
|
|
|
|
|
|
|
hres = CoCreateInstance(&CLSID_InternetShortcut, NULL, CLSCTX_ALL, &IID_IPersistFile, (void**)&persist_file);
|
|
|
|
ok(hres == S_OK, "Could not create InternetShortcut instance: %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IPersistFile_Load(persist_file, file_path, 0);
|
|
|
|
ok(hres == S_OK, "Load failed: %08x\n", hres);
|
|
|
|
|
|
|
|
test_shortcut_url((IUnknown*)persist_file, test->url);
|
|
|
|
|
2016-01-01 17:51:59 +01:00
|
|
|
hres = IPersistFile_QueryInterface(persist_file, &IID_IPropertySetStorage, (void **)&propsetstorage);
|
|
|
|
ok(hres == S_OK, "Unable to get an IPropertySetStorage, hr=0x%x\n", hres);
|
|
|
|
|
|
|
|
hres = IPropertySetStorage_Open(propsetstorage, &FMTID_Intshcut, STGM_READ | STGM_SHARE_EXCLUSIVE, &propstorage);
|
|
|
|
ok(hres == S_OK, "Unable to get an IPropertyStorage for reading, hr=0x%x\n", hres);
|
|
|
|
|
|
|
|
ps.ulKind = PRSPEC_PROPID;
|
|
|
|
U(ps).propid = PID_IS_ICONFILE;
|
|
|
|
v.vt = VT_NULL;
|
|
|
|
hres = IPropertyStorage_ReadMultiple(propstorage, 1, &ps, &v);
|
|
|
|
ok(hres == S_FALSE, "got 0x%08x\n", hres);
|
|
|
|
ok(v.vt == VT_EMPTY, "got %d\n", v.vt);
|
|
|
|
|
|
|
|
ps.ulKind = PRSPEC_PROPID;
|
|
|
|
U(ps).propid = PID_IS_ICONINDEX;
|
|
|
|
v.vt = VT_EMPTY;
|
|
|
|
hres = IPropertyStorage_ReadMultiple(propstorage, 1, &ps, &v);
|
|
|
|
ok(hres == S_FALSE, "got 0x%08x\n", hres);
|
|
|
|
ok(v.vt == VT_EMPTY, "got %d\n", v.vt);
|
|
|
|
|
|
|
|
IPropertyStorage_Release(propstorage);
|
|
|
|
IPropertySetStorage_Release(propsetstorage);
|
|
|
|
|
2011-04-12 13:27:55 +02:00
|
|
|
IPersistFile_Release(persist_file);
|
|
|
|
DeleteFileW(file_path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-03 11:18:26 +02:00
|
|
|
static void test_SetURLFlags(void)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IUniformResourceLocatorA *urlA;
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_InternetShortcut, NULL, CLSCTX_ALL, &IID_IUniformResourceLocatorA, (void**)&urlA);
|
2011-04-08 11:58:32 +02:00
|
|
|
ok(hr == S_OK, "Could not create InternetShortcut object: %08x\n", hr);
|
2008-08-03 11:18:26 +02:00
|
|
|
|
2011-04-08 11:59:43 +02:00
|
|
|
check_string_transform(urlA, "somerandomstring", 0, NULL, TRUE);
|
|
|
|
check_string_transform(urlA, "www.winehq.org", 0, NULL, TRUE);
|
2008-08-03 11:18:26 +02:00
|
|
|
|
2011-04-08 11:59:43 +02:00
|
|
|
check_string_transform(urlA, "www.winehq.org", IURL_SETURL_FL_GUESS_PROTOCOL, "http://www.winehq.org/", FALSE);
|
|
|
|
check_string_transform(urlA, "ftp.winehq.org", IURL_SETURL_FL_GUESS_PROTOCOL, "ftp://ftp.winehq.org/", FALSE);
|
2011-04-08 11:58:32 +02:00
|
|
|
|
|
|
|
urlA->lpVtbl->Release(urlA);
|
2008-08-03 11:18:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void test_InternetShortcut(void)
|
|
|
|
{
|
2011-04-08 11:58:32 +02:00
|
|
|
IUniformResourceLocatorA *url;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = CoCreateInstance(&CLSID_InternetShortcut, NULL, CLSCTX_ALL, &IID_IUniformResourceLocatorA, (void**)&url);
|
2011-08-03 12:45:42 +02:00
|
|
|
ok(hres == S_OK, "Could not create CLSID_InternetShortcut instance: %08x\n", hres);
|
|
|
|
if(FAILED(hres))
|
2011-04-08 11:58:32 +02:00
|
|
|
return;
|
2015-06-21 08:36:39 +02:00
|
|
|
url->lpVtbl->Release(url);
|
2011-04-08 11:58:32 +02:00
|
|
|
|
|
|
|
test_Aggregability();
|
|
|
|
test_QueryInterface();
|
|
|
|
test_NullURLs();
|
|
|
|
test_SetURLFlags();
|
|
|
|
test_ReadAndWriteProperties();
|
2011-04-12 13:27:55 +02:00
|
|
|
test_Load();
|
2008-08-03 11:18:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
START_TEST(intshcut)
|
|
|
|
{
|
|
|
|
OleInitialize(NULL);
|
2011-04-08 11:58:32 +02:00
|
|
|
|
2011-08-03 12:45:42 +02:00
|
|
|
test_InternetShortcut();
|
2011-04-08 11:58:32 +02:00
|
|
|
|
2008-08-03 11:18:26 +02:00
|
|
|
OleUninitialize();
|
|
|
|
}
|