ole32: Add tests for error info functions.

Robert Shearman rob at codeweavers.com
Wed Jan 10 16:56:30 CST 2007


Return E_INVALIDARG if dwReserved is not set to zero for both 
GetErrorInfo and SetErrorInfo.
---
  dlls/ole32/errorinfo.c       |   14 +++++
  dlls/ole32/tests/Makefile.in |    1
  dlls/ole32/tests/errorinfo.c |  111 
++++++++++++++++++++++++++++++++++++++++++
  3 files changed, 125 insertions(+), 1 deletions(-)
-------------- next part --------------
diff --git a/dlls/ole32/errorinfo.c b/dlls/ole32/errorinfo.c
index b184003..8328726 100644
--- a/dlls/ole32/errorinfo.c
+++ b/dlls/ole32/errorinfo.c
@@ -488,6 +488,12 @@ HRESULT WINAPI GetErrorInfo(ULONG dwRese
 {
 	TRACE("(%d, %p, %p)\n", dwReserved, pperrinfo, COM_CurrentInfo()->errorinfo);
 
+	if (dwReserved)
+	{
+		ERR("dwReserved (0x%x) != 0\n", dwReserved);
+		return E_INVALIDARG;
+	}
+    
 	if(!pperrinfo) return E_INVALIDARG;
         
 	if (!COM_CurrentInfo()->errorinfo)
@@ -511,7 +517,13 @@ HRESULT WINAPI SetErrorInfo(ULONG dwRese
 	IErrorInfo * pei;
 
 	TRACE("(%d, %p)\n", dwReserved, perrinfo);
-	
+
+	if (dwReserved)
+	{
+        	ERR("dwReserved (0x%x) != 0\n", dwReserved);
+        	return E_INVALIDARG;
+	}
+
 	/* release old errorinfo */
 	pei = COM_CurrentInfo()->errorinfo;
 	if (pei) IErrorInfo_Release(pei);
diff --git a/dlls/ole32/tests/Makefile.in b/dlls/ole32/tests/Makefile.in
index f34aef3..ef01690 100644
--- a/dlls/ole32/tests/Makefile.in
+++ b/dlls/ole32/tests/Makefile.in
@@ -9,6 +9,7 @@ EXTRALIBS = -luuid
 CTESTS = \
 	clipboard.c \
 	compobj.c \
+	errorinfo.c \
 	hglobalstream.c \
 	marshal.c \
 	moniker.c \
diff --git a/dlls/ole32/tests/errorinfo.c b/dlls/ole32/tests/errorinfo.c
new file mode 100644
index 0000000..f306ee6
--- /dev/null
+++ b/dlls/ole32/tests/errorinfo.c
@@ -0,0 +1,111 @@
+/*
+ * Component Object Tests
+ *
+ * Copyright 2005 Robert Shearman
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#define COBJMACROS
+#define CONST_VTABLE
+
+#include <stdarg.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "objbase.h"
+
+#include "wine/test.h"
+
+#define ok_ole_success(hr, func) ok(hr == S_OK, func " failed with error 0x%08x\n", hr)
+
+static const CLSID CLSID_WineTest =
+{ /* 9474ba1a-258b-490b-bc13-516e9239ace0 */
+    0x9474ba1a,
+    0x258b,
+    0x490b,
+    {0xbc, 0x13, 0x51, 0x6e, 0x92, 0x39, 0xac, 0xe0}
+};
+
+static void test_error_info(void)
+{
+    HRESULT hr;
+    ICreateErrorInfo *pCreateErrorInfo;
+    IErrorInfo *pErrorInfo;
+    static WCHAR wszDescription[] = {'F','a','i','l','e','d',' ','S','p','r','o','c','k','e','t',0};
+    static WCHAR wszHelpFile[] = {'s','p','r','o','c','k','e','t','.','h','l','p',0};
+    static WCHAR wszSource[] = {'s','p','r','o','c','k','e','t',0};
+    
+    hr = CreateErrorInfo(&pCreateErrorInfo);
+    ok_ole_success(hr, "CreateErrorInfo");
+    
+    hr = ICreateErrorInfo_SetDescription(pCreateErrorInfo, NULL);
+    ok_ole_success(hr, "ICreateErrorInfo_SetDescription");
+    
+    hr = ICreateErrorInfo_SetDescription(pCreateErrorInfo, wszDescription);
+    ok_ole_success(hr, "ICreateErrorInfo_SetDescription");
+    
+    hr = ICreateErrorInfo_SetGUID(pCreateErrorInfo, &CLSID_WineTest);
+    ok_ole_success(hr, "ICreateErrorInfo_SetGUID");
+    
+    hr = ICreateErrorInfo_SetHelpContext(pCreateErrorInfo, 0xdeadbeef);
+    ok_ole_success(hr, "ICreateErrorInfo_SetHelpContext");
+    
+    hr = ICreateErrorInfo_SetHelpFile(pCreateErrorInfo, NULL);
+    ok_ole_success(hr, "ICreateErrorInfo_SetHelpFile");
+    
+    hr = ICreateErrorInfo_SetHelpFile(pCreateErrorInfo, wszHelpFile);
+    ok_ole_success(hr, "ICreateErrorInfo_SetHelpFile");
+    
+    hr = ICreateErrorInfo_SetSource(pCreateErrorInfo, NULL);
+    ok_ole_success(hr, "ICreateErrorInfo_SetSource");
+    
+    hr = ICreateErrorInfo_SetSource(pCreateErrorInfo, wszSource);
+    ok_ole_success(hr, "ICreateErrorInfo_SetSource");
+    
+    hr = ICreateErrorInfo_QueryInterface(pCreateErrorInfo, &IID_IErrorInfo, (void **)&pErrorInfo);
+    ok_ole_success(hr, "ICreateErrorInfo_QueryInterface");
+    
+    ICreateErrorInfo_Release(pCreateErrorInfo);
+    
+    hr = SetErrorInfo(0, pErrorInfo);
+    ok_ole_success(hr, "SetErrorInfo");
+    
+    IErrorInfo_Release(pErrorInfo);
+    pErrorInfo = NULL;
+    
+    hr = GetErrorInfo(0, &pErrorInfo);
+    ok_ole_success(hr, "GetErrorInfo");
+    
+    IErrorInfo_Release(pErrorInfo);
+    
+    hr = GetErrorInfo(0, &pErrorInfo);
+    ok(hr == S_FALSE, "GetErrorInfo should have returned S_FALSE instead of 0x%08x\n", hr);
+    ok(!pErrorInfo, "pErrorInfo should be set to NULL\n");
+
+    hr = SetErrorInfo(0, NULL);
+    ok_ole_success(hr, "SetErrorInfo");
+
+    hr = GetErrorInfo(0xdeadbeef, &pErrorInfo);
+    ok(hr == E_INVALIDARG, "GetErrorInfo should have returned E_INVALIDARG instead of 0x%08x\n", hr);
+
+    hr = SetErrorInfo(0xdeadbeef, NULL);
+    ok(hr == E_INVALIDARG, "SetErrorInfo should have returned E_INVALIDARG instead of 0x%08x\n", hr);
+}
+
+START_TEST(errorinfo)
+{
+    test_error_info();
+}


More information about the wine-patches mailing list