summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKatarina Behrens <Katarina.Behrens@cib.de>2016-06-24 17:54:18 +0200
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2016-08-18 02:39:09 +0200
commitb8df3d4914f04c40570abca2afe0efac6d6c0d06 (patch)
treeb4d0769acec92b62d07a9edfb02d07d2daa8eb16
parentb5ff9533eef60c16c25fb66d97a3deaa73ed8494 (diff)
screenshots: names to copy screenshot IDs
For tab dialogs. While at it, factor out file-saving code into a separate function. Change-Id: Ideffc9934c0d562fe365d0bb1942f31056d4a486
-rw-r--r--include/vcl/abstdlg.hxx1
-rw-r--r--sd/qa/unit/dialogs-test.cxx61
-rw-r--r--sd/source/ui/dlg/sddlgfact.hxx2
3 files changed, 44 insertions, 20 deletions
diff --git a/include/vcl/abstdlg.hxx b/include/vcl/abstdlg.hxx
index e4416814f472..c18f1188e236 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 59f1cc47d217..8813c998ed5b 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 72b0505b6a2e..eb7597d6f6e4 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() \
{ \
} \