mirror of
https://github.com/reactos/reactos.git
synced 2025-08-02 17:27:03 +00:00
[XMLLITE_WINETEST] Sync with Wine Staging 1.9.11. CORE-11368
svn path=/trunk/; revision=71727
This commit is contained in:
parent
acef311a10
commit
b9122a338a
3 changed files with 475 additions and 190 deletions
|
@ -8,5 +8,5 @@ list(APPEND SOURCE
|
|||
|
||||
add_executable(xmllite_winetest ${SOURCE})
|
||||
set_module_type(xmllite_winetest win32cui)
|
||||
add_importlibs(xmllite_winetest ole32 msvcrt kernel32)
|
||||
add_importlibs(xmllite_winetest xmllite ole32 msvcrt kernel32)
|
||||
add_cd_file(TARGET xmllite_winetest DESTINATION reactos/bin FOR all)
|
||||
|
|
|
@ -38,14 +38,6 @@
|
|||
|
||||
DEFINE_GUID(IID_IXmlReaderInput, 0x0b3ccc9b, 0x9214, 0x428b, 0xa2, 0xae, 0xef, 0x3a, 0xa8, 0x71, 0xaf, 0xda);
|
||||
|
||||
static HRESULT (WINAPI *pCreateXmlReader)(REFIID riid, void **ppvObject, IMalloc *pMalloc);
|
||||
static HRESULT (WINAPI *pCreateXmlReaderInputWithEncodingName)(IUnknown *stream,
|
||||
IMalloc *pMalloc,
|
||||
LPCWSTR encoding,
|
||||
BOOL hint,
|
||||
LPCWSTR base_uri,
|
||||
IXmlReaderInput **ppInput);
|
||||
|
||||
static WCHAR *a2w(const char *str)
|
||||
{
|
||||
int len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
|
||||
|
@ -372,27 +364,51 @@ static const ISequentialStreamVtbl teststreamvtbl =
|
|||
teststream_Write
|
||||
};
|
||||
|
||||
static BOOL init_pointers(void)
|
||||
static HRESULT WINAPI resolver_QI(IXmlResolver *iface, REFIID riid, void **obj)
|
||||
{
|
||||
/* don't free module here, it's to be unloaded on exit */
|
||||
HMODULE mod = LoadLibraryA("xmllite.dll");
|
||||
ok(0, "unexpected call, riid %s\n", wine_dbgstr_guid(riid));
|
||||
|
||||
if (!mod)
|
||||
if (IsEqualIID(riid, &IID_IXmlResolver) || IsEqualIID(riid, &IID_IUnknown))
|
||||
{
|
||||
win_skip("xmllite library not available\n");
|
||||
return FALSE;
|
||||
*obj = iface;
|
||||
IXmlResolver_AddRef(iface);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
#define MAKEFUNC(f) if (!(p##f = (void*)GetProcAddress(mod, #f))) return FALSE;
|
||||
MAKEFUNC(CreateXmlReader);
|
||||
MAKEFUNC(CreateXmlReaderInputWithEncodingName);
|
||||
#undef MAKEFUNC
|
||||
|
||||
return TRUE;
|
||||
*obj = NULL;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
static ULONG WINAPI resolver_AddRef(IXmlResolver *iface)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
static ULONG WINAPI resolver_Release(IXmlResolver *iface)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI resolver_ResolveUri(IXmlResolver *iface, const WCHAR *base_uri,
|
||||
const WCHAR *public_id, const WCHAR *system_id, IUnknown **input)
|
||||
{
|
||||
ok(0, "unexpected call\n");
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static const IXmlResolverVtbl resolvervtbl =
|
||||
{
|
||||
resolver_QI,
|
||||
resolver_AddRef,
|
||||
resolver_Release,
|
||||
resolver_ResolveUri
|
||||
};
|
||||
|
||||
static IXmlResolver testresolver = { &resolvervtbl };
|
||||
|
||||
static void test_reader_create(void)
|
||||
{
|
||||
IXmlResolver *resolver;
|
||||
HRESULT hr;
|
||||
IXmlReader *reader;
|
||||
IUnknown *input;
|
||||
|
@ -402,11 +418,11 @@ static void test_reader_create(void)
|
|||
/* crashes native */
|
||||
if (0)
|
||||
{
|
||||
pCreateXmlReader(&IID_IXmlReader, NULL, NULL);
|
||||
pCreateXmlReader(NULL, (void**)&reader, NULL);
|
||||
CreateXmlReader(&IID_IXmlReader, NULL, NULL);
|
||||
CreateXmlReader(NULL, (void**)&reader, NULL);
|
||||
}
|
||||
|
||||
hr = pCreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
|
||||
hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
|
||||
test_read_state(reader, XmlReadState_Closed, -1, FALSE);
|
||||
|
@ -416,6 +432,26 @@ static void test_reader_create(void)
|
|||
ok(hr == S_FALSE, "got %08x\n", hr);
|
||||
ok(nodetype == XmlNodeType_None, "got %d\n", nodetype);
|
||||
|
||||
resolver = (void*)0xdeadbeef;
|
||||
hr = IXmlReader_GetProperty(reader, XmlReaderProperty_XmlResolver, (LONG_PTR*)&resolver);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
ok(resolver == NULL, "got %p\n", resolver);
|
||||
|
||||
hr = IXmlReader_SetProperty(reader, XmlReaderProperty_XmlResolver, 0);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = IXmlReader_SetProperty(reader, XmlReaderProperty_XmlResolver, (LONG_PTR)&testresolver);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
resolver = NULL;
|
||||
hr = IXmlReader_GetProperty(reader, XmlReaderProperty_XmlResolver, (LONG_PTR*)&resolver);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
ok(resolver == &testresolver, "got %p\n", resolver);
|
||||
IXmlResolver_Release(resolver);
|
||||
|
||||
hr = IXmlReader_SetProperty(reader, XmlReaderProperty_XmlResolver, 0);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
dtd = 2;
|
||||
hr = IXmlReader_GetProperty(reader, XmlReaderProperty_DtdProcessing, (LONG_PTR*)&dtd);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
|
@ -459,9 +495,9 @@ static void test_readerinput(void)
|
|||
HRESULT hr;
|
||||
LONG ref;
|
||||
|
||||
hr = pCreateXmlReaderInputWithEncodingName(NULL, NULL, NULL, FALSE, NULL, NULL);
|
||||
hr = CreateXmlReaderInputWithEncodingName(NULL, NULL, NULL, FALSE, NULL, NULL);
|
||||
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr);
|
||||
hr = pCreateXmlReaderInputWithEncodingName(NULL, NULL, NULL, FALSE, NULL, &reader_input);
|
||||
hr = CreateXmlReaderInputWithEncodingName(NULL, NULL, NULL, FALSE, NULL, &reader_input);
|
||||
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr);
|
||||
|
||||
hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
|
||||
|
@ -470,7 +506,7 @@ static void test_readerinput(void)
|
|||
ref = IStream_AddRef(stream);
|
||||
ok(ref == 2, "Expected 2, got %d\n", ref);
|
||||
IStream_Release(stream);
|
||||
hr = pCreateXmlReaderInputWithEncodingName((IUnknown*)stream, NULL, NULL, FALSE, NULL, &reader_input);
|
||||
hr = CreateXmlReaderInputWithEncodingName((IUnknown*)stream, NULL, NULL, FALSE, NULL, &reader_input);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
|
||||
hr = IUnknown_QueryInterface(reader_input, &IID_IStream, (void**)&stream2);
|
||||
|
@ -485,7 +521,7 @@ static void test_readerinput(void)
|
|||
IStream_Release(stream);
|
||||
|
||||
/* try ::SetInput() with valid IXmlReaderInput */
|
||||
hr = pCreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
|
||||
hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
|
||||
ref = IUnknown_AddRef(reader_input);
|
||||
|
@ -551,7 +587,7 @@ static void test_readerinput(void)
|
|||
ref = IUnknown_AddRef(input);
|
||||
ok(ref == 2, "Expected 2, got %d\n", ref);
|
||||
IUnknown_Release(input);
|
||||
hr = pCreateXmlReaderInputWithEncodingName(input, NULL, NULL, FALSE, NULL, &reader_input);
|
||||
hr = CreateXmlReaderInputWithEncodingName(input, NULL, NULL, FALSE, NULL, &reader_input);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok_iids(&input_iids, empty_seq, NULL, FALSE);
|
||||
/* IXmlReaderInput stores stream interface as IUnknown */
|
||||
|
@ -559,7 +595,7 @@ static void test_readerinput(void)
|
|||
ok(ref == 3, "Expected 3, got %d\n", ref);
|
||||
IUnknown_Release(input);
|
||||
|
||||
hr = pCreateXmlReader(&IID_IXmlReader, (LPVOID*)&reader, NULL);
|
||||
hr = CreateXmlReader(&IID_IXmlReader, (LPVOID*)&reader, NULL);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
|
||||
input_iids.count = 0;
|
||||
|
@ -590,7 +626,7 @@ static void test_readerinput(void)
|
|||
ok_iids(&input_iids, setinput_readerinput, NULL, FALSE);
|
||||
|
||||
/* another reader */
|
||||
hr = pCreateXmlReader(&IID_IXmlReader, (LPVOID*)&reader2, NULL);
|
||||
hr = CreateXmlReader(&IID_IXmlReader, (LPVOID*)&reader2, NULL);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
|
||||
/* resolving from IXmlReaderInput to IStream/ISequentialStream is done at
|
||||
|
@ -613,7 +649,7 @@ static void test_reader_state(void)
|
|||
XmlNodeType nodetype;
|
||||
HRESULT hr;
|
||||
|
||||
hr = pCreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
|
||||
hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
|
||||
/* invalid arguments */
|
||||
|
@ -653,7 +689,7 @@ static void test_read_xmldeclaration(void)
|
|||
BOOL ret;
|
||||
const WCHAR *val;
|
||||
|
||||
hr = pCreateXmlReader(&IID_IXmlReader, (LPVOID*)&reader, NULL);
|
||||
hr = CreateXmlReader(&IID_IXmlReader, (LPVOID*)&reader, NULL);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
|
||||
/* position methods with Null args */
|
||||
|
@ -874,7 +910,7 @@ static void test_read_comment(void)
|
|||
IXmlReader *reader;
|
||||
HRESULT hr;
|
||||
|
||||
hr = pCreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
|
||||
hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
|
||||
ok(hr == S_OK, "S_OK, got %08x\n", hr);
|
||||
|
||||
while (test->xml)
|
||||
|
@ -956,7 +992,7 @@ static void test_read_pi(void)
|
|||
IXmlReader *reader;
|
||||
HRESULT hr;
|
||||
|
||||
hr = pCreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
|
||||
hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
|
||||
ok(hr == S_OK, "S_OK, got %08x\n", hr);
|
||||
|
||||
while (test->xml)
|
||||
|
@ -1072,7 +1108,7 @@ static void test_read_full(void)
|
|||
HRESULT hr;
|
||||
int i;
|
||||
|
||||
hr = pCreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
|
||||
hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
|
||||
ok(hr == S_OK, "S_OK, got %08x\n", hr);
|
||||
|
||||
stream = create_stream_on_data(test->xml, strlen(test->xml)+1);
|
||||
|
@ -1121,7 +1157,7 @@ static void test_read_dtd(void)
|
|||
UINT len, count;
|
||||
HRESULT hr;
|
||||
|
||||
hr = pCreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
|
||||
hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
|
||||
ok(hr == S_OK, "S_OK, got %08x\n", hr);
|
||||
|
||||
hr = IXmlReader_SetProperty(reader, XmlReaderProperty_DtdProcessing, DtdProcessing_Parse);
|
||||
|
@ -1214,7 +1250,7 @@ static void test_read_element(void)
|
|||
UINT depth;
|
||||
HRESULT hr;
|
||||
|
||||
hr = pCreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
|
||||
hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
|
||||
ok(hr == S_OK, "S_OK, got %08x\n", hr);
|
||||
|
||||
while (test->xml)
|
||||
|
@ -1345,7 +1381,7 @@ static void test_read_pending(void)
|
|||
HRESULT hr;
|
||||
int c;
|
||||
|
||||
hr = pCreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
|
||||
hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
|
||||
ok(hr == S_OK, "S_OK, got 0x%08x\n", hr);
|
||||
|
||||
hr = IXmlReader_SetInput(reader, (IUnknown*)&teststream);
|
||||
|
@ -1383,7 +1419,7 @@ static void test_readvaluechunk(void)
|
|||
HRESULT hr;
|
||||
UINT c;
|
||||
|
||||
hr = pCreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
|
||||
hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
|
||||
ok(hr == S_OK, "S_OK, got %08x\n", hr);
|
||||
|
||||
stream = create_stream_on_data(testA, sizeof(testA));
|
||||
|
@ -1438,7 +1474,7 @@ static void test_read_cdata(void)
|
|||
IXmlReader *reader;
|
||||
HRESULT hr;
|
||||
|
||||
hr = pCreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
|
||||
hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
|
||||
ok(hr == S_OK, "S_OK, got %08x\n", hr);
|
||||
|
||||
while (test->xml)
|
||||
|
@ -1531,7 +1567,7 @@ static void test_read_text(void)
|
|||
IXmlReader *reader;
|
||||
HRESULT hr;
|
||||
|
||||
hr = pCreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
|
||||
hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
|
||||
ok(hr == S_OK, "S_OK, got %08x\n", hr);
|
||||
|
||||
while (test->xml)
|
||||
|
@ -1629,7 +1665,7 @@ static void test_isemptyelement(void)
|
|||
IXmlReader *reader;
|
||||
HRESULT hr;
|
||||
|
||||
hr = pCreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
|
||||
hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
|
||||
ok(hr == S_OK, "S_OK, got %08x\n", hr);
|
||||
|
||||
while (test->xml)
|
||||
|
@ -1687,7 +1723,7 @@ static void test_read_attribute(void)
|
|||
IXmlReader *reader;
|
||||
HRESULT hr;
|
||||
|
||||
hr = pCreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
|
||||
hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
|
||||
ok(hr == S_OK, "S_OK, got %08x\n", hr);
|
||||
|
||||
while (test->xml)
|
||||
|
@ -1756,9 +1792,6 @@ static void test_read_attribute(void)
|
|||
|
||||
START_TEST(reader)
|
||||
{
|
||||
if (!init_pointers())
|
||||
return;
|
||||
|
||||
test_reader_create();
|
||||
test_readerinput();
|
||||
test_reader_state();
|
||||
|
|
|
@ -39,15 +39,116 @@
|
|||
#include <initguid.h>
|
||||
DEFINE_GUID(IID_IXmlWriterOutput, 0xc1131708, 0x0f59, 0x477f, 0x93, 0x59, 0x7d, 0x33, 0x24, 0x51, 0xbc, 0x1a);
|
||||
|
||||
static HRESULT (WINAPI *pCreateXmlWriter)(REFIID riid, void **ppvObject, IMalloc *pMalloc);
|
||||
static HRESULT (WINAPI *pCreateXmlWriterOutputWithEncodingName)(IUnknown *stream,
|
||||
IMalloc *imalloc,
|
||||
LPCWSTR encoding_name,
|
||||
IXmlWriterOutput **output);
|
||||
static HRESULT (WINAPI *pCreateXmlWriterOutputWithEncodingCodePage)(IUnknown *stream,
|
||||
IMalloc *imalloc,
|
||||
UINT codepage,
|
||||
IXmlWriterOutput **output);
|
||||
static void check_output(IStream *stream, const char *expected, int line)
|
||||
{
|
||||
HGLOBAL hglobal;
|
||||
int len = strlen(expected), size;
|
||||
char *ptr;
|
||||
HRESULT hr;
|
||||
|
||||
hr = GetHGlobalFromStream(stream, &hglobal);
|
||||
ok_(__FILE__, line)(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
size = GlobalSize(hglobal);
|
||||
ptr = GlobalLock(hglobal);
|
||||
if (size != len)
|
||||
{
|
||||
ok_(__FILE__, line)(0, "data size mismatch, expected %u, got %u\n", len, size);
|
||||
ok_(__FILE__, line)(0, "got %s, expected %s\n", ptr, expected);
|
||||
}
|
||||
else
|
||||
ok_(__FILE__, line)(!strncmp(ptr, expected, len), "got %s, expected %s\n", ptr, expected);
|
||||
GlobalUnlock(hglobal);
|
||||
}
|
||||
#define CHECK_OUTPUT(stream, expected) check_output(stream, expected, __LINE__)
|
||||
|
||||
/* used to test all Write* methods for consistent error state */
|
||||
static void check_writer_state(IXmlWriter *writer, HRESULT exp_hr)
|
||||
{
|
||||
static const WCHAR aW[] = {'a',0};
|
||||
HRESULT hr;
|
||||
|
||||
/* FIXME: add WriteAttributes */
|
||||
|
||||
hr = IXmlWriter_WriteAttributeString(writer, NULL, aW, NULL, aW);
|
||||
ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr);
|
||||
|
||||
hr = IXmlWriter_WriteCData(writer, aW);
|
||||
ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr);
|
||||
|
||||
hr = IXmlWriter_WriteCharEntity(writer, aW[0]);
|
||||
ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr);
|
||||
|
||||
hr = IXmlWriter_WriteChars(writer, aW, 1);
|
||||
ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr);
|
||||
|
||||
hr = IXmlWriter_WriteComment(writer, aW);
|
||||
ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr);
|
||||
|
||||
/* FIXME: add WriteDocType */
|
||||
|
||||
hr = IXmlWriter_WriteElementString(writer, NULL, aW, NULL, aW);
|
||||
ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr);
|
||||
|
||||
hr = IXmlWriter_WriteEndDocument(writer);
|
||||
ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr);
|
||||
|
||||
hr = IXmlWriter_WriteEndElement(writer);
|
||||
ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr);
|
||||
|
||||
hr = IXmlWriter_WriteEntityRef(writer, aW);
|
||||
ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr);
|
||||
|
||||
hr = IXmlWriter_WriteFullEndElement(writer);
|
||||
ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr);
|
||||
|
||||
hr = IXmlWriter_WriteName(writer, aW);
|
||||
ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr);
|
||||
|
||||
hr = IXmlWriter_WriteNmToken(writer, aW);
|
||||
ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr);
|
||||
|
||||
/* FIXME: add WriteNode */
|
||||
/* FIXME: add WriteNodeShallow */
|
||||
|
||||
hr = IXmlWriter_WriteProcessingInstruction(writer, aW, aW);
|
||||
ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr);
|
||||
|
||||
hr = IXmlWriter_WriteQualifiedName(writer, aW, NULL);
|
||||
ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr);
|
||||
|
||||
hr = IXmlWriter_WriteRaw(writer, aW);
|
||||
ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr);
|
||||
|
||||
hr = IXmlWriter_WriteRawChars(writer, aW, 1);
|
||||
ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr);
|
||||
|
||||
hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit);
|
||||
ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr);
|
||||
|
||||
hr = IXmlWriter_WriteStartElement(writer, NULL, aW, NULL);
|
||||
ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr);
|
||||
|
||||
hr = IXmlWriter_WriteString(writer, aW);
|
||||
ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr);
|
||||
|
||||
/* FIXME: add WriteSurrogateCharEntity */
|
||||
/* FIXME: add WriteWhitespace */
|
||||
}
|
||||
|
||||
static IStream *writer_set_output(IXmlWriter *writer)
|
||||
{
|
||||
IStream *stream;
|
||||
HRESULT hr;
|
||||
|
||||
hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = IXmlWriter_SetOutput(writer, (IUnknown*)stream);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI testoutput_QueryInterface(IUnknown *iface, REFIID riid, void **obj)
|
||||
{
|
||||
|
@ -135,11 +236,11 @@ static void test_writer_create(void)
|
|||
/* crashes native */
|
||||
if (0)
|
||||
{
|
||||
pCreateXmlWriter(&IID_IXmlWriter, NULL, NULL);
|
||||
pCreateXmlWriter(NULL, (void**)&writer, NULL);
|
||||
CreateXmlWriter(&IID_IXmlWriter, NULL, NULL);
|
||||
CreateXmlWriter(NULL, (void**)&writer, NULL);
|
||||
}
|
||||
|
||||
hr = pCreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL);
|
||||
hr = CreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
|
||||
/* check default properties values */
|
||||
|
@ -166,26 +267,6 @@ static void test_writer_create(void)
|
|||
IXmlWriter_Release(writer);
|
||||
}
|
||||
|
||||
static BOOL init_pointers(void)
|
||||
{
|
||||
/* don't free module here, it's to be unloaded on exit */
|
||||
HMODULE mod = LoadLibraryA("xmllite.dll");
|
||||
|
||||
if (!mod)
|
||||
{
|
||||
win_skip("xmllite library not available\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#define MAKEFUNC(f) if (!(p##f = (void*)GetProcAddress(mod, #f))) return FALSE;
|
||||
MAKEFUNC(CreateXmlWriter);
|
||||
MAKEFUNC(CreateXmlWriterOutputWithEncodingName);
|
||||
MAKEFUNC(CreateXmlWriterOutputWithEncodingCodePage);
|
||||
#undef MAKEFUNC
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void test_writeroutput(void)
|
||||
{
|
||||
static const WCHAR utf16W[] = {'u','t','f','-','1','6',0};
|
||||
|
@ -194,11 +275,11 @@ static void test_writeroutput(void)
|
|||
HRESULT hr;
|
||||
|
||||
output = NULL;
|
||||
hr = pCreateXmlWriterOutputWithEncodingName(&testoutput, NULL, NULL, &output);
|
||||
hr = CreateXmlWriterOutputWithEncodingName(&testoutput, NULL, NULL, &output);
|
||||
ok(hr == S_OK, "got %08x\n", hr);
|
||||
IUnknown_Release(output);
|
||||
|
||||
hr = pCreateXmlWriterOutputWithEncodingName(&testoutput, NULL, utf16W, &output);
|
||||
hr = CreateXmlWriterOutputWithEncodingName(&testoutput, NULL, utf16W, &output);
|
||||
ok(hr == S_OK, "got %08x\n", hr);
|
||||
unk = NULL;
|
||||
hr = IUnknown_QueryInterface(output, &IID_IXmlWriterOutput, (void**)&unk);
|
||||
|
@ -208,11 +289,11 @@ static void test_writeroutput(void)
|
|||
IUnknown_Release(output);
|
||||
|
||||
output = NULL;
|
||||
hr = pCreateXmlWriterOutputWithEncodingCodePage(&testoutput, NULL, ~0u, &output);
|
||||
hr = CreateXmlWriterOutputWithEncodingCodePage(&testoutput, NULL, ~0u, &output);
|
||||
ok(hr == S_OK, "got %08x\n", hr);
|
||||
IUnknown_Release(output);
|
||||
|
||||
hr = pCreateXmlWriterOutputWithEncodingCodePage(&testoutput, NULL, CP_UTF8, &output);
|
||||
hr = CreateXmlWriterOutputWithEncodingCodePage(&testoutput, NULL, CP_UTF8, &output);
|
||||
ok(hr == S_OK, "got %08x\n", hr);
|
||||
unk = NULL;
|
||||
hr = IUnknown_QueryInterface(output, &IID_IXmlWriterOutput, (void**)&unk);
|
||||
|
@ -229,12 +310,10 @@ static void test_writestartdocument(void)
|
|||
static const WCHAR versionW[] = {'v','e','r','s','i','o','n','=','"','1','.','0','"',0};
|
||||
static const WCHAR xmlW[] = {'x','m','l',0};
|
||||
IXmlWriter *writer;
|
||||
HGLOBAL hglobal;
|
||||
IStream *stream;
|
||||
HRESULT hr;
|
||||
char *ptr;
|
||||
|
||||
hr = pCreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL);
|
||||
hr = CreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
|
||||
/* output not set */
|
||||
|
@ -247,11 +326,7 @@ static void test_writestartdocument(void)
|
|||
hr = IXmlWriter_Flush(writer);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = IXmlWriter_SetOutput(writer, (IUnknown*)stream);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
stream = writer_set_output(writer);
|
||||
|
||||
/* nothing written yet */
|
||||
hr = IXmlWriter_Flush(writer);
|
||||
|
@ -263,12 +338,7 @@ static void test_writestartdocument(void)
|
|||
hr = IXmlWriter_Flush(writer);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = GetHGlobalFromStream(stream, &hglobal);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
ptr = GlobalLock(hglobal);
|
||||
ok(!strncmp(ptr, fullprolog, strlen(fullprolog)), "got %s, expected %s\n", ptr, fullprolog);
|
||||
GlobalUnlock(hglobal);
|
||||
CHECK_OUTPUT(stream, fullprolog);
|
||||
|
||||
/* one more time */
|
||||
hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Yes);
|
||||
|
@ -276,11 +346,7 @@ static void test_writestartdocument(void)
|
|||
IStream_Release(stream);
|
||||
|
||||
/* now add PI manually, and try to start a document */
|
||||
hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = IXmlWriter_SetOutput(writer, (IUnknown*)stream);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
stream = writer_set_output(writer);
|
||||
|
||||
hr = IXmlWriter_WriteProcessingInstruction(writer, xmlW, versionW);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
@ -298,12 +364,7 @@ static void test_writestartdocument(void)
|
|||
hr = IXmlWriter_Flush(writer);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = GetHGlobalFromStream(stream, &hglobal);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
ptr = GlobalLock(hglobal);
|
||||
ok(!strncmp(ptr, prologversion, strlen(prologversion)), "got %s\n", ptr);
|
||||
GlobalUnlock(hglobal);
|
||||
CHECK_OUTPUT(stream, prologversion);
|
||||
|
||||
IStream_Release(stream);
|
||||
IXmlWriter_Release(writer);
|
||||
|
@ -314,7 +375,7 @@ static void test_flush(void)
|
|||
IXmlWriter *writer;
|
||||
HRESULT hr;
|
||||
|
||||
hr = pCreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL);
|
||||
hr = CreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
|
||||
hr = IXmlWriter_SetOutput(writer, (IUnknown*)&teststream);
|
||||
|
@ -350,14 +411,10 @@ static void test_omitxmldeclaration(void)
|
|||
HRESULT hr;
|
||||
char *ptr;
|
||||
|
||||
hr = pCreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL);
|
||||
hr = CreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
|
||||
hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = IXmlWriter_SetOutput(writer, (IUnknown*)stream);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
stream = writer_set_output(writer);
|
||||
|
||||
hr = IXmlWriter_SetProperty(writer, XmlWriterProperty_OmitXmlDeclaration, TRUE);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
@ -382,11 +439,7 @@ static void test_omitxmldeclaration(void)
|
|||
IStream_Release(stream);
|
||||
|
||||
/* now add PI manually, and try to start a document */
|
||||
hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = IXmlWriter_SetOutput(writer, (IUnknown*)stream);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
stream = writer_set_output(writer);
|
||||
|
||||
hr = IXmlWriter_WriteProcessingInstruction(writer, xmlW, versionW);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
@ -394,12 +447,7 @@ static void test_omitxmldeclaration(void)
|
|||
hr = IXmlWriter_Flush(writer);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = GetHGlobalFromStream(stream, &hglobal);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
ptr = GlobalLock(hglobal);
|
||||
ok(!strncmp(ptr, prologversion, strlen(prologversion)), "got %s\n", ptr);
|
||||
GlobalUnlock(hglobal);
|
||||
CHECK_OUTPUT(stream, prologversion);
|
||||
|
||||
hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Yes);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
@ -407,9 +455,7 @@ static void test_omitxmldeclaration(void)
|
|||
hr = IXmlWriter_Flush(writer);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
ptr = GlobalLock(hglobal);
|
||||
ok(!strncmp(ptr, prologversion, strlen(prologversion)), "got %s\n", ptr);
|
||||
GlobalUnlock(hglobal);
|
||||
CHECK_OUTPUT(stream, prologversion);
|
||||
|
||||
hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Yes);
|
||||
ok(hr == WR_E_INVALIDACTION, "got 0x%08x\n", hr);
|
||||
|
@ -417,9 +463,7 @@ static void test_omitxmldeclaration(void)
|
|||
hr = IXmlWriter_Flush(writer);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
ptr = GlobalLock(hglobal);
|
||||
ok(!strncmp(ptr, prologversion, strlen(prologversion)), "got %s\n", ptr);
|
||||
GlobalUnlock(hglobal);
|
||||
CHECK_OUTPUT(stream, prologversion);
|
||||
|
||||
/* another attempt to add 'xml' PI */
|
||||
hr = IXmlWriter_WriteProcessingInstruction(writer, xmlW, versionW);
|
||||
|
@ -448,10 +492,10 @@ static void test_bom(void)
|
|||
hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = pCreateXmlWriterOutputWithEncodingName((IUnknown*)stream, NULL, utf16W, &output);
|
||||
hr = CreateXmlWriterOutputWithEncodingName((IUnknown*)stream, NULL, utf16W, &output);
|
||||
ok(hr == S_OK, "got %08x\n", hr);
|
||||
|
||||
hr = pCreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL);
|
||||
hr = CreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
|
||||
hr = IXmlWriter_SetProperty(writer, XmlWriterProperty_OmitXmlDeclaration, TRUE);
|
||||
|
@ -481,7 +525,7 @@ static void test_bom(void)
|
|||
hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = pCreateXmlWriterOutputWithEncodingName((IUnknown*)stream, NULL, utf16W, &output);
|
||||
hr = CreateXmlWriterOutputWithEncodingName((IUnknown*)stream, NULL, utf16W, &output);
|
||||
ok(hr == S_OK, "got %08x\n", hr);
|
||||
|
||||
hr = IXmlWriter_SetOutput(writer, output);
|
||||
|
@ -507,7 +551,7 @@ static void test_bom(void)
|
|||
hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = pCreateXmlWriterOutputWithEncodingName((IUnknown*)stream, NULL, utf16W, &output);
|
||||
hr = CreateXmlWriterOutputWithEncodingName((IUnknown*)stream, NULL, utf16W, &output);
|
||||
ok(hr == S_OK, "got %08x\n", hr);
|
||||
|
||||
hr = IXmlWriter_SetOutput(writer, output);
|
||||
|
@ -533,7 +577,7 @@ static void test_bom(void)
|
|||
hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = pCreateXmlWriterOutputWithEncodingName((IUnknown*)stream, NULL, utf16W, &output);
|
||||
hr = CreateXmlWriterOutputWithEncodingName((IUnknown*)stream, NULL, utf16W, &output);
|
||||
ok(hr == S_OK, "got %08x\n", hr);
|
||||
|
||||
hr = IXmlWriter_SetOutput(writer, output);
|
||||
|
@ -564,23 +608,17 @@ static void test_writestartelement(void)
|
|||
static const char *str = "<a><b>value</b>";
|
||||
static const WCHAR aW[] = {'a',0};
|
||||
static const WCHAR bW[] = {'b',0};
|
||||
char *ptr;
|
||||
IXmlWriter *writer;
|
||||
IStream *stream;
|
||||
HGLOBAL hglobal;
|
||||
HRESULT hr;
|
||||
|
||||
hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = pCreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL);
|
||||
hr = CreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
|
||||
hr = IXmlWriter_WriteStartElement(writer, NULL, aW, NULL);
|
||||
ok(hr == E_UNEXPECTED, "got 0x%08x\n", hr);
|
||||
|
||||
hr = IXmlWriter_SetOutput(writer, (IUnknown*)stream);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
stream = writer_set_output(writer);
|
||||
|
||||
hr = IXmlWriter_WriteStartElement(writer, aW, NULL, NULL);
|
||||
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
||||
|
@ -594,18 +632,13 @@ static void test_writestartelement(void)
|
|||
hr = IXmlWriter_WriteStartElement(writer, NULL, aW, NULL);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = GetHGlobalFromStream(stream, &hglobal);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Yes);
|
||||
ok(hr == WR_E_INVALIDACTION, "got 0x%08x\n", hr);
|
||||
|
||||
hr = IXmlWriter_Flush(writer);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
ptr = GlobalLock(hglobal);
|
||||
ok(!strncmp(ptr, "<a", 2), "got %s\n", ptr);
|
||||
GlobalUnlock(hglobal);
|
||||
CHECK_OUTPUT(stream, "<a");
|
||||
|
||||
hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Yes);
|
||||
ok(hr == WR_E_INVALIDACTION, "got 0x%08x\n", hr);
|
||||
|
@ -620,17 +653,13 @@ static void test_writestartelement(void)
|
|||
IXmlWriter_Release(writer);
|
||||
|
||||
/* WriteElementString */
|
||||
hr = pCreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL);
|
||||
hr = CreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
|
||||
hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = IXmlWriter_WriteElementString(writer, NULL, bW, NULL, valueW);
|
||||
ok(hr == E_UNEXPECTED, "got 0x%08x\n", hr);
|
||||
|
||||
hr = IXmlWriter_SetOutput(writer, (IUnknown*)stream);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
stream = writer_set_output(writer);
|
||||
|
||||
hr = IXmlWriter_WriteStartElement(writer, NULL, aW, NULL);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
@ -641,12 +670,7 @@ static void test_writestartelement(void)
|
|||
hr = IXmlWriter_Flush(writer);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = GetHGlobalFromStream(stream, &hglobal);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
ptr = GlobalLock(hglobal);
|
||||
ok(!strncmp(ptr, str, strlen(str)), "got %s\n", ptr);
|
||||
GlobalUnlock(hglobal);
|
||||
CHECK_OUTPUT(stream, str);
|
||||
|
||||
IStream_Release(stream);
|
||||
IXmlWriter_Release(writer);
|
||||
|
@ -656,20 +680,14 @@ static void test_writeendelement(void)
|
|||
{
|
||||
static const WCHAR aW[] = {'a',0};
|
||||
static const WCHAR bW[] = {'b',0};
|
||||
char *ptr;
|
||||
IXmlWriter *writer;
|
||||
IStream *stream;
|
||||
HGLOBAL hglobal;
|
||||
HRESULT hr;
|
||||
|
||||
hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = pCreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL);
|
||||
hr = CreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
|
||||
hr = IXmlWriter_SetOutput(writer, (IUnknown*)stream);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
stream = writer_set_output(writer);
|
||||
|
||||
hr = IXmlWriter_WriteStartElement(writer, NULL, aW, NULL);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
@ -683,15 +701,10 @@ static void test_writeendelement(void)
|
|||
hr = IXmlWriter_WriteEndElement(writer);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = GetHGlobalFromStream(stream, &hglobal);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = IXmlWriter_Flush(writer);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
ptr = GlobalLock(hglobal);
|
||||
ok(!strncmp(ptr, "<a><b /></a>", 12), "got %s\n", ptr);
|
||||
GlobalUnlock(hglobal);
|
||||
CHECK_OUTPUT(stream, "<a><b /></a>");
|
||||
|
||||
IXmlWriter_Release(writer);
|
||||
IStream_Release(stream);
|
||||
|
@ -707,17 +720,13 @@ static void test_writeenddocument(void)
|
|||
HRESULT hr;
|
||||
char *ptr;
|
||||
|
||||
hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = pCreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL);
|
||||
hr = CreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
|
||||
hr = IXmlWriter_WriteEndDocument(writer);
|
||||
ok(hr == E_UNEXPECTED, "got 0x%08x\n", hr);
|
||||
|
||||
hr = IXmlWriter_SetOutput(writer, (IUnknown*)stream);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
stream = writer_set_output(writer);
|
||||
|
||||
/* WriteEndDocument resets it to initial state */
|
||||
hr = IXmlWriter_WriteEndDocument(writer);
|
||||
|
@ -754,21 +763,261 @@ static void test_writeenddocument(void)
|
|||
hr = IXmlWriter_Flush(writer);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
ptr = GlobalLock(hglobal);
|
||||
ok(ptr != NULL, "got %p\n", ptr);
|
||||
ok(!strncmp(ptr, "<a><b /></a>", 12), "got %s\n", ptr);
|
||||
GlobalUnlock(hglobal);
|
||||
CHECK_OUTPUT(stream, "<a><b /></a>");
|
||||
|
||||
IXmlWriter_Release(writer);
|
||||
IStream_Release(stream);
|
||||
}
|
||||
|
||||
static void test_WriteComment(void)
|
||||
{
|
||||
static const WCHAR closeW[] = {'-','-','>',0};
|
||||
static const WCHAR aW[] = {'a',0};
|
||||
static const WCHAR bW[] = {'b',0};
|
||||
IXmlWriter *writer;
|
||||
IStream *stream;
|
||||
HRESULT hr;
|
||||
|
||||
hr = CreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
|
||||
hr = IXmlWriter_SetProperty(writer, XmlWriterProperty_OmitXmlDeclaration, TRUE);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = IXmlWriter_WriteComment(writer, aW);
|
||||
ok(hr == E_UNEXPECTED, "got 0x%08x\n", hr);
|
||||
|
||||
stream = writer_set_output(writer);
|
||||
|
||||
hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = IXmlWriter_WriteComment(writer, aW);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = IXmlWriter_WriteStartElement(writer, NULL, bW, NULL);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = IXmlWriter_WriteComment(writer, aW);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = IXmlWriter_WriteComment(writer, NULL);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = IXmlWriter_WriteComment(writer, closeW);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = IXmlWriter_Flush(writer);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
CHECK_OUTPUT(stream, "<!--a--><b><!--a--><!----><!--- ->-->");
|
||||
|
||||
IXmlWriter_Release(writer);
|
||||
IStream_Release(stream);
|
||||
}
|
||||
|
||||
static void test_WriteCData(void)
|
||||
{
|
||||
static const WCHAR closeW[] = {']',']','>',0};
|
||||
static const WCHAR close2W[] = {'a',']',']','>','b',0};
|
||||
static const WCHAR aW[] = {'a',0};
|
||||
static const WCHAR bW[] = {'b',0};
|
||||
IXmlWriter *writer;
|
||||
IStream *stream;
|
||||
HRESULT hr;
|
||||
|
||||
hr = CreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
|
||||
hr = IXmlWriter_SetProperty(writer, XmlWriterProperty_OmitXmlDeclaration, TRUE);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = IXmlWriter_WriteCData(writer, aW);
|
||||
ok(hr == E_UNEXPECTED, "got 0x%08x\n", hr);
|
||||
|
||||
stream = writer_set_output(writer);
|
||||
|
||||
hr = IXmlWriter_WriteStartElement(writer, NULL, bW, NULL);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = IXmlWriter_WriteCData(writer, aW);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = IXmlWriter_WriteCData(writer, NULL);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = IXmlWriter_WriteCData(writer, closeW);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = IXmlWriter_WriteCData(writer, close2W);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = IXmlWriter_Flush(writer);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
CHECK_OUTPUT(stream,
|
||||
"<b>"
|
||||
"<![CDATA[a]]>"
|
||||
"<![CDATA[]]>"
|
||||
"<![CDATA[]]]]>"
|
||||
"<![CDATA[>]]>"
|
||||
"<![CDATA[a]]]]>"
|
||||
"<![CDATA[>b]]>");
|
||||
|
||||
IXmlWriter_Release(writer);
|
||||
IStream_Release(stream);
|
||||
}
|
||||
|
||||
static void test_WriteRaw(void)
|
||||
{
|
||||
static const WCHAR rawW[] = {'a','<',':',0};
|
||||
static const WCHAR aW[] = {'a',0};
|
||||
IXmlWriter *writer;
|
||||
IStream *stream;
|
||||
HRESULT hr;
|
||||
|
||||
hr = CreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
|
||||
hr = IXmlWriter_WriteRaw(writer, NULL);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = IXmlWriter_WriteRaw(writer, rawW);
|
||||
ok(hr == E_UNEXPECTED, "got 0x%08x\n", hr);
|
||||
|
||||
stream = writer_set_output(writer);
|
||||
|
||||
hr = IXmlWriter_WriteRaw(writer, NULL);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = IXmlWriter_WriteRaw(writer, rawW);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = IXmlWriter_WriteRaw(writer, rawW);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = IXmlWriter_WriteComment(writer, rawW);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = IXmlWriter_WriteRaw(writer, rawW);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = IXmlWriter_WriteElementString(writer, NULL, aW, NULL, aW);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Yes);
|
||||
ok(hr == WR_E_INVALIDACTION, "got 0x%08x\n", hr);
|
||||
|
||||
hr = IXmlWriter_WriteComment(writer, rawW);
|
||||
ok(hr == WR_E_INVALIDACTION, "got 0x%08x\n", hr);
|
||||
|
||||
hr = IXmlWriter_WriteEndDocument(writer);
|
||||
ok(hr == WR_E_INVALIDACTION, "got 0x%08x\n", hr);
|
||||
|
||||
hr = IXmlWriter_WriteRaw(writer, rawW);
|
||||
ok(hr == WR_E_INVALIDACTION, "got 0x%08x\n", hr);
|
||||
|
||||
hr = IXmlWriter_Flush(writer);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
CHECK_OUTPUT(stream, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>a<:a<:<!--a<:-->a<:<a>a</a>");
|
||||
|
||||
IXmlWriter_Release(writer);
|
||||
IStream_Release(stream);
|
||||
}
|
||||
|
||||
static void test_writer_state(void)
|
||||
{
|
||||
static const WCHAR aW[] = {'a',0};
|
||||
IXmlWriter *writer;
|
||||
IStream *stream;
|
||||
HRESULT hr;
|
||||
|
||||
hr = CreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
|
||||
/* initial state */
|
||||
check_writer_state(writer, E_UNEXPECTED);
|
||||
|
||||
/* set output and call 'wrong' method, WriteEndElement */
|
||||
stream = writer_set_output(writer);
|
||||
|
||||
hr = IXmlWriter_WriteEndElement(writer);
|
||||
ok(hr == WR_E_INVALIDACTION, "got 0x%08x\n", hr);
|
||||
|
||||
check_writer_state(writer, WR_E_INVALIDACTION);
|
||||
IStream_Release(stream);
|
||||
|
||||
/* WriteAttributeString */
|
||||
stream = writer_set_output(writer);
|
||||
|
||||
hr = IXmlWriter_WriteAttributeString(writer, NULL, aW, NULL, aW);
|
||||
ok(hr == WR_E_INVALIDACTION, "got 0x%08x\n", hr);
|
||||
|
||||
check_writer_state(writer, WR_E_INVALIDACTION);
|
||||
IStream_Release(stream);
|
||||
|
||||
/* WriteEndDocument */
|
||||
stream = writer_set_output(writer);
|
||||
|
||||
hr = IXmlWriter_WriteEndDocument(writer);
|
||||
ok(hr == WR_E_INVALIDACTION, "got 0x%08x\n", hr);
|
||||
|
||||
check_writer_state(writer, WR_E_INVALIDACTION);
|
||||
IStream_Release(stream);
|
||||
|
||||
/* WriteFullEndElement */
|
||||
stream = writer_set_output(writer);
|
||||
|
||||
hr = IXmlWriter_WriteFullEndElement(writer);
|
||||
ok(hr == WR_E_INVALIDACTION, "got 0x%08x\n", hr);
|
||||
|
||||
check_writer_state(writer, WR_E_INVALIDACTION);
|
||||
IStream_Release(stream);
|
||||
|
||||
/* WriteCData */
|
||||
stream = writer_set_output(writer);
|
||||
|
||||
hr = IXmlWriter_WriteCData(writer, aW);
|
||||
ok(hr == WR_E_INVALIDACTION, "got 0x%08x\n", hr);
|
||||
|
||||
check_writer_state(writer, WR_E_INVALIDACTION);
|
||||
IStream_Release(stream);
|
||||
|
||||
/* WriteName */
|
||||
stream = writer_set_output(writer);
|
||||
|
||||
hr = IXmlWriter_WriteName(writer, aW);
|
||||
ok(hr == WR_E_INVALIDACTION, "got 0x%08x\n", hr);
|
||||
|
||||
check_writer_state(writer, WR_E_INVALIDACTION);
|
||||
IStream_Release(stream);
|
||||
|
||||
/* WriteNmToken */
|
||||
stream = writer_set_output(writer);
|
||||
|
||||
hr = IXmlWriter_WriteNmToken(writer, aW);
|
||||
ok(hr == WR_E_INVALIDACTION, "got 0x%08x\n", hr);
|
||||
|
||||
check_writer_state(writer, WR_E_INVALIDACTION);
|
||||
IStream_Release(stream);
|
||||
|
||||
/* WriteString */
|
||||
stream = writer_set_output(writer);
|
||||
|
||||
hr = IXmlWriter_WriteString(writer, aW);
|
||||
ok(hr == WR_E_INVALIDACTION, "got 0x%08x\n", hr);
|
||||
|
||||
check_writer_state(writer, WR_E_INVALIDACTION);
|
||||
IStream_Release(stream);
|
||||
|
||||
IXmlWriter_Release(writer);
|
||||
}
|
||||
|
||||
START_TEST(writer)
|
||||
{
|
||||
if (!init_pointers())
|
||||
return;
|
||||
|
||||
test_writer_create();
|
||||
test_writer_state();
|
||||
test_writeroutput();
|
||||
test_writestartdocument();
|
||||
test_writestartelement();
|
||||
|
@ -777,4 +1026,7 @@ START_TEST(writer)
|
|||
test_omitxmldeclaration();
|
||||
test_bom();
|
||||
test_writeenddocument();
|
||||
test_WriteComment();
|
||||
test_WriteCData();
|
||||
test_WriteRaw();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue