ReactOS 0.4.16-dev-112-g52265ae
schema.c File Reference
#include <stdio.h>
#include <assert.h>
#include "initguid.h"
#include "windows.h"
#include "ole2.h"
#include "msxml2.h"
#include "msxml2did.h"
#include "dispex.h"
#include "cguid.h"
#include "wine/test.h"
Include dependency graph for schema.c:

Go to the source code of this file.

Classes

struct  xdr_datatypes
 

Macros

#define COBJMACROS
 
#define EXPECT_HR(hr, hr_exp)    ok(hr == hr_exp, "got 0x%08x, expected 0x%08x\n", hr, hr_exp)
 
#define check_ref_expr(expr, n)
 
#define check_refs(iface, obj, n)
 
#define ole_check(expr)
 
#define ole_expect(expr, expect)
 
#define _expect64(expr, str, base, TYPE, CONV)
 
#define expect_int64(expr, x, base)   _expect64(expr, #x, base, LONG64, strtoll)
 
#define expect_uint64(expr, x, base)   _expect64(expr, #x, base, ULONG64, strtoull)
 
#define _create(cls)   cls, #cls
 
#define create_document(iid)   _create_object(&_create(CLSID_DOMDocument), iid, __LINE__)
 
#define create_document_version(v, iid)   _create_object(&_create(CLSID_DOMDocument ## v), iid, __LINE__)
 
#define create_cache(iid)   _create_object(&_create(CLSID_XMLSchemaCache), iid, __LINE__)
 
#define create_cache_version(v, iid)   _create_object(&_create(CLSID_XMLSchemaCache ## v), iid, __LINE__)
 

Functions

static BSTR alloc_str_from_narrow (const char *str)
 
static BSTR _bstr_ (const char *str)
 
static void free_bstrs (void)
 
static VARIANT _variantdoc_ (void *doc)
 
static void_create_object (const GUID *clsid, const char *name, const IID *iid, int line)
 
static void test_schema_refs (void)
 
static void test_collection_refs (void)
 
static void test_length (void)
 
static void test_collection_content (void)
 
static HRESULT validate_regex_document (IXMLDOMDocument2 *doc, IXMLDOMDocument2 *schema, IXMLDOMSchemaCollection *cache, const WCHAR *regex, const WCHAR *input)
 
static void test_regex (void)
 
static void test_XDR_schemas (void)
 
static void test_XDR_datatypes (void)
 
static void test_validate_on_load (void)
 
static void test_obj_dispex (IUnknown *obj)
 
static void test_dispex (void)
 
static void test_get (void)
 
static void test_remove (void)
 
static void test_ifaces (void)
 
 START_TEST (schema)
 

Variables

static const CHAR xdr_schema1_uri [] = "x-schema:test1.xdr"
 
static const CHAR xdr_schema1_xml []
 
static const CHAR xdr_schema2_uri [] = "x-schema:test2.xdr"
 
static const CHAR xdr_schema2_xml []
 
static const CHAR xdr_schema3_uri [] = "x-schema:test3.xdr"
 
static const CHAR xdr_schema3_xml []
 
static const CHAR xsd_schema1_uri [] = "x-schema:test1.xsd"
 
static const CHAR xsd_schema1_xml []
 
static const CHAR xsd_schema2_uri [] = "x-schema:test2.xsd"
 
static const CHAR xsd_schema2_xml []
 
static const CHAR xsd_schema3_uri [] = "x-schema:test3.xsd"
 
static const CHAR xsd_schema3_xml []
 
static const CHAR szDatatypeXDR []
 
static const CHAR szDatatypeXML []
 
static const CHAR szOpenSeqXDR []
 
static const CHAR szOpenSeqXML1 [] = "<test><x/><x/><y/><z/><z/></test>"
 
static const CHAR szOpenSeqXML2 [] = "<test><x/><x/><y/><z/><z/><w/></test>"
 
static const CHAR szOpenSeqXML3 [] = "<test><w/><x/><x/><y/><z/><z/></test>"
 
static const CHAR szOpenSeqXML4 [] = "<test><x/><x/><y/><z/><z/><v/></test>"
 
static BSTR alloced_bstrs [256]
 
static int alloced_bstrs_count
 
static const xdr_datatypes xdr_datatypes_data []
 

Macro Definition Documentation

◆ _create

#define _create (   cls)    cls, #cls

Definition at line 486 of file schema.c.

◆ _expect64

#define _expect64 (   expr,
  str,
  base,
  TYPE,
  CONV 
)
Value:
{ \
TYPE v1 = expr; \
TYPE v2 = CONV(str, NULL, base); \
ok(v1 == v2, #expr "returned %s, expected %s\n", \
}
#define NULL
Definition: types.h:112
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
TYPE
Definition: eventcreate.c:652
GLfloat GLfloat v1
Definition: glext.h:6062
GLfloat GLfloat GLfloat v2
Definition: glext.h:6063
const WCHAR * str
Definition: query.h:86

Definition at line 425 of file schema.c.

◆ check_ref_expr

#define check_ref_expr (   expr,
  n 
)
Value:
{ \
LONG ref = expr; \
ok(ref == n, "expected %i refs, got %i\n", n, ref); \
}
GLdouble n
Definition: glext.h:7729
long LONG
Definition: pedump.c:60
Definition: send.c:48

Definition at line 403 of file schema.c.

◆ check_refs

#define check_refs (   iface,
  obj,
  n 
)
Value:
{ \
LONG ref = iface ## _AddRef(obj); \
ok(ref == n+1, "expected %i refs, got %i\n", n+1, ref); \
ref = iface ## _Release(obj); \
ok(ref == n, "expected %i refs, got %i\n", n, ref); \
}

Definition at line 408 of file schema.c.

◆ COBJMACROS

#define COBJMACROS

Definition at line 24 of file schema.c.

◆ create_cache

#define create_cache (   iid)    _create_object(&_create(CLSID_XMLSchemaCache), iid, __LINE__)

Definition at line 492 of file schema.c.

◆ create_cache_version

