1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
|
/*
* XML Parser implementation
*
* Copyright 2011 Alistair Leslie-Hughes
*
* 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>
#include <assert.h>
#include "windows.h"
#include "ole2.h"
#include "xmlparser.h"
#include "wine/test.h"
static HRESULT WINAPI nodefact_QueryInterface(IXMLNodeFactory *iface,
REFIID riid, void **ppvObject)
{
*ppvObject = NULL;
if (IsEqualGUID(riid, &IID_IXMLNodeFactory) ||
IsEqualGUID(riid, &IID_IUnknown))
*ppvObject = iface;
else
return E_NOINTERFACE;
return S_OK;
}
static ULONG WINAPI nodefact_AddRef(IXMLNodeFactory *iface)
{
return 2;
}
static ULONG WINAPI nodefact_Release(IXMLNodeFactory *iface)
{
return 1;
}
static HRESULT WINAPI nodefact_NotifyEvent(IXMLNodeFactory *iface,
IXMLNodeSource *pSource, XML_NODEFACTORY_EVENT iEvt)
{
return E_NOTIMPL;
}
static HRESULT WINAPI nodefact_BeginChildren(IXMLNodeFactory *iface,
IXMLNodeSource *pSource, XML_NODE_INFO *pNodeInfo)
{
return E_NOTIMPL;
}
static HRESULT WINAPI nodefact_EndChildren(IXMLNodeFactory *iface,
IXMLNodeSource *pSource, BOOL fEmpty, XML_NODE_INFO *pNodeInfo)
{
return E_NOTIMPL;
}
static HRESULT WINAPI nodefact_Error(IXMLNodeFactory *iface,
IXMLNodeSource *pSource, HRESULT hrErrorCode, USHORT cNumRecs,
XML_NODE_INFO **ppNodeInfo)
{
return E_NOTIMPL;
}
static HRESULT WINAPI nodefact_CreateNode(IXMLNodeFactory *iface, IXMLNodeSource *pSource,
PVOID pNodeParent, USHORT cNumRecs, XML_NODE_INFO **ppNodeInfo)
{
return E_NOTIMPL;
}
static const IXMLNodeFactoryVtbl nodefactoryVtbl =
{
nodefact_QueryInterface,
nodefact_AddRef,
nodefact_Release,
nodefact_NotifyEvent,
nodefact_BeginChildren,
nodefact_EndChildren,
nodefact_Error,
nodefact_CreateNode
};
static IXMLNodeFactory thenodefactory = { &nodefactoryVtbl };
static void create_test(void)
{
HRESULT hr;
IXMLParser *parser;
IXMLNodeFactory *nodefactory;
DWORD flags;
hr = CoCreateInstance(&CLSID_XMLParser30, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLParser, (void**)&parser);
if (FAILED(hr))
{
win_skip("IXMLParser is not available (0x%08x)\n", hr);
return;
}
flags = IXMLParser_GetFlags(parser);
ok(flags == 0, "Expected 0 got %d\n", flags);
hr = IXMLParser_SetFlags(parser, XMLFLAG_SAX);
ok(hr == S_OK, "Expected S_OK got 0x%08x\n", hr);
flags = IXMLParser_GetFlags(parser);
ok(flags == XMLFLAG_SAX, "Expected 0 got %d\n", flags);
hr = IXMLParser_GetFactory(parser, NULL);
ok(hr == E_INVALIDARG, "Expected S_OK got 0x%08x\n", hr);
hr = IXMLParser_GetFactory(parser, &nodefactory);
ok(hr == S_OK, "Expected S_OK got 0x%08x\n", hr);
ok(nodefactory == NULL, "expected NULL\n");
hr = IXMLParser_SetFactory(parser, &thenodefactory);
ok(hr == S_OK, "Expected S_OK got 0x%08x\n", hr);
hr = IXMLParser_GetFactory(parser, &nodefactory);
ok(hr == S_OK, "Expected S_OK got 0x%08x\n", hr);
ok(nodefactory == &thenodefactory, "expected NULL\n");
hr = IXMLParser_SetInput(parser, NULL);
ok(hr == E_INVALIDARG, "Expected S_OK got 0x%08x\n", hr);
hr = IXMLParser_SetFactory(parser, NULL);
ok(hr == S_OK, "Expected S_OK got 0x%08x\n", hr);
hr = IXMLParser_SetFlags(parser, 0);
ok(hr == S_OK, "Expected S_OK got 0x%08x\n", hr);
hr = IXMLParser_GetParserState(parser);
ok(hr == XMLPARSER_IDLE, "got 0x%08x\n", hr);
IXMLParser_Release(parser);
}
START_TEST(xmlparser)
{
HRESULT hr;
hr = CoInitialize( NULL );
ok( hr == S_OK, "failed to init com\n");
if (hr != S_OK)
return;
create_test();
CoUninitialize();
}
|