diff options
author | David Tardon <dtardon@redhat.com> | 2017-01-17 19:13:28 +0100 |
---|---|---|
committer | David Tardon <dtardon@redhat.com> | 2017-01-29 20:21:29 +0100 |
commit | 69c03000038e96d120f57b8259763e27907b8470 (patch) | |
tree | 996476144e64fcaa0a9c9044553c4e35df953cee /writerperfect/qa/unit | |
parent | 05ce36d2e2bada48ee97d6a7c45e3bcf71dff29a (diff) |
eliminate some code duplicity
Change-Id: I7792ddd691f81744971d45e1155e3192b24155dc
Diffstat (limited to 'writerperfect/qa/unit')
-rw-r--r-- | writerperfect/qa/unit/DirectoryStreamTest.cxx | 38 |
1 files changed, 4 insertions, 34 deletions
diff --git a/writerperfect/qa/unit/DirectoryStreamTest.cxx b/writerperfect/qa/unit/DirectoryStreamTest.cxx index 0b347ac40d71..730ce41aa718 100644 --- a/writerperfect/qa/unit/DirectoryStreamTest.cxx +++ b/writerperfect/qa/unit/DirectoryStreamTest.cxx @@ -20,7 +20,6 @@ #include <test/bootstrapfixture.hxx> #include <DirectoryStream.hxx> -#include <com/sun/star/container/XChild.hpp> #include <com/sun/star/ucb/XContent.hpp> namespace ucb = com::sun::star::ucb; @@ -64,35 +63,6 @@ static const char g_aDirPath[] = "/writerperfect/qa/unit/data/stream/test.dir"; static const char g_aNondirPath[] = "/writerperfect/qa/unit/data/stream/test.dir/mimetype"; static const char g_aNonexistentPath[] = "/writerperfect/qa/unit/data/stream/foo/bar"; -std::unique_ptr<DirectoryStream> createForParent(const css::uno::Reference<css::ucb::XContent> &xContent) -{ - try - { - if (!xContent.is()) - return nullptr; - - unique_ptr<DirectoryStream> pDir; - - const uno::Reference<css::container::XChild> xChild(xContent, uno::UNO_QUERY); - if (xChild.is()) - { - const uno::Reference<ucb::XContent> xDirContent(xChild->getParent(), uno::UNO_QUERY); - if (xDirContent.is()) - { - pDir = o3tl::make_unique<DirectoryStream>(xDirContent); - if (!pDir->isStructured()) - pDir.reset(); - } - } - - return pDir; - } - catch (...) - { - return nullptr; - } -} - DirectoryStreamTest::DirectoryStreamTest() { const uno::Reference<ucb::XCommandEnvironment> xCmdEnv; @@ -107,17 +77,17 @@ DirectoryStreamTest::DirectoryStreamTest() void DirectoryStreamTest::testConstruction() { - const unique_ptr<DirectoryStream> pDir(createForParent(m_xFile)); + const unique_ptr<DirectoryStream> pDir(DirectoryStream::createForParent(m_xFile)); CPPUNIT_ASSERT(bool(pDir)); CPPUNIT_ASSERT(pDir->isStructured()); // this should work for dirs too - const unique_ptr<DirectoryStream> pDir2(createForParent(m_xDir)); + const unique_ptr<DirectoryStream> pDir2(DirectoryStream::createForParent(m_xDir)); CPPUNIT_ASSERT(bool(pDir2)); CPPUNIT_ASSERT(pDir2->isStructured()); // for nonexistent dirs nothing is created - const unique_ptr<DirectoryStream> pNondir(createForParent(m_xNonexistent)); + const unique_ptr<DirectoryStream> pNondir(DirectoryStream::createForParent(m_xNonexistent)); CPPUNIT_ASSERT(!pNondir); // even if we try harder, just an empty shell is created @@ -169,7 +139,7 @@ void DirectoryStreamTest::testStructuredOperations() DirectoryStream aDir(m_xDir); lcl_testStructuredOperations(aDir); - unique_ptr<DirectoryStream> pDir(createForParent(m_xFile)); + unique_ptr<DirectoryStream> pDir(DirectoryStream::createForParent(m_xFile)); CPPUNIT_ASSERT(bool(pDir)); lcl_testStructuredOperations(*pDir.get()); } |