xmllite/writer: Fix a bunch of Write* methods to set closed state.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2016-03-24 10:41:25 +03:00 committed by Alexandre Julliard
parent 2d9f6f7215
commit 1cb6fa5e84
2 changed files with 63 additions and 2 deletions

View File

@ -918,23 +918,76 @@ static void test_writer_state(void)
/* initial state */
check_writer_state(writer, E_UNEXPECTED);
/* set output and call 'wrong' method */
/* 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);
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);

View File

@ -626,7 +626,9 @@ static HRESULT WINAPI xmlwriter_WriteCData(IXmlWriter *iface, LPCWSTR data)
case XmlWriterState_ElemStarted:
writer_close_starttag(This);
break;
case XmlWriterState_Ready:
case XmlWriterState_DocClosed:
This->state = XmlWriterState_DocClosed;
return WR_E_INVALIDACTION;
default:
;
@ -912,7 +914,9 @@ static HRESULT WINAPI xmlwriter_WriteName(IXmlWriter *iface, LPCWSTR pwszName)
{
case XmlWriterState_Initial:
return E_UNEXPECTED;
case XmlWriterState_Ready:
case XmlWriterState_DocClosed:
This->state = XmlWriterState_DocClosed;
return WR_E_INVALIDACTION;
default:
;
@ -931,7 +935,9 @@ static HRESULT WINAPI xmlwriter_WriteNmToken(IXmlWriter *iface, LPCWSTR pwszNmTo
{
case XmlWriterState_Initial:
return E_UNEXPECTED;
case XmlWriterState_Ready:
case XmlWriterState_DocClosed:
This->state = XmlWriterState_DocClosed;
return WR_E_INVALIDACTION;
default:
;
@ -1136,7 +1142,9 @@ static HRESULT WINAPI xmlwriter_WriteString(IXmlWriter *iface, LPCWSTR pwszText)
{
case XmlWriterState_Initial:
return E_UNEXPECTED;
case XmlWriterState_Ready:
case XmlWriterState_DocClosed:
This->state = XmlWriterState_DocClosed;
return WR_E_INVALIDACTION;
default:
;