Commit b109c5c6 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

xmllite: Reset state to XmlReadState_Initial on input reset, update tests to run on new versions.

parent 58642340
...@@ -135,7 +135,7 @@ static HRESULT WINAPI xmlreader_SetInput(IXmlReader* iface, IUnknown *input) ...@@ -135,7 +135,7 @@ static HRESULT WINAPI xmlreader_SetInput(IXmlReader* iface, IUnknown *input)
/* just reset current input */ /* just reset current input */
if (!input) if (!input)
{ {
This->state = XmlReadState_Closed; This->state = XmlReadState_Initial;
return S_OK; return S_OK;
} }
......
...@@ -74,27 +74,35 @@ static IStream *create_stream_on_data(const char *data, int size) ...@@ -74,27 +74,35 @@ static IStream *create_stream_on_data(const char *data, int size)
return stream; return stream;
} }
static void ok_pos_(IXmlReader *reader, int line, int pos, int todo, int _line_) static void ok_pos_(IXmlReader *reader, int line, int pos, int line_broken,
int pos_broken, int todo, int _line_)
{ {
UINT l, p; UINT l, p;
HRESULT hr; HRESULT hr;
int broken_state;
hr = IXmlReader_GetLineNumber(reader, &l); hr = IXmlReader_GetLineNumber(reader, &l);
ok_(__FILE__, _line_)(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok_(__FILE__, _line_)(hr == S_OK, "Expected S_OK, got %08x\n", hr);
hr = IXmlReader_GetLinePosition(reader, &p); hr = IXmlReader_GetLinePosition(reader, &p);
ok_(__FILE__, _line_)(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok_(__FILE__, _line_)(hr == S_OK, "Expected S_OK, got %08x\n", hr);
if (line_broken == -1 && pos_broken == -1)
broken_state = 0;
else
broken_state = broken((line_broken == -1 ? line : line_broken) == l &&
(pos_broken == -1 ? pos : pos_broken) == p);
if (todo) if (todo)
todo_wine todo_wine
ok_(__FILE__, _line_)(l == line && pos == p, ok_(__FILE__, _line_)((l == line && pos == p) || broken_state,
"Expected (%d,%d), got (%d,%d)\n", line, pos, l, p); "Expected (%d,%d), got (%d,%d)\n", line, pos, l, p);
else else
{ {
ok_(__FILE__, _line_)(l == line && pos == p, ok_(__FILE__, _line_)((l == line && pos == p) || broken_state,
"Expected (%d,%d), got (%d,%d)\n", line, pos, l, p); "Expected (%d,%d), got (%d,%d)\n", line, pos, l, p);
} }
} }
#define ok_pos(reader, l, p, todo) ok_pos_(reader, l, p, todo, __LINE__) #define ok_pos(reader, l, p, l_brk, p_brk, todo) ok_pos_(reader, l, p, l_brk, p_brk, todo, __LINE__)
typedef struct input_iids_t { typedef struct input_iids_t {
IID iids[10]; IID iids[10];
...@@ -214,27 +222,34 @@ static const char *type_to_str(XmlNodeType type) ...@@ -214,27 +222,34 @@ static const char *type_to_str(XmlNodeType type)
} }
} }
static void test_read_state_(IXmlReader *reader, XmlReadState expected, int todo, int line) static void test_read_state_(IXmlReader *reader, XmlReadState expected,
XmlReadState exp_broken, int todo, int line)
{ {
XmlReadState state; XmlReadState state;
HRESULT hr; HRESULT hr;
int broken_state;
state = -1; /* invalid value */ state = -1; /* invalid value */
hr = IXmlReader_GetProperty(reader, XmlReaderProperty_ReadState, (LONG_PTR*)&state); hr = IXmlReader_GetProperty(reader, XmlReaderProperty_ReadState, (LONG_PTR*)&state);
ok_(__FILE__, line)(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok_(__FILE__, line)(hr == S_OK, "Expected S_OK, got %08x\n", hr);
if (exp_broken == -1)
broken_state = 0;
else
broken_state = broken(exp_broken == state);
if (todo) if (todo)
{ {
todo_wine todo_wine
ok_(__FILE__, line)(state == expected, "Expected (%s), got (%s)\n", ok_(__FILE__, line)(state == expected || broken_state, "Expected (%s), got (%s)\n",
state_to_str(expected), state_to_str(state)); state_to_str(expected), state_to_str(state));
} }
else else
ok_(__FILE__, line)(state == expected, "Expected (%s), got (%s)\n", ok_(__FILE__, line)(state == expected || broken_state, "Expected (%s), got (%s)\n",
state_to_str(expected), state_to_str(state)); state_to_str(expected), state_to_str(state));
} }
#define test_read_sate(reader, exp, todo) test_read_state_(reader, exp, todo, __LINE__) #define test_read_sate(reader, exp, brk, todo) test_read_state_(reader, exp, brk, todo, __LINE__)
typedef struct _testinput typedef struct _testinput
{ {
...@@ -340,13 +355,13 @@ static void test_reader_create(void) ...@@ -340,13 +355,13 @@ static void test_reader_create(void)
hr = pCreateXmlReader(&IID_IXmlReader, (LPVOID*)&reader, NULL); hr = pCreateXmlReader(&IID_IXmlReader, (LPVOID*)&reader, NULL);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
test_read_sate(reader, XmlReadState_Closed, FALSE); test_read_sate(reader, XmlReadState_Closed, -1, FALSE);
/* Null input pointer, releases previous input */ /* Null input pointer, releases previous input */
hr = IXmlReader_SetInput(reader, NULL); hr = IXmlReader_SetInput(reader, NULL);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
test_read_sate(reader, XmlReadState_Closed, FALSE); test_read_sate(reader, XmlReadState_Initial, XmlReadState_Closed, FALSE);
/* test input interface selection sequence */ /* test input interface selection sequence */
hr = testinput_createinstance((void**)&input); hr = testinput_createinstance((void**)&input);
...@@ -401,7 +416,7 @@ static void test_readerinput(void) ...@@ -401,7 +416,7 @@ static void test_readerinput(void)
hr = IXmlReader_SetInput(reader, reader_input); hr = IXmlReader_SetInput(reader, reader_input);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
test_read_sate(reader, XmlReadState_Initial, FALSE); test_read_sate(reader, XmlReadState_Initial, -1, FALSE);
/* IXmlReader grabs a IXmlReaderInput reference */ /* IXmlReader grabs a IXmlReaderInput reference */
ref = IUnknown_AddRef(reader_input); ref = IUnknown_AddRef(reader_input);
...@@ -416,7 +431,7 @@ static void test_readerinput(void) ...@@ -416,7 +431,7 @@ static void test_readerinput(void)
hr = IXmlReader_SetInput(reader, NULL); hr = IXmlReader_SetInput(reader, NULL);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
test_read_sate(reader, XmlReadState_Closed, FALSE); test_read_sate(reader, XmlReadState_Initial, XmlReadState_Closed, FALSE);
IXmlReader_Release(reader); IXmlReader_Release(reader);
...@@ -473,7 +488,7 @@ static void test_readerinput(void) ...@@ -473,7 +488,7 @@ static void test_readerinput(void)
ok(hr == E_NOINTERFACE, "Expected E_NOINTERFACE, got %08x\n", hr); ok(hr == E_NOINTERFACE, "Expected E_NOINTERFACE, got %08x\n", hr);
ok_iids(&input_iids, setinput_readerinput, NULL, FALSE); ok_iids(&input_iids, setinput_readerinput, NULL, FALSE);
test_read_sate(reader, XmlReadState_Closed, FALSE); test_read_sate(reader, XmlReadState_Closed, -1, FALSE);
ref = IUnknown_AddRef(input); ref = IUnknown_AddRef(input);
ok(ref == 3, "Expected 3, got %d\n", ref); ok(ref == 3, "Expected 3, got %d\n", ref);
...@@ -545,7 +560,7 @@ static void test_read_xmldeclaration(void) ...@@ -545,7 +560,7 @@ static void test_read_xmldeclaration(void)
hr = IXmlReader_SetInput(reader, (IUnknown*)stream); hr = IXmlReader_SetInput(reader, (IUnknown*)stream);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
ok_pos(reader, 0, 0, FALSE); ok_pos(reader, 0, 0, -1, -1, FALSE);
type = -1; type = -1;
hr = IXmlReader_Read(reader, &type); hr = IXmlReader_Read(reader, &type);
...@@ -554,16 +569,17 @@ todo_wine { ...@@ -554,16 +569,17 @@ todo_wine {
ok(type == XmlNodeType_XmlDeclaration, ok(type == XmlNodeType_XmlDeclaration,
"Expected XmlNodeType_XmlDeclaration, got %s\n", type_to_str(type)); "Expected XmlNodeType_XmlDeclaration, got %s\n", type_to_str(type));
} }
ok_pos(reader, 1, 55, TRUE); /* new version 1.2.x and 1.3.x properly update postition for <?xml ?> */
ok_pos(reader, 1, 3, -1, 55, TRUE);
/* check attributes */ /* check attributes */
hr = IXmlReader_MoveToNextAttribute(reader); hr = IXmlReader_MoveToNextAttribute(reader);
todo_wine ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); todo_wine ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
ok_pos(reader, 1, 55, TRUE); ok_pos(reader, 1, 7, -1, 55, TRUE);
hr = IXmlReader_MoveToFirstAttribute(reader); hr = IXmlReader_MoveToFirstAttribute(reader);
todo_wine ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); todo_wine ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
ok_pos(reader, 1, 55, TRUE); ok_pos(reader, 1, 7, -1, 55, TRUE);
hr = IXmlReader_GetAttributeCount(reader, &count); hr = IXmlReader_GetAttributeCount(reader, &count);
todo_wine { todo_wine {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment