summaryrefslogtreecommitdiffstats
path: root/include/unotest
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 16:51:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 16:51:28 +0000
commit940b4d1848e8c70ab7642901a68594e8016caffc (patch)
treeeb72f344ee6c3d9b80a7ecc079ea79e9fba8676d /include/unotest
parentInitial commit. (diff)
downloadlibreoffice-upstream.tar.xz
libreoffice-upstream.zip
Adding upstream version 1:7.0.4.upstream/1%7.0.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--include/unotest/bootstrapfixturebase.hxx75
-rw-r--r--include/unotest/detail/unotestdllapi.hxx34
-rw-r--r--include/unotest/directories.hxx50
-rw-r--r--include/unotest/filters-test.hxx91
-rw-r--r--include/unotest/gettestargument.hxx38
-rw-r--r--include/unotest/macros_test.hxx57
-rw-r--r--include/unotest/officeconnection.hxx65
-rw-r--r--include/unotest/toabsolutefileurl.hxx39
8 files changed, 449 insertions, 0 deletions
diff --git a/include/unotest/bootstrapfixturebase.hxx b/include/unotest/bootstrapfixturebase.hxx
new file mode 100644
index 000000000..85f270b02
--- /dev/null
+++ b/include/unotest/bootstrapfixturebase.hxx
@@ -0,0 +1,75 @@
+/* -*- 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/.
+ */
+#ifndef INCLUDED_UNOTEST_BOOTSTRAPFIXTUREBASE_HXX
+#define INCLUDED_UNOTEST_BOOTSTRAPFIXTUREBASE_HXX
+
+#include <sal/config.h>
+
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XMultiComponentFactory.hpp>
+
+#include <cppunit/TestAssert.h>
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/plugin/TestPlugIn.h>
+#include <unotest/detail/unotestdllapi.hxx>
+#include <unotest/directories.hxx>
+
+// For cppunit < 1.15.0.
+#ifndef CPPUNIT_TEST_FIXTURE
+#define CPPUNIT_TEST_FIXTURE(TestClass, TestName) \
+ class TestName : public TestClass \
+ { \
+ public: \
+ void TestBody(); \
+ CPPUNIT_TEST_SUITE(TestName); \
+ CPPUNIT_TEST(TestBody); \
+ CPPUNIT_TEST_SUITE_END(); \
+ }; \
+ CPPUNIT_TEST_SUITE_REGISTRATION(TestName); \
+ void TestName::TestBody()
+#endif
+
+namespace test {
+
+// Class to do lots of heavy-lifting UNO & environment
+// bootstrapping for unit tests, such that we can use
+// almost an entire LibreOffice during compile - so
+// that we can get pieces of code alone to beat them up.
+
+// NB. this class is instantiated multiple times during a
+// run of unit tests ...
+class OOO_DLLPUBLIC_UNOTEST BootstrapFixtureBase : public CppUnit::TestFixture
+{
+protected:
+ Directories m_directories;
+ css::uno::Reference<css::uno::XComponentContext> m_xContext;
+ css::uno::Reference<css::lang::XMultiServiceFactory> m_xSFactory;
+ css::uno::Reference<css::lang::XMultiComponentFactory> m_xFactory;
+
+public:
+ BootstrapFixtureBase();
+ virtual ~BootstrapFixtureBase() override;
+
+ const css::uno::Reference<css::uno::XComponentContext>&
+ getComponentContext() const { return m_xContext; }
+ const css::uno::Reference<css::lang::XMultiServiceFactory>&
+ getMultiServiceFactory() const { return m_xSFactory; }
+
+ virtual void setUp() override;
+ virtual void tearDown() override;
+
+};
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/unotest/detail/unotestdllapi.hxx b/include/unotest/detail/unotestdllapi.hxx
new file mode 100644
index 000000000..b89013912
--- /dev/null
+++ b/include/unotest/detail/unotestdllapi.hxx
@@ -0,0 +1,34 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_UNOTEST_DETAIL_UNOTESTDLLAPI_HXX
+#define INCLUDED_UNOTEST_DETAIL_UNOTESTDLLAPI_HXX
+
+#include <sal/config.h>
+#include <sal/types.h>
+
+#if defined OOO_DLLIMPLEMENTATION_UNOTEST
+#define OOO_DLLPUBLIC_UNOTEST SAL_DLLPUBLIC_EXPORT
+#else
+#define OOO_DLLPUBLIC_UNOTEST SAL_DLLPUBLIC_IMPORT
+#endif
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/unotest/directories.hxx b/include/unotest/directories.hxx
new file mode 100644
index 000000000..5a901c878
--- /dev/null
+++ b/include/unotest/directories.hxx
@@ -0,0 +1,50 @@
+/* -*- 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/.
+ */
+
+#ifndef INCLUDED_UNOTEST_DIRECTORIES_HXX
+#define INCLUDED_UNOTEST_DIRECTORIES_HXX
+
+#include <sal/config.h>
+
+#include <rtl/ustring.hxx>
+#include <unotest/detail/unotestdllapi.hxx>
+
+namespace test {
+
+class OOO_DLLPUBLIC_UNOTEST Directories {
+private:
+ OUString m_aSrcRootURL;
+ OUString m_aSrcRootPath;
+ OUString m_aWorkdirRootURL;
+ OUString m_aWorkdirRootPath;
+
+public:
+ Directories();
+
+ const OUString& getSrcRootURL() const { return m_aSrcRootURL; }
+ const OUString& getSrcRootPath() const { return m_aSrcRootPath; }
+
+ // return a URL to a given path from the source directory
+ OUString getURLFromSrc(const OUString& rPath) const;
+
+ // return a Path to a given path from the source directory
+ OUString getPathFromSrc(const OUString& rPath) const;
+
+ // return a URL to a given path from the workdir directory
+ OUString getURLFromWorkdir(const OUString &rPath) const;
+
+ // return a Path to a given path from the workdir directory
+ OUString getPathFromWorkdir(const OUString &rPath) const;
+};
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/unotest/filters-test.hxx b/include/unotest/filters-test.hxx
new file mode 100644
index 000000000..5af991e04
--- /dev/null
+++ b/include/unotest/filters-test.hxx
@@ -0,0 +1,91 @@
+/* -*- 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/.
+ */
+
+#ifndef INCLUDED_UNOTEST_FILTERS_TEST_HXX
+#define INCLUDED_UNOTEST_FILTERS_TEST_HXX
+
+#include <comphelper/documentconstants.hxx>
+#include <rtl/ustring.hxx>
+#include <unotest/detail/unotestdllapi.hxx>
+#include <sot/formats.hxx>
+
+namespace test {
+
+enum filterStatus
+{
+ fail = 0,
+ pass = 1,
+ indeterminate = 2
+};
+
+/*
+ * NOTE, any files beginning with CVE-, BID- or EDB- will be assumed to be
+ * encrypted using arcfour with key 0x435645, this is to silence panicky
+ * virus/malware-checkers
+ *
+ * e.g. m[de]crypt --bare -a arcfour -o hex -k 435645 -s 3
+ */
+/* Implementation of Filters test */
+class OOO_DLLPUBLIC_UNOTEST FiltersTest
+{
+public:
+ void testDir(
+ //filter name
+ const OUString &rFilter,
+ //root dir of test files, must contain pass, fail, indeterminate
+ const OUString &rURL,
+ //additional filter data for SfxFilter
+ const OUString &rUserData = OUString(),
+ //SfxFilterFlags for SfxFilter
+ SfxFilterFlags nFilterFlags = SfxFilterFlags::IMPORT,
+ //Clipboard id for SfxFilter
+ SotClipboardFormatId nClipboardID = SotClipboardFormatId::NONE,
+ //additional filter version for SfxFilter
+ unsigned int nFilterVersion = 0,
+ //export or import?
+ bool bExport = false);
+
+ virtual bool load(
+ const OUString &rFilter,
+ const OUString &rURL,
+ const OUString &rUserData,
+ SfxFilterFlags nFilterFlags,
+ SotClipboardFormatId nClipboardID,
+ unsigned int nFilterVersion) = 0;
+
+ virtual bool save(
+ const OUString &/*rFilter*/,
+ const OUString &/*rURL*/,
+ const OUString &/*rUserData*/,
+ SfxFilterFlags /*nFilterFlags*/,
+ SotClipboardFormatId /*nClipboardID*/,
+ unsigned int /*nFilterVersion*/)
+ {
+ return true;
+ }
+
+protected:
+ ~FiltersTest() {}
+
+ void recursiveScan(
+ filterStatus nExpected,
+ const OUString &rFilter,
+ const OUString &rURL,
+ const OUString &rUserData,
+ SfxFilterFlags nFilterFlags,
+ SotClipboardFormatId nClipboardID,
+ unsigned int nFilterVersion,
+ bool bExport);
+};
+
+}
+
+#endif // INCLUDED_UNOTEST_FILTERS_TEST_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/unotest/gettestargument.hxx b/include/unotest/gettestargument.hxx
new file mode 100644
index 000000000..734b77e57
--- /dev/null
+++ b/include/unotest/gettestargument.hxx
@@ -0,0 +1,38 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_UNOTEST_GETTESTARGUMENT_HXX
+#define INCLUDED_UNOTEST_GETTESTARGUMENT_HXX
+
+#include <rtl/ustring.hxx>
+#include <unotest/detail/unotestdllapi.hxx>
+
+
+namespace test {
+
+// Obtain the value of a test argument (tunneled in via an "arg-testarg.<name>"
+// bootstrap variable):
+OOO_DLLPUBLIC_UNOTEST bool getTestArgument(
+ OUString const & name, OUString * value);
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/unotest/macros_test.hxx b/include/unotest/macros_test.hxx
new file mode 100644
index 000000000..c60ea1fe9
--- /dev/null
+++ b/include/unotest/macros_test.hxx
@@ -0,0 +1,57 @@
+/* -*- 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/.
+ */
+
+#ifndef INCLUDED_UNOTEST_MACROS_TEST_HXX
+#define INCLUDED_UNOTEST_MACROS_TEST_HXX
+
+#include <sal/config.h>
+
+#include <memory>
+#include <rtl/ustring.hxx>
+#include <unotest/detail/unotestdllapi.hxx>
+
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/frame/XDesktop2.hpp>
+
+struct TestMacroInfo
+{
+ OUString sFileBaseName;
+ OUString sMacroUrl;
+};
+
+class BasicDLL;
+
+namespace unotest {
+
+class OOO_DLLPUBLIC_UNOTEST MacrosTest
+{
+public:
+ MacrosTest();
+ ~MacrosTest();
+
+ css::uno::Reference< css::lang::XComponent > loadFromDesktop(const OUString& rURL, const OUString& rDocService = OUString(),
+ const css::uno::Sequence<css::beans::PropertyValue>& rExtra_args = css::uno::Sequence<css::beans::PropertyValue>() );
+
+ static void
+ dispatchCommand(const css::uno::Reference<css::lang::XComponent>& xComponent,
+ const OUString& rCommand,
+ const css::uno::Sequence<css::beans::PropertyValue>& rPropertyValues);
+
+protected:
+ css::uno::Reference< css::frame::XDesktop2> mxDesktop;
+
+private:
+ std::unique_ptr<BasicDLL> mpDll;
+};
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/unotest/officeconnection.hxx b/include/unotest/officeconnection.hxx
new file mode 100644
index 000000000..553f24b3c
--- /dev/null
+++ b/include/unotest/officeconnection.hxx
@@ -0,0 +1,65 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_UNOTEST_OFFICECONNECTION_HXX
+#define INCLUDED_UNOTEST_OFFICECONNECTION_HXX
+
+#include <sal/config.h>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <osl/process.h>
+#include <unotest/detail/unotestdllapi.hxx>
+
+namespace com::sun::star::uno {
+ class XComponentContext;
+}
+
+namespace test {
+
+// Start up and shut down an OOo instance (details about the OOo instance are
+// tunneled in via "arg-..." bootstrap variables):
+class OOO_DLLPUBLIC_UNOTEST OfficeConnection
+{
+ OfficeConnection(const OfficeConnection&) = delete;
+ OfficeConnection& operator=( const OfficeConnection& ) = delete;
+public:
+ OfficeConnection();
+ ~OfficeConnection();
+
+ void setUp();
+
+ void tearDown();
+
+ const css::uno::Reference< css::uno::XComponentContext >&
+ getComponentContext() const { return context_;}
+
+ // Must not be called before setUp or after tearDown:
+ bool isStillAlive() const;
+
+private:
+ oslProcess process_;
+ css::uno::Reference< css::uno::XComponentContext >
+ context_;
+};
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/unotest/toabsolutefileurl.hxx b/include/unotest/toabsolutefileurl.hxx
new file mode 100644
index 000000000..5bdb7b05e
--- /dev/null
+++ b/include/unotest/toabsolutefileurl.hxx
@@ -0,0 +1,39 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_UNOTEST_TOABSOLUTEFILEURL_HXX
+#define INCLUDED_UNOTEST_TOABSOLUTEFILEURL_HXX
+
+#include <rtl/ustring.hxx>
+
+#include <unotest/detail/unotestdllapi.hxx>
+
+
+namespace test {
+
+// Convert a pathname in system notation, potentially relative to the process's
+// current working directory, to an absolute file URL:
+OOO_DLLPUBLIC_UNOTEST OUString toAbsoluteFileUrl(
+ OUString const & relativePathname);
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */