[Libreoffice-commits] core.git: 7 commits - desktop/source libreofficekit/qa

Andrzej Hunt andrzej.hunt at collabora.com
Thu Jul 31 03:31:43 PDT 2014


 desktop/source/lib/init.cxx                   |  101 ++++++++++++--------------
 libreofficekit/qa/data/blank_presentation.odp |binary
 libreofficekit/qa/data/blank_text.odt         |binary
 libreofficekit/qa/data/impress_slidenames.odp |binary
 libreofficekit/qa/unit/tiledrendering.cxx     |  100 ++++++++++++++++++++++---
 5 files changed, 137 insertions(+), 64 deletions(-)

New commits:
commit 5909d640dc2fe7b6aed0aa6e9136d981b09175ad
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date:   Thu Jul 31 11:57:09 2014 +0200

    LOK: add document loading failure test.
    
    We don't really have any way of telling the client that the file didn't
    exist yet though, so not very useful so far.
    
    Change-Id: I1db386781b88b345f3e9cb4f37838ca1d95f92f9

diff --git a/libreofficekit/qa/unit/tiledrendering.cxx b/libreofficekit/qa/unit/tiledrendering.cxx
index 043ffaf..5d61000 100644
--- a/libreofficekit/qa/unit/tiledrendering.cxx
+++ b/libreofficekit/qa/unit/tiledrendering.cxx
@@ -48,6 +48,7 @@ public:
     // components on the one Office instance that we retrieve.
     void runAllTests();
 
+    void testDocumentLoadFail( Office* pOffice );
     void testDocumentTypes( Office* pOffice );
     void testImpressSlideNames( Office* pOffice );
     void testOverlay( Office* pOffice );
@@ -63,11 +64,23 @@ void TiledRenderingTest::runAllTests()
                                       m_sLOPath.c_str() ) );
     CPPUNIT_ASSERT( pOffice.get() );
 
+    testDocumentLoadFail( pOffice.get() );
     testDocumentTypes( pOffice.get() );
     testImpressSlideNames( pOffice.get() );
     testOverlay( pOffice.get() );
 }
 
+void TiledRenderingTest::testDocumentLoadFail( Office* pOffice )
+{
+    const string sDocPath = m_sSrcRoot + "/libreofficekit/qa/data/IDONOTEXIST.odt";
+    scoped_ptr< Document> pDocument( pOffice->documentLoad( sDocPath.c_str() ) );
+    CPPUNIT_ASSERT( !pDocument.get() );
+    // TODO: we probably want to have some way of returning what
+    // the cause of failure was. getError() will return
+    // something along the lines of:
+    // "Unsupported URL <file:///SRC_ROOT/libreofficekit/qa/data/IDONOTEXIST.odt>: "type detection failed""
+}
+
 // Our dumped .png files end up in
 // workdir/CppunitTest/libreofficekit_tiledrendering.test.core
 
commit dd418d8ca230da09a15de10db66970bb50db0172
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date:   Thu Jul 31 11:20:00 2014 +0200

    LOK documentLoad needs SolarMutex protection too.
    
    We probably need to do this for most of LOK now that
    we use soffice_main.
    
    Change-Id: I77be7865511c083679cf2f68b0e5df106506fd70

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index bc38cc2..53e49e3 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -276,6 +276,8 @@ static LibreOfficeKitDocument* lo_documentLoad(LibreOfficeKit* pThis, const char
 
     OUString aURL = getAbsoluteURL(pURL);
 
+    SolarMutexGuard aGuard;
+
     uno::Reference<frame::XDesktop2> xComponentLoader = frame::Desktop::create(xContext);
 
     pLib->maLastExceptionMsg = "";
commit 5beec739f0c790615ed84e35dd513282d7dfa17d
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date:   Thu Jul 31 10:22:55 2014 +0200

    LOK: add test for getDocumentType.
    
    Change-Id: I264567f73dae9ecd061e09c4413857f793fcac48

diff --git a/libreofficekit/qa/data/blank_presentation.odp b/libreofficekit/qa/data/blank_presentation.odp
new file mode 100644
index 0000000..fd68d9a
Binary files /dev/null and b/libreofficekit/qa/data/blank_presentation.odp differ
diff --git a/libreofficekit/qa/data/blank_text.odt b/libreofficekit/qa/data/blank_text.odt
new file mode 100644
index 0000000..00b92d7
Binary files /dev/null and b/libreofficekit/qa/data/blank_text.odt differ
diff --git a/libreofficekit/qa/unit/tiledrendering.cxx b/libreofficekit/qa/unit/tiledrendering.cxx
index c544615..043ffaf 100644
--- a/libreofficekit/qa/unit/tiledrendering.cxx
+++ b/libreofficekit/qa/unit/tiledrendering.cxx
@@ -48,6 +48,7 @@ public:
     // components on the one Office instance that we retrieve.
     void runAllTests();
 
+    void testDocumentTypes( Office* pOffice );
     void testImpressSlideNames( Office* pOffice );
     void testOverlay( Office* pOffice );
 
@@ -62,6 +63,7 @@ void TiledRenderingTest::runAllTests()
                                       m_sLOPath.c_str() ) );
     CPPUNIT_ASSERT( pOffice.get() );
 
