[Libreoffice-commits] core.git: Branch 'feature/dialog-screenshots' - sd/qa

Katarina Behrens Katarina.Behrens at cib.de
Thu Jun 23 21:08:01 UTC 2016


Rebased ref, commits from common ancestor:
commit a16b3794fc862c98ce536812cb25c57c464fcfc7
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date:   Thu Jun 23 23:06:35 2016 +0200

    Put 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;
         }
     }


More information about the Libreoffice-commits mailing list