Reactos
at master 1552 lines 56 kB view raw
1/* 2 * Schema test 3 * 4 * Copyright 2007 Huw Davies 5 * Copyright 2010 Adam Martinson for CodeWeavers 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public 9 * License as published by the Free Software Foundation; either 10 * version 2.1 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with this library; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 20 */ 21 22#include <stdio.h> 23#include <assert.h> 24#define COBJMACROS 25 26#include "initguid.h" 27#include "windows.h" 28#include "ole2.h" 29#include "msxml2.h" 30#undef CLSID_DOMDocument 31#include "msxml2did.h" 32#include "dispex.h" 33#include "cguid.h" 34 35#include "wine/test.h" 36 37static const WCHAR xdr_schema1_uri[] = L"x-schema:test1.xdr"; 38static const WCHAR xdr_schema1_xml[] = 39L"<?xml version='1.0'?>" 40"<Schema xmlns='urn:schemas-microsoft-com:xml-data'" 41" xmlns:dt='urn:schemas-microsoft-com:datatypes'" 42" name='test1.xdr'>" 43" <ElementType name='x' dt:type='boolean'/>" 44" <ElementType name='y'>" 45" <datatype dt:type='int'/>" 46" </ElementType>" 47" <ElementType name='z'/>" 48" <ElementType name='root' content='eltOnly' model='open' order='seq'>" 49" <element type='x'/>" 50" <element type='y'/>" 51" <element type='z'/>" 52" </ElementType>" 53"</Schema>"; 54 55static const WCHAR xdr_schema2_uri[] = L"x-schema:test2.xdr"; 56static const WCHAR xdr_schema2_xml[] = 57L"<?xml version='1.0'?>" 58"<Schema xmlns='urn:schemas-microsoft-com:xml-data'" 59" xmlns:dt='urn:schemas-microsoft-com:datatypes'" 60" name='test2.xdr'>" 61" <ElementType name='x' dt:type='bin.base64'/>" 62" <ElementType name='y' dt:type='uuid'/>" 63" <ElementType name='z'/>" 64" <ElementType name='root' content='eltOnly' model='closed' order='one'>" 65" <element type='x'/>" 66" <element type='y'/>" 67" <element type='z'/>" 68" </ElementType>" 69"</Schema>"; 70 71static const WCHAR xdr_schema3_uri[] = L"x-schema:test3.xdr"; 72static const WCHAR xdr_schema3_xml[] = 73L"<?xml version='1.0'?>" 74"<Schema xmlns='urn:schemas-microsoft-com:xml-data'" 75" xmlns:dt='urn:schemas-microsoft-com:datatypes'" 76" name='test3.xdr'>" 77" <ElementType name='root' content='textOnly' model='open'>" 78" <AttributeType name='x' dt:type='int'/>" 79" <AttributeType name='y' dt:type='enumeration' dt:values='a b c'/>" 80" <AttributeType name='z' dt:type='uuid'/>" 81" <attribute type='x'/>" 82" <attribute type='y'/>" 83" <attribute type='z'/>" 84" </ElementType>" 85"</Schema>"; 86 87static const WCHAR xsd_schema1_uri[] = L"x-schema:test1.xsd"; 88 89static const WCHAR szDatatypeXDR[] = 90L"<Schema xmlns='urn:schemas-microsoft-com:xml-data'\n" 91" xmlns:dt='urn:schemas-microsoft-com:datatypes'>\n" 92" <ElementType name='base64Data' content='textOnly' dt:type='bin.base64'/>\n" 93" <ElementType name='hexData' content='textOnly' dt:type='bin.hex'/>\n" 94" <ElementType name='boolData' content='textOnly' dt:type='boolean'/>\n" 95" <ElementType name='charData' content='textOnly' dt:type='char'/>\n" 96" <ElementType name='dateData' content='textOnly' dt:type='date'/>\n" 97" <ElementType name='dateTimeData' content='textOnly' dt:type='dateTime'/>\n" 98" <ElementType name='dateTimeTzData' content='textOnly' dt:type='dateTime.tz'/>\n" 99" <ElementType name='entityData' content='textOnly' dt:type='entity'/>\n" 100" <ElementType name='entitiesData' content='textOnly' dt:type='entities'/>\n" 101" <ElementType name='fixedData' content='textOnly' dt:type='fixed.14.4'/>\n" 102" <ElementType name='floatData' content='textOnly' dt:type='float'/>\n" 103" <ElementType name='i1Data' content='textOnly' dt:type='i1'/>\n" 104" <ElementType name='i2Data' content='textOnly' dt:type='i2'/>\n" 105" <ElementType name='i4Data' content='textOnly' dt:type='i4'/>\n" 106" <ElementType name='i8Data' content='textOnly' dt:type='i8'/>\n" 107" <ElementType name='intData' content='textOnly' dt:type='int'/>\n" 108" <ElementType name='nmtokData' content='textOnly' dt:type='nmtoken'/>\n" 109" <ElementType name='nmtoksData' content='textOnly' dt:type='nmtokens'/>\n" 110" <ElementType name='numData' content='textOnly' dt:type='number'/>\n" 111" <ElementType name='r4Data' content='textOnly' dt:type='r4'/>\n" 112" <ElementType name='r8Data' content='textOnly' dt:type='r8'/>\n" 113" <ElementType name='stringData' content='textOnly' dt:type='string'/>\n" 114" <ElementType name='timeData' content='textOnly' dt:type='time'/>\n" 115" <ElementType name='timeTzData' content='textOnly' dt:type='time.tz'/>\n" 116" <ElementType name='u1Data' content='textOnly' dt:type='ui1'/>\n" 117" <ElementType name='u2Data' content='textOnly' dt:type='ui2'/>\n" 118" <ElementType name='u4Data' content='textOnly' dt:type='ui4'/>\n" 119" <ElementType name='u8Data' content='textOnly' dt:type='ui8'/>\n" 120" <ElementType name='uriData' content='textOnly' dt:type='uri'/>\n" 121" <ElementType name='uuidData' content='textOnly' dt:type='uuid'/>\n" 122"\n" 123" <ElementType name='Name' content='textOnly' dt:type='nmtoken'/>\n" 124" <ElementType name='Value' content='eltOnly' order='many'>\n" 125" <element type='base64Data'/>\n" 126" <element type='hexData'/>\n" 127" <element type='boolData'/>\n" 128" <element type='charData'/>\n" 129" <element type='dateData'/>\n" 130" <element type='dateTimeData'/>\n" 131" <element type='dateTimeTzData'/>\n" 132" <element type='entityData'/>\n" 133" <element type='entitiesData'/>\n" 134" <element type='fixedData'/>\n" 135" <element type='floatData'/>\n" 136" <element type='i1Data'/>\n" 137" <element type='i2Data'/>\n" 138" <element type='i4Data'/>\n" 139" <element type='i8Data'/>\n" 140" <element type='intData'/>\n" 141" <element type='nmtokData'/>\n" 142" <element type='nmtoksData'/>\n" 143" <element type='numData'/>\n" 144" <element type='r4Data'/>\n" 145" <element type='r8Data'/>\n" 146" <element type='stringData'/>\n" 147" <element type='timeData'/>\n" 148" <element type='timeTzData'/>\n" 149" <element type='u1Data'/>\n" 150" <element type='u2Data'/>\n" 151" <element type='u4Data'/>\n" 152" <element type='u8Data'/>\n" 153" <element type='uriData'/>\n" 154" <element type='uuidData'/>\n" 155" </ElementType>\n" 156" <ElementType name='Property' content='eltOnly' order='seq'>\n" 157" <element type='Name'/>\n" 158" <element type='Value'/>\n" 159" </ElementType>\n" 160" <ElementType name='Properties' content='eltOnly'>\n" 161" <element type='Property' minOccurs='0' maxOccurs='*'/>\n" 162" </ElementType>\n" 163"</Schema>"; 164 165static const WCHAR szDatatypeXML[] = 166L"<?xml version='1.0'?>\n" 167"<Properties xmlns='urn:x-schema:datatype-test-xdr'>\n" 168" <Property>\n" 169" <Name>testBase64</Name>\n" 170" <Value>\n" 171" <base64Data>+HugeNumber+</base64Data>\n" 172" </Value>\n" 173" </Property>\n" 174" <Property>\n" 175" <Name>testHex</Name>\n" 176" <Value>\n" 177" <hexData>deadbeef</hexData>\n" 178" </Value>\n" 179" </Property>\n" 180" <Property>\n" 181" <Name>testBool</Name>\n" 182" <Value>\n" 183" <boolData>1</boolData>\n" 184" </Value>\n" 185" </Property>\n" 186" <Property>\n" 187" <Name>testChar</Name>\n" 188" <Value>\n" 189" <charData>u</charData>\n" 190" </Value>\n" 191" </Property>\n" 192" <Property>\n" 193" <Name>testDate</Name>\n" 194" <Value>\n" 195" <dateData>1998-02-01</dateData>\n" 196" </Value>\n" 197" </Property>\n" 198" <Property>\n" 199" <Name>testDateTime</Name>\n" 200" <Value>\n" 201" <dateTimeData>1998-02-01T12:34:56</dateTimeData>\n" 202" </Value>\n" 203" </Property>\n" 204" <Property>\n" 205" <Name>testDateTimeTz</Name>\n" 206" <Value>\n" 207" <dateTimeTzData>1998-02-01T12:34:56-06:00</dateTimeTzData>\n" 208" </Value>\n" 209" </Property>\n" 210" <Property>\n" 211" <Name>testFixed</Name>\n" 212" <Value>\n" 213" <fixedData>3.1416</fixedData>\n" 214" </Value>\n" 215" </Property>\n" 216" <Property>\n" 217" <Name>testFloat</Name>\n" 218" <Value>\n" 219" <floatData>3.14159</floatData>\n" 220" </Value>\n" 221" </Property>\n" 222" <Property>\n" 223" <Name>testI1</Name>\n" 224" <Value>\n" 225" <i1Data>42</i1Data>\n" 226" </Value>\n" 227" </Property>\n" 228" <Property>\n" 229" <Name>testI2</Name>\n" 230" <Value>\n" 231" <i2Data>420</i2Data>\n" 232" </Value>\n" 233" </Property>\n" 234" <Property>\n" 235" <Name>testI4</Name>\n" 236" <Value>\n" 237" <i4Data>-420000000</i4Data>\n" 238" </Value>\n" 239" </Property>\n" 240" <Property>\n" 241" <Name>testI8</Name>\n" 242" <Value>\n" 243" <i8Data>-4200000000</i8Data>\n" 244" </Value>\n" 245" </Property>\n" 246" <Property>\n" 247" <Name>testInt</Name>\n" 248" <Value>\n" 249" <intData>42</intData>\n" 250" </Value>\n" 251" </Property>\n" 252" <Property>\n" 253" <Name>testNmtoken</Name>\n" 254" <Value>\n" 255" <nmtokData>tok1</nmtokData>\n" 256" </Value>\n" 257" </Property>\n" 258" <Property>\n" 259" <Name>testNmtokens</Name>\n" 260" <Value>\n" 261" <nmtoksData>tok1 tok2 tok3</nmtoksData>\n" 262" </Value>\n" 263" </Property>\n" 264" <Property>\n" 265" <Name>testNumber</Name>\n" 266" <Value>\n" 267" <numData>3.14159</numData>\n" 268" </Value>\n" 269" </Property>\n" 270" <Property>\n" 271" <Name>testR4</Name>\n" 272" <Value>\n" 273" <r4Data>3.14159265</r4Data>\n" 274" </Value>\n" 275" </Property>\n" 276" <Property>\n" 277" <Name>testR8</Name>\n" 278" <Value>\n" 279" <r8Data>3.14159265358979323846</r8Data>\n" 280" </Value>\n" 281" </Property>\n" 282" <Property>\n" 283" <Name>testString</Name>\n" 284" <Value>\n" 285" <stringData>foo bar</stringData>\n" 286" </Value>\n" 287" </Property>\n" 288" <Property>\n" 289" <Name>testTime</Name>\n" 290" <Value>\n" 291" <timeData>12:34:56</timeData>\n" 292" </Value>\n" 293" </Property>\n" 294" <Property>\n" 295" <Name>testTimeTz</Name>\n" 296" <Value>\n" 297" <timeTzData>12:34:56-06:00</timeTzData>\n" 298" </Value>\n" 299" </Property>\n" 300" <Property>\n" 301" <Name>testU1</Name>\n" 302" <Value>\n" 303" <u1Data>255</u1Data>\n" 304" </Value>\n" 305" </Property>\n" 306" <Property>\n" 307" <Name>testU2</Name>\n" 308" <Value>\n" 309" <u2Data>65535</u2Data>\n" 310" </Value>\n" 311" </Property>\n" 312" <Property>\n" 313" <Name>testU4</Name>\n" 314" <Value>\n" 315" <u4Data>4294967295</u4Data>\n" 316" </Value>\n" 317" </Property>\n" 318" <Property>\n" 319" <Name>testU8</Name>\n" 320" <Value>\n" 321" <u8Data>18446744073709551615</u8Data>\n" 322" </Value>\n" 323" </Property>\n" 324" <Property>\n" 325" <Name>testURI</Name>\n" 326" <Value>\n" 327" <uriData>urn:schemas-microsoft-com:datatypes</uriData>\n" 328" </Value>\n" 329" </Property>\n" 330" <Property>\n" 331" <Name>testUUID</Name>\n" 332" <Value>\n" 333" <uuidData>2933BF81-7B36-11D2-B20E-00C04F983E60</uuidData>\n" 334" </Value>\n" 335" </Property>\n" 336"</Properties>"; 337 338static const WCHAR szOpenSeqXDR[] = 339L"<Schema xmlns='urn:schemas-microsoft-com:xml-data'>\n" 340" <ElementType name='w' content='empty' model='closed'/>\n" 341" <ElementType name='x' content='empty' model='closed'/>\n" 342" <ElementType name='y' content='empty' model='closed'/>\n" 343" <ElementType name='z' content='empty' model='closed'/>\n" 344" <ElementType name='test' content='eltOnly' model='open' order='seq'>\n" 345" <element type='x'/>\n" 346" <group order='seq'>\n" 347" <element type='x'/>\n" 348" <element type='y'/>\n" 349" <element type='z'/>\n" 350" </group>\n" 351" <element type='z'/>\n" 352" </ElementType>\n" 353"</Schema>"; 354 355static const WCHAR szOpenSeqXML1[] = L"<test><x/><x/><y/><z/><z/></test>"; 356static const WCHAR szOpenSeqXML2[] = L"<test><x/><x/><y/><z/><z/><w/></test>"; 357static const WCHAR szOpenSeqXML3[] = L"<test><w/><x/><x/><y/><z/><z/></test>"; 358static const WCHAR szOpenSeqXML4[] = L"<test><x/><x/><y/><z/><z/><v/></test>"; 359 360static ULONG get_refcount(void *iface) 361{ 362 IUnknown_AddRef((IUnknown *)iface); 363 return IUnknown_Release((IUnknown *)iface); 364} 365 366#define _expect64(expr, str, base, TYPE, CONV) { \ 367 TYPE v1 = expr; \ 368 TYPE v2 = CONV(str, NULL, base); \ 369 ok(v1 == v2, #expr "returned %s, expected %s\n", \ 370 wine_dbgstr_longlong(v1), wine_dbgstr_longlong(v2)); \ 371} 372 373#define expect_int64(expr, x, base) _expect64(expr, #x, base, LONG64, strtoll) 374#define expect_uint64(expr, x, base) _expect64(expr, #x, base, ULONG64, strtoull) 375 376static BSTR alloced_bstrs[256]; 377static int alloced_bstrs_count; 378 379static BSTR _bstr_(const WCHAR *str) 380{ 381 assert(alloced_bstrs_count < ARRAY_SIZE(alloced_bstrs)); 382 alloced_bstrs[alloced_bstrs_count] = SysAllocString(str); 383 return alloced_bstrs[alloced_bstrs_count++]; 384} 385 386static void free_bstrs(void) 387{ 388 int i; 389 for (i = 0; i < alloced_bstrs_count; i++) 390 SysFreeString(alloced_bstrs[i]); 391 alloced_bstrs_count = 0; 392} 393 394static VARIANT _variantdoc_(void* doc) 395{ 396 VARIANT v; 397 V_VT(&v) = VT_DISPATCH; 398 V_DISPATCH(&v) = (IDispatch*)doc; 399 return v; 400} 401 402static void* _create_object(const GUID *clsid, const char *name, const IID *iid, int line) 403{ 404 void *obj = NULL; 405 HRESULT hr; 406 407 hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, iid, &obj); 408 if (hr != S_OK) 409 win_skip_(__FILE__,line)("failed to create %s instance: hr %#lx.\n", name, hr); 410 411 return obj; 412} 413 414#define _create(cls) cls, #cls 415 416#define create_document(iid) _create_object(&_create(CLSID_DOMDocument), iid, __LINE__) 417 418#define create_document_version(v, iid) _create_object(&_create(CLSID_DOMDocument ## v), iid, __LINE__) 419 420#define create_cache(iid) _create_object(&_create(CLSID_XMLSchemaCache), iid, __LINE__) 421 422#define create_cache_version(v, iid) _create_object(&_create(CLSID_XMLSchemaCache ## v), iid, __LINE__) 423 424static void test_schema_refs(void) 425{ 426 static const WCHAR xdr_schema_xml[] = 427 L"<Schema xmlns=\"urn:schemas-microsoft-com:xml-data\"\nxmlns:dt=\"urn:schemas-microsoft-com:datatypes\">\n</Schema>\n"; 428 IXMLDOMDocument2 *doc; 429 IXMLDOMNode *node; 430 IXMLDOMSchemaCollection *cache; 431 LONG len, refcount; 432 VARIANT v; 433 VARIANT_BOOL b; 434 BSTR str; 435 HRESULT hr; 436 437 doc = create_document(&IID_IXMLDOMDocument2); 438 if (!doc) 439 return; 440 441 cache = create_cache(&IID_IXMLDOMSchemaCollection); 442 if(!cache) 443 { 444 IXMLDOMDocument2_Release(doc); 445 return; 446 } 447 448 VariantInit(&v); 449 str = SysAllocString(xdr_schema_xml); 450 hr = IXMLDOMDocument2_loadXML(doc, str, &b); 451 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 452 ok(b == VARIANT_TRUE, "b %04x\n", b); 453 SysFreeString(str); 454 455 node = (void*)0xdeadbeef; 456 hr = IXMLDOMSchemaCollection_get(cache, NULL, &node); 457 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 458 ok(node == NULL, "%p\n", node); 459 460 /* NULL uri pointer, still adds a document */ 461 hr = IXMLDOMSchemaCollection_add(cache, NULL, _variantdoc_(doc)); 462 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 463 len = -1; 464 hr = IXMLDOMSchemaCollection_get_length(cache, &len); 465 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 466 ok(len == 1, "Unexpected length %ld.\n", len); 467 /* read back - empty valid BSTR */ 468 str = NULL; 469 hr = IXMLDOMSchemaCollection_get_namespaceURI(cache, 0, &str); 470 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 471 ok(str && *str == 0, "got %p\n", str); 472 SysFreeString(str); 473 474 node = NULL; 475 hr = IXMLDOMSchemaCollection_get(cache, NULL, &node); 476 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 477 ok(node != NULL, "%p\n", node); 478 IXMLDOMNode_Release(node); 479 480 node = NULL; 481 str = SysAllocString(L""); 482 hr = IXMLDOMSchemaCollection_get(cache, str, &node); 483 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 484 ok(node != NULL, "%p\n", node); 485 IXMLDOMNode_Release(node); 486 SysFreeString(str); 487 488 /* remove with NULL uri */ 489 hr = IXMLDOMSchemaCollection_remove(cache, NULL); 490 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 491 len = -1; 492 hr = IXMLDOMSchemaCollection_get_length(cache, &len); 493 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 494 ok(len == 0, "Unexpected length %ld.\n", len); 495 496 /* same, but with VT_UNKNOWN type */ 497 V_VT(&v) = VT_UNKNOWN; 498 V_UNKNOWN(&v) = (IUnknown*)doc; 499 hr = IXMLDOMSchemaCollection_add(cache, NULL, v); 500 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 501 502 len = -1; 503 hr = IXMLDOMSchemaCollection_get_length(cache, &len); 504 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 505 ok(len == 1, "Unexpected length %ld.\n", len); 506 507 hr = IXMLDOMSchemaCollection_remove(cache, NULL); 508 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 509 len = -1; 510 hr = IXMLDOMSchemaCollection_get_length(cache, &len); 511 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 512 ok(len == 0, "Unexpected length %ld.\n", len); 513 514 str = SysAllocString(L"x-schema:test.xml"); 515 hr = IXMLDOMSchemaCollection_add(cache, str, _variantdoc_(doc)); 516 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 517 518 /* IXMLDOMSchemaCollection_add doesn't add a ref on doc */ 519 refcount = get_refcount(doc); 520 ok(refcount == 1, "Unexpected refcount %ld.\n", refcount); 521 522 SysFreeString(str); 523 524 V_VT(&v) = VT_INT; 525 hr = IXMLDOMDocument2_get_schemas(doc, &v); 526 ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr); 527 ok(V_VT(&v) == VT_NULL, "vt %x\n", V_VT(&v)); 528 529 refcount = IXMLDOMSchemaCollection_AddRef(cache); 530 ok(refcount == 2, "Unexpected refcount %ld.\n", refcount); 531 V_VT(&v) = VT_DISPATCH; 532 V_DISPATCH(&v) = (IDispatch*)cache; 533 534 /* check that putref_schemas takes a ref */ 535 hr = IXMLDOMDocument2_putref_schemas(doc, v); 536 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 537 refcount = get_refcount(cache); 538 ok(refcount == 3, "Unexpected refcount %ld.\n", refcount); 539 540 VariantClear(&v); /* refs now 2 */ 541 542 V_VT(&v) = VT_INT; 543 /* check that get_schemas adds a ref */ 544 hr = IXMLDOMDocument2_get_schemas(doc, &v); 545 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 546 ok(V_VT(&v) == VT_DISPATCH, "vt %x\n", V_VT(&v)); 547 refcount = get_refcount(cache); 548 ok(refcount == 3, "Unexpected refcount %ld.\n", refcount); 549 550 /* get_schemas doesn't release a ref if passed VT_DISPATCH - ie it doesn't call VariantClear() */ 551 hr = IXMLDOMDocument2_get_schemas(doc, &v); 552 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 553 ok(V_VT(&v) == VT_DISPATCH, "vt %x\n", V_VT(&v)); 554 refcount = get_refcount(cache); 555 ok(refcount == 4, "Unexpected refcount %ld.\n", refcount); 556 557 /* release the two refs returned by get_schemas */ 558 refcount = IXMLDOMSchemaCollection_Release(cache); 559 ok(refcount == 3, "Unexpected refcount %ld.\n", refcount); 560 refcount = IXMLDOMSchemaCollection_Release(cache); 561 ok(refcount == 2, "Unexpected refcount %ld.\n", refcount); 562 563 /* check that taking another ref on the document doesn't change the schema's ref count */ 564 refcount = IXMLDOMDocument2_AddRef(doc); 565 ok(refcount == 2, "Unexpected refcount %ld.\n", refcount); 566 refcount = get_refcount(cache); 567 ok(refcount == 2, "Unexpected refcount %ld.\n", refcount); 568 refcount = IXMLDOMDocument2_Release(doc); 569 ok(refcount == 1, "Unexpected refcount %ld.\n", refcount); 570 571 /* call putref_schema with some odd variants */ 572 V_VT(&v) = VT_INT; 573 hr = IXMLDOMDocument2_putref_schemas(doc, v); 574 ok(hr == E_FAIL, "Unexpected hr %#lx.\n", hr); 575 refcount = get_refcount(cache); 576 ok(refcount == 2, "Unexpected refcount %ld.\n", refcount); 577 578 /* calling with VT_EMPTY releases the schema */ 579 V_VT(&v) = VT_EMPTY; 580 hr = IXMLDOMDocument2_putref_schemas(doc, v); 581 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 582 refcount = get_refcount(cache); 583 ok(refcount == 1, "Unexpected refcount %ld.\n", refcount); 584 585 /* try setting with VT_UNKNOWN */ 586 refcount = IXMLDOMSchemaCollection_AddRef(cache); 587 ok(refcount == 2, "Unexpected refcount %ld.\n", refcount); 588 V_VT(&v) = VT_UNKNOWN; 589 V_UNKNOWN(&v) = (IUnknown*)cache; 590 hr = IXMLDOMDocument2_putref_schemas(doc, v); 591 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 592 refcount = get_refcount(cache); 593 ok(refcount == 3, "Unexpected refcount %ld.\n", refcount); 594 595 VariantClear(&v); /* refs now 2 */ 596 597 /* calling with VT_NULL releases the schema */ 598 V_VT(&v) = VT_NULL; 599 hr = IXMLDOMDocument2_putref_schemas(doc, v); 600 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 601 refcount = get_refcount(cache); 602 ok(refcount == 1, "Unexpected refcount %ld.\n", refcount); 603 604 /* refs now 1 */ 605 /* set again */ 606 refcount = IXMLDOMSchemaCollection_AddRef(cache); 607 ok(refcount == 2, "Unexpected refcount %ld.\n", refcount); 608 V_VT(&v) = VT_UNKNOWN; 609 V_UNKNOWN(&v) = (IUnknown*)cache; 610 hr = IXMLDOMDocument2_putref_schemas(doc, v); 611 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 612 refcount = get_refcount(cache); 613 ok(refcount == 3, "Unexpected refcount %ld.\n", refcount); 614 615 VariantClear(&v); /* refs now 2 */ 616 617 /* release the final ref on the doc which should release its ref on the schema */ 618 refcount = IXMLDOMDocument2_Release(doc); 619 ok(!refcount, "Unexpected refcount %ld.\n", refcount); 620 621 refcount = get_refcount(cache); 622 ok(refcount == 1, "Unexpected refcount %ld.\n", refcount); 623 refcount = IXMLDOMSchemaCollection_Release(cache); 624 ok(!refcount, "Unexpected refcount %ld.\n", refcount); 625} 626 627static void test_collection_refs(void) 628{ 629 IXMLDOMDocument2 *schema1, *schema2, *schema3; 630 IXMLDOMSchemaCollection *cache1, *cache2, *cache3; 631 LONG refcount, length; 632 VARIANT_BOOL b; 633 HRESULT hr; 634 635 schema1 = create_document(&IID_IXMLDOMDocument2); 636 ok(schema1 != NULL, "Failed to create a document.\n"); 637 638 cache1 = create_cache(&IID_IXMLDOMSchemaCollection); 639 ok(cache1 != NULL, "Failed to create schema collection.\n"); 640 641 if (!schema1 || !cache1) 642 { 643 if (schema1) 644 IXMLDOMDocument2_Release(schema1); 645 if (cache1) 646 IXMLDOMSchemaCollection_Release(cache1); 647 return; 648 } 649 650 schema2 = create_document(&IID_IXMLDOMDocument2); 651 schema3 = create_document(&IID_IXMLDOMDocument2); 652 653 cache2 = create_cache(&IID_IXMLDOMSchemaCollection); 654 cache3 = create_cache(&IID_IXMLDOMSchemaCollection); 655 656 hr = IXMLDOMDocument2_loadXML(schema1, _bstr_(xdr_schema1_xml), &b); 657 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 658 ok(b == VARIANT_TRUE, "failed to load XML\n"); 659 660 hr = IXMLDOMDocument2_loadXML(schema2, _bstr_(xdr_schema2_xml), &b); 661 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 662 ok(b == VARIANT_TRUE, "failed to load XML\n"); 663 664 hr = IXMLDOMDocument2_loadXML(schema3, _bstr_(xdr_schema3_xml), &b); 665 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 666 ok(b == VARIANT_TRUE, "failed to load XML\n"); 667 668 hr = IXMLDOMSchemaCollection_add(cache1, _bstr_(xdr_schema1_uri), _variantdoc_(schema1)); 669 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 670 hr = IXMLDOMSchemaCollection_add(cache2, _bstr_(xdr_schema2_uri), _variantdoc_(schema2)); 671 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 672 hr = IXMLDOMSchemaCollection_add(cache3, _bstr_(xdr_schema3_uri), _variantdoc_(schema3)); 673 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 674 675 refcount = IXMLDOMDocument2_Release(schema1); 676 ok(!refcount, "Unexpected refcount %ld.\n", refcount); 677 refcount = IXMLDOMDocument2_Release(schema2); 678 ok(!refcount, "Unexpected refcount %ld.\n", refcount); 679 refcount = IXMLDOMDocument2_Release(schema3); 680 ok(!refcount, "Unexpected refcount %ld.\n", refcount); 681 schema1 = NULL; 682 schema2 = NULL; 683 schema3 = NULL; 684 685 /* releasing the original doc does not affect the schema cache */ 686 hr = IXMLDOMSchemaCollection_get(cache1, _bstr_(xdr_schema1_uri), (IXMLDOMNode**)&schema1); 687 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 688 hr = IXMLDOMSchemaCollection_get(cache2, _bstr_(xdr_schema2_uri), (IXMLDOMNode**)&schema2); 689 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 690 hr = IXMLDOMSchemaCollection_get(cache3, _bstr_(xdr_schema3_uri), (IXMLDOMNode**)&schema3); 691 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 692 693 /* we get a read-only domdoc interface, created just for us */ 694 if (schema1) 695 { 696 refcount = get_refcount(schema1); 697 ok(refcount == 1, "Unexpected refcount %ld.\n", refcount); 698 } 699 700 if (schema2) 701 { 702 refcount = get_refcount(schema2); 703 ok(refcount == 1, "Unexpected refcount %ld.\n", refcount); 704 } 705 706 if (schema3) 707 { 708 refcount = get_refcount(schema3); 709 ok(refcount == 1, "Unexpected refcount %ld.\n", refcount); 710 } 711 712 hr = IXMLDOMSchemaCollection_addCollection(cache1, NULL); 713 ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr); 714 hr = IXMLDOMSchemaCollection_addCollection(cache2, cache1); 715 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 716 hr = IXMLDOMSchemaCollection_addCollection(cache3, cache2); 717 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 718 719 length = -1; 720 hr = IXMLDOMSchemaCollection_get_length(cache1, &length); 721 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 722 ok(length == 1, "Unexpected length %ld.\n", length); 723 724 length = -1; 725 hr = IXMLDOMSchemaCollection_get_length(cache2, &length); 726 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 727 ok(length == 2, "Unexpected length %ld.\n", length); 728 729 length = -1; 730 hr = IXMLDOMSchemaCollection_get_length(cache3, &length); 731 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 732 ok(length == 3, "Unexpected length %ld.\n", length); 733 734 /* merging collections does not affect the ref count */ 735 refcount = get_refcount(cache1); 736 ok(refcount == 1, "Unexpected refcount %ld.\n", refcount); 737 refcount = get_refcount(cache2); 738 ok(refcount == 1, "Unexpected refcount %ld.\n", refcount); 739 refcount = get_refcount(cache3); 740 ok(refcount == 1, "Unexpected refcount %ld.\n", refcount); 741 742 /* nor does it affect the domdoc instances */ 743 if (schema1) 744 { 745 refcount = IXMLDOMDocument2_Release(schema1); 746 ok(!refcount, "Unexpected refcount %ld.\n", refcount); 747 } 748 749 if (schema2) 750 { 751 refcount = IXMLDOMDocument2_Release(schema2); 752 ok(!refcount, "Unexpected refcount %ld.\n", refcount); 753 } 754 755 if (schema3) 756 { 757 refcount = IXMLDOMDocument2_Release(schema3); 758 ok(!refcount, "Unexpected refcount %ld.\n", refcount); 759 } 760 761 schema1 = NULL; 762 schema2 = NULL; 763 schema3 = NULL; 764 765 /* releasing the domdoc instances doesn't change the cache */ 766 hr = IXMLDOMSchemaCollection_get(cache1, _bstr_(xdr_schema1_uri), (IXMLDOMNode**)&schema1); 767 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 768 hr = IXMLDOMSchemaCollection_get(cache2, _bstr_(xdr_schema2_uri), (IXMLDOMNode**)&schema2); 769 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 770 hr = IXMLDOMSchemaCollection_get(cache3, _bstr_(xdr_schema3_uri), (IXMLDOMNode**)&schema3); 771 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 772 773 /* we can just get them again */ 774 if (schema1) 775 { 776 refcount = get_refcount(schema1); 777 ok(refcount == 1, "Unexpected refcount %ld.\n", refcount); 778 } 779 780 if (schema2) 781 { 782 refcount = get_refcount(schema2); 783 ok(refcount == 1, "Unexpected refcount %ld.\n", refcount); 784 } 785 786 if (schema3) 787 { 788 refcount = get_refcount(schema3); 789 ok(refcount == 1, "Unexpected refcount %ld.\n", refcount); 790 } 791 792 /* releasing the caches does not affect the domdoc instances */ 793 refcount = IXMLDOMSchemaCollection_Release(cache1); 794 ok(!refcount, "Unexpected refcount %ld.\n", refcount); 795 refcount = IXMLDOMSchemaCollection_Release(cache2); 796 ok(!refcount, "Unexpected refcount %ld.\n", refcount); 797 refcount = IXMLDOMSchemaCollection_Release(cache3); 798 ok(!refcount, "Unexpected refcount %ld.\n", refcount); 799 800 /* they're just for us */ 801 if (schema1) 802 { 803 refcount = IXMLDOMDocument2_Release(schema1); 804 ok(!refcount, "Unexpected refcount %ld.\n", refcount); 805 } 806 if (schema2) 807 { 808 refcount = IXMLDOMDocument2_Release(schema2); 809 ok(!refcount, "Unexpected refcount %ld.\n", refcount); 810 } 811 if (schema3) 812 { 813 refcount = IXMLDOMDocument2_Release(schema3); 814 ok(!refcount, "Unexpected refcount %ld.\n", refcount); 815 } 816 817 free_bstrs(); 818} 819 820static void test_length(void) 821{ 822 IXMLDOMDocument2 *schema1, *schema2, *schema3; 823 IXMLDOMSchemaCollection *cache; 824 VARIANT_BOOL b; 825 HRESULT hr; 826 VARIANT v; 827 LONG length; 828 829 schema1 = create_document(&IID_IXMLDOMDocument2); 830 schema2 = create_document(&IID_IXMLDOMDocument2); 831 schema3 = create_document(&IID_IXMLDOMDocument2); 832 833 cache = create_cache(&IID_IXMLDOMSchemaCollection); 834 835 if (!schema1 || !schema2 || !schema3 || !cache) 836 { 837 if (schema1) IXMLDOMDocument2_Release(schema1); 838 if (schema2) IXMLDOMDocument2_Release(schema2); 839 if (schema3) IXMLDOMDocument2_Release(schema3); 840 841 if (cache) IXMLDOMSchemaCollection_Release(cache); 842 843 return; 844 } 845 846 VariantInit(&v); 847 848 hr = IXMLDOMDocument2_loadXML(schema1, _bstr_(xdr_schema1_xml), &b); 849 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 850 ok(b == VARIANT_TRUE, "failed to load XML\n"); 851 852 hr = IXMLDOMDocument2_loadXML(schema2, _bstr_(xdr_schema2_xml), &b); 853 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 854 ok(b == VARIANT_TRUE, "failed to load XML\n"); 855 856 hr = IXMLDOMDocument2_loadXML(schema3, _bstr_(xdr_schema3_xml), &b); 857 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 858 ok(b == VARIANT_TRUE, "failed to load XML\n"); 859 860 hr = IXMLDOMSchemaCollection_get_length(cache, NULL); 861 ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr); 862 863 /* MSDN lies; removing a nonexistent entry produces no error */ 864 hr = IXMLDOMSchemaCollection_remove(cache, NULL); 865 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 866 hr = IXMLDOMSchemaCollection_remove(cache, _bstr_(xdr_schema1_uri)); 867 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 868 869 length = -1; 870 hr = IXMLDOMSchemaCollection_get_length(cache, &length); 871 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 872 ok(length == 0, "Unexpected length %ld.\n", length); 873 874 hr = IXMLDOMSchemaCollection_add(cache, _bstr_(xdr_schema1_uri), _variantdoc_(schema1)); 875 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 876 877 length = -1; 878 hr = IXMLDOMSchemaCollection_get_length(cache, &length); 879 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 880 ok(length == 1, "Unexpected length %ld.\n", length); 881 882 hr = IXMLDOMSchemaCollection_add(cache, _bstr_(xdr_schema2_uri), _variantdoc_(schema2)); 883 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 884 885 length = -1; 886 hr = IXMLDOMSchemaCollection_get_length(cache, &length); 887 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 888 ok(length == 2, "Unexpected length %ld.\n", length); 889 890 hr = IXMLDOMSchemaCollection_add(cache, _bstr_(xdr_schema3_uri), _variantdoc_(schema3)); 891 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 892 893 length = -1; 894 hr = IXMLDOMSchemaCollection_get_length(cache, &length); 895 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 896 ok(length == 3, "Unexpected length %ld.\n", length); 897 898 /* adding with VT_NULL is the same as removing */ 899 V_VT(&v) = VT_NULL; 900 hr = IXMLDOMSchemaCollection_add(cache, _bstr_(xdr_schema1_uri), v); 901 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 902 903 length = -1; 904 hr = IXMLDOMSchemaCollection_get_length(cache, &length); 905 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 906 ok(length == 2, "Unexpected length %ld.\n", length); 907 908 hr = IXMLDOMSchemaCollection_remove(cache, _bstr_(xdr_schema2_uri)); 909 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 910 911 length = -1; 912 hr = IXMLDOMSchemaCollection_get_length(cache, &length); 913 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 914 ok(length == 1, "Unexpected length %ld.\n", length); 915 916 hr = IXMLDOMSchemaCollection_remove(cache, _bstr_(xdr_schema3_uri)); 917 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 918 919 length = -1; 920 hr = IXMLDOMSchemaCollection_get_length(cache, &length); 921 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 922 ok(length == 0, "Unexpected length %ld.\n", length); 923 924 IXMLDOMDocument2_Release(schema1); 925 IXMLDOMDocument2_Release(schema2); 926 IXMLDOMDocument2_Release(schema3); 927 IXMLDOMSchemaCollection_Release(cache); 928 929 free_bstrs(); 930} 931 932static void test_collection_content(void) 933{ 934 IXMLDOMDocument2 *schema1, *schema2, *schema3; 935 BSTR content[5] = {NULL, NULL, NULL, NULL, NULL}; 936 IXMLDOMSchemaCollection *cache1; 937 VARIANT_BOOL b; 938 LONG length; 939 HRESULT hr; 940 BSTR bstr; 941 int i, j; 942 943 schema1 = create_document_version(30, &IID_IXMLDOMDocument2); 944 schema2 = create_document_version(30, &IID_IXMLDOMDocument2); 945 schema3 = create_document_version(30, &IID_IXMLDOMDocument2); 946 947 cache1 = create_cache_version(30, &IID_IXMLDOMSchemaCollection); 948 949 if (!schema1 || !schema2 || !schema3 || !cache1) 950 { 951 if (schema1) IXMLDOMDocument2_Release(schema1); 952 if (schema2) IXMLDOMDocument2_Release(schema2); 953 if (schema3) IXMLDOMDocument2_Release(schema3); 954 955 if (cache1) IXMLDOMSchemaCollection_Release(cache1); 956 957 return; 958 } 959 960 hr = IXMLDOMDocument2_loadXML(schema1, _bstr_(xdr_schema1_xml), &b); 961 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 962 ok(b == VARIANT_TRUE, "failed to load XML\n"); 963 964 hr = IXMLDOMDocument2_loadXML(schema2, _bstr_(xdr_schema2_xml), &b); 965 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 966 ok(b == VARIANT_TRUE, "failed to load XML\n"); 967 968 hr = IXMLDOMDocument2_loadXML(schema3, _bstr_(xdr_schema3_xml), &b); 969 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 970 ok(b == VARIANT_TRUE, "failed to load XML\n"); 971 972 hr = IXMLDOMSchemaCollection_add(cache1, _bstr_(xdr_schema1_uri), _variantdoc_(schema1)); 973 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 974 hr = IXMLDOMSchemaCollection_add(cache1, _bstr_(xdr_schema2_uri), _variantdoc_(schema2)); 975 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 976 hr = IXMLDOMSchemaCollection_add(cache1, _bstr_(xdr_schema3_uri), _variantdoc_(schema3)); 977 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 978 979 length = -1; 980 hr = IXMLDOMSchemaCollection_get_length(cache1, &length); 981 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 982 ok(length == 3, "Unexpected length %ld.\n", length); 983 984 IXMLDOMDocument2_Release(schema1); 985 IXMLDOMDocument2_Release(schema2); 986 IXMLDOMDocument2_Release(schema3); 987 988 bstr = (void*)0xdeadbeef; 989 /* error if index is out of range */ 990 hr = IXMLDOMSchemaCollection_get_namespaceURI(cache1, 3, &bstr); 991 ok(hr == E_FAIL, "Unexpected hr %#lx.\n", hr); 992 ok(bstr == (void*)0xdeadbeef, "got %p\n", bstr); 993 /* error if return pointer is NULL */ 994 hr = IXMLDOMSchemaCollection_get_namespaceURI(cache1, 0, NULL); 995 ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr); 996 /* pointer is checked first */ 997 hr = IXMLDOMSchemaCollection_get_namespaceURI(cache1, 3, NULL); 998 ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr); 999 1000 schema1 = NULL; 1001 /* no error if ns uri does not exist */ 1002 hr = IXMLDOMSchemaCollection_get(cache1, _bstr_(xsd_schema1_uri), (IXMLDOMNode**)&schema1); 1003 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 1004 ok(!schema1, "expected NULL\n"); 1005 /* a NULL bstr corresponds to no-uri ns */ 1006 hr = IXMLDOMSchemaCollection_get(cache1, NULL, (IXMLDOMNode**)&schema1); 1007 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 1008 ok(!schema1, "expected NULL\n"); 1009 /* error if return pointer is NULL */ 1010 hr = IXMLDOMSchemaCollection_get(cache1, _bstr_(xdr_schema1_uri), NULL); 1011 ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr); 1012 1013 for (i = 0; i < 3; ++i) 1014 { 1015 bstr = NULL; 1016 hr = IXMLDOMSchemaCollection_get_namespaceURI(cache1, i, &bstr); 1017 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 1018 ok(bstr != NULL && *bstr, "expected non-empty string\n"); 1019 content[i] = bstr; 1020 1021 for (j = 0; j < i; ++j) 1022 ok(wcscmp(content[j], bstr), "got duplicate entry\n"); 1023 } 1024 1025 for (i = 0; i < 3; ++i) 1026 { 1027 SysFreeString(content[i]); 1028 content[i] = NULL; 1029 } 1030 1031 IXMLDOMSchemaCollection_Release(cache1); 1032 free_bstrs(); 1033} 1034 1035static void test_XDR_schemas(void) 1036{ 1037 IXMLDOMDocument2 *doc, *schema; 1038 IXMLDOMSchemaCollection* cache; 1039 IXMLDOMParseError* err; 1040 VARIANT_BOOL b; 1041 HRESULT hr; 1042 VARIANT v; 1043 BSTR bstr; 1044 1045 doc = create_document(&IID_IXMLDOMDocument2); 1046 schema = create_document(&IID_IXMLDOMDocument2); 1047 cache = create_cache(&IID_IXMLDOMSchemaCollection); 1048 1049 if (!doc || !schema || !cache) 1050 { 1051 if (doc) IXMLDOMDocument2_Release(doc); 1052 if (schema) IXMLDOMDocument2_Release(schema); 1053 if (cache) IXMLDOMSchemaCollection_Release(cache); 1054 1055 return; 1056 } 1057 1058 VariantInit(&v); 1059 1060 hr = IXMLDOMDocument2_loadXML(doc, _bstr_(szOpenSeqXML1), &b); 1061 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 1062 ok(b == VARIANT_TRUE, "failed to load XML string\n"); 1063 1064 hr = IXMLDOMDocument2_loadXML(schema, _bstr_(szOpenSeqXDR), &b); 1065 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 1066 ok(b == VARIANT_TRUE, "failed to load XML string\n"); 1067 1068 /* load the schema */ 1069 V_VT(&v) = VT_DISPATCH; 1070 V_DISPATCH(&v) = NULL; 1071 hr = IXMLDOMDocument2_QueryInterface(schema, &IID_IDispatch, (void**)&V_DISPATCH(&v)); 1072 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 1073 ok(V_DISPATCH(&v) != NULL, "failed to get IDispatch interface\n"); 1074 hr = IXMLDOMSchemaCollection_add(cache, _bstr_(L""), v); 1075 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 1076 VariantClear(&v); 1077 1078 /* associate the cache to the doc */ 1079 V_VT(&v) = VT_DISPATCH; 1080 V_DISPATCH(&v) = NULL; 1081 hr = IXMLDOMSchemaCollection_QueryInterface(cache, &IID_IDispatch, (void**)&V_DISPATCH(&v)); 1082 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 1083 ok(V_DISPATCH(&v) != NULL, "failed to get IDispatch interface\n"); 1084 hr = IXMLDOMDocument2_putref_schemas(doc, v); 1085 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 1086 VariantClear(&v); 1087 1088 /* validate the doc 1089 * only declared elements in the declared order 1090 * this is fine */ 1091 err = NULL; 1092 bstr = NULL; 1093 hr = IXMLDOMDocument2_validate(doc, &err); 1094 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 1095 ok(err != NULL, "domdoc_validate() should always set err\n"); 1096 hr = IXMLDOMParseError_get_reason(err, &bstr); 1097 ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr); 1098 ok(IXMLDOMParseError_get_reason(err, &bstr) == S_FALSE, "got error: %s\n", wine_dbgstr_w(bstr)); 1099 SysFreeString(bstr); 1100 IXMLDOMParseError_Release(err); 1101 1102 /* load the next doc */ 1103 IXMLDOMDocument2_Release(doc); 1104 doc = create_document(&IID_IXMLDOMDocument2); 1105 hr = IXMLDOMDocument2_loadXML(doc, _bstr_(szOpenSeqXML2), &b); 1106 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 1107 ok(b == VARIANT_TRUE, "failed to load XML string\n"); 1108 1109 /* associate the cache to the doc */ 1110 V_VT(&v) = VT_DISPATCH; 1111 V_DISPATCH(&v) = NULL; 1112 hr = IXMLDOMSchemaCollection_QueryInterface(cache, &IID_IDispatch, (void**)&V_DISPATCH(&v)); 1113 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 1114 ok(V_DISPATCH(&v) != NULL, "failed to get IDispatch interface\n"); 1115 hr = IXMLDOMDocument2_putref_schemas(doc, v); 1116 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 1117 VariantClear(&v); 1118 1119 /* validate the doc 1120 * declared elements in the declared order, with an extra declared element at the end 1121 * this is fine */ 1122 err = NULL; 1123 bstr = NULL; 1124 hr = IXMLDOMDocument2_validate(doc, &err); 1125 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 1126 ok(err != NULL, "domdoc_validate() should always set err\n"); 1127 hr = IXMLDOMParseError_get_reason(err, &bstr); 1128 ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr); 1129 ok(IXMLDOMParseError_get_reason(err, &bstr) == S_FALSE, "got error: %s\n", wine_dbgstr_w(bstr)); 1130 SysFreeString(bstr); 1131 IXMLDOMParseError_Release(err); 1132 1133 /* load the next doc */ 1134 IXMLDOMDocument2_Release(doc); 1135 doc = create_document(&IID_IXMLDOMDocument2); 1136 hr = IXMLDOMDocument2_loadXML(doc, _bstr_(szOpenSeqXML3), &b); 1137 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 1138 ok(b == VARIANT_TRUE, "failed to load XML string\n"); 1139 1140 /* associate the cache to the doc */ 1141 V_VT(&v) = VT_DISPATCH; 1142 V_DISPATCH(&v) = NULL; 1143 hr = IXMLDOMSchemaCollection_QueryInterface(cache, &IID_IDispatch, (void**)&V_DISPATCH(&v)); 1144 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 1145 ok(V_DISPATCH(&v) != NULL, "failed to get IDispatch interface\n"); 1146 hr = IXMLDOMDocument2_putref_schemas(doc, v); 1147 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 1148 VariantClear(&v); 1149 1150 /* validate the doc 1151 * fails, extra elements are only allowed at the end */ 1152 err = NULL; 1153 bstr = NULL; 1154 hr = IXMLDOMDocument2_validate(doc, &err); 1155 ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr); 1156 ok(err != NULL, "domdoc_validate() should always set err\n"); 1157 todo_wine ok(IXMLDOMParseError_get_reason(err, &bstr) == S_OK, "got error: %s\n", wine_dbgstr_w(bstr)); 1158 SysFreeString(bstr); 1159 IXMLDOMParseError_Release(err); 1160 1161 /* load the next doc */ 1162 IXMLDOMDocument2_Release(doc); 1163 doc = create_document(&IID_IXMLDOMDocument2); 1164 hr = IXMLDOMDocument2_loadXML(doc, _bstr_(szOpenSeqXML4), &b); 1165 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 1166 ok(b == VARIANT_TRUE, "failed to load XML string\n"); 1167 1168 /* associate the cache to the doc */ 1169 V_VT(&v) = VT_DISPATCH; 1170 V_DISPATCH(&v) = NULL; 1171 hr = IXMLDOMSchemaCollection_QueryInterface(cache, &IID_IDispatch, (void**)&V_DISPATCH(&v)); 1172 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 1173 ok(V_DISPATCH(&v) != NULL, "failed to get IDispatch interface\n"); 1174 hr = IXMLDOMDocument2_putref_schemas(doc, v); 1175 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 1176 VariantClear(&v); 1177 1178 /* validate the doc 1179 * fails, undeclared elements are not allowed */ 1180 err = NULL; 1181 bstr = NULL; 1182 hr = IXMLDOMDocument2_validate(doc, &err); 1183 ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr); 1184 ok(err != NULL, "domdoc_validate() should always set err\n"); 1185 todo_wine ok(IXMLDOMParseError_get_reason(err, &bstr) == S_OK, "got error: %s\n", wine_dbgstr_w(bstr)); 1186 SysFreeString(bstr); 1187 IXMLDOMParseError_Release(err); 1188 1189 IXMLDOMDocument2_Release(doc); 1190 IXMLDOMDocument2_Release(schema); 1191 IXMLDOMSchemaCollection_Release(cache); 1192 1193 free_bstrs(); 1194} 1195 1196typedef struct { 1197 const WCHAR *query; 1198 enum VARENUM type_schema; 1199 const WCHAR *typename; 1200 BOOL todo; 1201} xdr_datatypes; 1202 1203static const xdr_datatypes xdr_datatypes_data[] = { 1204 { L"//Property[Name!text()='testBase64']/Value/base64Data", VT_ARRAY|VT_UI1, L"bin.base64" }, 1205 { L"//Property[Name!text()='testHex']/Value/hexData", VT_ARRAY|VT_UI1, L"bin.hex" }, 1206 { L"//Property[Name!text()='testBool']/Value/boolData", VT_BOOL, L"boolean" }, 1207 { L"//Property[Name!text()='testChar']/Value/charData", VT_I4, L"char", TRUE }, 1208 { L"//Property[Name!text()='testDate']/Value/dateData", VT_DATE, L"date" }, 1209 { L"//Property[Name!text()='testDateTime']/Value/dateTimeData", VT_DATE, L"dateTime" }, 1210 { L"//Property[Name!text()='testDateTimeTz']/Value/dateTimeTzData", VT_DATE, L"dateTime.tz" }, 1211 { L"//Property[Name!text()='testFixed']/Value/fixedData", VT_CY, L"fixed.14.4" }, 1212 { L"//Property[Name!text()='testFloat']/Value/floatData", VT_R8, L"float" }, 1213 { L"//Property[Name!text()='testI1']/Value/i1Data", VT_I1, L"i1" }, 1214 { L"//Property[Name!text()='testI2']/Value/i2Data", VT_I2, L"i2" }, 1215 { L"//Property[Name!text()='testI4']/Value/i4Data", VT_I4, L"i4" }, 1216 { L"//Property[Name!text()='testI8']/Value/i8Data", VT_NULL, L"i8", TRUE }, 1217 { L"//Property[Name!text()='testInt']/Value/intData", VT_I4, L"int" }, 1218 { L"//Property[Name!text()='testNmtoken']/Value/nmtokData", VT_BSTR, NULL }, 1219 { L"//Property[Name!text()='testNmtokens']/Value/nmtoksData", VT_BSTR, NULL }, 1220 { L"//Property[Name!text()='testNumber']/Value/numData", VT_BSTR, L"number" }, 1221 { L"//Property[Name!text()='testR4']/Value/r4Data", VT_R4, L"r4" }, 1222 { L"//Property[Name!text()='testR8']/Value/r8Data", VT_R8, L"r8" }, 1223 { L"//Property[Name!text()='testString']/Value/stringData", VT_BSTR, NULL }, 1224 { L"//Property[Name!text()='testTime']/Value/timeData", VT_DATE, L"time" }, 1225 { L"//Property[Name!text()='testTimeTz']/Value/timeTzData", VT_DATE, L"time.tz" }, 1226 { L"//Property[Name!text()='testU1']/Value/u1Data", VT_UI1, L"ui1" }, 1227 { L"//Property[Name!text()='testU2']/Value/u2Data", VT_UI2, L"ui2" }, 1228 { L"//Property[Name!text()='testU4']/Value/u4Data", VT_UI4, L"ui4" }, 1229 { L"//Property[Name!text()='testU8']/Value/u8Data", VT_NULL, L"ui8", TRUE }, 1230 { L"//Property[Name!text()='testURI']/Value/uriData", VT_BSTR, L"uri" }, 1231 { L"//Property[Name!text()='testUUID']/Value/uuidData", VT_BSTR, L"uuid" }, 1232 { NULL } 1233}; 1234 1235static void test_XDR_datatypes(void) 1236{ 1237 IXMLDOMDocument2 *doc, *schema, *doc2; 1238 IXMLDOMSchemaCollection* cache; 1239 const xdr_datatypes *ptr; 1240 IXMLDOMParseError* err; 1241 VARIANT_BOOL b; 1242 HRESULT hr; 1243 VARIANT v; 1244 BSTR bstr; 1245 LONG l; 1246 1247 VariantInit(&v); 1248 1249 doc = create_document(&IID_IXMLDOMDocument2); 1250 doc2 = create_document(&IID_IXMLDOMDocument2); 1251 schema = create_document(&IID_IXMLDOMDocument2); 1252 cache = create_cache(&IID_IXMLDOMSchemaCollection); 1253 1254 if (!doc || !doc2 || !schema || !cache) 1255 { 1256 if (doc) IXMLDOMDocument2_Release(doc); 1257 if (doc2) IXMLDOMDocument2_Release(doc2); 1258 if (schema) IXMLDOMDocument2_Release(schema); 1259 if (cache) IXMLDOMSchemaCollection_Release(cache); 1260 return; 1261 } 1262 1263 hr = IXMLDOMDocument2_loadXML(doc, _bstr_(szDatatypeXML), &b); 1264 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 1265 ok(b == VARIANT_TRUE, "failed to load XML string\n"); 1266 1267 hr = IXMLDOMDocument2_loadXML(doc2, _bstr_(szDatatypeXML), &b); 1268 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 1269 ok(b == VARIANT_TRUE, "failed to load XML string\n"); 1270 1271 hr = IXMLDOMDocument2_loadXML(schema, _bstr_(szDatatypeXDR), &b); 1272 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 1273 ok(b == VARIANT_TRUE, "failed to load XML string\n"); 1274 1275 err = NULL; 1276 hr = IXMLDOMDocument2_validate(doc, &err); 1277 ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr); 1278 ok(err != NULL, "domdoc_validate() should always set err\n"); 1279 hr = IXMLDOMParseError_get_errorCode(err, &l); 1280 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 1281 ok(l == E_XML_NODTD, "Unexpected error code %#lx.\n", l); 1282 IXMLDOMParseError_Release(err); 1283 1284 err = NULL; 1285 hr = IXMLDOMDocument2_validate(doc2, &err); 1286 ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr); 1287 ok(err != NULL, "domdoc_validate() should always set err\n"); 1288 hr = IXMLDOMParseError_get_errorCode(err, &l); 1289 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 1290 ok(l == E_XML_NODTD, "Unexpected error code %#lx.\n", l); 1291 IXMLDOMParseError_Release(err); 1292 1293 /* now load the schema */ 1294 V_VT(&v) = VT_DISPATCH; 1295 V_DISPATCH(&v) = NULL; 1296 hr = IXMLDOMDocument2_QueryInterface(schema, &IID_IDispatch, (void**)&V_DISPATCH(&v)); 1297 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 1298 ok(V_DISPATCH(&v) != NULL, "failed to get IDispatch interface\n"); 1299 hr = IXMLDOMSchemaCollection_add(cache, _bstr_(L"urn:x-schema:datatype-test-xdr"), v); 1300 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 1301 VariantClear(&v); 1302 1303 /* associate the cache to the doc */ 1304 V_VT(&v) = VT_DISPATCH; 1305 V_DISPATCH(&v) = NULL; 1306 hr = IXMLDOMSchemaCollection_QueryInterface(cache, &IID_IDispatch, (void**)&V_DISPATCH(&v)); 1307 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 1308 ok(V_DISPATCH(&v) != NULL, "failed to get IDispatch interface\n"); 1309 hr = IXMLDOMDocument2_putref_schemas(doc2, v); 1310 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 1311 VariantClear(&v); 1312 1313 /* validate the doc */ 1314 err = NULL; 1315 l = 0; 1316 bstr = NULL; 1317 hr = IXMLDOMDocument2_validate(doc2, &err); 1318 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 1319 ok(err != NULL, "domdoc_validate() should always set err\n"); 1320 hr = IXMLDOMParseError_get_errorCode(err, &l); 1321 ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr); 1322 hr = IXMLDOMParseError_get_reason(err, &bstr); 1323 ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr); 1324 ok(l == 0, "Unexpected value %lx : %s\n", l, wine_dbgstr_w(bstr)); 1325 SysFreeString(bstr); 1326 IXMLDOMParseError_Release(err); 1327 1328 ptr = xdr_datatypes_data; 1329 while (ptr->query) 1330 { 1331 IXMLDOMNode* node = NULL; 1332 VARIANT type; 1333 1334 /* check data types without the schema */ 1335 hr = IXMLDOMDocument2_selectSingleNode(doc, _bstr_(ptr->query), &node); 1336 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 1337 ok(node != NULL, "expected node\n"); 1338 1339 V_VT(&type) = VT_EMPTY; 1340 V_BSTR(&type) = (void*)-1; 1341 hr = IXMLDOMNode_get_dataType(node, &type); 1342 ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr); 1343 ok(V_VT(&type) == VT_NULL, "got type %i\n", V_VT(&type)); 1344 /* when returning VT_NULL, the pointer is set to NULL */ 1345 ok(V_BSTR(&type) == NULL, "got %p\n", V_BSTR(&type)); 1346 1347 VariantClear(&type); 1348 hr = IXMLDOMNode_get_nodeTypedValue(node, &type); 1349 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 1350 ok(V_VT(&type) == VT_BSTR, "got variant type %i\n", V_VT(&v)); 1351 VariantClear(&type); 1352 IXMLDOMNode_Release(node); 1353 1354 /* check the data with schema */ 1355 node = NULL; 1356 hr = IXMLDOMDocument2_selectSingleNode(doc2, _bstr_(ptr->query), &node); 1357 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 1358 ok(node != NULL, "expected node\n"); 1359 1360 V_VT(&type) = VT_EMPTY; 1361 hr = IXMLDOMNode_get_dataType(node, &type); 1362 if (ptr->typename) 1363 { 1364 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 1365 ok(V_VT(&type) == VT_BSTR, "got type %i\n", V_VT(&type)); 1366 ok(!lstrcmpW(V_BSTR(&type), _bstr_(ptr->typename)), "got %s\n", wine_dbgstr_w(V_BSTR(&type))); 1367 } 1368 else 1369 { 1370 ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr); 1371 ok(V_VT(&type) == VT_NULL, "%s: got type %i\n", wine_dbgstr_w(ptr->query), V_VT(&type)); 1372 } 1373 VariantClear(&type); 1374 1375 VariantClear(&v); 1376 hr = IXMLDOMNode_get_nodeTypedValue(node, &v); 1377 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 1378 1379 todo_wine_if(ptr->todo) 1380 ok(V_VT(&v) == ptr->type_schema, "%s: got variant type %i\n", wine_dbgstr_w(ptr->query), V_VT(&v)); 1381 1382 switch (ptr->type_schema) 1383 { 1384 case VT_BOOL: 1385 ok(V_BOOL(&v) == VARIANT_TRUE, "got %x\n", V_BOOL(&v)); 1386 break; 1387 case VT_I1: 1388 ok(V_I1(&v) == 42, "got %i\n", V_I1(&v)); 1389 break; 1390 case VT_I2: 1391 ok(V_I2(&v) == 420, "got %i\n", V_I2(&v)); 1392 break; 1393 case VT_I4: 1394 if (!wcscmp(ptr->typename, L"int")) 1395 ok(V_I4(&v) == 42, "got %ld\n", V_I4(&v)); 1396 else if (!wcscmp(ptr->typename, L"char")) 1397 todo_wine 1398 ok(V_I4(&v) == 'u', "got %lx\n", V_I4(&v)); 1399 else 1400 ok(V_I4(&v) == -420000000, "got %ld\n", V_I4(&v)); 1401 break; 1402 case VT_I8: 1403 expect_int64(V_I8(&v), -4200000000, 10); 1404 break; 1405 case VT_R4: 1406 ok(V_R4(&v) == (float)3.14159265, "got %f\n", V_R4(&v)); 1407 break; 1408 case VT_R8: 1409 if (!wcscmp(ptr->typename, L"float")) 1410 ok(V_R8(&v) == 3.14159, "got %f\n", V_R8(&v)); 1411 else 1412 todo_wine 1413 ok(V_R8(&v) == 3.14159265358979323846, "got %.20f\n", V_R8(&v)); 1414 break; 1415 case VT_UI1: 1416 ok(V_UI1(&v) == 0xFF, "got %02x\n", V_UI1(&v)); 1417 break; 1418 case VT_UI2: 1419 ok(V_UI2(&v) == 0xFFFF, "got %04x\n", V_UI2(&v)); 1420 break; 1421 case VT_UI4: 1422 ok(V_UI4(&v) == 0xFFFFFFFF, "got %#lx\n", V_UI4(&v)); 1423 break; 1424 case VT_UI8: 1425 expect_uint64(V_UI8(&v), 0xFFFFFFFFFFFFFFFF, 16); 1426 break; 1427 default: 1428 ; 1429 } 1430 1431 VariantClear(&v); 1432 1433 IXMLDOMNode_Release(node); 1434 1435 ptr++; 1436 } 1437 1438 IXMLDOMDocument2_Release(schema); 1439 IXMLDOMDocument2_Release(doc); 1440 IXMLDOMDocument2_Release(doc2); 1441 IXMLDOMSchemaCollection_Release(cache); 1442 1443 free_bstrs(); 1444} 1445 1446static void test_obj_dispex(IUnknown *obj) 1447{ 1448 DISPID dispid = DISPID_SAX_XMLREADER_GETFEATURE; 1449 IDispatchEx *dispex; 1450 IUnknown *unk; 1451 DWORD props; 1452 UINT ticnt; 1453 HRESULT hr; 1454 BSTR name; 1455 1456 hr = IUnknown_QueryInterface(obj, &IID_IDispatchEx, (void**)&dispex); 1457 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 1458 if (FAILED(hr)) return; 1459 1460 ticnt = 0; 1461 hr = IDispatchEx_GetTypeInfoCount(dispex, &ticnt); 1462 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 1463 ok(ticnt == 1, "ticnt=%u\n", ticnt); 1464 1465 name = SysAllocString(L"*"); 1466 hr = IDispatchEx_DeleteMemberByName(dispex, name, fdexNameCaseSensitive); 1467 ok(hr == E_NOTIMPL, "Unexpected hr %#lx.\n", hr); 1468 SysFreeString(name); 1469 1470 hr = IDispatchEx_DeleteMemberByDispID(dispex, dispid); 1471 ok(hr == E_NOTIMPL, "Unexpected hr %#lx.\n", hr); 1472 1473 props = 0; 1474 hr = IDispatchEx_GetMemberProperties(dispex, dispid, grfdexPropCanAll, &props); 1475 ok(hr == E_NOTIMPL, "Unexpected hr %#lx.\n", hr); 1476 ok(props == 0, "expected 0 got %ld\n", props); 1477 1478 hr = IDispatchEx_GetMemberName(dispex, dispid, &name); 1479 ok(hr == E_NOTIMPL, "Unexpected hr %#lx.\n", hr); 1480 if (SUCCEEDED(hr)) SysFreeString(name); 1481 1482 hr = IDispatchEx_GetNextDispID(dispex, fdexEnumDefault, DISPID_XMLDOM_SCHEMACOLLECTION_ADD, &dispid); 1483 ok(hr == E_NOTIMPL, "Unexpected hr %#lx.\n", hr); 1484 1485 unk = (IUnknown*)0xdeadbeef; 1486 hr = IDispatchEx_GetNameSpaceParent(dispex, &unk); 1487 ok(hr == E_NOTIMPL, "Unexpected hr %#lx.\n", hr); 1488 ok(unk == (IUnknown*)0xdeadbeef, "got %p\n", unk); 1489 1490 name = SysAllocString(L"testprop"); 1491 hr = IDispatchEx_GetDispID(dispex, name, fdexNameEnsure, &dispid); 1492 ok(hr == DISP_E_UNKNOWNNAME, "Unexpected hr %#lx.\n", hr); 1493 SysFreeString(name); 1494 1495 IDispatchEx_Release(dispex); 1496} 1497 1498static void test_dispex(void) 1499{ 1500 IXMLDOMSchemaCollection *cache; 1501 IDispatchEx *dispex; 1502 IUnknown *unk; 1503 HRESULT hr; 1504 DISPPARAMS dispparams; 1505 VARIANT arg, ret; 1506 1507 cache = create_cache(&IID_IXMLDOMSchemaCollection); 1508 if (!cache) return; 1509 1510 hr = IXMLDOMSchemaCollection_QueryInterface(cache, &IID_IUnknown, (void**)&unk); 1511 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 1512 test_obj_dispex(unk); 1513 IUnknown_Release(unk); 1514 1515 hr = IXMLDOMSchemaCollection_QueryInterface(cache, &IID_IDispatchEx, (void**)&dispex); 1516 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); 1517 1518 V_VT(&arg) = VT_I4; 1519 V_I4(&arg) = 0; 1520 dispparams.cArgs = 1; 1521 dispparams.cNamedArgs = 0; 1522 dispparams.rgdispidNamedArgs = NULL; 1523 dispparams.rgvarg = &arg; 1524 1525 V_VT(&ret) = VT_EMPTY; 1526 V_DISPATCH(&ret) = (void*)0x1; 1527 hr = IDispatchEx_Invoke(dispex, DISPID_VALUE, &IID_NULL, 0, DISPATCH_METHOD, &dispparams, &ret, NULL, NULL); 1528 ok(hr == DISP_E_MEMBERNOTFOUND, "Unexpected hr %#lx.\n", hr); 1529 ok(V_VT(&ret) == VT_EMPTY, "got %d\n", V_VT(&ret)); 1530 ok(V_DISPATCH(&ret) == (void*)0x1, "got %p\n", V_DISPATCH(&ret)); 1531 1532 IDispatchEx_Release(dispex); 1533 IXMLDOMSchemaCollection_Release(cache); 1534} 1535 1536START_TEST(schema) 1537{ 1538 HRESULT r; 1539 1540 r = CoInitialize( NULL ); 1541 ok( r == S_OK, "failed to init com\n"); 1542 1543 test_schema_refs(); 1544 test_collection_refs(); 1545 test_length(); 1546 test_collection_content(); 1547 test_XDR_schemas(); 1548 test_XDR_datatypes(); 1549 test_dispex(); 1550 1551 CoUninitialize(); 1552}