+    testDocumentTypes( pOffice.get() );
     testImpressSlideNames( pOffice.get() );
     testOverlay( pOffice.get() );
 }
@@ -83,6 +85,34 @@ static void dumpRGBABitmap( const OUString& rPath, const unsigned char* pBuffer,
     sOutput.Close();
 }
 
+LibreOfficeKitDocumentType getDocumentType( Office* pOffice, const string& rPath )
+{
+    scoped_ptr< Document> pDocument( pOffice->documentLoad( rPath.c_str() ) );
+    CPPUNIT_ASSERT( pDocument.get() );
+    return pDocument->getDocumentType();
+}
+
+void TiledRenderingTest::testDocumentTypes( Office* pOffice )
+{
+    const string sTextDocPath = m_sSrcRoot + "/libreofficekit/qa/data/blank_text.odt";
+    const string sTextLockFile = m_sSrcRoot +"/libreofficekit/qa/data/.~lock.blank_text.odt#";
+
+    // FIXME: same comment as below wrt lockfile removal.
+    remove( sTextLockFile.c_str() );
+
+    CPPUNIT_ASSERT( getDocumentType( pOffice, sTextDocPath ) == LOK_DOCTYPE_TEXT );
+
+    const string sPresentationDocPath = m_sSrcRoot + "/libreofficekit/qa/data/blank_presentation.odp";
+    const string sPresentationLockFile = m_sSrcRoot +"/libreofficekit/qa/data/.~lock.blank_presentation.odp#";
+
+    // FIXME: same comment as below wrt lockfile removal.
+    remove( sPresentationLockFile.c_str() );
+
+    CPPUNIT_ASSERT( getDocumentType( pOffice, sPresentationDocPath ) == LOK_DOCTYPE_PRESENTATION );
+
+    // TODO: do this for all supported document types
+}
+
 void TiledRenderingTest::testImpressSlideNames( Office* pOffice )
 {
     const string sDocPath = m_sSrcRoot + "/libreofficekit/qa/data/impress_slidenames.odp";
commit cc7f66dd53fd6b6c80134aa11fb4c00f95441f7c
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date:   Thu Jul 31 10:08:57 2014 +0200

    LOK: add slide name retrieval test.
    
    Change-Id: I6d2bc4dfa634223da662af6f7c9a91f06cfe7534

diff --git a/libreofficekit/qa/data/impress_slidenames.odp b/libreofficekit/qa/data/impress_slidenames.odp
new file mode 100644
index 0000000..d7cb6ae
Binary files /dev/null and b/libreofficekit/qa/data/impress_slidenames.odp differ
diff --git a/libreofficekit/qa/unit/tiledrendering.cxx b/libreofficekit/qa/unit/tiledrendering.cxx
index 74e0634..c544615 100644
--- a/libreofficekit/qa/unit/tiledrendering.cxx
+++ b/libreofficekit/qa/unit/tiledrendering.cxx
@@ -48,6 +48,7 @@ public:
     // components on the one Office instance that we retrieve.
     void runAllTests();
 
+    void testImpressSlideNames( Office* pOffice );
     void testOverlay( Office* pOffice );
 
     CPPUNIT_TEST_SUITE(TiledRenderingTest);
@@ -61,6 +62,7 @@ void TiledRenderingTest::runAllTests()
                                       m_sLOPath.c_str() ) );
     CPPUNIT_ASSERT( pOffice.get() );
 
+    testImpressSlideNames( pOffice.get() );
     testOverlay( pOffice.get() );
 }
 
