summaryrefslogtreecommitdiff
path: root/test/source
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.com>2014-05-15 16:04:47 +0200
committerTomaž Vajngerl <tomaz.vajngerl@collabora.com>2014-05-15 19:51:08 +0200
commit780cedb2cf63f6ffa3290d053172a117384b7383 (patch)
tree0f4b367572a7ce70c3b3a97b57a91f0622c7de67 /test/source
parent7da0a6e562de26222a8c56ae9a5a51611264c59a (diff)
test: parseXmlStream & parseHtmlStream added to test tools
Change-Id: Iff8af5e9ffefb4c3cecf387b16473d45e8b4a65a
Diffstat (limited to 'test/source')
-rw-r--r--test/source/htmltesttools.cxx13
-rw-r--r--test/source/xmltesttools.cxx17
2 files changed, 25 insertions, 5 deletions
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);