Kaydet (Commit) 780cedb2 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl

test: parseXmlStream & parseHtmlStream added to test tools

Change-Id: Iff8af5e9ffefb4c3cecf387b16473d45e8b4a65a
üst 7da0a6e5
......@@ -17,12 +17,12 @@
#include <libxml/HTMLtree.h>
#include <unotools/tempfile.hxx>
#include <boost/scoped_array.hpp>
class OOO_DLLPUBLIC_TEST HtmlTestTools
{
protected:
htmlDocPtr parseHtml(utl::TempFile& aTempFile);
htmlDocPtr parseHtmlStream(SvStream* pStream);
};
#endif
......
......@@ -14,12 +14,15 @@
#include <test/testdllapi.hxx>
#include <libxml/xmlwriter.h>
#include <libxml/tree.h>
#include <libxml/xpath.h>
#include <libxml/xpathInternals.h>
#include <libxml/parserInternals.h>
#include <rtl/string.hxx>
#include <rtl/ustring.hxx>
#include <unotools/tempfile.hxx>
#include <cppunit/TestAssert.h>
class OOO_DLLPUBLIC_TEST XmlTestTools
......@@ -28,6 +31,9 @@ protected:
XmlTestTools();
virtual ~XmlTestTools();
htmlDocPtr parseXml(utl::TempFile& aTempFile);
htmlDocPtr parseXmlStream(SvStream* pStream);
virtual void registerNamespaces(xmlXPathContextPtr& pXmlXpathCtx);
xmlNodeSetPtr getXPathNode(xmlDocPtr pXmlDoc, const OString& rXPath);
......
......@@ -9,17 +9,20 @@
#include <test/htmltesttools.hxx>
#include <boost/scoped_array.hpp>
htmlDocPtr HtmlTestTools::parseHtml(utl::TempFile& aTempFile)
{
SvFileStream aFileStream(aTempFile.GetURL(), STREAM_READ);
sal_Size nSize = aFileStream.remainingSize();
return parseHtmlStream(&aFileStream);
}
htmlDocPtr HtmlTestTools::parseHtmlStream(SvStream* pStream)
{
sal_Size nSize = pStream->remainingSize();
boost::scoped_array<sal_uInt8> pBuffer(new sal_uInt8[nSize + 1]);
aFileStream.Read(pBuffer.get(), nSize);
pStream->Read(pBuffer.get(), nSize);
pBuffer[nSize] = 0;
return htmlParseDoc(reinterpret_cast<xmlChar*>(pBuffer.get()), NULL);
}
......
......@@ -9,12 +9,29 @@
#include <test/xmltesttools.hxx>
#include <boost/scoped_array.hpp>
XmlTestTools::XmlTestTools()
{}
XmlTestTools::~XmlTestTools()
{}
htmlDocPtr XmlTestTools::parseXml(utl::TempFile& aTempFile)
{
SvFileStream aFileStream(aTempFile.GetURL(), STREAM_READ);
return parseXmlStream(&aFileStream);
}
xmlDocPtr XmlTestTools::parseXmlStream(SvStream* pStream)
{
sal_Size nSize = pStream->remainingSize();
boost::scoped_array<sal_uInt8> pBuffer(new sal_uInt8[nSize + 1]);
pStream->Read(pBuffer.get(), nSize);
pBuffer[nSize] = 0;
return xmlParseDoc(reinterpret_cast<xmlChar*>(pBuffer.get()));
}
xmlNodeSetPtr XmlTestTools::getXPathNode(xmlDocPtr pXmlDoc, const OString& rXPath)
{
xmlXPathContextPtr pXmlXpathCtx = xmlXPathNewContext(pXmlDoc);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment