[PATCH 4/5] Add basic test structure for IXmlReader

Nikolay Sivov bunglehead at gmail.com
Mon Jan 18 15:05:53 CST 2010


---
 configure.ac                   |    1 +
 dlls/xmllite/Makefile.in       |    3 +-
 dlls/xmllite/reader.c          |   39 +++++++++++++++
 dlls/xmllite/tests/Makefile.in |   13 +++++
 dlls/xmllite/tests/reader.c    |  101 ++++++++++++++++++++++++++++++++++++++++
 dlls/xmllite/xmllite.spec      |    2 +-
 6 files changed, 157 insertions(+), 2 deletions(-)
 create mode 100644 dlls/xmllite/reader.c
 create mode 100644 dlls/xmllite/tests/Makefile.in
 create mode 100644 dlls/xmllite/tests/reader.c

diff --git a/configure.ac b/configure.ac
index 943938b..01cf3a7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2587,6 +2587,7 @@ WINE_CONFIG_MAKEFILE([dlls/xinput1_3/Makefile],[dlls/Makedll.rules],[dlls],[ALL_
 WINE_CONFIG_MAKEFILE([dlls/xinput1_3/tests/Makefile],[dlls/Maketest.rules],[dlls],[ALL_TEST_DIRS],[enable_tests])
 WINE_CONFIG_MAKEFILE([dlls/xinput9_1_0/Makefile],[dlls/Makedll.rules],[dlls],[ALL_DLL_DIRS])
 WINE_CONFIG_MAKEFILE([dlls/xmllite/Makefile],[dlls/Makedll.rules],[dlls],[ALL_DLL_DIRS])
+WINE_CONFIG_MAKEFILE([dlls/xmllite/tests/Makefile],[dlls/Maketest.rules],[dlls],[ALL_TEST_DIRS],[enable_tests])
 WINE_CONFIG_MAKEFILE([documentation/Makefile],[Make.rules],[],[ALL_TOP_DIRS])
 WINE_CONFIG_MAKEFILE([fonts/Makefile],[Make.rules],[],[ALL_TOP_DIRS])
 WINE_CONFIG_MAKEFILE([include/Makefile],[Make.rules],[],[ALL_TOP_DIRS])
diff --git a/dlls/xmllite/Makefile.in b/dlls/xmllite/Makefile.in
index 17d8dd1..4c9b502 100644
--- a/dlls/xmllite/Makefile.in
+++ b/dlls/xmllite/Makefile.in
@@ -6,7 +6,8 @@ MODULE    = xmllite.dll
 IMPORTS   = kernel32
 
 C_SRCS = \
-	xmllite_main.c
+	xmllite_main.c \
+	reader.c
 
 @MAKE_DLL_RULES@
 
diff --git a/dlls/xmllite/reader.c b/dlls/xmllite/reader.c
new file mode 100644
index 0000000..17571e7
--- /dev/null
+++ b/dlls/xmllite/reader.c
@@ -0,0 +1,39 @@
+/*
+ * IXmlReader implementation
+ *
+ * Copyright 2010 Nikolay Sivov
+ *
+ * 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
+
+#include <stdarg.h>
+#include "windef.h"
+#include "winbase.h"
+#include "initguid.h"
+#include "objbase.h"
+#include "xmllite.h"
+
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(xmllite);
+
+HRESULT WINAPI CreateXmlReader(REFIID riid, void **pObject, IMalloc *pMalloc)
+{
+    FIXME("(%s, %p, %p)\n", wine_dbgstr_guid(riid), pObject, pMalloc);
+    return E_NOTIMPL;
+}
+
diff --git a/dlls/xmllite/tests/Makefile.in b/dlls/xmllite/tests/Makefile.in
new file mode 100644
index 0000000..def5a57
--- /dev/null
+++ b/dlls/xmllite/tests/Makefile.in
@@ -0,0 +1,13 @@
+TOPSRCDIR = @top_srcdir@
+TOPOBJDIR = ../../..
+SRCDIR    = @srcdir@
+VPATH     = @srcdir@
+TESTDLL   = xmllite.dll
+IMPORTS   = kernel32 ole32
+
+CTESTS = \
+	xmlreader.c
+
+ at MAKE_TEST_RULES@
+
+ at DEPENDENCIES@  # everything below this line is overwritten by make depend
diff --git a/dlls/xmllite/tests/reader.c b/dlls/xmllite/tests/reader.c
new file mode 100644
index 0000000..12641a0
--- /dev/null
+++ b/dlls/xmllite/tests/reader.c
@@ -0,0 +1,101 @@
+/*
+ * XMLLite IXmlReader tests
+ *
+ * Copyright 2010 (C) Nikolay Sivov
+ *
+ * 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
+
+#include <stdarg.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "ole2.h"
+#include "xmllite.h"
+#include "initguid.h"
+#include "wine/test.h"
+
+DEFINE_GUID(IID_IXmlReader, 0x7279fc81, 0x709d, 0x4095, 0xb6, 0x3d, 0x69,
+                            0xfe, 0x4b, 0x0d, 0x90, 0x30);
+
+HRESULT WINAPI (*pCreateXmlReader)(REFIID riid, void **ppvObject, IMalloc *pMalloc);
+
+static BOOL init_pointers(void)
+{
+    /* don't free module here, it's to be unloaded on exit */
+    HMODULE mod = LoadLibraryA("xmllite.dll");
+
+    if (!mod)
+    {
+        win_skip("xmllite library not available\n");
+        return FALSE;
+    }
+
+    pCreateXmlReader = (void*)GetProcAddress(mod, "CreateXmlReader");
+    if (!pCreateXmlReader) return FALSE;
+
+    return TRUE;
+}
+
+static void test_reader_create(void)
+{
+    HRESULT hr;
+    IXmlReader *reader;
+    IMalloc *imalloc;
+
+    /* crashes native */
+    if (0)
+    {
+        hr = pCreateXmlReader(&IID_IXmlReader, NULL, NULL);
+        hr = pCreateXmlReader(NULL, (LPVOID*)&reader, NULL);
+    }
+
+    hr = pCreateXmlReader(&IID_IXmlReader, (LPVOID*)&reader, NULL);
+    todo_wine ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+    if (hr != S_OK)
+    {
+        skip("Failed to create IXmlReader instance\n");
+        return;
+    }
+
+    hr = CoGetMalloc(1, &imalloc);
+    ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+
+    hr = IMalloc_DidAlloc(imalloc, reader);
+    ok(hr != 1, "Expected 0 or -1, got %08x\n", hr);
+
+    IXmlReader_Release(reader);
+}
+
+START_TEST(reader)
+{
+    HRESULT r;
+
+    r = CoInitialize( NULL );
+    ok( r == S_OK, "failed to init com\n");
+
+    if (!init_pointers())
+    {
+       CoUninitialize();
+       return;
+    }
+
+    test_reader_create();
+
+    CoUninitialize();
+}
+
diff --git a/dlls/xmllite/xmllite.spec b/dlls/xmllite/xmllite.spec
index cf43637..9b5a84a 100644
--- a/dlls/xmllite/xmllite.spec
+++ b/dlls/xmllite/xmllite.spec
@@ -1,4 +1,4 @@
-@ stub CreateXmlReader
+@ stdcall CreateXmlReader(ptr ptr ptr)
 @ stub CreateXmlReaderInputWithEncodingCodePage
 @ stub CreateXmlReaderInputWithEncodingName
 @ stub CreateXmlWriter
-- 
1.5.6.5


--=-9ZpAnmst62PtRziMtHgz--




More information about the wine-patches mailing list