summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2022-02-22 18:53:36 +0100
committerXisco Fauli <xiscofauli@libreoffice.org>2022-02-22 22:31:46 +0100
commit00e77788dc0fa13e08ad9f4d1929bb10a53daf8d (patch)
tree805b703584c897c26af34b87b0af94df616606c8
parent52f692937d479e80182ab01e195359a2df064c30 (diff)
sc: qa: factor out common code
Change-Id: I363f4adba8d1d3e98cff8422d0a574e73a6c442f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130366 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r--sc/qa/unit/copy_paste_test.cxx77
-rw-r--r--sc/qa/unit/helper/qahelper.cxx33
-rw-r--r--sc/qa/unit/helper/qahelper.hxx1
-rw-r--r--sc/qa/unit/subsequent_export_test2.cxx39
4 files changed, 48 insertions, 102 deletions
diff --git a/sc/qa/unit/copy_paste_test.cxx b/sc/qa/unit/copy_paste_test.cxx
index 736d84621288..79e1eaf7ef82 100644
--- a/sc/qa/unit/copy_paste_test.cxx
+++ b/sc/qa/unit/copy_paste_test.cxx
@@ -25,7 +25,6 @@
#include <userlist.hxx>
#include <com/sun/star/frame/Desktop.hpp>
-#include <com/sun/star/frame/XModel2.hpp>
#include "helper/qahelper.hxx"
@@ -75,8 +74,6 @@ public:
CPPUNIT_TEST_SUITE_END();
private:
-
- ScDocShellRef loadDocAndSetupModelViewController(std::u16string_view rFileName, sal_Int32 nFormat, bool bReadWrite);
void addToUserList(const OUString& rStr);
uno::Reference<uno::XInterface> m_xCalcComponent;
};
@@ -84,29 +81,7 @@ private:
// tdf#83366
void ScCopyPasteTest::testCopyPasteXLS()
{
- uno::Reference< frame::XDesktop2 > xDesktop = frame::Desktop::create(::comphelper::getProcessComponentContext());
- CPPUNIT_ASSERT( xDesktop.is() );
-
- // create a frame
- Reference< frame::XFrame > xTargetFrame = xDesktop->findFrame( "_blank", 0 );
- CPPUNIT_ASSERT( xTargetFrame.is() );
-
- // 1. Open the document
- ScDocShellRef xDocSh = loadDoc(u"chartx2.", FORMAT_XLS);
- CPPUNIT_ASSERT_MESSAGE("Failed to load chartx2.xls.", xDocSh.is());
-
- uno::Reference< frame::XModel2 > xModel2 = xDocSh->GetModel();
- CPPUNIT_ASSERT( xModel2.is() );
-
- Reference< frame::XController2 > xController = xModel2->createDefaultViewController( xTargetFrame );
- CPPUNIT_ASSERT( xController.is() );
-
- // introduce model/view/controller to each other
- xController->attachModel( xModel2 );
- xModel2->connectController( xController );
- xTargetFrame->setComponent( xController->getComponentWindow(), xController );
- xController->attachFrame( xTargetFrame );
- xModel2->setCurrentController( xController );
+ ScDocShellRef xDocSh = loadDocAndSetupModelViewController(u"chartx2.", FORMAT_XLS);
ScDocument& rDoc = xDocSh->GetDocument();
@@ -131,6 +106,7 @@ void ScCopyPasteTest::testCopyPasteXLS()
// 4. Close the document (Ctrl-W)
xDocSh->DoClose();
+ uno::Reference< frame::XDesktop2 > xDesktop = frame::Desktop::create(::comphelper::getProcessComponentContext());
// 5. Create a new Spreadsheet
Sequence < beans::PropertyValue > args{ comphelper::makePropertyValue("Hidden", true) };
@@ -463,38 +439,9 @@ static ScAddress lcl_getMergeSizeOfCell(const ScDocument& rDoc, SCCOL nCol, SCRO
return ScAddress(rMerge.GetColMerge(), rMerge.GetRowMerge(), nTab);
}
-ScDocShellRef ScCopyPasteTest::loadDocAndSetupModelViewController(std::u16string_view rFileName, sal_Int32 nFormat, bool bReadWrite)
-{
- uno::Reference< frame::XDesktop2 > xDesktop = frame::Desktop::create(::comphelper::getProcessComponentContext());
- CPPUNIT_ASSERT(xDesktop.is());
-
- // create a frame
- Reference< frame::XFrame > xTargetFrame = xDesktop->findFrame("_blank", 0);
- CPPUNIT_ASSERT(xTargetFrame.is());
-
- // 1. Open the document
- ScDocShellRef xDocSh = loadDoc(rFileName, nFormat, bReadWrite);
- CPPUNIT_ASSERT_MESSAGE(OString("Failed to load " + OUStringToOString(rFileName, RTL_TEXTENCODING_UTF8)).getStr(), xDocSh.is());
-
- uno::Reference< frame::XModel2 > xModel2 = xDocSh->GetModel();
- CPPUNIT_ASSERT(xModel2.is());
-
- Reference< frame::XController2 > xController = xModel2->createDefaultViewController(xTargetFrame);
- CPPUNIT_ASSERT(xController.is());
-
- // introduce model/view/controller to each other
- xController->attachModel(xModel2);
- xModel2->connectController(xController);
- xTargetFrame->setComponent(xController->getComponentWindow(), xController);
- xController->attachFrame(xTargetFrame);
- xModel2->setCurrentController(xController);
-
- return xDocSh;
-}
-
void ScCopyPasteTest::testTdf53431_fillOnAutofilter()
{
- ScDocShellRef xDocSh = loadDocAndSetupModelViewController(u"tdf53431_autofilterFilldown.", FORMAT_ODS, true);
+ ScDocShellRef xDocSh = loadDocAndSetupModelViewController(u"tdf53431_autofilterFilldown.", FORMAT_ODS);
ScDocument& rDoc = xDocSh->GetDocument();
// Get the document controller
@@ -532,7 +479,7 @@ void ScCopyPasteTest::testTdf53431_fillOnAutofilter()
void ScCopyPasteTest::testTdf40993_fillMergedCells()
{
- ScDocShellRef xDocSh = loadDocAndSetupModelViewController(u"tdf40993_fillMergedCells.", FORMAT_ODS, true);
+ ScDocShellRef xDocSh = loadDocAndSetupModelViewController(u"tdf40993_fillMergedCells.", FORMAT_ODS);
ScDocument& rDoc = xDocSh->GetDocument();
// Get the document controller
@@ -619,7 +566,7 @@ static void lcl_clickAndCheckCurrentArea(SCCOL nCol, SCROW nRow, SCCOL nCol2, SC
void ScCopyPasteTest::testTdf43958_clickSelectOnMergedCells()
{
- loadDocAndSetupModelViewController(u"tdf40993_fillMergedCells.", FORMAT_ODS, true);
+ loadDocAndSetupModelViewController(u"tdf40993_fillMergedCells.", FORMAT_ODS);
// select cell (e.g. by clicking on it) and check what is selected [but not marked]:
// if it is the top left cell of a merged area, the selection is enlarged to the area
@@ -640,7 +587,7 @@ void ScCopyPasteTest::testTdf43958_clickSelectOnMergedCells()
void ScCopyPasteTest::testTdf88782_autofillLinearNumbersInMergedCells()
{
- ScDocShellRef xDocSh = loadDocAndSetupModelViewController(u"tdf88782_AutofillLinearNumbersInMergedCells.", FORMAT_ODS, true);
+ ScDocShellRef xDocSh = loadDocAndSetupModelViewController(u"tdf88782_AutofillLinearNumbersInMergedCells.", FORMAT_ODS);
ScDocument& rDoc = xDocSh->GetDocument();
// Get the document controller
@@ -700,7 +647,7 @@ void ScCopyPasteTest::testTdf88782_autofillLinearNumbersInMergedCells()
void ScCopyPasteTest::tdf137621_autofillMergedBool()
{
- ScDocShellRef xDocSh = loadDocAndSetupModelViewController(u"tdf137621_autofillMergedBool.", FORMAT_ODS, true);
+ ScDocShellRef xDocSh = loadDocAndSetupModelViewController(u"tdf137621_autofillMergedBool.", FORMAT_ODS);
ScDocument& rDoc = xDocSh->GetDocument();
// Get the document controller
@@ -732,7 +679,7 @@ void ScCopyPasteTest::tdf137621_autofillMergedBool()
void ScCopyPasteTest::tdf137205_autofillDatesInMergedCells()
{
- ScDocShellRef xDocSh = loadDocAndSetupModelViewController(u"tdf137205_AutofillDatesInMergedCells.", FORMAT_ODS, true);
+ ScDocShellRef xDocSh = loadDocAndSetupModelViewController(u"tdf137205_AutofillDatesInMergedCells.", FORMAT_ODS);
ScDocument& rDoc = xDocSh->GetDocument();
// Get the document controller
@@ -770,7 +717,7 @@ void ScCopyPasteTest::addToUserList(const OUString& rStr)
void ScCopyPasteTest::tdf137653_137654_autofillUserlist()
{
- ScDocShellRef xDocSh = loadDocAndSetupModelViewController(u"tdf137653_137654_autofillUserlist.", FORMAT_ODS, true);
+ ScDocShellRef xDocSh = loadDocAndSetupModelViewController(u"tdf137653_137654_autofillUserlist.", FORMAT_ODS);
ScDocument& rDoc = xDocSh->GetDocument();
// Get the document controller
@@ -829,7 +776,7 @@ void ScCopyPasteTest::tdf137653_137654_autofillUserlist()
void ScCopyPasteTest::tdf113500_autofillMixed()
{
- ScDocShellRef xDocSh = loadDocAndSetupModelViewController(u"tdf113500_autofillMixed.", FORMAT_ODS, true);
+ ScDocShellRef xDocSh = loadDocAndSetupModelViewController(u"tdf113500_autofillMixed.", FORMAT_ODS);
ScDocument& rDoc = xDocSh->GetDocument();
// Get the document controller
@@ -878,7 +825,7 @@ void ScCopyPasteTest::tdf113500_autofillMixed()
void ScCopyPasteTest::tdf137625_autofillMergedUserlist()
{
- ScDocShellRef xDocSh = loadDocAndSetupModelViewController(u"tdf137625_autofillMergedUserlist.", FORMAT_ODS, true);
+ ScDocShellRef xDocSh = loadDocAndSetupModelViewController(u"tdf137625_autofillMergedUserlist.", FORMAT_ODS);
ScDocument& rDoc = xDocSh->GetDocument();
// Get the document controller
@@ -937,7 +884,7 @@ void ScCopyPasteTest::tdf137625_autofillMergedUserlist()
void ScCopyPasteTest::tdf137624_autofillMergedMixed()
{
- ScDocShellRef xDocSh = loadDocAndSetupModelViewController(u"tdf137624_autofillMergedMixed.", FORMAT_ODS, true);
+ ScDocShellRef xDocSh = loadDocAndSetupModelViewController(u"tdf137624_autofillMergedMixed.", FORMAT_ODS);
ScDocument& rDoc = xDocSh->GetDocument();
// Get the document controller
diff --git a/sc/qa/unit/helper/qahelper.cxx b/sc/qa/unit/helper/qahelper.cxx
index 76a6cf839c20..30894e939135 100644
--- a/sc/qa/unit/helper/qahelper.cxx
+++ b/sc/qa/unit/helper/qahelper.cxx
@@ -11,6 +11,7 @@
#include "csv_handler.hxx"
#include "debughelper.hxx"
#include <drwlayer.hxx>
+#include <comphelper/processfactory.hxx>
#include <comphelper/sequence.hxx>
#include <comphelper/storagehelper.hxx>
#include <compiler.hxx>
@@ -51,6 +52,9 @@
#include <com/sun/star/chart2/XChartDocument.hpp>
#include <com/sun/star/chart2/data/XDataReceiver.hpp>
#include <com/sun/star/document/MacroExecMode.hpp>
+#include <com/sun/star/frame/Desktop.hpp>
+#include <com/sun/star/frame/XModel2.hpp>
+
using namespace com::sun::star;
using namespace ::com::sun::star::uno;
@@ -641,6 +645,35 @@ ScDocShellRef ScBootstrapFixture::load(const OUString& rURL, sal_Int32 nFormat,
return load(bReadWrite, rURL, aFilterName, OUString(), aFilterType, nFormatType, nClipboardId, static_cast<sal_uIntPtr>(nFormatType));
}
+ScDocShellRef ScBootstrapFixture::loadDocAndSetupModelViewController(std::u16string_view rFileName, sal_Int32 nFormat)
+{
+ uno::Reference< frame::XDesktop2 > xDesktop = frame::Desktop::create(comphelper::getProcessComponentContext());
+ CPPUNIT_ASSERT(xDesktop.is());
+
+ // create a frame
+ Reference< frame::XFrame > xTargetFrame = xDesktop->findFrame("_blank", 0);
+ CPPUNIT_ASSERT(xTargetFrame.is());
+
+ // 1. Open the document
+ ScDocShellRef xDocSh = loadDoc(rFileName, nFormat, true);
+ CPPUNIT_ASSERT_MESSAGE(OString("Failed to load " + OUStringToOString(rFileName, RTL_TEXTENCODING_UTF8)).getStr(), xDocSh.is());
+
+ uno::Reference< frame::XModel2 > xModel2 = xDocSh->GetModel();
+ CPPUNIT_ASSERT(xModel2.is());
+
+ Reference< frame::XController2 > xController = xModel2->createDefaultViewController(xTargetFrame);
+ CPPUNIT_ASSERT(xController.is());
+
+ // introduce model/view/controller to each other
+ xController->attachModel(xModel2);
+ xModel2->connectController(xController);
+ xTargetFrame->setComponent(xController->getComponentWindow(), xController);
+ xController->attachFrame(xTargetFrame);
+ xModel2->setCurrentController(xController);
+
+ return xDocSh;
+}
+
ScDocShellRef ScBootstrapFixture::loadDoc(
std::u16string_view rFileName, sal_Int32 nFormat, bool bReadWrite )
{
diff --git a/sc/qa/unit/helper/qahelper.hxx b/sc/qa/unit/helper/qahelper.hxx
index 204ec020c7a8..888fd2162a0b 100644
--- a/sc/qa/unit/helper/qahelper.hxx
+++ b/sc/qa/unit/helper/qahelper.hxx
@@ -201,6 +201,7 @@ protected:
ScDocShellRef load(const OUString& rURL, sal_Int32 nFormat, bool bReadWrite = false);
+ ScDocShellRef loadDocAndSetupModelViewController(std::u16string_view rFileName, sal_Int32 nFormat);
ScDocShellRef loadDoc(
std::u16string_view rFileName, sal_Int32 nFormat, bool bReadWrite = false );
diff --git a/sc/qa/unit/subsequent_export_test2.cxx b/sc/qa/unit/subsequent_export_test2.cxx
index fa6b002f558e..88f82eaf8509 100644
--- a/sc/qa/unit/subsequent_export_test2.cxx
+++ b/sc/qa/unit/subsequent_export_test2.cxx
@@ -305,8 +305,6 @@ public:
CPPUNIT_TEST_SUITE_END();
private:
- ScDocShellRef loadDocAndSetupModelViewController(std::u16string_view rFileName,
- sal_Int32 nFormat, bool bReadWrite);
uno::Reference<uno::XInterface> m_xCalcComponent;
};
@@ -2560,51 +2558,18 @@ void ScExportTest2::testTdf139258_rotated_image()
assertXPathContent(pDrawing, "/xdr:wsDr/xdr:twoCellAnchor/xdr:to/xdr:row", "25");
}
-ScDocShellRef ScExportTest2::loadDocAndSetupModelViewController(std::u16string_view rFileName,
- sal_Int32 nFormat, bool bReadWrite)
-{
- uno::Reference<frame::XDesktop2> xDesktop
- = frame::Desktop::create(::comphelper::getProcessComponentContext());
- CPPUNIT_ASSERT(xDesktop.is());
-
- // create a frame
- Reference<frame::XFrame> xTargetFrame = xDesktop->findFrame("_blank", 0);
- CPPUNIT_ASSERT(xTargetFrame.is());
-
- // 1. Open the document
- ScDocShellRef xDocSh = loadDoc(rFileName, nFormat, bReadWrite);
- CPPUNIT_ASSERT_MESSAGE(
- OString("Failed to load " + OUStringToOString(rFileName, RTL_TEXTENCODING_UTF8)).getStr(),
- xDocSh.is());
-
- uno::Reference<frame::XModel2> xModel2 = xDocSh->GetModel();
- CPPUNIT_ASSERT(xModel2.is());
-
- Reference<frame::XController2> xController = xModel2->createDefaultViewController(xTargetFrame);
- CPPUNIT_ASSERT(xController.is());
-
- // introduce model/view/controller to each other
- xController->attachModel(xModel2);
- xModel2->connectController(xController);
- xTargetFrame->setComponent(xController->getComponentWindow(), xController);
- xController->attachFrame(xTargetFrame);
- xModel2->setCurrentController(xController);
-
- return xDocSh;
-}
-
void ScExportTest2::testTdf142854_GridVisibilityImportXlsxInHeadlessMode()
{
// Tests are running in Headless mode
// Import an ods file with 'Hide' global grid visibility setting.
ScDocShellRef xShell
- = loadDocAndSetupModelViewController(u"tdf126541_GridOffGlobally.", FORMAT_ODS, true);
+ = loadDocAndSetupModelViewController(u"tdf126541_GridOffGlobally.", FORMAT_ODS);
CPPUNIT_ASSERT(!xShell->GetDocument().GetViewOptions().GetOption(VOPT_GRID));
// To avoid regression, in headless mode leave the bug tdf126541
// It means Sheet based grid line visibility setting will overwrite the global setting.
// If there is only 1 sheet in the document, it will not result visible problems.
- xShell = loadDocAndSetupModelViewController(u"tdf126541_GridOff.", FORMAT_XLSX, true);
+ xShell = loadDocAndSetupModelViewController(u"tdf126541_GridOff.", FORMAT_XLSX);
CPPUNIT_ASSERT(!xShell->GetDocument().GetViewOptions().GetOption(VOPT_GRID));
}