2005-08-12 13:25:05 +02:00
|
|
|
/*
|
|
|
|
* XML test
|
|
|
|
*
|
|
|
|
* Copyright 2005 Mike McCormack for CodeWeavers
|
2008-03-11 09:33:06 +01:00
|
|
|
* Copyright 2007-2008 Alistair Leslie-Hughes
|
2005-08-12 13:25:05 +02:00
|
|
|
*
|
|
|
|
* 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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2005-08-12 13:25:05 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include "windows.h"
|
|
|
|
#include "ole2.h"
|
2006-12-28 03:40:46 +01:00
|
|
|
#include "xmldom.h"
|
2005-11-08 20:59:36 +01:00
|
|
|
#include "msxml2.h"
|
2005-08-12 13:25:05 +02:00
|
|
|
#include <stdio.h>
|
2007-05-09 20:09:11 +02:00
|
|
|
#include <assert.h>
|
2005-08-12 13:25:05 +02:00
|
|
|
|
|
|
|
#include "wine/test.h"
|
|
|
|
|
2007-02-26 13:49:12 +01:00
|
|
|
const CLSID CLSID_DOMDocument2 = {0xf6d90f11, 0x9c73, 0x11d3, {0xb3, 0x2e, 0x00, 0xc0, 0x4f, 0x99, 0x0b, 0xb4}};
|
|
|
|
const IID IID_IXMLDOMDocument2 = {0x2933bf95, 0x7b36, 0x11d2, {0xb2, 0x0e, 0x00, 0xc0, 0x4f, 0x98, 0x3e, 0x60}};
|
2006-11-13 16:31:45 +01:00
|
|
|
|
2005-08-23 11:37:42 +02:00
|
|
|
static const WCHAR szEmpty[] = { 0 };
|
|
|
|
static const WCHAR szIncomplete[] = {
|
|
|
|
'<','?','x','m','l',' ',
|
|
|
|
'v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',0
|
|
|
|
};
|
|
|
|
static const WCHAR szComplete1[] = {
|
|
|
|
'<','?','x','m','l',' ',
|
|
|
|
'v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',
|
|
|
|
'<','o','p','e','n','>','<','/','o','p','e','n','>','\n',0
|
|
|
|
};
|
|
|
|
static const WCHAR szComplete2[] = {
|
|
|
|
'<','?','x','m','l',' ',
|
|
|
|
'v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',
|
|
|
|
'<','o','>','<','/','o','>','\n',0
|
|
|
|
};
|
|
|
|
static const WCHAR szComplete3[] = {
|
|
|
|
'<','?','x','m','l',' ',
|
|
|
|
'v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',
|
|
|
|
'<','a','>','<','/','a','>','\n',0
|
|
|
|
};
|
|
|
|
static const WCHAR szComplete4[] = {
|
2005-11-05 11:42:45 +01:00
|
|
|
'<','?','x','m','l',' ','v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',
|
|
|
|
'<','l','c',' ','d','l','=','\'','s','t','r','1','\'','>','\n',
|
|
|
|
'<','b','s',' ','v','r','=','\'','s','t','r','2','\'',' ','s','z','=','\'','1','2','3','4','\'','>',
|
|
|
|
'f','n','1','.','t','x','t','\n',
|
|
|
|
'<','/','b','s','>','\n',
|
|
|
|
'<','p','r',' ','i','d','=','\'','s','t','r','3','\'',' ','v','r','=','\'','1','.','2','.','3','\'',' ',
|
|
|
|
'p','n','=','\'','w','i','n','e',' ','2','0','0','5','0','8','0','4','\'','>','\n',
|
|
|
|
'f','n','2','.','t','x','t','\n',
|
|
|
|
'<','/','p','r','>','\n',
|
2006-02-23 15:10:06 +01:00
|
|
|
'<','e','m','p','t','y','>','<','/','e','m','p','t','y','>','\n',
|
2006-07-10 15:48:45 +02:00
|
|
|
'<','f','o','>','\n',
|
|
|
|
'<','b','a','>','\n',
|
|
|
|
'f','1','\n',
|
|
|
|
'<','/','b','a','>','\n',
|
|
|
|
'<','/','f','o','>','\n',
|
2005-08-23 11:37:42 +02:00
|
|
|
'<','/','l','c','>','\n',0
|
|
|
|
};
|
2006-06-12 02:34:28 +02:00
|
|
|
static const WCHAR szComplete5[] = {
|
|
|
|
'<','S',':','s','e','a','r','c','h',' ','x','m','l','n','s',':','D','=','"','D','A','V',':','"',' ',
|
|
|
|
'x','m','l','n','s',':','C','=','"','u','r','n',':','s','c','h','e','m','a','s','-','m','i','c','r','o','s','o','f','t','-','c','o','m',':','o','f','f','i','c','e',':','c','l','i','p','g','a','l','l','e','r','y','"',
|
|
|
|
' ','x','m','l','n','s',':','S','=','"','u','r','n',':','s','c','h','e','m','a','s','-','m','i','c','r','o','s','o','f','t','-','c','o','m',':','o','f','f','i','c','e',':','c','l','i','p','g','a','l','l','e','r','y',':','s','e','a','r','c','h','"','>',
|
|
|
|
'<','S',':','s','c','o','p','e','>',
|
|
|
|
'<','S',':','d','e','e','p','>','/','<','/','S',':','d','e','e','p','>',
|
|
|
|
'<','/','S',':','s','c','o','p','e','>',
|
|
|
|
'<','S',':','c','o','n','t','e','n','t','f','r','e','e','t','e','x','t','>',
|
|
|
|
'<','C',':','t','e','x','t','o','r','p','r','o','p','e','r','t','y','/','>',
|
|
|
|
'c','o','m','p','u','t','e','r',
|
|
|
|
'<','/','S',':','c','o','n','t','e','n','t','f','r','e','e','t','e','x','t','>',
|
|
|
|
'<','/','S',':','s','e','a','r','c','h','>',0
|
|
|
|
};
|
|
|
|
|
2007-05-11 17:03:13 +02:00
|
|
|
static const CHAR szExampleXML[] =
|
|
|
|
"<?xml version='1.0' encoding='utf-8'?>\n"
|
|
|
|
"<root xmlns:foo='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'>\n"
|
|
|
|
" <elem>\n"
|
|
|
|
" <a>A1 field</a>\n"
|
|
|
|
" <b>B1 field</b>\n"
|
|
|
|
" <c>C1 field</c>\n"
|
|
|
|
" <description xmlns:foo='http://www.winehq.org' xmlns:bar='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'>\n"
|
|
|
|
" <html xmlns='http://www.w3.org/1999/xhtml'>\n"
|
|
|
|
" This is <strong>a</strong> <i>description</i>. <bar:x/>\n"
|
|
|
|
" </html>\n"
|
|
|
|
" </description>\n"
|
|
|
|
" </elem>\n"
|
|
|
|
"\n"
|
|
|
|
" <elem>\n"
|
|
|
|
" <a>A2 field</a>\n"
|
|
|
|
" <b>B2 field</b>\n"
|
|
|
|
" <c type=\"old\">C2 field</c>\n"
|
|
|
|
" </elem>\n"
|
|
|
|
"\n"
|
|
|
|
" <elem xmlns='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'>\n"
|
|
|
|
" <a>A3 field</a>\n"
|
|
|
|
" <b>B3 field</b>\n"
|
|
|
|
" <c>C3 field</c>\n"
|
|
|
|
" </elem>\n"
|
|
|
|
"\n"
|
|
|
|
" <elem>\n"
|
|
|
|
" <a>A4 field</a>\n"
|
|
|
|
" <b>B4 field</b>\n"
|
|
|
|
" <foo:c>C4 field</foo:c>\n"
|
|
|
|
" </elem>\n"
|
|
|
|
"</root>\n";
|
|
|
|
|
2005-10-26 12:09:22 +02:00
|
|
|
static const WCHAR szNonExistentFile[] = {
|
|
|
|
'c', ':', '\\', 'N', 'o', 'n', 'e', 'x', 'i', 's', 't', 'e', 'n', 't', '.', 'x', 'm', 'l', 0
|
|
|
|
};
|
2005-11-02 20:55:30 +01:00
|
|
|
static const WCHAR szDocument[] = {
|
|
|
|
'#', 'd', 'o', 'c', 'u', 'm', 'e', 'n', 't', 0
|
|
|
|
};
|
2005-10-26 12:09:22 +02:00
|
|
|
|
2005-08-23 11:37:42 +02:00
|
|
|
static const WCHAR szOpen[] = { 'o','p','e','n',0 };
|
2007-01-23 14:39:01 +01:00
|
|
|
static WCHAR szdl[] = { 'd','l',0 };
|
2006-02-16 19:33:39 +01:00
|
|
|
static const WCHAR szvr[] = { 'v','r',0 };
|
2005-08-23 11:37:42 +02:00
|
|
|
static const WCHAR szlc[] = { 'l','c',0 };
|
2007-01-23 14:39:01 +01:00
|
|
|
static WCHAR szbs[] = { 'b','s',0 };
|
2006-01-14 17:05:32 +01:00
|
|
|
static const WCHAR szstr1[] = { 's','t','r','1',0 };
|
2006-01-16 20:42:39 +01:00
|
|
|
static const WCHAR szstr2[] = { 's','t','r','2',0 };
|
2006-02-14 10:38:21 +01:00
|
|
|
static const WCHAR szstar[] = { '*',0 };
|
2006-02-16 19:33:39 +01:00
|
|
|
static const WCHAR szfn1_txt[] = {'f','n','1','.','t','x','t',0};
|
2005-08-23 11:37:42 +02:00
|
|
|
|
2008-01-03 23:08:35 +01:00
|
|
|
static WCHAR szComment[] = {'A',' ','C','o','m','m','e','n','t',0 };
|
2008-01-03 23:17:51 +01:00
|
|
|
static WCHAR szCommentXML[] = {'<','!','-','-','A',' ','C','o','m','m','e','n','t','-','-','>',0 };
|
|
|
|
static WCHAR szCommentNodeText[] = {'#','c','o','m','m','e','n','t',0 };
|
|
|
|
|
|
|
|
static WCHAR szElement[] = {'E','l','e','T','e','s','t', 0 };
|
|
|
|
static WCHAR szElementXML[] = {'<','E','l','e','T','e','s','t','/','>',0 };
|
|
|
|
static WCHAR szElementXML2[] = {'<','E','l','e','T','e','s','t',' ','A','t','t','r','=','"','"','/','>',0 };
|
2008-01-16 03:44:51 +01:00
|
|
|
static WCHAR szElementXML3[] = {'<','E','l','e','T','e','s','t',' ','A','t','t','r','=','"','"','>',
|
|
|
|
'T','e','s','t','i','n','g','N','o','d','e','<','/','E','l','e','T','e','s','t','>',0 };
|
2008-01-03 23:08:35 +01:00
|
|
|
|
2008-01-03 23:11:27 +01:00
|
|
|
static WCHAR szAttribute[] = {'A','t','t','r',0 };
|
2008-01-03 23:17:51 +01:00
|
|
|
static WCHAR szAttributeXML[] = {'A','t','t','r','=','"','"',0 };
|
2008-01-03 23:11:27 +01:00
|
|
|
|
2008-01-14 03:25:13 +01:00
|
|
|
static WCHAR szCData[] = {'[','1',']','*','2','=','3',';',' ','&','g','e','e',' ','t','h','a','t','s',
|
|
|
|
' ','n','o','t',' ','r','i','g','h','t','!', 0};
|
|
|
|
static WCHAR szCDataXML[] = {'<','!','[','C','D','A','T','A','[','[','1',']','*','2','=','3',';',' ','&',
|
|
|
|
'g','e','e',' ','t','h','a','t','s',' ','n','o','t',' ','r','i','g','h','t',
|
|
|
|
'!',']',']','>',0};
|
|
|
|
static WCHAR szCDataNodeText[] = {'#','c','d','a','t','a','-','s','e','c','t','i','o','n',0 };
|
2008-01-19 13:23:49 +01:00
|
|
|
static WCHAR szDocFragmentText[] = {'#','d','o','c','u','m','e','n','t','-','f','r','a','g','m','e','n','t',0 };
|
2008-01-14 03:25:13 +01:00
|
|
|
|
2008-02-01 10:49:05 +01:00
|
|
|
static WCHAR szEntityRef[] = {'e','n','t','i','t','y','r','e','f',0 };
|
2008-01-21 22:33:32 +01:00
|
|
|
static WCHAR szEntityRefXML[] = {'&','e','n','t','i','t','y','r','e','f',';',0 };
|
|
|
|
|
2007-05-09 20:09:11 +02:00
|
|
|
#define expect_bstr_eq_and_free(bstr, expect) { \
|
|
|
|
BSTR bstrExp = alloc_str_from_narrow(expect); \
|
|
|
|
ok(lstrcmpW(bstr, bstrExp) == 0, "String differs\n"); \
|
|
|
|
SysFreeString(bstr); \
|
|
|
|
SysFreeString(bstrExp); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define expect_eq(expr, value, type, format) { type ret = (expr); ok((value) == ret, #expr " expected " format " got " format "\n", value, ret); }
|
|
|
|
|
|
|
|
#define ole_check(expr) { \
|
|
|
|
HRESULT r = expr; \
|
|
|
|
ok(r == S_OK, #expr " returned %x\n", r); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define ole_expect(expr, expect) { \
|
|
|
|
HRESULT r = expr; \
|
|
|
|
ok(r == (expect), #expr " returned %x, expected %x\n", r, expect); \
|
|
|
|
}
|
|
|
|
|
|
|
|
static BSTR alloc_str_from_narrow(const char *str)
|
|
|
|
{
|
|
|
|
int len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
|
|
|
|
BSTR ret = SysAllocStringLen(NULL, len - 1); /* NUL character added automatically */
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
BSTR alloced_bstrs[256];
|
|
|
|
int alloced_bstrs_count = 0;
|
|
|
|
|
|
|
|
static BSTR _bstr_(const char *str)
|
|
|
|
{
|
|
|
|
assert(alloced_bstrs_count < sizeof(alloced_bstrs)/sizeof(alloced_bstrs[0]));
|
|
|
|
alloced_bstrs[alloced_bstrs_count] = alloc_str_from_narrow(str);
|
|
|
|
return alloced_bstrs[alloced_bstrs_count++];
|
|
|
|
}
|
|
|
|
|
2007-08-29 21:42:28 +02:00
|
|
|
static void free_bstrs(void)
|
2007-05-09 20:09:11 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < alloced_bstrs_count; i++)
|
|
|
|
SysFreeString(alloced_bstrs[i]);
|
|
|
|
alloced_bstrs_count = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static VARIANT _variantbstr_(const char *str)
|
|
|
|
{
|
|
|
|
VARIANT v;
|
|
|
|
V_VT(&v) = VT_BSTR;
|
|
|
|
V_BSTR(&v) = _bstr_(str);
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
|
2007-05-11 17:03:13 +02:00
|
|
|
static void get_str_for_type(DOMNodeType type, char *buf)
|
|
|
|
{
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case NODE_ATTRIBUTE:
|
|
|
|
strcpy(buf, "A");
|
|
|
|
break;
|
|
|
|
case NODE_ELEMENT:
|
|
|
|
strcpy(buf, "E");
|
|
|
|
break;
|
|
|
|
case NODE_DOCUMENT:
|
|
|
|
strcpy(buf, "D");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
wsprintfA(buf, "[%d]", type);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int get_node_position(IXMLDOMNode *node)
|
|
|
|
{
|
|
|
|
HRESULT r;
|
|
|
|
int pos = 0;
|
|
|
|
|
|
|
|
IXMLDOMNode_AddRef(node);
|
|
|
|
do
|
|
|
|
{
|
|
|
|
IXMLDOMNode *new_node;
|
|
|
|
|
|
|
|
pos++;
|
|
|
|
r = IXMLDOMNode_get_previousSibling(node, &new_node);
|
|
|
|
ok(!FAILED(r), "get_previousSibling failed\n");
|
|
|
|
IXMLDOMNode_Release(node);
|
|
|
|
node = new_node;
|
|
|
|
} while (r == S_OK);
|
|
|
|
return pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void node_to_string(IXMLDOMNode *node, char *buf)
|
|
|
|
{
|
|
|
|
HRESULT r = S_OK;
|
|
|
|
DOMNodeType type;
|
|
|
|
|
|
|
|
if (node == NULL)
|
|
|
|
{
|
|
|
|
lstrcpyA(buf, "(null)");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
IXMLDOMNode_AddRef(node);
|
|
|
|
while (r == S_OK)
|
|
|
|
{
|
|
|
|
IXMLDOMNode *new_node;
|
|
|
|
|
|
|
|
ole_check(IXMLDOMNode_get_nodeType(node, &type));
|
|
|
|
get_str_for_type(type, buf);
|
|
|
|
buf+=strlen(buf);
|
|
|
|
|
|
|
|
if (type == NODE_ATTRIBUTE)
|
|
|
|
{
|
|
|
|
BSTR bstr;
|
|
|
|
ole_check(IXMLDOMNode_get_nodeName(node, &bstr));
|
|
|
|
*(buf++) = '\'';
|
|
|
|
wsprintfA(buf, "%ws", bstr);
|
|
|
|
buf += strlen(buf);
|
|
|
|
*(buf++) = '\'';
|
|
|
|
SysFreeString(bstr);
|
|
|
|
|
|
|
|
r = IXMLDOMNode_selectSingleNode(node, _bstr_(".."), &new_node);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int pos = get_node_position(node);
|
|
|
|
DOMNodeType parent_type = NODE_INVALID;
|
|
|
|
r = IXMLDOMNode_get_parentNode(node, &new_node);
|
|
|
|
|
|
|
|
/* currently wine doesn't create a node for the <?xml ... ?>. To be able to test query
|
|
|
|
* results we "fix" it */
|
|
|
|
if (r == S_OK)
|
|
|
|
ole_check(IXMLDOMNode_get_nodeType(node, &parent_type));
|
|
|
|
/* we need also to workaround the no document node problem - see below */
|
|
|
|
if (((r == S_FALSE && type != NODE_DOCUMENT) || parent_type == NODE_DOCUMENT) && type != NODE_PROCESSING_INSTRUCTION && pos==1)
|
|
|
|
{
|
|
|
|
todo_wine ok(FALSE, "The first child of the document node in MSXML is the <?xml ... ?> processing instruction\n");
|
|
|
|
pos++;
|
|
|
|
}
|
|
|
|
wsprintf(buf, "%d", pos);
|
|
|
|
buf += strlen(buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
ok(!FAILED(r), "get_parentNode failed (%08x)\n", r);
|
|
|
|
IXMLDOMNode_Release(node);
|
|
|
|
node = new_node;
|
|
|
|
if (r == S_OK)
|
|
|
|
*(buf++) = '.';
|
|
|
|
}
|
|
|
|
|
|
|
|
/* currently we can't access document node in wine. All our examples this is the
|
|
|
|
* root node so to be able to test query results we add it */
|
|
|
|
if (type != NODE_DOCUMENT)
|
|
|
|
{
|
|
|
|
todo_wine ok(FALSE, "Document node is not the last returned node!\n");
|
|
|
|
*(buf++) = '.';
|
|
|
|
*(buf++) = 'D';
|
|
|
|
*(buf++) = '1';
|
|
|
|
}
|
|
|
|
*buf = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *list_to_string(IXMLDOMNodeList *list)
|
|
|
|
{
|
|
|
|
static char buf[4096];
|
|
|
|
char *pos = buf;
|
|
|
|
long len = 0;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (list == NULL)
|
|
|
|
{
|
|
|
|
lstrcpyA(buf, "(null)");
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
ole_check(IXMLDOMNodeList_get_length(list, &len));
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
{
|
|
|
|
IXMLDOMNode *node;
|
|
|
|
if (i > 0)
|
|
|
|
*(pos++) = ' ';
|
|
|
|
ole_check(IXMLDOMNodeList_nextNode(list, &node));
|
|
|
|
node_to_string(node, pos);
|
|
|
|
pos += strlen(pos);
|
|
|
|
IXMLDOMNode_Release(node);
|
|
|
|
}
|
|
|
|
*pos = 0;
|
|
|
|
return buf;
|
|
|
|
}
|
2007-05-11 17:04:43 +02:00
|
|
|
|
|
|
|
#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); }
|
2007-05-11 17:03:13 +02:00
|
|
|
#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); }
|
|
|
|
|
2006-12-10 16:51:26 +01:00
|
|
|
static void test_domdoc( void )
|
2005-08-12 13:25:05 +02:00
|
|
|
{
|
|
|
|
HRESULT r;
|
|
|
|
IXMLDOMDocument *doc = NULL;
|
2005-11-08 14:10:49 +01:00
|
|
|
IXMLDOMParseError *error;
|
2005-08-12 13:25:05 +02:00
|
|
|
IXMLDOMElement *element = NULL;
|
2006-06-27 11:54:40 +02:00
|
|
|
IXMLDOMNode *node;
|
2007-11-15 23:55:51 +01:00
|
|
|
IXMLDOMText *nodetext = NULL;
|
2008-01-03 23:08:35 +01:00
|
|
|
IXMLDOMComment *node_comment = NULL;
|
2008-01-03 23:11:27 +01:00
|
|
|
IXMLDOMAttribute *node_attr = NULL;
|
2008-01-08 00:28:57 +01:00
|
|
|
IXMLDOMNode *nodeChild = NULL;
|
2008-01-08 01:07:12 +01:00
|
|
|
IXMLDOMProcessingInstruction *nodePI = NULL;
|
2005-08-12 13:25:05 +02:00
|
|
|
VARIANT_BOOL b;
|
2005-10-26 12:09:22 +02:00
|
|
|
VARIANT var;
|
2005-08-12 13:25:05 +02:00
|
|
|
BSTR str;
|
2005-11-08 14:10:49 +01:00
|
|
|
long code;
|
2008-02-18 22:28:38 +01:00
|
|
|
long nLength = 0;
|
2005-08-12 13:25:05 +02:00
|
|
|
|
|
|
|
r = CoCreateInstance( &CLSID_DOMDocument, NULL,
|
|
|
|
CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (LPVOID*)&doc );
|
|
|
|
if( r != S_OK )
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* try some stupid things */
|
|
|
|
r = IXMLDOMDocument_loadXML( doc, NULL, NULL );
|
|
|
|
ok( r == S_FALSE, "loadXML failed\n");
|
|
|
|
|
|
|
|
b = VARIANT_TRUE;
|
|
|
|
r = IXMLDOMDocument_loadXML( doc, NULL, &b );
|
|
|
|
ok( r == S_FALSE, "loadXML failed\n");
|
|
|
|
ok( b == VARIANT_FALSE, "failed to load XML string\n");
|
|
|
|
|
2005-11-10 12:39:07 +01:00
|
|
|
/* try to load a document from a nonexistent file */
|
2005-10-26 12:09:22 +02:00
|
|
|
b = VARIANT_TRUE;
|
2005-11-02 20:55:30 +01:00
|
|
|
str = SysAllocString( szNonExistentFile );
|
2005-10-26 12:09:22 +02:00
|
|
|
VariantInit(&var);
|
|
|
|
V_VT(&var) = VT_BSTR;
|
|
|
|
V_BSTR(&var) = str;
|
|
|
|
|
|
|
|
r = IXMLDOMDocument_load( doc, var, &b);
|
|
|
|
ok( r == S_FALSE, "load (from file) failed\n");
|
|
|
|
ok( b == VARIANT_FALSE, "failed to load XML file\n");
|
|
|
|
SysFreeString( str );
|
|
|
|
|
2005-08-12 13:25:05 +02:00
|
|
|
/* try load an empty document */
|
|
|
|
b = VARIANT_TRUE;
|
|
|
|
str = SysAllocString( szEmpty );
|
|
|
|
r = IXMLDOMDocument_loadXML( doc, str, &b );
|
|
|
|
ok( r == S_FALSE, "loadXML failed\n");
|
|
|
|
ok( b == VARIANT_FALSE, "failed to load XML string\n");
|
|
|
|
SysFreeString( str );
|
|
|
|
|
|
|
|
/* check that there's no document element */
|
|
|
|
element = NULL;
|
|
|
|
r = IXMLDOMDocument_get_documentElement( doc, &element );
|
|
|
|
ok( r == S_FALSE, "should be no document element\n");
|
|
|
|
|
2006-06-27 11:54:40 +02:00
|
|
|
/* try finding a node */
|
|
|
|
node = NULL;
|
|
|
|
str = SysAllocString( szstr1 );
|
|
|
|
r = IXMLDOMDocument_selectSingleNode( doc, str, &node );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_FALSE, "ret %08x\n", r );
|
2006-06-27 11:54:40 +02:00
|
|
|
SysFreeString( str );
|
|
|
|
|
2005-08-12 13:25:05 +02:00
|
|
|
b = VARIANT_TRUE;
|
|
|
|
str = SysAllocString( szIncomplete );
|
|
|
|
r = IXMLDOMDocument_loadXML( doc, str, &b );
|
|
|
|
ok( r == S_FALSE, "loadXML failed\n");
|
|
|
|
ok( b == VARIANT_FALSE, "failed to load XML string\n");
|
|
|
|
SysFreeString( str );
|
|
|
|
|
|
|
|
/* check that there's no document element */
|
|
|
|
element = (IXMLDOMElement*)1;
|
|
|
|
r = IXMLDOMDocument_get_documentElement( doc, &element );
|
|
|
|
ok( r == S_FALSE, "should be no document element\n");
|
|
|
|
ok( element == NULL, "Element should be NULL\n");
|
|
|
|
|
|
|
|
/* try to load something valid */
|
|
|
|
b = VARIANT_FALSE;
|
|
|
|
str = SysAllocString( szComplete1 );
|
|
|
|
r = IXMLDOMDocument_loadXML( doc, str, &b );
|
|
|
|
ok( r == S_OK, "loadXML failed\n");
|
|
|
|
ok( b == VARIANT_TRUE, "failed to load XML string\n");
|
|
|
|
SysFreeString( str );
|
|
|
|
|
2007-11-11 12:36:07 +01:00
|
|
|
/* try with a null out pointer */
|
|
|
|
r = IXMLDOMDocument_get_documentElement( doc, NULL );
|
|
|
|
ok( r == E_INVALIDARG, "should be no document element\n");
|
2005-08-12 13:25:05 +02:00
|
|
|
|
2005-11-02 20:55:30 +01:00
|
|
|
/* check if nodename is correct */
|
|
|
|
r = IXMLDOMDocument_get_nodeName( doc, NULL );
|
2005-11-10 12:17:38 +01:00
|
|
|
ok ( r == E_INVALIDARG, "get_nodeName (NULL) wrong code\n");
|
2005-11-02 20:55:30 +01:00
|
|
|
|
|
|
|
/* content doesn't matter here */
|
2007-12-14 03:44:52 +01:00
|
|
|
str = NULL;
|
2005-11-02 20:55:30 +01:00
|
|
|
r = IXMLDOMDocument_get_nodeName( doc, &str );
|
|
|
|
ok ( r == S_OK, "get_nodeName wrong code\n");
|
|
|
|
ok ( str != NULL, "str is null\n");
|
|
|
|
ok( !lstrcmpW( str, szDocument ), "incorrect nodeName\n");
|
|
|
|
SysFreeString( str );
|
|
|
|
|
2008-01-16 03:44:51 +01:00
|
|
|
/* test put_text */
|
|
|
|
r = IXMLDOMDocument_put_text( doc, _bstr_("Should Fail") );
|
|
|
|
ok( r == E_FAIL, "ret %08x\n", r );
|
2005-11-02 20:55:30 +01:00
|
|
|
|
2005-11-23 14:30:22 +01:00
|
|
|
/* check that there's a document element */
|
2005-08-12 13:25:05 +02:00
|
|
|
element = NULL;
|
|
|
|
r = IXMLDOMDocument_get_documentElement( doc, &element );
|
|
|
|
ok( r == S_OK, "should be a document element\n");
|
|
|
|
if( element )
|
|
|
|
{
|
|
|
|
BSTR tag = NULL;
|
|
|
|
|
|
|
|
/* check if the tag is correct */
|
|
|
|
r = IXMLDOMElement_get_tagName( element, &tag );
|
|
|
|
ok( r == S_OK, "couldn't get tag name\n");
|
|
|
|
ok( tag != NULL, "tag was null\n");
|
|
|
|
ok( !lstrcmpW( tag, szOpen ), "incorrect tag name\n");
|
|
|
|
SysFreeString( tag );
|
|
|
|
|
|
|
|
/* figure out what happens if we try to reload the document */
|
|
|
|
str = SysAllocString( szComplete2 );
|
|
|
|
r = IXMLDOMDocument_loadXML( doc, str, &b );
|
|
|
|
ok( r == S_OK, "loadXML failed\n");
|
|
|
|
ok( b == VARIANT_TRUE, "failed to load XML string\n");
|
|
|
|
SysFreeString( str );
|
|
|
|
|
|
|
|
/* check if the tag is still correct */
|
|
|
|
tag = NULL;
|
|
|
|
r = IXMLDOMElement_get_tagName( element, &tag );
|
|
|
|
ok( r == S_OK, "couldn't get tag name\n");
|
|
|
|
ok( tag != NULL, "tag was null\n");
|
|
|
|
ok( !lstrcmpW( tag, szOpen ), "incorrect tag name\n");
|
|
|
|
SysFreeString( tag );
|
|
|
|
|
|
|
|
IXMLDOMElement_Release( element );
|
|
|
|
element = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* as soon as we call loadXML again, the document element will disappear */
|
|
|
|
b = 2;
|
|
|
|
r = IXMLDOMDocument_loadXML( doc, NULL, NULL );
|
|
|
|
ok( r == S_FALSE, "loadXML failed\n");
|
|
|
|
ok( b == 2, "variant modified\n");
|
|
|
|
r = IXMLDOMDocument_get_documentElement( doc, &element );
|
|
|
|
ok( r == S_FALSE, "should be no document element\n");
|
|
|
|
|
|
|
|
/* try to load something else simple and valid */
|
|
|
|
b = VARIANT_FALSE;
|
|
|
|
str = SysAllocString( szComplete3 );
|
|
|
|
r = IXMLDOMDocument_loadXML( doc, str, &b );
|
|
|
|
ok( r == S_OK, "loadXML failed\n");
|
|
|
|
ok( b == VARIANT_TRUE, "failed to load XML string\n");
|
|
|
|
SysFreeString( str );
|
|
|
|
|
|
|
|
/* try something a little more complicated */
|
|
|
|
b = FALSE;
|
|
|
|
str = SysAllocString( szComplete4 );
|
|
|
|
r = IXMLDOMDocument_loadXML( doc, str, &b );
|
|
|
|
ok( r == S_OK, "loadXML failed\n");
|
|
|
|
ok( b == VARIANT_TRUE, "failed to load XML string\n");
|
|
|
|
SysFreeString( str );
|
|
|
|
|
2005-11-08 14:10:49 +01:00
|
|
|
r = IXMLDOMDocument_get_parseError( doc, &error );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "returns %08x\n", r );
|
2005-11-08 14:10:49 +01:00
|
|
|
|
|
|
|
r = IXMLDOMParseError_get_errorCode( error, &code );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_FALSE, "returns %08x\n", r );
|
2005-11-08 14:10:49 +01:00
|
|
|
ok( code == 0, "code %ld\n", code );
|
|
|
|
IXMLDOMParseError_Release( error );
|
|
|
|
|
2007-11-15 23:55:51 +01:00
|
|
|
/* test createTextNode */
|
|
|
|
str = SysAllocString( szOpen );
|
|
|
|
r = IXMLDOMDocument_createTextNode(doc, str, NULL);
|
|
|
|
ok( r == E_INVALIDARG, "returns %08x\n", r );
|
|
|
|
r = IXMLDOMDocument_createTextNode(doc, str, &nodetext);
|
|
|
|
ok( r == S_OK, "returns %08x\n", r );
|
2008-03-11 09:33:06 +01:00
|
|
|
SysFreeString( str );
|
2008-01-08 00:28:57 +01:00
|
|
|
if(nodetext)
|
|
|
|
{
|
2008-01-08 02:43:34 +01:00
|
|
|
IXMLDOMNamedNodeMap *pAttribs;
|
|
|
|
|
2008-01-08 00:28:57 +01:00
|
|
|
/* Text Last Child Checks */
|
|
|
|
r = IXMLDOMText_get_lastChild(nodetext, NULL);
|
|
|
|
ok(r == E_INVALIDARG, "ret %08x\n", r );
|
|
|
|
|
|
|
|
nodeChild = (IXMLDOMNode*)0x1;
|
|
|
|
r = IXMLDOMText_get_lastChild(nodetext, &nodeChild);
|
|
|
|
ok(r == S_FALSE, "ret %08x\n", r );
|
|
|
|
ok(nodeChild == NULL, "nodeChild not NULL\n");
|
2008-01-08 02:43:34 +01:00
|
|
|
|
|
|
|
/* test get_attributes */
|
|
|
|
r = IXMLDOMText_get_attributes( nodetext, NULL );
|
|
|
|
ok( r == E_INVALIDARG, "get_attributes returned wrong code\n");
|
|
|
|
|
|
|
|
pAttribs = (IXMLDOMNamedNodeMap*)0x1;
|
|
|
|
r = IXMLDOMText_get_attributes( nodetext, &pAttribs);
|
|
|
|
ok(r == S_FALSE, "ret %08x\n", r );
|
|
|
|
ok( pAttribs == NULL, "pAttribs not NULL\n");
|
2008-01-14 02:44:56 +01:00
|
|
|
|
|
|
|
/* test get_dataType */
|
|
|
|
r = IXMLDOMText_get_dataType(nodetext, &var);
|
|
|
|
ok(r == S_FALSE, "ret %08x\n", r );
|
|
|
|
ok( V_VT(&var) == VT_NULL, "incorrect dataType type\n");
|
|
|
|
VariantClear(&var);
|
|
|
|
|
2008-02-18 22:28:38 +01:00
|
|
|
/* test length property */
|
|
|
|
r = IXMLDOMText_get_length(nodetext, NULL);
|
|
|
|
ok(r == E_INVALIDARG, "ret %08x\n", r );
|
|
|
|
|
|
|
|
r = IXMLDOMText_get_length(nodetext, &nLength);
|
|
|
|
ok(r == S_OK, "ret %08x\n", r );
|
|
|
|
ok(nLength == 4, "expected 4 got %ld\n", nLength);
|
|
|
|
|
2008-01-16 06:47:19 +01:00
|
|
|
/* test nodeTypeString */
|
|
|
|
r = IXMLDOMText_get_nodeTypeString(nodetext, &str);
|
|
|
|
ok(r == S_OK, "ret %08x\n", r );
|
|
|
|
ok( !lstrcmpW( str, _bstr_("text") ), "incorrect nodeTypeString string\n");
|
|
|
|
SysFreeString(str);
|
|
|
|
|
2008-02-25 10:05:00 +01:00
|
|
|
/* put data Tests */
|
|
|
|
r = IXMLDOMText_put_data(nodetext, _bstr_("This &is a ; test <>\\"));
|
|
|
|
ok(r == S_OK, "ret %08x\n", r );
|
|
|
|
|
2008-02-28 11:36:02 +01:00
|
|
|
/* get data Tests */
|
|
|
|
r = IXMLDOMText_get_data(nodetext, &str);
|
|
|
|
ok(r == S_OK, "ret %08x\n", r );
|
|
|
|
ok( !lstrcmpW( str, _bstr_("This &is a ; test <>\\") ), "incorrect put_data string\n");
|
|
|
|
SysFreeString(str);
|
|
|
|
|
2008-02-25 10:05:00 +01:00
|
|
|
/* Confirm XML text is good */
|
|
|
|
r = IXMLDOMText_get_xml(nodetext, &str);
|
|
|
|
ok(r == S_OK, "ret %08x\n", r );
|
|
|
|
ok( !lstrcmpW( str, _bstr_("This &is a ; test <>\\") ), "incorrect xml string\n");
|
|
|
|
SysFreeString(str);
|
|
|
|
|
|
|
|
/* Confirm we get the put_data Text back */
|
|
|
|
r = IXMLDOMText_get_text(nodetext, &str);
|
|
|
|
ok(r == S_OK, "ret %08x\n", r );
|
|
|
|
ok( !lstrcmpW( str, _bstr_("This &is a ; test <>\\") ), "incorrect xml string\n");
|
|
|
|
SysFreeString(str);
|
|
|
|
|
2008-02-29 12:39:30 +01:00
|
|
|
/* test substringData */
|
|
|
|
r = IXMLDOMText_substringData(nodetext, 0, 4, NULL);
|
|
|
|
ok(r == E_INVALIDARG, "ret %08x\n", r );
|
|
|
|
|
|
|
|
/* test substringData - Invalid offset */
|
|
|
|
str = (BSTR)&szElement;
|
|
|
|
r = IXMLDOMText_substringData(nodetext, -1, 4, &str);
|
|
|
|
ok(r == E_INVALIDARG, "ret %08x\n", r );
|
|
|
|
ok( str == NULL, "incorrect string\n");
|
|
|
|
|
|
|
|
/* test substringData - Invalid offset */
|
|
|
|
str = (BSTR)&szElement;
|
|
|
|
r = IXMLDOMText_substringData(nodetext, 30, 0, &str);
|
|
|
|
ok(r == S_FALSE, "ret %08x\n", r );
|
|
|
|
ok( str == NULL, "incorrect string\n");
|
|
|
|
|
|
|
|
/* test substringData - Invalid size */
|
|
|
|
str = (BSTR)&szElement;
|
|
|
|
r = IXMLDOMText_substringData(nodetext, 0, -1, &str);
|
|
|
|
ok(r == E_INVALIDARG, "ret %08x\n", r );
|
|
|
|
ok( str == NULL, "incorrect string\n");
|
|
|
|
|
|
|
|
/* test substringData - Invalid size */
|
|
|
|
str = (BSTR)&szElement;
|
|
|
|
r = IXMLDOMText_substringData(nodetext, 2, 0, &str);
|
|
|
|
ok(r == S_FALSE, "ret %08x\n", r );
|
|
|
|
ok( str == NULL, "incorrect string\n");
|
|
|
|
|
|
|
|
/* test substringData - Start of string */
|
|
|
|
r = IXMLDOMText_substringData(nodetext, 0, 4, &str);
|
|
|
|
ok(r == S_OK, "ret %08x\n", r );
|
|
|
|
ok( !lstrcmpW( str, _bstr_("This") ), "incorrect substringData string\n");
|
|
|
|
SysFreeString(str);
|
|
|
|
|
|
|
|
/* test substringData - Middle of string */
|
|
|
|
r = IXMLDOMText_substringData(nodetext, 13, 4, &str);
|
|
|
|
ok(r == S_OK, "ret %08x\n", r );
|
|
|
|
ok( !lstrcmpW( str, _bstr_("test") ), "incorrect substringData string\n");
|
|
|
|
SysFreeString(str);
|
|
|
|
|
|
|
|
/* test substringData - End of string */
|
|
|
|
r = IXMLDOMText_substringData(nodetext, 20, 4, &str);
|
|
|
|
ok(r == S_OK, "ret %08x\n", r );
|
|
|
|
ok( !lstrcmpW( str, _bstr_("\\") ), "incorrect substringData string\n");
|
|
|
|
SysFreeString(str);
|
|
|
|
|
2008-03-01 12:32:58 +01:00
|
|
|
/* test appendData */
|
|
|
|
r = IXMLDOMText_appendData(nodetext, NULL);
|
|
|
|
ok(r == S_OK, "ret %08x\n", r );
|
|
|
|
|
|
|
|
r = IXMLDOMText_appendData(nodetext, _bstr_(""));
|
|
|
|
ok(r == S_OK, "ret %08x\n", r );
|
|
|
|
|
|
|
|
r = IXMLDOMText_appendData(nodetext, _bstr_("Append"));
|
|
|
|
ok(r == S_OK, "ret %08x\n", r );
|
|
|
|
|
|
|
|
r = IXMLDOMText_get_text(nodetext, &str);
|
|
|
|
ok(r == S_OK, "ret %08x\n", r );
|
|
|
|
ok( !lstrcmpW( str, _bstr_("This &is a ; test <>\\Append") ), "incorrect get_text string\n");
|
|
|
|
SysFreeString(str);
|
|
|
|
|
2008-03-10 11:33:58 +01:00
|
|
|
/* test insertData */
|
|
|
|
str = SysAllocStringLen(NULL, 0);
|
|
|
|
r = IXMLDOMText_insertData(nodetext, -1, str);
|
|
|
|
ok(r == S_OK, "ret %08x\n", r );
|
|
|
|
|
|
|
|
r = IXMLDOMText_insertData(nodetext, -1, NULL);
|
|
|
|
ok(r == S_OK, "ret %08x\n", r );
|
|
|
|
|
|
|
|
r = IXMLDOMText_insertData(nodetext, 1000, str);
|
|
|
|
ok(r == S_OK, "ret %08x\n", r );
|
|
|
|
|
|
|
|
r = IXMLDOMText_insertData(nodetext, 1000, NULL);
|
|
|
|
ok(r == S_OK, "ret %08x\n", r );
|
|
|
|
|
|
|
|
r = IXMLDOMText_insertData(nodetext, 0, NULL);
|
|
|
|
ok(r == S_OK, "ret %08x\n", r );
|
|
|
|
|
|
|
|
r = IXMLDOMText_insertData(nodetext, 0, str);
|
|
|
|
ok(r == S_OK, "ret %08x\n", r );
|
|
|
|
SysFreeString(str);
|
|
|
|
|
|
|
|
r = IXMLDOMText_insertData(nodetext, -1, _bstr_("Inserting"));
|
|
|
|
ok(r == E_INVALIDARG, "ret %08x\n", r );
|
|
|
|
|
|
|
|
r = IXMLDOMText_insertData(nodetext, 1000, _bstr_("Inserting"));
|
|
|
|
ok(r == E_INVALIDARG, "ret %08x\n", r );
|
|
|
|
|
|
|
|
r = IXMLDOMText_insertData(nodetext, 0, _bstr_("Begin "));
|
|
|
|
ok(r == S_OK, "ret %08x\n", r );
|
|
|
|
|
|
|
|
r = IXMLDOMText_insertData(nodetext, 17, _bstr_("Middle"));
|
|
|
|
ok(r == S_OK, "ret %08x\n", r );
|
|
|
|
|
|
|
|
r = IXMLDOMText_insertData(nodetext, 39, _bstr_(" End"));
|
|
|
|
ok(r == S_OK, "ret %08x\n", r );
|
|
|
|
|
|
|
|
r = IXMLDOMText_get_text(nodetext, &str);
|
|
|
|
ok(r == S_OK, "ret %08x\n", r );
|
|
|
|
ok( !lstrcmpW( str, _bstr_("Begin This &is a Middle; test <>\\Append End") ), "incorrect get_text string\n");
|
|
|
|
SysFreeString(str);
|
|
|
|
|
2008-01-11 09:15:41 +01:00
|
|
|
IXMLDOMText_Release( nodetext );
|
2008-01-08 00:28:57 +01:00
|
|
|
}
|
2007-11-15 23:55:51 +01:00
|
|
|
|
2008-01-03 23:08:35 +01:00
|
|
|
/* test Create Comment */
|
|
|
|
r = IXMLDOMDocument_createComment(doc, NULL, NULL);
|
|
|
|
ok( r == E_INVALIDARG, "returns %08x\n", r );
|
|
|
|
r = IXMLDOMDocument_createComment(doc, szComment, &node_comment);
|
|
|
|
ok( r == S_OK, "returns %08x\n", r );
|
2008-01-08 00:28:57 +01:00
|
|
|
if(node_comment)
|
|
|
|
{
|
|
|
|
/* Last Child Checks */
|
|
|
|
r = IXMLDOMComment_get_lastChild(node_comment, NULL);
|
|
|
|
ok(r == E_INVALIDARG, "ret %08x\n", r );
|
|
|
|
|
|
|
|
nodeChild = (IXMLDOMNode*)0x1;
|
|
|
|
r = IXMLDOMComment_get_lastChild(node_comment, &nodeChild);
|
|
|
|
ok(r == S_FALSE, "ret %08x\n", r );
|
|
|
|
ok(nodeChild == NULL, "pLastChild not NULL\n");
|
2008-01-16 06:47:19 +01:00
|
|
|
|
|
|
|
IXMLDOMComment_Release( node_comment );
|
2008-01-08 00:28:57 +01:00
|
|
|
}
|
2008-01-03 23:08:35 +01:00
|
|
|
|
2008-01-03 23:11:27 +01:00
|
|
|
/* test Create Attribute */
|
|
|
|
r = IXMLDOMDocument_createAttribute(doc, NULL, NULL);
|
|
|
|
ok( r == E_INVALIDARG, "returns %08x\n", r );
|
|
|
|
r = IXMLDOMDocument_createAttribute(doc, szAttribute, &node_attr);
|
|
|
|
ok( r == S_OK, "returns %08x\n", r );
|
|
|
|
IXMLDOMText_Release( node_attr);
|
|
|
|
|
2008-01-08 01:07:12 +01:00
|
|
|
/* test Processing Instruction */
|
|
|
|
str = SysAllocStringLen(NULL, 0);
|
|
|
|
r = IXMLDOMDocument_createProcessingInstruction(doc, str, str, NULL);
|
|
|
|
ok( r == E_INVALIDARG, "returns %08x\n", r );
|
|
|
|
r = IXMLDOMDocument_createProcessingInstruction(doc, NULL, str, &nodePI);
|
|
|
|
ok( r == E_FAIL, "returns %08x\n", r );
|
|
|
|
r = IXMLDOMDocument_createProcessingInstruction(doc, str, str, &nodePI);
|
|
|
|
ok( r == E_FAIL, "returns %08x\n", r );
|
|
|
|
SysFreeString(str);
|
|
|
|
|
|
|
|
r = IXMLDOMDocument_createProcessingInstruction(doc, _bstr_("xml"), _bstr_("version=\"1.0\""), &nodePI);
|
|
|
|
ok( r == S_OK, "returns %08x\n", r );
|
|
|
|
if(nodePI)
|
|
|
|
{
|
|
|
|
/* Last Child Checks */
|
|
|
|
r = IXMLDOMProcessingInstruction_get_lastChild(nodePI, NULL);
|
|
|
|
ok(r == E_INVALIDARG, "ret %08x\n", r );
|
|
|
|
|
|
|
|
nodeChild = (IXMLDOMNode*)0x1;
|
|
|
|
r = IXMLDOMProcessingInstruction_get_lastChild(nodePI, &nodeChild);
|
|
|
|
ok(r == S_FALSE, "ret %08x\n", r );
|
|
|
|
ok(nodeChild == NULL, "nodeChild not NULL\n");
|
2008-01-14 02:44:56 +01:00
|
|
|
|
|
|
|
r = IXMLDOMProcessingInstruction_get_dataType(nodePI, &var);
|
|
|
|
ok(r == S_FALSE, "ret %08x\n", r );
|
|
|
|
ok( V_VT(&var) == VT_NULL, "incorrect dataType type\n");
|
|
|
|
VariantClear(&var);
|
|
|
|
|
2008-02-16 12:02:40 +01:00
|
|
|
/* test nodeName */
|
|
|
|
r = IXMLDOMProcessingInstruction_get_nodeName(nodePI, &str);
|
|
|
|
ok(r == S_OK, "ret %08x\n", r );
|
|
|
|
ok( !lstrcmpW( str, _bstr_("xml") ), "incorrect nodeName string\n");
|
|
|
|
SysFreeString(str);
|
|
|
|
|
|
|
|
/* test Target */
|
|
|
|
r = IXMLDOMProcessingInstruction_get_target(nodePI, &str);
|
|
|
|
ok(r == S_OK, "ret %08x\n", r );
|
|
|
|
ok( !lstrcmpW( str, _bstr_("xml") ), "incorrect target string\n");
|
|
|
|
SysFreeString(str);
|
|
|
|
|
2008-01-16 06:47:19 +01:00
|
|
|
/* test nodeTypeString */
|
|
|
|
r = IXMLDOMProcessingInstruction_get_nodeTypeString(nodePI, &str);
|
|
|
|
ok(r == S_OK, "ret %08x\n", r );
|
|
|
|
ok( !lstrcmpW( str, _bstr_("processinginstruction") ), "incorrect nodeTypeString string\n");
|
|
|
|
SysFreeString(str);
|
|
|
|
|
2008-02-20 12:35:07 +01:00
|
|
|
/* test get_nodeValue */
|
|
|
|
r = IXMLDOMProcessingInstruction_get_nodeValue(nodePI, &var);
|
|
|
|
ok(r == S_OK, "ret %08x\n", r );
|
|
|
|
ok( !lstrcmpW( V_BSTR(&var), _bstr_("version=\"1.0\"") ), "incorrect data string\n");
|
|
|
|
VariantClear(&var);
|
|
|
|
|
|
|
|
/* test get_data */
|
|
|
|
r = IXMLDOMProcessingInstruction_get_data(nodePI, &str);
|
|
|
|
ok(r == S_OK, "ret %08x\n", r );
|
|
|
|
ok( !lstrcmpW( str, _bstr_("version=\"1.0\"") ), "incorrect data string\n");
|
|
|
|
SysFreeString(str);
|
|
|
|
|
2008-02-25 10:05:00 +01:00
|
|
|
/* test put_data */
|
|
|
|
r = IXMLDOMProcessingInstruction_put_data(nodePI, _bstr_("version=\"1.0\" encoding=\"UTF-8\""));
|
2008-02-29 10:54:53 +01:00
|
|
|
ok(r == E_FAIL, "ret %08x\n", r );
|
2008-02-25 10:05:00 +01:00
|
|
|
|
2008-03-13 10:30:12 +01:00
|
|
|
/* test put_data */
|
|
|
|
V_VT(&var) = VT_BSTR;
|
|
|
|
V_BSTR(&var) = SysAllocString(szOpen); /* Doesnt matter what the string is, cannot set an xml node. */
|
|
|
|
r = IXMLDOMProcessingInstruction_put_nodeValue(nodePI, var);
|
|
|
|
ok(r == E_FAIL, "ret %08x\n", r );
|
|
|
|
VariantClear(&var);
|
|
|
|
|
2008-03-01 13:20:20 +01:00
|
|
|
/* test get nodeName */
|
|
|
|
r = IXMLDOMProcessingInstruction_get_nodeName(nodePI, &str);
|
|
|
|
ok( !lstrcmpW( str, _bstr_("xml") ), "incorrect nodeName string\n");
|
|
|
|
ok(r == S_OK, "ret %08x\n", r );
|
|
|
|
SysFreeString(str);
|
|
|
|
|
2008-01-11 09:15:41 +01:00
|
|
|
IXMLDOMProcessingInstruction_Release(nodePI);
|
2008-01-08 01:07:12 +01:00
|
|
|
}
|
|
|
|
|
2005-11-08 20:59:36 +01:00
|
|
|
r = IXMLDOMDocument_Release( doc );
|
2005-08-12 13:25:05 +02:00
|
|
|
ok( r == 0, "document ref count incorrect\n");
|
|
|
|
|
2008-02-25 10:05:00 +01:00
|
|
|
free_bstrs();
|
2005-08-23 11:37:42 +02:00
|
|
|
}
|
|
|
|
|
2006-12-10 16:51:26 +01:00
|
|
|
static void test_domnode( void )
|
2005-08-23 11:37:42 +02:00
|
|
|
{
|
|
|
|
HRESULT r;
|
|
|
|
IXMLDOMDocument *doc = NULL, *owner = NULL;
|
|
|
|
IXMLDOMElement *element = NULL;
|
|
|
|
IXMLDOMNamedNodeMap *map = NULL;
|
|
|
|
IXMLDOMNode *node = NULL, *next = NULL;
|
|
|
|
IXMLDOMNodeList *list = NULL;
|
|
|
|
DOMNodeType type = NODE_INVALID;
|
|
|
|
VARIANT_BOOL b;
|
|
|
|
BSTR str;
|
|
|
|
VARIANT var;
|
2005-11-03 13:04:52 +01:00
|
|
|
long count;
|
2005-08-23 11:37:42 +02:00
|
|
|
|
|
|
|
r = CoCreateInstance( &CLSID_DOMDocument, NULL,
|
|
|
|
CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (LPVOID*)&doc );
|
|
|
|
if( r != S_OK )
|
|
|
|
return;
|
|
|
|
|
|
|
|
b = FALSE;
|
|
|
|
str = SysAllocString( szComplete4 );
|
|
|
|
r = IXMLDOMDocument_loadXML( doc, str, &b );
|
|
|
|
ok( r == S_OK, "loadXML failed\n");
|
|
|
|
ok( b == VARIANT_TRUE, "failed to load XML string\n");
|
|
|
|
SysFreeString( str );
|
|
|
|
|
|
|
|
if (doc)
|
|
|
|
{
|
|
|
|
b = 1;
|
|
|
|
r = IXMLDOMNode_hasChildNodes( doc, &b );
|
|
|
|
ok( r == S_OK, "hasChildNoes bad return\n");
|
|
|
|
ok( b == VARIANT_TRUE, "hasChildNoes wrong result\n");
|
|
|
|
|
|
|
|
r = IXMLDOMDocument_get_documentElement( doc, &element );
|
|
|
|
ok( r == S_OK, "should be a document element\n");
|
|
|
|
ok( element != NULL, "should be an element\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ok( FALSE, "no document\n");
|
|
|
|
|
|
|
|
VariantInit(&var);
|
|
|
|
ok( V_VT(&var) == VT_EMPTY, "variant init failed\n");
|
2008-01-03 06:02:36 +01:00
|
|
|
|
|
|
|
r = IXMLDOMNode_get_nodeValue( doc, NULL );
|
|
|
|
ok(r == E_INVALIDARG, "get_nodeValue ret %08x\n", r );
|
|
|
|
|
2005-08-23 11:37:42 +02:00
|
|
|
r = IXMLDOMNode_get_nodeValue( doc, &var );
|
|
|
|
ok( r == S_FALSE, "nextNode returned wrong code\n");
|
|
|
|
ok( V_VT(&var) == VT_NULL, "variant wasn't empty\n");
|
|
|
|
ok( V_BSTR(&var) == NULL, "variant value wasn't null\n");
|
|
|
|
|
|
|
|
if (element)
|
|
|
|
{
|
|
|
|
owner = NULL;
|
|
|
|
r = IXMLDOMNode_get_ownerDocument( element, &owner );
|
|
|
|
todo_wine {
|
|
|
|
ok( r == S_OK, "get_ownerDocument return code\n");
|
|
|
|
}
|
|
|
|
ok( owner != doc, "get_ownerDocument return\n");
|
|
|
|
|
|
|
|
type = NODE_INVALID;
|
|
|
|
r = IXMLDOMNode_get_nodeType( element, &type);
|
|
|
|
ok( r == S_OK, "getNamedItem returned wrong code\n");
|
|
|
|
ok( type == NODE_ELEMENT, "node not an element\n");
|
|
|
|
|
|
|
|
str = NULL;
|
|
|
|
r = IXMLDOMNode_get_baseName( element, &str );
|
|
|
|
ok( r == S_OK, "get_baseName returned wrong code\n");
|
|
|
|
ok( lstrcmpW(str,szlc) == 0, "basename was wrong\n");
|
2007-12-09 10:50:39 +01:00
|
|
|
SysFreeString(str);
|
2005-08-23 11:37:42 +02:00
|
|
|
|
2005-11-02 20:55:30 +01:00
|
|
|
/* check if nodename is correct */
|
|
|
|
r = IXMLDOMElement_get_nodeName( element, NULL );
|
2005-11-10 12:17:38 +01:00
|
|
|
ok ( r == E_INVALIDARG, "get_nodeName (NULL) wrong code\n");
|
2005-11-02 20:55:30 +01:00
|
|
|
|
|
|
|
/* content doesn't matter here */
|
2007-12-11 06:06:00 +01:00
|
|
|
str = NULL;
|
2005-11-02 20:55:30 +01:00
|
|
|
r = IXMLDOMElement_get_nodeName( element, &str );
|
|
|
|
ok ( r == S_OK, "get_nodeName wrong code\n");
|
|
|
|
ok ( str != NULL, "str is null\n");
|
|
|
|
ok( !lstrcmpW( str, szlc ), "incorrect nodeName\n");
|
|
|
|
SysFreeString( str );
|
|
|
|
|
2006-01-14 17:05:32 +01:00
|
|
|
str = SysAllocString( szNonExistentFile );
|
|
|
|
V_VT(&var) = VT_I4;
|
|
|
|
V_I4(&var) = 0x1234;
|
|
|
|
r = IXMLDOMElement_getAttribute( element, str, &var );
|
2008-02-01 10:45:02 +01:00
|
|
|
ok( r == E_FAIL, "getAttribute ret %08x\n", r );
|
2008-01-14 11:13:01 +01:00
|
|
|
ok( V_VT(&var) == VT_NULL, "vt = %x\n", V_VT(&var));
|
2006-01-14 17:05:32 +01:00
|
|
|
VariantClear(&var);
|
|
|
|
SysFreeString( str );
|
|
|
|
|
|
|
|
str = SysAllocString( szdl );
|
|
|
|
V_VT(&var) = VT_I4;
|
|
|
|
V_I4(&var) = 0x1234;
|
|
|
|
r = IXMLDOMElement_getAttribute( element, str, &var );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "getAttribute ret %08x\n", r );
|
2006-01-14 17:05:32 +01:00
|
|
|
ok( V_VT(&var) == VT_BSTR, "vt = %x\n", V_VT(&var));
|
|
|
|
ok( !lstrcmpW(V_BSTR(&var), szstr1), "wrong attr value\n");
|
|
|
|
VariantClear( &var );
|
2008-01-14 11:13:01 +01:00
|
|
|
|
|
|
|
r = IXMLDOMElement_getAttribute( element, NULL, &var );
|
|
|
|
ok( r == E_INVALIDARG, "getAttribute ret %08x\n", r );
|
|
|
|
|
|
|
|
r = IXMLDOMElement_getAttribute( element, str, NULL );
|
|
|
|
ok( r == E_INVALIDARG, "getAttribute ret %08x\n", r );
|
|
|
|
|
2006-01-14 17:05:32 +01:00
|
|
|
SysFreeString( str );
|
|
|
|
|
2005-08-23 11:37:42 +02:00
|
|
|
r = IXMLDOMElement_get_attributes( element, &map );
|
|
|
|
ok( r == S_OK, "get_attributes returned wrong code\n");
|
|
|
|
ok( map != NULL, "should be attributes\n");
|
|
|
|
|
|
|
|
b = 1;
|
|
|
|
r = IXMLDOMNode_hasChildNodes( element, &b );
|
|
|
|
ok( r == S_OK, "hasChildNoes bad return\n");
|
|
|
|
ok( b == VARIANT_TRUE, "hasChildNoes wrong result\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ok( FALSE, "no element\n");
|
|
|
|
|
|
|
|
if (map)
|
|
|
|
{
|
2006-02-10 15:14:33 +01:00
|
|
|
ISupportErrorInfo *support_error;
|
|
|
|
r = IXMLDOMNamedNodeMap_QueryInterface( map, &IID_ISupportErrorInfo, (LPVOID*)&support_error );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "ret %08x\n", r );
|
2006-02-10 15:14:33 +01:00
|
|
|
|
|
|
|
r = ISupportErrorInfo_InterfaceSupportsErrorInfo( support_error, &IID_IXMLDOMNamedNodeMap );
|
|
|
|
todo_wine
|
|
|
|
{
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "ret %08x\n", r );
|
2006-02-10 15:14:33 +01:00
|
|
|
}
|
|
|
|
ISupportErrorInfo_Release( support_error );
|
|
|
|
|
2005-08-23 11:37:42 +02:00
|
|
|
str = SysAllocString( szdl );
|
|
|
|
r = IXMLDOMNamedNodeMap_getNamedItem( map, str, &node );
|
|
|
|
ok( r == S_OK, "getNamedItem returned wrong code\n");
|
|
|
|
ok( node != NULL, "should be attributes\n");
|
2005-11-23 14:30:22 +01:00
|
|
|
IXMLDOMNode_Release(node);
|
2005-11-03 13:04:52 +01:00
|
|
|
SysFreeString( str );
|
|
|
|
|
2006-09-21 01:41:30 +02:00
|
|
|
str = SysAllocString( szdl );
|
|
|
|
r = IXMLDOMNamedNodeMap_getNamedItem( map, str, NULL );
|
|
|
|
ok( r == E_INVALIDARG, "getNamedItem should return E_INVALIDARG\n");
|
|
|
|
SysFreeString( str );
|
|
|
|
|
|
|
|
/* something that isn't in szComplete4 */
|
|
|
|
str = SysAllocString( szOpen );
|
|
|
|
node = (IXMLDOMNode *) 1;
|
|
|
|
r = IXMLDOMNamedNodeMap_getNamedItem( map, str, &node );
|
|
|
|
ok( r = S_FALSE, "getNamedItem found a node that wasn't there\n");
|
|
|
|
ok( node == NULL, "getNamedItem should have returned NULL\n");
|
|
|
|
SysFreeString( str );
|
|
|
|
|
2005-11-03 13:04:52 +01:00
|
|
|
/* test indexed access of attributes */
|
|
|
|
r = IXMLDOMNamedNodeMap_get_length( map, &count );
|
|
|
|
ok ( r == S_OK, "get_length wrong code\n");
|
|
|
|
ok ( count == 1, "get_length != 1\n");
|
|
|
|
|
|
|
|
node = NULL;
|
|
|
|
r = IXMLDOMNamedNodeMap_get_item( map, -1, &node);
|
|
|
|
ok ( r == S_FALSE, "get_item (-1) wrong code\n");
|
|
|
|
ok ( node == NULL, "there is no node\n");
|
|
|
|
|
|
|
|
node = NULL;
|
|
|
|
r = IXMLDOMNamedNodeMap_get_item( map, 1, &node);
|
|
|
|
ok ( r == S_FALSE, "get_item (1) wrong code\n");
|
|
|
|
ok ( node == NULL, "there is no attribute\n");
|
|
|
|
|
|
|
|
node = NULL;
|
|
|
|
r = IXMLDOMNamedNodeMap_get_item( map, 0, &node);
|
|
|
|
ok ( r == S_OK, "get_item (0) wrong code\n");
|
|
|
|
ok ( node != NULL, "should be attribute\n");
|
|
|
|
|
|
|
|
r = IXMLDOMNode_get_nodeName( node, NULL );
|
2005-11-10 12:17:38 +01:00
|
|
|
ok ( r == E_INVALIDARG, "get_nodeName (NULL) wrong code\n");
|
2005-11-03 13:04:52 +01:00
|
|
|
|
|
|
|
/* content doesn't matter here */
|
2007-12-14 03:44:52 +01:00
|
|
|
str = NULL;
|
2005-11-03 13:04:52 +01:00
|
|
|
r = IXMLDOMNode_get_nodeName( node, &str );
|
|
|
|
ok ( r == S_OK, "get_nodeName wrong code\n");
|
|
|
|
ok ( str != NULL, "str is null\n");
|
|
|
|
ok( !lstrcmpW( str, szdl ), "incorrect node name\n");
|
|
|
|
SysFreeString( str );
|
2006-12-28 16:22:31 +01:00
|
|
|
|
|
|
|
/* test sequential access of attributes */
|
|
|
|
node = NULL;
|
|
|
|
r = IXMLDOMNamedNodeMap_nextNode( map, &node );
|
|
|
|
ok ( r == S_OK, "nextNode (first time) wrong code\n");
|
|
|
|
ok ( node != NULL, "nextNode, should be attribute\n");
|
|
|
|
|
|
|
|
r = IXMLDOMNamedNodeMap_nextNode( map, &node );
|
|
|
|
ok ( r != S_OK, "nextNode (second time) wrong code\n");
|
|
|
|
ok ( node == NULL, "nextNode, there is no attribute\n");
|
|
|
|
|
|
|
|
r = IXMLDOMNamedNodeMap_reset( map );
|
|
|
|
ok ( r == S_OK, "reset should return S_OK\n");
|
|
|
|
|
|
|
|
r = IXMLDOMNamedNodeMap_nextNode( map, &node );
|
|
|
|
ok ( r == S_OK, "nextNode (third time) wrong code\n");
|
|
|
|
ok ( node != NULL, "nextNode, should be attribute\n");
|
2005-08-23 11:37:42 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
ok( FALSE, "no map\n");
|
|
|
|
|
|
|
|
if (node)
|
|
|
|
{
|
|
|
|
type = NODE_INVALID;
|
|
|
|
r = IXMLDOMNode_get_nodeType( node, &type);
|
|
|
|
ok( r == S_OK, "getNamedItem returned wrong code\n");
|
|
|
|
ok( type == NODE_ATTRIBUTE, "node not an attribute\n");
|
|
|
|
|
|
|
|
str = NULL;
|
|
|
|
r = IXMLDOMNode_get_baseName( node, NULL );
|
|
|
|
ok( r == E_INVALIDARG, "get_baseName returned wrong code\n");
|
|
|
|
|
|
|
|
str = NULL;
|
|
|
|
r = IXMLDOMNode_get_baseName( node, &str );
|
|
|
|
ok( r == S_OK, "get_baseName returned wrong code\n");
|
|
|
|
ok( lstrcmpW(str,szdl) == 0, "basename was wrong\n");
|
2007-11-11 12:36:07 +01:00
|
|
|
SysFreeString( str );
|
2005-08-23 11:37:42 +02:00
|
|
|
|
2006-01-16 20:43:02 +01:00
|
|
|
r = IXMLDOMNode_get_nodeValue( node, &var );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "returns %08x\n", r );
|
2006-01-16 20:43:02 +01:00
|
|
|
ok( V_VT(&var) == VT_BSTR, "vt %x\n", V_VT(&var));
|
|
|
|
ok( !lstrcmpW(V_BSTR(&var), szstr1), "nodeValue incorrect\n");
|
|
|
|
VariantClear(&var);
|
|
|
|
|
2005-08-23 11:37:42 +02:00
|
|
|
r = IXMLDOMNode_get_childNodes( node, NULL );
|
|
|
|
ok( r == E_INVALIDARG, "get_childNodes returned wrong code\n");
|
|
|
|
|
|
|
|
r = IXMLDOMNode_get_childNodes( node, &list );
|
|
|
|
ok( r == S_OK, "get_childNodes returned wrong code\n");
|
|
|
|
|
|
|
|
if (list)
|
|
|
|
{
|
|
|
|
r = IXMLDOMNodeList_nextNode( list, &next );
|
|
|
|
ok( r == S_OK, "nextNode returned wrong code\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ok( FALSE, "no childlist\n");
|
|
|
|
|
|
|
|
if (next)
|
|
|
|
{
|
|
|
|
b = 1;
|
|
|
|
r = IXMLDOMNode_hasChildNodes( next, &b );
|
|
|
|
ok( r == S_FALSE, "hasChildNoes bad return\n");
|
|
|
|
ok( b == VARIANT_FALSE, "hasChildNoes wrong result\n");
|
|
|
|
|
|
|
|
type = NODE_INVALID;
|
|
|
|
r = IXMLDOMNode_get_nodeType( next, &type);
|
|
|
|
ok( r == S_OK, "getNamedItem returned wrong code\n");
|
|
|
|
ok( type == NODE_TEXT, "node not text\n");
|
|
|
|
|
|
|
|
str = (BSTR) 1;
|
|
|
|
r = IXMLDOMNode_get_baseName( next, &str );
|
|
|
|
ok( r == S_FALSE, "get_baseName returned wrong code\n");
|
|
|
|
ok( str == NULL, "basename was wrong\n");
|
2007-12-24 02:52:52 +01:00
|
|
|
SysFreeString(str);
|
2005-08-23 11:37:42 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
ok( FALSE, "no next\n");
|
|
|
|
|
|
|
|
if (next)
|
|
|
|
IXMLDOMNode_Release( next );
|
|
|
|
next = NULL;
|
|
|
|
if (list)
|
|
|
|
IXMLDOMNodeList_Release( list );
|
|
|
|
list = NULL;
|
|
|
|
if (node)
|
|
|
|
IXMLDOMNode_Release( node );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ok( FALSE, "no node\n");
|
|
|
|
node = NULL;
|
|
|
|
|
|
|
|
if (map)
|
|
|
|
IXMLDOMNamedNodeMap_Release( map );
|
|
|
|
|
2007-05-11 17:04:43 +02:00
|
|
|
/* now traverse the tree from the root element */
|
2005-08-23 11:37:42 +02:00
|
|
|
if (element)
|
|
|
|
{
|
2007-05-11 17:04:43 +02:00
|
|
|
IXMLDOMNode *node;
|
2005-08-23 11:37:42 +02:00
|
|
|
r = IXMLDOMNode_get_childNodes( element, &list );
|
|
|
|
ok( r == S_OK, "get_childNodes returned wrong code\n");
|
2007-05-11 17:04:43 +02:00
|
|
|
|
|
|
|
/* using get_item for child list doesn't advance the position */
|
|
|
|
ole_check(IXMLDOMNodeList_get_item(list, 1, &node));
|
|
|
|
expect_node(node, "E2.E2.D1");
|
|
|
|
IXMLDOMNode_Release(node);
|
|
|
|
ole_check(IXMLDOMNodeList_nextNode(list, &node));
|
|
|
|
expect_node(node, "E1.E2.D1");
|
|
|
|
IXMLDOMNode_Release(node);
|
|
|
|
ole_check(IXMLDOMNodeList_reset(list));
|
|
|
|
|
|
|
|
IXMLDOMNodeList_AddRef(list);
|
|
|
|
expect_list_and_release(list, "E1.E2.D1 E2.E2.D1 E3.E2.D1 E4.E2.D1");
|
|
|
|
ole_check(IXMLDOMNodeList_reset(list));
|
2005-08-23 11:37:42 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
ok( FALSE, "no element\n");
|
|
|
|
|
2006-07-18 16:53:00 +02:00
|
|
|
node = (void*)0xdeadbeef;
|
2007-01-23 14:39:01 +01:00
|
|
|
r = IXMLDOMNode_selectSingleNode( element, szdl, &node );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_FALSE, "ret %08x\n", r );
|
2006-07-18 16:53:00 +02:00
|
|
|
ok( node == NULL, "node %p\n", node );
|
2007-01-23 14:39:01 +01:00
|
|
|
r = IXMLDOMNode_selectSingleNode( element, szbs, &node );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "ret %08x\n", r );
|
2005-11-08 17:10:13 +01:00
|
|
|
r = IXMLDOMNode_Release( node );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == 0, "ret %08x\n", r );
|
2005-11-08 17:10:13 +01:00
|
|
|
|
2005-08-23 11:37:42 +02:00
|
|
|
if (list)
|
|
|
|
{
|
2005-11-05 11:42:45 +01:00
|
|
|
r = IXMLDOMNodeList_get_length( list, &count );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "get_length returns %08x\n", r );
|
2006-07-10 15:48:45 +02:00
|
|
|
ok( count == 4, "get_length got %ld\n", count );
|
2005-11-05 11:42:45 +01:00
|
|
|
|
2005-08-23 11:37:42 +02:00
|
|
|
r = IXMLDOMNodeList_nextNode( list, &node );
|
|
|
|
ok( r == S_OK, "nextNode returned wrong code\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ok( FALSE, "no list\n");
|
|
|
|
|
|
|
|
if (node)
|
|
|
|
{
|
|
|
|
type = NODE_INVALID;
|
|
|
|
r = IXMLDOMNode_get_nodeType( node, &type);
|
|
|
|
ok( r == S_OK, "getNamedItem returned wrong code\n");
|
|
|
|
ok( type == NODE_ELEMENT, "node not text\n");
|
|
|
|
|
|
|
|
VariantInit(&var);
|
|
|
|
ok( V_VT(&var) == VT_EMPTY, "variant init failed\n");
|
|
|
|
r = IXMLDOMNode_get_nodeValue( node, &var );
|
|
|
|
ok( r == S_FALSE, "nextNode returned wrong code\n");
|
|
|
|
ok( V_VT(&var) == VT_NULL, "variant wasn't empty\n");
|
|
|
|
ok( V_BSTR(&var) == NULL, "variant value wasn't null\n");
|
|
|
|
|
|
|
|
r = IXMLDOMNode_hasChildNodes( node, NULL );
|
|
|
|
ok( r == E_INVALIDARG, "hasChildNoes bad return\n");
|
|
|
|
|
|
|
|
b = 1;
|
|
|
|
r = IXMLDOMNode_hasChildNodes( node, &b );
|
|
|
|
ok( r == S_OK, "hasChildNoes bad return\n");
|
|
|
|
ok( b == VARIANT_TRUE, "hasChildNoes wrong result\n");
|
|
|
|
|
|
|
|
str = NULL;
|
|
|
|
r = IXMLDOMNode_get_baseName( node, &str );
|
|
|
|
ok( r == S_OK, "get_baseName returned wrong code\n");
|
|
|
|
ok( lstrcmpW(str,szbs) == 0, "basename was wrong\n");
|
2007-12-24 02:52:52 +01:00
|
|
|
SysFreeString(str);
|
2005-08-23 11:37:42 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
ok( FALSE, "no node\n");
|
|
|
|
|
|
|
|
if (node)
|
|
|
|
IXMLDOMNode_Release( node );
|
|
|
|
if (list)
|
|
|
|
IXMLDOMNodeList_Release( list );
|
2006-06-12 02:34:28 +02:00
|
|
|
if (element)
|
|
|
|
IXMLDOMElement_Release( element );
|
|
|
|
|
|
|
|
b = FALSE;
|
|
|
|
str = SysAllocString( szComplete5 );
|
|
|
|
r = IXMLDOMDocument_loadXML( doc, str, &b );
|
|
|
|
ok( r == S_OK, "loadXML failed\n");
|
|
|
|
ok( b == VARIANT_TRUE, "failed to load XML string\n");
|
|
|
|
SysFreeString( str );
|
|
|
|
|
|
|
|
b = 1;
|
|
|
|
r = IXMLDOMNode_hasChildNodes( doc, &b );
|
|
|
|
ok( r == S_OK, "hasChildNoes bad return\n");
|
|
|
|
ok( b == VARIANT_TRUE, "hasChildNoes wrong result\n");
|
|
|
|
|
|
|
|
r = IXMLDOMDocument_get_documentElement( doc, &element );
|
|
|
|
ok( r == S_OK, "should be a document element\n");
|
|
|
|
ok( element != NULL, "should be an element\n");
|
|
|
|
|
|
|
|
if (element)
|
|
|
|
{
|
|
|
|
static const WCHAR szSSearch[] = {'S',':','s','e','a','r','c','h',0};
|
|
|
|
BSTR tag = NULL;
|
|
|
|
|
|
|
|
/* check if the tag is correct */
|
|
|
|
r = IXMLDOMElement_get_tagName( element, &tag );
|
|
|
|
ok( r == S_OK, "couldn't get tag name\n");
|
|
|
|
ok( tag != NULL, "tag was null\n");
|
|
|
|
ok( !lstrcmpW( tag, szSSearch ), "incorrect tag name\n");
|
|
|
|
SysFreeString( tag );
|
|
|
|
}
|
|
|
|
|
2005-08-23 11:37:42 +02:00
|
|
|
if (element)
|
|
|
|
IXMLDOMElement_Release( element );
|
|
|
|
if (doc)
|
2005-11-08 20:59:36 +01:00
|
|
|
IXMLDOMDocument_Release( doc );
|
2005-08-12 13:25:05 +02:00
|
|
|
}
|
|
|
|
|
2005-11-18 16:05:26 +01:00
|
|
|
static void test_refs(void)
|
|
|
|
{
|
|
|
|
HRESULT r;
|
|
|
|
BSTR str;
|
|
|
|
VARIANT_BOOL b;
|
|
|
|
IXMLDOMDocument *doc = NULL;
|
|
|
|
IXMLDOMElement *element = NULL;
|
|
|
|
IXMLDOMNode *node = NULL, *node2;
|
|
|
|
IXMLDOMNodeList *node_list = NULL;
|
|
|
|
LONG ref;
|
2005-12-01 18:46:42 +01:00
|
|
|
IUnknown *unk, *unk2;
|
2005-11-18 16:05:26 +01:00
|
|
|
|
2006-01-10 19:58:42 +01:00
|
|
|
r = CoCreateInstance( &CLSID_DOMDocument, NULL,
|
|
|
|
CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (LPVOID*)&doc );
|
|
|
|
if( r != S_OK )
|
|
|
|
return;
|
|
|
|
ref = IXMLDOMDocument_Release(doc);
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( ref == 0, "ref %d\n", ref);
|
2006-01-10 19:58:42 +01:00
|
|
|
|
2005-11-18 16:05:26 +01:00
|
|
|
r = CoCreateInstance( &CLSID_DOMDocument, NULL,
|
|
|
|
CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (LPVOID*)&doc );
|
|
|
|
if( r != S_OK )
|
|
|
|
return;
|
|
|
|
|
|
|
|
str = SysAllocString( szComplete4 );
|
|
|
|
r = IXMLDOMDocument_loadXML( doc, str, &b );
|
|
|
|
ok( r == S_OK, "loadXML failed\n");
|
|
|
|
ok( b == VARIANT_TRUE, "failed to load XML string\n");
|
|
|
|
SysFreeString( str );
|
|
|
|
|
|
|
|
ref = IXMLDOMDocument_AddRef( doc );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( ref == 2, "ref %d\n", ref );
|
2005-11-18 16:05:26 +01:00
|
|
|
ref = IXMLDOMDocument_AddRef( doc );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( ref == 3, "ref %d\n", ref );
|
2005-11-18 16:05:26 +01:00
|
|
|
IXMLDOMDocument_Release( doc );
|
|
|
|
IXMLDOMDocument_Release( doc );
|
|
|
|
|
|
|
|
r = IXMLDOMDocument_get_documentElement( doc, &element );
|
|
|
|
ok( r == S_OK, "should be a document element\n");
|
|
|
|
ok( element != NULL, "should be an element\n");
|
|
|
|
|
|
|
|
ref = IXMLDOMDocument_AddRef( doc );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( ref == 2, "ref %d\n", ref );
|
2005-11-18 16:05:26 +01:00
|
|
|
IXMLDOMDocument_Release( doc );
|
|
|
|
|
|
|
|
r = IXMLDOMElement_get_childNodes( element, &node_list );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "rets %08x\n", r);
|
2005-11-18 16:05:26 +01:00
|
|
|
ref = IXMLDOMNodeList_AddRef( node_list );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( ref == 2, "ref %d\n", ref );
|
2005-11-18 16:05:26 +01:00
|
|
|
IXMLDOMNodeList_Release( node_list );
|
|
|
|
|
|
|
|
IXMLDOMNodeList_get_item( node_list, 0, &node );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "rets %08x\n", r);
|
2005-11-18 16:05:26 +01:00
|
|
|
|
|
|
|
IXMLDOMNodeList_get_item( node_list, 0, &node2 );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "rets %08x\n", r);
|
2005-11-18 16:05:26 +01:00
|
|
|
|
|
|
|
ref = IXMLDOMNode_AddRef( node );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( ref == 2, "ref %d\n", ref );
|
2005-11-18 16:05:26 +01:00
|
|
|
IXMLDOMNode_Release( node );
|
|
|
|
|
|
|
|
ref = IXMLDOMNode_Release( node );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( ref == 0, "ref %d\n", ref );
|
2005-11-18 16:05:26 +01:00
|
|
|
ref = IXMLDOMNode_Release( node2 );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( ref == 0, "ref %d\n", ref );
|
2005-11-18 16:05:26 +01:00
|
|
|
|
|
|
|
ref = IXMLDOMNodeList_Release( node_list );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( ref == 0, "ref %d\n", ref );
|
2005-11-18 16:05:26 +01:00
|
|
|
|
|
|
|
ok( node != node2, "node %p node2 %p\n", node, node2 );
|
|
|
|
|
|
|
|
ref = IXMLDOMDocument_Release( doc );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( ref == 0, "ref %d\n", ref );
|
2005-11-18 16:05:26 +01:00
|
|
|
|
|
|
|
ref = IXMLDOMElement_AddRef( element );
|
|
|
|
todo_wine {
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( ref == 3, "ref %d\n", ref );
|
2005-11-18 16:05:26 +01:00
|
|
|
}
|
|
|
|
IXMLDOMElement_Release( element );
|
2005-12-01 18:46:42 +01:00
|
|
|
|
|
|
|
/* IUnknown must be unique however we obtain it */
|
|
|
|
r = IXMLDOMElement_QueryInterface( element, &IID_IUnknown, (LPVOID*)&unk );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "rets %08x\n", r );
|
2005-12-01 18:46:42 +01:00
|
|
|
r = IXMLDOMElement_QueryInterface( element, &IID_IXMLDOMNode, (LPVOID*)&node );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "rets %08x\n", r );
|
2005-12-01 18:46:42 +01:00
|
|
|
r = IXMLDOMNode_QueryInterface( node, &IID_IUnknown, (LPVOID*)&unk2 );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "rets %08x\n", r );
|
2005-12-01 18:46:42 +01:00
|
|
|
ok( unk == unk2, "unk %p unk2 %p\n", unk, unk2 );
|
|
|
|
|
|
|
|
IUnknown_Release( unk2 );
|
|
|
|
IUnknown_Release( unk );
|
|
|
|
IXMLDOMNode_Release( node );
|
|
|
|
|
2005-11-18 16:05:26 +01:00
|
|
|
IXMLDOMElement_Release( element );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2006-01-11 21:15:12 +01:00
|
|
|
static void test_create(void)
|
|
|
|
{
|
|
|
|
HRESULT r;
|
|
|
|
VARIANT var;
|
2006-01-16 20:42:39 +01:00
|
|
|
BSTR str, name;
|
2006-01-11 21:15:12 +01:00
|
|
|
IXMLDOMDocument *doc;
|
2006-01-16 20:42:39 +01:00
|
|
|
IXMLDOMElement *element;
|
2006-01-11 21:15:12 +01:00
|
|
|
IXMLDOMNode *root, *node, *child;
|
2006-01-16 20:42:39 +01:00
|
|
|
IXMLDOMNamedNodeMap *attr_map;
|
2006-01-11 21:15:12 +01:00
|
|
|
IUnknown *unk;
|
2006-10-13 13:09:49 +02:00
|
|
|
LONG ref;
|
|
|
|
long num;
|
2006-01-11 21:15:12 +01:00
|
|
|
|
|
|
|
r = CoCreateInstance( &CLSID_DOMDocument, NULL,
|
|
|
|
CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (LPVOID*)&doc );
|
|
|
|
if( r != S_OK )
|
|
|
|
return;
|
|
|
|
|
|
|
|
V_VT(&var) = VT_I4;
|
|
|
|
V_I4(&var) = NODE_ELEMENT;
|
|
|
|
str = SysAllocString( szlc );
|
|
|
|
r = IXMLDOMDocument_createNode( doc, var, str, NULL, &node );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "returns %08x\n", r );
|
2006-01-11 21:15:12 +01:00
|
|
|
r = IXMLDOMDocument_appendChild( doc, node, &root );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "returns %08x\n", r );
|
2006-01-11 21:15:12 +01:00
|
|
|
ok( node == root, "%p %p\n", node, root );
|
|
|
|
|
|
|
|
ref = IXMLDOMNode_AddRef( node );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok(ref == 3, "ref %d\n", ref);
|
2006-01-11 21:15:12 +01:00
|
|
|
IXMLDOMNode_Release( node );
|
|
|
|
|
|
|
|
ref = IXMLDOMNode_Release( node );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok(ref == 1, "ref %d\n", ref);
|
2006-01-11 21:15:12 +01:00
|
|
|
SysFreeString( str );
|
|
|
|
|
|
|
|
V_VT(&var) = VT_I4;
|
|
|
|
V_I4(&var) = NODE_ELEMENT;
|
|
|
|
str = SysAllocString( szbs );
|
|
|
|
r = IXMLDOMDocument_createNode( doc, var, str, NULL, &node );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "returns %08x\n", r );
|
2006-01-11 21:15:12 +01:00
|
|
|
|
|
|
|
ref = IXMLDOMNode_AddRef( node );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok(ref == 2, "ref = %d\n", ref);
|
2006-01-11 21:15:12 +01:00
|
|
|
IXMLDOMNode_Release( node );
|
|
|
|
|
|
|
|
r = IXMLDOMNode_QueryInterface( node, &IID_IUnknown, (LPVOID*)&unk );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "returns %08x\n", r );
|
2006-01-11 21:15:12 +01:00
|
|
|
|
|
|
|
ref = IXMLDOMNode_AddRef( unk );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok(ref == 3, "ref = %d\n", ref);
|
2006-01-11 21:15:12 +01:00
|
|
|
IXMLDOMNode_Release( unk );
|
|
|
|
|
|
|
|
V_VT(&var) = VT_EMPTY;
|
|
|
|
r = IXMLDOMNode_insertBefore( root, (IXMLDOMNode*)unk, var, &child );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "returns %08x\n", r );
|
2006-01-11 21:15:12 +01:00
|
|
|
ok( unk == (IUnknown*)child, "%p %p\n", unk, child );
|
|
|
|
IXMLDOMNode_Release( child );
|
|
|
|
IUnknown_Release( unk );
|
|
|
|
|
|
|
|
|
|
|
|
V_VT(&var) = VT_NULL;
|
|
|
|
V_DISPATCH(&var) = (IDispatch*)node;
|
|
|
|
r = IXMLDOMNode_insertBefore( root, node, var, &child );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "returns %08x\n", r );
|
2006-01-11 21:15:12 +01:00
|
|
|
ok( node == child, "%p %p\n", node, child );
|
|
|
|
IXMLDOMNode_Release( child );
|
2006-01-16 20:42:39 +01:00
|
|
|
|
|
|
|
|
2007-11-14 06:07:14 +01:00
|
|
|
V_VT(&var) = VT_NULL;
|
|
|
|
V_DISPATCH(&var) = (IDispatch*)node;
|
|
|
|
r = IXMLDOMNode_insertBefore( root, node, var, NULL );
|
|
|
|
ok( r == S_OK, "returns %08x\n", r );
|
|
|
|
IXMLDOMNode_Release( node );
|
|
|
|
|
2006-01-16 20:42:39 +01:00
|
|
|
r = IXMLDOMNode_QueryInterface( root, &IID_IXMLDOMElement, (LPVOID*)&element );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "returns %08x\n", r );
|
2006-01-16 20:42:39 +01:00
|
|
|
|
|
|
|
r = IXMLDOMElement_get_attributes( element, &attr_map );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "returns %08x\n", r );
|
2006-01-16 20:42:39 +01:00
|
|
|
r = IXMLDOMNamedNodeMap_get_length( attr_map, &num );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "returns %08x\n", r );
|
2006-01-16 20:42:39 +01:00
|
|
|
ok( num == 0, "num %ld\n", num );
|
|
|
|
IXMLDOMNamedNodeMap_Release( attr_map );
|
|
|
|
|
|
|
|
V_VT(&var) = VT_BSTR;
|
|
|
|
V_BSTR(&var) = SysAllocString( szstr1 );
|
|
|
|
name = SysAllocString( szdl );
|
|
|
|
r = IXMLDOMElement_setAttribute( element, name, var );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "returns %08x\n", r );
|
2006-01-16 20:42:39 +01:00
|
|
|
r = IXMLDOMElement_get_attributes( element, &attr_map );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "returns %08x\n", r );
|
2006-01-16 20:42:39 +01:00
|
|
|
r = IXMLDOMNamedNodeMap_get_length( attr_map, &num );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "returns %08x\n", r );
|
2006-01-16 20:42:39 +01:00
|
|
|
ok( num == 1, "num %ld\n", num );
|
|
|
|
IXMLDOMNamedNodeMap_Release( attr_map );
|
|
|
|
VariantClear(&var);
|
|
|
|
|
|
|
|
V_VT(&var) = VT_BSTR;
|
|
|
|
V_BSTR(&var) = SysAllocString( szstr2 );
|
|
|
|
r = IXMLDOMElement_setAttribute( element, name, var );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "returns %08x\n", r );
|
2006-01-16 20:42:39 +01:00
|
|
|
r = IXMLDOMElement_get_attributes( element, &attr_map );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "returns %08x\n", r );
|
2006-01-16 20:42:39 +01:00
|
|
|
r = IXMLDOMNamedNodeMap_get_length( attr_map, &num );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "returns %08x\n", r );
|
2006-01-16 20:42:39 +01:00
|
|
|
ok( num == 1, "num %ld\n", num );
|
|
|
|
IXMLDOMNamedNodeMap_Release( attr_map );
|
|
|
|
VariantClear(&var);
|
|
|
|
r = IXMLDOMElement_getAttribute( element, name, &var );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "returns %08x\n", r );
|
2006-01-16 20:42:39 +01:00
|
|
|
ok( !lstrcmpW(V_BSTR(&var), szstr2), "wrong attr value\n");
|
|
|
|
VariantClear(&var);
|
|
|
|
SysFreeString(name);
|
|
|
|
|
|
|
|
V_VT(&var) = VT_BSTR;
|
|
|
|
V_BSTR(&var) = SysAllocString( szstr1 );
|
|
|
|
name = SysAllocString( szlc );
|
|
|
|
r = IXMLDOMElement_setAttribute( element, name, var );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "returns %08x\n", r );
|
2006-01-16 20:42:39 +01:00
|
|
|
r = IXMLDOMElement_get_attributes( element, &attr_map );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "returns %08x\n", r );
|
2006-01-16 20:42:39 +01:00
|
|
|
r = IXMLDOMNamedNodeMap_get_length( attr_map, &num );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "returns %08x\n", r );
|
2006-01-16 20:42:39 +01:00
|
|
|
ok( num == 2, "num %ld\n", num );
|
|
|
|
IXMLDOMNamedNodeMap_Release( attr_map );
|
|
|
|
VariantClear(&var);
|
|
|
|
SysFreeString(name);
|
|
|
|
|
|
|
|
V_VT(&var) = VT_I4;
|
|
|
|
V_I4(&var) = 10;
|
|
|
|
name = SysAllocString( szbs );
|
|
|
|
r = IXMLDOMElement_setAttribute( element, name, var );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "returns %08x\n", r );
|
2006-01-16 20:42:39 +01:00
|
|
|
VariantClear(&var);
|
|
|
|
r = IXMLDOMElement_getAttribute( element, name, &var );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "returns %08x\n", r );
|
2006-01-16 20:42:39 +01:00
|
|
|
ok( V_VT(&var) == VT_BSTR, "variant type %x\n", V_VT(&var));
|
|
|
|
VariantClear(&var);
|
|
|
|
SysFreeString(name);
|
|
|
|
|
|
|
|
IXMLDOMElement_Release( element );
|
2006-01-11 21:15:12 +01:00
|
|
|
IXMLDOMNode_Release( root );
|
|
|
|
IXMLDOMDocument_Release( doc );
|
|
|
|
}
|
|
|
|
|
2006-02-14 10:38:21 +01:00
|
|
|
static void test_getElementsByTagName(void)
|
|
|
|
{
|
|
|
|
HRESULT r;
|
|
|
|
BSTR str;
|
|
|
|
VARIANT_BOOL b;
|
|
|
|
IXMLDOMDocument *doc;
|
|
|
|
IXMLDOMNodeList *node_list;
|
2006-10-13 13:09:49 +02:00
|
|
|
long len;
|
2006-02-14 10:38:21 +01:00
|
|
|
|
|
|
|
r = CoCreateInstance( &CLSID_DOMDocument, NULL,
|
|
|
|
CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (LPVOID*)&doc );
|
|
|
|
if( r != S_OK )
|
|
|
|
return;
|
|
|
|
|
|
|
|
str = SysAllocString( szComplete4 );
|
|
|
|
r = IXMLDOMDocument_loadXML( doc, str, &b );
|
|
|
|
ok( r == S_OK, "loadXML failed\n");
|
|
|
|
ok( b == VARIANT_TRUE, "failed to load XML string\n");
|
|
|
|
SysFreeString( str );
|
|
|
|
|
|
|
|
str = SysAllocString( szstar );
|
|
|
|
r = IXMLDOMDocument_getElementsByTagName(doc, str, &node_list);
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "ret %08x\n", r );
|
2006-02-14 10:38:21 +01:00
|
|
|
r = IXMLDOMNodeList_get_length( node_list, &len );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "ret %08x\n", r );
|
2006-07-10 15:48:45 +02:00
|
|
|
ok( len == 6, "len %ld\n", len );
|
2006-02-14 10:38:21 +01:00
|
|
|
IXMLDOMNodeList_Release( node_list );
|
|
|
|
SysFreeString( str );
|
|
|
|
|
|
|
|
str = SysAllocString( szbs );
|
|
|
|
r = IXMLDOMDocument_getElementsByTagName(doc, str, &node_list);
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "ret %08x\n", r );
|
2006-02-14 10:38:21 +01:00
|
|
|
r = IXMLDOMNodeList_get_length( node_list, &len );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "ret %08x\n", r );
|
2006-02-14 10:38:21 +01:00
|
|
|
ok( len == 1, "len %ld\n", len );
|
|
|
|
IXMLDOMNodeList_Release( node_list );
|
|
|
|
SysFreeString( str );
|
|
|
|
|
|
|
|
str = SysAllocString( szdl );
|
|
|
|
r = IXMLDOMDocument_getElementsByTagName(doc, str, &node_list);
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "ret %08x\n", r );
|
2006-02-14 10:38:21 +01:00
|
|
|
r = IXMLDOMNodeList_get_length( node_list, &len );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "ret %08x\n", r );
|
2006-02-14 10:38:21 +01:00
|
|
|
ok( len == 0, "len %ld\n", len );
|
|
|
|
IXMLDOMNodeList_Release( node_list );
|
|
|
|
SysFreeString( str );
|
|
|
|
|
|
|
|
str = SysAllocString( szstr1 );
|
|
|
|
r = IXMLDOMDocument_getElementsByTagName(doc, str, &node_list);
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "ret %08x\n", r );
|
2006-02-14 10:38:21 +01:00
|
|
|
r = IXMLDOMNodeList_get_length( node_list, &len );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "ret %08x\n", r );
|
2006-02-14 10:38:21 +01:00
|
|
|
ok( len == 0, "len %ld\n", len );
|
|
|
|
IXMLDOMNodeList_Release( node_list );
|
|
|
|
SysFreeString( str );
|
|
|
|
|
|
|
|
IXMLDOMDocument_Release( doc );
|
|
|
|
}
|
2006-01-11 21:15:12 +01:00
|
|
|
|
2006-02-16 19:33:39 +01:00
|
|
|
static void test_get_text(void)
|
|
|
|
{
|
|
|
|
HRESULT r;
|
|
|
|
BSTR str;
|
|
|
|
VARIANT_BOOL b;
|
|
|
|
IXMLDOMDocument *doc;
|
|
|
|
IXMLDOMNode *node, *node2, *node3;
|
|
|
|
IXMLDOMNodeList *node_list;
|
|
|
|
IXMLDOMNamedNodeMap *node_map;
|
|
|
|
|
|
|
|
r = CoCreateInstance( &CLSID_DOMDocument, NULL,
|
|
|
|
CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (LPVOID*)&doc );
|
|
|
|
if( r != S_OK )
|
|
|
|
return;
|
|
|
|
|
|
|
|
str = SysAllocString( szComplete4 );
|
|
|
|
r = IXMLDOMDocument_loadXML( doc, str, &b );
|
|
|
|
ok( r == S_OK, "loadXML failed\n");
|
|
|
|
ok( b == VARIANT_TRUE, "failed to load XML string\n");
|
|
|
|
SysFreeString( str );
|
|
|
|
|
|
|
|
str = SysAllocString( szbs );
|
|
|
|
r = IXMLDOMDocument_getElementsByTagName( doc, str, &node_list );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "ret %08x\n", r );
|
2006-02-16 19:33:39 +01:00
|
|
|
SysFreeString(str);
|
|
|
|
|
|
|
|
r = IXMLDOMNodeList_get_item( node_list, 0, &node );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "ret %08x\n", r );
|
2006-02-16 19:33:39 +01:00
|
|
|
IXMLDOMNodeList_Release( node_list );
|
|
|
|
|
2007-11-20 11:23:35 +01:00
|
|
|
/* Invalid output parameter*/
|
|
|
|
r = IXMLDOMNode_get_text( node, NULL );
|
|
|
|
ok( r == E_INVALIDARG, "ret %08x\n", r );
|
|
|
|
|
2006-02-16 19:33:39 +01:00
|
|
|
r = IXMLDOMNode_get_text( node, &str );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "ret %08x\n", r );
|
2006-02-16 19:33:39 +01:00
|
|
|
todo_wine {
|
|
|
|
ok( !memcmp(str, szfn1_txt, sizeof(szfn1_txt)), "wrong string\n" );
|
|
|
|
}
|
|
|
|
ok( !memcmp(str, szfn1_txt, sizeof(szfn1_txt)-4), "wrong string\n" );
|
|
|
|
SysFreeString(str);
|
|
|
|
|
|
|
|
r = IXMLDOMNode_get_attributes( node, &node_map );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "ret %08x\n", r );
|
2006-02-16 19:33:39 +01:00
|
|
|
|
|
|
|
str = SysAllocString( szvr );
|
|
|
|
r = IXMLDOMNamedNodeMap_getNamedItem( node_map, str, &node2 );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "ret %08x\n", r );
|
2006-02-16 19:33:39 +01:00
|
|
|
SysFreeString(str);
|
|
|
|
|
|
|
|
r = IXMLDOMNode_get_text( node2, &str );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "ret %08x\n", r );
|
2006-02-16 19:33:39 +01:00
|
|
|
ok( !memcmp(str, szstr2, sizeof(szstr2)), "wrong string\n" );
|
|
|
|
SysFreeString(str);
|
|
|
|
|
|
|
|
r = IXMLDOMNode_get_firstChild( node2, &node3 );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "ret %08x\n", r );
|
2006-02-16 19:33:39 +01:00
|
|
|
|
|
|
|
r = IXMLDOMNode_get_text( node3, &str );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "ret %08x\n", r );
|
2006-02-16 19:33:39 +01:00
|
|
|
ok( !memcmp(str, szstr2, sizeof(szstr2)), "wrong string\n" );
|
|
|
|
SysFreeString(str);
|
|
|
|
|
|
|
|
|
|
|
|
IXMLDOMNode_Release( node3 );
|
|
|
|
IXMLDOMNode_Release( node2 );
|
|
|
|
IXMLDOMNamedNodeMap_Release( node_map );
|
|
|
|
IXMLDOMNode_Release( node );
|
|
|
|
IXMLDOMDocument_Release( doc );
|
|
|
|
}
|
|
|
|
|
2006-02-23 15:10:06 +01:00
|
|
|
static void test_get_childNodes(void)
|
|
|
|
{
|
|
|
|
HRESULT r;
|
|
|
|
BSTR str;
|
|
|
|
VARIANT_BOOL b;
|
|
|
|
IXMLDOMDocument *doc;
|
|
|
|
IXMLDOMElement *element;
|
|
|
|
IXMLDOMNode *node, *node2;
|
|
|
|
IXMLDOMNodeList *node_list, *node_list2;
|
|
|
|
long len;
|
|
|
|
|
|
|
|
r = CoCreateInstance( &CLSID_DOMDocument, NULL,
|
|
|
|
CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (LPVOID*)&doc );
|
|
|
|
if( r != S_OK )
|
|
|
|
return;
|
|
|
|
|
|
|
|
str = SysAllocString( szComplete4 );
|
|
|
|
r = IXMLDOMDocument_loadXML( doc, str, &b );
|
|
|
|
ok( r == S_OK, "loadXML failed\n");
|
|
|
|
ok( b == VARIANT_TRUE, "failed to load XML string\n");
|
|
|
|
SysFreeString( str );
|
|
|
|
|
|
|
|
r = IXMLDOMDocument_get_documentElement( doc, &element );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "ret %08x\n", r);
|
2006-02-23 15:10:06 +01:00
|
|
|
|
|
|
|
r = IXMLDOMElement_get_childNodes( element, &node_list );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "ret %08x\n", r);
|
2006-02-23 15:10:06 +01:00
|
|
|
|
|
|
|
r = IXMLDOMNodeList_get_length( node_list, &len );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "ret %08x\n", r);
|
2006-07-10 15:48:45 +02:00
|
|
|
ok( len == 4, "len %ld\n", len);
|
2006-02-23 15:10:06 +01:00
|
|
|
|
|
|
|
r = IXMLDOMNodeList_get_item( node_list, 2, &node );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "ret %08x\n", r);
|
2006-02-23 15:10:06 +01:00
|
|
|
|
|
|
|
r = IXMLDOMNode_get_childNodes( node, &node_list2 );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "ret %08x\n", r);
|
2006-02-23 15:10:06 +01:00
|
|
|
|
|
|
|
r = IXMLDOMNodeList_get_length( node_list2, &len );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "ret %08x\n", r);
|
2006-02-23 15:10:06 +01:00
|
|
|
ok( len == 0, "len %ld\n", len);
|
|
|
|
|
|
|
|
r = IXMLDOMNodeList_get_item( node_list2, 0, &node2);
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_FALSE, "ret %08x\n", r);
|
2006-02-23 15:10:06 +01:00
|
|
|
|
|
|
|
IXMLDOMNodeList_Release( node_list2 );
|
|
|
|
IXMLDOMNode_Release( node );
|
|
|
|
IXMLDOMNodeList_Release( node_list );
|
|
|
|
IXMLDOMElement_Release( element );
|
|
|
|
IXMLDOMDocument_Release( doc );
|
|
|
|
}
|
2006-07-10 15:48:45 +02:00
|
|
|
|
|
|
|
static void test_removeChild(void)
|
|
|
|
{
|
|
|
|
HRESULT r;
|
|
|
|
BSTR str;
|
|
|
|
VARIANT_BOOL b;
|
|
|
|
IXMLDOMDocument *doc;
|
|
|
|
IXMLDOMElement *element;
|
|
|
|
IXMLDOMNode *node, *node2, *node3, *node4;
|
|
|
|
IXMLDOMNodeList *node_list, *node_list2;
|
|
|
|
|
|
|
|
r = CoCreateInstance( &CLSID_DOMDocument, NULL,
|
|
|
|
CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (LPVOID*)&doc );
|
|
|
|
if( r != S_OK )
|
|
|
|
return;
|
|
|
|
|
|
|
|
str = SysAllocString( szComplete4 );
|
|
|
|
r = IXMLDOMDocument_loadXML( doc, str, &b );
|
|
|
|
ok( r == S_OK, "loadXML failed\n");
|
|
|
|
ok( b == VARIANT_TRUE, "failed to load XML string\n");
|
|
|
|
SysFreeString( str );
|
|
|
|
|
|
|
|
r = IXMLDOMDocument_get_documentElement( doc, &element );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "ret %08x\n", r);
|
2006-07-10 15:48:45 +02:00
|
|
|
|
|
|
|
r = IXMLDOMElement_get_childNodes( element, &node_list );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "ret %08x\n", r);
|
2006-07-10 15:48:45 +02:00
|
|
|
|
|
|
|
r = IXMLDOMNodeList_get_item( node_list, 3, &node );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "ret %08x\n", r);
|
2006-07-10 15:48:45 +02:00
|
|
|
|
|
|
|
r = IXMLDOMNode_get_childNodes( node, &node_list2 );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "ret %08x\n", r);
|
2006-07-10 15:48:45 +02:00
|
|
|
|
|
|
|
r = IXMLDOMNodeList_get_item( node_list, 0, &node4 );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "ret %08x\n", r);
|
2006-07-10 15:48:45 +02:00
|
|
|
|
2006-07-18 16:54:16 +02:00
|
|
|
r = IXMLDOMElement_removeChild( element, NULL, &node2 );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == E_INVALIDARG, "ret %08x\n", r );
|
2006-07-18 16:54:16 +02:00
|
|
|
|
2006-07-10 15:48:45 +02:00
|
|
|
r = IXMLDOMElement_removeChild( element, node4, &node2 );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_OK, "ret %08x\n", r);
|
2006-07-10 15:48:45 +02:00
|
|
|
ok( node4 == node2, "node %p node2 %p\n", node4, node2 );
|
|
|
|
|
|
|
|
r = IXMLDOMNode_get_parentNode( node4, &node3 );
|
2006-10-13 13:09:49 +02:00
|
|
|
ok( r == S_FALSE, "ret %08x\n", r);
|
2006-07-10 15:48:45 +02:00
|
|
|
ok( node3 == NULL, "%p\n", node3 );
|
|
|
|
|
|
|
|
IXMLDOMNode_Release( node2 );
|
|
|
|
IXMLDOMNode_Release( node4 );
|
|
|
|
IXMLDOMNodeList_Release( node_list2 );
|
|
|
|
IXMLDOMNode_Release( node );
|
|
|
|
IXMLDOMNodeList_Release( node_list );
|
|
|
|
IXMLDOMElement_Release( element );
|
|
|
|
IXMLDOMDocument_Release( doc );
|
|
|
|
}
|
|
|
|
|
2006-12-28 03:40:46 +01:00
|
|
|
static void test_XMLHTTP(void)
|
|
|
|
{
|
|
|
|
static const WCHAR wszBody[] = {'m','o','d','e','=','T','e','s','t',0};
|
|
|
|
static WCHAR wszPOST[] = {'P','O','S','T',0};
|
|
|
|
static WCHAR wszUrl[] = {'h','t','t','p',':','/','/',
|
|
|
|
'c','r','o','s','s','o','v','e','r','.','c','o','d','e','w','e','a','v','e','r','s','.','c','o','m','/',
|
|
|
|
'p','o','s','t','t','e','s','t','.','p','h','p',0};
|
|
|
|
static const WCHAR wszExpectedResponse[] = {'F','A','I','L','E','D',0};
|
|
|
|
IXMLHttpRequest *pXMLHttpRequest;
|
|
|
|
BSTR bstrResponse;
|
|
|
|
VARIANT dummy;
|
|
|
|
VARIANT varfalse;
|
|
|
|
VARIANT varbody;
|
|
|
|
HRESULT hr = CoCreateInstance(&CLSID_XMLHTTPRequest, NULL,
|
|
|
|
CLSCTX_INPROC_SERVER, &IID_IXMLHttpRequest,
|
|
|
|
(void **)&pXMLHttpRequest);
|
|
|
|
todo_wine {
|
|
|
|
ok(hr == S_OK, "CoCreateInstance(CLSID_XMLHTTPRequest) should have succeeded instead of failing with 0x%08x\n", hr);
|
|
|
|
}
|
|
|
|
if (hr != S_OK)
|
|
|
|
return;
|
|
|
|
|
|
|
|
VariantInit(&dummy);
|
|
|
|
V_VT(&dummy) = VT_ERROR;
|
|
|
|
V_ERROR(&dummy) = DISP_E_MEMBERNOTFOUND;
|
|
|
|
VariantInit(&varfalse);
|
|
|
|
V_VT(&varfalse) = VT_BOOL;
|
|
|
|
V_BOOL(&varfalse) = VARIANT_FALSE;
|
|
|
|
V_VT(&varbody) = VT_BSTR;
|
|
|
|
V_BSTR(&varbody) = SysAllocString(wszBody);
|
|
|
|
|
|
|
|
hr = IXMLHttpRequest_open(pXMLHttpRequest, wszPOST, wszUrl, varfalse, dummy, dummy);
|
|
|
|
ok(hr == S_OK, "IXMLHttpRequest_open should have succeeded instead of failing with 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IXMLHttpRequest_send(pXMLHttpRequest, varbody);
|
|
|
|
ok(hr == S_OK, "IXMLHttpRequest_send should have succeeded instead of failing with 0x%08x\n", hr);
|
|
|
|
VariantClear(&varbody);
|
|
|
|
|
|
|
|
hr = IXMLHttpRequest_get_responseText(pXMLHttpRequest, &bstrResponse);
|
|
|
|
ok(hr == S_OK, "IXMLHttpRequest_get_responseText should have succeeded instead of failing with 0x%08x\n", hr);
|
|
|
|
/* the server currently returns "FAILED" because the Content-Type header is
|
|
|
|
* not what the server expects */
|
|
|
|
ok(!memcmp(bstrResponse, wszExpectedResponse, sizeof(wszExpectedResponse)), "bstrResponse differs from what was expected\n");
|
|
|
|
SysFreeString(bstrResponse);
|
|
|
|
}
|
|
|
|
|
2007-02-26 13:49:12 +01:00
|
|
|
static void test_IXMLDOMDocument2(void)
|
|
|
|
{
|
|
|
|
HRESULT r;
|
|
|
|
VARIANT_BOOL b;
|
|
|
|
BSTR str;
|
|
|
|
IXMLDOMDocument *doc;
|
|
|
|
IXMLDOMDocument2 *doc2;
|
2007-05-09 20:09:11 +02:00
|
|
|
VARIANT var;
|
|
|
|
int ref;
|
2007-02-26 13:49:12 +01:00
|
|
|
|
|
|
|
r = CoCreateInstance( &CLSID_DOMDocument, NULL,
|
|
|
|
CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (LPVOID*)&doc );
|
|
|
|
if( r != S_OK )
|
|
|
|
return;
|
|
|
|
|
|
|
|
str = SysAllocString( szComplete4 );
|
|
|
|
r = IXMLDOMDocument_loadXML( doc, str, &b );
|
|
|
|
ok( r == S_OK, "loadXML failed\n");
|
|
|
|
ok( b == VARIANT_TRUE, "failed to load XML string\n");
|
|
|
|
SysFreeString( str );
|
|
|
|
|
|
|
|
r = IXMLDOMDocument_QueryInterface( doc, &IID_IXMLDOMDocument2, (void**)&doc2 );
|
|
|
|
ok( r == S_OK, "ret %08x\n", r );
|
|
|
|
ok( doc == (IXMLDOMDocument*)doc2, "interfaces differ\n");
|
2007-05-09 20:09:11 +02:00
|
|
|
|
|
|
|
/* we will check if the variant got cleared */
|
|
|
|
ref = IXMLDOMDocument2_AddRef(doc2);
|
|
|
|
expect_eq(ref, 3, int, "%d"); /* doc, doc2, AddRef*/
|
|
|
|
V_VT(&var) = VT_UNKNOWN;
|
|
|
|
V_UNKNOWN(&var) = (IUnknown *)doc2;
|
|
|
|
|
|
|
|
/* invalid calls */
|
|
|
|
ole_expect(IXMLDOMDocument2_getProperty(doc2, _bstr_("askldhfaklsdf"), &var), E_FAIL);
|
|
|
|
expect_eq(V_VT(&var), VT_UNKNOWN, int, "%x");
|
|
|
|
ole_expect(IXMLDOMDocument2_getProperty(doc2, _bstr_("SelectionLanguage"), NULL), E_INVALIDARG);
|
|
|
|
|
|
|
|
/* valid call */
|
|
|
|
ole_check(IXMLDOMDocument2_getProperty(doc2, _bstr_("SelectionLanguage"), &var));
|
|
|
|
expect_eq(V_VT(&var), VT_BSTR, int, "%x");
|
|
|
|
expect_bstr_eq_and_free(V_BSTR(&var), "XSLPattern");
|
|
|
|
V_VT(&var) = VT_R4;
|
|
|
|
|
|
|
|
/* the variant didn't get cleared*/
|
|
|
|
expect_eq(IXMLDOMDocument2_Release(doc2), 2, int, "%d");
|
|
|
|
|
|
|
|
/* setProperty tests */
|
|
|
|
ole_expect(IXMLDOMDocument2_setProperty(doc2, _bstr_("askldhfaklsdf"), var), E_FAIL);
|
|
|
|
ole_expect(IXMLDOMDocument2_setProperty(doc2, _bstr_("SelectionLanguage"), var), E_FAIL);
|
|
|
|
ole_expect(IXMLDOMDocument2_setProperty(doc2, _bstr_("SelectionLanguage"), _variantbstr_("alskjdh faklsjd hfk")), E_FAIL);
|
|
|
|
ole_check(IXMLDOMDocument2_setProperty(doc2, _bstr_("SelectionLanguage"), _variantbstr_("XSLPattern")));
|
|
|
|
ole_check(IXMLDOMDocument2_setProperty(doc2, _bstr_("SelectionLanguage"), _variantbstr_("XPath")));
|
|
|
|
ole_check(IXMLDOMDocument2_setProperty(doc2, _bstr_("SelectionLanguage"), _variantbstr_("XSLPattern")));
|
|
|
|
|
|
|
|
/* contrary to what MSDN calims you can switch back from XPath to XSLPattern */
|
|
|
|
ole_check(IXMLDOMDocument2_getProperty(doc2, _bstr_("SelectionLanguage"), &var));
|
|
|
|
expect_eq(V_VT(&var), VT_BSTR, int, "%x");
|
|
|
|
expect_bstr_eq_and_free(V_BSTR(&var), "XSLPattern");
|
|
|
|
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2_Release( doc2 );
|
|
|
|
IXMLDOMDocument_Release( doc );
|
2007-05-09 20:09:11 +02:00
|
|
|
free_bstrs();
|
2007-02-26 13:49:12 +01:00
|
|
|
}
|
|
|
|
|
2007-08-29 21:42:28 +02:00
|
|
|
static void test_XPath(void)
|
2007-05-11 17:03:13 +02:00
|
|
|
{
|
|
|
|
HRESULT r;
|
2007-05-11 17:05:32 +02:00
|
|
|
VARIANT var;
|
2007-05-11 17:03:13 +02:00
|
|
|
VARIANT_BOOL b;
|
|
|
|
IXMLDOMDocument2 *doc;
|
|
|
|
IXMLDOMNode *rootNode;
|
|
|
|
IXMLDOMNode *elem1Node;
|
2007-05-11 17:04:43 +02:00
|
|
|
IXMLDOMNode *node;
|
2007-05-11 17:03:13 +02:00
|
|
|
IXMLDOMNodeList *list;
|
|
|
|
|
|
|
|
r = CoCreateInstance( &CLSID_DOMDocument, NULL,
|
|
|
|
CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (LPVOID*)&doc );
|
|
|
|
if( r != S_OK )
|
|
|
|
return;
|
|
|
|
|
|
|
|
ole_check(IXMLDOMDocument_loadXML(doc, _bstr_(szExampleXML), &b));
|
|
|
|
ok(b == VARIANT_TRUE, "failed to load XML string\n");
|
|
|
|
|
|
|
|
/* switch to XPath */
|
|
|
|
ole_check(IXMLDOMDocument2_setProperty(doc, _bstr_("SelectionLanguage"), _variantbstr_("XPath")));
|
|
|
|
|
|
|
|
/* some simple queries*/
|
|
|
|
ole_check(IXMLDOMDocument_selectNodes(doc, _bstr_("root"), &list));
|
|
|
|
ole_check(IXMLDOMNodeList_get_item(list, 0, &rootNode));
|
|
|
|
ole_check(IXMLDOMNodeList_reset(list));
|
|
|
|
expect_list_and_release(list, "E2.D1");
|
|
|
|
if (rootNode == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ole_check(IXMLDOMDocument_selectNodes(doc, _bstr_("root//c"), &list));
|
|
|
|
expect_list_and_release(list, "E3.E1.E2.D1 E3.E2.E2.D1");
|
|
|
|
|
|
|
|
ole_check(IXMLDOMDocument_selectNodes(doc, _bstr_("//c[@type]"), &list));
|
|
|
|
expect_list_and_release(list, "E3.E2.E2.D1");
|
|
|
|
|
|
|
|
ole_check(IXMLDOMNode_selectNodes(rootNode, _bstr_("elem"), &list));
|
2007-05-11 17:04:43 +02:00
|
|
|
/* using get_item for query results advances the position */
|
|
|
|
ole_check(IXMLDOMNodeList_get_item(list, 1, &node));
|
|
|
|
expect_node(node, "E2.E2.D1");
|
|
|
|
IXMLDOMNode_Release(node);
|
|
|
|
ole_check(IXMLDOMNodeList_nextNode(list, &node));
|
|
|
|
expect_node(node, "E4.E2.D1");
|
|
|
|
IXMLDOMNode_Release(node);
|
|
|
|
ole_check(IXMLDOMNodeList_reset(list));
|
2007-05-11 17:03:13 +02:00
|
|
|
expect_list_and_release(list, "E1.E2.D1 E2.E2.D1 E4.E2.D1");
|
|
|
|
|
|
|
|
ole_check(IXMLDOMNode_selectNodes(rootNode, _bstr_("."), &list));
|
|
|
|
expect_list_and_release(list, "E2.D1");
|
|
|
|
|
|
|
|
ole_check(IXMLDOMNode_selectNodes(rootNode, _bstr_("elem[3]/preceding-sibling::*"), &list));
|
|
|
|
ole_check(IXMLDOMNodeList_get_item(list, 0, &elem1Node));
|
|
|
|
ole_check(IXMLDOMNodeList_reset(list));
|
|
|
|
expect_list_and_release(list, "E1.E2.D1 E2.E2.D1 E3.E2.D1");
|
|
|
|
|
|
|
|
/* select an attribute */
|
|
|
|
ole_check(IXMLDOMNode_selectNodes(rootNode, _bstr_(".//@type"), &list));
|
|
|
|
expect_list_and_release(list, "A'type'.E3.E2.E2.D1");
|
|
|
|
|
|
|
|
/* would evaluate to a number */
|
|
|
|
ole_expect(IXMLDOMNode_selectNodes(rootNode, _bstr_("count(*)"), &list), E_FAIL);
|
|
|
|
/* would evaluate to a boolean */
|
|
|
|
ole_expect(IXMLDOMNode_selectNodes(rootNode, _bstr_("position()>0"), &list), E_FAIL);
|
|
|
|
/* would evaluate to a string */
|
|
|
|
ole_expect(IXMLDOMNode_selectNodes(rootNode, _bstr_("name()"), &list), E_FAIL);
|
|
|
|
|
|
|
|
/* no results */
|
|
|
|
ole_check(IXMLDOMNode_selectNodes(rootNode, _bstr_("c"), &list));
|
|
|
|
expect_list_and_release(list, "");
|
|
|
|
ole_check(IXMLDOMDocument_selectNodes(doc, _bstr_("elem//c"), &list));
|
|
|
|
expect_list_and_release(list, "");
|
|
|
|
ole_check(IXMLDOMDocument_selectNodes(doc, _bstr_("//elem[4]"), &list));
|
|
|
|
expect_list_and_release(list, "");
|
|
|
|
|
|
|
|
/* foo undeclared in document node */
|
|
|
|
ole_expect(IXMLDOMDocument_selectNodes(doc, _bstr_("root//foo:c"), &list), E_FAIL);
|
|
|
|
/* undeclared in <root> node */
|
|
|
|
ole_expect(IXMLDOMNode_selectNodes(rootNode, _bstr_(".//foo:c"), &list), E_FAIL);
|
|
|
|
/* undeclared in <elem> node */
|
|
|
|
ole_expect(IXMLDOMNode_selectNodes(elem1Node, _bstr_("//foo:c"), &list), E_FAIL);
|
|
|
|
/* but this trick can be used */
|
|
|
|
ole_check(IXMLDOMNode_selectNodes(elem1Node, _bstr_("//*[name()='foo:c']"), &list));
|
|
|
|
expect_list_and_release(list, "E3.E4.E2.D1");
|
|
|
|
|
2007-05-11 17:05:32 +02:00
|
|
|
/* it has to be declared in SelectionNamespaces */
|
|
|
|
todo_wine ole_check(IXMLDOMDocument2_setProperty(doc, _bstr_("SelectionNamespaces"),
|
|
|
|
_variantbstr_("xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'")));
|
|
|
|
|
|
|
|
/* now the namespace can be used */
|
|
|
|
todo_wine ole_check(IXMLDOMDocument_selectNodes(doc, _bstr_("root//test:c"), &list));
|
|
|
|
todo_wine expect_list_and_release(list, "E3.E3.E2.D1 E3.E4.E2.D1");
|
|
|
|
todo_wine ole_check(IXMLDOMNode_selectNodes(rootNode, _bstr_(".//test:c"), &list));
|
|
|
|
todo_wine expect_list_and_release(list, "E3.E3.E2.D1 E3.E4.E2.D1");
|
|
|
|
todo_wine ole_check(IXMLDOMNode_selectNodes(elem1Node, _bstr_("//test:c"), &list));
|
|
|
|
todo_wine expect_list_and_release(list, "E3.E3.E2.D1 E3.E4.E2.D1");
|
|
|
|
todo_wine ole_check(IXMLDOMNode_selectNodes(elem1Node, _bstr_(".//test:x"), &list));
|
|
|
|
todo_wine expect_list_and_release(list, "E5.E1.E4.E1.E2.D1");
|
|
|
|
|
|
|
|
/* SelectionNamespaces syntax error - the namespaces doesn't work anymore but the value is stored */
|
|
|
|
ole_expect(IXMLDOMDocument2_setProperty(doc, _bstr_("SelectionNamespaces"),
|
|
|
|
_variantbstr_("xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29' xmlns:foo=###")), E_FAIL);
|
|
|
|
|
|
|
|
ole_expect(IXMLDOMDocument_selectNodes(doc, _bstr_("root//foo:c"), &list), E_FAIL);
|
|
|
|
|
2008-02-04 23:01:00 +01:00
|
|
|
VariantClear(&var);
|
2007-05-11 17:05:32 +02:00
|
|
|
todo_wine ole_check(IXMLDOMDocument2_getProperty(doc, _bstr_("SelectionNamespaces"), &var));
|
|
|
|
todo_wine expect_eq(V_VT(&var), VT_BSTR, int, "%x");
|
|
|
|
if (V_VT(&var) == VT_BSTR)
|
|
|
|
expect_bstr_eq_and_free(V_BSTR(&var), "xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29' xmlns:foo=###");
|
|
|
|
|
|
|
|
/* extra attributes - same thing*/
|
|
|
|
ole_expect(IXMLDOMDocument2_setProperty(doc, _bstr_("SelectionNamespaces"),
|
|
|
|
_variantbstr_("xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29' param='test'")), E_FAIL);
|
|
|
|
ole_expect(IXMLDOMDocument_selectNodes(doc, _bstr_("root//foo:c"), &list), E_FAIL);
|
|
|
|
|
2007-05-11 17:03:13 +02:00
|
|
|
IXMLDOMNode_Release(rootNode);
|
|
|
|
IXMLDOMNode_Release(elem1Node);
|
|
|
|
IXMLDOMDocument_Release(doc);
|
|
|
|
free_bstrs();
|
|
|
|
}
|
|
|
|
|
2007-12-02 22:17:48 +01:00
|
|
|
static void test_cloneNode(void )
|
|
|
|
{
|
|
|
|
IXMLDOMDocument *doc = NULL;
|
|
|
|
VARIANT_BOOL b;
|
|
|
|
IXMLDOMNodeList *pList;
|
|
|
|
IXMLDOMNamedNodeMap *mapAttr;
|
|
|
|
long nLength = 0, nLength1 = 0;
|
|
|
|
long nAttrCnt = 0, nAttrCnt1 = 0;
|
|
|
|
IXMLDOMNode *node;
|
|
|
|
IXMLDOMNode *node_clone;
|
|
|
|
HRESULT r;
|
|
|
|
BSTR str;
|
2007-12-09 10:50:39 +01:00
|
|
|
static const WCHAR szSearch[] = { 'l', 'c', '/', 'p', 'r', 0 };
|
2007-12-02 22:17:48 +01:00
|
|
|
|
|
|
|
r = CoCreateInstance( &CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (LPVOID*)&doc );
|
|
|
|
if( r != S_OK )
|
|
|
|
return;
|
|
|
|
|
|
|
|
str = SysAllocString( szComplete4 );
|
|
|
|
ole_check(IXMLDOMDocument_loadXML(doc, str, &b));
|
|
|
|
ok(b == VARIANT_TRUE, "failed to load XML string\n");
|
|
|
|
SysFreeString(str);
|
|
|
|
|
|
|
|
if(!b)
|
|
|
|
return;
|
|
|
|
|
2007-12-09 10:50:39 +01:00
|
|
|
str = SysAllocString( szSearch);
|
|
|
|
r = IXMLDOMNode_selectSingleNode(doc, str, &node);
|
2007-12-02 22:17:48 +01:00
|
|
|
ok( r == S_OK, "ret %08x\n", r );
|
|
|
|
ok( node != NULL, "node %p\n", node );
|
2007-12-09 10:50:39 +01:00
|
|
|
SysFreeString(str);
|
2007-12-02 22:17:48 +01:00
|
|
|
|
|
|
|
if(!node)
|
|
|
|
{
|
|
|
|
IXMLDOMDocument_Release(doc);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check invalid parameter */
|
|
|
|
r = IXMLDOMNode_cloneNode(node, VARIANT_TRUE, NULL);
|
|
|
|
ok( r == E_INVALIDARG, "ret %08x\n", r );
|
|
|
|
|
|
|
|
/* All Children */
|
|
|
|
r = IXMLDOMNode_cloneNode(node, VARIANT_TRUE, &node_clone);
|
|
|
|
ok( r == S_OK, "ret %08x\n", r );
|
|
|
|
ok( node_clone != NULL, "node %p\n", node );
|
|
|
|
|
|
|
|
if(!node_clone)
|
|
|
|
{
|
|
|
|
IXMLDOMDocument_Release(doc);
|
|
|
|
IXMLDOMNode_Release(node);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
r = IXMLDOMNode_get_childNodes(node, &pList);
|
|
|
|
ok( r == S_OK, "ret %08x\n", r );
|
|
|
|
if (pList)
|
|
|
|
{
|
|
|
|
IXMLDOMNodeList_get_length(pList, &nLength);
|
|
|
|
IXMLDOMNodeList_Release(pList);
|
|
|
|
}
|
|
|
|
|
|
|
|
r = IXMLDOMNode_get_attributes(node, &mapAttr);
|
|
|
|
ok( r == S_OK, "ret %08x\n", r );
|
|
|
|
if(mapAttr)
|
|
|
|
{
|
|
|
|
IXMLDOMNamedNodeMap_get_length(mapAttr, &nAttrCnt);
|
|
|
|
IXMLDOMNamedNodeMap_Release(mapAttr);
|
|
|
|
}
|
|
|
|
|
|
|
|
r = IXMLDOMNode_get_childNodes(node_clone, &pList);
|
|
|
|
ok( r == S_OK, "ret %08x\n", r );
|
|
|
|
if (pList)
|
|
|
|
{
|
|
|
|
IXMLDOMNodeList_get_length(pList, &nLength1);
|
|
|
|
IXMLDOMNodeList_Release(pList);
|
|
|
|
}
|
|
|
|
|
|
|
|
r = IXMLDOMNode_get_attributes(node_clone, &mapAttr);
|
|
|
|
ok( r == S_OK, "ret %08x\n", r );
|
|
|
|
if(mapAttr)
|
|
|
|
{
|
|
|
|
IXMLDOMNamedNodeMap_get_length(mapAttr, &nAttrCnt1);
|
|
|
|
IXMLDOMNamedNodeMap_Release(mapAttr);
|
|
|
|
}
|
|
|
|
|
|
|
|
ok(nLength == nLength1, "wrong Child count (%ld, %ld)\n", nLength, nLength1);
|
|
|
|
ok(nAttrCnt == nAttrCnt1, "wrong Attribute count (%ld, %ld)\n", nAttrCnt, nAttrCnt1);
|
|
|
|
IXMLDOMNode_Release(node_clone);
|
|
|
|
|
|
|
|
/* No Children */
|
|
|
|
r = IXMLDOMNode_cloneNode(node, VARIANT_FALSE, &node_clone);
|
|
|
|
ok( r == S_OK, "ret %08x\n", r );
|
|
|
|
ok( node_clone != NULL, "node %p\n", node );
|
|
|
|
|
|
|
|
if(!node_clone)
|
|
|
|
{
|
|
|
|
IXMLDOMDocument_Release(doc);
|
|
|
|
IXMLDOMNode_Release(node);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
r = IXMLDOMNode_get_childNodes(node_clone, &pList);
|
|
|
|
ok( r == S_OK, "ret %08x\n", r );
|
|
|
|
if (pList)
|
|
|
|
{
|
|
|
|
IXMLDOMNodeList_get_length(pList, &nLength1);
|
|
|
|
ok( nLength1 == 0, "Length should be 0 (%ld)\n", nLength1);
|
|
|
|
IXMLDOMNodeList_Release(pList);
|
|
|
|
}
|
|
|
|
|
|
|
|
r = IXMLDOMNode_get_attributes(node_clone, &mapAttr);
|
|
|
|
ok( r == S_OK, "ret %08x\n", r );
|
|
|
|
if(mapAttr)
|
|
|
|
{
|
|
|
|
IXMLDOMNamedNodeMap_get_length(mapAttr, &nAttrCnt1);
|
|
|
|
ok( nAttrCnt1 == 3, "Attribute count should be 3 (%ld)\n", nAttrCnt1);
|
|
|
|
IXMLDOMNamedNodeMap_Release(mapAttr);
|
|
|
|
}
|
|
|
|
|
|
|
|
ok(nLength != nLength1, "wrong Child count (%ld, %ld)\n", nLength, nLength1);
|
|
|
|
ok(nAttrCnt == nAttrCnt1, "wrong Attribute count (%ld, %ld)\n", nAttrCnt, nAttrCnt1);
|
|
|
|
IXMLDOMNode_Release(node_clone);
|
|
|
|
|
|
|
|
|
|
|
|
IXMLDOMNode_Release(node);
|
|
|
|
IXMLDOMDocument_Release(doc);
|
|
|
|
}
|
|
|
|
|
2008-01-03 23:17:51 +01:00
|
|
|
static void test_xmlTypes(void)
|
|
|
|
{
|
|
|
|
IXMLDOMDocument *doc = NULL;
|
|
|
|
IXMLDOMElement *pRoot;
|
|
|
|
HRESULT hr;
|
|
|
|
IXMLDOMComment *pComment;
|
|
|
|
IXMLDOMElement *pElement;
|
|
|
|
IXMLDOMAttribute *pAttrubute;
|
|
|
|
IXMLDOMNamedNodeMap *pAttribs;
|
2008-01-14 03:25:13 +01:00
|
|
|
IXMLDOMCDATASection *pCDataSec;
|
2008-01-18 10:33:03 +01:00
|
|
|
IXMLDOMImplementation *pIXMLDOMImplementation = NULL;
|
2008-01-19 13:23:49 +01:00
|
|
|
IXMLDOMDocumentFragment *pDocFrag = NULL;
|
2008-01-21 22:33:32 +01:00
|
|
|
IXMLDOMEntityReference *pEntityRef = NULL;
|
2008-01-03 23:17:51 +01:00
|
|
|
BSTR str;
|
2008-01-07 23:59:01 +01:00
|
|
|
IXMLDOMNode *pNextChild = (IXMLDOMNode *)0x1; /* Used for testing Siblings */
|
2008-01-14 02:44:56 +01:00
|
|
|
VARIANT v;
|
2008-02-26 10:21:11 +01:00
|
|
|
long len = 0;
|
2008-01-03 23:17:51 +01:00
|
|
|
|
|
|
|
hr = CoCreateInstance( &CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (LPVOID*)&doc );
|
|
|
|
if( hr != S_OK )
|
|
|
|
return;
|
|
|
|
|
2008-01-07 23:59:01 +01:00
|
|
|
hr = IXMLDOMDocument_get_nextSibling(doc, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IXMLDOMDocument_get_nextSibling(doc, &pNextChild);
|
|
|
|
ok(hr == S_FALSE, "ret %08x\n", hr );
|
|
|
|
ok(pNextChild == NULL, "pDocChild not NULL\n");
|
|
|
|
|
2008-01-08 01:34:29 +01:00
|
|
|
/* test previous Sibling */
|
|
|
|
hr = IXMLDOMDocument_get_previousSibling(doc, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
pNextChild = (IXMLDOMNode *)0x1;
|
|
|
|
hr = IXMLDOMDocument_get_previousSibling(doc, &pNextChild);
|
|
|
|
ok(hr == S_FALSE, "ret %08x\n", hr );
|
|
|
|
ok(pNextChild == NULL, "pNextChild not NULL\n");
|
|
|
|
|
2008-01-08 02:43:34 +01:00
|
|
|
/* test get_attributes */
|
|
|
|
hr = IXMLDOMDocument_get_attributes( doc, NULL );
|
|
|
|
ok( hr == E_INVALIDARG, "get_attributes returned wrong code\n");
|
|
|
|
|
|
|
|
pAttribs = (IXMLDOMNamedNodeMap*)0x1;
|
|
|
|
hr = IXMLDOMDocument_get_attributes( doc, &pAttribs);
|
|
|
|
ok(hr == S_FALSE, "ret %08x\n", hr );
|
|
|
|
ok( pAttribs == NULL, "pAttribs not NULL\n");
|
|
|
|
|
2008-01-14 02:44:56 +01:00
|
|
|
/* test get_dataType */
|
|
|
|
hr = IXMLDOMDocument_get_dataType(doc, &v);
|
|
|
|
ok(hr == S_FALSE, "ret %08x\n", hr );
|
|
|
|
ok( V_VT(&v) == VT_NULL, "incorrect dataType type\n");
|
|
|
|
VariantClear(&v);
|
|
|
|
|
2008-01-16 06:47:19 +01:00
|
|
|
/* test nodeTypeString */
|
|
|
|
hr = IXMLDOMDocument_get_nodeTypeString(doc, &str);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
ok( !lstrcmpW( str, _bstr_("document") ), "incorrect nodeTypeString string\n");
|
|
|
|
SysFreeString(str);
|
|
|
|
|
2008-01-18 10:33:03 +01:00
|
|
|
/* test implementation */
|
|
|
|
hr = IXMLDOMDocument_get_implementation(doc, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IXMLDOMDocument_get_implementation(doc, &pIXMLDOMImplementation);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
if(hr == S_OK)
|
|
|
|
{
|
|
|
|
VARIANT_BOOL hasFeature = VARIANT_TRUE;
|
|
|
|
BSTR sEmpty = SysAllocStringLen(NULL, 0);
|
|
|
|
|
|
|
|
hr = IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation, NULL, sEmpty, &hasFeature);
|
|
|
|
ok(hr == E_INVALIDARG, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation, sEmpty, sEmpty, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation, _bstr_("DOM"), sEmpty, &hasFeature);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
ok(hasFeature == VARIANT_FALSE, "hasFeature returned false\n");
|
|
|
|
|
|
|
|
hr = IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation, sEmpty, sEmpty, &hasFeature);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
ok(hasFeature == VARIANT_FALSE, "hasFeature returned true\n");
|
|
|
|
|
|
|
|
hr = IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation, _bstr_("DOM"), NULL, &hasFeature);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
ok(hasFeature == VARIANT_TRUE, "hasFeature returned false\n");
|
|
|
|
|
|
|
|
hr = IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation, _bstr_("DOM"), sEmpty, &hasFeature);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
ok(hasFeature == VARIANT_FALSE, "hasFeature returned false\n");
|
|
|
|
|
|
|
|
hr = IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation, _bstr_("DOM"), _bstr_("1.0"), &hasFeature);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
ok(hasFeature == VARIANT_TRUE, "hasFeature returned true\n");
|
|
|
|
|
|
|
|
hr = IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation, _bstr_("XML"), _bstr_("1.0"), &hasFeature);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
ok(hasFeature == VARIANT_TRUE, "hasFeature returned true\n");
|
|
|
|
|
|
|
|
hr = IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation, _bstr_("MS-DOM"), _bstr_("1.0"), &hasFeature);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
ok(hasFeature == VARIANT_TRUE, "hasFeature returned true\n");
|
|
|
|
|
|
|
|
hr = IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation, _bstr_("SSS"), NULL, &hasFeature);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
ok(hasFeature == VARIANT_FALSE, "hasFeature returned false\n");
|
|
|
|
|
|
|
|
SysFreeString(sEmpty);
|
|
|
|
IXMLDOMImplementation_Release(pIXMLDOMImplementation);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-01-03 23:17:51 +01:00
|
|
|
hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing"), &pRoot);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
if(hr == S_OK)
|
|
|
|
{
|
|
|
|
hr = IXMLDOMDocument_appendChild(doc, (IXMLDOMNode*)pRoot, NULL);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
if(hr == S_OK)
|
|
|
|
{
|
|
|
|
/* Comment */
|
|
|
|
hr = IXMLDOMDocument_createComment(doc, szComment, &pComment);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
if(hr == S_OK)
|
|
|
|
{
|
2008-01-08 02:43:34 +01:00
|
|
|
/* test get_attributes */
|
|
|
|
hr = IXMLDOMComment_get_attributes( pComment, NULL );
|
|
|
|
ok( hr == E_INVALIDARG, "get_attributes returned wrong code\n");
|
|
|
|
|
|
|
|
pAttribs = (IXMLDOMNamedNodeMap*)0x1;
|
|
|
|
hr = IXMLDOMComment_get_attributes( pComment, &pAttribs);
|
|
|
|
ok(hr == S_FALSE, "ret %08x\n", hr );
|
|
|
|
ok( pAttribs == NULL, "pAttribs not NULL\n");
|
|
|
|
|
2008-01-16 06:47:19 +01:00
|
|
|
/* test nodeTypeString */
|
|
|
|
hr = IXMLDOMComment_get_nodeTypeString(pComment, &str);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
ok( !lstrcmpW( str, _bstr_("comment") ), "incorrect nodeTypeString string\n");
|
|
|
|
SysFreeString(str);
|
|
|
|
|
2008-01-03 23:17:51 +01:00
|
|
|
hr = IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pComment, NULL);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IXMLDOMComment_get_nodeName(pComment, &str);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
ok( !lstrcmpW( str, szCommentNodeText ), "incorrect comment node Name\n");
|
|
|
|
SysFreeString(str);
|
|
|
|
|
|
|
|
hr = IXMLDOMComment_get_xml(pComment, &str);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
ok( !lstrcmpW( str, szCommentXML ), "incorrect comment xml\n");
|
|
|
|
SysFreeString(str);
|
|
|
|
|
2008-01-14 02:44:56 +01:00
|
|
|
hr = IXMLDOMComment_get_dataType(pComment, &v);
|
|
|
|
ok(hr == S_FALSE, "ret %08x\n", hr );
|
|
|
|
ok( V_VT(&v) == VT_NULL, "incorrect dataType type\n");
|
|
|
|
VariantClear(&v);
|
|
|
|
|
2008-02-25 10:05:00 +01:00
|
|
|
/* put data Tests */
|
|
|
|
hr = IXMLDOMComment_put_data(pComment, _bstr_("This &is a ; test <>\\"));
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
|
2008-02-28 11:06:54 +01:00
|
|
|
/* get data Tests */
|
|
|
|
hr = IXMLDOMComment_get_data(pComment, &str);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
ok( !lstrcmpW( str, _bstr_("This &is a ; test <>\\") ), "incorrect get_data string\n");
|
|
|
|
SysFreeString(str);
|
|
|
|
|
2008-02-28 11:03:59 +01:00
|
|
|
/* get data Tests */
|
|
|
|
hr = IXMLDOMComment_get_nodeValue(pComment, &v);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
ok( V_VT(&v) == VT_BSTR, "incorrect dataType type\n");
|
|
|
|
ok( !lstrcmpW( V_BSTR(&v), _bstr_("This &is a ; test <>\\") ), "incorrect get_nodeValue string\n");
|
|
|
|
VariantClear(&v);
|
|
|
|
|
2008-02-25 10:05:00 +01:00
|
|
|
/* Confirm XML text is good */
|
|
|
|
hr = IXMLDOMComment_get_xml(pComment, &str);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
ok( !lstrcmpW( str, _bstr_("<!--This &is a ; test <>\\-->") ), "incorrect xml string\n");
|
|
|
|
SysFreeString(str);
|
|
|
|
|
|
|
|
/* Confirm we get the put_data Text back */
|
|
|
|
hr = IXMLDOMComment_get_text(pComment, &str);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
ok( !lstrcmpW( str, _bstr_("This &is a ; test <>\\") ), "incorrect xml string\n");
|
|
|
|
SysFreeString(str);
|
|
|
|
|
2008-02-26 10:21:11 +01:00
|
|
|
/* test length property */
|
|
|
|
hr = IXMLDOMComment_get_length(pComment, &len);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
ok(len == 21, "expected 21 got %ld\n", len);
|
|
|
|
|
2008-03-10 05:58:30 +01:00
|
|
|
/* test substringData */
|
|
|
|
hr = IXMLDOMComment_substringData(pComment, 0, 4, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
/* test substringData - Invalid offset */
|
|
|
|
str = (BSTR)&szElement;
|
|
|
|
hr = IXMLDOMComment_substringData(pComment, -1, 4, &str);
|
|
|
|
ok(hr == E_INVALIDARG, "ret %08x\n", hr );
|
|
|
|
ok( str == NULL, "incorrect string\n");
|
|
|
|
|
|
|
|
/* test substringData - Invalid offset */
|
|
|
|
str = (BSTR)&szElement;
|
|
|
|
hr = IXMLDOMComment_substringData(pComment, 30, 0, &str);
|
|
|
|
ok(hr == S_FALSE, "ret %08x\n", hr );
|
|
|
|
ok( str == NULL, "incorrect string\n");
|
|
|
|
|
|
|
|
/* test substringData - Invalid size */
|
|
|
|
str = (BSTR)&szElement;
|
|
|
|
hr = IXMLDOMComment_substringData(pComment, 0, -1, &str);
|
|
|
|
ok(hr == E_INVALIDARG, "ret %08x\n", hr );
|
|
|
|
ok( str == NULL, "incorrect string\n");
|
|
|
|
|
|
|
|
/* test substringData - Invalid size */
|
|
|
|
str = (BSTR)&szElement;
|
|
|
|
hr = IXMLDOMComment_substringData(pComment, 2, 0, &str);
|
|
|
|
ok(hr == S_FALSE, "ret %08x\n", hr );
|
|
|
|
ok( str == NULL, "incorrect string\n");
|
|
|
|
|
|
|
|
/* test substringData - Start of string */
|
|
|
|
hr = IXMLDOMComment_substringData(pComment, 0, 4, &str);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
ok( !lstrcmpW( str, _bstr_("This") ), "incorrect substringData string\n");
|
|
|
|
SysFreeString(str);
|
|
|
|
|
|
|
|
/* test substringData - Middle of string */
|
|
|
|
hr = IXMLDOMComment_substringData(pComment, 13, 4, &str);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
ok( !lstrcmpW( str, _bstr_("test") ), "incorrect substringData string\n");
|
|
|
|
SysFreeString(str);
|
|
|
|
|
|
|
|
/* test substringData - End of string */
|
|
|
|
hr = IXMLDOMComment_substringData(pComment, 20, 4, &str);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
ok( !lstrcmpW( str, _bstr_("\\") ), "incorrect substringData string\n");
|
|
|
|
SysFreeString(str);
|
|
|
|
|
2008-03-13 11:19:24 +01:00
|
|
|
/* test appendData */
|
|
|
|
hr = IXMLDOMComment_appendData(pComment, NULL);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IXMLDOMComment_appendData(pComment, _bstr_(""));
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IXMLDOMComment_appendData(pComment, _bstr_("Append"));
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IXMLDOMComment_get_text(pComment, &str);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
ok( !lstrcmpW( str, _bstr_("This &is a ; test <>\\Append") ), "incorrect get_text string\n");
|
|
|
|
SysFreeString(str);
|
|
|
|
|
2008-01-03 23:17:51 +01:00
|
|
|
IXMLDOMComment_Release(pComment);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Element */
|
|
|
|
hr = IXMLDOMDocument_createElement(doc, szElement, &pElement);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
if(hr == S_OK)
|
|
|
|
{
|
|
|
|
hr = IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
|
2008-01-16 06:47:19 +01:00
|
|
|
/* test nodeTypeString */
|
|
|
|
hr = IXMLDOMDocument_get_nodeTypeString(pElement, &str);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
ok( !lstrcmpW( str, _bstr_("element") ), "incorrect nodeTypeString string\n");
|
|
|
|
SysFreeString(str);
|
|
|
|
|
2008-01-03 23:17:51 +01:00
|
|
|
hr = IXMLDOMElement_get_nodeName(pElement, &str);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
ok( !lstrcmpW( str, szElement ), "incorrect element node Name\n");
|
|
|
|
SysFreeString(str);
|
|
|
|
|
|
|
|
hr = IXMLDOMElement_get_xml(pElement, &str);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
ok( !lstrcmpW( str, szElementXML ), "incorrect element xml\n");
|
|
|
|
SysFreeString(str);
|
|
|
|
|
2008-01-14 02:44:56 +01:00
|
|
|
hr = IXMLDOMElement_get_dataType(pElement, &v);
|
|
|
|
ok(hr == S_FALSE, "ret %08x\n", hr );
|
|
|
|
ok( V_VT(&v) == VT_NULL, "incorrect dataType type\n");
|
|
|
|
VariantClear(&v);
|
|
|
|
|
2008-01-03 23:17:51 +01:00
|
|
|
/* Attribute */
|
|
|
|
hr = IXMLDOMDocument_createAttribute(doc, szAttribute, &pAttrubute);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
if(hr == S_OK)
|
|
|
|
{
|
|
|
|
IXMLDOMNode *pNewChild = (IXMLDOMNode *)0x1;
|
2008-01-07 23:59:01 +01:00
|
|
|
|
|
|
|
hr = IXMLDOMAttribute_get_nextSibling(pAttrubute, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
pNextChild = (IXMLDOMNode *)0x1;
|
|
|
|
hr = IXMLDOMAttribute_get_nextSibling(pAttrubute, &pNextChild);
|
|
|
|
ok(hr == S_FALSE, "ret %08x\n", hr );
|
|
|
|
ok(pNextChild == NULL, "pNextChild not NULL\n");
|
|
|
|
|
2008-01-08 01:34:29 +01:00
|
|
|
/* test Previous Sibling*/
|
|
|
|
hr = IXMLDOMAttribute_get_previousSibling(pAttrubute, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
pNextChild = (IXMLDOMNode *)0x1;
|
|
|
|
hr = IXMLDOMAttribute_get_previousSibling(pAttrubute, &pNextChild);
|
|
|
|
ok(hr == S_FALSE, "ret %08x\n", hr );
|
|
|
|
ok(pNextChild == NULL, "pNextChild not NULL\n");
|
|
|
|
|
2008-01-08 02:43:34 +01:00
|
|
|
/* test get_attributes */
|
|
|
|
hr = IXMLDOMAttribute_get_attributes( pAttrubute, NULL );
|
|
|
|
ok( hr == E_INVALIDARG, "get_attributes returned wrong code\n");
|
|
|
|
|
|
|
|
pAttribs = (IXMLDOMNamedNodeMap*)0x1;
|
|
|
|
hr = IXMLDOMAttribute_get_attributes( pAttrubute, &pAttribs);
|
|
|
|
ok(hr == S_FALSE, "ret %08x\n", hr );
|
|
|
|
ok( pAttribs == NULL, "pAttribs not NULL\n");
|
|
|
|
|
2008-01-03 23:17:51 +01:00
|
|
|
hr = IXMLDOMElement_appendChild(pElement, (IXMLDOMNode*)pAttrubute, &pNewChild);
|
|
|
|
ok(hr == E_FAIL, "ret %08x\n", hr );
|
2008-01-07 11:16:33 +01:00
|
|
|
ok(pNewChild == NULL, "pNewChild not NULL\n");
|
2008-01-03 23:17:51 +01:00
|
|
|
|
|
|
|
hr = IXMLDOMElement_get_attributes(pElement, &pAttribs);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
if ( hr == S_OK )
|
|
|
|
{
|
|
|
|
hr = IXMLDOMNamedNodeMap_setNamedItem(pAttribs, (IXMLDOMNode*)pAttrubute, NULL );
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
IXMLDOMNamedNodeMap_Release(pAttribs);
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IXMLDOMAttribute_get_nodeName(pAttrubute, &str);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
ok( !lstrcmpW( str, szAttribute ), "incorrect attribute node Name\n");
|
|
|
|
SysFreeString(str);
|
|
|
|
|
2008-01-16 06:47:19 +01:00
|
|
|
/* test nodeTypeString */
|
|
|
|
hr = IXMLDOMAttribute_get_nodeTypeString(pAttrubute, &str);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
ok( !lstrcmpW( str, _bstr_("attribute") ), "incorrect nodeTypeString string\n");
|
|
|
|
SysFreeString(str);
|
|
|
|
|
2008-02-16 12:31:01 +01:00
|
|
|
/* test nodeName */
|
|
|
|
hr = IXMLDOMAttribute_get_nodeName(pAttrubute, &str);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
ok( !lstrcmpW( str, szAttribute ), "incorrect nodeName string\n");
|
|
|
|
SysFreeString(str);
|
|
|
|
|
|
|
|
/* test name property */
|
|
|
|
hr = IXMLDOMAttribute_get_name(pAttrubute, &str);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
ok( !lstrcmpW( str, szAttribute ), "incorrect name string\n");
|
|
|
|
SysFreeString(str);
|
|
|
|
|
2008-01-03 23:17:51 +01:00
|
|
|
hr = IXMLDOMAttribute_get_xml(pAttrubute, &str);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
ok( !lstrcmpW( str, szAttributeXML ), "incorrect attribute xml\n");
|
|
|
|
SysFreeString(str);
|
|
|
|
|
2008-01-14 02:44:56 +01:00
|
|
|
hr = IXMLDOMAttribute_get_dataType(pAttrubute, &v);
|
|
|
|
ok(hr == S_FALSE, "ret %08x\n", hr );
|
|
|
|
ok( V_VT(&v) == VT_NULL, "incorrect dataType type\n");
|
|
|
|
VariantClear(&v);
|
|
|
|
|
2008-01-03 23:17:51 +01:00
|
|
|
IXMLDOMAttribute_Release(pAttrubute);
|
|
|
|
|
|
|
|
/* Check Element again with the Add Attribute*/
|
|
|
|
hr = IXMLDOMElement_get_xml(pElement, &str);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
ok( !lstrcmpW( str, szElementXML2 ), "incorrect element xml\n");
|
|
|
|
SysFreeString(str);
|
|
|
|
}
|
|
|
|
|
2008-01-16 03:44:51 +01:00
|
|
|
hr = IXMLDOMElement_put_text(pElement, _bstr_("TestingNode"));
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IXMLDOMElement_get_xml(pElement, &str);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
ok( !lstrcmpW( str, szElementXML3 ), "incorrect element xml\n");
|
2008-03-04 11:09:06 +01:00
|
|
|
SysFreeString(str);
|
2008-01-16 03:44:51 +01:00
|
|
|
|
2008-01-03 23:17:51 +01:00
|
|
|
IXMLDOMElement_Release(pElement);
|
|
|
|
}
|
|
|
|
|
2008-01-14 03:25:13 +01:00
|
|
|
/* CData Section */
|
|
|
|
hr = IXMLDOMDocument_createCDATASection(doc, szCData, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IXMLDOMDocument_createCDATASection(doc, szCData, &pCDataSec);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
if(hr == S_OK)
|
|
|
|
{
|
|
|
|
IXMLDOMNode *pNextChild = (IXMLDOMNode *)0x1;
|
2008-03-01 12:51:00 +01:00
|
|
|
VARIANT var;
|
2008-01-14 03:25:13 +01:00
|
|
|
|
|
|
|
hr = IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pCDataSec, NULL);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
/* get Attribute Tests */
|
|
|
|
hr = IXMLDOMCDATASection_get_attributes(pCDataSec, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
pAttribs = (IXMLDOMNamedNodeMap*)0x1;
|
|
|
|
hr = IXMLDOMCDATASection_get_attributes(pCDataSec, &pAttribs);
|
|
|
|
ok(hr == S_FALSE, "ret %08x\n", hr );
|
|
|
|
ok(pAttribs == NULL, "pAttribs != NULL\n");
|
|
|
|
|
|
|
|
hr = IXMLDOMCDATASection_get_nodeName(pCDataSec, &str);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
ok( !lstrcmpW( str, szCDataNodeText ), "incorrect cdata node Name\n");
|
|
|
|
SysFreeString(str);
|
|
|
|
|
|
|
|
hr = IXMLDOMCDATASection_get_xml(pCDataSec, &str);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
ok( !lstrcmpW( str, szCDataXML ), "incorrect cdata xml\n");
|
|
|
|
SysFreeString(str);
|
|
|
|
|
|
|
|
/* test lastChild */
|
|
|
|
pNextChild = (IXMLDOMNode*)0x1;
|
|
|
|
hr = IXMLDOMCDATASection_get_lastChild(pCDataSec, &pNextChild);
|
|
|
|
ok(hr == S_FALSE, "ret %08x\n", hr );
|
|
|
|
ok(pNextChild == NULL, "pNextChild not NULL\n");
|
|
|
|
|
|
|
|
/* test get_dataType */
|
|
|
|
hr = IXMLDOMCDATASection_get_dataType(pCDataSec, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IXMLDOMCDATASection_get_dataType(pCDataSec, &v);
|
|
|
|
ok(hr == S_FALSE, "ret %08x\n", hr );
|
|
|
|
ok( V_VT(&v) == VT_NULL, "incorrect dataType type\n");
|
|
|
|
VariantClear(&v);
|
|
|
|
|
2008-01-16 06:47:19 +01:00
|
|
|
/* test nodeTypeString */
|
|
|
|
hr = IXMLDOMCDATASection_get_nodeTypeString(pCDataSec, &str);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
ok( !lstrcmpW( str, _bstr_("cdatasection") ), "incorrect nodeTypeString string\n");
|
|
|
|
SysFreeString(str);
|
|
|
|
|
2008-02-25 10:05:00 +01:00
|
|
|
/* put data Tests */
|
|
|
|
hr = IXMLDOMCDATASection_put_data(pCDataSec, _bstr_("This &is a ; test <>\\"));
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
/* Confirm XML text is good */
|
|
|
|
hr = IXMLDOMCDATASection_get_xml(pCDataSec, &str);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
ok( !lstrcmpW( str, _bstr_("<![CDATA[This &is a ; test <>\\]]>") ), "incorrect xml string\n");
|
|
|
|
SysFreeString(str);
|
|
|
|
|
|
|
|
/* Confirm we get the put_data Text back */
|
|
|
|
hr = IXMLDOMCDATASection_get_text(pCDataSec, &str);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
ok( !lstrcmpW( str, _bstr_("This &is a ; test <>\\") ), "incorrect text string\n");
|
|
|
|
SysFreeString(str);
|
|
|
|
|
2008-02-26 10:21:43 +01:00
|
|
|
/* test length property */
|
2008-03-04 11:09:06 +01:00
|
|
|
hr = IXMLDOMCDATASection_get_length(pCDataSec, &len);
|
2008-02-26 10:21:43 +01:00
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
ok(len == 21, "expected 21 got %ld\n", len);
|
|
|
|
|
2008-03-01 12:54:33 +01:00
|
|
|
/* test get nodeValue */
|
2008-03-04 11:09:06 +01:00
|
|
|
hr = IXMLDOMCDATASection_get_nodeValue(pCDataSec, &var);
|
2008-03-01 12:51:00 +01:00
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
ok( !lstrcmpW( str, _bstr_("This &is a ; test <>\\") ), "incorrect text string\n");
|
|
|
|
VariantClear(&var);
|
|
|
|
|
2008-03-01 12:54:33 +01:00
|
|
|
/* test get data */
|
2008-03-04 11:09:06 +01:00
|
|
|
hr = IXMLDOMCDATASection_get_data(pCDataSec, &str);
|
2008-03-01 12:54:33 +01:00
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
ok( !lstrcmpW( str, _bstr_("This &is a ; test <>\\") ), "incorrect text string\n");
|
|
|
|
SysFreeString(str);
|
|
|
|
|
2008-03-09 05:18:40 +01:00
|
|
|
/* test substringData */
|
|
|
|
hr = IXMLDOMCDATASection_substringData(pCDataSec, 0, 4, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
/* test substringData - Invalid offset */
|
|
|
|
str = (BSTR)&szElement;
|
|
|
|
hr = IXMLDOMCDATASection_substringData(pCDataSec, -1, 4, &str);
|
|
|
|
ok(hr == E_INVALIDARG, "ret %08x\n", hr );
|
|
|
|
ok( str == NULL, "incorrect string\n");
|
|
|
|
|
|
|
|
/* test substringData - Invalid offset */
|
|
|
|
str = (BSTR)&szElement;
|
|
|
|
hr = IXMLDOMCDATASection_substringData(pCDataSec, 30, 0, &str);
|
|
|
|
ok(hr == S_FALSE, "ret %08x\n", hr );
|
|
|
|
ok( str == NULL, "incorrect string\n");
|
|
|
|
|
|
|
|
/* test substringData - Invalid size */
|
|
|
|
str = (BSTR)&szElement;
|
|
|
|
hr = IXMLDOMCDATASection_substringData(pCDataSec, 0, -1, &str);
|
|
|
|
ok(hr == E_INVALIDARG, "ret %08x\n", hr );
|
|
|
|
ok( str == NULL, "incorrect string\n");
|
|
|
|
|
|
|
|
/* test substringData - Invalid size */
|
|
|
|
str = (BSTR)&szElement;
|
|
|
|
hr = IXMLDOMCDATASection_substringData(pCDataSec, 2, 0, &str);
|
|
|
|
ok(hr == S_FALSE, "ret %08x\n", hr );
|
|
|
|
ok( str == NULL, "incorrect string\n");
|
|
|
|
|
|
|
|
/* test substringData - Start of string */
|
|
|
|
hr = IXMLDOMCDATASection_substringData(pCDataSec, 0, 4, &str);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
ok( !lstrcmpW( str, _bstr_("This") ), "incorrect substringData string\n");
|
|
|
|
SysFreeString(str);
|
|
|
|
|
|
|
|
/* test substringData - Middle of string */
|
|
|
|
hr = IXMLDOMCDATASection_substringData(pCDataSec, 13, 4, &str);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
ok( !lstrcmpW( str, _bstr_("test") ), "incorrect substringData string\n");
|
|
|
|
SysFreeString(str);
|
|
|
|
|
|
|
|
/* test substringData - End of string */
|
|
|
|
hr = IXMLDOMCDATASection_substringData(pCDataSec, 20, 4, &str);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
ok( !lstrcmpW( str, _bstr_("\\") ), "incorrect substringData string\n");
|
|
|
|
SysFreeString(str);
|
|
|
|
|
2008-03-10 05:52:48 +01:00
|
|
|
/* test appendData */
|
|
|
|
hr = IXMLDOMCDATASection_appendData(pCDataSec, NULL);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IXMLDOMCDATASection_appendData(pCDataSec, _bstr_(""));
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IXMLDOMCDATASection_appendData(pCDataSec, _bstr_("Append"));
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IXMLDOMCDATASection_get_text(pCDataSec, &str);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
ok( !lstrcmpW( str, _bstr_("This &is a ; test <>\\Append") ), "incorrect get_text string\n");
|
|
|
|
SysFreeString(str);
|
|
|
|
|
2008-03-13 11:50:30 +01:00
|
|
|
/* test insertData */
|
|
|
|
str = SysAllocStringLen(NULL, 0);
|
|
|
|
hr = IXMLDOMCDATASection_insertData(pCDataSec, -1, str);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IXMLDOMCDATASection_insertData(pCDataSec, -1, NULL);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IXMLDOMCDATASection_insertData(pCDataSec, 1000, str);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IXMLDOMCDATASection_insertData(pCDataSec, 1000, NULL);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IXMLDOMCDATASection_insertData(pCDataSec, 0, NULL);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IXMLDOMCDATASection_insertData(pCDataSec, 0, str);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
SysFreeString(str);
|
|
|
|
|
|
|
|
hr = IXMLDOMCDATASection_insertData(pCDataSec, -1, _bstr_("Inserting"));
|
|
|
|
ok(hr == E_INVALIDARG, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IXMLDOMCDATASection_insertData(pCDataSec, 1000, _bstr_("Inserting"));
|
|
|
|
ok(hr == E_INVALIDARG, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IXMLDOMCDATASection_insertData(pCDataSec, 0, _bstr_("Begin "));
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IXMLDOMCDATASection_insertData(pCDataSec, 17, _bstr_("Middle"));
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IXMLDOMCDATASection_insertData(pCDataSec, 39, _bstr_(" End"));
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IXMLDOMCDATASection_get_text(pCDataSec, &str);
|
|
|
|
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);
|
|
|
|
|
2008-01-14 03:25:13 +01:00
|
|
|
IXMLDOMCDATASection_Release(pCDataSec);
|
|
|
|
}
|
|
|
|
|
2008-01-19 13:23:49 +01:00
|
|
|
/* Document Fragments */
|
|
|
|
hr = IXMLDOMDocument_createDocumentFragment(doc, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IXMLDOMDocument_createDocumentFragment(doc, &pDocFrag);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
if(hr == S_OK)
|
|
|
|
{
|
|
|
|
IXMLDOMNode *pNextChild = (IXMLDOMNode *)0x1;
|
|
|
|
|
|
|
|
hr = IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pDocFrag, NULL);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
/* get Attribute Tests */
|
|
|
|
hr = IXMLDOMDocumentFragment_get_attributes(pDocFrag, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
pAttribs = (IXMLDOMNamedNodeMap*)0x1;
|
|
|
|
hr = IXMLDOMDocumentFragment_get_attributes(pDocFrag, &pAttribs);
|
|
|
|
ok(hr == S_FALSE, "ret %08x\n", hr );
|
|
|
|
ok(pAttribs == NULL, "pAttribs != NULL\n");
|
|
|
|
|
|
|
|
hr = IXMLDOMDocumentFragment_get_nodeName(pDocFrag, &str);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
ok( !lstrcmpW( str, szDocFragmentText ), "incorrect docfragment node Name\n");
|
|
|
|
SysFreeString(str);
|
|
|
|
|
|
|
|
/* test next Sibling*/
|
|
|
|
hr = IXMLDOMDocumentFragment_get_nextSibling(pDocFrag, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
pNextChild = (IXMLDOMNode *)0x1;
|
|
|
|
hr = IXMLDOMDocumentFragment_get_nextSibling(pDocFrag, &pNextChild);
|
|
|
|
ok(hr == S_FALSE, "ret %08x\n", hr );
|
|
|
|
ok(pNextChild == NULL, "pNextChild not NULL\n");
|
|
|
|
|
|
|
|
/* test Previous Sibling*/
|
|
|
|
hr = IXMLDOMDocumentFragment_get_previousSibling(pDocFrag, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
pNextChild = (IXMLDOMNode *)0x1;
|
|
|
|
hr = IXMLDOMDocumentFragment_get_previousSibling(pDocFrag, &pNextChild);
|
|
|
|
ok(hr == S_FALSE, "ret %08x\n", hr );
|
|
|
|
ok(pNextChild == NULL, "pNextChild not NULL\n");
|
|
|
|
|
|
|
|
/* test get_dataType */
|
|
|
|
hr = IXMLDOMDocumentFragment_get_dataType(pDocFrag, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IXMLDOMDocumentFragment_get_dataType(pDocFrag, &v);
|
|
|
|
ok(hr == S_FALSE, "ret %08x\n", hr );
|
|
|
|
ok( V_VT(&v) == VT_NULL, "incorrect dataType type\n");
|
|
|
|
VariantClear(&v);
|
|
|
|
|
|
|
|
/* test nodeTypeString */
|
|
|
|
hr = IXMLDOMDocumentFragment_get_nodeTypeString(pDocFrag, &str);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
ok( !lstrcmpW( str, _bstr_("documentfragment") ), "incorrect nodeTypeString string\n");
|
|
|
|
SysFreeString(str);
|
|
|
|
|
2008-03-04 11:09:06 +01:00
|
|
|
IXMLDOMDocumentFragment_Release(pDocFrag);
|
2008-01-19 13:23:49 +01:00
|
|
|
}
|
|
|
|
|
2008-01-21 22:33:32 +01:00
|
|
|
/* Entity References */
|
|
|
|
hr = IXMLDOMDocument_createEntityReference(doc, szEntityRef, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IXMLDOMDocument_createEntityReference(doc, szEntityRef, &pEntityRef);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
if(hr == S_OK)
|
|
|
|
{
|
|
|
|
hr = IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pEntityRef, NULL);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
2008-01-19 13:23:49 +01:00
|
|
|
|
2008-01-21 22:33:32 +01:00
|
|
|
/* get Attribute Tests */
|
|
|
|
hr = IXMLDOMEntityReference_get_attributes(pEntityRef, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
pAttribs = (IXMLDOMNamedNodeMap*)0x1;
|
|
|
|
hr = IXMLDOMEntityReference_get_attributes(pEntityRef, &pAttribs);
|
|
|
|
ok(hr == S_FALSE, "ret %08x\n", hr );
|
|
|
|
ok(pAttribs == NULL, "pAttribs != NULL\n");
|
2008-01-14 03:25:13 +01:00
|
|
|
|
2008-01-21 22:33:32 +01:00
|
|
|
/* test dataType */
|
|
|
|
hr = IXMLDOMEntityReference_get_dataType(pEntityRef, &v);
|
|
|
|
ok(hr == S_FALSE, "ret %08x\n", hr );
|
|
|
|
ok( V_VT(&v) == VT_NULL, "incorrect dataType type\n");
|
|
|
|
VariantClear(&v);
|
|
|
|
|
|
|
|
/* test nodeTypeString */
|
|
|
|
hr = IXMLDOMEntityReference_get_nodeTypeString(pEntityRef, &str);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
ok( !lstrcmpW( str, _bstr_("entityreference") ), "incorrect nodeTypeString string\n");
|
|
|
|
SysFreeString(str);
|
|
|
|
|
|
|
|
/* test get_xml*/
|
|
|
|
hr = IXMLDOMEntityReference_get_xml(pEntityRef, &str);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
2008-02-01 10:49:05 +01:00
|
|
|
ok( !lstrcmpW( str, szEntityRefXML ), "incorrect xml string\n");
|
2008-01-21 22:33:32 +01:00
|
|
|
SysFreeString(str);
|
|
|
|
|
|
|
|
IXMLDOMEntityReference_Release(pEntityRef);
|
|
|
|
}
|
2008-01-14 03:25:13 +01:00
|
|
|
|
2008-01-03 23:17:51 +01:00
|
|
|
IXMLDOMElement_Release( pRoot );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
IXMLDOMDocument_Release(doc);
|
2008-01-11 03:51:03 +01:00
|
|
|
|
|
|
|
free_bstrs();
|
2008-01-03 23:17:51 +01:00
|
|
|
}
|
|
|
|
|
2008-02-20 06:03:41 +01:00
|
|
|
static void test_nodeTypeTests( void )
|
|
|
|
{
|
|
|
|
IXMLDOMDocument *doc = NULL;
|
|
|
|
IXMLDOMElement *pRoot;
|
|
|
|
IXMLDOMElement *pElement;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = CoCreateInstance( &CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (LPVOID*)&doc );
|
|
|
|
if( hr != S_OK )
|
|
|
|
return;
|
|
|
|
|
|
|
|
hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing"), &pRoot);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
if(hr == S_OK)
|
|
|
|
{
|
|
|
|
hr = IXMLDOMDocument_appendChild(doc, (IXMLDOMNode*)pRoot, NULL);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
if(hr == S_OK)
|
|
|
|
{
|
|
|
|
hr = IXMLDOMElement_put_dataType(pRoot, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
/* Invalid Value */
|
|
|
|
hr = IXMLDOMElement_put_dataType(pRoot, _bstr_("abcdefg") );
|
|
|
|
ok(hr == E_FAIL, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
/* NOTE:
|
|
|
|
* The name passed into put_dataType is case-insensitive. So many of the names
|
|
|
|
* have been changed to reflect this.
|
|
|
|
*/
|
|
|
|
/* Boolean */
|
|
|
|
hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_Boolean"), &pElement);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
if(hr == S_OK)
|
|
|
|
{
|
|
|
|
IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
|
|
|
|
|
|
|
|
hr = IXMLDOMElement_put_dataType(pElement, _bstr_("Boolean") );
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
IXMLDOMElement_Release(pElement);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* String */
|
|
|
|
hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_String"), &pElement);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
if(hr == S_OK)
|
|
|
|
{
|
|
|
|
IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
|
|
|
|
|
|
|
|
hr = IXMLDOMElement_put_dataType(pElement, _bstr_("String") );
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
IXMLDOMElement_Release(pElement);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Number */
|
|
|
|
hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_Number"), &pElement);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
if(hr == S_OK)
|
|
|
|
{
|
|
|
|
IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
|
|
|
|
|
|
|
|
hr = IXMLDOMElement_put_dataType(pElement, _bstr_("number") );
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
IXMLDOMElement_Release(pElement);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Int */
|
|
|
|
hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_Int"), &pElement);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
if(hr == S_OK)
|
|
|
|
{
|
|
|
|
IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
|
|
|
|
|
|
|
|
hr = IXMLDOMElement_put_dataType(pElement, _bstr_("InT") );
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
IXMLDOMElement_Release(pElement);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Fixed */
|
|
|
|
hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_Fixed"), &pElement);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
if(hr == S_OK)
|
|
|
|
{
|
|
|
|
IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
|
|
|
|
|
|
|
|
hr = IXMLDOMElement_put_dataType(pElement, _bstr_("fixed.14.4") );
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
IXMLDOMElement_Release(pElement);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* DateTime */
|
|
|
|
hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_DateTime"), &pElement);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
if(hr == S_OK)
|
|
|
|
{
|
|
|
|
IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
|
|
|
|
|
|
|
|
hr = IXMLDOMElement_put_dataType(pElement, _bstr_("DateTime") );
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
IXMLDOMElement_Release(pElement);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* DateTime TZ */
|
|
|
|
hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_DateTime_tz"), &pElement);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
if(hr == S_OK)
|
|
|
|
{
|
|
|
|
IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
|
|
|
|
|
|
|
|
hr = IXMLDOMElement_put_dataType(pElement, _bstr_("DateTime.tz") );
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
IXMLDOMElement_Release(pElement);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Date */
|
|
|
|
hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_Date"), &pElement);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
if(hr == S_OK)
|
|
|
|
{
|
|
|
|
IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
|
|
|
|
|
|
|
|
hr = IXMLDOMElement_put_dataType(pElement, _bstr_("Date") );
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
IXMLDOMElement_Release(pElement);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Time */
|
|
|
|
hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_Time"), &pElement);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
if(hr == S_OK)
|
|
|
|
{
|
|
|
|
IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
|
|
|
|
|
|
|
|
hr = IXMLDOMElement_put_dataType(pElement, _bstr_("Time") );
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
IXMLDOMElement_Release(pElement);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Time.tz */
|
|
|
|
hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_Time_TZ"), &pElement);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
if(hr == S_OK)
|
|
|
|
{
|
|
|
|
IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
|
|
|
|
|
|
|
|
hr = IXMLDOMElement_put_dataType(pElement, _bstr_("Time.tz") );
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
IXMLDOMElement_Release(pElement);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* I1 */
|
|
|
|
hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_I1"), &pElement);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
if(hr == S_OK)
|
|
|
|
{
|
|
|
|
IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
|
|
|
|
|
|
|
|
hr = IXMLDOMElement_put_dataType(pElement, _bstr_("I1") );
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
IXMLDOMElement_Release(pElement);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* I2 */
|
|
|
|
hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_I2"), &pElement);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
if(hr == S_OK)
|
|
|
|
{
|
|
|
|
IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
|
|
|
|
|
|
|
|
hr = IXMLDOMElement_put_dataType(pElement, _bstr_("I2") );
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
IXMLDOMElement_Release(pElement);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* I4 */
|
|
|
|
hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_I4"), &pElement);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
if(hr == S_OK)
|
|
|
|
{
|
|
|
|
IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
|
|
|
|
|
|
|
|
hr = IXMLDOMElement_put_dataType(pElement, _bstr_("I4") );
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
IXMLDOMElement_Release(pElement);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* UI1 */
|
|
|
|
hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_UI1"), &pElement);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
if(hr == S_OK)
|
|
|
|
{
|
|
|
|
IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
|
|
|
|
|
|
|
|
hr = IXMLDOMElement_put_dataType(pElement, _bstr_("UI1") );
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
IXMLDOMElement_Release(pElement);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* UI2 */
|
|
|
|
hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_UI2"), &pElement);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
if(hr == S_OK)
|
|
|
|
{
|
|
|
|
IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
|
|
|
|
|
|
|
|
hr = IXMLDOMElement_put_dataType(pElement, _bstr_("UI2") );
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
IXMLDOMElement_Release(pElement);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* UI4 */
|
|
|
|
hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_UI4"), &pElement);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
if(hr == S_OK)
|
|
|
|
{
|
|
|
|
IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
|
|
|
|
|
|
|
|
hr = IXMLDOMElement_put_dataType(pElement, _bstr_("UI4") );
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
IXMLDOMElement_Release(pElement);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* r4 */
|
|
|
|
hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_r4"), &pElement);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
if(hr == S_OK)
|
|
|
|
{
|
|
|
|
IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
|
|
|
|
|
|
|
|
hr = IXMLDOMElement_put_dataType(pElement, _bstr_("r4") );
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
IXMLDOMElement_Release(pElement);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* r8 */
|
|
|
|
hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_r8"), &pElement);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
if(hr == S_OK)
|
|
|
|
{
|
|
|
|
IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
|
|
|
|
|
|
|
|
hr = IXMLDOMElement_put_dataType(pElement, _bstr_("r8") );
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
IXMLDOMElement_Release(pElement);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* float */
|
|
|
|
hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_float"), &pElement);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
if(hr == S_OK)
|
|
|
|
{
|
|
|
|
IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
|
|
|
|
|
|
|
|
hr = IXMLDOMElement_put_dataType(pElement, _bstr_("float") );
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
IXMLDOMElement_Release(pElement);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* uuid */
|
|
|
|
hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_uuid"), &pElement);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
if(hr == S_OK)
|
|
|
|
{
|
|
|
|
IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
|
|
|
|
|
|
|
|
hr = IXMLDOMElement_put_dataType(pElement, _bstr_("UuId") );
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
IXMLDOMElement_Release(pElement);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* bin.hex */
|
|
|
|
hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_bin_hex"), &pElement);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
if(hr == S_OK)
|
|
|
|
{
|
|
|
|
IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
|
|
|
|
|
|
|
|
hr = IXMLDOMElement_put_dataType(pElement, _bstr_("bin.hex") );
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
IXMLDOMElement_Release(pElement);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* bin.base64 */
|
|
|
|
hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_bin_base64"), &pElement);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
if(hr == S_OK)
|
|
|
|
{
|
|
|
|
IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
|
|
|
|
|
|
|
|
hr = IXMLDOMElement_put_dataType(pElement, _bstr_("bin.base64") );
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
IXMLDOMElement_Release(pElement);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check changing types */
|
|
|
|
hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_Change"), &pElement);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
if(hr == S_OK)
|
|
|
|
{
|
|
|
|
IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
|
|
|
|
|
|
|
|
hr = IXMLDOMElement_put_dataType(pElement, _bstr_("DateTime.tz") );
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IXMLDOMElement_put_dataType(pElement, _bstr_("string") );
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
IXMLDOMElement_Release(pElement);
|
|
|
|
}
|
|
|
|
|
|
|
|
IXMLDOMElement_Release(pRoot);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
IXMLDOMDocument_Release(doc);
|
|
|
|
|
|
|
|
free_bstrs();
|
|
|
|
}
|
|
|
|
|
2008-03-12 11:47:17 +01:00
|
|
|
static void test_DocumentSaveToDocument(void)
|
|
|
|
{
|
|
|
|
IXMLDOMDocument *doc = NULL;
|
|
|
|
IXMLDOMDocument *doc2 = NULL;
|
|
|
|
IXMLDOMElement *pRoot;
|
|
|
|
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = CoCreateInstance( &CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (LPVOID*)&doc );
|
|
|
|
if( hr != S_OK )
|
|
|
|
return;
|
|
|
|
|
|
|
|
hr = CoCreateInstance( &CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (LPVOID*)&doc2 );
|
|
|
|
if( hr != S_OK )
|
|
|
|
{
|
|
|
|
IXMLDOMDocument_Release(doc);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing"), &pRoot);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
if(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);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IXMLDOMDocument_get_xml(doc2, &sNew);
|
|
|
|
ok(hr == S_OK, "ret %08x\n", hr );
|
|
|
|
|
|
|
|
ok( !lstrcmpW( sOrig, sNew ), "New document is not the same as origial\n");
|
|
|
|
|
|
|
|
SysFreeString(sOrig);
|
|
|
|
SysFreeString(sNew);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
IXMLDOMDocument_Release(doc2);
|
|
|
|
IXMLDOMDocument_Release(doc);
|
|
|
|
}
|
|
|
|
|
2005-08-12 13:25:05 +02:00
|
|
|
START_TEST(domdoc)
|
|
|
|
{
|
2005-08-23 11:37:42 +02:00
|
|
|
HRESULT r;
|
|
|
|
|
|
|
|
r = CoInitialize( NULL );
|
|
|
|
ok( r == S_OK, "failed to init com\n");
|
|
|
|
|
2005-08-12 13:25:05 +02:00
|
|
|
test_domdoc();
|
2005-08-23 11:37:42 +02:00
|
|
|
test_domnode();
|
2005-11-18 16:05:26 +01:00
|
|
|
test_refs();
|
2006-01-11 21:15:12 +01:00
|
|
|
test_create();
|
2006-02-14 10:38:21 +01:00
|
|
|
test_getElementsByTagName();
|
2006-02-16 19:33:39 +01:00
|
|
|
test_get_text();
|
2006-02-23 15:10:06 +01:00
|
|
|
test_get_childNodes();
|
2006-07-10 15:48:45 +02:00
|
|
|
test_removeChild();
|
2006-12-28 03:40:46 +01:00
|
|
|
test_XMLHTTP();
|
2007-02-26 13:49:12 +01:00
|
|
|
test_IXMLDOMDocument2();
|
2007-05-11 17:03:13 +02:00
|
|
|
test_XPath();
|
2007-12-02 22:17:48 +01:00
|
|
|
test_cloneNode();
|
2008-01-03 23:17:51 +01:00
|
|
|
test_xmlTypes();
|
2008-02-20 06:03:41 +01:00
|
|
|
test_nodeTypeTests();
|
2008-03-12 11:47:17 +01:00
|
|
|
test_DocumentSaveToDocument();
|
2005-08-23 11:37:42 +02:00
|
|
|
|
|
|
|
CoUninitialize();
|
2005-08-12 13:25:05 +02:00
|
|
|
}
|