diff options
author | Katarina Behrens <Katarina.Behrens@cib.de> | 2016-06-23 23:06:35 +0200 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2016-08-18 02:39:09 +0200 |
commit | b5ff9533eef60c16c25fb66d97a3deaa73ed8494 (patch) | |
tree | 94ca1aec48ed88f90f4e09666714d5490acc9f7b /sd/qa | |
parent | ab436a45ea10a7bb76f7f2ee3371259d1eed36d4 (diff) |
screenshots: write created screenshots into workdir
Use osl file abstractions for that
Change-Id: I876ca61e1d42b29f7c592b2778d8847b15513b98
Diffstat (limited to 'sd/qa')
-rw-r--r-- | sd/qa/unit/dialogs-test.cxx | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/sd/qa/unit/dialogs-test.cxx b/sd/qa/unit/dialogs-test.cxx index 93d3cf020531..59f1cc47d217 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; } } |