msxml3/tests: Tests for IMXAttributes::clear().

This commit is contained in:
Nikolay Sivov 2012-02-24 18:09:27 +03:00 committed by Alexandre Julliard
parent 8a0d86833e
commit be7d4257f8

View file

@ -3092,6 +3092,22 @@ static const addattribute_test_t addattribute_data[] = {
{ &CLSID_SAXAttributes30, NULL, NULL, "ns:qname", NULL, "value", E_INVALIDARG },
{ &CLSID_SAXAttributes40, NULL, NULL, "ns:qname", NULL, "value", E_INVALIDARG },
{ &CLSID_SAXAttributes60, NULL, NULL, "ns:qname", NULL, "value", S_OK },
{ &CLSID_SAXAttributes, NULL, "qname", "ns:qname", NULL, "value", E_INVALIDARG },
{ &CLSID_SAXAttributes30, NULL, "qname", "ns:qname", NULL, "value", E_INVALIDARG },
{ &CLSID_SAXAttributes40, NULL, "qname", "ns:qname", NULL, "value", E_INVALIDARG },
{ &CLSID_SAXAttributes60, NULL, "qname", "ns:qname", NULL, "value", S_OK },
{ &CLSID_SAXAttributes, "uri", "qname", "ns:qname", NULL, "value", E_INVALIDARG },
{ &CLSID_SAXAttributes30, "uri", "qname", "ns:qname", NULL, "value", E_INVALIDARG },
{ &CLSID_SAXAttributes40, "uri", "qname", "ns:qname", NULL, "value", E_INVALIDARG },
{ &CLSID_SAXAttributes60, "uri", "qname", "ns:qname", NULL, "value", S_OK },
{ &CLSID_SAXAttributes, "uri", "qname", "ns:qname", "type", "value", S_OK },
{ &CLSID_SAXAttributes30, "uri", "qname", "ns:qname", "type", "value", S_OK },
{ &CLSID_SAXAttributes40, "uri", "qname", "ns:qname", "type", "value", S_OK },
{ &CLSID_SAXAttributes60, "uri", "qname", "ns:qname", "type", "value", S_OK },
{ NULL }
};
@ -3156,6 +3172,72 @@ static void test_mxattr_addAttribute(void)
free_bstrs();
}
static void test_mxattr_clear(void)
{
ISAXAttributes *saxattr;
IMXAttributes *mxattr;
const WCHAR *ptr;
HRESULT hr;
int len;
hr = CoCreateInstance(&CLSID_SAXAttributes, NULL, CLSCTX_INPROC_SERVER,
&IID_IMXAttributes, (void**)&mxattr);
EXPECT_HR(hr, S_OK);
hr = IMXAttributes_QueryInterface(mxattr, &IID_ISAXAttributes, (void**)&saxattr);
EXPECT_HR(hr, S_OK);
hr = ISAXAttributes_getQName(saxattr, 0, NULL, NULL);
EXPECT_HR(hr, E_INVALIDARG);
hr = ISAXAttributes_getQName(saxattr, 0, &ptr, &len);
EXPECT_HR(hr, E_INVALIDARG);
hr = IMXAttributes_addAttribute(mxattr, _bstr_("uri"), _bstr_("local"),
_bstr_("qname"), _bstr_("type"), _bstr_("value"));
EXPECT_HR(hr, S_OK);
len = -1;
hr = ISAXAttributes_getLength(saxattr, &len);
EXPECT_HR(hr, S_OK);
ok(len == 1, "got %d\n", len);
len = -1;
hr = ISAXAttributes_getQName(saxattr, 0, NULL, &len);
EXPECT_HR(hr, E_POINTER);
ok(len == -1, "got %d\n", len);
ptr = (void*)0xdeadbeef;
hr = ISAXAttributes_getQName(saxattr, 0, &ptr, NULL);
EXPECT_HR(hr, E_POINTER);
ok(ptr == (void*)0xdeadbeef, "got %p\n", ptr);
len = 0;
hr = ISAXAttributes_getQName(saxattr, 0, &ptr, &len);
EXPECT_HR(hr, S_OK);
ok(len == 5, "got %d\n", len);
ok(!lstrcmpW(ptr, _bstr_("qname")), "got %s\n", wine_dbgstr_w(ptr));
hr = IMXAttributes_clear(mxattr);
EXPECT_HR(hr, S_OK);
len = -1;
hr = ISAXAttributes_getLength(saxattr, &len);
EXPECT_HR(hr, S_OK);
ok(len == 0, "got %d\n", len);
len = -1;
ptr = (void*)0xdeadbeef;
hr = ISAXAttributes_getQName(saxattr, 0, &ptr, &len);
EXPECT_HR(hr, E_INVALIDARG);
ok(len == -1, "got %d\n", len);
ok(ptr == (void*)0xdeadbeef, "got %p\n", ptr);
IMXAttributes_Release(mxattr);
ISAXAttributes_Release(saxattr);
free_bstrs();
}
START_TEST(saxreader)
{
ISAXXMLReader *reader;
@ -3208,6 +3290,7 @@ START_TEST(saxreader)
if (is_clsid_supported(&CLSID_SAXAttributes, mxattributes_support_data))
{
test_mxattr_addAttribute();
test_mxattr_clear();
}
else
skip("SAXAttributes not supported\n");