[Libreoffice-commits] core.git: 2 commits - package/source writerperfect/CppunitTest_writerperfect_stream.mk writerperfect/qa
David Tardon
dtardon at redhat.com
Mon Jan 27 09:14:50 PST 2014
package/source/zippackage/zipfileaccess.cxx | 2
writerperfect/CppunitTest_writerperfect_stream.mk | 3 +
writerperfect/qa/unit/WPXSvStreamTest.cxx | 57 ++++++++++++++++++++++
writerperfect/qa/unit/data/fdo40686-1.doc |binary
writerperfect/qa/unit/data/test.odt |binary
5 files changed, 61 insertions(+), 1 deletion(-)
New commits:
commit 2dd8e2ce5c61fc14035e4a0732194c926539714c
Author: David Tardon <dtardon at redhat.com>
Date: Mon Jan 27 18:10:02 2014 +0100
add test for structured content
Change-Id: I039e5ccfd6946f3f16505b6265e248fbead37a64
diff --git a/writerperfect/CppunitTest_writerperfect_stream.mk b/writerperfect/CppunitTest_writerperfect_stream.mk
index b247cf3..b469658 100644
--- a/writerperfect/CppunitTest_writerperfect_stream.mk
+++ b/writerperfect/CppunitTest_writerperfect_stream.mk
@@ -34,6 +34,7 @@ $(eval $(call gb_CppunitTest_use_libraries,writerperfect_stream,\
sot \
test \
tl \
+ unotest \
utl \
))
@@ -45,6 +46,8 @@ $(eval $(call gb_CppunitTest_use_configuration,writerperfect_stream))
$(eval $(call gb_CppunitTest_use_components,writerperfect_stream,\
configmgr/source/configmgr \
+ i18npool/util/i18npool \
+ package/util/package2 \
ucb/source/core/ucb1 \
ucb/source/ucp/file/ucpfile1 \
))
diff --git a/writerperfect/qa/unit/WPXSvStreamTest.cxx b/writerperfect/qa/unit/WPXSvStreamTest.cxx
index 660d69e..3452bf6 100644
--- a/writerperfect/qa/unit/WPXSvStreamTest.cxx
+++ b/writerperfect/qa/unit/WPXSvStreamTest.cxx
@@ -16,8 +16,10 @@
#include <cppunit/plugin/TestPlugIn.h>
#include "com/sun/star/io/XInputStream.hpp"
+#include "com/sun/star/ucb/XSimpleFileAccess.hpp"
#include "com/sun/star/uno/Reference.hxx"
+#include "comphelper/processfactory.hxx"
#include "comphelper/seqstream.hxx"
#include "rtl/ref.hxx"
@@ -27,6 +29,7 @@
#include "WPXSvStream.hxx"
namespace io = com::sun::star::io;
+namespace ucb = com::sun::star::ucb;
namespace uno = com::sun::star::uno;
using boost::shared_ptr;
@@ -44,6 +47,7 @@ public:
CPPUNIT_TEST(testSeekSet);
CPPUNIT_TEST(testSeekCur);
CPPUNIT_TEST(testSeekEnd);
+ CPPUNIT_TEST(testStructured);
CPPUNIT_TEST_SUITE_END();
private:
@@ -51,9 +55,12 @@ private:
void testSeekSet();
void testSeekCur();
void testSeekEnd();
+ void testStructured();
};
static const char aText[] = "hello world";
+static const char aOLEFile[] = "/writerperfect/qa/unit/data/fdo40686-1.doc";
+static const char aZipFile[] = "/writerperfect/qa/unit/data/test.odt";
shared_ptr<WPXInputStream> lcl_createStream()
{
@@ -69,6 +76,21 @@ shared_ptr<WPXInputStream> lcl_createStream()
return pInputStream;
}
+const shared_ptr<WPXInputStream> lcl_createStreamForURL(const rtl::OUString &rURL)
+{
+ using uno::Reference;
+ using uno::UNO_QUERY_THROW;
+
+ const Reference<uno::XComponentContext> xContext(comphelper::getProcessComponentContext(), UNO_QUERY_THROW);
+ const Reference<ucb::XSimpleFileAccess> xFileAccess(
+ xContext->getServiceManager()->createInstanceWithContext("com.sun.star.ucb.SimpleFileAccess", xContext),
+ UNO_QUERY_THROW);
+ const Reference<io::XInputStream> xInputStream(xFileAccess->openFileRead(rURL), UNO_QUERY_THROW);
+
+ const shared_ptr<WPXInputStream> pInput(new WPXSvInputStream(xInputStream));
+ return pInput;
+}
+
void WPXSvStreamTest::testRead()
{
const shared_ptr<WPXInputStream> pInput(lcl_createStream());
@@ -244,6 +266,41 @@ void WPXSvStreamTest::testSeekEnd()
CPPUNIT_ASSERT(!pInput->atEOS());
}
+void WPXSvStreamTest::testStructured()
+{
+ // OLE2
+ {
+ const shared_ptr<WPXInputStream> pInput(lcl_createStreamForURL(getURLFromSrc(aOLEFile)));
+ assert(bool(pInput));
+
+ CPPUNIT_ASSERT(pInput->isOLEStream());
+ shared_ptr<WPXInputStream> pSubStream(pInput->getDocumentOLEStream("WordDocument"));
+ CPPUNIT_ASSERT(bool(pSubStream));
+ pSubStream.reset(pInput->getDocumentOLEStream("foo"));
+ CPPUNIT_ASSERT(!pSubStream);
+ }
+
+ // Zip
+ {
+ const shared_ptr<WPXInputStream> pInput(lcl_createStreamForURL(getURLFromSrc(aZipFile)));
+ assert(bool(pInput));
+
+ CPPUNIT_ASSERT(pInput->isOLEStream());
+ shared_ptr<WPXInputStream> pSubStream(pInput->getDocumentOLEStream("content.xml"));
+ CPPUNIT_ASSERT(bool(pSubStream));
+ pSubStream.reset(pInput->getDocumentOLEStream("foo"));
+ CPPUNIT_ASSERT(!pSubStream);
+ }
+
+ // not structured
+ {
+ const shared_ptr<WPXInputStream> pInput(lcl_createStream());
+
+ CPPUNIT_ASSERT(!pInput->isOLEStream());
+ CPPUNIT_ASSERT(0 == pInput->getDocumentOLEStream("foo"));
+ }
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(WPXSvStreamTest);
}
diff --git a/writerperfect/qa/unit/data/fdo40686-1.doc b/writerperfect/qa/unit/data/fdo40686-1.doc
new file mode 100644
index 0000000..bb0fd59
Binary files /dev/null and b/writerperfect/qa/unit/data/fdo40686-1.doc differ
diff --git a/writerperfect/qa/unit/data/test.odt b/writerperfect/qa/unit/data/test.odt
new file mode 100644
index 0000000..5688df4
Binary files /dev/null and b/writerperfect/qa/unit/data/test.odt differ
commit a6b0c67ee5202e97992c55201d82df071b059dd3
Author: David Tardon <dtardon at redhat.com>
Date: Mon Jan 27 18:10:27 2014 +0100
css::io::XInputStream _is_ allowed
Change-Id: Ib72c02a329bbc9a26390a16e115fd8ae94343263
diff --git a/package/source/zippackage/zipfileaccess.cxx b/package/source/zippackage/zipfileaccess.cxx
index 3139c10..44a27b4 100644
--- a/package/source/zippackage/zipfileaccess.cxx
+++ b/package/source/zippackage/zipfileaccess.cxx
@@ -199,7 +199,7 @@ void SAL_CALL OZipFileAccess::initialize( const uno::Sequence< uno::Any >& aArgu
m_xContentStream = xStream->getInputStream();
xSeekable = uno::Reference< io::XSeekable >( xStream, uno::UNO_QUERY );
}
- else if ( !( aArguments[0] >>= m_xContentStream ) )
+ else if ( aArguments[0] >>= m_xContentStream )
{
xSeekable = uno::Reference< io::XSeekable >( m_xContentStream, uno::UNO_QUERY );
}
More information about the Libreoffice-commits
mailing list