1568{
1578 FORMATETC fmtetc;
1579 STGMEDIUM stgmedium;
1587 static const WCHAR wszShell32[] = {
'\\',
's',
'h',
'e',
'l',
'l',
'3',
'2',
'.',
'd',
'l',
'l',0};
1588
1590 {
1591 { "AdviseSink_OnViewChange", 0 },
1592 { "AdviseSink_OnViewChange", 0 },
1593 { "draw_continue", 1 },
1594 { "draw_continue_false", 1 },
1595 { "DataObject_DAdvise", 0 },
1596 { "DataObject_DAdvise", 0 },
1597 { "DataObject_DUnadvise", 0 },
1598 { "DataObject_DUnadvise", 0 },
1600 };
1602 {
1603 { "AdviseSink_OnViewChange", 0 },
1604 { "draw_continue", 1 },
1605 { "draw_continue", 1 },
1606 { "draw_continue", 1 },
1608 };
1610 {
1611 { "DataObject_DAdvise", 0 },
1612 { "DataObject_DAdvise", 0 },
1613 { "DataObject_DAdvise", 0 },
1614 { "DataObject_DAdvise", 0 },
1615 { "DataObject_DUnadvise", 0 },
1616 { "DataObject_DUnadvise", 0 },
1617 { "DataObject_DUnadvise", 0 },
1618 { "DataObject_DUnadvise", 0 },
1620 };
1621
1623
1625
1627 fmtetc.dwAspect = DVASPECT_ICON;
1628 fmtetc.lindex = -1;
1630 fmtetc.tymed = TYMED_MFPICT;
1631
1634
1635
1636
1637
1640
1643
1648 ok(unk != (
IUnknown*)olecache,
"got %p, expected %p\n", olecache, unk);
1649 ok(unk != (
IUnknown*)pOleCache,
"got %p, expected %p\n", pOleCache, unk);
1650 IOleCache2_Release(pOleCache);
1651 IOleCache_Release(olecache);
1652 IUnknown_Release(unk);
1653
1662 ok(unk == (
IUnknown*)olecache,
"got %p, expected %p\n", olecache, unk);
1663 ok(unk == (
IUnknown*)pOleCache,
"got %p, expected %p\n", pOleCache, unk);
1664 ok(unk == unk2,
"got %p, expected %p\n", unk2, unk);
1665 IUnknown_Release(unk2);
1666 IOleCache2_Release(pOleCache);
1667 IOleCache_Release(olecache);
1668 IUnknown_Release(unk);
1669
1670
1671
1674
1681
1682 hr = IViewObject_SetAdvise(pViewObject, DVASPECT_ICON, ADVF_PRIMEFIRST, &
AdviseSink);
1684
1685 hr = IPersistStorage_InitNew(pPS, pStorage);
1687
1688 hr = IPersistStorage_IsDirty(pPS);
1690
1691 hr = IPersistStorage_GetClassID(pPS, &
clsid);
1694
1695 hr = IOleCache2_Uncache(pOleCache, 0xdeadbeef);
1696 ok(
hr ==
OLE_E_NOCONNECTION,
"IOleCache_Uncache with invalid value should return OLE_E_NOCONNECTION instead of 0x%lx\n",
hr);
1697
1698
1700 {
1701 hr = IOleCache2_Cache(pOleCache,
NULL, 0, &dwConnection);
1702 ok(
hr ==
E_INVALIDARG,
"IOleCache_Cache with NULL fmtetc should have returned E_INVALIDARG instead of 0x%08lx\n",
hr);
1703
1704 hr = IOleCache2_Cache(pOleCache,
NULL, 0,
NULL);
1705 ok(
hr ==
E_INVALIDARG,
"IOleCache_Cache with NULL pdwConnection should have returned E_INVALIDARG instead of 0x%08lx\n",
hr);
1706 }
1707 else
1708 {
1709 skip(
"tests with NULL parameters will crash on NT4 and below\n");
1710 }
1711
1712 for (fmtetc.cfFormat =
CF_TEXT; fmtetc.cfFormat <
CF_MAX; fmtetc.cfFormat++)
1713 {
1715 fmtetc.dwAspect = DVASPECT_THUMBNAIL;
1716 for (
i = 0;
i < 7;
i++)
1717 {
1718 fmtetc.tymed = 1 <<
i;
1719 hr = IOleCache2_Cache(pOleCache, &fmtetc, 0, &dwConnection);
1720 if ((fmtetc.cfFormat ==
CF_METAFILEPICT && fmtetc.tymed == TYMED_MFPICT) ||
1721 (fmtetc.cfFormat ==
CF_BITMAP && fmtetc.tymed == TYMED_GDI) ||
1722 (fmtetc.cfFormat ==
CF_DIB && fmtetc.tymed == TYMED_HGLOBAL) ||
1723 (fmtetc.cfFormat ==
CF_ENHMETAFILE && fmtetc.tymed == TYMED_ENHMF))
1724 ok(
hr ==
S_OK,
"IOleCache_Cache cfFormat = %d, tymed = %ld should have returned S_OK instead of 0x%08lx\n",
1725 fmtetc.cfFormat, fmtetc.tymed,
hr);
1726 else if (fmtetc.tymed == TYMED_HGLOBAL)
1729 "IOleCache_Cache cfFormat = %d, tymed = %ld should have returned CACHE_S_FORMATETC_NOTSUPPORTED instead of 0x%08lx\n",
1730 fmtetc.cfFormat, fmtetc.tymed,
hr);
1731 else
1732 ok(
hr ==
DV_E_TYMED,
"IOleCache_Cache cfFormat = %d, tymed = %ld should have returned DV_E_TYMED instead of 0x%08lx\n",
1733 fmtetc.cfFormat, fmtetc.tymed,
hr);
1735 {
1736 hr = IOleCache2_Uncache(pOleCache, dwConnection);
1738 }
1739 }
1740 }
1741
1743 fmtetc.dwAspect = DVASPECT_THUMBNAIL;
1744 fmtetc.tymed = TYMED_GDI;
1745 hr = IOleCache2_Cache(pOleCache, &fmtetc, 0, &dwConnection);
1747
1748 fmtetc.cfFormat = 0;
1749 fmtetc.dwAspect = DVASPECT_ICON;
1750 fmtetc.tymed = TYMED_MFPICT;
1751 hr = IOleCache2_Cache(pOleCache, &fmtetc, 0, &dwConnection);
1753
1755 memcpy(wszPath+
lstrlenW(wszPath), wszShell32,
sizeof(wszShell32));
1756
1758 stgmedium.tymed = TYMED_MFPICT;
1761 stgmedium.pUnkForRelease =
NULL;
1762
1763 fmtetc.dwAspect = DVASPECT_CONTENT;
1764 hr = IOleCache2_SetData(pOleCache, &fmtetc, &stgmedium,
FALSE);
1765 ok(
hr ==
OLE_E_BLANK,
"IOleCache_SetData for aspect not in cache should have return OLE_E_BLANK instead of 0x%08lx\n",
hr);
1766
1767 fmtetc.dwAspect = DVASPECT_ICON;
1768 hr = IOleCache2_SetData(pOleCache, &fmtetc, &stgmedium,
FALSE);
1771
1772 hr = IViewObject_Freeze(pViewObject, DVASPECT_ICON, -1,
NULL, &dwFreeze);
1775 hr = IViewObject_Freeze(pViewObject, DVASPECT_CONTENT, -1,
NULL, &dwFreeze);
1776 ok(
hr ==
OLE_E_BLANK,
"IViewObject_Freeze with uncached aspect should have returned OLE_E_BLANK instead of 0x%08lx\n",
hr);
1777 }
1778
1781 rcBounds.
right = 100;
1784
1785 hr = IViewObject_Draw(pViewObject, DVASPECT_ICON, -1,
NULL,
NULL,
NULL,
hdcMem, &rcBounds,
NULL,
draw_continue, 0xdeadbeef);
1787
1788 hr = IViewObject_Draw(pViewObject, DVASPECT_CONTENT, -1,
NULL,
NULL,
NULL,
hdcMem, &rcBounds,
NULL,
draw_continue, 0xdeadbeef);
1789 ok(
hr ==
OLE_E_BLANK,
"IViewObject_Draw with uncached aspect should have returned OLE_E_BLANK instead of 0x%08lx\n",
hr);
1790
1791
1792 hr = IViewObject_Draw(pViewObject, DVASPECT_ICON, -1,
NULL,
NULL,
NULL,
hdcMem, &rcBounds,
NULL,
NULL, 0xdeadbeef);
1794
1795
1796 hr = IViewObject_Draw(pViewObject, DVASPECT_ICON, -1,
NULL,
NULL,
NULL,
hdcMem, &rcBounds,
NULL,
draw_continue_false, 0xdeadbeef);
1799 "IViewObject_Draw with draw_continue_false returns 0x%08lx\n",
hr);
1800
1802
1803 hr = IOleCacheControl_OnRun(pOleCacheControl, &
DataObject);
1805
1806 hr = IPersistStorage_Save(pPS, pStorage,
TRUE);
1808
1809 hr = IPersistStorage_SaveCompleted(pPS,
NULL);
1811
1812 hr = IPersistStorage_IsDirty(pPS);
1813 ok(
hr ==
S_FALSE,
"IPersistStorage_IsDirty should have returned S_FALSE instead of 0x%lx\n",
hr);
1814
1815 IPersistStorage_Release(pPS);
1816 IViewObject_Release(pViewObject);
1817 IOleCache2_Release(pOleCache);
1818 IOleCacheControl_Release(pOleCacheControl);
1819
1821
1822
1824
1827
1832
1833 hr = IViewObject_SetAdvise(pViewObject, DVASPECT_ICON, ADVF_PRIMEFIRST, &
AdviseSink);
1835
1836 hr = IPersistStorage_Load(pPS, pStorage);
1838
1839 hr = IPersistStorage_IsDirty(pPS);
1840 ok(
hr ==
S_FALSE,
"IPersistStorage_IsDirty should have returned S_FALSE instead of 0x%lx\n",
hr);
1841
1842 fmtetc.cfFormat = 0;
1843 fmtetc.dwAspect = DVASPECT_ICON;
1844 fmtetc.lindex = -1;
1846 fmtetc.tymed = TYMED_MFPICT;
1847 hr = IOleCache2_Cache(pOleCache, &fmtetc, 0, &dwConnection);
1848 ok(
hr ==
CACHE_S_SAMECACHE,
"IOleCache_Cache with already loaded data format type should return CACHE_S_SAMECACHE instead of 0x%lx\n",
hr);
1849
1852 rcBounds.
right = 100;
1855
1856 hr = IViewObject_Draw(pViewObject, DVASPECT_ICON, -1,
NULL,
NULL,
NULL,
hdcMem, &rcBounds,
NULL,
draw_continue, 0xdeadbeef);
1858
1859 hr = IViewObject_Draw(pViewObject, DVASPECT_CONTENT, -1,
NULL,
NULL,
NULL,
hdcMem, &rcBounds,
NULL,
draw_continue, 0xdeadbeef);
1860 ok(
hr ==
OLE_E_BLANK,
"IViewObject_Draw with uncached aspect should have returned OLE_E_BLANK instead of 0x%08lx\n",
hr);
1861
1862
1863 hr = IOleCache2_DiscardCache(pOleCache, DISCARDCACHE_NOSAVE);
1865 hr = IViewObject_Draw(pViewObject, DVASPECT_ICON, -1,
NULL,
NULL,
NULL,
hdcMem, &rcBounds,
NULL,
draw_continue, 0xdeadbeef);
1867
1868
1869 hr = IPersistStorage_HandsOffStorage(pPS);
1871 hr = IViewObject_Draw(pViewObject, DVASPECT_ICON, -1,
NULL,
NULL,
NULL,
hdcMem, &rcBounds,
NULL,
draw_continue, 0xdeadbeef);
1873 hr = IOleCache2_DiscardCache(pOleCache, DISCARDCACHE_NOSAVE);
1875 hr = IViewObject_Draw(pViewObject, DVASPECT_ICON, -1,
NULL,
NULL,
NULL,
hdcMem, &rcBounds,
NULL,
draw_continue, 0xdeadbeef);
1876 ok(
hr ==
OLE_E_BLANK,
"IViewObject_Draw with uncached aspect should have returned OLE_E_BLANK instead of 0x%08lx\n",
hr);
1877
1879
1882
1883 IPersistStorage_Release(pPS);
1884 IViewObject_Release(pViewObject);
1885 IOleCache2_Release(pOleCache);
1886
1888
1891
1893
1898
1900 fmtetc.dwAspect = DVASPECT_CONTENT;
1901 fmtetc.tymed = TYMED_MFPICT;
1902
1903 hr = IOleCache2_Cache(pOleCache, &fmtetc, 0, &dwConnection);
1905
1906 hr = IDataObject_GetData(pCacheDataObject, &fmtetc, &stgmedium);
1908
1910 fmtetc.dwAspect = DVASPECT_CONTENT;
1911 fmtetc.tymed = TYMED_HGLOBAL;
1912
1913 hr = IOleCache2_Cache(pOleCache, &fmtetc, 0, &dwConnection);
1915
1916 hr = IDataObject_GetData(pCacheDataObject, &fmtetc, &stgmedium);
1918
1920 hr = IOleCache2_Cache(pOleCache, &fmtetc, ADVF_PRIMEFIRST, &dwConnection);
1922
1923 hr = IDataObject_GetData(pCacheDataObject, &fmtetc, &stgmedium);
1925
1926 hr = IOleCacheControl_OnRun(pOleCacheControl, &
DataObject);
1928
1930 hr = IOleCache2_Cache(pOleCache, &fmtetc, 0, &dwConnection);
1932
1934 hr = IDataObject_GetData(pCacheDataObject, &fmtetc, &stgmedium);
1936
1938 hr = IDataObject_GetData(pCacheDataObject, &fmtetc, &stgmedium);
1941
1943 hr = IDataObject_GetData(pCacheDataObject, &fmtetc, &stgmedium);
1945
1946 IOleCacheControl_Release(pOleCacheControl);
1947 IDataObject_Release(pCacheDataObject);
1948 IOleCache2_Release(pOleCache);
1949
1951
1952 IStorage_Release(pStorage);
1953}
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)