ReactOS 0.4.16-dev-2135-g2f5a67f
domdoc.c File Reference
#include <stdio.h>
#include <assert.h>
#include "windows.h"
#include "initguid.h"
#include "msxml6.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_DOMDocument60, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (void **)&doc);
333 if (hr != S_OK)
334 {
335 win_skip("class &CLSID_DOMDocument60 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_DOMDocument60, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (void **)&doc);
88 ok(hr == S_OK, "Failed to create DOMDocument60, 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 ok(hr == S_OK, "%d: unexpected hr %#lx\n", i, hr);
102 ok(!lstrcmpW(str, _bstr_(ptr->prefix)), "%d: got prefix %s, expected %s\n",
103 i, wine_dbgstr_w(str), wine_dbgstr_w(ptr->prefix));
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)) ||
116 broken(!ptr->prefix && !lstrcmpW(str, L"xmlns")), /* win7 msxml6 */
117 "%d: got uri %s, expected %s\n", i, wine_dbgstr_w(str), wine_dbgstr_w(ptr->href));
119
120 IXMLDOMNode_Release(node);
121 free_bstrs();
122
123 i++;
124 ptr++;
125 }
126
127 V_VT(&var) = VT_I1;
129 hr = IXMLDOMDocument2_createNode(doc, var, _bstr_(L"e"), NULL, &node);
130 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
131
132 hr = IXMLDOMNode_QueryInterface(node, &IID_IXMLDOMElement, (void**)&el);
133 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
134 IXMLDOMNode_Release(node);
135
136 V_VT(&var) = VT_I1;
138 hr = IXMLDOMDocument2_createNode(doc, var, _bstr_(L"xmlns:a"),
139 _bstr_(L"http://www.w3.org/2000/xmlns/"), &node);
140 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
141
142 hr = IXMLDOMElement_setAttributeNode(el, (IXMLDOMAttribute*)node, NULL);
143 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
144
145 /* for some reason default namespace uri is not reported */
146 hr = IXMLDOMNode_get_namespaceURI(node, &str);
147 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
148 ok(!lstrcmpW(str, L"http://www.w3.org/2000/xmlns/") ||
149 broken(!ptr->prefix && !lstrcmpW(str, L"xmlns")), /* win7 msxml6 */
150 "got uri %s\n", wine_dbgstr_w(str));
152
153 IXMLDOMNode_Release(node);
154 IXMLDOMElement_Release(el);
155 IXMLDOMDocument2_Release(doc);
156 free_bstrs();
157}
#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 160 of file domdoc.c.

161{
162 struct test
163 {
164 const WCHAR *xml;
165 int explen;
166 const WCHAR *names[3];
167 const WCHAR *prefixes[3];
168 const WCHAR *basenames[3];
169 const WCHAR *uris[3];
170 const WCHAR *texts[3];
171 const WCHAR *xmls[3];
172 };
173 static const struct test tests[] =
174 {
175 {
176 L"<a ns:b=\"b attr\" d=\"d attr\" xmlns:ns=\"nshref\" />", 3,
177 { L"ns:b", L"d", L"xmlns:ns" }, /* nodeName */
178 { L"ns", NULL, L"xmlns" }, /* prefix */
179 { L"b", L"d", L"ns" }, /* baseName */
180 { L"nshref", NULL, L"" }, /* namespaceURI */
181 { L"b attr", L"d attr", L"nshref" }, /* text */
182 { L"ns:b=\"b attr\"", L"d=\"d attr\"", L"xmlns:ns=\"nshref\"" }, /* xml */
183 },
184 /* property only */
185 {
186 L"<a d=\"d attr\" />", 1,
187 { L"d" }, /* nodeName */
188 { NULL }, /* prefix */
189 { L"d" }, /* baseName */
190 { NULL }, /* namespaceURI */
191 { L"d attr" }, /* text */
192 { L"d=\"d attr\"" }, /* xml */
193 },
194 /* namespace only */
195 {
196 L"<a xmlns:ns=\"nshref\" />", 1,
197 { L"xmlns:ns" }, /* nodeName */
198 { L"xmlns" }, /* prefix */
199 { L"ns" }, /* baseName */
200 { L"" }, /* namespaceURI */
201 { L"nshref" }, /* text */
202 { L"xmlns:ns=\"nshref\"" }, /* xml */
203 },
204 /* default namespace */
205 {
206 L"<a xmlns=\"nshref\" />", 1,
207 { L"xmlns" }, /* nodeName */
208 { NULL }, /* prefix */
209 { L"xmlns" }, /* baseName */
210 { L"http://www.w3.org/2000/xmlns/" }, /* namespaceURI */
211 { L"nshref" }, /* text */
212 { L"xmlns=\"nshref\"" }, /* xml */
213 },
214 /* no properties or namespaces */
215 {
216 L"<a />", 0,
217 },
218
219 { NULL }
220 };
221 const struct test *test;
224 IXMLDOMDocument2 *doc;
226 LONG len, i;
227 HRESULT hr;
228 BSTR str;
229
230 test = tests;
231 while (test->xml)
232 {
233 hr = CoCreateInstance(&CLSID_DOMDocument60, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (void **)&doc);
234 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
235
236 hr = IXMLDOMDocument2_loadXML(doc, _bstr_(test->xml), &b);
237 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
238
239 node = NULL;
240 hr = IXMLDOMDocument2_get_firstChild(doc, &node);
241 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
242
243 hr = IXMLDOMNode_get_attributes(node, &map);
244 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
245
246 len = -1;
247 hr = IXMLDOMNamedNodeMap_get_length(map, &len);
248 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
249 ok(len == test->explen, "got %ld\n", len);
250
251 item = NULL;
252 hr = IXMLDOMNamedNodeMap_get_item(map, test->explen+1, &item);
253 ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr);
254 ok(!item, "Item should be NULL\n");
255
256 for (i = 0; i < len; i++)
257 {
258 item = NULL;
259 hr = IXMLDOMNamedNodeMap_get_item(map, i, &item);
260 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
261
262 str = NULL;
263 hr = IXMLDOMNode_get_nodeName(item, &str);
264 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
265 ok(!lstrcmpW(str, test->names[i]), "got %s\n", wine_dbgstr_w(str));
267
268 str = NULL;
269 hr = IXMLDOMNode_get_prefix(item, &str);
270 if (test->prefixes[i])
271 {
272 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
273 ok(!lstrcmpW(str, test->prefixes[i]), "got %s\n", wine_dbgstr_w(str));
275 }
276 else
277 ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr );
278
279 str = NULL;
280 hr = IXMLDOMNode_get_baseName(item, &str);
281 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
282 ok(!lstrcmpW(str, test->basenames[i]), "got %s\n", wine_dbgstr_w(str));
284
285 str = NULL;
286 hr = IXMLDOMNode_get_namespaceURI(item, &str);
287 if (test->uris[i])
288 {
289 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
290 if (test->prefixes[i] && !lstrcmpW(test->prefixes[i], L"xmlns"))
291 ok(!lstrcmpW(str, L"http://www.w3.org/2000/xmlns/"),
292 "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/", NULL, L"http://www.w3.org/2000/xmlns/" },
{ L"xmlns", L"nondefaulturi", NULL, L"http://www.w3.org/2000/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"http://www.w3.org/2000/xmlns/" },
{ L"xmlns:c", L"nondefaulturi", L"xmlns", L"http://www.w3.org/2000/xmlns/" },
{ 0 }
}

Definition at line 64 of file domdoc.c.