summaryrefslogtreecommitdiff
path: root/sc/qa/unit/screenshots
diff options
context:
space:
mode:
authorArmin Le Grand <Armin.Le.Grand@cib.de>2016-07-15 15:25:59 +0200
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2016-08-18 02:39:11 +0200
commitd098f0c957824bd5dec89a799398d587ce9fb96f (patch)
treeca0f4ebf78b2a1bf2d6a3ee5e5c278738fc3b4e2 /sc/qa/unit/screenshots
parent836a77e5d6fdad5b74d296d5b55a6b0c8f016ade (diff)
screenshots: Use UI string and fallback for UI-String only
Two changes in this commit: The Dialogs to be dumped are identified in their test files using their UXMLDescription to allow later to 'find' the known dialogs and use the specialized construction for these. Also added a fallback to construct a vcl Dialog based on only the UXMLDescription and the VclBuilder. This will be constructed without any active initialization/layouting, so should only be used for unknown Dialogs. Also added a dumpDialogToPath version to the tooling that can work directly with a vcl Dialog instead of a VclAbstractDialog. Change-Id: I90abb6f59c2fcc5d534907ae7e4b9a15edc2d694
Diffstat (limited to 'sc/qa/unit/screenshots')
-rw-r--r--sc/qa/unit/screenshots/screenshots.cxx90
1 files changed, 68 insertions, 22 deletions
diff --git a/sc/qa/unit/screenshots/screenshots.cxx b/sc/qa/unit/screenshots/screenshots.cxx
index 10213e52eb63..556db725314e 100644
--- a/sc/qa/unit/screenshots/screenshots.cxx
+++ b/sc/qa/unit/screenshots/screenshots.cxx
@@ -40,8 +40,10 @@
#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/";
@@ -72,9 +74,19 @@ private:
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()
{
}
@@ -97,7 +109,29 @@ void ScScreenshotTest::initializeWithDoc(const char* pName)
CPPUNIT_ASSERT_MESSAGE("Failed to create dialog factory", pFact);
const OUString aCsv("some, strings, here, separated, by, commas");
- pStream.reset( new ScImportStringStream( aCsv) );
+ pStream.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;
+ }
}
VclAbstractDialog* ScScreenshotTest::createDialogByID( sal_uInt32 nID )
@@ -108,7 +142,7 @@ VclAbstractDialog* ScScreenshotTest::createDialogByID( sal_uInt32 nID )
switch ( nID )
{
- case 0:
+ case 0: // "modules/scalc/ui/insertsheet.ui"
{
ScViewData& rViewData = pViewShell->GetViewData();
SCTAB nTabSelCount = rViewData.GetMarkData().GetSelectCount();
@@ -119,43 +153,42 @@ VclAbstractDialog* ScScreenshotTest::createDialogByID( sal_uInt32 nID )
break;
}
- case 1:
+ case 1: // "modules/scalc/ui/deletecells.ui"
{
pReturnDialog = pFact->CreateScDeleteCellDlg( pViewShell->GetDialogParent(), false );
break;
}
- case 2:
+ case 2: // "modules/scalc/ui/pastespecial.ui"
{
pReturnDialog = pFact->CreateScInsertContentsDlg( pViewShell->GetDialogParent() );
break;
}
- case 3:
+ case 3: // "modules/scalc/ui/changesourcedialog.ui"
{
pReturnDialog = pFact->CreateScColRowLabelDlg( pViewShell->GetDialogParent(), true, false );
break;
}
- case 4:
+ case 4: // "modules/scalc/ui/selectdatasource.ui"
{
pReturnDialog = pFact->CreateScDataPilotDatabaseDlg( pViewShell->GetDialogParent() );
break;
}
- case 5:
+ case 5: // "modules/scalc/ui/selectsource.ui"
{
-
pReturnDialog = pFact->CreateScDataPilotSourceTypeDlg(pViewShell->GetDialogParent(), true );
break;
}
- case 6:
+ case 6: // "modules/scalc/ui/deletecontents.ui"
{
pReturnDialog = pFact->CreateScDeleteContentsDlg( pViewShell->GetDialogParent() );
break;
}
- case 7:
+ case 7: // "modules/scalc/ui/createnamesdialog.ui"
{
//// just fake some flags
sal_uInt16 nFlags = NAME_LEFT | NAME_TOP;
@@ -163,7 +196,7 @@ VclAbstractDialog* ScScreenshotTest::createDialogByID( sal_uInt32 nID )
break;
}
- case 8:
+ case 8: // "modules/scalc/ui/inputstringdialog.ui"
{
const OString aEmpty("");
pReturnDialog = pFact->CreateScStringInputDlg( pViewShell->GetDialogParent(),
@@ -172,7 +205,7 @@ VclAbstractDialog* ScScreenshotTest::createDialogByID( sal_uInt32 nID )
break;
}
- case 9:
+ case 9: // "modules/scalc/ui/tabcolordialog.ui"
{
pReturnDialog = pFact->CreateScTabBgColorDlg( pViewShell->GetDialogParent(),
OUString(ScResId(SCSTR_SET_TAB_BG_COLOR)),
@@ -180,13 +213,13 @@ VclAbstractDialog* ScScreenshotTest::createDialogByID( sal_uInt32 nID )
break;
}
- case 10:
+ case 10: // "modules/scalc/ui/textimportoptions.ui"
{
pReturnDialog = pFact->CreateScTextImportOptionsDlg();
break;
}
- case 11:
+ case 11: // "modules/scalc/ui/dataform.ui"
{
////FIXME: looks butt-ugly w/ empty file, move it elsewhere, where
////we actually have some data
@@ -194,18 +227,18 @@ VclAbstractDialog* ScScreenshotTest::createDialogByID( sal_uInt32 nID )
break;
}
- case 12:
+ case 12: // "modules/scalc/ui/movecopysheet.ui"
{
pReturnDialog = pFact->CreateScMoveTableDlg( pViewShell->GetDialogParent(), aDefaultSheetName );
break;
}
- case 13:
+ case 13: // "modules/scalc/ui/textimportcsv.ui"
{
pReturnDialog = pFact->CreateScImportAsciiDlg( OUString(), pStream.get(), SC_PASTETEXT );
break;
}
- case 14:
+ case 14: // "modules/scalc/ui/formatcellsdialog.ui"
{
ScViewData& rViewData = pViewShell->GetViewData();
ScDocument *pDoc = rViewData.GetDocument();
@@ -239,13 +272,26 @@ void ScScreenshotTest::testOpeningModalDialogs()
{
initializeWithDoc("empty.ods");
- const sal_uInt32 nDialogs = 15;
+ static bool bDumpAllKnownDialogs = true;
- for ( sal_uInt32 i = 0; i < nDialogs; i++ )
+ if (bDumpAllKnownDialogs)
{
- std::unique_ptr<VclAbstractDialog> pDialog( createDialogByID( i ) );
-
- dumpDialogToPath( *pDialog );
+ for (mapType::const_iterator i = maKnownDialogs.begin(); i != maKnownDialogs.end(); i++)
+ {
+ std::unique_ptr<VclAbstractDialog> pDlg(createDialogByID((*i).second));
+
+ if (pDlg)
+ {
+ // known dialog, dump screenshot to path
+ dumpDialogToPath(*pDlg);
+ }
+ else
+ {
+ // unknown dialog, should not happen in this basic loop.
+ // You have probably forgotten to add a case and
+ // implementastion to createDialogByID, please do this
+ }
+ }
}
}