From 8b2b455bd0f475333dc2b4b641aa4b871708bafd Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Thu, 14 Jul 2016 12:43:30 +0300 Subject: [PATCH] xmllite/writer: Close open tag with WriteFullEndElement(). Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/xmllite/tests/writer.c | 75 +++++++++++++++++++++++++++++++++++++ dlls/xmllite/writer.c | 4 +- 2 files changed, 78 insertions(+), 1 deletion(-) diff --git a/dlls/xmllite/tests/writer.c b/dlls/xmllite/tests/writer.c index 5e6769ce128..12433fa7de1 100644 --- a/dlls/xmllite/tests/writer.c +++ b/dlls/xmllite/tests/writer.c @@ -1143,6 +1143,80 @@ todo_wine IStream_Release(stream); } +static void test_WriteFullEndElement(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); + + /* 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); + + hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit); + 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_WriteFullEndElement(writer); + ok(hr == S_OK, "got 0x%08x\n", hr); + + hr = IXmlWriter_WriteEndDocument(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, + ""); + IStream_Release(stream); + + /* 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); + + hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit); + 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, aW, NULL); + ok(hr == S_OK, "got 0x%08x\n", hr); + + hr = IXmlWriter_WriteFullEndElement(writer); + ok(hr == S_OK, "got 0x%08x\n", hr); + + hr = IXmlWriter_WriteEndDocument(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, + "\r\n" + " \r\n" + ""); + + IXmlWriter_Release(writer); + IStream_Release(stream); +} + START_TEST(writer) { test_writer_create(); @@ -1160,4 +1234,5 @@ START_TEST(writer) test_WriteRaw(); test_indentation(); test_WriteAttributeString(); + test_WriteFullEndElement(); } diff --git a/dlls/xmllite/writer.c b/dlls/xmllite/writer.c index be5f0e10bc7..2e630ee4624 100644 --- a/dlls/xmllite/writer.c +++ b/dlls/xmllite/writer.c @@ -947,11 +947,13 @@ static HRESULT WINAPI xmlwriter_WriteFullEndElement(IXmlWriter *iface) if (!element) return WR_E_INVALIDACTION; + writer_close_starttag(This); + writer_dec_indent(This); + /* write full end tag */ write_output_buffer(This->output, closeelementW, ARRAY_SIZE(closeelementW)); write_output_buffer(This->output, element->qname, element->len); write_output_buffer(This->output, gtW, ARRAY_SIZE(gtW)); - This->starttagopen = FALSE; return S_OK; }