summaryrefslogtreecommitdiff
path: root/libreofficekit/qa
diff options
context:
space:
mode:
authorAndrzej Hunt <andrzej.hunt@collabora.com>2014-07-11 10:23:15 +0200
committerAndrzej Hunt <andrzej.hunt@collabora.com>2014-07-17 20:39:09 +0200
commit74eb70f957c28aa3fd3de0f215f31310608ab562 (patch)
tree854e774ea3ac3eb2585159f114d976eeff40dd43 /libreofficekit/qa
parentc003fca9f077958f4c73a80f56634e08c454b4e7 (diff)
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
Diffstat (limited to 'libreofficekit/qa')
-rw-r--r--libreofficekit/qa/unit/tiledrendering.cxx25
1 files changed, 25 insertions, 0 deletions
diff --git a/libreofficekit/qa/unit/tiledrendering.cxx b/libreofficekit/qa/unit/tiledrendering.cxx
index 67fa62ef2240..dbe5b52850d6 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