#define create_cache_version (   v,
  iid 
)    _create_object(&_create(CLSID_XMLSchemaCache ## v), iid, __LINE__)

Definition at line 494 of file schema.c.

◆ create_document

#define create_document (   iid)    _create_object(&_create(CLSID_DOMDocument), iid, __LINE__)

Definition at line 488 of file schema.c.

◆ create_document_version

#define create_document_version (   v,
  iid 
)    _create_object(&_create(CLSID_DOMDocument ## v), iid, __LINE__)

Definition at line 490 of file schema.c.

◆ EXPECT_HR

#define EXPECT_HR (   hr,
  hr_exp 
)     ok(hr == hr_exp, "got 0x%08x, expected 0x%08x\n", hr, hr_exp)

Definition at line 37 of file schema.c.

◆ expect_int64

#define expect_int64 (   expr,
  x,
  base 
)    _expect64(expr, #x, base, LONG64, strtoll)

Definition at line 436 of file schema.c.

◆ expect_uint64

#define expect_uint64 (   expr,
  x,
  base 
)    _expect64(expr, #x, base, ULONG64, strtoull)

Definition at line 437 of file schema.c.

◆ ole_check

#define ole_check (   expr)
Value:
{ \
HRESULT r = expr; \
ok(r == S_OK, #expr " returned %x\n", r); \
}
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define S_OK
Definition: intsafe.h:52

Definition at line 415 of file schema.c.

◆ ole_expect

#define ole_expect (   expr,
  expect 
)
Value:
{ \
HRESULT r = expr; \
ok(r == (expect), #expr " returned %x, expected %x\n", r, expect); \
}
#define expect(EXPECTED, GOT)
Definition: SystemMenu.c:483

Definition at line 420 of file schema.c.

Function Documentation

◆ _bstr_()

static BSTR _bstr_ ( const char str)
static

Definition at line 451 of file schema.c.

452{
456}
#define ARRAY_SIZE(A)
Definition: main.h:20
#define assert(x)
Definition: debug.h:53
static BSTR alloced_bstrs[256]
Definition: schema.c:440
static BSTR alloc_str_from_narrow(const char *str)
Definition: schema.c:443
static int alloced_bstrs_count
Definition: schema.c:441

Referenced by test_collection_content(), test_collection_refs(), test_get(), test_length(), test_remove(), test_XDR_datatypes(), and test_XDR_schemas().

◆ _create_object()

static void * _create_object ( const GUID clsid,
const char name,
const IID iid,
int  line 
)
static

Definition at line 474 of file schema.c.

475{
476 void *obj = NULL;
477 HRESULT hr;
478
479 hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, iid, &obj);
480 if (hr != S_OK)
481 win_skip_(__FILE__,line)("failed to create %s instance: 0x%08x\n", name, hr);
482
483 return obj;
484}
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
REFCLSID clsid
Definition: msctf.c:82
#define win_skip_(file, line)
Definition: test.h:157
HRESULT hr
Definition: shlfolder.c:183
Definition: parser.c:49
Definition: name.c:39

◆ _variantdoc_()

static VARIANT _variantdoc_ ( void doc)
static

Definition at line 466 of file schema.c.

467{
468 VARIANT v;
469 V_VT(&v) = VT_DISPATCH;
470 V_DISPATCH(&v) = (IDispatch*)doc;
471 return v;
472}
@ VT_DISPATCH
Definition: compat.h:2304
const GLdouble * v
Definition: gl.h:2040
#define V_VT(A)
Definition: oleauto.h:211
#define V_DISPATCH(A)
Definition: oleauto.h:239

Referenced by test_collection_content(), test_collection_refs(), test_length(), and test_schema_refs().

◆ alloc_str_from_narrow()

static BSTR alloc_str_from_narrow ( const char str)
static

Definition at line 443 of file schema.c.

444{
445 int len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
446 BSTR ret = SysAllocStringLen(NULL, len - 1); /* NUL character added automatically */
448 return ret;
449}
#define CP_ACP
Definition: compat.h:109
OLECHAR * BSTR
Definition: compat.h:2293
#define MultiByteToWideChar
Definition: compat.h:110
GLenum GLsizei len
Definition: glext.h:6722
BSTR WINAPI SysAllocStringLen(const OLECHAR *str, unsigned int len)
Definition: oleaut.c:339
int ret

Referenced by _bstr_(), and validate_regex_document().

◆ free_bstrs()

static void free_bstrs ( void  )
static

Definition at line 458 of file schema.c.

459{
460 int i;
461 for (i = 0; i < alloced_bstrs_count; i++)
464}
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

Referenced by test_collection_content(), test_collection_refs(), test_get(), test_length(), test_remove(), test_XDR_datatypes(), and test_XDR_schemas().

◆ START_TEST()

START_TEST ( schema  )

Definition at line 1850 of file schema.c.

1851{
1852 HRESULT r;
1853
1854 r = CoInitialize( NULL );
1855 ok( r == S_OK, "failed to init com\n");
1856
1859 test_length();
1861 test_regex();
1865 test_dispex();
1866 test_get();
1867 test_remove();
1868 test_ifaces();
1869
1871}
#define ok(value,...)
Definition: atltest.h:57
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
static void test_ifaces(void)
Definition: schema.c:1832
static void test_XDR_schemas(void)
Definition: schema.c:1204
static void test_collection_refs(void)
Definition: schema.c:666
static void test_XDR_datatypes(void)
Definition: schema.c:1382
static void test_length(void)
Definition: schema.c:785
static void test_regex(void)
Definition: schema.c:1130
static void test_remove(void)
Definition: schema.c:1740
static void test_get(void)
Definition: schema.c:1710
static void test_schema_refs(void)
Definition: schema.c:496
static void test_validate_on_load(void)
Definition: schema.c:1593
static void test_collection_content(void)
Definition: schema.c:877
static void test_dispex(void)
Definition: schema.c:1665

◆ test_collection_content()

static void test_collection_content ( void  )
static

Definition at line 877 of file schema.c.

878{
879 IXMLDOMDocument2 *schema1, *schema2, *schema3, *schema4, *schema5;
880 BSTR content[5] = {NULL, NULL, NULL, NULL, NULL};
881 IXMLDOMSchemaCollection *cache1, *cache2;
883 LONG length;
884 HRESULT hr;
885 BSTR bstr;
886 int i, j;
887
888 schema1 = create_document_version(30, &IID_IXMLDOMDocument2);
889 schema2 = create_document_version(30, &IID_IXMLDOMDocument2);
890 schema3 = create_document_version(30, &IID_IXMLDOMDocument2);
891
892 cache1 = create_cache_version(30, &IID_IXMLDOMSchemaCollection);
893 cache2 = create_cache_version(40, &IID_IXMLDOMSchemaCollection);
894
895 if (!schema1 || !schema2 || !schema3 || !cache1)
896 {
897 if (schema1) IXMLDOMDocument2_Release(schema1);
898 if (schema2) IXMLDOMDocument2_Release(schema2);
899 if (schema3) IXMLDOMDocument2_Release(schema3);
900
901 if (cache1) IXMLDOMSchemaCollection_Release(cache1);
902
903 return;
904 }
905
906 ole_check(IXMLDOMDocument2_loadXML(schema1, _bstr_(xdr_schema1_xml), &b));
907 ok(b == VARIANT_TRUE, "failed to load XML\n");
908
909 ole_check(IXMLDOMDocument2_loadXML(schema2, _bstr_(xdr_schema2_xml), &b));
910 ok(b == VARIANT_TRUE, "failed to load XML\n");
911
912 ole_check(IXMLDOMDocument2_loadXML(schema3, _bstr_(xdr_schema3_xml), &b));
913 ok(b == VARIANT_TRUE, "failed to load XML\n");
914
915 ole_check(IXMLDOMSchemaCollection_add(cache1, _bstr_(xdr_schema1_uri), _variantdoc_(schema1)));
916 ole_check(IXMLDOMSchemaCollection_add(cache1, _bstr_(xdr_schema2_uri), _variantdoc_(schema2)));
917 ole_check(IXMLDOMSchemaCollection_add(cache1, _bstr_(xdr_schema3_uri), _variantdoc_(schema3)));
918
919 length = -1;
920 ole_check(IXMLDOMSchemaCollection_get_length(cache1, &length));
921 ok(length == 3, "expected length 3, got %i\n", length);
922
923 IXMLDOMDocument2_Release(schema1);
924 IXMLDOMDocument2_Release(schema2);
925 IXMLDOMDocument2_Release(schema3);
926
927 if (cache2)
928 {
929 schema1 = create_document_version(40, &IID_IXMLDOMDocument2);
930 schema2 = create_document_version(40, &IID_IXMLDOMDocument2);
931 schema3 = create_document_version(40, &IID_IXMLDOMDocument2);
932 schema4 = create_document_version(40, &IID_IXMLDOMDocument2);
933 schema5 = create_document_version(40, &IID_IXMLDOMDocument2);
934 ole_check(IXMLDOMDocument2_loadXML(schema1, _bstr_(xdr_schema1_xml), &b));
935 ok(b == VARIANT_TRUE, "failed to load XML\n");
936 ole_check(IXMLDOMDocument2_loadXML(schema2, _bstr_(xdr_schema2_xml), &b));
937 ok(b == VARIANT_TRUE, "failed to load XML\n");
938 ole_check(IXMLDOMDocument2_loadXML(schema3, _bstr_(xsd_schema1_xml), &b));
939 ok(b == VARIANT_TRUE, "failed to load XML\n");
940 ole_check(IXMLDOMDocument2_loadXML(schema4, _bstr_(xsd_schema2_xml), &b));
941 ok(b == VARIANT_TRUE, "failed to load XML\n");
942 ole_check(IXMLDOMDocument2_loadXML(schema5, _bstr_(xsd_schema3_xml), &b));
943 ok(b == VARIANT_TRUE, "failed to load XML\n");
944
945 /* combining XDR and XSD schemas in the same cache is fine */
946 ole_check(IXMLDOMSchemaCollection_add(cache2, _bstr_(xdr_schema1_uri), _variantdoc_(schema1)));
947 ole_check(IXMLDOMSchemaCollection_add(cache2, _bstr_(xdr_schema2_uri), _variantdoc_(schema2)));
948 ole_check(IXMLDOMSchemaCollection_add(cache2, _bstr_(xsd_schema1_uri), _variantdoc_(schema3)));
949 ole_check(IXMLDOMSchemaCollection_add(cache2, _bstr_(xsd_schema2_uri), _variantdoc_(schema4)));
950 ole_check(IXMLDOMSchemaCollection_add(cache2, _bstr_(xsd_schema3_uri), _variantdoc_(schema5)));
951
952 length = -1;
953 ole_check(IXMLDOMSchemaCollection_get_length(cache2, &length));
954 ok(length == 5, "expected length 5, got %i\n", length);
955
956 IXMLDOMDocument2_Release(schema1);
957 IXMLDOMDocument2_Release(schema2);
958 IXMLDOMDocument2_Release(schema3);
959 IXMLDOMDocument2_Release(schema4);
960 IXMLDOMDocument2_Release(schema5);
961 }
962
963 bstr = (void*)0xdeadbeef;
964 /* error if index is out of range */
965 hr = IXMLDOMSchemaCollection_get_namespaceURI(cache1, 3, &bstr);
967 ok(bstr == (void*)0xdeadbeef, "got %p\n", bstr);
968 /* error if return pointer is NULL */
969 ole_expect(IXMLDOMSchemaCollection_get_namespaceURI(cache1, 0, NULL), E_POINTER);
970 /* pointer is checked first */
971 ole_expect(IXMLDOMSchemaCollection_get_namespaceURI(cache1, 3, NULL), E_POINTER);
972
973 schema1 = NULL;
974 /* no error if ns uri does not exist */
975 ole_check(IXMLDOMSchemaCollection_get(cache1, _bstr_(xsd_schema1_uri), (IXMLDOMNode**)&schema1));
976 ok(!schema1, "expected NULL\n");
977 /* a NULL bstr corresponds to no-uri ns */
978 ole_check(IXMLDOMSchemaCollection_get(cache1, NULL, (IXMLDOMNode**)&schema1));
979 ok(!schema1, "expected NULL\n");
980 /* error if return pointer is NULL */
981 ole_expect(IXMLDOMSchemaCollection_get(cache1, _bstr_(xdr_schema1_uri), NULL), E_POINTER);
982
983 for (i = 0; i < 3; ++i)
984 {
985 bstr = NULL;
986 ole_check(IXMLDOMSchemaCollection_get_namespaceURI(cache1, i, &bstr));
987 ok(bstr != NULL && *bstr, "expected non-empty string\n");
988#if __REACTOS__
989 if (bstr != NULL && *bstr)
990 {
991 content[i] = bstr;
992 for (j = 0; j < i; ++j)
993 ok(wcscmp(content[j], bstr), "got duplicate entry\n");
994 }
995#else
996 content[i] = bstr;
997
998 for (j = 0; j < i; ++j)
999 ok(winetest_strcmpW(content[j], bstr), "got duplicate entry\n");
1000#endif
1001
1002 }
1003
1004 for (i = 0; i < 3; ++i)
1005 {
1007 content[i] = NULL;
1008 }
1009
1010 if (cache2)
1011 {
1012 for (i = 0; i < 5; ++i)
1013 {
1014 bstr = NULL;
1015 ole_check(IXMLDOMSchemaCollection_get_namespaceURI(cache2, i, &bstr));
1016 ok(bstr != NULL && *bstr, "expected non-empty string\n");
1017
1018#if __REACTOS__
1019 if (bstr != NULL && *bstr)
1020 {
1021 for (j = 0; j < i; ++j)
1022 ok(wcscmp(content[j], bstr), "got duplicate entry\n");
1023 }
1024#else
1025 for (j = 0; j < i; ++j)
1026 ok(winetest_strcmpW(content[j], bstr), "got duplicate entry\n");
1027#endif
1028 content[i] = bstr;
1029 }
1030
1031 for (i = 0; i < 5; ++i)
1032 {
1034 content[i] = NULL;
1035 }
1036 }
1037
1038 IXMLDOMSchemaCollection_Release(cache1);
1039 if (cache2) IXMLDOMSchemaCollection_Release(cache2);
1040
1041 free_bstrs();
1042}
#define E_FAIL
Definition: ddrawi.h:102
content
Definition: atl_ax.c:994
short VARIANT_BOOL
Definition: compat.h:2290
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
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 GLint GLint j
Definition: glfuncs.h:250
#define b
Definition: ke_i.h:79
static BSTR _bstr_(const char *str)
Definition: schema.c:451
static const CHAR xdr_schema3_xml[]
Definition: schema.c:75
#define EXPECT_HR(hr, hr_exp)
Definition: schema.c:37
#define create_document_version(v, iid)
Definition: schema.c:490
static const CHAR xsd_schema3_uri[]
Definition: schema.c:118
static const CHAR xsd_schema1_uri[]
Definition: schema.c:90
static void free_bstrs(void)
Definition: schema.c:458
static const CHAR xdr_schema1_uri[]
Definition: schema.c:40
static const CHAR xdr_schema2_uri[]
Definition: schema.c:58
static const CHAR xdr_schema1_xml[]
Definition: schema.c:41
static const CHAR xsd_schema2_uri[]
Definition: schema.c:104
static const CHAR xsd_schema1_xml[]
Definition: schema.c:91
#define create_cache_version(v, iid)
Definition: schema.c:494
static VARIANT _variantdoc_(void *doc)
Definition: schema.c:466
static const CHAR xsd_schema3_xml[]
Definition: schema.c:119
#define ole_expect(expr, expect)
Definition: schema.c:420
#define ole_check(expr)
Definition: schema.c:415
static const CHAR xdr_schema3_uri[]
Definition: schema.c:74
static const CHAR xdr_schema2_xml[]
Definition: schema.c:59
static const CHAR xsd_schema2_xml[]
Definition: schema.c:105
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
static int winetest_strcmpW(const WCHAR *str1, const WCHAR *str2)
Definition: test.h:97
#define E_POINTER
Definition: winerror.h:2365

Referenced by START_TEST().

◆ test_collection_refs()

static void test_collection_refs ( void  )
static

Definition at line 666 of file schema.c.

667{
668 IXMLDOMDocument2 *schema1, *schema2, *schema3;
669 IXMLDOMSchemaCollection *cache1, *cache2, *cache3;
671 LONG length;
672
673 schema1 = create_document(&IID_IXMLDOMDocument2);
674 ok(schema1 != NULL, "Failed to create a document.\n");
675
676 cache1 = create_cache(&IID_IXMLDOMSchemaCollection);
677 ok(cache1 != NULL, "Failed to create schema collection.\n");
678
679 if (!schema1 || !cache1)
680 {
681 if (schema1)
682 IXMLDOMDocument2_Release(schema1);
683 if (cache1)
684 IXMLDOMSchemaCollection_Release(cache1);
685 return;
686 }
687
688 schema2 = create_document(&IID_IXMLDOMDocument2);
689 schema3 = create_document(&IID_IXMLDOMDocument2);
690
691 cache2 = create_cache(&IID_IXMLDOMSchemaCollection);
692 cache3 = create_cache(&IID_IXMLDOMSchemaCollection);
693
694 ole_check(IXMLDOMDocument2_loadXML(schema1, _bstr_(xdr_schema1_xml), &b));
695 ok(b == VARIANT_TRUE, "failed to load XML\n");
696
697 ole_check(IXMLDOMDocument2_loadXML(schema2, _bstr_(xdr_schema2_xml), &b));
698 ok(b == VARIANT_TRUE, "failed to load XML\n");
699
700 ole_check(IXMLDOMDocument2_loadXML(schema3, _bstr_(xdr_schema3_xml), &b));
701 ok(b == VARIANT_TRUE, "failed to load XML\n");
702
703 ole_check(IXMLDOMSchemaCollection_add(cache1, _bstr_(xdr_schema1_uri), _variantdoc_(schema1)));
704 ole_check(IXMLDOMSchemaCollection_add(cache2, _bstr_(xdr_schema2_uri), _variantdoc_(schema2)));
705 ole_check(IXMLDOMSchemaCollection_add(cache3, _bstr_(xdr_schema3_uri), _variantdoc_(schema3)));
706
707 check_ref_expr(IXMLDOMDocument2_Release(schema1), 0);
708 check_ref_expr(IXMLDOMDocument2_Release(schema2), 0);
709 check_ref_expr(IXMLDOMDocument2_Release(schema3), 0);
710 schema1 = NULL;
711 schema2 = NULL;
712 schema3 = NULL;
713
714 /* releasing the original doc does not affect the schema cache */
715 ole_check(IXMLDOMSchemaCollection_get(cache1, _bstr_(xdr_schema1_uri), (IXMLDOMNode**)&schema1));
716 ole_check(IXMLDOMSchemaCollection_get(cache2, _bstr_(xdr_schema2_uri), (IXMLDOMNode**)&schema2));
717 ole_check(IXMLDOMSchemaCollection_get(cache3, _bstr_(xdr_schema3_uri), (IXMLDOMNode**)&schema3));
718
719 /* we get a read-only domdoc interface, created just for us */
720 if (schema1) check_refs(IXMLDOMDocument2, schema1, 1);
721 if (schema2) check_refs(IXMLDOMDocument2, schema2, 1);
722 if (schema3) check_refs(IXMLDOMDocument2, schema3, 1);
723
724 ole_expect(IXMLDOMSchemaCollection_addCollection(cache1, NULL), E_POINTER);
725 ole_check(IXMLDOMSchemaCollection_addCollection(cache2, cache1));
726 ole_check(IXMLDOMSchemaCollection_addCollection(cache3, cache2));
727
728 length = -1;
729 ole_check(IXMLDOMSchemaCollection_get_length(cache1, &length));
730 ok(length == 1, "expected length 1, got %i\n", length);
731
732 length = -1;
733 ole_check(IXMLDOMSchemaCollection_get_length(cache2, &length));
734 ok(length == 2, "expected length 2, got %i\n", length);
735
736 length = -1;
737 ole_check(IXMLDOMSchemaCollection_get_length(cache3, &length));
738 ok(length == 3, "expected length 3, got %i\n", length);
739
740
741 /* merging collections does not affect the ref count */
742 check_refs(IXMLDOMSchemaCollection, cache1, 1);
743 check_refs(IXMLDOMSchemaCollection, cache2, 1);
744 check_refs(IXMLDOMSchemaCollection, cache3, 1);
745
746 /* nor does it affect the domdoc instances */
747 if (schema1) check_refs(IXMLDOMDocument2, schema1, 1);
748 if (schema2) check_refs(IXMLDOMDocument2, schema2, 1);
749 if (schema3) check_refs(IXMLDOMDocument2, schema3, 1);
750
751 if (schema1) check_ref_expr(IXMLDOMDocument2_Release(schema1), 0);
752 if (schema2) check_ref_expr(IXMLDOMDocument2_Release(schema2), 0);
753 if (schema3) check_ref_expr(IXMLDOMDocument2_Release(schema3), 0);
754 schema1 = NULL;
755 schema2 = NULL;
756 schema3 = NULL;
757
758 /* releasing the domdoc instances doesn't change the cache */
759 ole_check(IXMLDOMSchemaCollection_get(cache1, _bstr_(xdr_schema1_uri), (IXMLDOMNode**)&schema1));
760 ole_check(IXMLDOMSchemaCollection_get(cache2, _bstr_(xdr_schema2_uri), (IXMLDOMNode**)&schema2));
761 ole_check(IXMLDOMSchemaCollection_get(cache3, _bstr_(xdr_schema3_uri), (IXMLDOMNode**)&schema3));
762
763 /* we can just get them again */
764 if (schema1) check_refs(IXMLDOMDocument2, schema1, 1);
765 if (schema2) check_refs(IXMLDOMDocument2, schema2, 1);
766 if (schema3) check_refs(IXMLDOMDocument2, schema3, 1);
767
768 /* releasing the caches does not affect the domdoc instances */
769 check_ref_expr(IXMLDOMSchemaCollection_Release(cache1), 0);
770 check_ref_expr(IXMLDOMSchemaCollection_Release(cache2), 0);
771 check_ref_expr(IXMLDOMSchemaCollection_Release(cache3), 0);
772
773 /* they're just for us */
774 if (schema1) check_refs(IXMLDOMDocument2, schema1, 1);
775 if (schema2) check_refs(IXMLDOMDocument2, schema2, 1);
776 if (schema3) check_refs(IXMLDOMDocument2, schema3, 1);
777
778 if (schema1) check_ref_expr(IXMLDOMDocument2_Release(schema1), 0);
779 if (schema2) check_ref_expr(IXMLDOMDocument2_Release(schema2), 0);
780 if (schema3) check_ref_expr(IXMLDOMDocument2_Release(schema3), 0);
781
782 free_bstrs();
783}
#define create_cache(iid)
Definition: schema.c:492
#define check_ref_expr(expr, n)
Definition: schema.c:403
#define check_refs(iface, obj, n)
Definition: schema.c:408
#define create_document(iid)
Definition: schema.c:488

Referenced by START_TEST().

◆ test_dispex()

static void test_dispex ( void  )
static

Definition at line 1665 of file schema.c.

1666{
1667 IXMLDOMSchemaCollection *cache;
1668 IDispatchEx *dispex;
1669 IUnknown *unk;
1670 HRESULT hr;
1671 DISPPARAMS dispparams;
1672 VARIANT arg, ret;
1673
1674 cache = create_cache(&IID_IXMLDOMSchemaCollection);
1675 if (!cache) return;
1676
1677 hr = IXMLDOMSchemaCollection_QueryInterface(cache, &IID_IUnknown, (void**)&unk);
1678 EXPECT_HR(hr, S_OK);
1679 test_obj_dispex(unk);
1680 IUnknown_Release(unk);
1681
1682 hr = IXMLDOMSchemaCollection_QueryInterface(cache, &IID_IDispatchEx, (void**)&dispex);
1683 ok(hr == S_OK, "got 0x%08x\n", hr);
1684
1685 V_VT(&arg) = VT_I4;
1686 V_I4(&arg) = 0;
1687 dispparams.cArgs = 1;
1688 dispparams.cNamedArgs = 0;
1689 dispparams.rgdispidNamedArgs = NULL;
1690 dispparams.rgvarg = &arg;
1691
1692 V_VT(&ret) = VT_EMPTY;
1693 V_DISPATCH(&ret) = (void*)0x1;
1694 hr = IDispatchEx_Invoke(dispex, DISPID_VALUE, &IID_NULL, 0, DISPATCH_METHOD, &dispparams, &ret, NULL, NULL);
1695 ok(hr == DISP_E_MEMBERNOTFOUND, "got 0x%08x\n", hr);
1696 ok(V_VT(&ret) == VT_EMPTY, "got %d\n", V_VT(&ret));
1697 ok(V_DISPATCH(&ret) == (void*)0x1, "got %p\n", V_DISPATCH(&ret));
1698
1699 IDispatchEx_Release(dispex);
1700 IXMLDOMSchemaCollection_Release(cache);
1701
1702 cache = create_cache_version(60, &IID_IXMLDOMSchemaCollection);
1703 if (cache)
1704 {
1706 IXMLDOMSchemaCollection_Release(cache);
1707 }
1708}
const GUID IID_IUnknown
@ VT_I4
Definition: compat.h:2298
@ VT_EMPTY
Definition: compat.h:2295
static void test_obj_dispex(IUnknown *obj)
Definition: schema.c:1613
struct stdole::DISPPARAMS DISPPARAMS
#define DISPATCH_METHOD
Definition: oleauto.h:1006
#define V_I4(A)
Definition: oleauto.h:247
#define IID_NULL
Definition: guiddef.h:98
Definition: cache.c:49
void * arg
Definition: msvc.h:10
#define DISP_E_MEMBERNOTFOUND
Definition: winerror.h:2512

Referenced by START_TEST().

◆ test_get()

static void test_get ( void  )
static

Definition at line 1710 of file schema.c.

1711{
1712 IXMLDOMSchemaCollection2 *cache;
1714 HRESULT hr;
1715
1716 cache = create_cache_version(60, &IID_IXMLDOMSchemaCollection2);
1717 if (!cache) return;
1718
1719 hr = IXMLDOMSchemaCollection2_get(cache, NULL, NULL);
1720 ok(hr == E_NOTIMPL || hr == E_POINTER /* win8 */, "got %08x\n", hr);
1721
1722 hr = IXMLDOMSchemaCollection2_get(cache, _bstr_("uri"), &node);
1724
1725 IXMLDOMSchemaCollection2_Release(cache);
1726
1727 cache = create_cache_version(40, &IID_IXMLDOMSchemaCollection2);
1728 if (!cache) return;
1729
1730 hr = IXMLDOMSchemaCollection2_get(cache, NULL, NULL);
1732
1733 hr = IXMLDOMSchemaCollection2_get(cache, _bstr_("uri"), &node);
1734 EXPECT_HR(hr, S_OK);
1735
1736 IXMLDOMSchemaCollection2_Release(cache);
1737 free_bstrs();
1738}
#define E_NOTIMPL
Definition: ddrawi.h:99
Definition: dlist.c:348

Referenced by START_TEST().

◆ test_ifaces()

static void test_ifaces ( void  )
static

Definition at line 1832 of file schema.c.

1833{
1834 IXMLDOMSchemaCollection2 *cache;
1835 IUnknown *unk;
1836 HRESULT hr;
1837
1838 cache = create_cache_version(60, &IID_IXMLDOMSchemaCollection2);
1839 if (!cache) return;
1840
1841 /* CLSID_XMLSchemaCache60 is returned as an interface (the same as IXMLDOMSchemaCollection2). */
1842 hr = IXMLDOMSchemaCollection2_QueryInterface(cache, &CLSID_XMLSchemaCache60, (void**)&unk);
1843 ok (hr == S_OK, "Could not get CLSID_XMLSchemaCache60 iface: %08x\n", hr);
1844 ok (unk == (IUnknown*)cache, "unk != cache\n");
1845
1846 IUnknown_Release(unk);
1847 IXMLDOMSchemaCollection2_Release(cache);
1848}

Referenced by START_TEST().

◆ test_length()

static void test_length ( void  )
static

Definition at line 785 of file schema.c.

786{
787 IXMLDOMDocument2 *schema1, *schema2, *schema3;
788 IXMLDOMSchemaCollection *cache;
790 VARIANT v;
791 LONG length;
792
793 schema1 = create_document(&IID_IXMLDOMDocument2);
794 schema2 = create_document(&IID_IXMLDOMDocument2);
795 schema3 = create_document(&IID_IXMLDOMDocument2);
796
797 cache = create_cache(&IID_IXMLDOMSchemaCollection);
798
799 if (!schema1 || !schema2 || !schema3 || !cache)
800 {
801 if (schema1) IXMLDOMDocument2_Release(schema1);
802 if (schema2) IXMLDOMDocument2_Release(schema2);
803 if (schema3) IXMLDOMDocument2_Release(schema3);
804
805 if (cache) IXMLDOMSchemaCollection_Release(cache);
806
807 return;
808 }
809
810 VariantInit(&v);
811
812 ole_check(IXMLDOMDocument2_loadXML(schema1, _bstr_(xdr_schema1_xml), &b));
813 ok(b == VARIANT_TRUE, "failed to load XML\n");
814
815 ole_check(IXMLDOMDocument2_loadXML(schema2, _bstr_(xdr_schema2_xml), &b));
816 ok(b == VARIANT_TRUE, "failed to load XML\n");
817
818 ole_check(IXMLDOMDocument2_loadXML(schema3, _bstr_(xdr_schema3_xml), &b));
819 ok(b == VARIANT_TRUE, "failed to load XML\n");
820
821 ole_expect(IXMLDOMSchemaCollection_get_length(cache, NULL), E_POINTER);
822
823 /* MSDN lies; removing a nonexistent entry produces no error */
824 ole_check(IXMLDOMSchemaCollection_remove(cache, NULL));
825 ole_check(IXMLDOMSchemaCollection_remove(cache, _bstr_(xdr_schema1_uri)));
826
827 length = -1;
828 ole_check(IXMLDOMSchemaCollection_get_length(cache, &length));
829 ok(length == 0, "expected length 0, got %i\n", length);
830
831 ole_check(IXMLDOMSchemaCollection_add(cache, _bstr_(xdr_schema1_uri), _variantdoc_(schema1)));
832
833 length = -1;
834 ole_check(IXMLDOMSchemaCollection_get_length(cache, &length));
835 ok(length == 1, "expected length 1, got %i\n", length);
836
837 ole_check(IXMLDOMSchemaCollection_add(cache, _bstr_(xdr_schema2_uri), _variantdoc_(schema2)));
838
839 length = -1;
840 ole_check(IXMLDOMSchemaCollection_get_length(cache, &length));
841 ok(length == 2, "expected length 2, got %i\n", length);
842
843 ole_check(IXMLDOMSchemaCollection_add(cache, _bstr_(xdr_schema3_uri), _variantdoc_(schema3)));
844
845 length = -1;
846 ole_check(IXMLDOMSchemaCollection_get_length(cache, &length));
847 ok(length == 3, "expected length 3, got %i\n", length);
848
849 /* adding with VT_NULL is the same as removing */
850 V_VT(&v) = VT_NULL;
851 ole_check(IXMLDOMSchemaCollection_add(cache, _bstr_(xdr_schema1_uri), v));
852
853 length = -1;
854 ole_check(IXMLDOMSchemaCollection_get_length(cache, &length));
855 ok(length == 2, "expected length 2, got %i\n", length);
856
857 ole_check(IXMLDOMSchemaCollection_remove(cache, _bstr_(xdr_schema2_uri)));
858
859 length = -1;
860 ole_check(IXMLDOMSchemaCollection_get_length(cache, &length));
861 ok(length == 1, "expected length 1, got %i\n", length);
862
863 ole_check(IXMLDOMSchemaCollection_remove(cache, _bstr_(xdr_schema3_uri)));
864
865 length = -1;
866 ole_check(IXMLDOMSchemaCollection_get_length(cache, &length));
867 ok(length == 0, "expected length 0, got %i\n", length);
868
869 IXMLDOMDocument2_Release(schema1);
870 IXMLDOMDocument2_Release(schema2);
871 IXMLDOMDocument2_Release(schema3);
872 IXMLDOMSchemaCollection_Release(cache);
873
874 free_bstrs();
875}
@ VT_NULL
Definition: compat.h:2296
void WINAPI VariantInit(VARIANTARG *pVarg)
Definition: variant.c:568

Referenced by START_TEST().

◆ test_obj_dispex()

static void test_obj_dispex ( IUnknown obj)
static

Definition at line 1613 of file schema.c.

1614{
1616 IDispatchEx *dispex;
1617 IUnknown *unk;
1618 DWORD props;
1619 UINT ticnt;
1620 HRESULT hr;
1621 BSTR name;
1622
1623 hr = IUnknown_QueryInterface(obj, &IID_IDispatchEx, (void**)&dispex);
1624 EXPECT_HR(hr, S_OK);
1625 if (FAILED(hr)) return;
1626
1627 ticnt = 0;
1628 hr = IDispatchEx_GetTypeInfoCount(dispex, &ticnt);
1629 EXPECT_HR(hr, S_OK);
1630 ok(ticnt == 1, "ticnt=%u\n", ticnt);
1631
1632 name = SysAllocString(L"*");
1633 hr = IDispatchEx_DeleteMemberByName(dispex, name, fdexNameCaseSensitive);
1636
1637 hr = IDispatchEx_DeleteMemberByDispID(dispex, dispid);
1639
1640 props = 0;
1641 hr = IDispatchEx_GetMemberProperties(dispex, dispid, grfdexPropCanAll, &props);
1643 ok(props == 0, "expected 0 got %d\n", props);
1644
1645 hr = IDispatchEx_GetMemberName(dispex, dispid, &name);
1648
1649 hr = IDispatchEx_GetNextDispID(dispex, fdexEnumDefault, DISPID_XMLDOM_SCHEMACOLLECTION_ADD, &dispid);
1651
1652 unk = (IUnknown*)0xdeadbeef;
1653 hr = IDispatchEx_GetNameSpaceParent(dispex, &unk);
1655 ok(unk == (IUnknown*)0xdeadbeef, "got %p\n", unk);
1656
1657 name = SysAllocString(L"testprop");
1658 hr = IDispatchEx_GetDispID(dispex, name, fdexNameEnsure, &dispid);
1659 ok(hr == DISP_E_UNKNOWNNAME, "got 0x%08x\n", hr);
1661
1662 IDispatchEx_Release(dispex);
1663}
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
static VARIANTARG static DISPID
Definition: ordinal.c:52
#define DISPID_XMLDOM_SCHEMACOLLECTION_ADD
Definition: msxml2did.h:292
#define DISPID_SAX_XMLREADER_GETFEATURE
Definition: msxml2did.h:342
unsigned int UINT
Definition: ndis.h:50
#define L(x)
Definition: ntvdm.h:50
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:238
static const WCHAR props[]
Definition: wbemdisp.c:288
#define DISP_E_UNKNOWNNAME
Definition: winerror.h:2515

Referenced by test_dispex().

◆ test_regex()

static void test_regex ( void  )
static

Definition at line 1130 of file schema.c.

1131{
1132 struct regex_test {
1133 const WCHAR *regex;
1134 const WCHAR *input;
1135 };
1136
1137 struct regex_test tests[] = {
1138 { L"\\!", L"!" },
1139 { L"\\\"", L"\"" },
1140 { L"\\#", L"#" },
1141 { L"\\$", L"$" },
1142 { L"\\%", L"%" },
1143 { L"\\,", L"," },
1144 { L"\\/", L"/" },
1145 { L"\\:", L":" },
1146 { L"\\;", L";" },
1147 { L"\\=", L"=" },
1148 { L"\\>", L">" },
1149 { L"\\@", L"@" },
1150 { L"\\`", L"`" },
1151 { L"\\~", L"~" },
1152 { L"\\uCAFE", L"\xCAFE" },
1153 /* non-BMP character in surrogate pairs: */
1154 { L"\\uD83D\\uDE00", L"\xD83D\xDE00" },
1155 /* "x{,2}" is non-standard and only works on libxml2 <= v2.9.10 */
1156 { L"x{0,2}", L"x" }
1157 };
1158
1159 int i;
1160
1161 for (i = 0; i < ARRAY_SIZE(tests); i++)
1162 {
1163 IXMLDOMDocument2 *doc40, *doc60;
1164 IXMLDOMDocument2 *schema40, *schema60;
1165 IXMLDOMSchemaCollection *cache40, *cache60;
1166
1167 doc40 = create_document_version(40, &IID_IXMLDOMDocument2);
1168 doc60 = create_document_version(60, &IID_IXMLDOMDocument2);
1169 schema40 = create_document_version(40, &IID_IXMLDOMDocument2);
1170 schema60 = create_document_version(60, &IID_IXMLDOMDocument2);
1171 cache40 = create_cache_version(40, &IID_IXMLDOMSchemaCollection);
1172 cache60 = create_cache_version(60, &IID_IXMLDOMSchemaCollection);
1173
1174 if (doc60 && schema60 && cache60)
1175 {
1176 HRESULT hr = validate_regex_document(doc60, schema60, cache60, tests[i].regex, tests[i].input);
1177 ok(hr == S_OK, "got 0x%08x for for version 60 regex %s input %s\n",
1179 if (doc40 && schema40 && cache40)
1180 {
1181 hr = validate_regex_document(doc40, schema40, cache40, tests[i].regex, tests[i].input);
1182 ok(hr == S_OK, "got 0x%08x version 40 regex %s input %s\n",
1184 }
1185 }
1186 else
1187 ok(0, "out of memory\n");
1188
1189 if (doc40)
1190 IXMLDOMDocument2_Release(doc40);
1191 if (doc60)
1192 IXMLDOMDocument2_Release(doc60);
1193 if (schema40)
1194 IXMLDOMDocument2_Release(schema40);
1195 if (schema60)
1196 IXMLDOMDocument2_Release(schema60);
1197 if (cache40)
1198 IXMLDOMSchemaCollection_Release(cache40);
1199 if (cache60)
1200 IXMLDOMSchemaCollection_Release(cache60);
1201 }
1202}
GLenum GLenum GLenum input
Definition: glext.h:9031
#define wine_dbgstr_w
Definition: kernel32.h:34
static struct test_info tests[]
static HRESULT validate_regex_document(IXMLDOMDocument2 *doc, IXMLDOMDocument2 *schema, IXMLDOMSchemaCollection *cache, const WCHAR *regex, const WCHAR *input)
Definition: schema.c:1044
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by START_TEST().

◆ test_remove()

static void test_remove ( void  )
static

Definition at line 1740 of file schema.c.

1741{
1742 IXMLDOMSchemaCollection2 *cache;
1743 IXMLDOMDocument *doc;
1745 HRESULT hr;
1746 VARIANT v;
1747 LONG len;
1748
1749 cache = create_cache_version(60, &IID_IXMLDOMSchemaCollection2);
1750 if (!cache) return;
1751
1752 doc = create_document_version(60, &IID_IXMLDOMDocument);
1753 ok(doc != NULL, "got %p\n", doc);
1754
1755 hr = IXMLDOMDocument_loadXML(doc, _bstr_(xsd_schema1_xml), &b);
1756 EXPECT_HR(hr, S_OK);
1757
1758 V_VT(&v) = VT_DISPATCH;
1759 V_DISPATCH(&v) = (IDispatch*)doc;
1760 hr = IXMLDOMSchemaCollection2_add(cache, _bstr_(xsd_schema1_uri), v);
1761 EXPECT_HR(hr, S_OK);
1762
1763 len = -1;
1764 hr = IXMLDOMSchemaCollection2_get_length(cache, &len);
1765 EXPECT_HR(hr, S_OK);
1766 ok(len == 1, "got %d\n", len);
1767
1768 /* ::remove() is a stub for version 6 */
1769 hr = IXMLDOMSchemaCollection2_remove(cache, NULL);
1771
1772 hr = IXMLDOMSchemaCollection2_remove(cache, _bstr_("invaliduri"));
1774
1775 hr = IXMLDOMSchemaCollection2_remove(cache, _bstr_(xsd_schema1_uri));
1777
1778 len = -1;
1779 hr = IXMLDOMSchemaCollection2_get_length(cache, &len);
1780 EXPECT_HR(hr, S_OK);
1781 ok(len == 1, "got %d\n", len);
1782
1783 IXMLDOMDocument_Release(doc);
1784 IXMLDOMSchemaCollection2_Release(cache);
1785 free_bstrs();
1786
1787 /* ::remove() works for version 4 */
1788 cache = create_cache_version(40, &IID_IXMLDOMSchemaCollection2);
1789 if (!cache) return;
1790
1791 doc = create_document_version(40, &IID_IXMLDOMDocument);
1792 ok(doc != NULL, "got %p\n", doc);
1793
1794 hr = IXMLDOMDocument_loadXML(doc, _bstr_(xsd_schema1_xml), &b);
1795 EXPECT_HR(hr, S_OK);
1796
1797 V_VT(&v) = VT_DISPATCH;
1798 V_DISPATCH(&v) = (IDispatch*)doc;
1799 hr = IXMLDOMSchemaCollection2_add(cache, _bstr_(xsd_schema1_uri), v);
1800 EXPECT_HR(hr, S_OK);
1801
1802 len = -1;
1803 hr = IXMLDOMSchemaCollection2_get_length(cache, &len);
1804 EXPECT_HR(hr, S_OK);
1805 ok(len == 1, "got %d\n", len);
1806
1807 hr = IXMLDOMSchemaCollection2_remove(cache, NULL);
1808 EXPECT_HR(hr, S_OK);
1809
1810 hr = IXMLDOMSchemaCollection2_remove(cache, _bstr_("invaliduri"));
1811 EXPECT_HR(hr, S_OK);
1812
1813 len = -1;
1814 hr = IXMLDOMSchemaCollection2_get_length(cache, &len);
1815 EXPECT_HR(hr, S_OK);
1816 ok(len == 1, "got %d\n", len);
1817
1818 hr = IXMLDOMSchemaCollection2_remove(cache, _bstr_(xsd_schema1_uri));
1819 EXPECT_HR(hr, S_OK);
1820
1821 len = -1;
1822 hr = IXMLDOMSchemaCollection2_get_length(cache, &len);
1823 EXPECT_HR(hr, S_OK);
1824 ok(len == 0, "got %d\n", len);
1825
1826 IXMLDOMDocument_Release(doc);
1827 IXMLDOMSchemaCollection2_Release(cache);
1828
1829 free_bstrs();
1830}

Referenced by START_TEST().

◆ test_schema_refs()

static void test_schema_refs ( void  )
static

Definition at line 496 of file schema.c.

497{
498 static const WCHAR xdr_schema_xml[] =
499 L"<Schema xmlns=\"urn:schemas-microsoft-com:xml-data\"\nxmlns:dt=\"urn:schemas-microsoft-com:datatypes\">\n</Schema>\n";
500 IXMLDOMDocument2 *doc;
502 IXMLDOMSchemaCollection *cache;
503 VARIANT v;
505 BSTR str;
506 LONG len;
507 HRESULT hr;
508
509 doc = create_document(&IID_IXMLDOMDocument2);
510 if (!doc)
511 return;
512
513 cache = create_cache(&IID_IXMLDOMSchemaCollection);
514 if(!cache)
515 {
516 IXMLDOMDocument2_Release(doc);
517 return;
518 }
519
520 VariantInit(&v);
521 str = SysAllocString(xdr_schema_xml);
522 ole_check(IXMLDOMDocument2_loadXML(doc, str, &b));
523 ok(b == VARIANT_TRUE, "b %04x\n", b);
525
526 node = (void*)0xdeadbeef;
527 ole_check(IXMLDOMSchemaCollection_get(cache, NULL, &node));
528 ok(node == NULL, "%p\n", node);
529
530 /* NULL uri pointer, still adds a document */
531 ole_check(IXMLDOMSchemaCollection_add(cache, NULL, _variantdoc_(doc)));
532 len = -1;
533 ole_check(IXMLDOMSchemaCollection_get_length(cache, &len));
534 ok(len == 1, "got %d\n", len);
535 /* read back - empty valid BSTR */
536 str = NULL;
537 ole_check(IXMLDOMSchemaCollection_get_namespaceURI(cache, 0, &str));
538 ok(str && *str == 0, "got %p\n", str);
540
541 node = NULL;
542 ole_check(IXMLDOMSchemaCollection_get(cache, NULL, &node));
543 ok(node != NULL, "%p\n", node);
544#if __REACTOS__
545 if (node)
546#endif
547 IXMLDOMNode_Release(node);
548
549 node = NULL;
550 str = SysAllocString(L"");
551 ole_check(IXMLDOMSchemaCollection_get(cache, str, &node));
552 ok(node != NULL, "%p\n", node);
553#if __REACTOS__
554 if (node)
555#endif
556 IXMLDOMNode_Release(node);
558
559 /* remove with NULL uri */
560 ole_check(IXMLDOMSchemaCollection_remove(cache, NULL));
561 len = -1;
562 ole_check(IXMLDOMSchemaCollection_get_length(cache, &len));
563 ok(len == 0, "got %d\n", len);
564
565 /* same, but with VT_UNKNOWN type */
566 V_VT(&v) = VT_UNKNOWN;
567 V_UNKNOWN(&v) = (IUnknown*)doc;
568 hr = IXMLDOMSchemaCollection_add(cache, NULL, v);
569 ok(hr == S_OK, "got 0x%08x\n", hr);
570
571 len = -1;
572 hr = IXMLDOMSchemaCollection_get_length(cache, &len);
573 ok(hr == S_OK, "got 0x%08x\n", hr);
574 ok(len == 1, "got %d\n", len);
575
576 hr = IXMLDOMSchemaCollection_remove(cache, NULL);
577 ok(hr == S_OK, "got 0x%08x\n", hr);
578 len = -1;
579 hr = IXMLDOMSchemaCollection_get_length(cache, &len);
580 ok(hr == S_OK, "got 0x%08x\n", hr);
581 ok(len == 0, "got %d\n", len);
582
583 str = SysAllocString(L"x-schema:test.xml");
584 ole_check(IXMLDOMSchemaCollection_add(cache, str, _variantdoc_(doc)));
585
586 /* IXMLDOMSchemaCollection_add doesn't add a ref on doc */
587 check_refs(IXMLDOMDocument2, doc, 1);
588
590
591 V_VT(&v) = VT_INT;
592 ole_expect(IXMLDOMDocument2_get_schemas(doc, &v), S_FALSE);
593 ok(V_VT(&v) == VT_NULL, "vt %x\n", V_VT(&v));
594
595 check_ref_expr(IXMLDOMSchemaCollection_AddRef(cache), 2);
596 V_VT(&v) = VT_DISPATCH;
598
599 /* check that putref_schemas takes a ref */
600 ole_check(IXMLDOMDocument2_putref_schemas(doc, v));
601 check_refs(IXMLDOMSchemaCollection, cache, 3);
602
603 VariantClear(&v); /* refs now 2 */
604
605 V_VT(&v) = VT_INT;
606 /* check that get_schemas adds a ref */
607 ole_check(IXMLDOMDocument2_get_schemas(doc, &v));
608 ok(V_VT(&v) == VT_DISPATCH, "vt %x\n", V_VT(&v));
609 check_refs(IXMLDOMSchemaCollection, cache, 3);
610
611 /* get_schemas doesn't release a ref if passed VT_DISPATCH - ie it doesn't call VariantClear() */
612 ole_check(IXMLDOMDocument2_get_schemas(doc, &v));
613 ok(V_VT(&v) == VT_DISPATCH, "vt %x\n", V_VT(&v));
614 check_refs(IXMLDOMSchemaCollection, cache, 4);
615
616 /* release the two refs returned by get_schemas */
617 check_ref_expr(IXMLDOMSchemaCollection_Release(cache), 3);
618 check_ref_expr(IXMLDOMSchemaCollection_Release(cache), 2);
619
620 /* check that taking another ref on the document doesn't change the schema's ref count */
621 check_ref_expr(IXMLDOMDocument2_AddRef(doc), 2);
622 check_refs(IXMLDOMSchemaCollection, cache, 2);
623 check_ref_expr(IXMLDOMDocument2_Release(doc), 1);
624
625 /* call putref_schema with some odd variants */
626 V_VT(&v) = VT_INT;
627 ole_expect(IXMLDOMDocument2_putref_schemas(doc, v), E_FAIL);
628 check_refs(IXMLDOMSchemaCollection, cache, 2);
629
630 /* calling with VT_EMPTY releases the schema */
631 V_VT(&v) = VT_EMPTY;
632 ole_check(IXMLDOMDocument2_putref_schemas(doc, v));
633 check_refs(IXMLDOMSchemaCollection, cache, 1);
634
635 /* try setting with VT_UNKNOWN */
636 check_ref_expr(IXMLDOMSchemaCollection_AddRef(cache), 2);
637 V_VT(&v) = VT_UNKNOWN;
639 ole_check(IXMLDOMDocument2_putref_schemas(doc, v));
640 check_refs(IXMLDOMSchemaCollection, cache, 3);
641
642 VariantClear(&v); /* refs now 2 */
643
644 /* calling with VT_NULL releases the schema */
645 V_VT(&v) = VT_NULL;
646 ole_check(IXMLDOMDocument2_putref_schemas(doc, v));
647 check_refs(IXMLDOMSchemaCollection, cache, 1);
648
649 /* refs now 1 */
650 /* set again */
651 check_ref_expr(IXMLDOMSchemaCollection_AddRef(cache), 2);
652 V_VT(&v) = VT_UNKNOWN;
654 ole_check(IXMLDOMDocument2_putref_schemas(doc, v));
655 check_refs(IXMLDOMSchemaCollection, cache, 3);
656
657 VariantClear(&v); /* refs now 2 */
658
659 /* release the final ref on the doc which should release its ref on the schema */
660 check_ref_expr(IXMLDOMDocument2_Release(doc), 0);
661
662 check_refs(IXMLDOMSchemaCollection, cache, 1);
663 check_ref_expr(IXMLDOMSchemaCollection_Release(cache), 0);
664}
@ VT_INT
Definition: compat.h:2316
@ VT_UNKNOWN
Definition: compat.h:2308
#define V_UNKNOWN(A)
Definition: oleauto.h:281
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG *pVarg)
Definition: variant.c:648
#define S_FALSE
Definition: winerror.h:2357

Referenced by START_TEST().

◆ test_validate_on_load()

static void test_validate_on_load ( void  )
static

Definition at line 1593 of file schema.c.

1594{
1595 IXMLDOMSchemaCollection2 *cache;
1597 HRESULT hr;
1598
1599 cache = create_cache_version(40, &IID_IXMLDOMSchemaCollection2);
1600 if (!cache) return;
1601
1602 hr = IXMLDOMSchemaCollection2_get_validateOnLoad(cache, NULL);
1604
1605 b = VARIANT_FALSE;
1606 hr = IXMLDOMSchemaCollection2_get_validateOnLoad(cache, &b);
1607 EXPECT_HR(hr, S_OK);
1608 ok(b == VARIANT_TRUE, "got %d\n", b);
1609
1610 IXMLDOMSchemaCollection2_Release(cache);
1611}

Referenced by START_TEST().

◆ test_XDR_datatypes()

static void test_XDR_datatypes ( void  )
static

Definition at line 1382 of file schema.c.

1383{
1384 IXMLDOMDocument2 *doc, *schema, *doc2;
1385 IXMLDOMSchemaCollection* cache;
1386 const xdr_datatypes *ptr;
1389 HRESULT hr;
1390 VARIANT v;
1391 BSTR bstr;
1392 LONG l;
1393
1394 VariantInit(&v);
1395
1396 doc = create_document(&IID_IXMLDOMDocument2);
1397 doc2 = create_document(&IID_IXMLDOMDocument2);
1398 schema = create_document(&IID_IXMLDOMDocument2);
1399 cache = create_cache(&IID_IXMLDOMSchemaCollection);
1400
1401 if (!doc || !doc2 || !schema || !cache)
1402 {
1403 if (doc) IXMLDOMDocument2_Release(doc);
1404 if (doc2) IXMLDOMDocument2_Release(doc2);
1405 if (schema) IXMLDOMDocument2_Release(schema);
1406 if (cache) IXMLDOMSchemaCollection_Release(cache);
1407 return;
1408 }
1409
1410 hr = IXMLDOMDocument2_loadXML(doc, _bstr_(szDatatypeXML), &b);
1411 EXPECT_HR(hr, S_OK);
1412 ok(b == VARIANT_TRUE, "failed to load XML string\n");
1413
1414 hr = IXMLDOMDocument2_loadXML(doc2, _bstr_(szDatatypeXML), &b);
1415 EXPECT_HR(hr, S_OK);
1416 ok(b == VARIANT_TRUE, "failed to load XML string\n");
1417
1418 hr = IXMLDOMDocument2_loadXML(schema, _bstr_(szDatatypeXDR), &b);
1419 EXPECT_HR(hr, S_OK);
1420 ok(b == VARIANT_TRUE, "failed to load XML string\n");
1421
1422 err = NULL;
1423 hr = IXMLDOMDocument2_validate(doc, &err);
1425 ok(err != NULL, "domdoc_validate() should always set err\n");
1426 hr = IXMLDOMParseError_get_errorCode(err, &l);
1427 EXPECT_HR(hr, S_OK);
1428 ok(l == E_XML_NODTD, "got %08x\n", l);
1429 IXMLDOMParseError_Release(err);
1430
1431 err = NULL;
1432 hr = IXMLDOMDocument2_validate(doc2, &err);
1434 ok(err != NULL, "domdoc_validate() should always set err\n");
1435 hr = IXMLDOMParseError_get_errorCode(err, &l);
1436 EXPECT_HR(hr, S_OK);
1437 ok(l == E_XML_NODTD, "got %08x\n", l);
1438 IXMLDOMParseError_Release(err);
1439
1440 /* now load the schema */
1441 V_VT(&v) = VT_DISPATCH;
1442 V_DISPATCH(&v) = NULL;
1443 hr = IXMLDOMDocument2_QueryInterface(schema, &IID_IDispatch, (void**)&V_DISPATCH(&v));
1444 EXPECT_HR(hr, S_OK);
1445 ok(V_DISPATCH(&v) != NULL, "failed to get IDispatch interface\n");
1446 hr = IXMLDOMSchemaCollection_add(cache, _bstr_("urn:x-schema:datatype-test-xdr"), v);
1447 EXPECT_HR(hr, S_OK);
1448 VariantClear(&v);
1449
1450 /* associate the cache to the doc */
1451 V_VT(&v) = VT_DISPATCH;
1452 V_DISPATCH(&v) = NULL;
1453 hr = IXMLDOMSchemaCollection_QueryInterface(cache, &IID_IDispatch, (void**)&V_DISPATCH(&v));
1454 EXPECT_HR(hr, S_OK);
1455 ok(V_DISPATCH(&v) != NULL, "failed to get IDispatch interface\n");
1456 hr = IXMLDOMDocument2_putref_schemas(doc2, v);
1457 EXPECT_HR(hr, S_OK);
1458 VariantClear(&v);
1459
1460 /* validate the doc */
1461 err = NULL;
1462 l = 0;
1463 bstr = NULL;
1464 hr = IXMLDOMDocument2_validate(doc2, &err);
1465 EXPECT_HR(hr, S_OK);
1466 ok(err != NULL, "domdoc_validate() should always set err\n");
1467 hr = IXMLDOMParseError_get_errorCode(err, &l);
1469 hr = IXMLDOMParseError_get_reason(err, &bstr);
1471 ok(l == 0, "got %08x : %s\n", l, wine_dbgstr_w(bstr));
1472 SysFreeString(bstr);
1473 IXMLDOMParseError_Release(err);
1474
1476 while (ptr->query)
1477 {
1479 VARIANT type;
1480
1481 /* check data types without the schema */
1482 hr = IXMLDOMDocument2_selectSingleNode(doc, _bstr_(ptr->query), &node);
1483 EXPECT_HR(hr, S_OK);
1484 ok(node != NULL, "expected node\n");
1485
1486 V_VT(&type) = VT_EMPTY;
1487 V_BSTR(&type) = (void*)-1;
1488 hr = IXMLDOMNode_get_dataType(node, &type);
1490 ok(V_VT(&type) == VT_NULL, "got type %i\n", V_VT(&type));
1491 /* when returning VT_NULL, the pointer is set to NULL */
1492 ok(V_BSTR(&type) == NULL, "got %p\n", V_BSTR(&type));
1493
1495 hr = IXMLDOMNode_get_nodeTypedValue(node, &type);
1496 EXPECT_HR(hr, S_OK);
1497 ok(V_VT(&type) == VT_BSTR, "got variant type %i\n", V_VT(&v));
1499 IXMLDOMNode_Release(node);
1500
1501 /* check the data with schema */
1502 node = NULL;
1503 hr = IXMLDOMDocument2_selectSingleNode(doc2, _bstr_(ptr->query), &node);
1504 EXPECT_HR(hr, S_OK);
1505 ok(node != NULL, "expected node\n");
1506
1507 V_VT(&type) = VT_EMPTY;
1508 hr = IXMLDOMNode_get_dataType(node, &type);
1509 if (ptr->typename)
1510 {
1511 EXPECT_HR(hr, S_OK);
1512 ok(V_VT(&type) == VT_BSTR, "got type %i\n", V_VT(&type));
1513 ok(!lstrcmpW(V_BSTR(&type), _bstr_(ptr->typename)), "got %s\n", wine_dbgstr_w(V_BSTR(&type)));
1514 }
1515 else
1516 {
1518 ok(V_VT(&type) == VT_NULL, "%s: got type %i\n", ptr->query, V_VT(&type));
1519 }
1521
1522 VariantClear(&v);
1523 hr = IXMLDOMNode_get_nodeTypedValue(node, &v);
1524 EXPECT_HR(hr, S_OK);
1525
1526 todo_wine_if(ptr->todo)
1527 ok(V_VT(&v) == ptr->type_schema, "%s: got variant type %i\n", ptr->query, V_VT(&v));
1528
1529 switch (ptr->type_schema)
1530 {
1531 case VT_BOOL:
1532 ok(V_BOOL(&v) == VARIANT_TRUE, "got %x\n", V_BOOL(&v));
1533 break;
1534 case VT_I1:
1535 ok(V_I1(&v) == 42, "got %i\n", V_I1(&v));
1536 break;
1537 case VT_I2:
1538 ok(V_I2(&v) == 420, "got %i\n", V_I2(&v));
1539 break;
1540 case VT_I4:
1541 if (!strcmp(ptr->typename, "int"))
1542 ok(V_I4(&v) == 42, "got %i\n", V_I4(&v));
1543 else if (!strcmp(ptr->typename, "char"))
1544 todo_wine
1545 ok(V_I4(&v) == 'u', "got %x\n", V_I4(&v));
1546 else
1547 ok(V_I4(&v) == -420000000, "got %i\n", V_I4(&v));
1548 break;
1549 case VT_I8:
1550 expect_int64(V_I8(&v), -4200000000, 10);
1551 break;
1552 case VT_R4:
1553 ok(V_R4(&v) == (float)3.14159265, "got %f\n", V_R4(&v));
1554 break;
1555 case VT_R8:
1556 if (!strcmp(ptr->typename, "float"))
1557 ok(V_R8(&v) == 3.14159, "got %f\n", V_R8(&v));
1558 else
1559 todo_wine
1560 ok(V_R8(&v) == 3.14159265358979323846, "got %.20f\n", V_R8(&v));
1561 break;
1562 case VT_UI1:
1563 ok(V_UI1(&v) == 0xFF, "got %02x\n", V_UI1(&v));
1564 break;
1565 case VT_UI2:
1566 ok(V_UI2(&v) == 0xFFFF, "got %04x\n", V_UI2(&v));
1567 break;
1568 case VT_UI4:
1569 ok(V_UI4(&v) == 0xFFFFFFFF, "got %08x\n", V_UI4(&v));
1570 break;
1571 case VT_UI8:
1572 expect_uint64(V_UI8(&v), 0xFFFFFFFFFFFFFFFF, 16);
1573 break;
1574 default:
1575 ;
1576 }
1577
1578 VariantClear(&v);
1579
1580 IXMLDOMNode_Release(node);
1581
1582 ptr++;
1583 }
1584
1585 IXMLDOMDocument2_Release(schema);
1586 IXMLDOMDocument2_Release(doc);
1587 IXMLDOMDocument2_Release(doc2);
1588 IXMLDOMSchemaCollection_Release(cache);
1589
1590 free_bstrs();
1591}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
r l[0]
Definition: byte_order.h:168
@ VT_UI8
Definition: compat.h:2315
@ VT_BSTR
Definition: compat.h:2303
@ VT_R4
Definition: compat.h:2299
@ VT_UI2
Definition: compat.h:2312
@ VT_R8
Definition: compat.h:2300
@ VT_I8
Definition: compat.h:2314
@ VT_I1
Definition: compat.h:2310
@ VT_BOOL
Definition: compat.h:2306
@ VT_I2
Definition: compat.h:2297
@ VT_UI4
Definition: compat.h:2313
@ VT_UI1
Definition: compat.h:2311
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4242
switch(r->id)
Definition: btrfs.c:3046
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLdouble s
Definition: gl.h:2039
const WCHAR * schema
static PVOID ptr
Definition: dispmode.c:27
#define todo_wine_if(is_todo)
Definition: custom.c:86
#define todo_wine
Definition: custom.c:89
static const xdr_datatypes xdr_datatypes_data[]
Definition: schema.c:1350
#define expect_int64(expr, x, base)
Definition: schema.c:436
static const CHAR szDatatypeXDR[]
Definition: schema.c:132
#define expect_uint64(expr, x, base)
Definition: schema.c:437
static const CHAR szDatatypeXML[]
Definition: schema.c:208
#define V_UI1(A)
Definition: oleauto.h:266
#define V_I8(A)
Definition: oleauto.h:249
#define V_BOOL(A)
Definition: oleauto.h:224
#define V_UI2(A)
Definition: oleauto.h:268
#define V_I1(A)
Definition: oleauto.h:243
#define V_BSTR(A)
Definition: oleauto.h:226
#define V_R4(A)
Definition: oleauto.h:260
#define V_UI4(A)
Definition: oleauto.h:270
#define V_R8(A)
Definition: oleauto.h:262
#define V_UI8(A)
Definition: oleauto.h:272
#define V_I2(A)
Definition: oleauto.h:245
const GUID IID_IDispatch
#define err(...)

Referenced by START_TEST().

◆ test_XDR_schemas()

static void test_XDR_schemas ( void  )
static

Definition at line 1204 of file schema.c.

1205{
1206 IXMLDOMDocument2 *doc, *schema;
1207 IXMLDOMSchemaCollection* cache;
1210 VARIANT v;
1211 BSTR bstr;
1212
1213 doc = create_document(&IID_IXMLDOMDocument2);
1214 schema = create_document(&IID_IXMLDOMDocument2);
1215 cache = create_cache(&IID_IXMLDOMSchemaCollection);
1216
1217 if (!doc || !schema || !cache)
1218 {
1219 if (doc) IXMLDOMDocument2_Release(doc);
1220 if (schema) IXMLDOMDocument2_Release(schema);
1221 if (cache) IXMLDOMSchemaCollection_Release(cache);
1222
1223 return;
1224 }
1225
1226 VariantInit(&v);
1227
1228 ole_check(IXMLDOMDocument2_loadXML(doc, _bstr_(szOpenSeqXML1), &b));
1229 ok(b == VARIANT_TRUE, "failed to load XML string\n");
1230
1231 ole_check(IXMLDOMDocument2_loadXML(schema, _bstr_(szOpenSeqXDR), &b));
1232 ok(b == VARIANT_TRUE, "failed to load XML string\n");
1233
1234 /* load the schema */
1235 V_VT(&v) = VT_DISPATCH;
1236 V_DISPATCH(&v) = NULL;
1237 ole_check(IXMLDOMDocument2_QueryInterface(schema, &IID_IDispatch, (void**)&V_DISPATCH(&v)));
1238 ok(V_DISPATCH(&v) != NULL, "failed to get IDispatch interface\n");
1239 ole_check(IXMLDOMSchemaCollection_add(cache, _bstr_(""), v));
1240 VariantClear(&v);
1241
1242 /* associate the cache to the doc */
1243 V_VT(&v) = VT_DISPATCH;
1244 V_DISPATCH(&v) = NULL;
1245 ole_check(IXMLDOMSchemaCollection_QueryInterface(cache, &IID_IDispatch, (void**)&V_DISPATCH(&v)));
1246 ok(V_DISPATCH(&v) != NULL, "failed to get IDispatch interface\n");
1247 ole_check(IXMLDOMDocument2_putref_schemas(doc, v));
1248 VariantClear(&v);
1249
1250 /* validate the doc
1251 * only declared elements in the declared order
1252 * this is fine */
1253 err = NULL;
1254 bstr = NULL;
1255 ole_check(IXMLDOMDocument2_validate(doc, &err));
1256 ok(err != NULL, "domdoc_validate() should always set err\n");
1257 ole_expect(IXMLDOMParseError_get_reason(err, &bstr), S_FALSE);
1258 ok(IXMLDOMParseError_get_reason(err, &bstr) == S_FALSE, "got error: %s\n", wine_dbgstr_w(bstr));
1259 SysFreeString(bstr);
1260 IXMLDOMParseError_Release(err);
1261
1262 /* load the next doc */
1263 IXMLDOMDocument2_Release(doc);
1264 doc = create_document(&IID_IXMLDOMDocument2);
1265 ole_check(IXMLDOMDocument2_loadXML(doc, _bstr_(szOpenSeqXML2), &b));
1266 ok(b == VARIANT_TRUE, "failed to load XML string\n");
1267
1268 /* associate the cache to the doc */
1269 V_VT(&v) = VT_DISPATCH;
1270 V_DISPATCH(&v) = NULL;
1271 ole_check(IXMLDOMSchemaCollection_QueryInterface(cache, &IID_IDispatch, (void**)&V_DISPATCH(&v)));
1272 ok(V_DISPATCH(&v) != NULL, "failed to get IDispatch interface\n");
1273 ole_check(IXMLDOMDocument2_putref_schemas(doc, v));
1274 VariantClear(&v);
1275
1276 /* validate the doc
1277 * declared elements in the declared order, with an extra declared element at the end
1278 * this is fine */
1279 err = NULL;
1280 bstr = NULL;
1281 ole_check(IXMLDOMDocument2_validate(doc, &err));
1282 ok(err != NULL, "domdoc_validate() should always set err\n");
1283 ole_expect(IXMLDOMParseError_get_reason(err, &bstr), S_FALSE);
1284 ok(IXMLDOMParseError_get_reason(err, &bstr) == S_FALSE, "got error: %s\n", wine_dbgstr_w(bstr));
1285 SysFreeString(bstr);
1286 IXMLDOMParseError_Release(err);
1287
1288 /* load the next doc */
1289 IXMLDOMDocument2_Release(doc);
1290 doc = create_document(&IID_IXMLDOMDocument2);
1291 ole_check(IXMLDOMDocument2_loadXML(doc, _bstr_(szOpenSeqXML3), &b));
1292 ok(b == VARIANT_TRUE, "failed to load XML string\n");
1293
1294 /* associate the cache to the doc */
1295 V_VT(&v) = VT_DISPATCH;
1296 V_DISPATCH(&v) = NULL;
1297 ole_check(IXMLDOMSchemaCollection_QueryInterface(cache, &IID_IDispatch, (void**)&V_DISPATCH(&v)));
1298 ok(V_DISPATCH(&v) != NULL, "failed to get IDispatch interface\n");
1299 ole_check(IXMLDOMDocument2_putref_schemas(doc, v));
1300 VariantClear(&v);
1301
1302 /* validate the doc
1303 * fails, extra elements are only allowed at the end */
1304 err = NULL;
1305 bstr = NULL;
1306 ole_expect(IXMLDOMDocument2_validate(doc, &err), S_FALSE);
1307 ok(err != NULL, "domdoc_validate() should always set err\n");
1308 todo_wine ok(IXMLDOMParseError_get_reason(err, &bstr) == S_OK, "got error: %s\n", wine_dbgstr_w(bstr));
1309 SysFreeString(bstr);
1310 IXMLDOMParseError_Release(err);
1311
1312 /* load the next doc */
1313 IXMLDOMDocument2_Release(doc);
1314 doc = create_document(&IID_IXMLDOMDocument2);
1315 ole_check(IXMLDOMDocument2_loadXML(doc, _bstr_(szOpenSeqXML4), &b));
1316 ok(b == VARIANT_TRUE, "failed to load XML string\n");
1317
1318 /* associate the cache to the doc */
1319 V_VT(&v) = VT_DISPATCH;
1320 V_DISPATCH(&v) = NULL;
1321 ole_check(IXMLDOMSchemaCollection_QueryInterface(cache, &IID_IDispatch, (void**)&V_DISPATCH(&v)));
1322 ok(V_DISPATCH(&v) != NULL, "failed to get IDispatch interface\n");
1323 ole_check(IXMLDOMDocument2_putref_schemas(doc, v));
1324 VariantClear(&v);
1325
1326 /* validate the doc
1327 * fails, undeclared elements are not allowed */
1328 err = NULL;
1329 bstr = NULL;
1330 ole_expect(IXMLDOMDocument2_validate(doc, &err), S_FALSE);
1331 ok(err != NULL, "domdoc_validate() should always set err\n");
1332 todo_wine ok(IXMLDOMParseError_get_reason(err, &bstr) == S_OK, "got error: %s\n", wine_dbgstr_w(bstr));
1333 SysFreeString(bstr);
1334 IXMLDOMParseError_Release(err);
1335
1336 IXMLDOMDocument2_Release(doc);
1337 IXMLDOMDocument2_Release(schema);
1338 IXMLDOMSchemaCollection_Release(cache);
1339
1340 free_bstrs();
1341}
static const CHAR szOpenSeqXML3[]
Definition: schema.c:400
static const CHAR szOpenSeqXML2[]
Definition: schema.c:399
static const CHAR szOpenSeqXDR[]
Definition: schema.c:381
static const CHAR szOpenSeqXML1[]
Definition: schema.c:398
static const CHAR szOpenSeqXML4[]
Definition: schema.c:401

Referenced by START_TEST().

◆ validate_regex_document()

static HRESULT validate_regex_document ( IXMLDOMDocument2 *  doc,
IXMLDOMDocument2 *  schema,
IXMLDOMSchemaCollection *  cache,
const WCHAR regex,
const WCHAR input 
)
static

Definition at line 1044 of file schema.c.

1046{
1047 static const WCHAR regex_doc[] =
1048L""
1049"<?xml version='1.0'?>"
1050"<root xmlns='urn:test'>%s</root>";
1051
1052 static const WCHAR regex_schema[] =
1053L"<?xml version='1.0'?>"
1054"<schema xmlns='http://www.w3.org/2001/XMLSchema'"
1055" targetNamespace='urn:test'>"
1056" <element name='root'>"
1057" <simpleType>"
1058" <restriction base='string'>"
1059" <pattern value='%s'/>"
1060" </restriction>"
1061" </simpleType>"
1062" </element>"
1063"</schema>";
1064
1065 WCHAR buffer[1024];
1067 VARIANT v;
1069 BSTR namespace;
1070 BSTR bstr;
1071 HRESULT hr;
1072
1073 VariantInit(&v);
1074
1075#ifdef __REACTOS__
1076 swprintf(buffer, regex_doc, input);
1077#else
1078 swprintf(buffer, ARRAY_SIZE(buffer), regex_doc, input);
1079#endif
1080 bstr = SysAllocString(buffer);
1081 ole_check(IXMLDOMDocument2_loadXML(doc, bstr, &b));
1082 ok(b == VARIANT_TRUE, "failed to load XML\n");
1083 SysFreeString(bstr);
1084
1085#ifdef __REACTOS__
1086 swprintf(buffer, regex_schema, regex);
1087#else
1088 swprintf(buffer, ARRAY_SIZE(buffer), regex_schema, regex);
1089#endif
1090 bstr = SysAllocString(buffer);
1091 ole_check(IXMLDOMDocument2_loadXML(schema, bstr, &b));
1092 ok(b == VARIANT_TRUE, "failed to load XML\n");
1093 SysFreeString(bstr);
1094
1095 /* add the schema to the cache */
1096 V_VT(&v) = VT_DISPATCH;
1097 V_DISPATCH(&v) = NULL;
1098 ole_check(IXMLDOMDocument2_QueryInterface(schema, &IID_IDispatch, (void**)&V_DISPATCH(&v)));
1099 ok(V_DISPATCH(&v) != NULL, "failed to get IDispatch interface\n");
1100 namespace = alloc_str_from_narrow("urn:test");
1101 hr = IXMLDOMSchemaCollection_add(cache, namespace, v);
1102 SysFreeString(namespace);
1103 VariantClear(&v);
1104 if (FAILED(hr))
1105 return hr;
1106
1107 /* associate the cache to the doc */
1108 V_VT(&v) = VT_DISPATCH;
1109 V_DISPATCH(&v) = NULL;
1110 ole_check(IXMLDOMSchemaCollection_QueryInterface(cache, &IID_IDispatch, (void**)&V_DISPATCH(&v)));
1111 ok(V_DISPATCH(&v) != NULL, "failed to get IDispatch interface\n");
1112 ole_check(IXMLDOMDocument2_putref_schemas(doc, v));
1113 VariantClear(&v);
1114
1115 /* validate the doc
1116 * only declared elements in the declared order
1117 * this is fine */
1118 err = NULL;
1119 bstr = NULL;
1120 hr = IXMLDOMDocument2_validate(doc, &err);
1121 ok(err != NULL, "domdoc_validate() should always set err\n");
1122 if (IXMLDOMParseError_get_reason(err, &bstr) != S_FALSE)
1123 trace("got error: %s\n", wine_dbgstr_w(bstr));
1124 SysFreeString(bstr);
1125 IXMLDOMParseError_Release(err);
1126
1127 return hr;
1128}
#define trace
Definition: atltest.h:70
#define swprintf
Definition: precomp.h:40
GLuint buffer
Definition: glext.h:5915

Referenced by test_regex().

Variable Documentation

◆ alloced_bstrs

BSTR alloced_bstrs[256]
static

Definition at line 440 of file schema.c.

Referenced by _bstr_(), and free_bstrs().

◆ alloced_bstrs_count

int alloced_bstrs_count
static

Definition at line 441 of file schema.c.

Referenced by _bstr_(), and free_bstrs().

◆ szDatatypeXDR

const CHAR szDatatypeXDR[]
static

Definition at line 132 of file schema.c.

Referenced by test_XDR_datatypes().

◆ szDatatypeXML

const CHAR szDatatypeXML[]
static

Definition at line 208 of file schema.c.

Referenced by test_XDR_datatypes().

◆ szOpenSeqXDR

const CHAR szOpenSeqXDR[]
static
Initial value:
=
"<Schema xmlns='urn:schemas-microsoft-com:xml-data'>\n"
" <ElementType name='w' content='empty' model='closed'/>\n"
" <ElementType name='x' content='empty' model='closed'/>\n"
" <ElementType name='y' content='empty' model='closed'/>\n"
" <ElementType name='z' content='empty' model='closed'/>\n"
" <ElementType name='test' content='eltOnly' model='open' order='seq'>\n"
" <element type='x'/>\n"
" <group order='seq'>\n"
" <element type='x'/>\n"
" <element type='y'/>\n"
" <element type='z'/>\n"
" </group>\n"
" <element type='z'/>\n"
" </ElementType>\n"
"</Schema>"

Definition at line 381 of file schema.c.

Referenced by test_XDR_schemas().

◆ szOpenSeqXML1

const CHAR szOpenSeqXML1[] = "<test><x/><x/><y/><z/><z/></test>"
static

Definition at line 398 of file schema.c.

Referenced by test_XDR_schemas().

◆ szOpenSeqXML2

const CHAR szOpenSeqXML2[] = "<test><x/><x/><y/><z/><z/><w/></test>"
static

Definition at line 399 of file schema.c.

Referenced by test_XDR_schemas().

◆ szOpenSeqXML3

const CHAR szOpenSeqXML3[] = "<test><w/><x/><x/><y/><z/><z/></test>"
static

Definition at line 400 of file schema.c.

Referenced by test_XDR_schemas().

◆ szOpenSeqXML4

const CHAR szOpenSeqXML4[] = "<test><x/><x/><y/><z/><z/><v/></test>"
static

Definition at line 401 of file schema.c.

Referenced by test_XDR_schemas().

◆ xdr_datatypes_data

const xdr_datatypes xdr_datatypes_data[]
static

Definition at line 1350 of file schema.c.

Referenced by test_XDR_datatypes().

◆ xdr_schema1_uri

const CHAR xdr_schema1_uri[] = "x-schema:test1.xdr"
static

Definition at line 40 of file schema.c.

Referenced by test_collection_content(), test_collection_refs(), and test_length().

◆ xdr_schema1_xml

const CHAR xdr_schema1_xml[]
static
Initial value:
=
"<?xml version='1.0'?>"
"<Schema xmlns='urn:schemas-microsoft-com:xml-data'"
" xmlns:dt='urn:schemas-microsoft-com:datatypes'"
" name='test1.xdr'>"
" <ElementType name='x' dt:type='boolean'/>"
" <ElementType name='y'>"
" <datatype dt:type='int'/>"
" </ElementType>"
" <ElementType name='z'/>"
" <ElementType name='root' content='eltOnly' model='open' order='seq'>"
" <element type='x'/>"
" <element type='y'/>"
" <element type='z'/>"
" </ElementType>"
"</Schema>"

Definition at line 41 of file schema.c.

Referenced by test_collection_content(), test_collection_refs(), and test_length().

◆ xdr_schema2_uri

const CHAR xdr_schema2_uri[] = "x-schema:test2.xdr"
static

Definition at line 58 of file schema.c.

Referenced by test_collection_content(), test_collection_refs(), and test_length().

◆ xdr_schema2_xml

const CHAR xdr_schema2_xml[]
static
Initial value:
=
"<?xml version='1.0'?>"
"<Schema xmlns='urn:schemas-microsoft-com:xml-data'"
" xmlns:dt='urn:schemas-microsoft-com:datatypes'"
" name='test2.xdr'>"
" <ElementType name='x' dt:type='bin.base64'/>"
" <ElementType name='y' dt:type='uuid'/>"
" <ElementType name='z'/>"
" <ElementType name='root' content='eltOnly' model='closed' order='one'>"
" <element type='x'/>"
" <element type='y'/>"
" <element type='z'/>"
" </ElementType>"
"</Schema>"

Definition at line 59 of file schema.c.

Referenced by test_collection_content(), test_collection_refs(), and test_length().

◆ xdr_schema3_uri

const CHAR xdr_schema3_uri[] = "x-schema:test3.xdr"
static

Definition at line 74 of file schema.c.

Referenced by test_collection_content(), test_collection_refs(), and test_length().

◆ xdr_schema3_xml

const CHAR xdr_schema3_xml[]
static
Initial value:
=
"<?xml version='1.0'?>"
"<Schema xmlns='urn:schemas-microsoft-com:xml-data'"
" xmlns:dt='urn:schemas-microsoft-com:datatypes'"
" name='test3.xdr'>"
" <ElementType name='root' content='textOnly' model='open'>"
" <AttributeType name='x' dt:type='int'/>"
" <AttributeType name='y' dt:type='enumeration' dt:values='a b c'/>"
" <AttributeType name='z' dt:type='uuid'/>"
" <attribute type='x'/>"
" <attribute type='y'/>"
" <attribute type='z'/>"
" </ElementType>"
"</Schema>"

Definition at line 75 of file schema.c.

Referenced by test_collection_content(), test_collection_refs(), and test_length().

◆ xsd_schema1_uri

const CHAR xsd_schema1_uri[] = "x-schema:test1.xsd"
static

Definition at line 90 of file schema.c.

Referenced by test_collection_content(), and test_remove().

◆ xsd_schema1_xml

const CHAR xsd_schema1_xml[]
static
Initial value:
=
"<?xml version='1.0'?>"
"<schema xmlns='http://www.w3.org/2001/XMLSchema'"
" targetNamespace='x-schema:test1.xsd'>"
" <element name='root'>"
" <complexType>"
" <sequence maxOccurs='unbounded'>"
" <any/>"
" </sequence>"
" </complexType>"
" </element>"
"</schema>"

Definition at line 91 of file schema.c.

Referenced by test_collection_content(), and test_remove().

◆ xsd_schema2_uri

const CHAR xsd_schema2_uri[] = "x-schema:test2.xsd"
static

Definition at line 104 of file schema.c.

Referenced by test_collection_content().

◆ xsd_schema2_xml

const CHAR xsd_schema2_xml[]
static
Initial value:
=
"<?xml version='1.0'?>"
"<schema xmlns='http://www.w3.org/2001/XMLSchema'"
" targetNamespace='x-schema:test2.xsd'>"
" <element name='root'>"
" <complexType>"
" <sequence maxOccurs='unbounded'>"
" <any/>"
" </sequence>"
" </complexType>"
" </element>"
"</schema>"

Definition at line 105 of file schema.c.

Referenced by test_collection_content().

◆ xsd_schema3_uri

const CHAR xsd_schema3_uri[] = "x-schema:test3.xsd"
static

Definition at line 118 of file schema.c.

Referenced by test_collection_content().

◆ xsd_schema3_xml

const CHAR xsd_schema3_xml[]
static
Initial value:
=
"<?xml version='1.0'?>"
"<schema xmlns='http://www.w3.org/2001/XMLSchema'"
" targetNamespace='x-schema:test3.xsd'>"
" <element name='root'>"
" <complexType>"
" <sequence maxOccurs='unbounded'>"
" <any/>"
" </sequence>"
" </complexType>"
" </element>"
"</schema>"

Definition at line 119 of file schema.c.

Referenced by test_collection_content().