libreofficekit/CppunitTest_libreofficekit_tiledrendering.mk |    3 -
 libreofficekit/qa/unit/tiledrendering.cxx                   |   33 ++++++++++++
 2 files changed, 35 insertions(+), 1 deletion(-)

New commits:
commit 8ab7cbe751a1b643a2a72f06da2c8d7b9a3a3b31
Author: Andrzej Hunt <andrzej.h...@collabora.com>
Date:   Thu Jul 17 20:20:24 2014 +0200

    libreofficekit_tiledrendering test: force lock file removal
    
    If the lock file still exists when running this test, LOK will fail
    resulting in "documentLoad failed: unknown load failure"
    (the actual error is that the lock file dialog cannot be confirmed
     by the user in headless mode, resulting in loading failure, however
     this is then hidden by multiple layers of exception redirection
     in sfx2).
    
    Change-Id: I025ea6187c3d17805f25ab6f756eae9646f2c7c8

diff --git a/libreofficekit/qa/unit/tiledrendering.cxx 
b/libreofficekit/qa/unit/tiledrendering.cxx
index dbe5b52..cec35ed 100644
--- a/libreofficekit/qa/unit/tiledrendering.cxx
+++ b/libreofficekit/qa/unit/tiledrendering.cxx
@@ -14,6 +14,7 @@
 #include <cppunit/extensions/HelperMacros.h>
 #include <cstdlib>
 #include <string>
+#include <stdio.h>
 
 #include <sal/types.h>
 #include <tools/stream.hxx>
@@ -66,6 +67,13 @@ void TiledRenderingTest::testOverlay()
     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#";
+
+    // 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< Office > pOffice( lok_cpp_init(
                                       sLOPath.c_str() ) );
commit 74eb70f957c28aa3fd3de0f215f31310608ab562
Author: Andrzej Hunt <andrzej.h...@collabora.com>
Date:   Fri Jul 11 10:23:15 2014 +0200

    Add png dumping to LOK tiled rendering test.
    
    This allows for easier visual comparisons (i.e. currently the test
    would be failing for some tiles).
    
    Change-Id: I5b174375b57ffe0edd2700fdec411a83669e4a34

diff --git a/libreofficekit/CppunitTest_libreofficekit_tiledrendering.mk 
b/libreofficekit/CppunitTest_libreofficekit_tiledrendering.mk
index 3c41c0a..4b77fbf 100644
--- a/libreofficekit/CppunitTest_libreofficekit_tiledrendering.mk
+++ b/libreofficekit/CppunitTest_libreofficekit_tiledrendering.mk
@@ -21,9 +21,10 @@ $(eval $(call 
gb_CppunitTest_use_external,libreofficekit_tiledrendering,boost_he
 # our test specifically tests LOK only functionality which would otherwise not
 # require any normal LO api/libraries.
 $(eval $(call gb_CppunitTest_use_libraries,libreofficekit_tiledrendering, \
-       test \
        cppu \
        sal \
+       tl \
+       test \
        vcl \
        $(gb_UWINAPI) \
 ))
diff --git a/libreofficekit/qa/unit/tiledrendering.cxx 
b/libreofficekit/qa/unit/tiledrendering.cxx
index 67fa62e..dbe5b52 100644
--- a/libreofficekit/qa/unit/tiledrendering.cxx
+++ b/libreofficekit/qa/unit/tiledrendering.cxx
@@ -16,6 +16,10 @@
 #include <string>
 
 #include <sal/types.h>
+#include <tools/stream.hxx>
+#include <vcl/salbtype.hxx>
+#include <vcl/bmpacc.hxx>
+#include <vcl/pngwrite.hxx>
 
 #define LOK_USE_UNSTABLE_API
 #include <LibreOfficeKit/LibreOfficeKit.hxx>
@@ -39,6 +43,23 @@ public:
     CPPUNIT_TEST_SUITE_END();
 };
 
+// Our dumped .png files end up in
+// workdir/CppunitTest/libreofficekit_tiledrendering.test.core
+
+static void dumpRGBABitmap( const OUString& rPath, const unsigned char* 
pBuffer,
+                            const int nWidth, const int nHeight )
+{
+    Bitmap aBitmap( Size( nWidth, nHeight ), 32 );
+    Bitmap::ScopedWriteAccess pWriteAccess( aBitmap );
+    memcpy( pWriteAccess->GetBuffer(), pBuffer, 4*nWidth*nHeight );
+
+    BitmapEx aBitmapEx( aBitmap );
+    vcl::PNGWriter aWriter( aBitmapEx );
+    SvFileStream sOutput( rPath, STREAM_WRITE );
+    aWriter.Write( sOutput );
+    sOutput.Close();
+}
+
 void TiledRenderingTest::testOverlay()
 {
     const string sSrcRoot = getenv( "SRC_ROOT" );
@@ -82,6 +103,8 @@ void TiledRenderingTest::testOverlay()
     pDocument->paintTile( pLarge.get(),  nTotalWidthPix, nTotalHeightPix, 
&nRowStride,
                           0, 0,
                           nTotalWidthDoc, nTotalHeightDoc );
+    dumpRGBABitmap( "large.png", pLarge.get(), nTotalWidthPix, nTotalHeightPix 
);
+
     scoped_array< unsigned char > pSmall[4];
     for ( int i = 0; i < 4; i++ )
     {
@@ -90,6 +113,8 @@ void TiledRenderingTest::testOverlay()
                               // Tile 0/2: left. Tile 1/3: right. Tile 0/1: 
top. Tile 2/3: bottom
                               ((i%2 == 0) ?  0 : nTotalWidthDoc / 2), ((i < 2 
) ? 0 : nTotalHeightDoc / 2),
                               nTotalWidthDoc / 2, nTotalHeightDoc / 2);
+        dumpRGBABitmap( "small_" + OUString::number(i) + ".png",
+                        pSmall[i].get(), nTotalWidthPix/2, nTotalHeightPix/2 );
     }
 
     // Iterate over each pixel of the sub-tile, and compare that pixel for 
every
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to