1693{
1703 FORMATETC fmtetc;
1704 STGMEDIUM stgmedium;
1712 static const WCHAR wszShell32[] = {
'\\',
's',
'h',
'e',
'l',
'l',
'3',
'2',
'.',
'd',
'l',
'l',0};
1713
1715 {
1716 { "AdviseSink_OnViewChange", 0 },
1717 { "AdviseSink_OnViewChange", 0 },
1718 { "draw_continue", 1 },
1719 { "draw_continue_false", 1 },
1720 { "DataObject_DAdvise", 0 },
1721 { "DataObject_DAdvise", 0 },
1722 { "DataObject_DUnadvise", 0 },
1723 { "DataObject_DUnadvise", 0 },
1725 };
1727 {
1728 { "AdviseSink_OnViewChange", 0 },
1729 { "draw_continue", 1 },
1730 { "draw_continue", 1 },
1731 { "draw_continue", 1 },
1732 {
"DataObject_GetData", 0, {
CF_DIB,
NULL, DVASPECT_THUMBNAIL, -1, TYMED_HGLOBAL} },
1733 {
"DataObject_GetData", 0, {
CF_BITMAP,
NULL, DVASPECT_THUMBNAIL, -1, TYMED_GDI} },
1736 };
1738 {
1739 { "DataObject_DAdvise", 0 },
1740 { "DataObject_DAdvise", 0 },
1741 { "DataObject_DAdvise", 0 },
1742 { "DataObject_DAdvise", 0 },
1743 { "DataObject_DUnadvise", 0 },
1744 { "DataObject_DUnadvise", 0 },
1745 { "DataObject_DUnadvise", 0 },
1746 { "DataObject_DUnadvise", 0 },
1748 };
1749
1751
1753
1755 fmtetc.dwAspect = DVASPECT_ICON;
1756 fmtetc.lindex = -1;
1758 fmtetc.tymed = TYMED_MFPICT;
1759
1762
1763
1764
1765
1768
1771
1776 ok(unk != (
IUnknown*)olecache,
"got %p, expected %p\n", olecache, unk);
1777 ok(unk != (
IUnknown*)pOleCache,
"got %p, expected %p\n", pOleCache, unk);
1778 IOleCache2_Release(pOleCache);
1779 IOleCache_Release(olecache);
1780 IUnknown_Release(unk);
1781
1790 ok(unk == (
IUnknown*)olecache,
"got %p, expected %p\n", olecache, unk);
1791 ok(unk == (
IUnknown*)pOleCache,
"got %p, expected %p\n", pOleCache, unk);
1792 ok(unk == unk2,
"got %p, expected %p\n", unk2, unk);
1793 IUnknown_Release(unk2);
1794 IOleCache2_Release(pOleCache);
1795 IOleCache_Release(olecache);
1796 IUnknown_Release(unk);
1797
1798
1799
1802
1809
1810 hr = IViewObject_SetAdvise(pViewObject, DVASPECT_ICON, ADVF_PRIMEFIRST, &
AdviseSink);
1812
1813 hr = IPersistStorage_InitNew(pPS, pStorage);
1815
1816 hr = IPersistStorage_IsDirty(pPS);
1818
1819 hr = IPersistStorage_GetClassID(pPS, &
clsid);
1822
1823 hr = IOleCache2_Uncache(pOleCache, 0xdeadbeef);
1824 ok(
hr ==
OLE_E_NOCONNECTION,
"IOleCache_Uncache with invalid value should return OLE_E_NOCONNECTION instead of 0x%x\n",
hr);
1825
1826
1828 {
1829 hr = IOleCache2_Cache(pOleCache,
NULL, 0, &dwConnection);
1830 ok(
hr ==
E_INVALIDARG,
"IOleCache_Cache with NULL fmtetc should have returned E_INVALIDARG instead of 0x%08x\n",
hr);
1831
1832 hr = IOleCache2_Cache(pOleCache,
NULL, 0,
NULL);
1833 ok(
hr ==
E_INVALIDARG,
"IOleCache_Cache with NULL pdwConnection should have returned E_INVALIDARG instead of 0x%08x\n",
hr);
1834 }
1835 else
1836 {
1837 skip(
"tests with NULL parameters will crash on NT4 and below\n");
1838 }
1839
1840 for (fmtetc.cfFormat =
CF_TEXT; fmtetc.cfFormat <
CF_MAX; fmtetc.cfFormat++)
1841 {
1843 fmtetc.dwAspect = DVASPECT_THUMBNAIL;
1844 for (
i = 0;
i < 7;
i++)
1845 {
1846 fmtetc.tymed = 1 <<
i;
1847 hr = IOleCache2_Cache(pOleCache, &fmtetc, 0, &dwConnection);
1848 if ((fmtetc.cfFormat ==
CF_METAFILEPICT && fmtetc.tymed == TYMED_MFPICT) ||
1849 (fmtetc.cfFormat ==
CF_BITMAP && fmtetc.tymed == TYMED_GDI) ||
1850 (fmtetc.cfFormat ==
CF_DIB && fmtetc.tymed == TYMED_HGLOBAL) ||
1851 (fmtetc.cfFormat ==
CF_ENHMETAFILE && fmtetc.tymed == TYMED_ENHMF))
1852 ok(
hr ==
S_OK,
"IOleCache_Cache cfFormat = %d, tymed = %d should have returned S_OK instead of 0x%08x\n",
1853 fmtetc.cfFormat, fmtetc.tymed,
hr);
1854 else if (fmtetc.tymed == TYMED_HGLOBAL)
1857 "IOleCache_Cache cfFormat = %d, tymed = %d should have returned CACHE_S_FORMATETC_NOTSUPPORTED instead of 0x%08x\n",
1858 fmtetc.cfFormat, fmtetc.tymed,
hr);
1859 else
1860 ok(
hr ==
DV_E_TYMED,
"IOleCache_Cache cfFormat = %d, tymed = %d should have returned DV_E_TYMED instead of 0x%08x\n",
1861 fmtetc.cfFormat, fmtetc.tymed,
hr);
1863 {
1864 hr = IOleCache2_Uncache(pOleCache, dwConnection);
1866 }
1867 }
1868 }
1869
1871 fmtetc.dwAspect = DVASPECT_THUMBNAIL;
1872 fmtetc.tymed = TYMED_GDI;
1873 hr = IOleCache2_Cache(pOleCache, &fmtetc, 0, &dwConnection);
1875
1876 fmtetc.cfFormat = 0;
1877 fmtetc.dwAspect = DVASPECT_ICON;
1878 fmtetc.tymed = TYMED_MFPICT;
1879 hr = IOleCache2_Cache(pOleCache, &fmtetc, 0, &dwConnection);
1881
1883 memcpy(wszPath+
lstrlenW(wszPath), wszShell32,
sizeof(wszShell32));
1884
1886 stgmedium.tymed = TYMED_MFPICT;
1889 stgmedium.pUnkForRelease =
NULL;
1890
1891 fmtetc.dwAspect = DVASPECT_CONTENT;
1892 hr = IOleCache2_SetData(pOleCache, &fmtetc, &stgmedium,
FALSE);
1893 ok(
hr ==
OLE_E_BLANK,
"IOleCache_SetData for aspect not in cache should have return OLE_E_BLANK instead of 0x%08x\n",
hr);
1894
1895 fmtetc.dwAspect = DVASPECT_ICON;
1896 hr = IOleCache2_SetData(pOleCache, &fmtetc, &stgmedium,
FALSE);
1899
1900 hr = IViewObject_Freeze(pViewObject, DVASPECT_ICON, -1,
NULL, &dwFreeze);
1903 hr = IViewObject_Freeze(pViewObject, DVASPECT_CONTENT, -1,
NULL, &dwFreeze);
1904 ok(
hr ==
OLE_E_BLANK,
"IViewObject_Freeze with uncached aspect should have returned OLE_E_BLANK instead of 0x%08x\n",
hr);
1905 }
1906
1909 rcBounds.
right = 100;
1912
1913 hr = IViewObject_Draw(pViewObject, DVASPECT_ICON, -1,
NULL,
NULL,
NULL,
hdcMem, &rcBounds,
NULL,
draw_continue, 0xdeadbeef);
1915
1916 hr = IViewObject_Draw(pViewObject, DVASPECT_CONTENT, -1,
NULL,
NULL,
NULL,
hdcMem, &rcBounds,
NULL,
draw_continue, 0xdeadbeef);
1917 ok(
hr ==
OLE_E_BLANK,
"IViewObject_Draw with uncached aspect should have returned OLE_E_BLANK instead of 0x%08x\n",
hr);
1918
1919
1920 hr = IViewObject_Draw(pViewObject, DVASPECT_ICON, -1,
NULL,
NULL,
NULL,
hdcMem, &rcBounds,
NULL,
NULL, 0xdeadbeef);
1922
1923
1924 hr = IViewObject_Draw(pViewObject, DVASPECT_ICON, -1,
NULL,
NULL,
NULL,
hdcMem, &rcBounds,
NULL,
draw_continue_false, 0xdeadbeef);
1927 "IViewObject_Draw with draw_continue_false returns 0x%08x\n",
hr);
1928
1930
1931 hr = IOleCacheControl_OnRun(pOleCacheControl, &
DataObject);
1933
1934 hr = IPersistStorage_Save(pPS, pStorage,
TRUE);
1936
1937 hr = IPersistStorage_SaveCompleted(pPS,
NULL);
1939
1940 hr = IPersistStorage_IsDirty(pPS);
1941 ok(
hr ==
S_FALSE,
"IPersistStorage_IsDirty should have returned S_FALSE instead of 0x%x\n",
hr);
1942
1943 IPersistStorage_Release(pPS);
1944 IViewObject_Release(pViewObject);
1945 IOleCache2_Release(pOleCache);
1946 IOleCacheControl_Release(pOleCacheControl);
1947
1949
1950
1951 trace(
"Testing loaded data with CreateDataCache:\n");
1953
1956
1961
1962 hr = IViewObject_SetAdvise(pViewObject, DVASPECT_ICON, ADVF_PRIMEFIRST, &
AdviseSink);
1964
1965 hr = IPersistStorage_Load(pPS, pStorage);
1967
1968 hr = IPersistStorage_IsDirty(pPS);
1969 ok(
hr ==
S_FALSE,
"IPersistStorage_IsDirty should have returned S_FALSE instead of 0x%x\n",
hr);
1970
1971 fmtetc.cfFormat = 0;
1972 fmtetc.dwAspect = DVASPECT_ICON;
1973 fmtetc.lindex = -1;
1975 fmtetc.tymed = TYMED_MFPICT;
1976 hr = IOleCache2_Cache(pOleCache, &fmtetc, 0, &dwConnection);
1977 ok(
hr ==
CACHE_S_SAMECACHE,
"IOleCache_Cache with already loaded data format type should return CACHE_S_SAMECACHE instead of 0x%x\n",
hr);
1978
1981 rcBounds.
right = 100;
1984
1985 hr = IViewObject_Draw(pViewObject, DVASPECT_ICON, -1,
NULL,
NULL,
NULL,
hdcMem, &rcBounds,
NULL,
draw_continue, 0xdeadbeef);
1987
1988 hr = IViewObject_Draw(pViewObject, DVASPECT_CONTENT, -1,
NULL,
NULL,
NULL,
hdcMem, &rcBounds,
NULL,
draw_continue, 0xdeadbeef);
1989 ok(
hr ==
OLE_E_BLANK,
"IViewObject_Draw with uncached aspect should have returned OLE_E_BLANK instead of 0x%08x\n",
hr);
1990
1991
1992 hr = IOleCache2_DiscardCache(pOleCache, DISCARDCACHE_NOSAVE);
1994 hr = IViewObject_Draw(pViewObject, DVASPECT_ICON, -1,
NULL,
NULL,
NULL,
hdcMem, &rcBounds,
NULL,
draw_continue, 0xdeadbeef);
1996
1997
1998 hr = IPersistStorage_HandsOffStorage(pPS);
2000 hr = IViewObject_Draw(pViewObject, DVASPECT_ICON, -1,
NULL,
NULL,
NULL,
hdcMem, &rcBounds,
NULL,
draw_continue, 0xdeadbeef);
2002 hr = IOleCache2_DiscardCache(pOleCache, DISCARDCACHE_NOSAVE);
2004 hr = IViewObject_Draw(pViewObject, DVASPECT_ICON, -1,
NULL,
NULL,
NULL,
hdcMem, &rcBounds,
NULL,
draw_continue, 0xdeadbeef);
2005 ok(
hr ==
OLE_E_BLANK,
"IViewObject_Draw with uncached aspect should have returned OLE_E_BLANK instead of 0x%08x\n",
hr);
2006
2008
2011
2012 IPersistStorage_Release(pPS);
2013 IViewObject_Release(pViewObject);
2014 IOleCache2_Release(pOleCache);
2015
2017
2020
2022
2027
2029 fmtetc.dwAspect = DVASPECT_CONTENT;
2030 fmtetc.tymed = TYMED_MFPICT;
2031
2032 hr = IOleCache2_Cache(pOleCache, &fmtetc, 0, &dwConnection);
2034
2035 hr = IDataObject_GetData(pCacheDataObject, &fmtetc, &stgmedium);
2037
2039 fmtetc.dwAspect = DVASPECT_CONTENT;
2040 fmtetc.tymed = TYMED_HGLOBAL;
2041
2042 hr = IOleCache2_Cache(pOleCache, &fmtetc, 0, &dwConnection);
2044
2045 hr = IDataObject_GetData(pCacheDataObject, &fmtetc, &stgmedium);
2047
2049 hr = IOleCache2_Cache(pOleCache, &fmtetc, ADVF_PRIMEFIRST, &dwConnection);
2051
2052 hr = IDataObject_GetData(pCacheDataObject, &fmtetc, &stgmedium);
2054
2055 hr = IOleCacheControl_OnRun(pOleCacheControl, &
DataObject);
2057
2059 hr = IOleCache2_Cache(pOleCache, &fmtetc, 0, &dwConnection);
2061
2063 hr = IDataObject_GetData(pCacheDataObject, &fmtetc, &stgmedium);
2065
2067 hr = IDataObject_GetData(pCacheDataObject, &fmtetc, &stgmedium);
2070
2072 hr = IDataObject_GetData(pCacheDataObject, &fmtetc, &stgmedium);
2074
2075 IOleCacheControl_Release(pOleCacheControl);
2076 IDataObject_Release(pCacheDataObject);
2077 IOleCache2_Release(pOleCache);
2078
2080
2081 IStorage_Release(pStorage);
2082}
HRESULT WINAPI CreateDataCache(LPUNKNOWN pUnkOuter, REFCLSID rclsid, REFIID riid, LPVOID *ppvObj)
#define GetProcAddress(x, y)
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
UINT WINAPI GetSystemDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
void WINAPI ReleaseStgMedium(STGMEDIUM *pmedium)
static BOOL STDMETHODCALLTYPE draw_continue_false(ULONG_PTR param)
static IAdviseSink AdviseSink
#define CHECK_NO_EXTRA_METHODS()
static BOOL STDMETHODCALLTYPE draw_continue(ULONG_PTR param)
static IDataObject DataObject
HGLOBAL WINAPI OleMetafilePictFromIconAndLabel(HICON hIcon, LPOLESTR lpszLabel, LPOLESTR lpszSourceFile, UINT iIconIndex)
const GUID IID_IViewObject
const GUID IID_IOleCache2
const GUID IID_IOleCacheControl
#define CACHE_S_SAMECACHE
#define OLE_E_NOCONNECTION
#define CACHE_S_FORMATETC_NOTSUPPORTED
#define CACHE_E_NOCACHE_UPDATED
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
BOOL WINAPI DeleteDC(_In_ HDC)
HICON WINAPI LoadIconA(_In_opt_ HINSTANCE hInstance, _In_ LPCSTR lpIconName)