From 70f10e1a9f3dc468b446188bd96993ea2b3bafb8 Mon Sep 17 00:00:00 2001 From: Adam Martinson Date: Wed, 20 Oct 2010 16:37:23 -0500 Subject: [PATCH] msxml3: Implement schema_cache_get(). --- dlls/msxml3/schema.c | 20 +++++++++++-- dlls/msxml3/tests/schema.c | 58 ++++++++++++++++++++++---------------- 2 files changed, 52 insertions(+), 26 deletions(-) diff --git a/dlls/msxml3/schema.c b/dlls/msxml3/schema.c index 93aa2ca8943..bf3bc7eba83 100644 --- a/dlls/msxml3/schema.c +++ b/dlls/msxml3/schema.c @@ -448,8 +448,24 @@ static HRESULT WINAPI schema_cache_add(IXMLDOMSchemaCollection *iface, BSTR uri, static HRESULT WINAPI schema_cache_get(IXMLDOMSchemaCollection *iface, BSTR uri, IXMLDOMNode **node) { - FIXME("stub\n"); - return E_NOTIMPL; + schema_cache* This = impl_from_IXMLDOMSchemaCollection(iface); + xmlChar* name; + cache_entry* entry; + TRACE("(%p)->(%s, %p)\n", This, wine_dbgstr_w(uri), node); + + if (!node) + return E_POINTER; + + name = xmlChar_from_wchar(uri); + entry = (cache_entry*) xmlHashLookup(This->cache, name); + heap_free(name); + + /* TODO: this should be read-only */ + if (entry) + return DOMDocument_create_from_xmldoc(entry->doc, (IXMLDOMDocument3**)node); + + *node = NULL; + return S_OK; } static HRESULT WINAPI schema_cache_remove(IXMLDOMSchemaCollection *iface, BSTR uri) diff --git a/dlls/msxml3/tests/schema.c b/dlls/msxml3/tests/schema.c index 69a0dc35bb8..9b3a6ebf483 100644 --- a/dlls/msxml3/tests/schema.c +++ b/dlls/msxml3/tests/schema.c @@ -368,14 +368,14 @@ static void test_collection_refs(void) schema3 = NULL; /* releasing the original doc does not affect the schema cache */ - todo_wine ole_check(IXMLDOMSchemaCollection_get(cache1, _bstr_(xdr_schema1_uri), (IXMLDOMNode**)&schema1)); - todo_wine ole_check(IXMLDOMSchemaCollection_get(cache2, _bstr_(xdr_schema2_uri), (IXMLDOMNode**)&schema2)); - todo_wine ole_check(IXMLDOMSchemaCollection_get(cache3, _bstr_(xdr_schema3_uri), (IXMLDOMNode**)&schema3)); + ole_check(IXMLDOMSchemaCollection_get(cache1, _bstr_(xdr_schema1_uri), (IXMLDOMNode**)&schema1)); + ole_check(IXMLDOMSchemaCollection_get(cache2, _bstr_(xdr_schema2_uri), (IXMLDOMNode**)&schema2)); + ole_check(IXMLDOMSchemaCollection_get(cache3, _bstr_(xdr_schema3_uri), (IXMLDOMNode**)&schema3)); /* we get a read-only domdoc interface, created just for us */ - if (schema1) todo_wine check_refs(IXMLDOMDocument2, schema1, 1); - if (schema2) todo_wine check_refs(IXMLDOMDocument2, schema2, 1); - if (schema3) todo_wine check_refs(IXMLDOMDocument2, schema3, 1); + if (schema1) check_refs(IXMLDOMDocument2, schema1, 1); + if (schema2) check_refs(IXMLDOMDocument2, schema2, 1); + if (schema3) check_refs(IXMLDOMDocument2, schema3, 1); ole_expect(IXMLDOMSchemaCollection_addCollection(cache1, NULL), E_POINTER); ole_check(IXMLDOMSchemaCollection_addCollection(cache2, cache1)); @@ -400,26 +400,26 @@ static void test_collection_refs(void) check_refs(IXMLDOMSchemaCollection, cache3, 1); /* nor does it affect the domdoc instances */ - if (schema1) todo_wine check_refs(IXMLDOMDocument2, schema1, 1); - if (schema2) todo_wine check_refs(IXMLDOMDocument2, schema2, 1); - if (schema3) todo_wine check_refs(IXMLDOMDocument2, schema3, 1); + if (schema1) check_refs(IXMLDOMDocument2, schema1, 1); + if (schema2) check_refs(IXMLDOMDocument2, schema2, 1); + if (schema3) check_refs(IXMLDOMDocument2, schema3, 1); - if (schema1) todo_wine check_ref_expr(IXMLDOMDocument2_Release(schema1), 0); - if (schema2) todo_wine check_ref_expr(IXMLDOMDocument2_Release(schema2), 0); - if (schema3) todo_wine check_ref_expr(IXMLDOMDocument2_Release(schema3), 0); + if (schema1) check_ref_expr(IXMLDOMDocument2_Release(schema1), 0); + if (schema2) check_ref_expr(IXMLDOMDocument2_Release(schema2), 0); + if (schema3) check_ref_expr(IXMLDOMDocument2_Release(schema3), 0); schema1 = NULL; schema2 = NULL; schema3 = NULL; /* releasing the domdoc instances doesn't change the cache */ - todo_wine ole_check(IXMLDOMSchemaCollection_get(cache1, _bstr_(xdr_schema1_uri), (IXMLDOMNode**)&schema1)); - todo_wine ole_check(IXMLDOMSchemaCollection_get(cache2, _bstr_(xdr_schema2_uri), (IXMLDOMNode**)&schema2)); - todo_wine ole_check(IXMLDOMSchemaCollection_get(cache3, _bstr_(xdr_schema3_uri), (IXMLDOMNode**)&schema3)); + ole_check(IXMLDOMSchemaCollection_get(cache1, _bstr_(xdr_schema1_uri), (IXMLDOMNode**)&schema1)); + ole_check(IXMLDOMSchemaCollection_get(cache2, _bstr_(xdr_schema2_uri), (IXMLDOMNode**)&schema2)); + ole_check(IXMLDOMSchemaCollection_get(cache3, _bstr_(xdr_schema3_uri), (IXMLDOMNode**)&schema3)); /* we can just get them again */ - if (schema1) todo_wine check_refs(IXMLDOMDocument2, schema1, 1); - if (schema2) todo_wine check_refs(IXMLDOMDocument2, schema2, 1); - if (schema3) todo_wine check_refs(IXMLDOMDocument2, schema3, 1); + if (schema1) check_refs(IXMLDOMDocument2, schema1, 1); + if (schema2) check_refs(IXMLDOMDocument2, schema2, 1); + if (schema3) check_refs(IXMLDOMDocument2, schema3, 1); /* releasing the caches does not affect the domdoc instances */ check_ref_expr(IXMLDOMSchemaCollection_Release(cache1), 0); @@ -427,13 +427,13 @@ static void test_collection_refs(void) check_ref_expr(IXMLDOMSchemaCollection_Release(cache3), 0); /* they're just for us */ - if (schema1) todo_wine check_refs(IXMLDOMDocument2, schema1, 1); - if (schema2) todo_wine check_refs(IXMLDOMDocument2, schema2, 1); - if (schema3) todo_wine check_refs(IXMLDOMDocument2, schema3, 1); + if (schema1) check_refs(IXMLDOMDocument2, schema1, 1); + if (schema2) check_refs(IXMLDOMDocument2, schema2, 1); + if (schema3) check_refs(IXMLDOMDocument2, schema3, 1); - if (schema1) todo_wine check_ref_expr(IXMLDOMDocument2_Release(schema1), 0); - if (schema2) todo_wine check_ref_expr(IXMLDOMDocument2_Release(schema2), 0); - if (schema3) todo_wine check_ref_expr(IXMLDOMDocument2_Release(schema3), 0); + if (schema1) check_ref_expr(IXMLDOMDocument2_Release(schema1), 0); + if (schema2) check_ref_expr(IXMLDOMDocument2_Release(schema2), 0); + if (schema3) check_ref_expr(IXMLDOMDocument2_Release(schema3), 0); free_bstrs(); } @@ -624,6 +624,16 @@ static void test_collection_content(void) /* pointer is checked first */ ole_expect(IXMLDOMSchemaCollection_get_namespaceURI(cache1, 3, NULL), E_POINTER); + schema1 = NULL; + /* no error if ns uri does not exist */ + ole_check(IXMLDOMSchemaCollection_get(cache1, _bstr_(xsd_schema1_uri), (IXMLDOMNode**)&schema1)); + ok(!schema1, "expected NULL\n"); + /* a NULL bstr corresponds to no-uri ns */ + ole_check(IXMLDOMSchemaCollection_get(cache1, NULL, (IXMLDOMNode**)&schema1)); + ok(!schema1, "expected NULL\n"); + /* error if return pointer is NULL */ + ole_expect(IXMLDOMSchemaCollection_get(cache1, _bstr_(xdr_schema1_uri), NULL), E_POINTER); + for (i = 0; i < 3; ++i) { bstr = NULL;