From 74eb70f957c28aa3fd3de0f215f31310608ab562 Mon Sep 17 00:00:00 2001 From: Andrzej Hunt Date: Fri, 11 Jul 2014 10:23:15 +0200 Subject: 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 --- .../CppunitTest_libreofficekit_tiledrendering.mk | 3 ++- libreofficekit/qa/unit/tiledrendering.cxx | 25 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) (limited to 'libreofficekit') 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 #include +#include +#include +#include +#include #define LOK_USE_UNSTABLE_API #include @@ -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 -- cgit