include: Use the hard-float calling convention for Windows APIs on ARM
[wine.git] / dlls / packager / tests / oleobj.c
blob1f81cb5404467099ac0325b3f2e6174e94f9f3e4
1 /*
2 * Copyright 2014 Andrew Eikum for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #define COBJMACROS
21 #include <initguid.h>
22 #include <olectl.h>
24 #include "wine/test.h"
26 DEFINE_GUID(CLSID_Package, 0xf20da720, 0xc02f, 0x11ce, 0x92,0x7b, 0x08,0x00,0x09,0x5a,0xe3,0x40);
27 DEFINE_GUID(CLSID_Package_Alt, 0x0003000C, 0x0000, 0x0000, 0xC0,0x00, 0x00,0x00,0x00,0x00,0x00,0x46);
29 static HRESULT WINAPI ole10native_stream_QueryInterface(IStream* This, REFIID riid,
30 void **ppvObject)
32 ok(0, "queryinterface\n");
33 return E_NOTIMPL;
36 static ULONG WINAPI ole10native_stream_AddRef(IStream* This)
38 return 2;
41 static ULONG WINAPI ole10native_stream_Release(IStream* This)
43 return 1;
46 static UINT offs = 0;
48 static HRESULT WINAPI ole10native_stream_Read(IStream* This, void *pv, ULONG cb,
49 ULONG *pcbRead)
51 ULONG to_read;
53 static BYTE data[] = {
54 0xa5, 0x00, 0x00, 0x00, /* total size */
55 0x02, 0x00, /* ?? */
56 'l','a','b','e','l','.','t','x','t',0, /* label? */
57 'f','i','l','e','n','a','m','e','.','t','x','t',0, /* original filename? */
58 0x00, 0x00, /* ?? */
59 0x03, 0x00, /* ?? */
60 0x10, 0x00, 0x00, 0x00, /* ASCIIZ filename size */
61 'C',':','\\','f','i','l','e','n','a','m','e','2','.','t','x','t', /* ASCIIZ filename */
62 0x0a, 0x00, 0x00, 0x00, /* payload size */
63 's','o','m','e',' ','t','e','x','t','\n', /* payload */
64 0x10, 0x00, 0x00, 0x00, /* WCHAR filename size */
65 'C',0,':',0,'\\',0,'f',0,'i',0,'l',0,'e',0,'n',0,'a',0,'m',0,'e',0,'3',0,'.',0,'t',0,'x',0,'t',0, /* WCHAR filename */
66 0x0d, 0x00, 0x00, 0x00, /* another filename size */
67 'f',0,'i',0,'l',0,'e',0,'n',0,'a',0,'m',0,'e',0,'4',0,'.',0,'t',0,'x',0,'t',0, /* another filename */
68 0x10, 0x00, 0x00, 0x00, /* another filename size */
69 'C',0,':',0,'\\',0,'f',0,'i',0,'l',0,'e',0,'n',0,'a',0,'m',0,'e',0,'5',0,'.',0,'t',0,'x',0,'t',0, /* another filename */
72 to_read = min(sizeof(data) - offs, cb);
74 memcpy(pv, data + offs, to_read);
75 if(pcbRead)
76 *pcbRead = to_read;
78 offs += to_read;
80 return cb == to_read ? S_OK : S_FALSE;
83 static HRESULT WINAPI ole10native_stream_Write(IStream* This, const void *pv,
84 ULONG cb, ULONG *pcbWritten)
86 ok(0, "write\n");
87 return E_NOTIMPL;
90 static HRESULT WINAPI ole10native_stream_Seek(IStream* This, LARGE_INTEGER dlibMove,
91 DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
93 if(dwOrigin == STREAM_SEEK_CUR)
94 offs += dlibMove.u.LowPart;
95 else if(dwOrigin == STREAM_SEEK_SET)
96 offs = dlibMove.u.LowPart;
98 if(plibNewPosition){
99 plibNewPosition->u.HighPart = 0;
100 plibNewPosition->u.LowPart = offs;
103 return S_OK;
106 static HRESULT WINAPI ole10native_stream_SetSize(IStream* This,
107 ULARGE_INTEGER libNewSize)
109 ok(0, "setsize\n");
110 return E_NOTIMPL;
113 static HRESULT WINAPI ole10native_stream_CopyTo(IStream* This, IStream *pstm,
114 ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
116 ok(0, "copyto\n");
117 return E_NOTIMPL;
120 static HRESULT WINAPI ole10native_stream_Commit(IStream* This, DWORD grfCommitFlags)
122 ok(0, "commit\n");
123 return E_NOTIMPL;
126 static HRESULT WINAPI ole10native_stream_Revert(IStream* This)
128 ok(0, "revert\n");
129 return E_NOTIMPL;
132 static HRESULT WINAPI ole10native_stream_LockRegion(IStream* This,
133 ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
135 ok(0, "lockregion\n");
136 return E_NOTIMPL;
139 static HRESULT WINAPI ole10native_stream_UnlockRegion(IStream* This,
140 ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
142 ok(0, "unlockregion\n");
143 return E_NOTIMPL;
146 static HRESULT WINAPI ole10native_stream_Stat(IStream* This, STATSTG *pstatstg,
147 DWORD grfStatFlag)
149 ok(0, "stat\n");
150 return E_NOTIMPL;
153 static HRESULT WINAPI ole10native_stream_Clone(IStream* This, IStream **ppstm)
155 ok(0, "clone\n");
156 return E_NOTIMPL;
159 static IStreamVtbl ole10native_stream_vtbl = {
160 ole10native_stream_QueryInterface,
161 ole10native_stream_AddRef,
162 ole10native_stream_Release,
163 ole10native_stream_Read,
164 ole10native_stream_Write,
165 ole10native_stream_Seek,
166 ole10native_stream_SetSize,
167 ole10native_stream_CopyTo,
168 ole10native_stream_Commit,
169 ole10native_stream_Revert,
170 ole10native_stream_LockRegion,
171 ole10native_stream_UnlockRegion,
172 ole10native_stream_Stat,
173 ole10native_stream_Clone
176 static IStream ole10native_stream = {
177 &ole10native_stream_vtbl
180 static HRESULT WINAPI stg_QueryInterface(IStorage* This, REFIID riid,
181 void **ppvObject)
183 ok(0, "queryinterface: %s\n", wine_dbgstr_guid(riid));
185 if(IsEqualIID(riid, &IID_IUnknown) ||
186 IsEqualIID(riid, &IID_IStorage)){
187 *ppvObject = This;
188 return S_OK;
191 return E_NOINTERFACE;
194 static ULONG WINAPI stg_AddRef(IStorage* This)
196 return 2;
199 static ULONG WINAPI stg_Release(IStorage* This)
201 return 1;
204 static HRESULT WINAPI stg_CreateStream(IStorage* This, LPCOLESTR pwcsName,
205 DWORD grfMode, DWORD reserved1, DWORD reserved2, IStream **ppstm)
207 return E_NOTIMPL;
210 static HRESULT WINAPI stg_OpenStream(IStorage* This, LPCOLESTR pwcsName,
211 void *reserved1, DWORD grfMode, DWORD reserved2, IStream **ppstm)
213 static const WCHAR ole10NativeW[] = {1,'O','l','e','1','0','N','a','t','i','v','e',0};
215 if(lstrcmpW(pwcsName, ole10NativeW))
216 return STG_E_FILENOTFOUND;
218 *ppstm = &ole10native_stream;
220 return S_OK;
223 static HRESULT WINAPI stg_CreateStorage(IStorage* This, LPCOLESTR pwcsName,
224 DWORD grfMode, DWORD dwStgFmt, DWORD reserved2, IStorage **ppstg)
226 ok(0, "createstorage\n");
227 return E_NOTIMPL;
230 static HRESULT WINAPI stg_OpenStorage(IStorage* This, LPCOLESTR pwcsName,
231 IStorage *pstgPriority, DWORD grfMode, SNB snbExclude, DWORD reserved,
232 IStorage **ppstg)
234 ok(0, "openstorage: %s\n", wine_dbgstr_w(pwcsName));
235 return E_NOTIMPL;
238 static HRESULT WINAPI stg_CopyTo(IStorage* This, DWORD ciidExclude,
239 const IID *rgiidExclude, SNB snbExclude, IStorage *pstgDest)
241 ok(0, "copyto\n");
242 return E_NOTIMPL;
245 static HRESULT WINAPI stg_MoveElementTo(IStorage* This, LPCOLESTR pwcsName,
246 IStorage *pstgDest, LPCOLESTR pwcsNewName, DWORD grfFlags)
248 ok(0, "moveelem\n");
249 return E_NOTIMPL;
252 static HRESULT WINAPI stg_Commit(IStorage* This, DWORD grfCommitFlags)
254 ok(0, "commit\n");
255 return E_NOTIMPL;
258 static HRESULT WINAPI stg_Revert(IStorage* This)
260 ok(0, "revert\n");
261 return E_NOTIMPL;
264 static HRESULT WINAPI stg_EnumElements(IStorage* This, DWORD reserved1,
265 void *reserved2, DWORD reserved3, IEnumSTATSTG **ppenum)
267 ok(0, "enumelem\n");
268 return E_NOTIMPL;
271 static HRESULT WINAPI stg_DestroyElement(IStorage* This, LPCOLESTR pwcsName)
273 ok(0, "destroyelem\n");
274 return E_NOTIMPL;
277 static HRESULT WINAPI stg_RenameElement(IStorage* This, LPCOLESTR pwcsOldName,
278 LPCOLESTR pwcsNewName)
280 ok(0, "renamelem\n");
281 return E_NOTIMPL;
284 static HRESULT WINAPI stg_SetElementTimes(IStorage* This, LPCOLESTR pwcsName,
285 const FILETIME *pctime, const FILETIME *patime, const FILETIME *pmtime)
287 ok(0, "setelem\n");
288 return E_NOTIMPL;
291 static HRESULT WINAPI stg_SetClass(IStorage* This, REFCLSID clsid)
293 ok(0, "setclass\n");
294 return E_NOTIMPL;
297 static HRESULT WINAPI stg_SetStateBits(IStorage* This, DWORD grfStateBits,
298 DWORD grfMask)
300 ok(0, "setstate\n");
301 return E_NOTIMPL;
304 static HRESULT WINAPI stg_Stat(IStorage* This, STATSTG *pstatstg, DWORD grfStatFlag)
306 memset(pstatstg, 0, sizeof(*pstatstg));
307 pstatstg->clsid = CLSID_Package;
308 pstatstg->type = STGTY_STORAGE;
309 return S_OK;
312 static IStorageVtbl stg_vtbl = {
313 stg_QueryInterface,
314 stg_AddRef,
315 stg_Release,
316 stg_CreateStream,
317 stg_OpenStream,
318 stg_CreateStorage,
319 stg_OpenStorage,
320 stg_CopyTo,
321 stg_MoveElementTo,
322 stg_Commit,
323 stg_Revert,
324 stg_EnumElements,
325 stg_DestroyElement,
326 stg_RenameElement,
327 stg_SetElementTimes,
328 stg_SetClass,
329 stg_SetStateBits,
330 stg_Stat,
333 static IStorage stg = {
334 &stg_vtbl
337 static HRESULT WINAPI clientsite_QueryInterface(IOleClientSite* This,
338 REFIID riid, void **ppvObject)
340 ok(0, "query interface\n");
341 return E_NOINTERFACE;
344 static ULONG WINAPI clientsite_AddRef(IOleClientSite* This)
346 return 2;
349 static ULONG WINAPI clientsite_Release(IOleClientSite* This)
351 return 1;
354 static HRESULT WINAPI clientsite_SaveObject(IOleClientSite* This)
356 ok(0, "saveobject\n");
357 return E_NOTIMPL;
360 static HRESULT WINAPI clientsite_GetMoniker(IOleClientSite* This,
361 DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk)
363 ok(0, "getmoniker\n");
364 return E_NOTIMPL;
367 static HRESULT WINAPI clientsite_GetContainer(IOleClientSite* This,
368 IOleContainer **ppContainer)
370 ok(0, "getcontainer\n");
371 return E_NOTIMPL;
374 static HRESULT WINAPI clientsite_ShowObject(IOleClientSite* This)
376 ok(0, "showobject\n");
377 return E_NOTIMPL;
380 static HRESULT WINAPI clientsite_OnShowWindow(IOleClientSite* This,
381 BOOL fShow)
383 ok(0, "onshowwindow\n");
384 return E_NOTIMPL;
387 static HRESULT WINAPI clientsite_RequestNewObjectLayout(IOleClientSite* This)
389 ok(0, "requestnewobjectlayout\n");
390 return E_NOTIMPL;
393 static IOleClientSiteVtbl clientsite_vtbl = {
394 clientsite_QueryInterface,
395 clientsite_AddRef,
396 clientsite_Release,
397 clientsite_SaveObject,
398 clientsite_GetMoniker,
399 clientsite_GetContainer,
400 clientsite_ShowObject,
401 clientsite_OnShowWindow,
402 clientsite_RequestNewObjectLayout
405 static IOleClientSite clientsite = {
406 &clientsite_vtbl
409 static void test_packager(void)
411 IOleObject *oleobj;
412 IPersistStorage *persist;
413 DWORD len, bytes_read, status;
414 HRESULT hr;
415 HANDLE file;
416 WCHAR filename[MAX_PATH];
417 char contents[11];
418 BOOL br, extended = FALSE;
420 static const WCHAR filename3W[] = {'f','i','l','e','n','a','m','e','3','.','t','x','t',0};
422 hr = CoCreateInstance(&CLSID_Package, NULL, CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER,
423 &IID_IOleObject, (void**)&oleobj);
424 ok(hr == S_OK ||
425 hr == REGDB_E_CLASSNOTREG, "CoCreateInstance(CLSID_Package) failed: %08x\n", hr);
426 if(hr == S_OK){
427 IOleObject_Release(oleobj);
428 /* older OSes store temporary files in obscure locations, so don't run
429 * the full tests on them */
430 extended = TRUE;
431 }else
432 win_skip("Older OS doesn't support modern packager\n");
434 hr = CoCreateInstance(&CLSID_Package_Alt, NULL, CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER,
435 &IID_IOleObject, (void**)&oleobj);
436 ok(hr == S_OK, "CoCreateInstance(CLSID_Package_Alt) failed: %08x\n", hr);
438 hr = IOleObject_SetClientSite(oleobj, NULL);
439 ok(hr == S_OK, "SetClientSite failed: %08x\n", hr);
441 hr = IOleObject_SetClientSite(oleobj, &clientsite);
442 ok(hr == S_OK, "SetClientSite failed: %08x\n", hr);
444 hr = IOleObject_GetMiscStatus(oleobj, DVASPECT_CONTENT, NULL);
445 ok(hr == E_INVALIDARG, "GetMiscStatus failed: %08x\n", hr);
447 hr = IOleObject_GetMiscStatus(oleobj, DVASPECT_CONTENT, &status);
448 ok(hr == S_OK, "GetMiscStatus failed: %08x\n", hr);
449 ok(status == OLEMISC_ONLYICONIC ||
450 status == OLEMISC_CANTLINKINSIDE /* winxp */,
451 "Got wrong DVASPECT_CONTENT status: 0x%x\n", status);
453 hr = IOleObject_QueryInterface(oleobj, &IID_IPersistStorage, (void**)&persist);
454 ok(hr == S_OK, "QueryInterface(IPersistStorage) failed: %08x\n", hr);
456 hr = IPersistStorage_Load(persist, &stg);
457 ok(hr == S_OK, "Load failed: %08x\n", hr);
459 if(extended){
460 len = GetTempPathW(sizeof(filename) / sizeof(*filename), filename);
461 lstrcpyW(filename + len, filename3W);
463 file = CreateFileW(filename, GENERIC_READ, 0, NULL, OPEN_EXISTING,
464 FILE_ATTRIBUTE_NORMAL, NULL);
465 ok(file != INVALID_HANDLE_VALUE, "Couldn't find temporary file %s: %u\n",
466 wine_dbgstr_w(filename), GetLastError());
468 br = ReadFile(file, contents, sizeof(contents), &bytes_read, NULL);
469 ok(br == TRUE, "ReadFile failed\n");
470 ok(bytes_read == 10, "Got wrong file size: %u\n", bytes_read);
471 ok(!memcmp(contents, "some text\n", 10), "Got wrong file contents\n");
473 CloseHandle(file);
476 hr = IOleObject_Close(oleobj, OLECLOSE_NOSAVE);
477 ok(hr == S_OK, "Close failed: %08x\n", hr);
479 if(extended){
480 file = CreateFileW(filename, GENERIC_READ, 0, NULL, OPEN_EXISTING,
481 FILE_ATTRIBUTE_NORMAL, NULL);
482 ok(file != INVALID_HANDLE_VALUE, "Temporary file shouldn't be deleted\n");
483 CloseHandle(file);
486 IPersistStorage_Release(persist);
487 IOleObject_Release(oleobj);
489 if(extended){
490 file = CreateFileW(filename, GENERIC_READ, 0, NULL, OPEN_EXISTING,
491 FILE_ATTRIBUTE_NORMAL, NULL);
492 ok(file == INVALID_HANDLE_VALUE, "Temporary file should be deleted\n");
496 START_TEST(oleobj)
498 CoInitialize(NULL);
500 test_packager();
502 CoUninitialize();