Commit 59f64b28 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

msxml3: Merge save() tests to a single function.

parent 1adbe826
...@@ -5629,10 +5629,15 @@ static void test_nodeTypeTests( void ) ...@@ -5629,10 +5629,15 @@ static void test_nodeTypeTests( void )
free_bstrs(); free_bstrs();
} }
static void test_DocumentSaveToDocument(void) static void test_save(void)
{ {
IXMLDOMDocument *doc, *doc2; IXMLDOMDocument *doc, *doc2;
IXMLDOMElement *pRoot; IXMLDOMElement *root;
VARIANT file, vDoc;
BSTR sOrig, sNew;
char buffer[100];
DWORD read = 0;
HANDLE hfile;
HRESULT hr; HRESULT hr;
doc = create_document(&IID_IXMLDOMDocument); doc = create_document(&IID_IXMLDOMDocument);
...@@ -5645,86 +5650,53 @@ static void test_DocumentSaveToDocument(void) ...@@ -5645,86 +5650,53 @@ static void test_DocumentSaveToDocument(void)
return; return;
} }
hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing"), &pRoot); /* save to IXMLDOMDocument */
ok(hr == S_OK, "ret %08x\n", hr ); hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing"), &root);
if(hr == S_OK) EXPECT_HR(hr, S_OK);
{
hr = IXMLDOMDocument_appendChild(doc, (IXMLDOMNode*)pRoot, NULL);
ok(hr == S_OK, "ret %08x\n", hr );
if(hr == S_OK)
{
VARIANT vDoc;
BSTR sOrig;
BSTR sNew;
V_VT(&vDoc) = VT_UNKNOWN;
V_UNKNOWN(&vDoc) = (IUnknown*)doc2;
hr = IXMLDOMDocument_save(doc, vDoc);
ok(hr == S_OK, "ret %08x\n", hr );
hr = IXMLDOMDocument_get_xml(doc, &sOrig); hr = IXMLDOMDocument_appendChild(doc, (IXMLDOMNode*)root, NULL);
ok(hr == S_OK, "ret %08x\n", hr ); EXPECT_HR(hr, S_OK);
hr = IXMLDOMDocument_get_xml(doc2, &sNew); V_VT(&vDoc) = VT_UNKNOWN;
ok(hr == S_OK, "ret %08x\n", hr ); V_UNKNOWN(&vDoc) = (IUnknown*)doc2;
ok( !lstrcmpW( sOrig, sNew ), "New document is not the same as origial\n"); hr = IXMLDOMDocument_save(doc, vDoc);
EXPECT_HR(hr, S_OK);
SysFreeString(sOrig); hr = IXMLDOMDocument_get_xml(doc, &sOrig);
SysFreeString(sNew); EXPECT_HR(hr, S_OK);
}
IXMLDOMElement_Release(pRoot);
}
IXMLDOMDocument_Release(doc2); hr = IXMLDOMDocument_get_xml(doc2, &sNew);
IXMLDOMDocument_Release(doc); EXPECT_HR(hr, S_OK);
}
static void test_DocumentSaveToFile(void) ok( !lstrcmpW( sOrig, sNew ), "New document is not the same as origial\n");
{
IXMLDOMDocument *doc;
IXMLDOMElement *pRoot;
HANDLE file;
char buffer[100];
DWORD read = 0;
HRESULT hr;
doc = create_document(&IID_IXMLDOMDocument); SysFreeString(sOrig);
if (!doc) return; SysFreeString(sNew);
hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing"), &pRoot); IXMLDOMElement_Release(root);
ok(hr == S_OK, "ret %08x\n", hr ); IXMLDOMDocument_Release(doc2);
if(hr == S_OK)
{
hr = IXMLDOMDocument_appendChild(doc, (IXMLDOMNode*)pRoot, NULL);
ok(hr == S_OK, "ret %08x\n", hr );
if(hr == S_OK)
{
VARIANT vFile;
V_VT(&vFile) = VT_BSTR; /* save to path */
V_BSTR(&vFile) = _bstr_("test.xml"); V_VT(&file) = VT_BSTR;
V_BSTR(&file) = _bstr_("test.xml");
hr = IXMLDOMDocument_save(doc, vFile); hr = IXMLDOMDocument_save(doc, file);
ok(hr == S_OK, "ret %08x\n", hr ); EXPECT_HR(hr, S_OK);
}
}
IXMLDOMElement_Release(pRoot);
IXMLDOMDocument_Release(doc); IXMLDOMDocument_Release(doc);
file = CreateFile("test.xml", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); hfile = CreateFile("test.xml", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
ok(file != INVALID_HANDLE_VALUE, "Could not open file: %u\n", GetLastError()); ok(hfile != INVALID_HANDLE_VALUE, "Could not open file: %u\n", GetLastError());
if(file == INVALID_HANDLE_VALUE) if(hfile == INVALID_HANDLE_VALUE) return;
return;
ReadFile(file, buffer, sizeof(buffer), &read, NULL); ReadFile(hfile, buffer, sizeof(buffer), &read, NULL);
ok(read != 0, "could not read file\n"); ok(read != 0, "could not read file\n");
ok(buffer[0] != '<' || buffer[1] != '?', "File contains processing instruction\n"); ok(buffer[0] != '<' || buffer[1] != '?', "File contains processing instruction\n");
CloseHandle(file); CloseHandle(hfile);
DeleteFile("test.xml"); DeleteFile("test.xml");
free_bstrs();
} }
static void test_testTransforms(void) static void test_testTransforms(void)
...@@ -8678,8 +8650,7 @@ START_TEST(domdoc) ...@@ -8678,8 +8650,7 @@ START_TEST(domdoc)
test_cloneNode(); test_cloneNode();
test_xmlTypes(); test_xmlTypes();
test_nodeTypeTests(); test_nodeTypeTests();
test_DocumentSaveToDocument(); test_save();
test_DocumentSaveToFile();
test_testTransforms(); test_testTransforms();
test_Namespaces(); test_Namespaces();
test_FormattingXML(); test_FormattingXML();
......
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