Rob Shearman : ole32: Add tests for invalid clipformat/ tymed combinations in IOleCache: Cache and for caching formats with a clipformat of 0.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Dec 4 07:17:16 CST 2006


Module: wine
Branch: master
Commit: e99168e1ba8f4010adca2d8a085210ebf0c36b0c
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=e99168e1ba8f4010adca2d8a085210ebf0c36b0c

Author: Rob Shearman <rob at codeweavers.com>
Date:   Sat Dec  2 18:16:58 2006 +0000

ole32: Add tests for invalid clipformat/tymed combinations in IOleCache:Cache and for caching formats with a clipformat of 0.

---

 dlls/ole32/tests/ole2.c |   46 +++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 43 insertions(+), 3 deletions(-)

diff --git a/dlls/ole32/tests/ole2.c b/dlls/ole32/tests/ole2.c
index e15942d..36341d5 100644
--- a/dlls/ole32/tests/ole2.c
+++ b/dlls/ole32/tests/ole2.c
@@ -1071,12 +1071,14 @@ static void test_data_cache(void)
         "draw_continue",
         "DataObject_GetData",
         "DataObject_GetData",
+        "DataObject_GetData",
         NULL
     };
 
     GetSystemDirectory(szSystemDir, sizeof(szSystemDir)/sizeof(szSystemDir[0]));
 
     expected_method_list = methods_cacheinitnew;
+
     fmtetc.cfFormat = CF_METAFILEPICT;
     fmtetc.dwAspect = DVASPECT_ICON;
     fmtetc.lindex = -1;
@@ -1111,24 +1113,62 @@ static void test_data_cache(void)
     ok_ole_success(hr, "IPersistStorage_GetClassID");
     ok(IsEqualCLSID(&clsid, &IID_NULL), "clsid should be blank\n");
 
+    hr = IOleCache_Uncache(pOleCache, 0xdeadbeef);
+    ok(hr == OLE_E_NOCONNECTION, "IOleCache_Uncache with invalid value should return OLE_E_NOCONNECTION instead of 0x%x\n", hr);
+
+    for (fmtetc.cfFormat = CF_TEXT; fmtetc.cfFormat < CF_MAX; fmtetc.cfFormat++)
+    {
+        int i;
+        fmtetc.dwAspect = DVASPECT_THUMBNAIL;
+        for (i = 0; i < 7; i++)
+        {
+            fmtetc.tymed = 1 << i;
+            hr = IOleCache_Cache(pOleCache, &fmtetc, 0, &dwConnection);
+            if ((fmtetc.cfFormat == CF_METAFILEPICT && fmtetc.tymed == TYMED_MFPICT) ||
+                (fmtetc.cfFormat == CF_BITMAP && fmtetc.tymed == TYMED_GDI) ||
+                (fmtetc.cfFormat == CF_DIB && fmtetc.tymed == TYMED_HGLOBAL) ||
+                (fmtetc.cfFormat == CF_ENHMETAFILE && fmtetc.tymed == TYMED_ENHMF))
+                ok(hr == S_OK, "IOleCache_Cache cfFormat = %d, tymed = %d should have returned S_OK instead of 0x%08x\n",
+                    fmtetc.cfFormat, fmtetc.tymed, hr);
+            else if (fmtetc.tymed == TYMED_HGLOBAL)
+                ok(hr == CACHE_S_FORMATETC_NOTSUPPORTED,
+                    "IOleCache_Cache cfFormat = %d, tymed = %d should have returned CACHE_S_FORMATETC_NOTSUPPORTED instead of 0x%08x\n",
+                    fmtetc.cfFormat, fmtetc.tymed, hr);
+            else
+                ok(hr == DV_E_TYMED, "IOleCache_Cache cfFormat = %d, tymed = %d should have returned DV_E_TYMED instead of 0x%08x\n",
+                    fmtetc.cfFormat, fmtetc.tymed, hr);
+            if (SUCCEEDED(hr))
+            {
+                hr = IOleCache_Uncache(pOleCache, dwConnection);
+                ok_ole_success(hr, "IOleCache_Uncache");
+            }
+        }
+    }
+
+    fmtetc.cfFormat = CF_BITMAP;
+    fmtetc.dwAspect = DVASPECT_THUMBNAIL;
+    fmtetc.tymed = TYMED_GDI;
     hr = IOleCache_Cache(pOleCache, &fmtetc, 0, &dwConnection);
     ok_ole_success(hr, "IOleCache_Cache");
 
-    fmtetc.dwAspect = DVASPECT_THUMBNAIL;
+    fmtetc.cfFormat = 0;
+    fmtetc.dwAspect = DVASPECT_ICON;
+    fmtetc.tymed = TYMED_MFPICT;
     hr = IOleCache_Cache(pOleCache, &fmtetc, 0, &dwConnection);
     ok_ole_success(hr, "IOleCache_Cache");
 
     MultiByteToWideChar(CP_ACP, 0, szSystemDir, -1, wszPath, sizeof(wszPath)/sizeof(wszPath[0]));
     memcpy(wszPath+lstrlenW(wszPath), wszShell32, sizeof(wszShell32));
 
-    fmtetc.dwAspect = DVASPECT_CONTENT;
     fmtetc.cfFormat = CF_METAFILEPICT;
     stgmedium.tymed = TYMED_MFPICT;
     stgmedium.hMetaFilePict = OleMetafilePictFromIconAndLabel(
         LoadIcon(NULL, MAKEINTRESOURCE(IDI_APPLICATION)), wszPath, wszPath, 0);
     stgmedium.pUnkForRelease = NULL;
+
+    fmtetc.dwAspect = DVASPECT_CONTENT;
     hr = IOleCache_SetData(pOleCache, &fmtetc, &stgmedium, FALSE);
-    ok(hr == OLE_E_BLANK, "IOleCache_SetData for aspect not in cache should have return OLE_E_BLANK instead of 0x%x\n", hr);
+    ok(hr == OLE_E_BLANK, "IOleCache_SetData for aspect not in cache should have return OLE_E_BLANK instead of 0x%08x\n", hr);
 
     fmtetc.dwAspect = DVASPECT_ICON;
     hr = IOleCache_SetData(pOleCache, &fmtetc, &stgmedium, FALSE);




More information about the wine-cvs mailing list