summaryrefslogtreecommitdiff
path: root/unotest
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2016-03-09 14:14:18 +0100
committerStephan Bergmann <sbergman@redhat.com>2016-03-10 08:04:40 +0000
commit60b1c95cc47831246f097ee13dda8bcd71c57eb4 (patch)
tree8f8ede597a247c78f3742fa46ba9777b66edb76e /unotest
parent50336412f775af154509d67b1ebbdb4b5feb147b (diff)
Extract Directories from BootstrapFixtureBase
(as some tests derive from the latter only for the Directories part, not for the setUp/tearDown overrides: those tests will be cleaned up next) Change-Id: Ib6b78eea868b8bc21d4cc6e8fd9e1d025deca05f Reviewed-on: https://gerrit.libreoffice.org/23078 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'unotest')
-rw-r--r--unotest/Library_unotest.mk1
-rw-r--r--unotest/source/cpp/bootstrapfixturebase.cxx65
-rw-r--r--unotest/source/cpp/directories.cxx74
3 files changed, 76 insertions, 64 deletions
diff --git a/unotest/Library_unotest.mk b/unotest/Library_unotest.mk
index 3f9d99b6f0a3..315447cd6dd0 100644
--- a/unotest/Library_unotest.mk
+++ b/unotest/Library_unotest.mk
@@ -32,6 +32,7 @@ $(eval $(call gb_Library_use_externals,unotest,\
$(eval $(call gb_Library_add_exception_objects,unotest,\
unotest/source/cpp/bootstrapfixturebase \
+ unotest/source/cpp/directories \
unotest/source/cpp/filters-test \
unotest/source/cpp/getargument \
unotest/source/cpp/gettestargument \
diff --git a/unotest/source/cpp/bootstrapfixturebase.cxx b/unotest/source/cpp/bootstrapfixturebase.cxx
index 74a28026fc3c..e14736bd066f 100644
--- a/unotest/source/cpp/bootstrapfixturebase.cxx
+++ b/unotest/source/cpp/bootstrapfixturebase.cxx
@@ -10,91 +10,28 @@
#include "sal/config.h"
#include <unotest/bootstrapfixturebase.hxx>
-#include <osl/file.hxx>
-#include <rtl/strbuf.hxx>
#include <rtl/bootstrap.hxx>
-#include <cppuhelper/bootstrap.hxx>
#include <comphelper/processfactory.hxx>
#include <basic/sbstar.hxx>
-#include <com/sun/star/lang/Locale.hpp>
-#include <com/sun/star/lang/XComponent.hpp>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-
using namespace ::com::sun::star;
-namespace {
-
-OUString getFileURLFromSystemPath(OUString const & path) {
- OUString url;
- osl::FileBase::RC e = osl::FileBase::getFileURLFromSystemPath(path, url);
- CPPUNIT_ASSERT_EQUAL(osl::FileBase::E_None, e);
- if (!url.endsWith("/")) {
- url += "/";
- }
- return url;
-}
-
-}
-
// NB. this constructor is called before any tests are run, once for each
// test function in a rather non-intuitive way. This is why all the 'real'
// heavy lifting is deferred until setUp. setUp and tearDown are interleaved
// between the tests as you might expect.
test::BootstrapFixtureBase::BootstrapFixtureBase()
{
-#ifndef ANDROID
- const char* pSrcRoot = getenv( "SRC_ROOT" );
- CPPUNIT_ASSERT_MESSAGE("SRC_ROOT env variable not set", pSrcRoot != nullptr && pSrcRoot[0] != 0);
- const char* pWorkdirRoot = getenv( "WORKDIR_FOR_BUILD" );
- CPPUNIT_ASSERT_MESSAGE("$WORKDIR_FOR_BUILD env variable not set", pWorkdirRoot != nullptr && pWorkdirRoot[0] != 0);
-#else
- const char* pSrcRoot = "/assets";
- const char* pWorkdirRoot = "/assets";
-#endif
- m_aSrcRootPath = OUString::createFromAscii( pSrcRoot );
- m_aSrcRootURL = getFileURLFromSystemPath(m_aSrcRootPath);
-
- m_aWorkdirRootPath = OUString::createFromAscii( pWorkdirRoot );
- m_aWorkdirRootURL = getFileURLFromSystemPath(m_aWorkdirRootPath);
-
}
test::BootstrapFixtureBase::~BootstrapFixtureBase()
{
}
-OUString test::BootstrapFixtureBase::getURLFromSrc( const char *pPath )
-{
- return m_aSrcRootURL + OUString::createFromAscii( pPath );
-}
-
-OUString test::BootstrapFixtureBase::getURLFromSrc( const OUString& rPath )
-{
- return m_aSrcRootURL + rPath;
-}
-
-OUString test::BootstrapFixtureBase::getPathFromSrc( const char *pPath )
-{
- return m_aSrcRootPath + OUString::createFromAscii( pPath );
-}
-
-OUString test::BootstrapFixtureBase::getURLFromWorkdir( const char *pPath )
-{
- return m_aWorkdirRootURL + OUString::createFromAscii( pPath );
-}
-
-#ifdef _WIN32 // ifdef just to keep it out of unusedcode.easy
-OUString test::BootstrapFixtureBase::getPathFromWorkdir( const char *pPath )
-{
- return m_aWorkdirRootPath + OUString::createFromAscii( pPath );
-}
-#endif
-
void test::BootstrapFixtureBase::setUp()
{
// set UserInstallation to user profile dir in test/user-template
- OUString sUserInstallURL = m_aWorkdirRootURL + "/unittest";
+ OUString sUserInstallURL = m_directories.getURLFromWorkdir("/unittest");
rtl::Bootstrap::set("UserInstallation", sUserInstallURL);
m_xContext = comphelper::getProcessComponentContext();
diff --git a/unotest/source/cpp/directories.cxx b/unotest/source/cpp/directories.cxx
new file mode 100644
index 000000000000..177ed2c6f337
--- /dev/null
+++ b/unotest/source/cpp/directories.cxx
@@ -0,0 +1,74 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <sal/config.h>
+
+#include <cppunit/TestAssert.h>
+#include <osl/file.hxx>
+#include <unotest/directories.hxx>
+
+namespace {
+
+OUString getFileURLFromSystemPath(OUString const & path) {
+ OUString url;
+ osl::FileBase::RC e = osl::FileBase::getFileURLFromSystemPath(path, url);
+ CPPUNIT_ASSERT_EQUAL(osl::FileBase::E_None, e);
+ if (!url.endsWith("/")) {
+ url += "/";
+ }
+ return url;
+}
+
+}
+
+test::Directories::Directories() {
+#ifndef ANDROID
+ const char* pSrcRoot = getenv( "SRC_ROOT" );
+ CPPUNIT_ASSERT_MESSAGE("SRC_ROOT env variable not set", pSrcRoot != nullptr && pSrcRoot[0] != 0);
+ const char* pWorkdirRoot = getenv( "WORKDIR_FOR_BUILD" );
+ CPPUNIT_ASSERT_MESSAGE("$WORKDIR_FOR_BUILD env variable not set", pWorkdirRoot != nullptr && pWorkdirRoot[0] != 0);
+#else
+ const char* pSrcRoot = "/assets";
+ const char* pWorkdirRoot = "/assets";
+#endif
+ m_aSrcRootPath = OUString::createFromAscii( pSrcRoot );
+ m_aSrcRootURL = getFileURLFromSystemPath(m_aSrcRootPath);
+
+ m_aWorkdirRootPath = OUString::createFromAscii( pWorkdirRoot );
+ m_aWorkdirRootURL = getFileURLFromSystemPath(m_aWorkdirRootPath);
+}
+
+OUString test::Directories::getURLFromSrc( const char *pPath )
+{
+ return m_aSrcRootURL + OUString::createFromAscii( pPath );
+}
+
+OUString test::Directories::getURLFromSrc( const OUString& rPath )
+{
+ return m_aSrcRootURL + rPath;
+}
+
+OUString test::Directories::getPathFromSrc( const char *pPath )
+{
+ return m_aSrcRootPath + OUString::createFromAscii( pPath );
+}
+
+OUString test::Directories::getURLFromWorkdir( const char *pPath )
+{
+ return m_aWorkdirRootURL + OUString::createFromAscii( pPath );
+}
+
+#ifdef _WIN32 // ifdef just to keep it out of unusedcode.easy
+OUString test::Directories::getPathFromWorkdir( const char *pPath )
+{
+ return m_aWorkdirRootPath + OUString::createFromAscii( pPath );
+}
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */