diff options
author | David Tardon <dtardon@redhat.com> | 2014-01-27 18:10:02 +0100 |
---|---|---|
committer | David Tardon <dtardon@redhat.com> | 2014-01-27 18:14:05 +0100 |
commit | 2dd8e2ce5c61fc14035e4a0732194c926539714c (patch) | |
tree | 9ef1c08353aafc64079673b23b808943564a5d7c /writerperfect/qa | |
parent | a6b0c67ee5202e97992c55201d82df071b059dd3 (diff) |
add test for structured content
Change-Id: I039e5ccfd6946f3f16505b6265e248fbead37a64
Diffstat (limited to 'writerperfect/qa')
-rw-r--r-- | writerperfect/qa/unit/WPXSvStreamTest.cxx | 57 | ||||
-rw-r--r-- | writerperfect/qa/unit/data/fdo40686-1.doc | bin | 0 -> 12288 bytes | |||
-rw-r--r-- | writerperfect/qa/unit/data/test.odt | bin | 0 -> 8486 bytes |
3 files changed, 57 insertions, 0 deletions
diff --git a/writerperfect/qa/unit/WPXSvStreamTest.cxx b/writerperfect/qa/unit/WPXSvStreamTest.cxx index 660d69e57ff8..3452bf6e5297 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 Binary files differnew file mode 100644 index 000000000000..bb0fd59274fd --- /dev/null +++ b/writerperfect/qa/unit/data/fdo40686-1.doc diff --git a/writerperfect/qa/unit/data/test.odt b/writerperfect/qa/unit/data/test.odt Binary files differnew file mode 100644 index 000000000000..5688df4f92b1 --- /dev/null +++ b/writerperfect/qa/unit/data/test.odt |