@@ -81,6 +83,27 @@ static void dumpRGBABitmap( const OUString& rPath, const unsigned char* pBuffer,
     sOutput.Close();
 }
 
+void TiledRenderingTest::testImpressSlideNames( Office* pOffice )
+{
+    const string sDocPath = m_sSrcRoot + "/libreofficekit/qa/data/impress_slidenames.odp";
+    const string sLockFile = m_sSrcRoot +"/libreofficekit/qa/data/.~lock.impress_slidenames.odp#";
+
+    // FIXME: this is a temporary hack: LOK will fail when trying to open a
+    // locked file, and since we're reusing the file for a different unit
+    // test it's entirely possible that an unwanted lock file will remain.
+    // Hence forcefully remove it here.
+    remove( sLockFile.c_str() );
+
+    scoped_ptr< Document> pDocument( pOffice->documentLoad( sDocPath.c_str() ) );
+
+    CPPUNIT_ASSERT( pDocument->getParts() == 3 );
+    CPPUNIT_ASSERT( strcmp( pDocument->getPartName( 0 ), "TestText1" ) == 0 );
+    CPPUNIT_ASSERT( strcmp( pDocument->getPartName( 1 ), "TestText2" ) == 0 );
+    // The third slide hasn't had a name given to it (i.e. using the rename
+    // context menu in Impress), thus it should (as far as I can determine)
+    // have a localised version of "Slide 3".
+}
+
 void TiledRenderingTest::testOverlay( Office* pOffice )
 {
     const string sDocPath = m_sSrcRoot + "/odk/examples/java/DocumentHandling/test/test1.odt";
commit e780c96e8d5e6ad6142f328fa850fedb59f5ca97
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date:   Thu Jul 31 10:07:39 2014 +0200

    Use one test instance to run all LOK tests.
    
    Recreating Office instances after destruction (when still
    within the same process) currently fails, hence we need
    to do all tests at once for now.
    
    Change-Id: Ic7652c909e1cd970fe1ee76995e61fb6aae8f96c

diff --git a/libreofficekit/qa/unit/tiledrendering.cxx b/libreofficekit/qa/unit/tiledrendering.cxx
index 0d4aa95..74e0634 100644
--- a/libreofficekit/qa/unit/tiledrendering.cxx
+++ b/libreofficekit/qa/unit/tiledrendering.cxx
@@ -42,13 +42,28 @@ public:
 
     TiledRenderingTest() {}
 
-    void testOverlay();
+    // Currently it isn't possible to do multiple startup/shutdown
+    // cycle of LOK in a single process -- hence we run all our tests
+    // as one test, which simply carries out the individual test
+    // components on the one Office instance that we retrieve.
+    void runAllTests();
+
+    void testOverlay( Office* pOffice );
 
     CPPUNIT_TEST_SUITE(TiledRenderingTest);
-    CPPUNIT_TEST(testOverlay);
+    CPPUNIT_TEST(runAllTests);
     CPPUNIT_TEST_SUITE_END();
 };
 
+void TiledRenderingTest::runAllTests()
+{
+    scoped_ptr< Office > pOffice( lok_cpp_init(
+                                      m_sLOPath.c_str() ) );
+    CPPUNIT_ASSERT( pOffice.get() );
+
+    testOverlay( pOffice.get() );
+}
+
 // Our dumped .png files end up in
 // workdir/CppunitTest/libreofficekit_tiledrendering.test.core
 
@@ -66,7 +81,7 @@ static void dumpRGBABitmap( const OUString& rPath, const unsigned char* pBuffer,
     sOutput.Close();
 }
 
