Module: wine Branch: master Commit: 2821d9cb4115b7f8dca8bc2502e8df969de20bcc URL: https://gitlab.winehq.org/wine/wine/-/commit/2821d9cb4115b7f8dca8bc2502e8df9...
Author: Nikolay Sivov nsivov@codeweavers.com Date: Fri Sep 16 11:19:54 2022 +0300
xmllite/writer: Enable some more tests for WriteNode().
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com
---
dlls/xmllite/tests/writer.c | 40 ++++++++++++++++++++++++++++++++++++---- dlls/xmllite/writer.c | 6 ++++++ 2 files changed, 42 insertions(+), 4 deletions(-)
diff --git a/dlls/xmllite/tests/writer.c b/dlls/xmllite/tests/writer.c index 25dc9e3b8c1..7b98f61a207 100644 --- a/dlls/xmllite/tests/writer.c +++ b/dlls/xmllite/tests/writer.c @@ -136,8 +136,12 @@ static void writer_set_property(IXmlWriter *writer, XmlWriterProperty property) /* used to test all Write* methods for consistent error state */ static void check_writer_state(IXmlWriter *writer, HRESULT exp_hr) { + IXmlReader *reader; HRESULT hr;
+ hr = CreateXmlReader(&IID_IXmlReader, (void **)&reader, NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + /* FIXME: add WriteAttributes */
hr = IXmlWriter_WriteAttributeString(writer, NULL, L"a", NULL, L"a"); @@ -179,8 +183,18 @@ static void check_writer_state(IXmlWriter *writer, HRESULT exp_hr) hr = IXmlWriter_WriteNmToken(writer, L"a"); ok(hr == exp_hr, "Unexpected hr %#lx, expected %#lx.\n", hr, exp_hr);
- /* FIXME: add WriteNode */ - /* FIXME: add WriteNodeShallow */ + hr = IXmlWriter_WriteNode(writer, NULL, FALSE); + ok(hr == E_INVALIDARG, "Unexpected hr %#lx, expected %#lx.\n", hr, exp_hr); + + reader_set_input(reader, "<a/>"); + hr = IXmlWriter_WriteNode(writer, reader, FALSE); + ok(hr == exp_hr, "Unexpected hr %#lx, expected %#lx.\n", hr, exp_hr); + + reader_set_input(reader, "<a/>"); + hr = IXmlReader_Read(reader, NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IXmlWriter_WriteNodeShallow(writer, reader, FALSE); + ok(hr == exp_hr, "Unexpected hr %#lx, expected %#lx.\n", hr, exp_hr);
hr = IXmlWriter_WriteProcessingInstruction(writer, L"a", L"a"); ok(hr == exp_hr, "Unexpected hr %#lx, expected %#lx.\n", hr, exp_hr); @@ -207,6 +221,8 @@ static void check_writer_state(IXmlWriter *writer, HRESULT exp_hr)
hr = IXmlWriter_WriteWhitespace(writer, L" "); ok(hr == exp_hr, "Unexpected hr %#lx, expected %#lx.\n", hr, exp_hr); + + IXmlReader_Release(reader); }
static IStream *writer_set_output(IXmlWriter *writer) @@ -354,8 +370,12 @@ static void test_writer_create(void)
static void test_invalid_output_encoding(IXmlWriter *writer, IUnknown *output) { + IXmlReader *reader; HRESULT hr;
+ hr = CreateXmlReader(&IID_IXmlReader, (void **)&reader, NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IXmlWriter_SetOutput(writer, output); ok(hr == S_OK, "Failed to set output, hr %#lx.\n", hr);
@@ -400,8 +420,12 @@ static void test_invalid_output_encoding(IXmlWriter *writer, IUnknown *output) hr = IXmlWriter_WriteNmToken(writer, L"a"); ok(hr == MX_E_ENCODING, "Unexpected hr %#lx.\n", hr);
- /* TODO: WriteNode */ - /* TODO: WriteNodeShallow */ + reader_set_input(reader, "<a/>"); + hr = IXmlWriter_WriteNode(writer, reader, FALSE); + ok(hr == MX_E_ENCODING, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteNodeShallow(writer, reader, FALSE); + ok(hr == MX_E_ENCODING, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_WriteProcessingInstruction(writer, L"a", L"a"); ok(hr == MX_E_ENCODING, "Unexpected hr %#lx.\n", hr); @@ -431,6 +455,8 @@ static void test_invalid_output_encoding(IXmlWriter *writer, IUnknown *output)
hr = IXmlWriter_Flush(writer); ok(hr == S_OK, "Failed to flush, hr %#lx.\n", hr); + + IXmlReader_Release(reader); }
static void test_writeroutput(void) @@ -2295,6 +2321,9 @@ static void test_WriteNode(void) hr = CreateXmlWriter(&IID_IXmlWriter, (void **)&writer, NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
+ hr = IXmlWriter_WriteNode(writer, NULL, FALSE); + ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); + hr = CreateXmlReader(&IID_IXmlReader, (void **)&reader, NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
@@ -2445,6 +2474,9 @@ static void test_WriteNodeShallow(void) hr = CreateXmlWriter(&IID_IXmlWriter, (void **)&writer, NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
+ hr = IXmlWriter_WriteNodeShallow(writer, NULL, FALSE); + ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); + hr = CreateXmlReader(&IID_IXmlReader, (void **)&reader, NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
diff --git a/dlls/xmllite/writer.c b/dlls/xmllite/writer.c index fb2784ab439..1e1a8e8ddb8 100644 --- a/dlls/xmllite/writer.c +++ b/dlls/xmllite/writer.c @@ -1600,6 +1600,9 @@ static HRESULT WINAPI xmlwriter_WriteNode(IXmlWriter *iface, IXmlReader *reader,
TRACE("%p, %p, %d.\n", iface, reader, write_default_attributes);
+ if (!reader) + return E_INVALIDARG; + if (SUCCEEDED(hr = writer_write_node(iface, reader, FALSE, write_default_attributes))) hr = IXmlReader_Read(reader, NULL);
@@ -1610,6 +1613,9 @@ static HRESULT WINAPI xmlwriter_WriteNodeShallow(IXmlWriter *iface, IXmlReader * { TRACE("%p, %p, %d.\n", iface, reader, write_default_attributes);
+ if (!reader) + return E_INVALIDARG; + return writer_write_node(iface, reader, TRUE, write_default_attributes); }