[Libreoffice-commits] core.git: Branch 'feature/dialog-screenshots' - include/test sc/qa sd/qa sd/source test/source
Armin Le Grand
Armin.Le.Grand at cib.de
Thu Jul 21 14:17:42 UTC 2016
include/test/screenshot_test.hxx | 38 ++++-
sc/qa/unit/screenshots/data/screenshots.txt | 154 ++++++++++++++++++++
sc/qa/unit/screenshots/screenshots.cxx | 211 ++++++++++++++++------------
sd/qa/unit/data/dialogs-test.txt | 66 ++++++++
sd/qa/unit/dialogs-test.cxx | 123 ++++++++++------
sd/source/ui/dlg/headerfooterdlg.cxx | 41 ++---
test/source/screenshot_test.cxx | 28 +++
7 files changed, 500 insertions(+), 161 deletions(-)
New commits:
commit 70926f1111b285f9f219b0be0ef7e495cd3fd3d7
Author: Armin Le Grand <Armin.Le.Grand at cib.de>
Date: Thu Jul 21 16:12:47 2016 +0200
Make screenshot UTs read UXMLDescriptions from input file
Besides the already existing methods to dump adapted dialogs
and create and dump fallback dialogs I added a possibility to
process a given input file which may contain a list of
UXMLDescription files (*.ui files), one per line. This file
is processed (empty lines and comment lines using '#' allowed)
and for each descriptor first tries to find a known, adapted
dialog. If found it gets used, else fallback is tried.
Added ui-definition files for sd and sc which contain all
ui-files from these dialogs. Adapted the test base class to
hold the needed functionality.
Change-Id: I1d4c64af8cd5d9c89a53b193951c3e49669f5852
diff --git a/include/test/screenshot_test.hxx b/include/test/screenshot_test.hxx
index a3b0b0e..443db31 100644
--- a/include/test/screenshot_test.hxx
+++ b/include/test/screenshot_test.hxx
@@ -16,18 +16,46 @@
#include <com/sun/star/lang/XComponent.hpp>
#include <osl/file.hxx>
#include <vcl/dialog.hxx>
+#include <map>
class VclAbstractDialog;
-
+typedef std::map< OString, sal_uInt32 > mapType;
class OOO_DLLPUBLIC_TEST ScreenshotTest : public test::BootstrapFixture, public unotest::MacrosTest
{
+private:
+ /// the target directory for screenshots
+ OUString m_aScreenshotDirectory;
+
+ /// the set of known dialogs and their ID for usage in createDialogByID
+ mapType maKnownDialogs;
+
+private:
+ /// helpers
+ void implSaveScreenshot(const Bitmap& rScreenshot, const OString& rScreenshotId);
+ void saveScreenshot(VclAbstractDialog& rDialog);
+ void saveScreenshot(Dialog& rDialog);
+
+ /// helper method to populate maKnownDialogs, called in setUp(). Needs to be
+ /// written and has to add entries to maKnownDialogs
+ virtual void registerKnownDialogsByID(mapType& rKnownDialogs) = 0;
+
+ /// dialog creation for known dialogs by ID. Has to be implemented for
+ /// each registered known dialog
+ virtual VclAbstractDialog* createDialogByID(sal_uInt32 nID) = 0;
+
public:
ScreenshotTest();
+ virtual ~ScreenshotTest();
virtual void setUp() override;
virtual void tearDown() override;
+ /// Dialog creation for known dialogs by Name (path and UIXMLDescription, *.ui file).
+ /// This uses maKnownDialogs to check if known, and if so, calls createDialogByID
+ /// with the ID from the map
+ VclAbstractDialog* createDialogByName(const OString& rName);
+
/// version for AbstractDialogs, the ones created in AbstractDialogFactories
void dumpDialogToPath(VclAbstractDialog& rDialog);
@@ -40,12 +68,8 @@ public:
/// compared to the active dialog (can be compared with dialog previewer)
void dumpDialogToPath(const OString& rUIXMLDescription);
-private:
- void implSaveScreenshot(const Bitmap& rScreenshot, const OString& rScreenshotId);
- void saveScreenshot(VclAbstractDialog& rDialog);
- void saveScreenshot(Dialog& rDialog);
-
- OUString m_aScreenshotDirectory;
+ /// const access to known dialogs
+ const mapType& getKnownDialogs() const { return maKnownDialogs; }
};
#endif // INCLUDED_TEST_SCREENSHOT_TEST_HXX
diff --git a/sc/qa/unit/screenshots/data/screenshots.txt b/sc/qa/unit/screenshots/data/screenshots.txt
new file mode 100644
index 0000000..1fa34d7
--- /dev/null
+++ b/sc/qa/unit/screenshots/data/screenshots.txt
@@ -0,0 +1,154 @@
+# -*- 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 contains all dialogs that the test dialogs-test
+# will test. It will read one-by-one, try to open it and create a
+# screenshot that will be saved in workdir/screenshots using the
+# pattern of the ui-file name.
+#
+# You may use empty lines, or lines starrting with '#' which are treated
+# as comments. All other lines have to end with <CR> and will be interpreted
+# as ui-files.
+
+#
+# The known dialogs which have a hard-coded representation
+#
+
+modules/scalc/ui/insertsheet.ui
+modules/scalc/ui/deletecells.ui
+modules/scalc/ui/pastespecial.ui
+modules/scalc/ui/changesourcedialog.ui
+modules/scalc/ui/selectdatasource.ui
+modules/scalc/ui/selectsource.ui
+modules/scalc/ui/deletecontents.ui
+modules/scalc/ui/createnamesdialog.ui
+modules/scalc/ui/inputstringdialog.ui
+modules/scalc/ui/tabcolordialog.ui
+modules/scalc/ui/textimportoptions.ui
+modules/scalc/ui/dataform.ui
+modules/scalc/ui/movecopysheet.ui
+modules/scalc/ui/textimportcsv.ui
+modules/scalc/ui/formatcellsdialog.ui
+
+#
+# Dialogs without a hard-coded representation. These will
+# be visualized using a fallback based on VclBuilder
+#
+
+modules/scalc/ui/autoformattable.ui
+modules/scalc/ui/sortwarning.ui
+modules/scalc/ui/condformatmanager.ui
+modules/scalc/ui/pagetemplatedialog.ui
+modules/scalc/ui/paratemplatedialog.ui
+modules/scalc/ui/databaroptions.ui
+modules/scalc/ui/advancedfilterdialog.ui
+modules/scalc/ui/datafielddialog.ui
+modules/scalc/ui/pivotfielddialog.ui
+modules/scalc/ui/datafieldoptionsdialog.ui
+modules/scalc/ui/showdetaildialog.ui
+modules/scalc/ui/consolidatedialog.ui
+modules/scalc/ui/dapiservicedialog.ui
+modules/scalc/ui/imoptdialog.ui
+modules/scalc/ui/pivotfilterdialog.ui
+modules/scalc/ui/groupbynumber.ui
+modules/scalc/ui/groupbydate.ui
+modules/scalc/ui/sortdialog.ui
+modules/scalc/ui/standardfilterdialog.ui
+modules/scalc/ui/pivottablelayoutdialog.ui
+modules/scalc/ui/validationdialog.ui
+modules/scalc/ui/subtotaldialog.ui
+modules/scalc/ui/scenariodialog.ui
+modules/scalc/ui/searchresults.ui
+modules/scalc/ui/definename.ui
+modules/scalc/ui/insertname.ui
+modules/scalc/ui/tpviewpage.ui
+modules/scalc/ui/scgeneralpage.ui
+modules/scalc/ui/optformula.ui
+modules/scalc/ui/formulacalculationoptions.ui
+modules/scalc/ui/optdlg.ui
+modules/scalc/ui/optcompatibilitypage.ui
+modules/scalc/ui/optchangespage.ui
+modules/scalc/ui/optdefaultpage.ui
+modules/scalc/ui/optsortlists.ui
+modules/scalc/ui/optcalculatepage.ui
+modules/scalc/ui/movingaveragedialog.ui
+modules/scalc/ui/analysisofvariancedialog.ui
+modules/scalc/ui/covariancedialog.ui
+modules/scalc/ui/correlationdialog.ui
+modules/scalc/ui/ttestdialog.ui
+modules/scalc/ui/ztestdialog.ui
+modules/scalc/ui/chisquaretestdialog.ui
+modules/scalc/ui/regressiondialog.ui
+modules/scalc/ui/exponentialsmoothingdialog.ui
+modules/scalc/ui/descriptivestatisticsdialog.ui
+modules/scalc/ui/samplingdialog.ui
+modules/scalc/ui/goalseekdlg.ui
+modules/scalc/ui/selectrange.ui
+modules/scalc/ui/protectsheetdlg.ui
+modules/scalc/ui/namerangesdialog.ui
+modules/scalc/ui/sharedocumentdlg.ui
+modules/scalc/ui/solverdlg.ui
+modules/scalc/ui/solveroptionsdialog.ui
+modules/scalc/ui/externaldata.ui
+modules/scalc/ui/datastreams.ui
+modules/scalc/ui/statisticsinfopage.ui
+modules/scalc/ui/cellprotectionpage.ui
+modules/scalc/ui/printareasdialog.ui
+modules/scalc/ui/headerfooterdialog.ui
+modules/scalc/ui/conditionalformatdialog.ui
+modules/scalc/ui/definedatabaserangedialog.ui
+modules/scalc/ui/sortkey.ui
+modules/scalc/ui/sortcriteriapage.ui
+modules/scalc/ui/sortoptionspage.ui
+modules/scalc/ui/subtotalgrppage.ui
+modules/scalc/ui/subtotaloptionspage.ui
+modules/scalc/ui/validationcriteriapage.ui
+modules/scalc/ui/validationhelptabpage.ui
+modules/scalc/ui/erroralerttabpage.ui
+modules/scalc/ui/conflictsdialog.ui
+modules/scalc/ui/colorrowdialog.ui
+modules/scalc/ui/filldlg.ui
+modules/scalc/ui/ungroupdialog.ui
+modules/scalc/ui/groupdialog.ui
+modules/scalc/ui/showchangesdialog.ui
+modules/scalc/ui/insertcells.ui
+modules/scalc/ui/RowHeightDialog.ui
+modules/scalc/ui/OptimalRowHeightDialog.ui
+modules/scalc/ui/ColWidthDialog.ui
+modules/scalc/ui/OptimalColWidthDialog.ui
+modules/scalc/ui/solverprogressdialog.ui
+modules/scalc/ui/nosolutiondialog.ui
+modules/scalc/ui/solversuccessdialog.ui
+modules/scalc/ui/retypepassdialog.ui
+modules/scalc/ui/retypepassworddialog.ui
+modules/scalc/ui/showsheetdialog.ui
+modules/scalc/ui/simplerefdialog.ui
+modules/scalc/ui/integerdialog.ui
+modules/scalc/ui/doubledialog.ui
+modules/scalc/ui/multipleoperationsdialog.ui
+modules/scalc/ui/chardialog.ui
+modules/scalc/ui/paradialog.ui
+modules/scalc/ui/managenamesdialog.ui
+modules/scalc/ui/headerdialog.ui
+modules/scalc/ui/footerdialog.ui
+modules/scalc/ui/leftheaderdialog.ui
+modules/scalc/ui/rightheaderdialog.ui
+modules/scalc/ui/leftfooterdialog.ui
+modules/scalc/ui/rightfooterdialog.ui
+modules/scalc/ui/sharedheaderdialog.ui
+modules/scalc/ui/sharedfooterdialog.ui
+modules/scalc/ui/allheaderfooterdialog.ui
+modules/scalc/ui/headerfootercontent.ui
+modules/scalc/ui/sheetprintpage.ui
+modules/scalc/ui/sidebaralignment.ui
+modules/scalc/ui/sidebarcellappearance.ui
+modules/scalc/ui/sidebarnumberformat.ui
+modules/scalc/ui/randomnumbergenerator.ui
+modules/scalc/ui/printeroptions.ui
+modules/scalc/ui/xmlsourcedialog.ui
diff --git a/sc/qa/unit/screenshots/screenshots.cxx b/sc/qa/unit/screenshots/screenshots.cxx
index 556db72..927ec01 100644
--- a/sc/qa/unit/screenshots/screenshots.cxx
+++ b/sc/qa/unit/screenshots/screenshots.cxx
@@ -40,17 +40,36 @@
#include <sc.hrc>
#include <scresid.hxx>
#include <scitems.hxx>
-#include <map>
using namespace css;
-typedef std::map< OString, sal_uInt32 > mapType;
-
static const char* DATA_DIRECTORY = "/sc/qa/unit/screenshots/data/";
class ScScreenshotTest : public ScreenshotTest
{
+private:
+ /// members
+ uno::Reference<lang::XComponent> mxComponent;
+ SfxObjectShell* mpFoundShell;
+ ScDocShellRef mxDocSh;
+ ScTabViewShell* mpViewShell;
+ ScAbstractDialogFactory* mpFact;
+ std::unique_ptr<ScImportStringStream> mpStream;
+ std::unique_ptr<SfxItemSet> mpItemSet;
+
+ /// helper
+ void initializeWithDoc(const char* pName);
+
+ /// helper method to populate KnownDialogs, called in setUp(). Needs to be
+ /// written and has to add entries to KnownDialogs
+ virtual void registerKnownDialogsByID(mapType& rKnownDialogs) override;
+
+ /// dialog creation for known dialogs by ID. Has to be implemented for
+ /// each registered known dialog
+ virtual VclAbstractDialog* createDialogByID(sal_uInt32 nID) override;
+
public:
ScScreenshotTest();
+ virtual ~ScScreenshotTest();
void testOpeningModalDialogs();
//void testOpeningModelessDialogs();
@@ -59,34 +78,20 @@ public:
CPPUNIT_TEST(testOpeningModalDialogs);
//CPPUNIT_TEST(testOpeningModelessDialogs);
CPPUNIT_TEST_SUITE_END();
-
-private:
- void initializeWithDoc(const char* pName);
-
- VclAbstractDialog* createDialogByID( sal_uInt32 nID);
-
-
- uno::Reference<lang::XComponent> mxComponent;
- SfxObjectShell* pFoundShell;
- ScDocShellRef xDocSh;
- ScTabViewShell* pViewShell;
- ScAbstractDialogFactory* pFact;
-
- std::unique_ptr<ScImportStringStream> pStream;
- std::unique_ptr<SfxItemSet> pItemSet;
-
- /// the set of known dialogs and their ID for usage in createDialogByID
- mapType maKnownDialogs;
};
ScScreenshotTest::ScScreenshotTest()
: mxComponent(),
- pFoundShell(nullptr),
- xDocSh(),
- pViewShell(nullptr),
- pFact(nullptr),
- pStream(),
- maKnownDialogs()
+ mpFoundShell(nullptr),
+ mxDocSh(),
+ mpViewShell(nullptr),
+ mpFact(nullptr),
+ mpStream(),
+ mpItemSet()
+{
+}
+
+ScScreenshotTest::~ScScreenshotTest()
{
}
@@ -96,45 +101,43 @@ void ScScreenshotTest::initializeWithDoc(const char* pName)
mxComponent->dispose();
mxComponent = loadFromDesktop(m_directories.getURLFromSrc(DATA_DIRECTORY) + OUString::createFromAscii(pName), "com.sun.star.sheet.SpreadsheetDocument");
- pFoundShell = SfxObjectShell::GetShellFromComponent(mxComponent);
- CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell);
+ mpFoundShell = SfxObjectShell::GetShellFromComponent(mxComponent);
+ CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", mpFoundShell);
- xDocSh = dynamic_cast<ScDocShell*>(pFoundShell);
- CPPUNIT_ASSERT(xDocSh != nullptr);
+ mxDocSh = dynamic_cast<ScDocShell*>(mpFoundShell);
+ CPPUNIT_ASSERT(mxDocSh != nullptr);
- pViewShell = xDocSh->GetBestViewShell(false);
- CPPUNIT_ASSERT(pViewShell != nullptr);
+ mpViewShell = mxDocSh->GetBestViewShell(false);
+ CPPUNIT_ASSERT(mpViewShell != nullptr);
- pFact = ScAbstractDialogFactory::Create();
- CPPUNIT_ASSERT_MESSAGE("Failed to create dialog factory", pFact);
+ mpFact = ScAbstractDialogFactory::Create();
+ CPPUNIT_ASSERT_MESSAGE("Failed to create dialog factory", mpFact);
const OUString aCsv("some, strings, here, separated, by, commas");
- pStream.reset(new ScImportStringStream(aCsv));
+ mpStream.reset(new ScImportStringStream(aCsv));
+}
- if (maKnownDialogs.empty())
- {
- // fill map of unknown dilogs. Use a set here to allow later
- // to 'find' a ID for construction based on the UIXMLDescription
- // string (currently not yet used)
- maKnownDialogs["modules/scalc/ui/insertsheet.ui"] = 0;
- maKnownDialogs["modules/scalc/ui/deletecells.ui"] = 1;
- maKnownDialogs["modules/scalc/ui/pastespecial.ui"] = 2;
- maKnownDialogs["modules/scalc/ui/changesourcedialog.ui"] = 3;
- maKnownDialogs["modules/scalc/ui/selectdatasource.ui"] = 4;
- maKnownDialogs["modules/scalc/ui/selectsource.ui"] = 5;
- maKnownDialogs["modules/scalc/ui/deletecontents.ui"] = 6;
- maKnownDialogs["modules/scalc/ui/createnamesdialog.ui"] = 7;
- maKnownDialogs["modules/scalc/ui/inputstringdialog.ui"] = 8;
- maKnownDialogs["modules/scalc/ui/tabcolordialog.ui"] = 9;
- maKnownDialogs["modules/scalc/ui/textimportoptions.ui"] = 10;
- maKnownDialogs["modules/scalc/ui/dataform.ui"] = 11;
- maKnownDialogs["modules/scalc/ui/movecopysheet.ui"] = 12;
- maKnownDialogs["modules/scalc/ui/textimportcsv.ui"] = 13;
- maKnownDialogs["modules/scalc/ui/formatcellsdialog.ui"] = 14;
- }
+void ScScreenshotTest::registerKnownDialogsByID(mapType& rKnownDialogs)
+{
+ // fill map of unknown dilogs
+ rKnownDialogs["modules/scalc/ui/insertsheet.ui"] = 0;
+ rKnownDialogs["modules/scalc/ui/deletecells.ui"] = 1;
+ rKnownDialogs["modules/scalc/ui/pastespecial.ui"] = 2;
+ rKnownDialogs["modules/scalc/ui/changesourcedialog.ui"] = 3;
+ rKnownDialogs["modules/scalc/ui/selectdatasource.ui"] = 4;
+ rKnownDialogs["modules/scalc/ui/selectsource.ui"] = 5;
+ rKnownDialogs["modules/scalc/ui/deletecontents.ui"] = 6;
+ rKnownDialogs["modules/scalc/ui/createnamesdialog.ui"] = 7;
+ rKnownDialogs["modules/scalc/ui/inputstringdialog.ui"] = 8;
+ rKnownDialogs["modules/scalc/ui/tabcolordialog.ui"] = 9;
+ rKnownDialogs["modules/scalc/ui/textimportoptions.ui"] = 10;
+ rKnownDialogs["modules/scalc/ui/dataform.ui"] = 11;
+ rKnownDialogs["modules/scalc/ui/movecopysheet.ui"] = 12;
+ rKnownDialogs["modules/scalc/ui/textimportcsv.ui"] = 13;
+ rKnownDialogs["modules/scalc/ui/formatcellsdialog.ui"] = 14;
}
-VclAbstractDialog* ScScreenshotTest::createDialogByID( sal_uInt32 nID )
+VclAbstractDialog* ScScreenshotTest::createDialogByID(sal_uInt32 nID)
{
VclAbstractDialog *pReturnDialog = nullptr;
////FIXME: translatable string here
@@ -144,47 +147,47 @@ VclAbstractDialog* ScScreenshotTest::createDialogByID( sal_uInt32 nID )
{
case 0: // "modules/scalc/ui/insertsheet.ui"
{
- ScViewData& rViewData = pViewShell->GetViewData();
+ ScViewData& rViewData = mpViewShell->GetViewData();
SCTAB nTabSelCount = rViewData.GetMarkData().GetSelectCount();
- pReturnDialog = pFact->CreateScInsertTableDlg(
- pViewShell->GetDialogParent(), rViewData, nTabSelCount, false);
+ pReturnDialog = mpFact->CreateScInsertTableDlg(
+ mpViewShell->GetDialogParent(), rViewData, nTabSelCount, false);
break;
}
case 1: // "modules/scalc/ui/deletecells.ui"
{
- pReturnDialog = pFact->CreateScDeleteCellDlg( pViewShell->GetDialogParent(), false );
+ pReturnDialog = mpFact->CreateScDeleteCellDlg(mpViewShell->GetDialogParent(), false);
break;
}
case 2: // "modules/scalc/ui/pastespecial.ui"
{
- pReturnDialog = pFact->CreateScInsertContentsDlg( pViewShell->GetDialogParent() );
+ pReturnDialog = mpFact->CreateScInsertContentsDlg(mpViewShell->GetDialogParent());
break;
}
case 3: // "modules/scalc/ui/changesourcedialog.ui"
{
- pReturnDialog = pFact->CreateScColRowLabelDlg( pViewShell->GetDialogParent(), true, false );
+ pReturnDialog = mpFact->CreateScColRowLabelDlg(mpViewShell->GetDialogParent(), true, false);
break;
}
case 4: // "modules/scalc/ui/selectdatasource.ui"
{
- pReturnDialog = pFact->CreateScDataPilotDatabaseDlg( pViewShell->GetDialogParent() );
+ pReturnDialog = mpFact->CreateScDataPilotDatabaseDlg(mpViewShell->GetDialogParent());
break;
}
case 5: // "modules/scalc/ui/selectsource.ui"
{
- pReturnDialog = pFact->CreateScDataPilotSourceTypeDlg(pViewShell->GetDialogParent(), true );
+ pReturnDialog = mpFact->CreateScDataPilotSourceTypeDlg(mpViewShell->GetDialogParent(), true);
break;
}
case 6: // "modules/scalc/ui/deletecontents.ui"
{
- pReturnDialog = pFact->CreateScDeleteContentsDlg( pViewShell->GetDialogParent() );
+ pReturnDialog = mpFact->CreateScDeleteContentsDlg(mpViewShell->GetDialogParent());
break;
}
@@ -192,14 +195,14 @@ VclAbstractDialog* ScScreenshotTest::createDialogByID( sal_uInt32 nID )
{
//// just fake some flags
sal_uInt16 nFlags = NAME_LEFT | NAME_TOP;
- pReturnDialog = pFact->CreateScNameCreateDlg( pViewShell->GetDialogParent(), nFlags );
+ pReturnDialog = mpFact->CreateScNameCreateDlg(mpViewShell->GetDialogParent(), nFlags);
break;
}
case 8: // "modules/scalc/ui/inputstringdialog.ui"
{
const OString aEmpty("");
- pReturnDialog = pFact->CreateScStringInputDlg( pViewShell->GetDialogParent(),
+ pReturnDialog = mpFact->CreateScStringInputDlg(mpViewShell->GetDialogParent(),
OUString(ScResId(SCSTR_APDTABLE)), OUString(ScResId(SCSTR_NAME)),
aDefaultSheetName, aEmpty, aEmpty );
break;
@@ -207,7 +210,7 @@ VclAbstractDialog* ScScreenshotTest::createDialogByID( sal_uInt32 nID )
case 9: // "modules/scalc/ui/tabcolordialog.ui"
{
- pReturnDialog = pFact->CreateScTabBgColorDlg( pViewShell->GetDialogParent(),
+ pReturnDialog = mpFact->CreateScTabBgColorDlg(mpViewShell->GetDialogParent(),
OUString(ScResId(SCSTR_SET_TAB_BG_COLOR)),
OUString(ScResId(SCSTR_NO_TAB_BG_COLOR)), Color(0xff00ff) );
break;
@@ -215,7 +218,7 @@ VclAbstractDialog* ScScreenshotTest::createDialogByID( sal_uInt32 nID )
case 10: // "modules/scalc/ui/textimportoptions.ui"
{
- pReturnDialog = pFact->CreateScTextImportOptionsDlg();
+ pReturnDialog = mpFact->CreateScTextImportOptionsDlg();
break;
}
@@ -223,43 +226,43 @@ VclAbstractDialog* ScScreenshotTest::createDialogByID( sal_uInt32 nID )
{
////FIXME: looks butt-ugly w/ empty file, move it elsewhere, where
////we actually have some data
- pReturnDialog = pFact->CreateScDataFormDlg( pViewShell->GetDialogParent(), pViewShell );
+ pReturnDialog = mpFact->CreateScDataFormDlg(mpViewShell->GetDialogParent(), mpViewShell);
break;
}
case 12: // "modules/scalc/ui/movecopysheet.ui"
{
- pReturnDialog = pFact->CreateScMoveTableDlg( pViewShell->GetDialogParent(), aDefaultSheetName );
+ pReturnDialog = mpFact->CreateScMoveTableDlg(mpViewShell->GetDialogParent(), aDefaultSheetName);
break;
}
case 13: // "modules/scalc/ui/textimportcsv.ui"
{
- pReturnDialog = pFact->CreateScImportAsciiDlg( OUString(), pStream.get(), SC_PASTETEXT );
+ pReturnDialog = mpFact->CreateScImportAsciiDlg(OUString(), mpStream.get(), SC_PASTETEXT);
break;
}
case 14: // "modules/scalc/ui/formatcellsdialog.ui"
{
- ScViewData& rViewData = pViewShell->GetViewData();
+ ScViewData& rViewData = mpViewShell->GetViewData();
ScDocument *pDoc = rViewData.GetDocument();
- const ScPatternAttr *pAttr = pViewShell->GetSelectionPattern();
+ const ScPatternAttr *pAttr = mpViewShell->GetSelectionPattern();
std::unique_ptr<SvxNumberInfoItem> pNumberInfoItem;
- pItemSet.reset( new SfxItemSet( pAttr->GetItemSet() ) );
- pItemSet->Put( SfxUInt32Item( ATTR_VALUE_FORMAT,
+ mpItemSet.reset(new SfxItemSet(pAttr->GetItemSet()));
+ mpItemSet->Put(SfxUInt32Item(ATTR_VALUE_FORMAT,
pAttr->GetNumberFormat( pDoc->GetFormatTable() ) ) );
- pNumberInfoItem.reset( pViewShell->MakeNumberInfoItem(pDoc, &rViewData) );
+ pNumberInfoItem.reset(mpViewShell->MakeNumberInfoItem(pDoc, &rViewData));
- pItemSet->MergeRange( SID_ATTR_NUMBERFORMAT_INFO, SID_ATTR_NUMBERFORMAT_INFO );
- pItemSet->Put(*pNumberInfoItem );
+ mpItemSet->MergeRange(SID_ATTR_NUMBERFORMAT_INFO, SID_ATTR_NUMBERFORMAT_INFO);
+ mpItemSet->Put(*pNumberInfoItem);
- pReturnDialog = pFact->CreateScAttrDlg( pViewShell->GetDialogParent(), pItemSet.get() );
+ pReturnDialog = mpFact->CreateScAttrDlg(mpViewShell->GetDialogParent(), mpItemSet.get());
break;
}
- //ScopedVclPtrInstance<ScShareDocumentDlg> pDlg14( pViewShell->GetDialogParent(), &rViewData );
- //ScopedVclPtrInstance<ScTableProtectionDlg> pDlg16(pViewShell->GetDialogParent());
+ //ScopedVclPtrInstance<ScShareDocumentDlg> pDlg14( mpViewShell->GetDialogParent(), &rViewData );
+ //ScopedVclPtrInstance<ScTableProtectionDlg> pDlg16(mpViewShell->GetDialogParent());
default:
break;
}
@@ -272,11 +275,45 @@ void ScScreenshotTest::testOpeningModalDialogs()
{
initializeWithDoc("empty.ods");
- static bool bDumpAllKnownDialogs = true;
+ /// example how to process an input file containing the UXMLDescriptions of the dialogs
+ /// to dump
+ if (true)
+ {
+ test::Directories aDirectories;
+ OUString aURL = aDirectories.getURLFromSrc("sc/qa/unit/screenshots/data/screenshots.txt");
+ SvFileStream aStream(aURL, StreamMode::READ);
+ OString aNextUIFile;
+ OString aComment("#");
+
+ while (aStream.ReadLine(aNextUIFile))
+ {
+ if (!aNextUIFile.isEmpty() && !aNextUIFile.startsWith(aComment))
+ {
+ // first check if it's a known dialog
+ std::unique_ptr<VclAbstractDialog> pDlg(createDialogByName(aNextUIFile));
+
+ if (pDlg)
+ {
+ // known dialog, dump screenshot to path
+ dumpDialogToPath(*pDlg);
+ }
+ else
+ {
+ // unknown dialog, try fallback to generic created
+ // VclBuilder-generated instance. Keep in mind that Dialogs
+ // using this mechanism will probably not be layouted well
+ // since the setup/initialization part is missing. Thus,
+ // only use for fallback when only the UI file is available.
+ dumpDialogToPath(aNextUIFile);
+ }
+ }
+ }
+ }
- if (bDumpAllKnownDialogs)
+ /// example how to dump all known dialogs
+ if (false)
{
- for (mapType::const_iterator i = maKnownDialogs.begin(); i != maKnownDialogs.end(); i++)
+ for (mapType::const_iterator i = getKnownDialogs().begin(); i != getKnownDialogs().end(); i++)
{
std::unique_ptr<VclAbstractDialog> pDlg(createDialogByID((*i).second));
diff --git a/sd/qa/unit/data/dialogs-test.txt b/sd/qa/unit/data/dialogs-test.txt
new file mode 100644
index 0000000..2b7ad1a
--- /dev/null
+++ b/sd/qa/unit/data/dialogs-test.txt
@@ -0,0 +1,66 @@
+# -*- 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 contains all dialogs that the test dialogs-test
+# will test. It will read one-by-one, try to open it and create a
+# screenshot that will be saved in workdir/screenshots using the
+# pattern of the ui-file name.
+#
+# You may use empty lines, or lines starrting with '#' which are treated
+# as comments. All other lines have to end with <CR> and will be interpreted
+# as ui-files.
+
+#
+# The known dialogs which have a hard-coded representation
+#
+
+modules/simpress/ui/publishingdialog.ui
+modules/sdraw/ui/breakdialog.ui
+modules/sdraw/ui/copydlg.ui
+modules/simpress/ui/customslideshows.ui
+modules/sdraw/ui/drawchardialog.ui
+modules/sdraw/ui/drawpagedialog.ui
+modules/simpress/ui/dlgfield.ui
+modules/sdraw/ui/dlgsnap.ui
+modules/sdraw/ui/insertlayer.ui
+modules/sdraw/ui/insertslidesdialog.ui
+modules/sdraw/ui/crossfadedialog.ui
+modules/sdraw/ui/bulletsandnumbering.ui
+modules/sdraw/ui/drawparadialog.ui
+modules/simpress/ui/presentationdialog.ui
+modules/simpress/ui/remotedialog.ui
+modules/simpress/ui/templatedialog.ui
+modules/simpress/ui/slidedesigndialog.ui
+modules/sdraw/ui/drawprtldialog.ui
+modules/simpress/ui/interactiondialog.ui
+modules/sdraw/ui/vectorize.ui
+modules/simpress/ui/photoalbum.ui
+modules/simpress/ui/masterlayoutdlg.ui
+modules/simpress/ui/headerfooterdialog.ui
+
+#
+# Dialogs without a hard-coded representation. These will
+# be visualized using a fallback based on VclBuilder
+#
+
+modules/simpress/ui/headerfootertab.ui
+modules/simpress/ui/customanimationproperties.ui
+modules/simpress/ui/customanimationeffecttab.ui
+modules/simpress/ui/customanimationtimingtab.ui
+modules/simpress/ui/customanimationtexttab.ui
+modules/sdraw/ui/paranumberingtab.ui
+modules/simpress/ui/sdviewpage.ui
+modules/simpress/ui/prntopts.ui
+modules/simpress/ui/optimpressgeneralpage.ui
+modules/simpress/ui/interactionpage.ui
+modules/simpress/ui/assistentdialog.ui
+modules/sdraw/ui/namedesign.ui
+modules/simpress/ui/definecustomslideshow.ui
+modules/simpress/ui/insertslides.ui
+modules/sdraw/ui/tabledesigndialog.ui
diff --git a/sd/qa/unit/dialogs-test.cxx b/sd/qa/unit/dialogs-test.cxx
index 893fd43..368a96a 100644
--- a/sd/qa/unit/dialogs-test.cxx
+++ b/sd/qa/unit/dialogs-test.cxx
@@ -54,10 +54,8 @@
#include <com/sun/star/frame/XDesktop2.hpp>
#include <comphelper/processfactory.hxx>
#include <unotest/macros_test.hxx>
-#include <map>
using namespace ::com::sun::star;
-typedef std::map< OString, sal_uInt32 > mapType;
/// Test opening a dialog in sd
class SdDialogsTest : public ScreenshotTest
@@ -79,9 +77,6 @@ private:
std::unique_ptr<SfxItemSet> mpEmptySfxItemSet;
std::unique_ptr<SfxItemSet> mpEmptyFillStyleSfxItemSet;
- /// the set of known dialogs and their ID for usage in createDialogByID
- mapType maKnownDialogs;
-
/// helpers
SdAbstractDialogFactory* getSdAbstractDialogFactory();
SdXImpressDocument* getSdXImpressDocument();
@@ -92,12 +87,17 @@ private:
const SfxItemSet& getEmptySfxItemSet();
const SfxItemSet& getEmptyFillStyleSfxItemSet();
- /// central method: dialog creation and dumping to target directory (path)
- VclAbstractDialog* createDialogByID(sal_uInt32 nID);
+ /// helper method to populate KnownDialogs, called in setUp(). Needs to be
+ /// written and has to add entries to KnownDialogs
+ virtual void registerKnownDialogsByID(mapType& rKnownDialogs) override;
+
+ /// dialog creation for known dialogs by ID. Has to be implemented for
+ /// each registered known dialog
+ virtual VclAbstractDialog* createDialogByID(sal_uInt32 nID) override;
public:
SdDialogsTest();
- ~SdDialogsTest();
+ virtual ~SdDialogsTest();
virtual void setUp() override;
@@ -118,8 +118,7 @@ SdDialogsTest::SdDialogsTest()
mpDrawView(nullptr),
mpSfxItemSetFromSdrObject(nullptr),
mpEmptySfxItemSet(nullptr),
- mpEmptyFillStyleSfxItemSet(nullptr),
- maKnownDialogs()
+ mpEmptyFillStyleSfxItemSet(nullptr)
{
}
@@ -137,38 +136,9 @@ void SdDialogsTest::setUp()
mpImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get());
CPPUNIT_ASSERT(mpImpressDocument);
-
- if (maKnownDialogs.empty())
- {
- // fill map of unknown dilogs. Use a set here to allow later
- // to 'find' a ID for construction based on the UIXMLDescription
- // string (currently not yet used)
- maKnownDialogs["modules/simpress/ui/publishingdialog.ui"] = 0;
- maKnownDialogs["modules/sdraw/ui/breakdialog.ui"] = 1;
- maKnownDialogs["modules/sdraw/ui/copydlg.ui"] = 2;
- maKnownDialogs["modules/simpress/ui/customslideshows.ui"] = 3;
- maKnownDialogs["modules/sdraw/ui/drawchardialog.ui"] = 4;
- maKnownDialogs["modules/sdraw/ui/drawpagedialog.ui"] = 5;
- maKnownDialogs["modules/simpress/ui/dlgfield.ui"] = 6;
- maKnownDialogs["modules/sdraw/ui/dlgsnap.ui"] = 7;
- maKnownDialogs["modules/sdraw/ui/insertlayer.ui"] = 8;
- maKnownDialogs["modules/sdraw/ui/insertslidesdialog.ui"] = 9;
- maKnownDialogs["modules/sdraw/ui/crossfadedialog.ui"] = 10;
- maKnownDialogs["modules/sdraw/ui/bulletsandnumbering.ui"] = 11;
- maKnownDialogs["modules/sdraw/ui/drawparadialog.ui"] = 12;
- maKnownDialogs["modules/simpress/ui/presentationdialog.ui"] = 13;
- maKnownDialogs["modules/simpress/ui/remotedialog.ui"] = 14;
- maKnownDialogs["modules/sdraw/ui/drawprtldialog.ui"] = 15;
- maKnownDialogs["modules/simpress/ui/slidedesigndialog.ui"] = 16;
- maKnownDialogs["modules/sdraw/ui/drawprtldialog.ui"] = 17;
- maKnownDialogs["modules/simpress/ui/interactiondialog.ui"] = 18;
- maKnownDialogs["modules/sdraw/ui/vectorize.ui"] = 19;
- maKnownDialogs["modules/simpress/ui/photoalbum.ui"] = 20;
- maKnownDialogs["modules/simpress/ui/masterlayoutdlg.ui"] = 21;
- maKnownDialogs["modules/simpress/ui/headerfooterdialog.ui"] = 22;
- }
}
+
SdAbstractDialogFactory* SdDialogsTest::getSdAbstractDialogFactory()
{
return mpFact;
@@ -257,6 +227,34 @@ const SfxItemSet& SdDialogsTest::getEmptyFillStyleSfxItemSet()
return *mpEmptyFillStyleSfxItemSet;
}
+void SdDialogsTest::registerKnownDialogsByID(mapType& rKnownDialogs)
+{
+ // fill map of known dilogs
+ rKnownDialogs["modules/simpress/ui/publishingdialog.ui"] = 0;
+ rKnownDialogs["modules/sdraw/ui/breakdialog.ui"] = 1;
+ rKnownDialogs["modules/sdraw/ui/copydlg.ui"] = 2;
+ rKnownDialogs["modules/simpress/ui/customslideshows.ui"] = 3;
+ rKnownDialogs["modules/sdraw/ui/drawchardialog.ui"] = 4;
+ rKnownDialogs["modules/sdraw/ui/drawpagedialog.ui"] = 5;
+ rKnownDialogs["modules/simpress/ui/dlgfield.ui"] = 6;
+ rKnownDialogs["modules/sdraw/ui/dlgsnap.ui"] = 7;
+ rKnownDialogs["modules/sdraw/ui/insertlayer.ui"] = 8;
+ rKnownDialogs["modules/sdraw/ui/insertslidesdialog.ui"] = 9;
+ rKnownDialogs["modules/sdraw/ui/crossfadedialog.ui"] = 10;
+ rKnownDialogs["modules/sdraw/ui/bulletsandnumbering.ui"] = 11;
+ rKnownDialogs["modules/sdraw/ui/drawparadialog.ui"] = 12;
+ rKnownDialogs["modules/simpress/ui/presentationdialog.ui"] = 13;
+ rKnownDialogs["modules/simpress/ui/remotedialog.ui"] = 14;
+ rKnownDialogs["modules/sdraw/ui/drawprtldialog.ui"] = 15;
+ rKnownDialogs["modules/simpress/ui/slidedesigndialog.ui"] = 16;
+ rKnownDialogs["modules/simpress/ui/templatedialog.ui"] = 17;
+ rKnownDialogs["modules/simpress/ui/interactiondialog.ui"] = 18;
+ rKnownDialogs["modules/sdraw/ui/vectorize.ui"] = 19;
+ rKnownDialogs["modules/simpress/ui/photoalbum.ui"] = 20;
+ rKnownDialogs["modules/simpress/ui/masterlayoutdlg.ui"] = 21;
+ rKnownDialogs["modules/simpress/ui/headerfooterdialog.ui"] = 22;
+}
+
VclAbstractDialog* SdDialogsTest::createDialogByID(sal_uInt32 nID)
{
VclAbstractDialog* pRetval = 0;
@@ -606,14 +604,48 @@ VclAbstractDialog* SdDialogsTest::createDialogByID(sal_uInt32 nID)
void SdDialogsTest::openAnyDialog()
{
- static bool bDumpAllKnownDialogs = true;
+ /// example how to process an input file containing the UXMLDescriptions of the dialogs
+ /// to dump
+ if (true)
+ {
+ test::Directories aDirectories;
+ OUString aURL = aDirectories.getURLFromSrc("sd/qa/unit/data/dialogs-test.txt");
+ SvFileStream aStream(aURL, StreamMode::READ);
+ OString aNextUIFile;
+ OString aComment("#");
+
+ while (aStream.ReadLine(aNextUIFile))
+ {
+ if (!aNextUIFile.isEmpty() && !aNextUIFile.startsWith(aComment))
+ {
+ // first check if it's a known dialog
+ std::unique_ptr<VclAbstractDialog> pDlg(createDialogByName(aNextUIFile));
+
+ if (pDlg)
+ {
+ // known dialog, dump screenshot to path
+ dumpDialogToPath(*pDlg);
+ }
+ else
+ {
+ // unknown dialog, try fallback to generic created
+ // VclBuilder-generated instance. Keep in mind that Dialogs
+ // using this mechanism will probably not be layouted well
+ // since the setup/initialization part is missing. Thus,
+ // only use for fallback when only the UI file is available.
+ dumpDialogToPath(aNextUIFile);
+ }
+ }
+ }
+ }
- if (bDumpAllKnownDialogs)
+ /// example how to dump all known dialogs
+ if (false)
{
// example for SfxTabDialog: 5 -> "modules/sdraw/ui/drawpagedialog.ui"
// example for TabDialog: 22 -> "modules/simpress/ui/headerfooterdialog.ui"
// example for self-adapted wizard: 0 -> "modules/simpress/ui/publishingdialog.ui"
- for (mapType::const_iterator i = maKnownDialogs.begin(); i != maKnownDialogs.end(); i++)
+ for (mapType::const_iterator i = getKnownDialogs().begin(); i != getKnownDialogs().end(); i++)
{
std::unique_ptr<VclAbstractDialog> pDlg(createDialogByID((*i).second));
@@ -631,9 +663,8 @@ void SdDialogsTest::openAnyDialog()
}
}
- static bool bCheckFallbackDialog = false;
-
- if (bCheckFallbackDialog)
+ /// example how to dump a dialog using fallback functionality
+ if (false)
{
// unknown dialog, try fallback to generic created
// VclBuilder-generated instance. Keep in mind that Dialogs
diff --git a/sd/source/ui/dlg/headerfooterdlg.cxx b/sd/source/ui/dlg/headerfooterdlg.cxx
index 84e5216..ccab84b 100644
--- a/sd/source/ui/dlg/headerfooterdlg.cxx
+++ b/sd/source/ui/dlg/headerfooterdlg.cxx
@@ -796,25 +796,28 @@ void PresLayoutPreview::Paint(vcl::RenderContext& rRenderContext, const Rectangl
rRenderContext.DrawRect(maOutRect);
// paint presentation objects from masterpage
- SdrTextObj* pMasterTitle = static_cast<SdrTextObj*>(mpMaster->GetPresObj( PRESOBJ_TITLE ));
- SdrTextObj* pMasterOutline = static_cast<SdrTextObj*>(mpMaster->GetPresObj( mpMaster->GetPageKind()==PK_NOTES ? PRESOBJ_NOTES : PRESOBJ_OUTLINE ));
- SdrTextObj* pHeader = static_cast<SdrTextObj*>(mpMaster->GetPresObj( PRESOBJ_HEADER ));
- SdrTextObj* pFooter = static_cast<SdrTextObj*>(mpMaster->GetPresObj( PRESOBJ_FOOTER ));
- SdrTextObj* pDate = static_cast<SdrTextObj*>(mpMaster->GetPresObj( PRESOBJ_DATETIME ));
- SdrTextObj* pNumber = static_cast<SdrTextObj*>(mpMaster->GetPresObj( PRESOBJ_SLIDENUMBER ));
-
- if (pMasterTitle)
- Paint(rRenderContext, pMasterTitle, true, true);
- if (pMasterOutline)
- Paint(rRenderContext, pMasterOutline, true, true);
- if (pHeader)
- Paint(rRenderContext, pHeader, maSettings.mbHeaderVisible);
- if (pFooter)
- Paint(rRenderContext, pFooter, maSettings.mbFooterVisible);
- if (pDate)
- Paint(rRenderContext, pDate, maSettings.mbDateTimeVisible);
- if (pNumber)
- Paint(rRenderContext, pNumber, maSettings.mbSlideNumberVisible);
+ if (nullptr != mpMaster)
+ {
+ SdrTextObj* pMasterTitle = static_cast<SdrTextObj*>(mpMaster->GetPresObj(PRESOBJ_TITLE));
+ SdrTextObj* pMasterOutline = static_cast<SdrTextObj*>(mpMaster->GetPresObj(mpMaster->GetPageKind() == PK_NOTES ? PRESOBJ_NOTES : PRESOBJ_OUTLINE));
+ SdrTextObj* pHeader = static_cast<SdrTextObj*>(mpMaster->GetPresObj(PRESOBJ_HEADER));
+ SdrTextObj* pFooter = static_cast<SdrTextObj*>(mpMaster->GetPresObj(PRESOBJ_FOOTER));
+ SdrTextObj* pDate = static_cast<SdrTextObj*>(mpMaster->GetPresObj(PRESOBJ_DATETIME));
+ SdrTextObj* pNumber = static_cast<SdrTextObj*>(mpMaster->GetPresObj(PRESOBJ_SLIDENUMBER));
+
+ if (pMasterTitle)
+ Paint(rRenderContext, pMasterTitle, true, true);
+ if (pMasterOutline)
+ Paint(rRenderContext, pMasterOutline, true, true);
+ if (pHeader)
+ Paint(rRenderContext, pHeader, maSettings.mbHeaderVisible);
+ if (pFooter)
+ Paint(rRenderContext, pFooter, maSettings.mbFooterVisible);
+ if (pDate)
+ Paint(rRenderContext, pDate, maSettings.mbDateTimeVisible);
+ if (pNumber)
+ Paint(rRenderContext, pNumber, maSettings.mbSlideNumberVisible);
+ }
rRenderContext.Pop();
}
diff --git a/test/source/screenshot_test.cxx b/test/source/screenshot_test.cxx
index e33cf21..92f48ee 100644
--- a/test/source/screenshot_test.cxx
+++ b/test/source/screenshot_test.cxx
@@ -1,4 +1,4 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+ /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
@@ -33,7 +33,12 @@ using namespace css;
using namespace css::uno;
ScreenshotTest::ScreenshotTest()
- : m_aScreenshotDirectory("/workdir/screenshots/")
+: m_aScreenshotDirectory("/workdir/screenshots/"),
+ maKnownDialogs()
+{
+}
+
+ScreenshotTest::~ScreenshotTest()
{
}
@@ -46,6 +51,12 @@ void ScreenshotTest::setUp()
osl::FileBase::RC err = osl::Directory::create( m_directories.getURLFromSrc( m_aScreenshotDirectory ) );
CPPUNIT_ASSERT_MESSAGE( "Failed to create screenshot directory", (err == osl::FileBase::E_None || err == osl::FileBase::E_EXIST) );
+
+ // initialize maKnownDialogs
+ if (maKnownDialogs.empty())
+ {
+ registerKnownDialogsByID(maKnownDialogs);
+ }
}
void ScreenshotTest::tearDown()
@@ -101,6 +112,19 @@ void ScreenshotTest::saveScreenshot(Dialog& rDialog)
}
}
+VclAbstractDialog* ScreenshotTest::createDialogByName(const OString& rName)
+{
+ VclAbstractDialog* pRetval = nullptr;
+ const mapType::const_iterator aHit = maKnownDialogs.find(rName);
+
+ if (aHit != maKnownDialogs.end())
+ {
+ return createDialogByID((*aHit).second);
+ }
+
+ return pRetval;
+}
+
void ScreenshotTest::dumpDialogToPath(VclAbstractDialog& rDialog)
{
const std::vector<OString> aPageDescriptions(rDialog.getAllPageUIXMLDescriptions());
More information about the Libreoffice-commits
mailing list