Author: cwittich
Date: Sat Feb 6 22:35:37 2010
New Revision: 45471
URL:
http://svn.reactos.org/svn/reactos?rev=45471&view=rev
Log:
[MSXML3_WINETEST]
sync msxml3_winetest to wine 1.1.38
Modified:
trunk/rostests/winetests/msxml3/domdoc.c
trunk/rostests/winetests/msxml3/saxreader.c
trunk/rostests/winetests/msxml3/xmldoc.c
trunk/rostests/winetests/msxml3/xmlelem.c
Modified: trunk/rostests/winetests/msxml3/domdoc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/msxml3/domdoc.c…
==============================================================================
--- trunk/rostests/winetests/msxml3/domdoc.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/msxml3/domdoc.c [iso-8859-1] Sat Feb 6 22:35:37 2010
@@ -509,8 +509,8 @@
return buf;
}
-#define expect_node(node, expstr) { char str[4096]; node_to_string(node, str);
ok(strcmp(str, expstr)==0, "Invalid node: %s, exptected %s\n", str, expstr); }
-#define expect_list_and_release(list, expstr) { char *str = list_to_string(list);
ok(strcmp(str, expstr)==0, "Invalid node list: %s, exptected %s\n", str,
expstr); if (list) IXMLDOMNodeList_Release(list); }
+#define expect_node(node, expstr) { char str[4096]; node_to_string(node, str);
ok(strcmp(str, expstr)==0, "Invalid node: %s, expected %s\n", str, expstr); }
+#define expect_list_and_release(list, expstr) { char *str = list_to_string(list);
ok(strcmp(str, expstr)==0, "Invalid node list: %s, expected %s\n", str, expstr);
if (list) IXMLDOMNodeList_Release(list); }
static void test_domdoc( void )
{
@@ -868,6 +868,77 @@
ok( !lstrcmpW( str, _bstr_("Begin This &is a Middle; test
<>\\Append End") ), "incorrect get_text string\n");
SysFreeString(str);
+ /* delete data */
+ /* invalid arguments */
+ r = IXMLDOMText_deleteData(nodetext, -1, 1);
+ ok(r == E_INVALIDARG, "ret %08x\n", r );
+
+ r = IXMLDOMText_deleteData(nodetext, 0, 0);
+ ok(r == S_OK, "ret %08x\n", r );
+
+ r = IXMLDOMText_deleteData(nodetext, 0, -1);
+ ok(r == E_INVALIDARG, "ret %08x\n", r );
+
+ r = IXMLDOMText_get_length(nodetext, &nLength);
+ ok(r == S_OK, "ret %08x\n", r );
+ ok(nLength == 43, "expected 43 got %d\n", nLength);
+
+ r = IXMLDOMText_deleteData(nodetext, nLength, 1);
+ ok(r == S_OK, "ret %08x\n", r );
+
+ r = IXMLDOMText_deleteData(nodetext, nLength+1, 1);
+ ok(r == E_INVALIDARG, "ret %08x\n", r );
+
+ /* delete from start */
+ r = IXMLDOMText_deleteData(nodetext, 0, 5);
+ ok(r == S_OK, "ret %08x\n", r );
+
+ r = IXMLDOMText_get_length(nodetext, &nLength);
+ ok(r == S_OK, "ret %08x\n", r );
+ ok(nLength == 38, "expected 38 got %d\n", nLength);
+
+ r = IXMLDOMText_get_text(nodetext, &str);
+ ok(r == S_OK, "ret %08x\n", r );
+ /* whitespace preserving needs to be handled here */
+ todo_wine ok( !lstrcmpW( str, _bstr_("This &is a Middle; test
<>\\Append End") ), "incorrect get_text string\n");
+ SysFreeString(str);
+
+ /* delete from end */
+ r = IXMLDOMText_deleteData(nodetext, 35, 3);
+ ok(r == S_OK, "ret %08x\n", r );
+
+ r = IXMLDOMText_get_length(nodetext, &nLength);
+ ok(r == S_OK, "ret %08x\n", r );
+ ok(nLength == 35, "expected 35 got %d\n", nLength);
+
+ r = IXMLDOMText_get_text(nodetext, &str);
+ ok(r == S_OK, "ret %08x\n", r );
+ todo_wine ok( !lstrcmpW( str, _bstr_("This &is a Middle; test
<>\\Append") ), "incorrect get_text string\n");
+ SysFreeString(str);
+
+ /* delete from inside */
+ r = IXMLDOMText_deleteData(nodetext, 1, 33);
+ ok(r == S_OK, "ret %08x\n", r );
+
+ r = IXMLDOMText_get_length(nodetext, &nLength);
+ ok(r == S_OK, "ret %08x\n", r );
+ ok(nLength == 2, "expected 2 got %d\n", nLength);
+
+ r = IXMLDOMText_get_text(nodetext, &str);
+ ok(r == S_OK, "ret %08x\n", r );
+ todo_wine ok( !lstrcmpW( str, _bstr_("") ), "incorrect get_text
string\n");
+ SysFreeString(str);
+
+ /* delete whole data ... */
+ r = IXMLDOMText_get_length(nodetext, &nLength);
+ ok(r == S_OK, "ret %08x\n", r );
+
+ r = IXMLDOMText_deleteData(nodetext, 0, nLength);
+ ok(r == S_OK, "ret %08x\n", r );
+ /* ... and try again with empty string */
+ r = IXMLDOMText_deleteData(nodetext, 0, nLength);
+ ok(r == S_OK, "ret %08x\n", r );
+
/* test put_data */
V_VT(&var) = VT_BSTR;
V_BSTR(&var) = SysAllocString(szstr1);
@@ -1071,6 +1142,7 @@
r = IXMLDOMNode_get_ownerDocument( element, &owner );
ok( r == S_OK, "get_ownerDocument return code\n");
ok( owner != doc, "get_ownerDocument return\n");
+ IXMLDOMDocument_Release(owner);
type = NODE_INVALID;
r = IXMLDOMNode_get_nodeType( element, &type);
@@ -2926,6 +2998,76 @@
ok( !lstrcmpW( str, _bstr_("Begin This &is a Middle; test
<>\\Append End") ), "incorrect get_text string\n");
SysFreeString(str);
+ /* delete data */
+ /* invalid arguments */
+ hr = IXMLDOMComment_deleteData(pComment, -1, 1);
+ ok(hr == E_INVALIDARG, "ret %08x\n", hr );
+
+ hr = IXMLDOMComment_deleteData(pComment, 0, 0);
+ ok(hr == S_OK, "ret %08x\n", hr );
+
+ hr = IXMLDOMComment_deleteData(pComment, 0, -1);
+ ok(hr == E_INVALIDARG, "ret %08x\n", hr );
+
+ hr = IXMLDOMComment_get_length(pComment, &len);
+ ok(hr == S_OK, "ret %08x\n", hr );
+ ok(len == 43, "expected 43 got %d\n", len);
+
+ hr = IXMLDOMComment_deleteData(pComment, len, 1);
+ ok(hr == S_OK, "ret %08x\n", hr );
+
+ hr = IXMLDOMComment_deleteData(pComment, len+1, 1);
+ ok(hr == E_INVALIDARG, "ret %08x\n", hr );
+
+ /* delete from start */
+ hr = IXMLDOMComment_deleteData(pComment, 0, 5);
+ ok(hr == S_OK, "ret %08x\n", hr );
+
+ hr = IXMLDOMComment_get_length(pComment, &len);
+ ok(hr == S_OK, "ret %08x\n", hr );
+ ok(len == 38, "expected 38 got %d\n", len);
+
+ hr = IXMLDOMComment_get_text(pComment, &str);
+ ok(hr == S_OK, "ret %08x\n", hr );
+ ok( !lstrcmpW( str, _bstr_(" This &is a Middle; test
<>\\Append End") ), "incorrect get_text string\n");
+ SysFreeString(str);
+
+ /* delete from end */
+ hr = IXMLDOMComment_deleteData(pComment, 35, 3);
+ ok(hr == S_OK, "ret %08x\n", hr );
+
+ hr = IXMLDOMComment_get_length(pComment, &len);
+ ok(hr == S_OK, "ret %08x\n", hr );
+ ok(len == 35, "expected 35 got %d\n", len);
+
+ hr = IXMLDOMComment_get_text(pComment, &str);
+ ok(hr == S_OK, "ret %08x\n", hr );
+ ok( !lstrcmpW( str, _bstr_(" This &is a Middle; test
<>\\Append ") ), "incorrect get_text string\n");
+ SysFreeString(str);
+
+ /* delete from inside */
+ hr = IXMLDOMComment_deleteData(pComment, 1, 33);
+ ok(hr == S_OK, "ret %08x\n", hr );
+
+ hr = IXMLDOMComment_get_length(pComment, &len);
+ ok(hr == S_OK, "ret %08x\n", hr );
+ ok(len == 2, "expected 2 got %d\n", len);
+
+ hr = IXMLDOMComment_get_text(pComment, &str);
+ ok(hr == S_OK, "ret %08x\n", hr );
+ ok( !lstrcmpW( str, _bstr_(" ") ), "incorrect get_text
string\n");
+ SysFreeString(str);
+
+ /* delete whole data ... */
+ hr = IXMLDOMComment_get_length(pComment, &len);
+ ok(hr == S_OK, "ret %08x\n", hr );
+
+ hr = IXMLDOMComment_deleteData(pComment, 0, len);
+ ok(hr == S_OK, "ret %08x\n", hr );
+ /* ... and try again with empty string */
+ hr = IXMLDOMComment_deleteData(pComment, 0, len);
+ ok(hr == S_OK, "ret %08x\n", hr );
+
IXMLDOMComment_Release(pComment);
}
@@ -3268,6 +3410,77 @@
ok(hr == S_OK, "ret %08x\n", hr );
ok( !lstrcmpW( str, _bstr_("Begin This &is a Middle; test
<>\\Append End") ), "incorrect get_text string\n");
SysFreeString(str);
+
+ /* delete data */
+ /* invalid arguments */
+ hr = IXMLDOMCDATASection_deleteData(pCDataSec, -1, 1);
+ ok(hr == E_INVALIDARG, "ret %08x\n", hr );
+
+ hr = IXMLDOMCDATASection_deleteData(pCDataSec, 0, 0);
+ ok(hr == S_OK, "ret %08x\n", hr );
+
+ hr = IXMLDOMCDATASection_deleteData(pCDataSec, 0, -1);
+ ok(hr == E_INVALIDARG, "ret %08x\n", hr );
+
+ hr = IXMLDOMCDATASection_get_length(pCDataSec, &len);
+ ok(hr == S_OK, "ret %08x\n", hr );
+ ok(len == 43, "expected 43 got %d\n", len);
+
+ hr = IXMLDOMCDATASection_deleteData(pCDataSec, len, 1);
+ ok(hr == S_OK, "ret %08x\n", hr );
+
+ hr = IXMLDOMCDATASection_deleteData(pCDataSec, len+1, 1);
+ ok(hr == E_INVALIDARG, "ret %08x\n", hr );
+
+ /* delete from start */
+ hr = IXMLDOMCDATASection_deleteData(pCDataSec, 0, 5);
+ ok(hr == S_OK, "ret %08x\n", hr );
+
+ hr = IXMLDOMCDATASection_get_length(pCDataSec, &len);
+ ok(hr == S_OK, "ret %08x\n", hr );
+ ok(len == 38, "expected 38 got %d\n", len);
+
+ hr = IXMLDOMCDATASection_get_text(pCDataSec, &str);
+ ok(hr == S_OK, "ret %08x\n", hr );
+ ok( !lstrcmpW( str, _bstr_(" This &is a Middle; test
<>\\Append End") ), "incorrect get_text string\n");
+ SysFreeString(str);
+
+ /* delete from end */
+ hr = IXMLDOMCDATASection_deleteData(pCDataSec, 35, 3);
+ ok(hr == S_OK, "ret %08x\n", hr );
+
+ hr = IXMLDOMCDATASection_get_length(pCDataSec, &len);
+ ok(hr == S_OK, "ret %08x\n", hr );
+ ok(len == 35, "expected 35 got %d\n", len);
+
+ hr = IXMLDOMCDATASection_get_text(pCDataSec, &str);
+ ok(hr == S_OK, "ret %08x\n", hr );
+ ok( !lstrcmpW( str, _bstr_(" This &is a Middle; test
<>\\Append ") ), "incorrect get_text string\n");
+ SysFreeString(str);
+
+ /* delete from inside */
+ hr = IXMLDOMCDATASection_deleteData(pCDataSec, 1, 33);
+ ok(hr == S_OK, "ret %08x\n", hr );
+
+ hr = IXMLDOMCDATASection_get_length(pCDataSec, &len);
+ ok(hr == S_OK, "ret %08x\n", hr );
+ ok(len == 2, "expected 2 got %d\n", len);
+
+ hr = IXMLDOMCDATASection_get_text(pCDataSec, &str);
+ ok(hr == S_OK, "ret %08x\n", hr );
+ ok( !lstrcmpW( str, _bstr_(" ") ), "incorrect get_text
string\n");
+ SysFreeString(str);
+
+ /* delete whole data ... */
+ hr = IXMLDOMCDATASection_get_length(pCDataSec, &len);
+ ok(hr == S_OK, "ret %08x\n", hr );
+
+ hr = IXMLDOMCDATASection_deleteData(pCDataSec, 0, len);
+ ok(hr == S_OK, "ret %08x\n", hr );
+
+ /* ... and try again with empty string */
+ hr = IXMLDOMCDATASection_deleteData(pCDataSec, 0, len);
+ ok(hr == S_OK, "ret %08x\n", hr );
IXMLDOMCDATASection_Release(pCDataSec);
}
Modified: trunk/rostests/winetests/msxml3/saxreader.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/msxml3/saxreade…
==============================================================================
--- trunk/rostests/winetests/msxml3/saxreader.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/msxml3/saxreader.c [iso-8859-1] Sat Feb 6 22:35:37 2010
@@ -520,6 +520,8 @@
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
test_expect_call(CH_ENDTEST);
+ VariantClear(&var);
+
SADim[0].lLbound= 0;
SADim[0].cElements= sizeof(szTestXML)-1;
pSA = SafeArrayCreate(VT_UI1, 1, SADim);
@@ -559,6 +561,8 @@
hr = ISAXXMLReader_parse(reader, var);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
test_expect_call(CH_ENDTEST);
+
+ VariantClear(&var);
file = CreateFileA(testXmlA, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL, NULL);
ok(file != INVALID_HANDLE_VALUE, "Could not create file: %u\n",
GetLastError());
@@ -591,6 +595,7 @@
IXMLDOMDocument_Release(domDocument);
ISAXXMLReader_Release(reader);
+ SysFreeString(bstrData);
}
START_TEST(saxreader)
Modified: trunk/rostests/winetests/msxml3/xmldoc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/msxml3/xmldoc.c…
==============================================================================
--- trunk/rostests/winetests/msxml3/xmldoc.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/msxml3/xmldoc.c [iso-8859-1] Sat Feb 6 22:35:37 2010
@@ -39,6 +39,7 @@
static const char data[] =
"<?xml version=\"1.0\" ?>\n"
+ "<!DOCTYPE BankAccount>\n"
"<BankAccount>\n"
" <Number>1234</Number>\n"
" <Name>Captain Ahab</Name>\n"
@@ -46,6 +47,33 @@
WriteFile(hf, data, sizeof(data) - 1, &dwNumberOfBytesWritten, NULL);
CloseHandle(hf);
+}
+
+static void create_stream_on_file(IStream **stream, LPCSTR path)
+{
+ HANDLE hfile;
+ HGLOBAL hglobal;
+ LPVOID ptr;
+ HRESULT hr;
+ DWORD file_size, read;
+
+ hfile = CreateFile(path, GENERIC_READ, FILE_SHARE_READ, NULL,
+ OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ ok(hfile != INVALID_HANDLE_VALUE, "Expected a valid file handle\n");
+ file_size = GetFileSize(hfile, NULL);
+
+ hglobal = GlobalAlloc(GHND, file_size);
+ ptr = GlobalLock(hglobal);
+
+ ReadFile(hfile, ptr, file_size, &read, NULL);
+ ok(file_size == read, "Expected to read the whole file, read %d\n", read);
+
+ hr = CreateStreamOnHGlobal(hglobal, TRUE, stream);
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+ ok(*stream != NULL, "Expected non-NULL stream\n");
+
+ CloseHandle(hfile);
+ GlobalUnlock(hglobal);
}
static void test_xmldoc(void)
@@ -56,10 +84,6 @@
IXMLElementCollection *collection = NULL, *inner = NULL;
IPersistStreamInit *psi = NULL;
IStream *stream = NULL;
- HGLOBAL hglobal;
- HANDLE hfile;
- LPVOID ptr;
- DWORD file_size, read;
CHAR path[MAX_PATH];
LONG type, num_child;
VARIANT vIndex, vName;
@@ -70,35 +94,15 @@
static const WCHAR szNumVal[] = {'1','2','3','4',0};
static const WCHAR szName[] = {'N','A','M','E',0};
static const WCHAR szNameVal[] =
{'C','a','p','t','a','i','n','
','A','h','a','b',0};
+ static const WCHAR szVersion[] = {'1','.','0',0};
hr = CoCreateInstance(&CLSID_XMLDocument, NULL, CLSCTX_INPROC_SERVER,
&IID_IXMLDocument, (LPVOID*)&doc);
- if (FAILED(hr))
- {
- skip("Failed to create XMLDocument instance\n");
- return;
- }
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
create_xml_file("bank.xml");
GetFullPathNameA("bank.xml", MAX_PATH, path, NULL);
-
- hfile = CreateFile(path, GENERIC_READ, FILE_SHARE_READ, NULL,
- OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
- ok(hfile != INVALID_HANDLE_VALUE, "Expected a valid file handle\n");
- file_size = GetFileSize(hfile, NULL);
-
- hglobal = GlobalAlloc(GHND, file_size);
- ptr = GlobalLock(hglobal);
-
- ReadFile(hfile, ptr, file_size, &read, NULL);
- ok(file_size == read, "Expected to read the whole file, read %d\n", read);
-
- hr = CreateStreamOnHGlobal(hglobal, TRUE, &stream);
- ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
- ok(stream != NULL, "Expected non-NULL stream\n");
-
- CloseHandle(hfile);
- GlobalUnlock(hglobal);
+ create_stream_on_file(&stream, path);
hr = IXMLDocument_QueryInterface(doc, &IID_IPersistStreamInit, (LPVOID
*)&psi);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
@@ -115,9 +119,34 @@
ok(stream != NULL, "Expected non-NULL stream\n");
+ /* version field */
+ hr = IXMLDocument_get_version(doc, NULL);
+ ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr);
+
+ hr = IXMLDocument_get_version(doc, &name);
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+ ok(!lstrcmpW(name, szVersion), "Expected 1.0, got %s\n",
wine_dbgstr_w(name));
+ SysFreeString(name);
+
+ /* doctype */
+ hr = IXMLDocument_get_doctype(doc, NULL);
+ ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr);
+
+ hr = IXMLDocument_get_doctype(doc, &name);
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+ ok(!lstrcmpW(name, szBankAccount), "Expected BANKACCOUNT, got %s\n",
wine_dbgstr_w(name));
+ SysFreeString(name);
+
hr = IXMLDocument_get_root(doc, &element);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
ok(element != NULL, "Expected non-NULL element\n");
+
+ /* ::root() returns new instance each time */
+ hr = IXMLDocument_get_root(doc, &child);
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+ ok(child != NULL, "Expected non-NULL element\n");
+ ok(child != element, "Expected new element instance\n");
+ IXMLElement_Release(child);
hr = IXMLElement_get_type(element, &type);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
@@ -251,11 +280,7 @@
hr = CoCreateInstance(&CLSID_XMLDocument, NULL, CLSCTX_INPROC_SERVER,
&IID_IXMLDocument, (LPVOID*)&doc);
- if (FAILED(hr))
- {
- skip("Failed to create XMLDocument instance\n");
- return;
- }
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
/* invalid vType type */
V_VT(&vType) = VT_NULL;
@@ -334,6 +359,142 @@
IXMLDocument_Release(doc);
}
+static void test_persiststreaminit(void)
+{
+ IXMLDocument *doc = NULL;
+ IXMLElement *element = NULL;
+ IPersistStreamInit *psi = NULL;
+ IStream *stream = NULL;
+ STATSTG stat;
+ HRESULT hr;
+ ULARGE_INTEGER size;
+ CHAR path[MAX_PATH];
+ CLSID id;
+ BSTR str;
+ static const WCHAR testW[] = {'t','e','s','t',0};
+
+ hr = CoCreateInstance(&CLSID_XMLDocument, NULL, CLSCTX_INPROC_SERVER,
+ &IID_IXMLDocument, (LPVOID*)&doc);
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+
+ hr = IXMLDocument_QueryInterface(doc, &IID_IPersistStreamInit, (LPVOID
*)&psi);
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+ ok(psi != NULL, "Expected non-NULL psi\n");
+
+ /* null arguments */
+ hr = IPersistStreamInit_GetSizeMax(psi, NULL);
+ ok(hr == E_NOTIMPL, "Expected E_NOTIMPL, got %08x\n", hr);
+
+ hr = IPersistStreamInit_Load(psi, NULL);
+ ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr);
+
+ hr = IPersistStreamInit_Save(psi, NULL, FALSE);
+ todo_wine ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr);
+
+ hr = IPersistStreamInit_GetClassID(psi, NULL);
+ ok(hr == E_POINTER, "Expected E_POINTER, got %08x\n", hr);
+
+ hr = IPersistStreamInit_IsDirty(psi);
+ todo_wine ok(hr == S_FALSE, "Expected S_FALSE, got %08x\n", hr);
+
+ create_xml_file("bank.xml");
+ GetFullPathNameA("bank.xml", MAX_PATH, path, NULL);
+ create_stream_on_file(&stream, path);
+
+ /* GetSizeMax not implemented */
+ size.QuadPart = 0;
+ hr = IPersistStreamInit_GetSizeMax(psi, &size);
+ ok(hr == E_NOTIMPL, "Expected E_NOTIMPL, got %08x\n", hr);
+ ok(size.QuadPart == 0, "Expected 0\n");
+
+ hr = IPersistStreamInit_Load(psi, stream);
+ IStream_Release(stream);
+ ok(hr == S_OK || hr == XML_E_INVALIDATROOTLEVEL, "Expected S_OK, got
%08x\n", hr);
+ if(hr == XML_E_INVALIDATROOTLEVEL)
+ goto cleanup;
+
+ hr = IPersistStreamInit_IsDirty(psi);
+ todo_wine ok(hr == S_FALSE, "Expected S_FALSE, got %08x\n", hr);
+
+ /* try to save document */
+ stream = NULL;
+ hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+ hr = IPersistStreamInit_Save(psi, stream, FALSE);
+ todo_wine ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+
+ stat.cbSize.QuadPart = 0;
+ hr = IStream_Stat(stream, &stat, 0);
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+ todo_wine ok(stat.cbSize.QuadPart > 0, "Expected >0\n");
+ IStream_Release(stream);
+
+ str = SysAllocString(testW);
+ hr = IXMLDocument_get_root(doc, &element);
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+ hr = IXMLElement_put_text(element, str);
+ IXMLElement_Release(element);
+ SysFreeString(str);
+
+ hr = IPersistStreamInit_IsDirty(psi);
+ todo_wine ok(hr == S_FALSE, "Expected S_FALSE, got %08x\n", hr);
+
+ create_stream_on_file(&stream, path);
+ hr = IPersistStreamInit_Load(psi, stream);
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+ IStream_Release(stream);
+
+ hr = IPersistStreamInit_IsDirty(psi);
+ todo_wine ok(hr == S_FALSE, "Expected S_FALSE, got %08x\n", hr);
+
+ /* reset internal stream */
+ hr = IPersistStreamInit_InitNew(psi);
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+
+ hr = IPersistStreamInit_IsDirty(psi);
+ todo_wine ok(hr == S_FALSE, "Expected S_FALSE, got %08x\n", hr);
+
+ stream = NULL;
+ hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+
+ hr = IPersistStreamInit_Save(psi, stream, FALSE);
+ todo_wine ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+
+ stat.cbSize.QuadPart = 0;
+ hr = IStream_Stat(stream, &stat, 0);
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+ todo_wine ok(stat.cbSize.QuadPart > 0, "Expected >0\n");
+ IStream_Release(stream);
+
+ memset(&id, 0, sizeof(id));
+ hr = IPersistStreamInit_GetClassID(psi, &id);
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+ ok(IsEqualCLSID(&id, &CLSID_XMLDocument), "Expected
CLSID_XMLDocument\n");
+
+cleanup:
+ IPersistStreamInit_Release(psi);
+ IXMLDocument_Release(doc);
+ DeleteFileA("bank.xml");
+}
+
+static BOOL test_try_xmldoc(void)
+{
+ IXMLDocument *doc = NULL;
+ HRESULT hr;
+
+ hr = CoCreateInstance(&CLSID_XMLDocument, NULL, CLSCTX_INPROC_SERVER,
+ &IID_IXMLDocument, (LPVOID*)&doc);
+ if (FAILED(hr))
+ {
+ skip("Failed to create XMLDocument instance\n");
+ return FALSE;
+ }
+
+ IXMLDocument_Release(doc);
+ return TRUE;
+}
+
START_TEST(xmldoc)
{
HRESULT hr;
@@ -341,8 +502,15 @@
hr = CoInitialize(NULL);
ok(hr == S_OK, "failed to init com\n");
+ if (!test_try_xmldoc())
+ {
+ CoUninitialize();
+ return;
+ }
+
test_xmldoc();
test_createElement();
+ test_persiststreaminit();
CoUninitialize();
}
Modified: trunk/rostests/winetests/msxml3/xmlelem.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/msxml3/xmlelem.…
==============================================================================
--- trunk/rostests/winetests/msxml3/xmlelem.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/msxml3/xmlelem.c [iso-8859-1] Sat Feb 6 22:35:37 2010
@@ -53,11 +53,7 @@
hr = CoCreateInstance(&CLSID_XMLDocument, NULL, CLSCTX_INPROC_SERVER,
&IID_IXMLDocument, (LPVOID*)&doc);
- if (FAILED(hr))
- {
- skip("Failed to create XMLDocument instance\n");
- return;
- }
+ ok(hr == S_OK, "Expected S_OK, got 0x%08x\n", hr);
V_VT(&vType) = VT_I4;
V_I4(&vType) = XMLELEMTYPE_ELEMENT;
@@ -265,11 +261,7 @@
hr = CoCreateInstance(&CLSID_XMLDocument, NULL, CLSCTX_INPROC_SERVER,
&IID_IXMLDocument, (LPVOID*)&doc);
- if (FAILED(hr))
- {
- skip("Failed to create XMLDocument instance\n");
- return;
- }
+ ok(hr == S_OK, "Expected S_OK, got 0x%08x\n", hr);
create_xml_file(szBankXML);
GetFullPathNameA(szBankXML, MAX_PATH, pathA, NULL);
@@ -438,6 +430,144 @@
DeleteFileA("bank.xml");
}
+static void test_xmlelem_children(void)
+{
+ IXMLDocument *doc = NULL;
+ IXMLElement *element = NULL, *child = NULL, *child2 = NULL;
+ IXMLElementCollection *collection = NULL;
+ VARIANT vType, vName, vIndex;
+ LONG length;
+ HRESULT hr;
+
+ hr = CoCreateInstance(&CLSID_XMLDocument, NULL, CLSCTX_INPROC_SERVER,
+ &IID_IXMLDocument, (LPVOID*)&doc);
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+
+ V_VT(&vType) = VT_I4;
+ V_I4(&vType) = XMLELEMTYPE_ELEMENT;
+ V_VT(&vName) = VT_NULL;
+ hr = IXMLDocument_createElement(doc, vType, vName, &element);
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+ ok(element != NULL, "Expected non-NULL element\n");
+
+ V_VT(&vType) = VT_I4;
+ V_I4(&vType) = XMLELEMTYPE_TEXT;
+ V_VT(&vName) = VT_NULL;
+ hr = IXMLDocument_createElement(doc, vType, vName, &child);
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+ ok(child != NULL, "Expected non-NULL child\n");
+
+ V_VT(&vType) = VT_I4;
+ V_I4(&vType) = XMLELEMTYPE_TEXT;
+ V_VT(&vName) = VT_NULL;
+ hr = IXMLDocument_createElement(doc, vType, vName, &child2);
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+ ok(child2 != NULL, "Expected non-NULL child\n");
+
+ hr = IXMLElement_addChild(element, child, 0, -1);
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+
+ hr = IXMLElement_get_children(element, &collection);
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+ ok(collection != NULL, "Expected non-NULL collection\n");
+
+ length = 0;
+ hr = IXMLElementCollection_get_length(collection, &length);
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+ ok(length == 1, "Expected 1, got %08x\n", length);
+
+ /* remove/add child and check what happens with collection */
+ hr = IXMLElement_removeChild(element, child);
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+
+ length = -1;
+ hr = IXMLElementCollection_get_length(collection, &length);
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+ ok(length == 0, "Expected 0, got %08x\n", length);
+ IXMLElementCollection_Release(collection);
+
+ hr = IXMLElement_AddRef(child);
+ ok(hr == 2, "Expected 2, got %08x\n", hr);
+ IXMLElement_Release(child);
+ hr = IXMLElement_addChild(element, child, 0, -1);
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+ hr = IXMLElement_AddRef(child);
+ ok(hr == 2, "Expected 2, got %08x\n", hr);
+ IXMLElement_Release(child);
+ hr = IXMLElement_addChild(element, child2, 0, -1);
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+
+ hr = IXMLElement_get_children(element, &collection);
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+ ok(collection != NULL, "Expected non-NULL collection\n");
+
+ hr = IXMLElement_AddRef(child);
+ ok(hr == 2, "Expected 2, got %08x\n", hr);
+ IXMLElement_Release(child);
+
+ length = 0;
+ hr = IXMLElementCollection_get_length(collection, &length);
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+ ok(length == 2, "Expected 2, got %08x\n", length);
+
+ IXMLElement_Release(child2);
+
+ length = 0;
+ hr = IXMLElementCollection_get_length(collection, &length);
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+ ok(length == 2, "Expected 2, got %08x\n", length);
+
+ V_VT(&vIndex) = VT_I4;
+ V_I4(&vIndex) = 1;
+ hr = IXMLElementCollection_item(collection, vIndex, vName, (IDispatch
**)&child2);
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+ ok(child2 != NULL, "Expected not NULL child\n");
+ IXMLElementCollection_Release(collection);
+ IXMLElement_Release(child2);
+
+ /* add element->child->child2 structure, then remove child2 from node */
+ V_VT(&vType) = VT_I4;
+ V_I4(&vType) = XMLELEMTYPE_TEXT;
+ V_VT(&vName) = VT_NULL;
+ hr = IXMLDocument_createElement(doc, vType, vName, &child2);
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+ ok(child2 != NULL, "Expected non-NULL child\n");
+
+ hr = IXMLElement_addChild(child, child2, 0, -1);
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+
+ hr = IXMLElement_removeChild(element, child2);
+ ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr);
+
+ hr = IXMLElement_removeChild(child, child2);
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+
+ hr = IXMLElement_removeChild(child, NULL);
+ ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr);
+
+ IXMLElement_Release(element);
+ IXMLElement_Release(child);
+ IXMLElement_Release(child2);
+ IXMLDocument_Release(doc);
+}
+
+static BOOL test_try_xmldoc(void)
+{
+ IXMLDocument *doc = NULL;
+ HRESULT hr;
+
+ hr = CoCreateInstance(&CLSID_XMLDocument, NULL, CLSCTX_INPROC_SERVER,
+ &IID_IXMLDocument, (LPVOID*)&doc);
+ if (FAILED(hr))
+ {
+ skip("Failed to create XMLDocument instance\n");
+ return FALSE;
+ }
+
+ IXMLDocument_Release(doc);
+ return TRUE;
+}
+
START_TEST(xmlelem)
{
HRESULT hr;
@@ -445,8 +575,15 @@
hr = CoInitialize(NULL);
ok(hr == S_OK, "failed to init com\n");
+ if (!test_try_xmldoc())
+ {
+ CoUninitialize();
+ return;
+ }
+
test_xmlelem();
test_xmlelem_collection();
+ test_xmlelem_children();
CoUninitialize();
}