From 88570decb6941e1e4fbea14f120f9ad2cd1c18d1 Mon Sep 17 00:00:00 2001 From: David Tardon Date: Thu, 17 Dec 2015 13:06:20 +0100 Subject: allow to skip import tests based on library version That way we don't have to require the newest version for build just to run tests. Change-Id: I4f91828a13821b235004ff16a69043d6d43686c1 (cherry picked from commit ddbba41b39399644b1ce7008d8922998446411e7) Reviewed-on: https://gerrit.libreoffice.org/20937 Reviewed-by: Miklos Vajna Tested-by: Miklos Vajna --- config_host/config_writerperfect.h.in | 15 +++++++++++++++ configure.ac | 1 + writerperfect/CppunitTest_writerperfect_calc.mk | 1 + writerperfect/CppunitTest_writerperfect_draw.mk | 1 + writerperfect/CppunitTest_writerperfect_impress.mk | 1 + writerperfect/CppunitTest_writerperfect_writer.mk | 1 + writerperfect/qa/unit/WpftImportTestBase.cxx | 20 ++++++++++++++++++++ writerperfect/qa/unit/WpftImportTestBase.hxx | 14 ++++++++++++++ 8 files changed, 54 insertions(+) create mode 100644 config_host/config_writerperfect.h.in diff --git a/config_host/config_writerperfect.h.in b/config_host/config_writerperfect.h.in new file mode 100644 index 000000000000..4331b4f84839 --- /dev/null +++ b/config_host/config_writerperfect.h.in @@ -0,0 +1,15 @@ +/* -*- 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/. + */ + +/* Configuration for versions of import libraries used by writerperfect. + * This is needed to skip test files that are not supported by the used + * version. + */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/configure.ac b/configure.ac index 15b3fd2f6ae1..b5de019db106 100644 --- a/configure.ac +++ b/configure.ac @@ -12961,6 +12961,7 @@ AC_CONFIG_HEADERS([config_host/config_version.h]) AC_CONFIG_HEADERS([config_host/config_oauth2.h]) AC_CONFIG_HEADERS([config_host/config_poppler.h]) AC_CONFIG_HEADERS([config_host/config_python.h]) +AC_CONFIG_HEADERS([config_host/config_writerperfect.h]) AC_OUTPUT if test "$CROSS_COMPILING" = TRUE; then diff --git a/writerperfect/CppunitTest_writerperfect_calc.mk b/writerperfect/CppunitTest_writerperfect_calc.mk index 75716b38a00a..db0212a34465 100644 --- a/writerperfect/CppunitTest_writerperfect_calc.mk +++ b/writerperfect/CppunitTest_writerperfect_calc.mk @@ -24,6 +24,7 @@ $(eval $(call gb_CppunitTest_use_libraries,writerperfect_calc,\ cppuhelper \ sal \ test \ + tl \ ucbhelper \ unotest \ $(gb_UWINAPI) \ diff --git a/writerperfect/CppunitTest_writerperfect_draw.mk b/writerperfect/CppunitTest_writerperfect_draw.mk index fac4476a1457..232ef3451d40 100644 --- a/writerperfect/CppunitTest_writerperfect_draw.mk +++ b/writerperfect/CppunitTest_writerperfect_draw.mk @@ -24,6 +24,7 @@ $(eval $(call gb_CppunitTest_use_libraries,writerperfect_draw,\ cppuhelper \ sal \ test \ + tl \ ucbhelper \ unotest \ $(gb_UWINAPI) \ diff --git a/writerperfect/CppunitTest_writerperfect_impress.mk b/writerperfect/CppunitTest_writerperfect_impress.mk index 4da810cb8f0d..1c3bb7a14250 100644 --- a/writerperfect/CppunitTest_writerperfect_impress.mk +++ b/writerperfect/CppunitTest_writerperfect_impress.mk @@ -24,6 +24,7 @@ $(eval $(call gb_CppunitTest_use_libraries,writerperfect_impress,\ cppuhelper \ sal \ test \ + tl \ ucbhelper \ unotest \ $(gb_UWINAPI) \ diff --git a/writerperfect/CppunitTest_writerperfect_writer.mk b/writerperfect/CppunitTest_writerperfect_writer.mk index 0c3e6150af94..ca0ee0a72b8d 100644 --- a/writerperfect/CppunitTest_writerperfect_writer.mk +++ b/writerperfect/CppunitTest_writerperfect_writer.mk @@ -24,6 +24,7 @@ $(eval $(call gb_CppunitTest_use_libraries,writerperfect_writer,\ cppuhelper \ sal \ test \ + tl \ ucbhelper \ unotest \ $(gb_UWINAPI) \ diff --git a/writerperfect/qa/unit/WpftImportTestBase.cxx b/writerperfect/qa/unit/WpftImportTestBase.cxx index 874b4d6daac6..8b66c3b64f5a 100644 --- a/writerperfect/qa/unit/WpftImportTestBase.cxx +++ b/writerperfect/qa/unit/WpftImportTestBase.cxx @@ -24,6 +24,8 @@ #include #include +#include + #include #include "WpftImportTestBase.hxx" @@ -50,6 +52,7 @@ WpftImportTestBase::WpftImportTestBase(const rtl::OUString &rFactoryURL) , m_xDesktop() , m_xFilter() , m_xTypeMap() + , m_pOptionalMap(nullptr) { } @@ -75,6 +78,15 @@ void WpftImportTestBase::tearDown() bool WpftImportTestBase::load(const OUString &, const OUString &rURL, const OUString &, SfxFilterFlags, SotClipboardFormatId, unsigned int) { + if (m_pOptionalMap) + { + // first check if this test file is supported by the used version of the library + const INetURLObject aUrl(rURL); + const WpftOptionalMap_t::const_iterator it(m_pOptionalMap->find(aUrl.getName())); + if ((it != m_pOptionalMap->end()) && !it->second) + return true; // skip the file + } + // create an empty frame const uno::Reference xDoc( m_xDesktop->loadComponentFromURL(m_aFactoryURL, "_blank", 0, uno::Sequence()), @@ -163,6 +175,14 @@ void WpftImportTestBase::doTest(const rtl::OUString &rFilter, const rtl::OUStrin testDir(OUString(), getURLFromSrc(rPath), OUString()); } +void WpftImportTestBase::doTest(const rtl::OUString &rFilter, const rtl::OUString &rPath, const WpftOptionalMap_t &rOptionalMap) +{ + m_xFilter.set(m_xFactory->createInstanceWithContext(rFilter, m_xContext), uno::UNO_QUERY_THROW); + m_pOptionalMap = &rOptionalMap; + testDir(OUString(), getURLFromSrc(rPath), OUString()); + m_pOptionalMap = nullptr; +} + void WpftImportTestBase::impl_detectFilterName(uno::Sequence &rDescriptor, const rtl::OUString &rTypeName) { const sal_Int32 nDescriptorLen = rDescriptor.getLength(); diff --git a/writerperfect/qa/unit/WpftImportTestBase.hxx b/writerperfect/qa/unit/WpftImportTestBase.hxx index 43e1bf137060..4689f9847dd5 100644 --- a/writerperfect/qa/unit/WpftImportTestBase.hxx +++ b/writerperfect/qa/unit/WpftImportTestBase.hxx @@ -10,6 +10,10 @@ #ifndef INCLUDED_WRITERPERFECT_QA_UNIT_WPFTIMPORTTESTBASE_HXX #define INCLUDED_WRITERPERFECT_QA_UNIT_WPFTIMPORTTESTBASE_HXX +#include "config_writerperfect.h" + +#include + #include #include @@ -19,6 +23,12 @@ #include +#define REQUIRE_VERSION(major, minor, micro, req_major, req_minor, req_micro) \ + (major) > (req_major) || \ + ((major) == (req_major) && \ + ((minor) > (req_minor) \ + || ((minor) == (req_minor) && ((micro) >= (req_micro))))) + namespace com { namespace sun @@ -54,6 +64,8 @@ namespace writerperfect namespace test { +typedef std::unordered_map WpftOptionalMap_t; + class WpftImportTestBase : public ::test::FiltersTest , public ::test::BootstrapFixture @@ -66,6 +78,7 @@ public: protected: void doTest(const rtl::OUString &rFilter, const rtl::OUString &rPath); + void doTest(const rtl::OUString &rFilter, const rtl::OUString &rPath, const WpftOptionalMap_t &rOptionalMap); private: virtual bool load(const OUString &, const OUString &rURL, const OUString &, @@ -79,6 +92,7 @@ private: css::uno::Reference m_xFileAccess; css::uno::Reference m_xFilter; css::uno::Reference m_xTypeMap; + const WpftOptionalMap_t *m_pOptionalMap; }; } -- cgit v1.2.3