Author: akhaldi
Date: Sun Sep 24 11:18:47 2017
New Revision: 75951
URL:
http://svn.reactos.org/svn/reactos?rev=75951&view=rev
Log:
[XMLLITE_WINETEST] Sync with Wine Staging 2.16. CORE-13762
Modified:
trunk/rostests/winetests/xmllite/reader.c
trunk/rostests/winetests/xmllite/writer.c
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] Sun Sep 24 11:18:47 2017
@@ -801,7 +801,6 @@
{
XmlNodeType nodetype;
IXmlReader *reader;
- IStream *stream;
HRESULT hr;
hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
@@ -820,12 +819,7 @@
hr = IXmlReader_Read(reader, &nodetype);
ok(hr == S_FALSE, "got %08x\n", hr);
}
-
- stream = create_stream_on_data("xml", sizeof("xml"));
-
- hr = IXmlReader_SetInput(reader, (IUnknown *)stream);
- ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
-
+ set_input_string(reader, "xml");
TEST_READER_STATE(reader, XmlReadState_Initial);
nodetype = XmlNodeType_Element;
@@ -843,7 +837,6 @@
ok(FAILED(hr), "got %08x\n", hr);
ok(nodetype == XmlNodeType_None, "Unexpected node type %d\n", nodetype);
- IStream_Release(stream);
IXmlReader_Release(reader);
}
@@ -1287,7 +1280,6 @@
IXmlReader *reader;
const WCHAR *str;
XmlNodeType type;
- IStream *stream;
UINT len, count;
HRESULT hr;
@@ -1297,9 +1289,7 @@
hr = IXmlReader_SetProperty(reader, XmlReaderProperty_DtdProcessing,
DtdProcessing_Parse);
ok(hr == S_OK, "got 0x%8x\n", hr);
- stream = create_stream_on_data(test_public_dtd, sizeof(test_public_dtd));
- hr = IXmlReader_SetInput(reader, (IUnknown*)stream);
- ok(hr == S_OK, "got %08x\n", hr);
+ set_input_string(reader, test_public_dtd);
read_node(reader, XmlNodeType_DocumentType);
@@ -1340,7 +1330,6 @@
ok(len == lstrlenW(dtdnameW), "got %u\n", len);
ok(!lstrcmpW(str, dtdnameW), "got %s\n", wine_dbgstr_w(str));
}
- IStream_Release(stream);
IXmlReader_Release(reader);
}
@@ -1354,7 +1343,6 @@
IXmlReader *reader;
const WCHAR *str;
XmlNodeType type;
- IStream *stream;
UINT len, count;
HRESULT hr;
@@ -1364,9 +1352,7 @@
hr = IXmlReader_SetProperty(reader, XmlReaderProperty_DtdProcessing,
DtdProcessing_Parse);
ok(hr == S_OK, "got 0x%8x\n", hr);
- stream = create_stream_on_data(test_system_dtd, sizeof(test_system_dtd));
- hr = IXmlReader_SetInput(reader, (IUnknown*)stream);
- ok(hr == S_OK, "got %08x\n", hr);
+ set_input_string(reader, test_system_dtd);
read_node(reader, XmlNodeType_DocumentType);
@@ -1400,7 +1386,6 @@
read_node(reader, XmlNodeType_Comment);
- IStream_Release(stream);
IXmlReader_Release(reader);
}
@@ -1714,11 +1699,8 @@
while (test->xml)
{
XmlNodeType type;
- IStream *stream;
-
- stream = create_stream_on_data(test->xml, strlen(test->xml)+1);
- hr = IXmlReader_SetInput(reader, (IUnknown*)stream);
- ok(hr == S_OK, "got %08x\n", hr);
+
+ set_input_string(reader, test->xml);
type = XmlNodeType_None;
hr = IXmlReader_Read(reader, &type);
@@ -1764,7 +1746,6 @@
reader_value(reader, test->value);
}
- IStream_Release(stream);
test++;
}
@@ -1791,11 +1772,8 @@
while (test->xml)
{
XmlNodeType type;
- IStream *stream;
-
- stream = create_stream_on_data(test->xml, strlen(test->xml)+1);
- hr = IXmlReader_SetInput(reader, (IUnknown*)stream);
- ok(hr == S_OK, "got %08x\n", hr);
+
+ set_input_string(reader, test->xml);
type = XmlNodeType_None;
hr = IXmlReader_Read(reader, &type);
@@ -1837,7 +1815,6 @@
reader_value(reader, test->value);
}
- IStream_Release(stream);
test++;
}
@@ -1867,12 +1844,9 @@
while (test->xml)
{
XmlNodeType type;
- IStream *stream;
BOOL ret;
- stream = create_stream_on_data(test->xml, strlen(test->xml)+1);
- hr = IXmlReader_SetInput(reader, (IUnknown*)stream);
- ok(hr == S_OK, "got %08x\n", hr);
+ set_input_string(reader, test->xml);
type = XmlNodeType_None;
hr = IXmlReader_Read(reader, &type);
@@ -1882,7 +1856,6 @@
ret = IXmlReader_IsEmptyElement(reader);
ok(ret == test->empty, "got %d, expected %d. xml=%s\n", ret,
test->empty, test->xml);
- IStream_Release(stream);
test++;
}
@@ -1925,11 +1898,8 @@
while (test->xml)
{
XmlNodeType type;
- IStream *stream;
-
- stream = create_stream_on_data(test->xml, strlen(test->xml)+1);
- hr = IXmlReader_SetInput(reader, (IUnknown*)stream);
- ok(hr == S_OK, "got %08x\n", hr);
+
+ set_input_string(reader, test->xml);
hr = IXmlReader_Read(reader, NULL);
@@ -1967,7 +1937,6 @@
reader_value(reader, test->value);
}
- IStream_Release(stream);
test++;
}
@@ -2024,11 +1993,8 @@
for (i = 0; i < sizeof(prefix_tests)/sizeof(prefix_tests[0]); i++) {
XmlNodeType type;
- IStream *stream;
-
- stream = create_stream_on_data(prefix_tests[i].xml, strlen(prefix_tests[i].xml) +
1);
- hr = IXmlReader_SetInput(reader, (IUnknown *)stream);
- ok(hr == S_OK, "got %08x\n", hr);
+
+ set_input_string(reader, prefix_tests[i].xml);
hr = IXmlReader_Read(reader, &type);
ok(hr == S_OK, "Read() failed, %#x\n", hr);
@@ -2056,8 +2022,6 @@
/* back to the element, check prefix */
move_to_element(reader);
reader_prefix(reader, prefix_tests[i].prefix1);
-
- IStream_Release(stream);
}
IXmlReader_Release(reader);
@@ -2103,11 +2067,9 @@
ok(hr == S_OK, "S_OK, got %08x\n", hr);
for (i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); i++) {
- IStream *stream = create_stream_on_data(uri_tests[i].xml,
strlen(uri_tests[i].xml) + 1);
unsigned int j = 0;
- hr = IXmlReader_SetInput(reader, (IUnknown *)stream);
- ok(hr == S_OK, "got %08x\n", hr);
+ set_input_string(reader, uri_tests[i].xml);
type = ~0u;
while (IXmlReader_Read(reader, &type) == S_OK) {
@@ -2152,8 +2114,6 @@
j++;
}
ok(type == XmlNodeType_None, "Unexpected node type %d\n", type);
-
- IStream_Release(stream);
}
IXmlReader_Release(reader);
@@ -2229,17 +2189,12 @@
for (i = 0; i < sizeof(encoding_testsA)/sizeof(encoding_testsA[0]); i++)
{
- stream = create_stream_on_data(encoding_testsA[i], strlen(encoding_testsA[i]));
-
- hr = IXmlReader_SetInput(reader, (IUnknown *)stream);
- ok(hr == S_OK, "got %08x\n", hr);
+ set_input_string(reader, encoding_testsA[i]);
type = XmlNodeType_None;
hr = IXmlReader_Read(reader, &type);
ok(hr == S_OK, "got %08x\n", hr);
ok(type != XmlNodeType_None, "Unexpected node type %d\n", type);
-
- IStream_Release(stream);
}
for (i = 0; i < sizeof(encoding_testsW)/sizeof(encoding_testsW[0]); i++)
@@ -2617,6 +2572,90 @@
next_attribute(reader);
ok(name == reader_name(reader, "attr"), "attr pointer
changed\n");
ok(value == reader_value(reader, "value"), "value pointer
changed\n");
+
+ IXmlReader_Release(reader);
+}
+
+static void test_attribute_by_name(void)
+{
+ static const char *xml = "<a><elem xmlns=\"myns\"
a=\"value a\" b=\"value b\" xmlns:ns=\"ns uri\" "
+ "ns:c=\"value c\" c=\"value c2\"/></a>";
+ static const WCHAR xmlns_uriW[] =
{'h','t','t','p',':','/','/','w','w','w','.','w','3','.','o','r','g','/',
+
'2','0','0','0','/','x','m','l','n','s','/',0};
+ static const WCHAR nsuriW[] = {'n','s','
','u','r','i',0};
+ static const WCHAR xmlnsW[] =
{'x','m','l','n','s',0};
+ static const WCHAR mynsW[] = {'m','y','n','s',0};
+ static const WCHAR nsW[] = {'n','s',0};
+ static const WCHAR emptyW[] = {0};
+ static const WCHAR aW[] = {'a',0};
+ static const WCHAR bW[] = {'b',0};
+ static const WCHAR cW[] = {'c',0};
+ IXmlReader *reader;
+ HRESULT hr;
+
+ hr = CreateXmlReader(&IID_IXmlReader, (void **)&reader, NULL);
+ ok(hr == S_OK, "Failed to create reader, hr %#x.\n", hr);
+
+ set_input_string(reader, xml);
+
+ hr = IXmlReader_MoveToAttributeByName(reader, NULL, NULL);
+ ok(hr == E_INVALIDARG || broken(hr == S_FALSE) /* WinXP */, "Unexpected hr
%#x.\n", hr);
+
+ hr = IXmlReader_MoveToAttributeByName(reader, emptyW, NULL);
+ ok(hr == S_FALSE, "Unexpected hr %#x.\n", hr);
+
+ read_node(reader, XmlNodeType_Element);
+
+ hr = IXmlReader_MoveToAttributeByName(reader, emptyW, NULL);
+ ok(hr == S_FALSE, "Unexpected hr %#x.\n", hr);
+
+ read_node(reader, XmlNodeType_Element);
+
+ hr = IXmlReader_MoveToAttributeByName(reader, NULL, NULL);
+ ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
+
+ hr = IXmlReader_MoveToAttributeByName(reader, NULL, xmlns_uriW);
+ ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
+
+ hr = IXmlReader_MoveToAttributeByName(reader, emptyW, xmlns_uriW);
+ ok(hr == S_FALSE, "Unexpected hr %#x.\n", hr);
+
+ hr = IXmlReader_MoveToAttributeByName(reader, xmlnsW, NULL);
+ ok(hr == S_FALSE, "Unexpected hr %#x.\n", hr);
+
+ hr = IXmlReader_MoveToAttributeByName(reader, xmlnsW, xmlns_uriW);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+ reader_value(reader, "myns");
+
+ hr = IXmlReader_MoveToAttributeByName(reader, aW, NULL);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+ reader_value(reader, "value a");
+
+ hr = IXmlReader_MoveToAttributeByName(reader, bW, NULL);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+ reader_value(reader, "value b");
+
+ hr = IXmlReader_MoveToAttributeByName(reader, aW, mynsW);
+ ok(hr == S_FALSE, "Unexpected hr %#x.\n", hr);
+
+ hr = IXmlReader_MoveToAttributeByName(reader, nsW, NULL);
+ ok(hr == S_FALSE, "Unexpected hr %#x.\n", hr);
+
+ hr = IXmlReader_MoveToAttributeByName(reader, nsW, xmlns_uriW);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+ reader_value(reader, "ns uri");
+
+ hr = IXmlReader_MoveToAttributeByName(reader, bW, emptyW);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+ reader_value(reader, "value b");
+
+ hr = IXmlReader_MoveToAttributeByName(reader, cW, NULL);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+ reader_value(reader, "value c2");
+
+ hr = IXmlReader_MoveToAttributeByName(reader, cW, nsuriW);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+ reader_value(reader, "value c");
IXmlReader_Release(reader);
}
@@ -2648,4 +2687,5 @@
test_max_element_depth();
test_reader_position();
test_string_pointers();
-}
+ test_attribute_by_name();
+}
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] Sun Sep 24 11:18:47 2017
@@ -39,6 +39,8 @@
#include <initguid.h>
DEFINE_GUID(IID_IXmlWriterOutput, 0xc1131708, 0x0f59, 0x477f, 0x93, 0x59, 0x7d, 0x33,
0x24, 0x51, 0xbc, 0x1a);
+static const WCHAR aW[] = {'a',0};
+
#define EXPECT_REF(obj, ref) _expect_ref((IUnknown *)obj, ref, __LINE__)
static void _expect_ref(IUnknown *obj, ULONG ref, int line)
{
@@ -46,6 +48,25 @@
IUnknown_AddRef(obj);
refcount = IUnknown_Release(obj);
ok_(__FILE__, line)(refcount == ref, "expected refcount %d, got %d\n", ref,
refcount);
+}
+
+static void check_output_raw(IStream *stream, const void *expected, SIZE_T size, int
line)
+{
+ SIZE_T content_size;
+ HGLOBAL hglobal;
+ HRESULT hr;
+ char *ptr;
+
+ hr = GetHGlobalFromStream(stream, &hglobal);
+ ok_(__FILE__, line)(hr == S_OK, "Failed to get the stream handle, hr
%#x.\n", hr);
+
+ content_size = GlobalSize(hglobal);
+ ok_(__FILE__, line)(size <= content_size, "Unexpected test output
size.\n");
+ ptr = GlobalLock(hglobal);
+ if (size <= content_size)
+ ok_(__FILE__, line)(!memcmp(expected, ptr, size), "Unexpected output
content.\n");
+
+ GlobalUnlock(hglobal);
}
static void check_output(IStream *stream, const char *expected, BOOL todo, int line)
@@ -74,6 +95,15 @@
}
#define CHECK_OUTPUT(stream, expected) check_output(stream, expected, FALSE, __LINE__)
#define CHECK_OUTPUT_TODO(stream, expected) check_output(stream, expected, TRUE,
__LINE__)
+#define CHECK_OUTPUT_RAW(stream, expected, size) check_output_raw(stream, expected, size,
__LINE__)
+
+static void writer_set_property(IXmlWriter *writer, XmlWriterProperty property)
+{
+ HRESULT hr;
+
+ hr = IXmlWriter_SetProperty(writer, property, TRUE);
+ ok(hr == S_OK, "Failed to set writer property, hr %#x.\n", hr);
+}
/* used to test all Write* methods for consistent error state */
static void check_writer_state(IXmlWriter *writer, HRESULT exp_hr)
@@ -292,11 +322,93 @@
IXmlWriter_Release(writer);
}
+static void test_invalid_output_encoding(IXmlWriter *writer, IUnknown *output)
+{
+ HRESULT hr;
+
+ hr = IXmlWriter_SetOutput(writer, output);
+ ok(hr == S_OK, "Failed to set output, hr %#x.\n", hr);
+
+ /* TODO: WriteAttributes */
+
+ hr = IXmlWriter_WriteAttributeString(writer, NULL, aW, NULL, aW);
+ ok(hr == MX_E_ENCODING, "Unexpected hr %#x.\n", hr);
+
+ hr = IXmlWriter_WriteCData(writer, aW);
+ ok(hr == MX_E_ENCODING, "Unexpected hr %#x.\n", hr);
+
+ hr = IXmlWriter_WriteCharEntity(writer, 0x100);
+ ok(hr == MX_E_ENCODING, "Unexpected hr %#x.\n", hr);
+
+ hr = IXmlWriter_WriteChars(writer, aW, 1);
+ ok(hr == MX_E_ENCODING, "Unexpected hr %#x.\n", hr);
+
+ hr = IXmlWriter_WriteComment(writer, aW);
+ ok(hr == MX_E_ENCODING, "Unexpected hr %#x.\n", hr);
+
+ /* TODO: WriteDocType */
+
+ hr = IXmlWriter_WriteElementString(writer, NULL, aW, NULL, NULL);
+ ok(hr == MX_E_ENCODING, "Unexpected hr %#x.\n", hr);
+
+ hr = IXmlWriter_WriteEndDocument(writer);
+ ok(hr == MX_E_ENCODING, "Unexpected hr %#x.\n", hr);
+
+ hr = IXmlWriter_WriteEndElement(writer);
+ ok(hr == MX_E_ENCODING, "Unexpected hr %#x.\n", hr);
+
+ hr = IXmlWriter_WriteEntityRef(writer, aW);
+ ok(hr == MX_E_ENCODING, "Unexpected hr %#x.\n", hr);
+
+ hr = IXmlWriter_WriteFullEndElement(writer);
+ ok(hr == MX_E_ENCODING, "Unexpected hr %#x.\n", hr);
+
+ hr = IXmlWriter_WriteName(writer, aW);
+ ok(hr == MX_E_ENCODING, "Unexpected hr %#x.\n", hr);
+
+ hr = IXmlWriter_WriteNmToken(writer, aW);
+ ok(hr == MX_E_ENCODING, "Unexpected hr %#x.\n", hr);
+
+ /* TODO: WriteNode */
+ /* TODO: WriteNodeShallow */
+
+ hr = IXmlWriter_WriteProcessingInstruction(writer, aW, aW);
+ ok(hr == MX_E_ENCODING, "Unexpected hr %#x.\n", hr);
+
+ hr = IXmlWriter_WriteQualifiedName(writer, aW, NULL);
+ ok(hr == MX_E_ENCODING, "Unexpected hr %#x.\n", hr);
+
+ hr = IXmlWriter_WriteRaw(writer, aW);
+ ok(hr == MX_E_ENCODING, "Unexpected hr %#x.\n", hr);
+
+ hr = IXmlWriter_WriteRawChars(writer, aW, 1);
+ ok(hr == MX_E_ENCODING, "Unexpected hr %#x.\n", hr);
+
+ hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Yes);
+ ok(hr == MX_E_ENCODING, "Unexpected hr %#x.\n", hr);
+
+ hr = IXmlWriter_WriteStartElement(writer, NULL, aW, NULL);
+ ok(hr == MX_E_ENCODING, "Unexpected hr %#x.\n", hr);
+
+ hr = IXmlWriter_WriteString(writer, aW);
+ ok(hr == MX_E_ENCODING, "Unexpected hr %#x.\n", hr);
+
+ /* TODO: WriteSurrogateCharEntity */
+ /* ???TODO: WriteWhitespace */
+
+ hr = IXmlWriter_Flush(writer);
+ ok(hr == S_OK, "Failed to flush, hr %#x.\n", hr);
+}
+
static void test_writeroutput(void)
{
static const WCHAR utf16W[] =
{'u','t','f','-','1','6',0};
static const WCHAR usasciiW[] =
{'u','s','-','a','s','c','i','i',0};
+ static const WCHAR dummyW[] =
{'d','u','m','m','y',0};
+ static const WCHAR utf16_outputW[] = {0xfeff,'<','a'};
IXmlWriterOutput *output;
+ IXmlWriter *writer;
+ IStream *stream;
IUnknown *unk;
HRESULT hr;
@@ -339,6 +451,59 @@
hr = CreateXmlWriterOutputWithEncodingName(&testoutput, NULL, usasciiW,
&output);
ok(hr == S_OK, "got %08x\n", hr);
IUnknown_Release(output);
+
+ /* Output with codepage 1200. */
+ hr = CreateXmlWriter(&IID_IXmlWriter, (void **)&writer, NULL);
+ ok(hr == S_OK, "Failed to create writer, hr %#x.\n", hr);
+
+ hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
+ ok(hr == S_OK, "Failed to create stream, hr %#x.\n", hr);
+
+ hr = CreateXmlWriterOutputWithEncodingCodePage((IUnknown *)stream, NULL, 1200,
&output);
+ ok(hr == S_OK, "Failed to create writer output, hr %#x.\n", hr);
+
+ hr = IXmlWriter_SetOutput(writer, output);
+ ok(hr == S_OK, "Failed to set writer output, hr %#x.\n", hr);
+
+ hr = IXmlWriter_WriteStartElement(writer, NULL, aW, NULL);
+ ok(hr == S_OK, "Write failed, hr %#x.\n", hr);
+
+ hr = IXmlWriter_Flush(writer);
+ ok(hr == S_OK, "Failed to flush, hr %#x.\n", hr);
+
+ CHECK_OUTPUT_RAW(stream, utf16_outputW, sizeof(utf16_outputW));
+
+ IStream_Release(stream);
+
+ /* Create output with meaningless code page value. */
+ hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
+ ok(hr == S_OK, "Failed to create stream, hr %#x.\n", hr);
+
+ output = NULL;
+ hr = CreateXmlWriterOutputWithEncodingCodePage((IUnknown *)stream, NULL, ~0u,
&output);
+ ok(hr == S_OK, "Failed to create writer output, hr %#x.\n", hr);
+
+ test_invalid_output_encoding(writer, output);
+ CHECK_OUTPUT(stream, "");
+
+ IStream_Release(stream);
+ IUnknown_Release(output);
+
+ /* Same, with invalid encoding name. */
+ hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ output = NULL;
+ hr = CreateXmlWriterOutputWithEncodingName((IUnknown *)stream, NULL, dummyW,
&output);
+ ok(hr == S_OK, "got %08x\n", hr);
+
+ test_invalid_output_encoding(writer, output);
+ CHECK_OUTPUT(stream, "");
+
+ IStream_Release(stream);
+ IUnknown_Release(output);
+
+ IXmlWriter_Release(writer);
}
static void test_writestartdocument(void)
@@ -483,8 +648,7 @@
stream = writer_set_output(writer);
- hr = IXmlWriter_SetProperty(writer, XmlWriterProperty_OmitXmlDeclaration, TRUE);
- ok(hr == S_OK, "got 0x%08x\n", hr);
+ writer_set_property(writer, XmlWriterProperty_OmitXmlDeclaration);
hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Yes);
ok(hr == S_OK, "got 0x%08x\n", hr);
@@ -548,7 +712,6 @@
static const WCHAR versionW[] =
{'v','e','r','s','i','o','n','=','"','1','.','0','"',0};
static const WCHAR utf16W[] =
{'u','t','f','-','1','6',0};
static const WCHAR xmlW[] = {'x','m','l',0};
- static const WCHAR aW[] = {'a',0};
IXmlWriterOutput *output;
unsigned char *ptr;
IXmlWriter *writer;
@@ -565,8 +728,7 @@
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);
+ writer_set_property(writer, XmlWriterProperty_OmitXmlDeclaration);
hr = IXmlWriter_SetOutput(writer, output);
ok(hr == S_OK, "got 0x%08x\n", hr);
@@ -650,6 +812,8 @@
hr = IXmlWriter_SetOutput(writer, output);
ok(hr == S_OK, "got 0x%08x\n", hr);
+ writer_set_property(writer, XmlWriterProperty_Indent);
+
hr = IXmlWriter_WriteElementString(writer, NULL, aW, NULL, NULL);
ok(hr == S_OK, "got 0x%08x\n", hr);
@@ -660,7 +824,8 @@
ok(hr == S_OK, "got 0x%08x\n", hr);
ptr = GlobalLock(hglobal);
- ok(ptr[0] == 0xff && ptr[1] == 0xfe, "got %x,%x\n", ptr[0],
ptr[1]);
+ ok(ptr[0] == 0xff && ptr[1] == 0xfe && ptr[2] == '<',
"Unexpected output: %#x,%#x,%#x\n",
+ ptr[0], ptr[1], ptr[2]);
GlobalUnlock(hglobal);
IUnknown_Release(output);
@@ -672,7 +837,6 @@
static void test_writestartelement(void)
{
static const WCHAR valueW[] =
{'v','a','l','u','e',0};
- static const char *str = "<a><b>value</b>";
static const WCHAR aW[] = {'a',0};
static const WCHAR bW[] = {'b',0};
IXmlWriter *writer;
@@ -734,10 +898,14 @@
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);
+ hr = IXmlWriter_WriteElementString(writer, NULL, bW, NULL, NULL);
+ 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>value</b><b />");
IStream_Release(stream);
IXmlWriter_Release(writer);
@@ -848,8 +1016,7 @@
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);
+ writer_set_property(writer, XmlWriterProperty_OmitXmlDeclaration);
hr = IXmlWriter_WriteComment(writer, aW);
ok(hr == E_UNEXPECTED, "got 0x%08x\n", hr);
@@ -896,8 +1063,7 @@
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);
+ writer_set_property(writer, XmlWriterProperty_OmitXmlDeclaration);
hr = IXmlWriter_WriteCData(writer, aW);
ok(hr == E_UNEXPECTED, "got 0x%08x\n", hr);
@@ -1095,11 +1261,8 @@
stream = writer_set_output(writer);
- hr = IXmlWriter_SetProperty(writer, XmlWriterProperty_OmitXmlDeclaration, TRUE);
- ok(hr == S_OK, "got 0x%08x\n", hr);
-
- hr = IXmlWriter_SetProperty(writer, XmlWriterProperty_Indent, TRUE);
- ok(hr == S_OK, "got 0x%08x\n", hr);
+ writer_set_property(writer, XmlWriterProperty_OmitXmlDeclaration);
+ writer_set_property(writer, XmlWriterProperty_Indent);
hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit);
ok(hr == S_OK, "got 0x%08x\n", hr);
@@ -1125,8 +1288,35 @@
" <b />\r\n"
"</a>");
- IXmlWriter_Release(writer);
- IStream_Release(stream);
+ IStream_Release(stream);
+
+ /* WriteElementString */
+ stream = writer_set_output(writer);
+
+ hr = IXmlWriter_WriteStartElement(writer, NULL, aW, NULL);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+
+ hr = IXmlWriter_WriteElementString(writer, NULL, bW, NULL, NULL);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+
+ hr = IXmlWriter_WriteElementString(writer, NULL, bW, NULL, NULL);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+
+ hr = IXmlWriter_WriteEndElement(writer);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+
+ hr = IXmlWriter_Flush(writer);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+
+ CHECK_OUTPUT(stream,
+ "<a>\r\n"
+ " <b />\r\n"
+ " <b />\r\n"
+ "</a>");
+
+ IStream_Release(stream);
+
+ IXmlWriter_Release(writer);
}
static void test_WriteAttributeString(void)
@@ -1147,8 +1337,7 @@
stream = writer_set_output(writer);
- hr = IXmlWriter_SetProperty(writer, XmlWriterProperty_OmitXmlDeclaration, TRUE);
- ok(hr == S_OK, "got 0x%08x\n", hr);
+ writer_set_property(writer, XmlWriterProperty_OmitXmlDeclaration);
hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit);
ok(hr == S_OK, "got 0x%08x\n", hr);
@@ -1227,11 +1416,8 @@
/* standalone element */
stream = writer_set_output(writer);
- hr = IXmlWriter_SetProperty(writer, XmlWriterProperty_OmitXmlDeclaration, TRUE);
- ok(hr == S_OK, "got 0x%08x\n", hr);
-
- hr = IXmlWriter_SetProperty(writer, XmlWriterProperty_Indent, TRUE);
- ok(hr == S_OK, "got 0x%08x\n", hr);
+ writer_set_property(writer, XmlWriterProperty_OmitXmlDeclaration);
+ writer_set_property(writer, XmlWriterProperty_Indent);
hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit);
ok(hr == S_OK, "got 0x%08x\n", hr);
@@ -1255,11 +1441,8 @@
/* nested elements */
stream = writer_set_output(writer);
- hr = IXmlWriter_SetProperty(writer, XmlWriterProperty_OmitXmlDeclaration, TRUE);
- ok(hr == S_OK, "got 0x%08x\n", hr);
-
- hr = IXmlWriter_SetProperty(writer, XmlWriterProperty_Indent, TRUE);
- ok(hr == S_OK, "got 0x%08x\n", hr);
+ writer_set_property(writer, XmlWriterProperty_OmitXmlDeclaration);
+ writer_set_property(writer, XmlWriterProperty_Indent);
hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit);
ok(hr == S_OK, "got 0x%08x\n", hr);
@@ -1301,8 +1484,7 @@
/* without indentation */
stream = writer_set_output(writer);
- hr = IXmlWriter_SetProperty(writer, XmlWriterProperty_OmitXmlDeclaration, TRUE);
- ok(hr == S_OK, "got 0x%08x\n", hr);
+ writer_set_property(writer, XmlWriterProperty_OmitXmlDeclaration);
hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit);
ok(hr == S_OK, "got 0x%08x\n", hr);
@@ -1342,8 +1524,7 @@
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);
+ writer_set_property(writer, XmlWriterProperty_OmitXmlDeclaration);
hr = IXmlWriter_WriteString(writer, aW);
ok(hr == E_UNEXPECTED, "got 0x%08x\n", hr);