2 * Object Linking and Embedding Tests
4 * Copyright 2005 Robert Shearman
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #define WIN32_LEAN_AND_MEAN
32 #include "wine/test.h"
36 DEFINE_GUID(CLSID_Picture_Metafile
,0x315,0,0,0xc0,0,0,0,0,0,0,0x46);
37 DEFINE_GUID(CLSID_Picture_Dib
,0x316,0,0,0xc0,0,0,0,0,0,0,0x46);
39 #define ok_ole_success(hr, func) ok(hr == S_OK, func " failed with error 0x%08x\n", hr)
41 #define DEFINE_EXPECT(func) \
42 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
44 #define SET_EXPECT(func) \
45 expect_ ## func = TRUE
47 #define CHECK_EXPECT2(func) \
49 ok(expect_ ##func, "unexpected call " #func "\n"); \
50 called_ ## func = TRUE; \
53 #define CHECK_EXPECT(func) \
55 CHECK_EXPECT2(func); \
56 expect_ ## func = FALSE; \
59 #define CHECK_CALLED(func) \
61 ok(called_ ## func, "expected " #func "\n"); \
62 expect_ ## func = called_ ## func = FALSE; \
65 DEFINE_EXPECT(Storage_Stat
);
66 DEFINE_EXPECT(Storage_OpenStream_CompObj
);
67 DEFINE_EXPECT(Storage_SetClass
);
68 DEFINE_EXPECT(Storage_CreateStream_CompObj
);
69 DEFINE_EXPECT(Storage_OpenStream_Ole
);
71 static IPersistStorage OleObjectPersistStg
;
72 static IOleCache
*cache
;
73 static IRunnableObject
*runnable
;
75 static const CLSID CLSID_WineTestOld
=
76 { /* 9474ba1a-258b-490b-bc13-516e9239acd0 */
80 {0xbc, 0x13, 0x51, 0x6e, 0x92, 0x39, 0xac, 0xd0}
83 static const CLSID CLSID_WineTest
=
84 { /* 9474ba1a-258b-490b-bc13-516e9239ace0 */
88 {0xbc, 0x13, 0x51, 0x6e, 0x92, 0x39, 0xac, 0xe0}
91 static const IID IID_WineTest
=
92 { /* 9474ba1a-258b-490b-bc13-516e9239ace1 */
96 {0xbc, 0x13, 0x51, 0x6e, 0x92, 0x39, 0xac, 0xe1}
99 #define TEST_OPTIONAL 0x1
100 #define TEST_TODO 0x2
102 struct expected_method
108 static const struct expected_method
*expected_method_list
;
109 static FORMATETC
*g_expected_fetc
= NULL
;
111 static BOOL g_showRunnable
= TRUE
;
112 static BOOL g_isRunning
= TRUE
;
113 static BOOL g_failGetMiscStatus
;
114 static HRESULT g_QIFailsWith
;
116 static UINT cf_test_1
, cf_test_2
, cf_test_3
;
118 #define CHECK_EXPECTED_METHOD(method_name) \
120 trace("%s\n", method_name); \
121 ok(expected_method_list->method != NULL, "Extra method %s called\n", method_name); \
122 if (!strcmp(expected_method_list->method, "WINE_EXTRA")) \
124 todo_wine ok(0, "Too many method calls.\n"); \
127 if (expected_method_list->method) \
129 while (expected_method_list->flags & TEST_OPTIONAL && \
130 strcmp(expected_method_list->method, method_name) != 0) \
131 expected_method_list++; \
132 if (expected_method_list->flags & TEST_TODO) \
134 ok(!strcmp(expected_method_list->method, method_name), \
135 "Expected %s to be called instead of %s\n", \
136 expected_method_list->method, method_name); \
138 ok(!strcmp(expected_method_list->method, method_name), \
139 "Expected %s to be called instead of %s\n", \
140 expected_method_list->method, method_name); \
141 expected_method_list++; \
145 #define CHECK_NO_EXTRA_METHODS() \
147 while (expected_method_list->flags & TEST_OPTIONAL) \
148 expected_method_list++; \
149 ok(!expected_method_list->method, "Method sequence starting from %s not called\n", expected_method_list->method); \
152 static HRESULT WINAPI
OleObject_QueryInterface(IOleObject
*iface
, REFIID riid
, void **ppv
)
154 CHECK_EXPECTED_METHOD("OleObject_QueryInterface");
158 if (IsEqualIID(riid
, &IID_IUnknown
) || IsEqualIID(riid
, &IID_IOleObject
))
160 else if (IsEqualIID(riid
, &IID_IPersistStorage
))
161 *ppv
= &OleObjectPersistStg
;
162 else if (IsEqualIID(riid
, &IID_IOleCache
))
164 else if (IsEqualIID(riid
, &IID_IRunnableObject
) && g_showRunnable
)
166 else if (IsEqualIID(riid
, &IID_WineTest
))
167 return g_QIFailsWith
;
170 IUnknown_AddRef((IUnknown
*)*ppv
);
174 trace("OleObject_QueryInterface: returning E_NOINTERFACE\n");
175 return E_NOINTERFACE
;
178 static ULONG WINAPI
OleObject_AddRef(IOleObject
*iface
)
180 CHECK_EXPECTED_METHOD("OleObject_AddRef");
184 static ULONG WINAPI
OleObject_Release(IOleObject
*iface
)
186 CHECK_EXPECTED_METHOD("OleObject_Release");
190 static HRESULT WINAPI OleObject_SetClientSite
193 IOleClientSite
*pClientSite
196 CHECK_EXPECTED_METHOD("OleObject_SetClientSite");
200 static HRESULT WINAPI OleObject_GetClientSite
203 IOleClientSite
**ppClientSite
206 CHECK_EXPECTED_METHOD("OleObject_GetClientSite");
210 static HRESULT WINAPI OleObject_SetHostNames
213 LPCOLESTR szContainerApp
,
214 LPCOLESTR szContainerObj
217 CHECK_EXPECTED_METHOD("OleObject_SetHostNames");
221 static HRESULT WINAPI OleObject_Close
227 CHECK_EXPECTED_METHOD("OleObject_Close");
231 static HRESULT WINAPI OleObject_SetMoniker
234 DWORD dwWhichMoniker
,
238 CHECK_EXPECTED_METHOD("OleObject_SetMoniker");
242 static HRESULT WINAPI OleObject_GetMoniker
246 DWORD dwWhichMoniker
,
250 CHECK_EXPECTED_METHOD("OleObject_GetMoniker");
254 static HRESULT WINAPI OleObject_InitFromData
257 IDataObject
*pDataObject
,
262 CHECK_EXPECTED_METHOD("OleObject_InitFromData");
266 static HRESULT WINAPI OleObject_GetClipboardData
270 IDataObject
**ppDataObject
273 CHECK_EXPECTED_METHOD("OleObject_GetClipboardData");
277 static HRESULT WINAPI OleObject_DoVerb
282 IOleClientSite
*pActiveSite
,
288 CHECK_EXPECTED_METHOD("OleObject_DoVerb");
292 static HRESULT WINAPI OleObject_EnumVerbs
295 IEnumOLEVERB
**ppEnumOleVerb
298 CHECK_EXPECTED_METHOD("OleObject_EnumVerbs");
302 static HRESULT WINAPI OleObject_Update
307 CHECK_EXPECTED_METHOD("OleObject_Update");
311 static HRESULT WINAPI OleObject_IsUpToDate
316 CHECK_EXPECTED_METHOD("OleObject_IsUpToDate");
320 static HRESULT WINAPI OleObject_GetUserClassID
326 CHECK_EXPECTED_METHOD("OleObject_GetUserClassID");
330 static HRESULT WINAPI OleObject_GetUserType
334 LPOLESTR
*pszUserType
337 CHECK_EXPECTED_METHOD("OleObject_GetUserType");
341 static HRESULT WINAPI OleObject_SetExtent
348 CHECK_EXPECTED_METHOD("OleObject_SetExtent");
352 static HRESULT WINAPI OleObject_GetExtent
359 CHECK_EXPECTED_METHOD("OleObject_GetExtent");
363 static HRESULT WINAPI OleObject_Advise
366 IAdviseSink
*pAdvSink
,
370 CHECK_EXPECTED_METHOD("OleObject_Advise");
374 static HRESULT WINAPI OleObject_Unadvise
380 CHECK_EXPECTED_METHOD("OleObject_Unadvise");
384 static HRESULT WINAPI OleObject_EnumAdvise
387 IEnumSTATDATA
**ppenumAdvise
390 CHECK_EXPECTED_METHOD("OleObject_EnumAdvise");
394 static HRESULT WINAPI OleObject_GetMiscStatus
401 CHECK_EXPECTED_METHOD("OleObject_GetMiscStatus");
402 if(!g_failGetMiscStatus
)
404 *pdwStatus
= OLEMISC_RECOMPOSEONRESIZE
;
414 static HRESULT WINAPI OleObject_SetColorScheme
420 CHECK_EXPECTED_METHOD("OleObject_SetColorScheme");
424 static const IOleObjectVtbl OleObjectVtbl
=
426 OleObject_QueryInterface
,
429 OleObject_SetClientSite
,
430 OleObject_GetClientSite
,
431 OleObject_SetHostNames
,
433 OleObject_SetMoniker
,
434 OleObject_GetMoniker
,
435 OleObject_InitFromData
,
436 OleObject_GetClipboardData
,
440 OleObject_IsUpToDate
,
441 OleObject_GetUserClassID
,
442 OleObject_GetUserType
,
447 OleObject_EnumAdvise
,
448 OleObject_GetMiscStatus
,
449 OleObject_SetColorScheme
452 static IOleObject OleObject
= { &OleObjectVtbl
};
454 static HRESULT WINAPI
OleObjectPersistStg_QueryInterface(IPersistStorage
*iface
, REFIID riid
, void **ppv
)
456 trace("OleObjectPersistStg_QueryInterface\n");
457 return IUnknown_QueryInterface((IUnknown
*)&OleObject
, riid
, ppv
);
460 static ULONG WINAPI
OleObjectPersistStg_AddRef(IPersistStorage
*iface
)
462 CHECK_EXPECTED_METHOD("OleObjectPersistStg_AddRef");
466 static ULONG WINAPI
OleObjectPersistStg_Release(IPersistStorage
*iface
)
468 CHECK_EXPECTED_METHOD("OleObjectPersistStg_Release");
472 static HRESULT WINAPI
OleObjectPersistStg_GetClassId(IPersistStorage
*iface
, CLSID
*clsid
)
474 CHECK_EXPECTED_METHOD("OleObjectPersistStg_GetClassId");
478 static HRESULT WINAPI OleObjectPersistStg_IsDirty
480 IPersistStorage
*iface
483 CHECK_EXPECTED_METHOD("OleObjectPersistStg_IsDirty");
487 static HRESULT WINAPI OleObjectPersistStg_InitNew
489 IPersistStorage
*iface
,
493 CHECK_EXPECTED_METHOD("OleObjectPersistStg_InitNew");
497 static HRESULT WINAPI OleObjectPersistStg_Load
499 IPersistStorage
*iface
,
503 CHECK_EXPECTED_METHOD("OleObjectPersistStg_Load");
507 static HRESULT WINAPI OleObjectPersistStg_Save
509 IPersistStorage
*iface
,
514 CHECK_EXPECTED_METHOD("OleObjectPersistStg_Save");
518 static HRESULT WINAPI OleObjectPersistStg_SaveCompleted
520 IPersistStorage
*iface
,
524 CHECK_EXPECTED_METHOD("OleObjectPersistStg_SaveCompleted");
528 static HRESULT WINAPI OleObjectPersistStg_HandsOffStorage
530 IPersistStorage
*iface
533 CHECK_EXPECTED_METHOD("OleObjectPersistStg_HandsOffStorage");
537 static const IPersistStorageVtbl OleObjectPersistStgVtbl
=
539 OleObjectPersistStg_QueryInterface
,
540 OleObjectPersistStg_AddRef
,
541 OleObjectPersistStg_Release
,
542 OleObjectPersistStg_GetClassId
,
543 OleObjectPersistStg_IsDirty
,
544 OleObjectPersistStg_InitNew
,
545 OleObjectPersistStg_Load
,
546 OleObjectPersistStg_Save
,
547 OleObjectPersistStg_SaveCompleted
,
548 OleObjectPersistStg_HandsOffStorage
551 static IPersistStorage OleObjectPersistStg
= { &OleObjectPersistStgVtbl
};
553 static HRESULT WINAPI
OleObjectCache_QueryInterface(IOleCache
*iface
, REFIID riid
, void **ppv
)
555 return IUnknown_QueryInterface((IUnknown
*)&OleObject
, riid
, ppv
);
558 static ULONG WINAPI
OleObjectCache_AddRef(IOleCache
*iface
)
560 CHECK_EXPECTED_METHOD("OleObjectCache_AddRef");
564 static ULONG WINAPI
OleObjectCache_Release(IOleCache
*iface
)
566 CHECK_EXPECTED_METHOD("OleObjectCache_Release");
570 static HRESULT WINAPI OleObjectCache_Cache
573 FORMATETC
*pformatetc
,
578 CHECK_EXPECTED_METHOD("OleObjectCache_Cache");
579 if (g_expected_fetc
) {
580 ok(pformatetc
!= NULL
, "pformatetc should not be NULL\n");
582 ok(pformatetc
->cfFormat
== g_expected_fetc
->cfFormat
,
583 "cfFormat: %x\n", pformatetc
->cfFormat
);
584 ok((pformatetc
->ptd
!= NULL
) == (g_expected_fetc
->ptd
!= NULL
),
585 "ptd: %p\n", pformatetc
->ptd
);
586 ok(pformatetc
->dwAspect
== g_expected_fetc
->dwAspect
,
587 "dwAspect: %x\n", pformatetc
->dwAspect
);
588 ok(pformatetc
->lindex
== g_expected_fetc
->lindex
,
589 "lindex: %x\n", pformatetc
->lindex
);
590 ok(pformatetc
->tymed
== g_expected_fetc
->tymed
,
591 "tymed: %x\n", pformatetc
->tymed
);
594 ok(pformatetc
== NULL
, "pformatetc should be NULL\n");
598 static HRESULT WINAPI OleObjectCache_Uncache
604 CHECK_EXPECTED_METHOD("OleObjectCache_Uncache");
608 static HRESULT WINAPI OleObjectCache_EnumCache
611 IEnumSTATDATA
**ppenumSTATDATA
614 CHECK_EXPECTED_METHOD("OleObjectCache_EnumCache");
619 static HRESULT WINAPI OleObjectCache_InitCache
622 IDataObject
*pDataObject
625 CHECK_EXPECTED_METHOD("OleObjectCache_InitCache");
630 static HRESULT WINAPI OleObjectCache_SetData
633 FORMATETC
*pformatetc
,
638 CHECK_EXPECTED_METHOD("OleObjectCache_SetData");
643 static const IOleCacheVtbl OleObjectCacheVtbl
=
645 OleObjectCache_QueryInterface
,
646 OleObjectCache_AddRef
,
647 OleObjectCache_Release
,
648 OleObjectCache_Cache
,
649 OleObjectCache_Uncache
,
650 OleObjectCache_EnumCache
,
651 OleObjectCache_InitCache
,
652 OleObjectCache_SetData
655 static IOleCache OleObjectCache
= { &OleObjectCacheVtbl
};
657 static HRESULT WINAPI
OleObjectCF_QueryInterface(IClassFactory
*iface
, REFIID riid
, void **ppv
)
659 if (IsEqualIID(riid
, &IID_IUnknown
) || IsEqualIID(riid
, &IID_IClassFactory
))
662 IClassFactory_AddRef(iface
);
666 return E_NOINTERFACE
;
669 static ULONG WINAPI
OleObjectCF_AddRef(IClassFactory
*iface
)
674 static ULONG WINAPI
OleObjectCF_Release(IClassFactory
*iface
)
679 static HRESULT WINAPI
OleObjectCF_CreateInstance(IClassFactory
*iface
, IUnknown
*punkOuter
, REFIID riid
, void **ppv
)
681 return IUnknown_QueryInterface((IUnknown
*)&OleObject
, riid
, ppv
);
684 static HRESULT WINAPI
OleObjectCF_LockServer(IClassFactory
*iface
, BOOL lock
)
689 static const IClassFactoryVtbl OleObjectCFVtbl
=
691 OleObjectCF_QueryInterface
,
694 OleObjectCF_CreateInstance
,
695 OleObjectCF_LockServer
698 static IClassFactory OleObjectCF
= { &OleObjectCFVtbl
};
700 static HRESULT WINAPI
OleObjectRunnable_QueryInterface(IRunnableObject
*iface
, REFIID riid
, void **ppv
)
702 return IUnknown_QueryInterface((IUnknown
*)&OleObject
, riid
, ppv
);
705 static ULONG WINAPI
OleObjectRunnable_AddRef(IRunnableObject
*iface
)
707 CHECK_EXPECTED_METHOD("OleObjectRunnable_AddRef");
711 static ULONG WINAPI
OleObjectRunnable_Release(IRunnableObject
*iface
)
713 CHECK_EXPECTED_METHOD("OleObjectRunnable_Release");
717 static HRESULT WINAPI
OleObjectRunnable_GetRunningClass(
718 IRunnableObject
*iface
,
721 CHECK_EXPECTED_METHOD("OleObjectRunnable_GetRunningClass");
725 static HRESULT WINAPI
OleObjectRunnable_Run(
726 IRunnableObject
*iface
,
729 CHECK_EXPECTED_METHOD("OleObjectRunnable_Run");
733 static BOOL WINAPI
OleObjectRunnable_IsRunning(IRunnableObject
*iface
)
735 CHECK_EXPECTED_METHOD("OleObjectRunnable_IsRunning");
739 static HRESULT WINAPI
OleObjectRunnable_LockRunning(
740 IRunnableObject
*iface
,
742 BOOL fLastUnlockCloses
)
744 CHECK_EXPECTED_METHOD("OleObjectRunnable_LockRunning");
748 static HRESULT WINAPI
OleObjectRunnable_SetContainedObject(
749 IRunnableObject
*iface
,
752 CHECK_EXPECTED_METHOD("OleObjectRunnable_SetContainedObject");
756 static const IRunnableObjectVtbl OleObjectRunnableVtbl
=
758 OleObjectRunnable_QueryInterface
,
759 OleObjectRunnable_AddRef
,
760 OleObjectRunnable_Release
,
761 OleObjectRunnable_GetRunningClass
,
762 OleObjectRunnable_Run
,
763 OleObjectRunnable_IsRunning
,
764 OleObjectRunnable_LockRunning
,
765 OleObjectRunnable_SetContainedObject
768 static IRunnableObject OleObjectRunnable
= { &OleObjectRunnableVtbl
};
770 static const CLSID CLSID_Equation3
= {0x0002CE02, 0x0000, 0x0000, {0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46} };
772 static HRESULT WINAPI
viewobject_QueryInterface(IViewObject
*iface
, REFIID riid
, void **obj
)
774 if (IsEqualGUID(riid
, &IID_IUnknown
) || IsEqualGUID(riid
, &IID_IViewObject
))
781 return E_NOINTERFACE
;
784 static ULONG WINAPI
viewobject_AddRef(IViewObject
*iface
)
789 static ULONG WINAPI
viewobject_Release(IViewObject
*iface
)
794 static HRESULT WINAPI
viewobject_Draw(IViewObject
*iface
, DWORD aspect
, LONG index
,
795 void *paspect
, DVTARGETDEVICE
*ptd
, HDC hdcTargetDev
, HDC hdcDraw
,
796 LPCRECTL bounds
, LPCRECTL wbounds
, BOOL (STDMETHODCALLTYPE
*pfnContinue
)(ULONG_PTR dwContinue
),
797 ULONG_PTR dwContinue
)
799 ok(index
== -1, "index=%d\n", index
);
803 static HRESULT WINAPI
viewobject_GetColorSet(IViewObject
*iface
, DWORD draw_aspect
, LONG index
,
804 void *aspect
, DVTARGETDEVICE
*ptd
, HDC hicTargetDev
, LOGPALETTE
**colorset
)
806 ok(0, "unexpected call GetColorSet\n");
810 static HRESULT WINAPI
viewobject_Freeze(IViewObject
*iface
, DWORD draw_aspect
, LONG index
,
811 void *aspect
, DWORD
*freeze
)
813 ok(0, "unexpected call Freeze\n");
817 static HRESULT WINAPI
viewobject_Unfreeze(IViewObject
*iface
, DWORD freeze
)
819 ok(0, "unexpected call Unfreeze\n");
823 static HRESULT WINAPI
viewobject_SetAdvise(IViewObject
*iface
, DWORD aspects
, DWORD advf
, IAdviseSink
*sink
)
825 ok(0, "unexpected call SetAdvise\n");
829 static HRESULT WINAPI
viewobject_GetAdvise(IViewObject
*iface
, DWORD
*aspects
, DWORD
*advf
,
832 ok(0, "unexpected call GetAdvise\n");
836 static const struct IViewObjectVtbl viewobjectvtbl
= {
837 viewobject_QueryInterface
,
841 viewobject_GetColorSet
,
844 viewobject_SetAdvise
,
848 static IViewObject viewobject
= { &viewobjectvtbl
};
850 static void test_OleCreate(IStorage
*pStorage
)
855 static const struct expected_method methods_olerender_none
[] =
857 { "OleObject_QueryInterface", 0 },
858 { "OleObject_AddRef", 0 },
859 { "OleObject_QueryInterface", 0 },
860 { "OleObject_AddRef", TEST_OPTIONAL
},
861 { "OleObject_Release", TEST_OPTIONAL
},
862 { "OleObject_QueryInterface", TEST_OPTIONAL
},
863 { "OleObjectPersistStg_AddRef", 0 },
864 { "OleObjectPersistStg_InitNew", 0 },
865 { "OleObjectPersistStg_Release", 0 },
866 { "OleObject_Release", 0 },
867 { "OleObject_Release", TEST_OPTIONAL
},
870 static const struct expected_method methods_olerender_draw
[] =
872 { "OleObject_QueryInterface", 0 },
873 { "OleObject_AddRef", 0 },
874 { "OleObject_QueryInterface", 0 },
875 { "OleObject_AddRef", TEST_OPTIONAL
/* NT4 only */ },
876 { "OleObject_Release", TEST_OPTIONAL
/* NT4 only */ },
877 { "OleObject_QueryInterface", TEST_OPTIONAL
/* NT4 only */ },
878 { "OleObjectPersistStg_AddRef", 0 },
879 { "OleObjectPersistStg_InitNew", 0 },
880 { "OleObjectPersistStg_Release", 0 },
881 { "OleObject_QueryInterface", 0 },
882 { "OleObjectRunnable_AddRef", 0 },
883 { "OleObjectRunnable_Run", 0 },
884 { "OleObjectRunnable_Release", 0 },
885 { "OleObject_QueryInterface", 0 },
886 { "OleObjectCache_AddRef", 0 },
887 { "OleObjectCache_Cache", 0 },
888 { "OleObjectCache_Release", 0 },
889 { "OleObject_Release", 0 },
890 { "OleObject_Release", TEST_OPTIONAL
/* NT4 only */ },
893 static const struct expected_method methods_olerender_format
[] =
895 { "OleObject_QueryInterface", 0 },
896 { "OleObject_AddRef", 0 },
897 { "OleObject_QueryInterface", 0 },
898 { "OleObject_AddRef", 0 },
899 { "OleObject_GetMiscStatus", 0 },
900 { "OleObject_QueryInterface", 0 },
901 { "OleObjectPersistStg_AddRef", 0 },
902 { "OleObjectPersistStg_InitNew", 0 },
903 { "OleObjectPersistStg_Release", 0 },
904 { "OleObject_SetClientSite", 0 },
905 { "OleObject_Release", 0 },
906 { "OleObject_QueryInterface", 0 },
907 { "OleObjectRunnable_AddRef", 0 },
908 { "OleObjectRunnable_Run", 0 },
909 { "OleObjectRunnable_Release", 0 },
910 { "OleObject_QueryInterface", 0 },
911 { "OleObjectCache_AddRef", 0 },
912 { "OleObjectCache_Cache", 0 },
913 { "OleObjectCache_Release", 0 },
914 { "OleObject_Release", 0 },
917 static const struct expected_method methods_olerender_asis
[] =
919 { "OleObject_QueryInterface", 0 },
920 { "OleObject_AddRef", 0 },
921 { "OleObject_QueryInterface", 0 },
922 { "OleObject_AddRef", TEST_OPTIONAL
/* NT4 only */ },
923 { "OleObject_Release", TEST_OPTIONAL
/* NT4 only */ },
924 { "OleObject_QueryInterface", TEST_OPTIONAL
/* NT4 only */ },
925 { "OleObjectPersistStg_AddRef", 0 },
926 { "OleObjectPersistStg_InitNew", 0 },
927 { "OleObjectPersistStg_Release", 0 },
928 { "OleObject_Release", 0 },
929 { "OleObject_Release", TEST_OPTIONAL
/* NT4 only */ },
932 static const struct expected_method methods_olerender_draw_no_runnable
[] =
934 { "OleObject_QueryInterface", 0 },
935 { "OleObject_AddRef", 0 },
936 { "OleObject_QueryInterface", 0 },
937 { "OleObject_AddRef", TEST_OPTIONAL
/* NT4 only */ },
938 { "OleObject_Release", TEST_OPTIONAL
/* NT4 only */ },
939 { "OleObject_QueryInterface", TEST_OPTIONAL
/* NT4 only */ },
940 { "OleObjectPersistStg_AddRef", 0 },
941 { "OleObjectPersistStg_InitNew", 0 },
942 { "OleObjectPersistStg_Release", 0 },
943 { "OleObject_QueryInterface", 0 },
944 { "OleObject_QueryInterface", 0 },
945 { "OleObjectCache_AddRef", 0 },
946 { "OleObjectCache_Cache", 0 },
947 { "OleObjectCache_Release", 0 },
948 { "OleObject_Release", 0 },
949 { "OleObject_Release", TEST_OPTIONAL
/* NT4 only */ },
952 static const struct expected_method methods_olerender_draw_no_cache
[] =
954 { "OleObject_QueryInterface", 0 },
955 { "OleObject_AddRef", 0 },
956 { "OleObject_QueryInterface", 0 },
957 { "OleObject_AddRef", TEST_OPTIONAL
/* NT4 only */ },
958 { "OleObject_Release", TEST_OPTIONAL
/* NT4 only */ },
959 { "OleObject_QueryInterface", TEST_OPTIONAL
/* NT4 only */ },
960 { "OleObjectPersistStg_AddRef", 0 },
961 { "OleObjectPersistStg_InitNew", 0 },
962 { "OleObjectPersistStg_Release", 0 },
963 { "OleObject_QueryInterface", 0 },
964 { "OleObjectRunnable_AddRef", 0 },
965 { "OleObjectRunnable_Run", 0 },
966 { "OleObjectRunnable_Release", 0 },
967 { "OleObject_QueryInterface", 0 },
968 { "OleObject_Release", 0 },
969 { "OleObject_Release", TEST_OPTIONAL
/* NT4 only */ },
973 g_expected_fetc
= &formatetc
;
974 formatetc
.cfFormat
= 0;
975 formatetc
.ptd
= NULL
;
976 formatetc
.dwAspect
= DVASPECT_CONTENT
;
977 formatetc
.lindex
= -1;
978 formatetc
.tymed
= TYMED_NULL
;
979 runnable
= &OleObjectRunnable
;
980 cache
= &OleObjectCache
;
981 expected_method_list
= methods_olerender_none
;
982 trace("OleCreate with OLERENDER_NONE:\n");
983 hr
= OleCreate(&CLSID_Equation3
, &IID_IOleObject
, OLERENDER_NONE
, NULL
, NULL
, pStorage
, (void **)&pObject
);
984 ok_ole_success(hr
, "OleCreate");
985 IOleObject_Release(pObject
);
986 CHECK_NO_EXTRA_METHODS();
988 expected_method_list
= methods_olerender_draw
;
989 trace("OleCreate with OLERENDER_DRAW:\n");
990 hr
= OleCreate(&CLSID_Equation3
, &IID_IOleObject
, OLERENDER_DRAW
, NULL
, NULL
, pStorage
, (void **)&pObject
);
991 ok_ole_success(hr
, "OleCreate");
992 IOleObject_Release(pObject
);
993 CHECK_NO_EXTRA_METHODS();
995 formatetc
.cfFormat
= CF_TEXT
;
996 formatetc
.ptd
= NULL
;
997 formatetc
.dwAspect
= DVASPECT_CONTENT
;
998 formatetc
.lindex
= -1;
999 formatetc
.tymed
= TYMED_HGLOBAL
;
1000 expected_method_list
= methods_olerender_format
;
1001 trace("OleCreate with OLERENDER_FORMAT:\n");
1002 hr
= OleCreate(&CLSID_Equation3
, &IID_IOleObject
, OLERENDER_FORMAT
, &formatetc
, (IOleClientSite
*)0xdeadbeef, pStorage
, (void **)&pObject
);
1004 broken(hr
== E_INVALIDARG
), /* win2k */
1005 "OleCreate failed with error 0x%08x\n", hr
);
1008 IOleObject_Release(pObject
);
1009 CHECK_NO_EXTRA_METHODS();
1012 expected_method_list
= methods_olerender_asis
;
1013 trace("OleCreate with OLERENDER_ASIS:\n");
1014 hr
= OleCreate(&CLSID_Equation3
, &IID_IOleObject
, OLERENDER_ASIS
, NULL
, NULL
, pStorage
, (void **)&pObject
);
1015 ok_ole_success(hr
, "OleCreate");
1016 IOleObject_Release(pObject
);
1017 CHECK_NO_EXTRA_METHODS();
1019 formatetc
.cfFormat
= 0;
1020 formatetc
.tymed
= TYMED_NULL
;
1022 expected_method_list
= methods_olerender_draw_no_runnable
;
1023 trace("OleCreate with OLERENDER_DRAW (no IRunnableObject):\n");
1024 hr
= OleCreate(&CLSID_Equation3
, &IID_IOleObject
, OLERENDER_DRAW
, NULL
, NULL
, pStorage
, (void **)&pObject
);
1025 ok_ole_success(hr
, "OleCreate");
1026 IOleObject_Release(pObject
);
1027 CHECK_NO_EXTRA_METHODS();
1029 runnable
= &OleObjectRunnable
;
1031 expected_method_list
= methods_olerender_draw_no_cache
;
1032 trace("OleCreate with OLERENDER_DRAW (no IOleCache):\n");
1033 hr
= OleCreate(&CLSID_Equation3
, &IID_IOleObject
, OLERENDER_DRAW
, NULL
, NULL
, pStorage
, (void **)&pObject
);
1034 ok_ole_success(hr
, "OleCreate");
1035 IOleObject_Release(pObject
);
1036 CHECK_NO_EXTRA_METHODS();
1038 g_expected_fetc
= NULL
;
1041 static void test_OleLoad(IStorage
*pStorage
)
1044 IOleObject
*pObject
;
1046 static const struct expected_method methods_oleload
[] =
1048 { "OleObject_QueryInterface", 0 },
1049 { "OleObject_AddRef", 0 },
1050 { "OleObject_QueryInterface", 0 },
1051 { "OleObject_AddRef", 0 },
1052 { "OleObject_GetMiscStatus", 0 },
1053 { "OleObject_QueryInterface", 0 },
1054 { "OleObjectPersistStg_AddRef", 0 },
1055 { "OleObjectPersistStg_Load", 0 },
1056 { "OleObjectPersistStg_Release", 0 },
1057 { "OleObject_SetClientSite", 0 },
1058 { "OleObject_Release", 0 },
1059 { "OleObject_QueryInterface", 0 },
1060 { "OleObject_GetMiscStatus", 0 },
1061 { "OleObject_Release", 0 },
1065 /* Test once with IOleObject_GetMiscStatus failing */
1066 expected_method_list
= methods_oleload
;
1067 g_failGetMiscStatus
= TRUE
;
1068 trace("OleLoad:\n");
1069 hr
= OleLoad(pStorage
, &IID_IOleObject
, (IOleClientSite
*)0xdeadbeef, (void **)&pObject
);
1071 broken(hr
== E_INVALIDARG
), /* win98 and win2k */
1072 "OleLoad failed with error 0x%08x\n", hr
);
1075 DWORD dwStatus
= 0xdeadbeef;
1076 hr
= IOleObject_GetMiscStatus(pObject
, DVASPECT_CONTENT
, &dwStatus
);
1077 ok(hr
== E_FAIL
, "Got 0x%08x\n", hr
);
1078 ok(dwStatus
== 0x1234, "Got 0x%08x\n", dwStatus
);
1080 IOleObject_Release(pObject
);
1081 CHECK_NO_EXTRA_METHODS();
1084 /* Test again, let IOleObject_GetMiscStatus succeed. */
1085 g_failGetMiscStatus
= FALSE
;
1086 expected_method_list
= methods_oleload
;
1087 trace("OleLoad:\n");
1088 hr
= OleLoad(pStorage
, &IID_IOleObject
, (IOleClientSite
*)0xdeadbeef, (void **)&pObject
);
1090 broken(hr
== E_INVALIDARG
), /* win98 and win2k */
1091 "OleLoad failed with error 0x%08x\n", hr
);
1094 DWORD dwStatus
= 0xdeadbeef;
1095 hr
= IOleObject_GetMiscStatus(pObject
, DVASPECT_CONTENT
, &dwStatus
);
1096 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
1097 ok(dwStatus
== 1, "Got 0x%08x\n", dwStatus
);
1099 IOleObject_Release(pObject
);
1100 CHECK_NO_EXTRA_METHODS();
1104 static BOOL STDMETHODCALLTYPE
draw_continue(ULONG_PTR param
)
1106 CHECK_EXPECTED_METHOD("draw_continue");
1110 static BOOL STDMETHODCALLTYPE
draw_continue_false(ULONG_PTR param
)
1112 CHECK_EXPECTED_METHOD("draw_continue_false");
1116 static HRESULT WINAPI
AdviseSink_QueryInterface(IAdviseSink
*iface
, REFIID riid
, void **ppv
)
1118 if (IsEqualIID(riid
, &IID_IAdviseSink
) || IsEqualIID(riid
, &IID_IUnknown
))
1121 IAdviseSink_AddRef(iface
);
1125 return E_NOINTERFACE
;
1128 static ULONG WINAPI
AdviseSink_AddRef(IAdviseSink
*iface
)
1133 static ULONG WINAPI
AdviseSink_Release(IAdviseSink
*iface
)
1139 static void WINAPI
AdviseSink_OnDataChange(
1141 FORMATETC
*pFormatetc
,
1144 CHECK_EXPECTED_METHOD("AdviseSink_OnDataChange");
1147 static void WINAPI
AdviseSink_OnViewChange(
1152 CHECK_EXPECTED_METHOD("AdviseSink_OnViewChange");
1155 static void WINAPI
AdviseSink_OnRename(
1159 CHECK_EXPECTED_METHOD("AdviseSink_OnRename");
1162 static void WINAPI
AdviseSink_OnSave(IAdviseSink
*iface
)
1164 CHECK_EXPECTED_METHOD("AdviseSink_OnSave");
1167 static void WINAPI
AdviseSink_OnClose(IAdviseSink
*iface
)
1169 CHECK_EXPECTED_METHOD("AdviseSink_OnClose");
1172 static const IAdviseSinkVtbl AdviseSinkVtbl
=
1174 AdviseSink_QueryInterface
,
1177 AdviseSink_OnDataChange
,
1178 AdviseSink_OnViewChange
,
1179 AdviseSink_OnRename
,
1184 static IAdviseSink AdviseSink
= { &AdviseSinkVtbl
};
1186 static HRESULT WINAPI
DataObject_QueryInterface(
1191 CHECK_EXPECTED_METHOD("DataObject_QueryInterface");
1193 if (IsEqualIID(riid
, &IID_IDataObject
) || IsEqualIID(riid
, &IID_IUnknown
))
1202 static ULONG WINAPI
DataObject_AddRef(
1205 CHECK_EXPECTED_METHOD("DataObject_AddRef");
1209 static ULONG WINAPI
DataObject_Release(
1212 CHECK_EXPECTED_METHOD("DataObject_Release");
1216 static HRESULT WINAPI
DataObject_GetData(
1218 LPFORMATETC pformatetcIn
,
1221 CHECK_EXPECTED_METHOD("DataObject_GetData");
1225 static HRESULT WINAPI
DataObject_GetDataHere(
1227 LPFORMATETC pformatetc
,
1230 CHECK_EXPECTED_METHOD("DataObject_GetDataHere");
1234 static HRESULT WINAPI
DataObject_QueryGetData(
1236 LPFORMATETC pformatetc
)
1238 CHECK_EXPECTED_METHOD("DataObject_QueryGetData");
1242 static HRESULT WINAPI
DataObject_GetCanonicalFormatEtc(
1244 LPFORMATETC pformatectIn
,
1245 LPFORMATETC pformatetcOut
)
1247 CHECK_EXPECTED_METHOD("DataObject_GetCanonicalFormatEtc");
1251 static HRESULT WINAPI
DataObject_SetData(
1253 LPFORMATETC pformatetc
,
1257 CHECK_EXPECTED_METHOD("DataObject_SetData");
1261 static HRESULT WINAPI
DataObject_EnumFormatEtc(
1264 IEnumFORMATETC
** ppenumFormatEtc
)
1266 CHECK_EXPECTED_METHOD("DataObject_EnumFormatEtc");
1270 static HRESULT WINAPI
DataObject_DAdvise(
1272 FORMATETC
* pformatetc
,
1274 IAdviseSink
* pAdvSink
,
1275 DWORD
* pdwConnection
)
1277 STGMEDIUM stgmedium
;
1279 CHECK_EXPECTED_METHOD("DataObject_DAdvise");
1282 if(advf
& ADVF_PRIMEFIRST
)
1284 ok(pformatetc
->cfFormat
== cf_test_2
, "got %04x\n", pformatetc
->cfFormat
);
1285 stgmedium
.tymed
= TYMED_HGLOBAL
;
1286 U(stgmedium
).hGlobal
= GlobalAlloc(GMEM_MOVEABLE
| GMEM_ZEROINIT
, 4);
1287 stgmedium
.pUnkForRelease
= NULL
;
1288 IAdviseSink_OnDataChange(pAdvSink
, pformatetc
, &stgmedium
);
1294 static HRESULT WINAPI
DataObject_DUnadvise(
1298 CHECK_EXPECTED_METHOD("DataObject_DUnadvise");
1302 static HRESULT WINAPI
DataObject_EnumDAdvise(
1304 IEnumSTATDATA
** ppenumAdvise
)
1306 CHECK_EXPECTED_METHOD("DataObject_EnumDAdvise");
1307 return OLE_E_ADVISENOTSUPPORTED
;
1310 static IDataObjectVtbl DataObjectVtbl
=
1312 DataObject_QueryInterface
,
1316 DataObject_GetDataHere
,
1317 DataObject_QueryGetData
,
1318 DataObject_GetCanonicalFormatEtc
,
1320 DataObject_EnumFormatEtc
,
1322 DataObject_DUnadvise
,
1323 DataObject_EnumDAdvise
1326 static IDataObject DataObject
= { &DataObjectVtbl
};
1328 static void test_data_cache(void)
1331 IOleCache2
*pOleCache
;
1333 IPersistStorage
*pPS
;
1334 IViewObject
*pViewObject
;
1335 IOleCacheControl
*pOleCacheControl
;
1336 IDataObject
*pCacheDataObject
;
1338 STGMEDIUM stgmedium
;
1344 char szSystemDir
[MAX_PATH
];
1345 WCHAR wszPath
[MAX_PATH
];
1346 static const WCHAR wszShell32
[] = {'\\','s','h','e','l','l','3','2','.','d','l','l',0};
1348 static const struct expected_method methods_cacheinitnew
[] =
1350 { "AdviseSink_OnViewChange", 0 },
1351 { "AdviseSink_OnViewChange", 0 },
1352 { "draw_continue", 1 },
1353 { "draw_continue_false", 1 },
1354 { "DataObject_DAdvise", 0 },
1355 { "DataObject_DAdvise", 0 },
1356 { "DataObject_DUnadvise", 0 },
1357 { "DataObject_DUnadvise", 0 },
1360 static const struct expected_method methods_cacheload
[] =
1362 { "AdviseSink_OnViewChange", 0 },
1363 { "draw_continue", 1 },
1364 { "draw_continue", 1 },
1365 { "draw_continue", 1 },
1366 { "DataObject_GetData", 0 },
1367 { "DataObject_GetData", 0 },
1368 { "DataObject_GetData", 0 },
1371 static const struct expected_method methods_cachethenrun
[] =
1373 { "DataObject_DAdvise", 0 },
1374 { "DataObject_DAdvise", 0 },
1375 { "DataObject_DAdvise", 0 },
1376 { "DataObject_QueryGetData", 1 }, /* called by win9x and nt4 */
1377 { "DataObject_DAdvise", 0 },
1378 { "DataObject_DUnadvise", 0 },
1379 { "DataObject_DUnadvise", 0 },
1380 { "DataObject_DUnadvise", 0 },
1381 { "DataObject_DUnadvise", 0 },
1385 GetSystemDirectoryA(szSystemDir
, sizeof(szSystemDir
)/sizeof(szSystemDir
[0]));
1387 expected_method_list
= methods_cacheinitnew
;
1389 fmtetc
.cfFormat
= CF_METAFILEPICT
;
1390 fmtetc
.dwAspect
= DVASPECT_ICON
;
1393 fmtetc
.tymed
= TYMED_MFPICT
;
1395 hr
= StgCreateDocfile(NULL
, STGM_READWRITE
| STGM_CREATE
| STGM_SHARE_EXCLUSIVE
| STGM_DELETEONRELEASE
, 0, &pStorage
);
1396 ok_ole_success(hr
, "StgCreateDocfile");
1398 /* Test with new data */
1400 hr
= CreateDataCache(NULL
, &CLSID_NULL
, &IID_IOleCache2
, (LPVOID
*)&pOleCache
);
1401 ok_ole_success(hr
, "CreateDataCache");
1403 hr
= IOleCache2_QueryInterface(pOleCache
, &IID_IPersistStorage
, (LPVOID
*)&pPS
);
1404 ok_ole_success(hr
, "IOleCache_QueryInterface(IID_IPersistStorage)");
1405 hr
= IOleCache2_QueryInterface(pOleCache
, &IID_IViewObject
, (LPVOID
*)&pViewObject
);
1406 ok_ole_success(hr
, "IOleCache_QueryInterface(IID_IViewObject)");
1407 hr
= IOleCache2_QueryInterface(pOleCache
, &IID_IOleCacheControl
, (LPVOID
*)&pOleCacheControl
);
1408 ok_ole_success(hr
, "IOleCache_QueryInterface(IID_IOleCacheControl)");
1410 hr
= IViewObject_SetAdvise(pViewObject
, DVASPECT_ICON
, ADVF_PRIMEFIRST
, &AdviseSink
);
1411 ok_ole_success(hr
, "IViewObject_SetAdvise");
1413 hr
= IPersistStorage_InitNew(pPS
, pStorage
);
1414 ok_ole_success(hr
, "IPersistStorage_InitNew");
1416 hr
= IPersistStorage_IsDirty(pPS
);
1417 ok_ole_success(hr
, "IPersistStorage_IsDirty");
1419 hr
= IPersistStorage_GetClassID(pPS
, &clsid
);
1420 ok_ole_success(hr
, "IPersistStorage_GetClassID");
1421 ok(IsEqualCLSID(&clsid
, &IID_NULL
), "clsid should be blank\n");
1423 hr
= IOleCache2_Uncache(pOleCache
, 0xdeadbeef);
1424 ok(hr
== OLE_E_NOCONNECTION
, "IOleCache_Uncache with invalid value should return OLE_E_NOCONNECTION instead of 0x%x\n", hr
);
1426 /* Both tests crash on NT4 and below. StgCreatePropSetStg is only available on w2k and above. */
1427 if (GetProcAddress(GetModuleHandleA("ole32.dll"), "StgCreatePropSetStg"))
1429 hr
= IOleCache2_Cache(pOleCache
, NULL
, 0, &dwConnection
);
1430 ok(hr
== E_INVALIDARG
, "IOleCache_Cache with NULL fmtetc should have returned E_INVALIDARG instead of 0x%08x\n", hr
);
1432 hr
= IOleCache2_Cache(pOleCache
, NULL
, 0, NULL
);
1433 ok(hr
== E_INVALIDARG
, "IOleCache_Cache with NULL pdwConnection should have returned E_INVALIDARG instead of 0x%08x\n", hr
);
1437 skip("tests with NULL parameters will crash on NT4 and below\n");
1440 for (fmtetc
.cfFormat
= CF_TEXT
; fmtetc
.cfFormat
< CF_MAX
; fmtetc
.cfFormat
++)
1443 fmtetc
.dwAspect
= DVASPECT_THUMBNAIL
;
1444 for (i
= 0; i
< 7; i
++)
1446 fmtetc
.tymed
= 1 << i
;
1447 hr
= IOleCache2_Cache(pOleCache
, &fmtetc
, 0, &dwConnection
);
1448 if ((fmtetc
.cfFormat
== CF_METAFILEPICT
&& fmtetc
.tymed
== TYMED_MFPICT
) ||
1449 (fmtetc
.cfFormat
== CF_BITMAP
&& fmtetc
.tymed
== TYMED_GDI
) ||
1450 (fmtetc
.cfFormat
== CF_DIB
&& fmtetc
.tymed
== TYMED_HGLOBAL
) ||
1451 (fmtetc
.cfFormat
== CF_ENHMETAFILE
&& fmtetc
.tymed
== TYMED_ENHMF
))
1452 ok(hr
== S_OK
, "IOleCache_Cache cfFormat = %d, tymed = %d should have returned S_OK instead of 0x%08x\n",
1453 fmtetc
.cfFormat
, fmtetc
.tymed
, hr
);
1454 else if (fmtetc
.tymed
== TYMED_HGLOBAL
)
1455 ok(hr
== CACHE_S_FORMATETC_NOTSUPPORTED
||
1456 broken(hr
== S_OK
&& fmtetc
.cfFormat
== CF_BITMAP
) /* Win9x & NT4 */,
1457 "IOleCache_Cache cfFormat = %d, tymed = %d should have returned CACHE_S_FORMATETC_NOTSUPPORTED instead of 0x%08x\n",
1458 fmtetc
.cfFormat
, fmtetc
.tymed
, hr
);
1460 ok(hr
== DV_E_TYMED
, "IOleCache_Cache cfFormat = %d, tymed = %d should have returned DV_E_TYMED instead of 0x%08x\n",
1461 fmtetc
.cfFormat
, fmtetc
.tymed
, hr
);
1464 hr
= IOleCache2_Uncache(pOleCache
, dwConnection
);
1465 ok_ole_success(hr
, "IOleCache_Uncache");
1470 fmtetc
.cfFormat
= CF_BITMAP
;
1471 fmtetc
.dwAspect
= DVASPECT_THUMBNAIL
;
1472 fmtetc
.tymed
= TYMED_GDI
;
1473 hr
= IOleCache2_Cache(pOleCache
, &fmtetc
, 0, &dwConnection
);
1474 ok_ole_success(hr
, "IOleCache_Cache");
1476 fmtetc
.cfFormat
= 0;
1477 fmtetc
.dwAspect
= DVASPECT_ICON
;
1478 fmtetc
.tymed
= TYMED_MFPICT
;
1479 hr
= IOleCache2_Cache(pOleCache
, &fmtetc
, 0, &dwConnection
);
1480 ok_ole_success(hr
, "IOleCache_Cache");
1482 MultiByteToWideChar(CP_ACP
, 0, szSystemDir
, -1, wszPath
, sizeof(wszPath
)/sizeof(wszPath
[0]));
1483 memcpy(wszPath
+lstrlenW(wszPath
), wszShell32
, sizeof(wszShell32
));
1485 fmtetc
.cfFormat
= CF_METAFILEPICT
;
1486 stgmedium
.tymed
= TYMED_MFPICT
;
1487 U(stgmedium
).hMetaFilePict
= OleMetafilePictFromIconAndLabel(
1488 LoadIconA(NULL
, (LPSTR
)IDI_APPLICATION
), wszPath
, wszPath
, 0);
1489 stgmedium
.pUnkForRelease
= NULL
;
1491 fmtetc
.dwAspect
= DVASPECT_CONTENT
;
1492 hr
= IOleCache2_SetData(pOleCache
, &fmtetc
, &stgmedium
, FALSE
);
1493 ok(hr
== OLE_E_BLANK
, "IOleCache_SetData for aspect not in cache should have return OLE_E_BLANK instead of 0x%08x\n", hr
);
1495 fmtetc
.dwAspect
= DVASPECT_ICON
;
1496 hr
= IOleCache2_SetData(pOleCache
, &fmtetc
, &stgmedium
, FALSE
);
1497 ok_ole_success(hr
, "IOleCache_SetData");
1498 ReleaseStgMedium(&stgmedium
);
1500 hr
= IViewObject_Freeze(pViewObject
, DVASPECT_ICON
, -1, NULL
, &dwFreeze
);
1502 ok_ole_success(hr
, "IViewObject_Freeze");
1503 hr
= IViewObject_Freeze(pViewObject
, DVASPECT_CONTENT
, -1, NULL
, &dwFreeze
);
1504 ok(hr
== OLE_E_BLANK
, "IViewObject_Freeze with uncached aspect should have returned OLE_E_BLANK instead of 0x%08x\n", hr
);
1509 rcBounds
.right
= 100;
1510 rcBounds
.bottom
= 100;
1511 hdcMem
= CreateCompatibleDC(NULL
);
1513 hr
= IViewObject_Draw(pViewObject
, DVASPECT_ICON
, -1, NULL
, NULL
, NULL
, hdcMem
, &rcBounds
, NULL
, draw_continue
, 0xdeadbeef);
1514 ok_ole_success(hr
, "IViewObject_Draw");
1516 hr
= IViewObject_Draw(pViewObject
, DVASPECT_CONTENT
, -1, NULL
, NULL
, NULL
, hdcMem
, &rcBounds
, NULL
, draw_continue
, 0xdeadbeef);
1517 ok(hr
== OLE_E_BLANK
, "IViewObject_Draw with uncached aspect should have returned OLE_E_BLANK instead of 0x%08x\n", hr
);
1519 /* a NULL draw_continue fn ptr */
1520 hr
= IViewObject_Draw(pViewObject
, DVASPECT_ICON
, -1, NULL
, NULL
, NULL
, hdcMem
, &rcBounds
, NULL
, NULL
, 0xdeadbeef);
1521 ok_ole_success(hr
, "IViewObject_Draw");
1523 /* draw_continue that returns FALSE to abort drawing */
1524 hr
= IViewObject_Draw(pViewObject
, DVASPECT_ICON
, -1, NULL
, NULL
, NULL
, hdcMem
, &rcBounds
, NULL
, draw_continue_false
, 0xdeadbeef);
1526 broken(hr
== S_OK
), /* win9x may skip the callbacks */
1527 "IViewObject_Draw with draw_continue_false returns 0x%08x\n", hr
);
1531 hr
= IOleCacheControl_OnRun(pOleCacheControl
, &DataObject
);
1532 ok_ole_success(hr
, "IOleCacheControl_OnRun");
1534 hr
= IPersistStorage_Save(pPS
, pStorage
, TRUE
);
1535 ok_ole_success(hr
, "IPersistStorage_Save");
1537 hr
= IPersistStorage_SaveCompleted(pPS
, NULL
);
1538 ok_ole_success(hr
, "IPersistStorage_SaveCompleted");
1540 hr
= IPersistStorage_IsDirty(pPS
);
1541 ok(hr
== S_FALSE
, "IPersistStorage_IsDirty should have returned S_FALSE instead of 0x%x\n", hr
);
1543 IPersistStorage_Release(pPS
);
1544 IViewObject_Release(pViewObject
);
1545 IOleCache2_Release(pOleCache
);
1546 IOleCacheControl_Release(pOleCacheControl
);
1548 CHECK_NO_EXTRA_METHODS();
1550 /* Test with loaded data */
1551 trace("Testing loaded data with CreateDataCache:\n");
1552 expected_method_list
= methods_cacheload
;
1554 hr
= CreateDataCache(NULL
, &CLSID_NULL
, &IID_IOleCache2
, (LPVOID
*)&pOleCache
);
1555 ok_ole_success(hr
, "CreateDataCache");
1557 hr
= IOleCache2_QueryInterface(pOleCache
, &IID_IPersistStorage
, (LPVOID
*)&pPS
);
1558 ok_ole_success(hr
, "IOleCache_QueryInterface(IID_IPersistStorage)");
1559 hr
= IOleCache2_QueryInterface(pOleCache
, &IID_IViewObject
, (LPVOID
*)&pViewObject
);
1560 ok_ole_success(hr
, "IOleCache_QueryInterface(IID_IViewObject)");
1562 hr
= IViewObject_SetAdvise(pViewObject
, DVASPECT_ICON
, ADVF_PRIMEFIRST
, &AdviseSink
);
1563 ok_ole_success(hr
, "IViewObject_SetAdvise");
1565 hr
= IPersistStorage_Load(pPS
, pStorage
);
1566 ok_ole_success(hr
, "IPersistStorage_Load");
1568 hr
= IPersistStorage_IsDirty(pPS
);
1569 ok(hr
== S_FALSE
, "IPersistStorage_IsDirty should have returned S_FALSE instead of 0x%x\n", hr
);
1571 fmtetc
.cfFormat
= 0;
1572 fmtetc
.dwAspect
= DVASPECT_ICON
;
1575 fmtetc
.tymed
= TYMED_MFPICT
;
1576 hr
= IOleCache2_Cache(pOleCache
, &fmtetc
, 0, &dwConnection
);
1577 ok(hr
== CACHE_S_SAMECACHE
, "IOleCache_Cache with already loaded data format type should return CACHE_S_SAMECACHE instead of 0x%x\n", hr
);
1581 rcBounds
.right
= 100;
1582 rcBounds
.bottom
= 100;
1583 hdcMem
= CreateCompatibleDC(NULL
);
1585 hr
= IViewObject_Draw(pViewObject
, DVASPECT_ICON
, -1, NULL
, NULL
, NULL
, hdcMem
, &rcBounds
, NULL
, draw_continue
, 0xdeadbeef);
1586 ok_ole_success(hr
, "IViewObject_Draw");
1588 hr
= IViewObject_Draw(pViewObject
, DVASPECT_CONTENT
, -1, NULL
, NULL
, NULL
, hdcMem
, &rcBounds
, NULL
, draw_continue
, 0xdeadbeef);
1589 ok(hr
== OLE_E_BLANK
, "IViewObject_Draw with uncached aspect should have returned OLE_E_BLANK instead of 0x%08x\n", hr
);
1591 /* unload the cached storage object, causing it to be reloaded */
1592 hr
= IOleCache2_DiscardCache(pOleCache
, DISCARDCACHE_NOSAVE
);
1593 ok_ole_success(hr
, "IOleCache2_DiscardCache");
1594 hr
= IViewObject_Draw(pViewObject
, DVASPECT_ICON
, -1, NULL
, NULL
, NULL
, hdcMem
, &rcBounds
, NULL
, draw_continue
, 0xdeadbeef);
1595 ok_ole_success(hr
, "IViewObject_Draw");
1597 /* unload the cached storage object, but don't allow it to be reloaded */
1598 hr
= IPersistStorage_HandsOffStorage(pPS
);
1599 ok_ole_success(hr
, "IPersistStorage_HandsOffStorage");
1600 hr
= IViewObject_Draw(pViewObject
, DVASPECT_ICON
, -1, NULL
, NULL
, NULL
, hdcMem
, &rcBounds
, NULL
, draw_continue
, 0xdeadbeef);
1601 ok_ole_success(hr
, "IViewObject_Draw");
1602 hr
= IOleCache2_DiscardCache(pOleCache
, DISCARDCACHE_NOSAVE
);
1603 ok_ole_success(hr
, "IOleCache2_DiscardCache");
1604 hr
= IViewObject_Draw(pViewObject
, DVASPECT_ICON
, -1, NULL
, NULL
, NULL
, hdcMem
, &rcBounds
, NULL
, draw_continue
, 0xdeadbeef);
1605 ok(hr
== OLE_E_BLANK
, "IViewObject_Draw with uncached aspect should have returned OLE_E_BLANK instead of 0x%08x\n", hr
);
1610 hr
= IOleCache2_InitCache(pOleCache
, &DataObject
);
1611 ok(hr
== CACHE_E_NOCACHE_UPDATED
, "IOleCache_InitCache should have returned CACHE_E_NOCACHE_UPDATED instead of 0x%08x\n", hr
);
1614 IPersistStorage_Release(pPS
);
1615 IViewObject_Release(pViewObject
);
1616 IOleCache2_Release(pOleCache
);
1619 CHECK_NO_EXTRA_METHODS();
1622 hr
= CreateDataCache(NULL
, &CLSID_NULL
, &IID_IOleCache2
, (LPVOID
*)&pOleCache
);
1623 ok_ole_success(hr
, "CreateDataCache");
1625 expected_method_list
= methods_cachethenrun
;
1627 hr
= IOleCache2_QueryInterface(pOleCache
, &IID_IDataObject
, (LPVOID
*)&pCacheDataObject
);
1628 ok_ole_success(hr
, "IOleCache_QueryInterface(IID_IDataObject)");
1629 hr
= IOleCache2_QueryInterface(pOleCache
, &IID_IOleCacheControl
, (LPVOID
*)&pOleCacheControl
);
1630 ok_ole_success(hr
, "IOleCache_QueryInterface(IID_IOleCacheControl)");
1632 fmtetc
.cfFormat
= CF_METAFILEPICT
;
1633 fmtetc
.dwAspect
= DVASPECT_CONTENT
;
1634 fmtetc
.tymed
= TYMED_MFPICT
;
1636 hr
= IOleCache2_Cache(pOleCache
, &fmtetc
, 0, &dwConnection
);
1637 ok_ole_success(hr
, "IOleCache_Cache");
1639 hr
= IDataObject_GetData(pCacheDataObject
, &fmtetc
, &stgmedium
);
1640 ok(hr
== OLE_E_BLANK
, "got %08x\n", hr
);
1642 fmtetc
.cfFormat
= cf_test_1
;
1643 fmtetc
.dwAspect
= DVASPECT_CONTENT
;
1644 fmtetc
.tymed
= TYMED_HGLOBAL
;
1646 hr
= IOleCache2_Cache(pOleCache
, &fmtetc
, 0, &dwConnection
);
1647 ok(hr
== CACHE_S_FORMATETC_NOTSUPPORTED
, "got %08x\n", hr
);
1649 hr
= IDataObject_GetData(pCacheDataObject
, &fmtetc
, &stgmedium
);
1650 ok(hr
== OLE_E_BLANK
, "got %08x\n", hr
);
1652 fmtetc
.cfFormat
= cf_test_2
;
1653 hr
= IOleCache2_Cache(pOleCache
, &fmtetc
, ADVF_PRIMEFIRST
, &dwConnection
);
1654 ok(hr
== CACHE_S_FORMATETC_NOTSUPPORTED
, "got %08x\n", hr
);
1656 hr
= IDataObject_GetData(pCacheDataObject
, &fmtetc
, &stgmedium
);
1657 ok(hr
== OLE_E_BLANK
, "got %08x\n", hr
);
1659 hr
= IOleCacheControl_OnRun(pOleCacheControl
, &DataObject
);
1660 ok_ole_success(hr
, "IOleCacheControl_OnRun");
1662 fmtetc
.cfFormat
= cf_test_3
;
1663 hr
= IOleCache2_Cache(pOleCache
, &fmtetc
, 0, &dwConnection
);
1664 ok(hr
== CACHE_S_FORMATETC_NOTSUPPORTED
, "got %08x\n", hr
);
1666 fmtetc
.cfFormat
= cf_test_1
;
1667 hr
= IDataObject_GetData(pCacheDataObject
, &fmtetc
, &stgmedium
);
1668 ok(hr
== OLE_E_BLANK
, "got %08x\n", hr
);
1670 fmtetc
.cfFormat
= cf_test_2
;
1671 hr
= IDataObject_GetData(pCacheDataObject
, &fmtetc
, &stgmedium
);
1672 ok(hr
== S_OK
, "got %08x\n", hr
);
1673 ReleaseStgMedium(&stgmedium
);
1675 fmtetc
.cfFormat
= cf_test_3
;
1676 hr
= IDataObject_GetData(pCacheDataObject
, &fmtetc
, &stgmedium
);
1677 ok(hr
== OLE_E_BLANK
, "got %08x\n", hr
);
1679 IOleCacheControl_Release(pOleCacheControl
);
1680 IDataObject_Release(pCacheDataObject
);
1681 IOleCache2_Release(pOleCache
);
1683 CHECK_NO_EXTRA_METHODS();
1685 IStorage_Release(pStorage
);
1689 static const WCHAR CONTENTS
[] = {'C','O','N','T','E','N','T','S',0};
1691 /* 2 x 1 x 32 bpp dib. PelsPerMeter = 200x400 */
1694 0x42, 0x4d, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00,
1695 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x28, 0x00,
1697 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00,
1698 0x00, 0x00, 0x01, 0x00, 0x20, 0x00, 0x00, 0x00,
1700 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x00,
1701 0x00, 0x00, 0x90, 0x01, 0x00, 0x00, 0x00, 0x00,
1703 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff,
1704 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
1707 static IStorage
*create_storage( int num
)
1714 hr
= StgCreateDocfile( NULL
, STGM_READWRITE
| STGM_SHARE_EXCLUSIVE
| STGM_CREATE
| STGM_DELETEONRELEASE
, 0, &stg
);
1715 ok( hr
== S_OK
, "got %08x\n", hr
);
1716 hr
= IStorage_SetClass( stg
, &CLSID_Picture_Dib
);
1717 ok( hr
== S_OK
, "got %08x\n", hr
);
1718 hr
= IStorage_CreateStream( stg
, CONTENTS
, STGM_READWRITE
| STGM_SHARE_EXCLUSIVE
| STGM_CREATE
, 0, 0, &stm
);
1719 ok( hr
== S_OK
, "got %08x\n", hr
);
1720 if (num
== 1) /* Set biXPelsPerMeter = 0 */
1725 hr
= IStream_Write( stm
, dib
, sizeof(dib
), &written
);
1726 ok( hr
== S_OK
, "got %08x\n", hr
);
1727 IStream_Release( stm
);
1731 static void test_data_cache_dib_contents_stream(int num
)
1735 IPersistStorage
*persist
;
1739 FORMATETC fmt
= {CF_DIB
, NULL
, DVASPECT_CONTENT
, -1, TYMED_HGLOBAL
};
1744 hr
= CreateDataCache( NULL
, &CLSID_Picture_Metafile
, &IID_IUnknown
, (void *)&unk
);
1745 ok( SUCCEEDED(hr
), "got %08x\n", hr
);
1746 hr
= IUnknown_QueryInterface( unk
, &IID_IPersistStorage
, (void *)&persist
);
1747 ok( SUCCEEDED(hr
), "got %08x\n", hr
);
1748 hr
= IUnknown_QueryInterface( unk
, &IID_IDataObject
, (void *)&data
);
1749 ok( SUCCEEDED(hr
), "got %08x\n", hr
);
1750 hr
= IUnknown_QueryInterface( unk
, &IID_IViewObject2
, (void *)&view
);
1751 ok( SUCCEEDED(hr
), "got %08x\n", hr
);
1753 stg
= create_storage( num
);
1755 hr
= IPersistStorage_Load( persist
, stg
);
1756 ok( SUCCEEDED(hr
), "got %08x\n", hr
);
1757 IStorage_Release( stg
);
1759 hr
= IPersistStorage_GetClassID( persist
, &cls
);
1760 ok( SUCCEEDED(hr
), "got %08x\n", hr
);
1761 ok( IsEqualCLSID( &cls
, &CLSID_Picture_Dib
), "class id mismatch\n" );
1763 hr
= IDataObject_GetData( data
, &fmt
, &med
);
1764 ok( SUCCEEDED(hr
), "got %08x\n", hr
);
1767 ok( med
.tymed
== TYMED_HGLOBAL
, "got %x\n", med
.tymed
);
1768 ReleaseStgMedium( &med
);
1771 hr
= IViewObject2_GetExtent( view
, DVASPECT_CONTENT
, -1, NULL
, &sz
);
1772 ok( SUCCEEDED(hr
), "got %08x\n", hr
);
1775 ok( sz
.cx
== 1000, "got %d\n", sz
.cx
);
1776 ok( sz
.cy
== 250, "got %d\n", sz
.cy
);
1780 HDC hdc
= GetDC( 0 );
1781 LONG x
= 2 * 2540 / GetDeviceCaps( hdc
, LOGPIXELSX
);
1782 LONG y
= 1 * 2540 / GetDeviceCaps( hdc
, LOGPIXELSY
);
1783 ok( sz
.cx
== x
, "got %d %d\n", sz
.cx
, x
);
1784 ok( sz
.cy
== y
, "got %d %d\n", sz
.cy
, y
);
1786 ReleaseDC( 0, hdc
);
1789 IViewObject2_Release( view
);
1790 IDataObject_Release( data
);
1791 IPersistStorage_Release( persist
);
1792 IUnknown_Release( unk
);
1795 static void test_default_handler(void)
1798 IOleObject
*pObject
;
1799 IRunnableObject
*pRunnableObject
;
1800 IOleClientSite
*pClientSite
;
1801 IDataObject
*pDataObject
;
1805 LPOLESTR pszUserType
;
1810 IOleInPlaceObject
*pInPlaceObj
;
1811 IEnumOLEVERB
*pEnumVerbs
;
1813 static const WCHAR wszUnknown
[] = {'U','n','k','n','o','w','n',0};
1814 static const WCHAR wszHostName
[] = {'W','i','n','e',' ','T','e','s','t',' ','P','r','o','g','r','a','m',0};
1815 static const WCHAR wszDelim
[] = {'!',0};
1817 static const struct expected_method methods_embeddinghelper
[] =
1819 { "OleObject_QueryInterface", 0 },
1820 { "OleObject_AddRef", 0 },
1821 { "OleObject_QueryInterface", 0 },
1822 { "OleObject_QueryInterface", TEST_TODO
},
1823 { "OleObject_QueryInterface", 0 },
1824 { "OleObject_QueryInterface", 0 },
1825 { "OleObject_QueryInterface", TEST_OPTIONAL
}, /* Win95/98/NT4 */
1826 { "OleObject_Release", TEST_TODO
},
1827 { "WINE_EXTRA", TEST_OPTIONAL
},
1831 hr
= CoCreateInstance(&CLSID_WineTest
, NULL
, CLSCTX_INPROC_HANDLER
, &IID_IOleObject
, (void **)&pObject
);
1832 ok(hr
== REGDB_E_CLASSNOTREG
, "CoCreateInstance should have failed with REGDB_E_CLASSNOTREG instead of 0x%08x\n", hr
);
1834 hr
= OleCreateDefaultHandler(&CLSID_WineTest
, NULL
, &IID_IOleObject
, (void **)&pObject
);
1835 ok_ole_success(hr
, "OleCreateDefaultHandler");
1837 hr
= IOleObject_QueryInterface(pObject
, &IID_IOleInPlaceObject
, (void **)&pInPlaceObj
);
1838 ok(hr
== E_NOINTERFACE
, "IOleObject_QueryInterface(&IID_IOleInPlaceObject) should return E_NOINTERFACE instead of 0x%08x\n", hr
);
1840 hr
= IOleObject_Advise(pObject
, &AdviseSink
, &dwAdvConn
);
1841 ok_ole_success(hr
, "IOleObject_Advise");
1843 hr
= IOleObject_Close(pObject
, OLECLOSE_NOSAVE
);
1844 ok_ole_success(hr
, "IOleObject_Close");
1846 /* FIXME: test IOleObject_EnumAdvise */
1848 hr
= IOleObject_EnumVerbs(pObject
, &pEnumVerbs
);
1849 ok(hr
== REGDB_E_CLASSNOTREG
, "IOleObject_EnumVerbs should have returned REGDB_E_CLASSNOTREG instead of 0x%08x\n", hr
);
1851 hr
= IOleObject_GetClientSite(pObject
, &pClientSite
);
1852 ok_ole_success(hr
, "IOleObject_GetClientSite");
1854 hr
= IOleObject_SetClientSite(pObject
, pClientSite
);
1855 ok_ole_success(hr
, "IOleObject_SetClientSite");
1857 hr
= IOleObject_GetClipboardData(pObject
, 0, &pDataObject
);
1858 ok(hr
== OLE_E_NOTRUNNING
,
1859 "IOleObject_GetClipboardData should have returned OLE_E_NOTRUNNING instead of 0x%08x\n",
1862 hr
= IOleObject_GetExtent(pObject
, DVASPECT_CONTENT
, &sizel
);
1863 ok(hr
== OLE_E_BLANK
, "IOleObject_GetExtent should have returned OLE_E_BLANK instead of 0x%08x\n",
1866 hr
= IOleObject_GetMiscStatus(pObject
, DVASPECT_CONTENT
, &dwStatus
);
1867 ok(hr
== REGDB_E_CLASSNOTREG
, "IOleObject_GetMiscStatus should have returned REGDB_E_CLASSNOTREG instead of 0x%08x\n", hr
);
1869 hr
= IOleObject_GetUserClassID(pObject
, &clsid
);
1870 ok_ole_success(hr
, "IOleObject_GetUserClassID");
1871 ok(IsEqualCLSID(&clsid
, &CLSID_WineTest
), "clsid != CLSID_WineTest\n");
1873 hr
= IOleObject_GetUserType(pObject
, USERCLASSTYPE_FULL
, &pszUserType
);
1875 ok_ole_success(hr
, "IOleObject_GetUserType");
1876 ok(!lstrcmpW(pszUserType
, wszUnknown
), "Retrieved user type was wrong\n");
1879 hr
= IOleObject_InitFromData(pObject
, NULL
, TRUE
, 0);
1880 ok(hr
== OLE_E_NOTRUNNING
, "IOleObject_InitFromData should have returned OLE_E_NOTRUNNING instead of 0x%08x\n", hr
);
1882 hr
= IOleObject_IsUpToDate(pObject
);
1883 ok(hr
== OLE_E_NOTRUNNING
, "IOleObject_IsUpToDate should have returned OLE_E_NOTRUNNING instead of 0x%08x\n", hr
);
1885 palette
.palNumEntries
= 1;
1886 palette
.palVersion
= 2;
1887 memset(&palette
.palPalEntry
[0], 0, sizeof(palette
.palPalEntry
[0]));
1888 hr
= IOleObject_SetColorScheme(pObject
, &palette
);
1889 ok(hr
== OLE_E_NOTRUNNING
, "IOleObject_SetColorScheme should have returned OLE_E_NOTRUNNING instead of 0x%08x\n", hr
);
1891 sizel
.cx
= sizel
.cy
= 0;
1892 hr
= IOleObject_SetExtent(pObject
, DVASPECT_CONTENT
, &sizel
);
1893 ok(hr
== OLE_E_NOTRUNNING
, "IOleObject_SetExtent should have returned OLE_E_NOTRUNNING instead of 0x%08x\n", hr
);
1895 hr
= IOleObject_SetHostNames(pObject
, wszHostName
, NULL
);
1896 ok_ole_success(hr
, "IOleObject_SetHostNames");
1898 hr
= CreateItemMoniker(wszDelim
, wszHostName
, &pMoniker
);
1899 ok_ole_success(hr
, "CreateItemMoniker");
1900 hr
= IOleObject_SetMoniker(pObject
, OLEWHICHMK_CONTAINER
, pMoniker
);
1901 ok_ole_success(hr
, "IOleObject_SetMoniker");
1902 IMoniker_Release(pMoniker
);
1904 hr
= IOleObject_GetMoniker(pObject
, OLEGETMONIKER_ONLYIFTHERE
, OLEWHICHMK_CONTAINER
, &pMoniker
);
1905 ok(hr
== E_FAIL
, "IOleObject_GetMoniker should have returned E_FAIL instead of 0x%08x\n", hr
);
1907 hr
= IOleObject_Update(pObject
);
1909 ok(hr
== REGDB_E_CLASSNOTREG
, "IOleObject_Update should have returned REGDB_E_CLASSNOTREG instead of 0x%08x\n", hr
);
1911 hr
= IOleObject_QueryInterface(pObject
, &IID_IDataObject
, (void **)&pDataObject
);
1912 ok_ole_success(hr
, "IOleObject_QueryInterface");
1914 fmtetc
.cfFormat
= CF_TEXT
;
1916 fmtetc
.dwAspect
= DVASPECT_CONTENT
;
1918 fmtetc
.tymed
= TYMED_NULL
;
1919 hr
= IDataObject_DAdvise(pDataObject
, &fmtetc
, 0, &AdviseSink
, &dwAdvConn
);
1920 ok_ole_success(hr
, "IDataObject_DAdvise");
1922 fmtetc
.cfFormat
= CF_ENHMETAFILE
;
1924 fmtetc
.dwAspect
= DVASPECT_CONTENT
;
1926 fmtetc
.tymed
= TYMED_ENHMF
;
1927 hr
= IDataObject_DAdvise(pDataObject
, &fmtetc
, 0, &AdviseSink
, &dwAdvConn
);
1928 ok_ole_success(hr
, "IDataObject_DAdvise");
1930 fmtetc
.cfFormat
= CF_ENHMETAFILE
;
1932 fmtetc
.dwAspect
= DVASPECT_CONTENT
;
1934 fmtetc
.tymed
= TYMED_ENHMF
;
1935 hr
= IDataObject_QueryGetData(pDataObject
, &fmtetc
);
1937 ok(hr
== OLE_E_NOTRUNNING
, "IDataObject_QueryGetData should have returned OLE_E_NOTRUNNING instead of 0x%08x\n", hr
);
1939 fmtetc
.cfFormat
= CF_TEXT
;
1941 fmtetc
.dwAspect
= DVASPECT_CONTENT
;
1943 fmtetc
.tymed
= TYMED_NULL
;
1944 hr
= IDataObject_QueryGetData(pDataObject
, &fmtetc
);
1946 ok(hr
== OLE_E_NOTRUNNING
, "IDataObject_QueryGetData should have returned OLE_E_NOTRUNNING instead of 0x%08x\n", hr
);
1948 hr
= IOleObject_QueryInterface(pObject
, &IID_IRunnableObject
, (void **)&pRunnableObject
);
1949 ok_ole_success(hr
, "IOleObject_QueryInterface");
1951 hr
= IRunnableObject_SetContainedObject(pRunnableObject
, TRUE
);
1952 ok_ole_success(hr
, "IRunnableObject_SetContainedObject");
1954 hr
= IRunnableObject_Run(pRunnableObject
, NULL
);
1955 ok(hr
== REGDB_E_CLASSNOTREG
, "IOleObject_Run should have returned REGDB_E_CLASSNOTREG instead of 0x%08x\n", hr
);
1957 hr
= IOleObject_Close(pObject
, OLECLOSE_NOSAVE
);
1958 ok_ole_success(hr
, "IOleObject_Close");
1960 IRunnableObject_Release(pRunnableObject
);
1961 IOleObject_Release(pObject
);
1963 /* Test failure propagation from delegate ::QueryInterface */
1964 hr
= CoRegisterClassObject(&CLSID_WineTest
, (IUnknown
*)&OleObjectCF
,
1965 CLSCTX_INPROC_SERVER
, REGCLS_MULTIPLEUSE
, &dwRegister
);
1966 ok_ole_success(hr
, "CoRegisterClassObject");
1969 expected_method_list
= methods_embeddinghelper
;
1970 hr
= OleCreateEmbeddingHelper(&CLSID_WineTest
, NULL
, EMBDHLP_INPROC_SERVER
,
1971 &OleObjectCF
, &IID_IOleObject
, (void**)&pObject
);
1972 ok_ole_success(hr
, "OleCreateEmbeddingHelper");
1977 g_QIFailsWith
= E_FAIL
;
1978 hr
= IOleObject_QueryInterface(pObject
, &IID_WineTest
, (void**)&punk
);
1979 ok(hr
== E_FAIL
, "Got 0x%08x\n", hr
);
1981 g_QIFailsWith
= E_NOINTERFACE
;
1982 hr
= IOleObject_QueryInterface(pObject
, &IID_WineTest
, (void**)&punk
);
1983 ok(hr
== E_NOINTERFACE
, "Got 0x%08x\n", hr
);
1985 g_QIFailsWith
= CO_E_OBJNOTCONNECTED
;
1986 hr
= IOleObject_QueryInterface(pObject
, &IID_WineTest
, (void**)&punk
);
1987 ok(hr
== CO_E_OBJNOTCONNECTED
, "Got 0x%08x\n", hr
);
1989 g_QIFailsWith
= 0x87654321;
1990 hr
= IOleObject_QueryInterface(pObject
, &IID_WineTest
, (void**)&punk
);
1991 ok(hr
== 0x87654321, "Got 0x%08x\n", hr
);
1993 IOleObject_Release(pObject
);
1996 CHECK_NO_EXTRA_METHODS();
1998 hr
= CoRevokeClassObject(dwRegister
);
1999 ok_ole_success(hr
, "CoRevokeClassObject");
2003 static void test_runnable(void)
2005 static const struct expected_method methods_query_runnable
[] =
2007 { "OleObject_QueryInterface", 0 },
2008 { "OleObjectRunnable_AddRef", 0 },
2009 { "OleObjectRunnable_IsRunning", 0 },
2010 { "OleObjectRunnable_Release", 0 },
2014 static const struct expected_method methods_no_runnable
[] =
2016 { "OleObject_QueryInterface", 0 },
2021 IOleObject
*object
= &OleObject
;
2024 ret
= OleIsRunning(NULL
);
2025 ok(ret
== FALSE
, "got %d\n", ret
);
2027 expected_method_list
= methods_query_runnable
;
2028 ret
= OleIsRunning(object
);
2029 ok(ret
== TRUE
, "Object should be running\n");
2030 CHECK_NO_EXTRA_METHODS();
2032 g_isRunning
= FALSE
;
2033 expected_method_list
= methods_query_runnable
;
2034 ret
= OleIsRunning(object
);
2035 ok(ret
== FALSE
, "Object should not be running\n");
2036 CHECK_NO_EXTRA_METHODS();
2038 g_showRunnable
= FALSE
; /* QueryInterface(IID_IRunnableObject, ...) will fail */
2039 expected_method_list
= methods_no_runnable
;
2040 ret
= OleIsRunning(object
);
2041 ok(ret
== TRUE
, "Object without IRunnableObject should be running\n");
2042 CHECK_NO_EXTRA_METHODS();
2045 g_showRunnable
= TRUE
;
2048 static HRESULT WINAPI
Unknown_QueryInterface(IUnknown
*iface
, REFIID riid
, void **ppv
)
2051 if (IsEqualIID(riid
, &IID_IUnknown
)) *ppv
= iface
;
2054 IUnknown_AddRef((IUnknown
*)*ppv
);
2057 return E_NOINTERFACE
;
2060 static ULONG WINAPI
Unknown_AddRef(IUnknown
*iface
)
2065 static ULONG WINAPI
Unknown_Release(IUnknown
*iface
)
2070 static const IUnknownVtbl UnknownVtbl
=
2072 Unknown_QueryInterface
,
2077 static IUnknown unknown
= { &UnknownVtbl
};
2079 static void test_OleRun(void)
2083 hr
= OleRun(&unknown
);
2084 ok(hr
== S_OK
, "OleRun failed 0x%08x\n", hr
);
2087 static void test_OleLockRunning(void)
2091 hr
= OleLockRunning((LPUNKNOWN
)&unknown
, TRUE
, FALSE
);
2092 ok(hr
== S_OK
, "OleLockRunning failed 0x%08x\n", hr
);
2095 static void test_OleDraw(void)
2100 hr
= OleDraw((IUnknown
*)&viewobject
, 0, (HDC
)0x1, NULL
);
2101 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
2103 hr
= OleDraw(NULL
, 0, (HDC
)0x1, NULL
);
2104 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
2106 hr
= OleDraw(NULL
, 0, (HDC
)0x1, &rect
);
2107 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
2110 static const WCHAR comp_objW
[] = {1,'C','o','m','p','O','b','j',0};
2111 static IStream
*comp_obj_stream
;
2112 static IStream
*ole_stream
;
2114 static HRESULT WINAPI
Storage_QueryInterface(IStorage
*iface
, REFIID riid
, void **ppvObject
)
2116 ok(0, "unexpected call to QueryInterface\n");
2120 static ULONG WINAPI
Storage_AddRef(IStorage
*iface
)
2122 ok(0, "unexpected call to AddRef\n");
2126 static ULONG WINAPI
Storage_Release(IStorage
*iface
)
2128 ok(0, "unexpected call to Release\n");
2132 static HRESULT WINAPI
Storage_CreateStream(IStorage
*iface
, LPCOLESTR pwcsName
, DWORD grfMode
, DWORD reserved1
, DWORD reserved2
, IStream
**ppstm
)
2134 ULARGE_INTEGER size
= {{0}};
2135 LARGE_INTEGER pos
= {{0}};
2138 CHECK_EXPECT(Storage_CreateStream_CompObj
);
2139 ok(!lstrcmpW(pwcsName
, comp_objW
), "pwcsName = %s\n", wine_dbgstr_w(pwcsName
));
2140 todo_wine
ok(grfMode
== (STGM_CREATE
|STGM_SHARE_EXCLUSIVE
|STGM_READWRITE
), "grfMode = %x\n", grfMode
);
2141 ok(!reserved1
, "reserved1 = %x\n", reserved1
);
2142 ok(!reserved2
, "reserved2 = %x\n", reserved2
);
2143 ok(!!ppstm
, "ppstm = NULL\n");
2145 *ppstm
= comp_obj_stream
;
2146 IStream_AddRef(comp_obj_stream
);
2147 hr
= IStream_Seek(comp_obj_stream
, pos
, STREAM_SEEK_SET
, NULL
);
2148 ok(hr
== S_OK
, "IStream_Seek returned %x\n", hr
);
2149 hr
= IStream_SetSize(comp_obj_stream
, size
);
2150 ok(hr
== S_OK
, "IStream_SetSize returned %x\n", hr
);
2154 static HRESULT WINAPI
Storage_OpenStream(IStorage
*iface
, LPCOLESTR pwcsName
, void *reserved1
, DWORD grfMode
, DWORD reserved2
, IStream
**ppstm
)
2156 static const WCHAR ole1W
[] = {1,'O','l','e',0};
2158 LARGE_INTEGER pos
= {{0}};
2161 ok(!reserved1
, "reserved1 = %p\n", reserved1
);
2162 ok(!reserved2
, "reserved2 = %x\n", reserved2
);
2163 ok(!!ppstm
, "ppstm = NULL\n");
2165 if(!lstrcmpW(pwcsName
, comp_objW
)) {
2166 CHECK_EXPECT2(Storage_OpenStream_CompObj
);
2167 ok(grfMode
== STGM_SHARE_EXCLUSIVE
, "grfMode = %x\n", grfMode
);
2169 *ppstm
= comp_obj_stream
;
2170 IStream_AddRef(comp_obj_stream
);
2171 hr
= IStream_Seek(comp_obj_stream
, pos
, STREAM_SEEK_SET
, NULL
);
2172 ok(hr
== S_OK
, "IStream_Seek returned %x\n", hr
);
2174 }else if(!lstrcmpW(pwcsName
, ole1W
)) {
2175 CHECK_EXPECT(Storage_OpenStream_Ole
);
2176 ok(grfMode
== (STGM_SHARE_EXCLUSIVE
|STGM_READWRITE
), "grfMode = %x\n", grfMode
);
2178 *ppstm
= ole_stream
;
2179 IStream_AddRef(ole_stream
);
2180 hr
= IStream_Seek(ole_stream
, pos
, STREAM_SEEK_SET
, NULL
);
2181 ok(hr
== S_OK
, "IStream_Seek returned %x\n", hr
);
2185 ok(0, "unexpected call to OpenStream: %s\n", wine_dbgstr_w(pwcsName
));
2189 static HRESULT WINAPI
Storage_CreateStorage(IStorage
*iface
, LPCOLESTR pwcsName
, DWORD grfMode
, DWORD dwStgFmt
, DWORD reserved2
, IStorage
**ppstg
)
2191 ok(0, "unexpected call to CreateStorage\n");
2195 static HRESULT WINAPI
Storage_OpenStorage(IStorage
*iface
, LPCOLESTR pwcsName
, IStorage
*pstgPriority
, DWORD grfMode
, SNB snbExclude
, DWORD reserved
, IStorage
**ppstg
)
2197 ok(0, "unexpected call to OpenStorage\n");
2201 static HRESULT WINAPI
Storage_CopyTo(IStorage
*iface
, DWORD ciidExclude
, const IID
*rgiidExclude
, SNB snbExclude
, IStorage
*pstgDest
)
2203 ok(0, "unexpected call to CopyTo\n");
2207 static HRESULT WINAPI
Storage_MoveElementTo(IStorage
*iface
, LPCOLESTR pwcsName
, IStorage
*pstgDest
, LPCOLESTR pwcsNewName
, DWORD grfFlags
)
2209 ok(0, "unexpected call to MoveElementTo\n");
2213 static HRESULT WINAPI
Storage_Commit(IStorage
*iface
, DWORD grfCommitFlags
)
2215 ok(0, "unexpected call to Commit\n");
2219 static HRESULT WINAPI
Storage_Revert(IStorage
*iface
)
2221 ok(0, "unexpected call to Revert\n");
2225 static HRESULT WINAPI
Storage_EnumElements(IStorage
*iface
, DWORD reserved1
, void *reserved2
, DWORD reserved3
, IEnumSTATSTG
**ppenum
)
2227 ok(0, "unexpected call to EnumElements\n");
2231 static HRESULT WINAPI
Storage_DestroyElement(IStorage
*iface
, LPCOLESTR pwcsName
)
2233 ok(0, "unexpected call to DestroyElement\n");
2237 static HRESULT WINAPI
Storage_RenameElement(IStorage
*iface
, LPCOLESTR pwcsOldName
, LPCOLESTR pwcsNewName
)
2239 ok(0, "unexpected call to RenameElement\n");
2243 static HRESULT WINAPI
Storage_SetElementTimes(IStorage
*iface
, LPCOLESTR pwcsName
, const FILETIME
*pctime
, const FILETIME
*patime
, const FILETIME
*pmtime
)
2245 ok(0, "unexpected call to SetElementTimes\n");
2249 static HRESULT WINAPI
Storage_SetClass(IStorage
*iface
, REFCLSID clsid
)
2251 CHECK_EXPECT(Storage_SetClass
);
2252 ok(IsEqualIID(clsid
, &CLSID_WineTest
), "clsid = %s\n", wine_dbgstr_guid(clsid
));
2256 static HRESULT WINAPI
Storage_SetStateBits(IStorage
*iface
, DWORD grfStateBits
, DWORD grfMask
)
2258 ok(0, "unexpected call to SetStateBits\n");
2262 static HRESULT WINAPI
Storage_Stat(IStorage
*iface
, STATSTG
*pstatstg
, DWORD grfStatFlag
)
2264 CHECK_EXPECT2(Storage_Stat
);
2265 ok(pstatstg
!= NULL
, "pstatstg = NULL\n");
2266 ok(grfStatFlag
== STATFLAG_NONAME
, "grfStatFlag = %x\n", grfStatFlag
);
2268 memset(pstatstg
, 0, sizeof(STATSTG
));
2269 pstatstg
->type
= STGTY_STORAGE
;
2270 pstatstg
->clsid
= CLSID_WineTestOld
;
2274 static IStorageVtbl StorageVtbl
=
2276 Storage_QueryInterface
,
2279 Storage_CreateStream
,
2281 Storage_CreateStorage
,
2282 Storage_OpenStorage
,
2284 Storage_MoveElementTo
,
2287 Storage_EnumElements
,
2288 Storage_DestroyElement
,
2289 Storage_RenameElement
,
2290 Storage_SetElementTimes
,
2292 Storage_SetStateBits
,
2296 static IStorage Storage
= { &StorageVtbl
};
2298 static void test_OleDoAutoConvert(void)
2300 static const WCHAR clsidW
[] = {'C','L','S','I','D','\\',0};
2305 DWORD ansi_user_type_len
;
2306 DWORD ansi_clipboard_format_len
;
2308 DWORD unicode_marker
;
2309 DWORD unicode_user_type_len
;
2310 DWORD unicode_clipboard_format_len
;
2316 DWORD link_update_option
;
2318 DWORD reserved_moniker_stream_size
;
2319 DWORD relative_source_moniker_stream_size
;
2320 DWORD absolute_source_moniker_stream_size
;
2321 DWORD clsid_indicator
;
2323 DWORD reserved_display_name
;
2325 DWORD local_update_time
;
2326 DWORD local_check_update_time
;
2327 DWORD remote_update_time
;
2330 LARGE_INTEGER pos
= {{0}};
2337 hr
= CreateStreamOnHGlobal(NULL
, TRUE
, &comp_obj_stream
);
2338 ok(hr
== S_OK
, "CreateStreamOnHGlobal returned %x\n", hr
);
2339 hr
= IStream_Write(comp_obj_stream
, (char*)&comp_obj_data
, sizeof(comp_obj_data
), NULL
);
2340 ok(hr
== S_OK
, "IStream_Write returned %x\n", hr
);
2342 hr
= CreateStreamOnHGlobal(NULL
, TRUE
, &ole_stream
);
2343 ok(hr
== S_OK
, "CreateStreamOnHGlobal returned %x\n", hr
);
2344 hr
= IStream_Write(ole_stream
, (char*)&ole_data
, sizeof(ole_data
), NULL
);
2345 ok(hr
== S_OK
, "IStream_Write returned %x\n", hr
);
2347 clsid
= IID_WineTest
;
2348 hr
= OleDoAutoConvert(NULL
, &clsid
);
2349 ok(hr
== E_INVALIDARG
, "OleDoAutoConvert returned %x\n", hr
);
2350 ok(IsEqualIID(&clsid
, &IID_NULL
), "clsid = %s\n", wine_dbgstr_guid(&clsid
));
2352 if(0) /* crashes on Win7 */
2353 OleDoAutoConvert(&Storage
, NULL
);
2355 clsid
= IID_WineTest
;
2356 SET_EXPECT(Storage_Stat
);
2357 hr
= OleDoAutoConvert(&Storage
, &clsid
);
2358 ok(hr
== REGDB_E_CLASSNOTREG
, "OleDoAutoConvert returned %x\n", hr
);
2359 CHECK_CALLED(Storage_Stat
);
2360 ok(IsEqualIID(&clsid
, &CLSID_WineTestOld
), "clsid = %s\n", wine_dbgstr_guid(&clsid
));
2362 lstrcpyW(buf
, clsidW
);
2363 StringFromGUID2(&CLSID_WineTestOld
, buf
+6, 39);
2365 ret
= RegCreateKeyExW(HKEY_CLASSES_ROOT
, buf
, 0, NULL
, 0,
2366 KEY_READ
| KEY_WRITE
| KEY_CREATE_SUB_KEY
, NULL
, &root
, NULL
);
2367 if(ret
!= ERROR_SUCCESS
) {
2368 win_skip("not enough permissions to create CLSID key (%u)\n", ret
);
2372 clsid
= IID_WineTest
;
2373 SET_EXPECT(Storage_Stat
);
2374 hr
= OleDoAutoConvert(&Storage
, &clsid
);
2375 ok(hr
== REGDB_E_KEYMISSING
, "OleDoAutoConvert returned %x\n", hr
);
2376 CHECK_CALLED(Storage_Stat
);
2377 ok(IsEqualIID(&clsid
, &CLSID_WineTestOld
), "clsid = %s\n", wine_dbgstr_guid(&clsid
));
2379 hr
= OleSetAutoConvert(&CLSID_WineTestOld
, &CLSID_WineTest
);
2380 ok_ole_success(hr
, "OleSetAutoConvert");
2382 hr
= OleGetAutoConvert(&CLSID_WineTestOld
, &clsid
);
2383 ok_ole_success(hr
, "OleGetAutoConvert");
2384 ok(IsEqualIID(&clsid
, &CLSID_WineTest
), "incorrect clsid: %s\n", wine_dbgstr_guid(&clsid
));
2386 clsid
= IID_WineTest
;
2387 SET_EXPECT(Storage_Stat
);
2388 SET_EXPECT(Storage_OpenStream_CompObj
);
2389 SET_EXPECT(Storage_SetClass
);
2390 SET_EXPECT(Storage_CreateStream_CompObj
);
2391 SET_EXPECT(Storage_OpenStream_Ole
);
2392 hr
= OleDoAutoConvert(&Storage
, &clsid
);
2393 ok(hr
== S_OK
, "OleDoAutoConvert returned %x\n", hr
);
2394 CHECK_CALLED(Storage_Stat
);
2395 CHECK_CALLED(Storage_OpenStream_CompObj
);
2396 CHECK_CALLED(Storage_SetClass
);
2397 CHECK_CALLED(Storage_CreateStream_CompObj
);
2398 CHECK_CALLED(Storage_OpenStream_Ole
);
2399 ok(IsEqualIID(&clsid
, &CLSID_WineTest
), "clsid = %s\n", wine_dbgstr_guid(&clsid
));
2401 hr
= IStream_Seek(comp_obj_stream
, pos
, STREAM_SEEK_SET
, NULL
);
2402 ok(hr
== S_OK
, "IStream_Seek returned %x\n", hr
);
2403 hr
= IStream_Read(comp_obj_stream
, &comp_obj_data
, sizeof(comp_obj_data
), NULL
);
2404 ok(hr
== S_OK
, "IStream_Read returned %x\n", hr
);
2405 ok(comp_obj_data
.reserved1
== 0xfffe0001, "reserved1 = %x\n", comp_obj_data
.reserved1
);
2406 ok(comp_obj_data
.version
== 0xa03, "version = %x\n", comp_obj_data
.version
);
2407 ok(comp_obj_data
.reserved2
[0] == -1, "reserved2[0] = %x\n", comp_obj_data
.reserved2
[0]);
2408 ok(IsEqualIID(comp_obj_data
.reserved2
+1, &CLSID_WineTestOld
), "reserved2 = %s\n", wine_dbgstr_guid((CLSID
*)(comp_obj_data
.reserved2
+1)));
2409 ok(!comp_obj_data
.ansi_user_type_len
, "ansi_user_type_len = %d\n", comp_obj_data
.ansi_user_type_len
);
2410 ok(!comp_obj_data
.ansi_clipboard_format_len
, "ansi_clipboard_format_len = %d\n", comp_obj_data
.ansi_clipboard_format_len
);
2411 ok(!comp_obj_data
.reserved3
, "reserved3 = %x\n", comp_obj_data
.reserved3
);
2412 ok(comp_obj_data
.unicode_marker
== 0x71b239f4, "unicode_marker = %x\n", comp_obj_data
.unicode_marker
);
2413 ok(!comp_obj_data
.unicode_user_type_len
, "unicode_user_type_len = %d\n", comp_obj_data
.unicode_user_type_len
);
2414 ok(!comp_obj_data
.unicode_clipboard_format_len
, "unicode_clipboard_format_len = %d\n", comp_obj_data
.unicode_clipboard_format_len
);
2415 ok(!comp_obj_data
.reserved4
, "reserved4 %d\n", comp_obj_data
.reserved4
);
2417 hr
= IStream_Seek(ole_stream
, pos
, STREAM_SEEK_SET
, NULL
);
2418 ok(hr
== S_OK
, "IStream_Seek returned %x\n", hr
);
2419 hr
= IStream_Read(ole_stream
, &ole_data
, sizeof(ole_data
), NULL
);
2420 ok(hr
== S_OK
, "IStream_Read returned %x\n", hr
);
2421 ok(ole_data
.version
== 0, "version = %x\n", ole_data
.version
);
2422 ok(ole_data
.flags
== 4, "flags = %x\n", ole_data
.flags
);
2423 for(i
=2; i
<sizeof(ole_data
)/sizeof(DWORD
); i
++)
2424 ok(((DWORD
*)&ole_data
)[i
] == 0, "ole_data[%d] = %x\n", i
, ((DWORD
*)&ole_data
)[i
]);
2426 SET_EXPECT(Storage_OpenStream_Ole
);
2427 hr
= SetConvertStg(&Storage
, TRUE
);
2428 ok(hr
== S_OK
, "SetConvertStg returned %x\n", hr
);
2429 CHECK_CALLED(Storage_OpenStream_Ole
);
2431 SET_EXPECT(Storage_OpenStream_CompObj
);
2432 SET_EXPECT(Storage_Stat
);
2433 SET_EXPECT(Storage_CreateStream_CompObj
);
2434 hr
= WriteFmtUserTypeStg(&Storage
, 0, NULL
);
2435 ok(hr
== S_OK
, "WriteFmtUserTypeStg returned %x\n", hr
);
2436 todo_wine
CHECK_CALLED(Storage_OpenStream_CompObj
);
2437 CHECK_CALLED(Storage_Stat
);
2438 CHECK_CALLED(Storage_CreateStream_CompObj
);
2439 hr
= IStream_Seek(comp_obj_stream
, pos
, STREAM_SEEK_SET
, NULL
);
2440 ok(hr
== S_OK
, "IStream_Seek returned %x\n", hr
);
2441 hr
= IStream_Read(comp_obj_stream
, &comp_obj_data
, sizeof(comp_obj_data
), NULL
);
2442 ok(hr
== S_OK
, "IStream_Read returned %x\n", hr
);
2443 ok(comp_obj_data
.reserved1
== 0xfffe0001, "reserved1 = %x\n", comp_obj_data
.reserved1
);
2444 ok(comp_obj_data
.version
== 0xa03, "version = %x\n", comp_obj_data
.version
);
2445 ok(comp_obj_data
.reserved2
[0] == -1, "reserved2[0] = %x\n", comp_obj_data
.reserved2
[0]);
2446 ok(IsEqualIID(comp_obj_data
.reserved2
+1, &CLSID_WineTestOld
), "reserved2 = %s\n", wine_dbgstr_guid((CLSID
*)(comp_obj_data
.reserved2
+1)));
2447 ok(!comp_obj_data
.ansi_user_type_len
, "ansi_user_type_len = %d\n", comp_obj_data
.ansi_user_type_len
);
2448 ok(!comp_obj_data
.ansi_clipboard_format_len
, "ansi_clipboard_format_len = %d\n", comp_obj_data
.ansi_clipboard_format_len
);
2449 ok(!comp_obj_data
.reserved3
, "reserved3 = %x\n", comp_obj_data
.reserved3
);
2450 ok(comp_obj_data
.unicode_marker
== 0x71b239f4, "unicode_marker = %x\n", comp_obj_data
.unicode_marker
);
2451 ok(!comp_obj_data
.unicode_user_type_len
, "unicode_user_type_len = %d\n", comp_obj_data
.unicode_user_type_len
);
2452 ok(!comp_obj_data
.unicode_clipboard_format_len
, "unicode_clipboard_format_len = %d\n", comp_obj_data
.unicode_clipboard_format_len
);
2453 ok(!comp_obj_data
.reserved4
, "reserved4 %d\n", comp_obj_data
.reserved4
);
2455 ret
= IStream_Release(comp_obj_stream
);
2456 ok(!ret
, "comp_obj_stream was not freed\n");
2457 ret
= IStream_Release(ole_stream
);
2458 ok(!ret
, "ole_stream was not freed\n");
2460 ret
= RegDeleteKeyA(root
, "AutoConvertTo");
2461 ok(ret
== ERROR_SUCCESS
, "RegDeleteKey error %u\n", ret
);
2462 ret
= RegDeleteKeyA(root
, "");
2463 ok(ret
== ERROR_SUCCESS
, "RegDeleteKey error %u\n", ret
);
2474 cf_test_1
= RegisterClipboardFormatA("cf_winetest_1");
2475 cf_test_2
= RegisterClipboardFormatA("cf_winetest_2");
2476 cf_test_3
= RegisterClipboardFormatA("cf_winetest_3");
2480 hr
= CoRegisterClassObject(&CLSID_Equation3
, (IUnknown
*)&OleObjectCF
, CLSCTX_INPROC_SERVER
, REGCLS_MULTIPLEUSE
, &dwRegister
);
2481 ok_ole_success(hr
, "CoRegisterClassObject");
2483 hr
= StgCreateDocfile(NULL
, STGM_READWRITE
| STGM_CREATE
| STGM_SHARE_EXCLUSIVE
| STGM_DELETEONRELEASE
, 0, &pStorage
);
2484 ok_ole_success(hr
, "StgCreateDocfile");
2486 test_OleCreate(pStorage
);
2488 hr
= IStorage_Stat(pStorage
, &statstg
, STATFLAG_NONAME
);
2489 ok_ole_success(hr
, "IStorage_Stat");
2490 ok(IsEqualCLSID(&CLSID_Equation3
, &statstg
.clsid
), "Wrong CLSID in storage\n");
2492 test_OleLoad(pStorage
);
2494 IStorage_Release(pStorage
);
2496 hr
= CoRevokeClassObject(dwRegister
);
2497 ok_ole_success(hr
, "CoRevokeClassObject");
2500 test_data_cache_dib_contents_stream( 0 );
2501 test_data_cache_dib_contents_stream( 1 );
2502 test_default_handler();
2505 test_OleLockRunning();
2507 test_OleDoAutoConvert();