Author: akhaldi
Date: Sat Jul 2 12:57:07 2016
New Revision: 71727
URL:
http://svn.reactos.org/svn/reactos?rev=71727&view=rev
Log:
[XMLLITE_WINETEST] Sync with Wine Staging 1.9.11. CORE-11368
Modified:
trunk/rostests/winetests/xmllite/CMakeLists.txt
trunk/rostests/winetests/xmllite/reader.c
trunk/rostests/winetests/xmllite/writer.c
Modified: trunk/rostests/winetests/xmllite/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/xmllite/CMakeLi…
==============================================================================
--- trunk/rostests/winetests/xmllite/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/rostests/winetests/xmllite/CMakeLists.txt [iso-8859-1] Sat Jul 2 12:57:07 2016
@@ -8,5 +8,5 @@
add_executable(xmllite_winetest ${SOURCE})
set_module_type(xmllite_winetest win32cui)
-add_importlibs(xmllite_winetest ole32 msvcrt kernel32)
+add_importlibs(xmllite_winetest xmllite ole32 msvcrt kernel32)
add_cd_file(TARGET xmllite_winetest DESTINATION reactos/bin FOR all)
Modified: trunk/rostests/winetests/xmllite/reader.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/xmllite/reader.…
==============================================================================
--- trunk/rostests/winetests/xmllite/reader.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/xmllite/reader.c [iso-8859-1] Sat Jul 2 12:57:07 2016
@@ -38,14 +38,6 @@
DEFINE_GUID(IID_IXmlReaderInput, 0x0b3ccc9b, 0x9214, 0x428b, 0xa2, 0xae, 0xef, 0x3a,
0xa8, 0x71, 0xaf, 0xda);
-static HRESULT (WINAPI *pCreateXmlReader)(REFIID riid, void **ppvObject, IMalloc
*pMalloc);
-static HRESULT (WINAPI *pCreateXmlReaderInputWithEncodingName)(IUnknown *stream,
- IMalloc *pMalloc,
- LPCWSTR encoding,
- BOOL hint,
- LPCWSTR base_uri,
- IXmlReaderInput **ppInput);
-
static WCHAR *a2w(const char *str)
{
int len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
@@ -372,27 +364,51 @@
teststream_Write
};
-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(CreateXmlReader);
- MAKEFUNC(CreateXmlReaderInputWithEncodingName);
-#undef MAKEFUNC
-
- return TRUE;
-}
+static HRESULT WINAPI resolver_QI(IXmlResolver *iface, REFIID riid, void **obj)
+{
+ ok(0, "unexpected call, riid %s\n", wine_dbgstr_guid(riid));
+
+ if (IsEqualIID(riid, &IID_IXmlResolver) || IsEqualIID(riid, &IID_IUnknown))
+ {
+ *obj = iface;
+ IXmlResolver_AddRef(iface);
+ return S_OK;
+ }
+
+ *obj = NULL;
+ return E_NOINTERFACE;
+}
+
+static ULONG WINAPI resolver_AddRef(IXmlResolver *iface)
+{
+ return 2;
+}
+
+static ULONG WINAPI resolver_Release(IXmlResolver *iface)
+{
+ return 1;
+}
+
+static HRESULT WINAPI resolver_ResolveUri(IXmlResolver *iface, const WCHAR *base_uri,
+ const WCHAR *public_id, const WCHAR *system_id, IUnknown **input)
+{
+ ok(0, "unexpected call\n");
+ return E_NOTIMPL;
+}
+
+static const IXmlResolverVtbl resolvervtbl =
+{
+ resolver_QI,
+ resolver_AddRef,
+ resolver_Release,
+ resolver_ResolveUri
+};
+
+static IXmlResolver testresolver = { &resolvervtbl };
static void test_reader_create(void)
{
+ IXmlResolver *resolver;
HRESULT hr;
IXmlReader *reader;
IUnknown *input;
@@ -402,11 +418,11 @@
/* crashes native */
if (0)
{
- pCreateXmlReader(&IID_IXmlReader, NULL, NULL);
- pCreateXmlReader(NULL, (void**)&reader, NULL);
- }
-
- hr = pCreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
+ CreateXmlReader(&IID_IXmlReader, NULL, NULL);
+ CreateXmlReader(NULL, (void**)&reader, NULL);
+ }
+
+ hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
test_read_state(reader, XmlReadState_Closed, -1, FALSE);
@@ -415,6 +431,26 @@
hr = IXmlReader_GetNodeType(reader, &nodetype);
ok(hr == S_FALSE, "got %08x\n", hr);
ok(nodetype == XmlNodeType_None, "got %d\n", nodetype);
+
+ resolver = (void*)0xdeadbeef;
+ hr = IXmlReader_GetProperty(reader, XmlReaderProperty_XmlResolver,
(LONG_PTR*)&resolver);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+ ok(resolver == NULL, "got %p\n", resolver);
+
+ hr = IXmlReader_SetProperty(reader, XmlReaderProperty_XmlResolver, 0);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ hr = IXmlReader_SetProperty(reader, XmlReaderProperty_XmlResolver,
(LONG_PTR)&testresolver);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ resolver = NULL;
+ hr = IXmlReader_GetProperty(reader, XmlReaderProperty_XmlResolver,
(LONG_PTR*)&resolver);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+ ok(resolver == &testresolver, "got %p\n", resolver);
+ IXmlResolver_Release(resolver);
+
+ hr = IXmlReader_SetProperty(reader, XmlReaderProperty_XmlResolver, 0);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
dtd = 2;
hr = IXmlReader_GetProperty(reader, XmlReaderProperty_DtdProcessing,
(LONG_PTR*)&dtd);
@@ -459,9 +495,9 @@
HRESULT hr;
LONG ref;
- hr = pCreateXmlReaderInputWithEncodingName(NULL, NULL, NULL, FALSE, NULL, NULL);
+ hr = CreateXmlReaderInputWithEncodingName(NULL, NULL, NULL, FALSE, NULL, NULL);
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr);
- hr = pCreateXmlReaderInputWithEncodingName(NULL, NULL, NULL, FALSE, NULL,
&reader_input);
+ hr = CreateXmlReaderInputWithEncodingName(NULL, NULL, NULL, FALSE, NULL,
&reader_input);
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr);
hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
@@ -470,7 +506,7 @@
ref = IStream_AddRef(stream);
ok(ref == 2, "Expected 2, got %d\n", ref);
IStream_Release(stream);
- hr = pCreateXmlReaderInputWithEncodingName((IUnknown*)stream, NULL, NULL, FALSE,
NULL, &reader_input);
+ hr = CreateXmlReaderInputWithEncodingName((IUnknown*)stream, NULL, NULL, FALSE, NULL,
&reader_input);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
hr = IUnknown_QueryInterface(reader_input, &IID_IStream, (void**)&stream2);
@@ -485,7 +521,7 @@
IStream_Release(stream);
/* try ::SetInput() with valid IXmlReaderInput */
- hr = pCreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
+ hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
ref = IUnknown_AddRef(reader_input);
@@ -551,7 +587,7 @@
ref = IUnknown_AddRef(input);
ok(ref == 2, "Expected 2, got %d\n", ref);
IUnknown_Release(input);
- hr = pCreateXmlReaderInputWithEncodingName(input, NULL, NULL, FALSE, NULL,
&reader_input);
+ hr = CreateXmlReaderInputWithEncodingName(input, NULL, NULL, FALSE, NULL,
&reader_input);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
ok_iids(&input_iids, empty_seq, NULL, FALSE);
/* IXmlReaderInput stores stream interface as IUnknown */
@@ -559,7 +595,7 @@
ok(ref == 3, "Expected 3, got %d\n", ref);
IUnknown_Release(input);
- hr = pCreateXmlReader(&IID_IXmlReader, (LPVOID*)&reader, NULL);
+ hr = CreateXmlReader(&IID_IXmlReader, (LPVOID*)&reader, NULL);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
input_iids.count = 0;
@@ -590,7 +626,7 @@
ok_iids(&input_iids, setinput_readerinput, NULL, FALSE);
/* another reader */
- hr = pCreateXmlReader(&IID_IXmlReader, (LPVOID*)&reader2, NULL);
+ hr = CreateXmlReader(&IID_IXmlReader, (LPVOID*)&reader2, NULL);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
/* resolving from IXmlReaderInput to IStream/ISequentialStream is done at
@@ -613,7 +649,7 @@
XmlNodeType nodetype;
HRESULT hr;
- hr = pCreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
+ hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
/* invalid arguments */
@@ -653,7 +689,7 @@
BOOL ret;
const WCHAR *val;
- hr = pCreateXmlReader(&IID_IXmlReader, (LPVOID*)&reader, NULL);
+ hr = CreateXmlReader(&IID_IXmlReader, (LPVOID*)&reader, NULL);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
/* position methods with Null args */
@@ -874,7 +910,7 @@
IXmlReader *reader;
HRESULT hr;
- hr = pCreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
+ hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
ok(hr == S_OK, "S_OK, got %08x\n", hr);
while (test->xml)
@@ -956,7 +992,7 @@
IXmlReader *reader;
HRESULT hr;
- hr = pCreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
+ hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
ok(hr == S_OK, "S_OK, got %08x\n", hr);
while (test->xml)
@@ -1072,7 +1108,7 @@
HRESULT hr;
int i;
- hr = pCreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
+ hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
ok(hr == S_OK, "S_OK, got %08x\n", hr);
stream = create_stream_on_data(test->xml, strlen(test->xml)+1);
@@ -1121,7 +1157,7 @@
UINT len, count;
HRESULT hr;
- hr = pCreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
+ hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
ok(hr == S_OK, "S_OK, got %08x\n", hr);
hr = IXmlReader_SetProperty(reader, XmlReaderProperty_DtdProcessing,
DtdProcessing_Parse);
@@ -1214,7 +1250,7 @@
UINT depth;
HRESULT hr;
- hr = pCreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
+ hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
ok(hr == S_OK, "S_OK, got %08x\n", hr);
while (test->xml)
@@ -1345,7 +1381,7 @@
HRESULT hr;
int c;
- hr = pCreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
+ hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
ok(hr == S_OK, "S_OK, got 0x%08x\n", hr);
hr = IXmlReader_SetInput(reader, (IUnknown*)&teststream);
@@ -1383,7 +1419,7 @@
HRESULT hr;
UINT c;
- hr = pCreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
+ hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
ok(hr == S_OK, "S_OK, got %08x\n", hr);
stream = create_stream_on_data(testA, sizeof(testA));
@@ -1438,7 +1474,7 @@
IXmlReader *reader;
HRESULT hr;
- hr = pCreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
+ hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
ok(hr == S_OK, "S_OK, got %08x\n", hr);
while (test->xml)
@@ -1531,7 +1567,7 @@
IXmlReader *reader;
HRESULT hr;
- hr = pCreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
+ hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
ok(hr == S_OK, "S_OK, got %08x\n", hr);
while (test->xml)
@@ -1629,7 +1665,7 @@
IXmlReader *reader;
HRESULT hr;
- hr = pCreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
+ hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
ok(hr == S_OK, "S_OK, got %08x\n", hr);
while (test->xml)
@@ -1687,7 +1723,7 @@
IXmlReader *reader;
HRESULT hr;
- hr = pCreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
+ hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
ok(hr == S_OK, "S_OK, got %08x\n", hr);
while (test->xml)
@@ -1756,9 +1792,6 @@
START_TEST(reader)
{
- if (!init_pointers())
- return;
-
test_reader_create();
test_readerinput();
test_reader_state();
Modified: trunk/rostests/winetests/xmllite/writer.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/xmllite/writer.…
==============================================================================
--- trunk/rostests/winetests/xmllite/writer.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/xmllite/writer.c [iso-8859-1] Sat Jul 2 12:57:07 2016
@@ -39,15 +39,116 @@
#include <initguid.h>
DEFINE_GUID(IID_IXmlWriterOutput, 0xc1131708, 0x0f59, 0x477f, 0x93, 0x59, 0x7d, 0x33,
0x24, 0x51, 0xbc, 0x1a);
-static HRESULT (WINAPI *pCreateXmlWriter)(REFIID riid, void **ppvObject, IMalloc
*pMalloc);
-static HRESULT (WINAPI *pCreateXmlWriterOutputWithEncodingName)(IUnknown *stream,
- IMalloc *imalloc,
- LPCWSTR encoding_name,
- IXmlWriterOutput
**output);
-static HRESULT (WINAPI *pCreateXmlWriterOutputWithEncodingCodePage)(IUnknown *stream,
- IMalloc *imalloc,
- UINT codepage,
- IXmlWriterOutput
**output);
+static void check_output(IStream *stream, const char *expected, int line)
+{
+ HGLOBAL hglobal;
+ int len = strlen(expected), size;
+ char *ptr;
+ HRESULT hr;
+
+ hr = GetHGlobalFromStream(stream, &hglobal);
+ ok_(__FILE__, line)(hr == S_OK, "got 0x%08x\n", hr);
+
+ size = GlobalSize(hglobal);
+ ptr = GlobalLock(hglobal);
+ if (size != len)
+ {
+ ok_(__FILE__, line)(0, "data size mismatch, expected %u, got %u\n",
len, size);
+ ok_(__FILE__, line)(0, "got %s, expected %s\n", ptr, expected);
+ }
+ else
+ ok_(__FILE__, line)(!strncmp(ptr, expected, len), "got %s, expected
%s\n", ptr, expected);
+ GlobalUnlock(hglobal);
+}
+#define CHECK_OUTPUT(stream, expected) check_output(stream, expected, __LINE__)
+
+/* used to test all Write* methods for consistent error state */
+static void check_writer_state(IXmlWriter *writer, HRESULT exp_hr)
+{
+ static const WCHAR aW[] = {'a',0};
+ HRESULT hr;
+
+ /* FIXME: add WriteAttributes */
+
+ hr = IXmlWriter_WriteAttributeString(writer, NULL, aW, NULL, aW);
+ ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr);
+
+ hr = IXmlWriter_WriteCData(writer, aW);
+ ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr);
+
+ hr = IXmlWriter_WriteCharEntity(writer, aW[0]);
+ ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr);
+
+ hr = IXmlWriter_WriteChars(writer, aW, 1);
+ ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr);
+
+ hr = IXmlWriter_WriteComment(writer, aW);
+ ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr);
+
+ /* FIXME: add WriteDocType */
+
+ hr = IXmlWriter_WriteElementString(writer, NULL, aW, NULL, aW);
+ ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr);
+
+ hr = IXmlWriter_WriteEndDocument(writer);
+ ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr);
+
+ hr = IXmlWriter_WriteEndElement(writer);
+ ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr);
+
+ hr = IXmlWriter_WriteEntityRef(writer, aW);
+ ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr);
+
+ hr = IXmlWriter_WriteFullEndElement(writer);
+ ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr);
+
+ hr = IXmlWriter_WriteName(writer, aW);
+ ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr);
+
+ hr = IXmlWriter_WriteNmToken(writer, aW);
+ ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr);
+
+ /* FIXME: add WriteNode */
+ /* FIXME: add WriteNodeShallow */
+
+ hr = IXmlWriter_WriteProcessingInstruction(writer, aW, aW);
+ ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr);
+
+ hr = IXmlWriter_WriteQualifiedName(writer, aW, NULL);
+ ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr);
+
+ hr = IXmlWriter_WriteRaw(writer, aW);
+ ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr);
+
+ hr = IXmlWriter_WriteRawChars(writer, aW, 1);
+ ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr);
+
+ hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit);
+ ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr);
+
+ hr = IXmlWriter_WriteStartElement(writer, NULL, aW, NULL);
+ ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr);
+
+ hr = IXmlWriter_WriteString(writer, aW);
+ ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr);
+
+ /* FIXME: add WriteSurrogateCharEntity */
+ /* FIXME: add WriteWhitespace */
+}
+
+static IStream *writer_set_output(IXmlWriter *writer)
+{
+ IStream *stream;
+ HRESULT hr;
+
+ hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ hr = IXmlWriter_SetOutput(writer, (IUnknown*)stream);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ return stream;
+}
static HRESULT WINAPI testoutput_QueryInterface(IUnknown *iface, REFIID riid, void
**obj)
{
@@ -135,11 +236,11 @@
/* crashes native */
if (0)
{
- pCreateXmlWriter(&IID_IXmlWriter, NULL, NULL);
- pCreateXmlWriter(NULL, (void**)&writer, NULL);
+ CreateXmlWriter(&IID_IXmlWriter, NULL, NULL);
+ CreateXmlWriter(NULL, (void**)&writer, NULL);
}
- hr = pCreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL);
+ hr = CreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
/* check default properties values */
@@ -166,26 +267,6 @@
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);
- MAKEFUNC(CreateXmlWriterOutputWithEncodingName);
- MAKEFUNC(CreateXmlWriterOutputWithEncodingCodePage);
-#undef MAKEFUNC
-
- return TRUE;
-}
-
static void test_writeroutput(void)
{
static const WCHAR utf16W[] =
{'u','t','f','-','1','6',0};
@@ -194,11 +275,11 @@
HRESULT hr;
output = NULL;
- hr = pCreateXmlWriterOutputWithEncodingName(&testoutput, NULL, NULL,
&output);
+ hr = CreateXmlWriterOutputWithEncodingName(&testoutput, NULL, NULL,
&output);
ok(hr == S_OK, "got %08x\n", hr);
IUnknown_Release(output);
- hr = pCreateXmlWriterOutputWithEncodingName(&testoutput, NULL, utf16W,
&output);
+ hr = CreateXmlWriterOutputWithEncodingName(&testoutput, NULL, utf16W,
&output);
ok(hr == S_OK, "got %08x\n", hr);
unk = NULL;
hr = IUnknown_QueryInterface(output, &IID_IXmlWriterOutput, (void**)&unk);
@@ -208,11 +289,11 @@
IUnknown_Release(output);
output = NULL;
- hr = pCreateXmlWriterOutputWithEncodingCodePage(&testoutput, NULL, ~0u,
&output);
+ hr = CreateXmlWriterOutputWithEncodingCodePage(&testoutput, NULL, ~0u,
&output);
ok(hr == S_OK, "got %08x\n", hr);
IUnknown_Release(output);
- hr = pCreateXmlWriterOutputWithEncodingCodePage(&testoutput, NULL, CP_UTF8,
&output);
+ hr = CreateXmlWriterOutputWithEncodingCodePage(&testoutput, NULL, CP_UTF8,
&output);
ok(hr == S_OK, "got %08x\n", hr);
unk = NULL;
hr = IUnknown_QueryInterface(output, &IID_IXmlWriterOutput, (void**)&unk);
@@ -229,12 +310,10 @@
static const WCHAR versionW[] =
{'v','e','r','s','i','o','n','=','"','1','.','0','"',0};
static const WCHAR xmlW[] = {'x','m','l',0};
IXmlWriter *writer;
- HGLOBAL hglobal;
IStream *stream;
HRESULT hr;
- char *ptr;
-
- hr = pCreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL);
+
+ hr = CreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
/* output not set */
@@ -247,11 +326,7 @@
hr = IXmlWriter_Flush(writer);
ok(hr == S_OK, "got 0x%08x\n", hr);
- hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
- ok(hr == S_OK, "got 0x%08x\n", hr);
-
- hr = IXmlWriter_SetOutput(writer, (IUnknown*)stream);
- ok(hr == S_OK, "got 0x%08x\n", hr);
+ stream = writer_set_output(writer);
/* nothing written yet */
hr = IXmlWriter_Flush(writer);
@@ -263,12 +338,7 @@
hr = IXmlWriter_Flush(writer);
ok(hr == S_OK, "got 0x%08x\n", hr);
- hr = GetHGlobalFromStream(stream, &hglobal);
- ok(hr == S_OK, "got 0x%08x\n", hr);
-
- ptr = GlobalLock(hglobal);
- ok(!strncmp(ptr, fullprolog, strlen(fullprolog)), "got %s, expected %s\n",
ptr, fullprolog);
- GlobalUnlock(hglobal);
+ CHECK_OUTPUT(stream, fullprolog);
/* one more time */
hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Yes);
@@ -276,11 +346,7 @@
IStream_Release(stream);
/* now add PI manually, and try to start a document */
- hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
- ok(hr == S_OK, "got 0x%08x\n", hr);
-
- hr = IXmlWriter_SetOutput(writer, (IUnknown*)stream);
- ok(hr == S_OK, "got 0x%08x\n", hr);
+ stream = writer_set_output(writer);
hr = IXmlWriter_WriteProcessingInstruction(writer, xmlW, versionW);
ok(hr == S_OK, "got 0x%08x\n", hr);
@@ -298,12 +364,7 @@
hr = IXmlWriter_Flush(writer);
ok(hr == S_OK, "got 0x%08x\n", hr);
- hr = GetHGlobalFromStream(stream, &hglobal);
- ok(hr == S_OK, "got 0x%08x\n", hr);
-
- ptr = GlobalLock(hglobal);
- ok(!strncmp(ptr, prologversion, strlen(prologversion)), "got %s\n", ptr);
- GlobalUnlock(hglobal);
+ CHECK_OUTPUT(stream, prologversion);
IStream_Release(stream);
IXmlWriter_Release(writer);
@@ -314,7 +375,7 @@
IXmlWriter *writer;
HRESULT hr;
- hr = pCreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL);
+ hr = CreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
hr = IXmlWriter_SetOutput(writer, (IUnknown*)&teststream);
@@ -350,14 +411,10 @@
HRESULT hr;
char *ptr;
- hr = pCreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL);
- ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
-
- hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
- ok(hr == S_OK, "got 0x%08x\n", hr);
-
- hr = IXmlWriter_SetOutput(writer, (IUnknown*)stream);
- ok(hr == S_OK, "got 0x%08x\n", hr);
+ hr = CreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL);
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+
+ stream = writer_set_output(writer);
hr = IXmlWriter_SetProperty(writer, XmlWriterProperty_OmitXmlDeclaration, TRUE);
ok(hr == S_OK, "got 0x%08x\n", hr);
@@ -382,11 +439,7 @@
IStream_Release(stream);
/* now add PI manually, and try to start a document */
- hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
- ok(hr == S_OK, "got 0x%08x\n", hr);
-
- hr = IXmlWriter_SetOutput(writer, (IUnknown*)stream);
- ok(hr == S_OK, "got 0x%08x\n", hr);
+ stream = writer_set_output(writer);
hr = IXmlWriter_WriteProcessingInstruction(writer, xmlW, versionW);
ok(hr == S_OK, "got 0x%08x\n", hr);
@@ -394,32 +447,23 @@
hr = IXmlWriter_Flush(writer);
ok(hr == S_OK, "got 0x%08x\n", hr);
- hr = GetHGlobalFromStream(stream, &hglobal);
- ok(hr == S_OK, "got 0x%08x\n", hr);
-
- ptr = GlobalLock(hglobal);
- ok(!strncmp(ptr, prologversion, strlen(prologversion)), "got %s\n", ptr);
- GlobalUnlock(hglobal);
-
- hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Yes);
- ok(hr == S_OK, "got 0x%08x\n", hr);
-
- hr = IXmlWriter_Flush(writer);
- ok(hr == S_OK, "got 0x%08x\n", hr);
-
- ptr = GlobalLock(hglobal);
- ok(!strncmp(ptr, prologversion, strlen(prologversion)), "got %s\n", ptr);
- GlobalUnlock(hglobal);
-
- hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Yes);
- ok(hr == WR_E_INVALIDACTION, "got 0x%08x\n", hr);
-
- hr = IXmlWriter_Flush(writer);
- ok(hr == S_OK, "got 0x%08x\n", hr);
-
- ptr = GlobalLock(hglobal);
- ok(!strncmp(ptr, prologversion, strlen(prologversion)), "got %s\n", ptr);
- GlobalUnlock(hglobal);
+ CHECK_OUTPUT(stream, prologversion);
+
+ hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Yes);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ hr = IXmlWriter_Flush(writer);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ CHECK_OUTPUT(stream, prologversion);
+
+ hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Yes);
+ ok(hr == WR_E_INVALIDACTION, "got 0x%08x\n", hr);
+
+ hr = IXmlWriter_Flush(writer);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ CHECK_OUTPUT(stream, prologversion);
/* another attempt to add 'xml' PI */
hr = IXmlWriter_WriteProcessingInstruction(writer, xmlW, versionW);
@@ -448,10 +492,10 @@
hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
ok(hr == S_OK, "got 0x%08x\n", hr);
- hr = pCreateXmlWriterOutputWithEncodingName((IUnknown*)stream, NULL, utf16W,
&output);
+ hr = CreateXmlWriterOutputWithEncodingName((IUnknown*)stream, NULL, utf16W,
&output);
ok(hr == S_OK, "got %08x\n", hr);
- hr = pCreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL);
+ hr = CreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
hr = IXmlWriter_SetProperty(writer, XmlWriterProperty_OmitXmlDeclaration, TRUE);
@@ -481,7 +525,7 @@
hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
ok(hr == S_OK, "got 0x%08x\n", hr);
- hr = pCreateXmlWriterOutputWithEncodingName((IUnknown*)stream, NULL, utf16W,
&output);
+ hr = CreateXmlWriterOutputWithEncodingName((IUnknown*)stream, NULL, utf16W,
&output);
ok(hr == S_OK, "got %08x\n", hr);
hr = IXmlWriter_SetOutput(writer, output);
@@ -507,7 +551,7 @@
hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
ok(hr == S_OK, "got 0x%08x\n", hr);
- hr = pCreateXmlWriterOutputWithEncodingName((IUnknown*)stream, NULL, utf16W,
&output);
+ hr = CreateXmlWriterOutputWithEncodingName((IUnknown*)stream, NULL, utf16W,
&output);
ok(hr == S_OK, "got %08x\n", hr);
hr = IXmlWriter_SetOutput(writer, output);
@@ -533,7 +577,7 @@
hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
ok(hr == S_OK, "got 0x%08x\n", hr);
- hr = pCreateXmlWriterOutputWithEncodingName((IUnknown*)stream, NULL, utf16W,
&output);
+ hr = CreateXmlWriterOutputWithEncodingName((IUnknown*)stream, NULL, utf16W,
&output);
ok(hr == S_OK, "got %08x\n", hr);
hr = IXmlWriter_SetOutput(writer, output);
@@ -564,211 +608,416 @@
static const char *str = "<a><b>value</b>";
static const WCHAR aW[] = {'a',0};
static const WCHAR bW[] = {'b',0};
- char *ptr;
+ IXmlWriter *writer;
+ IStream *stream;
+ HRESULT hr;
+
+ hr = CreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL);
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+
+ hr = IXmlWriter_WriteStartElement(writer, NULL, aW, NULL);
+ ok(hr == E_UNEXPECTED, "got 0x%08x\n", hr);
+
+ stream = writer_set_output(writer);
+
+ hr = IXmlWriter_WriteStartElement(writer, aW, NULL, NULL);
+ ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
+
+ hr = IXmlWriter_WriteStartElement(writer, NULL, NULL, NULL);
+ ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
+
+ hr = IXmlWriter_WriteStartElement(writer, NULL, NULL, aW);
+ ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
+
+ hr = IXmlWriter_WriteStartElement(writer, NULL, aW, NULL);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Yes);
+ ok(hr == WR_E_INVALIDACTION, "got 0x%08x\n", hr);
+
+ hr = IXmlWriter_Flush(writer);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ CHECK_OUTPUT(stream, "<a");
+
+ hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Yes);
+ ok(hr == WR_E_INVALIDACTION, "got 0x%08x\n", hr);
+
+ hr = IXmlWriter_WriteStartElement(writer, NULL, NULL, NULL);
+ ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
+
+ hr = IXmlWriter_WriteProcessingInstruction(writer, aW, aW);
+ ok(hr == WR_E_INVALIDACTION, "got 0x%08x\n", hr);
+
+ IStream_Release(stream);
+ IXmlWriter_Release(writer);
+
+ /* WriteElementString */
+ hr = CreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL);
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+
+ hr = IXmlWriter_WriteElementString(writer, NULL, bW, NULL, valueW);
+ ok(hr == E_UNEXPECTED, "got 0x%08x\n", hr);
+
+ stream = writer_set_output(writer);
+
+ hr = IXmlWriter_WriteStartElement(writer, NULL, aW, NULL);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ hr = IXmlWriter_WriteElementString(writer, NULL, bW, NULL, valueW);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ hr = IXmlWriter_Flush(writer);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ CHECK_OUTPUT(stream, str);
+
+ IStream_Release(stream);
+ IXmlWriter_Release(writer);
+}
+
+static void test_writeendelement(void)
+{
+ static const WCHAR aW[] = {'a',0};
+ static const WCHAR bW[] = {'b',0};
+ IXmlWriter *writer;
+ IStream *stream;
+ HRESULT hr;
+
+ hr = CreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL);
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+
+ stream = writer_set_output(writer);
+
+ hr = IXmlWriter_WriteStartElement(writer, NULL, aW, NULL);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ hr = IXmlWriter_WriteStartElement(writer, NULL, bW, NULL);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ hr = IXmlWriter_WriteEndElement(writer);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ hr = IXmlWriter_WriteEndElement(writer);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ hr = IXmlWriter_Flush(writer);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ CHECK_OUTPUT(stream, "<a><b /></a>");
+
+ IXmlWriter_Release(writer);
+ IStream_Release(stream);
+}
+
+static void test_writeenddocument(void)
+{
+ static const WCHAR aW[] = {'a',0};
+ static const WCHAR bW[] = {'b',0};
IXmlWriter *writer;
IStream *stream;
HGLOBAL hglobal;
HRESULT hr;
-
- hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
- ok(hr == S_OK, "got 0x%08x\n", hr);
-
- hr = pCreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL);
- ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+ char *ptr;
+
+ hr = CreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL);
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+
+ hr = IXmlWriter_WriteEndDocument(writer);
+ ok(hr == E_UNEXPECTED, "got 0x%08x\n", hr);
+
+ stream = writer_set_output(writer);
+
+ /* WriteEndDocument resets it to initial state */
+ hr = IXmlWriter_WriteEndDocument(writer);
+ ok(hr == WR_E_INVALIDACTION, "got 0x%08x\n", hr);
+
+ hr = IXmlWriter_WriteEndDocument(writer);
+ ok(hr == WR_E_INVALIDACTION, "got 0x%08x\n", hr);
+
+ hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit);
+ ok(hr == WR_E_INVALIDACTION, "got 0x%08x\n", hr);
hr = IXmlWriter_WriteStartElement(writer, NULL, aW, NULL);
- ok(hr == E_UNEXPECTED, "got 0x%08x\n", hr);
+ ok(hr == WR_E_INVALIDACTION, "got 0x%08x\n", hr);
hr = IXmlWriter_SetOutput(writer, (IUnknown*)stream);
ok(hr == S_OK, "got 0x%08x\n", hr);
- hr = IXmlWriter_WriteStartElement(writer, aW, NULL, NULL);
- ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
-
- hr = IXmlWriter_WriteStartElement(writer, NULL, NULL, NULL);
- ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
-
- hr = IXmlWriter_WriteStartElement(writer, NULL, NULL, aW);
- ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
-
hr = IXmlWriter_WriteStartElement(writer, NULL, aW, NULL);
ok(hr == S_OK, "got 0x%08x\n", hr);
+ hr = IXmlWriter_WriteStartElement(writer, NULL, bW, NULL);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ hr = IXmlWriter_WriteEndDocument(writer);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
hr = GetHGlobalFromStream(stream, &hglobal);
ok(hr == S_OK, "got 0x%08x\n", hr);
- hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Yes);
- ok(hr == WR_E_INVALIDACTION, "got 0x%08x\n", hr);
-
- hr = IXmlWriter_Flush(writer);
- ok(hr == S_OK, "got 0x%08x\n", hr);
-
ptr = GlobalLock(hglobal);
- ok(!strncmp(ptr, "<a", 2), "got %s\n", ptr);
- GlobalUnlock(hglobal);
-
- hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Yes);
- ok(hr == WR_E_INVALIDACTION, "got 0x%08x\n", hr);
-
- hr = IXmlWriter_WriteStartElement(writer, NULL, NULL, NULL);
- ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
-
- hr = IXmlWriter_WriteProcessingInstruction(writer, aW, aW);
- ok(hr == WR_E_INVALIDACTION, "got 0x%08x\n", hr);
-
- IStream_Release(stream);
- IXmlWriter_Release(writer);
-
- /* WriteElementString */
- hr = pCreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL);
- ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
-
- hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
- ok(hr == S_OK, "got 0x%08x\n", hr);
-
- hr = IXmlWriter_WriteElementString(writer, NULL, bW, NULL, valueW);
- ok(hr == E_UNEXPECTED, "got 0x%08x\n", hr);
-
- hr = IXmlWriter_SetOutput(writer, (IUnknown*)stream);
- ok(hr == S_OK, "got 0x%08x\n", hr);
-
- hr = IXmlWriter_WriteStartElement(writer, NULL, aW, NULL);
- ok(hr == S_OK, "got 0x%08x\n", hr);
-
- hr = IXmlWriter_WriteElementString(writer, NULL, bW, NULL, valueW);
- ok(hr == S_OK, "got 0x%08x\n", hr);
-
- hr = IXmlWriter_Flush(writer);
- ok(hr == S_OK, "got 0x%08x\n", hr);
-
- hr = GetHGlobalFromStream(stream, &hglobal);
- ok(hr == S_OK, "got 0x%08x\n", hr);
-
- ptr = GlobalLock(hglobal);
- ok(!strncmp(ptr, str, strlen(str)), "got %s\n", ptr);
- GlobalUnlock(hglobal);
-
- IStream_Release(stream);
- IXmlWriter_Release(writer);
-}
-
-static void test_writeendelement(void)
-{
+ ok(ptr == NULL, "got %p\n", ptr);
+
+ /* we still need to flush manually, WriteEndDocument doesn't do that */
+ hr = IXmlWriter_Flush(writer);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ CHECK_OUTPUT(stream, "<a><b /></a>");
+
+ IXmlWriter_Release(writer);
+ IStream_Release(stream);
+}
+
+static void test_WriteComment(void)
+{
+ static const WCHAR closeW[] = {'-','-','>',0};
static const WCHAR aW[] = {'a',0};
static const WCHAR bW[] = {'b',0};
- char *ptr;
IXmlWriter *writer;
IStream *stream;
- HGLOBAL hglobal;
- HRESULT hr;
-
- hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
- ok(hr == S_OK, "got 0x%08x\n", hr);
-
- hr = pCreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL);
- ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
-
- hr = IXmlWriter_SetOutput(writer, (IUnknown*)stream);
- ok(hr == S_OK, "got 0x%08x\n", hr);
-
- hr = IXmlWriter_WriteStartElement(writer, NULL, aW, NULL);
+ HRESULT hr;
+
+ hr = CreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL);
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+
+ hr = IXmlWriter_SetProperty(writer, XmlWriterProperty_OmitXmlDeclaration, TRUE);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ hr = IXmlWriter_WriteComment(writer, aW);
+ ok(hr == E_UNEXPECTED, "got 0x%08x\n", hr);
+
+ stream = writer_set_output(writer);
+
+ hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ hr = IXmlWriter_WriteComment(writer, aW);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IXmlWriter_WriteStartElement(writer, NULL, bW, NULL);
ok(hr == S_OK, "got 0x%08x\n", hr);
- hr = IXmlWriter_WriteEndElement(writer);
- ok(hr == S_OK, "got 0x%08x\n", hr);
-
- hr = IXmlWriter_WriteEndElement(writer);
- ok(hr == S_OK, "got 0x%08x\n", hr);
-
- hr = GetHGlobalFromStream(stream, &hglobal);
- ok(hr == S_OK, "got 0x%08x\n", hr);
-
- hr = IXmlWriter_Flush(writer);
- ok(hr == S_OK, "got 0x%08x\n", hr);
-
- ptr = GlobalLock(hglobal);
- ok(!strncmp(ptr, "<a><b /></a>", 12), "got
%s\n", ptr);
- GlobalUnlock(hglobal);
-
- IXmlWriter_Release(writer);
- IStream_Release(stream);
-}
-
-static void test_writeenddocument(void)
-{
+ hr = IXmlWriter_WriteComment(writer, aW);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ hr = IXmlWriter_WriteComment(writer, NULL);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ hr = IXmlWriter_WriteComment(writer, closeW);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ hr = IXmlWriter_Flush(writer);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ CHECK_OUTPUT(stream, "<!--a--><b><!--a--><!----><!---
->-->");
+
+ IXmlWriter_Release(writer);
+ IStream_Release(stream);
+}
+
+static void test_WriteCData(void)
+{
+ static const WCHAR closeW[] = {']',']','>',0};
+ static const WCHAR close2W[] =
{'a',']',']','>','b',0};
static const WCHAR aW[] = {'a',0};
static const WCHAR bW[] = {'b',0};
IXmlWriter *writer;
IStream *stream;
- HGLOBAL hglobal;
- HRESULT hr;
- char *ptr;
-
- hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
- ok(hr == S_OK, "got 0x%08x\n", hr);
-
- hr = pCreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL);
- ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+ HRESULT hr;
+
+ hr = CreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL);
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+
+ hr = IXmlWriter_SetProperty(writer, XmlWriterProperty_OmitXmlDeclaration, TRUE);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ hr = IXmlWriter_WriteCData(writer, aW);
+ ok(hr == E_UNEXPECTED, "got 0x%08x\n", hr);
+
+ stream = writer_set_output(writer);
+
+ hr = IXmlWriter_WriteStartElement(writer, NULL, bW, NULL);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ hr = IXmlWriter_WriteCData(writer, aW);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ hr = IXmlWriter_WriteCData(writer, NULL);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ hr = IXmlWriter_WriteCData(writer, closeW);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ hr = IXmlWriter_WriteCData(writer, close2W);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ hr = IXmlWriter_Flush(writer);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ CHECK_OUTPUT(stream,
+ "<b>"
+ "<![CDATA[a]]>"
+ "<![CDATA[]]>"
+ "<![CDATA[]]]]>"
+ "<![CDATA[>]]>"
+ "<![CDATA[a]]]]>"
+ "<![CDATA[>b]]>");
+
+ IXmlWriter_Release(writer);
+ IStream_Release(stream);
+}
+
+static void test_WriteRaw(void)
+{
+ static const WCHAR rawW[] = {'a','<',':',0};
+ static const WCHAR aW[] = {'a',0};
+ IXmlWriter *writer;
+ IStream *stream;
+ HRESULT hr;
+
+ hr = CreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL);
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+
+ hr = IXmlWriter_WriteRaw(writer, NULL);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ hr = IXmlWriter_WriteRaw(writer, rawW);
+ ok(hr == E_UNEXPECTED, "got 0x%08x\n", hr);
+
+ stream = writer_set_output(writer);
+
+ hr = IXmlWriter_WriteRaw(writer, NULL);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ hr = IXmlWriter_WriteRaw(writer, rawW);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ hr = IXmlWriter_WriteRaw(writer, rawW);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ hr = IXmlWriter_WriteComment(writer, rawW);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ hr = IXmlWriter_WriteRaw(writer, rawW);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ hr = IXmlWriter_WriteElementString(writer, NULL, aW, NULL, aW);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Yes);
+ ok(hr == WR_E_INVALIDACTION, "got 0x%08x\n", hr);
+
+ hr = IXmlWriter_WriteComment(writer, rawW);
+ ok(hr == WR_E_INVALIDACTION, "got 0x%08x\n", hr);
hr = IXmlWriter_WriteEndDocument(writer);
- ok(hr == E_UNEXPECTED, "got 0x%08x\n", hr);
-
- hr = IXmlWriter_SetOutput(writer, (IUnknown*)stream);
- ok(hr == S_OK, "got 0x%08x\n", hr);
-
- /* WriteEndDocument resets it to initial state */
+ ok(hr == WR_E_INVALIDACTION, "got 0x%08x\n", hr);
+
+ hr = IXmlWriter_WriteRaw(writer, rawW);
+ ok(hr == WR_E_INVALIDACTION, "got 0x%08x\n", hr);
+
+ hr = IXmlWriter_Flush(writer);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ CHECK_OUTPUT(stream, "<?xml version=\"1.0\"
encoding=\"UTF-8\"?>a<:a<:<!--a<:-->a<:<a>a</a>");
+
+ IXmlWriter_Release(writer);
+ IStream_Release(stream);
+}
+
+static void test_writer_state(void)
+{
+ static const WCHAR aW[] = {'a',0};
+ IXmlWriter *writer;
+ IStream *stream;
+ HRESULT hr;
+
+ hr = CreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL);
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+
+ /* initial state */
+ check_writer_state(writer, E_UNEXPECTED);
+
+ /* set output and call 'wrong' method, WriteEndElement */
+ stream = writer_set_output(writer);
+
+ hr = IXmlWriter_WriteEndElement(writer);
+ ok(hr == WR_E_INVALIDACTION, "got 0x%08x\n", hr);
+
+ check_writer_state(writer, WR_E_INVALIDACTION);
+ IStream_Release(stream);
+
+ /* WriteAttributeString */
+ stream = writer_set_output(writer);
+
+ hr = IXmlWriter_WriteAttributeString(writer, NULL, aW, NULL, aW);
+ ok(hr == WR_E_INVALIDACTION, "got 0x%08x\n", hr);
+
+ check_writer_state(writer, WR_E_INVALIDACTION);
+ IStream_Release(stream);
+
+ /* WriteEndDocument */
+ stream = writer_set_output(writer);
+
hr = IXmlWriter_WriteEndDocument(writer);
ok(hr == WR_E_INVALIDACTION, "got 0x%08x\n", hr);
- hr = IXmlWriter_WriteEndDocument(writer);
- ok(hr == WR_E_INVALIDACTION, "got 0x%08x\n", hr);
-
- hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit);
- ok(hr == WR_E_INVALIDACTION, "got 0x%08x\n", hr);
-
- hr = IXmlWriter_WriteStartElement(writer, NULL, aW, NULL);
- ok(hr == WR_E_INVALIDACTION, "got 0x%08x\n", hr);
-
- hr = IXmlWriter_SetOutput(writer, (IUnknown*)stream);
- ok(hr == S_OK, "got 0x%08x\n", hr);
-
- hr = IXmlWriter_WriteStartElement(writer, NULL, aW, NULL);
- ok(hr == S_OK, "got 0x%08x\n", hr);
-
- hr = IXmlWriter_WriteStartElement(writer, NULL, bW, NULL);
- ok(hr == S_OK, "got 0x%08x\n", hr);
-
- hr = IXmlWriter_WriteEndDocument(writer);
- ok(hr == S_OK, "got 0x%08x\n", hr);
-
- hr = GetHGlobalFromStream(stream, &hglobal);
- ok(hr == S_OK, "got 0x%08x\n", hr);
-
- ptr = GlobalLock(hglobal);
- ok(ptr == NULL, "got %p\n", ptr);
-
- /* we still need to flush manually, WriteEndDocument doesn't do that */
- hr = IXmlWriter_Flush(writer);
- ok(hr == S_OK, "got 0x%08x\n", hr);
-
- ptr = GlobalLock(hglobal);
- ok(ptr != NULL, "got %p\n", ptr);
- ok(!strncmp(ptr, "<a><b /></a>", 12), "got
%s\n", ptr);
- GlobalUnlock(hglobal);
-
- IXmlWriter_Release(writer);
- IStream_Release(stream);
+ check_writer_state(writer, WR_E_INVALIDACTION);
+ IStream_Release(stream);
+
+ /* WriteFullEndElement */
+ stream = writer_set_output(writer);
+
+ hr = IXmlWriter_WriteFullEndElement(writer);
+ ok(hr == WR_E_INVALIDACTION, "got 0x%08x\n", hr);
+
+ check_writer_state(writer, WR_E_INVALIDACTION);
+ IStream_Release(stream);
+
+ /* WriteCData */
+ stream = writer_set_output(writer);
+
+ hr = IXmlWriter_WriteCData(writer, aW);
+ ok(hr == WR_E_INVALIDACTION, "got 0x%08x\n", hr);
+
+ check_writer_state(writer, WR_E_INVALIDACTION);
+ IStream_Release(stream);
+
+ /* WriteName */
+ stream = writer_set_output(writer);
+
+ hr = IXmlWriter_WriteName(writer, aW);
+ ok(hr == WR_E_INVALIDACTION, "got 0x%08x\n", hr);
+
+ check_writer_state(writer, WR_E_INVALIDACTION);
+ IStream_Release(stream);
+
+ /* WriteNmToken */
+ stream = writer_set_output(writer);
+
+ hr = IXmlWriter_WriteNmToken(writer, aW);
+ ok(hr == WR_E_INVALIDACTION, "got 0x%08x\n", hr);
+
+ check_writer_state(writer, WR_E_INVALIDACTION);
+ IStream_Release(stream);
+
+ /* WriteString */
+ stream = writer_set_output(writer);
+
+ hr = IXmlWriter_WriteString(writer, aW);
+ ok(hr == WR_E_INVALIDACTION, "got 0x%08x\n", hr);
+
+ check_writer_state(writer, WR_E_INVALIDACTION);
+ IStream_Release(stream);
+
+ IXmlWriter_Release(writer);
}
START_TEST(writer)
{
- if (!init_pointers())
- return;
-
test_writer_create();
+ test_writer_state();
test_writeroutput();
test_writestartdocument();
test_writestartelement();
@@ -777,4 +1026,7 @@
test_omitxmldeclaration();
test_bom();
test_writeenddocument();
-}
+ test_WriteComment();
+ test_WriteCData();
+ test_WriteRaw();
+}