>From 7791808474912c25a0798d59ae21949320910712 Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <nsivov@codeweavers.com>
Date: Sun, 11 Dec 2011 12:57:36 +0300
Subject: [PATCH 4/9] Accept disabled on load validation

---
 dlls/msxml3/schema.c       |   22 ++++++++++++++++++----
 dlls/msxml3/tests/schema.c |   24 ++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 4 deletions(-)

diff --git a/dlls/msxml3/schema.c b/dlls/msxml3/schema.c
index 9cdccb0..e9a9a84 100644
--- a/dlls/msxml3/schema.c
+++ b/dlls/msxml3/schema.c
@@ -93,6 +93,8 @@ typedef struct _schema_cache
     MSXML_VERSION version;
     xmlHashTablePtr cache;
     LONG ref;
+
+    VARIANT_BOOL validateOnLoad;
 } schema_cache;
 
 typedef struct _cache_entry
@@ -1285,6 +1287,11 @@ static HRESULT WINAPI schema_cache_put_validateOnLoad(IXMLDOMSchemaCollection2*
 {
     schema_cache* This = impl_from_IXMLDOMSchemaCollection2(iface);
     FIXME("(%p)->(%d): stub\n", This, value);
+
+    This->validateOnLoad = value;
+    /* it's ok to disable it, cause we don't validate on load anyway */
+    if (value == VARIANT_FALSE) return S_OK;
+
     return E_NOTIMPL;
 }
 
@@ -1292,8 +1299,12 @@ static HRESULT WINAPI schema_cache_get_validateOnLoad(IXMLDOMSchemaCollection2*
                                                       VARIANT_BOOL* value)
 {
     schema_cache* This = impl_from_IXMLDOMSchemaCollection2(iface);
-    FIXME("(%p)->(%p): stub\n", This, value);
-    return E_NOTIMPL;
+    TRACE("(%p)->(%p)\n", This, value);
+
+    if (!value) return E_POINTER;
+    *value = This->validateOnLoad;
+
+    return S_OK;
 }
 
 static HRESULT WINAPI schema_cache_getSchema(IXMLDOMSchemaCollection2* iface,
@@ -1425,18 +1436,21 @@ XDR_DT SchemaCache_get_node_dt(IXMLDOMSchemaCollection2* iface, xmlNodePtr node)
     return dt;
 }
 
-HRESULT SchemaCache_create(MSXML_VERSION version, IUnknown* pUnkOuter, void** ppObj)
+HRESULT SchemaCache_create(MSXML_VERSION version, IUnknown* outer, void** obj)
 {
     schema_cache* This = heap_alloc(sizeof(schema_cache));
     if (!This)
         return E_OUTOFMEMORY;
 
+    TRACE("(%d %p %p)\n", version, outer, obj);
+
     This->lpVtbl = &schema_cache_vtbl;
     This->cache = xmlHashCreate(DEFAULT_HASHTABLE_SIZE);
     This->ref = 1;
     This->version = version;
+    This->validateOnLoad = VARIANT_TRUE;
 
-    *ppObj = &This->lpVtbl;
+    *obj = &This->lpVtbl;
     return S_OK;
 }
 
diff --git a/dlls/msxml3/tests/schema.c b/dlls/msxml3/tests/schema.c
index 56a77e6..951ee68 100644
--- a/dlls/msxml3/tests/schema.c
+++ b/dlls/msxml3/tests/schema.c
@@ -31,6 +31,9 @@
 
 #include "wine/test.h"
 
+#define EXPECT_HR(hr,hr_exp) \
+    ok(hr == hr_exp, "got 0x%08x, expected 0x%08x\n", hr, hr_exp)
+
 static const WCHAR xdr_schema_uri[] = {'x','-','s','c','h','e','m','a',':','t','e','s','t','.','x','m','l',0};
 
 static const WCHAR xdr_schema_xml[] = {
@@ -1973,6 +1976,26 @@ static void test_XDR_datatypes(void)
     free_bstrs();
 }
 
+static void test_validate_on_load(void)
+{
+    IXMLDOMSchemaCollection2 *cache;
+    VARIANT_BOOL b;
+    HRESULT hr;
+
+    cache = create_cache_version(40, &IID_IXMLDOMSchemaCollection2);
+    if (!cache) return;
+
+    hr = IXMLDOMSchemaCollection2_get_validateOnLoad(cache, NULL);
+    EXPECT_HR(hr, E_POINTER);
+
+    b = VARIANT_FALSE;
+    hr = IXMLDOMSchemaCollection2_get_validateOnLoad(cache, &b);
+    EXPECT_HR(hr, S_OK);
+    ok(b == VARIANT_TRUE, "got %d\n", b);
+
+    IXMLDOMSchemaCollection2_Release(cache);
+}
+
 START_TEST(schema)
 {
     HRESULT r;
@@ -1986,6 +2009,7 @@ START_TEST(schema)
     test_collection_content();
     test_XDR_schemas();
     test_XDR_datatypes();
+    test_validate_on_load();
 
     CoUninitialize();
 }
-- 
1.5.6.5


