[Libreoffice-commits] core.git: Branch 'libreoffice-5-1' - config_host/config_writerperfect.h.in configure.ac writerperfect/CppunitTest_writerperfect_calc.mk writerperfect/CppunitTest_writerperfect_draw.mk writerperfect/CppunitTest_writerperfect_impress.mk writerperfect/CppunitTest_writerperfect_writer.mk writerperfect/qa

David Tardon dtardon at redhat.com
Tue Jan 5 06:16:38 PST 2016


 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(+)

New commits:
commit 88570decb6941e1e4fbea14f120f9ad2cd1c18d1
Author: David Tardon <dtardon at redhat.com>
Date:   Thu Dec 17 13:06:20 2015 +0100

    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 <vmiklos at collabora.co.uk>
    Tested-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/config_host/config_writerperfect.h.in b/config_host/config_writerperfect.h.in
new file mode 100644
index 0000000..4331b4f
--- /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 15b3fd2..b5de019 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 75716b3..db0212a 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 fac4476..232ef34 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 4da810c..1c3bb7a 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 0c3e615..ca0ee0a 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 874b4d6..8b66c3b 100644
--- a/writerperfect/qa/unit/WpftImportTestBase.cxx
+++ b/writerperfect/qa/unit/WpftImportTestBase.cxx
@@ -24,6 +24,8 @@
 #include <com/sun/star/ucb/XContent.hpp>
 #include <com/sun/star/util/XCloseable.hpp>
 
+#include <tools/urlobj.hxx>
+
 #include <ucbhelper/content.hxx>
 
 #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<lang::XComponent> xDoc(
         m_xDesktop->loadComponentFromURL(m_aFactoryURL, "_blank", 0, uno::Sequence<beans::PropertyValue>()),
@@ -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<beans::PropertyValue> &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 43e1bf1..4689f98 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 <unordered_map>
+
 #include <com/sun/star/uno/Reference.hxx>
 #include <com/sun/star/uno/Sequence.hxx>
 
@@ -19,6 +23,12 @@
 
 #include <unotest/filters-test.hxx>
 
+#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<rtl::OUString, bool, rtl::OUStringHash> 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<css::ucb::XSimpleFileAccess> m_xFileAccess;
     css::uno::Reference<css::document::XFilter> m_xFilter;
     css::uno::Reference<css::container::XNameAccess> m_xTypeMap;
+    const WpftOptionalMap_t *m_pOptionalMap;
 };
 
 }


More information about the Libreoffice-commits mailing list