diff options
author | Noel Grandin <noel@peralex.com> | 2016-02-02 16:15:51 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2016-02-08 06:08:14 +0000 |
commit | b14224fe97b8a44232c9c1401d3a49771f46582e (patch) | |
tree | 8f9cf31cf4b51a0edbb43022499a6acd17d0945d /writerperfect/qa/unit | |
parent | c474e610e453d0f38f7cc6cb9559ad7e7b5d69ca (diff) |
loplugin:unusedmethods
using an idea from dtardon:
<dtardon> noelgrandin, hi. could you try to run the unusedmethods clang
plugin with "make build-nocheck"? that would catch functions that are
only used in tests. e.g., i just removed the whole o3tl::range class,
which has not been used in many years, but htere was a test for it...
<noelgrandin> dtardon, interesting idea! Sure, I can do that.
Change-Id: I5653953a426a2186a1e43017212d87ffce520387
Reviewed-on: https://gerrit.libreoffice.org/22041
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Tested-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'writerperfect/qa/unit')
-rw-r--r-- | writerperfect/qa/unit/DirectoryStreamTest.cxx | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/writerperfect/qa/unit/DirectoryStreamTest.cxx b/writerperfect/qa/unit/DirectoryStreamTest.cxx index effedf8c5e4e..a3c399b7678c 100644 --- a/writerperfect/qa/unit/DirectoryStreamTest.cxx +++ b/writerperfect/qa/unit/DirectoryStreamTest.cxx @@ -18,6 +18,8 @@ #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; namespace uno = com::sun::star::uno; @@ -60,6 +62,38 @@ 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"; +static DirectoryStream* createForParent(const css::uno::Reference<css::ucb::XContent> &xContent) +{ + try + { + if (!xContent.is()) + return nullptr; + + DirectoryStream *pDir(nullptr); + + 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 = new writerperfect::DirectoryStream(xDirContent); + if (!pDir->isStructured()) + { + delete pDir; + pDir = nullptr; + } + } + } + + return pDir; + } + catch (...) + { + return nullptr; + } +} + DirectoryStreamTest::DirectoryStreamTest() { const uno::Reference<ucb::XCommandEnvironment> xCmdEnv; @@ -74,17 +108,17 @@ DirectoryStreamTest::DirectoryStreamTest() void DirectoryStreamTest::testConstruction() { - const unique_ptr<DirectoryStream> pDir(DirectoryStream::createForParent(m_xFile)); + const unique_ptr<DirectoryStream> pDir(createForParent(m_xFile)); CPPUNIT_ASSERT(bool(pDir)); CPPUNIT_ASSERT(pDir->isStructured()); // this should work for dirs too - const unique_ptr<DirectoryStream> pDir2(DirectoryStream::createForParent(m_xDir)); + const unique_ptr<DirectoryStream> pDir2(createForParent(m_xDir)); CPPUNIT_ASSERT(bool(pDir2)); CPPUNIT_ASSERT(pDir2->isStructured()); // for nonexistent dirs nothing is created - const unique_ptr<DirectoryStream> pNondir(DirectoryStream::createForParent(m_xNonexistent)); + const unique_ptr<DirectoryStream> pNondir(createForParent(m_xNonexistent)); CPPUNIT_ASSERT(!pNondir); // even if we try harder, just an empty shell is created @@ -136,7 +170,7 @@ void DirectoryStreamTest::testStructuredOperations() DirectoryStream aDir(m_xDir); lcl_testStructuredOperations(aDir); - unique_ptr<DirectoryStream> pDir(DirectoryStream::createForParent(m_xFile)); + unique_ptr<DirectoryStream> pDir(createForParent(m_xFile)); CPPUNIT_ASSERT(bool(pDir)); lcl_testStructuredOperations(*pDir.get()); } |