-void TiledRenderingTest::testOverlay()
+void TiledRenderingTest::testOverlay( Office* pOffice )
 {
     const string sDocPath = m_sSrcRoot + "/odk/examples/java/DocumentHandling/test/test1.odt";
     const string sLockFile = m_sSrcRoot + "/odk/examples/java/DocumentHandling/test/.~lock.test1.odt#";
@@ -77,10 +92,6 @@ void TiledRenderingTest::testOverlay()
     // Hence forcefully remove it here.
     remove( sLockFile.c_str() );
 
-    scoped_ptr< Office > pOffice( lok_cpp_init(
-                                      m_sLOPath.c_str() ) );
-    CPPUNIT_ASSERT( pOffice.get() );
-
     scoped_ptr< Document> pDocument( pOffice->documentLoad(
                                          sDocPath.c_str() ) );
 
commit d6fd97b4c90625b59f96d0017790eb2e2c996e49
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date:   Wed Jul 30 19:52:46 2014 +0200

    Make common paths member variables.
    
    We'll need these for other tests too.
    
    Change-Id: Ia99c2e60f5e5bb24a83875a9dcf85a6b4f54beb4

diff --git a/libreofficekit/qa/unit/tiledrendering.cxx b/libreofficekit/qa/unit/tiledrendering.cxx
index 4e1c0fa..0d4aa95 100644
--- a/libreofficekit/qa/unit/tiledrendering.cxx
+++ b/libreofficekit/qa/unit/tiledrendering.cxx
@@ -36,6 +36,10 @@ using namespace ::std;
 class TiledRenderingTest : public ::CppUnit::TestFixture
 {
 public:
+    const string m_sSrcRoot = getenv( "SRC_ROOT" );
+    const string m_sInstDir = getenv( "INSTDIR" );
+    const string m_sLOPath = m_sInstDir + "/program";
+
     TiledRenderingTest() {}
 
     void testOverlay();
@@ -64,11 +68,8 @@ static void dumpRGBABitmap( const OUString& rPath, const unsigned char* pBuffer,
 
 void TiledRenderingTest::testOverlay()
 {
-    const string sSrcRoot = getenv( "SRC_ROOT" );
-    const string sInstDir = getenv( "INSTDIR" );
-    const string sLOPath = sInstDir + "/program";
-    const string sDocPath = sSrcRoot + "/odk/examples/java/DocumentHandling/test/test1.odt";
-    const string sLockFile = sSrcRoot + "/odk/examples/java/DocumentHandling/test/.~lock.test1.odt#";
+    const string sDocPath = m_sSrcRoot + "/odk/examples/java/DocumentHandling/test/test1.odt";
+    const string sLockFile = m_sSrcRoot + "/odk/examples/java/DocumentHandling/test/.~lock.test1.odt#";
 
     // FIXME: this is a temporary hack: LOK will fail when trying to open a
     // locked file, and since we're reusing the file for a different unit
@@ -77,7 +78,7 @@ void TiledRenderingTest::testOverlay()
     remove( sLockFile.c_str() );
 
     scoped_ptr< Office > pOffice( lok_cpp_init(
-                                      sLOPath.c_str() ) );
+                                      m_sLOPath.c_str() ) );
     CPPUNIT_ASSERT( pOffice.get() );
 
     scoped_ptr< Document> pDocument( pOffice->documentLoad(
commit 3c115cd0474ac19240f491f6dcd1f1ec994a60da
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date:   Wed Jul 30 15:16:49 2014 +0200

    Use SolarMutexGuard instead of pairs of Acquire/ReleaseSolarMutex
    
    Change-Id: I7ff41dd932fd9860dff944b3bf8ff5bdc230ae5d

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 138b8f5..bc38cc2 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -466,11 +466,8 @@ static void doc_setPart(LibreOfficeKitDocument* pThis, int nPart)
         return;
     }
 
-    Application::AcquireSolarMutex(1);
-    {
-        pDoc->setPart( nPart );
-    }
-    Application::ReleaseSolarMutex();
+    SolarMutexGuard aGuard;
+    pDoc->setPart( nPart );
 }
 
 static char* doc_getPartName(LibreOfficeKitDocument* pThis, int nPart)
@@ -504,31 +501,29 @@ static void doc_setPartMode(LibreOfficeKitDocument* pThis,
         return;
     }
 
-    Application::AcquireSolarMutex(1);
+    SolarMutexGuard aGuard;
+
+    int nCurrentPart = pDoc->getPart();
+
+    pDoc->setPartMode(ePartMode);
+
+    // We need to make sure the internal state is updated, just changing the mode
+    // might not update the relevant shells (i.e. impress will keep rendering the
+    // previous mode unless we do this).
+    // TODO: we might want to do this within the relevant components rather than
+    // here, but that's also dependent on how we implement embedded object
+    // rendering I guess?
+    // TODO: we could be clever and e.g. set to 0 when we change to/from
+    // embedded object mode, and not when changing between slide/notes/combined
+    // modes?
+    if ( nCurrentPart < pDoc->getParts() )
     {
-        int nCurrentPart = pDoc->getPart();
-
-        pDoc->setPartMode(ePartMode);
-
-        // We need to make sure the internal state is updated, just changing the mode
-        // might not update the relevant shells (i.e. impress will keep rendering the
-        // previous mode unless we do this).
-        // TODO: we might want to do this within the relevant components rather than
-        // here, but that's also dependent on how we implement embedded object
-        // rendering I guess?
-        // TODO: we could be clever and e.g. set to 0 when we change to/from
-        // embedded object mode, and not when changing between slide/notes/combined
-        // modes?
-        if ( nCurrentPart < pDoc->getParts() )
-        {
-            pDoc->setPart( nCurrentPart );
-        }
-        else
-        {
-            pDoc->setPart( 0 );
-        }
+        pDoc->setPart( nCurrentPart );
+    }
+    else
+    {
+        pDoc->setPart( 0 );
     }
-    Application::ReleaseSolarMutex();
 }
 
 void doc_paintTile (LibreOfficeKitDocument* pThis,
@@ -550,38 +545,36 @@ void doc_paintTile (LibreOfficeKitDocument* pThis,
         return;
     }
 
-    Application::AcquireSolarMutex(1);
-    {
+    SolarMutexGuard aGuard;
+
 #if defined(UNX) && !defined(MACOSX) && !defined(ENABLE_HEADLESS)
-        ImplSVData* pSVData = ImplGetSVData();
-        SvpSalInstance* pSalInstance = static_cast< SvpSalInstance* >(pSVData->mpDefInst);
-        pSalInstance->setBitCountFormatMapping( 32, ::basebmp::FORMAT_THIRTYTWO_BIT_TC_MASK_RGBA );
+    ImplSVData* pSVData = ImplGetSVData();
+    SvpSalInstance* pSalInstance = static_cast< SvpSalInstance* >(pSVData->mpDefInst);
+    pSalInstance->setBitCountFormatMapping( 32, ::basebmp::FORMAT_THIRTYTWO_BIT_TC_MASK_RGBA );
 
-        VirtualDevice aDevice(0, (sal_uInt16)32);
-        boost::shared_array< sal_uInt8 > aBuffer( pBuffer, NoDelete< sal_uInt8 >() );
-        aDevice.SetOutputSizePixelScaleOffsetAndBuffer(
-                    Size(nCanvasWidth, nCanvasHeight), Fraction(1.0), Point(),
-                    aBuffer, true );
+    VirtualDevice aDevice(0, (sal_uInt16)32);
+    boost::shared_array< sal_uInt8 > aBuffer( pBuffer, NoDelete< sal_uInt8 >() );
+    aDevice.SetOutputSizePixelScaleOffsetAndBuffer(
+                Size(nCanvasWidth, nCanvasHeight), Fraction(1.0), Point(),
+                aBuffer, true );
 
-        pDoc->paintTile(aDevice, nCanvasWidth, nCanvasHeight,
-                        nTilePosX, nTilePosY, nTileWidth, nTileHeight);
+    pDoc->paintTile(aDevice, nCanvasWidth, nCanvasHeight,
+                    nTilePosX, nTilePosY, nTileWidth, nTileHeight);
 
-        SvpSalVirtualDevice* pSalDev = static_cast< SvpSalVirtualDevice* >(aDevice.getSalVirtualDevice());
-        basebmp::BitmapDeviceSharedPtr pBmpDev = pSalDev->getBitmapDevice();
+    SvpSalVirtualDevice* pSalDev = static_cast< SvpSalVirtualDevice* >(aDevice.getSalVirtualDevice());
+    basebmp::BitmapDeviceSharedPtr pBmpDev = pSalDev->getBitmapDevice();
 
-        *pRowStride = pBmpDev->getScanlineStride();
+    *pRowStride = pBmpDev->getScanlineStride();
 #else
-        (void) pBuffer;
-        (void) nCanvasWidth;
-        (void) nCanvasHeight;
-        (void) pRowStride;
-        (void) nTilePosX;
-        (void) nTilePosY;
-        (void) nTileWidth;
-        (void) nTileHeight;
+    (void) pBuffer;
+    (void) nCanvasWidth;
+    (void) nCanvasHeight;
+    (void) pRowStride;
+    (void) nTilePosX;
+    (void) nTilePosY;
+    (void) nTileWidth;
+    (void) nTileHeight;
 #endif
-    }
-    Application::ReleaseSolarMutex();
 }
 
 static void doc_getDocumentSize(LibreOfficeKitDocument* pThis,


More information about the Libreoffice-commits mailing list