ReactOS 0.4.16-dev-2135-g2f5a67f
domdoc.c File Reference
#include <stdio.h>
#include <assert.h>
#include "windows.h"
#include "initguid.h"
#include "msxml2.h"
#include "wine/test.h"
Include dependency graph for domdoc.c:

Go to the source code of this file.

Classes

struct  attrtest_t
 

Macros

#define COBJMACROS
 
#define CONST_VTABLE
 

Functions

static BSTR _bstr_ (const WCHAR *str)
 
static void free_bstrs (void)
 
static void test_create_attribute (void)
 
static void test_namespaces_as_attributes (void)
 
 START_TEST (domdoc)
 

Variables

static BSTR alloced_bstrs [256]
 
static int alloced_bstrs_count
 
static struct attrtest_t attrtests []
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 26 of file domdoc.c.

◆ CONST_VTABLE

#define CONST_VTABLE

Definition at line 27 of file domdoc.c.

Function Documentation

◆ _bstr_()

static BSTR _bstr_ ( const WCHAR str)
static

Definition at line 42 of file domdoc.c.

43{
47}
#define ARRAY_SIZE(A)
Definition: main.h:20
#define assert(_expr)
Definition: assert.h:32
static BSTR alloced_bstrs[256]
Definition: domdoc.c:1229
static int alloced_bstrs_count
Definition: domdoc.c:1230
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:238
const WCHAR * str

◆ free_bstrs()

static void free_bstrs ( void  )
static

Definition at line 49 of file domdoc.c.

50{
51 int i;
52 for (i = 0; i < alloced_bstrs_count; i++)
55}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:271

◆ START_TEST()

START_TEST ( domdoc  )

Definition at line 324 of file domdoc.c.

325{
326 HRESULT hr;
327 IXMLDOMDocument2 *doc;
328
330 ok(hr == S_OK, "failed to init com\n");
331
332 hr = CoCreateInstance(&CLSID_DOMDocument40, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (void **)&doc);
333 if (hr != S_OK)
334 {
335 win_skip("class &CLSID_DOMDocument40 not supported\n");
336 return;
337 }
338 IXMLDOMDocument2_Release(doc);
339
342
344}
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
#define S_OK
Definition: intsafe.h:52
#define win_skip
Definition: minitest.h:67
static void test_namespaces_as_attributes(void)
Definition: domdoc.c:13781
static void test_create_attribute(void)
Definition: domdoc.c:13397
HRESULT hr
Definition: shlfolder.c:183

◆ test_create_attribute()

static void test_create_attribute ( void  )
static

Definition at line 76 of file domdoc.c.

