mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 08:25:03 +00:00
[MSXML3_WINETEST]
* Addendum to r57257. svn path=/trunk/; revision=57258
This commit is contained in:
parent
082857b9ec
commit
0d50ee63ce
13 changed files with 16514 additions and 2913 deletions
|
@ -1,7 +1,5 @@
|
|||
|
||||
add_definitions(
|
||||
-D__ROS_LONG64__
|
||||
-D_DLL -D__USE_CRTIMP)
|
||||
add_definitions(-D__ROS_LONG64__)
|
||||
|
||||
list(APPEND SOURCE
|
||||
domdoc.c
|
||||
|
@ -9,9 +7,12 @@ list(APPEND SOURCE
|
|||
schema.c
|
||||
testlist.c
|
||||
xmldoc.c
|
||||
xmlelem.c)
|
||||
xmlparser.c
|
||||
xmlview.c)
|
||||
|
||||
add_executable(msxml3_winetest ${SOURCE})
|
||||
add_executable(msxml3_winetest ${SOURCE} rsrc.rc)
|
||||
add_idl_headers(xmlparser_idlheader_test xmlparser.idl)
|
||||
add_dependencies(msxml3_winetest xmlparser_idlheader_test)
|
||||
target_link_libraries(msxml3_winetest wine)
|
||||
set_module_type(msxml3_winetest win32cui)
|
||||
add_importlibs(msxml3_winetest user32 ole32 oleaut32 msvcrt kernel32 ntdll)
|
||||
|
|
File diff suppressed because it is too large
Load diff
23
rostests/winetests/msxml3/rsrc.rc
Normal file
23
rostests/winetests/msxml3/rsrc.rc
Normal file
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Copyright 2012 Piotr Caban for CodeWeavers
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/* @makedep: xmlview.xml */
|
||||
xmlview.xml XML "xmlview.xml"
|
||||
|
||||
/* @makedep: xmlview.xsl */
|
||||
xmlview.xsl XML "xmlview.xsl"
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -10,7 +10,8 @@ extern void func_domdoc(void);
|
|||
extern void func_saxreader(void);
|
||||
extern void func_schema(void);
|
||||
extern void func_xmldoc(void);
|
||||
extern void func_xmlelem(void);
|
||||
extern void func_xmlparser(void);
|
||||
extern void func_xmlview(void);
|
||||
|
||||
const struct test winetest_testlist[] =
|
||||
{
|
||||
|
@ -18,6 +19,7 @@ const struct test winetest_testlist[] =
|
|||
{ "saxreader", func_saxreader },
|
||||
{ "schema", func_schema },
|
||||
{ "xmldoc", func_xmldoc },
|
||||
{ "xmlelem", func_xmlelem },
|
||||
{ "xmlparser", func_xmlparser },
|
||||
{ "xmlview", func_xmlview },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
|
|
@ -24,10 +24,14 @@
|
|||
#include "windows.h"
|
||||
#include "ole2.h"
|
||||
#include "msxml2.h"
|
||||
#include "msxml2did.h"
|
||||
#include "ocidl.h"
|
||||
|
||||
#include "wine/test.h"
|
||||
|
||||
#define EXPECT_HR(hr,hr_exp) \
|
||||
ok(hr == hr_exp, "got 0x%08x, expected 0x%08x\n", hr, hr_exp)
|
||||
|
||||
/* Deprecated Error Code */
|
||||
#define XML_E_INVALIDATROOTLEVEL 0xc00ce556
|
||||
|
||||
|
@ -78,16 +82,18 @@ static void create_stream_on_file(IStream **stream, LPCSTR path)
|
|||
|
||||
static void test_xmldoc(void)
|
||||
{
|
||||
HRESULT hr;
|
||||
IXMLDocument *doc = NULL;
|
||||
IXMLElement *element = NULL, *child = NULL, *value = NULL;
|
||||
IXMLElementCollection *collection = NULL, *inner = NULL;
|
||||
IPersistStreamInit *psi = NULL;
|
||||
IXMLDocument *doc = NULL;
|
||||
IStream *stream = NULL;
|
||||
CHAR path[MAX_PATH];
|
||||
LONG type, num_child;
|
||||
VARIANT vIndex, vName;
|
||||
BSTR name = NULL;
|
||||
LONG type, num_child;
|
||||
CHAR path[MAX_PATH];
|
||||
IDispatch *disp;
|
||||
ITypeInfo *ti;
|
||||
HRESULT hr;
|
||||
BSTR name;
|
||||
|
||||
static const WCHAR szBankAccount[] = {'B','A','N','K','A','C','C','O','U','N','T',0};
|
||||
static const WCHAR szNumber[] = {'N','U','M','B','E','R',0};
|
||||
|
@ -95,16 +101,36 @@ static void test_xmldoc(void)
|
|||
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};
|
||||
static const WCHAR rootW[] = {'r','o','o','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);
|
||||
&IID_IXMLDocument, (void**)&doc);
|
||||
EXPECT_HR(hr, S_OK);
|
||||
|
||||
/* IDispatch */
|
||||
hr = IXMLDocument_QueryInterface(doc, &IID_IDispatch, (void**)&disp);
|
||||
EXPECT_HR(hr, S_OK);
|
||||
|
||||
/* just to make sure we're on right type data */
|
||||
hr = IDispatch_GetTypeInfo(disp, 0, 0, &ti);
|
||||
EXPECT_HR(hr, S_OK);
|
||||
name = NULL;
|
||||
hr = ITypeInfo_GetDocumentation(ti, DISPID_XMLDOCUMENT_ROOT, &name, NULL, NULL, NULL);
|
||||
EXPECT_HR(hr, S_OK);
|
||||
ok(!lstrcmpW(name, rootW), "got name %s\n", wine_dbgstr_w(name));
|
||||
SysFreeString(name);
|
||||
|
||||
ITypeInfo_Release(ti);
|
||||
IDispatch_Release(disp);
|
||||
|
||||
hr = IXMLDocument_QueryInterface(doc, &IID_IXMLDOMDocument, (void**)&disp);
|
||||
EXPECT_HR(hr, E_NOINTERFACE);
|
||||
|
||||
create_xml_file("bank.xml");
|
||||
GetFullPathNameA("bank.xml", MAX_PATH, path, NULL);
|
||||
create_stream_on_file(&stream, path);
|
||||
|
||||
hr = IXMLDocument_QueryInterface(doc, &IID_IPersistStreamInit, (LPVOID *)&psi);
|
||||
hr = IXMLDocument_QueryInterface(doc, &IID_IPersistStreamInit, (void**)&psi);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(psi != NULL, "Expected non-NULL psi\n");
|
||||
|
||||
|
@ -123,6 +149,7 @@ static void test_xmldoc(void)
|
|||
hr = IXMLDocument_get_version(doc, NULL);
|
||||
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr);
|
||||
|
||||
name = NULL;
|
||||
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));
|
||||
|
@ -433,6 +460,7 @@ static void test_persiststreaminit(void)
|
|||
hr = IXMLDocument_get_root(doc, &element);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
hr = IXMLElement_put_text(element, str);
|
||||
ok(hr == E_NOTIMPL, "Expected E_NOTIMPL, got %08x\n", hr);
|
||||
IXMLElement_Release(element);
|
||||
SysFreeString(str);
|
||||
|
||||
|
@ -495,6 +523,536 @@ static BOOL test_try_xmldoc(void)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
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 void test_xmlelem_collection(void)
|
||||
{
|
||||
HRESULT hr;
|
||||
IUnknown *unk = NULL;
|
||||
IXMLDocument *doc = NULL;
|
||||
IXMLElement *element = NULL, *child;
|
||||
IXMLElementCollection *collection = NULL;
|
||||
IEnumVARIANT *enumVar = NULL;
|
||||
CHAR pathA[MAX_PATH];
|
||||
WCHAR path[MAX_PATH];
|
||||
LONG length, type;
|
||||
ULONG num_vars;
|
||||
VARIANT var, vIndex, vName;
|
||||
BSTR url, str;
|
||||
static const CHAR szBankXML[] = "bank.xml";
|
||||
static const WCHAR szNumber[] = {'N','U','M','B','E','R',0};
|
||||
static const WCHAR szName[] = {'N','A','M','E',0};
|
||||
|
||||
hr = CoCreateInstance(&CLSID_XMLDocument, NULL, CLSCTX_INPROC_SERVER,
|
||||
&IID_IXMLDocument, (LPVOID*)&doc);
|
||||
ok(hr == S_OK, "Expected S_OK, got 0x%08x\n", hr);
|
||||
|
||||
create_xml_file(szBankXML);
|
||||
GetFullPathNameA(szBankXML, MAX_PATH, pathA, NULL);
|
||||
MultiByteToWideChar(CP_ACP, 0, pathA, -1, path, MAX_PATH);
|
||||
|
||||
url = SysAllocString(path);
|
||||
hr = IXMLDocument_put_URL(doc, url);
|
||||
ok(hr == S_OK, "Expected S_OK, got 0x%08x\n", hr);
|
||||
SysFreeString(url);
|
||||
|
||||
if(hr != S_OK)
|
||||
goto cleanup;
|
||||
|
||||
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");
|
||||
|
||||
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 = IXMLElementCollection_get_length(collection, NULL);
|
||||
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr);
|
||||
|
||||
hr = IXMLElementCollection_get_length(collection, &length);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(length == 2, "Expected 2, got %d\n", length);
|
||||
|
||||
/* IXMLElementCollection:put_length does nothing */
|
||||
hr = IXMLElementCollection_put_length(collection, -1);
|
||||
ok(hr == E_FAIL, "Expected E_FAIL, got %08x\n", hr);
|
||||
|
||||
hr = IXMLElementCollection_put_length(collection, 0);
|
||||
ok(hr == E_FAIL, "Expected E_FAIL, got %08x\n", hr);
|
||||
|
||||
hr = IXMLElementCollection_put_length(collection, 1);
|
||||
ok(hr == E_FAIL, "Expected E_FAIL, got %08x\n", hr);
|
||||
|
||||
hr = IXMLElementCollection_put_length(collection, 2);
|
||||
ok(hr == E_FAIL, "Expected E_FAIL, got %08x\n", hr);
|
||||
|
||||
hr = IXMLElementCollection_put_length(collection, 3);
|
||||
ok(hr == E_FAIL, "Expected E_FAIL, got %08x\n", hr);
|
||||
|
||||
hr = IXMLElementCollection_put_length(collection, 50);
|
||||
ok(hr == E_FAIL, "Expected E_FAIL, got %08x\n", hr);
|
||||
|
||||
/* make sure the length hasn't changed */
|
||||
hr = IXMLElementCollection_get_length(collection, &length);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(length == 2, "Expected 2, got %d\n", length);
|
||||
|
||||
/* IXMLElementCollection implements IEnumVARIANT */
|
||||
hr = IXMLElementCollection_QueryInterface(collection, &IID_IEnumVARIANT, (LPVOID *)&enumVar);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(enumVar != NULL, "Expected non-NULL enumVar\n");
|
||||
IEnumVARIANT_Release(enumVar);
|
||||
|
||||
hr = IXMLElementCollection_get__newEnum(collection, &unk);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(unk != NULL, "Expected non-NULL unk\n");
|
||||
|
||||
hr = IUnknown_QueryInterface(unk, &IID_IEnumVARIANT, (LPVOID *)&enumVar);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(enumVar != NULL, "Expected non-NULL enumVar\n");
|
||||
IUnknown_Release(unk);
|
||||
|
||||
/* <Number>1234</Number> */
|
||||
hr = IEnumVARIANT_Next(enumVar, 1, &var, &num_vars);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(V_VT(&var) == VT_DISPATCH, "Expected VT_DISPATCH, got %d\n", V_VT(&var));
|
||||
ok(num_vars == 1, "Expected 1, got %d\n", num_vars);
|
||||
|
||||
hr = IDispatch_QueryInterface(V_DISPATCH(&var), &IID_IXMLElement, (LPVOID *)&child);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(child != NULL, "Expected non-NULL child\n");
|
||||
|
||||
VariantClear(&var);
|
||||
|
||||
hr = IXMLElement_get_type(child, &type);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(type == XMLELEMTYPE_ELEMENT, "Expected XMLELEMTYPE_ELEMENT, got %d\n", type);
|
||||
|
||||
hr = IXMLElement_get_tagName(child, &str);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(!lstrcmpW(str, szNumber), "Expected NUMBER\n");
|
||||
SysFreeString(str);
|
||||
IXMLElement_Release(child);
|
||||
|
||||
/* <Name>Captain Ahab</Name> */
|
||||
hr = IEnumVARIANT_Next(enumVar, 1, &var, &num_vars);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(V_VT(&var) == VT_DISPATCH, "Expected VT_DISPATCH, got %d\n", V_VT(&var));
|
||||
ok(num_vars == 1, "Expected 1, got %d\n", num_vars);
|
||||
|
||||
/* try advance further, no children left */
|
||||
hr = IEnumVARIANT_Next(enumVar, 1, &var, &num_vars);
|
||||
ok(hr == S_FALSE, "Expected S_FALSE, got %08x\n", hr);
|
||||
ok(V_VT(&var) == 0, "Expected 0, got %d\n", V_VT(&var));
|
||||
ok(num_vars == 0, "Expected 0, got %d\n", num_vars);
|
||||
|
||||
hr = IEnumVARIANT_Next(enumVar, 1, &var, NULL);
|
||||
ok(hr == S_FALSE, "Expected S_FALSE, got %08x\n", hr);
|
||||
ok(V_VT(&var) == 0, "Expected 0, got %d\n", V_VT(&var));
|
||||
|
||||
hr = IDispatch_QueryInterface(V_DISPATCH(&var), &IID_IXMLElement, (LPVOID *)&child);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(child != NULL, "Expected non-NULL child\n");
|
||||
|
||||
VariantClear(&var);
|
||||
|
||||
hr = IXMLElement_get_type(child, &type);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(type == XMLELEMTYPE_ELEMENT, "Expected XMLELEMTYPE_ELEMENT, got %d\n", type);
|
||||
|
||||
hr = IXMLElement_get_tagName(child, &str);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(!lstrcmpW(str, szName), "Expected NAME\n");
|
||||
SysFreeString(str);
|
||||
IXMLElement_Release(child);
|
||||
|
||||
/* <Number>1234</Number> */
|
||||
V_VT(&vIndex) = VT_I4;
|
||||
V_I4(&vIndex) = 0;
|
||||
V_VT(&vName) = VT_ERROR;
|
||||
V_ERROR(&vName) = DISP_E_PARAMNOTFOUND;
|
||||
hr = IXMLElementCollection_item(collection, vIndex, vName, (IDispatch **)&child);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(child != NULL, "Expected non-NULL child\n");
|
||||
|
||||
hr = IXMLElement_get_type(child, &type);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(type == XMLELEMTYPE_ELEMENT, "Expected XMLELEMTYPE_ELEMENT, got %d\n", type);
|
||||
|
||||
hr = IXMLElement_get_tagName(child, &str);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(!lstrcmpW(str, szNumber), "Expected NUMBER\n");
|
||||
SysFreeString(str);
|
||||
IXMLElement_Release(child);
|
||||
|
||||
/* <Name>Captain Ahab</Name> */
|
||||
V_VT(&vIndex) = VT_I4;
|
||||
V_I4(&vIndex) = 1;
|
||||
V_VT(&vName) = VT_ERROR;
|
||||
V_ERROR(&vName) = DISP_E_PARAMNOTFOUND;
|
||||
hr = IXMLElementCollection_item(collection, vIndex, vName, (IDispatch **)&child);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(child != NULL, "Expected non-NULL child\n");
|
||||
|
||||
hr = IXMLElement_get_type(child, &type);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(type == XMLELEMTYPE_ELEMENT, "Expected XMLELEMTYPE_ELEMENT, got %d\n", type);
|
||||
|
||||
hr = IXMLElement_get_tagName(child, &str);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(!lstrcmpW(str, szName), "Expected NAME\n");
|
||||
SysFreeString(str);
|
||||
IXMLElement_Release(child);
|
||||
|
||||
V_I4(&vIndex) = 100;
|
||||
hr = IXMLElementCollection_item(collection, vIndex, vName, (IDispatch **)&child);
|
||||
ok(hr == E_FAIL, "Expected E_FAIL, got %08x\n", hr);
|
||||
ok(child == NULL, "Expected NULL child\n");
|
||||
|
||||
V_I4(&vIndex) = -1;
|
||||
child = (IXMLElement *)0xdeadbeef;
|
||||
hr = IXMLElementCollection_item(collection, vIndex, vName, (IDispatch **)&child);
|
||||
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr);
|
||||
ok(child == NULL, "Expected NULL child\n");
|
||||
|
||||
IEnumVARIANT_Release(enumVar);
|
||||
IXMLElement_Release(element);
|
||||
IXMLElementCollection_Release(collection);
|
||||
cleanup:
|
||||
IXMLDocument_Release(doc);
|
||||
DeleteFileA("bank.xml");
|
||||
}
|
||||
|
||||
static void test_xmlelem(void)
|
||||
{
|
||||
HRESULT hr;
|
||||
IXMLDocument *doc = NULL;
|
||||
IXMLElement *element = NULL, *parent;
|
||||
IXMLElement *child, *child2;
|
||||
IXMLElementCollection *children;
|
||||
VARIANT vType, vName;
|
||||
VARIANT vIndex, vValue;
|
||||
BSTR str, val, name;
|
||||
LONG type, num_child;
|
||||
IDispatch *disp;
|
||||
ITypeInfo *ti;
|
||||
|
||||
static const WCHAR propName[] = {'p','r','o','p',0};
|
||||
static const WCHAR propVal[] = {'v','a','l',0};
|
||||
static const WCHAR nextVal[] = {'n','e','x','t',0};
|
||||
static const WCHAR noexist[] = {'n','o','e','x','i','s','t',0};
|
||||
static const WCHAR crazyCase1[] = {'C','R','a','z','Y','c','A','S','E',0};
|
||||
static const WCHAR crazyCase2[] = {'C','R','A','Z','Y','C','A','S','E',0};
|
||||
|
||||
hr = CoCreateInstance(&CLSID_XMLDocument, NULL, CLSCTX_INPROC_SERVER,
|
||||
&IID_IXMLDocument, (LPVOID*)&doc);
|
||||
EXPECT_HR(hr, S_OK);
|
||||
|
||||
V_VT(&vType) = VT_I4;
|
||||
V_I4(&vType) = XMLELEMTYPE_ELEMENT;
|
||||
V_VT(&vName) = VT_NULL;
|
||||
hr = IXMLDocument_createElement(doc, vType, vName, &element);
|
||||
EXPECT_HR(hr, S_OK);
|
||||
ok(element != NULL, "Expected non-NULL element\n");
|
||||
|
||||
/* test for IDispatch */
|
||||
disp = NULL;
|
||||
hr = IXMLElement_QueryInterface(element, &IID_IDispatch, (void**)&disp);
|
||||
EXPECT_HR(hr, S_OK);
|
||||
|
||||
hr = IDispatch_GetTypeInfo(disp, 0, 0, &ti);
|
||||
EXPECT_HR(hr, S_OK);
|
||||
|
||||
name = NULL;
|
||||
hr = ITypeInfo_GetDocumentation(ti, DISPID_XMLELEMENT_TAGNAME, &name, NULL, NULL, NULL);
|
||||
EXPECT_HR(hr, S_OK);
|
||||
SysFreeString(name);
|
||||
|
||||
ITypeInfo_Release(ti);
|
||||
IDispatch_Release(disp);
|
||||
|
||||
hr = IXMLElement_get_tagName(element, &str);
|
||||
EXPECT_HR(hr, S_OK);
|
||||
ok(lstrlenW(str) == 0, "Expected empty tag name\n");
|
||||
SysFreeString(str);
|
||||
|
||||
parent = (IXMLElement *)0xdeadbeef;
|
||||
hr = IXMLElement_get_parent(element, &parent);
|
||||
ok(hr == 1, "Expected 1, got %08x\n", hr);
|
||||
ok(parent == NULL, "Expected NULL parent\n");
|
||||
|
||||
str = SysAllocString(noexist);
|
||||
hr = IXMLElement_getAttribute(element, str, &vValue);
|
||||
ok(hr == S_FALSE, "Expected S_FALSE, got %08x\n", hr);
|
||||
ok(V_VT(&vValue) == VT_EMPTY, "Expected VT_EMPTY, got %d\n", V_VT(&vValue));
|
||||
ok(V_BSTR(&vValue) == NULL, "Expected null value\n");
|
||||
VariantClear(&vValue);
|
||||
SysFreeString(str);
|
||||
|
||||
str = SysAllocString(crazyCase1);
|
||||
val = SysAllocString(propVal);
|
||||
V_VT(&vValue) = VT_BSTR;
|
||||
V_BSTR(&vValue) = val;
|
||||
hr = IXMLElement_setAttribute(element, str, vValue);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
SysFreeString(str);
|
||||
SysFreeString(val);
|
||||
|
||||
str = SysAllocString(crazyCase2);
|
||||
hr = IXMLElement_getAttribute(element, str, &vValue);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(V_VT(&vValue) == VT_BSTR, "Expected VT_BSTR, got %d\n", V_VT(&vValue));
|
||||
ok(!lstrcmpW(V_BSTR(&vValue), propVal), "Expected 'val'\n");
|
||||
VariantClear(&vValue);
|
||||
SysFreeString(str);
|
||||
|
||||
str = SysAllocString(propName);
|
||||
val = SysAllocString(propVal);
|
||||
V_VT(&vValue) = VT_BSTR;
|
||||
V_BSTR(&vValue) = val;
|
||||
hr = IXMLElement_setAttribute(element, str, vValue);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
SysFreeString(val);
|
||||
|
||||
hr = IXMLElement_getAttribute(element, str, &vValue);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(V_VT(&vValue) == VT_BSTR, "Expected VT_BSTR, got %d\n", V_VT(&vValue));
|
||||
ok(!lstrcmpW(V_BSTR(&vValue), propVal), "Expected 'val'\n");
|
||||
VariantClear(&vValue);
|
||||
|
||||
hr = IXMLElement_removeAttribute(element, str);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
|
||||
/* remove now nonexistent attribute */
|
||||
hr = IXMLElement_removeAttribute(element, str);
|
||||
ok(hr == S_FALSE, "Expected S_FALSE, got %08x\n", hr);
|
||||
|
||||
hr = IXMLElement_getAttribute(element, str, &vValue);
|
||||
ok(hr == 1, "Expected 1, got %08x\n", hr);
|
||||
ok(V_VT(&vValue) == VT_EMPTY, "Expected VT_EMPTY, got %d\n", V_VT(&vValue));
|
||||
ok(V_BSTR(&vValue) == NULL, "Expected null value\n");
|
||||
SysFreeString(str);
|
||||
VariantClear(&vValue);
|
||||
|
||||
children = (IXMLElementCollection *)0xdeadbeef;
|
||||
hr = IXMLElement_get_children(element, &children);
|
||||
ok(hr == 1, "Expected 1, got %08x\n", hr);
|
||||
ok(children == NULL, "Expected NULL collection\n");
|
||||
|
||||
hr = IXMLElement_get_type(element, &type);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(type == XMLELEMTYPE_ELEMENT, "Expected XMLELEMTYPE_ELEMENT, got %d\n", type);
|
||||
|
||||
hr = IXMLElement_get_text(element, &str);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(lstrlenW(str) == 0, "Expected empty text\n");
|
||||
SysFreeString(str);
|
||||
|
||||
/* put_text with an ELEMENT */
|
||||
str = SysAllocString(propVal);
|
||||
hr = IXMLElement_put_text(element, str);
|
||||
ok(hr == E_NOTIMPL, "Expected E_NOTIMPL, got %08x\n", hr);
|
||||
SysFreeString(str);
|
||||
|
||||
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");
|
||||
|
||||
hr = IXMLElement_addChild(element, child, 0, -1);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
|
||||
str = SysAllocString(propVal);
|
||||
hr = IXMLElement_put_text(child, str);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
SysFreeString(str);
|
||||
|
||||
parent = (IXMLElement *)0xdeadbeef;
|
||||
hr = IXMLElement_get_parent(child, &parent);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(parent != element, "Expected parent != element\n");
|
||||
|
||||
hr = IXMLElement_get_type(parent, &type);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(type == XMLELEMTYPE_ELEMENT, "Expected XMLELEMTYPE_ELEMENT, got %d\n", type);
|
||||
|
||||
children = (IXMLElementCollection *)0xdeadbeef;
|
||||
hr = IXMLElement_get_children(element, &children);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(children != NULL, "Expected non-NULL collection\n");
|
||||
|
||||
hr = IXMLElementCollection_get_length(children, &num_child);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(num_child == 1, "Expected 1, got %d\n", num_child);
|
||||
|
||||
V_VT(&vIndex) = VT_I4;
|
||||
V_I4(&vIndex) = 0;
|
||||
V_VT(&vName) = VT_ERROR;
|
||||
V_ERROR(&vName) = DISP_E_PARAMNOTFOUND;
|
||||
hr = IXMLElementCollection_item(children, vIndex, vName, (IDispatch **)&child2);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(child2 != NULL, "Expected non-NULL child\n");
|
||||
|
||||
hr = IXMLElement_get_type(child2, &type);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(type == XMLELEMTYPE_TEXT, "Expected XMLELEMTYPE_TEXT, got %d\n", type);
|
||||
|
||||
hr = IXMLElement_get_text(element, &str);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(!lstrcmpW(str, propVal), "Expected 'val'\n");
|
||||
SysFreeString(str);
|
||||
|
||||
hr = IXMLElement_get_text(child2, &str);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(!lstrcmpW(str, propVal), "Expected 'val'\n");
|
||||
SysFreeString(str);
|
||||
|
||||
/* try put_text on ELEMENT again, now that it has a text child */
|
||||
str = SysAllocString(nextVal);
|
||||
hr = IXMLElement_put_text(element, str);
|
||||
ok(hr == E_NOTIMPL, "Expected E_NOTIMPL, got %08x\n", hr);
|
||||
SysFreeString(str);
|
||||
|
||||
str = SysAllocString(nextVal);
|
||||
hr = IXMLElement_put_text(child2, str);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
SysFreeString(str);
|
||||
|
||||
hr = IXMLElement_get_text(element, &str);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(!lstrcmpW(str, nextVal), "Expected 'val'\n");
|
||||
SysFreeString(str);
|
||||
|
||||
IXMLElement_Release(child2);
|
||||
IXMLElementCollection_Release(children);
|
||||
IXMLElement_Release(parent);
|
||||
IXMLElement_Release(child);
|
||||
IXMLElement_Release(element);
|
||||
IXMLDocument_Release(doc);
|
||||
}
|
||||
|
||||
START_TEST(xmldoc)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
@ -511,6 +1069,9 @@ START_TEST(xmldoc)
|
|||
test_xmldoc();
|
||||
test_createElement();
|
||||
test_persiststreaminit();
|
||||
test_xmlelem();
|
||||
test_xmlelem_collection();
|
||||
test_xmlelem_children();
|
||||
|
||||
CoUninitialize();
|
||||
}
|
||||
|
|
|
@ -1,599 +0,0 @@
|
|||
/*
|
||||
* IXMLElement tests
|
||||
*
|
||||
* Copyright 2007 James Hawkins
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#define COBJMACROS
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "windows.h"
|
||||
#include "ole2.h"
|
||||
#include "xmldom.h"
|
||||
#include "msxml2.h"
|
||||
#include "ocidl.h"
|
||||
|
||||
#include "wine/test.h"
|
||||
|
||||
#define ERROR_URL_NOT_FOUND 0x800c0006
|
||||
|
||||
static void test_xmlelem(void)
|
||||
{
|
||||
HRESULT hr;
|
||||
IXMLDocument *doc = NULL;
|
||||
IXMLElement *element = NULL, *parent;
|
||||
IXMLElement *child, *child2;
|
||||
IXMLElementCollection *children;
|
||||
VARIANT vType, vName;
|
||||
VARIANT vIndex, vValue;
|
||||
BSTR str, val;
|
||||
LONG type, num_child;
|
||||
|
||||
static const WCHAR propName[] = {'p','r','o','p',0};
|
||||
static const WCHAR propVal[] = {'v','a','l',0};
|
||||
static const WCHAR nextVal[] = {'n','e','x','t',0};
|
||||
static const WCHAR noexist[] = {'n','o','e','x','i','s','t',0};
|
||||
static const WCHAR crazyCase1[] = {'C','R','a','z','Y','c','A','S','E',0};
|
||||
static const WCHAR crazyCase2[] = {'C','R','A','Z','Y','C','A','S','E',0};
|
||||
|
||||
hr = CoCreateInstance(&CLSID_XMLDocument, NULL, CLSCTX_INPROC_SERVER,
|
||||
&IID_IXMLDocument, (LPVOID*)&doc);
|
||||
ok(hr == S_OK, "Expected S_OK, got 0x%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");
|
||||
|
||||
hr = IXMLElement_get_tagName(element, &str);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(lstrlenW(str) == 0, "Expected empty tag name\n");
|
||||
SysFreeString(str);
|
||||
|
||||
parent = (IXMLElement *)0xdeadbeef;
|
||||
hr = IXMLElement_get_parent(element, &parent);
|
||||
ok(hr == 1, "Expected 1, got %08x\n", hr);
|
||||
ok(parent == NULL, "Expected NULL parent\n");
|
||||
|
||||
str = SysAllocString(noexist);
|
||||
hr = IXMLElement_getAttribute(element, str, &vValue);
|
||||
ok(hr == S_FALSE, "Expected S_FALSE, got %08x\n", hr);
|
||||
ok(V_VT(&vValue) == VT_EMPTY, "Expected VT_EMPTY, got %d\n", V_VT(&vValue));
|
||||
ok(V_BSTR(&vValue) == NULL, "Expected null value\n");
|
||||
VariantClear(&vValue);
|
||||
SysFreeString(str);
|
||||
|
||||
str = SysAllocString(crazyCase1);
|
||||
val = SysAllocString(propVal);
|
||||
V_VT(&vValue) = VT_BSTR;
|
||||
V_BSTR(&vValue) = val;
|
||||
hr = IXMLElement_setAttribute(element, str, vValue);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
SysFreeString(str);
|
||||
SysFreeString(val);
|
||||
|
||||
str = SysAllocString(crazyCase2);
|
||||
hr = IXMLElement_getAttribute(element, str, &vValue);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(V_VT(&vValue) == VT_BSTR, "Expected VT_BSTR, got %d\n", V_VT(&vValue));
|
||||
ok(!lstrcmpW(V_BSTR(&vValue), propVal), "Expected 'val'\n");
|
||||
VariantClear(&vValue);
|
||||
SysFreeString(str);
|
||||
|
||||
str = SysAllocString(propName);
|
||||
val = SysAllocString(propVal);
|
||||
V_VT(&vValue) = VT_BSTR;
|
||||
V_BSTR(&vValue) = val;
|
||||
hr = IXMLElement_setAttribute(element, str, vValue);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
SysFreeString(val);
|
||||
|
||||
hr = IXMLElement_getAttribute(element, str, &vValue);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(V_VT(&vValue) == VT_BSTR, "Expected VT_BSTR, got %d\n", V_VT(&vValue));
|
||||
ok(!lstrcmpW(V_BSTR(&vValue), propVal), "Expected 'val'\n");
|
||||
VariantClear(&vValue);
|
||||
|
||||
hr = IXMLElement_removeAttribute(element, str);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
|
||||
/* remove now nonexistent attribute */
|
||||
hr = IXMLElement_removeAttribute(element, str);
|
||||
ok(hr == S_FALSE, "Expected S_FALSE, got %08x\n", hr);
|
||||
|
||||
hr = IXMLElement_getAttribute(element, str, &vValue);
|
||||
ok(hr == 1, "Expected 1, got %08x\n", hr);
|
||||
ok(V_VT(&vValue) == VT_EMPTY, "Expected VT_EMPTY, got %d\n", V_VT(&vValue));
|
||||
ok(V_BSTR(&vValue) == NULL, "Expected null value\n");
|
||||
SysFreeString(str);
|
||||
VariantClear(&vValue);
|
||||
|
||||
children = (IXMLElementCollection *)0xdeadbeef;
|
||||
hr = IXMLElement_get_children(element, &children);
|
||||
ok(hr == 1, "Expected 1, got %08x\n", hr);
|
||||
ok(children == NULL, "Expected NULL collection\n");
|
||||
|
||||
hr = IXMLElement_get_type(element, &type);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(type == XMLELEMTYPE_ELEMENT, "Expected XMLELEMTYPE_ELEMENT, got %d\n", type);
|
||||
|
||||
hr = IXMLElement_get_text(element, &str);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(lstrlenW(str) == 0, "Expected empty text\n");
|
||||
SysFreeString(str);
|
||||
|
||||
/* put_text with an ELEMENT */
|
||||
str = SysAllocString(propVal);
|
||||
hr = IXMLElement_put_text(element, str);
|
||||
ok(hr == E_NOTIMPL, "Expected E_NOTIMPL, got %08x\n", hr);
|
||||
SysFreeString(str);
|
||||
|
||||
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");
|
||||
|
||||
hr = IXMLElement_addChild(element, child, 0, -1);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
|
||||
str = SysAllocString(propVal);
|
||||
hr = IXMLElement_put_text(child, str);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
SysFreeString(str);
|
||||
|
||||
parent = (IXMLElement *)0xdeadbeef;
|
||||
hr = IXMLElement_get_parent(child, &parent);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(parent != element, "Expected parent != element\n");
|
||||
|
||||
hr = IXMLElement_get_type(parent, &type);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(type == XMLELEMTYPE_ELEMENT, "Expected XMLELEMTYPE_ELEMENT, got %d\n", type);
|
||||
|
||||
children = (IXMLElementCollection *)0xdeadbeef;
|
||||
hr = IXMLElement_get_children(element, &children);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(children != NULL, "Expected non-NULL collection\n");
|
||||
|
||||
hr = IXMLElementCollection_get_length(children, &num_child);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(num_child == 1, "Expected 1, got %d\n", num_child);
|
||||
|
||||
V_VT(&vIndex) = VT_I4;
|
||||
V_I4(&vIndex) = 0;
|
||||
V_VT(&vName) = VT_ERROR;
|
||||
V_ERROR(&vName) = DISP_E_PARAMNOTFOUND;
|
||||
hr = IXMLElementCollection_item(children, vIndex, vName, (IDispatch **)&child2);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(child2 != NULL, "Expected non-NULL child\n");
|
||||
|
||||
hr = IXMLElement_get_type(child2, &type);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(type == XMLELEMTYPE_TEXT, "Expected XMLELEMTYPE_TEXT, got %d\n", type);
|
||||
|
||||
hr = IXMLElement_get_text(element, &str);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(!lstrcmpW(str, propVal), "Expected 'val'\n");
|
||||
SysFreeString(str);
|
||||
|
||||
hr = IXMLElement_get_text(child2, &str);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(!lstrcmpW(str, propVal), "Expected 'val'\n");
|
||||
SysFreeString(str);
|
||||
|
||||
/* try put_text on ELEMENT again, now that it has a text child */
|
||||
str = SysAllocString(nextVal);
|
||||
hr = IXMLElement_put_text(element, str);
|
||||
ok(hr == E_NOTIMPL, "Expected E_NOTIMPL, got %08x\n", hr);
|
||||
SysFreeString(str);
|
||||
|
||||
str = SysAllocString(nextVal);
|
||||
hr = IXMLElement_put_text(child2, str);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
SysFreeString(str);
|
||||
|
||||
hr = IXMLElement_get_text(element, &str);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(!lstrcmpW(str, nextVal), "Expected 'val'\n");
|
||||
SysFreeString(str);
|
||||
|
||||
IXMLElement_Release(child2);
|
||||
IXMLElementCollection_Release(children);
|
||||
IXMLElement_Release(parent);
|
||||
IXMLElement_Release(child);
|
||||
IXMLElement_Release(element);
|
||||
IXMLDocument_Release(doc);
|
||||
}
|
||||
|
||||
static void create_xml_file(LPCSTR filename)
|
||||
{
|
||||
DWORD dwNumberOfBytesWritten;
|
||||
HANDLE hf = CreateFile(filename, GENERIC_WRITE, 0, NULL,
|
||||
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
|
||||
static const char data[] =
|
||||
"<?xml version=\"1.0\" ?>\n"
|
||||
"<BankAccount>\n"
|
||||
" <Number>1234</Number>\n"
|
||||
" <Name>Captain Ahab</Name>\n"
|
||||
"</BankAccount>\n";
|
||||
|
||||
WriteFile(hf, data, sizeof(data) - 1, &dwNumberOfBytesWritten, NULL);
|
||||
CloseHandle(hf);
|
||||
}
|
||||
|
||||
static void test_xmlelem_collection(void)
|
||||
{
|
||||
HRESULT hr;
|
||||
IUnknown *unk = NULL;
|
||||
IXMLDocument *doc = NULL;
|
||||
IXMLElement *element = NULL, *child;
|
||||
IXMLElementCollection *collection = NULL;
|
||||
IEnumVARIANT *enumVar = NULL;
|
||||
CHAR pathA[MAX_PATH];
|
||||
WCHAR path[MAX_PATH];
|
||||
LONG length, type;
|
||||
ULONG num_vars;
|
||||
VARIANT var, vIndex, vName;
|
||||
BSTR url, str;
|
||||
static const CHAR szBankXML[] = "bank.xml";
|
||||
static const WCHAR szNumber[] = {'N','U','M','B','E','R',0};
|
||||
static const WCHAR szName[] = {'N','A','M','E',0};
|
||||
|
||||
hr = CoCreateInstance(&CLSID_XMLDocument, NULL, CLSCTX_INPROC_SERVER,
|
||||
&IID_IXMLDocument, (LPVOID*)&doc);
|
||||
ok(hr == S_OK, "Expected S_OK, got 0x%08x\n", hr);
|
||||
|
||||
create_xml_file(szBankXML);
|
||||
GetFullPathNameA(szBankXML, MAX_PATH, pathA, NULL);
|
||||
MultiByteToWideChar(CP_ACP, 0, pathA, -1, path, MAX_PATH);
|
||||
|
||||
url = SysAllocString(path);
|
||||
hr = IXMLDocument_put_URL(doc, url);
|
||||
ok(hr == S_OK, "Expected S_OK, got 0x%08x\n", hr);
|
||||
SysFreeString(url);
|
||||
|
||||
if(hr != S_OK)
|
||||
goto cleanup;
|
||||
|
||||
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");
|
||||
|
||||
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 = IXMLElementCollection_get_length(collection, NULL);
|
||||
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr);
|
||||
|
||||
hr = IXMLElementCollection_get_length(collection, &length);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(length == 2, "Expected 2, got %d\n", length);
|
||||
|
||||
/* IXMLElementCollection:put_length does nothing */
|
||||
hr = IXMLElementCollection_put_length(collection, -1);
|
||||
ok(hr == E_FAIL, "Expected E_FAIL, got %08x\n", hr);
|
||||
|
||||
hr = IXMLElementCollection_put_length(collection, 0);
|
||||
ok(hr == E_FAIL, "Expected E_FAIL, got %08x\n", hr);
|
||||
|
||||
hr = IXMLElementCollection_put_length(collection, 1);
|
||||
ok(hr == E_FAIL, "Expected E_FAIL, got %08x\n", hr);
|
||||
|
||||
hr = IXMLElementCollection_put_length(collection, 2);
|
||||
ok(hr == E_FAIL, "Expected E_FAIL, got %08x\n", hr);
|
||||
|
||||
hr = IXMLElementCollection_put_length(collection, 3);
|
||||
ok(hr == E_FAIL, "Expected E_FAIL, got %08x\n", hr);
|
||||
|
||||
hr = IXMLElementCollection_put_length(collection, 50);
|
||||
ok(hr == E_FAIL, "Expected E_FAIL, got %08x\n", hr);
|
||||
|
||||
/* make sure the length hasn't changed */
|
||||
hr = IXMLElementCollection_get_length(collection, &length);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(length == 2, "Expected 2, got %d\n", length);
|
||||
|
||||
/* IXMLElementCollection implements IEnumVARIANT */
|
||||
hr = IXMLElementCollection_QueryInterface(collection, &IID_IEnumVARIANT, (LPVOID *)&enumVar);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(enumVar != NULL, "Expected non-NULL enumVar\n");
|
||||
IEnumVARIANT_Release(enumVar);
|
||||
|
||||
hr = IXMLElementCollection_get__newEnum(collection, &unk);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(unk != NULL, "Expected non-NULL unk\n");
|
||||
|
||||
hr = IUnknown_QueryInterface(unk, &IID_IEnumVARIANT, (LPVOID *)&enumVar);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(enumVar != NULL, "Expected non-NULL enumVar\n");
|
||||
IUnknown_Release(unk);
|
||||
|
||||
/* <Number>1234</Number> */
|
||||
hr = IEnumVARIANT_Next(enumVar, 1, &var, &num_vars);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(V_VT(&var) == VT_DISPATCH, "Expected VT_DISPATCH, got %d\n", V_VT(&var));
|
||||
ok(num_vars == 1, "Expected 1, got %d\n", num_vars);
|
||||
|
||||
hr = IUnknown_QueryInterface(V_DISPATCH(&var), &IID_IXMLElement, (LPVOID *)&child);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(child != NULL, "Expected non-NULL child\n");
|
||||
|
||||
VariantClear(&var);
|
||||
|
||||
hr = IXMLElement_get_type(child, &type);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(type == XMLELEMTYPE_ELEMENT, "Expected XMLELEMTYPE_ELEMENT, got %d\n", type);
|
||||
|
||||
hr = IXMLElement_get_tagName(child, &str);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(!lstrcmpW(str, szNumber), "Expected NUMBER\n");
|
||||
SysFreeString(str);
|
||||
IXMLElement_Release(child);
|
||||
|
||||
/* <Name>Captain Ahab</Name> */
|
||||
hr = IEnumVARIANT_Next(enumVar, 1, &var, &num_vars);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(V_VT(&var) == VT_DISPATCH, "Expected VT_DISPATCH, got %d\n", V_VT(&var));
|
||||
ok(num_vars == 1, "Expected 1, got %d\n", num_vars);
|
||||
|
||||
/* try advance further, no children left */
|
||||
hr = IEnumVARIANT_Next(enumVar, 1, &var, &num_vars);
|
||||
ok(hr == S_FALSE, "Expected S_FALSE, got %08x\n", hr);
|
||||
ok(V_VT(&var) == 0, "Expected 0, got %d\n", V_VT(&var));
|
||||
ok(num_vars == 0, "Expected 0, got %d\n", num_vars);
|
||||
|
||||
hr = IEnumVARIANT_Next(enumVar, 1, &var, NULL);
|
||||
ok(hr == S_FALSE, "Expected S_FALSE, got %08x\n", hr);
|
||||
ok(V_VT(&var) == 0, "Expected 0, got %d\n", V_VT(&var));
|
||||
|
||||
hr = IUnknown_QueryInterface(V_DISPATCH(&var), &IID_IXMLElement, (LPVOID *)&child);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(child != NULL, "Expected non-NULL child\n");
|
||||
|
||||
VariantClear(&var);
|
||||
|
||||
hr = IXMLElement_get_type(child, &type);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(type == XMLELEMTYPE_ELEMENT, "Expected XMLELEMTYPE_ELEMENT, got %d\n", type);
|
||||
|
||||
hr = IXMLElement_get_tagName(child, &str);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(!lstrcmpW(str, szName), "Expected NAME\n");
|
||||
SysFreeString(str);
|
||||
IXMLElement_Release(child);
|
||||
|
||||
/* <Number>1234</Number> */
|
||||
V_VT(&vIndex) = VT_I4;
|
||||
V_I4(&vIndex) = 0;
|
||||
V_VT(&vName) = VT_ERROR;
|
||||
V_ERROR(&vName) = DISP_E_PARAMNOTFOUND;
|
||||
hr = IXMLElementCollection_item(collection, vIndex, vName, (IDispatch **)&child);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(child != NULL, "Expected non-NULL child\n");
|
||||
|
||||
hr = IXMLElement_get_type(child, &type);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(type == XMLELEMTYPE_ELEMENT, "Expected XMLELEMTYPE_ELEMENT, got %d\n", type);
|
||||
|
||||
hr = IXMLElement_get_tagName(child, &str);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(!lstrcmpW(str, szNumber), "Expected NUMBER\n");
|
||||
SysFreeString(str);
|
||||
IXMLElement_Release(child);
|
||||
|
||||
/* <Name>Captain Ahab</Name> */
|
||||
V_VT(&vIndex) = VT_I4;
|
||||
V_I4(&vIndex) = 1;
|
||||
V_VT(&vName) = VT_ERROR;
|
||||
V_ERROR(&vName) = DISP_E_PARAMNOTFOUND;
|
||||
hr = IXMLElementCollection_item(collection, vIndex, vName, (IDispatch **)&child);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(child != NULL, "Expected non-NULL child\n");
|
||||
|
||||
hr = IXMLElement_get_type(child, &type);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(type == XMLELEMTYPE_ELEMENT, "Expected XMLELEMTYPE_ELEMENT, got %d\n", type);
|
||||
|
||||
hr = IXMLElement_get_tagName(child, &str);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(!lstrcmpW(str, szName), "Expected NAME\n");
|
||||
SysFreeString(str);
|
||||
IXMLElement_Release(child);
|
||||
|
||||
V_I4(&vIndex) = 100;
|
||||
hr = IXMLElementCollection_item(collection, vIndex, vName, (IDispatch **)&child);
|
||||
ok(hr == E_FAIL, "Expected E_FAIL, got %08x\n", hr);
|
||||
ok(child == NULL, "Expected NULL child\n");
|
||||
|
||||
V_I4(&vIndex) = -1;
|
||||
child = (IXMLElement *)0xdeadbeef;
|
||||
hr = IXMLElementCollection_item(collection, vIndex, vName, (IDispatch **)&child);
|
||||
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr);
|
||||
ok(child == NULL, "Expected NULL child\n");
|
||||
|
||||
IEnumVARIANT_Release(enumVar);
|
||||
IXMLElement_Release(element);
|
||||
IXMLElementCollection_Release(collection);
|
||||
cleanup:
|
||||
IXMLDocument_Release(doc);
|
||||
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;
|
||||
|
||||
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();
|
||||
}
|
71
rostests/winetests/msxml3/xmlparser.c
Normal file
71
rostests/winetests/msxml3/xmlparser.c
Normal file
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* XML Parser implementation
|
||||
*
|
||||
* Copyright 2011 Alistair Leslie-Hughes
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
#define COBJMACROS
|
||||
#define CONST_VTABLE
|
||||
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "windows.h"
|
||||
#include "ole2.h"
|
||||
#include "xmlparser.h"
|
||||
#include "wine/test.h"
|
||||
|
||||
static void create_test(void)
|
||||
{
|
||||
HRESULT hr;
|
||||
IXMLParser *parser;
|
||||
DWORD flags;
|
||||
|
||||
hr = CoCreateInstance(&CLSID_XMLParser30, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLParser, (void**)&parser);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
win_skip("IXMLParser is not available (0x%08x)\n", hr);
|
||||
return;
|
||||
}
|
||||
|
||||
flags = IXMLParser_GetFlags(parser);
|
||||
ok(flags == 0, "Expected 0 got %d\n", flags);
|
||||
|
||||
hr = IXMLParser_SetFlags(parser, XMLFLAG_SAX);
|
||||
ok(hr == S_OK, "Expected S_OK got 0x%08x\n", hr);
|
||||
|
||||
flags = IXMLParser_GetFlags(parser);
|
||||
ok(flags == XMLFLAG_SAX, "Expected 0 got %d\n", flags);
|
||||
|
||||
hr = IXMLParser_SetFlags(parser, 0);
|
||||
ok(hr == S_OK, "Expected S_OK got 0x%08x\n", hr);
|
||||
|
||||
IXMLParser_Release(parser);
|
||||
}
|
||||
|
||||
START_TEST(xmlparser)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
hr = CoInitialize( NULL );
|
||||
ok( hr == S_OK, "failed to init com\n");
|
||||
if (hr != S_OK)
|
||||
return;
|
||||
|
||||
create_test();
|
||||
|
||||
CoUninitialize();
|
||||
}
|
381
rostests/winetests/msxml3/xmlparser.idl
Normal file
381
rostests/winetests/msxml3/xmlparser.idl
Normal file
|
@ -0,0 +1,381 @@
|
|||
/*
|
||||
* Copyright (C) 2011 Alistair Leslie-Hughes
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
import "unknwn.idl";
|
||||
import "objidl.idl";
|
||||
import "oaidl.idl";
|
||||
|
||||
interface IXMLNodeSource;
|
||||
interface IXMLParser;
|
||||
interface IXMLNodeFactory;
|
||||
interface IMoniker;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
XML_ELEMENT = 1,
|
||||
XML_ATTRIBUTE,
|
||||
XML_PI,
|
||||
XML_XMLDECL,
|
||||
XML_DOCTYPE,
|
||||
XML_DTDATTRIBUTE,
|
||||
XML_ENTITYDECL,
|
||||
XML_ELEMENTDECL,
|
||||
XML_ATTLISTDECL,
|
||||
XML_NOTATION,
|
||||
XML_GROUP,
|
||||
XML_INCLUDESECT,
|
||||
XML_PCDATA,
|
||||
XML_CDATA,
|
||||
XML_IGNORESECT,
|
||||
XML_COMMENT,
|
||||
XML_ENTITYREF,
|
||||
XML_WHITESPACE,
|
||||
XML_NAME,
|
||||
XML_NMTOKEN,
|
||||
XML_STRING,
|
||||
XML_PEREF,
|
||||
XML_MODEL,
|
||||
XML_ATTDEF,
|
||||
XML_ATTTYPE,
|
||||
XML_ATTPRESENCE,
|
||||
XML_DTDSUBSET,
|
||||
XML_LASTNODETYPE
|
||||
} XML_NODE_TYPE;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
XML_VERSION = XML_LASTNODETYPE,
|
||||
XML_ENCODING,
|
||||
XML_STANDALONE,
|
||||
XML_NS,
|
||||
XML_XMLSPACE,
|
||||
XML_XMLLANG,
|
||||
XML_SYSTEM,
|
||||
XML_PUBLIC,
|
||||
XML_NDATA,
|
||||
XML_AT_CDATA,
|
||||
XML_AT_ID,
|
||||
XML_AT_IDREF,
|
||||
XML_AT_IDREFS,
|
||||
XML_AT_ENTITY,
|
||||
XML_AT_ENTITIES,
|
||||
XML_AT_NMTOKEN,
|
||||
XML_AT_NMTOKENS,
|
||||
XML_AT_NOTATION,
|
||||
XML_AT_REQUIRED,
|
||||
XML_AT_IMPLIED,
|
||||
XML_AT_FIXED,
|
||||
XML_PENTITYDECL,
|
||||
XML_EMPTY,
|
||||
XML_ANY,
|
||||
XML_MIXED,
|
||||
XML_SEQUENCE,
|
||||
XML_CHOICE,
|
||||
XML_STAR,
|
||||
XML_PLUS,
|
||||
XML_QUESTIONMARK,
|
||||
XML_LASTSUBNODETYPE
|
||||
}
|
||||
XML_NODE_SUBTYPE;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
XML_E_PARSEERRORBASE = 0xC00CE500L,
|
||||
|
||||
XML_E_ENDOFINPUT = XML_E_PARSEERRORBASE,
|
||||
XML_E_MISSINGEQUALS = 0xC00CE501,
|
||||
XML_E_MISSINGQUOTE = 0xC00CE502,
|
||||
XML_E_COMMENTSYNTAX = 0xC00CE503,
|
||||
XML_E_BADSTARTNAMECHAR = 0xC00CE504,
|
||||
XML_E_BADNAMECHAR = 0xC00CE505,
|
||||
XML_E_BADCHARINSTRING = 0xC00CE506,
|
||||
XML_E_XMLDECLSYNTAX = 0xC00CE507,
|
||||
XML_E_BADCHARDATA = 0xC00CE508,
|
||||
XML_E_MISSINGWHITESPACE = 0xC00CE509,
|
||||
XML_E_EXPECTINGTAGEND = 0xC00CE50A,
|
||||
XML_E_BADCHARINDTD = 0xC00CE50B,
|
||||
XML_E_BADCHARINDECL = 0xC00CE50C,
|
||||
XML_E_MISSINGSEMICOLON = 0xC00CE50D,
|
||||
XML_E_BADCHARINENTREF = 0xC00CE50E,
|
||||
XML_E_UNBALANCEDPAREN = 0xC00CE50F,
|
||||
XML_E_EXPECTINGOPENBRACKET = 0xC00CE510,
|
||||
XML_E_BADENDCONDSECT = 0xC00CE511,
|
||||
XML_E_INTERNALERROR = 0xC00CE512,
|
||||
XML_E_UNEXPECTED_WHITESPACE = 0xC00CE513,
|
||||
XML_E_INCOMPLETE_ENCODING = 0xC00CE514,
|
||||
XML_E_BADCHARINMIXEDMODEL = 0xC00CE515,
|
||||
XML_E_MISSING_STAR = 0xC00CE516,
|
||||
XML_E_BADCHARINMODEL = 0xC00CE517,
|
||||
XML_E_MISSING_PAREN = 0xC00CE518,
|
||||
XML_E_BADCHARINENUMERATION = 0xC00CE519,
|
||||
XML_E_PIDECLSYNTAX = 0xC00CE51A,
|
||||
XML_E_EXPECTINGCLOSEQUOTE = 0xC00CE51B,
|
||||
XML_E_MULTIPLE_COLONS = 0xC00CE51C,
|
||||
XML_E_INVALID_DECIMAL = 0xC00CE51D,
|
||||
XML_E_INVALID_HEXIDECIMAL = 0xC00CE51E,
|
||||
XML_E_INVALID_UNICODE = 0xC00CE51F,
|
||||
XML_E_WHITESPACEORQUESTIONMARK = 0xC00CE520,
|
||||
XML_E_ENDOFPE = 0xC00CE521,
|
||||
|
||||
XML_E_TOKEN_ERROR = XML_E_PARSEERRORBASE + 0x50,
|
||||
XML_E_SUSPENDED = 0xC00CE550,
|
||||
XML_E_STOPPED = 0xC00CE551,
|
||||
XML_E_UNEXPECTEDENDTAG = 0xC00CE552,
|
||||
XML_E_UNCLOSEDTAG = 0xC00CE553,
|
||||
XML_E_DUPLICATEATTRIBUTE = 0xC00CE554,
|
||||
XML_E_MULTIPLEROOTS = 0xC00CE555,
|
||||
XML_E_INVALIDATROOTLEVEL = 0xC00CE556,
|
||||
XML_E_BADXMLDECL = 0xC00CE557,
|
||||
XML_E_MISSINGROOT = 0xC00CE558,
|
||||
XML_E_UNEXPECTEDEOF = 0xC00CE559,
|
||||
XML_E_BADPEREFINSUBSET = 0xC00CE55A,
|
||||
XML_E_PE_NESTING = 0xC00CE55B,
|
||||
XML_E_INVALID_CDATACLOSINGTAG = 0xC00CE55C,
|
||||
XML_E_UNCLOSEDPI = 0xC00CE55D,
|
||||
XML_E_UNCLOSEDSTARTTAG = 0xC00CE55E,
|
||||
XML_E_UNCLOSEDENDTAG = 0xC00CE55F,
|
||||
XML_E_UNCLOSEDSTRING = 0xC00CE560,
|
||||
XML_E_UNCLOSEDCOMMENT = 0xC00CE561,
|
||||
XML_E_UNCLOSEDDECL = 0xC00CE562,
|
||||
XML_E_UNCLOSEDMARKUPDECL = 0xC00CE563,
|
||||
XML_E_UNCLOSEDCDATA = 0xC00CE564,
|
||||
XML_E_BADDECLNAME = 0xC00CE565,
|
||||
XML_E_BADEXTERNALID = 0xC00CE566,
|
||||
XML_E_BADELEMENTINDTD = 0xC00CE567,
|
||||
XML_E_RESERVEDNAMESPACE = 0xC00CE568,
|
||||
XML_E_EXPECTING_VERSION = 0xC00CE569,
|
||||
XML_E_EXPECTING_ENCODING = 0xC00CE56A,
|
||||
XML_E_EXPECTING_NAME = 0xC00CE56B,
|
||||
XML_E_UNEXPECTED_ATTRIBUTE = 0xC00CE56C,
|
||||
XML_E_ENDTAGMISMATCH = 0xC00CE56D,
|
||||
XML_E_INVALIDENCODING = 0xC00CE56E,
|
||||
XML_E_INVALIDSWITCH = 0xC00CE56F,
|
||||
XML_E_EXPECTING_NDATA = 0xC00CE570,
|
||||
XML_E_INVALID_MODEL = 0xC00CE571,
|
||||
XML_E_INVALID_TYPE = 0xC00CE572,
|
||||
XML_E_INVALIDXMLSPACE = 0xC00CE573,
|
||||
XML_E_MULTI_ATTR_VALUE = 0xC00CE574,
|
||||
XML_E_INVALID_PRESENCE = 0xC00CE575,
|
||||
XML_E_BADXMLCASE = 0xC00CE576,
|
||||
XML_E_CONDSECTINSUBSET = 0xC00CE577,
|
||||
XML_E_CDATAINVALID = 0xC00CE578,
|
||||
XML_E_INVALID_STANDALONE = 0xC00CE579,
|
||||
XML_E_UNEXPECTED_STANDALONE = 0xC00CE57A,
|
||||
XML_E_DOCTYPE_IN_DTD = 0xC00CE57B,
|
||||
XML_E_MISSING_ENTITY = 0xC00CE57C,
|
||||
XML_E_ENTITYREF_INNAME = 0xC00CE57D,
|
||||
XML_E_DOCTYPE_OUTSIDE_PROLOG = 0xC00CE57E,
|
||||
XML_E_INVALID_VERSION = 0xC00CE57F,
|
||||
XML_E_DTDELEMENT_OUTSIDE_DTD = 0xC00CE580,
|
||||
XML_E_DUPLICATEDOCTYPE = 0xC00CE581,
|
||||
XML_E_RESOURCE = 0xC00CE582,
|
||||
XML_E_MISSINGNAME = 0xC00CE583,
|
||||
XML_E_LASTERROR = 0xC00CE584
|
||||
} XML_ERROR_CODE;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
XMLPARSER_IDLE,
|
||||
XMLPARSER_WAITING,
|
||||
XMLPARSER_BUSY,
|
||||
XMLPARSER_ERROR,
|
||||
XMLPARSER_STOPPED,
|
||||
XMLPARSER_SUSPENDED
|
||||
} XML_PARSER_STATE;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
XMLFLAG_FLOATINGAMP = 0x00000001,
|
||||
XMLFLAG_SHORTENDTAGS = 0x00000002,
|
||||
XMLFLAG_CASEINSENSITIVE = 0x00000004,
|
||||
XMLFLAG_NONAMESPACES = 0x00000008,
|
||||
XMLFLAG_NOWHITESPACE = 0x00000010,
|
||||
XMLFLAG_IE4QUIRKS = 0x00000020,
|
||||
XMLFLAG_NODTDNODES = 0x00000040,
|
||||
XMLFLAG_IE4COMPATIBILITY = 0x000000FF,
|
||||
XMLFLAG_IE5COMPATIBILITY = 0x00000100,
|
||||
XMLFLAG_SAX = 0x00000200,
|
||||
XMLFLAG_NORMALIZELB = 0x00000400,
|
||||
XMLFLAG_IGNOREENCODING = 0x00000800,
|
||||
XMLFLAG_USEWINHTTP = 0x00001000,
|
||||
XMLFLAG_RUNBUFFERONLY = 0x00002000,
|
||||
XMLFLAG_PROHIBIT_DTD = 0x00008000
|
||||
} XML_PARSER_FLAGS;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
XMLNF_STARTDOCUMENT,
|
||||
XMLNF_STARTDTD,
|
||||
XMLNF_ENDDTD,
|
||||
XMLNF_STARTDTDSUBSET,
|
||||
XMLNF_ENDDTDSUBSET,
|
||||
XMLNF_ENDPROLOG,
|
||||
XMLNF_STARTENTITY,
|
||||
XMLNF_ENDENTITY,
|
||||
XMLNF_ENDDOCUMENT,
|
||||
XMLNF_DATAAVAILABLE,
|
||||
XMLNF_LASTEVENT = XMLNF_DATAAVAILABLE
|
||||
} XML_NODEFACTORY_EVENT;
|
||||
|
||||
typedef struct _XML_NODE_INFO
|
||||
{
|
||||
DWORD dwSize;
|
||||
DWORD dwType;
|
||||
DWORD dwSubType;
|
||||
BOOL fTerminal;
|
||||
const WCHAR* pwcText;
|
||||
ULONG ulLen;
|
||||
ULONG ulNsPrefixLen;
|
||||
PVOID pNode;
|
||||
PVOID pReserved;
|
||||
} XML_NODE_INFO;
|
||||
|
||||
[
|
||||
uuid(d242361c-51a0-11d2-9caf-0060b0ec3d39),
|
||||
helpstring("Microsoft XML Parser 1.0"),
|
||||
lcid(0x0000),
|
||||
version(1.0)
|
||||
]
|
||||
library XMLPSR
|
||||
{
|
||||
importlib("stdole32.tlb");
|
||||
importlib("stdole2.tlb");
|
||||
|
||||
[
|
||||
local,
|
||||
object,
|
||||
pointer_default(unique),
|
||||
helpstring("IXMLNodeFactory Interface"),
|
||||
uuid(d242361f-51a0-11d2-9caf-0060b0ec3d39)
|
||||
]
|
||||
interface IXMLNodeFactory : IUnknown
|
||||
{
|
||||
HRESULT NotifyEvent([in] IXMLNodeSource* pSource,[in] XML_NODEFACTORY_EVENT iEvt);
|
||||
HRESULT BeginChildren([in] IXMLNodeSource* pSource, [in] XML_NODE_INFO* pNodeInfo);
|
||||
HRESULT EndChildren([in] IXMLNodeSource* pSource, [in] BOOL fEmpty, [in] XML_NODE_INFO* pNodeInfo);
|
||||
HRESULT Error([in] IXMLNodeSource* pSource,[in] HRESULT hrErrorCode,
|
||||
[in] USHORT cNumRecs, [in] XML_NODE_INFO** ppNodeInfo);
|
||||
HRESULT CreateNode([in] IXMLNodeSource* pSource, [in] PVOID pNodeParent, [in] USHORT cNumRecs,
|
||||
[in] XML_NODE_INFO** ppNodeInfo);
|
||||
};
|
||||
|
||||
[
|
||||
local,
|
||||
object,
|
||||
pointer_default(unique),
|
||||
uuid(d242361d-51a0-11d2-9caf-0060b0ec3d39)
|
||||
]
|
||||
interface IXMLNodeSource : IUnknown
|
||||
{
|
||||
HRESULT SetFactory([in] IXMLNodeFactory* pNodeFactory);
|
||||
HRESULT GetFactory([out] IXMLNodeFactory** ppNodeFactory);
|
||||
HRESULT Abort([in] BSTR bstrErrorInfo);
|
||||
ULONG GetLineNumber();
|
||||
ULONG GetLinePosition();
|
||||
ULONG GetAbsolutePosition();
|
||||
HRESULT GetLineBuffer([out] const WCHAR** ppBuf,[out] ULONG* Len, [out] ULONG* StartPos);
|
||||
HRESULT GetLastError();
|
||||
HRESULT GetErrorInfo([out] BSTR* pErrorInfo);
|
||||
ULONG GetFlags();
|
||||
HRESULT GetURL([out] const WCHAR** ppBuf);
|
||||
};
|
||||
|
||||
[
|
||||
local,
|
||||
object,
|
||||
pointer_default(unique),
|
||||
helpstring("IXMLParser Interface"),
|
||||
uuid(d242361e-51a0-11d2-9caf-0060b0ec3d39)
|
||||
]
|
||||
interface IXMLParser : IXMLNodeSource
|
||||
{
|
||||
HRESULT SetURL([in] const WCHAR* pszBaseUrl,[in] const WCHAR* pszRelativeUrl,[in] BOOL fAsync);
|
||||
HRESULT Load([in] BOOL fFullyAvailable, [in] IMoniker *pimkName, [in] LPBC pibc, [in] DWORD grfMode);
|
||||
HRESULT SetInput([in] IUnknown *pStm);
|
||||
HRESULT PushData([in] const char* pData, [in] ULONG ulChars, [in] BOOL fLastBuffer);
|
||||
HRESULT LoadDTD([in] const WCHAR* pszBaseUrl, [in] const WCHAR* pszRelativeUrl);
|
||||
HRESULT LoadEntity([in] const WCHAR* pszBaseUrl, [in] const WCHAR* pszRelativeUrl, [in] BOOL fpe);
|
||||
HRESULT ParseEntity([in] const WCHAR* pwcText, [in] ULONG ulLen, [in] BOOL fpe);
|
||||
HRESULT ExpandEntity([in] const WCHAR* pwcText, [in] ULONG ulLen);
|
||||
HRESULT SetRoot([in] PVOID pRoot);
|
||||
HRESULT GetRoot([in] PVOID* ppRoot);
|
||||
HRESULT Run([in] long lChars);
|
||||
HRESULT GetParserState();
|
||||
HRESULT Suspend();
|
||||
HRESULT Reset();
|
||||
HRESULT SetFlags([in] ULONG iFlags);
|
||||
HRESULT SetSecureBaseURL([in] const WCHAR* pszBaseUrl);
|
||||
HRESULT GetSecureBaseURL([out] const WCHAR** ppwcBuf);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
[
|
||||
helpstring("XML Parser"),
|
||||
uuid(f5078f19-c551-11d3-89b9-0000f81fe221),
|
||||
threading(both),
|
||||
progid("Msxml2.XMLParser"),
|
||||
vi_progid("Msxml2.XMLParser"),
|
||||
version(3.0)
|
||||
]
|
||||
coclass XMLParser
|
||||
{
|
||||
[default] interface IXMLParser;
|
||||
};
|
||||
|
||||
[
|
||||
helpstring("XML Parser 2.6"),
|
||||
uuid(f5078f20-c551-11d3-89b9-0000f81fe221),
|
||||
threading(both),
|
||||
progid("Msxml2.XMLParser.2.6"),
|
||||
vi_progid("Msxml2.XMLParser"),
|
||||
version(2.6)
|
||||
]
|
||||
coclass XMLParser26
|
||||
{
|
||||
[default] interface IXMLParser;
|
||||
};
|
||||
|
||||
[
|
||||
helpstring("XML Parser 3.0"),
|
||||
uuid(f5078f31-c551-11d3-89b9-0000f81fe221),
|
||||
threading(both),
|
||||
progid("Msxml2.XMLParser.3.0"),
|
||||
vi_progid("Msxml2.XMLParser"),
|
||||
version(3.0)
|
||||
]
|
||||
coclass XMLParser30
|
||||
{
|
||||
[default] interface IXMLParser;
|
||||
};
|
||||
|
||||
[
|
||||
helpstring("XML Document"),
|
||||
threading(apartment),
|
||||
uuid(48123bc4-99d9-11d1-a6b3-00c04fd91555),
|
||||
progid("xmlfile"),
|
||||
version(1.0)
|
||||
]
|
||||
coclass XMLView
|
||||
{
|
||||
interface IPersistMoniker;
|
||||
interface IPersistHistory;
|
||||
interface IOleCommandTarget;
|
||||
interface IOleObject;
|
||||
}
|
270
rostests/winetests/msxml3/xmlview.c
Normal file
270
rostests/winetests/msxml3/xmlview.c
Normal file
|
@ -0,0 +1,270 @@
|
|||
/*
|
||||
* Copyright 2012 Piotr Caban for CodeWeavers
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
#define COBJMACROS
|
||||
#define CONST_VTABLE
|
||||
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "windows.h"
|
||||
#include "ole2.h"
|
||||
#include "mshtml.h"
|
||||
#include "mshtmdid.h"
|
||||
#include "initguid.h"
|
||||
#include "perhist.h"
|
||||
#include "docobj.h"
|
||||
#include "urlmon.h"
|
||||
#include "xmlparser.h"
|
||||
|
||||
#include "wine/test.h"
|
||||
|
||||
HRESULT (WINAPI *pCreateURLMoniker)(IMoniker*, LPCWSTR, IMoniker**);
|
||||
|
||||
static const char xmlview_html[] =
|
||||
"\r\n"
|
||||
"<BODY><H2>Generated HTML</H2>\r\n"
|
||||
"<TABLE>\r\n"
|
||||
"<TBODY>\r\n"
|
||||
"<TR bgColor=green>\r\n"
|
||||
"<TH>Title</TH>\r\n"
|
||||
"<TH>Value</TH></TR>\r\n"
|
||||
"<TR>\r\n"
|
||||
"<TD>title1</TD>\r\n"
|
||||
"<TD>value1</TD></TR>\r\n"
|
||||
"<TR>\r\n"
|
||||
"<TD>title2</TD>\r\n"
|
||||
"<TD>value2</TD></TR></TBODY></TABLE></BODY>";
|
||||
|
||||
IHTMLDocument2 *html_doc;
|
||||
BOOL loaded;
|
||||
|
||||
static int html_src_compare(LPCWSTR strw, const char *stra)
|
||||
{
|
||||
char buf[2048], *p1;
|
||||
const char *p2;
|
||||
|
||||
WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), NULL, NULL);
|
||||
|
||||
p1 = buf;
|
||||
p2 = stra;
|
||||
while(1) {
|
||||
while(*p1=='\r' || *p1=='\n' || *p1=='\"') p1++;
|
||||
while(*p2=='\r' || *p2=='\n') p2++;
|
||||
|
||||
if(!*p1 || !*p2 || tolower(*p1)!=tolower(*p2))
|
||||
break;
|
||||
|
||||
p1++;
|
||||
p2++;
|
||||
}
|
||||
|
||||
return *p1 != *p2;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI HTMLEvents_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
|
||||
{
|
||||
if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IDispatch, riid)) {
|
||||
*ppv = iface;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
ok(0, "Unexpected call\n");
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
static ULONG WINAPI HTMLEvents_AddRef(IDispatch *iface)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
static ULONG WINAPI HTMLEvents_Release(IDispatch *iface)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI HTMLEvents_GetTypeInfoCount(IDispatch *iface, UINT *pctinfo)
|
||||
{
|
||||
ok(0, "unexpected call\n");
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI HTMLEvents_GetTypeInfo(IDispatch *iface, UINT iTInfo, LCID lcid,
|
||||
ITypeInfo **ppTInfo)
|
||||
{
|
||||
ok(0, "unexpected call\n");
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI HTMLEvents_GetIDsOfNames(IDispatch *iface, REFIID riid, LPOLESTR *rgszNames,
|
||||
UINT cNames, LCID lcid, DISPID *rgDispId)
|
||||
{
|
||||
ok(0, "unexpected call\n");
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI HTMLEvents_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
|
||||
LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
|
||||
EXCEPINFO *pExcepInfo, UINT *puArgErr)
|
||||
{
|
||||
if(dispIdMember == DISPID_HTMLDOCUMENTEVENTS2_ONREADYSTATECHANGE) {
|
||||
static const WCHAR completeW[] = {'c','o','m','p','l','e','t','e',0};
|
||||
BSTR state;
|
||||
|
||||
IHTMLDocument2_get_readyState(html_doc, &state);
|
||||
if(!memcmp(state, completeW, sizeof(completeW)))
|
||||
loaded = TRUE;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static const IDispatchVtbl HTMLEventsVtbl = {
|
||||
HTMLEvents_QueryInterface,
|
||||
HTMLEvents_AddRef,
|
||||
HTMLEvents_Release,
|
||||
HTMLEvents_GetTypeInfoCount,
|
||||
HTMLEvents_GetTypeInfo,
|
||||
HTMLEvents_GetIDsOfNames,
|
||||
HTMLEvents_Invoke
|
||||
};
|
||||
|
||||
static IDispatch HTMLEvents = { &HTMLEventsVtbl };
|
||||
|
||||
static void test_QueryInterface(void)
|
||||
{
|
||||
IUnknown *xmlview, *unk;
|
||||
IHTMLDocument *htmldoc;
|
||||
HRESULT hres;
|
||||
|
||||
hres = CoCreateInstance(&CLSID_XMLView, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
|
||||
&IID_IUnknown, (void**)&xmlview);
|
||||
if(FAILED(hres)) {
|
||||
win_skip("Failed to create XMLView instance\n");
|
||||
return;
|
||||
}
|
||||
ok(hres == S_OK, "CoCreateInstance returned %x, expected S_OK\n", hres);
|
||||
|
||||
hres = IUnknown_QueryInterface(xmlview, &IID_IPersistMoniker, (void**)&unk);
|
||||
ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker) returned %x, expected S_OK\n", hres);
|
||||
IUnknown_Release(unk);
|
||||
|
||||
hres = IUnknown_QueryInterface(xmlview, &IID_IPersistHistory, (void**)&unk);
|
||||
ok(hres == S_OK, "QueryInterface(IID_IPersistHistory) returned %x, expected S_OK\n", hres);
|
||||
IUnknown_Release(unk);
|
||||
|
||||
hres = IUnknown_QueryInterface(xmlview, &IID_IOleCommandTarget, (void**)&unk);
|
||||
ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) returned %x, expected S_OK\n", hres);
|
||||
IUnknown_Release(unk);
|
||||
|
||||
hres = IUnknown_QueryInterface(xmlview, &IID_IOleObject, (void**)&unk);
|
||||
ok(hres == S_OK, "QueryInterface(IID_IOleObject) returned %x, expected S_OK\n", hres);
|
||||
IUnknown_Release(unk);
|
||||
|
||||
hres = IUnknown_QueryInterface(xmlview, &IID_IHTMLDocument, (void**)&htmldoc);
|
||||
ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument) returned %x, expected S_OK\n", hres);
|
||||
hres = IHTMLDocument_QueryInterface(htmldoc, &IID_IUnknown, (void**)&unk);
|
||||
ok(hres == S_OK, "QueryInterface(IID_IUnknown) returned %x, expected S_OK\n", hres);
|
||||
todo_wine ok(unk == xmlview, "Aggregation is not working as expected\n");
|
||||
IUnknown_Release(unk);
|
||||
IHTMLDocument_Release(htmldoc);
|
||||
|
||||
IUnknown_Release(xmlview);
|
||||
}
|
||||
|
||||
static void test_Load(void)
|
||||
{
|
||||
static const WCHAR xmlview_xmlW[] = {'/','x','m','l','/','x','m','l','v','i','e','w','.','x','m','l',0};
|
||||
static const WCHAR res[] = {'r','e','s',':','/','/',0};
|
||||
|
||||
WCHAR buf[1024];
|
||||
IPersistMoniker *pers_mon;
|
||||
IConnectionPointContainer *cpc;
|
||||
IConnectionPoint *cp;
|
||||
IMoniker *mon;
|
||||
IBindCtx *bctx;
|
||||
IHTMLElement *elem;
|
||||
HRESULT hres;
|
||||
MSG msg;
|
||||
BSTR source;
|
||||
|
||||
lstrcpyW(buf, res);
|
||||
GetModuleFileNameW(NULL, buf+lstrlenW(buf), (sizeof(buf)-sizeof(res))/sizeof(WCHAR));
|
||||
lstrcatW(buf, xmlview_xmlW);
|
||||
|
||||
if(!pCreateURLMoniker) {
|
||||
win_skip("CreateURLMoniker not available\n");
|
||||
return;
|
||||
}
|
||||
|
||||
hres = CoCreateInstance(&CLSID_XMLView, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
|
||||
&IID_IPersistMoniker, (void**)&pers_mon);
|
||||
if(FAILED(hres)) {
|
||||
win_skip("Failed to create XMLView instance\n");
|
||||
return;
|
||||
}
|
||||
ok(hres == S_OK, "CoCreateInstance returned %x, expected S_OK\n", hres);
|
||||
|
||||
hres = IPersistMoniker_QueryInterface(pers_mon, &IID_IHTMLDocument2, (void**)&html_doc);
|
||||
ok(hres == S_OK, "QueryInterface(HTMLDocument2) returned %x, expected S_OK\n", hres);
|
||||
hres = IPersistMoniker_QueryInterface(pers_mon, &IID_IConnectionPointContainer, (void**)&cpc);
|
||||
ok(hres == S_OK, "QueryInterface(IConnectionPointContainer) returned %x, expected S_OK\n", hres);
|
||||
hres = IConnectionPointContainer_FindConnectionPoint(cpc, &IID_IDispatch, &cp);
|
||||
ok(hres == S_OK, "FindConnectionPoint returned %x, expected S_OK\n", hres);
|
||||
hres = IConnectionPoint_Advise(cp, (IUnknown*)&HTMLEvents, NULL);
|
||||
ok(hres == S_OK, "Advise returned %x, expected S_OK\n", hres);
|
||||
IConnectionPoint_Release(cp);
|
||||
IConnectionPointContainer_Release(cpc);
|
||||
|
||||
hres = CreateBindCtx(0, &bctx);
|
||||
ok(hres == S_OK, "CreateBindCtx returned %x, expected S_OK\n", hres);
|
||||
hres = pCreateURLMoniker(NULL, buf, &mon);
|
||||
ok(hres == S_OK, "CreateUrlMoniker returned %x, expected S_OK\n", hres);
|
||||
loaded = FALSE;
|
||||
hres = IPersistMoniker_Load(pers_mon, TRUE, mon, bctx, 0);
|
||||
ok(hres == S_OK, "Load returned %x, expected S_OK\n", hres);
|
||||
IBindCtx_Release(bctx);
|
||||
IMoniker_Release(mon);
|
||||
|
||||
while(!loaded && GetMessage(&msg, NULL, 0, 0)) {
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
|
||||
hres = IHTMLDocument2_get_body(html_doc, &elem);
|
||||
ok(hres == S_OK, "get_body returned %x, expected S_OK\n", hres);
|
||||
hres = IHTMLElement_get_outerHTML(elem, &source);
|
||||
ok(hres == S_OK, "get_outerHTML returned %x, expected S_OK\n", hres);
|
||||
ok(!html_src_compare(source, xmlview_html), "Incorrect HTML source: %s\n", wine_dbgstr_w(source));
|
||||
IHTMLElement_Release(elem);
|
||||
SysFreeString(source);
|
||||
|
||||
IHTMLDocument2_Release(html_doc);
|
||||
html_doc = NULL;
|
||||
IPersistMoniker_Release(pers_mon);
|
||||
}
|
||||
|
||||
START_TEST(xmlview)
|
||||
{
|
||||
HMODULE urlmon = LoadLibraryA("urlmon.dll");
|
||||
pCreateURLMoniker = (void*)GetProcAddress(urlmon, "CreateURLMoniker");
|
||||
|
||||
CoInitialize(NULL);
|
||||
test_QueryInterface();
|
||||
test_Load();
|
||||
CoUninitialize();
|
||||
}
|
12
rostests/winetests/msxml3/xmlview.xml
Normal file
12
rostests/winetests/msxml3/xmlview.xml
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<?xml-stylesheet type="text/xsl" href="xmlview.xsl"?>
|
||||
<test>
|
||||
<field>
|
||||
<title>title1</title>
|
||||
<value>value1</value>
|
||||
</field>
|
||||
<field>
|
||||
<title>title2</title>
|
||||
<value>value2</value>
|
||||
</field>
|
||||
</test>
|
26
rostests/winetests/msxml3/xmlview.xsl
Normal file
26
rostests/winetests/msxml3/xmlview.xsl
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||
|
||||
<xsl:template match="/">
|
||||
<html>
|
||||
<body>
|
||||
<h2>Generated HTML</h2>
|
||||
<table>
|
||||
<tr bgcolor="green">
|
||||
<th>Title</th>
|
||||
<th>Value</th>
|
||||
</tr>
|
||||
<xsl:for-each select="test/field">
|
||||
<tr>
|
||||
<td><xsl:value-of select="title"/></td>
|
||||
<td><xsl:value-of select="value"/></td>
|
||||
</tr>
|
||||
</xsl:for-each>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
Loading…
Reference in a new issue