Add a few tests for IPropertySetStorage on the Internet Shortcut.

Andrew Bogott andrew at CodeWeavers.com
Wed Nov 10 23:55:48 CST 2010


---
 dlls/shdocvw/tests/intshcut.c |   58 +++++++++++++++++++++++++++++++++++++++++
 include/shlobj.h              |   15 ++++++++++
 2 files changed, 73 insertions(+), 0 deletions(-)

diff --git a/dlls/shdocvw/tests/intshcut.c b/dlls/shdocvw/tests/intshcut.c
index c0f5582..ec3970e 100644
--- a/dlls/shdocvw/tests/intshcut.c
+++ b/dlls/shdocvw/tests/intshcut.c
@@ -173,6 +173,63 @@ static BOOL check_ie(void)
     return TRUE;
 }
 
+static void test_ReadAndWriteProperties(void)
+{
+    HRESULT hr;
+    IUniformResourceLocatorA *urlA;
+    IPropertySetStorage *pPropSetStg;
+
+    hr = CoCreateInstance(&CLSID_InternetShortcut, NULL, CLSCTX_ALL, &IID_IUniformResourceLocatorA, (void**)&urlA);
+    if (hr == S_OK)
+    {
+        WCHAR iconPath[] = {'f','i','l','e',':','/','/','/','C',':','/','a','r','b','i','t','r','a','r','y','/','i','c','o','n','/','p','a','t','h',0};
+        int iconIndex = 7;
+        IPropertyStorage *pPropStgWrite;
+        IPropertyStorage *pPropStgRead;
+        PROPSPEC ps[2];
+        PROPVARIANT pv[2];
+        PROPVARIANT pvread[2];
+        ps[0].ulKind = PRSPEC_PROPID;
+        ps[0].propid = PID_IS_ICONFILE;
+        ps[1].ulKind = PRSPEC_PROPID;
+        ps[1].propid = PID_IS_ICONINDEX;
+        pv[0].vt = VT_LPWSTR;
+        pv[0].pwszVal = (void *) iconPath;
+        pv[1].vt = VT_I4;
+        pv[1].iVal = iconIndex;
+
+        hr = urlA->lpVtbl->QueryInterface(urlA, &IID_IPropertySetStorage, (void **) &pPropSetStg);
+        ok(hr == S_OK, "Unable to get an IPropertySetStorage, hr=0x%x\n", hr);
+
+        hr = IPropertySetStorage_Open(pPropSetStg, &FMTID_Intshcut, STGM_READWRITE | STGM_SHARE_EXCLUSIVE, &pPropStgWrite);
+        ok(hr == S_OK, "Unable to get an IPropertyStorage for writing, hr=0x%x\n", hr);
+
+        hr = IPropertyStorage_WriteMultiple(pPropStgWrite, 2, ps, pv, 0);
+        ok(hr == S_OK, "Unable to set properties, hr=0x%x\n", hr);
+
+        hr = IPropertyStorage_Commit(pPropStgWrite, STGC_DEFAULT);
+        ok(hr == S_OK, "Failed to commit properties, hr=0x%x\n", hr);
+
+        pPropStgWrite->lpVtbl->Release(pPropStgWrite);
+
+        hr = IPropertySetStorage_Open(pPropSetStg, &FMTID_Intshcut, STGM_READ | STGM_SHARE_EXCLUSIVE, &pPropStgRead);
+        ok(hr == S_OK, "Unable to get an IPropertyStorage for reading, hr=0x%x\n", hr);
+
+        hr = IPropertyStorage_ReadMultiple(pPropStgRead, 2, ps, pvread);
+        ok(hr == S_OK, "Unable to read properties, hr=0x%x\n", hr);
+
+        ok(pvread[1].iVal == iconIndex, "Read wrong icon index: %d\n", pvread[1].iVal);
+
+        ok(lstrcmpW(pvread[0].pwszVal, iconPath) == 0, "Wrong icon path read: %s\n",wine_dbgstr_w(pvread[0].pwszVal));
+
+        IPropertyStorage_Release(pPropStgRead);
+        IPropertySetStorage_Release(pPropSetStg);
+        urlA->lpVtbl->Release(urlA);
+    }
+    else
+        skip("could not create a CLSID_InternetShortcut for property tests, hr=0x%x\n", hr);
+}
+
 static void test_NullURLs(void)
 {
     HRESULT hr;
@@ -231,6 +288,7 @@ static void test_InternetShortcut(void)
         test_QueryInterface();
         test_NullURLs();
         test_SetURLFlags();
+        test_ReadAndWriteProperties();
     }
 }
 
diff --git a/include/shlobj.h b/include/shlobj.h
index f3aa3b6..5615d0b 100644
--- a/include/shlobj.h
+++ b/include/shlobj.h
@@ -1679,6 +1679,21 @@ HRESULT      WINAPI ILLoadFromStream(LPSTREAM,LPITEMIDLIST*);
 BOOL         WINAPI ILRemoveLastID(LPITEMIDLIST);
 HRESULT      WINAPI ILSaveToStream(LPSTREAM,LPCITEMIDLIST);
 
+/****************************************************************************
+ * Internet shortcut properties
+ */
+
+#define PID_IS_URL         2
+#define PID_IS_NAME        4
+#define PID_IS_WORKINGDIR  5
+#define PID_IS_HOTKEY      6
+#define PID_IS_SHOWCMD     7
+#define PID_IS_ICONINDEX   8
+#define PID_IS_ICONFILE    9
+#define PID_IS_WHATSNEW    10
+#define PID_IS_AUTHOR      11
+#define PID_IS_DESCRIPTION 12
+#define PID_IS_COMMENT     13
 
 #include <poppack.h>
 
-- 
1.6.5


--------------080407030709040905050708--



More information about the wine-patches mailing list