Robert Shearman : ole32: Add some more tests for failure cases of Co* functions and make builtin ole32 pass them .

Alexandre Julliard julliard at wine.codeweavers.com
Wed Aug 16 10:17:53 CDT 2006


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

Author: Robert Shearman <rob at codeweavers.com>
Date:   Wed Aug 16 12:29:17 2006 +0100

ole32: Add some more tests for failure cases of Co* functions and make builtin ole32 pass them.

---

 dlls/ole32/compobj.c       |   27 +++++++++++++++++++++------
 dlls/ole32/tests/compobj.c |   37 +++++++++++++++++++++++++++++++++++++
 dlls/ole32/tests/marshal.c |   17 -----------------
 3 files changed, 58 insertions(+), 23 deletions(-)

diff --git a/dlls/ole32/compobj.c b/dlls/ole32/compobj.c
index 0537b2c..314411d 100644
--- a/dlls/ole32/compobj.c
+++ b/dlls/ole32/compobj.c
@@ -915,6 +915,9 @@ HRESULT WINAPI CLSIDFromString(LPOLESTR 
 {
     HRESULT ret;
 
+    if (!id)
+        return E_INVALIDARG;
+
     ret = __CLSIDFromString(idstr, id);
     if(ret != S_OK) { /* It appears a ProgID is also valid */
         ret = CLSIDFromProgID(idstr, id);
@@ -1057,21 +1060,27 @@ HRESULT COM_OpenKeyForCLSID(REFCLSID cls
  *
  * PARAMS
  *  clsid        [I] Class ID, as found in registry.
- *  lplpszProgID [O] Associated ProgID.
+ *  ppszProgID [O] Associated ProgID.
  *
  * RETURNS
  *   S_OK
  *   E_OUTOFMEMORY
  *   REGDB_E_CLASSNOTREG if the given clsid has no associated ProgID
  */
-HRESULT WINAPI ProgIDFromCLSID(REFCLSID clsid, LPOLESTR *lplpszProgID)
+HRESULT WINAPI ProgIDFromCLSID(REFCLSID clsid, LPOLESTR *ppszProgID)
 {
     static const WCHAR wszProgID[] = {'P','r','o','g','I','D',0};
     HKEY     hkey;
     HRESULT  ret;
     LONG progidlen = 0;
 
-    *lplpszProgID = NULL;
+    if (!ppszProgID)
+    {
+        ERR("ppszProgId isn't optional\n");
+        return E_INVALIDARG;
+    }
+
+    *ppszProgID = NULL;
     ret = COM_OpenKeyForCLSID(clsid, wszProgID, KEY_READ, &hkey);
     if (FAILED(ret))
         return ret;
@@ -1081,10 +1090,10 @@ HRESULT WINAPI ProgIDFromCLSID(REFCLSID 
 
     if (ret == S_OK)
     {
-      *lplpszProgID = CoTaskMemAlloc(progidlen * sizeof(WCHAR));
-      if (*lplpszProgID)
+      *ppszProgID = CoTaskMemAlloc(progidlen * sizeof(WCHAR));
+      if (*ppszProgID)
       {
-        if (RegQueryValueW(hkey, NULL, *lplpszProgID, &progidlen))
+        if (RegQueryValueW(hkey, NULL, *ppszProgID, &progidlen))
           ret = REGDB_E_CLASSNOTREG;
       }
       else
@@ -1200,6 +1209,12 @@ HRESULT WINAPI CoGetPSClsid(REFIID riid,
         return CO_E_NOTINITIALIZED;
     }
 
+    if (!pclsid)
+    {
+        ERR("pclsid isn't optional\n");
+        return E_INVALIDARG;
+    }
+
     EnterCriticalSection(&apt->cs);
 
     LIST_FOR_EACH_ENTRY(registered_psclsid, &apt->psclsids, struct registered_psclsid, entry)
diff --git a/dlls/ole32/tests/compobj.c b/dlls/ole32/tests/compobj.c
index 6f2247d..326d9c6 100644
--- a/dlls/ole32/tests/compobj.c
+++ b/dlls/ole32/tests/compobj.c
@@ -73,6 +73,9 @@ static void test_ProgIDFromCLSID(void)
     hr = ProgIDFromCLSID(&CLSID_non_existent, &progid);
     ok(hr == REGDB_E_CLASSNOTREG, "ProgIDFromCLSID returned %08lx\n", hr);
     ok(progid == NULL, "ProgIDFromCLSID returns with progid %p\n", progid);
+
+    hr = ProgIDFromCLSID(&CLSID_CDeviceMoniker, NULL);
+    ok(hr == E_INVALIDARG, "ProgIDFromCLSID should return E_INVALIDARG instead of 0x%08lx\n", hr);
 }
 
 static void test_CLSIDFromProgID(void)
@@ -106,6 +109,10 @@ static void test_CLSIDFromString(void)
     HRESULT hr = CLSIDFromString((LPOLESTR)wszCLSID_CDeviceMoniker, &clsid);
     ok_ole_success(hr, "CLSIDFromString");
     ok(IsEqualCLSID(&clsid, &CLSID_CDeviceMoniker), "clsid wasn't equal to CLSID_CDeviceMoniker\n");
+
+    hr = CLSIDFromString(NULL, &clsid);
+    ok_ole_success(hr, "CLSIDFromString");
+    ok(IsEqualCLSID(&clsid, &CLSID_NULL), "clsid wasn't equal to CLSID_NULL\n");
 }
 
 static void test_CoCreateInstance(void)
@@ -418,6 +425,35 @@ static void test_CoRegisterPSClsid(void)
     CoUninitialize();
 }
 
+static void test_CoGetPSClsid(void)
+{
+    HRESULT hr;
+    CLSID clsid;
+
+    hr = CoGetPSClsid(&IID_IClassFactory, &clsid);
+    ok(hr == CO_E_NOTINITIALIZED,
+       "CoGetPSClsid should have returned CO_E_NOTINITIALIZED instead of 0x%08lx\n",
+       hr);
+
+    pCoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
+
+    hr = CoGetPSClsid(&IID_IClassFactory, &clsid);
+    ok_ole_success(hr, "CoGetPSClsid");
+
+    hr = CoGetPSClsid(&IID_IWineTest, &clsid);
+    ok(hr == REGDB_E_IIDNOTREG,
+       "CoGetPSClsid for random IID returned 0x%08lx instead of REGDB_E_IIDNOTREG\n",
+       hr);
+
+    hr = CoGetPSClsid(&IID_IClassFactory, NULL);
+    ok(hr == E_INVALIDARG,
+       "CoGetPSClsid for null clsid returned 0x%08lx instead of E_INVALIDARG\n",
+       hr);
+
+    CoUninitialize();
+}
+
+
 START_TEST(compobj)
 {
     HMODULE hOle32 = GetModuleHandle("ole32");
@@ -435,4 +471,5 @@ START_TEST(compobj)
     test_CoGetClassObject();
     test_CoRegisterMessageFilter();
     test_CoRegisterPSClsid();
+    test_CoGetPSClsid();
 }
diff --git a/dlls/ole32/tests/marshal.c b/dlls/ole32/tests/marshal.c
index fc7c205..13d3d1b 100644
--- a/dlls/ole32/tests/marshal.c
+++ b/dlls/ole32/tests/marshal.c
@@ -46,20 +46,6 @@ static const IID IID_IWineTest =
     {0xa1, 0xa2, 0x5d, 0x5a, 0x36, 0x54, 0xd3, 0xbd}
 }; /* 5201163f-8164-4fd0-a1a2-5d5a3654d3bd */
 
-static void test_CoGetPSClsid(void)
-{
-	HRESULT hr;
-	CLSID clsid;
-
-	hr = CoGetPSClsid(&IID_IClassFactory, &clsid);
-	ok_ole_success(hr, CoGetPSClsid);
-
-	hr = CoGetPSClsid(&IID_IWineTest, &clsid);
-	ok(hr == REGDB_E_IIDNOTREG,
-	   "CoGetPSClsid for random IID returned 0x%08lx instead of REGDB_E_IIDNOTREG\n",
-	   hr);
-}
-
 static void test_cocreateinstance_proxy(void)
 {
     IUnknown *pProxy;
@@ -2281,9 +2267,6 @@ START_TEST(marshal)
 
     /* FIXME: test CoCreateInstanceEx */
 
-    /* helper function tests */
-    test_CoGetPSClsid();
-
     /* lifecycle management and marshaling tests */
     test_no_marshaler();
     test_normal_marshal_and_release();




More information about the wine-cvs mailing list