77{
78 struct attrtest_t *ptr = attrtests;
83 HRESULT hr;
84 int i = 0;
85 BSTR str;
86
87 hr = CoCreateInstance(&CLSID_DOMDocument40, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (void **)&doc);
88 ok(hr == S_OK, "Failed to create DOMDocument40, hr %#lx.\n", hr);
89
90 while (ptr->name)
91 {
92 V_VT(&var) = VT_I1;
94 hr = IXMLDOMDocument2_createNode(doc, var, _bstr_(ptr->name), _bstr_(ptr->uri), &node);
95 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
96
97 str = NULL;
98 hr = IXMLDOMNode_get_prefix(node, &str);
99 if (ptr->prefix)
100 {
101 /* MSXML4 can report different results with different service packs */
102 ok(hr == S_OK || broken(hr == S_FALSE), "Failed to get prefix, hr %#lx.\n", hr);
103 ok(!lstrcmpW(str, _bstr_(ptr->prefix)) || broken(!str), "got %s\n", wine_dbgstr_w(str));
104 }
105 else
106 {
107 ok(hr == S_FALSE, "%d: unexpected hr %#lx\n", i, hr);
108 ok(str == NULL, "%d: got prefix %s\n", i, wine_dbgstr_w(str));
109 }
111
112 str = NULL;
113 hr = IXMLDOMNode_get_namespaceURI(node, &str);
114 ok(hr == S_OK, "%d: unexpected hr %#lx\n", i, hr);
115 ok(!lstrcmpW(str, _bstr_(ptr->href)), "%d: got uri %s, expected %s\n",
118
119 IXMLDOMNode_Release(node);
120 free_bstrs();
121
122 i++;
123 ptr++;
124 }
125
126 V_VT(&var) = VT_I1;
128 hr = IXMLDOMDocument2_createNode(doc, var, _bstr_(L"e"), NULL, &node);
129 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
130
131 hr = IXMLDOMNode_QueryInterface(node, &IID_IXMLDOMElement, (void**)&el);
132 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
133 IXMLDOMNode_Release(node);
134
135 V_VT(&var) = VT_I1;
137 hr = IXMLDOMDocument2_createNode(doc, var, _bstr_(L"xmlns:a"),
138 _bstr_(L"http://www.w3.org/2000/xmlns/"), &node);
139 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
140
141 hr = IXMLDOMElement_setAttributeNode(el, (IXMLDOMAttribute*)node, NULL);
142 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
143
144 /* for some reason default namespace uri is not reported */
145 hr = IXMLDOMNode_get_namespaceURI(node, &str);
146 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
147 ok(!lstrcmpW(str, L""), "got uri %s\n", wine_dbgstr_w(str));
149
150 IXMLDOMNode_Release(node);
151 IXMLDOMElement_Release(el);
152 IXMLDOMDocument2_Release(doc);
153 free_bstrs();
154}
#define broken(x)
Definition: atltest.h:178
OLECHAR * BSTR
Definition: compat.h:2293
@ VT_I1
Definition: compat.h:2310
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4246
#define L(x)
Definition: resources.c:13
#define wine_dbgstr_w
Definition: kernel32.h:34
static PVOID ptr
Definition: dispmode.c:27
const char * var
Definition: shader.c:5666
static BSTR _bstr_(const char *str)
Definition: domdoc.c:1232
static struct attrtest_t attrtests[]
Definition: domdoc.c:13385
static void free_bstrs(void)
Definition: domdoc.c:1239
@ NODE_ATTRIBUTE
Definition: msxml6.idl:114
@ NODE_ELEMENT
Definition: msxml6.idl:113
#define V_I1(A)
Definition: oleauto.h:243
#define V_VT(A)
Definition: oleauto.h:211
Definition: dlist.c:348
#define S_FALSE
Definition: winerror.h:3451

◆ test_namespaces_as_attributes()

static void test_namespaces_as_attributes ( void  )
static

Definition at line 157 of file domdoc.c.

158{
159 struct test
160 {
161 const WCHAR *xml;
162 int explen;
163 const WCHAR *names[3];
164 const WCHAR *prefixes[3];
165 const WCHAR *basenames[3];
166 const WCHAR *uris[3];
167 const WCHAR *texts[3];
168 const WCHAR *xmls[3];
169 };
170 static const struct test tests[] =
171 {
172 {
173 L"<a ns:b=\"b attr\" d=\"d attr\" xmlns:ns=\"nshref\" />", 3,
174 { L"ns:b", L"d", L"xmlns:ns" }, /* nodeName */
175 { L"ns", NULL, L"xmlns" }, /* prefix */
176 { L"b", L"d", L"ns" }, /* baseName */
177 { L"nshref", NULL, L"" }, /* namespaceURI */
178 { L"b attr", L"d attr", L"nshref" }, /* text */
179 { L"ns:b=\"b attr\"", L"d=\"d attr\"", L"xmlns:ns=\"nshref\"" }, /* xml */
180 },
181 /* property only */
182 {
183 L"<a d=\"d attr\" />", 1,
184 { L"d" }, /* nodeName */
185 { NULL }, /* prefix */
186 { L"d" }, /* baseName */
187 { NULL }, /* namespaceURI */
188 { L"d attr" }, /* text */
189 { L"d=\"d attr\"" }, /* xml */
190 },
191 /* namespace only */
192 {
193 L"<a xmlns:ns=\"nshref\" />", 1,
194 { L"xmlns:ns" }, /* nodeName */
195 { L"xmlns" }, /* prefix */
196 { L"ns" }, /* baseName */
197 { L"" }, /* namespaceURI */
198 { L"nshref" }, /* text */
199 { L"xmlns:ns=\"nshref\"" }, /* xml */
200 },
201 /* default namespace */
202 {
203 L"<a xmlns=\"nshref\" />", 1,
204 { L"xmlns" }, /* nodeName */
205 { L"xmlns" }, /* prefix */
206 { L"" }, /* baseName */
207 { L"" }, /* namespaceURI */
208 { L"nshref" }, /* text */
209 { L"xmlns=\"nshref\"" }, /* xml */
210 },
211 /* no properties or namespaces */
212 {
213 L"<a />", 0,
214 },
215
216 { NULL }
217 };
218 const struct test *test;
221 IXMLDOMDocument2 *doc;
223 LONG len, i;
224 HRESULT hr;
225 BSTR str;
226
227 test = tests;
228 while (test->xml)
229 {
230 hr = CoCreateInstance(&CLSID_DOMDocument40, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (void **)&doc);
231 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
232
233 hr = IXMLDOMDocument2_loadXML(doc, _bstr_(test->xml), &b);
234 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
235
236 node = NULL;
237 hr = IXMLDOMDocument2_get_firstChild(doc, &node);
238 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
239
240 hr = IXMLDOMNode_get_attributes(node, &map);
241 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
242
243 len = -1;
244 hr = IXMLDOMNamedNodeMap_get_length(map, &len);
245 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
246 ok(len == test->explen, "got %ld\n", len);
247
248 item = NULL;
249 hr = IXMLDOMNamedNodeMap_get_item(map, test->explen+1, &item);
250 ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr);
251 ok(!item, "Item should be NULL\n");
252
253 for (i = 0; i < len; i++)
254 {
255 item = NULL;
256 hr = IXMLDOMNamedNodeMap_get_item(map, i, &item);
257 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
258
259 str = NULL;
260 hr = IXMLDOMNode_get_nodeName(item, &str);
261 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
262 ok(!lstrcmpW(str, test->names[i]), "got %s\n", wine_dbgstr_w(str));
264
265 str = NULL;
266 hr = IXMLDOMNode_get_prefix(item, &str);
267 if (test->prefixes[i])
268 {
269 /* MSXML4 can report different results with different service packs */
270 ok(hr == S_OK || broken(hr == S_FALSE), "Unexpected hr %#lx.\n", hr);
271 ok(!lstrcmpW(str, test->prefixes[i]) || broken(!str),
272 "got %s\n", wine_dbgstr_w(str));
274 }
275 else
276 ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr );
277
278 str = NULL;
279 hr = IXMLDOMNode_get_baseName(item, &str);
280 /* MSXML4 can report different results with different service packs */
281 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
282 ok(!lstrcmpW(str, test->basenames[i]) || broken(!lstrcmpW(str, L"xmlns")),
283 "got %s\n", wine_dbgstr_w(str));
285
286 str = NULL;
287 hr = IXMLDOMNode_get_namespaceURI(item, &str);
288 if (test->uris[i])
289 {
290 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
291 if (test->prefixes[i] && !lstrcmpW(test->prefixes[i], L"xmlns"))
292 ok(!lstrcmpW(str, L""), "got %s\n", wine_dbgstr_w(str));
293 else
294 ok(!lstrcmpW(str, test->uris[i]), "got %s\n", wine_dbgstr_w(str));
296 }
297 else
298 ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr );
299
300 str = NULL;
301 hr = IXMLDOMNode_get_text(item, &str);
302 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
303 ok(!lstrcmpW(str, test->texts[i]), "got %s\n", wine_dbgstr_w(str));
305
306 str = NULL;
307 hr = IXMLDOMNode_get_xml(item, &str);
308 ok(SUCCEEDED(hr), "Failed to get node xml, hr %#lx.\n", hr);
309 ok(!lstrcmpW(str, test->xmls[i]), "got %s\n", wine_dbgstr_w(str));
311
312 IXMLDOMNode_Release(item);
313 }
314
315 IXMLDOMNamedNodeMap_Release(map);
316 IXMLDOMNode_Release(node);
317 IXMLDOMDocument2_Release(doc);
318
319 test++;
320 }
321 free_bstrs();
322}
Definition: _map.h:48
short VARIANT_BOOL
Definition: compat.h:2290
GLuint GLuint * names
Definition: glext.h:11545
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLenum GLsizei len
Definition: glext.h:6722
static int prefixes
Definition: i386-dis.c:276
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define b
Definition: ke_i.h:79
static struct test_info tests[]
long LONG
Definition: pedump.c:60
#define test
Definition: rosglue.h:37
__wchar_t WCHAR
Definition: xmlstorage.h:180

Variable Documentation

◆ alloced_bstrs

BSTR alloced_bstrs[256]
static

Definition at line 39 of file domdoc.c.

◆ alloced_bstrs_count

int alloced_bstrs_count
static

Definition at line 40 of file domdoc.c.

◆ attrtests

struct attrtest_t attrtests[]
static
Initial value:
= {
{ L"xmlns", L"http://www.w3.org/2000/xmlns/", L"xmlns", L"xmlns" },
{ L"xmlns", L"nondefaulturi", L"xmlns", L"xmlns" },
{ L"c", L"http://www.w3.org/2000/xmlns/", NULL, L"http://www.w3.org/2000/xmlns/" },
{ L"c", L"nsref1", NULL, L"nsref1" },
{ L"ns:c", L"nsref1", L"ns", L"nsref1" },
{ L"xmlns:c", L"http://www.w3.org/2000/xmlns/", L"xmlns", L"" },
{ L"xmlns:c", L"nondefaulturi", L"xmlns", L"" },
{ 0 }
}

Definition at line 64 of file domdoc.c.