xmllite/writer: Fix WriteEndElement()/WriteFullEndElement() on ready 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-23 13:07:29 +03:00 committed by Alexandre Julliard
parent 6ca1ebdd25
commit e3a6d59324
2 changed files with 30 additions and 1 deletions

View File

@ -91,13 +91,14 @@ todo_wine
hr = IXmlWriter_WriteEndElement(writer);
ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr);
todo_wine {
hr = IXmlWriter_WriteEntityRef(writer, aW);
todo_wine
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);
todo_wine {
hr = IXmlWriter_WriteName(writer, aW);
ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr);
@ -915,13 +916,25 @@ static void test_WriteRaw(void)
static void test_writer_state(void)
{
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 */
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);
IXmlWriter_Release(writer);
}

View File

@ -788,6 +788,10 @@ static HRESULT WINAPI xmlwriter_WriteEndElement(IXmlWriter *iface)
{
case XmlWriterState_Initial:
return E_UNEXPECTED;
case XmlWriterState_Ready:
case XmlWriterState_DocClosed:
This->state = XmlWriterState_DocClosed;
return WR_E_INVALIDACTION;
default:
;
}
@ -827,6 +831,18 @@ static HRESULT WINAPI xmlwriter_WriteFullEndElement(IXmlWriter *iface)
TRACE("%p\n", This);
switch (This->state)
{
case XmlWriterState_Initial:
return E_UNEXPECTED;
case XmlWriterState_Ready:
case XmlWriterState_DocClosed:
This->state = XmlWriterState_DocClosed;
return WR_E_INVALIDACTION;
default:
;
}
element = pop_element(This);
if (!element)
return WR_E_INVALIDACTION;