[Libreoffice-commits] core.git: Branch 'feature/dialog-screenshots' - 28 commits - include/sfx2 include/test include/vcl sc/CppunitTest_sc_screenshots.mk sc/inc sc/Module_sc.mk sc/qa sc/source sd/CppunitTest_sd_dialogs_test.mk sd/inc sd/Module_sd.mk sd/qa sd/source sfx2/source solenv/gbuild test/Library_test.mk test/source vcl/source
Katarina Behrens
Katarina.Behrens at cib.de
Wed Jul 20 00:46:42 UTC 2016
Rebased ref, commits from common ancestor:
commit 873ff9a2c02e80855366c82da8bebc74b4eb4b08
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date: Fri Jul 1 17:03:42 2016 +0200
screenshots: use new bootstrap fixture in sc and sd
Change-Id: Ida0d3179726896b32b0876b1855b1f0be12d3b48
diff --git a/sc/qa/unit/screenshots/screenshots.cxx b/sc/qa/unit/screenshots/screenshots.cxx
index d331ffa..10213e5 100644
--- a/sc/qa/unit/screenshots/screenshots.cxx
+++ b/sc/qa/unit/screenshots/screenshots.cxx
@@ -7,9 +7,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-#include <test/bootstrapfixture.hxx>
-#include <unotest/macros_test.hxx>
-#include <test/xmltesttools.hxx>
+#include <test/screenshot_test.hxx>
#include <com/sun/star/frame/Desktop.hpp>
#include <comphelper/dispatchcommand.hxx>
@@ -45,53 +43,26 @@
using namespace css;
-#if !defined(WNT) && !defined(MACOSX)
static const char* DATA_DIRECTORY = "/sc/qa/unit/screenshots/data/";
-static const char* SCREENSHOT_DIRECTORY = "/workdir/screenshots/";
-#endif
-namespace {
- void splitHelpId( OString& rHelpId, OUString& rDirname, OUString &rBasename )
- {
- sal_Int32 nIndex = rHelpId.lastIndexOf( '/' );
-
- if( nIndex > 0 )
- rDirname = OStringToOUString( rHelpId.copy( 0, nIndex ), RTL_TEXTENCODING_UTF8 );
-
- if( rHelpId.getLength() > nIndex+1 )
- rBasename= OStringToOUString( rHelpId.copy( nIndex+1 ), RTL_TEXTENCODING_UTF8 );
- }
-}
-
-
-class ScScreenshotTest : public test::BootstrapFixture, public unotest::MacrosTest, public XmlTestTools
+class ScScreenshotTest : public ScreenshotTest
{
public:
ScScreenshotTest();
- virtual void setUp() SAL_OVERRIDE;
- virtual void tearDown() SAL_OVERRIDE;
-#if !defined(WNT) && !defined(MACOSX)
void testOpeningModalDialogs();
//void testOpeningModelessDialogs();
-#endif
CPPUNIT_TEST_SUITE(ScScreenshotTest);
-#if !defined(WNT) && !defined(MACOSX)
CPPUNIT_TEST(testOpeningModalDialogs);
//CPPUNIT_TEST(testOpeningModelessDialogs);
-#endif
CPPUNIT_TEST_SUITE_END();
private:
-#if !defined(WNT) && !defined(MACOSX)
void initializeWithDoc(const char* pName);
VclAbstractDialog* createDialogByID( sal_uInt32 nID);
- void dumpDialogToPath( VclAbstractDialog& rDialog );
- void saveScreenshot( VclAbstractDialog& rDialog );
-#endif
uno::Reference<lang::XComponent> mxComponent;
SfxObjectShell* pFoundShell;
@@ -107,25 +78,6 @@ ScScreenshotTest::ScScreenshotTest()
{
}
-void ScScreenshotTest::setUp()
-{
- test::BootstrapFixture::setUp();
-
- mxDesktop.set(css::frame::Desktop::create(comphelper::getComponentContext(getMultiServiceFactory())));
-
- osl::FileBase::RC err = osl::Directory::create( m_directories.getURLFromSrc( SCREENSHOT_DIRECTORY ) );
- CPPUNIT_ASSERT_MESSAGE( "Failed to create screenshot directory", (err == osl::FileBase::E_None || err == osl::FileBase::E_EXIST) );
-}
-
-void ScScreenshotTest::tearDown()
-{
- if (mxComponent.is())
- mxComponent->dispose();
-
- test::BootstrapFixture::tearDown();
-}
-
-#if !defined(WNT) && !defined(MACOSX)
void ScScreenshotTest::initializeWithDoc(const char* pName)
{
if (mxComponent.is())
@@ -283,54 +235,6 @@ VclAbstractDialog* ScScreenshotTest::createDialogByID( sal_uInt32 nID )
return pReturnDialog;
}
-void ScScreenshotTest::saveScreenshot( VclAbstractDialog& rDialog )
-{
- const Bitmap aScreenshot(rDialog.createScreenshot());
-
- if (!aScreenshot.IsEmpty())
- {
- OString aScreenshotId = rDialog.GetScreenshotId();
- OUString aDirname, aBasename;
- splitHelpId( aScreenshotId, aDirname, aBasename );
- aDirname = OUString::createFromAscii( SCREENSHOT_DIRECTORY ) + aDirname;
-
- osl::FileBase::RC err = osl::Directory::createPath( m_directories.getURLFromSrc( aDirname ));
- CPPUNIT_ASSERT_MESSAGE( OUStringToOString( "Failed to create " + aDirname, RTL_TEXTENCODING_UTF8).getStr(),
- (err == osl::FileBase::E_None || err == osl::FileBase::E_EXIST) );
-
- OUString aFullPath = m_directories.getSrcRootPath() + aDirname + "/" + aBasename + ".png";
- SvFileStream aNew(aFullPath, StreamMode::WRITE | StreamMode::TRUNC);
- CPPUNIT_ASSERT_MESSAGE( OUStringToOString( "Failed to open " + OUString::number(aNew.GetErrorCode()), RTL_TEXTENCODING_UTF8).getStr(), aNew.IsOpen() );
-
- vcl::PNGWriter aPNGWriter(aScreenshot);
- aPNGWriter.Write(aNew);
- }
-}
-
-void ScScreenshotTest::dumpDialogToPath( VclAbstractDialog& rDialog )
-{
- const std::vector<OString> aPageDescriptions(rDialog.getAllPageUIXMLDescriptions());
-
- if (aPageDescriptions.size())
- {
- for (sal_uInt32 a(0); a < aPageDescriptions.size(); a++)
- {
- if (rDialog.selectPageByUIXMLDescription(aPageDescriptions[a]))
- {
- saveScreenshot( rDialog );
- }
- else
- {
- CPPUNIT_ASSERT(false);
- }
- }
- }
- else
- {
- saveScreenshot( rDialog );
- }
-}
-
void ScScreenshotTest::testOpeningModalDialogs()
{
initializeWithDoc("empty.ods");
@@ -345,8 +249,6 @@ void ScScreenshotTest::testOpeningModalDialogs()
}
}
-#endif
-
CPPUNIT_TEST_SUITE_REGISTRATION(ScScreenshotTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sc/source/ui/inc/viewfunc.hxx b/sc/source/ui/inc/viewfunc.hxx
index 0b74142..c58ccd2 100644
--- a/sc/source/ui/inc/viewfunc.hxx
+++ b/sc/source/ui/inc/viewfunc.hxx
@@ -70,7 +70,7 @@ public:
ScViewFunc( vcl::Window* pParent, ScDocShell& rDocSh, ScTabViewShell* pViewShell );
~ScViewFunc();
- const ScPatternAttr* GetSelectionPattern ();
+ SC_DLLPUBLIC const ScPatternAttr* GetSelectionPattern ();
void GetSelectionFrame ( SvxBoxItem& rLineOuter,
SvxBoxInfoItem& rLineInner );
diff --git a/sd/qa/unit/dialogs-test.cxx b/sd/qa/unit/dialogs-test.cxx
index f3e51d2..02dfa20 100644
--- a/sd/qa/unit/dialogs-test.cxx
+++ b/sd/qa/unit/dialogs-test.cxx
@@ -8,7 +8,7 @@
*/
#include <sal/config.h>
-#include <test/bootstrapfixture.hxx>
+#include <test/screenshot_test.hxx>
#include <rtl/strbuf.hxx>
#include <osl/file.hxx>
#include <com/sun/star/lang/XComponent.hpp>
@@ -55,32 +55,13 @@
#include <comphelper/processfactory.hxx>
#include <unotest/macros_test.hxx>
-//#include "DrawController.hxx"
-//#include "ViewShellBase.hxx"
-
using namespace ::com::sun::star;
-static const char* SCREENSHOT_DIRECTORY = "/workdir/screenshots/";
-
-namespace {
- void splitHelpId( OString& rHelpId, OUString& rDirname, OUString &rBasename )
- {
- sal_Int32 nIndex = rHelpId.lastIndexOf( '/' );
-
- if( nIndex > 0 )
- rDirname = OStringToOUString( rHelpId.copy( 0, nIndex ), RTL_TEXTENCODING_UTF8 );
-
- if( rHelpId.getLength() > nIndex+1 )
- rBasename= OStringToOUString( rHelpId.copy( nIndex+1 ), RTL_TEXTENCODING_UTF8 );
- }
-}
-
/// Test opening a dialog in sd
-class SdDialogsTest : public test::BootstrapFixture, public unotest::MacrosTest
+class SdDialogsTest : public ScreenshotTest
{
private:
/// Document and ComponentContext
- uno::Reference<uno::XComponentContext> mxComponentContext;
uno::Reference<lang::XComponent> mxComponent;
/// initially created SdAbstractDialogFactory and pointer to document
@@ -106,17 +87,14 @@ private:
const SfxItemSet& getEmptySfxItemSet();
const SfxItemSet& getEmptyFillStyleSfxItemSet();
- /// central methods: dialog creation and dumping to target directory (path)
+ /// central method: dialog creation and dumping to target directory (path)
VclAbstractDialog* createDialogByID(sal_uInt32 nID);
- void dumpDialogToPath(VclAbstractDialog& rDlg);
- void saveScreenshot( VclAbstractDialog& rDlg);
public:
SdDialogsTest();
~SdDialogsTest();
virtual void setUp() override;
- virtual void tearDown() override;
// try to open a dialog
void openAnyDialog();
@@ -127,8 +105,7 @@ public:
};
SdDialogsTest::SdDialogsTest()
-: mxComponentContext(),
- mxComponent(),
+: mxComponent(),
mpFact(nullptr),
mpImpressDocument(nullptr),
mpDocShell(nullptr),
@@ -146,31 +123,16 @@ SdDialogsTest::~SdDialogsTest()
void SdDialogsTest::setUp()
{
- test::BootstrapFixture::setUp();
+ ScreenshotTest::setUp();
- mxComponentContext.set(comphelper::getComponentContext(getMultiServiceFactory()));
- mxDesktop.set(frame::Desktop::create(mxComponentContext));
mpFact = SdAbstractDialogFactory::Create();
mxComponent = loadFromDesktop("private:factory/simpress", "com.sun.star.presentation.PresentationDocument");
CPPUNIT_ASSERT(mxComponent.is());
- osl::FileBase::RC err = osl::Directory::create( m_directories.getURLFromSrc( SCREENSHOT_DIRECTORY ) );
- CPPUNIT_ASSERT_MESSAGE( "Failed to create screenshot directory", (err == osl::FileBase::E_None || err == osl::FileBase::E_EXIST) );
-
mpImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get());
CPPUNIT_ASSERT(mpImpressDocument);
}
-void SdDialogsTest::tearDown()
-{
- //if (mxComponent.is())
- //{
- // mxComponent->dispose();
- //}
-
- test::BootstrapFixture::tearDown();
-}
-
SdAbstractDialogFactory* SdDialogsTest::getSdAbstractDialogFactory()
{
return mpFact;
@@ -611,58 +573,6 @@ VclAbstractDialog* SdDialogsTest::createDialogByID(sal_uInt32 nID)
return pRetval;
}
-void SdDialogsTest::saveScreenshot(VclAbstractDialog& rDlg)
-{
- const Bitmap aScreenshot(rDlg.createScreenshot());
-
- if (!aScreenshot.IsEmpty())
- {
- OString aScreenshotId = rDlg.GetScreenshotId();
- OUString aDirname, aBasename;
- splitHelpId( aScreenshotId, aDirname, aBasename );
- aDirname = OUString::createFromAscii( SCREENSHOT_DIRECTORY ) + aDirname;
-
- osl::FileBase::RC err = osl::Directory::createPath( m_directories.getURLFromSrc( aDirname ));
- CPPUNIT_ASSERT_MESSAGE( OUStringToOString( "Failed to create " + aDirname, RTL_TEXTENCODING_UTF8).getStr(),
- (err == osl::FileBase::E_None || err == osl::FileBase::E_EXIST) );
-
- OUString aFullPath = m_directories.getSrcRootPath() + aDirname + "/" + aBasename + ".png";
- SvFileStream aNew(aFullPath, StreamMode::WRITE | StreamMode::TRUNC);
- CPPUNIT_ASSERT_MESSAGE( OUStringToOString( "Failed to open " + OUString::number(aNew.GetErrorCode()), RTL_TEXTENCODING_UTF8).getStr(), aNew.IsOpen() );
-
- vcl::PNGWriter aPNGWriter(aScreenshot);
- aPNGWriter.Write(aNew);
- }
-}
-
-void SdDialogsTest::dumpDialogToPath(VclAbstractDialog& rDlg)
-{
-
- // for dumping, a lossless format is needed. It may be seen if the created data
- // will be further modified/reduced, but for a input creating step it is
- // unavoidable to use a lossless format initially
- const std::vector<OString> aPageDescriptions(rDlg.getAllPageUIXMLDescriptions());
-
- if (aPageDescriptions.size())
- {
- for (sal_uInt32 a(0); a < aPageDescriptions.size(); a++)
- {
- if (rDlg.selectPageByUIXMLDescription(aPageDescriptions[a]))
- {
- saveScreenshot( rDlg );
- }
- else
- {
- CPPUNIT_ASSERT(false);
- }
- }
- }
- else
- {
- saveScreenshot( rDlg );
- }
-}
-
void SdDialogsTest::openAnyDialog()
{
// example for SfxTabDialog: 5
diff --git a/vcl/source/window/tabdlg.cxx b/vcl/source/window/tabdlg.cxx
index 868eb3f..5706e64 100644
--- a/vcl/source/window/tabdlg.cxx
+++ b/vcl/source/window/tabdlg.cxx
@@ -268,6 +268,8 @@ vcl::Window* findTabControl(vcl::Window* pCurrent)
pChild = pChild->GetWindow(GetWindowType::Next);
}
+
+ return nullptr;
}
std::vector<OString> TabDialog::getAllPageUIXMLDescriptions() const
commit e9ce1af9008bf3ab237f19629cbd48b0130bb63f
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date: Thu Jun 30 22:39:28 2016 +0200
screenshots: move shared code to separate class
Change-Id: I1760de221bc53d345c2bbfb4fe878c120073ea45
diff --git a/include/test/screenshot_test.hxx b/include/test/screenshot_test.hxx
new file mode 100644
index 0000000..f07c29a
--- /dev/null
+++ b/include/test/screenshot_test.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/.
+ */
+
+#ifndef INCLUDED_TEST_SCREENSHOT_TEST_HXX
+#define INCLUDED_TEST_SCREENSHOT_TEST_HXX
+
+#include <sal/config.h>
+#include <test/bootstrapfixture.hxx>
+#include <unotest/macros_test.hxx>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <osl/file.hxx>
+
+class VclAbstractDialog;
+
+
+class OOO_DLLPUBLIC_TEST ScreenshotTest : public test::BootstrapFixture, public unotest::MacrosTest
+{
+public:
+ ScreenshotTest();
+
+ virtual void setUp() override;
+ virtual void tearDown() override;
+
+ void dumpDialogToPath( VclAbstractDialog& rDialog );
+
+private:
+ void saveScreenshot( VclAbstractDialog& rDialog );
+ OUString m_aScreenshotDirectory;
+};
+
+#endif // INCLUDED_TEST_SCREENSHOT_TEST_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/Library_test.mk b/test/Library_test.mk
index df7bfd2..2e34b21 100644
--- a/test/Library_test.mk
+++ b/test/Library_test.mk
@@ -47,6 +47,7 @@ $(eval $(call gb_Library_add_exception_objects,test,\
test/source/mtfxmldump \
test/source/xmlwriter \
test/source/primitive2dxmldump \
+ test/source/screenshot_test \
))
# vim: set noet sw=4 ts=4:
diff --git a/test/source/screenshot_test.cxx b/test/source/screenshot_test.cxx
new file mode 100644
index 0000000..d02e738
--- /dev/null
+++ b/test/source/screenshot_test.cxx
@@ -0,0 +1,102 @@
+/* -*- 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 "test/screenshot_test.hxx"
+
+#include <com/sun/star/util/XCloseable.hpp>
+#include <com/sun/star/frame/Desktop.hpp>
+#include <comphelper/processfactory.hxx>
+#include <vcl/abstdlg.hxx>
+#include <vcl/pngwrite.hxx>
+
+namespace {
+ void splitHelpId( OString& rHelpId, OUString& rDirname, OUString &rBasename )
+ {
+ sal_Int32 nIndex = rHelpId.lastIndexOf( '/' );
+
+ if( nIndex > 0 )
+ rDirname = OStringToOUString( rHelpId.copy( 0, nIndex ), RTL_TEXTENCODING_UTF8 );
+
+ if( rHelpId.getLength() > nIndex+1 )
+ rBasename= OStringToOUString( rHelpId.copy( nIndex+1 ), RTL_TEXTENCODING_UTF8 );
+ }
+}
+
+using namespace css;
+using namespace css::uno;
+
+ScreenshotTest::ScreenshotTest()
+ : m_aScreenshotDirectory("/workdir/screenshots/")
+{
+}
+
+void ScreenshotTest::setUp()
+{
+ test::BootstrapFixture::setUp();
+
+ mxDesktop = css::frame::Desktop::create( comphelper::getComponentContext(getMultiServiceFactory()) );
+ CPPUNIT_ASSERT_MESSAGE("no desktop!", mxDesktop.is());
+
+ 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) );
+}
+
+void ScreenshotTest::tearDown()
+{
+ test::BootstrapFixture::tearDown();
+}
+
+void ScreenshotTest::saveScreenshot( VclAbstractDialog& rDialog )
+{
+ const Bitmap aScreenshot(rDialog.createScreenshot());
+
+ if (!aScreenshot.IsEmpty())
+ {
+ OString aScreenshotId = rDialog.GetScreenshotId();
+ OUString aDirname, aBasename;
+ splitHelpId( aScreenshotId, aDirname, aBasename );
+ aDirname = m_aScreenshotDirectory + aDirname;
+
+ osl::FileBase::RC err = osl::Directory::createPath( m_directories.getURLFromSrc( aDirname ));
+ CPPUNIT_ASSERT_MESSAGE( OUStringToOString( "Failed to create " + aDirname, RTL_TEXTENCODING_UTF8).getStr(),
+ (err == osl::FileBase::E_None || err == osl::FileBase::E_EXIST) );
+
+ OUString aFullPath = m_directories.getSrcRootPath() + aDirname + "/" + aBasename + ".png";
+ SvFileStream aNew(aFullPath, StreamMode::WRITE | StreamMode::TRUNC);
+ CPPUNIT_ASSERT_MESSAGE( OUStringToOString( "Failed to open " + OUString::number(aNew.GetErrorCode()), RTL_TEXTENCODING_UTF8).getStr(), aNew.IsOpen() );
+
+ vcl::PNGWriter aPNGWriter(aScreenshot);
+ aPNGWriter.Write(aNew);
+ }
+}
+
+void ScreenshotTest::dumpDialogToPath( VclAbstractDialog& rDialog )
+{
+ const std::vector<OString> aPageDescriptions(rDialog.getAllPageUIXMLDescriptions());
+
+ if (aPageDescriptions.size())
+ {
+ for (sal_uInt32 a(0); a < aPageDescriptions.size(); a++)
+ {
+ if (rDialog.selectPageByUIXMLDescription(aPageDescriptions[a]))
+ {
+ saveScreenshot( rDialog );
+ }
+ else
+ {
+ CPPUNIT_ASSERT(false);
+ }
+ }
+ }
+ else
+ {
+ saveScreenshot( rDialog );
+ }
+}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 2e47833b5fdbe8bb9f9d5e068e038d19e831bf9d
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date: Thu Jun 30 01:11:05 2016 +0200
screenshots: this is really unused
Change-Id: Iaaf171f7b91476be0f2d668402e6f309b81d53c3
diff --git a/sd/qa/unit/dialogs-test.cxx b/sd/qa/unit/dialogs-test.cxx
index d86e7bc..f3e51d2 100644
--- a/sd/qa/unit/dialogs-test.cxx
+++ b/sd/qa/unit/dialogs-test.cxx
@@ -665,8 +665,6 @@ void SdDialogsTest::dumpDialogToPath(VclAbstractDialog& rDlg)
void SdDialogsTest::openAnyDialog()
{
- const OUString aTempTargetPath = m_directories.getPathFromSrc( SCREENSHOT_DIRECTORY );
-
// example for SfxTabDialog: 5
// example for TabDialog: 23
// example for self-adapted wizard: 0
commit fccf39cf222d68db3feb5bafd86b4653df052956
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date: Thu Jun 30 01:08:06 2016 +0200
screenshots: use smart pointers
Change-Id: I7b3780aecc7807e5905865f8d7eca816993ab148
diff --git a/sd/qa/unit/dialogs-test.cxx b/sd/qa/unit/dialogs-test.cxx
index 0578fac..d86e7bc 100644
--- a/sd/qa/unit/dialogs-test.cxx
+++ b/sd/qa/unit/dialogs-test.cxx
@@ -91,9 +91,10 @@ private:
::sd::DrawDocShell* mpDocShell;
::sd::ViewShell* mpViewShell;
::sd::DrawView* mpDrawView;
- const SfxItemSet* mpSfxItemSetFromSdrObject;
- const SfxItemSet* mpEmptySfxItemSet;
- SfxItemSet* mpEmptyFillStyleSfxItemSet;
+
+ std::unique_ptr<SfxItemSet> mpSfxItemSetFromSdrObject;
+ std::unique_ptr<SfxItemSet> mpEmptySfxItemSet;
+ std::unique_ptr<SfxItemSet> mpEmptyFillStyleSfxItemSet;
/// helpers
SdAbstractDialogFactory* getSdAbstractDialogFactory();
@@ -162,20 +163,10 @@ void SdDialogsTest::setUp()
void SdDialogsTest::tearDown()
{
- if (mpEmptySfxItemSet)
- {
- delete mpEmptySfxItemSet;
- }
-
- if (mpEmptyFillStyleSfxItemSet)
- {
- delete mpEmptyFillStyleSfxItemSet;
- }
-
- if (mxComponent.is())
- {
- mxComponent->dispose();
- }
+ //if (mxComponent.is())
+ //{
+ // mxComponent->dispose();
+ //}
test::BootstrapFixture::tearDown();
}
@@ -233,7 +224,7 @@ const SfxItemSet& SdDialogsTest::getSfxItemSetFromSdrObject()
CPPUNIT_ASSERT(pSdPage);
SdrObject* pSdrObj = pSdPage->GetObj(0);
CPPUNIT_ASSERT(pSdrObj);
- mpSfxItemSetFromSdrObject = &pSdrObj->GetMergedItemSet();
+ mpSfxItemSetFromSdrObject.reset( new SfxItemSet( pSdrObj->GetMergedItemSet() ) );
CPPUNIT_ASSERT(mpSfxItemSetFromSdrObject);
}
@@ -247,7 +238,7 @@ const SfxItemSet& SdDialogsTest::getEmptySfxItemSet()
// needs an SfxItemSet, use the one from the 1st object
SdDrawDocument* pDrawDoc = getSdXImpressDocument()->GetDoc();
CPPUNIT_ASSERT(pDrawDoc);
- mpEmptySfxItemSet = new SfxItemSet(pDrawDoc->GetItemPool());
+ mpEmptySfxItemSet.reset( new SfxItemSet(pDrawDoc->GetItemPool()) );
CPPUNIT_ASSERT(mpEmptySfxItemSet);
}
@@ -260,7 +251,7 @@ const SfxItemSet& SdDialogsTest::getEmptyFillStyleSfxItemSet()
{
SdDrawDocument* pDrawDoc = getSdXImpressDocument()->GetDoc();
CPPUNIT_ASSERT(pDrawDoc);
- mpEmptyFillStyleSfxItemSet = new SfxItemSet(pDrawDoc->GetItemPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST);
+ mpEmptyFillStyleSfxItemSet.reset( new SfxItemSet(pDrawDoc->GetItemPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST) );
CPPUNIT_ASSERT(mpEmptyFillStyleSfxItemSet);
mpEmptyFillStyleSfxItemSet->Put(XFillStyleItem(drawing::FillStyle_NONE));
}
@@ -685,12 +676,11 @@ void SdDialogsTest::openAnyDialog()
// loop and dump all Dialogs from SD for now
for (sal_uInt32 a(nStartValue); a < nEndValue; a++)
{
- VclAbstractDialog* pDlg = createDialogByID(a);
+ std::unique_ptr<VclAbstractDialog> pDlg( createDialogByID(a) );
if (pDlg)
{
dumpDialogToPath(*pDlg);
- delete pDlg;
}
}
commit 336ca842e77de6e84214f69d6772b17195dc551d
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date: Wed Jun 29 17:48:42 2016 +0200
screenshots: gen screenshots during 'make slowcheck'
Change-Id: I666dfcb451367f5ac9f36207703cf090c1846b35
diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk
index 9c331bb..ebf8821 100644
--- a/sc/Module_sc.mk
+++ b/sc/Module_sc.mk
@@ -64,6 +64,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sc, \
CppunitTest_sc_opencl_test \
CppunitTest_sc_copypaste \
CppunitTest_sc_functions_test \
+ CppunitTest_sc_screenshots \
))
# Disabled to allow the check tinderbox execute the sd tests
diff --git a/sd/Module_sd.mk b/sd/Module_sd.mk
index a6b4f9d..1171eb8 100644
--- a/sd/Module_sd.mk
+++ b/sd/Module_sd.mk
@@ -46,6 +46,10 @@ $(eval $(call gb_Module_add_check_targets,sd,\
))
endif
+$(eval $(call gb_Module_add_slowcheck_targets,sd, \
+ CppunitTest_sd_dialogs_test \
+))
+
$(eval $(call gb_Module_add_subsequentcheck_targets,sd,\
JunitTest_sd_unoapi \
))
commit 4938f3214a3979ae5b5df4cdac3691955fff4880
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date: Wed Jun 29 14:40:23 2016 +0200
screenshots: don't leak windows
Change-Id: If39441d6419556d1ae7637626b17b81357d29c38
diff --git a/sc/qa/unit/screenshots/screenshots.cxx b/sc/qa/unit/screenshots/screenshots.cxx
index 46a5af2..d331ffa 100644
--- a/sc/qa/unit/screenshots/screenshots.cxx
+++ b/sc/qa/unit/screenshots/screenshots.cxx
@@ -339,7 +339,7 @@ void ScScreenshotTest::testOpeningModalDialogs()
for ( sal_uInt32 i = 0; i < nDialogs; i++ )
{
- VclAbstractDialog *pDialog = createDialogByID( i );
+ std::unique_ptr<VclAbstractDialog> pDialog( createDialogByID( i ) );
dumpDialogToPath( *pDialog );
}
commit 43010d1bca8b825bcef76f6ca874a1af4dd05ec9
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date: Wed Jun 29 12:49:58 2016 +0200
screenshots: support creating shots of tab dialogs
try that with ScAttrDlg first
Change-Id: Id84f5940ca3de9788446f2e513fa3991f31a2d5a
diff --git a/sc/qa/unit/screenshots/screenshots.cxx b/sc/qa/unit/screenshots/screenshots.cxx
index 68d2814..46a5af2 100644
--- a/sc/qa/unit/screenshots/screenshots.cxx
+++ b/sc/qa/unit/screenshots/screenshots.cxx
@@ -24,6 +24,7 @@
#include <sfx2/dispatch.hxx>
#include <sfx2/viewfrm.hxx>
#include <svl/srchitem.hxx>
+#include <svx/numinf.hxx>
#include <vcl/pngwrite.hxx>
#include <tabvwsh.hxx>
@@ -36,6 +37,7 @@
#include <reffact.hxx>
#include <scui_def.hxx>
#include <impex.hxx>
+#include <patattr.hxx>
#include <sc.hrc>
#include <scresid.hxx>
@@ -98,6 +100,7 @@ private:
ScAbstractDialogFactory* pFact;
std::unique_ptr<ScImportStringStream> pStream;
+ std::unique_ptr<SfxItemSet> pItemSet;
};
ScScreenshotTest::ScScreenshotTest()
@@ -250,6 +253,26 @@ VclAbstractDialog* ScScreenshotTest::createDialogByID( sal_uInt32 nID )
pReturnDialog = pFact->CreateScImportAsciiDlg( OUString(), pStream.get(), SC_PASTETEXT );
break;
}
+ case 14:
+ {
+ ScViewData& rViewData = pViewShell->GetViewData();
+ ScDocument *pDoc = rViewData.GetDocument();
+
+ const ScPatternAttr *pAttr = pViewShell->GetSelectionPattern();
+ std::unique_ptr<SvxNumberInfoItem> pNumberInfoItem;
+
+ pItemSet.reset( new SfxItemSet( pAttr->GetItemSet() ) );
+ pItemSet->Put( SfxUInt32Item( ATTR_VALUE_FORMAT,
+ pAttr->GetNumberFormat( pDoc->GetFormatTable() ) ) );
+
+ pNumberInfoItem.reset( pViewShell->MakeNumberInfoItem(pDoc, &rViewData) );
+
+ pItemSet->MergeRange( SID_ATTR_NUMBERFORMAT_INFO, SID_ATTR_NUMBERFORMAT_INFO );
+ pItemSet->Put(*pNumberInfoItem );
+
+ pReturnDialog = pFact->CreateScAttrDlg( pViewShell->GetDialogParent(), pItemSet.get() );
+ break;
+ }
//ScopedVclPtrInstance<ScShareDocumentDlg> pDlg14( pViewShell->GetDialogParent(), &rViewData );
//ScopedVclPtrInstance<ScTableProtectionDlg> pDlg16(pViewShell->GetDialogParent());
default:
@@ -286,14 +309,33 @@ void ScScreenshotTest::saveScreenshot( VclAbstractDialog& rDialog )
void ScScreenshotTest::dumpDialogToPath( VclAbstractDialog& rDialog )
{
- saveScreenshot( rDialog );
+ const std::vector<OString> aPageDescriptions(rDialog.getAllPageUIXMLDescriptions());
+
+ if (aPageDescriptions.size())
+ {
+ for (sal_uInt32 a(0); a < aPageDescriptions.size(); a++)
+ {
+ if (rDialog.selectPageByUIXMLDescription(aPageDescriptions[a]))
+ {
+ saveScreenshot( rDialog );
+ }
+ else
+ {
+ CPPUNIT_ASSERT(false);
+ }
+ }
+ }
+ else
+ {
+ saveScreenshot( rDialog );
+ }
}
void ScScreenshotTest::testOpeningModalDialogs()
{
initializeWithDoc("empty.ods");
- const sal_uInt32 nDialogs = 14;
+ const sal_uInt32 nDialogs = 15;
for ( sal_uInt32 i = 0; i < nDialogs; i++ )
{
commit 4f110753b8ca2d42c4fcebda6fca242fc19edb02
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date: Wed Jun 29 12:46:48 2016 +0200
screenshots: sc dialog factory ifc for tab dialogs
Change-Id: Ia1f67a161cfadbf2b71d3647c50e1c0a4b24ae8d
diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx
index 159eafc..19cc0f3 100644
--- a/sc/source/ui/attrdlg/scdlgfact.hxx
+++ b/sc/source/ui/attrdlg/scdlgfact.hxx
@@ -65,6 +65,8 @@ public: \
{} \
virtual ~Class(); \
virtual short Execute() override ; \
+ std::vector<OString> getAllPageUIXMLDescriptions() const; \
+ bool selectPageByUIXMLDescription(const OString& rUIXMLDescription) override; \
virtual Bitmap createScreenshot() const override; \
virtual OString GetScreenshotId() const; \
@@ -86,6 +88,14 @@ short Class::Execute() \
{ \
return pDlg->Execute(); \
} \
+std::vector<OString> Class::getAllPageUIXMLDescriptions() const \
+{ \
+ return pDlg->getAllPageUIXMLDescriptions(); \
+} \
+bool Class::selectPageByUIXMLDescription(const OString& rUIXMLDescription) \
+{ \
+ return pDlg->selectPageByUIXMLDescription(rUIXMLDescription); \
+} \
Bitmap Class::createScreenshot() const \
{ \
return pDlg->createScreenshot(); \
commit 098b9c35e2c7f960959b6a2c44636f4aa07138a0
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date: Tue Jun 28 22:29:52 2016 +0200
screenshots: don't crash on opening csv import dlg
Change-Id: I1ff56d79f7ff31317187cf077380481f1ef44366
diff --git a/sc/qa/unit/screenshots/screenshots.cxx b/sc/qa/unit/screenshots/screenshots.cxx
index ee12727..68d2814 100644
--- a/sc/qa/unit/screenshots/screenshots.cxx
+++ b/sc/qa/unit/screenshots/screenshots.cxx
@@ -96,6 +96,8 @@ private:
ScDocShellRef xDocSh;
ScTabViewShell* pViewShell;
ScAbstractDialogFactory* pFact;
+
+ std::unique_ptr<ScImportStringStream> pStream;
};
ScScreenshotTest::ScScreenshotTest()
@@ -138,6 +140,9 @@ void ScScreenshotTest::initializeWithDoc(const char* pName)
pFact = ScAbstractDialogFactory::Create();
CPPUNIT_ASSERT_MESSAGE("Failed to create dialog factory", pFact);
+
+ const OUString aCsv("some, strings, here, separated, by, commas");
+ pStream.reset( new ScImportStringStream( aCsv) );
}
VclAbstractDialog* ScScreenshotTest::createDialogByID( sal_uInt32 nID )
@@ -240,13 +245,11 @@ VclAbstractDialog* ScScreenshotTest::createDialogByID( sal_uInt32 nID )
break;
}
- //case 12:
- //{
- // const OUString aCsv("some, strings, here, separated, by, commas");
- // ScImportStringStream aStream( aCsv );
- // pReturnDialog = pFact->CreateScImportAsciiDlg( OUString(), &aStream, SC_PASTETEXT );
- // break;
- //}
+ case 13:
+ {
+ pReturnDialog = pFact->CreateScImportAsciiDlg( OUString(), pStream.get(), SC_PASTETEXT );
+ break;
+ }
//ScopedVclPtrInstance<ScShareDocumentDlg> pDlg14( pViewShell->GetDialogParent(), &rViewData );
//ScopedVclPtrInstance<ScTableProtectionDlg> pDlg16(pViewShell->GetDialogParent());
default:
@@ -290,7 +293,7 @@ void ScScreenshotTest::testOpeningModalDialogs()
{
initializeWithDoc("empty.ods");
- const sal_uInt32 nDialogs = 13;
+ const sal_uInt32 nDialogs = 14;
for ( sal_uInt32 i = 0; i < nDialogs; i++ )
{
commit 204f9e3bd2c99847c5f460f1ddd942172c9a0eaf
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date: Tue Jun 28 22:03:02 2016 +0200
screenshots: dialog doesn't even have a help button
So drop helpID argument from its ctor (not to mention the fact that a
help text with ID .uno:TabBgColor doesn't exist either)
Change-Id: I0624f0474334cc799d67f7f292e11194de5195fa
diff --git a/sc/inc/scabstdlg.hxx b/sc/inc/scabstdlg.hxx
index 8c6c6c5..a7130ce 100644
--- a/sc/inc/scabstdlg.hxx
+++ b/sc/inc/scabstdlg.hxx
@@ -447,8 +447,7 @@ public:
virtual AbstractScTabBgColorDlg * CreateScTabBgColorDlg ( vcl::Window* pParent,
const OUString& rTitle, //Dialog Title
const OUString& rTabBgColorNoColorText, //Label for no tab color
- const Color& rDefaultColor, //Currently selected Color
- const OString& ) = 0;
+ const Color& rDefaultColor ) = 0; //Currently selected Color
virtual AbstractScImportOptionsDlg * CreateScImportOptionsDlg ( bool bAscii = true,
const ScImportOptions* pOptions = nullptr,
diff --git a/sc/qa/unit/screenshots/screenshots.cxx b/sc/qa/unit/screenshots/screenshots.cxx
index b17afc9..ee12727 100644
--- a/sc/qa/unit/screenshots/screenshots.cxx
+++ b/sc/qa/unit/screenshots/screenshots.cxx
@@ -216,7 +216,7 @@ VclAbstractDialog* ScScreenshotTest::createDialogByID( sal_uInt32 nID )
{
pReturnDialog = pFact->CreateScTabBgColorDlg( pViewShell->GetDialogParent(),
OUString(ScResId(SCSTR_SET_TAB_BG_COLOR)),
- OUString(ScResId(SCSTR_NO_TAB_BG_COLOR)), Color(0xff00ff), ".uno:TabBgColor" );
+ OUString(ScResId(SCSTR_NO_TAB_BG_COLOR)), Color(0xff00ff) );
break;
}
diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx
index af6b1cd..9e2e3bd 100644
--- a/sc/source/ui/attrdlg/scdlgfact.cxx
+++ b/sc/source/ui/attrdlg/scdlgfact.cxx
@@ -878,10 +878,9 @@ AbstractScTabBgColorDlg * ScAbstractDialogFactory_Impl::CreateScTabBgColorDlg(
vcl::Window* pParent,
const OUString& rTitle,
const OUString& rTabBgColorNoColorText,
- const Color& rDefaultColor,
- const OString& sHelpId)
+ const Color& rDefaultColor)
{
- VclPtr<ScTabBgColorDlg> pDlg = VclPtr<ScTabBgColorDlg>::Create( pParent, rTitle, rTabBgColorNoColorText, rDefaultColor, sHelpId );
+ VclPtr<ScTabBgColorDlg> pDlg = VclPtr<ScTabBgColorDlg>::Create( pParent, rTitle, rTabBgColorNoColorText, rDefaultColor );
return new AbstractScTabBgColorDlg_Impl( pDlg );
}
diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx
index a7a6460..159eafc 100644
--- a/sc/source/ui/attrdlg/scdlgfact.hxx
+++ b/sc/source/ui/attrdlg/scdlgfact.hxx
@@ -519,8 +519,7 @@ public:
virtual AbstractScTabBgColorDlg * CreateScTabBgColorDlg ( vcl::Window* pParent,
const OUString& rTitle, //Dialog Title
const OUString& rTabBgColorNoColorText, //Label for no tab color
- const Color& rDefaultColor, //Currently selected Color
- const OString& sHelpId ) override;
+ const Color& rDefaultColor ) override; //Currently selected Color
virtual AbstractScImportOptionsDlg * CreateScImportOptionsDlg ( bool bAscii = true,
const ScImportOptions* pOptions = nullptr,
diff --git a/sc/source/ui/inc/tabbgcolordlg.hxx b/sc/source/ui/inc/tabbgcolordlg.hxx
index ae83b58..68e9b6d 100644
--- a/sc/source/ui/inc/tabbgcolordlg.hxx
+++ b/sc/source/ui/inc/tabbgcolordlg.hxx
@@ -31,8 +31,7 @@ public:
ScTabBgColorDlg( vcl::Window* pParent,
const OUString& rTitle,
const OUString& rTabBgColorNoColorText,
- const Color& rDefaultColor,
- const OString& nHelpId );
+ const Color& rDefaultColor );
virtual ~ScTabBgColorDlg();
virtual void dispose() override;
diff --git a/sc/source/ui/miscdlgs/tabbgcolordlg.cxx b/sc/source/ui/miscdlgs/tabbgcolordlg.cxx
index a8993d8..f88ca41 100644
--- a/sc/source/ui/miscdlgs/tabbgcolordlg.cxx
+++ b/sc/source/ui/miscdlgs/tabbgcolordlg.cxx
@@ -36,8 +36,7 @@
#define HDL(hdl) LINK(this,ScTabBgColorDlg,hdl)
ScTabBgColorDlg::ScTabBgColorDlg(vcl::Window* pParent, const OUString& rTitle,
- const OUString& rTabBgColorNoColorText, const Color& rDefaultColor,
- const OString& sHelpId)
+ const OUString& rTabBgColorNoColorText, const Color& rDefaultColor)
: ModalDialog(pParent, "TabColorDialog", "modules/scalc/ui/tabcolordialog.ui")
, m_aTabBgColor(rDefaultColor)
, m_aTabBgColorNoColorText(rTabBgColorNoColorText)
@@ -48,7 +47,6 @@ ScTabBgColorDlg::ScTabBgColorDlg(vcl::Window* pParent, const OUString& rTitle,
m_pTabBgColorSet->SetColCount(SvxColorValueSet::getColumnCount());
get(m_pBtnOk, "ok");
- SetHelpId( sHelpId );
this->SetText( rTitle );
this->SetStyle(GetStyle() | WB_BORDER | WB_STDFLOATWIN | WB_3DLOOK | WB_DIALOGCONTROL | WB_SYSTEMWINDOW | WB_STANDALONE | WB_HIDE);
diff --git a/sc/source/ui/view/tabvwshf.cxx b/sc/source/ui/view/tabvwshf.cxx
index fa9ee6e..5f8b52a 100644
--- a/sc/source/ui/view/tabvwshf.cxx
+++ b/sc/source/ui/view/tabvwshf.cxx
@@ -740,8 +740,7 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq )
GetDialogParent(),
OUString(ScResId(SCSTR_SET_TAB_BG_COLOR)),
OUString(ScResId(SCSTR_NO_TAB_BG_COLOR)),
- aTabBgColor,
- ".uno:TabBgColor"));
+ aTabBgColor));
while ( !bDone && nRet == RET_OK )
{
nRet = pDlg->Execute();
commit 76798a98a7c9240ca3496ec322c0dab0709c2bf9
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date: Tue Jun 28 15:39:54 2016 +0200
screenshots: actually save screenshots for sc
Change-Id: If563f5b0fd5b28589bfbe4cf91061951acd14ebf
diff --git a/sc/qa/unit/screenshots/screenshots.cxx b/sc/qa/unit/screenshots/screenshots.cxx
index 4937474..b17afc9 100644
--- a/sc/qa/unit/screenshots/screenshots.cxx
+++ b/sc/qa/unit/screenshots/screenshots.cxx
@@ -20,9 +20,11 @@
#include <editeng/editview.hxx>
#include <editeng/outliner.hxx>
#include <osl/conditn.hxx>
+#include <osl/file.hxx>
#include <sfx2/dispatch.hxx>
#include <sfx2/viewfrm.hxx>
#include <svl/srchitem.hxx>
+#include <vcl/pngwrite.hxx>
#include <tabvwsh.hxx>
#include <docsh.hxx>
@@ -43,8 +45,23 @@ using namespace css;
#if !defined(WNT) && !defined(MACOSX)
static const char* DATA_DIRECTORY = "/sc/qa/unit/screenshots/data/";
+static const char* SCREENSHOT_DIRECTORY = "/workdir/screenshots/";
#endif
+namespace {
+ void splitHelpId( OString& rHelpId, OUString& rDirname, OUString &rBasename )
+ {
+ sal_Int32 nIndex = rHelpId.lastIndexOf( '/' );
+
+ if( nIndex > 0 )
+ rDirname = OStringToOUString( rHelpId.copy( 0, nIndex ), RTL_TEXTENCODING_UTF8 );
+
+ if( rHelpId.getLength() > nIndex+1 )
+ rBasename= OStringToOUString( rHelpId.copy( nIndex+1 ), RTL_TEXTENCODING_UTF8 );
+ }
+}
+
+
class ScScreenshotTest : public test::BootstrapFixture, public unotest::MacrosTest, public XmlTestTools
{
public:
@@ -53,24 +70,32 @@ public:
virtual void tearDown() SAL_OVERRIDE;
#if !defined(WNT) && !defined(MACOSX)
- void testOpeningSomeDialog();
+ void testOpeningModalDialogs();
//void testOpeningModelessDialogs();
#endif
CPPUNIT_TEST_SUITE(ScScreenshotTest);
#if !defined(WNT) && !defined(MACOSX)
- CPPUNIT_TEST(testOpeningSomeDialog);
+ CPPUNIT_TEST(testOpeningModalDialogs);
//CPPUNIT_TEST(testOpeningModelessDialogs);
#endif
CPPUNIT_TEST_SUITE_END();
private:
#if !defined(WNT) && !defined(MACOSX)
- ScModelObj* createDoc(const char* pName);
+ void initializeWithDoc(const char* pName);
+
+ VclAbstractDialog* createDialogByID( sal_uInt32 nID);
+ void dumpDialogToPath( VclAbstractDialog& rDialog );
+ void saveScreenshot( VclAbstractDialog& rDialog );
#endif
uno::Reference<lang::XComponent> mxComponent;
+ SfxObjectShell* pFoundShell;
+ ScDocShellRef xDocSh;
+ ScTabViewShell* pViewShell;
+ ScAbstractDialogFactory* pFact;
};
ScScreenshotTest::ScScreenshotTest()
@@ -82,6 +107,9 @@ void ScScreenshotTest::setUp()
test::BootstrapFixture::setUp();
mxDesktop.set(css::frame::Desktop::create(comphelper::getComponentContext(getMultiServiceFactory())));
+
+ osl::FileBase::RC err = osl::Directory::create( m_directories.getURLFromSrc( SCREENSHOT_DIRECTORY ) );
+ CPPUNIT_ASSERT_MESSAGE( "Failed to create screenshot directory", (err == osl::FileBase::E_None || err == osl::FileBase::E_EXIST) );
}
void ScScreenshotTest::tearDown()
@@ -93,142 +121,183 @@ void ScScreenshotTest::tearDown()
}
#if !defined(WNT) && !defined(MACOSX)
-ScModelObj* ScScreenshotTest::createDoc(const char* pName)
+void ScScreenshotTest::initializeWithDoc(const char* pName)
{
if (mxComponent.is())
mxComponent->dispose();
mxComponent = loadFromDesktop(m_directories.getURLFromSrc(DATA_DIRECTORY) + OUString::createFromAscii(pName), "com.sun.star.sheet.SpreadsheetDocument");
- ScModelObj* pModelObj = dynamic_cast<ScModelObj*>(mxComponent.get());
- CPPUNIT_ASSERT(pModelObj);
- return pModelObj;
-}
-
-void ScScreenshotTest::testOpeningSomeDialog()
-{
- ScModelObj* pModelObj = createDoc("empty.ods");
- ScDocument* pDoc = pModelObj->GetDocument();
-
- // display insert sheet dialog
- //uno::Sequence<beans::PropertyValue> aArgs;
- //comphelper::dispatchCommand(".uno:Insert", aArgs);
- SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(mxComponent);
+ pFoundShell = SfxObjectShell::GetShellFromComponent(mxComponent);
CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell);
- ScDocShellRef xDocSh = dynamic_cast<ScDocShell*>(pFoundShell);
+ xDocSh = dynamic_cast<ScDocShell*>(pFoundShell);
CPPUNIT_ASSERT(xDocSh != nullptr);
- ScTabViewShell* pViewShell = xDocSh->GetBestViewShell(false);
+ pViewShell = xDocSh->GetBestViewShell(false);
CPPUNIT_ASSERT(pViewShell != nullptr);
- ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
- CPPUNIT_ASSERT( pFact != nullptr );
-
- ScViewData& rViewData = pViewShell->GetViewData();
- SCTAB nTabSelCount = rViewData.GetMarkData().GetSelectCount();
- std::unique_ptr<AbstractScInsertTableDlg> pDlg( pFact->CreateScInsertTableDlg(
- pViewShell->GetDialogParent(), rViewData, nTabSelCount, false));
- CPPUNIT_ASSERT( pDlg != nullptr );
-
- pDlg->Execute();
-
- std::unique_ptr<AbstractScDeleteCellDlg> pDlg2( pFact->CreateScDeleteCellDlg(
- pViewShell->GetDialogParent(), false));
- CPPUNIT_ASSERT( pDlg2 != nullptr );
-
- pDlg2->Execute();
-
- std::unique_ptr<AbstractScInsertContentsDlg> pDlg3( pFact->CreateScInsertContentsDlg(
- pViewShell->GetDialogParent()));
- CPPUNIT_ASSERT( pDlg3 != nullptr );
-
- pDlg3->Execute();
-
- std::unique_ptr<AbstractScColRowLabelDlg> pDlg4( pFact->CreateScColRowLabelDlg(
- pViewShell->GetDialogParent(), true, false));
- CPPUNIT_ASSERT( pDlg4 != nullptr );
-
- pDlg4->Execute();
-
- std::unique_ptr<AbstractScDataPilotDatabaseDlg> pDlg5( pFact->CreateScDataPilotDatabaseDlg(
- pViewShell->GetDialogParent()));
- CPPUNIT_ASSERT( pDlg5 != nullptr );
-
- pDlg5->Execute();
-
- std::unique_ptr<AbstractScDataPilotSourceTypeDlg> pDlg6( pFact->CreateScDataPilotSourceTypeDlg(
- pViewShell->GetDialogParent(), true));
- CPPUNIT_ASSERT( pDlg6 != nullptr );
-
- pDlg6->Execute();
-
- std::unique_ptr<AbstractScDeleteContentsDlg> pDlg7( pFact->CreateScDeleteContentsDlg(
- pViewShell->GetDialogParent()));
- CPPUNIT_ASSERT( pDlg7 != nullptr );
-
- pDlg7->Execute();
-
- // just fake some flags
- sal_uInt16 nFlags = NAME_LEFT | NAME_TOP;
- std::unique_ptr<AbstractScNameCreateDlg> pDlg8( pFact->CreateScNameCreateDlg(
- pViewShell->GetDialogParent(), nFlags));
- CPPUNIT_ASSERT( pDlg8 != nullptr );
-
- pDlg8->Execute();
+ pFact = ScAbstractDialogFactory::Create();
+ CPPUNIT_ASSERT_MESSAGE("Failed to create dialog factory", pFact);
+}
- //FIXME: translatable string here
+VclAbstractDialog* ScScreenshotTest::createDialogByID( sal_uInt32 nID )
+{
+ VclAbstractDialog *pReturnDialog = nullptr;
+ ////FIXME: translatable string here
const OUString aDefaultSheetName("Sheet1");
- const OString aEmpty("");
- std::unique_ptr<AbstractScStringInputDlg> pDlg9( pFact->CreateScStringInputDlg(
- pViewShell->GetDialogParent(), OUString(ScResId(SCSTR_APDTABLE)), OUString(ScResId(SCSTR_NAME)),
- aDefaultSheetName, aEmpty, aEmpty));
- CPPUNIT_ASSERT( pDlg9 != nullptr );
-
- pDlg9->Execute();
-
- std::unique_ptr<AbstractScTabBgColorDlg> pDlg10( pFact->CreateScTabBgColorDlg(
- pViewShell->GetDialogParent(), OUString(ScResId(SCSTR_SET_TAB_BG_COLOR)),
- OUString(ScResId(SCSTR_NO_TAB_BG_COLOR)), Color(0xff00ff), ".uno:TabBgColor"));
- CPPUNIT_ASSERT( pDlg10 != nullptr );
-
- pDlg10->Execute();
-
- std::unique_ptr<AbstractScTextImportOptionsDlg> pDlg11( pFact->CreateScTextImportOptionsDlg());
- CPPUNIT_ASSERT( pDlg11 != nullptr );
- pDlg11->Execute();
-
- //FIXME: looks butt-ugly w/ empty file, move it elsewhere, where
- //we actually have some data
- std::unique_ptr<AbstractScDataFormDlg> pDlg12( pFact->CreateScDataFormDlg(
- pViewShell->GetDialogParent(), pViewShell));
- CPPUNIT_ASSERT( pDlg12 != nullptr );
-
- pDlg12->Execute();
-
- const OUString aCsv("some, strings, here, separated, by, commas");
- ScImportStringStream aStream( aCsv );
- std::unique_ptr<AbstractScImportAsciiDlg> pDlg13( pFact->CreateScImportAsciiDlg(
- OUString(), &aStream, SC_PASTETEXT ));
- CPPUNIT_ASSERT( pDlg13 != nullptr );
-
- pDlg13->Execute();
+ switch ( nID )
+ {
+ case 0:
+ {
+ ScViewData& rViewData = pViewShell->GetViewData();
+ SCTAB nTabSelCount = rViewData.GetMarkData().GetSelectCount();
+
+ pReturnDialog = pFact->CreateScInsertTableDlg(
+ pViewShell->GetDialogParent(), rViewData, nTabSelCount, false);
+
+ break;
+ }
+
+ case 1:
+ {
+ pReturnDialog = pFact->CreateScDeleteCellDlg( pViewShell->GetDialogParent(), false );
+ break;
+ }
+
+ case 2:
+ {
+ pReturnDialog = pFact->CreateScInsertContentsDlg( pViewShell->GetDialogParent() );
+ break;
+ }
+
+ case 3:
+ {
+ pReturnDialog = pFact->CreateScColRowLabelDlg( pViewShell->GetDialogParent(), true, false );
+ break;
+ }
+
+ case 4:
+ {
+ pReturnDialog = pFact->CreateScDataPilotDatabaseDlg( pViewShell->GetDialogParent() );
+ break;
+ }
+ case 5:
+ {
+
+ pReturnDialog = pFact->CreateScDataPilotSourceTypeDlg(pViewShell->GetDialogParent(), true );
+ break;
+ }
+
+ case 6:
+ {
+ pReturnDialog = pFact->CreateScDeleteContentsDlg( pViewShell->GetDialogParent() );
+ break;
+ }
+
+ case 7:
+ {
+ //// just fake some flags
+ sal_uInt16 nFlags = NAME_LEFT | NAME_TOP;
+ pReturnDialog = pFact->CreateScNameCreateDlg( pViewShell->GetDialogParent(), nFlags );
+ break;
+ }
+
+ case 8:
+ {
+ const OString aEmpty("");
+ pReturnDialog = pFact->CreateScStringInputDlg( pViewShell->GetDialogParent(),
+ OUString(ScResId(SCSTR_APDTABLE)), OUString(ScResId(SCSTR_NAME)),
+ aDefaultSheetName, aEmpty, aEmpty );
+ break;
+ }
+
+ case 9:
+ {
+ pReturnDialog = pFact->CreateScTabBgColorDlg( pViewShell->GetDialogParent(),
+ OUString(ScResId(SCSTR_SET_TAB_BG_COLOR)),
+ OUString(ScResId(SCSTR_NO_TAB_BG_COLOR)), Color(0xff00ff), ".uno:TabBgColor" );
+ break;
+ }
+
+ case 10:
+ {
+ pReturnDialog = pFact->CreateScTextImportOptionsDlg();
+ break;
+ }
+
+ case 11:
+ {
+ ////FIXME: looks butt-ugly w/ empty file, move it elsewhere, where
+ ////we actually have some data
+ pReturnDialog = pFact->CreateScDataFormDlg( pViewShell->GetDialogParent(), pViewShell );
+ break;
+ }
+
+ case 12:
+ {
+ pReturnDialog = pFact->CreateScMoveTableDlg( pViewShell->GetDialogParent(), aDefaultSheetName );
+ break;
+ }
+
+ //case 12:
+ //{
+ // const OUString aCsv("some, strings, here, separated, by, commas");
+ // ScImportStringStream aStream( aCsv );
+ // pReturnDialog = pFact->CreateScImportAsciiDlg( OUString(), &aStream, SC_PASTETEXT );
+ // break;
+ //}
+ //ScopedVclPtrInstance<ScShareDocumentDlg> pDlg14( pViewShell->GetDialogParent(), &rViewData );
+ //ScopedVclPtrInstance<ScTableProtectionDlg> pDlg16(pViewShell->GetDialogParent());
+ default:
+ break;
+ }
+
+ //CPPUNIT_ASSERT_MESSAGE( "Failed to create dialog", pReturnDialog );
+ return pReturnDialog;
+}
- ScopedVclPtrInstance<ScShareDocumentDlg> pDlg14( pViewShell->GetDialogParent(), &rViewData );
- CPPUNIT_ASSERT( pDlg14 != nullptr );
+void ScScreenshotTest::saveScreenshot( VclAbstractDialog& rDialog )
+{
+ const Bitmap aScreenshot(rDialog.createScreenshot());
+
+ if (!aScreenshot.IsEmpty())
+ {
+ OString aScreenshotId = rDialog.GetScreenshotId();
+ OUString aDirname, aBasename;
+ splitHelpId( aScreenshotId, aDirname, aBasename );
+ aDirname = OUString::createFromAscii( SCREENSHOT_DIRECTORY ) + aDirname;
+
+ osl::FileBase::RC err = osl::Directory::createPath( m_directories.getURLFromSrc( aDirname ));
+ CPPUNIT_ASSERT_MESSAGE( OUStringToOString( "Failed to create " + aDirname, RTL_TEXTENCODING_UTF8).getStr(),
+ (err == osl::FileBase::E_None || err == osl::FileBase::E_EXIST) );
+
+ OUString aFullPath = m_directories.getSrcRootPath() + aDirname + "/" + aBasename + ".png";
+ SvFileStream aNew(aFullPath, StreamMode::WRITE | StreamMode::TRUNC);
+ CPPUNIT_ASSERT_MESSAGE( OUStringToOString( "Failed to open " + OUString::number(aNew.GetErrorCode()), RTL_TEXTENCODING_UTF8).getStr(), aNew.IsOpen() );
+
+ vcl::PNGWriter aPNGWriter(aScreenshot);
+ aPNGWriter.Write(aNew);
+ }
+}
- pDlg14->Execute();
+void ScScreenshotTest::dumpDialogToPath( VclAbstractDialog& rDialog )
+{
+ saveScreenshot( rDialog );
+}
- std::unique_ptr<AbstractScMoveTableDlg> pDlg15( pFact->CreateScMoveTableDlg(
- pViewShell->GetDialogParent(), aDefaultSheetName));
- CPPUNIT_ASSERT( pDlg15 != nullptr );
+void ScScreenshotTest::testOpeningModalDialogs()
+{
+ initializeWithDoc("empty.ods");
- pDlg15->Execute();
+ const sal_uInt32 nDialogs = 13;
- ScopedVclPtrInstance<ScTableProtectionDlg> pDlg16(pViewShell->GetDialogParent());
- CPPUNIT_ASSERT( pDlg16 != nullptr );
+ for ( sal_uInt32 i = 0; i < nDialogs; i++ )
+ {
+ VclAbstractDialog *pDialog = createDialogByID( i );
- pDlg16->Execute();
+ dumpDialogToPath( *pDialog );
+ }
}
#endif
commit 4910aa5f1f8c249b108c13a3044f726e7f3b49b8
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date: Tue Jun 28 14:47:25 2016 +0200
screenshots: interface for sc dialog factory
Change-Id: Ibe0f8ec2714002b2dc84ef0c0bb8cb845e906aab
diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx
index 95294ae..a7a6460 100644
--- a/sc/source/ui/attrdlg/scdlgfact.hxx
+++ b/sc/source/ui/attrdlg/scdlgfact.hxx
@@ -64,7 +64,9 @@ public: \
: pDlg(p) \
{} \
virtual ~Class(); \
- virtual short Execute() override ;
+ virtual short Execute() override ; \
+ virtual Bitmap createScreenshot() const override; \
+ virtual OString GetScreenshotId() const; \
#define DECL_ABSTDLG2_BASE(Class,DialogClass) \
ScopedVclPtr<DialogClass> pDlg; \
@@ -83,6 +85,14 @@ Class::~Class() \
short Class::Execute() \
{ \
return pDlg->Execute(); \
+} \
+Bitmap Class::createScreenshot() const \
+{ \
+ return pDlg->createScreenshot(); \
+} \
+OString Class::GetScreenshotId() const \
+{ \
+ return pDlg->GetScreenshotId(); \
}
#define IMPL_ABSTDLG2_BASE(Class) \
commit 9bfa2f39bf78d7662717b3a4c5945b78902db8ea
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date: Mon Jun 27 23:11:34 2016 +0200
screenshots: open more sc modal dialogs, part 2
Change-Id: Ia5a1bbc00acff10405aa5205b9fd5a930deb5fc9
diff --git a/sc/qa/unit/screenshots/screenshots.cxx b/sc/qa/unit/screenshots/screenshots.cxx
index 9af18fe..4937474 100644
--- a/sc/qa/unit/screenshots/screenshots.cxx
+++ b/sc/qa/unit/screenshots/screenshots.cxx
@@ -27,13 +27,17 @@
#include <tabvwsh.hxx>
#include <docsh.hxx>
#include <document.hxx>
+#include <sharedocdlg.hxx>
+#include <protectiondlg.hxx>
#include <docuno.hxx>
#include <scabstdlg.hxx>
#include <reffact.hxx>
#include <scui_def.hxx>
+#include <impex.hxx>
#include <sc.hrc>
#include <scresid.hxx>
+#include <scitems.hxx>
using namespace css;
@@ -201,6 +205,30 @@ void ScScreenshotTest::testOpeningSomeDialog()
CPPUNIT_ASSERT( pDlg12 != nullptr );
pDlg12->Execute();
+
+ const OUString aCsv("some, strings, here, separated, by, commas");
+ ScImportStringStream aStream( aCsv );
+ std::unique_ptr<AbstractScImportAsciiDlg> pDlg13( pFact->CreateScImportAsciiDlg(
+ OUString(), &aStream, SC_PASTETEXT ));
+ CPPUNIT_ASSERT( pDlg13 != nullptr );
+
+ pDlg13->Execute();
+
+ ScopedVclPtrInstance<ScShareDocumentDlg> pDlg14( pViewShell->GetDialogParent(), &rViewData );
+ CPPUNIT_ASSERT( pDlg14 != nullptr );
+
+ pDlg14->Execute();
+
+ std::unique_ptr<AbstractScMoveTableDlg> pDlg15( pFact->CreateScMoveTableDlg(
+ pViewShell->GetDialogParent(), aDefaultSheetName));
+ CPPUNIT_ASSERT( pDlg15 != nullptr );
+
+ pDlg15->Execute();
+
+ ScopedVclPtrInstance<ScTableProtectionDlg> pDlg16(pViewShell->GetDialogParent());
+ CPPUNIT_ASSERT( pDlg16 != nullptr );
+
+ pDlg16->Execute();
}
#endif
diff --git a/sc/source/ui/inc/protectiondlg.hxx b/sc/source/ui/inc/protectiondlg.hxx
index 6833117b..b2c1a47 100644
--- a/sc/source/ui/inc/protectiondlg.hxx
+++ b/sc/source/ui/inc/protectiondlg.hxx
@@ -27,6 +27,8 @@
#include <vcl/layout.hxx>
#include <svx/checklbx.hxx>
+#include "scdllapi.h"
+
namespace vcl { class Window; }
class ScTableProtection;
@@ -34,7 +36,7 @@ class ScTableProtectionDlg : public ModalDialog
{
public:
ScTableProtectionDlg() = delete;
- explicit ScTableProtectionDlg(vcl::Window* pParent);
+ explicit SC_DLLPUBLIC ScTableProtectionDlg(vcl::Window* pParent);
virtual ~ScTableProtectionDlg();
virtual void dispose() override;
diff --git a/sc/source/ui/inc/sharedocdlg.hxx b/sc/source/ui/inc/sharedocdlg.hxx
index 01a195a..838f3ac 100644
--- a/sc/source/ui/inc/sharedocdlg.hxx
+++ b/sc/source/ui/inc/sharedocdlg.hxx
@@ -47,7 +47,7 @@ private:
DECL_LINK_TYPED( ToggleHandle, CheckBox&, void );
public:
- ScShareDocumentDlg( vcl::Window* pParent, ScViewData* pViewData );
+ SC_DLLPUBLIC ScShareDocumentDlg( vcl::Window* pParent, ScViewData* pViewData );
virtual ~ScShareDocumentDlg();
virtual void dispose() override;
commit 9cb2761bb1cabb743b65e31ad2f9a57e55ebdfdf
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date: Mon Jun 27 14:50:44 2016 +0200
screenshots: rPath argument is now unused
Change-Id: Icd3c66b83419f25b198937b05ede9b22f1344726
diff --git a/sd/qa/unit/dialogs-test.cxx b/sd/qa/unit/dialogs-test.cxx
index 8813c99..0578fac 100644
--- a/sd/qa/unit/dialogs-test.cxx
+++ b/sd/qa/unit/dialogs-test.cxx
@@ -107,7 +107,7 @@ private:
/// central methods: dialog creation and dumping to target directory (path)
VclAbstractDialog* createDialogByID(sal_uInt32 nID);
- void dumpDialogToPath(VclAbstractDialog& rDlg, const OUString& rPath);
+ void dumpDialogToPath(VclAbstractDialog& rDlg);
void saveScreenshot( VclAbstractDialog& rDlg);
public:
@@ -644,7 +644,7 @@ void SdDialogsTest::saveScreenshot(VclAbstractDialog& rDlg)
}
}
-void SdDialogsTest::dumpDialogToPath(VclAbstractDialog& rDlg, const OUString& rPath)
+void SdDialogsTest::dumpDialogToPath(VclAbstractDialog& rDlg)
{
// for dumping, a lossless format is needed. It may be seen if the created data
@@ -689,7 +689,7 @@ void SdDialogsTest::openAnyDialog()
if (pDlg)
{
- dumpDialogToPath(*pDlg, aTempTargetPath + "/" + OUString::number(a));
+ dumpDialogToPath(*pDlg);
delete pDlg;
}
}
commit bc3a2e3dca8444eb171499c15df2bd59f5a5ddea
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date: Mon Jun 27 14:22:49 2016 +0200
screenshots: modify tab dialog screenshot id a bit
Use only ID of the current page.
Change-Id: I27ef4d2112a047379cec6bc221ba403f1a0371e4
diff --git a/sfx2/source/dialog/tabdlg.cxx b/sfx2/source/dialog/tabdlg.cxx
index 4a5f953..878d9fad 100644
--- a/sfx2/source/dialog/tabdlg.cxx
+++ b/sfx2/source/dialog/tabdlg.cxx
@@ -1235,7 +1235,7 @@ OString SfxTabDialog::GetScreenshotId() const
vcl::Window* pToplevelBox = pActiveTabPage->GetWindow( GetWindowType::FirstChild );
if ( pToplevelBox )
- aScreenshotId = aScreenshotId + OString("#") + pToplevelBox->GetHelpId();
+ aScreenshotId = pToplevelBox->GetHelpId();
}
return aScreenshotId;
commit 603b07fe74bec06d0939d2bad6a16ae55a1d299b
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date: Fri Jun 24 17:54:18 2016 +0200
screenshots: names to copy screenshot IDs
For tab dialogs. While at it, factor out file-saving code into
a separate function.
Change-Id: Ideffc9934c0d562fe365d0bb1942f31056d4a486
diff --git a/include/vcl/abstdlg.hxx b/include/vcl/abstdlg.hxx
index 676154e..9a6842b 100644
--- a/include/vcl/abstdlg.hxx
+++ b/include/vcl/abstdlg.hxx
@@ -39,6 +39,7 @@ public:
virtual std::vector<OString> getAllPageUIXMLDescriptions() const;
virtual bool selectPageByUIXMLDescription(const OString& rUIXMLDescription);
virtual Bitmap createScreenshot() const;
+ virtual OString GetScreenshotId() const { return OString(); };
};
class VCL_DLLPUBLIC VclAbstractDialog2
diff --git a/sd/qa/unit/dialogs-test.cxx b/sd/qa/unit/dialogs-test.cxx
index 59f1cc4..8813c99 100644
--- a/sd/qa/unit/dialogs-test.cxx
+++ b/sd/qa/unit/dialogs-test.cxx
@@ -60,7 +60,20 @@
using namespace ::com::sun::star;
-static const char* SCREENSHOT_DIRECTORY = "/workdir/screenshots";
+static const char* SCREENSHOT_DIRECTORY = "/workdir/screenshots/";
+
+namespace {
+ void splitHelpId( OString& rHelpId, OUString& rDirname, OUString &rBasename )
+ {
+ sal_Int32 nIndex = rHelpId.lastIndexOf( '/' );
+
+ if( nIndex > 0 )
+ rDirname = OStringToOUString( rHelpId.copy( 0, nIndex ), RTL_TEXTENCODING_UTF8 );
+
+ if( rHelpId.getLength() > nIndex+1 )
+ rBasename= OStringToOUString( rHelpId.copy( nIndex+1 ), RTL_TEXTENCODING_UTF8 );
+ }
+}
/// Test opening a dialog in sd
class SdDialogsTest : public test::BootstrapFixture, public unotest::MacrosTest
@@ -95,6 +108,7 @@ private:
/// central methods: dialog creation and dumping to target directory (path)
VclAbstractDialog* createDialogByID(sal_uInt32 nID);
void dumpDialogToPath(VclAbstractDialog& rDlg, const OUString& rPath);
+ void saveScreenshot( VclAbstractDialog& rDlg);
public:
SdDialogsTest();
@@ -606,6 +620,30 @@ VclAbstractDialog* SdDialogsTest::createDialogByID(sal_uInt32 nID)
return pRetval;
}
+void SdDialogsTest::saveScreenshot(VclAbstractDialog& rDlg)
+{
+ const Bitmap aScreenshot(rDlg.createScreenshot());
+
+ if (!aScreenshot.IsEmpty())
+ {
+ OString aScreenshotId = rDlg.GetScreenshotId();
+ OUString aDirname, aBasename;
+ splitHelpId( aScreenshotId, aDirname, aBasename );
+ aDirname = OUString::createFromAscii( SCREENSHOT_DIRECTORY ) + aDirname;
+
+ osl::FileBase::RC err = osl::Directory::createPath( m_directories.getURLFromSrc( aDirname ));
+ CPPUNIT_ASSERT_MESSAGE( OUStringToOString( "Failed to create " + aDirname, RTL_TEXTENCODING_UTF8).getStr(),
+ (err == osl::FileBase::E_None || err == osl::FileBase::E_EXIST) );
+
+ OUString aFullPath = m_directories.getSrcRootPath() + aDirname + "/" + aBasename + ".png";
+ SvFileStream aNew(aFullPath, StreamMode::WRITE | StreamMode::TRUNC);
+ CPPUNIT_ASSERT_MESSAGE( OUStringToOString( "Failed to open " + OUString::number(aNew.GetErrorCode()), RTL_TEXTENCODING_UTF8).getStr(), aNew.IsOpen() );
+
+ vcl::PNGWriter aPNGWriter(aScreenshot);
+ aPNGWriter.Write(aNew);
+ }
+}
+
void SdDialogsTest::dumpDialogToPath(VclAbstractDialog& rDlg, const OUString& rPath)
{
@@ -620,14 +658,7 @@ void SdDialogsTest::dumpDialogToPath(VclAbstractDialog& rDlg, const OUString& rP
{
if (rDlg.selectPageByUIXMLDescription(aPageDescriptions[a]))
{
- const Bitmap aScreenshot(rDlg.createScreenshot());
-
- if (!aScreenshot.IsEmpty())
- {
- SvFileStream aNew(rPath + OUString("_") + OUString::number(a) + OUString(".png"), StreamMode::WRITE | StreamMode::TRUNC);
- vcl::PNGWriter aPNGWriter(aScreenshot);
- aPNGWriter.Write(aNew);
- }
+ saveScreenshot( rDlg );
}
else
{
@@ -637,17 +668,7 @@ void SdDialogsTest::dumpDialogToPath(VclAbstractDialog& rDlg, const OUString& rP
}
else
{
- const Bitmap aScreenshot(rDlg.createScreenshot());
-
- if (!aScreenshot.IsEmpty())
- {
- const OUString aPath = rPath + ".png";
- SvFileStream aNew(aPath, StreamMode::WRITE | StreamMode::TRUNC);
- CPPUNIT_ASSERT_MESSAGE( OUStringToOString( "Failed to create " + aPath, RTL_TEXTENCODING_UTF8).getStr(), aNew.IsOpen() );
-
- vcl::PNGWriter aPNGWriter(aScreenshot);
- aPNGWriter.Write(aNew);
- }
+ saveScreenshot( rDlg );
}
}
diff --git a/sd/source/ui/dlg/sddlgfact.hxx b/sd/source/ui/dlg/sddlgfact.hxx
index 86bc1f7..9bb135c 100644
--- a/sd/source/ui/dlg/sddlgfact.hxx
+++ b/sd/source/ui/dlg/sddlgfact.hxx
@@ -32,6 +32,7 @@ public: \
virtual std::vector<OString> getAllPageUIXMLDescriptions() const override; \
virtual bool selectPageByUIXMLDescription(const OString& rUIXMLDescription) override; \
virtual Bitmap createScreenshot() const override; \
+ virtual OString GetScreenshotId() const; \
virtual ~Class(); \
virtual short Execute() override ;
@@ -39,6 +40,7 @@ public: \
std::vector<OString> Class::getAllPageUIXMLDescriptions() const { return pDlg->getAllPageUIXMLDescriptions(); } \
bool Class::selectPageByUIXMLDescription(const OString& rUIXMLDescription) { return pDlg->selectPageByUIXMLDescription(rUIXMLDescription); } \
Bitmap Class::createScreenshot() const { return pDlg->createScreenshot();} \
+OString Class::GetScreenshotId() const { return pDlg->GetScreenshotId();} \
Class::~Class() \
{ \
} \
commit 36131e6ae3b172d5a4b99ce98a64ed386f554dc9
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date: Thu Jun 23 23:06:35 2016 +0200
screenshots: write created screenshots into workdir
Use osl file abstractions for that
Change-Id: I876ca61e1d42b29f7c592b2778d8847b15513b98
diff --git a/sd/qa/unit/dialogs-test.cxx b/sd/qa/unit/dialogs-test.cxx
index 93d3cf0..59f1cc4 100644
--- a/sd/qa/unit/dialogs-test.cxx
+++ b/sd/qa/unit/dialogs-test.cxx
@@ -32,6 +32,7 @@
#include <osl/process.h>
#include <osl/thread.h>
+#include <osl/file.hxx>
#include "sdabstdlg.hxx"
#include <vcl/pngwrite.hxx>
@@ -59,6 +60,8 @@
using namespace ::com::sun::star;
+static const char* SCREENSHOT_DIRECTORY = "/workdir/screenshots";
+
/// Test opening a dialog in sd
class SdDialogsTest : public test::BootstrapFixture, public unotest::MacrosTest
{
@@ -135,6 +138,10 @@ void SdDialogsTest::setUp()
mpFact = SdAbstractDialogFactory::Create();
mxComponent = loadFromDesktop("private:factory/simpress", "com.sun.star.presentation.PresentationDocument");
CPPUNIT_ASSERT(mxComponent.is());
+
+ osl::FileBase::RC err = osl::Directory::create( m_directories.getURLFromSrc( SCREENSHOT_DIRECTORY ) );
+ CPPUNIT_ASSERT_MESSAGE( "Failed to create screenshot directory", (err == osl::FileBase::E_None || err == osl::FileBase::E_EXIST) );
+
mpImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get());
CPPUNIT_ASSERT(mpImpressDocument);
}
@@ -601,6 +608,7 @@ VclAbstractDialog* SdDialogsTest::createDialogByID(sal_uInt32 nID)
void SdDialogsTest::dumpDialogToPath(VclAbstractDialog& rDlg, const OUString& rPath)
{
+
// for dumping, a lossless format is needed. It may be seen if the created data
// will be further modified/reduced, but for a input creating step it is
// unavoidable to use a lossless format initially
@@ -633,7 +641,10 @@ void SdDialogsTest::dumpDialogToPath(VclAbstractDialog& rDlg, const OUString& rP
if (!aScreenshot.IsEmpty())
{
- SvFileStream aNew(rPath + OUString(".png"), StreamMode::WRITE | StreamMode::TRUNC);
+ const OUString aPath = rPath + ".png";
+ SvFileStream aNew(aPath, StreamMode::WRITE | StreamMode::TRUNC);
+ CPPUNIT_ASSERT_MESSAGE( OUStringToOString( "Failed to create " + aPath, RTL_TEXTENCODING_UTF8).getStr(), aNew.IsOpen() );
+
vcl::PNGWriter aPNGWriter(aScreenshot);
aPNGWriter.Write(aNew);
}
@@ -642,20 +653,7 @@ void SdDialogsTest::dumpDialogToPath(VclAbstractDialog& rDlg, const OUString& rP
void SdDialogsTest::openAnyDialog()
{
-// activate for debug using attach
-// while (true)
-// {
-// Sound::Beep();
-// }
-
- // current target for png's is defined here
- const OUString aTempTargetPath(
-#ifdef _WIN32
- "c:\\test_dlgF_"
-#else
- "~/test_dlgF_"
-#endif
- );
+ const OUString aTempTargetPath = m_directories.getPathFromSrc( SCREENSHOT_DIRECTORY );
// example for SfxTabDialog: 5
// example for TabDialog: 23
@@ -670,7 +668,7 @@ void SdDialogsTest::openAnyDialog()
if (pDlg)
{
- dumpDialogToPath(*pDlg, aTempTargetPath + OUString::number(a));
+ dumpDialogToPath(*pDlg, aTempTargetPath + "/" + OUString::number(a));
delete pDlg;
}
}
commit 1d2c236461ba745feb4ea09466216c1e7fd55a14
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date: Tue Jun 21 18:24:52 2016 +0200
screenshots: open more sc modal dialogs
Change-Id: Ie0d0bcea3409f99cce0b9dccd4f316d1da3c0d84
diff --git a/sc/qa/unit/screenshots/screenshots.cxx b/sc/qa/unit/screenshots/screenshots.cxx
index fb27cab..9af18fe 100644
--- a/sc/qa/unit/screenshots/screenshots.cxx
+++ b/sc/qa/unit/screenshots/screenshots.cxx
@@ -30,8 +30,10 @@
#include <docuno.hxx>
#include <scabstdlg.hxx>
#include <reffact.hxx>
+#include <scui_def.hxx>
#include <sc.hrc>
+#include <scresid.hxx>
using namespace css;
@@ -162,6 +164,43 @@ void ScScreenshotTest::testOpeningSomeDialog()
pDlg7->Execute();
+ // just fake some flags
+ sal_uInt16 nFlags = NAME_LEFT | NAME_TOP;
+ std::unique_ptr<AbstractScNameCreateDlg> pDlg8( pFact->CreateScNameCreateDlg(
+ pViewShell->GetDialogParent(), nFlags));
+ CPPUNIT_ASSERT( pDlg8 != nullptr );
+
+ pDlg8->Execute();
+
+ //FIXME: translatable string here
+ const OUString aDefaultSheetName("Sheet1");
+ const OString aEmpty("");
+ std::unique_ptr<AbstractScStringInputDlg> pDlg9( pFact->CreateScStringInputDlg(
+ pViewShell->GetDialogParent(), OUString(ScResId(SCSTR_APDTABLE)), OUString(ScResId(SCSTR_NAME)),
+ aDefaultSheetName, aEmpty, aEmpty));
+ CPPUNIT_ASSERT( pDlg9 != nullptr );
+
+ pDlg9->Execute();
+
+ std::unique_ptr<AbstractScTabBgColorDlg> pDlg10( pFact->CreateScTabBgColorDlg(
+ pViewShell->GetDialogParent(), OUString(ScResId(SCSTR_SET_TAB_BG_COLOR)),
+ OUString(ScResId(SCSTR_NO_TAB_BG_COLOR)), Color(0xff00ff), ".uno:TabBgColor"));
+ CPPUNIT_ASSERT( pDlg10 != nullptr );
+
+ pDlg10->Execute();
+
+ std::unique_ptr<AbstractScTextImportOptionsDlg> pDlg11( pFact->CreateScTextImportOptionsDlg());
+ CPPUNIT_ASSERT( pDlg11 != nullptr );
+
+ pDlg11->Execute();
+
+ //FIXME: looks butt-ugly w/ empty file, move it elsewhere, where
+ //we actually have some data
+ std::unique_ptr<AbstractScDataFormDlg> pDlg12( pFact->CreateScDataFormDlg(
+ pViewShell->GetDialogParent(), pViewShell));
+ CPPUNIT_ASSERT( pDlg12 != nullptr );
+
+ pDlg12->Execute();
}
#endif
commit 25aac25dc3074500733206888c6507cfc99b34a9
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date: Tue Jun 21 14:13:27 2016 +0200
screenshots: kill work-around for pseudo-headless mode
Start test with use_vcl_non_headless_with_windows instead
Change-Id: Id6ff9c6f15ec927e1cbe2c599c526857982a76d2
diff --git a/sd/CppunitTest_sd_dialogs_test.mk b/sd/CppunitTest_sd_dialogs_test.mk
index d6027e6..04571a2 100644
--- a/sd/CppunitTest_sd_dialogs_test.mk
+++ b/sd/CppunitTest_sd_dialogs_test.mk
@@ -61,7 +61,7 @@ $(eval $(call gb_CppunitTest_use_external,sd_dialogs_test,boost_headers))
$(eval $(call gb_CppunitTest_use_sdk_api,sd_dialogs_test))
$(eval $(call gb_CppunitTest_use_ure,sd_dialogs_test))
-$(eval $(call gb_CppunitTest_use_vcl_non_headless,sd_dialogs_test))
+$(eval $(call gb_CppunitTest_use_vcl_non_headless_with_windows,sd_dialogs_test))
$(eval $(call gb_CppunitTest_use_rdb,sd_dialogs_test,services))
diff --git a/sd/qa/unit/dialogs-test.cxx b/sd/qa/unit/dialogs-test.cxx
index c5a6d4d..93d3cf0 100644
--- a/sd/qa/unit/dialogs-test.cxx
+++ b/sd/qa/unit/dialogs-test.cxx
@@ -670,14 +670,6 @@ void SdDialogsTest::openAnyDialog()
if (pDlg)
{
- if (false)
- {
- const Application::DialogCancelMode aOriginalDialogCancelMode(Application::GetDialogCancelMode());
- Application::SetDialogCancelMode(Application::DialogCancelMode::Off);
- pDlg->Execute();
- Application::SetDialogCancelMode(aOriginalDialogCancelMode);
- }
-
dumpDialogToPath(*pDlg, aTempTargetPath + OUString::number(a));
delete pDlg;
}
diff --git a/vcl/source/app/settings.cxx b/vcl/source/app/settings.cxx
index 14dea6a..90482c6 100644
--- a/vcl/source/app/settings.cxx
+++ b/vcl/source/app/settings.cxx
@@ -2410,7 +2410,7 @@ ImplMiscData::ImplMiscData()
// Should we display any windows?
// need to hardly mask here for now, needs to be adapted of course...
- mbPseudoHeadless = false; // getenv("VCL_HIDE_WINDOWS") || comphelper::LibreOfficeKit::isActive();
+ mbPseudoHeadless = getenv("VCL_HIDE_WINDOWS") || comphelper::LibreOfficeKit::isActive();
}
ImplMiscData::ImplMiscData( const ImplMiscData& rData )
commit b1eba2e83bdc476dc9f9177d634ec3339b94cdcc
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date: Tue Jun 21 11:21:18 2016 +0200
screenshots: opening some sc dialogs from cppunit
Change-Id: I4e56f0264ada77e24f5d71fa9eaf48e5eedaaae8
diff --git a/sc/CppunitTest_sc_screenshots.mk b/sc/CppunitTest_sc_screenshots.mk
new file mode 100644
index 0000000..ac1aa41
--- /dev/null
+++ b/sc/CppunitTest_sc_screenshots.mk
@@ -0,0 +1,63 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#*************************************************************************
+#
+# 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/.
+#
+#*************************************************************************
+
+$(eval $(call gb_CppunitTest_CppunitTest,sc_screenshots))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sc_screenshots, \
+ sc/qa/unit/screenshots/screenshots \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,sc_screenshots, \
+ comphelper \
+ cppu \
+ cppuhelper \
+ editeng \
+ sal \
+ sfx \
+ svl \
+ svt \
+ svxcore \
+ sc \
+ scui \
+ test \
+ unotest \
+ vcl \
+ tl \
+ utl \
+ $(gb_UWINAPI) \
+))
+
+$(eval $(call gb_CppunitTest_use_externals,sc_screenshots,\
+ boost_headers \
+ libxml2 \
+))
+
+$(eval $(call gb_CppunitTest_set_include,sc_screenshots,\
+ -I$(SRCDIR)/sc/source/ui/inc \
+ -I$(SRCDIR)/sc/inc \
+ $$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_use_api,sc_screenshots,\
+ offapi \
+ udkapi \
+))
+
+$(eval $(call gb_CppunitTest_use_ure,sc_screenshots))
+$(eval $(call gb_CppunitTest_use_vcl_non_headless_with_windows,sc_screenshots))
+
+$(eval $(call gb_CppunitTest_use_rdb,sc_screenshots,services))
+
+$(eval $(call gb_CppunitTest_use_instdir_configuration,sc_screenshots))
+
+$(call gb_CppunitTest_get_target,sc_screenshots) : $(call gb_AllLangResTarget_get_target,sc)
+
+# vim: set noet sw=4 ts=4:
diff --git a/sc/qa/unit/screenshots/data/empty.ods b/sc/qa/unit/screenshots/data/empty.ods
new file mode 100644
index 0000000..14b4232
Binary files /dev/null and b/sc/qa/unit/screenshots/data/empty.ods differ
diff --git a/sc/qa/unit/screenshots/screenshots.cxx b/sc/qa/unit/screenshots/screenshots.cxx
new file mode 100644
index 0000000..fb27cab
--- /dev/null
+++ b/sc/qa/unit/screenshots/screenshots.cxx
@@ -0,0 +1,173 @@
+/* -*- 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 <test/bootstrapfixture.hxx>
+#include <unotest/macros_test.hxx>
+#include <test/xmltesttools.hxx>
+
+#include <com/sun/star/frame/Desktop.hpp>
+#include <comphelper/dispatchcommand.hxx>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/propertysequence.hxx>
+#include <comphelper/string.hxx>
+#include <editeng/editids.hrc>
+#include <editeng/editview.hxx>
+#include <editeng/outliner.hxx>
+#include <osl/conditn.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <svl/srchitem.hxx>
+
+#include <tabvwsh.hxx>
+#include <docsh.hxx>
+#include <document.hxx>
+#include <docuno.hxx>
+#include <scabstdlg.hxx>
+#include <reffact.hxx>
+
+#include <sc.hrc>
+
+using namespace css;
+
+#if !defined(WNT) && !defined(MACOSX)
+static const char* DATA_DIRECTORY = "/sc/qa/unit/screenshots/data/";
+#endif
+
+class ScScreenshotTest : public test::BootstrapFixture, public unotest::MacrosTest, public XmlTestTools
+{
+public:
+ ScScreenshotTest();
+ virtual void setUp() SAL_OVERRIDE;
+ virtual void tearDown() SAL_OVERRIDE;
+
+#if !defined(WNT) && !defined(MACOSX)
+ void testOpeningSomeDialog();
+ //void testOpeningModelessDialogs();
+#endif
+
+ CPPUNIT_TEST_SUITE(ScScreenshotTest);
+#if !defined(WNT) && !defined(MACOSX)
+ CPPUNIT_TEST(testOpeningSomeDialog);
+ //CPPUNIT_TEST(testOpeningModelessDialogs);
+#endif
+ CPPUNIT_TEST_SUITE_END();
+
+private:
+#if !defined(WNT) && !defined(MACOSX)
+ ScModelObj* createDoc(const char* pName);
+
+#endif
+
+ uno::Reference<lang::XComponent> mxComponent;
+};
+
+ScScreenshotTest::ScScreenshotTest()
+{
+}
+
+void ScScreenshotTest::setUp()
+{
+ test::BootstrapFixture::setUp();
+
+ mxDesktop.set(css::frame::Desktop::create(comphelper::getComponentContext(getMultiServiceFactory())));
+}
+
+void ScScreenshotTest::tearDown()
+{
+ if (mxComponent.is())
+ mxComponent->dispose();
+
+ test::BootstrapFixture::tearDown();
+}
+
+#if !defined(WNT) && !defined(MACOSX)
+ScModelObj* ScScreenshotTest::createDoc(const char* pName)
+{
+ if (mxComponent.is())
+ mxComponent->dispose();
+ mxComponent = loadFromDesktop(m_directories.getURLFromSrc(DATA_DIRECTORY) + OUString::createFromAscii(pName), "com.sun.star.sheet.SpreadsheetDocument");
+ ScModelObj* pModelObj = dynamic_cast<ScModelObj*>(mxComponent.get());
+ CPPUNIT_ASSERT(pModelObj);
+ return pModelObj;
+}
+
+void ScScreenshotTest::testOpeningSomeDialog()
+{
+ ScModelObj* pModelObj = createDoc("empty.ods");
+ ScDocument* pDoc = pModelObj->GetDocument();
+
+ // display insert sheet dialog
+ //uno::Sequence<beans::PropertyValue> aArgs;
+ //comphelper::dispatchCommand(".uno:Insert", aArgs);
+
+ SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(mxComponent);
+ CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell);
+
+ ScDocShellRef xDocSh = dynamic_cast<ScDocShell*>(pFoundShell);
+ CPPUNIT_ASSERT(xDocSh != nullptr);
+
+ ScTabViewShell* pViewShell = xDocSh->GetBestViewShell(false);
+ CPPUNIT_ASSERT(pViewShell != nullptr);
+
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ CPPUNIT_ASSERT( pFact != nullptr );
+
+ ScViewData& rViewData = pViewShell->GetViewData();
+ SCTAB nTabSelCount = rViewData.GetMarkData().GetSelectCount();
+ std::unique_ptr<AbstractScInsertTableDlg> pDlg( pFact->CreateScInsertTableDlg(
+ pViewShell->GetDialogParent(), rViewData, nTabSelCount, false));
+ CPPUNIT_ASSERT( pDlg != nullptr );
+
+ pDlg->Execute();
+
+ std::unique_ptr<AbstractScDeleteCellDlg> pDlg2( pFact->CreateScDeleteCellDlg(
+ pViewShell->GetDialogParent(), false));
+ CPPUNIT_ASSERT( pDlg2 != nullptr );
+
+ pDlg2->Execute();
+
+ std::unique_ptr<AbstractScInsertContentsDlg> pDlg3( pFact->CreateScInsertContentsDlg(
+ pViewShell->GetDialogParent()));
+ CPPUNIT_ASSERT( pDlg3 != nullptr );
+
+ pDlg3->Execute();
+
+ std::unique_ptr<AbstractScColRowLabelDlg> pDlg4( pFact->CreateScColRowLabelDlg(
+ pViewShell->GetDialogParent(), true, false));
+ CPPUNIT_ASSERT( pDlg4 != nullptr );
+
+ pDlg4->Execute();
+
+ std::unique_ptr<AbstractScDataPilotDatabaseDlg> pDlg5( pFact->CreateScDataPilotDatabaseDlg(
+ pViewShell->GetDialogParent()));
+ CPPUNIT_ASSERT( pDlg5 != nullptr );
+
+ pDlg5->Execute();
+
+ std::unique_ptr<AbstractScDataPilotSourceTypeDlg> pDlg6( pFact->CreateScDataPilotSourceTypeDlg(
+ pViewShell->GetDialogParent(), true));
+ CPPUNIT_ASSERT( pDlg6 != nullptr );
+
+ pDlg6->Execute();
+
+ std::unique_ptr<AbstractScDeleteContentsDlg> pDlg7( pFact->CreateScDeleteContentsDlg(
+ pViewShell->GetDialogParent()));
+ CPPUNIT_ASSERT( pDlg7 != nullptr );
+
+ pDlg7->Execute();
+
+}
+
+#endif
+
+CPPUNIT_TEST_SUITE_REGISTRATION(ScScreenshotTest);
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 3311e1dfaadcfb88661f6e052a3b8c1479759f73
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date: Wed Jun 15 14:07:16 2016 +0200
screenshots: unset VCL_HIDE_WINDOWS
Those screenshot cppunit tests need to run in non-headless mode with
dialog windows exposed (i.e. VCL_HIDE_WINDOWS must not be set)
To preserve the current behaviour (VCL_HIDE_WINDOWS is set always on Win
and Mac, and in use_vcl_non_headless case on Linux), introduce 2 new
variables:
gb_CppunitTest_show_windows: unset VCL_HIDE_WINDOWS unconditionally
gb_CppunitTest_hide_windows: set VCL_HIDE_WINDOWS=1 if HEADLESS is empty
(i.e. let's not use emptiness of HEADLESS as an indicator, as it is
empty in 2 mutually exclusive cases)
Change-Id: Ib2f7a9cfb1202944d10856c44b6ac7c41156b333
diff --git a/solenv/gbuild/CppunitTest.mk b/solenv/gbuild/CppunitTest.mk
index 5532192..a898cab 100644
--- a/solenv/gbuild/CppunitTest.mk
+++ b/solenv/gbuild/CppunitTest.mk
@@ -98,6 +98,8 @@ $(call gb_CppunitTest_get_clean_target,%) :
$(call gb_CppunitTest_get_target,%) :| $(gb_CppunitTest_RUNTIMEDEPS)
$(call gb_Output_announce,$*,$(true),CUT,2)
$(call gb_Helper_abbreviate_dirs,\
+ $(if $(gb_CppunitTest_vcl_hide_windows),VCL_HIDE_WINDOWS=1 && ) \
+ $(if $(gb_CppunitTest_vcl_show_windows),unset VCL_HIDE_WINDOWS && ) \
mkdir -p $(dir $@) && \
rm -fr $@.user && mkdir $@.user && \
$(if $(gb_CppunitTest__use_confpreinit), \
@@ -108,7 +110,6 @@ $(call gb_CppunitTest_get_target,%) :| $(gb_CppunitTest_RUNTIMEDEPS)
($(gb_CppunitTest_CPPTESTPRECOMMAND) \
$(if $(G_SLICE),G_SLICE=$(G_SLICE)) \
$(if $(GLIBCXX_FORCE_NEW),GLIBCXX_FORCE_NEW=$(GLIBCXX_FORCE_NEW)) \
- $(if $(HEADLESS),,VCL_HIDE_WINDOWS=1) \
$(gb_CppunitTest_malloc_check) \
$(if $(strip $(PYTHON_URE)),\
PYTHONDONTWRITEBYTECODE=1) \
@@ -209,6 +210,14 @@ endef
define gb_CppunitTest_use_vcl_non_headless
$(call gb_CppunitTest_get_target,$(1)) : HEADLESS :=
+$(call gb_CppunitTest_get_target,$(1)) : gb_CppunitTest_vcl_hide_windows := $(true)
+$(call gb_CppunitTest__use_vcl,$(1),$(false))
+
+endef
+
+define gb_CppunitTest_use_vcl_non_headless_with_windows
+$(call gb_CppunitTest_get_target,$(1)) : HEADLESS :=
+$(call gb_CppunitTest_get_target,$(1)) : gb_CppunitTest_vcl_show_windows := $(true)
$(call gb_CppunitTest__use_vcl,$(1),$(false))
endef
commit 49e27d5dab9421fbbe720cfa28d3bb4d4ad6afcb
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date: Fri Jun 17 16:10:26 2016 +0200
screenshots: exclude sd tests for the while
Change-Id: Ia5fc46f5030285049acf4836ba4cbd6285cbe5ae
diff --git a/sd/Module_sd.mk b/sd/Module_sd.mk
index 01f23aa..a6b4f9d 100644
--- a/sd/Module_sd.mk
+++ b/sd/Module_sd.mk
@@ -34,7 +34,6 @@ $(eval $(call gb_Module_add_check_targets,sd,\
CppunitTest_sd_export_ooxml2 \
CppunitTest_sd_export_tests \
CppunitTest_sd_filters_test \
- CppunitTest_sd_dialogs_test \
CppunitTest_sd_misc_tests \
CppunitTest_sd_html_export_tests \
))
commit 7f151ea46dc0e3550efe708571972e9fd1c3f07a
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date: Fri Jun 17 13:56:07 2016 +0200
screenshots: add missing cppunit files
Change-Id: I9fd716671c7d1dc568d14b914c9a802fc6239a5e
diff --git a/sd/CppunitTest_sd_dialogs_test.mk b/sd/CppunitTest_sd_dialogs_test.mk
new file mode 100644
index 0000000..d6027e6
--- /dev/null
+++ b/sd/CppunitTest_sd_dialogs_test.mk
@@ -0,0 +1,71 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#*************************************************************************
+#
+# 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/.
+#
+#*************************************************************************
+
+$(eval $(call gb_CppunitTest_CppunitTest,sd_dialogs_test))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sd_dialogs_test, \
+ sd/qa/unit/dialogs-test \
+))
+
+$(eval $(call gb_CppunitTest_use_sdk_api,sd_dialogs_test))
+
+$(eval $(call gb_CppunitTest_set_include,sd_dialogs_test,\
+ -I$(SRCDIR)/sd/source/ui/inc \
+ -I$(SRCDIR)/sd/inc \
+ $$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,sd_dialogs_test, \
+ basegfx \
+ comphelper \
+ cppu \
+ cppuhelper \
+ drawinglayer \
+ editeng \
+ i18nlangtag \
+ i18nutil \
+ msfilter \
+ oox \
+ sal \
+ salhelper \
+ sax \
+ sd \
+ sdui \
+ sfx \
+ sot \
+ svl \
+ svt \
+ svx \
+ svxcore \
+ test \
+ tl \
+ tk \
+ ucbhelper \
+ unotest \
+ utl \
+ vcl \
+ xo \
+ $(gb_UWINAPI) \
+))
+
+$(eval $(call gb_CppunitTest_use_external,sd_dialogs_test,boost_headers))
+
+$(eval $(call gb_CppunitTest_use_sdk_api,sd_dialogs_test))
+
+$(eval $(call gb_CppunitTest_use_ure,sd_dialogs_test))
+$(eval $(call gb_CppunitTest_use_vcl_non_headless,sd_dialogs_test))
+
+$(eval $(call gb_CppunitTest_use_rdb,sd_dialogs_test,services))
+
+# $(eval $(call gb_CppunitTest_use_configuration,sd_dialogs_test))
+$(eval $(call gb_CppunitTest_use_instdir_configuration,sd_dialogs_test))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sd/qa/unit/dialogs-test.cxx b/sd/qa/unit/dialogs-test.cxx
new file mode 100644
index 0000000..c5a6d4d
--- /dev/null
+++ b/sd/qa/unit/dialogs-test.cxx
@@ -0,0 +1,693 @@
+/* -*- 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 <sal/config.h>
+#include <test/bootstrapfixture.hxx>
+#include <rtl/strbuf.hxx>
+#include <osl/file.hxx>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
+#include <com/sun/star/presentation/AnimationEffect.hpp>
+#include <com/sun/star/presentation/ClickAction.hpp>
+
+#include <sfx2/app.hxx>
+#include <sfx2/docfilt.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/sfxmodelfactory.hxx>
+#include <svl/stritem.hxx>
+#include <svl/aeitem.hxx>
+#include <editeng/colritem.hxx>
+#include <svx/svdtext.hxx>
+#include <svx/svdotext.hxx>
+#include <vcl/sound.hxx>
+
+#include "drawdoc.hxx"
+#include "../source/ui/inc/DrawDocShell.hxx"
+
+#include <osl/process.h>
+#include <osl/thread.h>
+
+#include "sdabstdlg.hxx"
+#include <vcl/pngwrite.hxx>
+#include "unomodel.hxx"
+#include "ViewShell.hxx"
+#include "Window.hxx"
+#include "drawview.hxx"
+#include "DrawViewShell.hxx"
+#include <app.hrc>
+#include "stlsheet.hxx"
+#include "sdattr.hrc"
+#include "strings.hrc"
+#include "sdresid.hxx"
+#include "sdattr.hxx"
+#include "prltempl.hrc"
+
+#include <comphelper/servicehelper.hxx>
+#include <com/sun/star/frame/Desktop.hpp>
+#include <com/sun/star/frame/XDesktop2.hpp>
+#include <comphelper/processfactory.hxx>
+#include <unotest/macros_test.hxx>
+
+//#include "DrawController.hxx"
+//#include "ViewShellBase.hxx"
+
+using namespace ::com::sun::star;
+
+/// Test opening a dialog in sd
+class SdDialogsTest : public test::BootstrapFixture, public unotest::MacrosTest
+{
+private:
+ /// Document and ComponentContext
+ uno::Reference<uno::XComponentContext> mxComponentContext;
+ uno::Reference<lang::XComponent> mxComponent;
+
+ /// initially created SdAbstractDialogFactory and pointer to document
+ SdAbstractDialogFactory* mpFact;
+ SdXImpressDocument* mpImpressDocument;
+
+ /// on-demand created instances required for varoius dialogs to open
+ ::sd::DrawDocShell* mpDocShell;
+ ::sd::ViewShell* mpViewShell;
+ ::sd::DrawView* mpDrawView;
+ const SfxItemSet* mpSfxItemSetFromSdrObject;
+ const SfxItemSet* mpEmptySfxItemSet;
+ SfxItemSet* mpEmptyFillStyleSfxItemSet;
+
+ /// helpers
+ SdAbstractDialogFactory* getSdAbstractDialogFactory();
+ SdXImpressDocument* getSdXImpressDocument();
+ ::sd::DrawDocShell* getDocShell();
+ ::sd::ViewShell* getViewShell();
+ ::sd::DrawView* getDrawView();
+ const SfxItemSet& getSfxItemSetFromSdrObject();
+ const SfxItemSet& getEmptySfxItemSet();
+ const SfxItemSet& getEmptyFillStyleSfxItemSet();
+
+ /// central methods: dialog creation and dumping to target directory (path)
+ VclAbstractDialog* createDialogByID(sal_uInt32 nID);
+ void dumpDialogToPath(VclAbstractDialog& rDlg, const OUString& rPath);
+
+public:
+ SdDialogsTest();
+ ~SdDialogsTest();
+
+ virtual void setUp() override;
+ virtual void tearDown() override;
+
+ // try to open a dialog
+ void openAnyDialog();
+
+ CPPUNIT_TEST_SUITE(SdDialogsTest);
+ CPPUNIT_TEST(openAnyDialog);
+ CPPUNIT_TEST_SUITE_END();
+};
+
+SdDialogsTest::SdDialogsTest()
+: mxComponentContext(),
+ mxComponent(),
+ mpFact(nullptr),
+ mpImpressDocument(nullptr),
+ mpDocShell(nullptr),
+ mpViewShell(nullptr),
+ mpDrawView(nullptr),
+ mpSfxItemSetFromSdrObject(nullptr),
+ mpEmptySfxItemSet(nullptr),
+ mpEmptyFillStyleSfxItemSet(nullptr)
+{
+}
+
+SdDialogsTest::~SdDialogsTest()
+{
+}
+
+void SdDialogsTest::setUp()
+{
+ test::BootstrapFixture::setUp();
+
+ mxComponentContext.set(comphelper::getComponentContext(getMultiServiceFactory()));
+ mxDesktop.set(frame::Desktop::create(mxComponentContext));
+ mpFact = SdAbstractDialogFactory::Create();
+ mxComponent = loadFromDesktop("private:factory/simpress", "com.sun.star.presentation.PresentationDocument");
+ CPPUNIT_ASSERT(mxComponent.is());
+ mpImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get());
+ CPPUNIT_ASSERT(mpImpressDocument);
+}
+
+void SdDialogsTest::tearDown()
+{
+ if (mpEmptySfxItemSet)
+ {
+ delete mpEmptySfxItemSet;
+ }
+
+ if (mpEmptyFillStyleSfxItemSet)
+ {
+ delete mpEmptyFillStyleSfxItemSet;
+ }
+
+ if (mxComponent.is())
+ {
+ mxComponent->dispose();
+ }
+
+ test::BootstrapFixture::tearDown();
+}
+
+SdAbstractDialogFactory* SdDialogsTest::getSdAbstractDialogFactory()
+{
+ return mpFact;
+}
+
+SdXImpressDocument* SdDialogsTest::getSdXImpressDocument()
+{
+ return mpImpressDocument;
+}
+
+::sd::DrawDocShell* SdDialogsTest::getDocShell()
+{
+ if (!mpDocShell)
+ {
+ mpDocShell = getSdXImpressDocument()->GetDocShell();
+ CPPUNIT_ASSERT(mpDocShell);
+ }
+
+ return mpDocShell;
+}
+
+::sd::ViewShell* SdDialogsTest::getViewShell()
+{
+ if (!mpViewShell)
+ {
+ mpViewShell = getDocShell()->GetViewShell();
+ CPPUNIT_ASSERT(mpViewShell);
+ }
+
+ return mpViewShell;
+}
+
+::sd::DrawView* SdDialogsTest::getDrawView()
+{
+ if (!mpDrawView)
+ {
+ mpDrawView = dynamic_cast<::sd::DrawView*>(getViewShell()->GetDrawView());
+ CPPUNIT_ASSERT(mpDrawView);
+ }
+
+ return mpDrawView;
+}
+
+const SfxItemSet& SdDialogsTest::getSfxItemSetFromSdrObject()
+{
+ if (!mpSfxItemSetFromSdrObject)
+ {
+ SdDrawDocument* pDrawDoc = getSdXImpressDocument()->GetDoc();
+ CPPUNIT_ASSERT(pDrawDoc);
+ SdPage* pSdPage = pDrawDoc->GetSdPage(0, PK_STANDARD);
+ CPPUNIT_ASSERT(pSdPage);
+ SdrObject* pSdrObj = pSdPage->GetObj(0);
+ CPPUNIT_ASSERT(pSdrObj);
+ mpSfxItemSetFromSdrObject = &pSdrObj->GetMergedItemSet();
+ CPPUNIT_ASSERT(mpSfxItemSetFromSdrObject);
+ }
+
+ return *mpSfxItemSetFromSdrObject;
+}
+
+const SfxItemSet& SdDialogsTest::getEmptySfxItemSet()
+{
+ if (!mpEmptySfxItemSet)
+ {
+ // needs an SfxItemSet, use the one from the 1st object
+ SdDrawDocument* pDrawDoc = getSdXImpressDocument()->GetDoc();
+ CPPUNIT_ASSERT(pDrawDoc);
+ mpEmptySfxItemSet = new SfxItemSet(pDrawDoc->GetItemPool());
+ CPPUNIT_ASSERT(mpEmptySfxItemSet);
+ }
+
+ return *mpEmptySfxItemSet;
+}
+
+const SfxItemSet& SdDialogsTest::getEmptyFillStyleSfxItemSet()
+{
+ if (!mpEmptyFillStyleSfxItemSet)
+ {
+ SdDrawDocument* pDrawDoc = getSdXImpressDocument()->GetDoc();
+ CPPUNIT_ASSERT(pDrawDoc);
+ mpEmptyFillStyleSfxItemSet = new SfxItemSet(pDrawDoc->GetItemPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST);
+ CPPUNIT_ASSERT(mpEmptyFillStyleSfxItemSet);
+ mpEmptyFillStyleSfxItemSet->Put(XFillStyleItem(drawing::FillStyle_NONE));
+ }
+
+ return *mpEmptyFillStyleSfxItemSet;
+}
+
+VclAbstractDialog* SdDialogsTest::createDialogByID(sal_uInt32 nID)
+{
+ VclAbstractDialog* pRetval = 0;
+
+ if (getSdAbstractDialogFactory())
+ {
+ switch (nID)
+ {
+ case 0:
+ {
+ // CreateSdPublishingDlg(vcl::Window* pWindow, DocumentType eDocType) override;
+ // this dialog does not need much, not even a SdDrawDocument. OTOH
+ // it is more a 'wizard' in that it has prev/next buttons and implicitly
+ // multiple pages. To make use of that it is necessary that the implementation
+ // supports the 'Screenshot interface'
+ pRetval = getSdAbstractDialogFactory()->CreateSdPublishingDlg(
+ Application::GetDefDialogParent(),
+ DOCUMENT_TYPE_IMPRESS);
+ break;
+ }
+ case 1:
+ {
+ // CreateBreakDlg(vcl::Window* pWindow, ::sd::DrawView* pDrView, ::sd::DrawDocShell* pShell, sal_uLong nSumActionCount, sal_uLong nObjCount) override;
+ // this dialog requires pDrawView. It does not show much when
+ // there is no object selected that can be broken up. For better
+ // results it might be necessary to add/select an object that
+ // delivers a good metafile (which is the base for breaking)
+ pRetval = getSdAbstractDialogFactory()->CreateBreakDlg(
+ Application::GetDefDialogParent(),
+ getDrawView(),
+ getDocShell(),
+ 0,
+ 0);
+ break;
+ }
+ case 2:
+ {
+ // CreateCopyDlg(const SfxItemSet& rInAttrs, const rtl::Reference<XColorList> &pColTab, ::sd::View* pView) override;
+ // works without XColorList (DropDowns will be empty), but
+ // it's easy to access, so use it
+ XColorListRef pColorList(XColorList::CreateStdColorList());
+
+ // needs an SfxItemSet, use the one from the 1st object
+ pRetval = getSdAbstractDialogFactory()->CreateCopyDlg(
+ getViewShell()->GetActiveWindow(),
+ getSfxItemSetFromSdrObject(),
+ pColorList,
+ getDrawView());
+ break;
+ }
+ case 3:
+ {
+ // CreateSdCustomShowDlg(SdDrawDocument& rDrawDoc) = 0;
+ SdDrawDocument* pDrawDoc = getSdXImpressDocument()->GetDoc();
+ CPPUNIT_ASSERT(pDrawDoc);
+
+ pRetval = getSdAbstractDialogFactory()->CreateSdCustomShowDlg(
+ getViewShell()->GetActiveWindow(),
+ *pDrawDoc);
+ break;
+ }
+ case 4:
+ {
+ // CreateSdTabCharDialog(const SfxItemSet* pAttr, SfxObjectShell* pDocShell) override;
+ // needs an SfxItemSet, use an empty constructed one
+ // needs a 'SfxObjectShell* pDocShell', crashes without
+ pRetval = getSdAbstractDialogFactory()->CreateSdTabCharDialog(
+ getViewShell()->GetActiveWindow(),
+ &getEmptySfxItemSet(),
+ getDocShell());
+ break;
+ }
+ case 5:
+ {
+ // CreateSdTabPageDialog(const SfxItemSet* pAttr, SfxObjectShell* pDocShell, bool bAreaPage = true) override;
+ // needs a special SfxItemSet with merged content from page and other stuff, crashes without that (2nd page)
+ // needs a 'SfxObjectShell* pDocShell', crashes without. Also sufficient: FillStyleItemSet with XFILL_NONE set
+ pRetval = getSdAbstractDialogFactory()->CreateSdTabPageDialog(
+ getViewShell()->GetActiveWindow(),
+ &getEmptyFillStyleSfxItemSet(),
+ getDocShell(),
+ true);
+ break;
+ }
+ case 6:
+ {
+ // CreateAssistentDlg(bool bAutoPilot) has been dropped
+ break;
+ }
+ case 7:
+ {
+ // CreateSdModifyFieldDlg(vcl::Window* pWindow, const SvxFieldData* pInField, const SfxItemSet& rSet) override;
+ pRetval = getSdAbstractDialogFactory()->CreateSdModifyFieldDlg(
+ Application::GetDefDialogParent(),
+ nullptr,
+ getEmptySfxItemSet());
+ break;
+ }
+ case 8:
+ {
+ // CreateSdSnapLineDlg(const SfxItemSet& rInAttrs, ::sd::View* pView) override;
+ SdDrawDocument* pDrawDoc = getSdXImpressDocument()->GetDoc();
+ CPPUNIT_ASSERT(pDrawDoc);
+ SfxItemSet aNewAttr(pDrawDoc->GetItemPool(), ATTR_SNAPLINE_START, ATTR_SNAPLINE_END);
+ aNewAttr.Put(SfxInt32Item(ATTR_SNAPLINE_X, 0));
+ aNewAttr.Put(SfxInt32Item(ATTR_SNAPLINE_Y, 0));
+ pRetval = getSdAbstractDialogFactory()->CreateSdSnapLineDlg(
+ getViewShell()->GetActiveWindow(),
+ aNewAttr,
+ getDrawView());
+ break;
+ }
+ case 9:
+ {
+ // CreateSdInsertLayerDlg(const SfxItemSet& rInAttrs, bool bDeletable, const OUString& aStr) override;
+ SdDrawDocument* pDrawDoc = getSdXImpressDocument()->GetDoc();
+ CPPUNIT_ASSERT(pDrawDoc);
+ SfxItemSet aNewAttr(pDrawDoc->GetItemPool(), ATTR_LAYER_START, ATTR_LAYER_END);
+ const OUString aLayerName = SD_RESSTR(STR_LAYER); // + OUString::number(2);
+ aNewAttr.Put(SdAttrLayerName(aLayerName));
+ aNewAttr.Put(SdAttrLayerTitle());
+ aNewAttr.Put(SdAttrLayerDesc());
+ aNewAttr.Put(SdAttrLayerVisible());
+ aNewAttr.Put(SdAttrLayerPrintable());
+ aNewAttr.Put(SdAttrLayerLocked());
+ aNewAttr.Put(SdAttrLayerThisPage());
+ pRetval = getSdAbstractDialogFactory()->CreateSdInsertLayerDlg(
+ getViewShell()->GetActiveWindow(),
+ aNewAttr,
+ true, // alternative: false
+ SD_RESSTR(STR_INSERTLAYER) /* alternative: STR_MODIFYLAYER */);
+ break;
+ }
+ case 10:
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list