Commit 491ec41f authored by Adam Martinson's avatar Adam Martinson Committed by Alexandre Julliard

msxml3: Implement schema_cache_addCollection().

parent eac6ed01
......@@ -474,10 +474,31 @@ static HRESULT WINAPI schema_cache_get_namespaceURI(IXMLDOMSchemaCollection *ifa
return E_NOTIMPL;
}
static void cache_copy(void* data, void* dest, xmlChar* name)
{
schema_cache* This = (schema_cache*) dest;
cache_entry* entry = (cache_entry*) data;
if (xmlHashLookup(This->cache, name) == NULL)
{
cache_entry_add_ref(entry);
xmlHashAddEntry(This->cache, name, entry);
}
}
static HRESULT WINAPI schema_cache_addCollection(IXMLDOMSchemaCollection *iface, IXMLDOMSchemaCollection *otherCollection)
{
FIXME("stub\n");
return E_NOTIMPL;
schema_cache* This = impl_from_IXMLDOMSchemaCollection(iface);
schema_cache* That = impl_from_IXMLDOMSchemaCollection(otherCollection);
TRACE("(%p)->(%p)\n", This, That);
if (!otherCollection)
return E_POINTER;
/* TODO: detect errors while copying & return E_FAIL */
xmlHashScan(That->cache, cache_copy, This);
return S_OK;
}
static HRESULT WINAPI schema_cache_get__newEnum(IXMLDOMSchemaCollection *iface, IUnknown **ppUnk)
......
......@@ -324,6 +324,7 @@ static void test_collection_refs(void)
IXMLDOMDocument2 *schema1, *schema2, *schema3;
IXMLDOMSchemaCollection *cache1, *cache2, *cache3;
VARIANT_BOOL b;
LONG length;
schema1 = create_document(&IID_IXMLDOMDocument2);
schema2 = create_document(&IID_IXMLDOMDocument2);
......@@ -376,8 +377,22 @@ static void test_collection_refs(void)
if (schema2) todo_wine check_refs(IXMLDOMDocument2, schema2, 1);
if (schema3) todo_wine check_refs(IXMLDOMDocument2, schema3, 1);
todo_wine ole_check(IXMLDOMSchemaCollection_addCollection(cache2, cache1));
todo_wine ole_check(IXMLDOMSchemaCollection_addCollection(cache3, cache2));
ole_expect(IXMLDOMSchemaCollection_addCollection(cache1, NULL), E_POINTER);
ole_check(IXMLDOMSchemaCollection_addCollection(cache2, cache1));
ole_check(IXMLDOMSchemaCollection_addCollection(cache3, cache2));
length = -1;
ole_check(IXMLDOMSchemaCollection_get_length(cache1, &length));
ok(length == 1, "expected length 1, got %i", length);
length = -1;
ole_check(IXMLDOMSchemaCollection_get_length(cache2, &length));
ok(length == 2, "expected length 2, got %i", length);
length = -1;
ole_check(IXMLDOMSchemaCollection_get_length(cache3, &length));
ok(length == 3, "expected length 3, got %i", length);
/* merging collections does not affect the ref count */
check_refs(IXMLDOMSchemaCollection, cache1, 1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment