summaryrefslogtreecommitdiff
path: root/sc/qa/unit
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2022-11-24 14:52:45 +0100
committerXisco Fauli <xiscofauli@libreoffice.org>2022-11-24 17:33:20 +0100
commite328476c6c8793733ce87635d38869d99a7149da (patch)
treed76af5d5e0652a694099edd360c4aad4ee987c72 /sc/qa/unit
parent5dbb85ca6abfbc2b5353da1e3eb36c426fb62305 (diff)
ScBootstrapFixture: move to their own file and rename class
Change-Id: Ib3222f119f67b77b9c67269a6040301a44c7c5b0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143232 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sc/qa/unit')
-rw-r--r--sc/qa/unit/filters-test.cxx15
-rw-r--r--sc/qa/unit/functions_test.cxx4
-rw-r--r--sc/qa/unit/functions_test.hxx5
-rw-r--r--sc/qa/unit/helper/qahelper.cxx46
-rw-r--r--sc/qa/unit/helper/qahelper.hxx28
-rw-r--r--sc/qa/unit/helper/scfiltertestbase.cxx68
-rw-r--r--sc/qa/unit/helper/scfiltertestbase.hxx68
7 files changed, 146 insertions, 88 deletions
diff --git a/sc/qa/unit/filters-test.cxx b/sc/qa/unit/filters-test.cxx
index fcfbc786f334..d7b2197f1a29 100644
--- a/sc/qa/unit/filters-test.cxx
+++ b/sc/qa/unit/filters-test.cxx
@@ -8,10 +8,8 @@
*/
#include <sal/config.h>
-#include <unotest/filters-test.hxx>
-#include <test/bootstrapfixture.hxx>
-#include "helper/qahelper.hxx"
+#include "helper/scfiltertestbase.hxx"
#include <docsh.hxx>
#include <inputopt.hxx>
@@ -37,8 +35,7 @@ using namespace ::com::sun::star::uno;
/* Implementation of Filters test */
class ScFiltersTest
- : public test::FiltersTest
- , public ScBootstrapFixture
+ : public ScFilterTestBase
{
public:
ScFiltersTest();
@@ -84,7 +81,7 @@ bool ScFiltersTest::load(const OUString &rFilter, const OUString &rURL,
const OUString &rUserData, SfxFilterFlags nFilterFlags,
SotClipboardFormatId nClipboardID, unsigned int nFilterVersion)
{
- ScDocShellRef xDocShRef = ScBootstrapFixture::load(rURL, rFilter, rUserData,
+ ScDocShellRef xDocShRef = loadDoc(rURL, rFilter, rUserData,
OUString(), nFilterFlags, nClipboardID, nFilterVersion );
bool bLoaded = xDocShRef.is();
//reference counting of ScDocShellRef is very confused.
@@ -137,7 +134,7 @@ void ScFiltersTest::testTooManyColsRows()
// should be a warning on load.
OUString aFileName;
createFileURL(u"too-many-cols-rows.", u"ods", aFileName );
- ScDocShellRef xDocSh = ScBootstrapFixture::load(aFileName, "calc8", OUString(), OUString(),
+ ScDocShellRef xDocSh = loadDoc(aFileName, "calc8", OUString(), OUString(),
ODS_FORMAT_TYPE, SotClipboardFormatId::STARCALC_8);
CPPUNIT_ASSERT(xDocSh->GetErrorCode() == SCWARN_IMPORT_ROW_OVERFLOW
@@ -145,7 +142,7 @@ void ScFiltersTest::testTooManyColsRows()
xDocSh->DoClose();
createFileURL(u"too-many-cols-rows.", u"xlsx", aFileName );
- xDocSh = ScBootstrapFixture::load(
+ xDocSh = loadDoc(
aFileName, "Calc Office Open XML", OUString(), OUString(),
XLSX_FORMAT_TYPE, SotClipboardFormatId::STARCALC_8);
@@ -155,7 +152,7 @@ void ScFiltersTest::testTooManyColsRows()
}
ScFiltersTest::ScFiltersTest()
- : ScBootstrapFixture()
+ : ScFilterTestBase()
{
}
diff --git a/sc/qa/unit/functions_test.cxx b/sc/qa/unit/functions_test.cxx
index 6bc36540c2a4..8efdfa5b0f82 100644
--- a/sc/qa/unit/functions_test.cxx
+++ b/sc/qa/unit/functions_test.cxx
@@ -14,7 +14,7 @@
#include <rtl/math.hxx>
FunctionsTest::FunctionsTest():
- ScBootstrapFixture()
+ ScFilterTestBase()
{
}
@@ -23,7 +23,7 @@ bool FunctionsTest::load(const OUString& rFilter, const OUString& rURL,
SotClipboardFormatId nClipboardID,
unsigned int nFilterVersion)
{
- ScDocShellRef xDocShRef = ScBootstrapFixture::load(rURL, rFilter, rUserData,
+ ScDocShellRef xDocShRef = loadDoc(rURL, rFilter, rUserData,
OUString(), nFilterFlags, nClipboardID, nFilterVersion );
CPPUNIT_ASSERT(xDocShRef.is());
diff --git a/sc/qa/unit/functions_test.hxx b/sc/qa/unit/functions_test.hxx
index 52672bb8177b..547c537bf18a 100644
--- a/sc/qa/unit/functions_test.hxx
+++ b/sc/qa/unit/functions_test.hxx
@@ -10,12 +10,11 @@
#include <sal/config.h>
#include <sal/types.h>
-#include <unotest/filters-test.hxx>
-#include "helper/qahelper.hxx"
+#include "helper/scfiltertestbase.hxx"
#include <com/sun/star/uno/Reference.hxx>
-class SCQAHELPER_DLLPUBLIC FunctionsTest : public ScBootstrapFixture, public test::FiltersTest
+class SCQAHELPER_DLLPUBLIC FunctionsTest : public ScFilterTestBase
{
public:
diff --git a/sc/qa/unit/helper/qahelper.cxx b/sc/qa/unit/helper/qahelper.cxx
index bb263fcc9a44..bb61fb4eb119 100644
--- a/sc/qa/unit/helper/qahelper.cxx
+++ b/sc/qa/unit/helper/qahelper.cxx
@@ -469,52 +469,6 @@ OUString toString(
return aBuf.makeStringAndClear();
}
-ScDocShellRef ScBootstrapFixture::load(
- const OUString& rURL, const OUString& rFilter, const OUString &rUserData,
- const OUString& rTypeName, SfxFilterFlags nFilterFlags, SotClipboardFormatId nClipboardID,
- sal_Int32 nFilterVersion )
-{
- auto pFilter = std::make_shared<SfxFilter>(
- rFilter,
- OUString(), nFilterFlags, nClipboardID, rTypeName, OUString(),
- rUserData, "private:factory/scalc");
- pFilter->SetVersion(nFilterVersion);
-
- ScDocShellRef xDocShRef = new ScDocShell;
- xDocShRef->GetDocument().EnableUserInteraction(false);
- SfxMedium* pSrcMed = new SfxMedium(rURL, StreamMode::STD_READ );
- pSrcMed->SetFilter(pFilter);
- pSrcMed->UseInteractionHandler(false);
- SfxItemSet* pSet = pSrcMed->GetItemSet();
- pSet->Put(SfxUInt16Item(SID_MACROEXECMODE,css::document::MacroExecMode::ALWAYS_EXECUTE_NO_WARN));
- SAL_INFO( "sc.qa", "about to load " << rURL );
- if (!xDocShRef->DoLoad(pSrcMed))
- {
- xDocShRef->DoClose();
- // load failed.
- xDocShRef.clear();
- }
-
- return xDocShRef;
-}
-
-void ScBootstrapFixture::setUp()
-{
- test::BootstrapFixture::setUp();
-
- // This is a bit of a fudge, we do this to ensure that ScGlobals::ensure,
- // which is a private symbol to us, gets called
- m_xCalcComponent
- = getMultiServiceFactory()->createInstance("com.sun.star.comp.Calc.SpreadsheetDocument");
- CPPUNIT_ASSERT_MESSAGE("no calc component!", m_xCalcComponent.is());
-}
-
-void ScBootstrapFixture::tearDown()
-{
- uno::Reference< lang::XComponent >( m_xCalcComponent, UNO_QUERY_THROW )->dispose();
- test::BootstrapFixture::tearDown();
-}
-
void ScSimpleBootstrapFixture::setUp()
{
BootstrapFixture::setUp();
diff --git a/sc/qa/unit/helper/qahelper.hxx b/sc/qa/unit/helper/qahelper.hxx
index 3eac1c2c3a86..a4fbfd13fb79 100644
--- a/sc/qa/unit/helper/qahelper.hxx
+++ b/sc/qa/unit/helper/qahelper.hxx
@@ -34,19 +34,6 @@
namespace utl { class TempFileNamed; }
-#define ODS_FORMAT_TYPE (SfxFilterFlags::IMPORT | SfxFilterFlags::EXPORT | SfxFilterFlags::TEMPLATE | SfxFilterFlags::OWN | SfxFilterFlags::DEFAULT | SfxFilterFlags::ENCRYPTION | SfxFilterFlags::PASSWORDTOMODIFY)
-#define XLS_FORMAT_TYPE (SfxFilterFlags::IMPORT | SfxFilterFlags::EXPORT | SfxFilterFlags::ALIEN | SfxFilterFlags::ENCRYPTION | SfxFilterFlags::PASSWORDTOMODIFY | SfxFilterFlags::PREFERED)
-#define XLSX_FORMAT_TYPE (SfxFilterFlags::IMPORT | SfxFilterFlags::EXPORT | SfxFilterFlags::ALIEN | SfxFilterFlags::STARONEFILTER | SfxFilterFlags::PREFERED)
-#define LOTUS123_FORMAT_TYPE (SfxFilterFlags::IMPORT | SfxFilterFlags::ALIEN | SfxFilterFlags::PREFERED)
-#define CSV_FORMAT_TYPE (SfxFilterFlags::IMPORT | SfxFilterFlags::EXPORT | SfxFilterFlags::ALIEN )
-#define HTML_FORMAT_TYPE (SfxFilterFlags::IMPORT | SfxFilterFlags::EXPORT | SfxFilterFlags::ALIEN )
-#define DIF_FORMAT_TYPE (SfxFilterFlags::IMPORT | SfxFilterFlags::EXPORT | SfxFilterFlags::ALIEN )
-#define XLS_XML_FORMAT_TYPE (SfxFilterFlags::IMPORT | SfxFilterFlags::ALIEN | SfxFilterFlags::PREFERED)
-#define XLSB_XML_FORMAT_TYPE (SfxFilterFlags::IMPORT | SfxFilterFlags::ALIEN | SfxFilterFlags::STARONEFILTER | SfxFilterFlags::PREFERED)
-#define FODS_FORMAT_TYPE (SfxFilterFlags::IMPORT | SfxFilterFlags::EXPORT | SfxFilterFlags::OWN | SfxFilterFlags::STARONEFILTER )
-#define GNUMERIC_FORMAT_TYPE (SfxFilterFlags::IMPORT | SfxFilterFlags::ALIEN | SfxFilterFlags::PREFERED )
-#define XLTX_FORMAT_TYPE (SfxFilterFlags::IMPORT | SfxFilterFlags::EXPORT | SfxFilterFlags::TEMPLATE |SfxFilterFlags::ALIEN | SfxFilterFlags::STARONEFILTER | SfxFilterFlags::PREFERED)
-
enum class StringType { PureString, StringValue };
#define CHECK_OPTIMAL 0x1
@@ -124,21 +111,6 @@ public:
~FormulaGrammarSwitch();
};
-class SCQAHELPER_DLLPUBLIC ScBootstrapFixture : public test::BootstrapFixture
-{
-protected:
- ScDocShellRef load(
- const OUString& rURL, const OUString& rFilter, const OUString &rUserData,
- const OUString& rTypeName, SfxFilterFlags nFilterFlags, SotClipboardFormatId nClipboardID,
- sal_Int32 nFilterVersion = SOFFICE_FILEFORMAT_CURRENT );
-private:
- // reference to document interface that we are testing
- css::uno::Reference<css::uno::XInterface> m_xCalcComponent;
-public:
- virtual void setUp() override;
- virtual void tearDown() override;
-};
-
class SCQAHELPER_DLLPUBLIC ScSimpleBootstrapFixture : public test::BootstrapFixture
{
public:
diff --git a/sc/qa/unit/helper/scfiltertestbase.cxx b/sc/qa/unit/helper/scfiltertestbase.cxx
new file mode 100644
index 000000000000..d68a9c3267c9
--- /dev/null
+++ b/sc/qa/unit/helper/scfiltertestbase.cxx
@@ -0,0 +1,68 @@
+/* -*- 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 "scfiltertestbase.hxx"
+
+#include <sfx2/docfilt.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/sfxsids.hrc>
+#include <svl/intitem.hxx>
+
+#include <com/sun/star/document/MacroExecMode.hpp>
+
+using namespace com::sun::star;
+using namespace ::com::sun::star::uno;
+
+ScDocShellRef ScFilterTestBase::loadDoc(const OUString& rURL, const OUString& rFilter,
+ const OUString& rUserData, const OUString& rTypeName,
+ SfxFilterFlags nFilterFlags,
+ SotClipboardFormatId nClipboardID, sal_Int32 nFilterVersion)
+{
+ auto pFilter
+ = std::make_shared<SfxFilter>(rFilter, OUString(), nFilterFlags, nClipboardID, rTypeName,
+ OUString(), rUserData, "private:factory/scalc");
+ pFilter->SetVersion(nFilterVersion);
+
+ ScDocShellRef xDocShRef = new ScDocShell;
+ xDocShRef->GetDocument().EnableUserInteraction(false);
+ SfxMedium* pSrcMed = new SfxMedium(rURL, StreamMode::STD_READ);
+ pSrcMed->SetFilter(pFilter);
+ pSrcMed->UseInteractionHandler(false);
+ SfxItemSet* pSet = pSrcMed->GetItemSet();
+ pSet->Put(
+ SfxUInt16Item(SID_MACROEXECMODE, css::document::MacroExecMode::ALWAYS_EXECUTE_NO_WARN));
+ SAL_INFO("sc.qa", "about to load " << rURL);
+ if (!xDocShRef->DoLoad(pSrcMed))
+ {
+ xDocShRef->DoClose();
+ // load failed.
+ xDocShRef.clear();
+ }
+
+ return xDocShRef;
+}
+
+void ScFilterTestBase::setUp()
+{
+ test::BootstrapFixture::setUp();
+
+ // This is a bit of a fudge, we do this to ensure that ScGlobals::ensure,
+ // which is a private symbol to us, gets called
+ m_xCalcComponent
+ = getMultiServiceFactory()->createInstance("com.sun.star.comp.Calc.SpreadsheetDocument");
+ CPPUNIT_ASSERT_MESSAGE("no calc component!", m_xCalcComponent.is());
+}
+
+void ScFilterTestBase::tearDown()
+{
+ uno::Reference<lang::XComponent>(m_xCalcComponent, UNO_QUERY_THROW)->dispose();
+ test::BootstrapFixture::tearDown();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/qa/unit/helper/scfiltertestbase.hxx b/sc/qa/unit/helper/scfiltertestbase.hxx
new file mode 100644
index 000000000000..a0a12e47e2f4
--- /dev/null
+++ b/sc/qa/unit/helper/scfiltertestbase.hxx
@@ -0,0 +1,68 @@
+/* -*- 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/.
+ */
+
+#pragma once
+
+#include <unotest/filters-test.hxx>
+#include <test/bootstrapfixture.hxx>
+
+#include <docsh.hxx>
+#include <address.hxx>
+
+#include <comphelper/fileformat.h>
+#include "scqahelperdllapi.h"
+
+#define ODS_FORMAT_TYPE \
+ (SfxFilterFlags::IMPORT | SfxFilterFlags::EXPORT | SfxFilterFlags::TEMPLATE \
+ | SfxFilterFlags::OWN | SfxFilterFlags::DEFAULT | SfxFilterFlags::ENCRYPTION \
+ | SfxFilterFlags::PASSWORDTOMODIFY)
+#define XLS_FORMAT_TYPE \
+ (SfxFilterFlags::IMPORT | SfxFilterFlags::EXPORT | SfxFilterFlags::ALIEN \
+ | SfxFilterFlags::ENCRYPTION | SfxFilterFlags::PASSWORDTOMODIFY | SfxFilterFlags::PREFERED)
+#define XLSX_FORMAT_TYPE \
+ (SfxFilterFlags::IMPORT | SfxFilterFlags::EXPORT | SfxFilterFlags::ALIEN \
+ | SfxFilterFlags::STARONEFILTER | SfxFilterFlags::PREFERED)
+#define LOTUS123_FORMAT_TYPE \
+ (SfxFilterFlags::IMPORT | SfxFilterFlags::ALIEN | SfxFilterFlags::PREFERED)
+#define CSV_FORMAT_TYPE (SfxFilterFlags::IMPORT | SfxFilterFlags::EXPORT | SfxFilterFlags::ALIEN)
+#define HTML_FORMAT_TYPE (SfxFilterFlags::IMPORT | SfxFilterFlags::EXPORT | SfxFilterFlags::ALIEN)
+#define DIF_FORMAT_TYPE (SfxFilterFlags::IMPORT | SfxFilterFlags::EXPORT | SfxFilterFlags::ALIEN)
+#define XLS_XML_FORMAT_TYPE \
+ (SfxFilterFlags::IMPORT | SfxFilterFlags::ALIEN | SfxFilterFlags::PREFERED)
+#define XLSB_XML_FORMAT_TYPE \
+ (SfxFilterFlags::IMPORT | SfxFilterFlags::ALIEN | SfxFilterFlags::STARONEFILTER \
+ | SfxFilterFlags::PREFERED)
+#define FODS_FORMAT_TYPE \
+ (SfxFilterFlags::IMPORT | SfxFilterFlags::EXPORT | SfxFilterFlags::OWN \
+ | SfxFilterFlags::STARONEFILTER)
+#define GNUMERIC_FORMAT_TYPE \
+ (SfxFilterFlags::IMPORT | SfxFilterFlags::ALIEN | SfxFilterFlags::PREFERED)
+#define XLTX_FORMAT_TYPE \
+ (SfxFilterFlags::IMPORT | SfxFilterFlags::EXPORT | SfxFilterFlags::TEMPLATE \
+ | SfxFilterFlags::ALIEN | SfxFilterFlags::STARONEFILTER | SfxFilterFlags::PREFERED)
+
+class SCQAHELPER_DLLPUBLIC ScFilterTestBase : public test::BootstrapFixture,
+ public test::FiltersTest
+{
+protected:
+ ScDocShellRef loadDoc(const OUString& rURL, const OUString& rFilter, const OUString& rUserData,
+ const OUString& rTypeName, SfxFilterFlags nFilterFlags,
+ SotClipboardFormatId nClipboardID,
+ sal_Int32 nFilterVersion = SOFFICE_FILEFORMAT_CURRENT);
+
+private:
+ // reference to document interface that we are testing
+ css::uno::Reference<css::uno::XInterface> m_xCalcComponent;
+
+public:
+ virtual void setUp() override;
+ virtual void tearDown() override;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */