From 551ab97f990e2c50ffc734c8022e706fd83373c8 Mon Sep 17 00:00:00 2001 From: Rafal Harabien Date: Mon, 19 Mar 2012 15:18:56 +0000 Subject: [PATCH] [XMLLITE_WINETEST] - Sync to Wine 1.3.37 svn path=/trunk/; revision=56190 --- rostests/winetests/xmllite/CMakeLists.txt | 11 +-- rostests/winetests/xmllite/reader.c | 34 ++++----- rostests/winetests/xmllite/testlist.c | 2 + rostests/winetests/xmllite/writer.c | 87 +++++++++++++++++++++++ 4 files changed, 113 insertions(+), 21 deletions(-) create mode 100644 rostests/winetests/xmllite/writer.c diff --git a/rostests/winetests/xmllite/CMakeLists.txt b/rostests/winetests/xmllite/CMakeLists.txt index b7ffe09da0f..ad6442cffc9 100644 --- a/rostests/winetests/xmllite/CMakeLists.txt +++ b/rostests/winetests/xmllite/CMakeLists.txt @@ -1,12 +1,13 @@ add_definitions(-D__ROS_LONG64__) -add_executable(xmllite_winetest reader.c testlist.c) -target_link_libraries(xmllite_winetest wine) +list(APPEND SOURCE + reader.c + writer.c + testlist.c) -if(MSVC) - target_link_libraries(xmllite_winetest uuid) -endif() +add_executable(xmllite_winetest ${SOURCE}) +target_link_libraries(xmllite_winetest wine uuid) set_module_type(xmllite_winetest win32cui) add_importlibs(xmllite_winetest xmllite ole32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/xmllite/reader.c b/rostests/winetests/xmllite/reader.c index 035fc4f4ac9..ec474531d8e 100644 --- a/rostests/winetests/xmllite/reader.c +++ b/rostests/winetests/xmllite/reader.c @@ -19,6 +19,7 @@ */ #define COBJMACROS +#define CONST_VTABLE #include #include @@ -32,8 +33,8 @@ DEFINE_GUID(IID_IXmlReaderInput, 0x0b3ccc9b, 0x9214, 0x428b, 0xa2, 0xae, 0xef, 0x3a, 0xa8, 0x71, 0xaf, 0xda); -HRESULT (WINAPI *pCreateXmlReader)(REFIID riid, void **ppvObject, IMalloc *pMalloc); -HRESULT (WINAPI *pCreateXmlReaderInputWithEncodingName)(IUnknown *stream, +static HRESULT WINAPI (*pCreateXmlReader)(REFIID riid, void **ppvObject, IMalloc *pMalloc); +static HRESULT WINAPI (*pCreateXmlReaderInputWithEncodingName)(IUnknown *stream, IMalloc *pMalloc, LPCWSTR encoding, BOOL hint, @@ -258,13 +259,13 @@ static void test_read_state_(IXmlReader *reader, XmlReadState expected, typedef struct _testinput { - const IUnknownVtbl *lpVtbl; + IUnknown IUnknown_iface; LONG ref; } testinput; static inline testinput *impl_from_IUnknown(IUnknown *iface) { - return (testinput *)((char*)iface - FIELD_OFFSET(testinput, lpVtbl)); + return CONTAINING_RECORD(iface, testinput, IUnknown_iface); } static HRESULT WINAPI testinput_QueryInterface(IUnknown *iface, REFIID riid, void** ppvObj) @@ -317,10 +318,10 @@ static HRESULT testinput_createinstance(void **ppObj) input = HeapAlloc(GetProcessHeap(), 0, sizeof (*input)); if(!input) return E_OUTOFMEMORY; - input->lpVtbl = &testinput_vtbl; + input->IUnknown_iface.lpVtbl = &testinput_vtbl; input->ref = 1; - *ppObj = &input->lpVtbl; + *ppObj = &input->IUnknown_iface; return S_OK; } @@ -353,8 +354,8 @@ static void test_reader_create(void) /* crashes native */ if (0) { - hr = pCreateXmlReader(&IID_IXmlReader, NULL, NULL); - hr = pCreateXmlReader(NULL, (LPVOID*)&reader, NULL); + pCreateXmlReader(&IID_IXmlReader, NULL, NULL); + pCreateXmlReader(NULL, (LPVOID*)&reader, NULL); } hr = pCreateXmlReader(&IID_IXmlReader, (LPVOID*)&reader, NULL); @@ -372,13 +373,14 @@ static void test_reader_create(void) hr = testinput_createinstance((void**)&input); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); - input_iids.count = 0; - hr = IXmlReader_SetInput(reader, input); - ok(hr == E_NOINTERFACE, "Expected E_NOINTERFACE, got %08x\n", hr); - ok_iids(&input_iids, setinput_full, setinput_full_old, FALSE); - - IUnknown_Release(input); - + if (hr == S_OK) + { + input_iids.count = 0; + hr = IXmlReader_SetInput(reader, input); + ok(hr == E_NOINTERFACE, "Expected E_NOINTERFACE, got %08x\n", hr); + ok_iids(&input_iids, setinput_full, setinput_full_old, FALSE); + IUnknown_Release(input); + } IXmlReader_Release(reader); } @@ -574,7 +576,7 @@ todo_wine { ok(type == XmlNodeType_XmlDeclaration, "Expected XmlNodeType_XmlDeclaration, got %s\n", type_to_str(type)); } - /* new version 1.2.x and 1.3.x properly update postition for */ + /* new version 1.2.x and 1.3.x properly update position for */ ok_pos(reader, 1, 3, -1, 55, TRUE); /* check attributes */ diff --git a/rostests/winetests/xmllite/testlist.c b/rostests/winetests/xmllite/testlist.c index eb154d6a012..33de94d717a 100644 --- a/rostests/winetests/xmllite/testlist.c +++ b/rostests/winetests/xmllite/testlist.c @@ -7,9 +7,11 @@ #include "wine/test.h" extern void func_reader(void); +extern void func_writer(void); const struct test winetest_testlist[] = { { "reader", func_reader }, + { "writer", func_writer }, { 0, 0 } }; diff --git a/rostests/winetests/xmllite/writer.c b/rostests/winetests/xmllite/writer.c new file mode 100644 index 00000000000..e98db7bea4a --- /dev/null +++ b/rostests/winetests/xmllite/writer.c @@ -0,0 +1,87 @@ +/* + * XMLLite IXmlWriter tests + * + * Copyright 2011 (C) Alistair Leslie-Hughes + * + * 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 +#include + +#include "windef.h" +#include "winbase.h" +#include "ole2.h" +#include "xmllite.h" +#include "wine/test.h" + +static HRESULT WINAPI (*pCreateXmlWriter)(REFIID riid, void **ppvObject, IMalloc *pMalloc); + +static void test_writer_create(void) +{ + HRESULT hr; + IXmlWriter *writer; + + /* crashes native */ + if (0) + { + pCreateXmlWriter(&IID_IXmlWriter, NULL, NULL); + pCreateXmlWriter(NULL, (LPVOID*)&writer, NULL); + } + + hr = pCreateXmlWriter(&IID_IXmlWriter, (LPVOID*)&writer, NULL); + ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); + if(hr == S_OK) + { + IXmlWriter_Release(writer); + } +} + +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; + } + +#define MAKEFUNC(f) if (!(p##f = (void*)GetProcAddress(mod, #f))) return FALSE; + MAKEFUNC(CreateXmlWriter); +#undef MAKEFUNC + + return TRUE; +} + +START_TEST(writer) +{ + HRESULT r; + + r = CoInitialize( NULL ); + ok( r == S_OK, "failed to init com\n"); + + if (!init_pointers()) + { + CoUninitialize(); + return; + } + + test_writer_create(); + + CoUninitialize(); +}