1c2c66affSColin Finck /*
2c2c66affSColin Finck  * Object Linking and Embedding Tests
3c2c66affSColin Finck  *
4c2c66affSColin Finck  * Copyright 2005 Robert Shearman
5b44b1afbSAmine Khaldi  * Copyright 2017 Dmitry Timoshkov
6c2c66affSColin Finck  *
7c2c66affSColin Finck  * This library is free software; you can redistribute it and/or
8c2c66affSColin Finck  * modify it under the terms of the GNU Lesser General Public
9c2c66affSColin Finck  * License as published by the Free Software Foundation; either
10c2c66affSColin Finck  * version 2.1 of the License, or (at your option) any later version.
11c2c66affSColin Finck  *
12c2c66affSColin Finck  * This library is distributed in the hope that it will be useful,
13c2c66affSColin Finck  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14c2c66affSColin Finck  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15c2c66affSColin Finck  * Lesser General Public License for more details.
16c2c66affSColin Finck  *
17c2c66affSColin Finck  * You should have received a copy of the GNU Lesser General Public
18c2c66affSColin Finck  * License along with this library; if not, write to the Free Software
19c2c66affSColin Finck  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20c2c66affSColin Finck  */
21c2c66affSColin Finck 
2266f35ef8SAmine Khaldi #define COBJMACROS
2366f35ef8SAmine Khaldi #define CONST_VTABLE
2466f35ef8SAmine Khaldi #define WIN32_LEAN_AND_MEAN
25c2c66affSColin Finck 
2666f35ef8SAmine Khaldi #include <stdarg.h>
2766f35ef8SAmine Khaldi 
2866f35ef8SAmine Khaldi #include "windef.h"
2966f35ef8SAmine Khaldi #include "winbase.h"
3066f35ef8SAmine Khaldi #include "wingdi.h"
3166f35ef8SAmine Khaldi #include "objbase.h"
3266f35ef8SAmine Khaldi #include "shlguid.h"
3366f35ef8SAmine Khaldi 
3466f35ef8SAmine Khaldi #include "wine/test.h"
3566f35ef8SAmine Khaldi 
36c2c66affSColin Finck #define ok_ole_success(hr, func) ok(hr == S_OK, func " failed with error 0x%08x\n", hr)
37c2c66affSColin Finck 
38c2c66affSColin Finck #define DEFINE_EXPECT(func) \
39c2c66affSColin Finck     static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
40c2c66affSColin Finck 
41c2c66affSColin Finck #define SET_EXPECT(func) \
42c2c66affSColin Finck     expect_ ## func = TRUE
43c2c66affSColin Finck 
44c2c66affSColin Finck #define CHECK_EXPECT2(func) \
45c2c66affSColin Finck     do { \
46c2c66affSColin Finck         ok(expect_ ##func, "unexpected call " #func "\n"); \
47c2c66affSColin Finck         called_ ## func = TRUE; \
48c2c66affSColin Finck     }while(0)
49c2c66affSColin Finck 
50c2c66affSColin Finck #define CHECK_EXPECT(func) \
51c2c66affSColin Finck     do { \
52c2c66affSColin Finck         CHECK_EXPECT2(func); \
53c2c66affSColin Finck         expect_ ## func = FALSE; \
54c2c66affSColin Finck     }while(0)
55c2c66affSColin Finck 
56c2c66affSColin Finck #define CHECK_CALLED(func) \
57c2c66affSColin Finck     do { \
58c2c66affSColin Finck         ok(called_ ## func, "expected " #func "\n"); \
59c2c66affSColin Finck         expect_ ## func = called_ ## func = FALSE; \
60c2c66affSColin Finck     }while(0)
61c2c66affSColin Finck 
62c2c66affSColin Finck DEFINE_EXPECT(Storage_Stat);
63c2c66affSColin Finck DEFINE_EXPECT(Storage_OpenStream_CompObj);
64b44b1afbSAmine Khaldi DEFINE_EXPECT(Storage_OpenStream_OlePres);
65c2c66affSColin Finck DEFINE_EXPECT(Storage_SetClass);
66c2c66affSColin Finck DEFINE_EXPECT(Storage_CreateStream_CompObj);
67b44b1afbSAmine Khaldi DEFINE_EXPECT(Storage_CreateStream_OlePres);
68c2c66affSColin Finck DEFINE_EXPECT(Storage_OpenStream_Ole);
69b44b1afbSAmine Khaldi DEFINE_EXPECT(Storage_DestroyElement);
70b44b1afbSAmine Khaldi 
71b44b1afbSAmine Khaldi static const CLSID *Storage_SetClass_CLSID;
72b44b1afbSAmine Khaldi static int Storage_DestroyElement_limit;
73c2c66affSColin Finck 
74c2c66affSColin Finck static IPersistStorage OleObjectPersistStg;
75c2c66affSColin Finck static IOleCache *cache;
76c2c66affSColin Finck static IRunnableObject *runnable;
77c2c66affSColin Finck 
78c2c66affSColin Finck static const CLSID CLSID_WineTestOld =
79c2c66affSColin Finck { /* 9474ba1a-258b-490b-bc13-516e9239acd0 */
80c2c66affSColin Finck     0x9474ba1a,
81c2c66affSColin Finck     0x258b,
82c2c66affSColin Finck     0x490b,
83c2c66affSColin Finck     {0xbc, 0x13, 0x51, 0x6e, 0x92, 0x39, 0xac, 0xd0}
84c2c66affSColin Finck };
85c2c66affSColin Finck 
86c2c66affSColin Finck static const CLSID CLSID_WineTest =
87c2c66affSColin Finck { /* 9474ba1a-258b-490b-bc13-516e9239ace0 */
88c2c66affSColin Finck     0x9474ba1a,
89c2c66affSColin Finck     0x258b,
90c2c66affSColin Finck     0x490b,
91c2c66affSColin Finck     {0xbc, 0x13, 0x51, 0x6e, 0x92, 0x39, 0xac, 0xe0}
92c2c66affSColin Finck };
93c2c66affSColin Finck 
94c2c66affSColin Finck static const IID IID_WineTest =
95c2c66affSColin Finck { /* 9474ba1a-258b-490b-bc13-516e9239ace1 */
96c2c66affSColin Finck     0x9474ba1a,
97c2c66affSColin Finck     0x258b,
98c2c66affSColin Finck     0x490b,
99c2c66affSColin Finck     {0xbc, 0x13, 0x51, 0x6e, 0x92, 0x39, 0xac, 0xe1}
100c2c66affSColin Finck };
101c2c66affSColin Finck 
102c2c66affSColin Finck #define TEST_OPTIONAL 0x1
103c2c66affSColin Finck #define TEST_TODO     0x2
104c2c66affSColin Finck 
105c2c66affSColin Finck struct expected_method
106c2c66affSColin Finck {
107c2c66affSColin Finck     const char *method;
108c2c66affSColin Finck     unsigned int flags;
109b44b1afbSAmine Khaldi     FORMATETC fmt;
110c2c66affSColin Finck };
111c2c66affSColin Finck 
112c2c66affSColin Finck static const struct expected_method *expected_method_list;
113c2c66affSColin Finck static FORMATETC *g_expected_fetc = NULL;
114c2c66affSColin Finck 
115c2c66affSColin Finck static BOOL g_showRunnable = TRUE;
116c2c66affSColin Finck static BOOL g_isRunning = TRUE;
117c2c66affSColin Finck static HRESULT g_GetMiscStatusFailsWith = S_OK;
118c2c66affSColin Finck static HRESULT g_QIFailsWith;
119c2c66affSColin Finck 
120c2c66affSColin Finck static UINT cf_test_1, cf_test_2, cf_test_3;
121c2c66affSColin Finck 
122b44b1afbSAmine Khaldi static FORMATETC *g_dataobject_fmts;
123b44b1afbSAmine Khaldi 
124c2c66affSColin Finck /****************************************************************************
125c2c66affSColin Finck  * PresentationDataHeader
126c2c66affSColin Finck  *
127c2c66affSColin Finck  * This structure represents the header of the \002OlePresXXX stream in
128c2c66affSColin Finck  * the OLE object storage.
129c2c66affSColin Finck  */
130c2c66affSColin Finck typedef struct PresentationDataHeader
131c2c66affSColin Finck {
132c2c66affSColin Finck     /* clipformat:
133c2c66affSColin Finck      *  - standard clipformat:
134c2c66affSColin Finck      *  DWORD length = 0xffffffff;
135c2c66affSColin Finck      *  DWORD cfFormat;
136c2c66affSColin Finck      *  - or custom clipformat:
137c2c66affSColin Finck      *  DWORD length;
138c2c66affSColin Finck      *  CHAR format_name[length]; (null-terminated)
139c2c66affSColin Finck      */
140b44b1afbSAmine Khaldi     DWORD tdSize; /* This is actually a truncated DVTARGETDEVICE, if tdSize > sizeof(DWORD)
141b44b1afbSAmine Khaldi                      then there are tdSize - sizeof(DWORD) more bytes before dvAspect */
142c2c66affSColin Finck     DVASPECT dvAspect;
143c2c66affSColin Finck     DWORD lindex;
144c2c66affSColin Finck     DWORD advf;
145c2c66affSColin Finck     DWORD unknown7; /* 0 */
146c2c66affSColin Finck     DWORD dwObjectExtentX;
147c2c66affSColin Finck     DWORD dwObjectExtentY;
148c2c66affSColin Finck     DWORD dwSize;
149c2c66affSColin Finck } PresentationDataHeader;
150c2c66affSColin Finck 
15166f35ef8SAmine Khaldi #ifdef __REACTOS__
check_expected_method_fmt(const char * method_name,const FORMATETC * fmt)152b44b1afbSAmine Khaldi static inline void check_expected_method_fmt(const char *method_name, const FORMATETC *fmt)
15366f35ef8SAmine Khaldi #else
15466f35ef8SAmine Khaldi static void inline check_expected_method_fmt(const char *method_name, const FORMATETC *fmt)
15566f35ef8SAmine Khaldi #endif
156b44b1afbSAmine Khaldi {
157b44b1afbSAmine Khaldi     trace("%s\n", method_name);
158b44b1afbSAmine Khaldi     ok(expected_method_list->method != NULL, "Extra method %s called\n", method_name);
159b44b1afbSAmine Khaldi     if (!strcmp(expected_method_list->method, "WINE_EXTRA"))
160b44b1afbSAmine Khaldi     {
161b44b1afbSAmine Khaldi         todo_wine ok(0, "Too many method calls.\n");
162b44b1afbSAmine Khaldi         return;
163b44b1afbSAmine Khaldi     }
164b44b1afbSAmine Khaldi     if (expected_method_list->method)
165b44b1afbSAmine Khaldi     {
166b44b1afbSAmine Khaldi         while (expected_method_list->flags & TEST_OPTIONAL &&
167b44b1afbSAmine Khaldi                strcmp(expected_method_list->method, method_name) != 0)
168b44b1afbSAmine Khaldi             expected_method_list++;
169b44b1afbSAmine Khaldi         todo_wine_if (expected_method_list->flags & TEST_TODO)
170b44b1afbSAmine Khaldi         {
171b44b1afbSAmine Khaldi             ok(!strcmp(expected_method_list->method, method_name),
172b44b1afbSAmine Khaldi                "Expected %s to be called instead of %s\n",
173b44b1afbSAmine Khaldi                expected_method_list->method, method_name);
174b44b1afbSAmine Khaldi             if (fmt)
175b44b1afbSAmine Khaldi             {
176b44b1afbSAmine Khaldi                 ok(fmt->cfFormat == expected_method_list->fmt.cfFormat, "got cf %04x vs %04x\n",
177b44b1afbSAmine Khaldi                    fmt->cfFormat, expected_method_list->fmt.cfFormat );
178b44b1afbSAmine Khaldi                 ok(fmt->dwAspect == expected_method_list->fmt.dwAspect, "got aspect %d vs %d\n",
179b44b1afbSAmine Khaldi                    fmt->dwAspect, expected_method_list->fmt.dwAspect );
180b44b1afbSAmine Khaldi                 ok(fmt->lindex == expected_method_list->fmt.lindex, "got lindex %d vs %d\n",
181b44b1afbSAmine Khaldi                    fmt->lindex, expected_method_list->fmt.lindex );
182b44b1afbSAmine Khaldi                 ok(fmt->tymed == expected_method_list->fmt.tymed, "got tymed %d vs %d\n",
183b44b1afbSAmine Khaldi                    fmt->tymed, expected_method_list->fmt.tymed );
184b44b1afbSAmine Khaldi             }
185b44b1afbSAmine Khaldi         }
186b44b1afbSAmine Khaldi         expected_method_list++;
187b44b1afbSAmine Khaldi     }
188b44b1afbSAmine Khaldi }
189b44b1afbSAmine Khaldi 
190b44b1afbSAmine Khaldi #define CHECK_EXPECTED_METHOD(method_name) check_expected_method_fmt(method_name, NULL)
191b44b1afbSAmine Khaldi #define CHECK_EXPECTED_METHOD_FMT(method_name, fmt) check_expected_method_fmt(method_name, fmt)
192c2c66affSColin Finck 
193c2c66affSColin Finck #define CHECK_NO_EXTRA_METHODS() \
194c2c66affSColin Finck     do { \
195c2c66affSColin Finck         while (expected_method_list->flags & TEST_OPTIONAL) \
196c2c66affSColin Finck             expected_method_list++; \
197c2c66affSColin Finck         ok(!expected_method_list->method, "Method sequence starting from %s not called\n", expected_method_list->method); \
198c2c66affSColin Finck     } while (0)
199c2c66affSColin Finck 
200b44b1afbSAmine Khaldi /* 2 x 1 x 32 bpp dib. PelsPerMeter = 200x400 */
201b44b1afbSAmine Khaldi static const BYTE dib[] =
202b44b1afbSAmine Khaldi {
203b44b1afbSAmine Khaldi     0x28, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
204b44b1afbSAmine Khaldi     0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x20, 0x00,
205b44b1afbSAmine Khaldi     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
206b44b1afbSAmine Khaldi     0xc8, 0x00, 0x00, 0x00, 0x90, 0x01, 0x00, 0x00,
207b44b1afbSAmine Khaldi     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
208b44b1afbSAmine Khaldi     0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
209b44b1afbSAmine Khaldi };
210b44b1afbSAmine Khaldi 
create_dib(STGMEDIUM * med)211b44b1afbSAmine Khaldi static void create_dib( STGMEDIUM *med )
212b44b1afbSAmine Khaldi {
213b44b1afbSAmine Khaldi     void *ptr;
214b44b1afbSAmine Khaldi 
215b44b1afbSAmine Khaldi     med->tymed = TYMED_HGLOBAL;
216b44b1afbSAmine Khaldi     U(med)->hGlobal = GlobalAlloc( GMEM_MOVEABLE, sizeof(dib) );
217b44b1afbSAmine Khaldi     ptr = GlobalLock( U(med)->hGlobal );
218b44b1afbSAmine Khaldi     memcpy( ptr, dib, sizeof(dib) );
219b44b1afbSAmine Khaldi     GlobalUnlock( U(med)->hGlobal );
220b44b1afbSAmine Khaldi     med->pUnkForRelease = NULL;
221b44b1afbSAmine Khaldi }
222b44b1afbSAmine Khaldi 
create_bitmap(STGMEDIUM * med)223b44b1afbSAmine Khaldi static void create_bitmap( STGMEDIUM *med )
224b44b1afbSAmine Khaldi {
225b44b1afbSAmine Khaldi     med->tymed = TYMED_GDI;
226b44b1afbSAmine Khaldi     U(med)->hBitmap = CreateBitmap( 1, 1, 1, 1, NULL );
227b44b1afbSAmine Khaldi     med->pUnkForRelease = NULL;
228b44b1afbSAmine Khaldi }
229b44b1afbSAmine Khaldi 
create_emf(STGMEDIUM * med)230b44b1afbSAmine Khaldi static void create_emf(STGMEDIUM *med)
231b44b1afbSAmine Khaldi {
232b44b1afbSAmine Khaldi     HDC hdc = CreateEnhMetaFileW(NULL, NULL, NULL, NULL);
233b44b1afbSAmine Khaldi 
234b44b1afbSAmine Khaldi     Rectangle(hdc, 0, 0, 150, 300);
235b44b1afbSAmine Khaldi     med->tymed = TYMED_ENHMF;
236b44b1afbSAmine Khaldi     U(med)->hEnhMetaFile = CloseEnhMetaFile(hdc);
237b44b1afbSAmine Khaldi     med->pUnkForRelease = NULL;
238b44b1afbSAmine Khaldi }
239b44b1afbSAmine Khaldi 
create_mfpict(STGMEDIUM * med)240b44b1afbSAmine Khaldi static void create_mfpict(STGMEDIUM *med)
241b44b1afbSAmine Khaldi {
242b44b1afbSAmine Khaldi     METAFILEPICT *mf;
243b44b1afbSAmine Khaldi     HDC hdc = CreateMetaFileW(NULL);
244b44b1afbSAmine Khaldi 
245b44b1afbSAmine Khaldi     Rectangle(hdc, 0, 0, 100, 200);
246b44b1afbSAmine Khaldi 
247b44b1afbSAmine Khaldi     med->tymed = TYMED_MFPICT;
248b44b1afbSAmine Khaldi     U(med)->hMetaFilePict = GlobalAlloc(GMEM_MOVEABLE, sizeof(METAFILEPICT));
249b44b1afbSAmine Khaldi     mf = GlobalLock(U(med)->hMetaFilePict);
250b44b1afbSAmine Khaldi     mf->mm = MM_ANISOTROPIC;
251b44b1afbSAmine Khaldi     mf->xExt = 100;
252b44b1afbSAmine Khaldi     mf->yExt = 200;
253b44b1afbSAmine Khaldi     mf->hMF = CloseMetaFile(hdc);
254b44b1afbSAmine Khaldi     GlobalUnlock(U(med)->hMetaFilePict);
255b44b1afbSAmine Khaldi     med->pUnkForRelease = NULL;
256b44b1afbSAmine Khaldi }
257b44b1afbSAmine Khaldi 
create_text(STGMEDIUM * med)258*5c1bcfecSAmine Khaldi static void create_text(STGMEDIUM *med)
259*5c1bcfecSAmine Khaldi {
260*5c1bcfecSAmine Khaldi     HGLOBAL handle;
261*5c1bcfecSAmine Khaldi     char *p;
262*5c1bcfecSAmine Khaldi 
263*5c1bcfecSAmine Khaldi     handle = GlobalAlloc(GMEM_DDESHARE|GMEM_MOVEABLE, 5);
264*5c1bcfecSAmine Khaldi     p = GlobalLock(handle);
265*5c1bcfecSAmine Khaldi     strcpy(p, "test");
266*5c1bcfecSAmine Khaldi     GlobalUnlock(handle);
267*5c1bcfecSAmine Khaldi 
268*5c1bcfecSAmine Khaldi     med->tymed = TYMED_HGLOBAL;
269*5c1bcfecSAmine Khaldi     U(med)->hGlobal = handle;
270*5c1bcfecSAmine Khaldi     med->pUnkForRelease = NULL;
271*5c1bcfecSAmine Khaldi }
272*5c1bcfecSAmine Khaldi 
OleObject_QueryInterface(IOleObject * iface,REFIID riid,void ** ppv)273c2c66affSColin Finck static HRESULT WINAPI OleObject_QueryInterface(IOleObject *iface, REFIID riid, void **ppv)
274c2c66affSColin Finck {
275c2c66affSColin Finck     CHECK_EXPECTED_METHOD("OleObject_QueryInterface");
276c2c66affSColin Finck 
277c2c66affSColin Finck     *ppv = NULL;
278c2c66affSColin Finck 
279c2c66affSColin Finck     if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IOleObject))
280c2c66affSColin Finck         *ppv = iface;
281c2c66affSColin Finck     else if (IsEqualIID(riid, &IID_IPersistStorage))
282c2c66affSColin Finck         *ppv = &OleObjectPersistStg;
283c2c66affSColin Finck     else if (IsEqualIID(riid, &IID_IOleCache))
284c2c66affSColin Finck         *ppv = cache;
285c2c66affSColin Finck     else if (IsEqualIID(riid, &IID_IRunnableObject) && g_showRunnable)
286c2c66affSColin Finck         *ppv = runnable;
287c2c66affSColin Finck     else if (IsEqualIID(riid, &IID_WineTest))
288c2c66affSColin Finck         return g_QIFailsWith;
289c2c66affSColin Finck 
290c2c66affSColin Finck     if(*ppv) {
291c2c66affSColin Finck         IUnknown_AddRef((IUnknown*)*ppv);
292c2c66affSColin Finck         return S_OK;
293c2c66affSColin Finck     }
294c2c66affSColin Finck 
295c2c66affSColin Finck     trace("OleObject_QueryInterface: returning E_NOINTERFACE\n");
296c2c66affSColin Finck     return E_NOINTERFACE;
297c2c66affSColin Finck }
298c2c66affSColin Finck 
OleObject_AddRef(IOleObject * iface)299c2c66affSColin Finck static ULONG WINAPI OleObject_AddRef(IOleObject *iface)
300c2c66affSColin Finck {
301c2c66affSColin Finck     CHECK_EXPECTED_METHOD("OleObject_AddRef");
302c2c66affSColin Finck     return 2;
303c2c66affSColin Finck }
304c2c66affSColin Finck 
OleObject_Release(IOleObject * iface)305c2c66affSColin Finck static ULONG WINAPI OleObject_Release(IOleObject *iface)
306c2c66affSColin Finck {
307c2c66affSColin Finck     CHECK_EXPECTED_METHOD("OleObject_Release");
308c2c66affSColin Finck     return 1;
309c2c66affSColin Finck }
310c2c66affSColin Finck 
OleObject_SetClientSite(IOleObject * iface,IOleClientSite * pClientSite)311c2c66affSColin Finck static HRESULT WINAPI OleObject_SetClientSite
312c2c66affSColin Finck     (
313c2c66affSColin Finck         IOleObject *iface,
314c2c66affSColin Finck         IOleClientSite *pClientSite
315c2c66affSColin Finck     )
316c2c66affSColin Finck {
317c2c66affSColin Finck     CHECK_EXPECTED_METHOD("OleObject_SetClientSite");
318c2c66affSColin Finck     return S_OK;
319c2c66affSColin Finck }
320c2c66affSColin Finck 
OleObject_GetClientSite(IOleObject * iface,IOleClientSite ** ppClientSite)321c2c66affSColin Finck static HRESULT WINAPI OleObject_GetClientSite
322c2c66affSColin Finck     (
323c2c66affSColin Finck         IOleObject *iface,
324c2c66affSColin Finck         IOleClientSite **ppClientSite
325c2c66affSColin Finck     )
326c2c66affSColin Finck {
327c2c66affSColin Finck     CHECK_EXPECTED_METHOD("OleObject_GetClientSite");
328c2c66affSColin Finck     return E_NOTIMPL;
329c2c66affSColin Finck }
330c2c66affSColin Finck 
OleObject_SetHostNames(IOleObject * iface,LPCOLESTR szContainerApp,LPCOLESTR szContainerObj)331c2c66affSColin Finck static HRESULT WINAPI OleObject_SetHostNames
332c2c66affSColin Finck     (
333c2c66affSColin Finck         IOleObject *iface,
334c2c66affSColin Finck         LPCOLESTR szContainerApp,
335c2c66affSColin Finck         LPCOLESTR szContainerObj
336c2c66affSColin Finck     )
337c2c66affSColin Finck {
338c2c66affSColin Finck     CHECK_EXPECTED_METHOD("OleObject_SetHostNames");
339c2c66affSColin Finck     return S_OK;
340c2c66affSColin Finck }
341c2c66affSColin Finck 
OleObject_Close(IOleObject * iface,DWORD dwSaveOption)342c2c66affSColin Finck static HRESULT WINAPI OleObject_Close
343c2c66affSColin Finck     (
344c2c66affSColin Finck         IOleObject *iface,
345c2c66affSColin Finck         DWORD dwSaveOption
346c2c66affSColin Finck     )
347c2c66affSColin Finck {
348c2c66affSColin Finck     CHECK_EXPECTED_METHOD("OleObject_Close");
349c2c66affSColin Finck     return S_OK;
350c2c66affSColin Finck }
351c2c66affSColin Finck 
OleObject_SetMoniker(IOleObject * iface,DWORD dwWhichMoniker,IMoniker * pmk)352c2c66affSColin Finck static HRESULT WINAPI OleObject_SetMoniker
353c2c66affSColin Finck     (
354c2c66affSColin Finck         IOleObject *iface,
355c2c66affSColin Finck         DWORD dwWhichMoniker,
356c2c66affSColin Finck         IMoniker *pmk
357c2c66affSColin Finck     )
358c2c66affSColin Finck {
359c2c66affSColin Finck     CHECK_EXPECTED_METHOD("OleObject_SetMoniker");
360c2c66affSColin Finck     return S_OK;
361c2c66affSColin Finck }
362c2c66affSColin Finck 
OleObject_GetMoniker(IOleObject * iface,DWORD dwAssign,DWORD dwWhichMoniker,IMoniker ** ppmk)363c2c66affSColin Finck static HRESULT WINAPI OleObject_GetMoniker
364c2c66affSColin Finck     (
365c2c66affSColin Finck         IOleObject *iface,
366c2c66affSColin Finck         DWORD dwAssign,
367c2c66affSColin Finck         DWORD dwWhichMoniker,
368c2c66affSColin Finck         IMoniker **ppmk
369c2c66affSColin Finck     )
370c2c66affSColin Finck {
371c2c66affSColin Finck     CHECK_EXPECTED_METHOD("OleObject_GetMoniker");
372c2c66affSColin Finck     return S_OK;
373c2c66affSColin Finck }
374c2c66affSColin Finck 
OleObject_InitFromData(IOleObject * iface,IDataObject * pDataObject,BOOL fCreation,DWORD dwReserved)375c2c66affSColin Finck static HRESULT WINAPI OleObject_InitFromData
376c2c66affSColin Finck     (
377c2c66affSColin Finck         IOleObject *iface,
378c2c66affSColin Finck         IDataObject *pDataObject,
379c2c66affSColin Finck         BOOL fCreation,
380c2c66affSColin Finck         DWORD dwReserved
381c2c66affSColin Finck     )
382c2c66affSColin Finck {
383c2c66affSColin Finck     CHECK_EXPECTED_METHOD("OleObject_InitFromData");
384c2c66affSColin Finck     return S_OK;
385c2c66affSColin Finck }
386c2c66affSColin Finck 
OleObject_GetClipboardData(IOleObject * iface,DWORD dwReserved,IDataObject ** ppDataObject)387c2c66affSColin Finck static HRESULT WINAPI OleObject_GetClipboardData
388c2c66affSColin Finck     (
389c2c66affSColin Finck         IOleObject *iface,
390c2c66affSColin Finck         DWORD dwReserved,
391c2c66affSColin Finck         IDataObject **ppDataObject
392c2c66affSColin Finck     )
393c2c66affSColin Finck {
394c2c66affSColin Finck     CHECK_EXPECTED_METHOD("OleObject_GetClipboardData");
395c2c66affSColin Finck     return E_NOTIMPL;
396c2c66affSColin Finck }
397c2c66affSColin Finck 
OleObject_DoVerb(IOleObject * iface,LONG iVerb,LPMSG lpmsg,IOleClientSite * pActiveSite,LONG lindex,HWND hwndParent,LPCRECT lprcPosRect)398c2c66affSColin Finck static HRESULT WINAPI OleObject_DoVerb
399c2c66affSColin Finck     (
400c2c66affSColin Finck         IOleObject *iface,
401c2c66affSColin Finck         LONG iVerb,
402c2c66affSColin Finck         LPMSG lpmsg,
403c2c66affSColin Finck         IOleClientSite *pActiveSite,
404c2c66affSColin Finck         LONG lindex,
405c2c66affSColin Finck         HWND hwndParent,
406c2c66affSColin Finck         LPCRECT lprcPosRect
407c2c66affSColin Finck     )
408c2c66affSColin Finck {
409c2c66affSColin Finck     CHECK_EXPECTED_METHOD("OleObject_DoVerb");
410c2c66affSColin Finck     return S_OK;
411c2c66affSColin Finck }
412c2c66affSColin Finck 
OleObject_EnumVerbs(IOleObject * iface,IEnumOLEVERB ** ppEnumOleVerb)413c2c66affSColin Finck static HRESULT WINAPI OleObject_EnumVerbs
414c2c66affSColin Finck     (
415c2c66affSColin Finck         IOleObject *iface,
416c2c66affSColin Finck         IEnumOLEVERB **ppEnumOleVerb
417c2c66affSColin Finck     )
418c2c66affSColin Finck {
419c2c66affSColin Finck     CHECK_EXPECTED_METHOD("OleObject_EnumVerbs");
420c2c66affSColin Finck     return E_NOTIMPL;
421c2c66affSColin Finck }
422c2c66affSColin Finck 
OleObject_Update(IOleObject * iface)423c2c66affSColin Finck static HRESULT WINAPI OleObject_Update
424c2c66affSColin Finck     (
425c2c66affSColin Finck         IOleObject *iface
426c2c66affSColin Finck     )
427c2c66affSColin Finck {
428c2c66affSColin Finck     CHECK_EXPECTED_METHOD("OleObject_Update");
429c2c66affSColin Finck     return S_OK;
430c2c66affSColin Finck }
431c2c66affSColin Finck 
OleObject_IsUpToDate(IOleObject * iface)432c2c66affSColin Finck static HRESULT WINAPI OleObject_IsUpToDate
433c2c66affSColin Finck     (
434c2c66affSColin Finck         IOleObject *iface
435c2c66affSColin Finck     )
436c2c66affSColin Finck {
437c2c66affSColin Finck     CHECK_EXPECTED_METHOD("OleObject_IsUpToDate");
438c2c66affSColin Finck     return S_OK;
439c2c66affSColin Finck }
440c2c66affSColin Finck 
OleObject_GetUserClassID(IOleObject * iface,CLSID * pClsid)441c2c66affSColin Finck static HRESULT WINAPI OleObject_GetUserClassID
442c2c66affSColin Finck (
443c2c66affSColin Finck     IOleObject *iface,
444c2c66affSColin Finck     CLSID *pClsid
445c2c66affSColin Finck )
446c2c66affSColin Finck {
447c2c66affSColin Finck     CHECK_EXPECTED_METHOD("OleObject_GetUserClassID");
448c2c66affSColin Finck     return E_NOTIMPL;
449c2c66affSColin Finck }
450c2c66affSColin Finck 
OleObject_GetUserType(IOleObject * iface,DWORD dwFormOfType,LPOLESTR * pszUserType)451c2c66affSColin Finck static HRESULT WINAPI OleObject_GetUserType
452c2c66affSColin Finck (
453c2c66affSColin Finck     IOleObject *iface,
454c2c66affSColin Finck     DWORD dwFormOfType,
455c2c66affSColin Finck     LPOLESTR *pszUserType
456c2c66affSColin Finck )
457c2c66affSColin Finck {
458c2c66affSColin Finck     CHECK_EXPECTED_METHOD("OleObject_GetUserType");
459c2c66affSColin Finck     return E_NOTIMPL;
460c2c66affSColin Finck }
461c2c66affSColin Finck 
OleObject_SetExtent(IOleObject * iface,DWORD dwDrawAspect,SIZEL * psizel)462c2c66affSColin Finck static HRESULT WINAPI OleObject_SetExtent
463c2c66affSColin Finck (
464c2c66affSColin Finck     IOleObject *iface,
465c2c66affSColin Finck     DWORD dwDrawAspect,
466c2c66affSColin Finck     SIZEL *psizel
467c2c66affSColin Finck )
468c2c66affSColin Finck {
469c2c66affSColin Finck     CHECK_EXPECTED_METHOD("OleObject_SetExtent");
470c2c66affSColin Finck     return S_OK;
471c2c66affSColin Finck }
472c2c66affSColin Finck 
OleObject_GetExtent(IOleObject * iface,DWORD dwDrawAspect,SIZEL * psizel)473c2c66affSColin Finck static HRESULT WINAPI OleObject_GetExtent
474c2c66affSColin Finck (
475c2c66affSColin Finck     IOleObject *iface,
476c2c66affSColin Finck     DWORD dwDrawAspect,
477c2c66affSColin Finck     SIZEL *psizel
478c2c66affSColin Finck )
479c2c66affSColin Finck {
480c2c66affSColin Finck     CHECK_EXPECTED_METHOD("OleObject_GetExtent");
481c2c66affSColin Finck     return E_NOTIMPL;
482c2c66affSColin Finck }
483c2c66affSColin Finck 
OleObject_Advise(IOleObject * iface,IAdviseSink * pAdvSink,DWORD * pdwConnection)484c2c66affSColin Finck static HRESULT WINAPI OleObject_Advise
485c2c66affSColin Finck (
486c2c66affSColin Finck     IOleObject *iface,
487c2c66affSColin Finck     IAdviseSink *pAdvSink,
488c2c66affSColin Finck     DWORD *pdwConnection
489c2c66affSColin Finck )
490c2c66affSColin Finck {
491c2c66affSColin Finck     CHECK_EXPECTED_METHOD("OleObject_Advise");
492c2c66affSColin Finck     return S_OK;
493c2c66affSColin Finck }
494c2c66affSColin Finck 
OleObject_Unadvise(IOleObject * iface,DWORD dwConnection)495c2c66affSColin Finck static HRESULT WINAPI OleObject_Unadvise
496c2c66affSColin Finck (
497c2c66affSColin Finck     IOleObject *iface,
498c2c66affSColin Finck     DWORD dwConnection
499c2c66affSColin Finck )
500c2c66affSColin Finck {
501c2c66affSColin Finck     CHECK_EXPECTED_METHOD("OleObject_Unadvise");
502c2c66affSColin Finck     return S_OK;
503c2c66affSColin Finck }
504c2c66affSColin Finck 
OleObject_EnumAdvise(IOleObject * iface,IEnumSTATDATA ** ppenumAdvise)505c2c66affSColin Finck static HRESULT WINAPI OleObject_EnumAdvise
506c2c66affSColin Finck (
507c2c66affSColin Finck     IOleObject *iface,
508c2c66affSColin Finck     IEnumSTATDATA **ppenumAdvise
509c2c66affSColin Finck )
510c2c66affSColin Finck {
511c2c66affSColin Finck     CHECK_EXPECTED_METHOD("OleObject_EnumAdvise");
512c2c66affSColin Finck     return E_NOTIMPL;
513c2c66affSColin Finck }
514c2c66affSColin Finck 
OleObject_GetMiscStatus(IOleObject * iface,DWORD aspect,DWORD * pdwStatus)515c2c66affSColin Finck static HRESULT WINAPI OleObject_GetMiscStatus
516c2c66affSColin Finck (
517c2c66affSColin Finck     IOleObject *iface,
518c2c66affSColin Finck     DWORD aspect,
519c2c66affSColin Finck     DWORD *pdwStatus
520c2c66affSColin Finck )
521c2c66affSColin Finck {
522c2c66affSColin Finck     CHECK_EXPECTED_METHOD("OleObject_GetMiscStatus");
523c2c66affSColin Finck 
524c2c66affSColin Finck     ok(aspect == DVASPECT_CONTENT, "got aspect %d\n", aspect);
525c2c66affSColin Finck 
526c2c66affSColin Finck     if (g_GetMiscStatusFailsWith == S_OK)
527c2c66affSColin Finck     {
528c2c66affSColin Finck         *pdwStatus = OLEMISC_RECOMPOSEONRESIZE;
529c2c66affSColin Finck         return S_OK;
530c2c66affSColin Finck     }
531c2c66affSColin Finck     else
532c2c66affSColin Finck     {
533c2c66affSColin Finck         *pdwStatus = 0x1234;
534c2c66affSColin Finck         return g_GetMiscStatusFailsWith;
535c2c66affSColin Finck     }
536c2c66affSColin Finck }
537c2c66affSColin Finck 
OleObject_SetColorScheme(IOleObject * iface,LOGPALETTE * pLogpal)538c2c66affSColin Finck static HRESULT WINAPI OleObject_SetColorScheme
539c2c66affSColin Finck (
540c2c66affSColin Finck     IOleObject *iface,
541c2c66affSColin Finck     LOGPALETTE *pLogpal
542c2c66affSColin Finck )
543c2c66affSColin Finck {
544c2c66affSColin Finck     CHECK_EXPECTED_METHOD("OleObject_SetColorScheme");
545c2c66affSColin Finck     return E_NOTIMPL;
546c2c66affSColin Finck }
547c2c66affSColin Finck 
548c2c66affSColin Finck static const IOleObjectVtbl OleObjectVtbl =
549c2c66affSColin Finck {
550c2c66affSColin Finck     OleObject_QueryInterface,
551c2c66affSColin Finck     OleObject_AddRef,
552c2c66affSColin Finck     OleObject_Release,
553c2c66affSColin Finck     OleObject_SetClientSite,
554c2c66affSColin Finck     OleObject_GetClientSite,
555c2c66affSColin Finck     OleObject_SetHostNames,
556c2c66affSColin Finck     OleObject_Close,
557c2c66affSColin Finck     OleObject_SetMoniker,
558c2c66affSColin Finck     OleObject_GetMoniker,
559c2c66affSColin Finck     OleObject_InitFromData,
560c2c66affSColin Finck     OleObject_GetClipboardData,
561c2c66affSColin Finck     OleObject_DoVerb,
562c2c66affSColin Finck     OleObject_EnumVerbs,
563c2c66affSColin Finck     OleObject_Update,
564c2c66affSColin Finck     OleObject_IsUpToDate,
565c2c66affSColin Finck     OleObject_GetUserClassID,
566c2c66affSColin Finck     OleObject_GetUserType,
567c2c66affSColin Finck     OleObject_SetExtent,
568c2c66affSColin Finck     OleObject_GetExtent,
569c2c66affSColin Finck     OleObject_Advise,
570c2c66affSColin Finck     OleObject_Unadvise,
571c2c66affSColin Finck     OleObject_EnumAdvise,
572c2c66affSColin Finck     OleObject_GetMiscStatus,
573c2c66affSColin Finck     OleObject_SetColorScheme
574c2c66affSColin Finck };
575c2c66affSColin Finck 
576c2c66affSColin Finck static IOleObject OleObject = { &OleObjectVtbl };
577c2c66affSColin Finck 
OleObjectPersistStg_QueryInterface(IPersistStorage * iface,REFIID riid,void ** ppv)578c2c66affSColin Finck static HRESULT WINAPI OleObjectPersistStg_QueryInterface(IPersistStorage *iface, REFIID riid, void **ppv)
579c2c66affSColin Finck {
580c2c66affSColin Finck     trace("OleObjectPersistStg_QueryInterface\n");
581c2c66affSColin Finck     return IOleObject_QueryInterface(&OleObject, riid, ppv);
582c2c66affSColin Finck }
583c2c66affSColin Finck 
OleObjectPersistStg_AddRef(IPersistStorage * iface)584c2c66affSColin Finck static ULONG WINAPI OleObjectPersistStg_AddRef(IPersistStorage *iface)
585c2c66affSColin Finck {
586c2c66affSColin Finck     CHECK_EXPECTED_METHOD("OleObjectPersistStg_AddRef");
587c2c66affSColin Finck     return 2;
588c2c66affSColin Finck }
589c2c66affSColin Finck 
OleObjectPersistStg_Release(IPersistStorage * iface)590c2c66affSColin Finck static ULONG WINAPI OleObjectPersistStg_Release(IPersistStorage *iface)
591c2c66affSColin Finck {
592c2c66affSColin Finck     CHECK_EXPECTED_METHOD("OleObjectPersistStg_Release");
593c2c66affSColin Finck     return 1;
594c2c66affSColin Finck }
595c2c66affSColin Finck 
OleObjectPersistStg_GetClassId(IPersistStorage * iface,CLSID * clsid)596c2c66affSColin Finck static HRESULT WINAPI OleObjectPersistStg_GetClassId(IPersistStorage *iface, CLSID *clsid)
597c2c66affSColin Finck {
598c2c66affSColin Finck     CHECK_EXPECTED_METHOD("OleObjectPersistStg_GetClassId");
599c2c66affSColin Finck     return E_NOTIMPL;
600c2c66affSColin Finck }
601c2c66affSColin Finck 
OleObjectPersistStg_IsDirty(IPersistStorage * iface)602c2c66affSColin Finck static HRESULT WINAPI OleObjectPersistStg_IsDirty
603c2c66affSColin Finck (
604c2c66affSColin Finck     IPersistStorage *iface
605c2c66affSColin Finck )
606c2c66affSColin Finck {
607c2c66affSColin Finck     CHECK_EXPECTED_METHOD("OleObjectPersistStg_IsDirty");
608c2c66affSColin Finck     return S_OK;
609c2c66affSColin Finck }
610c2c66affSColin Finck 
OleObjectPersistStg_InitNew(IPersistStorage * iface,IStorage * pStg)611c2c66affSColin Finck static HRESULT WINAPI OleObjectPersistStg_InitNew
612c2c66affSColin Finck (
613c2c66affSColin Finck     IPersistStorage *iface,
614c2c66affSColin Finck     IStorage *pStg
615c2c66affSColin Finck )
616c2c66affSColin Finck {
617c2c66affSColin Finck     CHECK_EXPECTED_METHOD("OleObjectPersistStg_InitNew");
618c2c66affSColin Finck     return S_OK;
619c2c66affSColin Finck }
620c2c66affSColin Finck 
OleObjectPersistStg_Load(IPersistStorage * iface,IStorage * pStg)621c2c66affSColin Finck static HRESULT WINAPI OleObjectPersistStg_Load
622c2c66affSColin Finck (
623c2c66affSColin Finck     IPersistStorage *iface,
624c2c66affSColin Finck     IStorage *pStg
625c2c66affSColin Finck )
626c2c66affSColin Finck {
627c2c66affSColin Finck     CHECK_EXPECTED_METHOD("OleObjectPersistStg_Load");
628c2c66affSColin Finck     return S_OK;
629c2c66affSColin Finck }
630c2c66affSColin Finck 
OleObjectPersistStg_Save(IPersistStorage * iface,IStorage * pStgSave,BOOL fSameAsLoad)631c2c66affSColin Finck static HRESULT WINAPI OleObjectPersistStg_Save
632c2c66affSColin Finck (
633c2c66affSColin Finck     IPersistStorage *iface,
634c2c66affSColin Finck     IStorage *pStgSave,
635c2c66affSColin Finck     BOOL fSameAsLoad
636c2c66affSColin Finck )
637c2c66affSColin Finck {
638c2c66affSColin Finck     CHECK_EXPECTED_METHOD("OleObjectPersistStg_Save");
639c2c66affSColin Finck     return S_OK;
640c2c66affSColin Finck }
641c2c66affSColin Finck 
OleObjectPersistStg_SaveCompleted(IPersistStorage * iface,IStorage * pStgNew)642c2c66affSColin Finck static HRESULT WINAPI OleObjectPersistStg_SaveCompleted
643c2c66affSColin Finck (
644c2c66affSColin Finck     IPersistStorage *iface,
645c2c66affSColin Finck     IStorage *pStgNew
646c2c66affSColin Finck )
647c2c66affSColin Finck {
648c2c66affSColin Finck     CHECK_EXPECTED_METHOD("OleObjectPersistStg_SaveCompleted");
649c2c66affSColin Finck     return S_OK;
650c2c66affSColin Finck }
651c2c66affSColin Finck 
OleObjectPersistStg_HandsOffStorage(IPersistStorage * iface)652c2c66affSColin Finck static HRESULT WINAPI OleObjectPersistStg_HandsOffStorage
653c2c66affSColin Finck (
654c2c66affSColin Finck     IPersistStorage *iface
655c2c66affSColin Finck )
656c2c66affSColin Finck {
657c2c66affSColin Finck     CHECK_EXPECTED_METHOD("OleObjectPersistStg_HandsOffStorage");
658c2c66affSColin Finck     return S_OK;
659c2c66affSColin Finck }
660c2c66affSColin Finck 
661c2c66affSColin Finck static const IPersistStorageVtbl OleObjectPersistStgVtbl =
662c2c66affSColin Finck {
663c2c66affSColin Finck     OleObjectPersistStg_QueryInterface,
664c2c66affSColin Finck     OleObjectPersistStg_AddRef,
665c2c66affSColin Finck     OleObjectPersistStg_Release,
666c2c66affSColin Finck     OleObjectPersistStg_GetClassId,
667c2c66affSColin Finck     OleObjectPersistStg_IsDirty,
668c2c66affSColin Finck     OleObjectPersistStg_InitNew,
669c2c66affSColin Finck     OleObjectPersistStg_Load,
670c2c66affSColin Finck     OleObjectPersistStg_Save,
671c2c66affSColin Finck     OleObjectPersistStg_SaveCompleted,
672c2c66affSColin Finck     OleObjectPersistStg_HandsOffStorage
673c2c66affSColin Finck };
674c2c66affSColin Finck 
675c2c66affSColin Finck static IPersistStorage OleObjectPersistStg = { &OleObjectPersistStgVtbl };
676c2c66affSColin Finck 
OleObjectCache_QueryInterface(IOleCache * iface,REFIID riid,void ** ppv)677c2c66affSColin Finck static HRESULT WINAPI OleObjectCache_QueryInterface(IOleCache *iface, REFIID riid, void **ppv)
678c2c66affSColin Finck {
679c2c66affSColin Finck     return IOleObject_QueryInterface(&OleObject, riid, ppv);
680c2c66affSColin Finck }
681c2c66affSColin Finck 
OleObjectCache_AddRef(IOleCache * iface)682c2c66affSColin Finck static ULONG WINAPI OleObjectCache_AddRef(IOleCache *iface)
683c2c66affSColin Finck {
684c2c66affSColin Finck     CHECK_EXPECTED_METHOD("OleObjectCache_AddRef");
685c2c66affSColin Finck     return 2;
686c2c66affSColin Finck }
687c2c66affSColin Finck 
OleObjectCache_Release(IOleCache * iface)688c2c66affSColin Finck static ULONG WINAPI OleObjectCache_Release(IOleCache *iface)
689c2c66affSColin Finck {
690c2c66affSColin Finck     CHECK_EXPECTED_METHOD("OleObjectCache_Release");
691c2c66affSColin Finck     return 1;
692c2c66affSColin Finck }
693c2c66affSColin Finck 
OleObjectCache_Cache(IOleCache * iface,FORMATETC * pformatetc,DWORD advf,DWORD * pdwConnection)694c2c66affSColin Finck static HRESULT WINAPI OleObjectCache_Cache
695c2c66affSColin Finck (
696c2c66affSColin Finck     IOleCache *iface,
697c2c66affSColin Finck     FORMATETC *pformatetc,
698c2c66affSColin Finck     DWORD advf,
699c2c66affSColin Finck     DWORD *pdwConnection
700c2c66affSColin Finck )
701c2c66affSColin Finck {
702c2c66affSColin Finck     CHECK_EXPECTED_METHOD("OleObjectCache_Cache");
703c2c66affSColin Finck     if (g_expected_fetc) {
704c2c66affSColin Finck         ok(pformatetc != NULL, "pformatetc should not be NULL\n");
705c2c66affSColin Finck         if (pformatetc) {
706c2c66affSColin Finck             ok(pformatetc->cfFormat == g_expected_fetc->cfFormat,
707c2c66affSColin Finck                     "cfFormat: %x\n", pformatetc->cfFormat);
708c2c66affSColin Finck             ok((pformatetc->ptd != NULL) == (g_expected_fetc->ptd != NULL),
709c2c66affSColin Finck                     "ptd: %p\n", pformatetc->ptd);
710c2c66affSColin Finck             ok(pformatetc->dwAspect == g_expected_fetc->dwAspect,
711c2c66affSColin Finck                     "dwAspect: %x\n", pformatetc->dwAspect);
712c2c66affSColin Finck             ok(pformatetc->lindex == g_expected_fetc->lindex,
713c2c66affSColin Finck                     "lindex: %x\n", pformatetc->lindex);
714c2c66affSColin Finck             ok(pformatetc->tymed == g_expected_fetc->tymed,
715c2c66affSColin Finck                     "tymed: %x\n", pformatetc->tymed);
716c2c66affSColin Finck         }
717c2c66affSColin Finck     } else
718c2c66affSColin Finck         ok(pformatetc == NULL, "pformatetc should be NULL\n");
719c2c66affSColin Finck     return S_OK;
720c2c66affSColin Finck }
721c2c66affSColin Finck 
OleObjectCache_Uncache(IOleCache * iface,DWORD dwConnection)722c2c66affSColin Finck static HRESULT WINAPI OleObjectCache_Uncache
723c2c66affSColin Finck (
724c2c66affSColin Finck     IOleCache *iface,
725c2c66affSColin Finck     DWORD dwConnection
726c2c66affSColin Finck )
727c2c66affSColin Finck {
728c2c66affSColin Finck     CHECK_EXPECTED_METHOD("OleObjectCache_Uncache");
729c2c66affSColin Finck     return S_OK;
730c2c66affSColin Finck }
731c2c66affSColin Finck 
OleObjectCache_EnumCache(IOleCache * iface,IEnumSTATDATA ** ppenumSTATDATA)732c2c66affSColin Finck static HRESULT WINAPI OleObjectCache_EnumCache
733c2c66affSColin Finck (
734c2c66affSColin Finck     IOleCache *iface,
735c2c66affSColin Finck     IEnumSTATDATA **ppenumSTATDATA
736c2c66affSColin Finck )
737c2c66affSColin Finck {
738c2c66affSColin Finck     CHECK_EXPECTED_METHOD("OleObjectCache_EnumCache");
739c2c66affSColin Finck     return S_OK;
740c2c66affSColin Finck }
741c2c66affSColin Finck 
742c2c66affSColin Finck 
OleObjectCache_InitCache(IOleCache * iface,IDataObject * pDataObject)743c2c66affSColin Finck static HRESULT WINAPI OleObjectCache_InitCache
744c2c66affSColin Finck (
745c2c66affSColin Finck     IOleCache *iface,
746c2c66affSColin Finck     IDataObject *pDataObject
747c2c66affSColin Finck )
748c2c66affSColin Finck {
749c2c66affSColin Finck     CHECK_EXPECTED_METHOD("OleObjectCache_InitCache");
750c2c66affSColin Finck     return S_OK;
751c2c66affSColin Finck }
752c2c66affSColin Finck 
753c2c66affSColin Finck 
OleObjectCache_SetData(IOleCache * iface,FORMATETC * pformatetc,STGMEDIUM * pmedium,BOOL fRelease)754c2c66affSColin Finck static HRESULT WINAPI OleObjectCache_SetData
755c2c66affSColin Finck (
756c2c66affSColin Finck     IOleCache *iface,
757c2c66affSColin Finck     FORMATETC *pformatetc,
758c2c66affSColin Finck     STGMEDIUM *pmedium,
759c2c66affSColin Finck     BOOL fRelease
760c2c66affSColin Finck )
761c2c66affSColin Finck {
762c2c66affSColin Finck     CHECK_EXPECTED_METHOD("OleObjectCache_SetData");
763c2c66affSColin Finck     return S_OK;
764c2c66affSColin Finck }
765c2c66affSColin Finck 
766c2c66affSColin Finck 
767c2c66affSColin Finck static const IOleCacheVtbl OleObjectCacheVtbl =
768c2c66affSColin Finck {
769c2c66affSColin Finck     OleObjectCache_QueryInterface,
770c2c66affSColin Finck     OleObjectCache_AddRef,
771c2c66affSColin Finck     OleObjectCache_Release,
772c2c66affSColin Finck     OleObjectCache_Cache,
773c2c66affSColin Finck     OleObjectCache_Uncache,
774c2c66affSColin Finck     OleObjectCache_EnumCache,
775c2c66affSColin Finck     OleObjectCache_InitCache,
776c2c66affSColin Finck     OleObjectCache_SetData
777c2c66affSColin Finck };
778c2c66affSColin Finck 
779c2c66affSColin Finck static IOleCache OleObjectCache = { &OleObjectCacheVtbl };
780c2c66affSColin Finck 
OleObjectCF_QueryInterface(IClassFactory * iface,REFIID riid,void ** ppv)781c2c66affSColin Finck static HRESULT WINAPI OleObjectCF_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
782c2c66affSColin Finck {
783c2c66affSColin Finck     if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IClassFactory))
784c2c66affSColin Finck     {
785c2c66affSColin Finck         *ppv = iface;
786c2c66affSColin Finck         IClassFactory_AddRef(iface);
787c2c66affSColin Finck         return S_OK;
788c2c66affSColin Finck     }
789c2c66affSColin Finck     *ppv = NULL;
790c2c66affSColin Finck     return E_NOINTERFACE;
791c2c66affSColin Finck }
792c2c66affSColin Finck 
OleObjectCF_AddRef(IClassFactory * iface)793c2c66affSColin Finck static ULONG WINAPI OleObjectCF_AddRef(IClassFactory *iface)
794c2c66affSColin Finck {
795c2c66affSColin Finck     return 2;
796c2c66affSColin Finck }
797c2c66affSColin Finck 
OleObjectCF_Release(IClassFactory * iface)798c2c66affSColin Finck static ULONG WINAPI OleObjectCF_Release(IClassFactory *iface)
799c2c66affSColin Finck {
800c2c66affSColin Finck     return 1;
801c2c66affSColin Finck }
802c2c66affSColin Finck 
OleObjectCF_CreateInstance(IClassFactory * iface,IUnknown * punkOuter,REFIID riid,void ** ppv)803c2c66affSColin Finck static HRESULT WINAPI OleObjectCF_CreateInstance(IClassFactory *iface, IUnknown *punkOuter, REFIID riid, void **ppv)
804c2c66affSColin Finck {
805c2c66affSColin Finck     return IOleObject_QueryInterface(&OleObject, riid, ppv);
806c2c66affSColin Finck }
807c2c66affSColin Finck 
OleObjectCF_LockServer(IClassFactory * iface,BOOL lock)808c2c66affSColin Finck static HRESULT WINAPI OleObjectCF_LockServer(IClassFactory *iface, BOOL lock)
809c2c66affSColin Finck {
810c2c66affSColin Finck     return S_OK;
811c2c66affSColin Finck }
812c2c66affSColin Finck 
813c2c66affSColin Finck static const IClassFactoryVtbl OleObjectCFVtbl =
814c2c66affSColin Finck {
815c2c66affSColin Finck     OleObjectCF_QueryInterface,
816c2c66affSColin Finck     OleObjectCF_AddRef,
817c2c66affSColin Finck     OleObjectCF_Release,
818c2c66affSColin Finck     OleObjectCF_CreateInstance,
819c2c66affSColin Finck     OleObjectCF_LockServer
820c2c66affSColin Finck };
821c2c66affSColin Finck 
822c2c66affSColin Finck static IClassFactory OleObjectCF = { &OleObjectCFVtbl };
823c2c66affSColin Finck 
OleObjectRunnable_QueryInterface(IRunnableObject * iface,REFIID riid,void ** ppv)824c2c66affSColin Finck static HRESULT WINAPI OleObjectRunnable_QueryInterface(IRunnableObject *iface, REFIID riid, void **ppv)
825c2c66affSColin Finck {
826c2c66affSColin Finck     return IOleObject_QueryInterface(&OleObject, riid, ppv);
827c2c66affSColin Finck }
828c2c66affSColin Finck 
OleObjectRunnable_AddRef(IRunnableObject * iface)829c2c66affSColin Finck static ULONG WINAPI OleObjectRunnable_AddRef(IRunnableObject *iface)
830c2c66affSColin Finck {
831c2c66affSColin Finck     CHECK_EXPECTED_METHOD("OleObjectRunnable_AddRef");
832c2c66affSColin Finck     return 2;
833c2c66affSColin Finck }
834c2c66affSColin Finck 
OleObjectRunnable_Release(IRunnableObject * iface)835c2c66affSColin Finck static ULONG WINAPI OleObjectRunnable_Release(IRunnableObject *iface)
836c2c66affSColin Finck {
837c2c66affSColin Finck     CHECK_EXPECTED_METHOD("OleObjectRunnable_Release");
838c2c66affSColin Finck     return 1;
839c2c66affSColin Finck }
840c2c66affSColin Finck 
OleObjectRunnable_GetRunningClass(IRunnableObject * iface,LPCLSID lpClsid)841c2c66affSColin Finck static HRESULT WINAPI OleObjectRunnable_GetRunningClass(
842c2c66affSColin Finck     IRunnableObject *iface,
843c2c66affSColin Finck     LPCLSID lpClsid)
844c2c66affSColin Finck {
845c2c66affSColin Finck     CHECK_EXPECTED_METHOD("OleObjectRunnable_GetRunningClass");
846c2c66affSColin Finck     return E_NOTIMPL;
847c2c66affSColin Finck }
848c2c66affSColin Finck 
OleObjectRunnable_Run(IRunnableObject * iface,LPBINDCTX pbc)849c2c66affSColin Finck static HRESULT WINAPI OleObjectRunnable_Run(
850c2c66affSColin Finck     IRunnableObject *iface,
851c2c66affSColin Finck     LPBINDCTX pbc)
852c2c66affSColin Finck {
853c2c66affSColin Finck     CHECK_EXPECTED_METHOD("OleObjectRunnable_Run");
854c2c66affSColin Finck     return S_OK;
855c2c66affSColin Finck }
856c2c66affSColin Finck 
OleObjectRunnable_IsRunning(IRunnableObject * iface)857c2c66affSColin Finck static BOOL WINAPI OleObjectRunnable_IsRunning(IRunnableObject *iface)
858c2c66affSColin Finck {
859c2c66affSColin Finck     CHECK_EXPECTED_METHOD("OleObjectRunnable_IsRunning");
860c2c66affSColin Finck     return g_isRunning;
861c2c66affSColin Finck }
862c2c66affSColin Finck 
OleObjectRunnable_LockRunning(IRunnableObject * iface,BOOL fLock,BOOL fLastUnlockCloses)863c2c66affSColin Finck static HRESULT WINAPI OleObjectRunnable_LockRunning(
864c2c66affSColin Finck     IRunnableObject *iface,
865c2c66affSColin Finck     BOOL fLock,
866c2c66affSColin Finck     BOOL fLastUnlockCloses)
867c2c66affSColin Finck {
868c2c66affSColin Finck     CHECK_EXPECTED_METHOD("OleObjectRunnable_LockRunning");
869c2c66affSColin Finck     return S_OK;
870c2c66affSColin Finck }
871c2c66affSColin Finck 
OleObjectRunnable_SetContainedObject(IRunnableObject * iface,BOOL fContained)872c2c66affSColin Finck static HRESULT WINAPI OleObjectRunnable_SetContainedObject(
873c2c66affSColin Finck     IRunnableObject *iface,
874c2c66affSColin Finck     BOOL fContained)
875c2c66affSColin Finck {
876c2c66affSColin Finck     CHECK_EXPECTED_METHOD("OleObjectRunnable_SetContainedObject");
877c2c66affSColin Finck     return S_OK;
878c2c66affSColin Finck }
879c2c66affSColin Finck 
880c2c66affSColin Finck static const IRunnableObjectVtbl OleObjectRunnableVtbl =
881c2c66affSColin Finck {
882c2c66affSColin Finck     OleObjectRunnable_QueryInterface,
883c2c66affSColin Finck     OleObjectRunnable_AddRef,
884c2c66affSColin Finck     OleObjectRunnable_Release,
885c2c66affSColin Finck     OleObjectRunnable_GetRunningClass,
886c2c66affSColin Finck     OleObjectRunnable_Run,
887c2c66affSColin Finck     OleObjectRunnable_IsRunning,
888c2c66affSColin Finck     OleObjectRunnable_LockRunning,
889c2c66affSColin Finck     OleObjectRunnable_SetContainedObject
890c2c66affSColin Finck };
891c2c66affSColin Finck 
892c2c66affSColin Finck static IRunnableObject OleObjectRunnable = { &OleObjectRunnableVtbl };
893c2c66affSColin Finck 
894c2c66affSColin Finck static const CLSID CLSID_Equation3 = {0x0002CE02, 0x0000, 0x0000, {0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46} };
895c2c66affSColin Finck 
viewobject_QueryInterface(IViewObject * iface,REFIID riid,void ** obj)896c2c66affSColin Finck static HRESULT WINAPI viewobject_QueryInterface(IViewObject *iface, REFIID riid, void **obj)
897c2c66affSColin Finck {
898c2c66affSColin Finck     if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IViewObject))
899c2c66affSColin Finck     {
900c2c66affSColin Finck         *obj = iface;
901c2c66affSColin Finck         return S_OK;
902c2c66affSColin Finck     }
903c2c66affSColin Finck 
904c2c66affSColin Finck     *obj = NULL;
905c2c66affSColin Finck     return E_NOINTERFACE;
906c2c66affSColin Finck }
907c2c66affSColin Finck 
viewobject_AddRef(IViewObject * iface)908c2c66affSColin Finck static ULONG WINAPI viewobject_AddRef(IViewObject *iface)
909c2c66affSColin Finck {
910c2c66affSColin Finck     return 2;
911c2c66affSColin Finck }
912c2c66affSColin Finck 
viewobject_Release(IViewObject * iface)913c2c66affSColin Finck static ULONG WINAPI viewobject_Release(IViewObject *iface)
914c2c66affSColin Finck {
915c2c66affSColin Finck     return 1;
916c2c66affSColin Finck }
917c2c66affSColin Finck 
viewobject_Draw(IViewObject * iface,DWORD aspect,LONG index,void * paspect,DVTARGETDEVICE * ptd,HDC hdcTargetDev,HDC hdcDraw,LPCRECTL bounds,LPCRECTL wbounds,BOOL (STDMETHODCALLTYPE * pfnContinue)(ULONG_PTR dwContinue),ULONG_PTR dwContinue)918c2c66affSColin Finck static HRESULT WINAPI viewobject_Draw(IViewObject *iface, DWORD aspect, LONG index,
919c2c66affSColin Finck     void *paspect, DVTARGETDEVICE *ptd, HDC hdcTargetDev, HDC hdcDraw,
920c2c66affSColin Finck     LPCRECTL bounds, LPCRECTL wbounds, BOOL (STDMETHODCALLTYPE *pfnContinue)(ULONG_PTR dwContinue),
921c2c66affSColin Finck     ULONG_PTR dwContinue)
922c2c66affSColin Finck {
923c2c66affSColin Finck     ok(index == -1, "index=%d\n", index);
924c2c66affSColin Finck     return S_OK;
925c2c66affSColin Finck }
926c2c66affSColin Finck 
viewobject_GetColorSet(IViewObject * iface,DWORD draw_aspect,LONG index,void * aspect,DVTARGETDEVICE * ptd,HDC hicTargetDev,LOGPALETTE ** colorset)927c2c66affSColin Finck static HRESULT WINAPI viewobject_GetColorSet(IViewObject *iface, DWORD draw_aspect, LONG index,
928c2c66affSColin Finck     void *aspect, DVTARGETDEVICE *ptd, HDC hicTargetDev, LOGPALETTE **colorset)
929c2c66affSColin Finck {
930c2c66affSColin Finck     ok(0, "unexpected call GetColorSet\n");
931c2c66affSColin Finck     return E_NOTIMPL;
932c2c66affSColin Finck }
933c2c66affSColin Finck 
viewobject_Freeze(IViewObject * iface,DWORD draw_aspect,LONG index,void * aspect,DWORD * freeze)934c2c66affSColin Finck static HRESULT WINAPI viewobject_Freeze(IViewObject *iface, DWORD draw_aspect, LONG index,
935c2c66affSColin Finck     void *aspect, DWORD *freeze)
936c2c66affSColin Finck {
937c2c66affSColin Finck     ok(0, "unexpected call Freeze\n");
938c2c66affSColin Finck     return E_NOTIMPL;
939c2c66affSColin Finck }
940c2c66affSColin Finck 
viewobject_Unfreeze(IViewObject * iface,DWORD freeze)941c2c66affSColin Finck static HRESULT WINAPI viewobject_Unfreeze(IViewObject *iface, DWORD freeze)
942c2c66affSColin Finck {
943c2c66affSColin Finck     ok(0, "unexpected call Unfreeze\n");
944c2c66affSColin Finck     return E_NOTIMPL;
945c2c66affSColin Finck }
946c2c66affSColin Finck 
viewobject_SetAdvise(IViewObject * iface,DWORD aspects,DWORD advf,IAdviseSink * sink)947c2c66affSColin Finck static HRESULT WINAPI viewobject_SetAdvise(IViewObject *iface, DWORD aspects, DWORD advf, IAdviseSink *sink)
948c2c66affSColin Finck {
949c2c66affSColin Finck     ok(0, "unexpected call SetAdvise\n");
950c2c66affSColin Finck     return E_NOTIMPL;
951c2c66affSColin Finck }
952c2c66affSColin Finck 
viewobject_GetAdvise(IViewObject * iface,DWORD * aspects,DWORD * advf,IAdviseSink ** sink)953c2c66affSColin Finck static HRESULT WINAPI viewobject_GetAdvise(IViewObject *iface, DWORD *aspects, DWORD *advf,
954c2c66affSColin Finck     IAdviseSink **sink)
955c2c66affSColin Finck {
956c2c66affSColin Finck     ok(0, "unexpected call GetAdvise\n");
957c2c66affSColin Finck     return E_NOTIMPL;
958c2c66affSColin Finck }
959c2c66affSColin Finck 
960c2c66affSColin Finck static const struct IViewObjectVtbl viewobjectvtbl = {
961c2c66affSColin Finck     viewobject_QueryInterface,
962c2c66affSColin Finck     viewobject_AddRef,
963c2c66affSColin Finck     viewobject_Release,
964c2c66affSColin Finck     viewobject_Draw,
965c2c66affSColin Finck     viewobject_GetColorSet,
966c2c66affSColin Finck     viewobject_Freeze,
967c2c66affSColin Finck     viewobject_Unfreeze,
968c2c66affSColin Finck     viewobject_SetAdvise,
969c2c66affSColin Finck     viewobject_GetAdvise
970c2c66affSColin Finck };
971c2c66affSColin Finck 
972c2c66affSColin Finck static IViewObject viewobject = { &viewobjectvtbl };
973c2c66affSColin Finck 
test_OleCreate(IStorage * pStorage)974c2c66affSColin Finck static void test_OleCreate(IStorage *pStorage)
975c2c66affSColin Finck {
976c2c66affSColin Finck     HRESULT hr;
977c2c66affSColin Finck     IOleObject *pObject;
978c2c66affSColin Finck     FORMATETC formatetc;
979c2c66affSColin Finck     static const struct expected_method methods_olerender_none[] =
980c2c66affSColin Finck     {
981c2c66affSColin Finck         { "OleObject_QueryInterface", 0 },
982c2c66affSColin Finck         { "OleObject_AddRef", 0 },
983c2c66affSColin Finck         { "OleObject_QueryInterface", 0 },
984c2c66affSColin Finck         { "OleObject_AddRef", TEST_OPTIONAL },
985c2c66affSColin Finck         { "OleObject_Release", TEST_OPTIONAL },
986c2c66affSColin Finck         { "OleObject_QueryInterface", TEST_OPTIONAL },
987c2c66affSColin Finck         { "OleObjectPersistStg_AddRef", 0 },
988c2c66affSColin Finck         { "OleObjectPersistStg_InitNew", 0 },
989c2c66affSColin Finck         { "OleObjectPersistStg_Release", 0 },
990c2c66affSColin Finck         { "OleObject_Release", 0 },
991c2c66affSColin Finck         { "OleObject_Release", TEST_OPTIONAL },
992c2c66affSColin Finck         { NULL, 0 }
993c2c66affSColin Finck     };
994c2c66affSColin Finck     static const struct expected_method methods_olerender_draw[] =
995c2c66affSColin Finck     {
996c2c66affSColin Finck         { "OleObject_QueryInterface", 0 },
997c2c66affSColin Finck         { "OleObject_AddRef", 0 },
998c2c66affSColin Finck         { "OleObject_QueryInterface", 0 },
999c2c66affSColin Finck         { "OleObject_AddRef", TEST_OPTIONAL /* NT4 only */ },
1000c2c66affSColin Finck         { "OleObject_Release", TEST_OPTIONAL /* NT4 only */ },
1001c2c66affSColin Finck         { "OleObject_QueryInterface", TEST_OPTIONAL /* NT4 only */ },
1002c2c66affSColin Finck         { "OleObjectPersistStg_AddRef", 0 },
1003c2c66affSColin Finck         { "OleObjectPersistStg_InitNew", 0 },
1004c2c66affSColin Finck         { "OleObjectPersistStg_Release", 0 },
1005c2c66affSColin Finck         { "OleObject_QueryInterface", 0 },
1006c2c66affSColin Finck         { "OleObjectRunnable_AddRef", 0 },
1007c2c66affSColin Finck         { "OleObjectRunnable_Run", 0 },
1008c2c66affSColin Finck         { "OleObjectRunnable_Release", 0 },
1009c2c66affSColin Finck         { "OleObject_QueryInterface", 0 },
1010c2c66affSColin Finck         { "OleObjectCache_AddRef", 0 },
1011c2c66affSColin Finck         { "OleObjectCache_Cache", 0 },
1012c2c66affSColin Finck         { "OleObjectCache_Release", 0 },
1013c2c66affSColin Finck         { "OleObject_Release", 0 },
1014c2c66affSColin Finck         { "OleObject_Release", TEST_OPTIONAL /* NT4 only */ },
1015c2c66affSColin Finck         { NULL, 0 }
1016c2c66affSColin Finck     };
1017c2c66affSColin Finck     static const struct expected_method methods_olerender_draw_with_site[] =
1018c2c66affSColin Finck     {
1019c2c66affSColin Finck         { "OleObject_QueryInterface", 0 },
1020c2c66affSColin Finck         { "OleObject_AddRef", 0 },
1021c2c66affSColin Finck         { "OleObject_QueryInterface", 0 },
1022c2c66affSColin Finck         { "OleObject_AddRef", 0 },
1023c2c66affSColin Finck         { "OleObject_GetMiscStatus", 0 },
1024c2c66affSColin Finck         { "OleObject_QueryInterface", 0 },
1025c2c66affSColin Finck         { "OleObjectPersistStg_AddRef", 0 },
1026c2c66affSColin Finck         { "OleObjectPersistStg_InitNew", 0 },
1027c2c66affSColin Finck         { "OleObjectPersistStg_Release", 0 },
1028c2c66affSColin Finck         { "OleObject_SetClientSite", 0 },
1029c2c66affSColin Finck         { "OleObject_Release", 0 },
1030c2c66affSColin Finck         { "OleObject_QueryInterface", 0 },
1031c2c66affSColin Finck         { "OleObjectRunnable_AddRef", 0 },
1032c2c66affSColin Finck         { "OleObjectRunnable_Run", 0 },
1033c2c66affSColin Finck         { "OleObjectRunnable_Release", 0 },
1034c2c66affSColin Finck         { "OleObject_QueryInterface", 0 },
1035c2c66affSColin Finck         { "OleObjectCache_AddRef", 0 },
1036c2c66affSColin Finck         { "OleObjectCache_Cache", 0 },
1037c2c66affSColin Finck         { "OleObjectCache_Release", 0 },
1038c2c66affSColin Finck         { "OleObject_Release", 0 },
1039c2c66affSColin Finck         { NULL, 0 }
1040c2c66affSColin Finck     };
1041c2c66affSColin Finck     static const struct expected_method methods_olerender_format[] =
1042c2c66affSColin Finck     {
1043c2c66affSColin Finck         { "OleObject_QueryInterface", 0 },
1044c2c66affSColin Finck         { "OleObject_AddRef", 0 },
1045c2c66affSColin Finck         { "OleObject_QueryInterface", 0 },
1046c2c66affSColin Finck         { "OleObject_AddRef", 0 },
1047c2c66affSColin Finck         { "OleObject_GetMiscStatus", 0 },
1048c2c66affSColin Finck         { "OleObject_QueryInterface", 0 },
1049c2c66affSColin Finck         { "OleObjectPersistStg_AddRef", 0 },
1050c2c66affSColin Finck         { "OleObjectPersistStg_InitNew", 0 },
1051c2c66affSColin Finck         { "OleObjectPersistStg_Release", 0 },
1052c2c66affSColin Finck         { "OleObject_SetClientSite", 0 },
1053c2c66affSColin Finck         { "OleObject_Release", 0 },
1054c2c66affSColin Finck         { "OleObject_QueryInterface", 0 },
1055c2c66affSColin Finck         { "OleObjectRunnable_AddRef", 0 },
1056c2c66affSColin Finck         { "OleObjectRunnable_Run", 0 },
1057c2c66affSColin Finck         { "OleObjectRunnable_Release", 0 },
1058c2c66affSColin Finck         { "OleObject_QueryInterface", 0 },
1059c2c66affSColin Finck         { "OleObjectCache_AddRef", 0 },
1060c2c66affSColin Finck         { "OleObjectCache_Cache", 0 },
1061c2c66affSColin Finck         { "OleObjectCache_Release", 0 },
1062c2c66affSColin Finck         { "OleObject_Release", 0 },
1063c2c66affSColin Finck         { NULL, 0 }
1064c2c66affSColin Finck     };
1065c2c66affSColin Finck     static const struct expected_method methods_olerender_asis[] =
1066c2c66affSColin Finck     {
1067c2c66affSColin Finck         { "OleObject_QueryInterface", 0 },
1068c2c66affSColin Finck         { "OleObject_AddRef", 0 },
1069c2c66affSColin Finck         { "OleObject_QueryInterface", 0 },
1070c2c66affSColin Finck         { "OleObject_AddRef", TEST_OPTIONAL /* NT4 only */ },
1071c2c66affSColin Finck         { "OleObject_Release", TEST_OPTIONAL /* NT4 only */ },
1072c2c66affSColin Finck         { "OleObject_QueryInterface", TEST_OPTIONAL /* NT4 only */ },
1073c2c66affSColin Finck         { "OleObjectPersistStg_AddRef", 0 },
1074c2c66affSColin Finck         { "OleObjectPersistStg_InitNew", 0 },
1075c2c66affSColin Finck         { "OleObjectPersistStg_Release", 0 },
1076c2c66affSColin Finck         { "OleObject_Release", 0 },
1077c2c66affSColin Finck         { "OleObject_Release", TEST_OPTIONAL /* NT4 only */ },
1078c2c66affSColin Finck         { NULL, 0 }
1079c2c66affSColin Finck     };
1080c2c66affSColin Finck     static const struct expected_method methods_olerender_draw_no_runnable[] =
1081c2c66affSColin Finck     {
1082c2c66affSColin Finck         { "OleObject_QueryInterface", 0 },
1083c2c66affSColin Finck         { "OleObject_AddRef", 0 },
1084c2c66affSColin Finck         { "OleObject_QueryInterface", 0 },
1085c2c66affSColin Finck         { "OleObject_AddRef", TEST_OPTIONAL /* NT4 only */ },
1086c2c66affSColin Finck         { "OleObject_Release", TEST_OPTIONAL /* NT4 only */ },
1087c2c66affSColin Finck         { "OleObject_QueryInterface", TEST_OPTIONAL /* NT4 only */ },
1088c2c66affSColin Finck         { "OleObjectPersistStg_AddRef", 0 },
1089c2c66affSColin Finck         { "OleObjectPersistStg_InitNew", 0 },
1090c2c66affSColin Finck         { "OleObjectPersistStg_Release", 0 },
1091c2c66affSColin Finck         { "OleObject_QueryInterface", 0 },
1092c2c66affSColin Finck         { "OleObject_QueryInterface", 0 },
1093c2c66affSColin Finck         { "OleObjectCache_AddRef", 0 },
1094c2c66affSColin Finck         { "OleObjectCache_Cache", 0 },
1095c2c66affSColin Finck         { "OleObjectCache_Release", 0 },
1096c2c66affSColin Finck         { "OleObject_Release", 0 },
1097c2c66affSColin Finck         { "OleObject_Release", TEST_OPTIONAL /* NT4 only */ },
1098c2c66affSColin Finck         { NULL, 0 },
1099c2c66affSColin Finck     };
1100c2c66affSColin Finck     static const struct expected_method methods_olerender_draw_no_cache[] =
1101c2c66affSColin Finck     {
1102c2c66affSColin Finck         { "OleObject_QueryInterface", 0 },
1103c2c66affSColin Finck         { "OleObject_AddRef", 0 },
1104c2c66affSColin Finck         { "OleObject_QueryInterface", 0 },
1105c2c66affSColin Finck         { "OleObject_AddRef", TEST_OPTIONAL /* NT4 only */ },
1106c2c66affSColin Finck         { "OleObject_Release", TEST_OPTIONAL /* NT4 only */ },
1107c2c66affSColin Finck         { "OleObject_QueryInterface", TEST_OPTIONAL /* NT4 only */ },
1108c2c66affSColin Finck         { "OleObjectPersistStg_AddRef", 0 },
1109c2c66affSColin Finck         { "OleObjectPersistStg_InitNew", 0 },
1110c2c66affSColin Finck         { "OleObjectPersistStg_Release", 0 },
1111c2c66affSColin Finck         { "OleObject_QueryInterface", 0 },
1112c2c66affSColin Finck         { "OleObjectRunnable_AddRef", 0 },
1113c2c66affSColin Finck         { "OleObjectRunnable_Run", 0 },
1114c2c66affSColin Finck         { "OleObjectRunnable_Release", 0 },
1115c2c66affSColin Finck         { "OleObject_QueryInterface", 0 },
1116c2c66affSColin Finck         { "OleObject_Release", 0 },
1117c2c66affSColin Finck         { "OleObject_Release", TEST_OPTIONAL /* NT4 only */ },
1118c2c66affSColin Finck         { NULL, 0 }
1119c2c66affSColin Finck     };
1120c2c66affSColin Finck 
1121c2c66affSColin Finck     g_expected_fetc = &formatetc;
1122c2c66affSColin Finck     formatetc.cfFormat = 0;
1123c2c66affSColin Finck     formatetc.ptd = NULL;
1124c2c66affSColin Finck     formatetc.dwAspect = DVASPECT_CONTENT;
1125c2c66affSColin Finck     formatetc.lindex = -1;
1126c2c66affSColin Finck     formatetc.tymed = TYMED_NULL;
1127c2c66affSColin Finck     runnable = &OleObjectRunnable;
1128c2c66affSColin Finck     cache = &OleObjectCache;
1129c2c66affSColin Finck     expected_method_list = methods_olerender_none;
1130c2c66affSColin Finck     trace("OleCreate with OLERENDER_NONE:\n");
1131c2c66affSColin Finck     hr = OleCreate(&CLSID_Equation3, &IID_IOleObject, OLERENDER_NONE, NULL, NULL, pStorage, (void **)&pObject);
1132c2c66affSColin Finck     ok_ole_success(hr, "OleCreate");
1133c2c66affSColin Finck     IOleObject_Release(pObject);
1134c2c66affSColin Finck     CHECK_NO_EXTRA_METHODS();
1135c2c66affSColin Finck 
1136c2c66affSColin Finck     expected_method_list = methods_olerender_draw;
1137c2c66affSColin Finck     trace("OleCreate with OLERENDER_DRAW:\n");
1138c2c66affSColin Finck     hr = OleCreate(&CLSID_Equation3, &IID_IOleObject, OLERENDER_DRAW, NULL, NULL, pStorage, (void **)&pObject);
1139c2c66affSColin Finck     ok_ole_success(hr, "OleCreate");
1140c2c66affSColin Finck     IOleObject_Release(pObject);
1141c2c66affSColin Finck     CHECK_NO_EXTRA_METHODS();
1142c2c66affSColin Finck 
1143c2c66affSColin Finck     expected_method_list = methods_olerender_draw_with_site;
1144c2c66affSColin Finck     trace("OleCreate with OLERENDER_DRAW, with site:\n");
1145c2c66affSColin Finck     hr = OleCreate(&CLSID_Equation3, &IID_IOleObject, OLERENDER_DRAW, NULL, (IOleClientSite*)0xdeadbeef, pStorage, (void **)&pObject);
1146c2c66affSColin Finck     ok_ole_success(hr, "OleCreate");
1147c2c66affSColin Finck     IOleObject_Release(pObject);
1148c2c66affSColin Finck     CHECK_NO_EXTRA_METHODS();
1149c2c66affSColin Finck 
1150c2c66affSColin Finck     /* GetMiscStatus fails */
1151c2c66affSColin Finck     g_GetMiscStatusFailsWith = 0x8fafefaf;
1152c2c66affSColin Finck     expected_method_list = methods_olerender_draw_with_site;
1153c2c66affSColin Finck     trace("OleCreate with OLERENDER_DRAW, with site:\n");
1154c2c66affSColin Finck     hr = OleCreate(&CLSID_Equation3, &IID_IOleObject, OLERENDER_DRAW, NULL, (IOleClientSite*)0xdeadbeef, pStorage, (void **)&pObject);
1155c2c66affSColin Finck     ok_ole_success(hr, "OleCreate");
1156c2c66affSColin Finck     IOleObject_Release(pObject);
1157c2c66affSColin Finck     CHECK_NO_EXTRA_METHODS();
1158c2c66affSColin Finck     g_GetMiscStatusFailsWith = S_OK;
1159c2c66affSColin Finck 
1160c2c66affSColin Finck     formatetc.cfFormat = CF_TEXT;
1161c2c66affSColin Finck     formatetc.ptd = NULL;
1162c2c66affSColin Finck     formatetc.dwAspect = DVASPECT_CONTENT;
1163c2c66affSColin Finck     formatetc.lindex = -1;
1164c2c66affSColin Finck     formatetc.tymed = TYMED_HGLOBAL;
1165c2c66affSColin Finck     expected_method_list = methods_olerender_format;
1166c2c66affSColin Finck     trace("OleCreate with OLERENDER_FORMAT:\n");
1167c2c66affSColin Finck     hr = OleCreate(&CLSID_Equation3, &IID_IOleObject, OLERENDER_FORMAT, &formatetc, (IOleClientSite *)0xdeadbeef, pStorage, (void **)&pObject);
1168c2c66affSColin Finck     ok(hr == S_OK ||
1169c2c66affSColin Finck        broken(hr == E_INVALIDARG), /* win2k */
1170c2c66affSColin Finck        "OleCreate failed with error 0x%08x\n", hr);
1171c2c66affSColin Finck     if (pObject)
1172c2c66affSColin Finck     {
1173c2c66affSColin Finck         IOleObject_Release(pObject);
1174c2c66affSColin Finck         CHECK_NO_EXTRA_METHODS();
1175c2c66affSColin Finck     }
1176c2c66affSColin Finck 
1177c2c66affSColin Finck     expected_method_list = methods_olerender_asis;
1178c2c66affSColin Finck     trace("OleCreate with OLERENDER_ASIS:\n");
1179c2c66affSColin Finck     hr = OleCreate(&CLSID_Equation3, &IID_IOleObject, OLERENDER_ASIS, NULL, NULL, pStorage, (void **)&pObject);
1180c2c66affSColin Finck     ok_ole_success(hr, "OleCreate");
1181c2c66affSColin Finck     IOleObject_Release(pObject);
1182c2c66affSColin Finck     CHECK_NO_EXTRA_METHODS();
1183c2c66affSColin Finck 
1184c2c66affSColin Finck     formatetc.cfFormat = 0;
1185c2c66affSColin Finck     formatetc.tymed = TYMED_NULL;
1186c2c66affSColin Finck     runnable = NULL;
1187c2c66affSColin Finck     expected_method_list = methods_olerender_draw_no_runnable;
1188c2c66affSColin Finck     trace("OleCreate with OLERENDER_DRAW (no IRunnableObject):\n");
1189c2c66affSColin Finck     hr = OleCreate(&CLSID_Equation3, &IID_IOleObject, OLERENDER_DRAW, NULL, NULL, pStorage, (void **)&pObject);
1190c2c66affSColin Finck     ok_ole_success(hr, "OleCreate");
1191c2c66affSColin Finck     IOleObject_Release(pObject);
1192c2c66affSColin Finck     CHECK_NO_EXTRA_METHODS();
1193c2c66affSColin Finck 
1194c2c66affSColin Finck     runnable = &OleObjectRunnable;
1195c2c66affSColin Finck     cache = NULL;
1196c2c66affSColin Finck     expected_method_list = methods_olerender_draw_no_cache;
1197c2c66affSColin Finck     trace("OleCreate with OLERENDER_DRAW (no IOleCache):\n");
1198c2c66affSColin Finck     hr = OleCreate(&CLSID_Equation3, &IID_IOleObject, OLERENDER_DRAW, NULL, NULL, pStorage, (void **)&pObject);
1199c2c66affSColin Finck     ok_ole_success(hr, "OleCreate");
1200c2c66affSColin Finck     IOleObject_Release(pObject);
1201c2c66affSColin Finck     CHECK_NO_EXTRA_METHODS();
1202c2c66affSColin Finck     trace("end\n");
1203c2c66affSColin Finck     g_expected_fetc = NULL;
1204c2c66affSColin Finck }
1205c2c66affSColin Finck 
test_OleLoad(IStorage * pStorage)1206c2c66affSColin Finck static void test_OleLoad(IStorage *pStorage)
1207c2c66affSColin Finck {
1208c2c66affSColin Finck     HRESULT hr;
1209c2c66affSColin Finck     IOleObject *pObject;
1210c2c66affSColin Finck     DWORD fmt;
1211c2c66affSColin Finck 
1212c2c66affSColin Finck     static const struct expected_method methods_oleload[] =
1213c2c66affSColin Finck     {
1214c2c66affSColin Finck         { "OleObject_QueryInterface", 0 },
1215c2c66affSColin Finck         { "OleObject_AddRef", 0 },
1216c2c66affSColin Finck         { "OleObject_QueryInterface", 0 },
1217c2c66affSColin Finck         { "OleObject_AddRef", 0 },
1218c2c66affSColin Finck         { "OleObject_GetMiscStatus", 0 },
1219c2c66affSColin Finck         { "OleObject_QueryInterface", 0 },
1220c2c66affSColin Finck         { "OleObjectPersistStg_AddRef", 0 },
1221c2c66affSColin Finck         { "OleObjectPersistStg_Load", 0 },
1222c2c66affSColin Finck         { "OleObjectPersistStg_Release", 0 },
1223c2c66affSColin Finck         { "OleObject_SetClientSite", 0 },
1224c2c66affSColin Finck         { "OleObject_Release", 0 },
1225c2c66affSColin Finck         { "OleObject_QueryInterface", 0 },
1226c2c66affSColin Finck         { "OleObject_GetMiscStatus", 0 },
1227c2c66affSColin Finck         { "OleObject_Release", 0 },
1228c2c66affSColin Finck         { NULL, 0 }
1229c2c66affSColin Finck     };
1230c2c66affSColin Finck 
1231c2c66affSColin Finck     /* Test once with IOleObject_GetMiscStatus failing */
1232c2c66affSColin Finck     expected_method_list = methods_oleload;
1233c2c66affSColin Finck     g_GetMiscStatusFailsWith = E_FAIL;
1234c2c66affSColin Finck     trace("OleLoad:\n");
1235c2c66affSColin Finck     hr = OleLoad(pStorage, &IID_IOleObject, (IOleClientSite *)0xdeadbeef, (void **)&pObject);
1236c2c66affSColin Finck     ok(hr == S_OK ||
1237c2c66affSColin Finck        broken(hr == E_INVALIDARG), /* win98 and win2k */
1238c2c66affSColin Finck        "OleLoad failed with error 0x%08x\n", hr);
1239c2c66affSColin Finck     if(pObject)
1240c2c66affSColin Finck     {
1241c2c66affSColin Finck         DWORD dwStatus = 0xdeadbeef;
1242c2c66affSColin Finck         hr = IOleObject_GetMiscStatus(pObject, DVASPECT_CONTENT, &dwStatus);
1243c2c66affSColin Finck         ok(hr == E_FAIL, "Got 0x%08x\n", hr);
1244c2c66affSColin Finck         ok(dwStatus == 0x1234, "Got 0x%08x\n", dwStatus);
1245c2c66affSColin Finck 
1246c2c66affSColin Finck         IOleObject_Release(pObject);
1247c2c66affSColin Finck         CHECK_NO_EXTRA_METHODS();
1248c2c66affSColin Finck     }
1249c2c66affSColin Finck     g_GetMiscStatusFailsWith = S_OK;
1250c2c66affSColin Finck 
1251c2c66affSColin Finck     /* Test again, let IOleObject_GetMiscStatus succeed. */
1252c2c66affSColin Finck     expected_method_list = methods_oleload;
1253c2c66affSColin Finck     trace("OleLoad:\n");
1254c2c66affSColin Finck     hr = OleLoad(pStorage, &IID_IOleObject, (IOleClientSite *)0xdeadbeef, (void **)&pObject);
1255c2c66affSColin Finck     ok(hr == S_OK ||
1256c2c66affSColin Finck        broken(hr == E_INVALIDARG), /* win98 and win2k */
1257c2c66affSColin Finck        "OleLoad failed with error 0x%08x\n", hr);
1258c2c66affSColin Finck     if (pObject)
1259c2c66affSColin Finck     {
1260c2c66affSColin Finck         DWORD dwStatus = 0xdeadbeef;
1261c2c66affSColin Finck         hr = IOleObject_GetMiscStatus(pObject, DVASPECT_CONTENT, &dwStatus);
1262c2c66affSColin Finck         ok(hr == S_OK, "Got 0x%08x\n", hr);
1263c2c66affSColin Finck         ok(dwStatus == 1, "Got 0x%08x\n", dwStatus);
1264c2c66affSColin Finck 
1265c2c66affSColin Finck         IOleObject_Release(pObject);
1266c2c66affSColin Finck         CHECK_NO_EXTRA_METHODS();
1267c2c66affSColin Finck     }
1268c2c66affSColin Finck 
1269c2c66affSColin Finck     for (fmt = CF_TEXT; fmt < CF_MAX; fmt++)
1270c2c66affSColin Finck     {
1271c2c66affSColin Finck         static const WCHAR olrepres[] = { 2,'O','l','e','P','r','e','s','0','0','0',0 };
1272c2c66affSColin Finck         IStorage *stg;
1273c2c66affSColin Finck         IStream *stream;
1274c2c66affSColin Finck         IUnknown *obj;
1275c2c66affSColin Finck         DWORD data, i, data_size;
1276c2c66affSColin Finck         PresentationDataHeader header;
1277c2c66affSColin Finck         HDC hdc;
1278c2c66affSColin Finck         HGDIOBJ hobj;
1279c2c66affSColin Finck         RECT rc;
1280c2c66affSColin Finck         char buf[256];
1281c2c66affSColin Finck 
1282c2c66affSColin Finck         for (i = 0; i < 7; i++)
1283c2c66affSColin Finck         {
1284c2c66affSColin Finck             hr = StgCreateDocfile(NULL, STGM_READWRITE | STGM_CREATE | STGM_SHARE_EXCLUSIVE | STGM_DELETEONRELEASE, 0, &stg);
1285c2c66affSColin Finck             ok(hr == S_OK, "StgCreateDocfile error %#x\n", hr);
1286c2c66affSColin Finck 
1287c2c66affSColin Finck             hr = IStorage_SetClass(stg, &CLSID_WineTest);
1288c2c66affSColin Finck             ok(hr == S_OK, "SetClass error %#x\n", hr);
1289c2c66affSColin Finck 
1290c2c66affSColin Finck             hr = IStorage_CreateStream(stg, olrepres, STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE, 0, 0, &stream);
1291c2c66affSColin Finck             ok(hr == S_OK, "CreateStream error %#x\n", hr);
1292c2c66affSColin Finck 
1293c2c66affSColin Finck             data = ~0;
1294c2c66affSColin Finck             hr = IStream_Write(stream, &data, sizeof(data), NULL);
1295c2c66affSColin Finck             ok(hr == S_OK, "Write error %#x\n", hr);
1296c2c66affSColin Finck 
1297c2c66affSColin Finck             data = fmt;
1298c2c66affSColin Finck             hr = IStream_Write(stream, &data, sizeof(data), NULL);
1299c2c66affSColin Finck             ok(hr == S_OK, "Write error %#x\n", hr);
1300c2c66affSColin Finck 
1301c2c66affSColin Finck             switch (fmt)
1302c2c66affSColin Finck             {
1303c2c66affSColin Finck             case CF_BITMAP:
1304c2c66affSColin Finck                 /* FIXME: figure out stream format */
1305c2c66affSColin Finck                 hobj = CreateBitmap(1, 1, 1, 1, NULL);
1306c2c66affSColin Finck                 data_size = GetBitmapBits(hobj, sizeof(buf), buf);
1307c2c66affSColin Finck                 DeleteObject(hobj);
1308c2c66affSColin Finck                 break;
1309c2c66affSColin Finck 
1310c2c66affSColin Finck             case CF_METAFILEPICT:
1311c2c66affSColin Finck             case CF_ENHMETAFILE:
1312c2c66affSColin Finck                 hdc = CreateMetaFileA(NULL);
1313c2c66affSColin Finck                 hobj = CloseMetaFile(hdc);
1314c2c66affSColin Finck                 data_size = GetMetaFileBitsEx(hobj, sizeof(buf), buf);
1315c2c66affSColin Finck                 DeleteMetaFile(hobj);
1316c2c66affSColin Finck                 break;
1317c2c66affSColin Finck 
1318c2c66affSColin Finck             default:
1319c2c66affSColin Finck                 data_size = sizeof(buf);
1320c2c66affSColin Finck                 memset(buf, 'A', sizeof(buf));
1321c2c66affSColin Finck                 break;
1322c2c66affSColin Finck             }
1323c2c66affSColin Finck 
1324b44b1afbSAmine Khaldi             header.tdSize = sizeof(header.tdSize);
1325c2c66affSColin Finck             header.dvAspect = DVASPECT_CONTENT;
1326c2c66affSColin Finck             header.lindex = -1;
1327c2c66affSColin Finck             header.advf = 1 << i;
1328c2c66affSColin Finck             header.unknown7 = 0;
1329c2c66affSColin Finck             header.dwObjectExtentX = 1;
1330c2c66affSColin Finck             header.dwObjectExtentY = 1;
1331c2c66affSColin Finck             header.dwSize = data_size;
1332c2c66affSColin Finck             hr = IStream_Write(stream, &header, sizeof(header), NULL);
1333c2c66affSColin Finck             ok(hr == S_OK, "Write error %#x\n", hr);
1334c2c66affSColin Finck 
1335c2c66affSColin Finck             hr = IStream_Write(stream, buf, data_size, NULL);
1336c2c66affSColin Finck             ok(hr == S_OK, "Write error %#x\n", hr);
1337c2c66affSColin Finck 
1338c2c66affSColin Finck             IStream_Release(stream);
1339c2c66affSColin Finck 
1340c2c66affSColin Finck             hr = OleLoad(stg, &IID_IUnknown, NULL, (void **)&obj);
1341c2c66affSColin Finck             /* FIXME: figure out stream format */
1342c2c66affSColin Finck             if (fmt == CF_BITMAP && hr != S_OK)
1343c2c66affSColin Finck             {
1344c2c66affSColin Finck                 IStorage_Release(stg);
1345c2c66affSColin Finck                 continue;
1346c2c66affSColin Finck             }
1347c2c66affSColin Finck             ok(hr == S_OK, "OleLoad error %#x: cfFormat = %u, advf = %#x\n", hr, fmt, header.advf);
1348c2c66affSColin Finck 
1349c2c66affSColin Finck             hdc = CreateCompatibleDC(0);
1350c2c66affSColin Finck             SetRect(&rc, 0, 0, 100, 100);
1351c2c66affSColin Finck             hr = OleDraw(obj, DVASPECT_CONTENT, hdc, &rc);
1352c2c66affSColin Finck             DeleteDC(hdc);
1353c2c66affSColin Finck             if (fmt == CF_METAFILEPICT)
1354c2c66affSColin Finck                 ok(hr == S_OK, "OleDraw error %#x: cfFormat = %u, advf = %#x\n", hr, fmt, header.advf);
1355c2c66affSColin Finck             else if (fmt == CF_ENHMETAFILE)
1356c2c66affSColin Finck todo_wine
1357c2c66affSColin Finck                 ok(hr == S_OK, "OleDraw error %#x: cfFormat = %u, advf = %#x\n", hr, fmt, header.advf);
1358c2c66affSColin Finck             else
1359c2c66affSColin Finck                 ok(hr == OLE_E_BLANK || hr == OLE_E_NOTRUNNING || hr == E_FAIL, "OleDraw should fail: %#x, cfFormat = %u, advf = %#x\n", hr, fmt, header.advf);
1360c2c66affSColin Finck 
1361c2c66affSColin Finck             IUnknown_Release(obj);
1362c2c66affSColin Finck             IStorage_Release(stg);
1363c2c66affSColin Finck         }
1364c2c66affSColin Finck     }
1365c2c66affSColin Finck }
1366c2c66affSColin Finck 
draw_continue(ULONG_PTR param)1367c2c66affSColin Finck static BOOL STDMETHODCALLTYPE draw_continue(ULONG_PTR param)
1368c2c66affSColin Finck {
1369c2c66affSColin Finck     CHECK_EXPECTED_METHOD("draw_continue");
1370c2c66affSColin Finck     return TRUE;
1371c2c66affSColin Finck }
1372c2c66affSColin Finck 
draw_continue_false(ULONG_PTR param)1373c2c66affSColin Finck static BOOL STDMETHODCALLTYPE draw_continue_false(ULONG_PTR param)
1374c2c66affSColin Finck {
1375c2c66affSColin Finck     CHECK_EXPECTED_METHOD("draw_continue_false");
1376c2c66affSColin Finck     return FALSE;
1377c2c66affSColin Finck }
1378c2c66affSColin Finck 
AdviseSink_QueryInterface(IAdviseSink * iface,REFIID riid,void ** ppv)1379c2c66affSColin Finck static HRESULT WINAPI AdviseSink_QueryInterface(IAdviseSink *iface, REFIID riid, void **ppv)
1380c2c66affSColin Finck {
1381c2c66affSColin Finck     if (IsEqualIID(riid, &IID_IAdviseSink) || IsEqualIID(riid, &IID_IUnknown))
1382c2c66affSColin Finck     {
1383c2c66affSColin Finck         *ppv = iface;
1384c2c66affSColin Finck         IAdviseSink_AddRef(iface);
1385c2c66affSColin Finck         return S_OK;
1386c2c66affSColin Finck     }
1387c2c66affSColin Finck     *ppv = NULL;
1388c2c66affSColin Finck     return E_NOINTERFACE;
1389c2c66affSColin Finck }
1390c2c66affSColin Finck 
AdviseSink_AddRef(IAdviseSink * iface)1391c2c66affSColin Finck static ULONG WINAPI AdviseSink_AddRef(IAdviseSink *iface)
1392c2c66affSColin Finck {
1393c2c66affSColin Finck     return 2;
1394c2c66affSColin Finck }
1395c2c66affSColin Finck 
AdviseSink_Release(IAdviseSink * iface)1396c2c66affSColin Finck static ULONG WINAPI AdviseSink_Release(IAdviseSink *iface)
1397c2c66affSColin Finck {
1398c2c66affSColin Finck     return 1;
1399c2c66affSColin Finck }
1400c2c66affSColin Finck 
1401c2c66affSColin Finck 
AdviseSink_OnDataChange(IAdviseSink * iface,FORMATETC * pFormatetc,STGMEDIUM * pStgmed)1402c2c66affSColin Finck static void WINAPI AdviseSink_OnDataChange(
1403c2c66affSColin Finck     IAdviseSink *iface,
1404c2c66affSColin Finck     FORMATETC *pFormatetc,
1405c2c66affSColin Finck     STGMEDIUM *pStgmed)
1406c2c66affSColin Finck {
1407c2c66affSColin Finck     CHECK_EXPECTED_METHOD("AdviseSink_OnDataChange");
1408c2c66affSColin Finck }
1409c2c66affSColin Finck 
AdviseSink_OnViewChange(IAdviseSink * iface,DWORD dwAspect,LONG lindex)1410c2c66affSColin Finck static void WINAPI AdviseSink_OnViewChange(
1411c2c66affSColin Finck     IAdviseSink *iface,
1412c2c66affSColin Finck     DWORD dwAspect,
1413c2c66affSColin Finck     LONG lindex)
1414c2c66affSColin Finck {
1415c2c66affSColin Finck     CHECK_EXPECTED_METHOD("AdviseSink_OnViewChange");
1416c2c66affSColin Finck }
1417c2c66affSColin Finck 
AdviseSink_OnRename(IAdviseSink * iface,IMoniker * pmk)1418c2c66affSColin Finck static void WINAPI AdviseSink_OnRename(
1419c2c66affSColin Finck     IAdviseSink *iface,
1420c2c66affSColin Finck     IMoniker *pmk)
1421c2c66affSColin Finck {
1422c2c66affSColin Finck     CHECK_EXPECTED_METHOD("AdviseSink_OnRename");
1423c2c66affSColin Finck }
1424c2c66affSColin Finck 
AdviseSink_OnSave(IAdviseSink * iface)1425c2c66affSColin Finck static void WINAPI AdviseSink_OnSave(IAdviseSink *iface)
1426c2c66affSColin Finck {
1427c2c66affSColin Finck     CHECK_EXPECTED_METHOD("AdviseSink_OnSave");
1428c2c66affSColin Finck }
1429c2c66affSColin Finck 
AdviseSink_OnClose(IAdviseSink * iface)1430c2c66affSColin Finck static void WINAPI AdviseSink_OnClose(IAdviseSink *iface)
1431c2c66affSColin Finck {
1432c2c66affSColin Finck     CHECK_EXPECTED_METHOD("AdviseSink_OnClose");
1433c2c66affSColin Finck }
1434c2c66affSColin Finck 
1435c2c66affSColin Finck static const IAdviseSinkVtbl AdviseSinkVtbl =
1436c2c66affSColin Finck {
1437c2c66affSColin Finck     AdviseSink_QueryInterface,
1438c2c66affSColin Finck     AdviseSink_AddRef,
1439c2c66affSColin Finck     AdviseSink_Release,
1440c2c66affSColin Finck     AdviseSink_OnDataChange,
1441c2c66affSColin Finck     AdviseSink_OnViewChange,
1442c2c66affSColin Finck     AdviseSink_OnRename,
1443c2c66affSColin Finck     AdviseSink_OnSave,
1444c2c66affSColin Finck     AdviseSink_OnClose
1445c2c66affSColin Finck };
1446c2c66affSColin Finck 
1447c2c66affSColin Finck static IAdviseSink AdviseSink = { &AdviseSinkVtbl };
1448c2c66affSColin Finck 
DataObject_QueryInterface(IDataObject * iface,REFIID riid,void ** ppvObject)1449c2c66affSColin Finck static HRESULT WINAPI DataObject_QueryInterface(
1450c2c66affSColin Finck             IDataObject*     iface,
1451c2c66affSColin Finck             REFIID           riid,
1452c2c66affSColin Finck             void**           ppvObject)
1453c2c66affSColin Finck {
1454c2c66affSColin Finck     CHECK_EXPECTED_METHOD("DataObject_QueryInterface");
1455c2c66affSColin Finck 
1456c2c66affSColin Finck     if (IsEqualIID(riid, &IID_IDataObject) || IsEqualIID(riid, &IID_IUnknown))
1457c2c66affSColin Finck     {
1458c2c66affSColin Finck         *ppvObject = iface;
1459c2c66affSColin Finck         return S_OK;
1460c2c66affSColin Finck     }
1461c2c66affSColin Finck     *ppvObject = NULL;
1462c2c66affSColin Finck     return S_OK;
1463c2c66affSColin Finck }
1464c2c66affSColin Finck 
DataObject_AddRef(IDataObject * iface)1465c2c66affSColin Finck static ULONG WINAPI DataObject_AddRef(
1466c2c66affSColin Finck             IDataObject*     iface)
1467c2c66affSColin Finck {
1468c2c66affSColin Finck     CHECK_EXPECTED_METHOD("DataObject_AddRef");
1469c2c66affSColin Finck     return 2;
1470c2c66affSColin Finck }
1471c2c66affSColin Finck 
DataObject_Release(IDataObject * iface)1472c2c66affSColin Finck static ULONG WINAPI DataObject_Release(
1473c2c66affSColin Finck             IDataObject*     iface)
1474c2c66affSColin Finck {
1475c2c66affSColin Finck     CHECK_EXPECTED_METHOD("DataObject_Release");
1476c2c66affSColin Finck     return 1;
1477c2c66affSColin Finck }
1478c2c66affSColin Finck 
fmtetc_equal(const FORMATETC * a,const FORMATETC * b)1479b44b1afbSAmine Khaldi static inline BOOL fmtetc_equal( const FORMATETC *a, const FORMATETC *b )
1480c2c66affSColin Finck {
1481b44b1afbSAmine Khaldi     /* FIXME ptd */
1482b44b1afbSAmine Khaldi     return a->cfFormat == b->cfFormat && a->dwAspect == b->dwAspect &&
1483b44b1afbSAmine Khaldi         a->lindex == b->lindex && a->tymed == b->tymed;
1484b44b1afbSAmine Khaldi 
1485b44b1afbSAmine Khaldi }
1486b44b1afbSAmine Khaldi 
DataObject_GetData(IDataObject * iface,FORMATETC * fmt_in,STGMEDIUM * med)1487b44b1afbSAmine Khaldi static HRESULT WINAPI DataObject_GetData( IDataObject *iface, FORMATETC *fmt_in,
1488b44b1afbSAmine Khaldi                                           STGMEDIUM *med )
1489b44b1afbSAmine Khaldi {
1490b44b1afbSAmine Khaldi     FORMATETC *fmt;
1491b44b1afbSAmine Khaldi 
1492b44b1afbSAmine Khaldi     CHECK_EXPECTED_METHOD_FMT("DataObject_GetData", fmt_in);
1493b44b1afbSAmine Khaldi 
1494b44b1afbSAmine Khaldi     for (fmt = g_dataobject_fmts; fmt && fmt->cfFormat != 0; fmt++)
1495b44b1afbSAmine Khaldi     {
1496b44b1afbSAmine Khaldi         if (fmtetc_equal( fmt_in, fmt ))
1497b44b1afbSAmine Khaldi         {
1498b44b1afbSAmine Khaldi             switch (fmt->cfFormat)
1499b44b1afbSAmine Khaldi             {
1500b44b1afbSAmine Khaldi             case CF_DIB:
1501b44b1afbSAmine Khaldi                 create_dib( med );
1502b44b1afbSAmine Khaldi                 return S_OK;
1503b44b1afbSAmine Khaldi             case CF_BITMAP:
1504b44b1afbSAmine Khaldi                 create_bitmap( med );
1505b44b1afbSAmine Khaldi                 return S_OK;
1506*5c1bcfecSAmine Khaldi             case CF_ENHMETAFILE:
1507*5c1bcfecSAmine Khaldi                 create_emf( med );
1508*5c1bcfecSAmine Khaldi                 return S_OK;
1509*5c1bcfecSAmine Khaldi             case CF_TEXT:
1510*5c1bcfecSAmine Khaldi                 create_text( med );
1511*5c1bcfecSAmine Khaldi                 return S_OK;
1512b44b1afbSAmine Khaldi             default:
1513b44b1afbSAmine Khaldi                 trace( "unhandled fmt %d\n", fmt->cfFormat );
1514b44b1afbSAmine Khaldi             }
1515b44b1afbSAmine Khaldi         }
1516b44b1afbSAmine Khaldi     }
1517b44b1afbSAmine Khaldi 
1518b44b1afbSAmine Khaldi     return S_FALSE;
1519c2c66affSColin Finck }
1520c2c66affSColin Finck 
DataObject_GetDataHere(IDataObject * iface,LPFORMATETC pformatetc,STGMEDIUM * pmedium)1521c2c66affSColin Finck static HRESULT WINAPI DataObject_GetDataHere(
1522c2c66affSColin Finck         IDataObject*     iface,
1523c2c66affSColin Finck         LPFORMATETC      pformatetc,
1524c2c66affSColin Finck         STGMEDIUM*       pmedium)
1525c2c66affSColin Finck {
1526c2c66affSColin Finck     CHECK_EXPECTED_METHOD("DataObject_GetDataHere");
1527c2c66affSColin Finck     return E_NOTIMPL;
1528c2c66affSColin Finck }
1529c2c66affSColin Finck 
DataObject_QueryGetData(IDataObject * iface,FORMATETC * fmt_in)1530b44b1afbSAmine Khaldi static HRESULT WINAPI DataObject_QueryGetData( IDataObject *iface, FORMATETC *fmt_in )
1531c2c66affSColin Finck {
1532b44b1afbSAmine Khaldi     FORMATETC *fmt;
1533b44b1afbSAmine Khaldi 
1534b44b1afbSAmine Khaldi     CHECK_EXPECTED_METHOD_FMT("DataObject_QueryGetData", fmt_in);
1535b44b1afbSAmine Khaldi 
1536b44b1afbSAmine Khaldi     for (fmt = g_dataobject_fmts; fmt && fmt->cfFormat != 0; fmt++)
1537b44b1afbSAmine Khaldi         if (fmtetc_equal( fmt_in, fmt )) return S_OK;
1538b44b1afbSAmine Khaldi 
1539b44b1afbSAmine Khaldi     return S_FALSE;
1540c2c66affSColin Finck }
1541c2c66affSColin Finck 
DataObject_GetCanonicalFormatEtc(IDataObject * iface,LPFORMATETC pformatectIn,LPFORMATETC pformatetcOut)1542c2c66affSColin Finck static HRESULT WINAPI DataObject_GetCanonicalFormatEtc(
1543c2c66affSColin Finck         IDataObject*     iface,
1544c2c66affSColin Finck         LPFORMATETC      pformatectIn,
1545c2c66affSColin Finck         LPFORMATETC      pformatetcOut)
1546c2c66affSColin Finck {
1547c2c66affSColin Finck     CHECK_EXPECTED_METHOD("DataObject_GetCanonicalFormatEtc");
1548c2c66affSColin Finck     return E_NOTIMPL;
1549c2c66affSColin Finck }
1550c2c66affSColin Finck 
DataObject_SetData(IDataObject * iface,LPFORMATETC pformatetc,STGMEDIUM * pmedium,BOOL fRelease)1551c2c66affSColin Finck static HRESULT WINAPI DataObject_SetData(
1552c2c66affSColin Finck         IDataObject*     iface,
1553c2c66affSColin Finck         LPFORMATETC      pformatetc,
1554c2c66affSColin Finck         STGMEDIUM*       pmedium,
1555c2c66affSColin Finck         BOOL             fRelease)
1556c2c66affSColin Finck {
1557c2c66affSColin Finck     CHECK_EXPECTED_METHOD("DataObject_SetData");
1558c2c66affSColin Finck     return E_NOTIMPL;
1559c2c66affSColin Finck }
1560c2c66affSColin Finck 
DataObject_EnumFormatEtc(IDataObject * iface,DWORD dwDirection,IEnumFORMATETC ** ppenumFormatEtc)1561c2c66affSColin Finck static HRESULT WINAPI DataObject_EnumFormatEtc(
1562c2c66affSColin Finck         IDataObject*     iface,
1563c2c66affSColin Finck         DWORD            dwDirection,
1564c2c66affSColin Finck         IEnumFORMATETC** ppenumFormatEtc)
1565c2c66affSColin Finck {
1566c2c66affSColin Finck     CHECK_EXPECTED_METHOD("DataObject_EnumFormatEtc");
1567c2c66affSColin Finck     return E_NOTIMPL;
1568c2c66affSColin Finck }
1569c2c66affSColin Finck 
DataObject_DAdvise(IDataObject * iface,FORMATETC * pformatetc,DWORD advf,IAdviseSink * pAdvSink,DWORD * pdwConnection)1570c2c66affSColin Finck static HRESULT WINAPI DataObject_DAdvise(
1571c2c66affSColin Finck         IDataObject*     iface,
1572c2c66affSColin Finck         FORMATETC*       pformatetc,
1573c2c66affSColin Finck         DWORD            advf,
1574c2c66affSColin Finck         IAdviseSink*     pAdvSink,
1575c2c66affSColin Finck         DWORD*           pdwConnection)
1576c2c66affSColin Finck {
1577c2c66affSColin Finck     STGMEDIUM stgmedium;
1578c2c66affSColin Finck 
1579c2c66affSColin Finck     CHECK_EXPECTED_METHOD("DataObject_DAdvise");
1580c2c66affSColin Finck     *pdwConnection = 1;
1581c2c66affSColin Finck 
1582c2c66affSColin Finck     if(advf & ADVF_PRIMEFIRST)
1583c2c66affSColin Finck     {
1584c2c66affSColin Finck         ok(pformatetc->cfFormat == cf_test_2, "got %04x\n", pformatetc->cfFormat);
1585c2c66affSColin Finck         stgmedium.tymed = TYMED_HGLOBAL;
1586c2c66affSColin Finck         U(stgmedium).hGlobal = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, 4);
1587c2c66affSColin Finck         stgmedium.pUnkForRelease = NULL;
1588c2c66affSColin Finck         IAdviseSink_OnDataChange(pAdvSink, pformatetc, &stgmedium);
1589c2c66affSColin Finck     }
1590c2c66affSColin Finck 
1591c2c66affSColin Finck     return S_OK;
1592c2c66affSColin Finck }
1593c2c66affSColin Finck 
DataObject_DUnadvise(IDataObject * iface,DWORD dwConnection)1594c2c66affSColin Finck static HRESULT WINAPI DataObject_DUnadvise(
1595c2c66affSColin Finck         IDataObject*     iface,
1596c2c66affSColin Finck         DWORD            dwConnection)
1597c2c66affSColin Finck {
1598c2c66affSColin Finck     CHECK_EXPECTED_METHOD("DataObject_DUnadvise");
1599c2c66affSColin Finck     return S_OK;
1600c2c66affSColin Finck }
1601c2c66affSColin Finck 
DataObject_EnumDAdvise(IDataObject * iface,IEnumSTATDATA ** ppenumAdvise)1602c2c66affSColin Finck static HRESULT WINAPI DataObject_EnumDAdvise(
1603c2c66affSColin Finck         IDataObject*     iface,
1604c2c66affSColin Finck         IEnumSTATDATA**  ppenumAdvise)
1605c2c66affSColin Finck {
1606c2c66affSColin Finck     CHECK_EXPECTED_METHOD("DataObject_EnumDAdvise");
1607c2c66affSColin Finck     return OLE_E_ADVISENOTSUPPORTED;
1608c2c66affSColin Finck }
1609c2c66affSColin Finck 
1610c2c66affSColin Finck static IDataObjectVtbl DataObjectVtbl =
1611c2c66affSColin Finck {
1612c2c66affSColin Finck     DataObject_QueryInterface,
1613c2c66affSColin Finck     DataObject_AddRef,
1614c2c66affSColin Finck     DataObject_Release,
1615c2c66affSColin Finck     DataObject_GetData,
1616c2c66affSColin Finck     DataObject_GetDataHere,
1617c2c66affSColin Finck     DataObject_QueryGetData,
1618c2c66affSColin Finck     DataObject_GetCanonicalFormatEtc,
1619c2c66affSColin Finck     DataObject_SetData,
1620c2c66affSColin Finck     DataObject_EnumFormatEtc,
1621c2c66affSColin Finck     DataObject_DAdvise,
1622c2c66affSColin Finck     DataObject_DUnadvise,
1623c2c66affSColin Finck     DataObject_EnumDAdvise
1624c2c66affSColin Finck };
1625c2c66affSColin Finck 
1626c2c66affSColin Finck static IDataObject DataObject = { &DataObjectVtbl };
1627c2c66affSColin Finck 
Unknown_QueryInterface(IUnknown * iface,REFIID riid,void ** ppv)1628c2c66affSColin Finck static HRESULT WINAPI Unknown_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
1629c2c66affSColin Finck {
1630c2c66affSColin Finck     *ppv = NULL;
1631c2c66affSColin Finck     if (IsEqualIID(riid, &IID_IUnknown)) *ppv = iface;
1632c2c66affSColin Finck     if (*ppv)
1633c2c66affSColin Finck     {
1634c2c66affSColin Finck         IUnknown_AddRef((IUnknown *)*ppv);
1635c2c66affSColin Finck         return S_OK;
1636c2c66affSColin Finck     }
1637c2c66affSColin Finck     return E_NOINTERFACE;
1638c2c66affSColin Finck }
1639c2c66affSColin Finck 
Unknown_AddRef(IUnknown * iface)1640c2c66affSColin Finck static ULONG WINAPI Unknown_AddRef(IUnknown *iface)
1641c2c66affSColin Finck {
1642c2c66affSColin Finck     return 2;
1643c2c66affSColin Finck }
1644c2c66affSColin Finck 
Unknown_Release(IUnknown * iface)1645c2c66affSColin Finck static ULONG WINAPI Unknown_Release(IUnknown *iface)
1646c2c66affSColin Finck {
1647c2c66affSColin Finck     return 1;
1648c2c66affSColin Finck }
1649c2c66affSColin Finck 
1650c2c66affSColin Finck static const IUnknownVtbl UnknownVtbl =
1651c2c66affSColin Finck {
1652c2c66affSColin Finck     Unknown_QueryInterface,
1653c2c66affSColin Finck     Unknown_AddRef,
1654c2c66affSColin Finck     Unknown_Release
1655c2c66affSColin Finck };
1656c2c66affSColin Finck 
1657c2c66affSColin Finck static IUnknown unknown = { &UnknownVtbl };
1658c2c66affSColin Finck 
check_enum_cache(IOleCache2 * cache,const STATDATA * expect,int num)1659c2c66affSColin Finck static void check_enum_cache(IOleCache2 *cache, const STATDATA *expect, int num)
1660c2c66affSColin Finck {
1661c2c66affSColin Finck     IEnumSTATDATA *enum_stat;
1662c2c66affSColin Finck     STATDATA stat;
1663c2c66affSColin Finck     HRESULT hr;
1664c2c66affSColin Finck 
1665c2c66affSColin Finck     hr = IOleCache2_EnumCache( cache, &enum_stat );
1666c2c66affSColin Finck     ok( hr == S_OK, "got %08x\n", hr );
1667c2c66affSColin Finck 
1668c2c66affSColin Finck     while (IEnumSTATDATA_Next(enum_stat, 1, &stat, NULL) == S_OK)
1669c2c66affSColin Finck     {
1670c2c66affSColin Finck         ok( stat.formatetc.cfFormat == expect->formatetc.cfFormat, "got %d expect %d\n",
1671c2c66affSColin Finck             stat.formatetc.cfFormat, expect->formatetc.cfFormat );
1672c2c66affSColin Finck         ok( !stat.formatetc.ptd == !expect->formatetc.ptd, "got %p expect %p\n",
1673c2c66affSColin Finck             stat.formatetc.ptd, expect->formatetc.ptd );
1674c2c66affSColin Finck         ok( stat.formatetc.dwAspect == expect->formatetc.dwAspect, "got %d expect %d\n",
1675c2c66affSColin Finck             stat.formatetc.dwAspect, expect->formatetc.dwAspect );
1676c2c66affSColin Finck         ok( stat.formatetc.lindex == expect->formatetc.lindex, "got %d expect %d\n",
1677c2c66affSColin Finck             stat.formatetc.lindex, expect->formatetc.lindex );
1678c2c66affSColin Finck         ok( stat.formatetc.tymed == expect->formatetc.tymed, "got %d expect %d\n",
1679c2c66affSColin Finck             stat.formatetc.tymed, expect->formatetc.tymed );
1680c2c66affSColin Finck         ok( stat.advf == expect->advf, "got %d expect %d\n", stat.advf, expect->advf );
1681c2c66affSColin Finck         ok( stat.pAdvSink == 0, "got %p\n", stat.pAdvSink );
1682c2c66affSColin Finck         ok( stat.dwConnection == expect->dwConnection, "got %d expect %d\n", stat.dwConnection, expect->dwConnection );
1683c2c66affSColin Finck         num--;
1684c2c66affSColin Finck         expect++;
1685c2c66affSColin Finck     }
1686c2c66affSColin Finck 
1687c2c66affSColin Finck     ok( num == 0, "incorrect number. num %d\n", num );
1688c2c66affSColin Finck 
1689c2c66affSColin Finck     IEnumSTATDATA_Release( enum_stat );
1690c2c66affSColin Finck }
1691c2c66affSColin Finck 
test_data_cache(void)1692c2c66affSColin Finck static void test_data_cache(void)
1693c2c66affSColin Finck {
1694c2c66affSColin Finck     HRESULT hr;
1695c2c66affSColin Finck     IOleCache2 *pOleCache;
1696c2c66affSColin Finck     IOleCache *olecache;
1697c2c66affSColin Finck     IStorage *pStorage;
1698b44b1afbSAmine Khaldi     IUnknown *unk, *unk2;
1699c2c66affSColin Finck     IPersistStorage *pPS;
1700c2c66affSColin Finck     IViewObject *pViewObject;
1701c2c66affSColin Finck     IOleCacheControl *pOleCacheControl;
1702c2c66affSColin Finck     IDataObject *pCacheDataObject;
1703c2c66affSColin Finck     FORMATETC fmtetc;
1704c2c66affSColin Finck     STGMEDIUM stgmedium;
1705c2c66affSColin Finck     DWORD dwConnection;
1706c2c66affSColin Finck     DWORD dwFreeze;
1707c2c66affSColin Finck     RECTL rcBounds;
1708c2c66affSColin Finck     HDC hdcMem;
1709c2c66affSColin Finck     CLSID clsid;
1710c2c66affSColin Finck     char szSystemDir[MAX_PATH];
1711c2c66affSColin Finck     WCHAR wszPath[MAX_PATH];
1712c2c66affSColin Finck     static const WCHAR wszShell32[] = {'\\','s','h','e','l','l','3','2','.','d','l','l',0};
1713c2c66affSColin Finck 
1714c2c66affSColin Finck     static const struct expected_method methods_cacheinitnew[] =
1715c2c66affSColin Finck     {
1716c2c66affSColin Finck         { "AdviseSink_OnViewChange", 0 },
1717c2c66affSColin Finck         { "AdviseSink_OnViewChange", 0 },
1718c2c66affSColin Finck         { "draw_continue", 1 },
1719c2c66affSColin Finck         { "draw_continue_false", 1 },
1720c2c66affSColin Finck         { "DataObject_DAdvise", 0 },
1721c2c66affSColin Finck         { "DataObject_DAdvise", 0 },
1722c2c66affSColin Finck         { "DataObject_DUnadvise", 0 },
1723c2c66affSColin Finck         { "DataObject_DUnadvise", 0 },
1724c2c66affSColin Finck         { NULL, 0 }
1725c2c66affSColin Finck     };
1726c2c66affSColin Finck     static const struct expected_method methods_cacheload[] =
1727c2c66affSColin Finck     {
1728c2c66affSColin Finck         { "AdviseSink_OnViewChange", 0 },
1729c2c66affSColin Finck         { "draw_continue", 1 },
1730c2c66affSColin Finck         { "draw_continue", 1 },
1731c2c66affSColin Finck         { "draw_continue", 1 },
1732b44b1afbSAmine Khaldi         { "DataObject_GetData", 0, { CF_DIB,          NULL, DVASPECT_THUMBNAIL, -1, TYMED_HGLOBAL} },
1733b44b1afbSAmine Khaldi         { "DataObject_GetData", 0, { CF_BITMAP,       NULL, DVASPECT_THUMBNAIL, -1, TYMED_GDI} },
1734b44b1afbSAmine Khaldi         { "DataObject_GetData", 0, { CF_METAFILEPICT, NULL, DVASPECT_ICON,      -1, TYMED_MFPICT} },
1735c2c66affSColin Finck         { NULL, 0 }
1736c2c66affSColin Finck     };
1737c2c66affSColin Finck     static const struct expected_method methods_cachethenrun[] =
1738c2c66affSColin Finck     {
1739c2c66affSColin Finck         { "DataObject_DAdvise", 0 },
1740c2c66affSColin Finck         { "DataObject_DAdvise", 0 },
1741c2c66affSColin Finck         { "DataObject_DAdvise", 0 },
1742c2c66affSColin Finck         { "DataObject_DAdvise", 0 },
1743c2c66affSColin Finck         { "DataObject_DUnadvise", 0 },
1744c2c66affSColin Finck         { "DataObject_DUnadvise", 0 },
1745c2c66affSColin Finck         { "DataObject_DUnadvise", 0 },
1746c2c66affSColin Finck         { "DataObject_DUnadvise", 0 },
1747c2c66affSColin Finck         { NULL, 0 }
1748c2c66affSColin Finck     };
1749c2c66affSColin Finck 
1750*5c1bcfecSAmine Khaldi     GetSystemDirectoryA(szSystemDir, ARRAY_SIZE(szSystemDir));
1751c2c66affSColin Finck 
1752c2c66affSColin Finck     expected_method_list = methods_cacheinitnew;
1753c2c66affSColin Finck 
1754c2c66affSColin Finck     fmtetc.cfFormat = CF_METAFILEPICT;
1755c2c66affSColin Finck     fmtetc.dwAspect = DVASPECT_ICON;
1756c2c66affSColin Finck     fmtetc.lindex = -1;
1757c2c66affSColin Finck     fmtetc.ptd = NULL;
1758c2c66affSColin Finck     fmtetc.tymed = TYMED_MFPICT;
1759c2c66affSColin Finck 
1760c2c66affSColin Finck     hr = StgCreateDocfile(NULL, STGM_READWRITE | STGM_CREATE | STGM_SHARE_EXCLUSIVE | STGM_DELETEONRELEASE, 0, &pStorage);
1761c2c66affSColin Finck     ok_ole_success(hr, "StgCreateDocfile");
1762c2c66affSColin Finck 
1763c2c66affSColin Finck     /* aggregation */
1764c2c66affSColin Finck 
1765c2c66affSColin Finck     /* requested is not IUnknown */
1766c2c66affSColin Finck     hr = CreateDataCache(&unknown, &CLSID_NULL, &IID_IOleCache2, (void**)&pOleCache);
1767c2c66affSColin Finck     ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
1768c2c66affSColin Finck 
1769c2c66affSColin Finck     hr = CreateDataCache(&unknown, &CLSID_NULL, &IID_IUnknown, (void**)&unk);
1770c2c66affSColin Finck     ok(hr == S_OK, "got 0x%08x\n", hr);
1771c2c66affSColin Finck 
1772c2c66affSColin Finck     hr = IUnknown_QueryInterface(unk, &IID_IOleCache, (void**)&olecache);
1773c2c66affSColin Finck     ok(hr == S_OK, "got 0x%08x\n", hr);
1774c2c66affSColin Finck     hr = IUnknown_QueryInterface(unk, &IID_IOleCache2, (void**)&pOleCache);
1775c2c66affSColin Finck     ok(hr == S_OK, "got 0x%08x\n", hr);
1776c2c66affSColin Finck     ok(unk != (IUnknown*)olecache, "got %p, expected %p\n", olecache, unk);
1777c2c66affSColin Finck     ok(unk != (IUnknown*)pOleCache, "got %p, expected %p\n", pOleCache, unk);
1778c2c66affSColin Finck     IOleCache2_Release(pOleCache);
1779c2c66affSColin Finck     IOleCache_Release(olecache);
1780c2c66affSColin Finck     IUnknown_Release(unk);
1781c2c66affSColin Finck 
1782c2c66affSColin Finck     hr = CreateDataCache(NULL, &CLSID_NULL, &IID_IUnknown, (void**)&unk);
1783c2c66affSColin Finck     ok(hr == S_OK, "got 0x%08x\n", hr);
1784c2c66affSColin Finck     hr = IUnknown_QueryInterface(unk, &IID_IOleCache, (void**)&olecache);
1785c2c66affSColin Finck     ok(hr == S_OK, "got 0x%08x\n", hr);
1786c2c66affSColin Finck     hr = IUnknown_QueryInterface(unk, &IID_IOleCache2, (void**)&pOleCache);
1787c2c66affSColin Finck     ok(hr == S_OK, "got 0x%08x\n", hr);
1788b44b1afbSAmine Khaldi     hr = IUnknown_QueryInterface(unk, &IID_IUnknown, (void**)&unk2);
1789b44b1afbSAmine Khaldi     ok(hr == S_OK, "got 0x%08x\n", hr);
1790c2c66affSColin Finck     ok(unk == (IUnknown*)olecache, "got %p, expected %p\n", olecache, unk);
1791c2c66affSColin Finck     ok(unk == (IUnknown*)pOleCache, "got %p, expected %p\n", pOleCache, unk);
1792b44b1afbSAmine Khaldi     ok(unk == unk2, "got %p, expected %p\n", unk2, unk);
1793b44b1afbSAmine Khaldi     IUnknown_Release(unk2);
1794c2c66affSColin Finck     IOleCache2_Release(pOleCache);
1795c2c66affSColin Finck     IOleCache_Release(olecache);
1796c2c66affSColin Finck     IUnknown_Release(unk);
1797c2c66affSColin Finck 
1798c2c66affSColin Finck     /* Test with new data */
1799c2c66affSColin Finck 
1800c2c66affSColin Finck     hr = CreateDataCache(NULL, &CLSID_NULL, &IID_IOleCache2, (LPVOID *)&pOleCache);
1801c2c66affSColin Finck     ok_ole_success(hr, "CreateDataCache");
1802c2c66affSColin Finck 
1803c2c66affSColin Finck     hr = IOleCache2_QueryInterface(pOleCache, &IID_IPersistStorage, (LPVOID *)&pPS);
1804c2c66affSColin Finck     ok_ole_success(hr, "IOleCache_QueryInterface(IID_IPersistStorage)");
1805c2c66affSColin Finck     hr = IOleCache2_QueryInterface(pOleCache, &IID_IViewObject, (LPVOID *)&pViewObject);
1806c2c66affSColin Finck     ok_ole_success(hr, "IOleCache_QueryInterface(IID_IViewObject)");
1807c2c66affSColin Finck     hr = IOleCache2_QueryInterface(pOleCache, &IID_IOleCacheControl, (LPVOID *)&pOleCacheControl);
1808c2c66affSColin Finck     ok_ole_success(hr, "IOleCache_QueryInterface(IID_IOleCacheControl)");
1809c2c66affSColin Finck 
1810c2c66affSColin Finck     hr = IViewObject_SetAdvise(pViewObject, DVASPECT_ICON, ADVF_PRIMEFIRST, &AdviseSink);
1811c2c66affSColin Finck     ok_ole_success(hr, "IViewObject_SetAdvise");
1812c2c66affSColin Finck 
1813c2c66affSColin Finck     hr = IPersistStorage_InitNew(pPS, pStorage);
1814c2c66affSColin Finck     ok_ole_success(hr, "IPersistStorage_InitNew");
1815c2c66affSColin Finck 
1816c2c66affSColin Finck     hr = IPersistStorage_IsDirty(pPS);
1817c2c66affSColin Finck     ok_ole_success(hr, "IPersistStorage_IsDirty");
1818c2c66affSColin Finck 
1819c2c66affSColin Finck     hr = IPersistStorage_GetClassID(pPS, &clsid);
1820c2c66affSColin Finck     ok_ole_success(hr, "IPersistStorage_GetClassID");
1821c2c66affSColin Finck     ok(IsEqualCLSID(&clsid, &IID_NULL), "clsid should be blank\n");
1822c2c66affSColin Finck 
1823c2c66affSColin Finck     hr = IOleCache2_Uncache(pOleCache, 0xdeadbeef);
1824c2c66affSColin Finck     ok(hr == OLE_E_NOCONNECTION, "IOleCache_Uncache with invalid value should return OLE_E_NOCONNECTION instead of 0x%x\n", hr);
1825c2c66affSColin Finck 
1826c2c66affSColin Finck     /* Both tests crash on NT4 and below. StgCreatePropSetStg is only available on w2k and above. */
1827c2c66affSColin Finck     if (GetProcAddress(GetModuleHandleA("ole32.dll"), "StgCreatePropSetStg"))
1828c2c66affSColin Finck     {
1829c2c66affSColin Finck         hr = IOleCache2_Cache(pOleCache, NULL, 0, &dwConnection);
1830c2c66affSColin Finck         ok(hr == E_INVALIDARG, "IOleCache_Cache with NULL fmtetc should have returned E_INVALIDARG instead of 0x%08x\n", hr);
1831c2c66affSColin Finck 
1832c2c66affSColin Finck         hr = IOleCache2_Cache(pOleCache, NULL, 0, NULL);
1833c2c66affSColin Finck         ok(hr == E_INVALIDARG, "IOleCache_Cache with NULL pdwConnection should have returned E_INVALIDARG instead of 0x%08x\n", hr);
1834c2c66affSColin Finck     }
1835c2c66affSColin Finck     else
1836c2c66affSColin Finck     {
1837c2c66affSColin Finck         skip("tests with NULL parameters will crash on NT4 and below\n");
1838c2c66affSColin Finck     }
1839c2c66affSColin Finck 
1840c2c66affSColin Finck     for (fmtetc.cfFormat = CF_TEXT; fmtetc.cfFormat < CF_MAX; fmtetc.cfFormat++)
1841c2c66affSColin Finck     {
1842c2c66affSColin Finck         int i;
1843c2c66affSColin Finck         fmtetc.dwAspect = DVASPECT_THUMBNAIL;
1844c2c66affSColin Finck         for (i = 0; i < 7; i++)
1845c2c66affSColin Finck         {
1846c2c66affSColin Finck             fmtetc.tymed = 1 << i;
1847c2c66affSColin Finck             hr = IOleCache2_Cache(pOleCache, &fmtetc, 0, &dwConnection);
1848c2c66affSColin Finck             if ((fmtetc.cfFormat == CF_METAFILEPICT && fmtetc.tymed == TYMED_MFPICT) ||
1849c2c66affSColin Finck                 (fmtetc.cfFormat == CF_BITMAP && fmtetc.tymed == TYMED_GDI) ||
1850c2c66affSColin Finck                 (fmtetc.cfFormat == CF_DIB && fmtetc.tymed == TYMED_HGLOBAL) ||
1851c2c66affSColin Finck                 (fmtetc.cfFormat == CF_ENHMETAFILE && fmtetc.tymed == TYMED_ENHMF))
1852c2c66affSColin Finck                 ok(hr == S_OK, "IOleCache_Cache cfFormat = %d, tymed = %d should have returned S_OK instead of 0x%08x\n",
1853c2c66affSColin Finck                     fmtetc.cfFormat, fmtetc.tymed, hr);
1854c2c66affSColin Finck             else if (fmtetc.tymed == TYMED_HGLOBAL)
1855c2c66affSColin Finck                 ok(hr == CACHE_S_FORMATETC_NOTSUPPORTED ||
1856c2c66affSColin Finck                    broken(hr == S_OK && fmtetc.cfFormat == CF_BITMAP) /* Win9x & NT4 */,
1857c2c66affSColin Finck                     "IOleCache_Cache cfFormat = %d, tymed = %d should have returned CACHE_S_FORMATETC_NOTSUPPORTED instead of 0x%08x\n",
1858c2c66affSColin Finck                     fmtetc.cfFormat, fmtetc.tymed, hr);
1859c2c66affSColin Finck             else
1860c2c66affSColin Finck                 ok(hr == DV_E_TYMED, "IOleCache_Cache cfFormat = %d, tymed = %d should have returned DV_E_TYMED instead of 0x%08x\n",
1861c2c66affSColin Finck                     fmtetc.cfFormat, fmtetc.tymed, hr);
1862c2c66affSColin Finck             if (SUCCEEDED(hr))
1863c2c66affSColin Finck             {
1864c2c66affSColin Finck                 hr = IOleCache2_Uncache(pOleCache, dwConnection);
1865c2c66affSColin Finck                 ok_ole_success(hr, "IOleCache_Uncache");
1866c2c66affSColin Finck             }
1867c2c66affSColin Finck         }
1868c2c66affSColin Finck     }
1869c2c66affSColin Finck 
1870c2c66affSColin Finck     fmtetc.cfFormat = CF_BITMAP;
1871c2c66affSColin Finck     fmtetc.dwAspect = DVASPECT_THUMBNAIL;
1872c2c66affSColin Finck     fmtetc.tymed = TYMED_GDI;
1873c2c66affSColin Finck     hr = IOleCache2_Cache(pOleCache, &fmtetc, 0, &dwConnection);
1874c2c66affSColin Finck     ok_ole_success(hr, "IOleCache_Cache");
1875c2c66affSColin Finck 
1876c2c66affSColin Finck     fmtetc.cfFormat = 0;
1877c2c66affSColin Finck     fmtetc.dwAspect = DVASPECT_ICON;
1878c2c66affSColin Finck     fmtetc.tymed = TYMED_MFPICT;
1879c2c66affSColin Finck     hr = IOleCache2_Cache(pOleCache, &fmtetc, 0, &dwConnection);
1880c2c66affSColin Finck     ok_ole_success(hr, "IOleCache_Cache");
1881c2c66affSColin Finck 
1882*5c1bcfecSAmine Khaldi     MultiByteToWideChar(CP_ACP, 0, szSystemDir, -1, wszPath, ARRAY_SIZE(wszPath));
1883c2c66affSColin Finck     memcpy(wszPath+lstrlenW(wszPath), wszShell32, sizeof(wszShell32));
1884c2c66affSColin Finck 
1885c2c66affSColin Finck     fmtetc.cfFormat = CF_METAFILEPICT;
1886c2c66affSColin Finck     stgmedium.tymed = TYMED_MFPICT;
1887c2c66affSColin Finck     U(stgmedium).hMetaFilePict = OleMetafilePictFromIconAndLabel(
1888c2c66affSColin Finck         LoadIconA(NULL, (LPSTR)IDI_APPLICATION), wszPath, wszPath, 0);
1889c2c66affSColin Finck     stgmedium.pUnkForRelease = NULL;
1890c2c66affSColin Finck 
1891c2c66affSColin Finck     fmtetc.dwAspect = DVASPECT_CONTENT;
1892c2c66affSColin Finck     hr = IOleCache2_SetData(pOleCache, &fmtetc, &stgmedium, FALSE);
1893c2c66affSColin Finck     ok(hr == OLE_E_BLANK, "IOleCache_SetData for aspect not in cache should have return OLE_E_BLANK instead of 0x%08x\n", hr);
1894c2c66affSColin Finck 
1895c2c66affSColin Finck     fmtetc.dwAspect = DVASPECT_ICON;
1896c2c66affSColin Finck     hr = IOleCache2_SetData(pOleCache, &fmtetc, &stgmedium, FALSE);
1897c2c66affSColin Finck     ok_ole_success(hr, "IOleCache_SetData");
1898c2c66affSColin Finck     ReleaseStgMedium(&stgmedium);
1899c2c66affSColin Finck 
1900c2c66affSColin Finck     hr = IViewObject_Freeze(pViewObject, DVASPECT_ICON, -1, NULL, &dwFreeze);
1901c2c66affSColin Finck     todo_wine {
1902c2c66affSColin Finck     ok_ole_success(hr, "IViewObject_Freeze");
1903c2c66affSColin Finck     hr = IViewObject_Freeze(pViewObject, DVASPECT_CONTENT, -1, NULL, &dwFreeze);
1904c2c66affSColin Finck     ok(hr == OLE_E_BLANK, "IViewObject_Freeze with uncached aspect should have returned OLE_E_BLANK instead of 0x%08x\n", hr);
1905c2c66affSColin Finck     }
1906c2c66affSColin Finck 
1907c2c66affSColin Finck     rcBounds.left = 0;
1908c2c66affSColin Finck     rcBounds.top = 0;
1909c2c66affSColin Finck     rcBounds.right = 100;
1910c2c66affSColin Finck     rcBounds.bottom = 100;
1911c2c66affSColin Finck     hdcMem = CreateCompatibleDC(NULL);
1912c2c66affSColin Finck 
1913c2c66affSColin Finck     hr = IViewObject_Draw(pViewObject, DVASPECT_ICON, -1, NULL, NULL, NULL, hdcMem, &rcBounds, NULL, draw_continue, 0xdeadbeef);
1914c2c66affSColin Finck     ok_ole_success(hr, "IViewObject_Draw");
1915c2c66affSColin Finck 
1916c2c66affSColin Finck     hr = IViewObject_Draw(pViewObject, DVASPECT_CONTENT, -1, NULL, NULL, NULL, hdcMem, &rcBounds, NULL, draw_continue, 0xdeadbeef);
1917c2c66affSColin Finck     ok(hr == OLE_E_BLANK, "IViewObject_Draw with uncached aspect should have returned OLE_E_BLANK instead of 0x%08x\n", hr);
1918c2c66affSColin Finck 
1919c2c66affSColin Finck     /* a NULL draw_continue fn ptr */
1920c2c66affSColin Finck     hr = IViewObject_Draw(pViewObject, DVASPECT_ICON, -1, NULL, NULL, NULL, hdcMem, &rcBounds, NULL, NULL, 0xdeadbeef);
1921c2c66affSColin Finck     ok_ole_success(hr, "IViewObject_Draw");
1922c2c66affSColin Finck 
1923c2c66affSColin Finck     /* draw_continue that returns FALSE to abort drawing */
1924c2c66affSColin Finck     hr = IViewObject_Draw(pViewObject, DVASPECT_ICON, -1, NULL, NULL, NULL, hdcMem, &rcBounds, NULL, draw_continue_false, 0xdeadbeef);
1925c2c66affSColin Finck     ok(hr == E_ABORT ||
1926c2c66affSColin Finck        broken(hr == S_OK), /* win9x may skip the callbacks */
1927c2c66affSColin Finck        "IViewObject_Draw with draw_continue_false returns 0x%08x\n", hr);
1928c2c66affSColin Finck 
1929c2c66affSColin Finck     DeleteDC(hdcMem);
1930c2c66affSColin Finck 
1931c2c66affSColin Finck     hr = IOleCacheControl_OnRun(pOleCacheControl, &DataObject);
1932c2c66affSColin Finck     ok_ole_success(hr, "IOleCacheControl_OnRun");
1933c2c66affSColin Finck 
1934c2c66affSColin Finck     hr = IPersistStorage_Save(pPS, pStorage, TRUE);
1935c2c66affSColin Finck     ok_ole_success(hr, "IPersistStorage_Save");
1936c2c66affSColin Finck 
1937c2c66affSColin Finck     hr = IPersistStorage_SaveCompleted(pPS, NULL);
1938c2c66affSColin Finck     ok_ole_success(hr, "IPersistStorage_SaveCompleted");
1939c2c66affSColin Finck 
1940c2c66affSColin Finck     hr = IPersistStorage_IsDirty(pPS);
1941c2c66affSColin Finck     ok(hr == S_FALSE, "IPersistStorage_IsDirty should have returned S_FALSE instead of 0x%x\n", hr);
1942c2c66affSColin Finck 
1943c2c66affSColin Finck     IPersistStorage_Release(pPS);
1944c2c66affSColin Finck     IViewObject_Release(pViewObject);
1945c2c66affSColin Finck     IOleCache2_Release(pOleCache);
1946c2c66affSColin Finck     IOleCacheControl_Release(pOleCacheControl);
1947c2c66affSColin Finck 
1948c2c66affSColin Finck     CHECK_NO_EXTRA_METHODS();
1949c2c66affSColin Finck 
1950c2c66affSColin Finck     /* Test with loaded data */
1951c2c66affSColin Finck     trace("Testing loaded data with CreateDataCache:\n");
1952c2c66affSColin Finck     expected_method_list = methods_cacheload;
1953c2c66affSColin Finck 
1954c2c66affSColin Finck     hr = CreateDataCache(NULL, &CLSID_NULL, &IID_IOleCache2, (LPVOID *)&pOleCache);
1955c2c66affSColin Finck     ok_ole_success(hr, "CreateDataCache");
1956c2c66affSColin Finck 
1957c2c66affSColin Finck     hr = IOleCache2_QueryInterface(pOleCache, &IID_IPersistStorage, (LPVOID *)&pPS);
1958c2c66affSColin Finck     ok_ole_success(hr, "IOleCache_QueryInterface(IID_IPersistStorage)");
1959c2c66affSColin Finck     hr = IOleCache2_QueryInterface(pOleCache, &IID_IViewObject, (LPVOID *)&pViewObject);
1960c2c66affSColin Finck     ok_ole_success(hr, "IOleCache_QueryInterface(IID_IViewObject)");
1961c2c66affSColin Finck 
1962c2c66affSColin Finck     hr = IViewObject_SetAdvise(pViewObject, DVASPECT_ICON, ADVF_PRIMEFIRST, &AdviseSink);
1963c2c66affSColin Finck     ok_ole_success(hr, "IViewObject_SetAdvise");
1964c2c66affSColin Finck 
1965c2c66affSColin Finck     hr = IPersistStorage_Load(pPS, pStorage);
1966c2c66affSColin Finck     ok_ole_success(hr, "IPersistStorage_Load");
1967c2c66affSColin Finck 
1968c2c66affSColin Finck     hr = IPersistStorage_IsDirty(pPS);
1969c2c66affSColin Finck     ok(hr == S_FALSE, "IPersistStorage_IsDirty should have returned S_FALSE instead of 0x%x\n", hr);
1970c2c66affSColin Finck 
1971c2c66affSColin Finck     fmtetc.cfFormat = 0;
1972c2c66affSColin Finck     fmtetc.dwAspect = DVASPECT_ICON;
1973c2c66affSColin Finck     fmtetc.lindex = -1;
1974c2c66affSColin Finck     fmtetc.ptd = NULL;
1975c2c66affSColin Finck     fmtetc.tymed = TYMED_MFPICT;
1976c2c66affSColin Finck     hr = IOleCache2_Cache(pOleCache, &fmtetc, 0, &dwConnection);
1977c2c66affSColin Finck     ok(hr == CACHE_S_SAMECACHE, "IOleCache_Cache with already loaded data format type should return CACHE_S_SAMECACHE instead of 0x%x\n", hr);
1978c2c66affSColin Finck 
1979c2c66affSColin Finck     rcBounds.left = 0;
1980c2c66affSColin Finck     rcBounds.top = 0;
1981c2c66affSColin Finck     rcBounds.right = 100;
1982c2c66affSColin Finck     rcBounds.bottom = 100;
1983c2c66affSColin Finck     hdcMem = CreateCompatibleDC(NULL);
1984c2c66affSColin Finck 
1985c2c66affSColin Finck     hr = IViewObject_Draw(pViewObject, DVASPECT_ICON, -1, NULL, NULL, NULL, hdcMem, &rcBounds, NULL, draw_continue, 0xdeadbeef);
1986c2c66affSColin Finck     ok_ole_success(hr, "IViewObject_Draw");
1987c2c66affSColin Finck 
1988c2c66affSColin Finck     hr = IViewObject_Draw(pViewObject, DVASPECT_CONTENT, -1, NULL, NULL, NULL, hdcMem, &rcBounds, NULL, draw_continue, 0xdeadbeef);
1989c2c66affSColin Finck     ok(hr == OLE_E_BLANK, "IViewObject_Draw with uncached aspect should have returned OLE_E_BLANK instead of 0x%08x\n", hr);
1990c2c66affSColin Finck 
1991c2c66affSColin Finck     /* unload the cached storage object, causing it to be reloaded */
1992c2c66affSColin Finck     hr = IOleCache2_DiscardCache(pOleCache, DISCARDCACHE_NOSAVE);
1993c2c66affSColin Finck     ok_ole_success(hr, "IOleCache2_DiscardCache");
1994c2c66affSColin Finck     hr = IViewObject_Draw(pViewObject, DVASPECT_ICON, -1, NULL, NULL, NULL, hdcMem, &rcBounds, NULL, draw_continue, 0xdeadbeef);
1995c2c66affSColin Finck     ok_ole_success(hr, "IViewObject_Draw");
1996c2c66affSColin Finck 
1997c2c66affSColin Finck     /* unload the cached storage object, but don't allow it to be reloaded */
1998c2c66affSColin Finck     hr = IPersistStorage_HandsOffStorage(pPS);
1999c2c66affSColin Finck     ok_ole_success(hr, "IPersistStorage_HandsOffStorage");
2000c2c66affSColin Finck     hr = IViewObject_Draw(pViewObject, DVASPECT_ICON, -1, NULL, NULL, NULL, hdcMem, &rcBounds, NULL, draw_continue, 0xdeadbeef);
2001c2c66affSColin Finck     ok_ole_success(hr, "IViewObject_Draw");
2002c2c66affSColin Finck     hr = IOleCache2_DiscardCache(pOleCache, DISCARDCACHE_NOSAVE);
2003c2c66affSColin Finck     ok_ole_success(hr, "IOleCache2_DiscardCache");
2004c2c66affSColin Finck     hr = IViewObject_Draw(pViewObject, DVASPECT_ICON, -1, NULL, NULL, NULL, hdcMem, &rcBounds, NULL, draw_continue, 0xdeadbeef);
2005c2c66affSColin Finck     ok(hr == OLE_E_BLANK, "IViewObject_Draw with uncached aspect should have returned OLE_E_BLANK instead of 0x%08x\n", hr);
2006c2c66affSColin Finck 
2007c2c66affSColin Finck     DeleteDC(hdcMem);
2008c2c66affSColin Finck 
2009c2c66affSColin Finck     hr = IOleCache2_InitCache(pOleCache, &DataObject);
2010c2c66affSColin Finck     ok(hr == CACHE_E_NOCACHE_UPDATED, "IOleCache_InitCache should have returned CACHE_E_NOCACHE_UPDATED instead of 0x%08x\n", hr);
2011c2c66affSColin Finck 
2012c2c66affSColin Finck     IPersistStorage_Release(pPS);
2013c2c66affSColin Finck     IViewObject_Release(pViewObject);
2014c2c66affSColin Finck     IOleCache2_Release(pOleCache);
2015c2c66affSColin Finck 
2016c2c66affSColin Finck     CHECK_NO_EXTRA_METHODS();
2017c2c66affSColin Finck 
2018c2c66affSColin Finck     hr = CreateDataCache(NULL, &CLSID_NULL, &IID_IOleCache2, (LPVOID *)&pOleCache);
2019c2c66affSColin Finck     ok_ole_success(hr, "CreateDataCache");
2020c2c66affSColin Finck 
2021c2c66affSColin Finck     expected_method_list = methods_cachethenrun;
2022c2c66affSColin Finck 
2023c2c66affSColin Finck     hr = IOleCache2_QueryInterface(pOleCache, &IID_IDataObject, (LPVOID *)&pCacheDataObject);
2024c2c66affSColin Finck     ok_ole_success(hr, "IOleCache_QueryInterface(IID_IDataObject)");
2025c2c66affSColin Finck     hr = IOleCache2_QueryInterface(pOleCache, &IID_IOleCacheControl, (LPVOID *)&pOleCacheControl);
2026c2c66affSColin Finck     ok_ole_success(hr, "IOleCache_QueryInterface(IID_IOleCacheControl)");
2027c2c66affSColin Finck 
2028c2c66affSColin Finck     fmtetc.cfFormat = CF_METAFILEPICT;
2029c2c66affSColin Finck     fmtetc.dwAspect = DVASPECT_CONTENT;
2030c2c66affSColin Finck     fmtetc.tymed = TYMED_MFPICT;
2031c2c66affSColin Finck 
2032c2c66affSColin Finck     hr = IOleCache2_Cache(pOleCache, &fmtetc, 0, &dwConnection);
2033c2c66affSColin Finck     ok_ole_success(hr, "IOleCache_Cache");
2034c2c66affSColin Finck 
2035c2c66affSColin Finck     hr = IDataObject_GetData(pCacheDataObject, &fmtetc, &stgmedium);
2036c2c66affSColin Finck     ok(hr == OLE_E_BLANK, "got %08x\n", hr);
2037c2c66affSColin Finck 
2038c2c66affSColin Finck     fmtetc.cfFormat = cf_test_1;
2039c2c66affSColin Finck     fmtetc.dwAspect = DVASPECT_CONTENT;
2040c2c66affSColin Finck     fmtetc.tymed = TYMED_HGLOBAL;
2041c2c66affSColin Finck 
2042c2c66affSColin Finck     hr = IOleCache2_Cache(pOleCache, &fmtetc, 0, &dwConnection);
2043c2c66affSColin Finck     ok(hr == CACHE_S_FORMATETC_NOTSUPPORTED, "got %08x\n", hr);
2044c2c66affSColin Finck 
2045c2c66affSColin Finck     hr = IDataObject_GetData(pCacheDataObject, &fmtetc, &stgmedium);
2046c2c66affSColin Finck     ok(hr == OLE_E_BLANK, "got %08x\n", hr);
2047c2c66affSColin Finck 
2048c2c66affSColin Finck     fmtetc.cfFormat = cf_test_2;
2049c2c66affSColin Finck     hr = IOleCache2_Cache(pOleCache, &fmtetc, ADVF_PRIMEFIRST, &dwConnection);
2050c2c66affSColin Finck     ok(hr == CACHE_S_FORMATETC_NOTSUPPORTED, "got %08x\n", hr);
2051c2c66affSColin Finck 
2052c2c66affSColin Finck     hr = IDataObject_GetData(pCacheDataObject, &fmtetc, &stgmedium);
2053c2c66affSColin Finck     ok(hr == OLE_E_BLANK, "got %08x\n", hr);
2054c2c66affSColin Finck 
2055c2c66affSColin Finck     hr = IOleCacheControl_OnRun(pOleCacheControl, &DataObject);
2056c2c66affSColin Finck     ok_ole_success(hr, "IOleCacheControl_OnRun");
2057c2c66affSColin Finck 
2058c2c66affSColin Finck     fmtetc.cfFormat = cf_test_3;
2059c2c66affSColin Finck     hr = IOleCache2_Cache(pOleCache, &fmtetc, 0, &dwConnection);
2060c2c66affSColin Finck     ok(hr == CACHE_S_FORMATETC_NOTSUPPORTED, "got %08x\n", hr);
2061c2c66affSColin Finck 
2062c2c66affSColin Finck     fmtetc.cfFormat = cf_test_1;
2063c2c66affSColin Finck     hr = IDataObject_GetData(pCacheDataObject, &fmtetc, &stgmedium);
2064c2c66affSColin Finck     ok(hr == OLE_E_BLANK, "got %08x\n", hr);
2065c2c66affSColin Finck 
2066c2c66affSColin Finck     fmtetc.cfFormat = cf_test_2;
2067c2c66affSColin Finck     hr = IDataObject_GetData(pCacheDataObject, &fmtetc, &stgmedium);
2068c2c66affSColin Finck     ok(hr == S_OK, "got %08x\n", hr);
2069c2c66affSColin Finck     ReleaseStgMedium(&stgmedium);
2070c2c66affSColin Finck 
2071c2c66affSColin Finck     fmtetc.cfFormat = cf_test_3;
2072c2c66affSColin Finck     hr = IDataObject_GetData(pCacheDataObject, &fmtetc, &stgmedium);
2073c2c66affSColin Finck     ok(hr == OLE_E_BLANK, "got %08x\n", hr);
2074c2c66affSColin Finck 
2075c2c66affSColin Finck     IOleCacheControl_Release(pOleCacheControl);
2076c2c66affSColin Finck     IDataObject_Release(pCacheDataObject);
2077c2c66affSColin Finck     IOleCache2_Release(pOleCache);
2078c2c66affSColin Finck 
2079c2c66affSColin Finck     CHECK_NO_EXTRA_METHODS();
2080c2c66affSColin Finck 
2081c2c66affSColin Finck     IStorage_Release(pStorage);
2082c2c66affSColin Finck }
2083c2c66affSColin Finck 
2084c2c66affSColin Finck static const WCHAR CONTENTS[] = {'C','O','N','T','E','N','T','S',0};
2085c2c66affSColin Finck 
2086c2c66affSColin Finck /* 2 x 1 x 32 bpp dib. PelsPerMeter = 200x400 */
2087b44b1afbSAmine Khaldi static BYTE file_dib[] =
2088c2c66affSColin Finck {
2089c2c66affSColin Finck     0x42, 0x4d, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00,
2090c2c66affSColin Finck     0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x28, 0x00,
2091c2c66affSColin Finck     0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00,
2092c2c66affSColin Finck     0x00, 0x00, 0x01, 0x00, 0x20, 0x00, 0x00, 0x00,
2093c2c66affSColin Finck     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x00,
2094c2c66affSColin Finck     0x00, 0x00, 0x90, 0x01, 0x00, 0x00, 0x00, 0x00,
2095c2c66affSColin Finck     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff,
2096c2c66affSColin Finck     0xff, 0xff, 0xff, 0xff, 0xff, 0xff
2097c2c66affSColin Finck };
2098c2c66affSColin Finck 
create_storage(int num)2099c2c66affSColin Finck static IStorage *create_storage( int num )
2100c2c66affSColin Finck {
2101c2c66affSColin Finck     IStorage *stg;
2102c2c66affSColin Finck     IStream *stm;
2103c2c66affSColin Finck     HRESULT hr;
2104c2c66affSColin Finck     ULONG written;
2105c2c66affSColin Finck 
2106c2c66affSColin Finck     hr = StgCreateDocfile( NULL, STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE | STGM_DELETEONRELEASE, 0, &stg );
2107c2c66affSColin Finck     ok( hr == S_OK, "got %08x\n", hr);
2108c2c66affSColin Finck     hr = IStorage_SetClass( stg, &CLSID_Picture_Dib );
2109c2c66affSColin Finck     ok( hr == S_OK, "got %08x\n", hr);
2110c2c66affSColin Finck     hr = IStorage_CreateStream( stg, CONTENTS, STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE, 0, 0, &stm );
2111c2c66affSColin Finck     ok( hr == S_OK, "got %08x\n", hr);
2112c2c66affSColin Finck     if (num == 1) /* Set biXPelsPerMeter = 0 */
2113c2c66affSColin Finck     {
2114b44b1afbSAmine Khaldi         file_dib[0x26] = 0;
2115b44b1afbSAmine Khaldi         file_dib[0x27] = 0;
2116c2c66affSColin Finck     }
2117b44b1afbSAmine Khaldi     hr = IStream_Write( stm, file_dib, sizeof(file_dib), &written );
2118c2c66affSColin Finck     ok( hr == S_OK, "got %08x\n", hr);
2119c2c66affSColin Finck     IStream_Release( stm );
2120c2c66affSColin Finck     return stg;
2121c2c66affSColin Finck }
2122c2c66affSColin Finck 
test_data_cache_dib_contents_stream(int num)2123c2c66affSColin Finck static void test_data_cache_dib_contents_stream(int num)
2124c2c66affSColin Finck {
2125c2c66affSColin Finck     HRESULT hr;
2126c2c66affSColin Finck     IUnknown *unk;
2127c2c66affSColin Finck     IPersistStorage *persist;
2128c2c66affSColin Finck     IDataObject *data;
2129c2c66affSColin Finck     IViewObject2 *view;
2130c2c66affSColin Finck     IStorage *stg;
2131c2c66affSColin Finck     IOleCache2 *cache;
2132c2c66affSColin Finck     FORMATETC fmt = {CF_DIB, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
2133c2c66affSColin Finck     STGMEDIUM med;
2134c2c66affSColin Finck     CLSID cls;
2135c2c66affSColin Finck     SIZEL sz;
2136c2c66affSColin Finck     BYTE *ptr;
2137c2c66affSColin Finck     BITMAPINFOHEADER expect_info;
2138c2c66affSColin Finck     STATDATA enum_expect[] =
2139c2c66affSColin Finck     {
2140c2c66affSColin Finck         {{ CF_DIB,          0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }, 0, NULL, 1 },
2141c2c66affSColin Finck         {{ CF_BITMAP,       0, DVASPECT_CONTENT, -1, TYMED_GDI },     0, NULL, 1 },
2142c2c66affSColin Finck     };
2143c2c66affSColin Finck 
2144c2c66affSColin Finck     hr = CreateDataCache( NULL, &CLSID_Picture_Metafile, &IID_IUnknown, (void **)&unk );
2145c2c66affSColin Finck     ok( SUCCEEDED(hr), "got %08x\n", hr );
2146c2c66affSColin Finck     hr = IUnknown_QueryInterface( unk, &IID_IPersistStorage, (void **)&persist );
2147c2c66affSColin Finck     ok( SUCCEEDED(hr), "got %08x\n", hr );
2148c2c66affSColin Finck     hr = IUnknown_QueryInterface( unk, &IID_IDataObject, (void **)&data );
2149c2c66affSColin Finck     ok( SUCCEEDED(hr), "got %08x\n", hr );
2150c2c66affSColin Finck     hr = IUnknown_QueryInterface( unk, &IID_IViewObject2, (void **)&view );
2151c2c66affSColin Finck     ok( SUCCEEDED(hr), "got %08x\n", hr );
2152c2c66affSColin Finck     hr = IUnknown_QueryInterface( unk, &IID_IOleCache2, (void **)&cache );
2153c2c66affSColin Finck     ok( SUCCEEDED(hr), "got %08x\n", hr );
2154c2c66affSColin Finck 
2155c2c66affSColin Finck     stg = create_storage( num );
2156c2c66affSColin Finck 
2157c2c66affSColin Finck     hr = IPersistStorage_Load( persist, stg );
2158c2c66affSColin Finck     ok( SUCCEEDED(hr), "got %08x\n", hr );
2159c2c66affSColin Finck     IStorage_Release( stg );
2160c2c66affSColin Finck 
2161c2c66affSColin Finck     hr = IPersistStorage_GetClassID( persist, &cls );
2162c2c66affSColin Finck     ok( SUCCEEDED(hr), "got %08x\n", hr );
2163c2c66affSColin Finck     ok( IsEqualCLSID( &cls, &CLSID_Picture_Dib ), "class id mismatch\n" );
2164c2c66affSColin Finck 
2165c2c66affSColin Finck     hr = IDataObject_GetData( data, &fmt, &med );
2166c2c66affSColin Finck     ok( SUCCEEDED(hr), "got %08x\n", hr );
2167c2c66affSColin Finck     ok( med.tymed == TYMED_HGLOBAL, "got %x\n", med.tymed );
2168c2c66affSColin Finck     ok( GlobalSize( U(med).hGlobal ) >= sizeof(dib) - sizeof(BITMAPFILEHEADER),
2169c2c66affSColin Finck         "got %lu\n", GlobalSize( U(med).hGlobal ) );
2170c2c66affSColin Finck     ptr = GlobalLock( U(med).hGlobal );
2171c2c66affSColin Finck 
2172b44b1afbSAmine Khaldi     expect_info = *(BITMAPINFOHEADER *)(file_dib + sizeof(BITMAPFILEHEADER));
2173c2c66affSColin Finck     if (expect_info.biXPelsPerMeter == 0 || expect_info.biYPelsPerMeter == 0)
2174c2c66affSColin Finck     {
2175c2c66affSColin Finck         HDC hdc = GetDC( 0 );
2176c2c66affSColin Finck         expect_info.biXPelsPerMeter = MulDiv( GetDeviceCaps( hdc, LOGPIXELSX ), 10000, 254 );
2177c2c66affSColin Finck         expect_info.biYPelsPerMeter = MulDiv( GetDeviceCaps( hdc, LOGPIXELSY ), 10000, 254 );
2178c2c66affSColin Finck         ReleaseDC( 0, hdc );
2179c2c66affSColin Finck     }
2180c2c66affSColin Finck     ok( !memcmp( ptr, &expect_info, sizeof(expect_info) ), "mismatch\n" );
2181b44b1afbSAmine Khaldi     ok( !memcmp( ptr + sizeof(expect_info), file_dib + sizeof(BITMAPFILEHEADER) + sizeof(expect_info),
2182b44b1afbSAmine Khaldi                  sizeof(file_dib) - sizeof(BITMAPFILEHEADER) - sizeof(expect_info) ), "mismatch\n" );
2183c2c66affSColin Finck     GlobalUnlock( U(med).hGlobal );
2184c2c66affSColin Finck     ReleaseStgMedium( &med );
2185c2c66affSColin Finck 
2186c2c66affSColin Finck     check_enum_cache( cache, enum_expect, 2 );
2187c2c66affSColin Finck 
2188c2c66affSColin Finck     hr = IViewObject2_GetExtent( view, DVASPECT_CONTENT, -1, NULL, &sz );
2189c2c66affSColin Finck     ok( SUCCEEDED(hr), "got %08x\n", hr );
2190c2c66affSColin Finck     if (num == 0)
2191c2c66affSColin Finck     {
2192c2c66affSColin Finck         ok( sz.cx == 1000, "got %d\n", sz.cx );
2193c2c66affSColin Finck         ok( sz.cy == 250, "got %d\n", sz.cy );
2194c2c66affSColin Finck     }
2195c2c66affSColin Finck     else
2196c2c66affSColin Finck     {
2197c2c66affSColin Finck         HDC hdc = GetDC( 0 );
2198c2c66affSColin Finck         LONG x = 2 * 2540 / GetDeviceCaps( hdc, LOGPIXELSX );
2199c2c66affSColin Finck         LONG y = 1 * 2540 / GetDeviceCaps( hdc, LOGPIXELSY );
2200c2c66affSColin Finck         ok( sz.cx == x, "got %d %d\n", sz.cx, x );
2201c2c66affSColin Finck         ok( sz.cy == y, "got %d %d\n", sz.cy, y );
2202c2c66affSColin Finck 
2203c2c66affSColin Finck         ReleaseDC( 0, hdc );
2204c2c66affSColin Finck     }
2205c2c66affSColin Finck 
2206c2c66affSColin Finck     IOleCache2_Release( cache );
2207c2c66affSColin Finck     IViewObject2_Release( view );
2208c2c66affSColin Finck     IDataObject_Release( data );
2209c2c66affSColin Finck     IPersistStorage_Release( persist );
2210c2c66affSColin Finck     IUnknown_Release( unk );
2211c2c66affSColin Finck }
2212c2c66affSColin Finck 
check_bitmap_size(HBITMAP h,int cx,int cy)2213c2c66affSColin Finck static void check_bitmap_size( HBITMAP h, int cx, int cy )
2214c2c66affSColin Finck {
2215c2c66affSColin Finck     BITMAP bm;
2216c2c66affSColin Finck 
2217c2c66affSColin Finck     GetObjectW( h, sizeof(bm), &bm );
2218c2c66affSColin Finck     ok( bm.bmWidth == cx, "got %d expect %d\n", bm.bmWidth, cx );
2219c2c66affSColin Finck     ok( bm.bmHeight == cy, "got %d expect %d\n", bm.bmHeight, cy );
2220c2c66affSColin Finck }
2221c2c66affSColin Finck 
check_dib_size(HGLOBAL h,int cx,int cy)2222c2c66affSColin Finck static void check_dib_size( HGLOBAL h, int cx, int cy )
2223c2c66affSColin Finck {
2224c2c66affSColin Finck     BITMAPINFO *info;
2225c2c66affSColin Finck 
2226c2c66affSColin Finck     info = GlobalLock( h );
2227c2c66affSColin Finck     ok( info->bmiHeader.biWidth == cx, "got %d expect %d\n", info->bmiHeader.biWidth, cx );
2228c2c66affSColin Finck     ok( info->bmiHeader.biHeight == cy, "got %d expect %d\n", info->bmiHeader.biHeight, cy );
2229c2c66affSColin Finck     GlobalUnlock( h );
2230c2c66affSColin Finck }
2231c2c66affSColin Finck 
test_data_cache_cache(void)2232b44b1afbSAmine Khaldi static void test_data_cache_cache(void)
2233c2c66affSColin Finck {
2234c2c66affSColin Finck     HRESULT hr;
2235c2c66affSColin Finck     IOleCache2 *cache;
2236c2c66affSColin Finck     IDataObject *data;
2237c2c66affSColin Finck     FORMATETC fmt;
2238c2c66affSColin Finck     DWORD conn;
2239c2c66affSColin Finck     STGMEDIUM med;
2240c2c66affSColin Finck     STATDATA expect[] =
2241c2c66affSColin Finck     {
2242c2c66affSColin Finck         {{ CF_DIB,          0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }, 0, NULL, 0 },
2243c2c66affSColin Finck         {{ CF_BITMAP,       0, DVASPECT_CONTENT, -1, TYMED_GDI },     0, NULL, 0 },
2244c2c66affSColin Finck         {{ CF_METAFILEPICT, 0, DVASPECT_CONTENT, -1, TYMED_MFPICT },  0, NULL, 0 },
2245c2c66affSColin Finck         {{ CF_ENHMETAFILE,  0, DVASPECT_CONTENT, -1, TYMED_ENHMF },   0, NULL, 0 }
2246c2c66affSColin Finck     };
2247b44b1afbSAmine Khaldi     STATDATA view_caching[] =
2248b44b1afbSAmine Khaldi     {
2249b44b1afbSAmine Khaldi         {{ 0,               0, DVASPECT_CONTENT,   -1, TYMED_ENHMF },   0, NULL, 0 },
2250b44b1afbSAmine Khaldi         {{ 0,               0, DVASPECT_THUMBNAIL, -1, TYMED_HGLOBAL }, 0, NULL, 0 },
2251b44b1afbSAmine Khaldi         {{ 0,               0, DVASPECT_DOCPRINT,  -1, TYMED_HGLOBAL }, 0, NULL, 0 },
2252b44b1afbSAmine Khaldi         {{ CF_METAFILEPICT, 0, DVASPECT_ICON,      -1, TYMED_MFPICT },  0, NULL, 0 }
2253b44b1afbSAmine Khaldi     };
2254c2c66affSColin Finck 
2255c2c66affSColin Finck     hr = CreateDataCache( NULL, &CLSID_NULL, &IID_IOleCache2, (void **)&cache );
2256c2c66affSColin Finck     ok( hr == S_OK, "got %08x\n", hr );
2257c2c66affSColin Finck 
2258c2c66affSColin Finck     /* create a dib entry which will also create a bitmap entry too */
2259c2c66affSColin Finck     fmt.cfFormat = CF_DIB;
2260c2c66affSColin Finck     fmt.ptd = NULL;
2261c2c66affSColin Finck     fmt.dwAspect = DVASPECT_CONTENT;
2262c2c66affSColin Finck     fmt.lindex = -1;
2263c2c66affSColin Finck     fmt.tymed = TYMED_HGLOBAL;
2264c2c66affSColin Finck 
2265c2c66affSColin Finck     hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
2266c2c66affSColin Finck     ok( hr == S_OK, "got %08x\n", hr );
2267c2c66affSColin Finck     ok( conn == 2, "got %d\n", conn );
2268c2c66affSColin Finck     expect[0].dwConnection = conn;
2269c2c66affSColin Finck     expect[1].dwConnection = conn;
2270c2c66affSColin Finck 
2271c2c66affSColin Finck     check_enum_cache( cache, expect, 2 );
2272c2c66affSColin Finck 
2273c2c66affSColin Finck     /* now try to add a bitmap */
2274c2c66affSColin Finck     fmt.cfFormat = CF_BITMAP;
2275c2c66affSColin Finck     fmt.tymed = TYMED_GDI;
2276c2c66affSColin Finck 
2277c2c66affSColin Finck     hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
2278c2c66affSColin Finck     ok( hr == CACHE_S_SAMECACHE, "got %08x\n", hr );
2279c2c66affSColin Finck 
2280c2c66affSColin Finck     /* metafile */
2281c2c66affSColin Finck     fmt.cfFormat = CF_METAFILEPICT;
2282c2c66affSColin Finck     fmt.tymed = TYMED_MFPICT;
2283c2c66affSColin Finck 
2284c2c66affSColin Finck     hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
2285c2c66affSColin Finck     ok( hr == S_OK, "got %08x\n", hr );
2286c2c66affSColin Finck     ok( conn == 3, "got %d\n", conn );
2287c2c66affSColin Finck     expect[2].dwConnection = conn;
2288c2c66affSColin Finck 
2289c2c66affSColin Finck     check_enum_cache( cache, expect,  3);
2290c2c66affSColin Finck 
2291c2c66affSColin Finck     /* enhmetafile */
2292c2c66affSColin Finck     fmt.cfFormat = CF_ENHMETAFILE;
2293c2c66affSColin Finck     fmt.tymed = TYMED_ENHMF;
2294c2c66affSColin Finck 
2295c2c66affSColin Finck     hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
2296c2c66affSColin Finck     ok( hr == S_OK, "got %08x\n", hr );
2297c2c66affSColin Finck     ok( conn == 4, "got %d\n", conn );
2298c2c66affSColin Finck     expect[3].dwConnection = conn;
2299c2c66affSColin Finck 
2300c2c66affSColin Finck     check_enum_cache( cache, expect, 4 );
2301c2c66affSColin Finck 
2302c2c66affSColin Finck     /* uncache everything */
2303c2c66affSColin Finck     hr = IOleCache2_Uncache( cache, expect[3].dwConnection );
2304c2c66affSColin Finck     ok( hr == S_OK, "got %08x\n", hr );
2305c2c66affSColin Finck     hr = IOleCache2_Uncache( cache, expect[2].dwConnection );
2306c2c66affSColin Finck     ok( hr == S_OK, "got %08x\n", hr );
2307c2c66affSColin Finck     hr = IOleCache2_Uncache( cache, expect[0].dwConnection );
2308c2c66affSColin Finck     ok( hr == S_OK, "got %08x\n", hr );
2309c2c66affSColin Finck     hr = IOleCache2_Uncache( cache, expect[0].dwConnection );
2310c2c66affSColin Finck     ok( hr == OLE_E_NOCONNECTION, "got %08x\n", hr );
2311c2c66affSColin Finck 
2312c2c66affSColin Finck     check_enum_cache( cache, expect, 0 );
2313c2c66affSColin Finck 
2314c2c66affSColin Finck     /* just create a bitmap entry which again adds both dib and bitmap */
2315c2c66affSColin Finck     fmt.cfFormat = CF_BITMAP;
2316c2c66affSColin Finck     fmt.tymed = TYMED_GDI;
2317c2c66affSColin Finck 
2318c2c66affSColin Finck     hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
2319c2c66affSColin Finck     ok( hr == S_OK, "got %08x\n", hr );
2320c2c66affSColin Finck 
2321c2c66affSColin Finck     expect[0].dwConnection = conn;
2322c2c66affSColin Finck     expect[1].dwConnection = conn;
2323c2c66affSColin Finck 
2324c2c66affSColin Finck     check_enum_cache( cache, expect, 2 );
2325c2c66affSColin Finck 
2326c2c66affSColin Finck     /* Try setting a 1x1 bitmap */
2327c2c66affSColin Finck     hr = IOleCache2_QueryInterface( cache, &IID_IDataObject, (void **) &data );
2328c2c66affSColin Finck     ok( hr == S_OK, "got %08x\n", hr );
2329c2c66affSColin Finck 
2330b44b1afbSAmine Khaldi     create_bitmap( &med );
2331c2c66affSColin Finck 
2332c2c66affSColin Finck     hr = IOleCache2_SetData( cache, &fmt, &med, TRUE );
2333c2c66affSColin Finck     ok( hr == S_OK, "got %08x\n", hr );
2334c2c66affSColin Finck 
2335c2c66affSColin Finck     hr = IDataObject_GetData( data, &fmt, &med );
2336c2c66affSColin Finck     ok( hr == S_OK, "got %08x\n", hr );
2337c2c66affSColin Finck     ok( med.tymed == TYMED_GDI, "got %d\n", med.tymed );
2338c2c66affSColin Finck     check_bitmap_size( U(med).hBitmap, 1, 1 );
2339c2c66affSColin Finck     ReleaseStgMedium( &med );
2340c2c66affSColin Finck 
2341c2c66affSColin Finck     fmt.cfFormat = CF_DIB;
2342c2c66affSColin Finck     fmt.tymed = TYMED_HGLOBAL;
2343c2c66affSColin Finck     hr = IDataObject_GetData( data, &fmt, &med );
2344c2c66affSColin Finck     ok( hr == S_OK, "got %08x\n", hr );
2345c2c66affSColin Finck     ok( med.tymed == TYMED_HGLOBAL, "got %d\n", med.tymed );
2346c2c66affSColin Finck     check_dib_size( U(med).hGlobal, 1, 1 );
2347c2c66affSColin Finck     ReleaseStgMedium( &med );
2348c2c66affSColin Finck 
2349c2c66affSColin Finck     /* Now set a 2x1 dib */
2350c2c66affSColin Finck     fmt.cfFormat = CF_DIB;
2351c2c66affSColin Finck     fmt.tymed = TYMED_HGLOBAL;
2352b44b1afbSAmine Khaldi     create_dib( &med );
2353c2c66affSColin Finck 
2354c2c66affSColin Finck     hr = IOleCache2_SetData( cache, &fmt, &med, TRUE );
2355c2c66affSColin Finck     ok( hr == S_OK, "got %08x\n", hr );
2356c2c66affSColin Finck 
2357c2c66affSColin Finck     fmt.cfFormat = CF_BITMAP;
2358c2c66affSColin Finck     fmt.tymed = TYMED_GDI;
2359c2c66affSColin Finck     hr = IDataObject_GetData( data, &fmt, &med );
2360c2c66affSColin Finck     ok( hr == S_OK, "got %08x\n", hr );
2361c2c66affSColin Finck     ok( med.tymed == TYMED_GDI, "got %d\n", med.tymed );
2362c2c66affSColin Finck     check_bitmap_size( U(med).hBitmap, 2, 1 );
2363c2c66affSColin Finck     ReleaseStgMedium( &med );
2364c2c66affSColin Finck 
2365c2c66affSColin Finck     fmt.cfFormat = CF_DIB;
2366c2c66affSColin Finck     fmt.tymed = TYMED_HGLOBAL;
2367c2c66affSColin Finck     hr = IDataObject_GetData( data, &fmt, &med );
2368c2c66affSColin Finck     ok( hr == S_OK, "got %08x\n", hr );
2369c2c66affSColin Finck     ok( med.tymed == TYMED_HGLOBAL, "got %d\n", med.tymed );
2370c2c66affSColin Finck     check_dib_size( U(med).hGlobal, 2, 1 );
2371c2c66affSColin Finck     ReleaseStgMedium( &med );
2372c2c66affSColin Finck 
2373b44b1afbSAmine Khaldi     /* uncache everything */
2374b44b1afbSAmine Khaldi     hr = IOleCache2_Uncache( cache, conn );
2375b44b1afbSAmine Khaldi     ok( hr == S_OK, "got %08x\n", hr );
2376b44b1afbSAmine Khaldi 
2377b44b1afbSAmine Khaldi     /* view caching */
2378b44b1afbSAmine Khaldi     fmt.cfFormat = 0;
2379b44b1afbSAmine Khaldi     fmt.tymed = TYMED_ENHMF;
2380b44b1afbSAmine Khaldi     hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
2381b44b1afbSAmine Khaldi     ok( hr == S_OK, "got %08x\n", hr );
2382b44b1afbSAmine Khaldi     view_caching[0].dwConnection = conn;
2383b44b1afbSAmine Khaldi 
2384b44b1afbSAmine Khaldi     fmt.tymed = TYMED_HGLOBAL;
2385b44b1afbSAmine Khaldi     hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
2386b44b1afbSAmine Khaldi     ok( hr == CACHE_S_SAMECACHE, "got %08x\n", hr );
2387b44b1afbSAmine Khaldi 
2388b44b1afbSAmine Khaldi     fmt.dwAspect = DVASPECT_THUMBNAIL;
2389b44b1afbSAmine Khaldi     hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
2390b44b1afbSAmine Khaldi     ok( hr == S_OK, "got %08x\n", hr );
2391b44b1afbSAmine Khaldi     view_caching[1].dwConnection = conn;
2392b44b1afbSAmine Khaldi 
2393b44b1afbSAmine Khaldi     fmt.dwAspect = DVASPECT_DOCPRINT;
2394b44b1afbSAmine Khaldi     hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
2395b44b1afbSAmine Khaldi     ok( hr == S_OK, "got %08x\n", hr );
2396b44b1afbSAmine Khaldi     view_caching[2].dwConnection = conn;
2397b44b1afbSAmine Khaldi 
2398b44b1afbSAmine Khaldi     /* DVASPECT_ICON view cache gets mapped to CF_METAFILEPICT */
2399b44b1afbSAmine Khaldi     fmt.dwAspect = DVASPECT_ICON;
2400b44b1afbSAmine Khaldi     hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
2401b44b1afbSAmine Khaldi     ok( hr == S_OK, "got %08x\n", hr );
2402b44b1afbSAmine Khaldi     view_caching[3].dwConnection = conn;
2403b44b1afbSAmine Khaldi 
2404b44b1afbSAmine Khaldi     check_enum_cache( cache, view_caching, 4 );
2405b44b1afbSAmine Khaldi 
2406b44b1afbSAmine Khaldi     /* uncache everything */
2407b44b1afbSAmine Khaldi     hr = IOleCache2_Uncache( cache, view_caching[3].dwConnection );
2408b44b1afbSAmine Khaldi     ok( hr == S_OK, "got %08x\n", hr );
2409b44b1afbSAmine Khaldi     hr = IOleCache2_Uncache( cache, view_caching[2].dwConnection );
2410b44b1afbSAmine Khaldi     ok( hr == S_OK, "got %08x\n", hr );
2411b44b1afbSAmine Khaldi     hr = IOleCache2_Uncache( cache, view_caching[1].dwConnection );
2412b44b1afbSAmine Khaldi     ok( hr == S_OK, "got %08x\n", hr );
2413b44b1afbSAmine Khaldi     hr = IOleCache2_Uncache( cache, view_caching[0].dwConnection );
2414b44b1afbSAmine Khaldi     ok( hr == S_OK, "got %08x\n", hr );
2415b44b1afbSAmine Khaldi 
2416b44b1afbSAmine Khaldi     /* Only able to set cfFormat == CF_METAFILEPICT (or == 0, see above) for DVASPECT_ICON */
2417b44b1afbSAmine Khaldi     fmt.dwAspect = DVASPECT_ICON;
2418b44b1afbSAmine Khaldi     fmt.cfFormat = CF_DIB;
2419b44b1afbSAmine Khaldi     fmt.tymed = TYMED_HGLOBAL;
2420b44b1afbSAmine Khaldi     hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
2421b44b1afbSAmine Khaldi     ok( hr == DV_E_FORMATETC, "got %08x\n", hr );
2422b44b1afbSAmine Khaldi     fmt.cfFormat = CF_BITMAP;
2423b44b1afbSAmine Khaldi     fmt.tymed = TYMED_GDI;
2424b44b1afbSAmine Khaldi     hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
2425b44b1afbSAmine Khaldi     ok( hr == DV_E_FORMATETC, "got %08x\n", hr );
2426b44b1afbSAmine Khaldi     fmt.cfFormat = CF_ENHMETAFILE;
2427b44b1afbSAmine Khaldi     fmt.tymed = TYMED_ENHMF;
2428b44b1afbSAmine Khaldi     hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
2429b44b1afbSAmine Khaldi     ok( hr == DV_E_FORMATETC, "got %08x\n", hr );
2430b44b1afbSAmine Khaldi     fmt.cfFormat = CF_METAFILEPICT;
2431b44b1afbSAmine Khaldi     fmt.tymed = TYMED_MFPICT;
2432b44b1afbSAmine Khaldi     hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
2433b44b1afbSAmine Khaldi     ok( hr == S_OK, "got %08x\n", hr );
2434b44b1afbSAmine Khaldi 
2435b44b1afbSAmine Khaldi     /* uncache everything */
2436b44b1afbSAmine Khaldi     hr = IOleCache2_Uncache( cache, conn );
2437b44b1afbSAmine Khaldi     ok( hr == S_OK, "got %08x\n", hr );
2438b44b1afbSAmine Khaldi 
2439b44b1afbSAmine Khaldi     /* tymed == 0 */
2440b44b1afbSAmine Khaldi     fmt.cfFormat = CF_ENHMETAFILE;
2441b44b1afbSAmine Khaldi     fmt.dwAspect = DVASPECT_CONTENT;
2442b44b1afbSAmine Khaldi     fmt.tymed = 0;
2443b44b1afbSAmine Khaldi     hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
2444b44b1afbSAmine Khaldi     ok( hr == DV_E_TYMED, "got %08x\n", hr );
2445b44b1afbSAmine Khaldi 
2446c2c66affSColin Finck     IDataObject_Release( data );
2447c2c66affSColin Finck     IOleCache2_Release( cache );
244866f35ef8SAmine Khaldi 
244966f35ef8SAmine Khaldi     /* tests for a static class cache */
245066f35ef8SAmine Khaldi     hr = CreateDataCache( NULL, &CLSID_Picture_Dib, &IID_IOleCache2, (void **)&cache );
245166f35ef8SAmine Khaldi 
245266f35ef8SAmine Khaldi     fmt.cfFormat = CF_DIB;
245366f35ef8SAmine Khaldi     fmt.dwAspect = DVASPECT_CONTENT;
245466f35ef8SAmine Khaldi     fmt.tymed = TYMED_HGLOBAL;
245566f35ef8SAmine Khaldi     hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
245666f35ef8SAmine Khaldi     ok( hr == CACHE_S_SAMECACHE, "got %08x\n", hr );
245766f35ef8SAmine Khaldi 
245866f35ef8SAmine Khaldi     /* aspect other than DVASPECT_CONTENT should fail */
245966f35ef8SAmine Khaldi     fmt.dwAspect = DVASPECT_THUMBNAIL;
246066f35ef8SAmine Khaldi     hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
246166f35ef8SAmine Khaldi     ok( FAILED(hr), "got %08x\n", hr );
246266f35ef8SAmine Khaldi 
246366f35ef8SAmine Khaldi     fmt.dwAspect = DVASPECT_DOCPRINT;
246466f35ef8SAmine Khaldi     hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
246566f35ef8SAmine Khaldi     ok( FAILED(hr), "got %08x\n", hr );
246666f35ef8SAmine Khaldi 
246766f35ef8SAmine Khaldi     /* try caching another clip format */
246866f35ef8SAmine Khaldi     fmt.cfFormat = CF_METAFILEPICT;
246966f35ef8SAmine Khaldi     fmt.dwAspect = DVASPECT_CONTENT;
247066f35ef8SAmine Khaldi     fmt.tymed = TYMED_MFPICT;
247166f35ef8SAmine Khaldi     hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
247266f35ef8SAmine Khaldi     ok( FAILED(hr), "got %08x\n", hr );
247366f35ef8SAmine Khaldi 
247466f35ef8SAmine Khaldi     /* As an exception, it's possible to add an icon aspect */
247566f35ef8SAmine Khaldi     fmt.cfFormat = CF_METAFILEPICT;
247666f35ef8SAmine Khaldi     fmt.dwAspect = DVASPECT_ICON;
247766f35ef8SAmine Khaldi     fmt.tymed = TYMED_MFPICT;
247866f35ef8SAmine Khaldi     hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
247966f35ef8SAmine Khaldi     ok( hr == S_OK, "got %08x\n", hr );
248066f35ef8SAmine Khaldi 
248166f35ef8SAmine Khaldi     IOleCache2_Release( cache );
2482c2c66affSColin Finck }
2483c2c66affSColin Finck 
2484c2c66affSColin Finck /* The CLSID_Picture_ classes automatically create appropriate cache entries */
test_data_cache_init(void)2485c2c66affSColin Finck static void test_data_cache_init(void)
2486c2c66affSColin Finck {
2487c2c66affSColin Finck     HRESULT hr;
2488c2c66affSColin Finck     IOleCache2 *cache;
2489c2c66affSColin Finck     IPersistStorage *persist;
2490c2c66affSColin Finck     int i;
2491c2c66affSColin Finck     CLSID clsid;
2492c2c66affSColin Finck     static const STATDATA enum_expect[] =
2493c2c66affSColin Finck     {
2494c2c66affSColin Finck         {{ CF_DIB,          0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }, 0, NULL, 1 },
2495c2c66affSColin Finck         {{ CF_BITMAP,       0, DVASPECT_CONTENT, -1, TYMED_GDI },     0, NULL, 1 },
2496c2c66affSColin Finck         {{ CF_METAFILEPICT, 0, DVASPECT_CONTENT, -1, TYMED_MFPICT },  0, NULL, 1 },
2497c2c66affSColin Finck         {{ CF_ENHMETAFILE,  0, DVASPECT_CONTENT, -1, TYMED_ENHMF },   0, NULL, 1 }
2498c2c66affSColin Finck     };
2499c2c66affSColin Finck     static const struct
2500c2c66affSColin Finck     {
2501c2c66affSColin Finck         const CLSID *clsid;
2502c2c66affSColin Finck         int enum_start, enum_num;
2503c2c66affSColin Finck     } data[] =
2504c2c66affSColin Finck     {
2505c2c66affSColin Finck         { &CLSID_NULL, 0, 0 },
2506c2c66affSColin Finck         { &CLSID_WineTestOld, 0, 0 },
2507c2c66affSColin Finck         { &CLSID_Picture_Dib, 0, 2 },
2508c2c66affSColin Finck         { &CLSID_Picture_Metafile, 2, 1 },
2509c2c66affSColin Finck         { &CLSID_Picture_EnhMetafile, 3, 1 }
2510c2c66affSColin Finck     };
2511c2c66affSColin Finck 
2512*5c1bcfecSAmine Khaldi     for (i = 0; i < ARRAY_SIZE(data); i++)
2513c2c66affSColin Finck     {
2514c2c66affSColin Finck         hr = CreateDataCache( NULL, data[i].clsid, &IID_IOleCache2, (void **)&cache );
2515c2c66affSColin Finck         ok( hr == S_OK, "got %08x\n", hr );
2516c2c66affSColin Finck 
2517c2c66affSColin Finck         check_enum_cache( cache, enum_expect + data[i].enum_start , data[i].enum_num );
2518c2c66affSColin Finck 
2519c2c66affSColin Finck         IOleCache2_QueryInterface( cache, &IID_IPersistStorage, (void **) &persist );
2520c2c66affSColin Finck         hr = IPersistStorage_GetClassID( persist, &clsid );
2521c2c66affSColin Finck         ok( hr == S_OK, "got %08x\n", hr );
2522c2c66affSColin Finck         ok( IsEqualCLSID( &clsid, data[i].clsid ), "class id mismatch %s %s\n", wine_dbgstr_guid( &clsid ),
2523c2c66affSColin Finck             wine_dbgstr_guid( data[i].clsid ) );
2524c2c66affSColin Finck 
2525c2c66affSColin Finck         IPersistStorage_Release( persist );
2526c2c66affSColin Finck         IOleCache2_Release( cache );
2527c2c66affSColin Finck     }
2528c2c66affSColin Finck }
2529c2c66affSColin Finck 
test_data_cache_initnew(void)2530c2c66affSColin Finck static void test_data_cache_initnew(void)
2531c2c66affSColin Finck {
2532c2c66affSColin Finck     HRESULT hr;
2533c2c66affSColin Finck     IOleCache2 *cache;
2534c2c66affSColin Finck     IPersistStorage *persist;
2535c2c66affSColin Finck     IStorage *stg_dib, *stg_mf, *stg_wine;
2536c2c66affSColin Finck     CLSID clsid;
2537c2c66affSColin Finck     static const STATDATA initnew_expect[] =
2538c2c66affSColin Finck     {
2539c2c66affSColin Finck         {{ CF_DIB,          0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }, 0, NULL, 1 },
2540c2c66affSColin Finck         {{ CF_BITMAP,       0, DVASPECT_CONTENT, -1, TYMED_GDI },     0, NULL, 1 },
2541c2c66affSColin Finck     };
2542c2c66affSColin Finck     static const STATDATA initnew2_expect[] =
2543c2c66affSColin Finck     {
2544c2c66affSColin Finck         {{ CF_METAFILEPICT, 0, DVASPECT_CONTENT, -1, TYMED_MFPICT },  0, NULL, 1 },
2545c2c66affSColin Finck         {{ CF_DIB,          0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }, 0, NULL, 2 },
2546c2c66affSColin Finck         {{ CF_BITMAP,       0, DVASPECT_CONTENT, -1, TYMED_GDI },     0, NULL, 2 },
2547c2c66affSColin Finck     };
2548c2c66affSColin Finck     static const STATDATA initnew3_expect[] =
2549c2c66affSColin Finck     {
2550c2c66affSColin Finck         {{ CF_DIB,          0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }, 0, NULL, 1 },
2551c2c66affSColin Finck         {{ CF_BITMAP,       0, DVASPECT_CONTENT, -1, TYMED_GDI },     0, NULL, 1 },
2552c2c66affSColin Finck         {{ CF_DIB,          0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }, 0, NULL, 2 },
2553c2c66affSColin Finck         {{ CF_BITMAP,       0, DVASPECT_CONTENT, -1, TYMED_GDI },     0, NULL, 2 },
2554c2c66affSColin Finck         {{ CF_METAFILEPICT, 0, DVASPECT_CONTENT, -1, TYMED_MFPICT },  0, NULL, 3 },
2555c2c66affSColin Finck     };
2556c2c66affSColin Finck     static const STATDATA initnew4_expect[] =
2557c2c66affSColin Finck     {
2558c2c66affSColin Finck         {{ CF_DIB,          0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }, 0, NULL, 2 },
2559c2c66affSColin Finck         {{ CF_BITMAP,       0, DVASPECT_CONTENT, -1, TYMED_GDI },     0, NULL, 2 },
2560c2c66affSColin Finck         {{ CF_METAFILEPICT, 0, DVASPECT_CONTENT, -1, TYMED_MFPICT },  0, NULL, 3 },
2561c2c66affSColin Finck         {{ CF_DIB,          0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }, 0, NULL, 4 },
2562c2c66affSColin Finck         {{ CF_BITMAP,       0, DVASPECT_CONTENT, -1, TYMED_GDI },     0, NULL, 4 },
2563c2c66affSColin Finck     };
2564c2c66affSColin Finck 
2565c2c66affSColin Finck     hr = StgCreateDocfile( NULL, STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE | STGM_DELETEONRELEASE, 0, &stg_dib );
2566c2c66affSColin Finck     ok( hr == S_OK, "got %08x\n", hr);
2567c2c66affSColin Finck     hr = IStorage_SetClass( stg_dib, &CLSID_Picture_Dib );
2568c2c66affSColin Finck     ok( hr == S_OK, "got %08x\n", hr);
2569c2c66affSColin Finck 
2570c2c66affSColin Finck     hr = StgCreateDocfile( NULL, STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE | STGM_DELETEONRELEASE, 0, &stg_mf );
2571c2c66affSColin Finck     ok( hr == S_OK, "got %08x\n", hr);
2572c2c66affSColin Finck     hr = IStorage_SetClass( stg_mf, &CLSID_Picture_Metafile );
2573c2c66affSColin Finck     ok( hr == S_OK, "got %08x\n", hr);
2574c2c66affSColin Finck 
2575c2c66affSColin Finck     hr = StgCreateDocfile( NULL, STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE | STGM_DELETEONRELEASE, 0, &stg_wine );
2576c2c66affSColin Finck     ok( hr == S_OK, "got %08x\n", hr);
2577c2c66affSColin Finck     hr = IStorage_SetClass( stg_wine, &CLSID_WineTestOld );
2578c2c66affSColin Finck     ok( hr == S_OK, "got %08x\n", hr);
2579c2c66affSColin Finck 
2580c2c66affSColin Finck     hr = CreateDataCache( NULL, &CLSID_WineTestOld, &IID_IOleCache2, (void **)&cache );
2581c2c66affSColin Finck     ok( hr == S_OK, "got %08x\n", hr );
2582c2c66affSColin Finck     IOleCache2_QueryInterface( cache, &IID_IPersistStorage, (void **) &persist );
2583c2c66affSColin Finck 
2584c2c66affSColin Finck     hr = IPersistStorage_InitNew( persist, stg_dib );
2585c2c66affSColin Finck     ok( hr == S_OK, "got %08x\n", hr);
2586c2c66affSColin Finck 
2587c2c66affSColin Finck     hr = IPersistStorage_GetClassID( persist, &clsid );
2588c2c66affSColin Finck     ok( hr == S_OK, "got %08x\n", hr );
2589c2c66affSColin Finck     ok( IsEqualCLSID( &clsid, &CLSID_Picture_Dib ), "got %s\n", wine_dbgstr_guid( &clsid ) );
2590c2c66affSColin Finck 
2591c2c66affSColin Finck     check_enum_cache( cache, initnew_expect, 2 );
2592c2c66affSColin Finck 
2593c2c66affSColin Finck     hr = IPersistStorage_InitNew( persist, stg_mf );
2594c2c66affSColin Finck     ok( hr == CO_E_ALREADYINITIALIZED, "got %08x\n", hr);
2595c2c66affSColin Finck 
2596c2c66affSColin Finck     hr = IPersistStorage_HandsOffStorage( persist );
2597c2c66affSColin Finck     ok( hr == S_OK, "got %08x\n", hr);
2598c2c66affSColin Finck 
2599c2c66affSColin Finck     hr = IPersistStorage_GetClassID( persist, &clsid );
2600c2c66affSColin Finck     ok( hr == S_OK, "got %08x\n", hr );
2601c2c66affSColin Finck     ok( IsEqualCLSID( &clsid, &CLSID_Picture_Dib ), "got %s\n", wine_dbgstr_guid( &clsid ) );
2602c2c66affSColin Finck 
2603c2c66affSColin Finck     hr = IPersistStorage_InitNew( persist, stg_mf );
2604c2c66affSColin Finck     ok( hr == S_OK, "got %08x\n", hr);
2605c2c66affSColin Finck 
2606c2c66affSColin Finck     hr = IPersistStorage_GetClassID( persist, &clsid );
2607c2c66affSColin Finck     ok( hr == S_OK, "got %08x\n", hr );
2608c2c66affSColin Finck     ok( IsEqualCLSID( &clsid, &CLSID_Picture_Metafile ), "got %s\n", wine_dbgstr_guid( &clsid ) );
2609c2c66affSColin Finck 
2610c2c66affSColin Finck     check_enum_cache( cache, initnew2_expect, 3 );
2611c2c66affSColin Finck 
2612c2c66affSColin Finck     hr = IPersistStorage_HandsOffStorage( persist );
2613c2c66affSColin Finck     ok( hr == S_OK, "got %08x\n", hr);
2614c2c66affSColin Finck 
2615c2c66affSColin Finck     hr = IPersistStorage_InitNew( persist, stg_dib );
2616c2c66affSColin Finck     ok( hr == S_OK, "got %08x\n", hr);
2617c2c66affSColin Finck 
2618c2c66affSColin Finck     hr = IPersistStorage_GetClassID( persist, &clsid );
2619c2c66affSColin Finck     ok( hr == S_OK, "got %08x\n", hr );
2620c2c66affSColin Finck     ok( IsEqualCLSID( &clsid, &CLSID_Picture_Dib ), "got %s\n", wine_dbgstr_guid( &clsid ) );
2621c2c66affSColin Finck 
2622c2c66affSColin Finck     check_enum_cache( cache, initnew3_expect, 5 );
2623c2c66affSColin Finck 
2624c2c66affSColin Finck     hr = IPersistStorage_HandsOffStorage( persist );
2625c2c66affSColin Finck     ok( hr == S_OK, "got %08x\n", hr);
2626c2c66affSColin Finck 
2627c2c66affSColin Finck     hr = IPersistStorage_InitNew( persist, stg_wine );
2628c2c66affSColin Finck     ok( hr == S_OK, "got %08x\n", hr);
2629c2c66affSColin Finck 
2630c2c66affSColin Finck     hr = IPersistStorage_GetClassID( persist, &clsid );
2631c2c66affSColin Finck     ok( hr == S_OK, "got %08x\n", hr );
2632c2c66affSColin Finck     ok( IsEqualCLSID( &clsid, &CLSID_WineTestOld ), "got %s\n", wine_dbgstr_guid( &clsid ) );
2633c2c66affSColin Finck 
2634c2c66affSColin Finck     check_enum_cache( cache, initnew4_expect, 5 );
2635c2c66affSColin Finck 
2636c2c66affSColin Finck     IStorage_Release( stg_wine );
2637c2c66affSColin Finck     IStorage_Release( stg_mf );
2638c2c66affSColin Finck     IStorage_Release( stg_dib );
2639c2c66affSColin Finck 
2640c2c66affSColin Finck     IPersistStorage_Release( persist );
2641c2c66affSColin Finck     IOleCache2_Release( cache );
2642c2c66affSColin Finck }
2643c2c66affSColin Finck 
test_data_cache_updatecache(void)2644b44b1afbSAmine Khaldi static void test_data_cache_updatecache( void )
2645b44b1afbSAmine Khaldi {
2646b44b1afbSAmine Khaldi     HRESULT hr;
2647b44b1afbSAmine Khaldi     IOleCache2 *cache;
2648b44b1afbSAmine Khaldi     FORMATETC fmt;
2649b44b1afbSAmine Khaldi     DWORD conn[4];
2650b44b1afbSAmine Khaldi 
2651b44b1afbSAmine Khaldi     static const struct expected_method methods_dib[] =
2652b44b1afbSAmine Khaldi     {
2653b44b1afbSAmine Khaldi         { "DataObject_GetData", 0, { CF_DIB,          NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL } },
2654b44b1afbSAmine Khaldi         { "DataObject_GetData", 0, { CF_BITMAP,       NULL, DVASPECT_CONTENT, -1, TYMED_GDI } },
2655b44b1afbSAmine Khaldi         { NULL }
2656b44b1afbSAmine Khaldi     };
2657b44b1afbSAmine Khaldi 
2658b44b1afbSAmine Khaldi     static const struct expected_method methods_dib_emf[] =
2659b44b1afbSAmine Khaldi     {
2660b44b1afbSAmine Khaldi         { "DataObject_GetData", 0, { CF_DIB,          NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL } },
2661b44b1afbSAmine Khaldi         { "DataObject_GetData", 0, { CF_ENHMETAFILE,  NULL, DVASPECT_CONTENT, -1, TYMED_ENHMF } },
2662b44b1afbSAmine Khaldi         { "DataObject_GetData", 0, { CF_METAFILEPICT, NULL, DVASPECT_CONTENT, -1, TYMED_MFPICT } },
2663b44b1afbSAmine Khaldi         { NULL }
2664b44b1afbSAmine Khaldi     };
2665b44b1afbSAmine Khaldi     static const struct expected_method methods_dib_wmf[] =
2666b44b1afbSAmine Khaldi     {
2667b44b1afbSAmine Khaldi         { "DataObject_GetData", 0, { CF_DIB,          NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL } },
2668b44b1afbSAmine Khaldi         { "DataObject_GetData", 0, { CF_METAFILEPICT, NULL, DVASPECT_CONTENT, -1, TYMED_MFPICT } },
2669b44b1afbSAmine Khaldi         { NULL }
2670b44b1afbSAmine Khaldi     };
2671b44b1afbSAmine Khaldi     static const struct expected_method methods_viewcache[] =
2672b44b1afbSAmine Khaldi     {
2673b44b1afbSAmine Khaldi         { "DataObject_QueryGetData", 0, { CF_METAFILEPICT, NULL, DVASPECT_CONTENT, -1, TYMED_MFPICT } },
2674b44b1afbSAmine Khaldi         { "DataObject_QueryGetData", 0, { CF_ENHMETAFILE,  NULL, DVASPECT_CONTENT, -1, TYMED_ENHMF } },
2675b44b1afbSAmine Khaldi         { "DataObject_QueryGetData", 0, { CF_DIB,          NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL } },
2676b44b1afbSAmine Khaldi         { "DataObject_QueryGetData", 0, { CF_BITMAP,       NULL, DVASPECT_CONTENT, -1, TYMED_GDI } },
2677b44b1afbSAmine Khaldi         { NULL }
2678b44b1afbSAmine Khaldi     };
2679b44b1afbSAmine Khaldi     static const struct expected_method methods_viewcache_with_dib[] =
2680b44b1afbSAmine Khaldi     {
2681b44b1afbSAmine Khaldi         { "DataObject_QueryGetData", 0, { CF_METAFILEPICT, NULL, DVASPECT_CONTENT, -1, TYMED_MFPICT } },
2682b44b1afbSAmine Khaldi         { "DataObject_QueryGetData", 0, { CF_ENHMETAFILE,  NULL, DVASPECT_CONTENT, -1, TYMED_ENHMF } },
2683b44b1afbSAmine Khaldi         { "DataObject_QueryGetData", 0, { CF_DIB,          NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL } },
2684b44b1afbSAmine Khaldi         { "DataObject_GetData",      0, { CF_DIB,          NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL } },
2685b44b1afbSAmine Khaldi         { NULL }
2686b44b1afbSAmine Khaldi     };
2687b44b1afbSAmine Khaldi     static const struct expected_method methods_flags_all[] =
2688b44b1afbSAmine Khaldi     {
2689b44b1afbSAmine Khaldi         { "DataObject_GetData", 0, { CF_DIB,          NULL, DVASPECT_CONTENT,   -1, TYMED_HGLOBAL } },
2690b44b1afbSAmine Khaldi         { "DataObject_GetData", 0, { CF_ENHMETAFILE,  NULL, DVASPECT_CONTENT,   -1, TYMED_ENHMF } },
2691b44b1afbSAmine Khaldi         { "DataObject_GetData", 0, { CF_METAFILEPICT, NULL, DVASPECT_CONTENT,   -1, TYMED_MFPICT } },
2692b44b1afbSAmine Khaldi         { "DataObject_GetData", 0, { CF_METAFILEPICT, NULL, DVASPECT_CONTENT,   -1, TYMED_MFPICT } },
2693b44b1afbSAmine Khaldi         { NULL }
2694b44b1afbSAmine Khaldi     };
2695b44b1afbSAmine Khaldi     static const struct expected_method methods_flags_ifblank_1[] =
2696b44b1afbSAmine Khaldi     {
2697b44b1afbSAmine Khaldi         { "DataObject_GetData", 0, { CF_METAFILEPICT, NULL, DVASPECT_CONTENT,   -1, TYMED_MFPICT } },
2698b44b1afbSAmine Khaldi         { NULL }
2699b44b1afbSAmine Khaldi     };
2700b44b1afbSAmine Khaldi     static const struct expected_method methods_flags_ifblank_2[] =
2701b44b1afbSAmine Khaldi     {
2702b44b1afbSAmine Khaldi         { "DataObject_GetData", 0, { CF_DIB,          NULL, DVASPECT_CONTENT,   -1, TYMED_HGLOBAL } },
2703b44b1afbSAmine Khaldi         { "DataObject_GetData", 0, { CF_METAFILEPICT, NULL, DVASPECT_CONTENT,   -1, TYMED_MFPICT } },
2704b44b1afbSAmine Khaldi         { NULL }
2705b44b1afbSAmine Khaldi     };
2706b44b1afbSAmine Khaldi     static const struct expected_method methods_flags_normal[] =
2707b44b1afbSAmine Khaldi     {
2708b44b1afbSAmine Khaldi         { "DataObject_GetData", 0, { CF_DIB,          NULL, DVASPECT_CONTENT,   -1, TYMED_HGLOBAL } },
2709b44b1afbSAmine Khaldi         { NULL }
2710b44b1afbSAmine Khaldi     };
2711b44b1afbSAmine Khaldi     static const struct expected_method methods_initcache[] =
2712b44b1afbSAmine Khaldi     {
2713b44b1afbSAmine Khaldi         { "DataObject_GetData", 0, { CF_DIB,          NULL, DVASPECT_CONTENT,   -1, TYMED_HGLOBAL } },
2714b44b1afbSAmine Khaldi         { "DataObject_GetData", 0, { CF_METAFILEPICT, NULL, DVASPECT_CONTENT,   -1, TYMED_MFPICT } },
2715b44b1afbSAmine Khaldi         { NULL }
2716b44b1afbSAmine Khaldi     };
2717b44b1afbSAmine Khaldi     static const struct expected_method methods_empty[] =
2718b44b1afbSAmine Khaldi     {
2719b44b1afbSAmine Khaldi         { NULL }
2720b44b1afbSAmine Khaldi     };
2721b44b1afbSAmine Khaldi 
2722b44b1afbSAmine Khaldi     static STATDATA view_cache[] =
2723b44b1afbSAmine Khaldi     {
2724b44b1afbSAmine Khaldi         {{ 0,          0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }, 0, NULL, 0 }
2725b44b1afbSAmine Khaldi     };
2726b44b1afbSAmine Khaldi     static STATDATA view_cache_after_dib[] =
2727b44b1afbSAmine Khaldi     {
2728b44b1afbSAmine Khaldi         {{ CF_DIB,          0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }, 0, NULL, 0 },
2729b44b1afbSAmine Khaldi         {{ CF_BITMAP,       0, DVASPECT_CONTENT, -1, TYMED_GDI },     0, NULL, 0 }
2730b44b1afbSAmine Khaldi     };
2731b44b1afbSAmine Khaldi 
2732b44b1afbSAmine Khaldi     static FORMATETC dib_fmt[] =
2733b44b1afbSAmine Khaldi     {
2734b44b1afbSAmine Khaldi         { CF_DIB,       NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL },
2735b44b1afbSAmine Khaldi         { 0 }
2736b44b1afbSAmine Khaldi     };
2737b44b1afbSAmine Khaldi 
2738b44b1afbSAmine Khaldi     hr = CreateDataCache( NULL, &CLSID_WineTestOld, &IID_IOleCache2, (void **)&cache );
2739b44b1afbSAmine Khaldi     ok( hr == S_OK, "got %08x\n", hr );
2740b44b1afbSAmine Khaldi 
2741b44b1afbSAmine Khaldi     /* No cache slots */
2742b44b1afbSAmine Khaldi     g_dataobject_fmts = NULL;
2743b44b1afbSAmine Khaldi     expected_method_list = NULL;
2744b44b1afbSAmine Khaldi 
2745b44b1afbSAmine Khaldi     hr = IOleCache2_UpdateCache( cache, &DataObject, UPDFCACHE_ALL, NULL );
2746b44b1afbSAmine Khaldi     ok( hr == S_OK, "got %08x\n", hr );
2747b44b1afbSAmine Khaldi 
2748b44b1afbSAmine Khaldi     /* A dib cache slot */
2749b44b1afbSAmine Khaldi     fmt.cfFormat = CF_DIB;
2750b44b1afbSAmine Khaldi     fmt.ptd = NULL;
2751b44b1afbSAmine Khaldi     fmt.dwAspect = DVASPECT_CONTENT;
2752b44b1afbSAmine Khaldi     fmt.lindex = -1;
2753b44b1afbSAmine Khaldi     fmt.tymed = TYMED_HGLOBAL;
2754b44b1afbSAmine Khaldi 
2755b44b1afbSAmine Khaldi     hr = IOleCache2_Cache( cache, &fmt, 0, &conn[0] );
2756b44b1afbSAmine Khaldi     ok( hr == S_OK, "got %08x\n", hr );
2757b44b1afbSAmine Khaldi 
2758b44b1afbSAmine Khaldi     expected_method_list = methods_dib;
2759b44b1afbSAmine Khaldi 
2760b44b1afbSAmine Khaldi     hr = IOleCache2_UpdateCache( cache, &DataObject, UPDFCACHE_ALL, NULL );
2761b44b1afbSAmine Khaldi     ok( hr == CACHE_E_NOCACHE_UPDATED, "got %08x\n", hr );
2762b44b1afbSAmine Khaldi 
2763b44b1afbSAmine Khaldi     CHECK_NO_EXTRA_METHODS();
2764b44b1afbSAmine Khaldi 
2765b44b1afbSAmine Khaldi     /* Now with a dib available */
2766b44b1afbSAmine Khaldi     g_dataobject_fmts = dib_fmt;
2767b44b1afbSAmine Khaldi     expected_method_list = methods_dib;
2768b44b1afbSAmine Khaldi 
2769b44b1afbSAmine Khaldi     hr = IOleCache2_UpdateCache( cache, &DataObject, UPDFCACHE_ALL, NULL );
2770b44b1afbSAmine Khaldi     ok( hr == S_OK, "got %08x\n", hr );
2771b44b1afbSAmine Khaldi 
2772b44b1afbSAmine Khaldi     /* Add an EMF cache slot */
2773b44b1afbSAmine Khaldi     fmt.cfFormat = CF_ENHMETAFILE;
2774b44b1afbSAmine Khaldi     fmt.ptd = NULL;
2775b44b1afbSAmine Khaldi     fmt.dwAspect = DVASPECT_CONTENT;
2776b44b1afbSAmine Khaldi     fmt.lindex = -1;
2777b44b1afbSAmine Khaldi     fmt.tymed = TYMED_ENHMF;
2778b44b1afbSAmine Khaldi 
2779b44b1afbSAmine Khaldi     hr = IOleCache2_Cache( cache, &fmt, 0, &conn[1] );
2780b44b1afbSAmine Khaldi     ok( hr == S_OK, "got %08x\n", hr );
2781b44b1afbSAmine Khaldi 
2782b44b1afbSAmine Khaldi     g_dataobject_fmts = dib_fmt;
2783b44b1afbSAmine Khaldi     expected_method_list = methods_dib_emf;
2784b44b1afbSAmine Khaldi 
2785b44b1afbSAmine Khaldi     /* Two slots to fill, only the dib will succeed */
2786b44b1afbSAmine Khaldi     hr = IOleCache2_UpdateCache( cache, &DataObject, UPDFCACHE_ALL, NULL );
2787b44b1afbSAmine Khaldi     ok( hr == S_OK, "got %08x\n", hr );
2788b44b1afbSAmine Khaldi 
2789b44b1afbSAmine Khaldi     CHECK_NO_EXTRA_METHODS();
2790b44b1afbSAmine Khaldi 
2791b44b1afbSAmine Khaldi     /* Replace the emf slot with a wmf */
2792b44b1afbSAmine Khaldi     hr = IOleCache2_Uncache( cache, conn[1] );
2793b44b1afbSAmine Khaldi     ok( hr == S_OK, "got %08x\n", hr );
2794b44b1afbSAmine Khaldi 
2795b44b1afbSAmine Khaldi     fmt.cfFormat = CF_METAFILEPICT;
2796b44b1afbSAmine Khaldi     fmt.ptd = NULL;
2797b44b1afbSAmine Khaldi     fmt.dwAspect = DVASPECT_CONTENT;
2798b44b1afbSAmine Khaldi     fmt.lindex = -1;
2799b44b1afbSAmine Khaldi     fmt.tymed = TYMED_MFPICT;
2800b44b1afbSAmine Khaldi 
2801b44b1afbSAmine Khaldi     hr = IOleCache2_Cache( cache, &fmt, 0, &conn[1] );
2802b44b1afbSAmine Khaldi     ok( hr == S_OK, "got %08x\n", hr );
2803b44b1afbSAmine Khaldi 
2804b44b1afbSAmine Khaldi     g_dataobject_fmts = dib_fmt;
2805b44b1afbSAmine Khaldi     expected_method_list = methods_dib_wmf;
2806b44b1afbSAmine Khaldi 
2807b44b1afbSAmine Khaldi     hr = IOleCache2_UpdateCache( cache, &DataObject, UPDFCACHE_ALL, NULL );
2808b44b1afbSAmine Khaldi     ok( hr == S_OK, "got %08x\n", hr );
2809b44b1afbSAmine Khaldi 
2810b44b1afbSAmine Khaldi     hr = IOleCache2_Uncache( cache, conn[1] );
2811b44b1afbSAmine Khaldi     ok( hr == S_OK, "got %08x\n", hr );
2812b44b1afbSAmine Khaldi     hr = IOleCache2_Uncache( cache, conn[0] );
2813b44b1afbSAmine Khaldi     ok( hr == S_OK, "got %08x\n", hr );
2814b44b1afbSAmine Khaldi 
2815b44b1afbSAmine Khaldi     /* View caching */
2816b44b1afbSAmine Khaldi     fmt.cfFormat = 0;
2817b44b1afbSAmine Khaldi     fmt.ptd = NULL;
2818b44b1afbSAmine Khaldi     fmt.dwAspect = DVASPECT_CONTENT;
2819b44b1afbSAmine Khaldi     fmt.lindex = -1;
2820b44b1afbSAmine Khaldi     fmt.tymed = TYMED_HGLOBAL;
2821b44b1afbSAmine Khaldi 
2822b44b1afbSAmine Khaldi     hr = IOleCache2_Cache( cache, &fmt, 0, &conn[0] );
2823b44b1afbSAmine Khaldi     ok( hr == S_OK, "got %08x\n", hr );
2824b44b1afbSAmine Khaldi     view_cache[0].dwConnection = conn[0];
2825b44b1afbSAmine Khaldi 
2826b44b1afbSAmine Khaldi     g_dataobject_fmts = NULL;
2827b44b1afbSAmine Khaldi     expected_method_list = methods_viewcache;
2828b44b1afbSAmine Khaldi 
2829b44b1afbSAmine Khaldi     hr = IOleCache2_UpdateCache( cache, &DataObject, UPDFCACHE_ALL, NULL );
2830b44b1afbSAmine Khaldi     ok( hr == CACHE_E_NOCACHE_UPDATED, "got %08x\n", hr );
2831b44b1afbSAmine Khaldi 
2832b44b1afbSAmine Khaldi     CHECK_NO_EXTRA_METHODS();
2833b44b1afbSAmine Khaldi     check_enum_cache( cache, view_cache, 1 );
2834b44b1afbSAmine Khaldi 
2835b44b1afbSAmine Khaldi     g_dataobject_fmts = dib_fmt;
2836b44b1afbSAmine Khaldi     expected_method_list = methods_viewcache_with_dib;
2837b44b1afbSAmine Khaldi 
2838b44b1afbSAmine Khaldi     hr = IOleCache2_UpdateCache( cache, &DataObject, UPDFCACHE_ALL, NULL );
2839b44b1afbSAmine Khaldi     ok( hr == S_OK, "got %08x\n", hr );
2840b44b1afbSAmine Khaldi 
2841b44b1afbSAmine Khaldi     CHECK_NO_EXTRA_METHODS();
2842b44b1afbSAmine Khaldi     view_cache_after_dib[0].dwConnection = view_cache_after_dib[1].dwConnection = view_cache[0].dwConnection;
2843b44b1afbSAmine Khaldi     check_enum_cache( cache, view_cache_after_dib, 2 );
2844b44b1afbSAmine Khaldi 
2845b44b1afbSAmine Khaldi     hr = IOleCache2_Uncache( cache, conn[0] );
2846b44b1afbSAmine Khaldi     ok( hr == S_OK, "got %08x\n", hr );
2847b44b1afbSAmine Khaldi 
2848b44b1afbSAmine Khaldi     /* Try some different flags */
2849b44b1afbSAmine Khaldi 
2850b44b1afbSAmine Khaldi     fmt.cfFormat = CF_DIB;
2851b44b1afbSAmine Khaldi     fmt.ptd = NULL;
2852b44b1afbSAmine Khaldi     fmt.dwAspect = DVASPECT_CONTENT;
2853b44b1afbSAmine Khaldi     fmt.lindex = -1;
2854b44b1afbSAmine Khaldi     fmt.tymed = TYMED_HGLOBAL;
2855b44b1afbSAmine Khaldi 
2856b44b1afbSAmine Khaldi     hr = IOleCache2_Cache( cache, &fmt, 0, &conn[0] );
2857b44b1afbSAmine Khaldi     ok( hr == S_OK, "got %08x\n", hr );
2858b44b1afbSAmine Khaldi 
2859b44b1afbSAmine Khaldi     fmt.cfFormat = CF_ENHMETAFILE;
2860b44b1afbSAmine Khaldi     fmt.ptd = NULL;
2861b44b1afbSAmine Khaldi     fmt.dwAspect = DVASPECT_CONTENT;
2862b44b1afbSAmine Khaldi     fmt.lindex = -1;
2863b44b1afbSAmine Khaldi     fmt.tymed = TYMED_ENHMF;
2864b44b1afbSAmine Khaldi 
2865b44b1afbSAmine Khaldi     hr = IOleCache2_Cache( cache, &fmt, ADVF_NODATA, &conn[1] );
2866b44b1afbSAmine Khaldi     ok( hr == S_OK, "got %08x\n", hr );
2867b44b1afbSAmine Khaldi 
2868b44b1afbSAmine Khaldi     fmt.cfFormat = CF_METAFILEPICT;
2869b44b1afbSAmine Khaldi     fmt.ptd = NULL;
2870b44b1afbSAmine Khaldi     fmt.dwAspect = DVASPECT_CONTENT;
2871b44b1afbSAmine Khaldi     fmt.lindex = -1;
2872b44b1afbSAmine Khaldi     fmt.tymed = TYMED_MFPICT;
2873b44b1afbSAmine Khaldi 
2874b44b1afbSAmine Khaldi     hr = IOleCache2_Cache( cache, &fmt, ADVFCACHE_ONSAVE, &conn[2] );
2875b44b1afbSAmine Khaldi     ok( hr == S_OK, "got %08x\n", hr );
2876b44b1afbSAmine Khaldi 
2877b44b1afbSAmine Khaldi     g_dataobject_fmts = dib_fmt;
2878b44b1afbSAmine Khaldi     expected_method_list = methods_flags_all;
2879b44b1afbSAmine Khaldi 
2880b44b1afbSAmine Khaldi     hr = IOleCache2_UpdateCache( cache, &DataObject, UPDFCACHE_ALL, NULL );
2881b44b1afbSAmine Khaldi 
2882b44b1afbSAmine Khaldi     CHECK_NO_EXTRA_METHODS();
2883b44b1afbSAmine Khaldi 
2884b44b1afbSAmine Khaldi     expected_method_list = methods_flags_all;
2885b44b1afbSAmine Khaldi 
2886b44b1afbSAmine Khaldi     hr = IOleCache2_UpdateCache( cache, &DataObject, UPDFCACHE_ALL, NULL );
2887b44b1afbSAmine Khaldi     ok( hr == S_OK, "got %08x\n", hr );
2888b44b1afbSAmine Khaldi 
2889b44b1afbSAmine Khaldi     CHECK_NO_EXTRA_METHODS();
2890b44b1afbSAmine Khaldi 
2891b44b1afbSAmine Khaldi     expected_method_list = methods_flags_ifblank_1;
2892b44b1afbSAmine Khaldi 
2893b44b1afbSAmine Khaldi     hr = IOleCache2_UpdateCache( cache, &DataObject, UPDFCACHE_IFBLANK , NULL );
2894b44b1afbSAmine Khaldi     ok( hr == S_OK, "got %08x\n", hr );
2895b44b1afbSAmine Khaldi 
2896b44b1afbSAmine Khaldi     CHECK_NO_EXTRA_METHODS();
2897b44b1afbSAmine Khaldi 
2898b44b1afbSAmine Khaldi     hr = IOleCache2_DiscardCache( cache, DISCARDCACHE_NOSAVE );
2899b44b1afbSAmine Khaldi     ok( hr == S_OK, "got %08x\n", hr );
2900b44b1afbSAmine Khaldi 
2901b44b1afbSAmine Khaldi     expected_method_list = methods_flags_ifblank_2;
2902b44b1afbSAmine Khaldi 
2903b44b1afbSAmine Khaldi     hr = IOleCache2_UpdateCache( cache, &DataObject, UPDFCACHE_IFBLANK , NULL );
2904b44b1afbSAmine Khaldi     ok( hr == S_OK, "got %08x\n", hr );
2905b44b1afbSAmine Khaldi 
2906b44b1afbSAmine Khaldi     CHECK_NO_EXTRA_METHODS();
2907b44b1afbSAmine Khaldi 
2908b44b1afbSAmine Khaldi     hr = IOleCache2_DiscardCache( cache, DISCARDCACHE_NOSAVE );
2909b44b1afbSAmine Khaldi     ok( hr == S_OK, "got %08x\n", hr );
2910b44b1afbSAmine Khaldi 
2911b44b1afbSAmine Khaldi     expected_method_list = methods_flags_all;
2912b44b1afbSAmine Khaldi 
2913b44b1afbSAmine Khaldi     hr = IOleCache2_UpdateCache( cache, &DataObject, UPDFCACHE_IFBLANK | UPDFCACHE_NODATACACHE, NULL );
2914b44b1afbSAmine Khaldi     ok( hr == S_OK, "got %08x\n", hr );
2915b44b1afbSAmine Khaldi 
2916b44b1afbSAmine Khaldi     CHECK_NO_EXTRA_METHODS();
2917b44b1afbSAmine Khaldi 
2918b44b1afbSAmine Khaldi     expected_method_list = methods_empty;
2919b44b1afbSAmine Khaldi 
2920b44b1afbSAmine Khaldi     hr = IOleCache2_UpdateCache( cache, &DataObject, UPDFCACHE_ONLYIFBLANK | UPDFCACHE_NORMALCACHE, NULL );
2921b44b1afbSAmine Khaldi     ok( hr == S_OK, "got %08x\n", hr );
2922b44b1afbSAmine Khaldi 
2923b44b1afbSAmine Khaldi     CHECK_NO_EXTRA_METHODS();
2924b44b1afbSAmine Khaldi 
2925b44b1afbSAmine Khaldi     hr = IOleCache2_DiscardCache( cache, DISCARDCACHE_NOSAVE );
2926b44b1afbSAmine Khaldi     ok( hr == S_OK, "got %08x\n", hr );
2927b44b1afbSAmine Khaldi 
2928b44b1afbSAmine Khaldi     expected_method_list = methods_flags_normal;
2929b44b1afbSAmine Khaldi 
2930b44b1afbSAmine Khaldi     hr = IOleCache2_UpdateCache( cache, &DataObject, UPDFCACHE_ONLYIFBLANK | UPDFCACHE_NORMALCACHE, NULL );
2931b44b1afbSAmine Khaldi     ok( hr == S_OK, "got %08x\n", hr );
2932b44b1afbSAmine Khaldi 
2933b44b1afbSAmine Khaldi     CHECK_NO_EXTRA_METHODS();
2934b44b1afbSAmine Khaldi 
2935b44b1afbSAmine Khaldi     expected_method_list = methods_initcache;
2936b44b1afbSAmine Khaldi 
2937b44b1afbSAmine Khaldi     hr = IOleCache2_InitCache( cache, &DataObject );
2938b44b1afbSAmine Khaldi     ok( hr == S_OK, "got %08x\n", hr );
2939b44b1afbSAmine Khaldi 
2940b44b1afbSAmine Khaldi     CHECK_NO_EXTRA_METHODS();
2941b44b1afbSAmine Khaldi 
2942b44b1afbSAmine Khaldi     IOleCache2_Release( cache );
2943b44b1afbSAmine Khaldi }
2944b44b1afbSAmine Khaldi 
test_default_handler(void)2945c2c66affSColin Finck static void test_default_handler(void)
2946c2c66affSColin Finck {
2947c2c66affSColin Finck     HRESULT hr;
2948c2c66affSColin Finck     IOleObject *pObject;
2949c2c66affSColin Finck     IRunnableObject *pRunnableObject;
2950c2c66affSColin Finck     IOleClientSite *pClientSite;
2951c2c66affSColin Finck     IDataObject *pDataObject;
2952c2c66affSColin Finck     SIZEL sizel;
2953c2c66affSColin Finck     DWORD dwStatus;
2954c2c66affSColin Finck     CLSID clsid;
2955c2c66affSColin Finck     LPOLESTR pszUserType;
2956c2c66affSColin Finck     LOGPALETTE palette;
2957c2c66affSColin Finck     DWORD dwAdvConn;
2958c2c66affSColin Finck     IMoniker *pMoniker;
2959c2c66affSColin Finck     FORMATETC fmtetc;
2960c2c66affSColin Finck     IOleInPlaceObject *pInPlaceObj;
2961c2c66affSColin Finck     IEnumOLEVERB *pEnumVerbs;
2962c2c66affSColin Finck     DWORD dwRegister;
2963c2c66affSColin Finck     static const WCHAR wszUnknown[] = {'U','n','k','n','o','w','n',0};
2964c2c66affSColin Finck     static const WCHAR wszHostName[] = {'W','i','n','e',' ','T','e','s','t',' ','P','r','o','g','r','a','m',0};
2965c2c66affSColin Finck     static const WCHAR wszDelim[] = {'!',0};
2966c2c66affSColin Finck 
2967c2c66affSColin Finck     static const struct expected_method methods_embeddinghelper[] =
2968c2c66affSColin Finck     {
2969c2c66affSColin Finck         { "OleObject_QueryInterface", 0 },
2970c2c66affSColin Finck         { "OleObject_AddRef", 0 },
2971c2c66affSColin Finck         { "OleObject_QueryInterface", 0 },
2972c2c66affSColin Finck         { "OleObject_QueryInterface", TEST_TODO },
2973c2c66affSColin Finck         { "OleObject_QueryInterface", 0 },
2974c2c66affSColin Finck         { "OleObject_QueryInterface", 0 },
2975c2c66affSColin Finck         { "OleObject_QueryInterface", TEST_OPTIONAL }, /* Win95/98/NT4 */
2976c2c66affSColin Finck         { "OleObject_Release", TEST_TODO },
2977c2c66affSColin Finck         { "WINE_EXTRA", TEST_OPTIONAL },
2978c2c66affSColin Finck         { NULL, 0 }
2979c2c66affSColin Finck     };
2980c2c66affSColin Finck 
2981c2c66affSColin Finck     hr = CoCreateInstance(&CLSID_WineTest, NULL, CLSCTX_INPROC_HANDLER, &IID_IOleObject, (void **)&pObject);
2982c2c66affSColin Finck     ok(hr == REGDB_E_CLASSNOTREG, "CoCreateInstance should have failed with REGDB_E_CLASSNOTREG instead of 0x%08x\n", hr);
2983c2c66affSColin Finck 
2984c2c66affSColin Finck     hr = OleCreateDefaultHandler(&CLSID_WineTest, NULL, &IID_IOleObject, (void **)&pObject);
2985c2c66affSColin Finck     ok_ole_success(hr, "OleCreateDefaultHandler");
2986c2c66affSColin Finck 
2987c2c66affSColin Finck     hr = IOleObject_QueryInterface(pObject, &IID_IOleInPlaceObject, (void **)&pInPlaceObj);
2988c2c66affSColin Finck     ok(hr == E_NOINTERFACE, "IOleObject_QueryInterface(&IID_IOleInPlaceObject) should return E_NOINTERFACE instead of 0x%08x\n", hr);
2989c2c66affSColin Finck 
2990c2c66affSColin Finck     hr = IOleObject_Advise(pObject, &AdviseSink, &dwAdvConn);
2991c2c66affSColin Finck     ok_ole_success(hr, "IOleObject_Advise");
2992c2c66affSColin Finck 
2993c2c66affSColin Finck     hr = IOleObject_Close(pObject, OLECLOSE_NOSAVE);
2994c2c66affSColin Finck     ok_ole_success(hr, "IOleObject_Close");
2995c2c66affSColin Finck 
2996c2c66affSColin Finck     /* FIXME: test IOleObject_EnumAdvise */
2997c2c66affSColin Finck 
2998c2c66affSColin Finck     hr = IOleObject_EnumVerbs(pObject, &pEnumVerbs);
2999c2c66affSColin Finck     ok(hr == REGDB_E_CLASSNOTREG, "IOleObject_EnumVerbs should have returned REGDB_E_CLASSNOTREG instead of 0x%08x\n", hr);
3000c2c66affSColin Finck 
3001c2c66affSColin Finck     hr = IOleObject_GetClientSite(pObject, &pClientSite);
3002c2c66affSColin Finck     ok_ole_success(hr, "IOleObject_GetClientSite");
3003c2c66affSColin Finck 
3004c2c66affSColin Finck     hr = IOleObject_SetClientSite(pObject, pClientSite);
3005c2c66affSColin Finck     ok_ole_success(hr, "IOleObject_SetClientSite");
3006c2c66affSColin Finck 
3007c2c66affSColin Finck     hr = IOleObject_GetClipboardData(pObject, 0, &pDataObject);
3008c2c66affSColin Finck     ok(hr == OLE_E_NOTRUNNING,
3009c2c66affSColin Finck        "IOleObject_GetClipboardData should have returned OLE_E_NOTRUNNING instead of 0x%08x\n",
3010c2c66affSColin Finck        hr);
3011c2c66affSColin Finck 
3012c2c66affSColin Finck     hr = IOleObject_GetExtent(pObject, DVASPECT_CONTENT, &sizel);
3013c2c66affSColin Finck     ok(hr == OLE_E_BLANK, "IOleObject_GetExtent should have returned OLE_E_BLANK instead of 0x%08x\n",
3014c2c66affSColin Finck        hr);
3015c2c66affSColin Finck 
3016c2c66affSColin Finck     hr = IOleObject_GetMiscStatus(pObject, DVASPECT_CONTENT, &dwStatus);
3017c2c66affSColin Finck     ok(hr == REGDB_E_CLASSNOTREG, "IOleObject_GetMiscStatus should have returned REGDB_E_CLASSNOTREG instead of 0x%08x\n", hr);
3018c2c66affSColin Finck 
3019c2c66affSColin Finck     hr = IOleObject_GetUserClassID(pObject, &clsid);
3020c2c66affSColin Finck     ok_ole_success(hr, "IOleObject_GetUserClassID");
3021c2c66affSColin Finck     ok(IsEqualCLSID(&clsid, &CLSID_WineTest), "clsid != CLSID_WineTest\n");
3022c2c66affSColin Finck 
3023c2c66affSColin Finck     hr = IOleObject_GetUserType(pObject, USERCLASSTYPE_FULL, &pszUserType);
3024c2c66affSColin Finck     todo_wine {
3025c2c66affSColin Finck     ok_ole_success(hr, "IOleObject_GetUserType");
3026c2c66affSColin Finck     ok(!lstrcmpW(pszUserType, wszUnknown), "Retrieved user type was wrong\n");
3027c2c66affSColin Finck     }
3028c2c66affSColin Finck 
3029c2c66affSColin Finck     hr = IOleObject_InitFromData(pObject, NULL, TRUE, 0);
3030c2c66affSColin Finck     ok(hr == OLE_E_NOTRUNNING, "IOleObject_InitFromData should have returned OLE_E_NOTRUNNING instead of 0x%08x\n", hr);
3031c2c66affSColin Finck 
3032c2c66affSColin Finck     hr = IOleObject_IsUpToDate(pObject);
3033c2c66affSColin Finck     ok(hr == OLE_E_NOTRUNNING, "IOleObject_IsUpToDate should have returned OLE_E_NOTRUNNING instead of 0x%08x\n", hr);
3034c2c66affSColin Finck 
3035c2c66affSColin Finck     palette.palNumEntries = 1;
3036c2c66affSColin Finck     palette.palVersion = 2;
3037c2c66affSColin Finck     memset(&palette.palPalEntry[0], 0, sizeof(palette.palPalEntry[0]));
3038c2c66affSColin Finck     hr = IOleObject_SetColorScheme(pObject, &palette);
3039c2c66affSColin Finck     ok(hr == OLE_E_NOTRUNNING, "IOleObject_SetColorScheme should have returned OLE_E_NOTRUNNING instead of 0x%08x\n", hr);
3040c2c66affSColin Finck 
3041c2c66affSColin Finck     sizel.cx = sizel.cy = 0;
3042c2c66affSColin Finck     hr = IOleObject_SetExtent(pObject, DVASPECT_CONTENT, &sizel);
3043c2c66affSColin Finck     ok(hr == OLE_E_NOTRUNNING, "IOleObject_SetExtent should have returned OLE_E_NOTRUNNING instead of 0x%08x\n", hr);
3044c2c66affSColin Finck 
3045c2c66affSColin Finck     hr = IOleObject_SetHostNames(pObject, wszHostName, NULL);
3046c2c66affSColin Finck     ok_ole_success(hr, "IOleObject_SetHostNames");
3047c2c66affSColin Finck 
3048c2c66affSColin Finck     hr = CreateItemMoniker(wszDelim, wszHostName, &pMoniker);
3049c2c66affSColin Finck     ok_ole_success(hr, "CreateItemMoniker");
3050c2c66affSColin Finck     hr = IOleObject_SetMoniker(pObject, OLEWHICHMK_CONTAINER, pMoniker);
3051c2c66affSColin Finck     ok_ole_success(hr, "IOleObject_SetMoniker");
3052c2c66affSColin Finck     IMoniker_Release(pMoniker);
3053c2c66affSColin Finck 
3054c2c66affSColin Finck     hr = IOleObject_GetMoniker(pObject, OLEGETMONIKER_ONLYIFTHERE, OLEWHICHMK_CONTAINER, &pMoniker);
3055c2c66affSColin Finck     ok(hr == E_FAIL, "IOleObject_GetMoniker should have returned E_FAIL instead of 0x%08x\n", hr);
3056c2c66affSColin Finck 
3057c2c66affSColin Finck     hr = IOleObject_Update(pObject);
3058c2c66affSColin Finck     todo_wine
3059c2c66affSColin Finck     ok(hr == REGDB_E_CLASSNOTREG, "IOleObject_Update should have returned REGDB_E_CLASSNOTREG instead of 0x%08x\n", hr);
3060c2c66affSColin Finck 
3061c2c66affSColin Finck     hr = IOleObject_QueryInterface(pObject, &IID_IDataObject, (void **)&pDataObject);
3062c2c66affSColin Finck     ok_ole_success(hr, "IOleObject_QueryInterface");
3063c2c66affSColin Finck 
3064c2c66affSColin Finck     fmtetc.cfFormat = CF_TEXT;
3065c2c66affSColin Finck     fmtetc.ptd = NULL;
3066c2c66affSColin Finck     fmtetc.dwAspect = DVASPECT_CONTENT;
3067c2c66affSColin Finck     fmtetc.lindex = -1;
3068c2c66affSColin Finck     fmtetc.tymed = TYMED_NULL;
3069c2c66affSColin Finck     hr = IDataObject_DAdvise(pDataObject, &fmtetc, 0, &AdviseSink, &dwAdvConn);
3070c2c66affSColin Finck     ok_ole_success(hr, "IDataObject_DAdvise");
3071c2c66affSColin Finck 
3072c2c66affSColin Finck     fmtetc.cfFormat = CF_ENHMETAFILE;
3073c2c66affSColin Finck     fmtetc.ptd = NULL;
3074c2c66affSColin Finck     fmtetc.dwAspect = DVASPECT_CONTENT;
3075c2c66affSColin Finck     fmtetc.lindex = -1;
3076c2c66affSColin Finck     fmtetc.tymed = TYMED_ENHMF;
3077c2c66affSColin Finck     hr = IDataObject_DAdvise(pDataObject, &fmtetc, 0, &AdviseSink, &dwAdvConn);
3078c2c66affSColin Finck     ok_ole_success(hr, "IDataObject_DAdvise");
3079c2c66affSColin Finck 
3080c2c66affSColin Finck     fmtetc.cfFormat = CF_ENHMETAFILE;
3081c2c66affSColin Finck     fmtetc.ptd = NULL;
3082c2c66affSColin Finck     fmtetc.dwAspect = DVASPECT_CONTENT;
3083c2c66affSColin Finck     fmtetc.lindex = -1;
3084c2c66affSColin Finck     fmtetc.tymed = TYMED_ENHMF;
3085c2c66affSColin Finck     hr = IDataObject_QueryGetData(pDataObject, &fmtetc);
3086c2c66affSColin Finck     ok(hr == OLE_E_NOTRUNNING, "IDataObject_QueryGetData should have returned OLE_E_NOTRUNNING instead of 0x%08x\n", hr);
3087c2c66affSColin Finck 
3088c2c66affSColin Finck     fmtetc.cfFormat = CF_TEXT;
3089c2c66affSColin Finck     fmtetc.ptd = NULL;
3090c2c66affSColin Finck     fmtetc.dwAspect = DVASPECT_CONTENT;
3091c2c66affSColin Finck     fmtetc.lindex = -1;
3092c2c66affSColin Finck     fmtetc.tymed = TYMED_NULL;
3093c2c66affSColin Finck     hr = IDataObject_QueryGetData(pDataObject, &fmtetc);
3094c2c66affSColin Finck     ok(hr == OLE_E_NOTRUNNING, "IDataObject_QueryGetData should have returned OLE_E_NOTRUNNING instead of 0x%08x\n", hr);
3095c2c66affSColin Finck 
3096c2c66affSColin Finck     hr = IOleObject_QueryInterface(pObject, &IID_IRunnableObject, (void **)&pRunnableObject);
3097c2c66affSColin Finck     ok_ole_success(hr, "IOleObject_QueryInterface");
3098c2c66affSColin Finck 
3099c2c66affSColin Finck     hr = IRunnableObject_SetContainedObject(pRunnableObject, TRUE);
3100c2c66affSColin Finck     ok_ole_success(hr, "IRunnableObject_SetContainedObject");
3101c2c66affSColin Finck 
3102c2c66affSColin Finck     hr = IRunnableObject_Run(pRunnableObject, NULL);
3103c2c66affSColin Finck     ok(hr == REGDB_E_CLASSNOTREG, "IOleObject_Run should have returned REGDB_E_CLASSNOTREG instead of 0x%08x\n", hr);
3104c2c66affSColin Finck 
3105c2c66affSColin Finck     hr = IOleObject_Close(pObject, OLECLOSE_NOSAVE);
3106c2c66affSColin Finck     ok_ole_success(hr, "IOleObject_Close");
3107c2c66affSColin Finck 
3108c2c66affSColin Finck     IRunnableObject_Release(pRunnableObject);
3109c2c66affSColin Finck     IOleObject_Release(pObject);
3110c2c66affSColin Finck 
3111c2c66affSColin Finck     /* Test failure propagation from delegate ::QueryInterface */
3112c2c66affSColin Finck     hr = CoRegisterClassObject(&CLSID_WineTest, (IUnknown*)&OleObjectCF,
3113c2c66affSColin Finck                                CLSCTX_INPROC_SERVER, REGCLS_MULTIPLEUSE, &dwRegister);
3114c2c66affSColin Finck     ok_ole_success(hr, "CoRegisterClassObject");
3115c2c66affSColin Finck     if(SUCCEEDED(hr))
3116c2c66affSColin Finck     {
3117c2c66affSColin Finck         expected_method_list = methods_embeddinghelper;
3118c2c66affSColin Finck         hr = OleCreateEmbeddingHelper(&CLSID_WineTest, NULL, EMBDHLP_INPROC_SERVER,
3119c2c66affSColin Finck                                       &OleObjectCF, &IID_IOleObject, (void**)&pObject);
3120c2c66affSColin Finck         ok_ole_success(hr, "OleCreateEmbeddingHelper");
3121c2c66affSColin Finck         if(SUCCEEDED(hr))
3122c2c66affSColin Finck         {
3123c2c66affSColin Finck             IUnknown *punk;
3124c2c66affSColin Finck 
3125c2c66affSColin Finck             g_QIFailsWith = E_FAIL;
3126c2c66affSColin Finck             hr = IOleObject_QueryInterface(pObject, &IID_WineTest, (void**)&punk);
3127c2c66affSColin Finck             ok(hr == E_FAIL, "Got 0x%08x\n", hr);
3128c2c66affSColin Finck 
3129c2c66affSColin Finck             g_QIFailsWith = E_NOINTERFACE;
3130c2c66affSColin Finck             hr = IOleObject_QueryInterface(pObject, &IID_WineTest, (void**)&punk);
3131c2c66affSColin Finck             ok(hr == E_NOINTERFACE, "Got 0x%08x\n", hr);
3132c2c66affSColin Finck 
3133c2c66affSColin Finck             g_QIFailsWith = CO_E_OBJNOTCONNECTED;
3134c2c66affSColin Finck             hr = IOleObject_QueryInterface(pObject, &IID_WineTest, (void**)&punk);
3135c2c66affSColin Finck             ok(hr == CO_E_OBJNOTCONNECTED, "Got 0x%08x\n", hr);
3136c2c66affSColin Finck 
3137c2c66affSColin Finck             g_QIFailsWith = 0x87654321;
3138c2c66affSColin Finck             hr = IOleObject_QueryInterface(pObject, &IID_WineTest, (void**)&punk);
3139c2c66affSColin Finck             ok(hr == 0x87654321, "Got 0x%08x\n", hr);
3140c2c66affSColin Finck 
3141c2c66affSColin Finck             IOleObject_Release(pObject);
3142c2c66affSColin Finck         }
3143c2c66affSColin Finck 
3144c2c66affSColin Finck         CHECK_NO_EXTRA_METHODS();
3145c2c66affSColin Finck 
3146c2c66affSColin Finck         hr = CoRevokeClassObject(dwRegister);
3147c2c66affSColin Finck         ok_ole_success(hr, "CoRevokeClassObject");
3148c2c66affSColin Finck     }
3149c2c66affSColin Finck }
3150c2c66affSColin Finck 
test_runnable(void)3151c2c66affSColin Finck static void test_runnable(void)
3152c2c66affSColin Finck {
3153c2c66affSColin Finck     static const struct expected_method methods_query_runnable[] =
3154c2c66affSColin Finck     {
3155c2c66affSColin Finck         { "OleObject_QueryInterface", 0 },
3156c2c66affSColin Finck         { "OleObjectRunnable_AddRef", 0 },
3157c2c66affSColin Finck         { "OleObjectRunnable_IsRunning", 0 },
3158c2c66affSColin Finck         { "OleObjectRunnable_Release", 0 },
3159c2c66affSColin Finck         { NULL, 0 }
3160c2c66affSColin Finck     };
3161c2c66affSColin Finck 
3162c2c66affSColin Finck     static const struct expected_method methods_no_runnable[] =
3163c2c66affSColin Finck     {
3164c2c66affSColin Finck         { "OleObject_QueryInterface", 0 },
3165c2c66affSColin Finck         { NULL, 0 }
3166c2c66affSColin Finck     };
3167c2c66affSColin Finck 
3168c2c66affSColin Finck     BOOL ret;
3169c2c66affSColin Finck     IOleObject *object = &OleObject;
3170c2c66affSColin Finck 
3171c2c66affSColin Finck     /* null argument */
3172c2c66affSColin Finck     ret = OleIsRunning(NULL);
3173c2c66affSColin Finck     ok(ret == FALSE, "got %d\n", ret);
3174c2c66affSColin Finck 
3175c2c66affSColin Finck     expected_method_list = methods_query_runnable;
3176c2c66affSColin Finck     ret = OleIsRunning(object);
3177c2c66affSColin Finck     ok(ret == TRUE, "Object should be running\n");
3178c2c66affSColin Finck     CHECK_NO_EXTRA_METHODS();
3179c2c66affSColin Finck 
3180c2c66affSColin Finck     g_isRunning = FALSE;
3181c2c66affSColin Finck     expected_method_list = methods_query_runnable;
3182c2c66affSColin Finck     ret = OleIsRunning(object);
3183c2c66affSColin Finck     ok(ret == FALSE, "Object should not be running\n");
3184c2c66affSColin Finck     CHECK_NO_EXTRA_METHODS();
3185c2c66affSColin Finck 
3186c2c66affSColin Finck     g_showRunnable = FALSE;  /* QueryInterface(IID_IRunnableObject, ...) will fail */
3187c2c66affSColin Finck     expected_method_list = methods_no_runnable;
3188c2c66affSColin Finck     ret = OleIsRunning(object);
3189c2c66affSColin Finck     ok(ret == TRUE, "Object without IRunnableObject should be running\n");
3190c2c66affSColin Finck     CHECK_NO_EXTRA_METHODS();
3191c2c66affSColin Finck 
3192c2c66affSColin Finck     g_isRunning = TRUE;
3193c2c66affSColin Finck     g_showRunnable = TRUE;
3194c2c66affSColin Finck }
3195c2c66affSColin Finck 
3196c2c66affSColin Finck 
OleRun_QueryInterface(IRunnableObject * iface,REFIID riid,void ** ppv)3197c2c66affSColin Finck static HRESULT WINAPI OleRun_QueryInterface(IRunnableObject *iface, REFIID riid, void **ppv)
3198c2c66affSColin Finck {
3199c2c66affSColin Finck     *ppv = NULL;
3200c2c66affSColin Finck 
3201c2c66affSColin Finck     if (IsEqualIID(riid, &IID_IUnknown) ||
3202c2c66affSColin Finck         IsEqualIID(riid, &IID_IRunnableObject)) {
3203c2c66affSColin Finck         *ppv = iface;
3204c2c66affSColin Finck     }
3205c2c66affSColin Finck 
3206c2c66affSColin Finck     if (*ppv)
3207c2c66affSColin Finck     {
3208c2c66affSColin Finck         IUnknown_AddRef((IUnknown *)*ppv);
3209c2c66affSColin Finck         return S_OK;
3210c2c66affSColin Finck     }
3211c2c66affSColin Finck 
3212c2c66affSColin Finck     return E_NOINTERFACE;
3213c2c66affSColin Finck }
3214c2c66affSColin Finck 
OleRun_AddRef(IRunnableObject * iface)3215c2c66affSColin Finck static ULONG WINAPI OleRun_AddRef(IRunnableObject *iface)
3216c2c66affSColin Finck {
3217c2c66affSColin Finck     return 2;
3218c2c66affSColin Finck }
3219c2c66affSColin Finck 
OleRun_Release(IRunnableObject * iface)3220c2c66affSColin Finck static ULONG WINAPI OleRun_Release(IRunnableObject *iface)
3221c2c66affSColin Finck {
3222c2c66affSColin Finck     return 1;
3223c2c66affSColin Finck }
3224c2c66affSColin Finck 
OleRun_GetRunningClass(IRunnableObject * iface,CLSID * clsid)3225c2c66affSColin Finck static HRESULT WINAPI OleRun_GetRunningClass(IRunnableObject *iface, CLSID *clsid)
3226c2c66affSColin Finck {
3227c2c66affSColin Finck     ok(0, "unexpected\n");
3228c2c66affSColin Finck     return E_NOTIMPL;
3229c2c66affSColin Finck }
3230c2c66affSColin Finck 
OleRun_Run(IRunnableObject * iface,LPBINDCTX ctx)3231c2c66affSColin Finck static HRESULT WINAPI OleRun_Run(IRunnableObject *iface, LPBINDCTX ctx)
3232c2c66affSColin Finck {
3233c2c66affSColin Finck     ok(ctx == NULL, "got %p\n", ctx);
3234c2c66affSColin Finck     return 0xdeadc0de;
3235c2c66affSColin Finck }
3236c2c66affSColin Finck 
OleRun_IsRunning(IRunnableObject * iface)3237c2c66affSColin Finck static BOOL WINAPI OleRun_IsRunning(IRunnableObject *iface)
3238c2c66affSColin Finck {
3239c2c66affSColin Finck     ok(0, "unexpected\n");
3240c2c66affSColin Finck     return FALSE;
3241c2c66affSColin Finck }
3242c2c66affSColin Finck 
OleRun_LockRunning(IRunnableObject * iface,BOOL lock,BOOL last_unlock_closes)3243c2c66affSColin Finck static HRESULT WINAPI OleRun_LockRunning(IRunnableObject *iface, BOOL lock,
3244c2c66affSColin Finck     BOOL last_unlock_closes)
3245c2c66affSColin Finck {
3246c2c66affSColin Finck     ok(0, "unexpected\n");
3247c2c66affSColin Finck     return E_NOTIMPL;
3248c2c66affSColin Finck }
3249c2c66affSColin Finck 
OleRun_SetContainedObject(IRunnableObject * iface,BOOL contained)3250c2c66affSColin Finck static HRESULT WINAPI OleRun_SetContainedObject(IRunnableObject *iface, BOOL contained)
3251c2c66affSColin Finck {
3252c2c66affSColin Finck     ok(0, "unexpected\n");
3253c2c66affSColin Finck     return E_NOTIMPL;
3254c2c66affSColin Finck }
3255c2c66affSColin Finck 
3256c2c66affSColin Finck static const IRunnableObjectVtbl oleruntestvtbl =
3257c2c66affSColin Finck {
3258c2c66affSColin Finck     OleRun_QueryInterface,
3259c2c66affSColin Finck     OleRun_AddRef,
3260c2c66affSColin Finck     OleRun_Release,
3261c2c66affSColin Finck     OleRun_GetRunningClass,
3262c2c66affSColin Finck     OleRun_Run,
3263c2c66affSColin Finck     OleRun_IsRunning,
3264c2c66affSColin Finck     OleRun_LockRunning,
3265c2c66affSColin Finck     OleRun_SetContainedObject
3266c2c66affSColin Finck };
3267c2c66affSColin Finck 
3268c2c66affSColin Finck static IRunnableObject testrunnable = { &oleruntestvtbl };
3269c2c66affSColin Finck 
test_OleRun(void)3270c2c66affSColin Finck static void test_OleRun(void)
3271c2c66affSColin Finck {
3272c2c66affSColin Finck     HRESULT hr;
3273c2c66affSColin Finck 
3274c2c66affSColin Finck     /* doesn't support IRunnableObject */
3275c2c66affSColin Finck     hr = OleRun(&unknown);
3276c2c66affSColin Finck     ok(hr == S_OK, "OleRun failed 0x%08x\n", hr);
3277c2c66affSColin Finck 
3278c2c66affSColin Finck     hr = OleRun((IUnknown*)&testrunnable);
3279c2c66affSColin Finck     ok(hr == 0xdeadc0de, "got 0x%08x\n", hr);
3280c2c66affSColin Finck }
3281c2c66affSColin Finck 
test_OleLockRunning(void)3282c2c66affSColin Finck static void test_OleLockRunning(void)
3283c2c66affSColin Finck {
3284c2c66affSColin Finck     HRESULT hr;
3285c2c66affSColin Finck 
3286c2c66affSColin Finck     hr = OleLockRunning(&unknown, TRUE, FALSE);
3287c2c66affSColin Finck     ok(hr == S_OK, "OleLockRunning failed 0x%08x\n", hr);
3288c2c66affSColin Finck }
3289c2c66affSColin Finck 
test_OleDraw(void)3290c2c66affSColin Finck static void test_OleDraw(void)
3291c2c66affSColin Finck {
3292c2c66affSColin Finck     HRESULT hr;
3293c2c66affSColin Finck     RECT rect;
3294c2c66affSColin Finck 
3295c2c66affSColin Finck     hr = OleDraw((IUnknown*)&viewobject, 0, (HDC)0x1, NULL);
3296c2c66affSColin Finck     ok(hr == S_OK, "got 0x%08x\n", hr);
3297c2c66affSColin Finck 
3298c2c66affSColin Finck     hr = OleDraw(NULL, 0, (HDC)0x1, NULL);
3299c2c66affSColin Finck     ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
3300c2c66affSColin Finck 
3301c2c66affSColin Finck     hr = OleDraw(NULL, 0, (HDC)0x1, &rect);
3302c2c66affSColin Finck     ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
3303c2c66affSColin Finck }
3304c2c66affSColin Finck 
3305b44b1afbSAmine Khaldi static const WCHAR olepres0W[] = {2,'O','l','e','P','r','e','s','0','0','0',0};
3306c2c66affSColin Finck static const WCHAR comp_objW[] = {1,'C','o','m','p','O','b','j',0};
3307c2c66affSColin Finck static IStream *comp_obj_stream;
3308c2c66affSColin Finck static IStream *ole_stream;
3309b44b1afbSAmine Khaldi static IStream *olepres_stream;
3310b44b1afbSAmine Khaldi static IStream *contents_stream;
3311c2c66affSColin Finck 
Storage_QueryInterface(IStorage * iface,REFIID riid,void ** ppvObject)3312c2c66affSColin Finck static HRESULT WINAPI Storage_QueryInterface(IStorage *iface, REFIID riid, void **ppvObject)
3313c2c66affSColin Finck {
3314c2c66affSColin Finck     ok(0, "unexpected call to QueryInterface\n");
3315c2c66affSColin Finck     return E_NOTIMPL;
3316c2c66affSColin Finck }
3317c2c66affSColin Finck 
Storage_AddRef(IStorage * iface)3318c2c66affSColin Finck static ULONG WINAPI Storage_AddRef(IStorage *iface)
3319c2c66affSColin Finck {
3320c2c66affSColin Finck     ok(0, "unexpected call to AddRef\n");
3321c2c66affSColin Finck     return 2;
3322c2c66affSColin Finck }
3323c2c66affSColin Finck 
Storage_Release(IStorage * iface)3324c2c66affSColin Finck static ULONG WINAPI Storage_Release(IStorage *iface)
3325c2c66affSColin Finck {
3326c2c66affSColin Finck     ok(0, "unexpected call to Release\n");
3327c2c66affSColin Finck     return 1;
3328c2c66affSColin Finck }
3329c2c66affSColin Finck 
Storage_CreateStream(IStorage * iface,LPCOLESTR pwcsName,DWORD grfMode,DWORD reserved1,DWORD reserved2,IStream ** ppstm)3330c2c66affSColin Finck static HRESULT WINAPI Storage_CreateStream(IStorage *iface, LPCOLESTR pwcsName, DWORD grfMode, DWORD reserved1, DWORD reserved2, IStream **ppstm)
3331c2c66affSColin Finck {
3332c2c66affSColin Finck     ULARGE_INTEGER size = {{0}};
3333c2c66affSColin Finck     LARGE_INTEGER pos = {{0}};
3334c2c66affSColin Finck     HRESULT hr;
3335c2c66affSColin Finck 
3336b44b1afbSAmine Khaldi     if (!lstrcmpW(pwcsName, comp_objW))
3337b44b1afbSAmine Khaldi     {
3338c2c66affSColin Finck         CHECK_EXPECT(Storage_CreateStream_CompObj);
3339b44b1afbSAmine Khaldi         *ppstm = comp_obj_stream;
3340b44b1afbSAmine Khaldi 
3341c2c66affSColin Finck         todo_wine ok(grfMode == (STGM_CREATE|STGM_SHARE_EXCLUSIVE|STGM_READWRITE), "grfMode = %x\n", grfMode);
3342b44b1afbSAmine Khaldi     }
3343b44b1afbSAmine Khaldi     else if (!lstrcmpW(pwcsName, olepres0W))
3344b44b1afbSAmine Khaldi     {
3345b44b1afbSAmine Khaldi         CHECK_EXPECT(Storage_CreateStream_OlePres);
3346b44b1afbSAmine Khaldi         *ppstm = olepres_stream;
3347b44b1afbSAmine Khaldi 
3348b44b1afbSAmine Khaldi         todo_wine ok(grfMode == (STGM_SHARE_EXCLUSIVE|STGM_READWRITE), "grfMode = %x\n", grfMode);
3349b44b1afbSAmine Khaldi     }
3350b44b1afbSAmine Khaldi     else
3351b44b1afbSAmine Khaldi     {
3352b44b1afbSAmine Khaldi todo_wine
3353b44b1afbSAmine Khaldi         ok(0, "unexpected stream name %s\n", wine_dbgstr_w(pwcsName));
3354b44b1afbSAmine Khaldi #if 0   /* FIXME: return NULL once Wine is fixed */
3355b44b1afbSAmine Khaldi         *ppstm = NULL;
3356b44b1afbSAmine Khaldi         return E_NOTIMPL;
3357b44b1afbSAmine Khaldi #else
3358b44b1afbSAmine Khaldi         *ppstm = contents_stream;
3359b44b1afbSAmine Khaldi #endif
3360b44b1afbSAmine Khaldi     }
3361b44b1afbSAmine Khaldi 
3362c2c66affSColin Finck     ok(!reserved1, "reserved1 = %x\n", reserved1);
3363c2c66affSColin Finck     ok(!reserved2, "reserved2 = %x\n", reserved2);
3364c2c66affSColin Finck     ok(!!ppstm, "ppstm = NULL\n");
3365c2c66affSColin Finck 
3366b44b1afbSAmine Khaldi     IStream_AddRef(*ppstm);
3367b44b1afbSAmine Khaldi     hr = IStream_Seek(*ppstm, pos, STREAM_SEEK_SET, NULL);
3368c2c66affSColin Finck     ok(hr == S_OK, "IStream_Seek returned %x\n", hr);
3369b44b1afbSAmine Khaldi     hr = IStream_SetSize(*ppstm, size);
3370c2c66affSColin Finck     ok(hr == S_OK, "IStream_SetSize returned %x\n", hr);
3371c2c66affSColin Finck     return S_OK;
3372c2c66affSColin Finck }
3373c2c66affSColin Finck 
Storage_OpenStream(IStorage * iface,LPCOLESTR pwcsName,void * reserved1,DWORD grfMode,DWORD reserved2,IStream ** ppstm)3374c2c66affSColin Finck static HRESULT WINAPI Storage_OpenStream(IStorage *iface, LPCOLESTR pwcsName, void *reserved1, DWORD grfMode, DWORD reserved2, IStream **ppstm)
3375c2c66affSColin Finck {
3376c2c66affSColin Finck     static  const WCHAR ole1W[] = {1,'O','l','e',0};
3377c2c66affSColin Finck 
3378c2c66affSColin Finck     LARGE_INTEGER pos = {{0}};
3379c2c66affSColin Finck     HRESULT hr;
3380c2c66affSColin Finck 
3381c2c66affSColin Finck     ok(!reserved1, "reserved1 = %p\n", reserved1);
3382c2c66affSColin Finck     ok(!reserved2, "reserved2 = %x\n", reserved2);
3383c2c66affSColin Finck     ok(!!ppstm, "ppstm = NULL\n");
3384c2c66affSColin Finck 
3385c2c66affSColin Finck     if(!lstrcmpW(pwcsName, comp_objW)) {
3386c2c66affSColin Finck         CHECK_EXPECT2(Storage_OpenStream_CompObj);
3387c2c66affSColin Finck         ok(grfMode == STGM_SHARE_EXCLUSIVE, "grfMode = %x\n", grfMode);
3388c2c66affSColin Finck 
3389c2c66affSColin Finck         *ppstm = comp_obj_stream;
3390c2c66affSColin Finck         IStream_AddRef(comp_obj_stream);
3391c2c66affSColin Finck         hr = IStream_Seek(comp_obj_stream, pos, STREAM_SEEK_SET, NULL);
3392c2c66affSColin Finck         ok(hr == S_OK, "IStream_Seek returned %x\n", hr);
3393c2c66affSColin Finck         return S_OK;
3394c2c66affSColin Finck     }else if(!lstrcmpW(pwcsName, ole1W)) {
3395c2c66affSColin Finck         CHECK_EXPECT(Storage_OpenStream_Ole);
3396b44b1afbSAmine Khaldi 
3397b44b1afbSAmine Khaldi         if (!ole_stream)
3398b44b1afbSAmine Khaldi         {
3399b44b1afbSAmine Khaldi             ok(grfMode == (STGM_SHARE_EXCLUSIVE|STGM_READ), "grfMode = %x\n", grfMode);
3400b44b1afbSAmine Khaldi 
3401b44b1afbSAmine Khaldi             *ppstm = NULL;
3402b44b1afbSAmine Khaldi             return STG_E_FILENOTFOUND;
3403b44b1afbSAmine Khaldi         }
3404b44b1afbSAmine Khaldi 
3405c2c66affSColin Finck         ok(grfMode == (STGM_SHARE_EXCLUSIVE|STGM_READWRITE), "grfMode = %x\n", grfMode);
3406c2c66affSColin Finck 
3407c2c66affSColin Finck         *ppstm = ole_stream;
3408c2c66affSColin Finck         IStream_AddRef(ole_stream);
3409c2c66affSColin Finck         hr = IStream_Seek(ole_stream, pos, STREAM_SEEK_SET, NULL);
3410c2c66affSColin Finck         ok(hr == S_OK, "IStream_Seek returned %x\n", hr);
3411c2c66affSColin Finck         return S_OK;
3412b44b1afbSAmine Khaldi 
3413b44b1afbSAmine Khaldi     }else if(!lstrcmpW(pwcsName, olepres0W)) {
3414b44b1afbSAmine Khaldi         CHECK_EXPECT(Storage_OpenStream_OlePres);
3415b44b1afbSAmine Khaldi         ok(grfMode == (STGM_SHARE_EXCLUSIVE|STGM_READWRITE), "grfMode = %x\n", grfMode);
3416b44b1afbSAmine Khaldi 
3417b44b1afbSAmine Khaldi         *ppstm = olepres_stream;
3418b44b1afbSAmine Khaldi         IStream_AddRef(olepres_stream);
3419b44b1afbSAmine Khaldi         hr = IStream_Seek(olepres_stream, pos, STREAM_SEEK_SET, NULL);
3420b44b1afbSAmine Khaldi         ok(hr == S_OK, "IStream_Seek returned %x\n", hr);
3421b44b1afbSAmine Khaldi         return S_OK;
3422c2c66affSColin Finck     }
3423c2c66affSColin Finck 
3424c2c66affSColin Finck     ok(0, "unexpected call to OpenStream: %s\n", wine_dbgstr_w(pwcsName));
3425c2c66affSColin Finck     return E_NOTIMPL;
3426c2c66affSColin Finck }
3427c2c66affSColin Finck 
Storage_CreateStorage(IStorage * iface,LPCOLESTR pwcsName,DWORD grfMode,DWORD dwStgFmt,DWORD reserved2,IStorage ** ppstg)3428c2c66affSColin Finck static HRESULT WINAPI Storage_CreateStorage(IStorage *iface, LPCOLESTR pwcsName, DWORD grfMode, DWORD dwStgFmt, DWORD reserved2, IStorage **ppstg)
3429c2c66affSColin Finck {
3430c2c66affSColin Finck     ok(0, "unexpected call to CreateStorage\n");
3431c2c66affSColin Finck     return E_NOTIMPL;
3432c2c66affSColin Finck }
3433c2c66affSColin Finck 
Storage_OpenStorage(IStorage * iface,LPCOLESTR pwcsName,IStorage * pstgPriority,DWORD grfMode,SNB snbExclude,DWORD reserved,IStorage ** ppstg)3434c2c66affSColin Finck static HRESULT WINAPI Storage_OpenStorage(IStorage *iface, LPCOLESTR pwcsName, IStorage *pstgPriority, DWORD grfMode, SNB snbExclude, DWORD reserved, IStorage **ppstg)
3435c2c66affSColin Finck {
3436c2c66affSColin Finck     ok(0, "unexpected call to OpenStorage\n");
3437c2c66affSColin Finck     return E_NOTIMPL;
3438c2c66affSColin Finck }
3439c2c66affSColin Finck 
Storage_CopyTo(IStorage * iface,DWORD ciidExclude,const IID * rgiidExclude,SNB snbExclude,IStorage * pstgDest)3440c2c66affSColin Finck static HRESULT WINAPI Storage_CopyTo(IStorage *iface, DWORD ciidExclude, const IID *rgiidExclude, SNB snbExclude, IStorage *pstgDest)
3441c2c66affSColin Finck {
3442c2c66affSColin Finck     ok(0, "unexpected call to CopyTo\n");
3443c2c66affSColin Finck     return E_NOTIMPL;
3444c2c66affSColin Finck }
3445c2c66affSColin Finck 
Storage_MoveElementTo(IStorage * iface,LPCOLESTR pwcsName,IStorage * pstgDest,LPCOLESTR pwcsNewName,DWORD grfFlags)3446c2c66affSColin Finck static HRESULT WINAPI Storage_MoveElementTo(IStorage *iface, LPCOLESTR pwcsName, IStorage *pstgDest, LPCOLESTR pwcsNewName, DWORD grfFlags)
3447c2c66affSColin Finck {
3448c2c66affSColin Finck     ok(0, "unexpected call to MoveElementTo\n");
3449c2c66affSColin Finck     return E_NOTIMPL;
3450c2c66affSColin Finck }
3451c2c66affSColin Finck 
Storage_Commit(IStorage * iface,DWORD grfCommitFlags)3452c2c66affSColin Finck static HRESULT WINAPI Storage_Commit(IStorage *iface, DWORD grfCommitFlags)
3453c2c66affSColin Finck {
3454c2c66affSColin Finck     ok(0, "unexpected call to Commit\n");
3455c2c66affSColin Finck     return E_NOTIMPL;
3456c2c66affSColin Finck }
3457c2c66affSColin Finck 
Storage_Revert(IStorage * iface)3458c2c66affSColin Finck static HRESULT WINAPI Storage_Revert(IStorage *iface)
3459c2c66affSColin Finck {
3460c2c66affSColin Finck     ok(0, "unexpected call to Revert\n");
3461c2c66affSColin Finck     return E_NOTIMPL;
3462c2c66affSColin Finck }
3463c2c66affSColin Finck 
Storage_EnumElements(IStorage * iface,DWORD reserved1,void * reserved2,DWORD reserved3,IEnumSTATSTG ** ppenum)3464c2c66affSColin Finck static HRESULT WINAPI Storage_EnumElements(IStorage *iface, DWORD reserved1, void *reserved2, DWORD reserved3, IEnumSTATSTG **ppenum)
3465c2c66affSColin Finck {
3466c2c66affSColin Finck     ok(0, "unexpected call to EnumElements\n");
3467c2c66affSColin Finck     return E_NOTIMPL;
3468c2c66affSColin Finck }
3469c2c66affSColin Finck 
Storage_DestroyElement(IStorage * iface,LPCOLESTR pwcsName)3470c2c66affSColin Finck static HRESULT WINAPI Storage_DestroyElement(IStorage *iface, LPCOLESTR pwcsName)
3471c2c66affSColin Finck {
3472b44b1afbSAmine Khaldi     char name[32];
3473b44b1afbSAmine Khaldi     int stream_n, cmp;
3474b44b1afbSAmine Khaldi 
3475b44b1afbSAmine Khaldi     CHECK_EXPECT2(Storage_DestroyElement);
3476b44b1afbSAmine Khaldi     cmp = CompareStringW(LOCALE_NEUTRAL, 0, pwcsName, 8, olepres0W, 8);
3477b44b1afbSAmine Khaldi     ok(cmp == CSTR_EQUAL,
3478b44b1afbSAmine Khaldi        "unexpected call to DestroyElement(%s)\n", wine_dbgstr_w(pwcsName));
3479b44b1afbSAmine Khaldi 
3480b44b1afbSAmine Khaldi     WideCharToMultiByte(CP_ACP, 0, pwcsName, -1, name, sizeof(name), NULL, NULL);
3481b44b1afbSAmine Khaldi     stream_n = atol(name + 8);
3482b44b1afbSAmine Khaldi     if (stream_n <= Storage_DestroyElement_limit)
3483b44b1afbSAmine Khaldi         return S_OK;
3484b44b1afbSAmine Khaldi 
3485b44b1afbSAmine Khaldi     return STG_E_FILENOTFOUND;
3486c2c66affSColin Finck }
3487c2c66affSColin Finck 
Storage_RenameElement(IStorage * iface,LPCOLESTR pwcsOldName,LPCOLESTR pwcsNewName)3488c2c66affSColin Finck static HRESULT WINAPI Storage_RenameElement(IStorage *iface, LPCOLESTR pwcsOldName, LPCOLESTR pwcsNewName)
3489c2c66affSColin Finck {
3490c2c66affSColin Finck     ok(0, "unexpected call to RenameElement\n");
3491c2c66affSColin Finck     return E_NOTIMPL;
3492c2c66affSColin Finck }
3493c2c66affSColin Finck 
Storage_SetElementTimes(IStorage * iface,LPCOLESTR pwcsName,const FILETIME * pctime,const FILETIME * patime,const FILETIME * pmtime)3494c2c66affSColin Finck static HRESULT WINAPI Storage_SetElementTimes(IStorage *iface, LPCOLESTR pwcsName, const FILETIME *pctime, const FILETIME *patime, const FILETIME *pmtime)
3495c2c66affSColin Finck {
3496c2c66affSColin Finck     ok(0, "unexpected call to SetElementTimes\n");
3497c2c66affSColin Finck     return E_NOTIMPL;
3498c2c66affSColin Finck }
3499c2c66affSColin Finck 
Storage_SetClass(IStorage * iface,REFCLSID clsid)3500c2c66affSColin Finck static HRESULT WINAPI Storage_SetClass(IStorage *iface, REFCLSID clsid)
3501c2c66affSColin Finck {
3502c2c66affSColin Finck     CHECK_EXPECT(Storage_SetClass);
3503b44b1afbSAmine Khaldi     ok(IsEqualIID(clsid, Storage_SetClass_CLSID), "expected %s, got %s\n",
3504b44b1afbSAmine Khaldi        wine_dbgstr_guid(Storage_SetClass_CLSID), wine_dbgstr_guid(clsid));
3505c2c66affSColin Finck     return S_OK;
3506c2c66affSColin Finck }
3507c2c66affSColin Finck 
Storage_SetStateBits(IStorage * iface,DWORD grfStateBits,DWORD grfMask)3508c2c66affSColin Finck static HRESULT WINAPI Storage_SetStateBits(IStorage *iface, DWORD grfStateBits, DWORD grfMask)
3509c2c66affSColin Finck {
3510c2c66affSColin Finck     ok(0, "unexpected call to SetStateBits\n");
3511c2c66affSColin Finck     return E_NOTIMPL;
3512c2c66affSColin Finck }
3513c2c66affSColin Finck 
Storage_Stat(IStorage * iface,STATSTG * pstatstg,DWORD grfStatFlag)3514c2c66affSColin Finck static HRESULT WINAPI Storage_Stat(IStorage *iface, STATSTG *pstatstg, DWORD grfStatFlag)
3515c2c66affSColin Finck {
3516c2c66affSColin Finck     CHECK_EXPECT2(Storage_Stat);
3517c2c66affSColin Finck     ok(pstatstg != NULL, "pstatstg = NULL\n");
3518c2c66affSColin Finck     ok(grfStatFlag == STATFLAG_NONAME, "grfStatFlag = %x\n", grfStatFlag);
3519c2c66affSColin Finck 
3520c2c66affSColin Finck     memset(pstatstg, 0, sizeof(STATSTG));
3521c2c66affSColin Finck     pstatstg->type = STGTY_STORAGE;
3522c2c66affSColin Finck     pstatstg->clsid = CLSID_WineTestOld;
3523c2c66affSColin Finck     return S_OK;
3524c2c66affSColin Finck }
3525c2c66affSColin Finck 
3526c2c66affSColin Finck static IStorageVtbl StorageVtbl =
3527c2c66affSColin Finck {
3528c2c66affSColin Finck     Storage_QueryInterface,
3529c2c66affSColin Finck     Storage_AddRef,
3530c2c66affSColin Finck     Storage_Release,
3531c2c66affSColin Finck     Storage_CreateStream,
3532c2c66affSColin Finck     Storage_OpenStream,
3533c2c66affSColin Finck     Storage_CreateStorage,
3534c2c66affSColin Finck     Storage_OpenStorage,
3535c2c66affSColin Finck     Storage_CopyTo,
3536c2c66affSColin Finck     Storage_MoveElementTo,
3537c2c66affSColin Finck     Storage_Commit,
3538c2c66affSColin Finck     Storage_Revert,
3539c2c66affSColin Finck     Storage_EnumElements,
3540c2c66affSColin Finck     Storage_DestroyElement,
3541c2c66affSColin Finck     Storage_RenameElement,
3542c2c66affSColin Finck     Storage_SetElementTimes,
3543c2c66affSColin Finck     Storage_SetClass,
3544c2c66affSColin Finck     Storage_SetStateBits,
3545c2c66affSColin Finck     Storage_Stat
3546c2c66affSColin Finck };
3547c2c66affSColin Finck 
3548c2c66affSColin Finck static IStorage Storage = { &StorageVtbl };
3549c2c66affSColin Finck 
test_OleDoAutoConvert(void)3550c2c66affSColin Finck static void test_OleDoAutoConvert(void)
3551c2c66affSColin Finck {
3552c2c66affSColin Finck     static const WCHAR clsidW[] = {'C','L','S','I','D','\\',0};
3553c2c66affSColin Finck     static struct {
3554c2c66affSColin Finck         DWORD reserved1;
3555c2c66affSColin Finck         DWORD version;
3556c2c66affSColin Finck         DWORD reserved2[5];
3557c2c66affSColin Finck         DWORD ansi_user_type_len;
3558c2c66affSColin Finck         DWORD ansi_clipboard_format_len;
3559c2c66affSColin Finck         DWORD reserved3;
3560c2c66affSColin Finck         DWORD unicode_marker;
3561c2c66affSColin Finck         DWORD unicode_user_type_len;
3562c2c66affSColin Finck         DWORD unicode_clipboard_format_len;
3563c2c66affSColin Finck         DWORD reserved4;
3564c2c66affSColin Finck     } comp_obj_data;
3565c2c66affSColin Finck     static struct {
3566c2c66affSColin Finck         DWORD version;
3567c2c66affSColin Finck         DWORD flags;
3568c2c66affSColin Finck         DWORD link_update_option;
3569c2c66affSColin Finck         DWORD reserved1;
3570c2c66affSColin Finck         DWORD reserved_moniker_stream_size;
3571c2c66affSColin Finck         DWORD relative_source_moniker_stream_size;
3572c2c66affSColin Finck         DWORD absolute_source_moniker_stream_size;
3573c2c66affSColin Finck         DWORD clsid_indicator;
3574c2c66affSColin Finck         CLSID clsid;
3575c2c66affSColin Finck         DWORD reserved_display_name;
3576c2c66affSColin Finck         DWORD reserved2;
3577c2c66affSColin Finck         DWORD local_update_time;
3578c2c66affSColin Finck         DWORD local_check_update_time;
3579c2c66affSColin Finck         DWORD remote_update_time;
3580c2c66affSColin Finck     } ole_data;
3581c2c66affSColin Finck 
3582c2c66affSColin Finck     LARGE_INTEGER pos = {{0}};
3583c2c66affSColin Finck     WCHAR buf[39+6];
3584c2c66affSColin Finck     DWORD i, ret;
3585c2c66affSColin Finck     HKEY root;
3586c2c66affSColin Finck     CLSID clsid;
3587c2c66affSColin Finck     HRESULT hr;
3588c2c66affSColin Finck 
3589c2c66affSColin Finck     hr = CreateStreamOnHGlobal(NULL, TRUE, &comp_obj_stream);
3590c2c66affSColin Finck     ok(hr == S_OK, "CreateStreamOnHGlobal returned %x\n", hr);
3591c2c66affSColin Finck     hr = IStream_Write(comp_obj_stream, (char*)&comp_obj_data, sizeof(comp_obj_data), NULL);
3592c2c66affSColin Finck     ok(hr == S_OK, "IStream_Write returned %x\n", hr);
3593c2c66affSColin Finck 
3594c2c66affSColin Finck     hr = CreateStreamOnHGlobal(NULL, TRUE, &ole_stream);
3595c2c66affSColin Finck     ok(hr == S_OK, "CreateStreamOnHGlobal returned %x\n", hr);
3596c2c66affSColin Finck     hr = IStream_Write(ole_stream, (char*)&ole_data, sizeof(ole_data), NULL);
3597c2c66affSColin Finck     ok(hr == S_OK, "IStream_Write returned %x\n", hr);
3598c2c66affSColin Finck 
3599c2c66affSColin Finck     clsid = IID_WineTest;
3600c2c66affSColin Finck     hr = OleDoAutoConvert(NULL, &clsid);
3601c2c66affSColin Finck     ok(hr == E_INVALIDARG, "OleDoAutoConvert returned %x\n", hr);
3602c2c66affSColin Finck     ok(IsEqualIID(&clsid, &IID_NULL), "clsid = %s\n", wine_dbgstr_guid(&clsid));
3603c2c66affSColin Finck 
3604c2c66affSColin Finck     if(0) /* crashes on Win7 */
3605c2c66affSColin Finck         OleDoAutoConvert(&Storage, NULL);
3606c2c66affSColin Finck 
3607c2c66affSColin Finck     clsid = IID_WineTest;
3608c2c66affSColin Finck     SET_EXPECT(Storage_Stat);
3609c2c66affSColin Finck     hr = OleDoAutoConvert(&Storage, &clsid);
3610c2c66affSColin Finck     ok(hr == REGDB_E_CLASSNOTREG, "OleDoAutoConvert returned %x\n", hr);
3611c2c66affSColin Finck     CHECK_CALLED(Storage_Stat);
3612c2c66affSColin Finck     ok(IsEqualIID(&clsid, &CLSID_WineTestOld), "clsid = %s\n", wine_dbgstr_guid(&clsid));
3613c2c66affSColin Finck 
3614c2c66affSColin Finck     lstrcpyW(buf, clsidW);
3615c2c66affSColin Finck     StringFromGUID2(&CLSID_WineTestOld, buf+6, 39);
3616c2c66affSColin Finck 
3617c2c66affSColin Finck     ret = RegCreateKeyExW(HKEY_CLASSES_ROOT, buf, 0, NULL, 0,
3618c2c66affSColin Finck             KEY_READ | KEY_WRITE | KEY_CREATE_SUB_KEY, NULL, &root, NULL);
3619c2c66affSColin Finck     if(ret != ERROR_SUCCESS) {
3620c2c66affSColin Finck         win_skip("not enough permissions to create CLSID key (%u)\n", ret);
3621c2c66affSColin Finck         return;
3622c2c66affSColin Finck     }
3623c2c66affSColin Finck 
3624c2c66affSColin Finck     clsid = IID_WineTest;
3625c2c66affSColin Finck     SET_EXPECT(Storage_Stat);
3626c2c66affSColin Finck     hr = OleDoAutoConvert(&Storage, &clsid);
3627c2c66affSColin Finck     ok(hr == REGDB_E_KEYMISSING, "OleDoAutoConvert returned %x\n", hr);
3628c2c66affSColin Finck     CHECK_CALLED(Storage_Stat);
3629c2c66affSColin Finck     ok(IsEqualIID(&clsid, &CLSID_WineTestOld), "clsid = %s\n", wine_dbgstr_guid(&clsid));
3630c2c66affSColin Finck 
3631c2c66affSColin Finck     hr = OleSetAutoConvert(&CLSID_WineTestOld, &CLSID_WineTest);
3632c2c66affSColin Finck     ok_ole_success(hr, "OleSetAutoConvert");
3633c2c66affSColin Finck 
3634c2c66affSColin Finck     hr = OleGetAutoConvert(&CLSID_WineTestOld, &clsid);
3635c2c66affSColin Finck     ok_ole_success(hr, "OleGetAutoConvert");
3636c2c66affSColin Finck     ok(IsEqualIID(&clsid, &CLSID_WineTest), "incorrect clsid: %s\n", wine_dbgstr_guid(&clsid));
3637c2c66affSColin Finck 
3638c2c66affSColin Finck     clsid = IID_WineTest;
3639c2c66affSColin Finck     SET_EXPECT(Storage_Stat);
3640c2c66affSColin Finck     SET_EXPECT(Storage_OpenStream_CompObj);
3641c2c66affSColin Finck     SET_EXPECT(Storage_SetClass);
3642c2c66affSColin Finck     SET_EXPECT(Storage_CreateStream_CompObj);
3643c2c66affSColin Finck     SET_EXPECT(Storage_OpenStream_Ole);
3644c2c66affSColin Finck     hr = OleDoAutoConvert(&Storage, &clsid);
3645c2c66affSColin Finck     ok(hr == S_OK, "OleDoAutoConvert returned %x\n", hr);
3646c2c66affSColin Finck     CHECK_CALLED(Storage_Stat);
3647c2c66affSColin Finck     CHECK_CALLED(Storage_OpenStream_CompObj);
3648c2c66affSColin Finck     CHECK_CALLED(Storage_SetClass);
3649c2c66affSColin Finck     CHECK_CALLED(Storage_CreateStream_CompObj);
3650c2c66affSColin Finck     CHECK_CALLED(Storage_OpenStream_Ole);
3651c2c66affSColin Finck     ok(IsEqualIID(&clsid, &CLSID_WineTest), "clsid = %s\n", wine_dbgstr_guid(&clsid));
3652c2c66affSColin Finck 
3653c2c66affSColin Finck     hr = IStream_Seek(comp_obj_stream, pos, STREAM_SEEK_SET, NULL);
3654c2c66affSColin Finck     ok(hr == S_OK, "IStream_Seek returned %x\n", hr);
3655c2c66affSColin Finck     hr = IStream_Read(comp_obj_stream, &comp_obj_data, sizeof(comp_obj_data), NULL);
3656c2c66affSColin Finck     ok(hr == S_OK, "IStream_Read returned %x\n", hr);
3657c2c66affSColin Finck     ok(comp_obj_data.reserved1 == 0xfffe0001, "reserved1 = %x\n", comp_obj_data.reserved1);
3658c2c66affSColin Finck     ok(comp_obj_data.version == 0xa03, "version = %x\n", comp_obj_data.version);
3659c2c66affSColin Finck     ok(comp_obj_data.reserved2[0] == -1, "reserved2[0] = %x\n", comp_obj_data.reserved2[0]);
3660c2c66affSColin Finck     ok(IsEqualIID(comp_obj_data.reserved2+1, &CLSID_WineTestOld), "reserved2 = %s\n", wine_dbgstr_guid((CLSID*)(comp_obj_data.reserved2+1)));
3661c2c66affSColin Finck     ok(!comp_obj_data.ansi_user_type_len, "ansi_user_type_len = %d\n", comp_obj_data.ansi_user_type_len);
3662c2c66affSColin Finck     ok(!comp_obj_data.ansi_clipboard_format_len, "ansi_clipboard_format_len = %d\n", comp_obj_data.ansi_clipboard_format_len);
3663c2c66affSColin Finck     ok(!comp_obj_data.reserved3, "reserved3 = %x\n", comp_obj_data.reserved3);
3664c2c66affSColin Finck     ok(comp_obj_data.unicode_marker == 0x71b239f4, "unicode_marker = %x\n", comp_obj_data.unicode_marker);
3665c2c66affSColin Finck     ok(!comp_obj_data.unicode_user_type_len, "unicode_user_type_len = %d\n", comp_obj_data.unicode_user_type_len);
3666c2c66affSColin Finck     ok(!comp_obj_data.unicode_clipboard_format_len, "unicode_clipboard_format_len = %d\n", comp_obj_data.unicode_clipboard_format_len);
3667c2c66affSColin Finck     ok(!comp_obj_data.reserved4, "reserved4 %d\n", comp_obj_data.reserved4);
3668c2c66affSColin Finck 
3669c2c66affSColin Finck     hr = IStream_Seek(ole_stream, pos, STREAM_SEEK_SET, NULL);
3670c2c66affSColin Finck     ok(hr == S_OK, "IStream_Seek returned %x\n", hr);
3671c2c66affSColin Finck     hr = IStream_Read(ole_stream, &ole_data, sizeof(ole_data), NULL);
3672c2c66affSColin Finck     ok(hr == S_OK, "IStream_Read returned %x\n", hr);
3673c2c66affSColin Finck     ok(ole_data.version == 0, "version = %x\n", ole_data.version);
3674c2c66affSColin Finck     ok(ole_data.flags == 4, "flags = %x\n", ole_data.flags);
3675c2c66affSColin Finck     for(i=2; i<sizeof(ole_data)/sizeof(DWORD); i++)
3676c2c66affSColin Finck         ok(((DWORD*)&ole_data)[i] == 0, "ole_data[%d] = %x\n", i, ((DWORD*)&ole_data)[i]);
3677c2c66affSColin Finck 
3678c2c66affSColin Finck     SET_EXPECT(Storage_OpenStream_Ole);
3679c2c66affSColin Finck     hr = SetConvertStg(&Storage, TRUE);
3680c2c66affSColin Finck     ok(hr == S_OK, "SetConvertStg returned %x\n", hr);
3681c2c66affSColin Finck     CHECK_CALLED(Storage_OpenStream_Ole);
3682c2c66affSColin Finck 
3683c2c66affSColin Finck     SET_EXPECT(Storage_OpenStream_CompObj);
3684c2c66affSColin Finck     SET_EXPECT(Storage_Stat);
3685c2c66affSColin Finck     SET_EXPECT(Storage_CreateStream_CompObj);
3686c2c66affSColin Finck     hr = WriteFmtUserTypeStg(&Storage, 0, NULL);
3687c2c66affSColin Finck     ok(hr == S_OK, "WriteFmtUserTypeStg returned %x\n", hr);
3688c2c66affSColin Finck     todo_wine CHECK_CALLED(Storage_OpenStream_CompObj);
3689c2c66affSColin Finck     CHECK_CALLED(Storage_Stat);
3690c2c66affSColin Finck     CHECK_CALLED(Storage_CreateStream_CompObj);
3691c2c66affSColin Finck     hr = IStream_Seek(comp_obj_stream, pos, STREAM_SEEK_SET, NULL);
3692c2c66affSColin Finck     ok(hr == S_OK, "IStream_Seek returned %x\n", hr);
3693c2c66affSColin Finck     hr = IStream_Read(comp_obj_stream, &comp_obj_data, sizeof(comp_obj_data), NULL);
3694c2c66affSColin Finck     ok(hr == S_OK, "IStream_Read returned %x\n", hr);
3695c2c66affSColin Finck     ok(comp_obj_data.reserved1 == 0xfffe0001, "reserved1 = %x\n", comp_obj_data.reserved1);
3696c2c66affSColin Finck     ok(comp_obj_data.version == 0xa03, "version = %x\n", comp_obj_data.version);
3697c2c66affSColin Finck     ok(comp_obj_data.reserved2[0] == -1, "reserved2[0] = %x\n", comp_obj_data.reserved2[0]);
3698c2c66affSColin Finck     ok(IsEqualIID(comp_obj_data.reserved2+1, &CLSID_WineTestOld), "reserved2 = %s\n", wine_dbgstr_guid((CLSID*)(comp_obj_data.reserved2+1)));
3699c2c66affSColin Finck     ok(!comp_obj_data.ansi_user_type_len, "ansi_user_type_len = %d\n", comp_obj_data.ansi_user_type_len);
3700c2c66affSColin Finck     ok(!comp_obj_data.ansi_clipboard_format_len, "ansi_clipboard_format_len = %d\n", comp_obj_data.ansi_clipboard_format_len);
3701c2c66affSColin Finck     ok(!comp_obj_data.reserved3, "reserved3 = %x\n", comp_obj_data.reserved3);
3702c2c66affSColin Finck     ok(comp_obj_data.unicode_marker == 0x71b239f4, "unicode_marker = %x\n", comp_obj_data.unicode_marker);
3703c2c66affSColin Finck     ok(!comp_obj_data.unicode_user_type_len, "unicode_user_type_len = %d\n", comp_obj_data.unicode_user_type_len);
3704c2c66affSColin Finck     ok(!comp_obj_data.unicode_clipboard_format_len, "unicode_clipboard_format_len = %d\n", comp_obj_data.unicode_clipboard_format_len);
3705c2c66affSColin Finck     ok(!comp_obj_data.reserved4, "reserved4 %d\n", comp_obj_data.reserved4);
3706c2c66affSColin Finck 
3707c2c66affSColin Finck     ret = IStream_Release(comp_obj_stream);
3708c2c66affSColin Finck     ok(!ret, "comp_obj_stream was not freed\n");
3709c2c66affSColin Finck     ret = IStream_Release(ole_stream);
3710c2c66affSColin Finck     ok(!ret, "ole_stream was not freed\n");
3711c2c66affSColin Finck 
3712c2c66affSColin Finck     ret = RegDeleteKeyA(root, "AutoConvertTo");
3713c2c66affSColin Finck     ok(ret == ERROR_SUCCESS, "RegDeleteKey error %u\n", ret);
3714c2c66affSColin Finck     ret = RegDeleteKeyA(root, "");
3715c2c66affSColin Finck     ok(ret == ERROR_SUCCESS, "RegDeleteKey error %u\n", ret);
3716c2c66affSColin Finck     RegCloseKey(root);
3717c2c66affSColin Finck }
3718c2c66affSColin Finck 
3719b44b1afbSAmine Khaldi /* 1x1 pixel bmp */
3720b44b1afbSAmine Khaldi static const unsigned char bmpimage[] =
3721b44b1afbSAmine Khaldi {
3722b44b1afbSAmine Khaldi     0x42,0x4d,0x42,0x00,0x00,0x00,0x00,0x00,
3723b44b1afbSAmine Khaldi     0x00,0x00,0x3e,0x00,0x00,0x00,0x28,0x00,
3724b44b1afbSAmine Khaldi     0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,
3725b44b1afbSAmine Khaldi     0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x00,
3726b44b1afbSAmine Khaldi     0x00,0x00,0x04,0x00,0x00,0x00,0x12,0x0b,
3727b44b1afbSAmine Khaldi     0x00,0x00,0x12,0x0b,0x00,0x00,0x02,0x00,
3728b44b1afbSAmine Khaldi     0x00,0x00,0x02,0x00,0x00,0x00,0xff,0xff,
3729b44b1afbSAmine Khaldi     0xff,0x00,0xff,0xff,0xff,0x00,0x00,0x00,
3730b44b1afbSAmine Khaldi     0x00,0x00
3731b44b1afbSAmine Khaldi };
3732b44b1afbSAmine Khaldi 
3733b44b1afbSAmine Khaldi static const unsigned char mf_blank_bits[] =
3734b44b1afbSAmine Khaldi {
3735b44b1afbSAmine Khaldi     0x01,0x00,0x09,0x00,0x00,0x03,0x0c,0x00,
3736b44b1afbSAmine Khaldi     0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,
3737b44b1afbSAmine Khaldi     0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00
3738b44b1afbSAmine Khaldi };
3739b44b1afbSAmine Khaldi 
test_data_cache_save(void)3740b44b1afbSAmine Khaldi static void test_data_cache_save(void)
3741b44b1afbSAmine Khaldi {
3742b44b1afbSAmine Khaldi     static const WCHAR contentsW[] = { 'C','o','n','t','e','n','t','s',0 };
3743b44b1afbSAmine Khaldi     HRESULT hr;
3744b44b1afbSAmine Khaldi     ILockBytes *ilb;
3745b44b1afbSAmine Khaldi     IStorage *doc;
3746b44b1afbSAmine Khaldi     IStream *stm;
3747b44b1afbSAmine Khaldi     IOleCache2 *cache;
3748b44b1afbSAmine Khaldi     IPersistStorage *stg;
3749b44b1afbSAmine Khaldi     DWORD clipformat[2];
3750b44b1afbSAmine Khaldi     PresentationDataHeader hdr;
3751b44b1afbSAmine Khaldi 
3752b44b1afbSAmine Khaldi     hr = CreateILockBytesOnHGlobal(0, TRUE, &ilb);
3753b44b1afbSAmine Khaldi     ok(hr == S_OK, "unexpected %#x\n", hr);
3754b44b1afbSAmine Khaldi     hr = StgCreateDocfileOnILockBytes(ilb, STGM_CREATE | STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0,  &doc);
3755b44b1afbSAmine Khaldi     ok(hr == S_OK, "unexpected %#x\n", hr);
3756b44b1afbSAmine Khaldi 
3757b44b1afbSAmine Khaldi     ILockBytes_Release(ilb);
3758b44b1afbSAmine Khaldi 
3759b44b1afbSAmine Khaldi     hr = IStorage_SetClass(doc, &CLSID_WineTest);
3760b44b1afbSAmine Khaldi     ok(hr == S_OK, "unexpected %#x\n", hr);
3761b44b1afbSAmine Khaldi 
3762b44b1afbSAmine Khaldi     hr = IStorage_CreateStream(doc, contentsW, STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stm);
3763b44b1afbSAmine Khaldi     ok(hr == S_OK, "unexpected %#x\n", hr);
3764b44b1afbSAmine Khaldi     hr = IStream_Write(stm, bmpimage, sizeof(bmpimage), NULL);
3765b44b1afbSAmine Khaldi     ok(hr == S_OK, "unexpected %#x\n", hr);
3766b44b1afbSAmine Khaldi     IStream_Release(stm);
3767b44b1afbSAmine Khaldi 
3768b44b1afbSAmine Khaldi     hr = IStorage_CreateStream(doc, olepres0W, STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stm);
3769b44b1afbSAmine Khaldi     ok(hr == S_OK, "unexpected %#x\n", hr);
3770b44b1afbSAmine Khaldi 
3771b44b1afbSAmine Khaldi     clipformat[0] = -1;
3772b44b1afbSAmine Khaldi     clipformat[1] = CF_METAFILEPICT;
3773b44b1afbSAmine Khaldi     hr = IStream_Write(stm, clipformat, sizeof(clipformat), NULL);
3774b44b1afbSAmine Khaldi     ok(hr == S_OK, "unexpected %#x\n", hr);
3775b44b1afbSAmine Khaldi 
3776b44b1afbSAmine Khaldi     hdr.tdSize = sizeof(hdr.tdSize);
3777b44b1afbSAmine Khaldi     hdr.dvAspect = DVASPECT_CONTENT;
3778b44b1afbSAmine Khaldi     hdr.lindex = -1;
3779b44b1afbSAmine Khaldi     hdr.advf = ADVF_PRIMEFIRST;
3780b44b1afbSAmine Khaldi     hdr.unknown7 = 0;
3781b44b1afbSAmine Khaldi     hdr.dwObjectExtentX = 0;
3782b44b1afbSAmine Khaldi     hdr.dwObjectExtentY = 0;
3783b44b1afbSAmine Khaldi     hdr.dwSize = sizeof(mf_blank_bits);
3784b44b1afbSAmine Khaldi     hr = IStream_Write(stm, &hdr, sizeof(hdr), NULL);
3785b44b1afbSAmine Khaldi     ok(hr == S_OK, "unexpected %#x\n", hr);
3786b44b1afbSAmine Khaldi     hr = IStream_Write(stm, mf_blank_bits, sizeof(mf_blank_bits), NULL);
3787b44b1afbSAmine Khaldi     ok(hr == S_OK, "unexpected %#x\n", hr);
3788b44b1afbSAmine Khaldi 
3789b44b1afbSAmine Khaldi     IStream_Release(stm);
3790b44b1afbSAmine Khaldi 
3791b44b1afbSAmine Khaldi     hr = CreateDataCache(NULL, &CLSID_NULL, &IID_IUnknown, (void **)&cache);
3792b44b1afbSAmine Khaldi     ok(hr == S_OK, "unexpected %#x\n", hr);
3793b44b1afbSAmine Khaldi     hr = IOleCache2_QueryInterface(cache, &IID_IPersistStorage, (void **)&stg);
3794b44b1afbSAmine Khaldi     ok(hr == S_OK, "unexpected %#x\n", hr);
3795b44b1afbSAmine Khaldi     hr = IPersistStorage_Load(stg, doc);
3796b44b1afbSAmine Khaldi     ok(hr == S_OK, "unexpected %#x\n", hr);
3797b44b1afbSAmine Khaldi 
3798b44b1afbSAmine Khaldi     IStorage_Release(doc);
3799b44b1afbSAmine Khaldi 
3800b44b1afbSAmine Khaldi     hr = IPersistStorage_IsDirty(stg);
3801b44b1afbSAmine Khaldi     ok(hr == S_FALSE, "unexpected %#x\n", hr);
3802b44b1afbSAmine Khaldi 
3803b44b1afbSAmine Khaldi     ole_stream = NULL;
3804b44b1afbSAmine Khaldi     hr = CreateStreamOnHGlobal(NULL, TRUE, &olepres_stream);
3805b44b1afbSAmine Khaldi     ok(hr == S_OK, "unexpected %#x\n", hr);
3806b44b1afbSAmine Khaldi 
3807b44b1afbSAmine Khaldi     /* FIXME: remove this stream once Wine is fixed */
3808b44b1afbSAmine Khaldi     hr = CreateStreamOnHGlobal(NULL, TRUE, &contents_stream);
3809b44b1afbSAmine Khaldi     ok(hr == S_OK, "unexpected %#x\n", hr);
3810b44b1afbSAmine Khaldi 
3811b44b1afbSAmine Khaldi     SET_EXPECT(Storage_CreateStream_OlePres);
3812b44b1afbSAmine Khaldi     SET_EXPECT(Storage_OpenStream_OlePres);
3813b44b1afbSAmine Khaldi     SET_EXPECT(Storage_OpenStream_Ole);
3814b44b1afbSAmine Khaldi     SET_EXPECT(Storage_DestroyElement);
3815b44b1afbSAmine Khaldi     Storage_DestroyElement_limit = 50;
3816b44b1afbSAmine Khaldi     Storage_SetClass_CLSID = &CLSID_NULL;
3817b44b1afbSAmine Khaldi     trace("IPersistStorage_Save:\n");
3818b44b1afbSAmine Khaldi     hr = IPersistStorage_Save(stg, &Storage, FALSE);
3819b44b1afbSAmine Khaldi     ok(hr == S_OK, "unexpected %#x\n", hr);
3820b44b1afbSAmine Khaldi     CHECK_CALLED(Storage_CreateStream_OlePres);
3821b44b1afbSAmine Khaldi todo_wine
3822b44b1afbSAmine Khaldi     CHECK_CALLED(Storage_OpenStream_OlePres);
3823b44b1afbSAmine Khaldi todo_wine
3824b44b1afbSAmine Khaldi     CHECK_CALLED(Storage_OpenStream_Ole);
3825b44b1afbSAmine Khaldi todo_wine
3826b44b1afbSAmine Khaldi     CHECK_CALLED(Storage_DestroyElement);
3827b44b1afbSAmine Khaldi 
3828b44b1afbSAmine Khaldi     IStream_Release(olepres_stream);
3829b44b1afbSAmine Khaldi     IStream_Release(contents_stream);
3830b44b1afbSAmine Khaldi 
3831b44b1afbSAmine Khaldi     IPersistStorage_Release(stg);
3832b44b1afbSAmine Khaldi     IOleCache2_Release(cache);
3833b44b1afbSAmine Khaldi }
3834b44b1afbSAmine Khaldi 
3835b44b1afbSAmine Khaldi #define MAX_STREAM 16
3836b44b1afbSAmine Khaldi 
3837b44b1afbSAmine Khaldi struct stream_def
3838b44b1afbSAmine Khaldi {
3839b44b1afbSAmine Khaldi     const char *name;
3840b44b1afbSAmine Khaldi     int cf;
3841b44b1afbSAmine Khaldi     DVASPECT dvAspect;
3842b44b1afbSAmine Khaldi     ADVF advf;
3843b44b1afbSAmine Khaldi     const void *data;
3844b44b1afbSAmine Khaldi     size_t data_size;
3845b44b1afbSAmine Khaldi };
3846b44b1afbSAmine Khaldi 
3847b44b1afbSAmine Khaldi struct storage_def
3848b44b1afbSAmine Khaldi {
3849b44b1afbSAmine Khaldi     const CLSID *clsid;
3850b44b1afbSAmine Khaldi     int stream_count;
3851b44b1afbSAmine Khaldi     struct stream_def stream[MAX_STREAM];
3852b44b1afbSAmine Khaldi };
3853b44b1afbSAmine Khaldi 
3854b44b1afbSAmine Khaldi static const struct storage_def stg_def_0 =
3855b44b1afbSAmine Khaldi {
3856b44b1afbSAmine Khaldi     &CLSID_NULL, 1,
3857b44b1afbSAmine Khaldi     {{ "Contents", -1, 0, 0, bmpimage, sizeof(bmpimage) }}
3858b44b1afbSAmine Khaldi };
3859b44b1afbSAmine Khaldi static const struct storage_def stg_def_0_saved =
3860b44b1afbSAmine Khaldi {
3861b44b1afbSAmine Khaldi     &CLSID_NULL, 0, {{ 0 }}
3862b44b1afbSAmine Khaldi };
3863b44b1afbSAmine Khaldi static const struct storage_def stg_def_1 =
3864b44b1afbSAmine Khaldi {
3865b44b1afbSAmine Khaldi     &CLSID_NULL, 2,
3866b44b1afbSAmine Khaldi     {{ "Contents", -1, 0, 0, NULL, 0 },
3867b44b1afbSAmine Khaldi     { "\2OlePres000", 0, DVASPECT_ICON, ADVF_PRIMEFIRST | ADVF_ONLYONCE, NULL, 0 }}
3868b44b1afbSAmine Khaldi };
3869b44b1afbSAmine Khaldi static const struct storage_def stg_def_1_saved =
3870b44b1afbSAmine Khaldi {
3871b44b1afbSAmine Khaldi     &CLSID_NULL, 1,
3872b44b1afbSAmine Khaldi     {{ "\2OlePres000", 0, DVASPECT_ICON, ADVF_PRIMEFIRST | ADVF_ONLYONCE, NULL, 0 }}
3873b44b1afbSAmine Khaldi };
3874b44b1afbSAmine Khaldi static const struct storage_def stg_def_2 =
3875b44b1afbSAmine Khaldi {
3876b44b1afbSAmine Khaldi     &CLSID_ManualResetEvent, 2,
3877b44b1afbSAmine Khaldi     {{ "Contents", -1, 0, 0, bmpimage, sizeof(bmpimage) },
3878b44b1afbSAmine Khaldi     { "\2OlePres000", 0, DVASPECT_ICON, ADVF_PRIMEFIRST | ADVF_ONLYONCE, NULL, 0 }}
3879b44b1afbSAmine Khaldi };
3880b44b1afbSAmine Khaldi static const struct storage_def stg_def_2_saved =
3881b44b1afbSAmine Khaldi {
3882b44b1afbSAmine Khaldi     &CLSID_NULL, 1,
3883b44b1afbSAmine Khaldi     {{ "\2OlePres000", 0, DVASPECT_ICON, ADVF_PRIMEFIRST | ADVF_ONLYONCE, NULL, 0 }}
3884b44b1afbSAmine Khaldi };
3885b44b1afbSAmine Khaldi static const struct storage_def stg_def_3 =
3886b44b1afbSAmine Khaldi {
3887b44b1afbSAmine Khaldi     &CLSID_NULL, 5,
3888b44b1afbSAmine Khaldi     {{ "Contents", -1, 0, 0, bmpimage, sizeof(bmpimage) },
3889b44b1afbSAmine Khaldi     { "\2OlePres000", 0, DVASPECT_ICON, ADVF_PRIMEFIRST | ADVF_ONLYONCE, NULL, 0 },
3890b44b1afbSAmine Khaldi     { "\2OlePres001", CF_METAFILEPICT, DVASPECT_CONTENT, ADVF_PRIMEFIRST, mf_blank_bits, sizeof(mf_blank_bits) },
3891b44b1afbSAmine Khaldi     { "\2OlePres002", CF_DIB, DVASPECT_CONTENT, ADVF_PRIMEFIRST, bmpimage, sizeof(bmpimage) },
3892b44b1afbSAmine Khaldi     { "MyStream", -1, 0, 0, "Hello World!", 13 }}
3893b44b1afbSAmine Khaldi };
3894b44b1afbSAmine Khaldi static const struct storage_def stg_def_3_saved =
3895b44b1afbSAmine Khaldi {
3896b44b1afbSAmine Khaldi     &CLSID_NULL, 3,
3897b44b1afbSAmine Khaldi     {{ "\2OlePres000", 0, DVASPECT_ICON, ADVF_PRIMEFIRST | ADVF_ONLYONCE, NULL, 0 },
3898b44b1afbSAmine Khaldi     { "\2OlePres001", CF_METAFILEPICT, DVASPECT_CONTENT, ADVF_PRIMEFIRST, mf_blank_bits, sizeof(mf_blank_bits) },
3899b44b1afbSAmine Khaldi     { "\2OlePres002", CF_DIB, DVASPECT_CONTENT, ADVF_PRIMEFIRST, bmpimage, sizeof(bmpimage) }}
3900b44b1afbSAmine Khaldi };
3901b44b1afbSAmine Khaldi static const struct storage_def stg_def_4 =
3902b44b1afbSAmine Khaldi {
3903b44b1afbSAmine Khaldi     &CLSID_Picture_EnhMetafile, 5,
3904b44b1afbSAmine Khaldi     {{ "Contents", -1, 0, 0, bmpimage, sizeof(bmpimage) },
3905b44b1afbSAmine Khaldi     { "\2OlePres000", 0, DVASPECT_ICON, ADVF_PRIMEFIRST | ADVF_ONLYONCE, NULL, 0 },
3906b44b1afbSAmine Khaldi     { "\2OlePres001", CF_METAFILEPICT, DVASPECT_CONTENT, ADVF_PRIMEFIRST, mf_blank_bits, sizeof(mf_blank_bits) },
3907b44b1afbSAmine Khaldi     { "\2OlePres002", CF_DIB, DVASPECT_CONTENT, ADVF_PRIMEFIRST, bmpimage, sizeof(bmpimage) },
3908b44b1afbSAmine Khaldi     { "MyStream", -1, 0, 0, "Hello World!", 13 }}
3909b44b1afbSAmine Khaldi };
3910b44b1afbSAmine Khaldi static const struct storage_def stg_def_4_saved =
3911b44b1afbSAmine Khaldi {
3912b44b1afbSAmine Khaldi     &CLSID_NULL, 1,
3913b44b1afbSAmine Khaldi     {{ "\2OlePres000", 0, DVASPECT_ICON, ADVF_PRIMEFIRST | ADVF_ONLYONCE, NULL, 0 }}
3914b44b1afbSAmine Khaldi };
3915b44b1afbSAmine Khaldi static const struct storage_def stg_def_5 =
3916b44b1afbSAmine Khaldi {
3917b44b1afbSAmine Khaldi     &CLSID_Picture_Dib, 5,
3918b44b1afbSAmine Khaldi     {{ "Contents", -1, 0, 0, bmpimage, sizeof(bmpimage) },
3919b44b1afbSAmine Khaldi     { "\2OlePres002", CF_DIB, DVASPECT_CONTENT, ADVF_PRIMEFIRST, bmpimage, sizeof(bmpimage) },
3920b44b1afbSAmine Khaldi     { "\2OlePres001", CF_METAFILEPICT, DVASPECT_CONTENT, ADVF_PRIMEFIRST, mf_blank_bits, sizeof(mf_blank_bits) },
3921b44b1afbSAmine Khaldi     { "\2OlePres000", 0, DVASPECT_ICON, ADVF_PRIMEFIRST | ADVF_ONLYONCE, NULL, 0 },
3922b44b1afbSAmine Khaldi     { "MyStream", -1, 0, 0, "Hello World!", 13 }}
3923b44b1afbSAmine Khaldi };
3924b44b1afbSAmine Khaldi static const struct storage_def stg_def_5_saved =
3925b44b1afbSAmine Khaldi {
3926b44b1afbSAmine Khaldi     &CLSID_NULL, 1,
3927b44b1afbSAmine Khaldi     {{ "\2OlePres000", 0, DVASPECT_ICON, ADVF_PRIMEFIRST | ADVF_ONLYONCE, NULL, 0 }}
3928b44b1afbSAmine Khaldi };
3929b44b1afbSAmine Khaldi static const struct storage_def stg_def_6 =
3930b44b1afbSAmine Khaldi {
3931b44b1afbSAmine Khaldi     &CLSID_Picture_Metafile, 5,
3932b44b1afbSAmine Khaldi     {{ "Contents", -1, 0, 0, bmpimage, sizeof(bmpimage) },
3933b44b1afbSAmine Khaldi     { "\2OlePres001", CF_METAFILEPICT, DVASPECT_CONTENT, ADVF_PRIMEFIRST, mf_blank_bits, sizeof(mf_blank_bits) },
3934b44b1afbSAmine Khaldi     { "\2OlePres000", 0, DVASPECT_ICON, ADVF_PRIMEFIRST | ADVF_ONLYONCE, NULL, 0 },
3935b44b1afbSAmine Khaldi     { "\2OlePres002", CF_DIB, DVASPECT_CONTENT, ADVF_PRIMEFIRST, bmpimage, sizeof(bmpimage) },
3936b44b1afbSAmine Khaldi     { "MyStream", -1, 0, 0, "Hello World!", 13 }}
3937b44b1afbSAmine Khaldi };
3938b44b1afbSAmine Khaldi static const struct storage_def stg_def_6_saved =
3939b44b1afbSAmine Khaldi {
3940b44b1afbSAmine Khaldi     &CLSID_NULL, 1,
3941b44b1afbSAmine Khaldi     {{ "\2OlePres000", 0, DVASPECT_ICON, ADVF_PRIMEFIRST | ADVF_ONLYONCE, NULL, 0 }}
3942b44b1afbSAmine Khaldi };
3943b44b1afbSAmine Khaldi static const struct storage_def stg_def_7 =
3944b44b1afbSAmine Khaldi {
3945b44b1afbSAmine Khaldi     &CLSID_Picture_Dib, 1,
3946b44b1afbSAmine Khaldi     {{ "Contents", -1, 0, 0, bmpimage, sizeof(bmpimage) }}
3947b44b1afbSAmine Khaldi };
3948b44b1afbSAmine Khaldi static const struct storage_def stg_def_7_saved =
3949b44b1afbSAmine Khaldi {
3950b44b1afbSAmine Khaldi     &CLSID_NULL, 0, {{ 0 }}
3951b44b1afbSAmine Khaldi };
3952b44b1afbSAmine Khaldi static const struct storage_def stg_def_8 =
3953b44b1afbSAmine Khaldi {
3954b44b1afbSAmine Khaldi     &CLSID_Picture_Metafile, 1,
3955b44b1afbSAmine Khaldi     {{ "Contents", -1, 0, 0, mf_blank_bits, sizeof(mf_blank_bits) }}
3956b44b1afbSAmine Khaldi };
3957b44b1afbSAmine Khaldi static const struct storage_def stg_def_8_saved =
3958b44b1afbSAmine Khaldi {
3959b44b1afbSAmine Khaldi     &CLSID_NULL, 0, {{ 0 }}
3960b44b1afbSAmine Khaldi };
3961b44b1afbSAmine Khaldi static const struct storage_def stg_def_9 =
3962b44b1afbSAmine Khaldi {
3963b44b1afbSAmine Khaldi     &CLSID_Picture_EnhMetafile, 1,
3964b44b1afbSAmine Khaldi     {{ "Contents", -1, 0, 0, bmpimage, sizeof(bmpimage) }}
3965b44b1afbSAmine Khaldi };
3966b44b1afbSAmine Khaldi static const struct storage_def stg_def_9_saved =
3967b44b1afbSAmine Khaldi {
3968b44b1afbSAmine Khaldi     &CLSID_NULL, 0, {{ 0 }}
3969b44b1afbSAmine Khaldi };
3970b44b1afbSAmine Khaldi 
read_clipformat(IStream * stream)3971b44b1afbSAmine Khaldi static int read_clipformat(IStream *stream)
3972b44b1afbSAmine Khaldi {
3973b44b1afbSAmine Khaldi     HRESULT hr;
3974b44b1afbSAmine Khaldi     ULONG bytes;
3975b44b1afbSAmine Khaldi     int length, clipformat = -2;
3976b44b1afbSAmine Khaldi 
3977b44b1afbSAmine Khaldi     hr = IStream_Read(stream, &length, sizeof(length), &bytes);
3978b44b1afbSAmine Khaldi     if (hr != S_OK || bytes != sizeof(length))
3979b44b1afbSAmine Khaldi         return -2;
3980b44b1afbSAmine Khaldi     if (length == 0)
3981b44b1afbSAmine Khaldi         return 0;
3982b44b1afbSAmine Khaldi     if (length == -1)
3983b44b1afbSAmine Khaldi     {
3984b44b1afbSAmine Khaldi         hr = IStream_Read(stream, &clipformat, sizeof(clipformat), &bytes);
3985b44b1afbSAmine Khaldi         if (hr != S_OK || bytes != sizeof(clipformat))
3986b44b1afbSAmine Khaldi             return -2;
3987b44b1afbSAmine Khaldi     }
3988b44b1afbSAmine Khaldi     else
3989b44b1afbSAmine Khaldi         ok(0, "unhandled clipformat length %d\n", length);
3990b44b1afbSAmine Khaldi 
3991b44b1afbSAmine Khaldi     return clipformat;
3992b44b1afbSAmine Khaldi }
3993b44b1afbSAmine Khaldi 
check_storage_contents(IStorage * stg,const struct storage_def * stg_def,int * enumerated_streams,int * matched_streams)3994b44b1afbSAmine Khaldi static void check_storage_contents(IStorage *stg, const struct storage_def *stg_def,
3995b44b1afbSAmine Khaldi         int *enumerated_streams, int *matched_streams)
3996b44b1afbSAmine Khaldi {
3997b44b1afbSAmine Khaldi     HRESULT hr;
3998b44b1afbSAmine Khaldi     IEnumSTATSTG *enumstg;
3999b44b1afbSAmine Khaldi     IStream *stream;
4000b44b1afbSAmine Khaldi     STATSTG stat;
4001b44b1afbSAmine Khaldi     int i, seen_stream[MAX_STREAM] = { 0 };
4002b44b1afbSAmine Khaldi 
4003b44b1afbSAmine Khaldi     if (winetest_debug > 1)
4004b44b1afbSAmine Khaldi         trace("check_storage_contents:\n=============================================\n");
4005b44b1afbSAmine Khaldi 
4006b44b1afbSAmine Khaldi     *enumerated_streams = 0;
4007b44b1afbSAmine Khaldi     *matched_streams = 0;
4008b44b1afbSAmine Khaldi 
4009b44b1afbSAmine Khaldi     hr = IStorage_Stat(stg, &stat, STATFLAG_NONAME);
4010b44b1afbSAmine Khaldi     ok(hr == S_OK, "unexpected %#x\n", hr);
4011b44b1afbSAmine Khaldi     ok(IsEqualCLSID(stg_def->clsid, &stat.clsid), "expected %s, got %s\n",
4012b44b1afbSAmine Khaldi        wine_dbgstr_guid(stg_def->clsid), wine_dbgstr_guid(&stat.clsid));
4013b44b1afbSAmine Khaldi 
4014b44b1afbSAmine Khaldi     hr = IStorage_EnumElements(stg, 0, NULL, 0, &enumstg);
4015b44b1afbSAmine Khaldi     ok(hr == S_OK, "unexpected %#x\n", hr);
4016b44b1afbSAmine Khaldi 
4017b44b1afbSAmine Khaldi     for (;;)
4018b44b1afbSAmine Khaldi     {
4019b44b1afbSAmine Khaldi         ULONG bytes;
4020b44b1afbSAmine Khaldi         int clipformat = -1;
4021b44b1afbSAmine Khaldi         PresentationDataHeader header;
4022b44b1afbSAmine Khaldi         char name[32];
4023b44b1afbSAmine Khaldi         BYTE data[1024];
4024b44b1afbSAmine Khaldi 
4025b44b1afbSAmine Khaldi         memset(&header, 0, sizeof(header));
4026b44b1afbSAmine Khaldi 
4027b44b1afbSAmine Khaldi         hr = IEnumSTATSTG_Next(enumstg, 1, &stat, NULL);
4028b44b1afbSAmine Khaldi         if(hr == S_FALSE) break;
4029b44b1afbSAmine Khaldi         ok(hr == S_OK, "unexpected %#x\n", hr);
4030b44b1afbSAmine Khaldi 
4031b44b1afbSAmine Khaldi         if (winetest_debug > 1)
4032b44b1afbSAmine Khaldi             trace("name %s, type %u, size %d, clsid %s\n",
4033b44b1afbSAmine Khaldi                 wine_dbgstr_w(stat.pwcsName), stat.type, stat.cbSize.u.LowPart, wine_dbgstr_guid(&stat.clsid));
4034b44b1afbSAmine Khaldi 
4035b44b1afbSAmine Khaldi         ok(stat.type == STGTY_STREAM, "unexpected %#x\n", stat.type);
4036b44b1afbSAmine Khaldi 
4037b44b1afbSAmine Khaldi         WideCharToMultiByte(CP_ACP, 0, stat.pwcsName, -1, name, sizeof(name), NULL, NULL);
4038b44b1afbSAmine Khaldi 
4039b44b1afbSAmine Khaldi         hr = IStorage_OpenStream(stg, stat.pwcsName, NULL, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &stream);
4040b44b1afbSAmine Khaldi         ok(hr == S_OK, "unexpected %#x\n", hr);
4041b44b1afbSAmine Khaldi 
404266f35ef8SAmine Khaldi         if (!memcmp(name, "\2OlePres", 8))
4043b44b1afbSAmine Khaldi         {
404466f35ef8SAmine Khaldi             ULONG header_size = sizeof(header);
404566f35ef8SAmine Khaldi 
4046b44b1afbSAmine Khaldi             clipformat = read_clipformat(stream);
4047b44b1afbSAmine Khaldi 
404866f35ef8SAmine Khaldi             if (clipformat == 0) /* view cache */
404966f35ef8SAmine Khaldi                 header_size = FIELD_OFFSET(PresentationDataHeader, unknown7);
405066f35ef8SAmine Khaldi 
405166f35ef8SAmine Khaldi             hr = IStream_Read(stream, &header, header_size, &bytes);
4052b44b1afbSAmine Khaldi             ok(hr == S_OK, "unexpected %#x\n", hr);
405366f35ef8SAmine Khaldi             ok(bytes == header_size, "read %u bytes, expected %u\n", bytes, header_size);
4054b44b1afbSAmine Khaldi 
4055b44b1afbSAmine Khaldi             if (winetest_debug > 1)
4056b44b1afbSAmine Khaldi                 trace("header: tdSize %#x, dvAspect %#x, lindex %#x, advf %#x, unknown7 %#x, dwObjectExtentX %#x, dwObjectExtentY %#x, dwSize %#x\n",
4057b44b1afbSAmine Khaldi                     header.tdSize, header.dvAspect, header.lindex, header.advf, header.unknown7,
4058b44b1afbSAmine Khaldi                     header.dwObjectExtentX, header.dwObjectExtentY, header.dwSize);
4059b44b1afbSAmine Khaldi         }
4060b44b1afbSAmine Khaldi 
4061b44b1afbSAmine Khaldi         memset(data, 0, sizeof(data));
4062b44b1afbSAmine Khaldi         hr = IStream_Read(stream, data, sizeof(data), &bytes);
4063b44b1afbSAmine Khaldi         ok(hr == S_OK, "unexpected %#x\n", hr);
4064b44b1afbSAmine Khaldi         if (winetest_debug > 1)
4065b44b1afbSAmine Khaldi             trace("stream data (%u bytes): %02x %02x %02x %02x\n", bytes, data[0], data[1], data[2], data[3]);
4066b44b1afbSAmine Khaldi 
4067b44b1afbSAmine Khaldi         for (i = 0; i < stg_def->stream_count; i++)
4068b44b1afbSAmine Khaldi         {
4069b44b1afbSAmine Khaldi             if (seen_stream[i]) continue;
4070b44b1afbSAmine Khaldi 
4071b44b1afbSAmine Khaldi             if (winetest_debug > 1)
4072b44b1afbSAmine Khaldi                 trace("%s/%s, %d/%d, %d/%d, %d/%d\n",
4073b44b1afbSAmine Khaldi                     stg_def->stream[i].name, name,
4074b44b1afbSAmine Khaldi                     stg_def->stream[i].cf, clipformat,
4075b44b1afbSAmine Khaldi                     stg_def->stream[i].dvAspect, header.dvAspect,
4076b44b1afbSAmine Khaldi                     stg_def->stream[i].advf, header.advf);
4077b44b1afbSAmine Khaldi 
4078b44b1afbSAmine Khaldi             if (!strcmp(stg_def->stream[i].name, name) &&
4079b44b1afbSAmine Khaldi                 stg_def->stream[i].cf == clipformat &&
4080b44b1afbSAmine Khaldi                 stg_def->stream[i].dvAspect == header.dvAspect &&
4081b44b1afbSAmine Khaldi                 stg_def->stream[i].advf == header.advf &&
4082b44b1afbSAmine Khaldi                 stg_def->stream[i].data_size <= bytes &&
4083b44b1afbSAmine Khaldi                 (!stg_def->stream[i].data_size ||
4084b44b1afbSAmine Khaldi                     (!memcmp(stg_def->stream[i].data, data, min(stg_def->stream[i].data_size, bytes)))))
4085b44b1afbSAmine Khaldi             {
4086b44b1afbSAmine Khaldi                 if (winetest_debug > 1)
4087b44b1afbSAmine Khaldi                     trace("stream %d matches def stream %d\n", *enumerated_streams, i);
4088b44b1afbSAmine Khaldi                 seen_stream[i] = 1;
4089b44b1afbSAmine Khaldi                 *matched_streams += 1;
4090b44b1afbSAmine Khaldi             }
4091b44b1afbSAmine Khaldi         }
4092b44b1afbSAmine Khaldi 
4093b44b1afbSAmine Khaldi         CoTaskMemFree(stat.pwcsName);
4094b44b1afbSAmine Khaldi         IStream_Release(stream);
4095b44b1afbSAmine Khaldi 
4096b44b1afbSAmine Khaldi         *enumerated_streams += 1;
4097b44b1afbSAmine Khaldi     }
4098*5c1bcfecSAmine Khaldi 
4099*5c1bcfecSAmine Khaldi     IEnumSTATSTG_Release(enumstg);
4100b44b1afbSAmine Khaldi }
4101b44b1afbSAmine Khaldi 
stgmedium_cmp(const STGMEDIUM * med1,STGMEDIUM * med2)4102a6cdf4ffSAmine Khaldi static HRESULT stgmedium_cmp(const STGMEDIUM *med1, STGMEDIUM *med2)
4103a6cdf4ffSAmine Khaldi {
4104a6cdf4ffSAmine Khaldi     BYTE *data1, *data2;
4105a6cdf4ffSAmine Khaldi     ULONG datasize1, datasize2;
4106a6cdf4ffSAmine Khaldi 
4107a6cdf4ffSAmine Khaldi     if (med1->tymed != med2->tymed)
4108a6cdf4ffSAmine Khaldi         return E_FAIL;
4109a6cdf4ffSAmine Khaldi 
4110a6cdf4ffSAmine Khaldi     if (med1->tymed == TYMED_MFPICT)
4111a6cdf4ffSAmine Khaldi     {
4112a6cdf4ffSAmine Khaldi         METAFILEPICT *mfpict1 = GlobalLock(U(med1)->hMetaFilePict);
4113a6cdf4ffSAmine Khaldi         METAFILEPICT *mfpict2 = GlobalLock(U(med2)->hMetaFilePict);
4114a6cdf4ffSAmine Khaldi 
4115a6cdf4ffSAmine Khaldi         datasize1 = GetMetaFileBitsEx(mfpict1->hMF, 0, NULL);
4116a6cdf4ffSAmine Khaldi         datasize2 = GetMetaFileBitsEx(mfpict2->hMF, 0, NULL);
4117a6cdf4ffSAmine Khaldi         if (datasize1 == datasize2)
4118a6cdf4ffSAmine Khaldi         {
4119a6cdf4ffSAmine Khaldi             data1 = HeapAlloc(GetProcessHeap(), 0, datasize1);
4120a6cdf4ffSAmine Khaldi             data2 = HeapAlloc(GetProcessHeap(), 0, datasize2);
4121a6cdf4ffSAmine Khaldi             GetMetaFileBitsEx(mfpict1->hMF, datasize1, data1);
4122a6cdf4ffSAmine Khaldi             GetMetaFileBitsEx(mfpict2->hMF, datasize2, data2);
4123a6cdf4ffSAmine Khaldi         }
4124a6cdf4ffSAmine Khaldi         else return E_FAIL;
4125a6cdf4ffSAmine Khaldi     }
4126a6cdf4ffSAmine Khaldi     else if (med1->tymed == TYMED_ENHMF)
4127a6cdf4ffSAmine Khaldi     {
4128a6cdf4ffSAmine Khaldi         datasize1 = GetEnhMetaFileBits(med1->hEnhMetaFile, 0, NULL);
4129a6cdf4ffSAmine Khaldi         datasize2 = GetEnhMetaFileBits(med2->hEnhMetaFile, 0, NULL);
4130a6cdf4ffSAmine Khaldi         if (datasize1 == datasize2)
4131a6cdf4ffSAmine Khaldi         {
4132a6cdf4ffSAmine Khaldi             data1 = HeapAlloc(GetProcessHeap(), 0, datasize1);
4133a6cdf4ffSAmine Khaldi             data2 = HeapAlloc(GetProcessHeap(), 0, datasize2);
4134a6cdf4ffSAmine Khaldi             GetEnhMetaFileBits(med1->hEnhMetaFile, datasize1, data1);
4135a6cdf4ffSAmine Khaldi             GetEnhMetaFileBits(med2->hEnhMetaFile, datasize2, data2);
4136a6cdf4ffSAmine Khaldi         }
4137a6cdf4ffSAmine Khaldi         else return E_FAIL;
4138a6cdf4ffSAmine Khaldi     }
4139a6cdf4ffSAmine Khaldi     else if (med1->tymed == TYMED_HGLOBAL)
4140a6cdf4ffSAmine Khaldi     {
4141a6cdf4ffSAmine Khaldi         datasize1 = GlobalSize(med1->hGlobal);
4142a6cdf4ffSAmine Khaldi         datasize2 = GlobalSize(med2->hGlobal);
4143a6cdf4ffSAmine Khaldi 
4144a6cdf4ffSAmine Khaldi         if (datasize1 == datasize2)
4145a6cdf4ffSAmine Khaldi         {
4146a6cdf4ffSAmine Khaldi             data1 = GlobalLock(med1->hGlobal);
4147a6cdf4ffSAmine Khaldi             data2 = GlobalLock(med2->hGlobal);
4148a6cdf4ffSAmine Khaldi         }
4149a6cdf4ffSAmine Khaldi         else
4150a6cdf4ffSAmine Khaldi             return E_FAIL;
4151a6cdf4ffSAmine Khaldi     }
4152a6cdf4ffSAmine Khaldi     else
4153a6cdf4ffSAmine Khaldi         return E_NOTIMPL;
4154a6cdf4ffSAmine Khaldi 
4155a6cdf4ffSAmine Khaldi     if (memcmp(data1, data2, datasize1) != 0)
4156a6cdf4ffSAmine Khaldi         return E_FAIL;
4157a6cdf4ffSAmine Khaldi 
4158a6cdf4ffSAmine Khaldi     if (med1->tymed == TYMED_HGLOBAL)
4159a6cdf4ffSAmine Khaldi     {
4160a6cdf4ffSAmine Khaldi         GlobalUnlock(U(med1)->hGlobal);
4161a6cdf4ffSAmine Khaldi         GlobalUnlock(U(med2)->hGlobal);
4162a6cdf4ffSAmine Khaldi     }
4163a6cdf4ffSAmine Khaldi     else if (med1->tymed == TYMED_MFPICT)
4164a6cdf4ffSAmine Khaldi     {
4165a6cdf4ffSAmine Khaldi         HeapFree(GetProcessHeap(), 0, data1);
4166a6cdf4ffSAmine Khaldi         HeapFree(GetProcessHeap(), 0, data2);
4167a6cdf4ffSAmine Khaldi         GlobalUnlock(U(med1)->hMetaFilePict);
4168a6cdf4ffSAmine Khaldi         GlobalUnlock(U(med2)->hMetaFilePict);
4169a6cdf4ffSAmine Khaldi     }
4170a6cdf4ffSAmine Khaldi     else
4171a6cdf4ffSAmine Khaldi     {
4172a6cdf4ffSAmine Khaldi         HeapFree(GetProcessHeap(), 0, data1);
4173a6cdf4ffSAmine Khaldi         HeapFree(GetProcessHeap(), 0, data2);
4174a6cdf4ffSAmine Khaldi     }
4175a6cdf4ffSAmine Khaldi 
4176a6cdf4ffSAmine Khaldi     return S_OK;
4177a6cdf4ffSAmine Khaldi }
4178a6cdf4ffSAmine Khaldi 
create_storage_from_def(const struct storage_def * stg_def)4179b44b1afbSAmine Khaldi static IStorage *create_storage_from_def(const struct storage_def *stg_def)
4180b44b1afbSAmine Khaldi {
4181b44b1afbSAmine Khaldi     HRESULT hr;
4182b44b1afbSAmine Khaldi     IStorage *stg;
4183b44b1afbSAmine Khaldi     IStream *stm;
4184b44b1afbSAmine Khaldi     int i;
4185b44b1afbSAmine Khaldi 
4186b44b1afbSAmine Khaldi     hr = StgCreateDocfile(NULL, STGM_CREATE | STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_DELETEONRELEASE, 0, &stg);
4187b44b1afbSAmine Khaldi     ok(hr == S_OK, "unexpected %#x\n", hr);
4188b44b1afbSAmine Khaldi 
4189b44b1afbSAmine Khaldi     hr = IStorage_SetClass(stg, stg_def->clsid);
4190b44b1afbSAmine Khaldi     ok(hr == S_OK, "unexpected %#x\n", hr);
4191b44b1afbSAmine Khaldi 
4192b44b1afbSAmine Khaldi     for (i = 0; i < stg_def->stream_count; i++)
4193b44b1afbSAmine Khaldi     {
4194b44b1afbSAmine Khaldi         WCHAR name[32];
4195b44b1afbSAmine Khaldi 
4196b44b1afbSAmine Khaldi         MultiByteToWideChar(CP_ACP, 0, stg_def->stream[i].name, -1, name, 32);
4197b44b1afbSAmine Khaldi         hr = IStorage_CreateStream(stg, name, STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stm);
4198b44b1afbSAmine Khaldi         ok(hr == S_OK, "unexpected %#x\n", hr);
4199b44b1afbSAmine Khaldi 
4200b44b1afbSAmine Khaldi         if (stg_def->stream[i].cf != -1)
4201b44b1afbSAmine Khaldi         {
4202b44b1afbSAmine Khaldi             int clipformat[2];
4203b44b1afbSAmine Khaldi             PresentationDataHeader hdr;
4204b44b1afbSAmine Khaldi 
4205b44b1afbSAmine Khaldi             if (stg_def->stream[i].cf)
4206b44b1afbSAmine Khaldi             {
4207b44b1afbSAmine Khaldi                 clipformat[0] = -1;
4208b44b1afbSAmine Khaldi                 clipformat[1] = stg_def->stream[i].cf;
4209b44b1afbSAmine Khaldi                 hr = IStream_Write(stm, clipformat, sizeof(clipformat), NULL);
4210b44b1afbSAmine Khaldi             }
4211b44b1afbSAmine Khaldi             else
4212b44b1afbSAmine Khaldi             {
4213b44b1afbSAmine Khaldi                 clipformat[0] = 0;
4214b44b1afbSAmine Khaldi                 hr = IStream_Write(stm, &clipformat[0], sizeof(clipformat[0]), NULL);
4215b44b1afbSAmine Khaldi             }
4216b44b1afbSAmine Khaldi             ok(hr == S_OK, "unexpected %#x\n", hr);
4217b44b1afbSAmine Khaldi 
4218b44b1afbSAmine Khaldi             hdr.tdSize = sizeof(hdr.tdSize);
4219b44b1afbSAmine Khaldi             hdr.dvAspect = stg_def->stream[i].dvAspect;
4220b44b1afbSAmine Khaldi             hdr.lindex = -1;
4221b44b1afbSAmine Khaldi             hdr.advf = stg_def->stream[i].advf;
4222b44b1afbSAmine Khaldi             hdr.unknown7 = 0;
4223b44b1afbSAmine Khaldi             hdr.dwObjectExtentX = 0;
4224b44b1afbSAmine Khaldi             hdr.dwObjectExtentY = 0;
4225b44b1afbSAmine Khaldi             hdr.dwSize = stg_def->stream[i].data_size;
4226b44b1afbSAmine Khaldi             hr = IStream_Write(stm, &hdr, sizeof(hdr), NULL);
4227b44b1afbSAmine Khaldi             ok(hr == S_OK, "unexpected %#x\n", hr);
4228b44b1afbSAmine Khaldi         }
4229b44b1afbSAmine Khaldi 
4230b44b1afbSAmine Khaldi         if (stg_def->stream[i].data_size)
4231b44b1afbSAmine Khaldi         {
4232b44b1afbSAmine Khaldi             hr = IStream_Write(stm, stg_def->stream[i].data, stg_def->stream[i].data_size, NULL);
4233b44b1afbSAmine Khaldi             ok(hr == S_OK, "unexpected %#x\n", hr);
4234b44b1afbSAmine Khaldi         }
4235b44b1afbSAmine Khaldi 
4236b44b1afbSAmine Khaldi         IStream_Release(stm);
4237b44b1afbSAmine Khaldi     }
4238b44b1afbSAmine Khaldi 
4239b44b1afbSAmine Khaldi     return stg;
4240b44b1afbSAmine Khaldi }
4241b44b1afbSAmine Khaldi 
4242b44b1afbSAmine Khaldi static const BYTE dib_inf[] =
4243b44b1afbSAmine Khaldi {
4244b44b1afbSAmine Khaldi     0x42, 0x4d, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00,
4245b44b1afbSAmine Khaldi     0x00, 0x00, 0x36, 0x00, 0x00, 0x00
4246b44b1afbSAmine Khaldi };
4247b44b1afbSAmine Khaldi 
4248b44b1afbSAmine Khaldi static const BYTE mf_rec[] =
4249b44b1afbSAmine Khaldi {
4250b44b1afbSAmine Khaldi     0xd7, 0xcd, 0xc6, 0x9a, 0x00, 0x00, 0x00, 0x00,
4251b44b1afbSAmine Khaldi     0x00, 0x00, 0x16, 0x00, 0x2d, 0x00, 0x40, 0x02,
4252b44b1afbSAmine Khaldi     0x00, 0x00, 0x00, 0x00, 0x6a, 0x55
4253b44b1afbSAmine Khaldi };
4254b44b1afbSAmine Khaldi 
get_stgdef(struct storage_def * stg_def,CLIPFORMAT cf,STGMEDIUM * stg_med,int stm_idx)4255b44b1afbSAmine Khaldi static void get_stgdef(struct storage_def *stg_def, CLIPFORMAT cf, STGMEDIUM *stg_med, int stm_idx)
4256b44b1afbSAmine Khaldi {
4257b44b1afbSAmine Khaldi     BYTE *data;
4258b44b1afbSAmine Khaldi     int data_size;
4259b44b1afbSAmine Khaldi     METAFILEPICT *mfpict;
4260b44b1afbSAmine Khaldi     HDC hdc;
4261b44b1afbSAmine Khaldi 
4262b44b1afbSAmine Khaldi     switch (cf)
4263b44b1afbSAmine Khaldi     {
4264b44b1afbSAmine Khaldi     case CF_DIB:
4265b44b1afbSAmine Khaldi         data_size = sizeof(dib);
4266b44b1afbSAmine Khaldi         if (!strcmp(stg_def->stream[stm_idx].name, "CONTENTS"))
4267b44b1afbSAmine Khaldi         {
4268b44b1afbSAmine Khaldi             data_size += sizeof(dib_inf);
4269b44b1afbSAmine Khaldi             data = HeapAlloc(GetProcessHeap(), 0, data_size);
4270b44b1afbSAmine Khaldi             memcpy(data, dib_inf, sizeof(dib_inf));
4271b44b1afbSAmine Khaldi             memcpy(data + sizeof(dib_inf), dib, sizeof(dib));
4272b44b1afbSAmine Khaldi         }
4273b44b1afbSAmine Khaldi         else
4274b44b1afbSAmine Khaldi         {
4275b44b1afbSAmine Khaldi             data = HeapAlloc(GetProcessHeap(), 0, data_size);
4276b44b1afbSAmine Khaldi             memcpy(data, dib, sizeof(dib));
4277b44b1afbSAmine Khaldi         }
4278b44b1afbSAmine Khaldi         stg_def->stream[stm_idx].data = data;
4279b44b1afbSAmine Khaldi         stg_def->stream[stm_idx].data_size = data_size;
4280b44b1afbSAmine Khaldi         break;
4281b44b1afbSAmine Khaldi     case CF_METAFILEPICT:
4282b44b1afbSAmine Khaldi         mfpict = GlobalLock(U(stg_med)->hMetaFilePict);
4283b44b1afbSAmine Khaldi         data_size = GetMetaFileBitsEx(mfpict->hMF, 0, NULL);
4284b44b1afbSAmine Khaldi         if (!strcmp(stg_def->stream[stm_idx].name, "CONTENTS"))
4285b44b1afbSAmine Khaldi         {
4286b44b1afbSAmine Khaldi             data = HeapAlloc(GetProcessHeap(), 0, data_size + sizeof(mf_rec));
4287b44b1afbSAmine Khaldi             memcpy(data, mf_rec, sizeof(mf_rec));
4288b44b1afbSAmine Khaldi             GetMetaFileBitsEx(mfpict->hMF, data_size, data + sizeof(mf_rec));
4289b44b1afbSAmine Khaldi             data_size += sizeof(mf_rec);
4290b44b1afbSAmine Khaldi         }
4291b44b1afbSAmine Khaldi         else
4292b44b1afbSAmine Khaldi         {
4293b44b1afbSAmine Khaldi             data = HeapAlloc(GetProcessHeap(), 0, data_size);
4294b44b1afbSAmine Khaldi             GetMetaFileBitsEx(mfpict->hMF, data_size, data);
4295b44b1afbSAmine Khaldi         }
4296b44b1afbSAmine Khaldi         GlobalUnlock(U(stg_med)->hMetaFilePict);
4297b44b1afbSAmine Khaldi         stg_def->stream[stm_idx].data_size = data_size;
4298b44b1afbSAmine Khaldi         stg_def->stream[stm_idx].data = data;
4299b44b1afbSAmine Khaldi         break;
4300b44b1afbSAmine Khaldi     case CF_ENHMETAFILE:
4301b44b1afbSAmine Khaldi         if (!strcmp(stg_def->stream[stm_idx].name, "CONTENTS"))
4302b44b1afbSAmine Khaldi         {
4303b44b1afbSAmine Khaldi             data_size = GetEnhMetaFileBits(U(stg_med)->hEnhMetaFile, 0, NULL);
4304b44b1afbSAmine Khaldi             data = HeapAlloc(GetProcessHeap(), 0, sizeof(DWORD) + sizeof(ENHMETAHEADER) + data_size);
4305b44b1afbSAmine Khaldi             *((DWORD *)data) = sizeof(ENHMETAHEADER);
4306b44b1afbSAmine Khaldi             GetEnhMetaFileBits(U(stg_med)->hEnhMetaFile, data_size, data + sizeof(DWORD) + sizeof(ENHMETAHEADER));
4307b44b1afbSAmine Khaldi             memcpy(data + sizeof(DWORD), data + sizeof(DWORD) + sizeof(ENHMETAHEADER), sizeof(ENHMETAHEADER));
4308b44b1afbSAmine Khaldi             data_size += sizeof(DWORD) + sizeof(ENHMETAHEADER);
4309b44b1afbSAmine Khaldi         }
4310b44b1afbSAmine Khaldi         else
4311b44b1afbSAmine Khaldi         {
4312b44b1afbSAmine Khaldi             hdc = GetDC(NULL);
4313b44b1afbSAmine Khaldi             data_size = GetWinMetaFileBits(U(stg_med)->hEnhMetaFile, 0, NULL, MM_ANISOTROPIC, hdc);
4314b44b1afbSAmine Khaldi             data = HeapAlloc(GetProcessHeap(), 0, data_size);
4315b44b1afbSAmine Khaldi             GetWinMetaFileBits(U(stg_med)->hEnhMetaFile, data_size, data, MM_ANISOTROPIC, hdc);
4316b44b1afbSAmine Khaldi             ReleaseDC(NULL, hdc);
4317b44b1afbSAmine Khaldi         }
4318b44b1afbSAmine Khaldi         stg_def->stream[stm_idx].data_size = data_size;
4319b44b1afbSAmine Khaldi         stg_def->stream[stm_idx].data = data;
4320b44b1afbSAmine Khaldi         break;
4321b44b1afbSAmine Khaldi     }
4322b44b1afbSAmine Khaldi }
4323b44b1afbSAmine Khaldi 
get_stgmedium(CLIPFORMAT cfFormat,STGMEDIUM * stgmedium)4324b44b1afbSAmine Khaldi static void get_stgmedium(CLIPFORMAT cfFormat, STGMEDIUM *stgmedium)
4325b44b1afbSAmine Khaldi {
4326b44b1afbSAmine Khaldi     switch (cfFormat)
4327b44b1afbSAmine Khaldi     {
4328b44b1afbSAmine Khaldi     case CF_DIB:
4329b44b1afbSAmine Khaldi         create_dib(stgmedium);
4330b44b1afbSAmine Khaldi         break;
4331b44b1afbSAmine Khaldi     case CF_METAFILEPICT:
4332b44b1afbSAmine Khaldi         create_mfpict(stgmedium);
4333b44b1afbSAmine Khaldi         break;
4334b44b1afbSAmine Khaldi     case CF_ENHMETAFILE:
4335b44b1afbSAmine Khaldi         create_emf(stgmedium);
4336b44b1afbSAmine Khaldi         break;
4337b44b1afbSAmine Khaldi     default:
4338b44b1afbSAmine Khaldi         ok(0, "cf %x not implemented\n", cfFormat);
4339b44b1afbSAmine Khaldi     }
4340b44b1afbSAmine Khaldi }
4341b44b1afbSAmine Khaldi 
4342b44b1afbSAmine Khaldi #define MAX_FMTS 5
test_data_cache_save_data(void)4343b44b1afbSAmine Khaldi static void test_data_cache_save_data(void)
4344b44b1afbSAmine Khaldi {
4345b44b1afbSAmine Khaldi     HRESULT hr;
4346b44b1afbSAmine Khaldi     STGMEDIUM stgmed;
4347b44b1afbSAmine Khaldi     ILockBytes *ilb;
4348b44b1afbSAmine Khaldi     IStorage *doc;
4349b44b1afbSAmine Khaldi     IOleCache2 *cache;
4350b44b1afbSAmine Khaldi     IPersistStorage *persist;
4351a6cdf4ffSAmine Khaldi     IDataObject *odata;
4352b44b1afbSAmine Khaldi     int enumerated_streams, matched_streams, i;
4353b44b1afbSAmine Khaldi     DWORD dummy;
4354a6cdf4ffSAmine Khaldi     STGMEDIUM stgmeds[MAX_FMTS];
4355b44b1afbSAmine Khaldi     struct tests_data_cache
4356b44b1afbSAmine Khaldi     {
4357b44b1afbSAmine Khaldi         FORMATETC fmts[MAX_FMTS];
4358b44b1afbSAmine Khaldi         int num_fmts, num_set;
4359b44b1afbSAmine Khaldi         const CLSID *clsid;
4360b44b1afbSAmine Khaldi         struct storage_def stg_def;
4361b44b1afbSAmine Khaldi     };
4362b44b1afbSAmine Khaldi 
4363b44b1afbSAmine Khaldi     static struct tests_data_cache *pdata, data[] =
4364b44b1afbSAmine Khaldi     {
4365b44b1afbSAmine Khaldi         {
4366b44b1afbSAmine Khaldi             {
4367b44b1afbSAmine Khaldi                 { CF_DIB, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL },
4368b44b1afbSAmine Khaldi                 { CF_METAFILEPICT, 0, DVASPECT_CONTENT, -1, TYMED_MFPICT },
4369b44b1afbSAmine Khaldi                 { CF_ENHMETAFILE, 0, DVASPECT_CONTENT, -1, TYMED_ENHMF },
437066f35ef8SAmine Khaldi                 { 0, 0, DVASPECT_DOCPRINT, -1, TYMED_HGLOBAL },
4371b44b1afbSAmine Khaldi             },
437266f35ef8SAmine Khaldi             4, 3, &CLSID_WineTest,
4373b44b1afbSAmine Khaldi             {
437466f35ef8SAmine Khaldi                 &CLSID_WineTestOld, 4, { { "\2OlePres000", CF_DIB, DVASPECT_CONTENT, 0, NULL, 0 },
4375b44b1afbSAmine Khaldi                                          { "\2OlePres001", CF_METAFILEPICT, DVASPECT_CONTENT, 0, NULL, 0 },
437666f35ef8SAmine Khaldi                                          { "\2OlePres002", CF_ENHMETAFILE, DVASPECT_CONTENT, 0, NULL, 0 },
437766f35ef8SAmine Khaldi                                          { "\2OlePres003", 0, DVASPECT_DOCPRINT, 0, NULL, 0 } }
4378b44b1afbSAmine Khaldi             }
4379b44b1afbSAmine Khaldi         },
4380b44b1afbSAmine Khaldi         /* without setting data */
4381b44b1afbSAmine Khaldi         {
4382b44b1afbSAmine Khaldi             {
4383b44b1afbSAmine Khaldi                 { CF_DIB, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL },
4384b44b1afbSAmine Khaldi                 { CF_METAFILEPICT, 0, DVASPECT_CONTENT, -1, TYMED_MFPICT },
4385b44b1afbSAmine Khaldi                 { CF_ENHMETAFILE, 0, DVASPECT_CONTENT, -1, TYMED_ENHMF },
4386b44b1afbSAmine Khaldi             },
4387b44b1afbSAmine Khaldi             3, 0, &CLSID_WineTest,
4388b44b1afbSAmine Khaldi             {
4389b44b1afbSAmine Khaldi                 &CLSID_WineTestOld, 3, { { "\2OlePres000", CF_DIB, DVASPECT_CONTENT, 0, NULL, 0 },
4390b44b1afbSAmine Khaldi                                          { "\2OlePres001", CF_METAFILEPICT, DVASPECT_CONTENT, 0, NULL, 0 },
4391b44b1afbSAmine Khaldi                                          { "\2OlePres002", CF_ENHMETAFILE, DVASPECT_CONTENT, 0, NULL, 0 } }
4392b44b1afbSAmine Khaldi             }
4393b44b1afbSAmine Khaldi         },
4394b44b1afbSAmine Khaldi         /* static picture clsids */
4395b44b1afbSAmine Khaldi         {
4396b44b1afbSAmine Khaldi             {
4397b44b1afbSAmine Khaldi                 { CF_DIB, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL },
4398b44b1afbSAmine Khaldi             },
4399b44b1afbSAmine Khaldi             1, 1, &CLSID_Picture_Dib,
4400b44b1afbSAmine Khaldi             {
4401b44b1afbSAmine Khaldi                 &CLSID_WineTestOld, 1, { { "CONTENTS", -1, 0, 0, NULL, 0 } }
4402b44b1afbSAmine Khaldi             }
4403b44b1afbSAmine Khaldi         },
4404b44b1afbSAmine Khaldi         {
4405b44b1afbSAmine Khaldi             {
4406b44b1afbSAmine Khaldi                 { CF_METAFILEPICT, 0, DVASPECT_CONTENT, -1, TYMED_MFPICT },
4407b44b1afbSAmine Khaldi             },
4408b44b1afbSAmine Khaldi             1, 1, &CLSID_Picture_Metafile,
4409b44b1afbSAmine Khaldi             {
4410b44b1afbSAmine Khaldi                 &CLSID_WineTestOld, 1, { { "CONTENTS", -1, 0, 0, NULL, 0 } }
4411b44b1afbSAmine Khaldi             }
4412b44b1afbSAmine Khaldi         },
4413b44b1afbSAmine Khaldi         {
4414b44b1afbSAmine Khaldi             {
4415b44b1afbSAmine Khaldi                 { CF_ENHMETAFILE, 0, DVASPECT_CONTENT, -1, TYMED_ENHMF },
4416b44b1afbSAmine Khaldi             },
4417b44b1afbSAmine Khaldi             1, 1, &CLSID_Picture_EnhMetafile,
4418b44b1afbSAmine Khaldi             {
4419b44b1afbSAmine Khaldi                 &CLSID_WineTestOld, 1, { { "CONTENTS", -1, 0, 0, NULL, 0 } }
4420b44b1afbSAmine Khaldi             }
4421b44b1afbSAmine Khaldi         },
4422b44b1afbSAmine Khaldi         /* static picture clsids without setting any data */
4423b44b1afbSAmine Khaldi         {
4424b44b1afbSAmine Khaldi             {
4425b44b1afbSAmine Khaldi                 { CF_DIB, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL },
4426b44b1afbSAmine Khaldi             },
4427b44b1afbSAmine Khaldi             1, 0, &CLSID_Picture_Dib,
4428b44b1afbSAmine Khaldi             {
4429b44b1afbSAmine Khaldi                 &CLSID_WineTestOld, 1, { { "CONTENTS", -1, 0, 0, NULL, 0 } }
4430b44b1afbSAmine Khaldi             }
4431b44b1afbSAmine Khaldi         },
4432b44b1afbSAmine Khaldi         {
4433b44b1afbSAmine Khaldi             {
4434b44b1afbSAmine Khaldi                 { CF_METAFILEPICT, 0, DVASPECT_CONTENT, -1, TYMED_MFPICT },
4435b44b1afbSAmine Khaldi             },
4436b44b1afbSAmine Khaldi             1, 0, &CLSID_Picture_Metafile,
4437b44b1afbSAmine Khaldi             {
4438b44b1afbSAmine Khaldi                 &CLSID_WineTestOld, 1, { { "CONTENTS", -1, 0, 0, NULL, 0 } }
4439b44b1afbSAmine Khaldi             }
4440b44b1afbSAmine Khaldi         },
4441b44b1afbSAmine Khaldi         {
4442b44b1afbSAmine Khaldi             {
4443b44b1afbSAmine Khaldi                 { CF_ENHMETAFILE, 0, DVASPECT_CONTENT, -1, TYMED_ENHMF },
4444b44b1afbSAmine Khaldi             },
4445b44b1afbSAmine Khaldi             1, 0, &CLSID_Picture_EnhMetafile,
4446b44b1afbSAmine Khaldi             {
4447b44b1afbSAmine Khaldi                 &CLSID_WineTestOld, 1, { { "CONTENTS", -1, 0, 0, NULL, 0 } }
4448b44b1afbSAmine Khaldi             }
4449b44b1afbSAmine Khaldi         },
4450b44b1afbSAmine Khaldi         {
4451b44b1afbSAmine Khaldi             {
4452b44b1afbSAmine Khaldi                 { 0 }
4453b44b1afbSAmine Khaldi             }
4454b44b1afbSAmine Khaldi         }
4455b44b1afbSAmine Khaldi     };
4456b44b1afbSAmine Khaldi 
4457b44b1afbSAmine Khaldi     /* test _Save after caching directly through _Cache + _SetData */
4458b44b1afbSAmine Khaldi     for (pdata = data; pdata->clsid != NULL; pdata++)
4459b44b1afbSAmine Khaldi     {
4460b44b1afbSAmine Khaldi         hr = CreateDataCache(NULL, pdata->clsid, &IID_IOleCache2, (void **)&cache);
4461b44b1afbSAmine Khaldi         ok(hr == S_OK, "unexpected %#x\n", hr);
4462b44b1afbSAmine Khaldi 
4463b44b1afbSAmine Khaldi         for (i = 0; i < pdata->num_fmts; i++)
4464b44b1afbSAmine Khaldi         {
4465b44b1afbSAmine Khaldi             hr = IOleCache2_Cache(cache, &pdata->fmts[i], 0, &dummy);
4466b44b1afbSAmine Khaldi             ok(SUCCEEDED(hr), "unexpected %#x\n", hr);
4467b44b1afbSAmine Khaldi             if (i < pdata->num_set)
4468b44b1afbSAmine Khaldi             {
4469a6cdf4ffSAmine Khaldi                 get_stgmedium(pdata->fmts[i].cfFormat, &stgmeds[i]);
4470a6cdf4ffSAmine Khaldi                 get_stgdef(&pdata->stg_def, pdata->fmts[i].cfFormat, &stgmeds[i], i);
4471a6cdf4ffSAmine Khaldi                 hr = IOleCache2_SetData(cache, &pdata->fmts[i], &stgmeds[i], FALSE);
4472b44b1afbSAmine Khaldi                 ok(hr == S_OK, "unexpected %#x\n", hr);
4473b44b1afbSAmine Khaldi             }
4474b44b1afbSAmine Khaldi         }
4475b44b1afbSAmine Khaldi 
4476b44b1afbSAmine Khaldi         /* create Storage in memory where we'll save cache */
4477b44b1afbSAmine Khaldi         hr = CreateILockBytesOnHGlobal(0, TRUE, &ilb);
4478b44b1afbSAmine Khaldi         ok(hr == S_OK, "unexpected %#x\n", hr);
4479b44b1afbSAmine Khaldi         hr = StgCreateDocfileOnILockBytes(ilb, STGM_CREATE | STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0, &doc);
4480b44b1afbSAmine Khaldi         ok(hr == S_OK, "unexpected %#x\n", hr);
4481b44b1afbSAmine Khaldi         ILockBytes_Release(ilb);
4482b44b1afbSAmine Khaldi         hr = IStorage_SetClass(doc, &CLSID_WineTestOld);
4483b44b1afbSAmine Khaldi         ok(hr == S_OK, "unexpected %#x\n", hr);
4484b44b1afbSAmine Khaldi 
4485b44b1afbSAmine Khaldi         hr = IOleCache2_QueryInterface(cache, &IID_IPersistStorage, (void **)&persist);
4486b44b1afbSAmine Khaldi         ok(hr == S_OK, "unexpected %#x\n", hr);
4487b44b1afbSAmine Khaldi 
4488b44b1afbSAmine Khaldi         /* cache entries are dirty. test saving them to stg */
4489b44b1afbSAmine Khaldi         trace("IPersistStorage_Save:\n");
4490b44b1afbSAmine Khaldi         hr = IPersistStorage_Save(persist, doc, FALSE);
4491b44b1afbSAmine Khaldi         ok(hr == S_OK, "unexpected %#x\n", hr);
4492b44b1afbSAmine Khaldi 
4493b44b1afbSAmine Khaldi         hr = IPersistStorage_IsDirty(persist);
4494b44b1afbSAmine Khaldi         ok(hr == S_OK, "unexpected %#x\n", hr);
4495b44b1afbSAmine Khaldi 
4496b44b1afbSAmine Khaldi         check_storage_contents(doc, &pdata->stg_def, &enumerated_streams, &matched_streams);
4497b44b1afbSAmine Khaldi         ok(enumerated_streams == matched_streams, "enumerated %d != matched %d\n",
4498b44b1afbSAmine Khaldi            enumerated_streams, matched_streams);
4499b44b1afbSAmine Khaldi         ok(enumerated_streams == pdata->stg_def.stream_count, "created %d != def streams %d\n",
4500b44b1afbSAmine Khaldi            enumerated_streams, pdata->stg_def.stream_count);
4501b44b1afbSAmine Khaldi 
4502a6cdf4ffSAmine Khaldi         IPersistStorage_Release(persist);
4503a6cdf4ffSAmine Khaldi         IOleCache2_Release(cache);
4504b44b1afbSAmine Khaldi 
4505a6cdf4ffSAmine Khaldi         /* now test _Load/_GetData using the storage we used for _Save */
4506a6cdf4ffSAmine Khaldi         hr = CreateDataCache(NULL, pdata->clsid, &IID_IOleCache2, (void **)&cache);
4507a6cdf4ffSAmine Khaldi         ok(hr == S_OK, "unexpected %#x\n", hr);
4508a6cdf4ffSAmine Khaldi         hr = IOleCache2_QueryInterface(cache, &IID_IPersistStorage, (void **)&persist);
4509a6cdf4ffSAmine Khaldi         ok(hr == S_OK, "unexpected %#x\n", hr);
4510a6cdf4ffSAmine Khaldi 
4511a6cdf4ffSAmine Khaldi         hr = IStorage_SetClass(doc, pdata->clsid);
4512a6cdf4ffSAmine Khaldi         ok(hr == S_OK, "unexpected %#x\n", hr);
4513a6cdf4ffSAmine Khaldi         trace("IPersistStorage_Load\n");
4514a6cdf4ffSAmine Khaldi         hr = IPersistStorage_Load(persist, doc);
4515a6cdf4ffSAmine Khaldi         ok(hr == S_OK, "unexpected %#x\n", hr);
4516a6cdf4ffSAmine Khaldi 
4517a6cdf4ffSAmine Khaldi         hr = IOleCache2_QueryInterface(cache, &IID_IDataObject, (void **)&odata);
4518a6cdf4ffSAmine Khaldi         ok(hr == S_OK, "unexpected %#x\n", hr);
4519a6cdf4ffSAmine Khaldi         for (i = 0; i < pdata->num_set; i++)
4520a6cdf4ffSAmine Khaldi         {
4521a6cdf4ffSAmine Khaldi             hr = IDataObject_GetData(odata, &pdata->fmts[i], &stgmed);
4522a6cdf4ffSAmine Khaldi             ok(hr == S_OK, "unexpected %#x\n", hr);
4523a6cdf4ffSAmine Khaldi 
4524a6cdf4ffSAmine Khaldi             hr = stgmedium_cmp(&stgmeds[i], &stgmed);
4525a6cdf4ffSAmine Khaldi             ok(hr == S_OK, "unexpected %#x\n", hr);
4526a6cdf4ffSAmine Khaldi             ReleaseStgMedium(&stgmed);
4527a6cdf4ffSAmine Khaldi             ReleaseStgMedium(&stgmeds[i]);
4528a6cdf4ffSAmine Khaldi         }
4529a6cdf4ffSAmine Khaldi 
4530a6cdf4ffSAmine Khaldi         IDataObject_Release(odata);
4531b44b1afbSAmine Khaldi         IPersistStorage_Release(persist);
4532b44b1afbSAmine Khaldi         IStorage_Release(doc);
4533b44b1afbSAmine Khaldi         IOleCache2_Release(cache);
4534a6cdf4ffSAmine Khaldi         for (i = 0; i < pdata->num_set; i++)
4535a6cdf4ffSAmine Khaldi             HeapFree(GetProcessHeap(), 0, (void *)pdata->stg_def.stream[i].data);
4536a6cdf4ffSAmine Khaldi 
4537b44b1afbSAmine Khaldi     }
4538b44b1afbSAmine Khaldi }
4539b44b1afbSAmine Khaldi 
test_data_cache_contents(void)4540b44b1afbSAmine Khaldi static void test_data_cache_contents(void)
4541b44b1afbSAmine Khaldi {
4542b44b1afbSAmine Khaldi     HRESULT hr;
4543b44b1afbSAmine Khaldi     IStorage *doc1, *doc2;
4544b44b1afbSAmine Khaldi     IOleCache2 *cache;
4545b44b1afbSAmine Khaldi     IPersistStorage *stg;
4546b44b1afbSAmine Khaldi     int i, enumerated_streams, matched_streams;
4547b44b1afbSAmine Khaldi     static const struct
4548b44b1afbSAmine Khaldi     {
4549b44b1afbSAmine Khaldi         const struct storage_def *in;
4550b44b1afbSAmine Khaldi         const struct storage_def *out;
4551b44b1afbSAmine Khaldi     } test_data[] =
4552b44b1afbSAmine Khaldi     {
4553b44b1afbSAmine Khaldi         { &stg_def_0, &stg_def_0_saved },
4554b44b1afbSAmine Khaldi         { &stg_def_1, &stg_def_1_saved },
4555b44b1afbSAmine Khaldi         { &stg_def_2, &stg_def_2_saved },
4556b44b1afbSAmine Khaldi         { &stg_def_3, &stg_def_3_saved },
4557b44b1afbSAmine Khaldi         { &stg_def_4, &stg_def_4_saved },
4558b44b1afbSAmine Khaldi         { &stg_def_5, &stg_def_5_saved },
4559b44b1afbSAmine Khaldi         { &stg_def_6, &stg_def_6_saved },
4560b44b1afbSAmine Khaldi         { &stg_def_7, &stg_def_7_saved },
4561b44b1afbSAmine Khaldi         { &stg_def_8, &stg_def_8_saved },
4562b44b1afbSAmine Khaldi         { &stg_def_9, &stg_def_9_saved },
4563b44b1afbSAmine Khaldi     };
4564b44b1afbSAmine Khaldi 
4565*5c1bcfecSAmine Khaldi     for (i = 0; i < ARRAY_SIZE(test_data); i++)
4566b44b1afbSAmine Khaldi     {
4567b44b1afbSAmine Khaldi         if (winetest_debug > 1)
4568b44b1afbSAmine Khaldi             trace("start testing storage def %d\n", i);
4569b44b1afbSAmine Khaldi 
4570b44b1afbSAmine Khaldi         doc1 = create_storage_from_def(test_data[i].in);
4571b44b1afbSAmine Khaldi         if (!doc1) continue;
4572b44b1afbSAmine Khaldi 
4573b44b1afbSAmine Khaldi         enumerated_streams = matched_streams = -1;
4574b44b1afbSAmine Khaldi         check_storage_contents(doc1, test_data[i].in, &enumerated_streams, &matched_streams);
4575b44b1afbSAmine Khaldi         ok(enumerated_streams == matched_streams, "%d in: enumerated %d != matched %d\n", i,
4576b44b1afbSAmine Khaldi            enumerated_streams, matched_streams);
4577b44b1afbSAmine Khaldi         ok(enumerated_streams == test_data[i].in->stream_count, "%d: created %d != def streams %d\n", i,
4578b44b1afbSAmine Khaldi            enumerated_streams, test_data[i].in->stream_count);
4579b44b1afbSAmine Khaldi 
4580b44b1afbSAmine Khaldi         hr = CreateDataCache(NULL, &CLSID_NULL, &IID_IUnknown, (void **)&cache);
4581b44b1afbSAmine Khaldi         ok(hr == S_OK, "unexpected %#x\n", hr);
4582b44b1afbSAmine Khaldi         hr = IOleCache2_QueryInterface(cache, &IID_IPersistStorage, (void **)&stg);
4583b44b1afbSAmine Khaldi         ok(hr == S_OK, "unexpected %#x\n", hr);
4584b44b1afbSAmine Khaldi         hr = IPersistStorage_Load(stg, doc1);
4585b44b1afbSAmine Khaldi         ok(hr == S_OK, "unexpected %#x\n", hr);
4586b44b1afbSAmine Khaldi 
4587b44b1afbSAmine Khaldi         IStorage_Release(doc1);
4588b44b1afbSAmine Khaldi 
4589b44b1afbSAmine Khaldi         hr = StgCreateDocfile(NULL, STGM_CREATE | STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_DELETEONRELEASE, 0, &doc2);
4590b44b1afbSAmine Khaldi         ok(hr == S_OK, "unexpected %#x\n", hr);
4591b44b1afbSAmine Khaldi 
4592b44b1afbSAmine Khaldi         hr = IPersistStorage_IsDirty(stg);
4593b44b1afbSAmine Khaldi         ok(hr == S_FALSE, "%d: unexpected %#x\n", i, hr);
4594b44b1afbSAmine Khaldi 
4595b44b1afbSAmine Khaldi         hr = IPersistStorage_Save(stg, doc2, FALSE);
4596b44b1afbSAmine Khaldi         ok(hr == S_OK, "unexpected %#x\n", hr);
4597b44b1afbSAmine Khaldi 
4598b44b1afbSAmine Khaldi         IPersistStorage_Release(stg);
4599b44b1afbSAmine Khaldi 
4600b44b1afbSAmine Khaldi         enumerated_streams = matched_streams = -1;
4601b44b1afbSAmine Khaldi         check_storage_contents(doc2, test_data[i].out, &enumerated_streams, &matched_streams);
4602b44b1afbSAmine Khaldi todo_wine_if(!(test_data[i].in == &stg_def_0 || test_data[i].in == &stg_def_1 || test_data[i].in == &stg_def_2))
4603b44b1afbSAmine Khaldi         ok(enumerated_streams == matched_streams, "%d out: enumerated %d != matched %d\n", i,
4604b44b1afbSAmine Khaldi            enumerated_streams, matched_streams);
460566f35ef8SAmine Khaldi todo_wine_if(!(test_data[i].in == &stg_def_0 || test_data[i].in == &stg_def_4 || test_data[i].in == &stg_def_5
460666f35ef8SAmine Khaldi                  || test_data[i].in == &stg_def_6))
4607b44b1afbSAmine Khaldi         ok(enumerated_streams == test_data[i].out->stream_count, "%d: saved streams %d != def streams %d\n", i,
4608b44b1afbSAmine Khaldi             enumerated_streams, test_data[i].out->stream_count);
4609b44b1afbSAmine Khaldi 
4610b44b1afbSAmine Khaldi         IStorage_Release(doc2);
4611b44b1afbSAmine Khaldi 
4612b44b1afbSAmine Khaldi         if (winetest_debug > 1)
4613b44b1afbSAmine Khaldi             trace("done testing storage def %d\n", i);
4614b44b1afbSAmine Khaldi     }
4615b44b1afbSAmine Khaldi }
4616b44b1afbSAmine Khaldi 
test_OleCreateStaticFromData(void)4617*5c1bcfecSAmine Khaldi static void test_OleCreateStaticFromData(void)
4618*5c1bcfecSAmine Khaldi {
4619*5c1bcfecSAmine Khaldi     HRESULT hr;
4620*5c1bcfecSAmine Khaldi     IOleObject *ole_obj = NULL;
4621*5c1bcfecSAmine Khaldi     IStorage *storage;
4622*5c1bcfecSAmine Khaldi     ILockBytes *ilb;
4623*5c1bcfecSAmine Khaldi     IPersist *persist;
4624*5c1bcfecSAmine Khaldi     CLSID clsid;
4625*5c1bcfecSAmine Khaldi     STATSTG statstg;
4626*5c1bcfecSAmine Khaldi     int enumerated_streams, matched_streams;
4627*5c1bcfecSAmine Khaldi     STGMEDIUM stgmed;
4628*5c1bcfecSAmine Khaldi     static FORMATETC dib_fmt[] =
4629*5c1bcfecSAmine Khaldi     {
4630*5c1bcfecSAmine Khaldi         { CF_DIB, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL },
4631*5c1bcfecSAmine Khaldi         { 0 }
4632*5c1bcfecSAmine Khaldi     };
4633*5c1bcfecSAmine Khaldi     static FORMATETC emf_fmt[] =
4634*5c1bcfecSAmine Khaldi     {
4635*5c1bcfecSAmine Khaldi         { CF_ENHMETAFILE, NULL, DVASPECT_CONTENT, -1, TYMED_ENHMF },
4636*5c1bcfecSAmine Khaldi         { 0 }
4637*5c1bcfecSAmine Khaldi     };
4638*5c1bcfecSAmine Khaldi     static FORMATETC text_fmt[] =
4639*5c1bcfecSAmine Khaldi     {
4640*5c1bcfecSAmine Khaldi         { CF_TEXT, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL },
4641*5c1bcfecSAmine Khaldi         { 0 }
4642*5c1bcfecSAmine Khaldi     };
4643*5c1bcfecSAmine Khaldi     static const struct expected_method methods_create_from_dib[] =
4644*5c1bcfecSAmine Khaldi     {
4645*5c1bcfecSAmine Khaldi         { "DataObject_EnumFormatEtc", TEST_TODO },
4646*5c1bcfecSAmine Khaldi         { "DataObject_GetDataHere", 0 },
4647*5c1bcfecSAmine Khaldi         { "DataObject_QueryGetData", 0, { CF_METAFILEPICT, NULL, DVASPECT_CONTENT, -1, TYMED_ISTORAGE } },
4648*5c1bcfecSAmine Khaldi         { NULL }
4649*5c1bcfecSAmine Khaldi     };
4650*5c1bcfecSAmine Khaldi     static const struct expected_method methods_createstatic_from_dib[] =
4651*5c1bcfecSAmine Khaldi     {
4652*5c1bcfecSAmine Khaldi         { "DataObject_GetData", 0, { CF_DIB, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL } },
4653*5c1bcfecSAmine Khaldi         { NULL }
4654*5c1bcfecSAmine Khaldi     };
4655*5c1bcfecSAmine Khaldi     static const struct expected_method methods_createstatic_from_emf[] =
4656*5c1bcfecSAmine Khaldi     {
4657*5c1bcfecSAmine Khaldi         { "DataObject_GetData", 0, { CF_ENHMETAFILE, NULL, DVASPECT_CONTENT, -1, TYMED_ENHMF } },
4658*5c1bcfecSAmine Khaldi         { NULL }
4659*5c1bcfecSAmine Khaldi     };
4660*5c1bcfecSAmine Khaldi     static const struct expected_method methods_createstatic_from_text[] =
4661*5c1bcfecSAmine Khaldi     {
4662*5c1bcfecSAmine Khaldi         { "DataObject_GetData", 0, { CF_TEXT, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL } },
4663*5c1bcfecSAmine Khaldi         { NULL }
4664*5c1bcfecSAmine Khaldi     };
4665*5c1bcfecSAmine Khaldi     static struct storage_def stg_def_dib =
4666*5c1bcfecSAmine Khaldi     {
4667*5c1bcfecSAmine Khaldi         &CLSID_Picture_Dib, 3,
4668*5c1bcfecSAmine Khaldi         {{ "\1Ole", -1, 0, 0, NULL, 0 },
4669*5c1bcfecSAmine Khaldi          { "\1CompObj", -1, 0, 0, NULL, 0 },
4670*5c1bcfecSAmine Khaldi          { "CONTENTS", -1, 0, 0, NULL, 0 }}
4671*5c1bcfecSAmine Khaldi     };
4672*5c1bcfecSAmine Khaldi     static struct storage_def stg_def_emf =
4673*5c1bcfecSAmine Khaldi     {
4674*5c1bcfecSAmine Khaldi         &CLSID_Picture_EnhMetafile, 3,
4675*5c1bcfecSAmine Khaldi         {{ "\1Ole", -1, 0, 0, NULL, 0 },
4676*5c1bcfecSAmine Khaldi          { "\1CompObj", -1, 0, 0, NULL, 0 },
4677*5c1bcfecSAmine Khaldi          { "CONTENTS", -1, 0, 0, NULL, 0 }}
4678*5c1bcfecSAmine Khaldi     };
4679*5c1bcfecSAmine Khaldi 
4680*5c1bcfecSAmine Khaldi 
4681*5c1bcfecSAmine Khaldi     hr = CreateILockBytesOnHGlobal(NULL, TRUE, &ilb);
4682*5c1bcfecSAmine Khaldi     ok(hr == S_OK, "CreateILockBytesOnHGlobal failed: 0x%08x.\n", hr);
4683*5c1bcfecSAmine Khaldi     hr = StgCreateDocfileOnILockBytes(ilb, STGM_SHARE_EXCLUSIVE | STGM_CREATE | STGM_READWRITE,
4684*5c1bcfecSAmine Khaldi                                       0, &storage);
4685*5c1bcfecSAmine Khaldi     ok(hr == S_OK, "StgCreateDocfileOnILockBytes failed: 0x%08x.\n", hr);
4686*5c1bcfecSAmine Khaldi     ILockBytes_Release(ilb);
4687*5c1bcfecSAmine Khaldi 
4688*5c1bcfecSAmine Khaldi     hr = OleCreateStaticFromData(&DataObject, &IID_IOleObject, OLERENDER_FORMAT,
4689*5c1bcfecSAmine Khaldi                                  dib_fmt, NULL, NULL, (void **)&ole_obj);
4690*5c1bcfecSAmine Khaldi     ok(hr == E_INVALIDARG, "OleCreateStaticFromData should fail: 0x%08x.\n", hr);
4691*5c1bcfecSAmine Khaldi 
4692*5c1bcfecSAmine Khaldi     hr = OleCreateStaticFromData(&DataObject, &IID_IOleObject, OLERENDER_FORMAT,
4693*5c1bcfecSAmine Khaldi                                  dib_fmt, NULL, storage, NULL);
4694*5c1bcfecSAmine Khaldi     ok(hr == E_INVALIDARG, "OleCreateStaticFromData should fail: 0x%08x.\n", hr);
4695*5c1bcfecSAmine Khaldi 
4696*5c1bcfecSAmine Khaldi     /* CF_DIB */
4697*5c1bcfecSAmine Khaldi     g_dataobject_fmts = dib_fmt;
4698*5c1bcfecSAmine Khaldi     expected_method_list = methods_createstatic_from_dib;
4699*5c1bcfecSAmine Khaldi     hr = OleCreateStaticFromData(&DataObject, &IID_IOleObject, OLERENDER_FORMAT,
4700*5c1bcfecSAmine Khaldi                                  dib_fmt, NULL, storage, (void **)&ole_obj);
4701*5c1bcfecSAmine Khaldi     ok(hr == S_OK, "OleCreateStaticFromData failed: 0x%08x.\n", hr);
4702*5c1bcfecSAmine Khaldi     hr = IOleObject_QueryInterface(ole_obj, &IID_IPersist, (void **)&persist);
4703*5c1bcfecSAmine Khaldi     ok(hr == S_OK, "IOleObject_QueryInterface failed: 0x%08x.\n", hr);
4704*5c1bcfecSAmine Khaldi     hr = IPersist_GetClassID(persist, &clsid);
4705*5c1bcfecSAmine Khaldi     ok(hr == S_OK, "IPersist_GetClassID failed: 0x%08x.\n", hr);
4706*5c1bcfecSAmine Khaldi     ok(IsEqualCLSID(&clsid, &CLSID_Picture_Dib), "Got wrong clsid: %s, expected: %s.\n",
4707*5c1bcfecSAmine Khaldi        wine_dbgstr_guid(&clsid), wine_dbgstr_guid(&CLSID_Picture_Dib));
4708*5c1bcfecSAmine Khaldi     hr = IStorage_Stat(storage, &statstg, STATFLAG_NONAME);
4709*5c1bcfecSAmine Khaldi     ok_ole_success(hr, "IStorage_Stat");
4710*5c1bcfecSAmine Khaldi     ok(IsEqualCLSID(&CLSID_Picture_Dib, &statstg.clsid), "Wrong CLSID in storage.\n");
4711*5c1bcfecSAmine Khaldi     enumerated_streams = matched_streams = -1;
4712*5c1bcfecSAmine Khaldi     get_stgmedium(CF_DIB, &stgmed);
4713*5c1bcfecSAmine Khaldi     get_stgdef(&stg_def_dib, CF_DIB, &stgmed, 2);
4714*5c1bcfecSAmine Khaldi     check_storage_contents(storage, &stg_def_dib, &enumerated_streams, &matched_streams);
4715*5c1bcfecSAmine Khaldi     ok(enumerated_streams == matched_streams, "enumerated %d != matched %d\n",
4716*5c1bcfecSAmine Khaldi        enumerated_streams, matched_streams);
4717*5c1bcfecSAmine Khaldi     ok(enumerated_streams == stg_def_dib.stream_count, "created %d != def streams %d\n",
4718*5c1bcfecSAmine Khaldi        enumerated_streams, stg_def_dib.stream_count);
4719*5c1bcfecSAmine Khaldi     ReleaseStgMedium(&stgmed);
4720*5c1bcfecSAmine Khaldi     IPersist_Release(persist);
4721*5c1bcfecSAmine Khaldi     IStorage_Release(storage);
4722*5c1bcfecSAmine Khaldi     IOleObject_Release(ole_obj);
4723*5c1bcfecSAmine Khaldi 
4724*5c1bcfecSAmine Khaldi     /* CF_ENHMETAFILE */
4725*5c1bcfecSAmine Khaldi     hr = CreateILockBytesOnHGlobal(NULL, TRUE, &ilb);
4726*5c1bcfecSAmine Khaldi     ok(hr == S_OK, "CreateILockBytesOnHGlobal failed: 0x%08x.\n", hr);
4727*5c1bcfecSAmine Khaldi     hr = StgCreateDocfileOnILockBytes(ilb, STGM_SHARE_EXCLUSIVE | STGM_CREATE | STGM_READWRITE,
4728*5c1bcfecSAmine Khaldi                                       0, &storage);
4729*5c1bcfecSAmine Khaldi     ok(hr == S_OK, "StgCreateDocfileOnILockBytes failed: 0x%08x.\n", hr);
4730*5c1bcfecSAmine Khaldi     ILockBytes_Release(ilb);
4731*5c1bcfecSAmine Khaldi     g_dataobject_fmts = emf_fmt;
4732*5c1bcfecSAmine Khaldi     expected_method_list = methods_createstatic_from_emf;
4733*5c1bcfecSAmine Khaldi     hr = OleCreateStaticFromData(&DataObject, &IID_IOleObject, OLERENDER_FORMAT,
4734*5c1bcfecSAmine Khaldi                                  emf_fmt, NULL, storage, (void **)&ole_obj);
4735*5c1bcfecSAmine Khaldi     ok(hr == S_OK, "OleCreateStaticFromData failed: 0x%08x.\n", hr);
4736*5c1bcfecSAmine Khaldi     hr = IOleObject_QueryInterface(ole_obj, &IID_IPersist, (void **)&persist);
4737*5c1bcfecSAmine Khaldi     ok(hr == S_OK, "IOleObject_QueryInterface failed: 0x%08x.\n", hr);
4738*5c1bcfecSAmine Khaldi     hr = IPersist_GetClassID(persist, &clsid);
4739*5c1bcfecSAmine Khaldi     ok(hr == S_OK, "IPersist_GetClassID failed: 0x%08x.\n", hr);
4740*5c1bcfecSAmine Khaldi     ok(IsEqualCLSID(&clsid, &CLSID_Picture_EnhMetafile), "Got wrong clsid: %s, expected: %s.\n",
4741*5c1bcfecSAmine Khaldi        wine_dbgstr_guid(&clsid), wine_dbgstr_guid(&CLSID_Picture_EnhMetafile));
4742*5c1bcfecSAmine Khaldi     hr = IStorage_Stat(storage, &statstg, STATFLAG_NONAME);
4743*5c1bcfecSAmine Khaldi     ok_ole_success(hr, "IStorage_Stat");
4744*5c1bcfecSAmine Khaldi     ok(IsEqualCLSID(&CLSID_Picture_EnhMetafile, &statstg.clsid), "Wrong CLSID in storage.\n");
4745*5c1bcfecSAmine Khaldi     enumerated_streams = matched_streams = -1;
4746*5c1bcfecSAmine Khaldi     get_stgmedium(CF_ENHMETAFILE, &stgmed);
4747*5c1bcfecSAmine Khaldi     get_stgdef(&stg_def_emf, CF_ENHMETAFILE, &stgmed, 2);
4748*5c1bcfecSAmine Khaldi     check_storage_contents(storage, &stg_def_emf, &enumerated_streams, &matched_streams);
4749*5c1bcfecSAmine Khaldi     ok(enumerated_streams == matched_streams, "enumerated %d != matched %d\n",
4750*5c1bcfecSAmine Khaldi        enumerated_streams, matched_streams);
4751*5c1bcfecSAmine Khaldi     ok(enumerated_streams == stg_def_emf.stream_count, "created %d != def streams %d\n",
4752*5c1bcfecSAmine Khaldi        enumerated_streams, stg_def_emf.stream_count);
4753*5c1bcfecSAmine Khaldi     ReleaseStgMedium(&stgmed);
4754*5c1bcfecSAmine Khaldi     IPersist_Release(persist);
4755*5c1bcfecSAmine Khaldi     IStorage_Release(storage);
4756*5c1bcfecSAmine Khaldi     IOleObject_Release(ole_obj);
4757*5c1bcfecSAmine Khaldi 
4758*5c1bcfecSAmine Khaldi     /* CF_TEXT */
4759*5c1bcfecSAmine Khaldi     hr = CreateILockBytesOnHGlobal(NULL, TRUE, &ilb);
4760*5c1bcfecSAmine Khaldi     ok(hr == S_OK, "CreateILockBytesOnHGlobal failed: 0x%08x.\n", hr);
4761*5c1bcfecSAmine Khaldi     hr = StgCreateDocfileOnILockBytes(ilb, STGM_SHARE_EXCLUSIVE | STGM_CREATE | STGM_READWRITE,
4762*5c1bcfecSAmine Khaldi                                       0, &storage);
4763*5c1bcfecSAmine Khaldi     ok(hr == S_OK, "StgCreateDocfileOnILockBytes failed: 0x%08x.\n", hr);
4764*5c1bcfecSAmine Khaldi     ILockBytes_Release(ilb);
4765*5c1bcfecSAmine Khaldi     g_dataobject_fmts = text_fmt;
4766*5c1bcfecSAmine Khaldi     expected_method_list = methods_createstatic_from_text;
4767*5c1bcfecSAmine Khaldi     hr = OleCreateStaticFromData(&DataObject, &IID_IOleObject, OLERENDER_FORMAT,
4768*5c1bcfecSAmine Khaldi                                  text_fmt, NULL, storage, (void **)&ole_obj);
4769*5c1bcfecSAmine Khaldi     ok(hr == DV_E_CLIPFORMAT, "OleCreateStaticFromData should fail: 0x%08x.\n", hr);
4770*5c1bcfecSAmine Khaldi     IStorage_Release(storage);
4771*5c1bcfecSAmine Khaldi 
4772*5c1bcfecSAmine Khaldi     hr = CreateILockBytesOnHGlobal(NULL, TRUE, &ilb);
4773*5c1bcfecSAmine Khaldi     ok(hr == S_OK, "CreateILockBytesOnHGlobal failed: 0x%08x.\n", hr);
4774*5c1bcfecSAmine Khaldi     hr = StgCreateDocfileOnILockBytes(ilb, STGM_SHARE_EXCLUSIVE | STGM_CREATE | STGM_READWRITE,
4775*5c1bcfecSAmine Khaldi                                       0, &storage);
4776*5c1bcfecSAmine Khaldi     ok(hr == S_OK, "StgCreateDocfileOnILockBytes failed: 0x%08x.\n", hr);
4777*5c1bcfecSAmine Khaldi     ILockBytes_Release(ilb);
4778*5c1bcfecSAmine Khaldi     g_dataobject_fmts = dib_fmt;
4779*5c1bcfecSAmine Khaldi     expected_method_list = methods_create_from_dib;
4780*5c1bcfecSAmine Khaldi     hr = OleCreateFromData(&DataObject, &IID_IOleObject, OLERENDER_FORMAT, dib_fmt, NULL,
4781*5c1bcfecSAmine Khaldi                            storage, (void **)&ole_obj);
4782*5c1bcfecSAmine Khaldi     todo_wine ok(hr == DV_E_FORMATETC, "OleCreateFromData should failed: 0x%08x.\n", hr);
4783*5c1bcfecSAmine Khaldi     IStorage_Release(storage);
4784*5c1bcfecSAmine Khaldi }
4785*5c1bcfecSAmine Khaldi 
START_TEST(ole2)4786c2c66affSColin Finck START_TEST(ole2)
4787c2c66affSColin Finck {
4788c2c66affSColin Finck     DWORD dwRegister;
4789c2c66affSColin Finck     IStorage *pStorage;
4790c2c66affSColin Finck     STATSTG statstg;
4791c2c66affSColin Finck     HRESULT hr;
4792c2c66affSColin Finck 
4793c2c66affSColin Finck     cf_test_1 = RegisterClipboardFormatA("cf_winetest_1");
4794c2c66affSColin Finck     cf_test_2 = RegisterClipboardFormatA("cf_winetest_2");
4795c2c66affSColin Finck     cf_test_3 = RegisterClipboardFormatA("cf_winetest_3");
4796c2c66affSColin Finck 
4797c2c66affSColin Finck     CoInitialize(NULL);
4798c2c66affSColin Finck 
4799c2c66affSColin Finck     hr = CoRegisterClassObject(&CLSID_Equation3, (IUnknown *)&OleObjectCF, CLSCTX_INPROC_SERVER, REGCLS_MULTIPLEUSE, &dwRegister);
4800c2c66affSColin Finck     ok_ole_success(hr, "CoRegisterClassObject");
4801c2c66affSColin Finck 
4802c2c66affSColin Finck     hr = StgCreateDocfile(NULL, STGM_READWRITE | STGM_CREATE | STGM_SHARE_EXCLUSIVE | STGM_DELETEONRELEASE, 0, &pStorage);
4803c2c66affSColin Finck     ok_ole_success(hr, "StgCreateDocfile");
4804c2c66affSColin Finck 
4805c2c66affSColin Finck     test_OleCreate(pStorage);
4806c2c66affSColin Finck 
4807c2c66affSColin Finck     hr = IStorage_Stat(pStorage, &statstg, STATFLAG_NONAME);
4808c2c66affSColin Finck     ok_ole_success(hr, "IStorage_Stat");
4809c2c66affSColin Finck     ok(IsEqualCLSID(&CLSID_Equation3, &statstg.clsid), "Wrong CLSID in storage\n");
4810c2c66affSColin Finck 
4811c2c66affSColin Finck     test_OleLoad(pStorage);
4812c2c66affSColin Finck 
4813c2c66affSColin Finck     IStorage_Release(pStorage);
4814c2c66affSColin Finck 
4815c2c66affSColin Finck     hr = CoRevokeClassObject(dwRegister);
4816c2c66affSColin Finck     ok_ole_success(hr, "CoRevokeClassObject");
4817c2c66affSColin Finck 
4818b44b1afbSAmine Khaldi     Storage_SetClass_CLSID = &CLSID_WineTest;
4819b44b1afbSAmine Khaldi 
4820c2c66affSColin Finck     test_data_cache();
4821c2c66affSColin Finck     test_data_cache_dib_contents_stream( 0 );
4822c2c66affSColin Finck     test_data_cache_dib_contents_stream( 1 );
4823b44b1afbSAmine Khaldi     test_data_cache_cache();
4824c2c66affSColin Finck     test_data_cache_init();
4825c2c66affSColin Finck     test_data_cache_initnew();
4826b44b1afbSAmine Khaldi     test_data_cache_updatecache();
4827c2c66affSColin Finck     test_default_handler();
4828c2c66affSColin Finck     test_runnable();
4829c2c66affSColin Finck     test_OleRun();
4830c2c66affSColin Finck     test_OleLockRunning();
4831c2c66affSColin Finck     test_OleDraw();
4832c2c66affSColin Finck     test_OleDoAutoConvert();
4833b44b1afbSAmine Khaldi     test_data_cache_save();
4834b44b1afbSAmine Khaldi     test_data_cache_save_data();
4835b44b1afbSAmine Khaldi     test_data_cache_contents();
4836*5c1bcfecSAmine Khaldi     test_OleCreateStaticFromData();
4837c2c66affSColin Finck 
4838c2c66affSColin Finck     CoUninitialize();
4839c2c66affSColin Finck }
4840