diff options
author | Andrzej Hunt <andrzej.hunt@collabora.com> | 2014-07-11 10:23:15 +0200 |
---|---|---|
committer | Andrzej Hunt <andrzej.hunt@collabora.com> | 2014-07-17 20:39:09 +0200 |
commit | 74eb70f957c28aa3fd3de0f215f31310608ab562 (patch) | |
tree | 854e774ea3ac3eb2585159f114d976eeff40dd43 /libreofficekit | |
parent | c003fca9f077958f4c73a80f56634e08c454b4e7 (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')
-rw-r--r-- | libreofficekit/CppunitTest_libreofficekit_tiledrendering.mk | 3 | ||||
-rw-r--r-- | libreofficekit/qa/unit/tiledrendering.cxx | 25 |
2 files changed, 27 insertions, 1 deletions
diff --git a/libreofficekit/CppunitTest_libreofficekit_tiledrendering.mk b/libreofficekit/CppunitTest_libreofficekit_tiledrendering.mk index 3c41c0a811d3..4b77fbf3549d 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 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 |