78 ok(
hr ==
S_OK,
"could not create instance of CLSID_InternetShortcut with IID_IUnknown, hr = 0x%lx\n",
hr);
83 ok(
hr ==
S_OK,
"could not create instance of CLSID_InternetShortcut with IID_IUniformResourceLocatorA, hr = 0x%lx\n",
hr);
97 hr = IUnknown_QueryInterface(
pUnknown,
riid, (
void**)&newInterface);
100 IUnknown_Release(newInterface);
109 ok(
hr ==
S_OK,
"Could not create InternetShortcut object: %08lx\n",
hr);
117#define test_shortcut_url(a,b) _test_shortcut_url(__LINE__,a,b)
120 IUniformResourceLocatorA *locator_a;
124 hres = IUnknown_QueryInterface(unk, &IID_IUniformResourceLocatorA, (
void**)&locator_a);
125 ok_(__FILE__,
line)(
hres ==
S_OK,
"Could not get IUniformResourceLocatorA iface: %08lx\n",
hres);
127 hres = locator_a->lpVtbl->GetURL(locator_a, &url_a);
129 ok_(__FILE__,
line)(!
strcmp(url_a, exurl),
"unexpected URL, got %s, expected %s\n", url_a, exurl);
132 IUnknown_Release((
IUnknown*)locator_a);
135#define check_string_transform(a,b,c,d,e) _check_string_transform(__LINE__,a,b,c,d,e)
147 output = (
void*)0xdeadbeef;
148 hr = urlA->lpVtbl->GetURL(urlA, &output);
154 ok_(__FILE__,
line)(!
lstrcmpA(output, expectedOutput),
"unexpected URL change %s -> %s (expected %s)\n",
155 input, output, expectedOutput);
160 ok_(__FILE__,
line)(!output,
"GetUrl returned %s\n", output);
171 IUniformResourceLocatorA *urlA;
172 IUniformResourceLocatorA *urlAFromFile;
174 static WCHAR iconPath[] =
L"file:///C:/arbitrary/icon/path";
175 char testurl[] =
"http://some/bogus/url.html";
176 PROPVARIANT pv[2], pvread[2];
178 ps[0].ulKind = PRSPEC_PROPID;
180 ps[1].ulKind = PRSPEC_PROPID;
184 pv[0].pwszVal = iconPath;
186 pv[1].lVal = iconIndex;
190 lstrcatW(fileNameW,
L"testshortcut.url");
192 hr =
CoCreateInstance(&CLSID_InternetShortcut,
NULL, CLSCTX_ALL, &IID_IUniformResourceLocatorA, (
void**)&urlA);
193 ok(
hr ==
S_OK,
"Could not create CLSID_InternetShortcut instance: %08lx\n",
hr);
201 hr = urlA->lpVtbl->SetURL(urlA, testurl, 0);
202 ok(
hr ==
S_OK,
"Failed to set a URL. hr=0x%lx\n",
hr);
206 ok(
hr ==
S_OK,
"Failed to get the IPersistFile for writing. hr=0x%lx\n",
hr);
208 hr = IPersistFile_Save(pf, fileNameW,
TRUE);
209 ok(
hr ==
S_OK,
"Failed to save via IPersistFile. hr=0x%lx\n",
hr);
211 IPersistFile_Release(pf);
213 hr = urlA->lpVtbl->
QueryInterface(urlA, &IID_IPropertySetStorage, (
void **) &pPropSetStg);
214 ok(
hr ==
S_OK,
"Unable to get an IPropertySetStorage, hr=0x%lx\n",
hr);
217 ok(
hr ==
S_OK,
"Unable to get an IPropertyStorage for writing, hr=0x%lx\n",
hr);
219 hr = IPropertyStorage_WriteMultiple(pPropStgWrite, 2, ps, pv, 0);
220 ok(
hr ==
S_OK,
"Unable to set properties, hr=0x%lx\n",
hr);
222 memset(pvread, 0,
sizeof(pvread));
223 hr = IPropertyStorage_ReadMultiple(pPropStgWrite, 2, ps, pvread);
224 ok(
hr ==
S_OK,
"Unable to read properties, hr=0x%lx\n",
hr);
225 ok(pvread[1].
vt ==
VT_I4,
"got %d\n", pvread[1].
vt);
226 ok(pvread[1].lVal == iconIndex,
"Read wrong icon index: %d\n", pvread[1].iVal);
228 ok(
lstrcmpW(pvread[0].pwszVal, iconPath) == 0,
"Wrong icon path read: %s\n",
wine_dbgstr_w(pvread[0].pwszVal));
232 hr = IPropertyStorage_Commit(pPropStgWrite, STGC_DEFAULT);
233 ok(
hr ==
S_OK,
"Failed to commit properties, hr=0x%lx\n",
hr);
235 pPropStgWrite->lpVtbl->
Release(pPropStgWrite);
238 hr = IPropertySetStorage_Open(pPropSetStg, &FMTID_Intshcut,
STGM_WRITE, &pPropStgWrite);
239 ok(
hr ==
S_OK,
"Unable to get an IPropertyStorage for writing, hr=0x%lx\n",
hr);
243 memset(pvread, 0,
sizeof(pvread));
244 hr = IPropertyStorage_ReadMultiple(pPropStgWrite, 2, ps, pvread);
245 ok(
hr ==
S_OK,
"Unable to read properties, hr=0x%lx\n",
hr);
246 ok(pvread[1].
vt ==
VT_I4,
"got %d\n", pvread[1].
vt);
247 ok(pvread[1].lVal == iconIndex,
"Read wrong icon index: %d\n", pvread[1].iVal);
249 ok(
lstrcmpW(pvread[0].pwszVal, iconPath) == 0,
"Wrong icon path read: %s\n",
wine_dbgstr_w(pvread[0].pwszVal));
253 IPropertyStorage_Release(pPropStgWrite);
255 urlA->lpVtbl->Release(urlA);
256 IPropertySetStorage_Release(pPropSetStg);
259 hr =
CoCreateInstance(&CLSID_InternetShortcut,
NULL, CLSCTX_ALL, &IID_IUniformResourceLocatorA, (
void**)&urlAFromFile);
260 ok(
hr ==
S_OK,
"Could not create CLSID_InternetShortcut instance: %08lx\n",
hr);
265 PROPVARIANT pvread[2];
271 ok(
hr ==
S_OK,
"Failed to get the IPersistFile for reading. hr=0x%lx\n",
hr);
273 hr = IPersistFile_Load(pf, fileNameW, 0);
274 ok(
hr ==
S_OK,
"Failed to load via IPersistFile. hr=0x%lx\n",
hr);
275 IPersistFile_Release(pf);
278 hr = urlAFromFile->lpVtbl->GetURL(urlAFromFile, &
url);
279 ok(
hr ==
S_OK,
"Unable to get url from file, hr=0x%lx\n",
hr);
283 hr = urlAFromFile->lpVtbl->
QueryInterface(urlAFromFile, &IID_IPropertySetStorage, (
void **) &pPropSetStg);
284 ok(
hr ==
S_OK,
"Unable to get an IPropertySetStorage, hr=0x%lx\n",
hr);
287 ok(
hr ==
S_OK,
"Unable to get an IPropertyStorage for reading, hr=0x%lx\n",
hr);
289 memset(pvread, 0,
sizeof(pvread));
290 hr = IPropertyStorage_ReadMultiple(pPropStgRead, 2, ps, pvread);
293 ok(
hr ==
S_OK,
"Unable to read properties, hr=0x%lx\n",
hr);
294 ok(pvread[1].
vt ==
VT_I4,
"got %d\n", pvread[1].
vt);
295 ok(pvread[1].lVal == iconIndex,
"Read wrong icon index: %d\n", pvread[1].iVal);
297 ok(
lstrcmpW(pvread[0].pwszVal, iconPath) == 0,
"Wrong icon path read: %s\n",
wine_dbgstr_w(pvread[0].pwszVal));
302 hr = IPropertyStorage_WriteMultiple(pPropStgRead, 2, ps, pv, 0);
305 IPropertyStorage_Release(pPropStgRead);
306 IPropertySetStorage_Release(pPropSetStg);
307 urlAFromFile->lpVtbl->Release(urlAFromFile);
316 IUniformResourceLocatorA *urlA;
318 hr =
CoCreateInstance(&CLSID_InternetShortcut,
NULL, CLSCTX_ALL, &IID_IUniformResourceLocatorA, (
void**)&urlA);
319 ok(
hr ==
S_OK,
"Could not create InternetShortcut object: %08lx\n",
hr);
321 hr = urlA->lpVtbl->GetURL(urlA, &
url);
322 ok(
hr ==
S_FALSE,
"getting uninitialized URL unexpectedly failed, hr=0x%lx\n",
hr);
323 ok(
url ==
NULL,
"uninitialized URL is not NULL but %s\n",
url);
325 hr = urlA->lpVtbl->SetURL(urlA,
NULL, 0);
326 ok(
hr ==
S_OK,
"setting NULL URL unexpectedly failed, hr=0x%lx\n",
hr);
328 hr = urlA->lpVtbl->GetURL(urlA, &
url);
329 ok(
hr ==
S_FALSE,
"getting NULL URL unexpectedly failed, hr=0x%lx\n",
hr);
330 ok(
url ==
NULL,
"URL unexpectedly not NULL but %s\n",
url);
332 urlA->lpVtbl->Release(urlA);
341 {
"[InternetShortcut]\n"
342 "URL=http://www.winehq.org/\n"
345 "[{000214A0-0000-0000-C000-000000000046}]\n"
348 "http://www.winehq.org/"
379 ok(
hres ==
S_OK,
"Could not create InternetShortcut instance: %08lx\n",
hres);
386 hres = IPersistFile_QueryInterface(persist_file, &IID_IPropertySetStorage, (
void **)&propsetstorage);
387 ok(
hres ==
S_OK,
"Unable to get an IPropertySetStorage, hr=0x%lx\n",
hres);
390 ok(
hres ==
S_OK,
"Unable to get an IPropertyStorage for reading, hr=0x%lx\n",
hres);
392 ps.ulKind = PRSPEC_PROPID;
395 hres = IPropertyStorage_ReadMultiple(propstorage, 1, &ps, &
v);
399 ps.ulKind = PRSPEC_PROPID;
402 hres = IPropertyStorage_ReadMultiple(propstorage, 1, &ps, &
v);
406 IPropertyStorage_Release(propstorage);
407 IPropertySetStorage_Release(propsetstorage);
409 IPersistFile_Release(persist_file);
417 IUniformResourceLocatorA *urlA;
419 hr =
CoCreateInstance(&CLSID_InternetShortcut,
NULL, CLSCTX_ALL, &IID_IUniformResourceLocatorA, (
void**)&urlA);
420 ok(
hr ==
S_OK,
"Could not create InternetShortcut object: %08lx\n",
hr);
428 urlA->lpVtbl->Release(urlA);
433 IUniformResourceLocatorA *
url;
437 ok(
hres ==
S_OK,
"Could not create CLSID_InternetShortcut instance: %08lx\n",
hres);
440 url->lpVtbl->Release(
url);
HRESULT WINAPI PropVariantClear(PROPVARIANT *pvar)
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, IUnknown *outer, DWORD cls_context, REFIID riid, void **obj)
void WINAPI CoTaskMemFree(void *ptr)
#define INVALID_HANDLE_VALUE
#define FILE_ATTRIBUTE_NORMAL
static ULONG Unknown_Release(InternetShortcut *This)
static HRESULT Unknown_QueryInterface(InternetShortcut *This, REFIID riid, PVOID *ppvObject)
static ULONG Unknown_AddRef(InternetShortcut *This)
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
BOOL WINAPI WriteFile(_In_ HANDLE hFile, _In_reads_bytes_opt_(nNumberOfBytesToWrite) LPCVOID lpBuffer, _In_ DWORD nNumberOfBytesToWrite, _Out_opt_ LPDWORD lpNumberOfBytesWritten, _Inout_opt_ LPOVERLAPPED lpOverlapped)
DWORD WINAPI GetTempPathW(IN DWORD count, OUT LPWSTR path)
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
int WINAPI lstrcmpA(LPCSTR str1, LPCSTR str2)
static REFPROPVARIANT PROPVAR_CHANGE_FLAGS VARTYPE vt
_ACRTIMP size_t __cdecl strlen(const char *)
_ACRTIMP int __cdecl strcmp(const char *, const char *)
HRESULT WINAPI DECLSPEC_HOTPATCH OleInitialize(LPVOID reserved)
void WINAPI DECLSPEC_HOTPATCH OleUninitialize(void)
GLenum GLenum GLenum input
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
@ IURL_SETURL_FL_GUESS_PROTOCOL
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
#define todo_wine_if(is_todo)
#define check_string_transform(a, b, c, d, e)
static void test_Aggregability(void)
static IUnknownVtbl unknownVtbl
static void test_ReadAndWriteProperties(void)
static void test_InternetShortcut(void)
static void test_QueryInterface(void)
#define test_shortcut_url(a, b)
static void test_NullURLs(void)
static void test_SetURLFlags(void)
static void _test_shortcut_url(unsigned line, IUnknown *unk, const char *exurl)
static void _check_string_transform(unsigned line, IUniformResourceLocatorA *urlA, LPCSTR input, DWORD flags, LPCSTR expectedOutput, BOOL is_todo)
static const load_test_t load_tests[]
static void can_query_interface(IUnknown *pUnknown, REFIID riid)
static void test_Load(void)
#define STGM_SHARE_EXCLUSIVE
const GUID IID_IPersistFile
#define IsEqualGUID(rguid1, rguid2)
static __inline const char * wine_dbgstr_guid(const GUID *id)
TCHAR file_path[MAX_PATH]
#define CLASS_E_NOAGGREGATION
#define STG_E_ACCESSDENIED