2008-07-08 20:53:43 +02:00
|
|
|
/*
|
2012-04-15 11:47:30 +02:00
|
|
|
* SAXReader/MXWriter tests
|
2008-07-08 20:53:43 +02:00
|
|
|
*
|
|
|
|
* Copyright 2008 Piotr Caban
|
2011-08-13 01:11:30 +02:00
|
|
|
* Copyright 2011 Thomas Mullaly
|
2012-04-15 11:47:30 +02:00
|
|
|
* Copyright 2012 Nikolay Sivov
|
2008-07-08 20:53:43 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
#define CONST_VTABLE
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2011-05-01 18:05:31 +02:00
|
|
|
#include <assert.h>
|
|
|
|
|
2008-07-08 20:53:43 +02:00
|
|
|
#include "windows.h"
|
|
|
|
#include "ole2.h"
|
|
|
|
#include "msxml2.h"
|
2011-11-21 10:23:25 +01:00
|
|
|
#include "msxml2did.h"
|
2008-07-08 20:53:43 +02:00
|
|
|
#include "ocidl.h"
|
2011-11-21 10:23:25 +01:00
|
|
|
#include "dispex.h"
|
2008-07-08 20:53:43 +02:00
|
|
|
|
|
|
|
#include "wine/test.h"
|
|
|
|
|
2013-07-27 16:27:27 +02:00
|
|
|
static const WCHAR emptyW[] = {0};
|
|
|
|
|
2011-08-25 13:31:02 +02:00
|
|
|
#define EXPECT_HR(hr,hr_exp) \
|
|
|
|
ok(hr == hr_exp, "got 0x%08x, expected 0x%08x\n", hr, hr_exp)
|
|
|
|
|
2011-04-30 13:18:03 +02:00
|
|
|
#define EXPECT_REF(obj,ref) _expect_ref((IUnknown*)obj, ref, __LINE__)
|
|
|
|
static void _expect_ref(IUnknown* obj, ULONG ref, int line)
|
|
|
|
{
|
|
|
|
ULONG rc = IUnknown_AddRef(obj);
|
|
|
|
IUnknown_Release(obj);
|
|
|
|
ok_(__FILE__,line)(rc-1 == ref, "expected refcount %d, got %d\n", ref, rc-1);
|
|
|
|
}
|
|
|
|
|
2012-04-26 21:54:22 +02:00
|
|
|
static LONG get_refcount(void *iface)
|
|
|
|
{
|
|
|
|
IUnknown *unk = iface;
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
ref = IUnknown_AddRef(unk);
|
|
|
|
IUnknown_Release(unk);
|
|
|
|
return ref-1;
|
|
|
|
}
|
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
struct msxmlsupported_data_t
|
|
|
|
{
|
|
|
|
const GUID *clsid;
|
|
|
|
const char *name;
|
|
|
|
BOOL supported;
|
|
|
|
};
|
|
|
|
|
|
|
|
static BOOL is_clsid_supported(const GUID *clsid, const struct msxmlsupported_data_t *table)
|
|
|
|
{
|
|
|
|
while (table->clsid)
|
|
|
|
{
|
|
|
|
if (table->clsid == clsid) return table->supported;
|
|
|
|
table++;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-05-01 18:05:31 +02:00
|
|
|
static BSTR alloc_str_from_narrow(const char *str)
|
|
|
|
{
|
|
|
|
int len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
|
|
|
|
BSTR ret = SysAllocStringLen(NULL, len - 1); /* NUL character added automatically */
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-08-27 12:19:22 +02:00
|
|
|
static BSTR alloced_bstrs[512];
|
2011-05-01 18:05:31 +02:00
|
|
|
static int alloced_bstrs_count;
|
|
|
|
|
|
|
|
static BSTR _bstr_(const char *str)
|
|
|
|
{
|
|
|
|
assert(alloced_bstrs_count < sizeof(alloced_bstrs)/sizeof(alloced_bstrs[0]));
|
|
|
|
alloced_bstrs[alloced_bstrs_count] = alloc_str_from_narrow(str);
|
|
|
|
return alloced_bstrs[alloced_bstrs_count++];
|
|
|
|
}
|
|
|
|
|
|
|
|
static void free_bstrs(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < alloced_bstrs_count; i++)
|
|
|
|
SysFreeString(alloced_bstrs[i]);
|
|
|
|
alloced_bstrs_count = 0;
|
|
|
|
}
|
|
|
|
|
2013-10-29 22:23:38 +01:00
|
|
|
static void test_saxstr(const char *file, unsigned line, BSTR str, const char *expected, BOOL todo, int *failcount)
|
2012-04-15 11:47:30 +02:00
|
|
|
{
|
|
|
|
int len, lenexp, cmp;
|
|
|
|
WCHAR buf[1024];
|
|
|
|
|
|
|
|
len = SysStringLen(str);
|
|
|
|
|
|
|
|
if (!expected) {
|
|
|
|
if (str && todo)
|
|
|
|
{
|
|
|
|
(*failcount)++;
|
|
|
|
todo_wine
|
|
|
|
ok_(file, line) (!str, "got %p, expected null str\n", str);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ok_(file, line) (!str, "got %p, expected null str\n", str);
|
|
|
|
|
|
|
|
if (len && todo)
|
|
|
|
{
|
|
|
|
(*failcount)++;
|
|
|
|
todo_wine
|
|
|
|
ok_(file, line) (len == 0, "got len %d, expected 0\n", len);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ok_(file, line) (len == 0, "got len %d, expected 0\n", len);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
lenexp = strlen(expected);
|
|
|
|
if (lenexp != len && todo)
|
|
|
|
{
|
|
|
|
(*failcount)++;
|
|
|
|
todo_wine
|
|
|
|
ok_(file, line) (lenexp == len, "len %d (%s), expected %d (%s)\n", len, wine_dbgstr_wn(str, len), lenexp, expected);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ok_(file, line) (lenexp == len, "len %d (%s), expected %d (%s)\n", len, wine_dbgstr_wn(str, len), lenexp, expected);
|
|
|
|
|
|
|
|
/* exit earlier on length mismatch */
|
|
|
|
if (lenexp != len) return;
|
|
|
|
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, expected, -1, buf, sizeof(buf)/sizeof(WCHAR));
|
|
|
|
|
|
|
|
cmp = memcmp(str, buf, lenexp*sizeof(WCHAR));
|
|
|
|
if (cmp && todo)
|
|
|
|
{
|
|
|
|
(*failcount)++;
|
|
|
|
todo_wine
|
|
|
|
ok_(file, line) (!cmp, "unexpected str %s, expected %s\n",
|
|
|
|
wine_dbgstr_wn(str, len), expected);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ok_(file, line) (!cmp, "unexpected str %s, expected %s\n",
|
|
|
|
wine_dbgstr_wn(str, len), expected);
|
|
|
|
}
|
|
|
|
|
2008-07-17 00:42:14 +02:00
|
|
|
typedef enum _CH {
|
|
|
|
CH_ENDTEST,
|
|
|
|
CH_PUTDOCUMENTLOCATOR,
|
|
|
|
CH_STARTDOCUMENT,
|
|
|
|
CH_ENDDOCUMENT,
|
|
|
|
CH_STARTPREFIXMAPPING,
|
|
|
|
CH_ENDPREFIXMAPPING,
|
|
|
|
CH_STARTELEMENT,
|
|
|
|
CH_ENDELEMENT,
|
|
|
|
CH_CHARACTERS,
|
|
|
|
CH_IGNORABLEWHITESPACE,
|
|
|
|
CH_PROCESSINGINSTRUCTION,
|
2011-10-24 12:55:22 +02:00
|
|
|
CH_SKIPPEDENTITY,
|
2013-03-12 09:45:54 +01:00
|
|
|
LH_STARTCDATA,
|
|
|
|
LH_ENDCDATA,
|
2011-10-24 12:55:22 +02:00
|
|
|
EH_ERROR,
|
|
|
|
EH_FATALERROR,
|
2013-03-12 09:45:54 +01:00
|
|
|
EH_IGNORABLEWARNING,
|
2012-04-15 11:47:30 +02:00
|
|
|
EVENT_LAST
|
2008-07-17 00:42:14 +02:00
|
|
|
} CH;
|
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
static const char *event_names[EVENT_LAST] = {
|
|
|
|
"endtest",
|
|
|
|
"putDocumentLocator",
|
|
|
|
"startDocument",
|
|
|
|
"endDocument",
|
|
|
|
"startPrefixMapping",
|
|
|
|
"endPrefixMapping",
|
|
|
|
"startElement",
|
|
|
|
"endElement",
|
|
|
|
"characters",
|
|
|
|
"ignorableWhitespace",
|
2012-05-15 10:15:32 +02:00
|
|
|
"processingInstruction",
|
2012-04-15 11:47:30 +02:00
|
|
|
"skippedEntity",
|
2013-03-12 09:45:54 +01:00
|
|
|
"startCDATA",
|
|
|
|
"endCDATA",
|
2012-04-15 11:47:30 +02:00
|
|
|
"error",
|
|
|
|
"fatalError",
|
|
|
|
"ignorableWarning"
|
|
|
|
};
|
|
|
|
|
|
|
|
struct attribute_entry {
|
|
|
|
const char *uri;
|
|
|
|
const char *local;
|
|
|
|
const char *qname;
|
|
|
|
const char *value;
|
|
|
|
|
|
|
|
/* used for actual call data only, null for expected call data */
|
|
|
|
BSTR uriW;
|
|
|
|
BSTR localW;
|
|
|
|
BSTR qnameW;
|
|
|
|
BSTR valueW;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct call_entry {
|
|
|
|
CH id;
|
|
|
|
int line;
|
|
|
|
int column;
|
|
|
|
HRESULT ret;
|
|
|
|
const char *arg1;
|
|
|
|
const char *arg2;
|
|
|
|
const char *arg3;
|
|
|
|
|
|
|
|
/* allocated once at startElement callback */
|
|
|
|
struct attribute_entry *attributes;
|
|
|
|
int attr_count;
|
|
|
|
|
|
|
|
/* used for actual call data only, null for expected call data */
|
|
|
|
BSTR arg1W;
|
|
|
|
BSTR arg2W;
|
|
|
|
BSTR arg3W;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct call_sequence
|
|
|
|
{
|
|
|
|
int count;
|
|
|
|
int size;
|
|
|
|
struct call_entry *sequence;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define CONTENT_HANDLER_INDEX 0
|
|
|
|
#define NUM_CALL_SEQUENCES 1
|
|
|
|
static struct call_sequence *sequences[NUM_CALL_SEQUENCES];
|
|
|
|
|
|
|
|
static void init_call_entry(ISAXLocator *locator, struct call_entry *call)
|
|
|
|
{
|
|
|
|
memset(call, 0, sizeof(*call));
|
|
|
|
ISAXLocator_getLineNumber(locator, &call->line);
|
|
|
|
ISAXLocator_getColumnNumber(locator, &call->column);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void add_call(struct call_sequence **seq, int sequence_index,
|
|
|
|
const struct call_entry *call)
|
|
|
|
{
|
|
|
|
struct call_sequence *call_seq = seq[sequence_index];
|
|
|
|
|
|
|
|
if (!call_seq->sequence)
|
|
|
|
{
|
|
|
|
call_seq->size = 10;
|
|
|
|
call_seq->sequence = HeapAlloc(GetProcessHeap(), 0,
|
|
|
|
call_seq->size * sizeof (struct call_entry));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (call_seq->count == call_seq->size)
|
|
|
|
{
|
|
|
|
call_seq->size *= 2;
|
|
|
|
call_seq->sequence = HeapReAlloc(GetProcessHeap(), 0,
|
|
|
|
call_seq->sequence,
|
|
|
|
call_seq->size * sizeof (struct call_entry));
|
|
|
|
}
|
|
|
|
|
|
|
|
assert(call_seq->sequence);
|
|
|
|
|
|
|
|
call_seq->sequence[call_seq->count].id = call->id;
|
|
|
|
call_seq->sequence[call_seq->count].line = call->line;
|
|
|
|
call_seq->sequence[call_seq->count].column = call->column;
|
|
|
|
call_seq->sequence[call_seq->count].arg1W = call->arg1W;
|
|
|
|
call_seq->sequence[call_seq->count].arg2W = call->arg2W;
|
|
|
|
call_seq->sequence[call_seq->count].arg3W = call->arg3W;
|
|
|
|
call_seq->sequence[call_seq->count].ret = call->ret;
|
|
|
|
call_seq->sequence[call_seq->count].attr_count = call->attr_count;
|
|
|
|
call_seq->sequence[call_seq->count].attributes = call->attributes;
|
|
|
|
|
|
|
|
call_seq->count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void flush_sequence(struct call_sequence **seg, int sequence_index)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
struct call_sequence *call_seq = seg[sequence_index];
|
|
|
|
|
|
|
|
for (i = 0; i < call_seq->count; i++)
|
|
|
|
{
|
|
|
|
int j;
|
|
|
|
|
|
|
|
for (j = 0; j < call_seq->sequence[i].attr_count; j++)
|
|
|
|
{
|
|
|
|
SysFreeString(call_seq->sequence[i].attributes[j].uriW);
|
|
|
|
SysFreeString(call_seq->sequence[i].attributes[j].localW);
|
|
|
|
SysFreeString(call_seq->sequence[i].attributes[j].qnameW);
|
|
|
|
}
|
|
|
|
|
|
|
|
SysFreeString(call_seq->sequence[i].arg1W);
|
|
|
|
SysFreeString(call_seq->sequence[i].arg2W);
|
|
|
|
SysFreeString(call_seq->sequence[i].arg3W);
|
|
|
|
}
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, call_seq->sequence);
|
|
|
|
call_seq->sequence = NULL;
|
|
|
|
call_seq->count = call_seq->size = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *get_event_name(CH event)
|
|
|
|
{
|
|
|
|
return event_names[event];
|
|
|
|
}
|
|
|
|
|
|
|
|
static void compare_attributes(const struct call_entry *actual, const struct call_entry *expected, const char *context,
|
2013-10-29 22:23:38 +01:00
|
|
|
BOOL todo, const char *file, int line, int *failcount)
|
2012-04-15 11:47:30 +02:00
|
|
|
{
|
|
|
|
int i, lenexp = 0;
|
|
|
|
|
|
|
|
/* attribute count is not stored for expected data */
|
|
|
|
if (expected->attributes)
|
|
|
|
{
|
|
|
|
struct attribute_entry *ptr = expected->attributes;
|
|
|
|
while (ptr->uri) { lenexp++; ptr++; };
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check count first and exit earlier */
|
|
|
|
if (actual->attr_count != lenexp && todo)
|
|
|
|
{
|
|
|
|
(*failcount)++;
|
|
|
|
todo_wine
|
|
|
|
ok_(file, line) (FALSE, "%s: in event %s expecting attr count %d got %d\n",
|
|
|
|
context, get_event_name(actual->id), lenexp, actual->attr_count);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ok_(file, line) (actual->attr_count == lenexp, "%s: in event %s expecting attr count %d got %d\n",
|
|
|
|
context, get_event_name(actual->id), lenexp, actual->attr_count);
|
|
|
|
|
|
|
|
if (actual->attr_count != lenexp) return;
|
|
|
|
|
|
|
|
/* now compare all attributes strings */
|
|
|
|
for (i = 0; i < actual->attr_count; i++)
|
|
|
|
{
|
|
|
|
test_saxstr(file, line, actual->attributes[i].uriW, expected->attributes[i].uri, todo, failcount);
|
|
|
|
test_saxstr(file, line, actual->attributes[i].localW, expected->attributes[i].local, todo, failcount);
|
|
|
|
test_saxstr(file, line, actual->attributes[i].qnameW, expected->attributes[i].qname, todo, failcount);
|
|
|
|
test_saxstr(file, line, actual->attributes[i].valueW, expected->attributes[i].value, todo, failcount);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ok_sequence_(struct call_sequence **seq, int sequence_index,
|
2013-10-29 22:23:38 +01:00
|
|
|
const struct call_entry *expected, const char *context, BOOL todo,
|
2012-04-15 11:47:30 +02:00
|
|
|
const char *file, int line)
|
|
|
|
{
|
|
|
|
struct call_sequence *call_seq = seq[sequence_index];
|
|
|
|
static const struct call_entry end_of_sequence = { CH_ENDTEST };
|
|
|
|
const struct call_entry *actual, *sequence;
|
|
|
|
int failcount = 0;
|
|
|
|
|
|
|
|
add_call(seq, sequence_index, &end_of_sequence);
|
|
|
|
|
|
|
|
sequence = call_seq->sequence;
|
|
|
|
actual = sequence;
|
|
|
|
|
|
|
|
while (expected->id != CH_ENDTEST && actual->id != CH_ENDTEST)
|
|
|
|
{
|
|
|
|
if (expected->id == actual->id)
|
|
|
|
{
|
2014-02-12 13:30:56 +01:00
|
|
|
if (expected->line != -1)
|
2012-04-15 11:47:30 +02:00
|
|
|
{
|
2014-02-12 13:30:56 +01:00
|
|
|
/* always test position data */
|
|
|
|
if (expected->line != actual->line && todo)
|
2012-04-15 11:47:30 +02:00
|
|
|
{
|
2014-02-12 13:30:56 +01:00
|
|
|
todo_wine
|
|
|
|
{
|
|
|
|
failcount++;
|
|
|
|
ok_(file, line) (FALSE,
|
|
|
|
"%s: in event %s expecting line %d got %d\n",
|
|
|
|
context, get_event_name(actual->id), expected->line, actual->line);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ok_(file, line) (expected->line == actual->line,
|
2012-04-15 11:47:30 +02:00
|
|
|
"%s: in event %s expecting line %d got %d\n",
|
|
|
|
context, get_event_name(actual->id), expected->line, actual->line);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-12 13:30:56 +01:00
|
|
|
|
|
|
|
if (expected->column != -1)
|
2012-04-15 11:47:30 +02:00
|
|
|
{
|
2014-02-12 13:30:56 +01:00
|
|
|
if (expected->column != actual->column && todo)
|
2012-04-15 11:47:30 +02:00
|
|
|
{
|
2014-02-12 13:30:56 +01:00
|
|
|
todo_wine
|
|
|
|
{
|
|
|
|
failcount++;
|
|
|
|
ok_(file, line) (FALSE,
|
|
|
|
"%s: in event %s expecting column %d got %d\n",
|
|
|
|
context, get_event_name(actual->id), expected->column, actual->column);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ok_(file, line) (expected->column == actual->column,
|
2012-04-15 11:47:30 +02:00
|
|
|
"%s: in event %s expecting column %d got %d\n",
|
|
|
|
context, get_event_name(actual->id), expected->column, actual->column);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (actual->id)
|
|
|
|
{
|
|
|
|
case CH_PUTDOCUMENTLOCATOR:
|
|
|
|
case CH_STARTDOCUMENT:
|
|
|
|
case CH_ENDDOCUMENT:
|
2013-03-12 09:45:54 +01:00
|
|
|
case LH_STARTCDATA:
|
|
|
|
case LH_ENDCDATA:
|
2012-04-15 11:47:30 +02:00
|
|
|
break;
|
|
|
|
case CH_STARTPREFIXMAPPING:
|
|
|
|
/* prefix, uri */
|
|
|
|
test_saxstr(file, line, actual->arg1W, expected->arg1, todo, &failcount);
|
|
|
|
test_saxstr(file, line, actual->arg2W, expected->arg2, todo, &failcount);
|
|
|
|
break;
|
|
|
|
case CH_ENDPREFIXMAPPING:
|
|
|
|
/* prefix */
|
|
|
|
test_saxstr(file, line, actual->arg1W, expected->arg1, todo, &failcount);
|
|
|
|
break;
|
|
|
|
case CH_STARTELEMENT:
|
|
|
|
/* compare attributes */
|
|
|
|
compare_attributes(actual, expected, context, todo, file, line, &failcount);
|
|
|
|
/* fallthrough */
|
|
|
|
case CH_ENDELEMENT:
|
|
|
|
/* uri, localname, qname */
|
|
|
|
test_saxstr(file, line, actual->arg1W, expected->arg1, todo, &failcount);
|
|
|
|
test_saxstr(file, line, actual->arg2W, expected->arg2, todo, &failcount);
|
|
|
|
test_saxstr(file, line, actual->arg3W, expected->arg3, todo, &failcount);
|
|
|
|
break;
|
|
|
|
case CH_CHARACTERS:
|
|
|
|
case CH_IGNORABLEWHITESPACE:
|
|
|
|
/* char data */
|
|
|
|
test_saxstr(file, line, actual->arg1W, expected->arg1, todo, &failcount);
|
|
|
|
break;
|
|
|
|
case CH_PROCESSINGINSTRUCTION:
|
|
|
|
/* target, data */
|
|
|
|
test_saxstr(file, line, actual->arg1W, expected->arg1, todo, &failcount);
|
|
|
|
test_saxstr(file, line, actual->arg2W, expected->arg2, todo, &failcount);
|
|
|
|
break;
|
|
|
|
case CH_SKIPPEDENTITY:
|
|
|
|
/* name */
|
|
|
|
test_saxstr(file, line, actual->arg1W, expected->arg1, todo, &failcount);
|
|
|
|
break;
|
|
|
|
case EH_FATALERROR:
|
|
|
|
/* test return value only */
|
|
|
|
if (expected->ret != actual->ret && todo)
|
|
|
|
{
|
|
|
|
failcount++;
|
|
|
|
ok_(file, line) (FALSE,
|
|
|
|
"%s: in event %s expecting ret 0x%08x got 0x%08x\n",
|
|
|
|
context, get_event_name(actual->id), expected->ret, actual->ret);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ok_(file, line) (expected->ret == actual->ret,
|
|
|
|
"%s: in event %s expecting ret 0x%08x got 0x%08x\n",
|
|
|
|
context, get_event_name(actual->id), expected->ret, actual->ret);
|
|
|
|
break;
|
|
|
|
case EH_ERROR:
|
2013-03-12 09:45:54 +01:00
|
|
|
case EH_IGNORABLEWARNING:
|
2012-04-15 11:47:30 +02:00
|
|
|
default:
|
|
|
|
ok(0, "%s: callback not handled, %s\n", context, get_event_name(actual->id));
|
|
|
|
}
|
|
|
|
expected++;
|
|
|
|
actual++;
|
|
|
|
}
|
|
|
|
else if (todo)
|
|
|
|
{
|
|
|
|
failcount++;
|
|
|
|
todo_wine
|
|
|
|
{
|
|
|
|
ok_(file, line) (FALSE, "%s: call %s was expected, but got call %s instead\n",
|
|
|
|
context, get_event_name(expected->id), get_event_name(actual->id));
|
|
|
|
}
|
|
|
|
|
|
|
|
flush_sequence(seq, sequence_index);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ok_(file, line) (FALSE, "%s: call %s was expected, but got call %s instead\n",
|
|
|
|
context, get_event_name(expected->id), get_event_name(actual->id));
|
|
|
|
expected++;
|
|
|
|
actual++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (todo)
|
|
|
|
{
|
|
|
|
todo_wine
|
|
|
|
{
|
|
|
|
if (expected->id != CH_ENDTEST || actual->id != CH_ENDTEST)
|
|
|
|
{
|
|
|
|
failcount++;
|
|
|
|
ok_(file, line) (FALSE, "%s: the call sequence is not complete: expected %s - actual %s\n",
|
|
|
|
context, get_event_name(expected->id), get_event_name(actual->id));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (expected->id != CH_ENDTEST || actual->id != CH_ENDTEST)
|
|
|
|
{
|
|
|
|
ok_(file, line) (FALSE, "%s: the call sequence is not complete: expected %s - actual %s\n",
|
|
|
|
context, get_event_name(expected->id), get_event_name(actual->id));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (todo && !failcount) /* succeeded yet marked todo */
|
|
|
|
{
|
|
|
|
todo_wine
|
|
|
|
{
|
|
|
|
ok_(file, line)(TRUE, "%s: marked \"todo_wine\" but succeeds\n", context);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
flush_sequence(seq, sequence_index);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define ok_sequence(seq, index, exp, contx, todo) \
|
|
|
|
ok_sequence_(seq, index, (exp), (contx), (todo), __FILE__, __LINE__)
|
|
|
|
|
|
|
|
static void init_call_sequences(struct call_sequence **seq, int n)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
seq[i] = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct call_sequence));
|
|
|
|
}
|
|
|
|
|
2008-07-10 15:22:14 +02:00
|
|
|
static const WCHAR szSimpleXML[] = {
|
|
|
|
'<','?','x','m','l',' ','v','e','r','s','i','o','n','=','\"','1','.','0','\"',' ','?','>','\n',
|
|
|
|
'<','B','a','n','k','A','c','c','o','u','n','t','>','\n',
|
|
|
|
' ',' ',' ','<','N','u','m','b','e','r','>','1','2','3','4','<','/','N','u','m','b','e','r','>','\n',
|
|
|
|
' ',' ',' ','<','N','a','m','e','>','C','a','p','t','a','i','n',' ','A','h','a','b','<','/','N','a','m','e','>','\n',
|
|
|
|
'<','/','B','a','n','k','A','c','c','o','u','n','t','>','\n','\0'
|
|
|
|
};
|
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
static const WCHAR carriage_ret_test[] = {
|
2008-07-23 16:39:43 +02:00
|
|
|
'<','?','x','m','l',' ','v','e','r','s','i','o','n','=','"','1','.','0','"','?','>','\r','\n',
|
|
|
|
'<','B','a','n','k','A','c','c','o','u','n','t','>','\r','\n',
|
|
|
|
'\t','<','N','u','m','b','e','r','>','1','2','3','4','<','/','N','u','m','b','e','r','>','\r','\n',
|
|
|
|
'\t','<','N','a','m','e','>','C','a','p','t','a','i','n',' ','A','h','a','b','<','/','N','a','m','e','>','\r','\n',
|
2011-10-24 20:09:12 +02:00
|
|
|
'<','/','B','a','n','k','A','c','c','o','u','n','t','>','\r','\n','\0'
|
2008-07-23 16:39:43 +02:00
|
|
|
};
|
|
|
|
|
2011-08-13 01:11:30 +02:00
|
|
|
static const WCHAR szUtf16XML[] = {
|
|
|
|
'<','?','x','m','l',' ','v','e','r','s','i','o','n','=','"','1','.','0','"',' ',
|
|
|
|
'e','n','c','o','d','i','n','g','=','"','U','T','F','-','1','6','"',' ',
|
|
|
|
's','t','a','n','d','a','l','o','n','e','=','"','n','o','"','?','>','\r','\n'
|
|
|
|
};
|
|
|
|
|
|
|
|
static const CHAR szUtf16BOM[] = {0xff, 0xfe};
|
|
|
|
|
|
|
|
static const CHAR szUtf8XML[] =
|
|
|
|
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\r\n";
|
|
|
|
|
2011-12-16 00:36:53 +01:00
|
|
|
static const char utf8xml2[] =
|
|
|
|
"<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\r\n";
|
|
|
|
|
2012-08-27 07:39:43 +02:00
|
|
|
static const char testXML[] =
|
2008-07-19 22:32:26 +02:00
|
|
|
"<?xml version=\"1.0\" ?>\n"
|
|
|
|
"<BankAccount>\n"
|
|
|
|
" <Number>1234</Number>\n"
|
|
|
|
" <Name>Captain Ahab</Name>\n"
|
|
|
|
"</BankAccount>\n";
|
|
|
|
|
2012-04-19 08:46:03 +02:00
|
|
|
static const char test_attributes[] =
|
2011-10-26 13:25:52 +02:00
|
|
|
"<?xml version=\"1.0\" ?>\n"
|
2011-10-31 12:33:28 +01:00
|
|
|
"<document xmlns:test=\"prefix_test\" xmlns=\"prefix\" test:arg1=\"arg1\" arg2=\"arg2\" test:ar3=\"arg3\">\n"
|
2011-10-31 12:32:49 +01:00
|
|
|
"<node1 xmlns:p=\"test\" />"
|
2011-10-26 13:25:52 +02:00
|
|
|
"</document>\n";
|
|
|
|
|
2013-03-12 09:45:54 +01:00
|
|
|
static const char test_cdata_xml[] =
|
|
|
|
"<?xml version=\"1.0\" ?>"
|
2013-03-13 12:04:59 +01:00
|
|
|
"<a><![CDATA[Some \r\ntext\n\r\ndata\n\n]]></a>";
|
|
|
|
|
|
|
|
static const char test2_cdata_xml[] =
|
|
|
|
"<?xml version=\"1.0\" ?>"
|
|
|
|
"<a><![CDATA[\n\r\nSome \r\ntext\n\r\ndata\n\n]]></a>";
|
|
|
|
|
|
|
|
static const char test3_cdata_xml[] =
|
|
|
|
"<?xml version=\"1.0\" ?><a><![CDATA[Some text data]]></a>";
|
2013-03-12 09:45:54 +01:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
static struct call_entry content_handler_test1[] = {
|
|
|
|
{ CH_PUTDOCUMENTLOCATOR, 0, 0, S_OK },
|
|
|
|
{ CH_STARTDOCUMENT, 0, 0, S_OK },
|
|
|
|
{ CH_STARTELEMENT, 2, 14, S_OK, "", "BankAccount", "BankAccount" },
|
|
|
|
{ CH_CHARACTERS, 2, 14, S_OK, "\n " },
|
|
|
|
{ CH_STARTELEMENT, 3, 12, S_OK, "", "Number", "Number" },
|
|
|
|
{ CH_CHARACTERS, 3, 12, S_OK, "1234" },
|
|
|
|
{ CH_ENDELEMENT, 3, 18, S_OK, "", "Number", "Number" },
|
|
|
|
{ CH_CHARACTERS, 3, 25, S_OK, "\n " },
|
|
|
|
{ CH_STARTELEMENT, 4, 10, S_OK, "", "Name", "Name" },
|
|
|
|
{ CH_CHARACTERS, 4, 10, S_OK, "Captain Ahab" },
|
|
|
|
{ CH_ENDELEMENT, 4, 24, S_OK, "", "Name", "Name" },
|
|
|
|
{ CH_CHARACTERS, 4, 29, S_OK, "\n" },
|
|
|
|
{ CH_ENDELEMENT, 5, 3, S_OK, "", "BankAccount", "BankAccount" },
|
|
|
|
{ CH_ENDDOCUMENT, 0, 0, S_OK},
|
|
|
|
{ CH_ENDTEST }
|
|
|
|
};
|
|
|
|
|
|
|
|
/* applies to versions 4 and 6 */
|
|
|
|
static struct call_entry content_handler_test1_alternate[] = {
|
|
|
|
{ CH_PUTDOCUMENTLOCATOR, 1, 0, S_OK },
|
|
|
|
{ CH_STARTDOCUMENT, 1, 22, S_OK },
|
|
|
|
{ CH_STARTELEMENT, 2, 13, S_OK, "", "BankAccount", "BankAccount" },
|
|
|
|
{ CH_CHARACTERS, 3, 4, S_OK, "\n " },
|
|
|
|
{ CH_STARTELEMENT, 3, 11, S_OK, "", "Number", "Number" },
|
|
|
|
{ CH_CHARACTERS, 3, 16, S_OK, "1234" },
|
|
|
|
{ CH_ENDELEMENT, 3, 24, S_OK, "", "Number", "Number" },
|
|
|
|
{ CH_CHARACTERS, 4, 4, S_OK, "\n " },
|
|
|
|
{ CH_STARTELEMENT, 4, 9, S_OK, "", "Name", "Name" },
|
|
|
|
{ CH_CHARACTERS, 4, 22, S_OK, "Captain Ahab" },
|
|
|
|
{ CH_ENDELEMENT, 4, 28, S_OK, "", "Name", "Name" },
|
|
|
|
{ CH_CHARACTERS, 5, 1, S_OK, "\n" },
|
|
|
|
{ CH_ENDELEMENT, 5, 14, S_OK, "", "BankAccount", "BankAccount" },
|
|
|
|
{ CH_ENDDOCUMENT, 6, 0, S_OK },
|
|
|
|
{ CH_ENDTEST }
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct call_entry content_handler_test2[] = {
|
|
|
|
{ CH_PUTDOCUMENTLOCATOR, 0, 0, S_OK },
|
|
|
|
{ CH_STARTDOCUMENT, 0, 0, S_OK },
|
|
|
|
{ CH_STARTELEMENT, 2, 14, S_OK, "", "BankAccount", "BankAccount" },
|
|
|
|
{ CH_CHARACTERS, 2, 14, S_OK, "\n" },
|
|
|
|
{ CH_CHARACTERS, 2, 16, S_OK, "\t" },
|
|
|
|
{ CH_STARTELEMENT, 3, 10, S_OK, "", "Number", "Number" },
|
|
|
|
{ CH_CHARACTERS, 3, 10, S_OK, "1234" },
|
|
|
|
{ CH_ENDELEMENT, 3, 16, S_OK, "", "Number", "Number" },
|
|
|
|
{ CH_CHARACTERS, 3, 23, S_OK, "\n" },
|
|
|
|
{ CH_CHARACTERS, 3, 25, S_OK, "\t" },
|
|
|
|
{ CH_STARTELEMENT, 4, 8, S_OK, "", "Name", "Name" },
|
|
|
|
{ CH_CHARACTERS, 4, 8, S_OK, "Captain Ahab" },
|
|
|
|
{ CH_ENDELEMENT, 4, 22, S_OK, "", "Name", "Name" },
|
|
|
|
{ CH_CHARACTERS, 4, 27, S_OK, "\n" },
|
|
|
|
{ CH_ENDELEMENT, 5, 3, S_OK, "", "BankAccount", "BankAccount" },
|
|
|
|
{ CH_ENDDOCUMENT, 0, 0, S_OK },
|
|
|
|
{ CH_ENDTEST }
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct call_entry content_handler_test2_alternate[] = {
|
|
|
|
{ CH_PUTDOCUMENTLOCATOR, 1, 0, S_OK },
|
|
|
|
{ CH_STARTDOCUMENT, 1, 21, S_OK },
|
|
|
|
{ CH_STARTELEMENT, 2, 13, S_OK, "", "BankAccount", "BankAccount" },
|
|
|
|
{ CH_CHARACTERS, 3, 0, S_OK, "\n" },
|
|
|
|
{ CH_CHARACTERS, 3, 2, S_OK, "\t" },
|
|
|
|
{ CH_STARTELEMENT, 3, 9, S_OK, "", "Number", "Number" },
|
|
|
|
{ CH_CHARACTERS, 3, 14, S_OK, "1234" },
|
|
|
|
{ CH_ENDELEMENT, 3, 22, S_OK, "", "Number", "Number" },
|
|
|
|
{ CH_CHARACTERS, 4, 0, S_OK, "\n" },
|
|
|
|
{ CH_CHARACTERS, 4, 2, S_OK, "\t" },
|
|
|
|
{ CH_STARTELEMENT, 4, 7, S_OK, "", "Name", "Name" },
|
|
|
|
{ CH_CHARACTERS, 4, 20, S_OK, "Captain Ahab" },
|
|
|
|
{ CH_ENDELEMENT, 4, 26, S_OK, "", "Name", "Name" },
|
|
|
|
{ CH_CHARACTERS, 5, 0, S_OK, "\n" },
|
|
|
|
{ CH_ENDELEMENT, 5, 14, S_OK, "", "BankAccount", "BankAccount" },
|
|
|
|
{ CH_ENDDOCUMENT, 6, 0, S_OK },
|
2008-07-17 00:42:14 +02:00
|
|
|
{ CH_ENDTEST }
|
|
|
|
};
|
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
static struct call_entry content_handler_testerror[] = {
|
|
|
|
{ CH_PUTDOCUMENTLOCATOR, 0, 0, E_FAIL },
|
|
|
|
{ EH_FATALERROR, 0, 0, E_FAIL },
|
2008-07-23 16:39:43 +02:00
|
|
|
{ CH_ENDTEST }
|
|
|
|
};
|
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
static struct call_entry content_handler_testerror_alternate[] = {
|
|
|
|
{ CH_PUTDOCUMENTLOCATOR, 1, 0, E_FAIL },
|
|
|
|
{ EH_FATALERROR, 1, 0, E_FAIL },
|
2011-10-24 12:55:22 +02:00
|
|
|
{ CH_ENDTEST }
|
|
|
|
};
|
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
static struct call_entry content_handler_test_callback_rets[] = {
|
|
|
|
{ CH_PUTDOCUMENTLOCATOR, 0, 0, S_FALSE },
|
|
|
|
{ CH_STARTDOCUMENT, 0, 0, S_FALSE },
|
|
|
|
{ EH_FATALERROR, 0, 0, S_FALSE },
|
|
|
|
{ CH_ENDTEST }
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct call_entry content_handler_test_callback_rets_alt[] = {
|
|
|
|
{ CH_PUTDOCUMENTLOCATOR, 1, 0, S_FALSE },
|
|
|
|
{ CH_STARTDOCUMENT, 1, 22, S_FALSE },
|
|
|
|
{ CH_STARTELEMENT, 2, 13, S_FALSE, "", "BankAccount", "BankAccount" },
|
|
|
|
{ CH_CHARACTERS, 3, 4, S_FALSE, "\n " },
|
|
|
|
{ CH_STARTELEMENT, 3, 11, S_FALSE, "", "Number", "Number" },
|
|
|
|
{ CH_CHARACTERS, 3, 16, S_FALSE, "1234" },
|
|
|
|
{ CH_ENDELEMENT, 3, 24, S_FALSE, "", "Number", "Number" },
|
|
|
|
{ CH_CHARACTERS, 4, 4, S_FALSE, "\n " },
|
|
|
|
{ CH_STARTELEMENT, 4, 9, S_FALSE, "", "Name", "Name" },
|
|
|
|
{ CH_CHARACTERS, 4, 22, S_FALSE, "Captain Ahab" },
|
|
|
|
{ CH_ENDELEMENT, 4, 28, S_FALSE, "", "Name", "Name" },
|
|
|
|
{ CH_CHARACTERS, 5, 1, S_FALSE, "\n" },
|
|
|
|
{ CH_ENDELEMENT, 5, 14, S_FALSE, "", "BankAccount", "BankAccount" },
|
|
|
|
{ CH_ENDDOCUMENT, 6, 0, S_FALSE },
|
|
|
|
{ CH_ENDTEST }
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct attribute_entry ch_attributes1[] = {
|
|
|
|
{ "", "", "xmlns:test", "prefix_test" },
|
|
|
|
{ "", "", "xmlns", "prefix" },
|
|
|
|
{ "prefix_test", "arg1", "test:arg1", "arg1" },
|
|
|
|
{ "", "arg2", "arg2", "arg2" },
|
|
|
|
{ "prefix_test", "ar3", "test:ar3", "arg3" },
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct attribute_entry ch_attributes2[] = {
|
|
|
|
{ "", "", "xmlns:p", "test" },
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct call_entry content_handler_test_attributes[] = {
|
|
|
|
{ CH_PUTDOCUMENTLOCATOR, 0, 0, S_OK },
|
|
|
|
{ CH_STARTDOCUMENT, 0, 0, S_OK },
|
|
|
|
{ CH_STARTPREFIXMAPPING, 2, 96, S_OK, "test", "prefix_test" },
|
|
|
|
{ CH_STARTPREFIXMAPPING, 2, 96, S_OK, "", "prefix" },
|
|
|
|
{ CH_STARTELEMENT, 2, 96, S_OK, "prefix", "document", "document", ch_attributes1 },
|
|
|
|
{ CH_CHARACTERS, 2, 96, S_OK, "\n" },
|
|
|
|
{ CH_STARTPREFIXMAPPING, 3, 25, S_OK, "p", "test" },
|
|
|
|
{ CH_STARTELEMENT, 3, 25, S_OK, "prefix", "node1", "node1", ch_attributes2 },
|
|
|
|
{ CH_ENDELEMENT, 3, 25, S_OK, "prefix", "node1", "node1" },
|
|
|
|
{ CH_ENDPREFIXMAPPING, 3, 25, S_OK, "p" },
|
|
|
|
{ CH_ENDELEMENT, 3, 27, S_OK, "prefix", "document", "document" },
|
|
|
|
{ CH_ENDPREFIXMAPPING, 3, 27, S_OK, "" },
|
|
|
|
{ CH_ENDPREFIXMAPPING, 3, 27, S_OK, "test" },
|
|
|
|
{ CH_ENDDOCUMENT, 0, 0 },
|
2011-10-24 20:09:12 +02:00
|
|
|
{ CH_ENDTEST }
|
|
|
|
};
|
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
static struct attribute_entry ch_attributes_alt_4[] = {
|
|
|
|
{ "prefix_test", "arg1", "test:arg1", "arg1" },
|
|
|
|
{ "", "arg2", "arg2", "arg2" },
|
|
|
|
{ "prefix_test", "ar3", "test:ar3", "arg3" },
|
|
|
|
{ "", "", "xmlns:test", "prefix_test" },
|
|
|
|
{ "", "", "xmlns", "prefix" },
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct call_entry content_handler_test_attributes_alternate_4[] = {
|
|
|
|
{ CH_PUTDOCUMENTLOCATOR, 1, 0, S_OK },
|
|
|
|
{ CH_STARTDOCUMENT, 1, 22, S_OK },
|
|
|
|
{ CH_STARTPREFIXMAPPING, 2, 95, S_OK, "test", "prefix_test" },
|
|
|
|
{ CH_STARTPREFIXMAPPING, 2, 95, S_OK, "", "prefix" },
|
|
|
|
{ CH_STARTELEMENT, 2, 95, S_OK, "prefix", "document", "document", ch_attributes_alt_4 },
|
|
|
|
{ CH_CHARACTERS, 3, 1, S_OK, "\n" },
|
|
|
|
{ CH_STARTPREFIXMAPPING, 3, 24, S_OK, "p", "test" },
|
|
|
|
{ CH_STARTELEMENT, 3, 24, S_OK, "prefix", "node1", "node1", ch_attributes2 },
|
|
|
|
{ CH_ENDELEMENT, 3, 24, S_OK, "prefix", "node1", "node1" },
|
|
|
|
{ CH_ENDPREFIXMAPPING, 3, 24, S_OK, "p" },
|
|
|
|
{ CH_ENDELEMENT, 3, 35, S_OK, "prefix", "document", "document" },
|
|
|
|
{ CH_ENDPREFIXMAPPING, 3, 35, S_OK, "test" },
|
|
|
|
{ CH_ENDPREFIXMAPPING, 3, 35, S_OK, "" },
|
|
|
|
{ CH_ENDDOCUMENT, 4, 0, S_OK },
|
2011-10-24 12:55:22 +02:00
|
|
|
{ CH_ENDTEST }
|
|
|
|
};
|
|
|
|
|
2012-04-19 08:46:03 +02:00
|
|
|
/* 'namespace' feature switched off */
|
|
|
|
static struct attribute_entry ch_attributes_alt_no_ns[] = {
|
|
|
|
{ "", "", "xmlns:test", "prefix_test" },
|
|
|
|
{ "", "", "xmlns", "prefix" },
|
|
|
|
{ "", "", "test:arg1", "arg1" },
|
|
|
|
{ "", "", "arg2", "arg2" },
|
|
|
|
{ "", "", "test:ar3", "arg3" },
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct call_entry content_handler_test_attributes_alt_no_ns[] = {
|
|
|
|
{ CH_PUTDOCUMENTLOCATOR, 1, 0, S_OK },
|
|
|
|
{ CH_STARTDOCUMENT, 1, 22, S_OK },
|
|
|
|
{ CH_STARTELEMENT, 2, 95, S_OK, "", "", "document", ch_attributes_alt_no_ns },
|
|
|
|
{ CH_CHARACTERS, 3, 1, S_OK, "\n" },
|
|
|
|
{ CH_STARTELEMENT, 3, 24, S_OK, "", "", "node1", ch_attributes2 },
|
|
|
|
{ CH_ENDELEMENT, 3, 24, S_OK, "", "", "node1" },
|
|
|
|
{ CH_ENDELEMENT, 3, 35, S_OK, "", "", "document" },
|
|
|
|
{ CH_ENDDOCUMENT, 4, 0, S_OK },
|
|
|
|
{ CH_ENDTEST }
|
|
|
|
};
|
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
static struct attribute_entry ch_attributes_alt_6[] = {
|
|
|
|
{ "prefix_test", "arg1", "test:arg1", "arg1" },
|
|
|
|
{ "", "arg2", "arg2", "arg2" },
|
|
|
|
{ "prefix_test", "ar3", "test:ar3", "arg3" },
|
|
|
|
{ "http://www.w3.org/2000/xmlns/", "", "xmlns:test", "prefix_test" },
|
|
|
|
{ "http://www.w3.org/2000/xmlns/", "", "xmlns", "prefix" },
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct attribute_entry ch_attributes2_6[] = {
|
|
|
|
{ "http://www.w3.org/2000/xmlns/", "", "xmlns:p", "test" },
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct call_entry content_handler_test_attributes_alternate_6[] = {
|
|
|
|
{ CH_PUTDOCUMENTLOCATOR, 1, 0, S_OK },
|
|
|
|
{ CH_STARTDOCUMENT, 1, 22, S_OK },
|
|
|
|
{ CH_STARTPREFIXMAPPING, 2, 95, S_OK, "test", "prefix_test" },
|
|
|
|
{ CH_STARTPREFIXMAPPING, 2, 95, S_OK, "", "prefix" },
|
|
|
|
{ CH_STARTELEMENT, 2, 95, S_OK, "prefix", "document", "document", ch_attributes_alt_6 },
|
|
|
|
{ CH_CHARACTERS, 3, 1, S_OK, "\n" },
|
|
|
|
{ CH_STARTPREFIXMAPPING, 3, 24, S_OK, "p", "test" },
|
|
|
|
{ CH_STARTELEMENT, 3, 24, S_OK, "prefix", "node1", "node1", ch_attributes2_6 },
|
|
|
|
{ CH_ENDELEMENT, 3, 24, S_OK, "prefix", "node1", "node1" },
|
|
|
|
{ CH_ENDPREFIXMAPPING, 3, 24, S_OK, "p" },
|
|
|
|
{ CH_ENDELEMENT, 3, 35, S_OK, "prefix", "document", "document" },
|
|
|
|
{ CH_ENDPREFIXMAPPING, 3, 35, S_OK, "test" },
|
|
|
|
{ CH_ENDPREFIXMAPPING, 3, 35, S_OK, "" },
|
|
|
|
{ CH_ENDDOCUMENT, 4, 0, S_OK },
|
2011-10-26 13:25:52 +02:00
|
|
|
{ CH_ENDTEST }
|
|
|
|
};
|
|
|
|
|
2012-04-20 09:03:18 +02:00
|
|
|
/* 'namespaces' is on, 'namespace-prefixes' if off */
|
|
|
|
static struct attribute_entry ch_attributes_no_prefix[] = {
|
|
|
|
{ "prefix_test", "arg1", "test:arg1", "arg1" },
|
|
|
|
{ "", "arg2", "arg2", "arg2" },
|
|
|
|
{ "prefix_test", "ar3", "test:ar3", "arg3" },
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct call_entry content_handler_test_attributes_alt_no_prefix[] = {
|
|
|
|
{ CH_PUTDOCUMENTLOCATOR, 1, 0, S_OK },
|
|
|
|
{ CH_STARTDOCUMENT, 1, 22, S_OK },
|
|
|
|
{ CH_STARTPREFIXMAPPING, 2, 95, S_OK, "test", "prefix_test" },
|
|
|
|
{ CH_STARTPREFIXMAPPING, 2, 95, S_OK, "", "prefix" },
|
|
|
|
{ CH_STARTELEMENT, 2, 95, S_OK, "prefix", "document", "document", ch_attributes_no_prefix },
|
|
|
|
{ CH_CHARACTERS, 3, 1, S_OK, "\n" },
|
|
|
|
{ CH_STARTPREFIXMAPPING, 3, 24, S_OK, "p", "test" },
|
|
|
|
{ CH_STARTELEMENT, 3, 24, S_OK, "prefix", "node1", "node1", NULL },
|
|
|
|
{ CH_ENDELEMENT, 3, 24, S_OK, "prefix", "node1", "node1" },
|
|
|
|
{ CH_ENDPREFIXMAPPING, 3, 24, S_OK, "p" },
|
|
|
|
{ CH_ENDELEMENT, 3, 35, S_OK, "prefix", "document", "document" },
|
|
|
|
{ CH_ENDPREFIXMAPPING, 3, 35, S_OK, "test" },
|
|
|
|
{ CH_ENDPREFIXMAPPING, 3, 35, S_OK, "" },
|
|
|
|
{ CH_ENDDOCUMENT, 4, 0, S_OK },
|
|
|
|
{ CH_ENDTEST }
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct call_entry content_handler_test_attributes_no_prefix[] = {
|
|
|
|
{ CH_PUTDOCUMENTLOCATOR, 0, 0, S_OK },
|
|
|
|
{ CH_STARTDOCUMENT, 0, 0, S_OK },
|
|
|
|
{ CH_STARTPREFIXMAPPING, 2, 96, S_OK, "test", "prefix_test" },
|
|
|
|
{ CH_STARTPREFIXMAPPING, 2, 96, S_OK, "", "prefix" },
|
|
|
|
{ CH_STARTELEMENT, 2, 96, S_OK, "prefix", "document", "document", ch_attributes_no_prefix },
|
|
|
|
{ CH_CHARACTERS, 2, 96, S_OK, "\n" },
|
|
|
|
{ CH_STARTPREFIXMAPPING, 3, 25, S_OK, "p", "test" },
|
|
|
|
{ CH_STARTELEMENT, 3, 25, S_OK, "prefix", "node1", "node1", NULL },
|
|
|
|
{ CH_ENDELEMENT, 3, 25, S_OK, "prefix", "node1", "node1" },
|
|
|
|
{ CH_ENDPREFIXMAPPING, 3, 25, S_OK, "p" },
|
|
|
|
{ CH_ENDELEMENT, 3, 27, S_OK, "prefix", "document", "document" },
|
|
|
|
{ CH_ENDPREFIXMAPPING, 3, 27, S_OK, "" },
|
|
|
|
{ CH_ENDPREFIXMAPPING, 3, 27, S_OK, "test" },
|
|
|
|
{ CH_ENDDOCUMENT, 0, 0 },
|
|
|
|
{ CH_ENDTEST }
|
|
|
|
};
|
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
static struct attribute_entry xmlspace_attrs[] = {
|
|
|
|
{ "http://www.w3.org/XML/1998/namespace", "space", "xml:space", "preserve" },
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct call_entry xmlspaceattr_test[] = {
|
|
|
|
{ CH_PUTDOCUMENTLOCATOR, 0, 0, S_OK },
|
|
|
|
{ CH_STARTDOCUMENT, 0, 0, S_OK },
|
|
|
|
{ CH_STARTELEMENT, 1, 64, S_OK, "", "a", "a", xmlspace_attrs },
|
|
|
|
{ CH_CHARACTERS, 1, 64, S_OK, " Some text data " },
|
|
|
|
{ CH_ENDELEMENT, 1, 82, S_OK, "", "a", "a" },
|
|
|
|
{ CH_ENDDOCUMENT, 0, 0, S_OK },
|
2011-10-26 13:25:52 +02:00
|
|
|
{ CH_ENDTEST }
|
|
|
|
};
|
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
static struct call_entry xmlspaceattr_test_alternate[] = {
|
|
|
|
{ CH_PUTDOCUMENTLOCATOR, 1, 0, S_OK },
|
|
|
|
{ CH_STARTDOCUMENT, 1, 39, S_OK },
|
|
|
|
{ CH_STARTELEMENT, 1, 63, S_OK, "", "a", "a", xmlspace_attrs },
|
|
|
|
{ CH_CHARACTERS, 1, 80, S_OK, " Some text data " },
|
|
|
|
{ CH_ENDELEMENT, 1, 83, S_OK, "", "a", "a" },
|
|
|
|
{ CH_ENDDOCUMENT, 1, 83, S_OK },
|
2012-03-01 19:06:39 +01:00
|
|
|
{ CH_ENDTEST }
|
|
|
|
};
|
|
|
|
|
2012-04-28 11:20:06 +02:00
|
|
|
/* attribute value normalization test */
|
|
|
|
static const char attribute_normalize[] =
|
|
|
|
"<?xml version=\"1.0\" ?>\n"
|
2013-07-31 08:31:04 +02:00
|
|
|
"<a attr1=\" \r \n \tattr_value A & &\t \r \n\r\n \n\"/>\n";
|
2012-04-28 11:20:06 +02:00
|
|
|
|
|
|
|
static struct attribute_entry attribute_norm_attrs[] = {
|
2013-07-31 08:31:04 +02:00
|
|
|
{ "", "attr1", "attr1", " attr_value A & & " },
|
2012-04-28 11:20:06 +02:00
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct call_entry attribute_norm[] = {
|
|
|
|
{ CH_PUTDOCUMENTLOCATOR, 0, 0, S_OK },
|
|
|
|
{ CH_STARTDOCUMENT, 0, 0, S_OK },
|
|
|
|
{ CH_STARTELEMENT, 6, 4, S_OK, "", "a", "a", attribute_norm_attrs },
|
|
|
|
{ CH_ENDELEMENT, 6, 4, S_OK, "", "a", "a" },
|
|
|
|
{ CH_ENDDOCUMENT, 0, 0, S_OK },
|
|
|
|
{ CH_ENDTEST }
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct call_entry attribute_norm_alt[] = {
|
|
|
|
{ CH_PUTDOCUMENTLOCATOR, 1, 0, S_OK },
|
|
|
|
{ CH_STARTDOCUMENT, 1, 22, S_OK },
|
|
|
|
{ CH_STARTELEMENT, 8, 3, S_OK, "", "a", "a", attribute_norm_attrs },
|
|
|
|
{ CH_ENDELEMENT, 8, 3, S_OK, "", "a", "a" },
|
|
|
|
{ CH_ENDDOCUMENT, 9, 0, S_OK },
|
|
|
|
{ CH_ENDTEST }
|
|
|
|
};
|
|
|
|
|
2013-03-12 09:45:54 +01:00
|
|
|
static struct call_entry cdata_test[] = {
|
|
|
|
{ CH_PUTDOCUMENTLOCATOR, 0, 0, S_OK },
|
|
|
|
{ CH_STARTDOCUMENT, 0, 0, S_OK },
|
|
|
|
{ CH_STARTELEMENT, 1, 26, S_OK, "", "a", "a" },
|
|
|
|
{ LH_STARTCDATA, 1, 35, S_OK },
|
|
|
|
{ CH_CHARACTERS, 1, 35, S_OK, "Some \n" },
|
|
|
|
{ CH_CHARACTERS, 1, 42, S_OK, "text\n\n" },
|
2013-03-13 12:04:59 +01:00
|
|
|
{ CH_CHARACTERS, 1, 49, S_OK, "data\n\n" },
|
|
|
|
{ LH_ENDCDATA, 1, 49, S_OK },
|
|
|
|
{ CH_ENDELEMENT, 6, 6, S_OK, "", "a", "a" },
|
|
|
|
{ CH_ENDDOCUMENT, 0, 0, S_OK },
|
|
|
|
{ CH_ENDTEST }
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct call_entry cdata_test2[] = {
|
|
|
|
{ CH_PUTDOCUMENTLOCATOR, 0, 0, S_OK },
|
|
|
|
{ CH_STARTDOCUMENT, 0, 0, S_OK },
|
|
|
|
{ CH_STARTELEMENT, 1, 26, S_OK, "", "a", "a" },
|
|
|
|
{ LH_STARTCDATA, 1, 35, S_OK },
|
|
|
|
{ CH_CHARACTERS, 1, 35, S_OK, "\n\n" },
|
|
|
|
{ CH_CHARACTERS, 1, 38, S_OK, "Some \n" },
|
|
|
|
{ CH_CHARACTERS, 1, 45, S_OK, "text\n\n" },
|
|
|
|
{ CH_CHARACTERS, 1, 52, S_OK, "data\n\n" },
|
|
|
|
{ LH_ENDCDATA, 1, 52, S_OK },
|
|
|
|
{ CH_ENDELEMENT, 8, 6, S_OK, "", "a", "a" },
|
|
|
|
{ CH_ENDDOCUMENT, 0, 0, S_OK },
|
|
|
|
{ CH_ENDTEST }
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct call_entry cdata_test3[] = {
|
|
|
|
{ CH_PUTDOCUMENTLOCATOR, 0, 0, S_OK },
|
|
|
|
{ CH_STARTDOCUMENT, 0, 0, S_OK },
|
|
|
|
{ CH_STARTELEMENT, 1, 26, S_OK, "", "a", "a" },
|
|
|
|
{ LH_STARTCDATA, 1, 35, S_OK },
|
|
|
|
{ CH_CHARACTERS, 1, 35, S_OK, "Some text data" },
|
|
|
|
{ LH_ENDCDATA, 1, 35, S_OK },
|
|
|
|
{ CH_ENDELEMENT, 1, 54, S_OK, "", "a", "a" },
|
2013-03-12 09:45:54 +01:00
|
|
|
{ CH_ENDDOCUMENT, 0, 0, S_OK },
|
|
|
|
{ CH_ENDTEST }
|
|
|
|
};
|
|
|
|
|
|
|
|
/* this is what MSXML6 does */
|
|
|
|
static struct call_entry cdata_test_alt[] = {
|
|
|
|
{ CH_PUTDOCUMENTLOCATOR, 1, 0, S_OK },
|
|
|
|
{ CH_STARTDOCUMENT, 1, 22, S_OK },
|
|
|
|
{ CH_STARTELEMENT, 1, 25, S_OK, "", "a", "a" },
|
|
|
|
{ LH_STARTCDATA, 1, 34, S_OK },
|
|
|
|
{ CH_CHARACTERS, 1, 40, S_OK, "Some " },
|
|
|
|
{ CH_CHARACTERS, 2, 0, S_OK, "\n" },
|
|
|
|
{ CH_CHARACTERS, 3, 1, S_OK, "text\n" },
|
|
|
|
{ CH_CHARACTERS, 4, 0, S_OK, "\n" },
|
2013-03-13 12:04:59 +01:00
|
|
|
{ CH_CHARACTERS, 6, 3, S_OK, "data\n\n" },
|
|
|
|
{ LH_ENDCDATA, 6, 3, S_OK },
|
|
|
|
{ CH_ENDELEMENT, 6, 7, S_OK, "", "a", "a" },
|
|
|
|
{ CH_ENDDOCUMENT, 6, 7, S_OK },
|
|
|
|
{ CH_ENDTEST }
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct call_entry cdata_test2_alt[] = {
|
|
|
|
{ CH_PUTDOCUMENTLOCATOR, 1, 0, S_OK },
|
|
|
|
{ CH_STARTDOCUMENT, 1, 22, S_OK },
|
|
|
|
{ CH_STARTELEMENT, 1, 25, S_OK, "", "a", "a" },
|
|
|
|
{ LH_STARTCDATA, 1, 34, S_OK },
|
|
|
|
{ CH_CHARACTERS, 2, 1, S_OK, "\n" },
|
|
|
|
{ CH_CHARACTERS, 3, 0, S_OK, "\n" },
|
|
|
|
{ CH_CHARACTERS, 3, 6, S_OK, "Some " },
|
|
|
|
{ CH_CHARACTERS, 4, 0, S_OK, "\n" },
|
|
|
|
{ CH_CHARACTERS, 5, 1, S_OK, "text\n" },
|
|
|
|
{ CH_CHARACTERS, 6, 0, S_OK, "\n" },
|
|
|
|
{ CH_CHARACTERS, 8, 3, S_OK, "data\n\n" },
|
|
|
|
{ LH_ENDCDATA, 8, 3, S_OK },
|
|
|
|
{ CH_ENDELEMENT, 8, 7, S_OK, "", "a", "a" },
|
|
|
|
{ CH_ENDDOCUMENT, 8, 7, S_OK },
|
|
|
|
{ CH_ENDTEST }
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct call_entry cdata_test3_alt[] = {
|
|
|
|
{ CH_PUTDOCUMENTLOCATOR, 1, 0, S_OK },
|
|
|
|
{ CH_STARTDOCUMENT, 1, 22, S_OK },
|
|
|
|
{ CH_STARTELEMENT, 1, 25, S_OK, "", "a", "a" },
|
|
|
|
{ LH_STARTCDATA, 1, 34, S_OK },
|
|
|
|
{ CH_CHARACTERS, 1, 51, S_OK, "Some text data" },
|
|
|
|
{ LH_ENDCDATA, 1, 51, S_OK },
|
|
|
|
{ CH_ENDELEMENT, 1, 55, S_OK, "", "a", "a" },
|
|
|
|
{ CH_ENDDOCUMENT, 1, 55, S_OK },
|
2013-03-12 09:45:54 +01:00
|
|
|
{ CH_ENDTEST }
|
|
|
|
};
|
|
|
|
|
2014-02-12 13:30:56 +01:00
|
|
|
static struct attribute_entry read_test_attrs[] = {
|
|
|
|
{ "", "attr", "attr", "val" },
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct call_entry read_test_seq[] = {
|
|
|
|
{ CH_PUTDOCUMENTLOCATOR, -1, 0, S_OK },
|
|
|
|
{ CH_STARTDOCUMENT, -1, -1, S_OK },
|
|
|
|
{ CH_STARTELEMENT, -1, -1, S_OK, "", "rootelem", "rootelem" },
|
|
|
|
{ CH_STARTELEMENT, -1, -1, S_OK, "", "elem", "elem", read_test_attrs },
|
|
|
|
{ CH_CHARACTERS, -1, -1, S_OK, "text" },
|
|
|
|
{ CH_ENDELEMENT, -1, -1, S_OK, "", "elem", "elem" },
|
|
|
|
{ CH_STARTELEMENT, -1, -1, S_OK, "", "elem", "elem", read_test_attrs },
|
|
|
|
{ CH_CHARACTERS, -1, -1, S_OK, "text" },
|
|
|
|
{ CH_ENDELEMENT, -1, -1, S_OK, "", "elem", "elem" },
|
|
|
|
{ CH_STARTELEMENT, -1, -1, S_OK, "", "elem", "elem", read_test_attrs },
|
|
|
|
{ CH_CHARACTERS, -1, -1, S_OK, "text" },
|
|
|
|
{ CH_ENDELEMENT, -1, -1, S_OK, "", "elem", "elem" },
|
|
|
|
{ CH_STARTELEMENT, -1, -1, S_OK, "", "elem", "elem", read_test_attrs },
|
|
|
|
{ CH_CHARACTERS, -1, -1, S_OK, "text" },
|
|
|
|
{ CH_ENDELEMENT, -1, -1, S_OK, "", "elem", "elem" },
|
|
|
|
{ CH_ENDELEMENT, -1, -1, S_OK, "", "rootelem", "rootelem" },
|
|
|
|
{ CH_ENDDOCUMENT, -1, -1, S_OK},
|
|
|
|
{ CH_ENDTEST }
|
|
|
|
};
|
|
|
|
|
2012-03-01 19:06:39 +01:00
|
|
|
static const char xmlspace_attr[] =
|
|
|
|
"<?xml version=\"1.0\" encoding=\"UTF-16\"?>"
|
|
|
|
"<a xml:space=\"preserve\"> Some text data </a>";
|
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
static struct call_entry *expectCall;
|
2008-07-17 00:42:14 +02:00
|
|
|
static ISAXLocator *locator;
|
2012-04-19 08:46:03 +02:00
|
|
|
static ISAXXMLReader *g_reader;
|
2011-10-24 20:09:12 +02:00
|
|
|
int msxml_version;
|
2008-07-17 00:42:14 +02:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
static void set_expected_seq(struct call_entry *expected)
|
2008-07-17 00:42:14 +02:00
|
|
|
{
|
2012-04-15 11:47:30 +02:00
|
|
|
expectCall = expected;
|
2008-07-17 00:42:14 +02:00
|
|
|
}
|
2008-07-08 20:53:43 +02:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
/* to be called once on each tested callback return */
|
|
|
|
static HRESULT get_expected_ret(void)
|
2008-07-08 20:53:43 +02:00
|
|
|
{
|
2012-04-15 11:47:30 +02:00
|
|
|
HRESULT hr = expectCall->ret;
|
|
|
|
if (expectCall->id != CH_ENDTEST) expectCall++;
|
|
|
|
return hr;
|
2008-07-08 20:53:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI contentHandler_QueryInterface(
|
|
|
|
ISAXContentHandler* iface,
|
|
|
|
REFIID riid,
|
|
|
|
void **ppvObject)
|
|
|
|
{
|
|
|
|
*ppvObject = NULL;
|
|
|
|
|
|
|
|
if(IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_ISAXContentHandler))
|
|
|
|
{
|
|
|
|
*ppvObject = iface;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI contentHandler_AddRef(
|
|
|
|
ISAXContentHandler* iface)
|
|
|
|
{
|
2008-07-10 15:22:14 +02:00
|
|
|
return 2;
|
2008-07-08 20:53:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI contentHandler_Release(
|
|
|
|
ISAXContentHandler* iface)
|
|
|
|
{
|
2008-07-10 15:22:14 +02:00
|
|
|
return 1;
|
2008-07-08 20:53:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI contentHandler_putDocumentLocator(
|
|
|
|
ISAXContentHandler* iface,
|
|
|
|
ISAXLocator *pLocator)
|
|
|
|
{
|
2012-04-15 11:47:30 +02:00
|
|
|
struct call_entry call;
|
2014-03-05 07:41:11 +01:00
|
|
|
IUnknown *unk;
|
2011-12-24 14:10:33 +01:00
|
|
|
HRESULT hr;
|
2011-10-31 12:32:49 +01:00
|
|
|
|
2008-07-17 00:42:14 +02:00
|
|
|
locator = pLocator;
|
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
init_call_entry(locator, &call);
|
|
|
|
call.id = CH_PUTDOCUMENTLOCATOR;
|
|
|
|
add_call(sequences, CONTENT_HANDLER_INDEX, &call);
|
|
|
|
|
2014-03-05 07:41:11 +01:00
|
|
|
hr = ISAXLocator_QueryInterface(pLocator, &IID_IVBSAXLocator, (void**)&unk);
|
|
|
|
EXPECT_HR(hr, E_NOINTERFACE);
|
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
if (msxml_version >= 6) {
|
2012-02-24 15:38:18 +01:00
|
|
|
ISAXAttributes *attr, *attr1;
|
|
|
|
IMXAttributes *mxattr;
|
|
|
|
|
2011-12-24 14:10:33 +01:00
|
|
|
EXPECT_REF(pLocator, 1);
|
|
|
|
hr = ISAXLocator_QueryInterface(pLocator, &IID_ISAXAttributes, (void**)&attr);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
EXPECT_REF(pLocator, 2);
|
|
|
|
hr = ISAXLocator_QueryInterface(pLocator, &IID_ISAXAttributes, (void**)&attr1);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
EXPECT_REF(pLocator, 3);
|
|
|
|
ok(attr == attr1, "got %p, %p\n", attr, attr1);
|
2012-02-24 15:38:18 +01:00
|
|
|
|
2014-03-05 07:41:11 +01:00
|
|
|
hr = ISAXAttributes_QueryInterface(attr, &IID_IVBSAXAttributes, (void**)&unk);
|
|
|
|
EXPECT_HR(hr, E_NOINTERFACE);
|
|
|
|
|
|
|
|
hr = ISAXLocator_QueryInterface(pLocator, &IID_IVBSAXAttributes, (void**)&unk);
|
|
|
|
EXPECT_HR(hr, E_NOINTERFACE);
|
|
|
|
|
2012-02-24 15:38:18 +01:00
|
|
|
hr = ISAXAttributes_QueryInterface(attr, &IID_IMXAttributes, (void**)&mxattr);
|
|
|
|
EXPECT_HR(hr, E_NOINTERFACE);
|
|
|
|
|
2011-10-31 12:32:49 +01:00
|
|
|
ISAXAttributes_Release(attr);
|
2011-12-24 14:10:33 +01:00
|
|
|
ISAXAttributes_Release(attr1);
|
2011-10-31 12:32:49 +01:00
|
|
|
}
|
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
return get_expected_ret();
|
2008-07-08 20:53:43 +02:00
|
|
|
}
|
|
|
|
|
2011-10-31 12:32:49 +01:00
|
|
|
static ISAXAttributes *test_attr_ptr;
|
2008-07-08 20:53:43 +02:00
|
|
|
static HRESULT WINAPI contentHandler_startDocument(
|
|
|
|
ISAXContentHandler* iface)
|
|
|
|
{
|
2012-04-15 11:47:30 +02:00
|
|
|
struct call_entry call;
|
|
|
|
|
|
|
|
init_call_entry(locator, &call);
|
|
|
|
call.id = CH_STARTDOCUMENT;
|
|
|
|
add_call(sequences, CONTENT_HANDLER_INDEX, &call);
|
2008-07-17 00:42:14 +02:00
|
|
|
|
2011-10-31 12:32:49 +01:00
|
|
|
test_attr_ptr = NULL;
|
2008-07-17 00:42:14 +02:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
return get_expected_ret();
|
2008-07-08 20:53:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI contentHandler_endDocument(
|
|
|
|
ISAXContentHandler* iface)
|
|
|
|
{
|
2012-04-15 11:47:30 +02:00
|
|
|
struct call_entry call;
|
2008-07-17 00:42:14 +02:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
init_call_entry(locator, &call);
|
|
|
|
call.id = CH_ENDDOCUMENT;
|
|
|
|
add_call(sequences, CONTENT_HANDLER_INDEX, &call);
|
2008-07-17 00:42:14 +02:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
return get_expected_ret();
|
2008-07-08 20:53:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI contentHandler_startPrefixMapping(
|
|
|
|
ISAXContentHandler* iface,
|
2012-04-15 11:47:30 +02:00
|
|
|
const WCHAR *prefix, int prefix_len,
|
|
|
|
const WCHAR *uri, int uri_len)
|
2008-07-08 20:53:43 +02:00
|
|
|
{
|
2012-04-15 11:47:30 +02:00
|
|
|
struct call_entry call;
|
2008-07-17 00:42:14 +02:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
init_call_entry(locator, &call);
|
|
|
|
call.id = CH_STARTPREFIXMAPPING;
|
|
|
|
call.arg1W = SysAllocStringLen(prefix, prefix_len);
|
|
|
|
call.arg2W = SysAllocStringLen(uri, uri_len);
|
|
|
|
add_call(sequences, CONTENT_HANDLER_INDEX, &call);
|
2008-07-17 00:42:14 +02:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
return get_expected_ret();
|
2008-07-08 20:53:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI contentHandler_endPrefixMapping(
|
|
|
|
ISAXContentHandler* iface,
|
2012-04-15 11:47:30 +02:00
|
|
|
const WCHAR *prefix, int len)
|
2008-07-08 20:53:43 +02:00
|
|
|
{
|
2012-04-15 11:47:30 +02:00
|
|
|
struct call_entry call;
|
2008-07-17 00:42:14 +02:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
init_call_entry(locator, &call);
|
|
|
|
call.id = CH_ENDPREFIXMAPPING;
|
|
|
|
call.arg1W = SysAllocStringLen(prefix, len);
|
|
|
|
add_call(sequences, CONTENT_HANDLER_INDEX, &call);
|
2008-07-17 00:42:14 +02:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
return get_expected_ret();
|
2008-07-08 20:53:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI contentHandler_startElement(
|
|
|
|
ISAXContentHandler* iface,
|
2012-04-15 11:47:30 +02:00
|
|
|
const WCHAR *uri, int uri_len,
|
|
|
|
const WCHAR *localname, int local_len,
|
|
|
|
const WCHAR *qname, int qname_len,
|
|
|
|
ISAXAttributes *saxattr)
|
2008-07-08 20:53:43 +02:00
|
|
|
{
|
2012-04-15 11:47:30 +02:00
|
|
|
struct call_entry call;
|
2012-03-08 21:11:45 +01:00
|
|
|
IMXAttributes *mxattr;
|
2012-04-15 11:47:30 +02:00
|
|
|
HRESULT hr;
|
2012-03-08 21:11:45 +01:00
|
|
|
int len;
|
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
hr = ISAXAttributes_QueryInterface(saxattr, &IID_IMXAttributes, (void**)&mxattr);
|
|
|
|
EXPECT_HR(hr, E_NOINTERFACE);
|
2008-07-17 00:42:14 +02:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
init_call_entry(locator, &call);
|
|
|
|
call.id = CH_STARTELEMENT;
|
|
|
|
call.arg1W = SysAllocStringLen(uri, uri_len);
|
|
|
|
call.arg2W = SysAllocStringLen(localname, local_len);
|
|
|
|
call.arg3W = SysAllocStringLen(qname, qname_len);
|
2008-07-17 00:42:14 +02:00
|
|
|
|
2011-10-31 12:32:49 +01:00
|
|
|
if(!test_attr_ptr)
|
2012-04-15 11:47:30 +02:00
|
|
|
test_attr_ptr = saxattr;
|
|
|
|
ok(test_attr_ptr == saxattr, "Multiple ISAXAttributes instances are used (%p %p)\n", test_attr_ptr, saxattr);
|
2011-10-31 12:32:49 +01:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
/* store actual attributes */
|
|
|
|
len = 0;
|
|
|
|
hr = ISAXAttributes_getLength(saxattr, &len);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
if (len)
|
|
|
|
{
|
2012-04-19 08:46:03 +02:00
|
|
|
VARIANT_BOOL v;
|
2011-10-26 13:25:52 +02:00
|
|
|
int i;
|
2012-04-15 11:47:30 +02:00
|
|
|
|
|
|
|
struct attribute_entry *attr;
|
|
|
|
attr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len*sizeof(struct attribute_entry));
|
|
|
|
|
2012-04-19 08:46:03 +02:00
|
|
|
v = VARIANT_TRUE;
|
|
|
|
hr = ISAXXMLReader_getFeature(g_reader, _bstr_("http://xml.org/sax/features/namespaces"), &v);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
{
|
|
|
|
const WCHAR *value;
|
|
|
|
int value_len;
|
|
|
|
|
|
|
|
hr = ISAXAttributes_getName(saxattr, i, &uri, &uri_len,
|
|
|
|
&localname, &local_len, &qname, &qname_len);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = ISAXAttributes_getValue(saxattr, i, &value, &value_len);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
2012-04-19 08:46:03 +02:00
|
|
|
/* if 'namespaces' switched off uri and local name contains garbage */
|
|
|
|
if (v == VARIANT_FALSE && msxml_version > 0)
|
|
|
|
{
|
|
|
|
attr[i].uriW = SysAllocStringLen(NULL, 0);
|
|
|
|
attr[i].localW = SysAllocStringLen(NULL, 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
attr[i].uriW = SysAllocStringLen(uri, uri_len);
|
|
|
|
attr[i].localW = SysAllocStringLen(localname, local_len);
|
|
|
|
}
|
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
attr[i].qnameW = SysAllocStringLen(qname, qname_len);
|
|
|
|
attr[i].valueW = SysAllocStringLen(value, value_len);
|
2011-10-26 13:25:52 +02:00
|
|
|
}
|
2012-04-15 11:47:30 +02:00
|
|
|
|
|
|
|
call.attributes = attr;
|
|
|
|
call.attr_count = len;
|
2011-10-26 13:25:52 +02:00
|
|
|
}
|
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
add_call(sequences, CONTENT_HANDLER_INDEX, &call);
|
|
|
|
|
|
|
|
return get_expected_ret();
|
2008-07-08 20:53:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI contentHandler_endElement(
|
|
|
|
ISAXContentHandler* iface,
|
2012-04-15 11:47:30 +02:00
|
|
|
const WCHAR *uri, int uri_len,
|
|
|
|
const WCHAR *localname, int local_len,
|
|
|
|
const WCHAR *qname, int qname_len)
|
|
|
|
{
|
|
|
|
struct call_entry call;
|
2008-07-17 00:42:14 +02:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
init_call_entry(locator, &call);
|
|
|
|
call.id = CH_ENDELEMENT;
|
|
|
|
call.arg1W = SysAllocStringLen(uri, uri_len);
|
|
|
|
call.arg2W = SysAllocStringLen(localname, local_len);
|
|
|
|
call.arg3W = SysAllocStringLen(qname, qname_len);
|
|
|
|
add_call(sequences, CONTENT_HANDLER_INDEX, &call);
|
2008-07-17 00:42:14 +02:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
return get_expected_ret();
|
2008-07-08 20:53:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI contentHandler_characters(
|
|
|
|
ISAXContentHandler* iface,
|
2012-04-15 11:47:30 +02:00
|
|
|
const WCHAR *chars,
|
|
|
|
int len)
|
2008-07-08 20:53:43 +02:00
|
|
|
{
|
2012-04-15 11:47:30 +02:00
|
|
|
struct call_entry call;
|
2008-07-17 00:42:14 +02:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
init_call_entry(locator, &call);
|
|
|
|
call.id = CH_CHARACTERS;
|
|
|
|
call.arg1W = SysAllocStringLen(chars, len);
|
|
|
|
add_call(sequences, CONTENT_HANDLER_INDEX, &call);
|
2008-07-17 00:42:14 +02:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
return get_expected_ret();
|
2008-07-08 20:53:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI contentHandler_ignorableWhitespace(
|
|
|
|
ISAXContentHandler* iface,
|
2012-04-15 11:47:30 +02:00
|
|
|
const WCHAR *chars, int len)
|
2008-07-08 20:53:43 +02:00
|
|
|
{
|
2012-04-15 11:47:30 +02:00
|
|
|
struct call_entry call;
|
2008-07-17 00:42:14 +02:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
init_call_entry(locator, &call);
|
|
|
|
call.id = CH_IGNORABLEWHITESPACE;
|
|
|
|
call.arg1W = SysAllocStringLen(chars, len);
|
|
|
|
add_call(sequences, CONTENT_HANDLER_INDEX, &call);
|
2008-07-17 00:42:14 +02:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
return get_expected_ret();
|
2008-07-08 20:53:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI contentHandler_processingInstruction(
|
|
|
|
ISAXContentHandler* iface,
|
2012-04-15 11:47:30 +02:00
|
|
|
const WCHAR *target, int target_len,
|
|
|
|
const WCHAR *data, int data_len)
|
2008-07-08 20:53:43 +02:00
|
|
|
{
|
2012-04-15 11:47:30 +02:00
|
|
|
struct call_entry call;
|
2008-07-17 00:42:14 +02:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
init_call_entry(locator, &call);
|
|
|
|
call.id = CH_PROCESSINGINSTRUCTION;
|
|
|
|
call.arg1W = SysAllocStringLen(target, target_len);
|
|
|
|
call.arg2W = SysAllocStringLen(data, data_len);
|
|
|
|
add_call(sequences, CONTENT_HANDLER_INDEX, &call);
|
2008-07-17 00:42:14 +02:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
return get_expected_ret();
|
2008-07-08 20:53:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI contentHandler_skippedEntity(
|
|
|
|
ISAXContentHandler* iface,
|
2012-04-15 11:47:30 +02:00
|
|
|
const WCHAR *name, int len)
|
2008-07-08 20:53:43 +02:00
|
|
|
{
|
2012-04-15 11:47:30 +02:00
|
|
|
struct call_entry call;
|
2008-07-17 00:42:14 +02:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
init_call_entry(locator, &call);
|
|
|
|
call.id = CH_SKIPPEDENTITY;
|
|
|
|
call.arg1W = SysAllocStringLen(name, len);
|
2012-11-28 18:54:24 +01:00
|
|
|
add_call(sequences, CONTENT_HANDLER_INDEX, &call);
|
2008-07-17 00:42:14 +02:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
return get_expected_ret();
|
2008-07-08 20:53:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const ISAXContentHandlerVtbl contentHandlerVtbl =
|
|
|
|
{
|
|
|
|
contentHandler_QueryInterface,
|
|
|
|
contentHandler_AddRef,
|
|
|
|
contentHandler_Release,
|
|
|
|
contentHandler_putDocumentLocator,
|
|
|
|
contentHandler_startDocument,
|
|
|
|
contentHandler_endDocument,
|
|
|
|
contentHandler_startPrefixMapping,
|
|
|
|
contentHandler_endPrefixMapping,
|
|
|
|
contentHandler_startElement,
|
|
|
|
contentHandler_endElement,
|
|
|
|
contentHandler_characters,
|
|
|
|
contentHandler_ignorableWhitespace,
|
|
|
|
contentHandler_processingInstruction,
|
|
|
|
contentHandler_skippedEntity
|
|
|
|
};
|
|
|
|
|
|
|
|
static ISAXContentHandler contentHandler = { &contentHandlerVtbl };
|
|
|
|
|
2008-07-19 22:32:03 +02:00
|
|
|
static HRESULT WINAPI isaxerrorHandler_QueryInterface(
|
|
|
|
ISAXErrorHandler* iface,
|
|
|
|
REFIID riid,
|
|
|
|
void **ppvObject)
|
|
|
|
{
|
|
|
|
*ppvObject = NULL;
|
|
|
|
|
|
|
|
if(IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_ISAXErrorHandler))
|
|
|
|
{
|
|
|
|
*ppvObject = iface;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI isaxerrorHandler_AddRef(
|
|
|
|
ISAXErrorHandler* iface)
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI isaxerrorHandler_Release(
|
|
|
|
ISAXErrorHandler* iface)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxerrorHandler_error(
|
|
|
|
ISAXErrorHandler* iface,
|
|
|
|
ISAXLocator *pLocator,
|
|
|
|
const WCHAR *pErrorMessage,
|
|
|
|
HRESULT hrErrorCode)
|
|
|
|
{
|
2011-10-24 12:55:22 +02:00
|
|
|
ok(0, "unexpected call\n");
|
2008-07-19 22:32:03 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxerrorHandler_fatalError(
|
|
|
|
ISAXErrorHandler* iface,
|
|
|
|
ISAXLocator *pLocator,
|
2012-04-15 11:47:30 +02:00
|
|
|
const WCHAR *message,
|
|
|
|
HRESULT hr)
|
2008-07-19 22:32:03 +02:00
|
|
|
{
|
2012-04-15 11:47:30 +02:00
|
|
|
struct call_entry call;
|
|
|
|
|
|
|
|
init_call_entry(locator, &call);
|
|
|
|
call.id = EH_FATALERROR;
|
|
|
|
call.ret = hr;
|
2011-10-24 12:55:22 +02:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
add_call(sequences, CONTENT_HANDLER_INDEX, &call);
|
2011-10-24 12:55:22 +02:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
get_expected_ret();
|
2008-07-19 22:32:03 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2013-03-12 09:45:54 +01:00
|
|
|
static HRESULT WINAPI isaxerrorHandler_ignorableWarning(
|
2008-07-19 22:32:03 +02:00
|
|
|
ISAXErrorHandler* iface,
|
|
|
|
ISAXLocator *pLocator,
|
|
|
|
const WCHAR *pErrorMessage,
|
|
|
|
HRESULT hrErrorCode)
|
|
|
|
{
|
2011-10-24 12:55:22 +02:00
|
|
|
ok(0, "unexpected call\n");
|
2008-07-19 22:32:03 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const ISAXErrorHandlerVtbl errorHandlerVtbl =
|
|
|
|
{
|
|
|
|
isaxerrorHandler_QueryInterface,
|
|
|
|
isaxerrorHandler_AddRef,
|
|
|
|
isaxerrorHandler_Release,
|
|
|
|
isaxerrorHandler_error,
|
|
|
|
isaxerrorHandler_fatalError,
|
2013-03-12 09:45:54 +01:00
|
|
|
isaxerrorHandler_ignorableWarning
|
2008-07-19 22:32:03 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static ISAXErrorHandler errorHandler = { &errorHandlerVtbl };
|
2008-07-08 20:53:43 +02:00
|
|
|
|
2011-05-07 17:37:59 +02:00
|
|
|
static HRESULT WINAPI isaxattributes_QueryInterface(
|
|
|
|
ISAXAttributes* iface,
|
|
|
|
REFIID riid,
|
|
|
|
void **ppvObject)
|
|
|
|
{
|
|
|
|
*ppvObject = NULL;
|
|
|
|
|
|
|
|
if(IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_ISAXAttributes))
|
|
|
|
{
|
|
|
|
*ppvObject = iface;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI isaxattributes_AddRef(ISAXAttributes* iface)
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI isaxattributes_Release(ISAXAttributes* iface)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxattributes_getLength(ISAXAttributes* iface, int *length)
|
|
|
|
{
|
2011-12-11 00:32:51 +01:00
|
|
|
*length = 3;
|
2011-05-07 17:37:59 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxattributes_getURI(
|
|
|
|
ISAXAttributes* iface,
|
|
|
|
int nIndex,
|
|
|
|
const WCHAR **pUrl,
|
|
|
|
int *pUriSize)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxattributes_getLocalName(
|
|
|
|
ISAXAttributes* iface,
|
|
|
|
int nIndex,
|
|
|
|
const WCHAR **pLocalName,
|
|
|
|
int *pLocalNameLength)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxattributes_getQName(
|
|
|
|
ISAXAttributes* iface,
|
2011-12-11 00:32:51 +01:00
|
|
|
int index,
|
|
|
|
const WCHAR **QName,
|
|
|
|
int *QNameLength)
|
2011-05-07 17:37:59 +02:00
|
|
|
{
|
2011-12-11 00:32:51 +01:00
|
|
|
static const WCHAR attrqnamesW[][15] = {{'a',':','a','t','t','r','1','j','u','n','k',0},
|
|
|
|
{'a','t','t','r','2','j','u','n','k',0},
|
|
|
|
{'a','t','t','r','3',0}};
|
|
|
|
static const int attrqnamelen[] = {7, 5, 5};
|
2011-05-07 17:37:59 +02:00
|
|
|
|
2011-12-11 00:32:51 +01:00
|
|
|
ok(index >= 0 && index <= 2, "invalid index received %d\n", index);
|
2011-05-07 17:37:59 +02:00
|
|
|
|
2014-04-07 07:24:19 +02:00
|
|
|
if (index >= 0 && index <= 2) {
|
|
|
|
*QName = attrqnamesW[index];
|
|
|
|
*QNameLength = attrqnamelen[index];
|
|
|
|
} else {
|
|
|
|
*QName = NULL;
|
|
|
|
*QNameLength = 0;
|
|
|
|
}
|
2011-05-07 17:37:59 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxattributes_getName(
|
|
|
|
ISAXAttributes* iface,
|
|
|
|
int nIndex,
|
|
|
|
const WCHAR **pUri,
|
|
|
|
int * pUriLength,
|
|
|
|
const WCHAR ** pLocalName,
|
|
|
|
int * pLocalNameSize,
|
|
|
|
const WCHAR ** pQName,
|
|
|
|
int * pQNameLength)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxattributes_getIndexFromName(
|
|
|
|
ISAXAttributes* iface,
|
|
|
|
const WCHAR * pUri,
|
|
|
|
int cUriLength,
|
|
|
|
const WCHAR * pLocalName,
|
|
|
|
int cocalNameLength,
|
|
|
|
int * index)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxattributes_getIndexFromQName(
|
|
|
|
ISAXAttributes* iface,
|
|
|
|
const WCHAR * pQName,
|
|
|
|
int nQNameLength,
|
|
|
|
int * index)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxattributes_getType(
|
|
|
|
ISAXAttributes* iface,
|
|
|
|
int nIndex,
|
|
|
|
const WCHAR ** pType,
|
|
|
|
int * pTypeLength)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxattributes_getTypeFromName(
|
|
|
|
ISAXAttributes* iface,
|
|
|
|
const WCHAR * pUri,
|
|
|
|
int nUri,
|
|
|
|
const WCHAR * pLocalName,
|
|
|
|
int nLocalName,
|
|
|
|
const WCHAR ** pType,
|
|
|
|
int * nType)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxattributes_getTypeFromQName(
|
|
|
|
ISAXAttributes* iface,
|
|
|
|
const WCHAR * pQName,
|
|
|
|
int nQName,
|
|
|
|
const WCHAR ** pType,
|
|
|
|
int * nType)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2011-12-11 00:32:51 +01:00
|
|
|
static HRESULT WINAPI isaxattributes_getValue(ISAXAttributes* iface, int index,
|
|
|
|
const WCHAR **value, int *nValue)
|
2011-05-07 17:37:59 +02:00
|
|
|
{
|
2011-12-11 00:32:51 +01:00
|
|
|
static const WCHAR attrvaluesW[][10] = {{'a','1','j','u','n','k',0},
|
|
|
|
{'a','2','j','u','n','k',0},
|
2013-08-20 10:49:54 +02:00
|
|
|
{'<','&','"','>','\'',0}};
|
|
|
|
static const int attrvalueslen[] = {2, 2, 5};
|
2011-05-07 17:37:59 +02:00
|
|
|
|
2011-12-11 00:32:51 +01:00
|
|
|
ok(index >= 0 && index <= 2, "invalid index received %d\n", index);
|
2011-05-07 17:37:59 +02:00
|
|
|
|
2014-04-07 07:24:19 +02:00
|
|
|
if (index >= 0 && index <= 2) {
|
|
|
|
*value = attrvaluesW[index];
|
|
|
|
*nValue = attrvalueslen[index];
|
|
|
|
} else {
|
|
|
|
*value = NULL;
|
|
|
|
*nValue = 0;
|
|
|
|
}
|
2011-05-07 17:37:59 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxattributes_getValueFromName(
|
|
|
|
ISAXAttributes* iface,
|
|
|
|
const WCHAR * pUri,
|
|
|
|
int nUri,
|
|
|
|
const WCHAR * pLocalName,
|
|
|
|
int nLocalName,
|
|
|
|
const WCHAR ** pValue,
|
|
|
|
int * nValue)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxattributes_getValueFromQName(
|
|
|
|
ISAXAttributes* iface,
|
|
|
|
const WCHAR * pQName,
|
|
|
|
int nQName,
|
|
|
|
const WCHAR ** pValue,
|
|
|
|
int * nValue)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const ISAXAttributesVtbl SAXAttributesVtbl =
|
|
|
|
{
|
|
|
|
isaxattributes_QueryInterface,
|
|
|
|
isaxattributes_AddRef,
|
|
|
|
isaxattributes_Release,
|
|
|
|
isaxattributes_getLength,
|
|
|
|
isaxattributes_getURI,
|
|
|
|
isaxattributes_getLocalName,
|
|
|
|
isaxattributes_getQName,
|
|
|
|
isaxattributes_getName,
|
|
|
|
isaxattributes_getIndexFromName,
|
|
|
|
isaxattributes_getIndexFromQName,
|
|
|
|
isaxattributes_getType,
|
|
|
|
isaxattributes_getTypeFromName,
|
|
|
|
isaxattributes_getTypeFromQName,
|
|
|
|
isaxattributes_getValue,
|
|
|
|
isaxattributes_getValueFromName,
|
|
|
|
isaxattributes_getValueFromQName
|
|
|
|
};
|
|
|
|
|
|
|
|
static ISAXAttributes saxattributes = { &SAXAttributesVtbl };
|
|
|
|
|
2012-04-26 21:54:22 +02:00
|
|
|
struct saxlexicalhandler
|
|
|
|
{
|
|
|
|
ISAXLexicalHandler ISAXLexicalHandler_iface;
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
HRESULT qi_hr; /* ret value for QueryInterface for handler riid */
|
|
|
|
};
|
2011-09-21 19:01:10 +02:00
|
|
|
|
2012-04-26 21:54:22 +02:00
|
|
|
static inline struct saxlexicalhandler *impl_from_ISAXLexicalHandler( ISAXLexicalHandler *iface )
|
2011-09-21 19:01:10 +02:00
|
|
|
{
|
2012-04-26 21:54:22 +02:00
|
|
|
return CONTAINING_RECORD(iface, struct saxlexicalhandler, ISAXLexicalHandler_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxlexical_QueryInterface(ISAXLexicalHandler* iface, REFIID riid, void **out)
|
|
|
|
{
|
|
|
|
struct saxlexicalhandler *handler = impl_from_ISAXLexicalHandler(iface);
|
|
|
|
|
|
|
|
*out = NULL;
|
2011-09-21 19:01:10 +02:00
|
|
|
|
2012-04-26 21:54:22 +02:00
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown))
|
2011-09-21 19:01:10 +02:00
|
|
|
{
|
2012-04-26 21:54:22 +02:00
|
|
|
*out = iface;
|
|
|
|
ok(0, "got unexpected IID_IUnknown query\n");
|
2011-09-21 19:01:10 +02:00
|
|
|
}
|
2012-04-26 21:54:22 +02:00
|
|
|
else if (IsEqualGUID(riid, &IID_ISAXLexicalHandler))
|
2011-09-21 19:01:10 +02:00
|
|
|
{
|
2012-04-26 21:54:22 +02:00
|
|
|
if (handler->qi_hr == E_NOINTERFACE) return handler->qi_hr;
|
|
|
|
*out = iface;
|
2011-09-21 19:01:10 +02:00
|
|
|
}
|
|
|
|
|
2012-04-26 21:54:22 +02:00
|
|
|
if (*out)
|
|
|
|
ISAXLexicalHandler_AddRef(iface);
|
|
|
|
else
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
|
2011-09-21 19:01:10 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI isaxlexical_AddRef(ISAXLexicalHandler* iface)
|
|
|
|
{
|
2012-04-26 21:54:22 +02:00
|
|
|
struct saxlexicalhandler *handler = impl_from_ISAXLexicalHandler(iface);
|
|
|
|
return InterlockedIncrement(&handler->ref);
|
2011-09-21 19:01:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI isaxlexical_Release(ISAXLexicalHandler* iface)
|
|
|
|
{
|
2012-04-26 21:54:22 +02:00
|
|
|
struct saxlexicalhandler *handler = impl_from_ISAXLexicalHandler(iface);
|
|
|
|
return InterlockedDecrement(&handler->ref);
|
2011-09-21 19:01:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxlexical_startDTD(ISAXLexicalHandler* iface,
|
|
|
|
const WCHAR * pName, int nName, const WCHAR * pPublicId,
|
|
|
|
int nPublicId, const WCHAR * pSystemId, int nSystemId)
|
|
|
|
{
|
|
|
|
ok(0, "call not expected\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxlexical_endDTD(ISAXLexicalHandler* iface)
|
|
|
|
{
|
|
|
|
ok(0, "call not expected\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxlexical_startEntity(ISAXLexicalHandler *iface,
|
|
|
|
const WCHAR * pName, int nName)
|
|
|
|
{
|
|
|
|
ok(0, "call not expected\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxlexical_endEntity(ISAXLexicalHandler *iface,
|
|
|
|
const WCHAR * pName, int nName)
|
|
|
|
{
|
|
|
|
ok(0, "call not expected\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxlexical_startCDATA(ISAXLexicalHandler *iface)
|
|
|
|
{
|
2013-03-12 09:45:54 +01:00
|
|
|
struct call_entry call;
|
|
|
|
|
|
|
|
init_call_entry(locator, &call);
|
|
|
|
call.id = LH_STARTCDATA;
|
|
|
|
add_call(sequences, CONTENT_HANDLER_INDEX, &call);
|
|
|
|
|
|
|
|
return get_expected_ret();
|
2011-09-21 19:01:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxlexical_endCDATA(ISAXLexicalHandler *iface)
|
|
|
|
{
|
2013-03-12 09:45:54 +01:00
|
|
|
struct call_entry call;
|
|
|
|
|
|
|
|
init_call_entry(locator, &call);
|
|
|
|
call.id = LH_ENDCDATA;
|
|
|
|
add_call(sequences, CONTENT_HANDLER_INDEX, &call);
|
|
|
|
|
|
|
|
return get_expected_ret();
|
2011-09-21 19:01:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxlexical_comment(ISAXLexicalHandler *iface,
|
|
|
|
const WCHAR * pChars, int nChars)
|
|
|
|
{
|
|
|
|
ok(0, "call not expected\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const ISAXLexicalHandlerVtbl SAXLexicalHandlerVtbl =
|
|
|
|
{
|
|
|
|
isaxlexical_QueryInterface,
|
|
|
|
isaxlexical_AddRef,
|
|
|
|
isaxlexical_Release,
|
|
|
|
isaxlexical_startDTD,
|
|
|
|
isaxlexical_endDTD,
|
|
|
|
isaxlexical_startEntity,
|
|
|
|
isaxlexical_endEntity,
|
|
|
|
isaxlexical_startCDATA,
|
|
|
|
isaxlexical_endCDATA,
|
|
|
|
isaxlexical_comment
|
|
|
|
};
|
|
|
|
|
2012-04-26 21:54:22 +02:00
|
|
|
static void init_saxlexicalhandler(struct saxlexicalhandler *handler, HRESULT hr)
|
|
|
|
{
|
|
|
|
handler->ISAXLexicalHandler_iface.lpVtbl = &SAXLexicalHandlerVtbl;
|
|
|
|
handler->ref = 1;
|
|
|
|
handler->qi_hr = hr;
|
|
|
|
}
|
2011-09-21 19:01:10 +02:00
|
|
|
|
2012-04-26 21:54:22 +02:00
|
|
|
struct saxdeclhandler
|
2011-09-22 08:50:41 +02:00
|
|
|
{
|
2012-04-26 21:54:22 +02:00
|
|
|
ISAXDeclHandler ISAXDeclHandler_iface;
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
HRESULT qi_hr; /* ret value for QueryInterface for handler riid */
|
|
|
|
};
|
2011-09-22 08:50:41 +02:00
|
|
|
|
2012-04-26 21:54:22 +02:00
|
|
|
static inline struct saxdeclhandler *impl_from_ISAXDeclHandler( ISAXDeclHandler *iface )
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct saxdeclhandler, ISAXDeclHandler_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxdecl_QueryInterface(ISAXDeclHandler* iface, REFIID riid, void **out)
|
|
|
|
{
|
|
|
|
struct saxdeclhandler *handler = impl_from_ISAXDeclHandler(iface);
|
|
|
|
|
|
|
|
*out = NULL;
|
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown))
|
2011-09-22 08:50:41 +02:00
|
|
|
{
|
2012-04-26 21:54:22 +02:00
|
|
|
*out = iface;
|
|
|
|
ok(0, "got unexpected IID_IUnknown query\n");
|
2011-09-22 08:50:41 +02:00
|
|
|
}
|
2012-04-26 21:54:22 +02:00
|
|
|
else if (IsEqualGUID(riid, &IID_ISAXDeclHandler))
|
2011-09-22 08:50:41 +02:00
|
|
|
{
|
2012-04-26 21:54:22 +02:00
|
|
|
if (handler->qi_hr == E_NOINTERFACE) return handler->qi_hr;
|
|
|
|
*out = iface;
|
2011-09-22 08:50:41 +02:00
|
|
|
}
|
|
|
|
|
2012-04-26 21:54:22 +02:00
|
|
|
if (*out)
|
|
|
|
ISAXDeclHandler_AddRef(iface);
|
|
|
|
else
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
|
2011-09-22 08:50:41 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI isaxdecl_AddRef(ISAXDeclHandler* iface)
|
|
|
|
{
|
2012-04-26 21:54:22 +02:00
|
|
|
struct saxdeclhandler *handler = impl_from_ISAXDeclHandler(iface);
|
|
|
|
return InterlockedIncrement(&handler->ref);
|
2011-09-22 08:50:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI isaxdecl_Release(ISAXDeclHandler* iface)
|
|
|
|
{
|
2012-04-26 21:54:22 +02:00
|
|
|
struct saxdeclhandler *handler = impl_from_ISAXDeclHandler(iface);
|
|
|
|
return InterlockedDecrement(&handler->ref);
|
2011-09-22 08:50:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxdecl_elementDecl(ISAXDeclHandler* iface,
|
|
|
|
const WCHAR * pName, int nName, const WCHAR * pModel, int nModel)
|
|
|
|
{
|
|
|
|
ok(0, "call not expected\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxdecl_attributeDecl(ISAXDeclHandler* iface,
|
|
|
|
const WCHAR * pElementName, int nElementName, const WCHAR * pAttributeName,
|
|
|
|
int nAttributeName, const WCHAR * pType, int nType, const WCHAR * pValueDefault,
|
|
|
|
int nValueDefault, const WCHAR * pValue, int nValue)
|
|
|
|
{
|
|
|
|
ok(0, "call not expected\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxdecl_internalEntityDecl(ISAXDeclHandler* iface,
|
|
|
|
const WCHAR * pName, int nName, const WCHAR * pValue, int nValue)
|
|
|
|
{
|
|
|
|
ok(0, "call not expected\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxdecl_externalEntityDecl(ISAXDeclHandler* iface,
|
|
|
|
const WCHAR * pName, int nName, const WCHAR * pPublicId, int nPublicId,
|
|
|
|
const WCHAR * pSystemId, int nSystemId)
|
|
|
|
{
|
|
|
|
ok(0, "call not expected\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const ISAXDeclHandlerVtbl SAXDeclHandlerVtbl =
|
|
|
|
{
|
|
|
|
isaxdecl_QueryInterface,
|
|
|
|
isaxdecl_AddRef,
|
|
|
|
isaxdecl_Release,
|
|
|
|
isaxdecl_elementDecl,
|
|
|
|
isaxdecl_attributeDecl,
|
|
|
|
isaxdecl_internalEntityDecl,
|
|
|
|
isaxdecl_externalEntityDecl
|
|
|
|
};
|
|
|
|
|
2012-04-26 21:54:22 +02:00
|
|
|
static void init_saxdeclhandler(struct saxdeclhandler *handler, HRESULT hr)
|
|
|
|
{
|
|
|
|
handler->ISAXDeclHandler_iface.lpVtbl = &SAXDeclHandlerVtbl;
|
|
|
|
handler->ref = 1;
|
|
|
|
handler->qi_hr = hr;
|
|
|
|
}
|
2011-09-22 08:50:41 +02:00
|
|
|
|
2011-08-13 01:11:30 +02:00
|
|
|
typedef struct mxwriter_write_test_t {
|
|
|
|
BOOL last;
|
|
|
|
const BYTE *data;
|
|
|
|
DWORD cb;
|
|
|
|
BOOL null_written;
|
2011-08-13 01:11:54 +02:00
|
|
|
BOOL fail_write;
|
2011-08-13 01:11:30 +02:00
|
|
|
} mxwriter_write_test;
|
|
|
|
|
|
|
|
typedef struct mxwriter_stream_test_t {
|
|
|
|
VARIANT_BOOL bom;
|
|
|
|
const char *encoding;
|
|
|
|
mxwriter_write_test expected_writes[4];
|
|
|
|
} mxwriter_stream_test;
|
|
|
|
|
|
|
|
static const mxwriter_write_test *current_write_test;
|
|
|
|
static DWORD current_stream_test_index;
|
|
|
|
|
|
|
|
static HRESULT WINAPI istream_QueryInterface(IStream *iface, REFIID riid, void **ppvObject)
|
|
|
|
{
|
|
|
|
*ppvObject = NULL;
|
|
|
|
|
|
|
|
if(IsEqualGUID(riid, &IID_IStream) || IsEqualGUID(riid, &IID_IUnknown))
|
|
|
|
*ppvObject = iface;
|
|
|
|
else
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI istream_AddRef(IStream *iface)
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI istream_Release(IStream *iface)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI istream_Read(IStream *iface, void *pv, ULONG cb, ULONG *pcbRead)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI istream_Write(IStream *iface, const void *pv, ULONG cb, ULONG *pcbWritten)
|
|
|
|
{
|
2014-02-12 13:30:56 +01:00
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
2011-08-13 01:11:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI istream_Seek(IStream *iface, LARGE_INTEGER dlibMove, DWORD dwOrigin,
|
|
|
|
ULARGE_INTEGER *plibNewPosition)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI istream_SetSize(IStream *iface, ULARGE_INTEGER libNewSize)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI istream_CopyTo(IStream *iface, IStream *pstm, ULARGE_INTEGER cb,
|
|
|
|
ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *plibWritten)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI istream_Commit(IStream *iface, DWORD grfCommitFlags)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI istream_Revert(IStream *iface)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI istream_LockRegion(IStream *iface, ULARGE_INTEGER libOffset,
|
|
|
|
ULARGE_INTEGER cb, DWORD dwLockType)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI istream_UnlockRegion(IStream *iface, ULARGE_INTEGER libOffset,
|
|
|
|
ULARGE_INTEGER cb, DWORD dwLockType)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI istream_Stat(IStream *iface, STATSTG *pstatstg, DWORD grfStatFlag)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI istream_Clone(IStream *iface, IStream **ppstm)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2014-02-12 13:30:56 +01:00
|
|
|
static HRESULT WINAPI mxstream_Write(IStream *iface, const void *pv, ULONG cb, ULONG *pcbWritten)
|
|
|
|
{
|
|
|
|
BOOL fail = FALSE;
|
|
|
|
|
|
|
|
ok(pv != NULL, "pv == NULL\n");
|
|
|
|
|
|
|
|
if(current_write_test->last) {
|
|
|
|
ok(0, "Too many Write calls made on test %d\n", current_stream_test_index);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
fail = current_write_test->fail_write;
|
|
|
|
|
|
|
|
ok(current_write_test->cb == cb, "Expected %d, but got %d on test %d\n",
|
|
|
|
current_write_test->cb, cb, current_stream_test_index);
|
|
|
|
|
|
|
|
if(!pcbWritten)
|
|
|
|
ok(current_write_test->null_written, "pcbWritten was NULL on test %d\n", current_stream_test_index);
|
|
|
|
else
|
|
|
|
ok(!memcmp(current_write_test->data, pv, cb), "Unexpected data on test %d\n", current_stream_test_index);
|
|
|
|
|
|
|
|
++current_write_test;
|
|
|
|
|
|
|
|
if(pcbWritten)
|
|
|
|
*pcbWritten = cb;
|
|
|
|
|
|
|
|
return fail ? E_FAIL : S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IStreamVtbl mxstreamVtbl = {
|
2011-08-13 01:11:30 +02:00
|
|
|
istream_QueryInterface,
|
|
|
|
istream_AddRef,
|
|
|
|
istream_Release,
|
|
|
|
istream_Read,
|
2014-02-12 13:30:56 +01:00
|
|
|
mxstream_Write,
|
|
|
|
istream_Seek,
|
|
|
|
istream_SetSize,
|
|
|
|
istream_CopyTo,
|
|
|
|
istream_Commit,
|
|
|
|
istream_Revert,
|
|
|
|
istream_LockRegion,
|
|
|
|
istream_UnlockRegion,
|
|
|
|
istream_Stat,
|
|
|
|
istream_Clone
|
|
|
|
};
|
|
|
|
|
|
|
|
static IStream mxstream = { &mxstreamVtbl };
|
|
|
|
|
|
|
|
static int read_cnt;
|
|
|
|
|
|
|
|
static HRESULT WINAPI instream_Read(IStream *iface, void *pv, ULONG cb, ULONG *pcbRead)
|
|
|
|
{
|
|
|
|
static const char *ret_str;
|
|
|
|
|
|
|
|
if(!read_cnt)
|
|
|
|
ret_str = "<?xml version=\"1.0\" ?>\n<rootelem>";
|
|
|
|
else if(read_cnt < 5)
|
|
|
|
ret_str = "<elem attr=\"val\">text</elem>";
|
|
|
|
else if(read_cnt == 5)
|
|
|
|
ret_str = "</rootelem>\n";
|
|
|
|
else
|
|
|
|
ret_str = "";
|
|
|
|
|
|
|
|
read_cnt++;
|
|
|
|
strcpy(pv, ret_str);
|
|
|
|
*pcbRead = strlen(ret_str);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IStreamVtbl instreamVtbl = {
|
|
|
|
istream_QueryInterface,
|
|
|
|
istream_AddRef,
|
|
|
|
istream_Release,
|
|
|
|
instream_Read,
|
2011-08-13 01:11:30 +02:00
|
|
|
istream_Write,
|
|
|
|
istream_Seek,
|
|
|
|
istream_SetSize,
|
|
|
|
istream_CopyTo,
|
|
|
|
istream_Commit,
|
|
|
|
istream_Revert,
|
|
|
|
istream_LockRegion,
|
|
|
|
istream_UnlockRegion,
|
|
|
|
istream_Stat,
|
|
|
|
istream_Clone
|
|
|
|
};
|
|
|
|
|
2014-02-12 13:30:56 +01:00
|
|
|
static IStream instream = { &instreamVtbl };
|
2011-08-13 01:11:30 +02:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
static struct msxmlsupported_data_t reader_support_data[] =
|
|
|
|
{
|
|
|
|
{ &CLSID_SAXXMLReader, "SAXReader" },
|
|
|
|
{ &CLSID_SAXXMLReader30, "SAXReader30" },
|
|
|
|
{ &CLSID_SAXXMLReader40, "SAXReader40" },
|
|
|
|
{ &CLSID_SAXXMLReader60, "SAXReader60" },
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
2013-03-12 09:45:54 +01:00
|
|
|
static struct saxlexicalhandler lexicalhandler;
|
|
|
|
static struct saxdeclhandler declhandler;
|
|
|
|
|
2013-03-13 12:04:59 +01:00
|
|
|
static IStream *create_test_stream(const char *data, int len)
|
|
|
|
{
|
|
|
|
ULARGE_INTEGER size;
|
|
|
|
LARGE_INTEGER pos;
|
|
|
|
IStream *stream;
|
|
|
|
ULONG written;
|
|
|
|
|
|
|
|
if (len == -1) len = strlen(data);
|
|
|
|
CreateStreamOnHGlobal(NULL, TRUE, &stream);
|
|
|
|
size.QuadPart = len;
|
|
|
|
IStream_SetSize(stream, size);
|
|
|
|
IStream_Write(stream, data, len, &written);
|
|
|
|
pos.QuadPart = 0;
|
|
|
|
IStream_Seek(stream, pos, STREAM_SEEK_SET, NULL);
|
|
|
|
|
|
|
|
return stream;
|
|
|
|
}
|
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
static void test_saxreader(void)
|
2008-07-08 20:53:43 +02:00
|
|
|
{
|
2012-04-15 11:47:30 +02:00
|
|
|
const struct msxmlsupported_data_t *table = reader_support_data;
|
2008-07-08 20:53:43 +02:00
|
|
|
HRESULT hr;
|
|
|
|
ISAXXMLReader *reader = NULL;
|
2008-07-10 15:22:14 +02:00
|
|
|
VARIANT var;
|
2012-04-15 11:47:30 +02:00
|
|
|
ISAXContentHandler *content;
|
2008-07-19 22:32:03 +02:00
|
|
|
ISAXErrorHandler *lpErrorHandler;
|
2012-04-15 11:47:30 +02:00
|
|
|
SAFEARRAY *sa;
|
2008-07-19 22:32:26 +02:00
|
|
|
SAFEARRAYBOUND SADim[1];
|
2012-04-15 11:47:30 +02:00
|
|
|
char *ptr = NULL;
|
|
|
|
IStream *stream;
|
|
|
|
ULONG written;
|
2008-07-27 19:54:55 +02:00
|
|
|
HANDLE file;
|
2008-09-03 09:39:16 +02:00
|
|
|
static const CHAR testXmlA[] = "test.xml";
|
2008-07-27 19:54:55 +02:00
|
|
|
static const WCHAR testXmlW[] = {'t','e','s','t','.','x','m','l',0};
|
2012-04-15 11:47:30 +02:00
|
|
|
IXMLDOMDocument *doc;
|
2014-03-10 06:16:58 +01:00
|
|
|
char seqname[50];
|
2012-04-15 11:47:30 +02:00
|
|
|
VARIANT_BOOL v;
|
|
|
|
|
|
|
|
while (table->clsid)
|
|
|
|
{
|
|
|
|
struct call_entry *test_seq;
|
2012-11-16 22:46:36 +01:00
|
|
|
ISAXEntityResolver *resolver;
|
2012-04-20 09:03:18 +02:00
|
|
|
BSTR str;
|
2012-04-15 11:47:30 +02:00
|
|
|
|
|
|
|
if (!is_clsid_supported(table->clsid, reader_support_data))
|
|
|
|
{
|
|
|
|
table++;
|
|
|
|
continue;
|
2011-10-24 20:09:12 +02:00
|
|
|
}
|
2008-07-08 20:53:43 +02:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
hr = CoCreateInstance(table->clsid, NULL, CLSCTX_INPROC_SERVER, &IID_ISAXXMLReader, (void**)&reader);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
2012-04-19 08:46:03 +02:00
|
|
|
g_reader = reader;
|
2008-07-11 00:36:38 +02:00
|
|
|
|
2012-04-19 08:46:03 +02:00
|
|
|
if (IsEqualGUID(table->clsid, &CLSID_SAXXMLReader40))
|
|
|
|
msxml_version = 4;
|
|
|
|
else if (IsEqualGUID(table->clsid, &CLSID_SAXXMLReader60))
|
|
|
|
msxml_version = 6;
|
|
|
|
else
|
|
|
|
msxml_version = 0;
|
2008-07-19 22:32:03 +02:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
/* crashes on old versions */
|
|
|
|
if (!IsEqualGUID(table->clsid, &CLSID_SAXXMLReader40) &&
|
|
|
|
!IsEqualGUID(table->clsid, &CLSID_SAXXMLReader60))
|
|
|
|
{
|
|
|
|
hr = ISAXXMLReader_getContentHandler(reader, NULL);
|
|
|
|
EXPECT_HR(hr, E_POINTER);
|
2008-07-10 15:22:14 +02:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
hr = ISAXXMLReader_getErrorHandler(reader, NULL);
|
|
|
|
EXPECT_HR(hr, E_POINTER);
|
|
|
|
}
|
2008-07-19 22:32:03 +02:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
hr = ISAXXMLReader_getContentHandler(reader, &content);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(content == NULL, "Expected %p, got %p\n", NULL, content);
|
2008-07-10 15:22:14 +02:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
hr = ISAXXMLReader_getErrorHandler(reader, &lpErrorHandler);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(lpErrorHandler == NULL, "Expected %p, got %p\n", NULL, lpErrorHandler);
|
2008-07-08 20:53:43 +02:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
hr = ISAXXMLReader_putContentHandler(reader, NULL);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
2008-07-19 22:32:03 +02:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
hr = ISAXXMLReader_putContentHandler(reader, &contentHandler);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
2008-07-10 15:22:14 +02:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
hr = ISAXXMLReader_putErrorHandler(reader, &errorHandler);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
2008-07-10 15:22:14 +02:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
hr = ISAXXMLReader_getContentHandler(reader, &content);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(content == &contentHandler, "Expected %p, got %p\n", &contentHandler, content);
|
2008-07-10 15:22:14 +02:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
V_VT(&var) = VT_BSTR;
|
|
|
|
V_BSTR(&var) = SysAllocString(szSimpleXML);
|
2010-01-10 16:44:59 +01:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
if (IsEqualGUID(table->clsid, &CLSID_SAXXMLReader40) ||
|
|
|
|
IsEqualGUID(table->clsid, &CLSID_SAXXMLReader60))
|
|
|
|
test_seq = content_handler_test1_alternate;
|
|
|
|
else
|
|
|
|
test_seq = content_handler_test1;
|
|
|
|
set_expected_seq(test_seq);
|
|
|
|
hr = ISAXXMLReader_parse(reader, var);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok_sequence(sequences, CONTENT_HANDLER_INDEX, test_seq, "content test 1", FALSE);
|
2008-07-19 22:32:26 +02:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
VariantClear(&var);
|
2008-07-19 22:32:26 +02:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
SADim[0].lLbound = 0;
|
|
|
|
SADim[0].cElements = sizeof(testXML)-1;
|
|
|
|
sa = SafeArrayCreate(VT_UI1, 1, SADim);
|
|
|
|
SafeArrayAccessData(sa, (void**)&ptr);
|
|
|
|
memcpy(ptr, testXML, sizeof(testXML)-1);
|
|
|
|
SafeArrayUnaccessData(sa);
|
|
|
|
V_VT(&var) = VT_ARRAY|VT_UI1;
|
|
|
|
V_ARRAY(&var) = sa;
|
2008-07-19 22:32:26 +02:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
set_expected_seq(test_seq);
|
|
|
|
hr = ISAXXMLReader_parse(reader, var);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok_sequence(sequences, CONTENT_HANDLER_INDEX, test_seq, "content test 1: from safe array", FALSE);
|
2008-07-23 16:39:33 +02:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
SafeArrayDestroy(sa);
|
2008-07-23 16:39:33 +02:00
|
|
|
|
2013-03-13 12:04:59 +01:00
|
|
|
stream = create_test_stream(testXML, -1);
|
2012-05-09 18:13:32 +02:00
|
|
|
V_VT(&var) = VT_UNKNOWN;
|
2012-04-15 11:47:30 +02:00
|
|
|
V_UNKNOWN(&var) = (IUnknown*)stream;
|
2008-07-23 16:39:33 +02:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
set_expected_seq(test_seq);
|
|
|
|
hr = ISAXXMLReader_parse(reader, var);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok_sequence(sequences, CONTENT_HANDLER_INDEX, test_seq, "content test 1: from stream", FALSE);
|
|
|
|
|
|
|
|
IStream_Release(stream);
|
|
|
|
|
2013-03-13 12:04:59 +01:00
|
|
|
stream = create_test_stream(test_attributes, -1);
|
2012-05-09 18:13:32 +02:00
|
|
|
V_VT(&var) = VT_UNKNOWN;
|
2012-04-15 11:47:30 +02:00
|
|
|
V_UNKNOWN(&var) = (IUnknown*)stream;
|
|
|
|
|
|
|
|
if (IsEqualGUID(table->clsid, &CLSID_SAXXMLReader40))
|
|
|
|
test_seq = content_handler_test_attributes_alternate_4;
|
|
|
|
else if (IsEqualGUID(table->clsid, &CLSID_SAXXMLReader60))
|
|
|
|
test_seq = content_handler_test_attributes_alternate_6;
|
|
|
|
else
|
|
|
|
test_seq = content_handler_test_attributes;
|
2011-10-26 13:25:52 +02:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
set_expected_seq(test_seq);
|
|
|
|
hr = ISAXXMLReader_parse(reader, var);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
2011-10-26 13:25:52 +02:00
|
|
|
|
2012-04-16 00:29:18 +02:00
|
|
|
if (IsEqualGUID(table->clsid, &CLSID_SAXXMLReader40) ||
|
|
|
|
IsEqualGUID(table->clsid, &CLSID_SAXXMLReader60))
|
2012-04-15 11:47:30 +02:00
|
|
|
ok_sequence(sequences, CONTENT_HANDLER_INDEX, test_seq, "content test attributes", FALSE);
|
|
|
|
else
|
|
|
|
ok_sequence(sequences, CONTENT_HANDLER_INDEX, test_seq, "content test attributes", TRUE);
|
2011-10-26 13:25:52 +02:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
IStream_Release(stream);
|
2008-07-23 16:39:43 +02:00
|
|
|
|
2014-02-12 13:30:56 +01:00
|
|
|
V_VT(&var) = VT_UNKNOWN;
|
|
|
|
V_UNKNOWN(&var) = (IUnknown*)&instream;
|
|
|
|
|
|
|
|
test_seq = read_test_seq;
|
|
|
|
read_cnt = 0;
|
|
|
|
set_expected_seq(test_seq);
|
|
|
|
hr = ISAXXMLReader_parse(reader, var);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(read_cnt == 7, "read_cnt = %d\n", read_cnt);
|
|
|
|
ok_sequence(sequences, CONTENT_HANDLER_INDEX, test_seq, "Read call test", FALSE);
|
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
V_VT(&var) = VT_BSTR;
|
|
|
|
V_BSTR(&var) = SysAllocString(carriage_ret_test);
|
2008-07-23 16:39:43 +02:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
if (IsEqualGUID(table->clsid, &CLSID_SAXXMLReader40) ||
|
|
|
|
IsEqualGUID(table->clsid, &CLSID_SAXXMLReader60))
|
|
|
|
test_seq = content_handler_test2_alternate;
|
|
|
|
else
|
|
|
|
test_seq = content_handler_test2;
|
2010-01-10 16:44:59 +01:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
set_expected_seq(test_seq);
|
|
|
|
hr = ISAXXMLReader_parse(reader, var);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok_sequence(sequences, CONTENT_HANDLER_INDEX, test_seq, "content test 2", FALSE);
|
2008-07-27 19:54:55 +02:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
VariantClear(&var);
|
2008-07-27 19:54:55 +02:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
/* from file url */
|
|
|
|
file = CreateFileA(testXmlA, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
ok(file != INVALID_HANDLE_VALUE, "Could not create file: %u\n", GetLastError());
|
|
|
|
WriteFile(file, testXML, sizeof(testXML)-1, &written, NULL);
|
|
|
|
CloseHandle(file);
|
2011-10-24 12:55:22 +02:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
if (IsEqualGUID(table->clsid, &CLSID_SAXXMLReader40) ||
|
|
|
|
IsEqualGUID(table->clsid, &CLSID_SAXXMLReader60))
|
|
|
|
test_seq = content_handler_test1_alternate;
|
|
|
|
else
|
|
|
|
test_seq = content_handler_test1;
|
|
|
|
set_expected_seq(test_seq);
|
|
|
|
hr = ISAXXMLReader_parseURL(reader, testXmlW);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok_sequence(sequences, CONTENT_HANDLER_INDEX, test_seq, "content test 1: from file url", FALSE);
|
2011-10-24 12:55:22 +02:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
/* error handler */
|
|
|
|
if (IsEqualGUID(table->clsid, &CLSID_SAXXMLReader40) ||
|
|
|
|
IsEqualGUID(table->clsid, &CLSID_SAXXMLReader60))
|
|
|
|
test_seq = content_handler_testerror_alternate;
|
|
|
|
else
|
|
|
|
test_seq = content_handler_testerror;
|
|
|
|
set_expected_seq(test_seq);
|
|
|
|
hr = ISAXXMLReader_parseURL(reader, testXmlW);
|
|
|
|
EXPECT_HR(hr, E_FAIL);
|
|
|
|
ok_sequence(sequences, CONTENT_HANDLER_INDEX, test_seq, "content test error", FALSE);
|
2008-07-27 19:54:55 +02:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
/* callback ret values */
|
|
|
|
if (IsEqualGUID(table->clsid, &CLSID_SAXXMLReader40) ||
|
|
|
|
IsEqualGUID(table->clsid, &CLSID_SAXXMLReader60))
|
|
|
|
{
|
|
|
|
test_seq = content_handler_test_callback_rets_alt;
|
|
|
|
set_expected_seq(test_seq);
|
|
|
|
hr = ISAXXMLReader_parseURL(reader, testXmlW);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
test_seq = content_handler_test_callback_rets;
|
|
|
|
set_expected_seq(test_seq);
|
|
|
|
hr = ISAXXMLReader_parseURL(reader, testXmlW);
|
|
|
|
EXPECT_HR(hr, S_FALSE);
|
|
|
|
}
|
|
|
|
ok_sequence(sequences, CONTENT_HANDLER_INDEX, test_seq, "content callback ret values", FALSE);
|
2008-09-19 16:01:24 +02:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
DeleteFileA(testXmlA);
|
2008-09-19 16:01:24 +02:00
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
/* parse from IXMLDOMDocument */
|
|
|
|
hr = CoCreateInstance(&CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IXMLDOMDocument, (void**)&doc);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
str = SysAllocString(szSimpleXML);
|
|
|
|
hr = IXMLDOMDocument_loadXML(doc, str, &v);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
2012-04-20 09:03:18 +02:00
|
|
|
SysFreeString(str);
|
2012-04-15 11:47:30 +02:00
|
|
|
|
|
|
|
V_VT(&var) = VT_UNKNOWN;
|
|
|
|
V_UNKNOWN(&var) = (IUnknown*)doc;
|
|
|
|
|
|
|
|
if (IsEqualGUID(table->clsid, &CLSID_SAXXMLReader40) ||
|
|
|
|
IsEqualGUID(table->clsid, &CLSID_SAXXMLReader60))
|
|
|
|
test_seq = content_handler_test2_alternate;
|
|
|
|
else
|
|
|
|
test_seq = content_handler_test2;
|
|
|
|
|
|
|
|
set_expected_seq(test_seq);
|
|
|
|
hr = ISAXXMLReader_parse(reader, var);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok_sequence(sequences, CONTENT_HANDLER_INDEX, test_seq, "parse from IXMLDOMDocument", FALSE);
|
|
|
|
IXMLDOMDocument_Release(doc);
|
|
|
|
|
|
|
|
/* xml:space test */
|
|
|
|
if (IsEqualGUID(table->clsid, &CLSID_SAXXMLReader40) ||
|
|
|
|
IsEqualGUID(table->clsid, &CLSID_SAXXMLReader60))
|
|
|
|
{
|
|
|
|
test_seq = xmlspaceattr_test_alternate;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
test_seq = xmlspaceattr_test;
|
|
|
|
|
|
|
|
set_expected_seq(test_seq);
|
|
|
|
V_VT(&var) = VT_BSTR;
|
|
|
|
V_BSTR(&var) = _bstr_(xmlspace_attr);
|
|
|
|
hr = ISAXXMLReader_parse(reader, var);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
if (IsEqualGUID(table->clsid, &CLSID_SAXXMLReader40) ||
|
|
|
|
IsEqualGUID(table->clsid, &CLSID_SAXXMLReader60))
|
|
|
|
{
|
|
|
|
ok_sequence(sequences, CONTENT_HANDLER_INDEX, test_seq, "xml:space handling", TRUE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ok_sequence(sequences, CONTENT_HANDLER_INDEX, test_seq, "xml:space handling", FALSE);
|
|
|
|
|
2012-04-19 08:46:03 +02:00
|
|
|
/* switch off 'namespaces' feature */
|
|
|
|
hr = ISAXXMLReader_putFeature(reader, _bstr_("http://xml.org/sax/features/namespaces"), VARIANT_FALSE);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
2013-03-13 12:04:59 +01:00
|
|
|
stream = create_test_stream(test_attributes, -1);
|
2012-05-09 18:13:32 +02:00
|
|
|
V_VT(&var) = VT_UNKNOWN;
|
2012-04-19 08:46:03 +02:00
|
|
|
V_UNKNOWN(&var) = (IUnknown*)stream;
|
|
|
|
|
|
|
|
if (IsEqualGUID(table->clsid, &CLSID_SAXXMLReader40) ||
|
|
|
|
IsEqualGUID(table->clsid, &CLSID_SAXXMLReader60))
|
|
|
|
{
|
|
|
|
test_seq = content_handler_test_attributes_alt_no_ns;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
test_seq = content_handler_test_attributes;
|
|
|
|
|
|
|
|
set_expected_seq(test_seq);
|
|
|
|
hr = ISAXXMLReader_parse(reader, var);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok_sequence(sequences, CONTENT_HANDLER_INDEX, test_seq, "content test attributes", TRUE);
|
2012-04-20 09:03:18 +02:00
|
|
|
hr = ISAXXMLReader_putFeature(reader, _bstr_("http://xml.org/sax/features/namespaces"), VARIANT_TRUE);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
/* switch off 'namespace-prefixes' feature */
|
|
|
|
hr = ISAXXMLReader_putFeature(reader, _bstr_("http://xml.org/sax/features/namespace-prefixes"), VARIANT_FALSE);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
2013-03-13 12:04:59 +01:00
|
|
|
stream = create_test_stream(test_attributes, -1);
|
2012-05-09 18:13:32 +02:00
|
|
|
V_VT(&var) = VT_UNKNOWN;
|
2012-04-20 09:03:18 +02:00
|
|
|
V_UNKNOWN(&var) = (IUnknown*)stream;
|
|
|
|
|
|
|
|
if (IsEqualGUID(table->clsid, &CLSID_SAXXMLReader40) ||
|
|
|
|
IsEqualGUID(table->clsid, &CLSID_SAXXMLReader60))
|
|
|
|
{
|
|
|
|
test_seq = content_handler_test_attributes_alt_no_prefix;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
test_seq = content_handler_test_attributes_no_prefix;
|
|
|
|
|
|
|
|
set_expected_seq(test_seq);
|
|
|
|
hr = ISAXXMLReader_parse(reader, var);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok_sequence(sequences, CONTENT_HANDLER_INDEX, test_seq, "content test attributes", FALSE);
|
|
|
|
|
|
|
|
hr = ISAXXMLReader_putFeature(reader, _bstr_("http://xml.org/sax/features/namespace-prefixes"), VARIANT_TRUE);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
2012-04-19 08:46:03 +02:00
|
|
|
|
2012-04-28 11:20:06 +02:00
|
|
|
/* attribute normalization */
|
2013-03-13 12:04:59 +01:00
|
|
|
stream = create_test_stream(attribute_normalize, -1);
|
2012-05-09 18:13:32 +02:00
|
|
|
V_VT(&var) = VT_UNKNOWN;
|
2012-04-28 11:20:06 +02:00
|
|
|
V_UNKNOWN(&var) = (IUnknown*)stream;
|
|
|
|
|
|
|
|
if (IsEqualGUID(table->clsid, &CLSID_SAXXMLReader40) ||
|
|
|
|
IsEqualGUID(table->clsid, &CLSID_SAXXMLReader60))
|
|
|
|
{
|
|
|
|
test_seq = attribute_norm_alt;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
test_seq = attribute_norm;
|
|
|
|
|
|
|
|
set_expected_seq(test_seq);
|
|
|
|
hr = ISAXXMLReader_parse(reader, var);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok_sequence(sequences, CONTENT_HANDLER_INDEX, test_seq, "attribute value normalization", TRUE);
|
2014-05-04 18:33:35 +02:00
|
|
|
IStream_Release(stream);
|
2012-04-28 11:20:06 +02:00
|
|
|
|
2012-11-16 22:46:36 +01:00
|
|
|
resolver = (void*)0xdeadbeef;
|
|
|
|
hr = ISAXXMLReader_getEntityResolver(reader, &resolver);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(resolver == NULL, "got %p\n", resolver);
|
|
|
|
|
|
|
|
hr = ISAXXMLReader_putEntityResolver(reader, NULL);
|
|
|
|
ok(hr == S_OK || broken(hr == E_FAIL), "got 0x%08x\n", hr);
|
|
|
|
|
2013-03-12 09:45:54 +01:00
|
|
|
/* CDATA sections */
|
|
|
|
init_saxlexicalhandler(&lexicalhandler, S_OK);
|
|
|
|
|
|
|
|
V_VT(&var) = VT_UNKNOWN;
|
|
|
|
V_UNKNOWN(&var) = (IUnknown*)&lexicalhandler.ISAXLexicalHandler_iface;
|
|
|
|
hr = ISAXXMLReader_putProperty(reader, _bstr_("http://xml.org/sax/properties/lexical-handler"), var);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
2013-03-13 12:04:59 +01:00
|
|
|
stream = create_test_stream(test_cdata_xml, -1);
|
2013-03-12 09:45:54 +01:00
|
|
|
V_VT(&var) = VT_UNKNOWN;
|
|
|
|
V_UNKNOWN(&var) = (IUnknown*)stream;
|
|
|
|
|
2014-03-10 06:16:58 +01:00
|
|
|
if (IsEqualGUID(table->clsid, &CLSID_SAXXMLReader60) ||
|
|
|
|
IsEqualGUID(table->clsid, &CLSID_SAXXMLReader40))
|
2013-03-12 09:45:54 +01:00
|
|
|
test_seq = cdata_test_alt;
|
|
|
|
else
|
|
|
|
test_seq = cdata_test;
|
|
|
|
|
|
|
|
set_expected_seq(test_seq);
|
|
|
|
hr = ISAXXMLReader_parse(reader, var);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2014-03-10 06:16:58 +01:00
|
|
|
sprintf(seqname, "%s: cdata test", table->name);
|
|
|
|
ok_sequence(sequences, CONTENT_HANDLER_INDEX, test_seq, seqname, TRUE);
|
2013-03-12 09:45:54 +01:00
|
|
|
|
2014-05-04 18:33:35 +02:00
|
|
|
IStream_Release(stream);
|
|
|
|
|
2013-03-13 12:04:59 +01:00
|
|
|
/* 2. CDATA sections */
|
|
|
|
stream = create_test_stream(test2_cdata_xml, -1);
|
|
|
|
V_VT(&var) = VT_UNKNOWN;
|
|
|
|
V_UNKNOWN(&var) = (IUnknown*)stream;
|
|
|
|
|
2014-03-10 06:16:58 +01:00
|
|
|
if (IsEqualGUID(table->clsid, &CLSID_SAXXMLReader60) ||
|
|
|
|
IsEqualGUID(table->clsid, &CLSID_SAXXMLReader40))
|
2013-03-13 12:04:59 +01:00
|
|
|
test_seq = cdata_test2_alt;
|
|
|
|
else
|
|
|
|
test_seq = cdata_test2;
|
|
|
|
|
|
|
|
set_expected_seq(test_seq);
|
|
|
|
hr = ISAXXMLReader_parse(reader, var);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2014-03-10 06:16:58 +01:00
|
|
|
sprintf(seqname, "%s: cdata test 2", table->name);
|
|
|
|
ok_sequence(sequences, CONTENT_HANDLER_INDEX, test_seq, seqname, TRUE);
|
2013-03-13 12:04:59 +01:00
|
|
|
|
|
|
|
IStream_Release(stream);
|
|
|
|
|
|
|
|
/* 3. CDATA sections */
|
|
|
|
stream = create_test_stream(test3_cdata_xml, -1);
|
|
|
|
V_VT(&var) = VT_UNKNOWN;
|
|
|
|
V_UNKNOWN(&var) = (IUnknown*)stream;
|
|
|
|
|
2014-03-10 06:16:58 +01:00
|
|
|
if (IsEqualGUID(table->clsid, &CLSID_SAXXMLReader60) ||
|
|
|
|
IsEqualGUID(table->clsid, &CLSID_SAXXMLReader40))
|
2013-03-13 12:04:59 +01:00
|
|
|
test_seq = cdata_test3_alt;
|
|
|
|
else
|
|
|
|
test_seq = cdata_test3;
|
|
|
|
|
|
|
|
set_expected_seq(test_seq);
|
|
|
|
hr = ISAXXMLReader_parse(reader, var);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2014-03-10 06:16:58 +01:00
|
|
|
sprintf(seqname, "%s: cdata test 3", table->name);
|
|
|
|
ok_sequence(sequences, CONTENT_HANDLER_INDEX, test_seq, seqname, TRUE);
|
2013-03-13 12:04:59 +01:00
|
|
|
|
2013-03-12 09:45:54 +01:00
|
|
|
IStream_Release(stream);
|
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
ISAXXMLReader_Release(reader);
|
|
|
|
table++;
|
|
|
|
}
|
|
|
|
|
2012-03-01 19:06:39 +01:00
|
|
|
free_bstrs();
|
2008-07-08 20:53:43 +02:00
|
|
|
}
|
|
|
|
|
2011-09-22 08:50:41 +02:00
|
|
|
struct saxreader_props_test_t
|
|
|
|
{
|
|
|
|
const char *prop_name;
|
|
|
|
IUnknown *iface;
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct saxreader_props_test_t props_test_data[] = {
|
2012-04-26 21:54:22 +02:00
|
|
|
{ "http://xml.org/sax/properties/lexical-handler", (IUnknown*)&lexicalhandler.ISAXLexicalHandler_iface },
|
|
|
|
{ "http://xml.org/sax/properties/declaration-handler", (IUnknown*)&declhandler.ISAXDeclHandler_iface },
|
2011-09-22 08:50:41 +02:00
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
2011-09-21 19:01:10 +02:00
|
|
|
static void test_saxreader_properties(void)
|
|
|
|
{
|
2011-09-22 08:50:41 +02:00
|
|
|
const struct saxreader_props_test_t *ptr = props_test_data;
|
2011-09-21 19:01:10 +02:00
|
|
|
ISAXXMLReader *reader;
|
|
|
|
HRESULT hr;
|
2012-08-27 07:39:43 +02:00
|
|
|
VARIANT v;
|
2014-03-03 05:54:52 +01:00
|
|
|
BSTR str;
|
2011-09-21 19:01:10 +02:00
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_SAXXMLReader, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_ISAXXMLReader, (void**)&reader);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = ISAXXMLReader_getProperty(reader, _bstr_("http://xml.org/sax/properties/lexical-handler"), NULL);
|
|
|
|
EXPECT_HR(hr, E_POINTER);
|
|
|
|
|
2011-09-22 08:50:41 +02:00
|
|
|
while (ptr->prop_name)
|
|
|
|
{
|
2014-03-03 05:55:37 +01:00
|
|
|
VARIANT varref;
|
2012-04-26 21:54:22 +02:00
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
init_saxlexicalhandler(&lexicalhandler, S_OK);
|
|
|
|
init_saxdeclhandler(&declhandler, S_OK);
|
2011-09-22 08:50:41 +02:00
|
|
|
|
|
|
|
V_VT(&v) = VT_EMPTY;
|
|
|
|
V_UNKNOWN(&v) = (IUnknown*)0xdeadbeef;
|
|
|
|
hr = ISAXXMLReader_getProperty(reader, _bstr_(ptr->prop_name), &v);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(V_VT(&v) == VT_UNKNOWN, "got %d\n", V_VT(&v));
|
|
|
|
ok(V_UNKNOWN(&v) == NULL, "got %p\n", V_UNKNOWN(&v));
|
|
|
|
|
2014-03-03 05:55:37 +01:00
|
|
|
/* VT_UNKNOWN */
|
2011-09-22 08:50:41 +02:00
|
|
|
V_VT(&v) = VT_UNKNOWN;
|
|
|
|
V_UNKNOWN(&v) = ptr->iface;
|
2012-04-26 21:54:22 +02:00
|
|
|
ref = get_refcount(ptr->iface);
|
2011-09-22 08:50:41 +02:00
|
|
|
hr = ISAXXMLReader_putProperty(reader, _bstr_(ptr->prop_name), v);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
2012-04-26 21:54:22 +02:00
|
|
|
ok(ref < get_refcount(ptr->iface), "expected inreased refcount\n");
|
2011-09-22 08:50:41 +02:00
|
|
|
|
2014-03-03 05:55:37 +01:00
|
|
|
/* VT_DISPATCH */
|
|
|
|
V_VT(&v) = VT_DISPATCH;
|
|
|
|
V_UNKNOWN(&v) = ptr->iface;
|
|
|
|
ref = get_refcount(ptr->iface);
|
|
|
|
hr = ISAXXMLReader_putProperty(reader, _bstr_(ptr->prop_name), v);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(ref == get_refcount(ptr->iface), "got wrong refcount %d, expected %d\n", get_refcount(ptr->iface), ref);
|
|
|
|
|
|
|
|
/* VT_VARIANT|VT_BYREF with VT_UNKNOWN in referenced variant */
|
|
|
|
V_VT(&varref) = VT_UNKNOWN;
|
|
|
|
V_UNKNOWN(&varref) = ptr->iface;
|
|
|
|
|
|
|
|
V_VT(&v) = VT_VARIANT|VT_BYREF;
|
|
|
|
V_VARIANTREF(&v) = &varref;
|
|
|
|
ref = get_refcount(ptr->iface);
|
|
|
|
hr = ISAXXMLReader_putProperty(reader, _bstr_(ptr->prop_name), v);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(ref == get_refcount(ptr->iface), "got wrong refcount %d, expected %d\n", get_refcount(ptr->iface), ref);
|
|
|
|
|
|
|
|
/* VT_VARIANT|VT_BYREF with VT_DISPATCH in referenced variant */
|
|
|
|
V_VT(&varref) = VT_DISPATCH;
|
|
|
|
V_UNKNOWN(&varref) = ptr->iface;
|
|
|
|
|
|
|
|
V_VT(&v) = VT_VARIANT|VT_BYREF;
|
|
|
|
V_VARIANTREF(&v) = &varref;
|
|
|
|
ref = get_refcount(ptr->iface);
|
|
|
|
hr = ISAXXMLReader_putProperty(reader, _bstr_(ptr->prop_name), v);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(ref == get_refcount(ptr->iface), "got wrong refcount %d, expected %d\n", get_refcount(ptr->iface), ref);
|
|
|
|
|
2011-09-22 08:50:41 +02:00
|
|
|
V_VT(&v) = VT_EMPTY;
|
|
|
|
V_UNKNOWN(&v) = (IUnknown*)0xdeadbeef;
|
2012-04-26 21:54:22 +02:00
|
|
|
|
|
|
|
ref = get_refcount(ptr->iface);
|
2011-09-22 08:50:41 +02:00
|
|
|
hr = ISAXXMLReader_getProperty(reader, _bstr_(ptr->prop_name), &v);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(V_VT(&v) == VT_UNKNOWN, "got %d\n", V_VT(&v));
|
|
|
|
ok(V_UNKNOWN(&v) == ptr->iface, "got %p\n", V_UNKNOWN(&v));
|
2012-04-26 21:54:22 +02:00
|
|
|
ok(ref < get_refcount(ptr->iface), "expected inreased refcount\n");
|
2011-09-22 08:50:41 +02:00
|
|
|
VariantClear(&v);
|
|
|
|
|
|
|
|
V_VT(&v) = VT_EMPTY;
|
|
|
|
V_UNKNOWN(&v) = (IUnknown*)0xdeadbeef;
|
|
|
|
hr = ISAXXMLReader_putProperty(reader, _bstr_(ptr->prop_name), v);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
V_VT(&v) = VT_EMPTY;
|
|
|
|
V_UNKNOWN(&v) = (IUnknown*)0xdeadbeef;
|
|
|
|
hr = ISAXXMLReader_getProperty(reader, _bstr_(ptr->prop_name), &v);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(V_VT(&v) == VT_UNKNOWN, "got %d\n", V_VT(&v));
|
|
|
|
ok(V_UNKNOWN(&v) == NULL, "got %p\n", V_UNKNOWN(&v));
|
|
|
|
|
|
|
|
V_VT(&v) = VT_UNKNOWN;
|
|
|
|
V_UNKNOWN(&v) = ptr->iface;
|
|
|
|
hr = ISAXXMLReader_putProperty(reader, _bstr_(ptr->prop_name), v);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
/* only VT_EMPTY seems to be valid to reset property */
|
|
|
|
V_VT(&v) = VT_I4;
|
|
|
|
V_UNKNOWN(&v) = (IUnknown*)0xdeadbeef;
|
|
|
|
hr = ISAXXMLReader_putProperty(reader, _bstr_(ptr->prop_name), v);
|
|
|
|
EXPECT_HR(hr, E_INVALIDARG);
|
|
|
|
|
|
|
|
V_VT(&v) = VT_EMPTY;
|
|
|
|
V_UNKNOWN(&v) = (IUnknown*)0xdeadbeef;
|
|
|
|
hr = ISAXXMLReader_getProperty(reader, _bstr_(ptr->prop_name), &v);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(V_VT(&v) == VT_UNKNOWN, "got %d\n", V_VT(&v));
|
|
|
|
ok(V_UNKNOWN(&v) == ptr->iface, "got %p\n", V_UNKNOWN(&v));
|
|
|
|
VariantClear(&v);
|
|
|
|
|
|
|
|
V_VT(&v) = VT_UNKNOWN;
|
|
|
|
V_UNKNOWN(&v) = NULL;
|
|
|
|
hr = ISAXXMLReader_putProperty(reader, _bstr_(ptr->prop_name), v);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
V_VT(&v) = VT_EMPTY;
|
|
|
|
V_UNKNOWN(&v) = (IUnknown*)0xdeadbeef;
|
|
|
|
hr = ISAXXMLReader_getProperty(reader, _bstr_(ptr->prop_name), &v);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(V_VT(&v) == VT_UNKNOWN, "got %d\n", V_VT(&v));
|
|
|
|
ok(V_UNKNOWN(&v) == NULL, "got %p\n", V_UNKNOWN(&v));
|
|
|
|
|
2012-04-26 21:54:22 +02:00
|
|
|
/* block QueryInterface on handler riid */
|
2012-07-14 22:36:54 +02:00
|
|
|
V_VT(&v) = VT_UNKNOWN;
|
|
|
|
V_UNKNOWN(&v) = ptr->iface;
|
|
|
|
hr = ISAXXMLReader_putProperty(reader, _bstr_(ptr->prop_name), v);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
2012-04-26 21:54:22 +02:00
|
|
|
init_saxlexicalhandler(&lexicalhandler, E_NOINTERFACE);
|
|
|
|
init_saxdeclhandler(&declhandler, E_NOINTERFACE);
|
|
|
|
|
|
|
|
V_VT(&v) = VT_UNKNOWN;
|
|
|
|
V_UNKNOWN(&v) = ptr->iface;
|
|
|
|
EXPECT_REF(ptr->iface, 1);
|
|
|
|
ref = get_refcount(ptr->iface);
|
|
|
|
hr = ISAXXMLReader_putProperty(reader, _bstr_(ptr->prop_name), v);
|
|
|
|
EXPECT_HR(hr, E_NOINTERFACE);
|
|
|
|
EXPECT_REF(ptr->iface, 1);
|
|
|
|
|
2012-07-14 22:36:54 +02:00
|
|
|
V_VT(&v) = VT_EMPTY;
|
|
|
|
V_UNKNOWN(&v) = (IUnknown*)0xdeadbeef;
|
|
|
|
hr = ISAXXMLReader_getProperty(reader, _bstr_(ptr->prop_name), &v);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(V_VT(&v) == VT_UNKNOWN, "got %d\n", V_VT(&v));
|
|
|
|
ok(V_UNKNOWN(&v) != NULL, "got %p\n", V_UNKNOWN(&v));
|
|
|
|
|
2011-09-22 08:50:41 +02:00
|
|
|
ptr++;
|
2012-08-27 07:39:43 +02:00
|
|
|
free_bstrs();
|
2011-09-22 08:50:41 +02:00
|
|
|
}
|
2011-09-21 19:01:10 +02:00
|
|
|
|
2012-08-27 07:39:43 +02:00
|
|
|
ISAXXMLReader_Release(reader);
|
|
|
|
|
|
|
|
if (!is_clsid_supported(&CLSID_SAXXMLReader40, reader_support_data))
|
|
|
|
return;
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_SAXXMLReader40, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_ISAXXMLReader, (void**)&reader);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
/* xmldecl-version property */
|
|
|
|
V_VT(&v) = VT_EMPTY;
|
|
|
|
V_BSTR(&v) = (void*)0xdeadbeef;
|
|
|
|
hr = ISAXXMLReader_getProperty(reader, _bstr_("xmldecl-version"), &v);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(V_VT(&v) == VT_BSTR, "got %d\n", V_VT(&v));
|
|
|
|
ok(V_BSTR(&v) == NULL, "got %s\n", wine_dbgstr_w(V_BSTR(&v)));
|
|
|
|
|
|
|
|
/* stream without declaration */
|
|
|
|
V_VT(&v) = VT_BSTR;
|
|
|
|
V_BSTR(&v) = _bstr_("<element></element>");
|
|
|
|
hr = ISAXXMLReader_parse(reader, v);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
V_VT(&v) = VT_EMPTY;
|
|
|
|
V_BSTR(&v) = (void*)0xdeadbeef;
|
|
|
|
hr = ISAXXMLReader_getProperty(reader, _bstr_("xmldecl-version"), &v);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(V_VT(&v) == VT_BSTR, "got %d\n", V_VT(&v));
|
|
|
|
ok(V_BSTR(&v) == NULL, "got %s\n", wine_dbgstr_w(V_BSTR(&v)));
|
|
|
|
|
|
|
|
/* stream with declaration */
|
|
|
|
V_VT(&v) = VT_BSTR;
|
|
|
|
V_BSTR(&v) = _bstr_("<?xml version=\"1.0\"?><element></element>");
|
|
|
|
hr = ISAXXMLReader_parse(reader, v);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
2014-03-03 05:54:52 +01:00
|
|
|
/* VT_BSTR|VT_BYREF input type */
|
|
|
|
str = _bstr_("<?xml version=\"1.0\"?><element></element>");
|
|
|
|
V_VT(&v) = VT_BSTR|VT_BYREF;
|
|
|
|
V_BSTRREF(&v) = &str;
|
|
|
|
hr = ISAXXMLReader_parse(reader, v);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
2012-08-27 07:39:43 +02:00
|
|
|
V_VT(&v) = VT_EMPTY;
|
|
|
|
V_BSTR(&v) = (void*)0xdeadbeef;
|
|
|
|
hr = ISAXXMLReader_getProperty(reader, _bstr_("xmldecl-version"), &v);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(V_VT(&v) == VT_BSTR, "got %d\n", V_VT(&v));
|
|
|
|
ok(!lstrcmpW(V_BSTR(&v), _bstr_("1.0")), "got %s\n", wine_dbgstr_w(V_BSTR(&v)));
|
|
|
|
VariantClear(&v);
|
|
|
|
|
2011-09-21 19:01:10 +02:00
|
|
|
ISAXXMLReader_Release(reader);
|
|
|
|
free_bstrs();
|
|
|
|
}
|
|
|
|
|
2011-10-05 20:29:37 +02:00
|
|
|
struct feature_ns_entry_t {
|
|
|
|
const GUID *guid;
|
|
|
|
const char *clsid;
|
|
|
|
VARIANT_BOOL value;
|
2012-04-19 08:46:03 +02:00
|
|
|
VARIANT_BOOL value2; /* feature value after feature set to 0xc */
|
2011-10-05 20:29:37 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static const struct feature_ns_entry_t feature_ns_entry_data[] = {
|
2012-04-19 08:46:03 +02:00
|
|
|
{ &CLSID_SAXXMLReader, "CLSID_SAXXMLReader", VARIANT_TRUE, VARIANT_FALSE },
|
|
|
|
{ &CLSID_SAXXMLReader30, "CLSID_SAXXMLReader30", VARIANT_TRUE, VARIANT_FALSE },
|
|
|
|
{ &CLSID_SAXXMLReader40, "CLSID_SAXXMLReader40", VARIANT_TRUE, VARIANT_TRUE },
|
|
|
|
{ &CLSID_SAXXMLReader60, "CLSID_SAXXMLReader60", VARIANT_TRUE, VARIANT_TRUE },
|
2011-10-05 20:29:37 +02:00
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
2012-04-19 08:46:03 +02:00
|
|
|
static const char *feature_names[] = {
|
|
|
|
"http://xml.org/sax/features/namespaces",
|
2012-04-20 09:03:18 +02:00
|
|
|
"http://xml.org/sax/features/namespace-prefixes",
|
2012-04-19 08:46:03 +02:00
|
|
|
0
|
|
|
|
};
|
|
|
|
|
2011-10-05 20:29:37 +02:00
|
|
|
static void test_saxreader_features(void)
|
|
|
|
{
|
|
|
|
const struct feature_ns_entry_t *entry = feature_ns_entry_data;
|
|
|
|
ISAXXMLReader *reader;
|
|
|
|
|
|
|
|
while (entry->guid)
|
|
|
|
{
|
|
|
|
VARIANT_BOOL value;
|
2012-04-19 08:46:03 +02:00
|
|
|
const char **name;
|
2011-10-05 20:29:37 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = CoCreateInstance(entry->guid, NULL, CLSCTX_INPROC_SERVER, &IID_ISAXXMLReader, (void**)&reader);
|
|
|
|
if (hr != S_OK)
|
|
|
|
{
|
|
|
|
win_skip("can't create %s instance\n", entry->clsid);
|
|
|
|
entry++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2012-04-19 08:46:03 +02:00
|
|
|
name = feature_names;
|
|
|
|
while (*name)
|
|
|
|
{
|
|
|
|
value = 0xc;
|
|
|
|
hr = ISAXXMLReader_getFeature(reader, _bstr_(*name), &value);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(entry->value == value, "%s: got wrong default value %x, expected %x\n", entry->clsid, value, entry->value);
|
2011-10-05 20:29:37 +02:00
|
|
|
|
2012-04-19 08:46:03 +02:00
|
|
|
value = 0xc;
|
|
|
|
hr = ISAXXMLReader_putFeature(reader, _bstr_(*name), value);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
value = 0xd;
|
|
|
|
hr = ISAXXMLReader_getFeature(reader, _bstr_(*name), &value);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
2012-04-19 08:53:15 +02:00
|
|
|
ok(entry->value2 == value, "%s: got wrong value %x, expected %x\n", entry->clsid, value, entry->value2);
|
2012-04-19 08:46:03 +02:00
|
|
|
|
|
|
|
hr = ISAXXMLReader_putFeature(reader, _bstr_(*name), VARIANT_FALSE);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
value = 0xd;
|
|
|
|
hr = ISAXXMLReader_getFeature(reader, _bstr_(*name), &value);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(value == VARIANT_FALSE, "%s: got wrong value %x, expected VARIANT_FALSE\n", entry->clsid, value);
|
|
|
|
|
|
|
|
hr = ISAXXMLReader_putFeature(reader, _bstr_(*name), VARIANT_TRUE);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
value = 0xd;
|
|
|
|
hr = ISAXXMLReader_getFeature(reader, _bstr_(*name), &value);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(value == VARIANT_TRUE, "%s: got wrong value %x, expected VARIANT_TRUE\n", entry->clsid, value);
|
|
|
|
|
|
|
|
name++;
|
|
|
|
}
|
2011-10-05 20:29:37 +02:00
|
|
|
|
|
|
|
ISAXXMLReader_Release(reader);
|
|
|
|
|
|
|
|
entry++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-28 23:00:44 +02:00
|
|
|
/* UTF-8 data with UTF-8 BOM and UTF-16 in prolog */
|
|
|
|
static const CHAR UTF8BOMTest[] =
|
|
|
|
"\xEF\xBB\xBF<?xml version = \"1.0\" encoding = \"UTF-16\"?>\n"
|
|
|
|
"<a></a>\n";
|
|
|
|
|
|
|
|
struct enc_test_entry_t {
|
|
|
|
const GUID *guid;
|
|
|
|
const char *clsid;
|
|
|
|
const char *data;
|
|
|
|
HRESULT hr;
|
2014-01-04 15:48:23 +01:00
|
|
|
BOOL todo;
|
2010-10-28 23:00:44 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static const struct enc_test_entry_t encoding_test_data[] = {
|
2014-01-04 15:48:23 +01:00
|
|
|
{ &CLSID_SAXXMLReader, "CLSID_SAXXMLReader", UTF8BOMTest, 0xc00ce56f, TRUE },
|
|
|
|
{ &CLSID_SAXXMLReader30, "CLSID_SAXXMLReader30", UTF8BOMTest, 0xc00ce56f, TRUE },
|
|
|
|
{ &CLSID_SAXXMLReader40, "CLSID_SAXXMLReader40", UTF8BOMTest, S_OK, FALSE },
|
|
|
|
{ &CLSID_SAXXMLReader60, "CLSID_SAXXMLReader60", UTF8BOMTest, S_OK, FALSE },
|
2010-10-28 23:00:44 +02:00
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
2012-04-21 10:32:15 +02:00
|
|
|
static void test_saxreader_encoding(void)
|
2010-10-28 23:00:44 +02:00
|
|
|
{
|
|
|
|
const struct enc_test_entry_t *entry = encoding_test_data;
|
|
|
|
static const WCHAR testXmlW[] = {'t','e','s','t','.','x','m','l',0};
|
|
|
|
static const CHAR testXmlA[] = "test.xml";
|
|
|
|
|
|
|
|
while (entry->guid)
|
|
|
|
{
|
2012-04-21 10:32:15 +02:00
|
|
|
ISAXXMLReader *reader;
|
|
|
|
VARIANT input;
|
|
|
|
DWORD written;
|
|
|
|
HANDLE file;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2010-10-28 23:00:44 +02:00
|
|
|
hr = CoCreateInstance(entry->guid, NULL, CLSCTX_INPROC_SERVER, &IID_ISAXXMLReader, (void**)&reader);
|
|
|
|
if (hr != S_OK)
|
|
|
|
{
|
|
|
|
win_skip("can't create %s instance\n", entry->clsid);
|
|
|
|
entry++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
file = CreateFileA(testXmlA, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
ok(file != INVALID_HANDLE_VALUE, "Could not create file: %u\n", GetLastError());
|
|
|
|
WriteFile(file, UTF8BOMTest, sizeof(UTF8BOMTest)-1, &written, NULL);
|
|
|
|
CloseHandle(file);
|
|
|
|
|
|
|
|
hr = ISAXXMLReader_parseURL(reader, testXmlW);
|
|
|
|
if (entry->todo)
|
|
|
|
todo_wine ok(hr == entry->hr, "Expected 0x%08x, got 0x%08x. CLSID %s\n", entry->hr, hr, entry->clsid);
|
|
|
|
else
|
|
|
|
ok(hr == entry->hr, "Expected 0x%08x, got 0x%08x. CLSID %s\n", entry->hr, hr, entry->clsid);
|
|
|
|
|
|
|
|
DeleteFileA(testXmlA);
|
2012-04-21 10:32:15 +02:00
|
|
|
|
|
|
|
/* try BSTR input with no BOM or '<?xml' instruction */
|
|
|
|
V_VT(&input) = VT_BSTR;
|
|
|
|
V_BSTR(&input) = _bstr_("<element></element>");
|
|
|
|
hr = ISAXXMLReader_parse(reader, input);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
2010-10-28 23:00:44 +02:00
|
|
|
ISAXXMLReader_Release(reader);
|
|
|
|
|
2012-04-21 10:32:15 +02:00
|
|
|
free_bstrs();
|
2010-10-28 23:00:44 +02:00
|
|
|
entry++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-27 12:45:21 +01:00
|
|
|
static void test_mxwriter_handlers(void)
|
2011-04-30 13:18:03 +02:00
|
|
|
{
|
2014-03-05 07:39:39 +01:00
|
|
|
IMXWriter *writer;
|
2011-04-30 13:18:03 +02:00
|
|
|
HRESULT hr;
|
2014-03-05 07:39:39 +01:00
|
|
|
int i;
|
|
|
|
|
2014-12-01 22:58:01 +01:00
|
|
|
static REFIID riids[] =
|
2014-03-05 07:39:39 +01:00
|
|
|
{
|
|
|
|
&IID_ISAXContentHandler,
|
|
|
|
&IID_ISAXLexicalHandler,
|
|
|
|
&IID_ISAXDeclHandler,
|
|
|
|
&IID_ISAXDTDHandler,
|
2014-03-05 07:39:57 +01:00
|
|
|
&IID_ISAXErrorHandler,
|
2014-03-05 07:39:39 +01:00
|
|
|
&IID_IVBSAXDeclHandler,
|
|
|
|
&IID_IVBSAXLexicalHandler,
|
|
|
|
&IID_IVBSAXContentHandler,
|
2014-03-05 07:39:57 +01:00
|
|
|
&IID_IVBSAXDTDHandler,
|
|
|
|
&IID_IVBSAXErrorHandler
|
2014-03-05 07:39:39 +01:00
|
|
|
};
|
2011-04-30 13:18:03 +02:00
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_MXXMLWriter, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IMXWriter, (void**)&writer);
|
|
|
|
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
|
|
|
|
|
|
|
EXPECT_REF(writer, 1);
|
|
|
|
|
2014-03-05 07:39:39 +01:00
|
|
|
for (i = 0; i < sizeof(riids)/sizeof(REFIID); i++)
|
|
|
|
{
|
|
|
|
IUnknown *handler;
|
|
|
|
IMXWriter *writer2;
|
|
|
|
|
|
|
|
/* handler from IMXWriter */
|
|
|
|
hr = IMXWriter_QueryInterface(writer, riids[i], (void**)&handler);
|
|
|
|
ok(hr == S_OK, "%s, expected S_OK, got %08x\n", wine_dbgstr_guid(riids[i]), hr);
|
|
|
|
EXPECT_REF(writer, 2);
|
|
|
|
EXPECT_REF(handler, 2);
|
|
|
|
|
|
|
|
/* IMXWriter from a handler */
|
|
|
|
hr = IUnknown_QueryInterface(handler, &IID_IMXWriter, (void**)&writer2);
|
|
|
|
ok(hr == S_OK, "%s, expected S_OK, got %08x\n", wine_dbgstr_guid(riids[i]), hr);
|
|
|
|
ok(writer2 == writer, "got %p, expected %p\n", writer2, writer);
|
|
|
|
EXPECT_REF(writer, 3);
|
|
|
|
EXPECT_REF(writer2, 3);
|
|
|
|
IMXWriter_Release(writer2);
|
|
|
|
IUnknown_Release(handler);
|
|
|
|
}
|
2014-03-03 05:55:59 +01:00
|
|
|
|
2011-04-30 13:18:03 +02:00
|
|
|
IMXWriter_Release(writer);
|
|
|
|
}
|
|
|
|
|
2012-02-24 15:38:18 +01:00
|
|
|
static struct msxmlsupported_data_t mxwriter_support_data[] =
|
2011-08-26 06:09:31 +02:00
|
|
|
{
|
2012-04-15 11:47:30 +02:00
|
|
|
{ &CLSID_MXXMLWriter, "MXXMLWriter" },
|
2011-08-26 06:09:31 +02:00
|
|
|
{ &CLSID_MXXMLWriter30, "MXXMLWriter30" },
|
|
|
|
{ &CLSID_MXXMLWriter40, "MXXMLWriter40" },
|
|
|
|
{ &CLSID_MXXMLWriter60, "MXXMLWriter60" },
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
2012-02-24 15:38:18 +01:00
|
|
|
static struct msxmlsupported_data_t mxattributes_support_data[] =
|
|
|
|
{
|
2012-04-15 11:47:30 +02:00
|
|
|
{ &CLSID_SAXAttributes, "SAXAttributes" },
|
2012-02-24 15:38:18 +01:00
|
|
|
{ &CLSID_SAXAttributes30, "SAXAttributes30" },
|
|
|
|
{ &CLSID_SAXAttributes40, "SAXAttributes40" },
|
|
|
|
{ &CLSID_SAXAttributes60, "SAXAttributes60" },
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
2011-08-26 06:09:31 +02:00
|
|
|
struct mxwriter_props_t
|
|
|
|
{
|
|
|
|
const GUID *clsid;
|
|
|
|
VARIANT_BOOL bom;
|
|
|
|
VARIANT_BOOL disable_escape;
|
|
|
|
VARIANT_BOOL indent;
|
|
|
|
VARIANT_BOOL omitdecl;
|
|
|
|
VARIANT_BOOL standalone;
|
|
|
|
const char *encoding;
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct mxwriter_props_t mxwriter_default_props[] =
|
|
|
|
{
|
|
|
|
{ &CLSID_MXXMLWriter, VARIANT_TRUE, VARIANT_FALSE, VARIANT_FALSE, VARIANT_FALSE, VARIANT_FALSE, "UTF-16" },
|
|
|
|
{ &CLSID_MXXMLWriter30, VARIANT_TRUE, VARIANT_FALSE, VARIANT_FALSE, VARIANT_FALSE, VARIANT_FALSE, "UTF-16" },
|
|
|
|
{ &CLSID_MXXMLWriter40, VARIANT_TRUE, VARIANT_FALSE, VARIANT_FALSE, VARIANT_FALSE, VARIANT_FALSE, "UTF-16" },
|
|
|
|
{ &CLSID_MXXMLWriter60, VARIANT_TRUE, VARIANT_FALSE, VARIANT_FALSE, VARIANT_FALSE, VARIANT_FALSE, "UTF-16" },
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static void test_mxwriter_default_properties(const struct mxwriter_props_t *table)
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
while (table->clsid)
|
|
|
|
{
|
|
|
|
IMXWriter *writer;
|
|
|
|
VARIANT_BOOL b;
|
|
|
|
BSTR encoding;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2012-02-24 15:38:18 +01:00
|
|
|
if (!is_clsid_supported(table->clsid, mxwriter_support_data))
|
2011-08-26 06:09:31 +02:00
|
|
|
{
|
|
|
|
table++;
|
|
|
|
i++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = CoCreateInstance(table->clsid, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IMXWriter, (void**)&writer);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
b = !table->bom;
|
|
|
|
hr = IMXWriter_get_byteOrderMark(writer, &b);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(table->bom == b, "test %d: got BOM %d, expected %d\n", i, b, table->bom);
|
|
|
|
|
|
|
|
b = !table->disable_escape;
|
|
|
|
hr = IMXWriter_get_disableOutputEscaping(writer, &b);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(table->disable_escape == b, "test %d: got disable escape %d, expected %d\n", i, b,
|
|
|
|
table->disable_escape);
|
|
|
|
|
|
|
|
b = !table->indent;
|
|
|
|
hr = IMXWriter_get_indent(writer, &b);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(table->indent == b, "test %d: got indent %d, expected %d\n", i, b, table->indent);
|
|
|
|
|
|
|
|
b = !table->omitdecl;
|
|
|
|
hr = IMXWriter_get_omitXMLDeclaration(writer, &b);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(table->omitdecl == b, "test %d: got omitdecl %d, expected %d\n", i, b, table->omitdecl);
|
|
|
|
|
|
|
|
b = !table->standalone;
|
|
|
|
hr = IMXWriter_get_standalone(writer, &b);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(table->standalone == b, "test %d: got standalone %d, expected %d\n", i, b, table->standalone);
|
|
|
|
|
|
|
|
hr = IMXWriter_get_encoding(writer, &encoding);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(!lstrcmpW(encoding, _bstr_(table->encoding)), "test %d: got encoding %s, expected %s\n",
|
|
|
|
i, wine_dbgstr_w(encoding), table->encoding);
|
|
|
|
SysFreeString(encoding);
|
|
|
|
|
|
|
|
IMXWriter_Release(writer);
|
|
|
|
|
|
|
|
table++;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-30 13:36:37 +02:00
|
|
|
static void test_mxwriter_properties(void)
|
|
|
|
{
|
2011-05-01 10:54:09 +02:00
|
|
|
static const WCHAR utf16W[] = {'U','T','F','-','1','6',0};
|
|
|
|
static const WCHAR testW[] = {'t','e','s','t',0};
|
2011-12-16 00:36:53 +01:00
|
|
|
ISAXContentHandler *content;
|
2011-04-30 13:36:37 +02:00
|
|
|
IMXWriter *writer;
|
|
|
|
VARIANT_BOOL b;
|
|
|
|
HRESULT hr;
|
2011-05-01 10:54:09 +02:00
|
|
|
BSTR str, str2;
|
2011-12-16 00:36:53 +01:00
|
|
|
VARIANT dest;
|
2011-04-30 13:36:37 +02:00
|
|
|
|
2011-08-26 06:09:31 +02:00
|
|
|
test_mxwriter_default_properties(mxwriter_default_props);
|
|
|
|
|
2011-04-30 13:36:37 +02:00
|
|
|
hr = CoCreateInstance(&CLSID_MXXMLWriter, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IMXWriter, (void**)&writer);
|
|
|
|
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
|
|
|
|
2011-05-07 20:15:33 +02:00
|
|
|
hr = IMXWriter_get_disableOutputEscaping(writer, NULL);
|
|
|
|
ok(hr == E_POINTER, "got %08x\n", hr);
|
|
|
|
|
2011-05-07 19:57:45 +02:00
|
|
|
hr = IMXWriter_get_byteOrderMark(writer, NULL);
|
|
|
|
ok(hr == E_POINTER, "got %08x\n", hr);
|
|
|
|
|
2011-05-07 18:53:33 +02:00
|
|
|
hr = IMXWriter_get_indent(writer, NULL);
|
|
|
|
ok(hr == E_POINTER, "got %08x\n", hr);
|
|
|
|
|
2011-05-04 09:10:34 +02:00
|
|
|
hr = IMXWriter_get_omitXMLDeclaration(writer, NULL);
|
|
|
|
ok(hr == E_POINTER, "got %08x\n", hr);
|
|
|
|
|
2011-04-30 13:36:37 +02:00
|
|
|
hr = IMXWriter_get_standalone(writer, NULL);
|
|
|
|
ok(hr == E_POINTER, "got %08x\n", hr);
|
|
|
|
|
|
|
|
/* set and check */
|
|
|
|
hr = IMXWriter_put_standalone(writer, VARIANT_TRUE);
|
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
|
|
|
|
|
|
|
b = VARIANT_FALSE;
|
|
|
|
hr = IMXWriter_get_standalone(writer, &b);
|
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
|
|
|
ok(b == VARIANT_TRUE, "got %d\n", b);
|
|
|
|
|
2011-05-01 10:54:09 +02:00
|
|
|
hr = IMXWriter_get_encoding(writer, NULL);
|
2011-12-16 00:36:53 +01:00
|
|
|
EXPECT_HR(hr, E_POINTER);
|
2011-05-01 10:54:09 +02:00
|
|
|
|
|
|
|
/* UTF-16 is a default setting apparently */
|
|
|
|
str = (void*)0xdeadbeef;
|
|
|
|
hr = IMXWriter_get_encoding(writer, &str);
|
2011-12-16 00:36:53 +01:00
|
|
|
EXPECT_HR(hr, S_OK);
|
2011-05-01 10:54:09 +02:00
|
|
|
ok(lstrcmpW(str, utf16W) == 0, "expected empty string, got %s\n", wine_dbgstr_w(str));
|
|
|
|
|
|
|
|
str2 = (void*)0xdeadbeef;
|
|
|
|
hr = IMXWriter_get_encoding(writer, &str2);
|
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
|
|
|
ok(str != str2, "expected newly allocated, got same %p\n", str);
|
|
|
|
|
|
|
|
SysFreeString(str2);
|
|
|
|
SysFreeString(str);
|
|
|
|
|
|
|
|
/* put empty string */
|
|
|
|
str = SysAllocString(emptyW);
|
|
|
|
hr = IMXWriter_put_encoding(writer, str);
|
|
|
|
ok(hr == E_INVALIDARG, "got %08x\n", hr);
|
|
|
|
SysFreeString(str);
|
|
|
|
|
|
|
|
str = (void*)0xdeadbeef;
|
|
|
|
hr = IMXWriter_get_encoding(writer, &str);
|
2011-12-16 00:36:53 +01:00
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(!lstrcmpW(str, _bstr_("UTF-16")), "got %s\n", wine_dbgstr_w(str));
|
2011-07-15 14:38:20 +02:00
|
|
|
SysFreeString(str);
|
2011-05-01 10:54:09 +02:00
|
|
|
|
|
|
|
/* invalid encoding name */
|
|
|
|
str = SysAllocString(testW);
|
|
|
|
hr = IMXWriter_put_encoding(writer, str);
|
|
|
|
ok(hr == E_INVALIDARG, "got %08x\n", hr);
|
|
|
|
SysFreeString(str);
|
|
|
|
|
2011-12-16 00:36:53 +01:00
|
|
|
/* test case sensivity */
|
|
|
|
hr = IMXWriter_put_encoding(writer, _bstr_("utf-8"));
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
str = (void*)0xdeadbeef;
|
|
|
|
hr = IMXWriter_get_encoding(writer, &str);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(!lstrcmpW(str, _bstr_("utf-8")), "got %s\n", wine_dbgstr_w(str));
|
|
|
|
SysFreeString(str);
|
|
|
|
|
|
|
|
hr = IMXWriter_put_encoding(writer, _bstr_("uTf-16"));
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
str = (void*)0xdeadbeef;
|
|
|
|
hr = IMXWriter_get_encoding(writer, &str);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(!lstrcmpW(str, _bstr_("uTf-16")), "got %s\n", wine_dbgstr_w(str));
|
|
|
|
SysFreeString(str);
|
|
|
|
|
|
|
|
/* how it affects document creation */
|
|
|
|
hr = IMXWriter_QueryInterface(writer, &IID_ISAXContentHandler, (void**)&content);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_startDocument(content);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
hr = ISAXContentHandler_endDocument(content);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_get_output(writer, &dest);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest));
|
|
|
|
ok(!lstrcmpW(_bstr_("<?xml version=\"1.0\" encoding=\"UTF-16\" standalone=\"yes\"?>\r\n"),
|
|
|
|
V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest)));
|
|
|
|
VariantClear(&dest);
|
|
|
|
ISAXContentHandler_Release(content);
|
|
|
|
|
2011-05-01 18:05:31 +02:00
|
|
|
hr = IMXWriter_get_version(writer, NULL);
|
|
|
|
ok(hr == E_POINTER, "got %08x\n", hr);
|
|
|
|
/* default version is 'surprisingly' 1.0 */
|
|
|
|
hr = IMXWriter_get_version(writer, &str);
|
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
|
|
|
ok(!lstrcmpW(str, _bstr_("1.0")), "got %s\n", wine_dbgstr_w(str));
|
2011-07-15 14:38:20 +02:00
|
|
|
SysFreeString(str);
|
2011-05-01 18:05:31 +02:00
|
|
|
|
2011-08-24 11:25:29 +02:00
|
|
|
/* store version string as is */
|
|
|
|
hr = IMXWriter_put_version(writer, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "got %08x\n", hr);
|
|
|
|
|
|
|
|
hr = IMXWriter_put_version(writer, _bstr_("1.0"));
|
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
|
|
|
|
|
|
|
hr = IMXWriter_put_version(writer, _bstr_(""));
|
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
|
|
|
hr = IMXWriter_get_version(writer, &str);
|
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
|
|
|
ok(!lstrcmpW(str, _bstr_("")), "got %s\n", wine_dbgstr_w(str));
|
|
|
|
SysFreeString(str);
|
|
|
|
|
|
|
|
hr = IMXWriter_put_version(writer, _bstr_("a.b"));
|
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
|
|
|
hr = IMXWriter_get_version(writer, &str);
|
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
|
|
|
ok(!lstrcmpW(str, _bstr_("a.b")), "got %s\n", wine_dbgstr_w(str));
|
|
|
|
SysFreeString(str);
|
|
|
|
|
|
|
|
hr = IMXWriter_put_version(writer, _bstr_("2.0"));
|
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
|
|
|
hr = IMXWriter_get_version(writer, &str);
|
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
|
|
|
ok(!lstrcmpW(str, _bstr_("2.0")), "got %s\n", wine_dbgstr_w(str));
|
|
|
|
SysFreeString(str);
|
|
|
|
|
2011-04-30 13:36:37 +02:00
|
|
|
IMXWriter_Release(writer);
|
2011-05-01 18:05:31 +02:00
|
|
|
free_bstrs();
|
2011-04-30 13:36:37 +02:00
|
|
|
}
|
|
|
|
|
2011-05-01 10:04:59 +02:00
|
|
|
static void test_mxwriter_flush(void)
|
|
|
|
{
|
|
|
|
ISAXContentHandler *content;
|
|
|
|
IMXWriter *writer;
|
|
|
|
LARGE_INTEGER pos;
|
|
|
|
ULARGE_INTEGER pos2;
|
|
|
|
IStream *stream;
|
|
|
|
VARIANT dest;
|
|
|
|
HRESULT hr;
|
2012-05-19 12:43:56 +02:00
|
|
|
char *buff;
|
2012-06-22 20:36:04 +02:00
|
|
|
LONG ref;
|
2012-06-22 22:38:12 +02:00
|
|
|
int len;
|
2011-05-01 10:04:59 +02:00
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_MXXMLWriter, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IMXWriter, (void**)&writer);
|
|
|
|
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
|
|
|
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
|
|
|
|
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
|
|
|
EXPECT_REF(stream, 1);
|
|
|
|
|
2011-08-03 23:50:18 +02:00
|
|
|
/* detach when nothing was attached */
|
2011-05-01 10:04:59 +02:00
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_put_output(writer, dest);
|
|
|
|
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
|
|
|
|
|
|
|
/* attach stream */
|
|
|
|
V_VT(&dest) = VT_UNKNOWN;
|
|
|
|
V_UNKNOWN(&dest) = (IUnknown*)stream;
|
|
|
|
hr = IMXWriter_put_output(writer, dest);
|
|
|
|
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
|
|
|
todo_wine EXPECT_REF(stream, 3);
|
|
|
|
|
|
|
|
/* detach setting VT_EMPTY destination */
|
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_put_output(writer, dest);
|
|
|
|
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
|
|
|
EXPECT_REF(stream, 1);
|
|
|
|
|
|
|
|
V_VT(&dest) = VT_UNKNOWN;
|
|
|
|
V_UNKNOWN(&dest) = (IUnknown*)stream;
|
|
|
|
hr = IMXWriter_put_output(writer, dest);
|
|
|
|
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
|
|
|
|
|
|
|
/* flush() doesn't detach a stream */
|
|
|
|
hr = IMXWriter_flush(writer);
|
|
|
|
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
2011-08-13 01:11:08 +02:00
|
|
|
todo_wine EXPECT_REF(stream, 3);
|
2011-05-01 10:04:59 +02:00
|
|
|
|
|
|
|
pos.QuadPart = 0;
|
|
|
|
hr = IStream_Seek(stream, pos, STREAM_SEEK_CUR, &pos2);
|
|
|
|
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
2011-08-24 23:32:16 +02:00
|
|
|
ok(pos2.QuadPart == 0, "expected stream beginning\n");
|
2011-05-01 10:04:59 +02:00
|
|
|
|
|
|
|
hr = IMXWriter_QueryInterface(writer, &IID_ISAXContentHandler, (void**)&content);
|
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_startDocument(content);
|
2011-05-01 18:05:31 +02:00
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
2011-05-01 10:04:59 +02:00
|
|
|
|
|
|
|
pos.QuadPart = 0;
|
|
|
|
hr = IStream_Seek(stream, pos, STREAM_SEEK_CUR, &pos2);
|
|
|
|
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
2011-08-13 01:11:08 +02:00
|
|
|
ok(pos2.QuadPart != 0, "expected stream beginning\n");
|
2011-05-01 10:04:59 +02:00
|
|
|
|
|
|
|
/* already started */
|
|
|
|
hr = ISAXContentHandler_startDocument(content);
|
2011-05-01 18:05:31 +02:00
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
2011-05-01 10:04:59 +02:00
|
|
|
|
|
|
|
hr = ISAXContentHandler_endDocument(content);
|
2011-08-13 01:11:08 +02:00
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
2011-05-01 10:04:59 +02:00
|
|
|
|
|
|
|
/* flushed on endDocument() */
|
|
|
|
pos.QuadPart = 0;
|
|
|
|
hr = IStream_Seek(stream, pos, STREAM_SEEK_CUR, &pos2);
|
|
|
|
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
2011-08-13 01:11:08 +02:00
|
|
|
ok(pos2.QuadPart != 0, "expected stream position moved\n");
|
2011-05-01 10:04:59 +02:00
|
|
|
|
2012-05-19 12:43:56 +02:00
|
|
|
IStream_Release(stream);
|
|
|
|
|
|
|
|
/* auto-flush feature */
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
EXPECT_REF(stream, 1);
|
|
|
|
|
|
|
|
V_VT(&dest) = VT_UNKNOWN;
|
|
|
|
V_UNKNOWN(&dest) = (IUnknown*)stream;
|
|
|
|
hr = IMXWriter_put_output(writer, dest);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = IMXWriter_put_byteOrderMark(writer, VARIANT_FALSE);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = IMXWriter_put_omitXMLDeclaration(writer, VARIANT_TRUE);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_startDocument(content);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_startElement(content, emptyW, 0, emptyW, 0, _bstr_("a"), -1, NULL);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
/* internal buffer is flushed automatically on certain threshold */
|
|
|
|
pos.QuadPart = 0;
|
|
|
|
pos2.QuadPart = 1;
|
|
|
|
hr = IStream_Seek(stream, pos, STREAM_SEEK_CUR, &pos2);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(pos2.QuadPart == 0, "expected stream beginning\n");
|
|
|
|
|
2012-06-22 22:38:12 +02:00
|
|
|
len = 2048;
|
2014-05-04 18:33:18 +02:00
|
|
|
buff = HeapAlloc(GetProcessHeap(), 0, len+1);
|
2012-06-22 22:38:12 +02:00
|
|
|
memset(buff, 'A', len);
|
2014-05-04 18:33:18 +02:00
|
|
|
buff[len] = 0;
|
2012-06-22 22:38:12 +02:00
|
|
|
hr = ISAXContentHandler_characters(content, _bstr_(buff), len);
|
2012-05-19 12:43:56 +02:00
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
pos.QuadPart = 0;
|
|
|
|
pos2.QuadPart = 0;
|
|
|
|
hr = IStream_Seek(stream, pos, STREAM_SEEK_CUR, &pos2);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
todo_wine
|
|
|
|
ok(pos2.QuadPart != 0, "unexpected stream beginning\n");
|
|
|
|
|
2012-06-22 20:36:04 +02:00
|
|
|
hr = IMXWriter_get_output(writer, NULL);
|
|
|
|
EXPECT_HR(hr, E_POINTER);
|
|
|
|
|
|
|
|
ref = get_refcount(stream);
|
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_get_output(writer, &dest);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(V_VT(&dest) == VT_UNKNOWN, "got vt type %d\n", V_VT(&dest));
|
|
|
|
ok(V_UNKNOWN(&dest) == (IUnknown*)stream, "got pointer %p\n", V_UNKNOWN(&dest));
|
|
|
|
ok(ref+1 == get_refcount(stream), "expected increased refcount\n");
|
|
|
|
VariantClear(&dest);
|
|
|
|
|
2012-05-19 12:43:56 +02:00
|
|
|
hr = ISAXContentHandler_endDocument(content);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
IStream_Release(stream);
|
|
|
|
|
|
|
|
/* test char count lower than threshold */
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
EXPECT_REF(stream, 1);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_startDocument(content);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_startElement(content, emptyW, 0, emptyW, 0, _bstr_("a"), -1, NULL);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
pos.QuadPart = 0;
|
|
|
|
pos2.QuadPart = 1;
|
|
|
|
hr = IStream_Seek(stream, pos, STREAM_SEEK_CUR, &pos2);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(pos2.QuadPart == 0, "expected stream beginning\n");
|
|
|
|
|
2012-06-22 22:38:12 +02:00
|
|
|
memset(buff, 'A', len);
|
2014-05-04 18:33:18 +02:00
|
|
|
buff[len] = 0;
|
2012-06-22 22:38:12 +02:00
|
|
|
hr = ISAXContentHandler_characters(content, _bstr_(buff), len - 8);
|
2012-05-19 12:43:56 +02:00
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
pos.QuadPart = 0;
|
|
|
|
pos2.QuadPart = 1;
|
|
|
|
hr = IStream_Seek(stream, pos, STREAM_SEEK_CUR, &pos2);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(pos2.QuadPart == 0, "expected stream beginning\n");
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_endDocument(content);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
2012-06-22 22:38:12 +02:00
|
|
|
/* test auto-flush function when stream is not set */
|
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_put_output(writer, dest);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_startDocument(content);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_startElement(content, emptyW, 0, emptyW, 0, _bstr_("a"), -1, NULL);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
memset(buff, 'A', len);
|
2014-05-04 18:33:18 +02:00
|
|
|
buff[len] = 0;
|
2012-06-22 22:38:12 +02:00
|
|
|
hr = ISAXContentHandler_characters(content, _bstr_(buff), len);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_get_output(writer, &dest);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
len += strlen("<a>");
|
|
|
|
ok(SysStringLen(V_BSTR(&dest)) == len, "got len=%d, expected %d\n", SysStringLen(V_BSTR(&dest)), len);
|
|
|
|
VariantClear(&dest);
|
|
|
|
|
2012-05-19 12:43:56 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, buff);
|
2011-05-01 10:04:59 +02:00
|
|
|
ISAXContentHandler_Release(content);
|
|
|
|
IStream_Release(stream);
|
|
|
|
IMXWriter_Release(writer);
|
2012-05-19 12:43:56 +02:00
|
|
|
free_bstrs();
|
2011-05-01 10:04:59 +02:00
|
|
|
}
|
|
|
|
|
2011-05-01 18:05:31 +02:00
|
|
|
static void test_mxwriter_startenddocument(void)
|
|
|
|
{
|
|
|
|
ISAXContentHandler *content;
|
|
|
|
IMXWriter *writer;
|
|
|
|
VARIANT dest;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_MXXMLWriter, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IMXWriter, (void**)&writer);
|
|
|
|
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
|
|
|
|
|
|
|
hr = IMXWriter_QueryInterface(writer, &IID_ISAXContentHandler, (void**)&content);
|
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_startDocument(content);
|
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_endDocument(content);
|
2011-08-13 01:11:08 +02:00
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
2011-05-01 18:05:31 +02:00
|
|
|
|
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_get_output(writer, &dest);
|
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
|
|
|
ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest));
|
|
|
|
ok(!lstrcmpW(_bstr_("<?xml version=\"1.0\" encoding=\"UTF-16\" standalone=\"no\"?>\r\n"), V_BSTR(&dest)),
|
|
|
|
"got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest)));
|
|
|
|
VariantClear(&dest);
|
|
|
|
|
|
|
|
/* now try another startDocument */
|
|
|
|
hr = ISAXContentHandler_startDocument(content);
|
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
2011-08-03 23:50:18 +02:00
|
|
|
/* and get duplicated prolog */
|
2011-05-01 18:05:31 +02:00
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_get_output(writer, &dest);
|
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
|
|
|
ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest));
|
|
|
|
ok(!lstrcmpW(_bstr_("<?xml version=\"1.0\" encoding=\"UTF-16\" standalone=\"no\"?>\r\n"
|
|
|
|
"<?xml version=\"1.0\" encoding=\"UTF-16\" standalone=\"no\"?>\r\n"), V_BSTR(&dest)),
|
|
|
|
"got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest)));
|
|
|
|
VariantClear(&dest);
|
|
|
|
|
|
|
|
ISAXContentHandler_Release(content);
|
|
|
|
IMXWriter_Release(writer);
|
2011-05-04 09:10:34 +02:00
|
|
|
|
|
|
|
/* now with omitted declaration */
|
|
|
|
hr = CoCreateInstance(&CLSID_MXXMLWriter, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IMXWriter, (void**)&writer);
|
|
|
|
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
|
|
|
|
|
|
|
hr = IMXWriter_QueryInterface(writer, &IID_ISAXContentHandler, (void**)&content);
|
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
|
|
|
|
|
|
|
hr = IMXWriter_put_omitXMLDeclaration(writer, VARIANT_TRUE);
|
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_startDocument(content);
|
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_endDocument(content);
|
2011-08-13 01:11:08 +02:00
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
2011-05-04 09:10:34 +02:00
|
|
|
|
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_get_output(writer, &dest);
|
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
|
|
|
ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest));
|
|
|
|
ok(!lstrcmpW(_bstr_(""), V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest)));
|
|
|
|
VariantClear(&dest);
|
|
|
|
|
|
|
|
ISAXContentHandler_Release(content);
|
|
|
|
IMXWriter_Release(writer);
|
|
|
|
|
2011-05-01 18:05:31 +02:00
|
|
|
free_bstrs();
|
|
|
|
}
|
|
|
|
|
2011-08-25 13:32:27 +02:00
|
|
|
enum startendtype
|
|
|
|
{
|
2012-04-26 18:40:53 +02:00
|
|
|
StartElement = 0x001,
|
|
|
|
EndElement = 0x010,
|
|
|
|
StartEndElement = 0x011,
|
|
|
|
DisableEscaping = 0x100
|
2011-08-25 13:32:27 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct writer_startendelement_t {
|
2011-08-25 13:31:02 +02:00
|
|
|
const GUID *clsid;
|
2011-08-25 13:32:27 +02:00
|
|
|
enum startendtype type;
|
2011-08-25 13:31:02 +02:00
|
|
|
const char *uri;
|
|
|
|
const char *local_name;
|
|
|
|
const char *qname;
|
|
|
|
const char *output;
|
|
|
|
HRESULT hr;
|
2011-08-25 22:28:23 +02:00
|
|
|
ISAXAttributes *attr;
|
2011-08-25 13:31:02 +02:00
|
|
|
};
|
|
|
|
|
2013-08-20 10:49:54 +02:00
|
|
|
static const char startelement_xml[] = "<uri:local a:attr1=\"a1\" attr2=\"a2\" attr3=\"<&">\'\">";
|
|
|
|
static const char startendelement_xml[] = "<uri:local a:attr1=\"a1\" attr2=\"a2\" attr3=\"<&">\'\"/>";
|
|
|
|
static const char startendelement_noescape_xml[] = "<uri:local a:attr1=\"a1\" attr2=\"a2\" attr3=\"<&\">\'\"/>";
|
2011-12-11 00:32:51 +01:00
|
|
|
|
2011-08-25 13:32:27 +02:00
|
|
|
static const struct writer_startendelement_t writer_startendelement[] = {
|
2011-08-25 13:31:02 +02:00
|
|
|
/* 0 */
|
2011-08-25 13:32:27 +02:00
|
|
|
{ &CLSID_MXXMLWriter, StartElement, NULL, NULL, NULL, NULL, E_INVALIDARG },
|
|
|
|
{ &CLSID_MXXMLWriter30, StartElement, NULL, NULL, NULL, NULL, E_INVALIDARG },
|
|
|
|
{ &CLSID_MXXMLWriter40, StartElement, NULL, NULL, NULL, NULL, E_INVALIDARG },
|
|
|
|
{ &CLSID_MXXMLWriter60, StartElement, NULL, NULL, NULL, "<>", S_OK },
|
|
|
|
{ &CLSID_MXXMLWriter, StartElement, "uri", NULL, NULL, NULL, E_INVALIDARG },
|
2011-08-25 13:31:02 +02:00
|
|
|
/* 5 */
|
2011-08-25 13:32:27 +02:00
|
|
|
{ &CLSID_MXXMLWriter30, StartElement, "uri", NULL, NULL, NULL, E_INVALIDARG },
|
|
|
|
{ &CLSID_MXXMLWriter40, StartElement, "uri", NULL, NULL, NULL, E_INVALIDARG },
|
|
|
|
{ &CLSID_MXXMLWriter60, StartElement, "uri", NULL, NULL, "<>", S_OK },
|
|
|
|
{ &CLSID_MXXMLWriter, StartElement, NULL, "local", NULL, NULL, E_INVALIDARG },
|
|
|
|
{ &CLSID_MXXMLWriter30, StartElement, NULL, "local", NULL, NULL, E_INVALIDARG },
|
2011-08-25 13:31:02 +02:00
|
|
|
/* 10 */
|
2011-08-25 13:32:27 +02:00
|
|
|
{ &CLSID_MXXMLWriter40, StartElement, NULL, "local", NULL, NULL, E_INVALIDARG },
|
|
|
|
{ &CLSID_MXXMLWriter60, StartElement, NULL, "local", NULL, "<>", S_OK },
|
|
|
|
{ &CLSID_MXXMLWriter, StartElement, NULL, NULL, "qname", NULL, E_INVALIDARG },
|
|
|
|
{ &CLSID_MXXMLWriter30, StartElement, NULL, NULL, "qname", NULL, E_INVALIDARG },
|
|
|
|
{ &CLSID_MXXMLWriter40, StartElement, NULL, NULL, "qname", NULL, E_INVALIDARG },
|
2011-08-25 13:31:02 +02:00
|
|
|
/* 15 */
|
2011-08-25 13:32:27 +02:00
|
|
|
{ &CLSID_MXXMLWriter60, StartElement, NULL, NULL, "qname", "<qname>", S_OK },
|
|
|
|
{ &CLSID_MXXMLWriter, StartElement, "uri", "local", "qname", "<qname>", S_OK },
|
|
|
|
{ &CLSID_MXXMLWriter30, StartElement, "uri", "local", "qname", "<qname>", S_OK },
|
|
|
|
{ &CLSID_MXXMLWriter40, StartElement, "uri", "local", "qname", "<qname>", S_OK },
|
|
|
|
{ &CLSID_MXXMLWriter60, StartElement, "uri", "local", "qname", "<qname>", S_OK },
|
2011-08-25 13:31:02 +02:00
|
|
|
/* 20 */
|
2011-08-25 13:32:27 +02:00
|
|
|
{ &CLSID_MXXMLWriter, StartElement, "uri", "local", NULL, NULL, E_INVALIDARG },
|
|
|
|
{ &CLSID_MXXMLWriter30, StartElement, "uri", "local", NULL, NULL, E_INVALIDARG },
|
|
|
|
{ &CLSID_MXXMLWriter40, StartElement, "uri", "local", NULL, NULL, E_INVALIDARG },
|
|
|
|
{ &CLSID_MXXMLWriter60, StartElement, "uri", "local", NULL, "<>", S_OK },
|
|
|
|
{ &CLSID_MXXMLWriter, StartElement, "uri", "local", "uri:local", "<uri:local>", S_OK },
|
2011-08-25 13:31:02 +02:00
|
|
|
/* 25 */
|
2011-08-25 13:32:27 +02:00
|
|
|
{ &CLSID_MXXMLWriter30, StartElement, "uri", "local", "uri:local", "<uri:local>", S_OK },
|
|
|
|
{ &CLSID_MXXMLWriter40, StartElement, "uri", "local", "uri:local", "<uri:local>", S_OK },
|
|
|
|
{ &CLSID_MXXMLWriter60, StartElement, "uri", "local", "uri:local", "<uri:local>", S_OK },
|
|
|
|
{ &CLSID_MXXMLWriter, StartElement, "uri", "local", "uri:local2", "<uri:local2>", S_OK },
|
|
|
|
{ &CLSID_MXXMLWriter30, StartElement, "uri", "local", "uri:local2", "<uri:local2>", S_OK },
|
2011-08-25 13:31:02 +02:00
|
|
|
/* 30 */
|
2011-08-25 13:32:27 +02:00
|
|
|
{ &CLSID_MXXMLWriter40, StartElement, "uri", "local", "uri:local2", "<uri:local2>", S_OK },
|
|
|
|
{ &CLSID_MXXMLWriter60, StartElement, "uri", "local", "uri:local2", "<uri:local2>", S_OK },
|
|
|
|
/* endElement tests */
|
|
|
|
{ &CLSID_MXXMLWriter, EndElement, NULL, NULL, NULL, NULL, E_INVALIDARG },
|
|
|
|
{ &CLSID_MXXMLWriter30, EndElement, NULL, NULL, NULL, NULL, E_INVALIDARG },
|
|
|
|
{ &CLSID_MXXMLWriter40, EndElement, NULL, NULL, NULL, NULL, E_INVALIDARG },
|
|
|
|
/* 35 */
|
|
|
|
{ &CLSID_MXXMLWriter60, EndElement, NULL, NULL, NULL, "</>", S_OK },
|
|
|
|
{ &CLSID_MXXMLWriter, EndElement, "uri", NULL, NULL, NULL, E_INVALIDARG },
|
|
|
|
{ &CLSID_MXXMLWriter30, EndElement, "uri", NULL, NULL, NULL, E_INVALIDARG },
|
|
|
|
{ &CLSID_MXXMLWriter40, EndElement, "uri", NULL, NULL, NULL, E_INVALIDARG },
|
|
|
|
{ &CLSID_MXXMLWriter60, EndElement, "uri", NULL, NULL, "</>", S_OK },
|
|
|
|
/* 40 */
|
|
|
|
{ &CLSID_MXXMLWriter, EndElement, NULL, "local", NULL, NULL, E_INVALIDARG },
|
|
|
|
{ &CLSID_MXXMLWriter30, EndElement, NULL, "local", NULL, NULL, E_INVALIDARG },
|
|
|
|
{ &CLSID_MXXMLWriter40, EndElement, NULL, "local", NULL, NULL, E_INVALIDARG },
|
|
|
|
{ &CLSID_MXXMLWriter60, EndElement, NULL, "local", NULL, "</>", S_OK },
|
|
|
|
{ &CLSID_MXXMLWriter, EndElement, NULL, NULL, "qname", NULL, E_INVALIDARG },
|
|
|
|
/* 45 */
|
|
|
|
{ &CLSID_MXXMLWriter30, EndElement, NULL, NULL, "qname", NULL, E_INVALIDARG },
|
|
|
|
{ &CLSID_MXXMLWriter40, EndElement, NULL, NULL, "qname", NULL, E_INVALIDARG },
|
|
|
|
{ &CLSID_MXXMLWriter60, EndElement, NULL, NULL, "qname", "</qname>", S_OK },
|
|
|
|
{ &CLSID_MXXMLWriter, EndElement, "uri", "local", "qname", "</qname>", S_OK },
|
|
|
|
{ &CLSID_MXXMLWriter30, EndElement, "uri", "local", "qname", "</qname>", S_OK },
|
|
|
|
/* 50 */
|
|
|
|
{ &CLSID_MXXMLWriter40, EndElement, "uri", "local", "qname", "</qname>", S_OK },
|
|
|
|
{ &CLSID_MXXMLWriter60, EndElement, "uri", "local", "qname", "</qname>", S_OK },
|
|
|
|
{ &CLSID_MXXMLWriter, EndElement, "uri", "local", NULL, NULL, E_INVALIDARG },
|
|
|
|
{ &CLSID_MXXMLWriter30, EndElement, "uri", "local", NULL, NULL, E_INVALIDARG },
|
|
|
|
{ &CLSID_MXXMLWriter40, EndElement, "uri", "local", NULL, NULL, E_INVALIDARG },
|
|
|
|
/* 55 */
|
|
|
|
{ &CLSID_MXXMLWriter60, EndElement, "uri", "local", NULL, "</>", S_OK },
|
|
|
|
{ &CLSID_MXXMLWriter, EndElement, "uri", "local", "uri:local", "</uri:local>", S_OK },
|
|
|
|
{ &CLSID_MXXMLWriter30, EndElement, "uri", "local", "uri:local", "</uri:local>", S_OK },
|
|
|
|
{ &CLSID_MXXMLWriter40, EndElement, "uri", "local", "uri:local", "</uri:local>", S_OK },
|
|
|
|
{ &CLSID_MXXMLWriter60, EndElement, "uri", "local", "uri:local", "</uri:local>", S_OK },
|
|
|
|
/* 60 */
|
|
|
|
{ &CLSID_MXXMLWriter, EndElement, "uri", "local", "uri:local2", "</uri:local2>", S_OK },
|
|
|
|
{ &CLSID_MXXMLWriter30, EndElement, "uri", "local", "uri:local2", "</uri:local2>", S_OK },
|
|
|
|
{ &CLSID_MXXMLWriter40, EndElement, "uri", "local", "uri:local2", "</uri:local2>", S_OK },
|
|
|
|
{ &CLSID_MXXMLWriter60, EndElement, "uri", "local", "uri:local2", "</uri:local2>", S_OK },
|
2011-08-25 22:28:23 +02:00
|
|
|
|
|
|
|
/* with attributes */
|
2011-12-11 00:32:51 +01:00
|
|
|
{ &CLSID_MXXMLWriter, StartElement, "uri", "local", "uri:local", startelement_xml, S_OK, &saxattributes },
|
2011-08-25 22:28:23 +02:00
|
|
|
/* 65 */
|
2011-12-11 00:32:51 +01:00
|
|
|
{ &CLSID_MXXMLWriter30, StartElement, "uri", "local", "uri:local", startelement_xml, S_OK, &saxattributes },
|
|
|
|
{ &CLSID_MXXMLWriter40, StartElement, "uri", "local", "uri:local", startelement_xml, S_OK, &saxattributes },
|
|
|
|
{ &CLSID_MXXMLWriter60, StartElement, "uri", "local", "uri:local", startelement_xml, S_OK, &saxattributes },
|
2011-08-27 12:19:22 +02:00
|
|
|
/* empty elements */
|
2011-12-11 00:32:51 +01:00
|
|
|
{ &CLSID_MXXMLWriter, StartEndElement, "uri", "local", "uri:local", startendelement_xml, S_OK, &saxattributes },
|
|
|
|
{ &CLSID_MXXMLWriter30, StartEndElement, "uri", "local", "uri:local", startendelement_xml, S_OK, &saxattributes },
|
2011-08-27 12:19:22 +02:00
|
|
|
/* 70 */
|
2011-12-11 00:32:51 +01:00
|
|
|
{ &CLSID_MXXMLWriter40, StartEndElement, "uri", "local", "uri:local", startendelement_xml, S_OK, &saxattributes },
|
|
|
|
{ &CLSID_MXXMLWriter60, StartEndElement, "uri", "local", "uri:local", startendelement_xml, S_OK, &saxattributes },
|
2011-08-27 12:19:22 +02:00
|
|
|
{ &CLSID_MXXMLWriter, StartEndElement, "", "", "", "</>", S_OK },
|
|
|
|
{ &CLSID_MXXMLWriter30, StartEndElement, "", "", "", "</>", S_OK },
|
|
|
|
{ &CLSID_MXXMLWriter40, StartEndElement, "", "", "", "</>", S_OK },
|
|
|
|
/* 75 */
|
|
|
|
{ &CLSID_MXXMLWriter60, StartEndElement, "", "", "", "</>", S_OK },
|
2012-04-26 18:40:53 +02:00
|
|
|
|
|
|
|
/* with disabled output escaping */
|
|
|
|
{ &CLSID_MXXMLWriter, StartEndElement | DisableEscaping, "uri", "local", "uri:local", startendelement_noescape_xml, S_OK, &saxattributes },
|
|
|
|
{ &CLSID_MXXMLWriter30, StartEndElement | DisableEscaping, "uri", "local", "uri:local", startendelement_noescape_xml, S_OK, &saxattributes },
|
|
|
|
{ &CLSID_MXXMLWriter40, StartEndElement | DisableEscaping, "uri", "local", "uri:local", startendelement_xml, S_OK, &saxattributes },
|
|
|
|
{ &CLSID_MXXMLWriter60, StartEndElement | DisableEscaping, "uri", "local", "uri:local", startendelement_xml, S_OK, &saxattributes },
|
|
|
|
|
2011-08-25 13:31:02 +02:00
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
static void get_class_support_data(struct msxmlsupported_data_t *table, REFIID riid)
|
2011-08-25 13:31:02 +02:00
|
|
|
{
|
|
|
|
while (table->clsid)
|
|
|
|
{
|
2012-04-15 11:47:30 +02:00
|
|
|
IUnknown *unk;
|
2011-08-25 13:31:02 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
hr = CoCreateInstance(table->clsid, NULL, CLSCTX_INPROC_SERVER, riid, (void**)&unk);
|
|
|
|
if (hr == S_OK) IUnknown_Release(unk);
|
2011-08-25 13:31:02 +02:00
|
|
|
|
|
|
|
table->supported = hr == S_OK;
|
|
|
|
if (hr != S_OK) win_skip("class %s not supported\n", table->name);
|
|
|
|
|
|
|
|
table++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-25 13:32:27 +02:00
|
|
|
static void test_mxwriter_startendelement_batch(const struct writer_startendelement_t *table)
|
2011-08-25 13:31:02 +02:00
|
|
|
{
|
2011-08-26 06:09:31 +02:00
|
|
|
int i = 0;
|
2011-08-25 13:31:02 +02:00
|
|
|
|
|
|
|
while (table->clsid)
|
|
|
|
{
|
|
|
|
ISAXContentHandler *content;
|
|
|
|
IMXWriter *writer;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2012-02-24 15:38:18 +01:00
|
|
|
if (!is_clsid_supported(table->clsid, mxwriter_support_data))
|
2011-08-25 13:31:02 +02:00
|
|
|
{
|
|
|
|
table++;
|
|
|
|
i++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = CoCreateInstance(table->clsid, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IMXWriter, (void**)&writer);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = IMXWriter_QueryInterface(writer, &IID_ISAXContentHandler, (void**)&content);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = IMXWriter_put_omitXMLDeclaration(writer, VARIANT_TRUE);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_startDocument(content);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
2012-04-26 18:40:53 +02:00
|
|
|
if (table->type & DisableEscaping)
|
2011-08-27 12:19:22 +02:00
|
|
|
{
|
2012-04-26 18:40:53 +02:00
|
|
|
hr = IMXWriter_put_disableOutputEscaping(writer, VARIANT_TRUE);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
2011-08-27 12:19:22 +02:00
|
|
|
}
|
2012-04-26 18:40:53 +02:00
|
|
|
|
|
|
|
if (table->type & StartElement)
|
2011-08-27 12:19:22 +02:00
|
|
|
{
|
2013-11-16 16:07:21 +01:00
|
|
|
hr = ISAXContentHandler_startElement(content, _bstr_(table->uri), table->uri ? strlen(table->uri) : 0,
|
|
|
|
_bstr_(table->local_name), table->local_name ? strlen(table->local_name) : 0, _bstr_(table->qname),
|
|
|
|
table->qname ? strlen(table->qname) : 0, table->attr);
|
2011-08-27 12:19:22 +02:00
|
|
|
ok(hr == table->hr, "test %d: got 0x%08x, expected 0x%08x\n", i, hr, table->hr);
|
2012-04-26 18:40:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (table->type & EndElement)
|
|
|
|
{
|
2013-11-16 16:07:21 +01:00
|
|
|
hr = ISAXContentHandler_endElement(content, _bstr_(table->uri), table->uri ? strlen(table->uri) : 0,
|
|
|
|
_bstr_(table->local_name), table->local_name ? strlen(table->local_name) : 0, _bstr_(table->qname),
|
|
|
|
table->qname ? strlen(table->qname) : 0);
|
2011-08-27 12:19:22 +02:00
|
|
|
ok(hr == table->hr, "test %d: got 0x%08x, expected 0x%08x\n", i, hr, table->hr);
|
|
|
|
}
|
2011-08-25 13:31:02 +02:00
|
|
|
|
|
|
|
/* test output */
|
|
|
|
if (hr == S_OK)
|
|
|
|
{
|
|
|
|
VARIANT dest;
|
|
|
|
|
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_get_output(writer, &dest);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest));
|
|
|
|
ok(!lstrcmpW(_bstr_(table->output), V_BSTR(&dest)),
|
|
|
|
"test %d: got wrong content %s, expected %s\n", i, wine_dbgstr_w(V_BSTR(&dest)), table->output);
|
|
|
|
VariantClear(&dest);
|
|
|
|
}
|
|
|
|
|
|
|
|
ISAXContentHandler_Release(content);
|
|
|
|
IMXWriter_Release(writer);
|
|
|
|
|
|
|
|
table++;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
free_bstrs();
|
|
|
|
}
|
|
|
|
|
2012-06-23 10:29:14 +02:00
|
|
|
/* point of these test is to start/end element with different names and name lengths */
|
|
|
|
struct writer_startendelement2_t {
|
|
|
|
const GUID *clsid;
|
|
|
|
const char *qnamestart;
|
|
|
|
int qnamestart_len;
|
|
|
|
const char *qnameend;
|
|
|
|
int qnameend_len;
|
|
|
|
const char *output;
|
|
|
|
HRESULT hr;
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct writer_startendelement2_t writer_startendelement2[] = {
|
|
|
|
{ &CLSID_MXXMLWriter, "a", -1, "b", -1, "<a/>", S_OK },
|
|
|
|
{ &CLSID_MXXMLWriter30, "a", -1, "b", -1, "<a/>", S_OK },
|
|
|
|
{ &CLSID_MXXMLWriter40, "a", -1, "b", -1, "<a/>", S_OK },
|
|
|
|
/* -1 length is not allowed for version 6 */
|
|
|
|
{ &CLSID_MXXMLWriter60, "a", -1, "b", -1, "<a/>", E_INVALIDARG },
|
|
|
|
|
|
|
|
{ &CLSID_MXXMLWriter, "a", 1, "b", 1, "<a/>", S_OK },
|
|
|
|
{ &CLSID_MXXMLWriter30, "a", 1, "b", 1, "<a/>", S_OK },
|
|
|
|
{ &CLSID_MXXMLWriter40, "a", 1, "b", 1, "<a/>", S_OK },
|
|
|
|
{ &CLSID_MXXMLWriter60, "a", 1, "b", 1, "<a/>", S_OK },
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static void test_mxwriter_startendelement_batch2(const struct writer_startendelement2_t *table)
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
while (table->clsid)
|
|
|
|
{
|
|
|
|
ISAXContentHandler *content;
|
|
|
|
IMXWriter *writer;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if (!is_clsid_supported(table->clsid, mxwriter_support_data))
|
|
|
|
{
|
|
|
|
table++;
|
|
|
|
i++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = CoCreateInstance(table->clsid, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IMXWriter, (void**)&writer);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = IMXWriter_QueryInterface(writer, &IID_ISAXContentHandler, (void**)&content);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = IMXWriter_put_omitXMLDeclaration(writer, VARIANT_TRUE);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_startDocument(content);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_startElement(content, _bstr_(""), 0, _bstr_(""), 0,
|
|
|
|
_bstr_(table->qnamestart), table->qnamestart_len, NULL);
|
|
|
|
ok(hr == table->hr, "test %d: got 0x%08x, expected 0x%08x\n", i, hr, table->hr);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_endElement(content, _bstr_(""), 0, _bstr_(""), 0,
|
|
|
|
_bstr_(table->qnameend), table->qnameend_len);
|
|
|
|
ok(hr == table->hr, "test %d: got 0x%08x, expected 0x%08x\n", i, hr, table->hr);
|
|
|
|
|
|
|
|
/* test output */
|
|
|
|
if (hr == S_OK)
|
|
|
|
{
|
|
|
|
VARIANT dest;
|
|
|
|
|
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_get_output(writer, &dest);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest));
|
|
|
|
ok(!lstrcmpW(_bstr_(table->output), V_BSTR(&dest)),
|
|
|
|
"test %d: got wrong content %s, expected %s\n", i, wine_dbgstr_w(V_BSTR(&dest)), table->output);
|
|
|
|
VariantClear(&dest);
|
|
|
|
}
|
|
|
|
|
|
|
|
ISAXContentHandler_Release(content);
|
|
|
|
IMXWriter_Release(writer);
|
|
|
|
|
|
|
|
table++;
|
|
|
|
i++;
|
|
|
|
|
|
|
|
free_bstrs();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-05-04 10:21:39 +02:00
|
|
|
static void test_mxwriter_startendelement(void)
|
|
|
|
{
|
|
|
|
ISAXContentHandler *content;
|
|
|
|
IMXWriter *writer;
|
|
|
|
VARIANT dest;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2011-08-25 13:32:27 +02:00
|
|
|
test_mxwriter_startendelement_batch(writer_startendelement);
|
2012-06-23 10:29:14 +02:00
|
|
|
test_mxwriter_startendelement_batch2(writer_startendelement2);
|
2011-08-25 13:31:02 +02:00
|
|
|
|
2011-05-04 10:21:39 +02:00
|
|
|
hr = CoCreateInstance(&CLSID_MXXMLWriter, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IMXWriter, (void**)&writer);
|
|
|
|
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
|
|
|
|
|
|
|
hr = IMXWriter_QueryInterface(writer, &IID_ISAXContentHandler, (void**)&content);
|
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
|
|
|
|
|
|
|
hr = IMXWriter_put_omitXMLDeclaration(writer, VARIANT_TRUE);
|
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_startDocument(content);
|
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
|
|
|
|
|
|
|
/* all string pointers should be not null */
|
|
|
|
hr = ISAXContentHandler_startElement(content, _bstr_(""), 0, _bstr_("b"), 1, _bstr_(""), 0, NULL);
|
2011-05-07 16:34:37 +02:00
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
2011-05-04 10:21:39 +02:00
|
|
|
|
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_get_output(writer, &dest);
|
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
|
|
|
ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest));
|
2011-05-07 16:34:37 +02:00
|
|
|
ok(!lstrcmpW(_bstr_("<>"), V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest)));
|
2011-05-04 10:21:39 +02:00
|
|
|
VariantClear(&dest);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_startElement(content, _bstr_(""), 0, _bstr_(""), 0, _bstr_("b"), 1, NULL);
|
2011-05-07 16:34:37 +02:00
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
2011-05-04 10:21:39 +02:00
|
|
|
|
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_get_output(writer, &dest);
|
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
|
|
|
ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest));
|
2011-05-07 16:34:37 +02:00
|
|
|
ok(!lstrcmpW(_bstr_("<><b>"), V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest)));
|
2011-05-04 10:21:39 +02:00
|
|
|
VariantClear(&dest);
|
|
|
|
|
2011-05-07 16:34:37 +02:00
|
|
|
hr = ISAXContentHandler_endElement(content, NULL, 0, NULL, 0, _bstr_("a:b"), 3);
|
2011-08-27 15:35:13 +02:00
|
|
|
EXPECT_HR(hr, E_INVALIDARG);
|
2011-05-07 16:34:37 +02:00
|
|
|
|
|
|
|
hr = ISAXContentHandler_endElement(content, NULL, 0, _bstr_("b"), 1, _bstr_("a:b"), 3);
|
2011-08-27 15:35:13 +02:00
|
|
|
EXPECT_HR(hr, E_INVALIDARG);
|
2011-05-07 16:34:37 +02:00
|
|
|
|
|
|
|
/* only local name is an error too */
|
|
|
|
hr = ISAXContentHandler_endElement(content, NULL, 0, _bstr_("b"), 1, NULL, 0);
|
2011-08-27 15:35:13 +02:00
|
|
|
EXPECT_HR(hr, E_INVALIDARG);
|
2011-05-07 16:34:37 +02:00
|
|
|
|
2011-05-04 10:21:39 +02:00
|
|
|
hr = ISAXContentHandler_endElement(content, _bstr_(""), 0, _bstr_(""), 0, _bstr_("b"), 1);
|
2011-08-27 15:35:13 +02:00
|
|
|
EXPECT_HR(hr, S_OK);
|
2011-05-04 10:21:39 +02:00
|
|
|
|
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_get_output(writer, &dest);
|
2011-08-27 15:35:13 +02:00
|
|
|
EXPECT_HR(hr, S_OK);
|
2011-05-04 10:21:39 +02:00
|
|
|
ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest));
|
2011-05-07 16:34:37 +02:00
|
|
|
ok(!lstrcmpW(_bstr_("<><b></b>"), V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest)));
|
2011-05-04 10:21:39 +02:00
|
|
|
VariantClear(&dest);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_endDocument(content);
|
2011-08-27 15:35:13 +02:00
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_put_output(writer, dest);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
2011-12-09 19:34:27 +01:00
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_get_output(writer, &dest);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest));
|
|
|
|
ok(!lstrcmpW(_bstr_(""), V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest)));
|
|
|
|
VariantClear(&dest);
|
|
|
|
|
2011-08-27 15:35:13 +02:00
|
|
|
hr = ISAXContentHandler_startDocument(content);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_startElement(content, _bstr_(""), 0, _bstr_(""), 0, _bstr_("abcdef"), 3, NULL);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_get_output(writer, &dest);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest));
|
|
|
|
ok(!lstrcmpW(_bstr_("<abc>"), V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest)));
|
|
|
|
VariantClear(&dest);
|
2011-05-04 10:21:39 +02:00
|
|
|
|
2013-07-22 09:01:31 +02:00
|
|
|
hr = ISAXContentHandler_endDocument(content);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
2011-10-05 23:04:04 +02:00
|
|
|
IMXWriter_flush(writer);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_endElement(content, _bstr_(""), 0, _bstr_(""), 0, _bstr_("abdcdef"), 3);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_get_output(writer, &dest);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest));
|
|
|
|
ok(!lstrcmpW(_bstr_("<abc></abd>"), V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest)));
|
|
|
|
VariantClear(&dest);
|
|
|
|
|
2012-06-22 22:38:12 +02:00
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_put_output(writer, dest);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
2012-06-23 10:29:14 +02:00
|
|
|
/* length -1 */
|
2012-06-22 22:38:12 +02:00
|
|
|
hr = ISAXContentHandler_startElement(content, _bstr_(""), 0, _bstr_(""), 0, _bstr_("a"), -1, NULL);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_get_output(writer, &dest);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest));
|
|
|
|
ok(!lstrcmpW(_bstr_("<a>"), V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest)));
|
2012-06-23 10:29:14 +02:00
|
|
|
VariantClear(&dest);
|
2012-06-22 22:38:12 +02:00
|
|
|
|
2011-05-04 10:21:39 +02:00
|
|
|
ISAXContentHandler_Release(content);
|
|
|
|
IMXWriter_Release(writer);
|
|
|
|
free_bstrs();
|
|
|
|
}
|
|
|
|
|
2012-02-24 21:20:48 +01:00
|
|
|
struct writer_characters_t {
|
|
|
|
const GUID *clsid;
|
|
|
|
const char *data;
|
|
|
|
const char *output;
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct writer_characters_t writer_characters[] = {
|
2013-08-20 10:49:54 +02:00
|
|
|
{ &CLSID_MXXMLWriter, "< > & \" \'", "< > & \" \'" },
|
|
|
|
{ &CLSID_MXXMLWriter30, "< > & \" \'", "< > & \" \'" },
|
|
|
|
{ &CLSID_MXXMLWriter40, "< > & \" \'", "< > & \" \'" },
|
|
|
|
{ &CLSID_MXXMLWriter60, "< > & \" \'", "< > & \" \'" },
|
2012-02-24 21:20:48 +01:00
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
2011-05-07 19:51:33 +02:00
|
|
|
static void test_mxwriter_characters(void)
|
|
|
|
{
|
|
|
|
static const WCHAR chardataW[] = {'T','E','S','T','C','H','A','R','D','A','T','A',' ','.',0};
|
2012-02-24 21:20:48 +01:00
|
|
|
const struct writer_characters_t *table = writer_characters;
|
2011-05-07 19:51:33 +02:00
|
|
|
ISAXContentHandler *content;
|
|
|
|
IMXWriter *writer;
|
|
|
|
VARIANT dest;
|
|
|
|
HRESULT hr;
|
2012-02-24 21:20:48 +01:00
|
|
|
int i = 0;
|
2011-05-07 19:51:33 +02:00
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_MXXMLWriter, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IMXWriter, (void**)&writer);
|
2011-08-27 12:19:22 +02:00
|
|
|
EXPECT_HR(hr, S_OK);
|
2011-05-07 19:51:33 +02:00
|
|
|
|
|
|
|
hr = IMXWriter_QueryInterface(writer, &IID_ISAXContentHandler, (void**)&content);
|
2011-08-27 12:19:22 +02:00
|
|
|
EXPECT_HR(hr, S_OK);
|
2011-05-07 19:51:33 +02:00
|
|
|
|
|
|
|
hr = IMXWriter_put_omitXMLDeclaration(writer, VARIANT_TRUE);
|
2011-08-27 12:19:22 +02:00
|
|
|
EXPECT_HR(hr, S_OK);
|
2011-05-07 19:51:33 +02:00
|
|
|
|
|
|
|
hr = ISAXContentHandler_startDocument(content);
|
2011-08-27 12:19:22 +02:00
|
|
|
EXPECT_HR(hr, S_OK);
|
2011-05-07 19:51:33 +02:00
|
|
|
|
|
|
|
hr = ISAXContentHandler_characters(content, NULL, 0);
|
2011-08-27 12:19:22 +02:00
|
|
|
EXPECT_HR(hr, E_INVALIDARG);
|
2011-05-07 19:51:33 +02:00
|
|
|
|
|
|
|
hr = ISAXContentHandler_characters(content, chardataW, 0);
|
2011-08-27 12:19:22 +02:00
|
|
|
EXPECT_HR(hr, S_OK);
|
2011-05-07 19:51:33 +02:00
|
|
|
|
|
|
|
hr = ISAXContentHandler_characters(content, chardataW, sizeof(chardataW)/sizeof(WCHAR) - 1);
|
2011-08-27 12:19:22 +02:00
|
|
|
EXPECT_HR(hr, S_OK);
|
2011-05-07 19:51:33 +02:00
|
|
|
|
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_get_output(writer, &dest);
|
2011-08-27 12:19:22 +02:00
|
|
|
EXPECT_HR(hr, S_OK);
|
2011-05-07 19:51:33 +02:00
|
|
|
ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest));
|
|
|
|
ok(!lstrcmpW(_bstr_("TESTCHARDATA ."), V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest)));
|
|
|
|
VariantClear(&dest);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_endDocument(content);
|
2011-08-27 12:19:22 +02:00
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
ISAXContentHandler_Release(content);
|
|
|
|
IMXWriter_Release(writer);
|
|
|
|
|
|
|
|
/* try empty characters data to see if element is closed */
|
|
|
|
hr = CoCreateInstance(&CLSID_MXXMLWriter, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IMXWriter, (void**)&writer);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = IMXWriter_QueryInterface(writer, &IID_ISAXContentHandler, (void**)&content);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = IMXWriter_put_omitXMLDeclaration(writer, VARIANT_TRUE);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_startDocument(content);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_startElement(content, _bstr_(""), 0, _bstr_(""), 0, _bstr_("a"), 1, NULL);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_characters(content, chardataW, 0);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_endElement(content, _bstr_(""), 0, _bstr_(""), 0, _bstr_("a"), 1);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_get_output(writer, &dest);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest));
|
|
|
|
ok(!lstrcmpW(_bstr_("<a></a>"), V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest)));
|
|
|
|
VariantClear(&dest);
|
2011-05-07 19:51:33 +02:00
|
|
|
|
|
|
|
ISAXContentHandler_Release(content);
|
|
|
|
IMXWriter_Release(writer);
|
|
|
|
|
2012-02-24 21:20:48 +01:00
|
|
|
/* batch tests */
|
|
|
|
while (table->clsid)
|
|
|
|
{
|
|
|
|
ISAXContentHandler *content;
|
|
|
|
IMXWriter *writer;
|
2012-04-26 18:22:27 +02:00
|
|
|
VARIANT dest;
|
2012-02-24 21:20:48 +01:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if (!is_clsid_supported(table->clsid, mxwriter_support_data))
|
|
|
|
{
|
|
|
|
table++;
|
|
|
|
i++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = CoCreateInstance(table->clsid, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IMXWriter, (void**)&writer);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = IMXWriter_QueryInterface(writer, &IID_ISAXContentHandler, (void**)&content);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = IMXWriter_put_omitXMLDeclaration(writer, VARIANT_TRUE);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_startDocument(content);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_characters(content, _bstr_(table->data), strlen(table->data));
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
/* test output */
|
|
|
|
if (hr == S_OK)
|
|
|
|
{
|
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_get_output(writer, &dest);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest));
|
|
|
|
ok(!lstrcmpW(_bstr_(table->output), V_BSTR(&dest)),
|
2012-04-26 18:22:27 +02:00
|
|
|
"test %d: got wrong content %s, expected \"%s\"\n", i, wine_dbgstr_w(V_BSTR(&dest)), table->output);
|
2012-02-24 21:20:48 +01:00
|
|
|
VariantClear(&dest);
|
|
|
|
}
|
|
|
|
|
2012-04-26 18:22:27 +02:00
|
|
|
/* with disabled escaping */
|
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_put_output(writer, dest);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = IMXWriter_put_disableOutputEscaping(writer, VARIANT_TRUE);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_characters(content, _bstr_(table->data), strlen(table->data));
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
/* test output */
|
|
|
|
if (hr == S_OK)
|
|
|
|
{
|
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_get_output(writer, &dest);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest));
|
|
|
|
ok(!lstrcmpW(_bstr_(table->data), V_BSTR(&dest)),
|
|
|
|
"test %d: got wrong content %s, expected \"%s\"\n", i, wine_dbgstr_w(V_BSTR(&dest)), table->data);
|
|
|
|
VariantClear(&dest);
|
|
|
|
}
|
|
|
|
|
|
|
|
ISAXContentHandler_Release(content);
|
|
|
|
IMXWriter_Release(writer);
|
|
|
|
|
2012-02-24 21:20:48 +01:00
|
|
|
table++;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
2011-05-07 19:51:33 +02:00
|
|
|
free_bstrs();
|
|
|
|
}
|
|
|
|
|
2011-08-13 01:11:30 +02:00
|
|
|
static const mxwriter_stream_test mxwriter_stream_tests[] = {
|
|
|
|
{
|
|
|
|
VARIANT_TRUE,"UTF-16",
|
|
|
|
{
|
|
|
|
{FALSE,(const BYTE*)szUtf16BOM,sizeof(szUtf16BOM),TRUE},
|
|
|
|
{FALSE,(const BYTE*)szUtf16XML,sizeof(szUtf16XML)},
|
|
|
|
{TRUE}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
VARIANT_FALSE,"UTF-16",
|
|
|
|
{
|
|
|
|
{FALSE,(const BYTE*)szUtf16XML,sizeof(szUtf16XML)},
|
|
|
|
{TRUE}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
VARIANT_TRUE,"UTF-8",
|
|
|
|
{
|
|
|
|
{FALSE,(const BYTE*)szUtf8XML,sizeof(szUtf8XML)-1},
|
|
|
|
/* For some reason Windows makes an empty write call when UTF-8 encoding is used
|
|
|
|
* and the writer is released.
|
|
|
|
*/
|
|
|
|
{FALSE,NULL,0},
|
|
|
|
{TRUE}
|
|
|
|
}
|
|
|
|
},
|
2011-12-16 00:36:53 +01:00
|
|
|
{
|
|
|
|
VARIANT_TRUE,"utf-8",
|
|
|
|
{
|
|
|
|
{FALSE,(const BYTE*)utf8xml2,sizeof(utf8xml2)-1},
|
|
|
|
/* For some reason Windows makes an empty write call when UTF-8 encoding is used
|
|
|
|
* and the writer is released.
|
|
|
|
*/
|
|
|
|
{FALSE,NULL,0},
|
|
|
|
{TRUE}
|
|
|
|
}
|
|
|
|
},
|
2011-08-13 01:11:30 +02:00
|
|
|
{
|
|
|
|
VARIANT_TRUE,"UTF-16",
|
|
|
|
{
|
|
|
|
{FALSE,(const BYTE*)szUtf16BOM,sizeof(szUtf16BOM),TRUE},
|
|
|
|
{FALSE,(const BYTE*)szUtf16XML,sizeof(szUtf16XML)},
|
|
|
|
{TRUE}
|
|
|
|
}
|
2011-08-13 01:11:54 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
VARIANT_TRUE,"UTF-16",
|
|
|
|
{
|
|
|
|
{FALSE,(const BYTE*)szUtf16BOM,sizeof(szUtf16BOM),TRUE,TRUE},
|
|
|
|
{FALSE,(const BYTE*)szUtf16XML,sizeof(szUtf16XML)},
|
|
|
|
{TRUE}
|
|
|
|
}
|
2011-08-13 01:11:30 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static void test_mxwriter_stream(void)
|
|
|
|
{
|
2011-08-13 01:11:54 +02:00
|
|
|
IMXWriter *writer;
|
|
|
|
ISAXContentHandler *content;
|
|
|
|
HRESULT hr;
|
|
|
|
VARIANT dest;
|
|
|
|
IStream *stream;
|
|
|
|
LARGE_INTEGER pos;
|
|
|
|
ULARGE_INTEGER pos2;
|
2011-08-13 01:11:30 +02:00
|
|
|
DWORD test_count = sizeof(mxwriter_stream_tests)/sizeof(mxwriter_stream_tests[0]);
|
|
|
|
|
|
|
|
for(current_stream_test_index = 0; current_stream_test_index < test_count; ++current_stream_test_index) {
|
|
|
|
const mxwriter_stream_test *test = mxwriter_stream_tests+current_stream_test_index;
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_MXXMLWriter, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IMXWriter, (void**)&writer);
|
|
|
|
ok(hr == S_OK, "CoCreateInstance failed: %08x\n", hr);
|
|
|
|
|
|
|
|
hr = IMXWriter_QueryInterface(writer, &IID_ISAXContentHandler, (void**)&content);
|
|
|
|
ok(hr == S_OK, "QueryInterface(ISAXContentHandler) failed: %08x\n", hr);
|
|
|
|
|
|
|
|
hr = IMXWriter_put_encoding(writer, _bstr_(test->encoding));
|
|
|
|
ok(hr == S_OK, "put_encoding failed with %08x on test %d\n", hr, current_stream_test_index);
|
|
|
|
|
|
|
|
V_VT(&dest) = VT_UNKNOWN;
|
|
|
|
V_UNKNOWN(&dest) = (IUnknown*)&mxstream;
|
|
|
|
hr = IMXWriter_put_output(writer, dest);
|
|
|
|
ok(hr == S_OK, "put_output failed with %08x on test %d\n", hr, current_stream_test_index);
|
|
|
|
VariantClear(&dest);
|
|
|
|
|
|
|
|
hr = IMXWriter_put_byteOrderMark(writer, test->bom);
|
|
|
|
ok(hr == S_OK, "put_byteOrderMark failed with %08x on test %d\n", hr, current_stream_test_index);
|
|
|
|
|
|
|
|
current_write_test = test->expected_writes;
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_startDocument(content);
|
|
|
|
ok(hr == S_OK, "startDocument failed with %08x on test %d\n", hr, current_stream_test_index);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_endDocument(content);
|
2011-08-13 01:11:08 +02:00
|
|
|
ok(hr == S_OK, "endDocument failed with %08x on test %d\n", hr, current_stream_test_index);
|
2011-08-13 01:11:30 +02:00
|
|
|
|
|
|
|
ISAXContentHandler_Release(content);
|
|
|
|
IMXWriter_Release(writer);
|
|
|
|
|
2011-08-13 01:11:08 +02:00
|
|
|
ok(current_write_test->last, "The last %d write calls on test %d were missed\n",
|
2011-08-31 01:20:59 +02:00
|
|
|
(int)(current_write_test-test->expected_writes), current_stream_test_index);
|
2011-08-13 01:11:30 +02:00
|
|
|
}
|
|
|
|
|
2011-08-13 01:11:54 +02:00
|
|
|
hr = CoCreateInstance(&CLSID_MXXMLWriter, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IMXWriter, (void**)&writer);
|
|
|
|
ok(hr == S_OK, "CoCreateInstance failed: %08x\n", hr);
|
|
|
|
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
|
|
|
|
ok(hr == S_OK, "CreateStreamOnHGlobal failed: %08x\n", hr);
|
|
|
|
|
|
|
|
hr = IMXWriter_QueryInterface(writer, &IID_ISAXContentHandler, (void**)&content);
|
|
|
|
ok(hr == S_OK, "QueryInterface(ISAXContentHandler) failed: %08x\n", hr);
|
|
|
|
|
|
|
|
hr = IMXWriter_put_encoding(writer, _bstr_("UTF-8"));
|
|
|
|
ok(hr == S_OK, "put_encoding failed: %08x\n", hr);
|
|
|
|
|
|
|
|
V_VT(&dest) = VT_UNKNOWN;
|
|
|
|
V_UNKNOWN(&dest) = (IUnknown*)stream;
|
|
|
|
hr = IMXWriter_put_output(writer, dest);
|
|
|
|
ok(hr == S_OK, "put_output failed: %08x\n", hr);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_startDocument(content);
|
|
|
|
ok(hr == S_OK, "startDocument failed: %08x\n", hr);
|
|
|
|
|
|
|
|
/* Setting output of the mxwriter causes the current output to be flushed,
|
|
|
|
* and the writer to start over.
|
|
|
|
*/
|
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_put_output(writer, dest);
|
|
|
|
ok(hr == S_OK, "put_output failed: %08x\n", hr);
|
|
|
|
|
|
|
|
pos.QuadPart = 0;
|
|
|
|
hr = IStream_Seek(stream, pos, STREAM_SEEK_CUR, &pos2);
|
|
|
|
ok(hr == S_OK, "Seek failed: %08x\n", hr);
|
2011-08-13 01:11:08 +02:00
|
|
|
ok(pos2.QuadPart != 0, "expected stream position moved\n");
|
2011-08-13 01:11:54 +02:00
|
|
|
|
|
|
|
hr = ISAXContentHandler_startDocument(content);
|
|
|
|
ok(hr == S_OK, "startDocument failed: %08x\n", hr);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_endDocument(content);
|
2011-08-13 01:11:08 +02:00
|
|
|
ok(hr == S_OK, "endDocument failed: %08x\n", hr);
|
2011-08-13 01:11:54 +02:00
|
|
|
|
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_get_output(writer, &dest);
|
|
|
|
ok(hr == S_OK, "get_output failed: %08x\n", hr);
|
|
|
|
ok(V_VT(&dest) == VT_BSTR, "Expected VT_BSTR, got %d\n", V_VT(&dest));
|
2011-08-13 01:11:08 +02:00
|
|
|
ok(!lstrcmpW(_bstr_("<?xml version=\"1.0\" encoding=\"UTF-16\" standalone=\"no\"?>\r\n"), V_BSTR(&dest)),
|
2011-08-13 01:11:54 +02:00
|
|
|
"Got wrong content: %s\n", wine_dbgstr_w(V_BSTR(&dest)));
|
|
|
|
VariantClear(&dest);
|
|
|
|
|
2011-12-09 12:02:10 +01:00
|
|
|
/* test when BOM is written to output stream */
|
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_put_output(writer, dest);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
pos.QuadPart = 0;
|
|
|
|
hr = IStream_Seek(stream, pos, STREAM_SEEK_SET, NULL);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
V_VT(&dest) = VT_UNKNOWN;
|
|
|
|
V_UNKNOWN(&dest) = (IUnknown*)stream;
|
|
|
|
hr = IMXWriter_put_output(writer, dest);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = IMXWriter_put_byteOrderMark(writer, VARIANT_TRUE);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = IMXWriter_put_encoding(writer, _bstr_("UTF-16"));
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_startDocument(content);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
pos.QuadPart = 0;
|
|
|
|
pos2.QuadPart = 0;
|
|
|
|
hr = IStream_Seek(stream, pos, STREAM_SEEK_CUR, &pos2);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(pos2.QuadPart == 2, "got wrong position\n");
|
|
|
|
|
2014-05-04 18:33:35 +02:00
|
|
|
IStream_Release(stream);
|
2011-08-13 01:11:54 +02:00
|
|
|
ISAXContentHandler_Release(content);
|
|
|
|
IMXWriter_Release(writer);
|
|
|
|
|
|
|
|
free_bstrs();
|
|
|
|
}
|
|
|
|
|
2012-05-14 14:46:32 +02:00
|
|
|
static const char *encoding_names[] = {
|
|
|
|
"iso-8859-1",
|
|
|
|
"iso-8859-2",
|
|
|
|
"iso-8859-3",
|
|
|
|
"iso-8859-4",
|
|
|
|
"iso-8859-5",
|
|
|
|
"iso-8859-7",
|
|
|
|
"iso-8859-9",
|
|
|
|
"iso-8859-13",
|
|
|
|
"iso-8859-15",
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2011-08-13 01:11:54 +02:00
|
|
|
static void test_mxwriter_encoding(void)
|
|
|
|
{
|
|
|
|
ISAXContentHandler *content;
|
2011-12-12 23:00:44 +01:00
|
|
|
IMXWriter *writer;
|
|
|
|
IStream *stream;
|
2012-05-14 14:46:32 +02:00
|
|
|
const char *enc;
|
2011-08-13 01:11:54 +02:00
|
|
|
VARIANT dest;
|
2011-12-12 23:00:44 +01:00
|
|
|
HRESULT hr;
|
|
|
|
HGLOBAL g;
|
|
|
|
char *ptr;
|
|
|
|
BSTR s;
|
2012-05-14 14:46:32 +02:00
|
|
|
int i;
|
2011-08-13 01:11:54 +02:00
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_MXXMLWriter, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IMXWriter, (void**)&writer);
|
2011-12-12 23:00:44 +01:00
|
|
|
EXPECT_HR(hr, S_OK);
|
2011-08-13 01:11:54 +02:00
|
|
|
|
|
|
|
hr = IMXWriter_QueryInterface(writer, &IID_ISAXContentHandler, (void**)&content);
|
2011-12-12 23:00:44 +01:00
|
|
|
EXPECT_HR(hr, S_OK);
|
2011-08-13 01:11:54 +02:00
|
|
|
|
|
|
|
hr = IMXWriter_put_encoding(writer, _bstr_("UTF-8"));
|
2011-12-12 23:00:44 +01:00
|
|
|
EXPECT_HR(hr, S_OK);
|
2011-08-13 01:11:54 +02:00
|
|
|
|
|
|
|
hr = ISAXContentHandler_startDocument(content);
|
2011-12-12 23:00:44 +01:00
|
|
|
EXPECT_HR(hr, S_OK);
|
2011-08-13 01:11:54 +02:00
|
|
|
|
|
|
|
hr = ISAXContentHandler_endDocument(content);
|
2011-12-12 23:00:44 +01:00
|
|
|
EXPECT_HR(hr, S_OK);
|
2011-08-13 01:11:54 +02:00
|
|
|
|
|
|
|
/* The content is always re-encoded to UTF-16 when the output is
|
|
|
|
* retrieved as a BSTR.
|
|
|
|
*/
|
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_get_output(writer, &dest);
|
2011-12-09 19:34:27 +01:00
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(V_VT(&dest) == VT_BSTR, "Expected VT_BSTR, got %d\n", V_VT(&dest));
|
|
|
|
ok(!lstrcmpW(_bstr_("<?xml version=\"1.0\" encoding=\"UTF-16\" standalone=\"no\"?>\r\n"), V_BSTR(&dest)),
|
2011-08-13 01:11:54 +02:00
|
|
|
"got wrong content: %s\n", wine_dbgstr_w(V_BSTR(&dest)));
|
|
|
|
VariantClear(&dest);
|
|
|
|
|
2011-12-12 23:00:44 +01:00
|
|
|
/* switch encoding when something is written already */
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
V_VT(&dest) = VT_UNKNOWN;
|
|
|
|
V_UNKNOWN(&dest) = (IUnknown*)stream;
|
|
|
|
hr = IMXWriter_put_output(writer, dest);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = IMXWriter_put_encoding(writer, _bstr_("UTF-8"));
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
/* write empty element */
|
|
|
|
hr = ISAXContentHandler_startElement(content, _bstr_(""), 0, _bstr_(""), 0, _bstr_("a"), 1, NULL);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_endElement(content, _bstr_(""), 0, _bstr_(""), 0, _bstr_("a"), 1);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
/* switch */
|
|
|
|
hr = IMXWriter_put_encoding(writer, _bstr_("UTF-16"));
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = IMXWriter_flush(writer);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = GetHGlobalFromStream(stream, &g);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
ptr = GlobalLock(g);
|
|
|
|
ok(!strncmp(ptr, "<a/>", 4), "got %c%c%c%c\n", ptr[0],ptr[1],ptr[2],ptr[3]);
|
|
|
|
GlobalUnlock(g);
|
|
|
|
|
|
|
|
/* so output is unaffected, encoding name is stored however */
|
|
|
|
hr = IMXWriter_get_encoding(writer, &s);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(!lstrcmpW(s, _bstr_("UTF-16")), "got %s\n", wine_dbgstr_w(s));
|
|
|
|
SysFreeString(s);
|
|
|
|
|
|
|
|
IStream_Release(stream);
|
|
|
|
|
2012-05-14 14:46:32 +02:00
|
|
|
i = 0;
|
|
|
|
enc = encoding_names[i];
|
|
|
|
while (enc)
|
|
|
|
{
|
|
|
|
char expectedA[200];
|
|
|
|
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
V_VT(&dest) = VT_UNKNOWN;
|
|
|
|
V_UNKNOWN(&dest) = (IUnknown*)stream;
|
|
|
|
hr = IMXWriter_put_output(writer, dest);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = IMXWriter_put_encoding(writer, _bstr_(enc));
|
|
|
|
ok(hr == S_OK || broken(hr != S_OK) /* old win versions do not support certain encodings */,
|
|
|
|
"%s: encoding not accepted\n", enc);
|
|
|
|
if (hr != S_OK)
|
|
|
|
{
|
2012-05-19 12:38:30 +02:00
|
|
|
enc = encoding_names[++i];
|
2012-05-14 14:46:32 +02:00
|
|
|
IStream_Release(stream);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_startDocument(content);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_endDocument(content);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = IMXWriter_flush(writer);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
/* prepare expected string */
|
|
|
|
*expectedA = 0;
|
|
|
|
strcat(expectedA, "<?xml version=\"1.0\" encoding=\"");
|
|
|
|
strcat(expectedA, enc);
|
|
|
|
strcat(expectedA, "\" standalone=\"no\"?>\r\n");
|
|
|
|
|
|
|
|
hr = GetHGlobalFromStream(stream, &g);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
ptr = GlobalLock(g);
|
|
|
|
ok(!strncmp(ptr, expectedA, strlen(expectedA)), "%s: got %s, expected %.50s\n", enc, ptr, expectedA);
|
|
|
|
GlobalUnlock(g);
|
|
|
|
|
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_put_output(writer, dest);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
IStream_Release(stream);
|
|
|
|
|
|
|
|
enc = encoding_names[++i];
|
|
|
|
}
|
|
|
|
|
2011-08-13 01:11:54 +02:00
|
|
|
ISAXContentHandler_Release(content);
|
|
|
|
IMXWriter_Release(writer);
|
|
|
|
|
2011-08-13 01:11:30 +02:00
|
|
|
free_bstrs();
|
|
|
|
}
|
|
|
|
|
2011-11-21 10:23:25 +01:00
|
|
|
static void test_obj_dispex(IUnknown *obj)
|
|
|
|
{
|
2014-03-08 16:06:11 +01:00
|
|
|
static const WCHAR testW[] = {'t','e','s','t','p','r','o','p',0};
|
2011-11-21 10:23:25 +01:00
|
|
|
static const WCHAR starW[] = {'*',0};
|
|
|
|
DISPID dispid = DISPID_SAX_XMLREADER_GETFEATURE;
|
|
|
|
IDispatchEx *dispex;
|
|
|
|
IUnknown *unk;
|
|
|
|
DWORD props;
|
|
|
|
UINT ticnt;
|
|
|
|
HRESULT hr;
|
|
|
|
BSTR name;
|
2014-03-08 16:06:11 +01:00
|
|
|
DISPID did;
|
2011-11-21 10:23:25 +01:00
|
|
|
|
|
|
|
hr = IUnknown_QueryInterface(obj, &IID_IDispatchEx, (void**)&dispex);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
if (FAILED(hr)) return;
|
|
|
|
|
|
|
|
ticnt = 0;
|
|
|
|
hr = IDispatchEx_GetTypeInfoCount(dispex, &ticnt);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(ticnt == 1, "ticnt=%u\n", ticnt);
|
|
|
|
|
|
|
|
name = SysAllocString(starW);
|
|
|
|
hr = IDispatchEx_DeleteMemberByName(dispex, name, fdexNameCaseSensitive);
|
|
|
|
EXPECT_HR(hr, E_NOTIMPL);
|
|
|
|
SysFreeString(name);
|
|
|
|
|
|
|
|
hr = IDispatchEx_DeleteMemberByDispID(dispex, dispid);
|
|
|
|
EXPECT_HR(hr, E_NOTIMPL);
|
|
|
|
|
|
|
|
props = 0;
|
|
|
|
hr = IDispatchEx_GetMemberProperties(dispex, dispid, grfdexPropCanAll, &props);
|
|
|
|
EXPECT_HR(hr, E_NOTIMPL);
|
|
|
|
ok(props == 0, "expected 0 got %d\n", props);
|
|
|
|
|
|
|
|
hr = IDispatchEx_GetMemberName(dispex, dispid, &name);
|
|
|
|
EXPECT_HR(hr, E_NOTIMPL);
|
|
|
|
if (SUCCEEDED(hr)) SysFreeString(name);
|
|
|
|
|
|
|
|
hr = IDispatchEx_GetNextDispID(dispex, fdexEnumDefault, DISPID_SAX_XMLREADER_GETFEATURE, &dispid);
|
|
|
|
EXPECT_HR(hr, E_NOTIMPL);
|
|
|
|
|
2014-03-08 16:06:11 +01:00
|
|
|
unk = (IUnknown*)0xdeadbeef;
|
2011-11-21 10:23:25 +01:00
|
|
|
hr = IDispatchEx_GetNameSpaceParent(dispex, &unk);
|
|
|
|
EXPECT_HR(hr, E_NOTIMPL);
|
2014-03-08 16:06:11 +01:00
|
|
|
ok(unk == (IUnknown*)0xdeadbeef, "got %p\n", unk);
|
|
|
|
|
|
|
|
name = SysAllocString(testW);
|
|
|
|
hr = IDispatchEx_GetDispID(dispex, name, fdexNameEnsure, &did);
|
|
|
|
ok(hr == DISP_E_UNKNOWNNAME, "got 0x%08x\n", hr);
|
|
|
|
SysFreeString(name);
|
2011-11-21 10:23:25 +01:00
|
|
|
|
|
|
|
IDispatchEx_Release(dispex);
|
|
|
|
}
|
|
|
|
|
2014-03-07 09:07:27 +01:00
|
|
|
static void test_saxreader_dispex(void)
|
2011-11-21 10:23:25 +01:00
|
|
|
{
|
2014-03-07 09:07:27 +01:00
|
|
|
IVBSAXXMLReader *vbreader;
|
|
|
|
ISAXXMLReader *reader;
|
|
|
|
DISPPARAMS dispparams;
|
|
|
|
DISPID dispid;
|
|
|
|
IUnknown *unk;
|
|
|
|
VARIANT arg;
|
|
|
|
HRESULT hr;
|
2011-11-21 10:23:25 +01:00
|
|
|
|
2014-03-07 09:07:27 +01:00
|
|
|
hr = CoCreateInstance(&CLSID_SAXXMLReader, NULL, CLSCTX_INPROC_SERVER,
|
2011-11-21 10:23:25 +01:00
|
|
|
&IID_ISAXXMLReader, (void**)&reader);
|
2014-03-07 09:07:27 +01:00
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = ISAXXMLReader_QueryInterface(reader, &IID_IUnknown, (void**)&unk);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
test_obj_dispex(unk);
|
|
|
|
IUnknown_Release(unk);
|
|
|
|
|
|
|
|
hr = ISAXXMLReader_QueryInterface(reader, &IID_IVBSAXXMLReader, (void**)&vbreader);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
hr = IVBSAXXMLReader_QueryInterface(vbreader, &IID_IUnknown, (void**)&unk);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
test_obj_dispex(unk);
|
|
|
|
IUnknown_Release(unk);
|
|
|
|
|
|
|
|
dispid = DISPID_PROPERTYPUT;
|
|
|
|
dispparams.cArgs = 1;
|
|
|
|
dispparams.cNamedArgs = 1;
|
|
|
|
dispparams.rgdispidNamedArgs = &dispid;
|
|
|
|
dispparams.rgvarg = &arg;
|
|
|
|
|
|
|
|
V_VT(&arg) = VT_DISPATCH;
|
|
|
|
V_DISPATCH(&arg) = NULL;
|
|
|
|
|
|
|
|
/* propputref is callable as PROPERTYPUT and PROPERTYPUTREF */
|
|
|
|
hr = IVBSAXXMLReader_Invoke(vbreader,
|
|
|
|
DISPID_SAX_XMLREADER_CONTENTHANDLER,
|
|
|
|
&IID_NULL,
|
|
|
|
0,
|
|
|
|
DISPATCH_PROPERTYPUT,
|
|
|
|
&dispparams,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IVBSAXXMLReader_Invoke(vbreader,
|
|
|
|
DISPID_SAX_XMLREADER_CONTENTHANDLER,
|
|
|
|
&IID_NULL,
|
|
|
|
0,
|
|
|
|
DISPATCH_PROPERTYPUTREF,
|
|
|
|
&dispparams,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
IVBSAXXMLReader_Release(vbreader);
|
|
|
|
ISAXXMLReader_Release(reader);
|
2014-03-08 16:06:11 +01:00
|
|
|
|
|
|
|
if (is_clsid_supported(&CLSID_SAXXMLReader60, reader_support_data))
|
|
|
|
{
|
|
|
|
hr = CoCreateInstance(&CLSID_SAXXMLReader60, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void**)&unk);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
test_obj_dispex(unk);
|
|
|
|
IUnknown_Release(unk);
|
|
|
|
}
|
2011-11-21 10:23:25 +01:00
|
|
|
}
|
|
|
|
|
2011-12-05 09:07:26 +01:00
|
|
|
static void test_mxwriter_dispex(void)
|
|
|
|
{
|
|
|
|
IDispatchEx *dispex;
|
|
|
|
IMXWriter *writer;
|
|
|
|
IUnknown *unk;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_MXXMLWriter, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IMXWriter, (void**)&writer);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = IMXWriter_QueryInterface(writer, &IID_IDispatchEx, (void**)&dispex);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
hr = IDispatchEx_QueryInterface(dispex, &IID_IUnknown, (void**)&unk);
|
|
|
|
test_obj_dispex(unk);
|
|
|
|
IUnknown_Release(unk);
|
|
|
|
IDispatchEx_Release(dispex);
|
|
|
|
IMXWriter_Release(writer);
|
2014-03-08 16:06:11 +01:00
|
|
|
|
|
|
|
if (is_clsid_supported(&CLSID_MXXMLWriter60, mxwriter_support_data))
|
|
|
|
{
|
|
|
|
hr = CoCreateInstance(&CLSID_MXXMLWriter60, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void**)&unk);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
test_obj_dispex(unk);
|
|
|
|
IUnknown_Release(unk);
|
|
|
|
}
|
2011-12-05 09:07:26 +01:00
|
|
|
}
|
|
|
|
|
2012-01-27 13:13:54 +01:00
|
|
|
static void test_mxwriter_comment(void)
|
|
|
|
{
|
|
|
|
static const WCHAR commentW[] = {'c','o','m','m','e','n','t',0};
|
2014-03-03 05:56:20 +01:00
|
|
|
IVBSAXLexicalHandler *vblexical;
|
2012-01-27 13:13:54 +01:00
|
|
|
ISAXContentHandler *content;
|
|
|
|
ISAXLexicalHandler *lexical;
|
|
|
|
IMXWriter *writer;
|
|
|
|
VARIANT dest;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_MXXMLWriter, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IMXWriter, (void**)&writer);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = IMXWriter_QueryInterface(writer, &IID_ISAXContentHandler, (void**)&content);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = IMXWriter_QueryInterface(writer, &IID_ISAXLexicalHandler, (void**)&lexical);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
2014-03-03 05:56:20 +01:00
|
|
|
hr = IMXWriter_QueryInterface(writer, &IID_IVBSAXLexicalHandler, (void**)&vblexical);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
2012-01-27 13:13:54 +01:00
|
|
|
hr = IMXWriter_put_omitXMLDeclaration(writer, VARIANT_TRUE);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_startDocument(content);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = ISAXLexicalHandler_comment(lexical, NULL, 0);
|
|
|
|
EXPECT_HR(hr, E_INVALIDARG);
|
|
|
|
|
2014-03-03 05:56:20 +01:00
|
|
|
hr = IVBSAXLexicalHandler_comment(vblexical, NULL);
|
|
|
|
EXPECT_HR(hr, E_POINTER);
|
|
|
|
|
2012-01-27 13:13:54 +01:00
|
|
|
hr = ISAXLexicalHandler_comment(lexical, commentW, 0);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_get_output(writer, &dest);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest));
|
|
|
|
ok(!lstrcmpW(_bstr_("<!---->\r\n"), V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest)));
|
|
|
|
VariantClear(&dest);
|
|
|
|
|
|
|
|
hr = ISAXLexicalHandler_comment(lexical, commentW, sizeof(commentW)/sizeof(WCHAR)-1);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_get_output(writer, &dest);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest));
|
|
|
|
ok(!lstrcmpW(_bstr_("<!---->\r\n<!--comment-->\r\n"), V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest)));
|
|
|
|
VariantClear(&dest);
|
|
|
|
|
|
|
|
ISAXContentHandler_Release(content);
|
|
|
|
ISAXLexicalHandler_Release(lexical);
|
2014-03-03 05:56:20 +01:00
|
|
|
IVBSAXLexicalHandler_Release(vblexical);
|
2012-01-27 13:13:54 +01:00
|
|
|
IMXWriter_Release(writer);
|
|
|
|
free_bstrs();
|
|
|
|
}
|
|
|
|
|
2012-01-27 13:30:03 +01:00
|
|
|
static void test_mxwriter_cdata(void)
|
|
|
|
{
|
2014-03-03 05:56:20 +01:00
|
|
|
IVBSAXLexicalHandler *vblexical;
|
2012-01-27 13:30:03 +01:00
|
|
|
ISAXContentHandler *content;
|
|
|
|
ISAXLexicalHandler *lexical;
|
|
|
|
IMXWriter *writer;
|
|
|
|
VARIANT dest;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_MXXMLWriter, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IMXWriter, (void**)&writer);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = IMXWriter_QueryInterface(writer, &IID_ISAXContentHandler, (void**)&content);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = IMXWriter_QueryInterface(writer, &IID_ISAXLexicalHandler, (void**)&lexical);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
2014-03-03 05:56:20 +01:00
|
|
|
hr = IMXWriter_QueryInterface(writer, &IID_IVBSAXLexicalHandler, (void**)&vblexical);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
2012-01-27 13:30:03 +01:00
|
|
|
hr = IMXWriter_put_omitXMLDeclaration(writer, VARIANT_TRUE);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_startDocument(content);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = ISAXLexicalHandler_startCDATA(lexical);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_get_output(writer, &dest);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest));
|
|
|
|
ok(!lstrcmpW(_bstr_("<![CDATA["), V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest)));
|
|
|
|
VariantClear(&dest);
|
|
|
|
|
2014-03-03 05:56:20 +01:00
|
|
|
hr = IVBSAXLexicalHandler_startCDATA(vblexical);
|
2012-01-27 13:30:03 +01:00
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
2012-02-24 21:20:48 +01:00
|
|
|
/* all these are escaped for text nodes */
|
|
|
|
hr = ISAXContentHandler_characters(content, _bstr_("< > & \""), 7);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
2012-01-27 13:30:03 +01:00
|
|
|
hr = ISAXLexicalHandler_endCDATA(lexical);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_get_output(writer, &dest);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest));
|
2012-02-24 21:20:48 +01:00
|
|
|
ok(!lstrcmpW(_bstr_("<![CDATA[<![CDATA[< > & \"]]>"), V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest)));
|
2012-01-27 13:30:03 +01:00
|
|
|
VariantClear(&dest);
|
|
|
|
|
|
|
|
ISAXContentHandler_Release(content);
|
|
|
|
ISAXLexicalHandler_Release(lexical);
|
2014-03-03 05:56:20 +01:00
|
|
|
IVBSAXLexicalHandler_Release(vblexical);
|
2012-01-27 13:30:03 +01:00
|
|
|
IMXWriter_Release(writer);
|
|
|
|
free_bstrs();
|
2012-01-27 14:09:42 +01:00
|
|
|
}
|
2012-01-27 13:30:03 +01:00
|
|
|
|
2012-03-17 08:33:04 +01:00
|
|
|
static void test_mxwriter_pi(void)
|
|
|
|
{
|
|
|
|
static const WCHAR targetW[] = {'t','a','r','g','e','t',0};
|
|
|
|
static const WCHAR dataW[] = {'d','a','t','a',0};
|
|
|
|
ISAXContentHandler *content;
|
|
|
|
IMXWriter *writer;
|
|
|
|
VARIANT dest;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_MXXMLWriter, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IMXWriter, (void**)&writer);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = IMXWriter_QueryInterface(writer, &IID_ISAXContentHandler, (void**)&content);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_processingInstruction(content, NULL, 0, NULL, 0);
|
|
|
|
EXPECT_HR(hr, E_INVALIDARG);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_processingInstruction(content, targetW, 0, NULL, 0);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_processingInstruction(content, targetW, 6, NULL, 0);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_get_output(writer, &dest);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest));
|
|
|
|
ok(!lstrcmpW(_bstr_("<?\?>\r\n<?target?>\r\n"), V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest)));
|
|
|
|
VariantClear(&dest);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_processingInstruction(content, targetW, 4, dataW, 4);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_get_output(writer, &dest);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest));
|
|
|
|
ok(!lstrcmpW(_bstr_("<?\?>\r\n<?target?>\r\n<?targ data?>\r\n"), V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest)));
|
|
|
|
VariantClear(&dest);
|
|
|
|
|
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_put_output(writer, dest);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_processingInstruction(content, targetW, 6, dataW, 0);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_get_output(writer, &dest);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest));
|
|
|
|
ok(!lstrcmpW(_bstr_("<?target?>\r\n"), V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest)));
|
|
|
|
VariantClear(&dest);
|
|
|
|
|
2012-03-17 08:41:43 +01:00
|
|
|
|
|
|
|
ISAXContentHandler_Release(content);
|
|
|
|
IMXWriter_Release(writer);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_mxwriter_ignorablespaces(void)
|
|
|
|
{
|
|
|
|
static const WCHAR dataW[] = {'d','a','t','a',0};
|
|
|
|
ISAXContentHandler *content;
|
|
|
|
IMXWriter *writer;
|
|
|
|
VARIANT dest;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_MXXMLWriter, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IMXWriter, (void**)&writer);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = IMXWriter_QueryInterface(writer, &IID_ISAXContentHandler, (void**)&content);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_ignorableWhitespace(content, NULL, 0);
|
|
|
|
EXPECT_HR(hr, E_INVALIDARG);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_ignorableWhitespace(content, dataW, 0);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_ignorableWhitespace(content, dataW, 4);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_ignorableWhitespace(content, dataW, 1);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_get_output(writer, &dest);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest));
|
|
|
|
ok(!lstrcmpW(_bstr_("datad"), V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest)));
|
|
|
|
VariantClear(&dest);
|
|
|
|
|
2012-03-17 08:33:04 +01:00
|
|
|
ISAXContentHandler_Release(content);
|
|
|
|
IMXWriter_Release(writer);
|
|
|
|
}
|
|
|
|
|
2012-01-27 14:09:42 +01:00
|
|
|
static void test_mxwriter_dtd(void)
|
|
|
|
{
|
2012-03-08 10:03:27 +01:00
|
|
|
static const WCHAR contentW[] = {'c','o','n','t','e','n','t'};
|
2012-01-27 14:09:42 +01:00
|
|
|
static const WCHAR nameW[] = {'n','a','m','e'};
|
|
|
|
static const WCHAR pubW[] = {'p','u','b'};
|
|
|
|
static const WCHAR sysW[] = {'s','y','s'};
|
2014-03-03 05:56:20 +01:00
|
|
|
IVBSAXLexicalHandler *vblexical;
|
2012-01-27 14:09:42 +01:00
|
|
|
ISAXContentHandler *content;
|
|
|
|
ISAXLexicalHandler *lexical;
|
2014-03-03 05:55:59 +01:00
|
|
|
IVBSAXDeclHandler *vbdecl;
|
2012-03-08 10:03:27 +01:00
|
|
|
ISAXDeclHandler *decl;
|
2012-01-27 14:09:42 +01:00
|
|
|
IMXWriter *writer;
|
|
|
|
VARIANT dest;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_MXXMLWriter, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IMXWriter, (void**)&writer);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = IMXWriter_QueryInterface(writer, &IID_ISAXContentHandler, (void**)&content);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = IMXWriter_QueryInterface(writer, &IID_ISAXLexicalHandler, (void**)&lexical);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
2012-03-08 10:03:27 +01:00
|
|
|
hr = IMXWriter_QueryInterface(writer, &IID_ISAXDeclHandler, (void**)&decl);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
2014-03-03 05:55:59 +01:00
|
|
|
hr = IMXWriter_QueryInterface(writer, &IID_IVBSAXDeclHandler, (void**)&vbdecl);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
2014-03-03 05:56:20 +01:00
|
|
|
hr = IMXWriter_QueryInterface(writer, &IID_IVBSAXLexicalHandler, (void**)&vblexical);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
2012-01-27 14:09:42 +01:00
|
|
|
hr = IMXWriter_put_omitXMLDeclaration(writer, VARIANT_TRUE);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_startDocument(content);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = ISAXLexicalHandler_startDTD(lexical, NULL, 0, NULL, 0, NULL, 0);
|
|
|
|
EXPECT_HR(hr, E_INVALIDARG);
|
|
|
|
|
2014-03-03 05:56:20 +01:00
|
|
|
hr = IVBSAXLexicalHandler_startDTD(vblexical, NULL, NULL, NULL);
|
|
|
|
EXPECT_HR(hr, E_POINTER);
|
|
|
|
|
2012-01-27 14:09:42 +01:00
|
|
|
hr = ISAXLexicalHandler_startDTD(lexical, NULL, 0, pubW, sizeof(pubW)/sizeof(WCHAR), NULL, 0);
|
|
|
|
EXPECT_HR(hr, E_INVALIDARG);
|
|
|
|
|
|
|
|
hr = ISAXLexicalHandler_startDTD(lexical, NULL, 0, NULL, 0, sysW, sizeof(sysW)/sizeof(WCHAR));
|
|
|
|
EXPECT_HR(hr, E_INVALIDARG);
|
|
|
|
|
|
|
|
hr = ISAXLexicalHandler_startDTD(lexical, NULL, 0, pubW, sizeof(pubW)/sizeof(WCHAR), sysW, sizeof(sysW)/sizeof(WCHAR));
|
|
|
|
EXPECT_HR(hr, E_INVALIDARG);
|
|
|
|
|
|
|
|
hr = ISAXLexicalHandler_startDTD(lexical, nameW, sizeof(nameW)/sizeof(WCHAR), NULL, 0, NULL, 0);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_get_output(writer, &dest);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest));
|
|
|
|
ok(!lstrcmpW(_bstr_("<!DOCTYPE name [\r\n"), V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest)));
|
|
|
|
VariantClear(&dest);
|
|
|
|
|
|
|
|
/* system id is required if public is present */
|
|
|
|
hr = ISAXLexicalHandler_startDTD(lexical, nameW, sizeof(nameW)/sizeof(WCHAR), pubW, sizeof(pubW)/sizeof(WCHAR), NULL, 0);
|
|
|
|
EXPECT_HR(hr, E_INVALIDARG);
|
|
|
|
|
|
|
|
hr = ISAXLexicalHandler_startDTD(lexical, nameW, sizeof(nameW)/sizeof(WCHAR),
|
|
|
|
pubW, sizeof(pubW)/sizeof(WCHAR), sysW, sizeof(sysW)/sizeof(WCHAR));
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_get_output(writer, &dest);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest));
|
|
|
|
ok(!lstrcmpW(_bstr_("<!DOCTYPE name [\r\n<!DOCTYPE name PUBLIC \"pub\""
|
|
|
|
"<!DOCTYPE name PUBLIC \"pub\" \"sys\" [\r\n"), V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest)));
|
|
|
|
VariantClear(&dest);
|
|
|
|
|
|
|
|
hr = ISAXLexicalHandler_endDTD(lexical);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
2014-03-03 05:56:20 +01:00
|
|
|
hr = IVBSAXLexicalHandler_endDTD(vblexical);
|
2012-01-27 14:09:42 +01:00
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_get_output(writer, &dest);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest));
|
|
|
|
ok(!lstrcmpW(_bstr_("<!DOCTYPE name [\r\n<!DOCTYPE name PUBLIC \"pub\""
|
|
|
|
"<!DOCTYPE name PUBLIC \"pub\" \"sys\" [\r\n]>\r\n]>\r\n"),
|
|
|
|
V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest)));
|
|
|
|
VariantClear(&dest);
|
|
|
|
|
2012-03-08 10:03:27 +01:00
|
|
|
/* element declaration */
|
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_put_output(writer, dest);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = ISAXDeclHandler_elementDecl(decl, NULL, 0, NULL, 0);
|
|
|
|
EXPECT_HR(hr, E_INVALIDARG);
|
|
|
|
|
2014-03-03 05:55:59 +01:00
|
|
|
hr = IVBSAXDeclHandler_elementDecl(vbdecl, NULL, NULL);
|
|
|
|
EXPECT_HR(hr, E_POINTER);
|
|
|
|
|
2012-03-08 10:03:27 +01:00
|
|
|
hr = ISAXDeclHandler_elementDecl(decl, nameW, sizeof(nameW)/sizeof(WCHAR), NULL, 0);
|
|
|
|
EXPECT_HR(hr, E_INVALIDARG);
|
|
|
|
|
|
|
|
hr = ISAXDeclHandler_elementDecl(decl, nameW, sizeof(nameW)/sizeof(WCHAR), contentW, sizeof(contentW)/sizeof(WCHAR));
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_get_output(writer, &dest);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest));
|
|
|
|
ok(!lstrcmpW(_bstr_("<!ELEMENT name content>\r\n"),
|
|
|
|
V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest)));
|
|
|
|
VariantClear(&dest);
|
|
|
|
|
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_put_output(writer, dest);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = ISAXDeclHandler_elementDecl(decl, nameW, sizeof(nameW)/sizeof(WCHAR), contentW, 0);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_get_output(writer, &dest);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest));
|
|
|
|
ok(!lstrcmpW(_bstr_("<!ELEMENT name >\r\n"),
|
|
|
|
V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest)));
|
|
|
|
VariantClear(&dest);
|
|
|
|
|
2012-06-23 11:38:03 +02:00
|
|
|
/* attribute declaration */
|
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_put_output(writer, dest);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = ISAXDeclHandler_attributeDecl(decl, _bstr_("element"), strlen("element"),
|
|
|
|
_bstr_("attribute"), strlen("attribute"), _bstr_("CDATA"), strlen("CDATA"),
|
|
|
|
_bstr_("#REQUIRED"), strlen("#REQUIRED"), _bstr_("value"), strlen("value"));
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_get_output(writer, &dest);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest));
|
|
|
|
ok(!lstrcmpW(_bstr_("<!ATTLIST element attribute CDATA #REQUIRED \"value\">\r\n"),
|
|
|
|
V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest)));
|
|
|
|
VariantClear(&dest);
|
|
|
|
|
|
|
|
hr = ISAXDeclHandler_attributeDecl(decl, _bstr_("element"), strlen("element"),
|
|
|
|
_bstr_("attribute2"), strlen("attribute2"), _bstr_("CDATA"), strlen("CDATA"),
|
|
|
|
_bstr_("#REQUIRED"), strlen("#REQUIRED"), _bstr_("value2"), strlen("value2"));
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = ISAXDeclHandler_attributeDecl(decl, _bstr_("element2"), strlen("element2"),
|
|
|
|
_bstr_("attribute3"), strlen("attribute3"), _bstr_("CDATA"), strlen("CDATA"),
|
|
|
|
_bstr_("#REQUIRED"), strlen("#REQUIRED"), _bstr_("value3"), strlen("value3"));
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_get_output(writer, &dest);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest));
|
|
|
|
ok(!lstrcmpW(_bstr_("<!ATTLIST element attribute CDATA #REQUIRED \"value\">\r\n"
|
|
|
|
"<!ATTLIST element attribute2 CDATA #REQUIRED \"value2\">\r\n"
|
|
|
|
"<!ATTLIST element2 attribute3 CDATA #REQUIRED \"value3\">\r\n"),
|
|
|
|
V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest)));
|
|
|
|
VariantClear(&dest);
|
|
|
|
|
2012-06-23 11:56:53 +02:00
|
|
|
/* internal entities */
|
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_put_output(writer, dest);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = ISAXDeclHandler_internalEntityDecl(decl, NULL, 0, NULL, 0);
|
|
|
|
EXPECT_HR(hr, E_INVALIDARG);
|
|
|
|
|
2014-03-03 05:55:59 +01:00
|
|
|
hr = IVBSAXDeclHandler_internalEntityDecl(vbdecl, NULL, NULL);
|
|
|
|
EXPECT_HR(hr, E_POINTER);
|
|
|
|
|
2012-06-23 11:56:53 +02:00
|
|
|
hr = ISAXDeclHandler_internalEntityDecl(decl, _bstr_("name"), -1, NULL, 0);
|
|
|
|
EXPECT_HR(hr, E_INVALIDARG);
|
|
|
|
|
|
|
|
hr = ISAXDeclHandler_internalEntityDecl(decl, _bstr_("name"), strlen("name"), _bstr_("value"), strlen("value"));
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_get_output(writer, &dest);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest));
|
|
|
|
ok(!lstrcmpW(_bstr_("<!ENTITY name \"value\">\r\n"), V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest)));
|
|
|
|
VariantClear(&dest);
|
|
|
|
|
2013-07-27 18:37:46 +02:00
|
|
|
/* external entities */
|
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_put_output(writer, dest);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = ISAXDeclHandler_externalEntityDecl(decl, NULL, 0, NULL, 0, NULL, 0);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
|
2014-03-03 05:55:59 +01:00
|
|
|
hr = IVBSAXDeclHandler_externalEntityDecl(vbdecl, NULL, NULL, NULL);
|
|
|
|
ok(hr == E_POINTER, "got 0x%08x\n", hr);
|
|
|
|
|
2013-07-27 18:37:46 +02:00
|
|
|
hr = ISAXDeclHandler_externalEntityDecl(decl, _bstr_("name"), -1, NULL, 0, NULL, 0);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = ISAXDeclHandler_externalEntityDecl(decl, _bstr_("name"), strlen("name"), _bstr_("pubid"), strlen("pubid"),
|
|
|
|
_bstr_("sysid"), strlen("sysid"));
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_get_output(writer, &dest);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest));
|
|
|
|
ok(!lstrcmpW(_bstr_("<!ENTITY name PUBLIC \"pubid\" \"sysid\">\r\n"), V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest)));
|
|
|
|
VariantClear(&dest);
|
|
|
|
|
2012-01-27 14:09:42 +01:00
|
|
|
ISAXContentHandler_Release(content);
|
|
|
|
ISAXLexicalHandler_Release(lexical);
|
2014-03-03 05:56:20 +01:00
|
|
|
IVBSAXLexicalHandler_Release(vblexical);
|
2014-03-03 05:55:59 +01:00
|
|
|
IVBSAXDeclHandler_Release(vbdecl);
|
2012-03-08 10:03:27 +01:00
|
|
|
ISAXDeclHandler_Release(decl);
|
2012-01-27 14:09:42 +01:00
|
|
|
IMXWriter_Release(writer);
|
|
|
|
free_bstrs();
|
2012-01-27 13:30:03 +01:00
|
|
|
}
|
|
|
|
|
2012-02-24 15:38:18 +01:00
|
|
|
typedef struct {
|
|
|
|
const CLSID *clsid;
|
|
|
|
const char *uri;
|
|
|
|
const char *local;
|
|
|
|
const char *qname;
|
|
|
|
const char *type;
|
|
|
|
const char *value;
|
|
|
|
HRESULT hr;
|
|
|
|
} addattribute_test_t;
|
|
|
|
|
|
|
|
static const addattribute_test_t addattribute_data[] = {
|
|
|
|
{ &CLSID_SAXAttributes, NULL, NULL, "ns:qname", NULL, "value", E_INVALIDARG },
|
|
|
|
{ &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 },
|
2012-02-24 16:09:27 +01:00
|
|
|
|
|
|
|
{ &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 },
|
|
|
|
|
2012-02-24 15:38:18 +01:00
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static void test_mxattr_addAttribute(void)
|
|
|
|
{
|
|
|
|
const addattribute_test_t *table = addattribute_data;
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
while (table->clsid)
|
|
|
|
{
|
|
|
|
ISAXAttributes *saxattr;
|
|
|
|
IMXAttributes *mxattr;
|
2012-03-14 07:21:05 +01:00
|
|
|
const WCHAR *value;
|
2012-03-14 10:18:55 +01:00
|
|
|
int len, index;
|
2012-02-24 15:38:18 +01:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if (!is_clsid_supported(table->clsid, mxattributes_support_data))
|
|
|
|
{
|
|
|
|
table++;
|
|
|
|
i++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = CoCreateInstance(table->clsid, 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);
|
|
|
|
|
2012-03-13 09:05:45 +01:00
|
|
|
/* SAXAttributes40 and SAXAttributes60 both crash on this test */
|
2012-02-24 15:38:18 +01:00
|
|
|
if (IsEqualGUID(table->clsid, &CLSID_SAXAttributes) ||
|
|
|
|
IsEqualGUID(table->clsid, &CLSID_SAXAttributes30))
|
|
|
|
{
|
|
|
|
hr = ISAXAttributes_getLength(saxattr, NULL);
|
|
|
|
EXPECT_HR(hr, E_POINTER);
|
|
|
|
}
|
|
|
|
|
|
|
|
len = -1;
|
|
|
|
hr = ISAXAttributes_getLength(saxattr, &len);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(len == 0, "got %d\n", len);
|
2012-03-13 09:05:45 +01:00
|
|
|
|
2012-03-14 07:21:05 +01:00
|
|
|
hr = ISAXAttributes_getValue(saxattr, 0, &value, &len);
|
|
|
|
EXPECT_HR(hr, E_INVALIDARG);
|
|
|
|
|
|
|
|
hr = ISAXAttributes_getValue(saxattr, 0, NULL, &len);
|
2014-03-10 06:16:58 +01:00
|
|
|
ok(hr == E_POINTER /* win8 */ || hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
2012-03-14 07:21:05 +01:00
|
|
|
|
|
|
|
hr = ISAXAttributes_getValue(saxattr, 0, &value, NULL);
|
2014-03-10 06:16:58 +01:00
|
|
|
ok(hr == E_POINTER /* win8 */ || hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
2012-03-14 07:21:05 +01:00
|
|
|
|
|
|
|
hr = ISAXAttributes_getValue(saxattr, 0, NULL, NULL);
|
2014-03-10 06:16:58 +01:00
|
|
|
ok(hr == E_POINTER /* win8 */ || hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
2012-03-14 07:21:05 +01:00
|
|
|
|
2012-03-14 09:44:34 +01:00
|
|
|
hr = ISAXAttributes_getType(saxattr, 0, &value, &len);
|
|
|
|
EXPECT_HR(hr, E_INVALIDARG);
|
|
|
|
|
|
|
|
hr = ISAXAttributes_getType(saxattr, 0, NULL, &len);
|
2014-03-10 06:16:58 +01:00
|
|
|
ok(hr == E_POINTER /* win8 */ || hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
2012-03-14 09:44:34 +01:00
|
|
|
|
|
|
|
hr = ISAXAttributes_getType(saxattr, 0, &value, NULL);
|
2014-03-10 06:16:58 +01:00
|
|
|
ok(hr == E_POINTER /* win8 */ || hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
2012-03-14 09:44:34 +01:00
|
|
|
|
|
|
|
hr = ISAXAttributes_getType(saxattr, 0, NULL, NULL);
|
2014-03-10 06:16:58 +01:00
|
|
|
ok(hr == E_POINTER /* win8 */ || hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
2012-03-14 09:44:34 +01:00
|
|
|
|
2012-02-24 15:38:18 +01:00
|
|
|
hr = IMXAttributes_addAttribute(mxattr, _bstr_(table->uri), _bstr_(table->local),
|
|
|
|
_bstr_(table->qname), _bstr_(table->type), _bstr_(table->value));
|
|
|
|
ok(hr == table->hr, "%d: got 0x%08x, expected 0x%08x\n", i, hr, table->hr);
|
|
|
|
|
2012-03-14 07:21:05 +01:00
|
|
|
if (hr == S_OK)
|
|
|
|
{
|
|
|
|
/* SAXAttributes40 and SAXAttributes60 both crash on this test */
|
|
|
|
if (IsEqualGUID(table->clsid, &CLSID_SAXAttributes) ||
|
|
|
|
IsEqualGUID(table->clsid, &CLSID_SAXAttributes30))
|
|
|
|
{
|
|
|
|
hr = ISAXAttributes_getValue(saxattr, 0, NULL, &len);
|
|
|
|
EXPECT_HR(hr, E_POINTER);
|
|
|
|
|
|
|
|
hr = ISAXAttributes_getValue(saxattr, 0, &value, NULL);
|
|
|
|
EXPECT_HR(hr, E_POINTER);
|
|
|
|
|
|
|
|
hr = ISAXAttributes_getValue(saxattr, 0, NULL, NULL);
|
|
|
|
EXPECT_HR(hr, E_POINTER);
|
2012-03-14 09:44:34 +01:00
|
|
|
|
|
|
|
hr = ISAXAttributes_getType(saxattr, 0, NULL, &len);
|
|
|
|
EXPECT_HR(hr, E_POINTER);
|
|
|
|
|
|
|
|
hr = ISAXAttributes_getType(saxattr, 0, &value, NULL);
|
|
|
|
EXPECT_HR(hr, E_POINTER);
|
|
|
|
|
|
|
|
hr = ISAXAttributes_getType(saxattr, 0, NULL, NULL);
|
|
|
|
EXPECT_HR(hr, E_POINTER);
|
2012-03-14 07:21:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
len = -1;
|
|
|
|
hr = ISAXAttributes_getValue(saxattr, 0, &value, &len);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(!lstrcmpW(_bstr_(table->value), value), "%d: got %s, expected %s\n", i, wine_dbgstr_w(value),
|
|
|
|
table->value);
|
|
|
|
ok(lstrlenW(value) == len, "%d: got wrong value length %d\n", i, len);
|
2012-03-14 09:44:34 +01:00
|
|
|
|
|
|
|
len = -1;
|
|
|
|
value = (void*)0xdeadbeef;
|
|
|
|
hr = ISAXAttributes_getType(saxattr, 0, &value, &len);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
if (table->type)
|
|
|
|
{
|
|
|
|
ok(!lstrcmpW(_bstr_(table->type), value), "%d: got %s, expected %s\n", i, wine_dbgstr_w(value),
|
|
|
|
table->type);
|
|
|
|
ok(lstrlenW(value) == len, "%d: got wrong type value length %d\n", i, len);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ok(*value == 0, "%d: got type value %s\n", i, wine_dbgstr_w(value));
|
|
|
|
ok(len == 0, "%d: got wrong type value length %d\n", i, len);
|
|
|
|
}
|
2012-03-14 10:18:55 +01:00
|
|
|
|
|
|
|
hr = ISAXAttributes_getIndexFromQName(saxattr, NULL, 0, NULL);
|
|
|
|
if (IsEqualGUID(table->clsid, &CLSID_SAXAttributes) ||
|
|
|
|
IsEqualGUID(table->clsid, &CLSID_SAXAttributes30))
|
|
|
|
{
|
|
|
|
EXPECT_HR(hr, E_POINTER);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
EXPECT_HR(hr, E_INVALIDARG);
|
|
|
|
|
|
|
|
hr = ISAXAttributes_getIndexFromQName(saxattr, NULL, 0, &index);
|
|
|
|
EXPECT_HR(hr, E_INVALIDARG);
|
|
|
|
|
|
|
|
index = -1;
|
|
|
|
hr = ISAXAttributes_getIndexFromQName(saxattr, _bstr_("nonexistent"), 11, &index);
|
|
|
|
EXPECT_HR(hr, E_INVALIDARG);
|
|
|
|
ok(index == -1, "%d: got wrong index %d\n", i, index);
|
|
|
|
|
|
|
|
index = -1;
|
|
|
|
hr = ISAXAttributes_getIndexFromQName(saxattr, _bstr_(table->qname), 0, &index);
|
|
|
|
EXPECT_HR(hr, E_INVALIDARG);
|
|
|
|
ok(index == -1, "%d: got wrong index %d\n", i, index);
|
|
|
|
|
|
|
|
index = -1;
|
|
|
|
hr = ISAXAttributes_getIndexFromQName(saxattr, _bstr_(table->qname), strlen(table->qname), &index);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(index == 0, "%d: got wrong index %d\n", i, index);
|
|
|
|
|
|
|
|
index = -1;
|
|
|
|
hr = ISAXAttributes_getIndexFromQName(saxattr, _bstr_(table->qname), strlen(table->qname)-1, &index);
|
|
|
|
EXPECT_HR(hr, E_INVALIDARG);
|
|
|
|
ok(index == -1, "%d: got wrong index %d\n", i, index);
|
2012-03-15 07:58:34 +01:00
|
|
|
|
|
|
|
if (IsEqualGUID(table->clsid, &CLSID_SAXAttributes40) ||
|
|
|
|
IsEqualGUID(table->clsid, &CLSID_SAXAttributes60))
|
|
|
|
{
|
|
|
|
hr = ISAXAttributes_getValueFromQName(saxattr, NULL, 0, NULL, NULL);
|
2014-03-10 06:16:58 +01:00
|
|
|
ok(hr == E_POINTER /* win8 */ || hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
2012-03-15 07:58:34 +01:00
|
|
|
|
|
|
|
hr = ISAXAttributes_getValueFromQName(saxattr, _bstr_(table->qname), 0, NULL, NULL);
|
2014-03-10 06:16:58 +01:00
|
|
|
ok(hr == E_POINTER /* win8 */ || hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
2012-03-15 07:58:34 +01:00
|
|
|
|
|
|
|
hr = ISAXAttributes_getValueFromQName(saxattr, _bstr_(table->qname), 0, &value, NULL);
|
2014-03-10 06:16:58 +01:00
|
|
|
ok(hr == E_POINTER /* win8 */ || hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
2012-04-22 22:00:24 +02:00
|
|
|
|
|
|
|
hr = ISAXAttributes_getValueFromName(saxattr, NULL, 0, NULL, 0, NULL, NULL);
|
2014-03-10 06:16:58 +01:00
|
|
|
ok(hr == E_POINTER /* win8 */ || hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
2012-04-22 22:00:24 +02:00
|
|
|
|
|
|
|
hr = ISAXAttributes_getValueFromName(saxattr, _bstr_(table->uri), 0, NULL, 0, NULL, NULL);
|
2014-03-10 06:16:58 +01:00
|
|
|
ok(hr == E_POINTER /* win8 */ || hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
2012-04-22 22:00:24 +02:00
|
|
|
|
|
|
|
hr = ISAXAttributes_getValueFromName(saxattr, _bstr_(table->uri), 0, NULL, 0, &value, NULL);
|
2014-03-10 06:16:58 +01:00
|
|
|
ok(hr == E_POINTER /* win8 */ || hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
2012-03-15 07:58:34 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hr = ISAXAttributes_getValueFromQName(saxattr, NULL, 0, NULL, NULL);
|
|
|
|
EXPECT_HR(hr, E_POINTER);
|
|
|
|
|
|
|
|
hr = ISAXAttributes_getValueFromQName(saxattr, _bstr_(table->qname), 0, NULL, NULL);
|
|
|
|
EXPECT_HR(hr, E_POINTER);
|
|
|
|
|
|
|
|
hr = ISAXAttributes_getValueFromQName(saxattr, _bstr_(table->qname), 0, &value, NULL);
|
|
|
|
EXPECT_HR(hr, E_POINTER);
|
|
|
|
|
|
|
|
/* versions 4 and 6 crash */
|
|
|
|
hr = ISAXAttributes_getValueFromQName(saxattr, _bstr_(table->qname), strlen(table->qname), NULL, NULL);
|
|
|
|
EXPECT_HR(hr, E_POINTER);
|
|
|
|
|
|
|
|
hr = ISAXAttributes_getValueFromQName(saxattr, _bstr_(table->qname), strlen(table->qname), NULL, &len);
|
|
|
|
EXPECT_HR(hr, E_POINTER);
|
2012-04-22 22:00:24 +02:00
|
|
|
|
|
|
|
hr = ISAXAttributes_getValueFromName(saxattr, NULL, 0, NULL, 0, NULL, NULL);
|
|
|
|
EXPECT_HR(hr, E_POINTER);
|
|
|
|
|
|
|
|
hr = ISAXAttributes_getValueFromName(saxattr, _bstr_(table->uri), 0, NULL, 0, NULL, NULL);
|
|
|
|
EXPECT_HR(hr, E_POINTER);
|
|
|
|
|
|
|
|
hr = ISAXAttributes_getValueFromName(saxattr, _bstr_(table->uri), 0, NULL, 0, &value, NULL);
|
|
|
|
EXPECT_HR(hr, E_POINTER);
|
|
|
|
|
|
|
|
hr = ISAXAttributes_getValueFromName(saxattr, _bstr_(table->uri), 0, _bstr_(table->local), 0, &value, NULL);
|
|
|
|
EXPECT_HR(hr, E_POINTER);
|
|
|
|
|
|
|
|
hr = ISAXAttributes_getValueFromName(saxattr, _bstr_(table->uri), 0, _bstr_(table->local), 0, NULL, &len);
|
|
|
|
EXPECT_HR(hr, E_POINTER);
|
|
|
|
|
|
|
|
hr = ISAXAttributes_getValueFromName(saxattr, _bstr_(table->uri), strlen(table->uri), _bstr_(table->local),
|
|
|
|
strlen(table->local), NULL, NULL);
|
|
|
|
EXPECT_HR(hr, E_POINTER);
|
2012-03-15 07:58:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
hr = ISAXAttributes_getValueFromQName(saxattr, _bstr_(table->qname), strlen(table->qname), &value, &len);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
2012-04-22 22:00:24 +02:00
|
|
|
ok(!lstrcmpW(_bstr_(table->value), value), "%d: got %s, expected %s\n", i, wine_dbgstr_w(value),
|
|
|
|
table->value);
|
|
|
|
ok(lstrlenW(value) == len, "%d: got wrong value length %d\n", i, len);
|
|
|
|
|
|
|
|
if (table->uri) {
|
|
|
|
hr = ISAXAttributes_getValueFromName(saxattr, _bstr_(table->uri), strlen(table->uri),
|
|
|
|
_bstr_(table->local), strlen(table->local), &value, &len);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(!lstrcmpW(_bstr_(table->value), value), "%d: got %s, expected %s\n", i, wine_dbgstr_w(value),
|
|
|
|
table->value);
|
|
|
|
ok(lstrlenW(value) == len, "%d: got wrong value length %d\n", i, len);
|
|
|
|
}
|
2012-03-14 07:21:05 +01:00
|
|
|
}
|
|
|
|
|
2012-02-24 15:38:18 +01:00
|
|
|
len = -1;
|
|
|
|
hr = ISAXAttributes_getLength(saxattr, &len);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
if (table->hr == S_OK)
|
2012-06-04 17:31:18 +02:00
|
|
|
ok(len == 1, "%d: got %d length, expected 1\n", i, len);
|
2012-02-24 15:38:18 +01:00
|
|
|
else
|
2012-06-04 17:31:18 +02:00
|
|
|
ok(len == 0, "%d: got %d length, expected 0\n", i, len);
|
2012-02-24 15:38:18 +01:00
|
|
|
|
|
|
|
ISAXAttributes_Release(saxattr);
|
|
|
|
IMXAttributes_Release(mxattr);
|
|
|
|
|
|
|
|
table++;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
free_bstrs();
|
|
|
|
}
|
|
|
|
|
2012-02-24 16:09:27 +01:00
|
|
|
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);
|
|
|
|
|
2012-04-16 07:32:03 +02:00
|
|
|
hr = IMXAttributes_clear(mxattr);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
2012-02-24 16:09:27 +01:00
|
|
|
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);
|
2012-03-13 09:12:16 +01:00
|
|
|
ok(!lstrcmpW(ptr, _bstr_("qname")), "got %s\n", wine_dbgstr_w(ptr));
|
2012-02-24 16:09:27 +01:00
|
|
|
|
|
|
|
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);
|
2012-04-16 07:32:03 +02:00
|
|
|
|
2012-02-24 16:09:27 +01:00
|
|
|
IMXAttributes_Release(mxattr);
|
|
|
|
ISAXAttributes_Release(saxattr);
|
|
|
|
free_bstrs();
|
|
|
|
}
|
|
|
|
|
2012-03-08 21:11:45 +01:00
|
|
|
static void test_mxattr_dispex(void)
|
|
|
|
{
|
|
|
|
IMXAttributes *mxattr;
|
|
|
|
IDispatchEx *dispex;
|
|
|
|
IUnknown *unk;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_SAXAttributes, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IMXAttributes, (void**)&mxattr);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = IMXAttributes_QueryInterface(mxattr, &IID_IDispatchEx, (void**)&dispex);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
hr = IDispatchEx_QueryInterface(dispex, &IID_IUnknown, (void**)&unk);
|
|
|
|
test_obj_dispex(unk);
|
|
|
|
IUnknown_Release(unk);
|
|
|
|
IDispatchEx_Release(dispex);
|
|
|
|
|
|
|
|
IMXAttributes_Release(mxattr);
|
|
|
|
}
|
|
|
|
|
2012-03-15 10:53:45 +01:00
|
|
|
static void test_mxattr_qi(void)
|
|
|
|
{
|
|
|
|
IVBSAXAttributes *vbsaxattr, *vbsaxattr2;
|
|
|
|
ISAXAttributes *saxattr;
|
|
|
|
IMXAttributes *mxattr;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_SAXAttributes, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IMXAttributes, (void**)&mxattr);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
EXPECT_REF(mxattr, 1);
|
|
|
|
hr = IMXAttributes_QueryInterface(mxattr, &IID_ISAXAttributes, (void**)&saxattr);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
EXPECT_REF(mxattr, 2);
|
|
|
|
EXPECT_REF(saxattr, 2);
|
|
|
|
|
|
|
|
hr = IMXAttributes_QueryInterface(mxattr, &IID_IVBSAXAttributes, (void**)&vbsaxattr);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
EXPECT_REF(vbsaxattr, 3);
|
|
|
|
EXPECT_REF(mxattr, 3);
|
|
|
|
EXPECT_REF(saxattr, 3);
|
|
|
|
|
|
|
|
hr = ISAXAttributes_QueryInterface(saxattr, &IID_IVBSAXAttributes, (void**)&vbsaxattr2);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
EXPECT_REF(vbsaxattr, 4);
|
|
|
|
EXPECT_REF(mxattr, 4);
|
|
|
|
EXPECT_REF(saxattr, 4);
|
|
|
|
|
|
|
|
IMXAttributes_Release(mxattr);
|
|
|
|
ISAXAttributes_Release(saxattr);
|
|
|
|
IVBSAXAttributes_Release(vbsaxattr);
|
|
|
|
IVBSAXAttributes_Release(vbsaxattr2);
|
|
|
|
}
|
|
|
|
|
2012-04-16 08:29:34 +02:00
|
|
|
static struct msxmlsupported_data_t saxattr_support_data[] =
|
|
|
|
{
|
|
|
|
{ &CLSID_SAXAttributes, "SAXAttributes" },
|
|
|
|
{ &CLSID_SAXAttributes30, "SAXAttributes30" },
|
|
|
|
{ &CLSID_SAXAttributes40, "SAXAttributes40" },
|
|
|
|
{ &CLSID_SAXAttributes60, "SAXAttributes60" },
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static void test_mxattr_localname(void)
|
|
|
|
{
|
|
|
|
static const WCHAR localname1W[] = {'l','o','c','a','l','n','a','m','e','1',0};
|
|
|
|
static const WCHAR localnameW[] = {'l','o','c','a','l','n','a','m','e',0};
|
|
|
|
static const WCHAR uri1W[] = {'u','r','i','1',0};
|
|
|
|
static const WCHAR uriW[] = {'u','r','i',0};
|
|
|
|
|
|
|
|
const struct msxmlsupported_data_t *table = saxattr_support_data;
|
|
|
|
|
|
|
|
while (table->clsid)
|
|
|
|
{
|
|
|
|
ISAXAttributes *saxattr;
|
|
|
|
IMXAttributes *mxattr;
|
|
|
|
HRESULT hr;
|
|
|
|
int index;
|
|
|
|
|
|
|
|
if (!is_clsid_supported(table->clsid, mxattributes_support_data))
|
|
|
|
{
|
|
|
|
table++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = CoCreateInstance(table->clsid, 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_getIndexFromName(saxattr, NULL, 0, NULL, 0, &index);
|
|
|
|
EXPECT_HR(hr, E_INVALIDARG);
|
|
|
|
|
|
|
|
/* add some ambiguos attribute names */
|
|
|
|
hr = IMXAttributes_addAttribute(mxattr, _bstr_("uri"), _bstr_("localname"),
|
|
|
|
_bstr_("a:localname"), _bstr_(""), _bstr_("value"));
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
hr = IMXAttributes_addAttribute(mxattr, _bstr_("uri"), _bstr_("localname"),
|
|
|
|
_bstr_("b:localname"), _bstr_(""), _bstr_("value"));
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
index = -1;
|
|
|
|
hr = ISAXAttributes_getIndexFromName(saxattr, uriW, lstrlenW(uriW), localnameW, lstrlenW(localnameW), &index);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(index == 0, "%s: got index %d\n", table->name, index);
|
|
|
|
|
|
|
|
index = -1;
|
|
|
|
hr = ISAXAttributes_getIndexFromName(saxattr, uri1W, lstrlenW(uri1W), localnameW, lstrlenW(localnameW), &index);
|
|
|
|
EXPECT_HR(hr, E_INVALIDARG);
|
|
|
|
ok(index == -1, "%s: got index %d\n", table->name, index);
|
|
|
|
|
|
|
|
index = -1;
|
|
|
|
hr = ISAXAttributes_getIndexFromName(saxattr, uriW, lstrlenW(uriW), localname1W, lstrlenW(localname1W), &index);
|
|
|
|
EXPECT_HR(hr, E_INVALIDARG);
|
|
|
|
ok(index == -1, "%s: got index %d\n", table->name, index);
|
|
|
|
|
|
|
|
if (IsEqualGUID(table->clsid, &CLSID_SAXAttributes) ||
|
|
|
|
IsEqualGUID(table->clsid, &CLSID_SAXAttributes30))
|
|
|
|
{
|
|
|
|
hr = ISAXAttributes_getIndexFromName(saxattr, NULL, 0, NULL, 0, NULL);
|
|
|
|
EXPECT_HR(hr, E_POINTER);
|
|
|
|
|
|
|
|
hr = ISAXAttributes_getIndexFromName(saxattr, uriW, lstrlenW(uriW), localname1W, lstrlenW(localname1W), NULL);
|
|
|
|
EXPECT_HR(hr, E_POINTER);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hr = ISAXAttributes_getIndexFromName(saxattr, NULL, 0, NULL, 0, NULL);
|
|
|
|
EXPECT_HR(hr, E_INVALIDARG);
|
|
|
|
|
|
|
|
hr = ISAXAttributes_getIndexFromName(saxattr, uriW, lstrlenW(uriW), localname1W, lstrlenW(localname1W), NULL);
|
|
|
|
EXPECT_HR(hr, E_INVALIDARG);
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = ISAXAttributes_getIndexFromName(saxattr, uriW, lstrlenW(uriW), NULL, 0, &index);
|
|
|
|
EXPECT_HR(hr, E_INVALIDARG);
|
|
|
|
|
|
|
|
hr = ISAXAttributes_getIndexFromName(saxattr, NULL, 0, localname1W, lstrlenW(localname1W), &index);
|
|
|
|
EXPECT_HR(hr, E_INVALIDARG);
|
|
|
|
|
|
|
|
table++;
|
|
|
|
|
|
|
|
ISAXAttributes_Release(saxattr);
|
|
|
|
IMXAttributes_Release(mxattr);
|
2014-05-04 18:33:35 +02:00
|
|
|
free_bstrs();
|
2012-04-16 08:29:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-27 16:27:27 +02:00
|
|
|
static void test_mxwriter_indent(void)
|
|
|
|
{
|
|
|
|
ISAXContentHandler *content;
|
|
|
|
IMXWriter *writer;
|
|
|
|
VARIANT dest;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_MXXMLWriter, NULL, CLSCTX_INPROC_SERVER, &IID_IMXWriter, (void**)&writer);
|
|
|
|
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
|
|
|
|
|
|
|
hr = IMXWriter_put_indent(writer, VARIANT_TRUE);
|
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
|
|
|
|
|
|
|
hr = IMXWriter_QueryInterface(writer, &IID_ISAXContentHandler, (void**)&content);
|
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_startDocument(content);
|
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_startElement(content, emptyW, 0, emptyW, 0, _bstr_("a"), -1, NULL);
|
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_characters(content, _bstr_(""), 0);
|
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_startElement(content, emptyW, 0, emptyW, 0, _bstr_("b"), -1, NULL);
|
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_startElement(content, emptyW, 0, emptyW, 0, _bstr_("c"), -1, NULL);
|
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_endElement(content, emptyW, 0, emptyW, 0, _bstr_("c"), -1);
|
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_endElement(content, emptyW, 0, emptyW, 0, _bstr_("b"), -1);
|
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_endElement(content, emptyW, 0, emptyW, 0, _bstr_("a"), -1);
|
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
|
|
|
|
|
|
|
hr = ISAXContentHandler_endDocument(content);
|
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
|
|
|
|
|
|
|
V_VT(&dest) = VT_EMPTY;
|
|
|
|
hr = IMXWriter_get_output(writer, &dest);
|
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
|
|
|
ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest));
|
|
|
|
ok(!lstrcmpW(_bstr_("<?xml version=\"1.0\" encoding=\"UTF-16\" standalone=\"no\"?>\r\n<a><b>\r\n\t\t<c/>\r\n\t</b>\r\n</a>"), V_BSTR(&dest)),
|
|
|
|
"got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest)));
|
|
|
|
VariantClear(&dest);
|
|
|
|
|
|
|
|
ISAXContentHandler_Release(content);
|
|
|
|
IMXWriter_Release(writer);
|
|
|
|
|
|
|
|
free_bstrs();
|
|
|
|
}
|
|
|
|
|
2008-07-08 20:53:43 +02:00
|
|
|
START_TEST(saxreader)
|
|
|
|
{
|
2010-10-28 23:00:44 +02:00
|
|
|
ISAXXMLReader *reader;
|
2008-07-08 20:53:43 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = CoInitialize(NULL);
|
|
|
|
ok(hr == S_OK, "failed to init com\n");
|
|
|
|
|
2010-10-28 23:00:44 +02:00
|
|
|
hr = CoCreateInstance(&CLSID_SAXXMLReader, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_ISAXXMLReader, (void**)&reader);
|
|
|
|
|
|
|
|
if(FAILED(hr))
|
|
|
|
{
|
|
|
|
skip("Failed to create SAXXMLReader instance\n");
|
|
|
|
CoUninitialize();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ISAXXMLReader_Release(reader);
|
|
|
|
|
2012-04-15 11:47:30 +02:00
|
|
|
init_call_sequences(sequences, NUM_CALL_SEQUENCES);
|
|
|
|
|
|
|
|
get_class_support_data(reader_support_data, &IID_ISAXXMLReader);
|
|
|
|
|
|
|
|
test_saxreader();
|
2011-09-21 19:01:10 +02:00
|
|
|
test_saxreader_properties();
|
2011-10-05 20:29:37 +02:00
|
|
|
test_saxreader_features();
|
2012-04-21 10:32:15 +02:00
|
|
|
test_saxreader_encoding();
|
2014-03-07 09:07:27 +01:00
|
|
|
test_saxreader_dispex();
|
2011-05-01 10:04:59 +02:00
|
|
|
|
2011-08-26 06:09:31 +02:00
|
|
|
/* MXXMLWriter tests */
|
2012-04-15 11:47:30 +02:00
|
|
|
get_class_support_data(mxwriter_support_data, &IID_IMXWriter);
|
2012-02-24 15:38:18 +01:00
|
|
|
if (is_clsid_supported(&CLSID_MXXMLWriter, mxwriter_support_data))
|
2011-05-01 10:04:59 +02:00
|
|
|
{
|
2012-01-27 12:45:21 +01:00
|
|
|
test_mxwriter_handlers();
|
2011-05-01 18:05:31 +02:00
|
|
|
test_mxwriter_startenddocument();
|
2011-05-04 10:21:39 +02:00
|
|
|
test_mxwriter_startendelement();
|
2011-05-07 19:51:33 +02:00
|
|
|
test_mxwriter_characters();
|
2012-01-27 13:13:54 +01:00
|
|
|
test_mxwriter_comment();
|
2012-01-27 13:30:03 +01:00
|
|
|
test_mxwriter_cdata();
|
2012-03-17 08:33:04 +01:00
|
|
|
test_mxwriter_pi();
|
2012-03-17 08:41:43 +01:00
|
|
|
test_mxwriter_ignorablespaces();
|
2012-01-27 14:09:42 +01:00
|
|
|
test_mxwriter_dtd();
|
2011-05-01 10:04:59 +02:00
|
|
|
test_mxwriter_properties();
|
|
|
|
test_mxwriter_flush();
|
2011-08-13 01:11:30 +02:00
|
|
|
test_mxwriter_stream();
|
2011-08-13 01:11:54 +02:00
|
|
|
test_mxwriter_encoding();
|
2011-12-05 09:07:26 +01:00
|
|
|
test_mxwriter_dispex();
|
2013-07-27 16:27:27 +02:00
|
|
|
test_mxwriter_indent();
|
2011-05-01 10:04:59 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
win_skip("MXXMLWriter not supported\n");
|
2008-07-08 20:53:43 +02:00
|
|
|
|
2012-02-24 15:38:18 +01:00
|
|
|
/* SAXAttributes tests */
|
2012-04-15 11:47:30 +02:00
|
|
|
get_class_support_data(mxattributes_support_data, &IID_IMXAttributes);
|
2012-02-24 15:38:18 +01:00
|
|
|
if (is_clsid_supported(&CLSID_SAXAttributes, mxattributes_support_data))
|
|
|
|
{
|
2012-03-15 10:53:45 +01:00
|
|
|
test_mxattr_qi();
|
2012-02-24 15:38:18 +01:00
|
|
|
test_mxattr_addAttribute();
|
2012-02-24 16:09:27 +01:00
|
|
|
test_mxattr_clear();
|
2012-04-16 08:29:34 +02:00
|
|
|
test_mxattr_localname();
|
2012-03-08 21:11:45 +01:00
|
|
|
test_mxattr_dispex();
|
2012-02-24 15:38:18 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
skip("SAXAttributes not supported\n");
|
|
|
|
|
2008-07-08 20:53:43 +02:00
|
|
|
CoUninitialize();
|
|
|
|
}
|