summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/test/htmltesttools.hxx2
-rw-r--r--include/test/xmltesttools.hxx6
-rw-r--r--test/source/htmltesttools.cxx13
-rw-r--r--test/source/xmltesttools.cxx17
4 files changed, 32 insertions, 6 deletions
diff --git a/include/test/htmltesttools.hxx b/include/test/htmltesttools.hxx
index 1cc493241e83..8889a6eaeddf 100644
--- a/include/test/htmltesttools.hxx
+++ b/include/test/htmltesttools.hxx
@@ -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
diff --git a/include/test/xmltesttools.hxx b/include/test/xmltesttools.hxx
index 3473f97a3c88..8937211b9f3f 100644
--- a/include/test/xmltesttools.hxx
+++ b/include/test/xmltesttools.hxx
@@ -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);
diff --git a/test/source/htmltesttools.cxx b/test/source/htmltesttools.cxx
index 9b264bb3f4e9..ba48aae31769 100644
--- a/test/source/htmltesttools.cxx
+++ b/test/source/htmltesttools.cxx
@@ -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);
}
diff --git a/test/source/xmltesttools.cxx b/test/source/xmltesttools.cxx
index e80674d2238b..1cb231c0849d 100644
--- a/test/source/xmltesttools.cxx
+++ b/test/source/xmltesttools.cxx
@@ -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);