diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2016-06-07 18:07:43 +0900 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2016-06-07 18:13:09 +0900 |
commit | f08e1630ae56e6f3335a11020e6d2c33c4ce2863 (patch) | |
tree | b9a399cab6f9ab497b3315070e3676acf8e2da84 /sd | |
parent | d8df3ed9dfef931d5384a18f3ac3b1f49ee3200c (diff) |
sd: make test "testTdf93124" more robust
Check that the bitmap ihas been exported and imported correctly
instead of seg. fault.
+ use ScopedReadAccess
Change-Id: Ib79b5beddef5dc4f7c3435bae94c2f6a26f8ac10
Diffstat (limited to 'sd')
-rw-r--r-- | sd/qa/unit/import-tests.cxx | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx index b5994967bfc5..4ed7d43bb437 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -1297,18 +1297,25 @@ void SdImportTest::testTdf93124() SvFileStream aFileStream(aTempFile.GetURL(), StreamMode::READ); vcl::PNGReader aPNGReader(aFileStream); BitmapEx aBMPEx = aPNGReader.Read(); + + // make sure the bitmap is not empty and correct size (PNG export->import was successful) + CPPUNIT_ASSERT_EQUAL(Size(320, 180), aBMPEx.GetSizePixel()); Bitmap aBMP = aBMPEx.GetBitmap(); - BitmapReadAccess* pRead = aBMP.AcquireReadAccess(); - int nNonWhiteCount = 0; - // The word "Top" should be in rectangle 34,4 - 76,30. If text alignment is wrong, the rectangle will be white. - for (long nX = 34; nX < (34 + 43); ++nX) + { + Bitmap::ScopedReadAccess pReadAccess(aBMP); + int nNonWhiteCount = 0; + // The word "Top" should be in rectangle 34,4 - 76,30. If text alignment is wrong, the rectangle will be white. for (long nY = 4; nY < (4 + 26); ++nY) { - const Color aColor = pRead->GetColor(nY, nX); - if ((aColor.GetRed() != 0xff) || (aColor.GetGreen() != 0xff) || (aColor.GetBlue() != 0xff)) - ++nNonWhiteCount; + for (long nX = 34; nX < (34 + 43); ++nX) + { + const Color aColor = pReadAccess->GetColor(nY, nX); + if ((aColor.GetRed() != 0xff) || (aColor.GetGreen() != 0xff) || (aColor.GetBlue() != 0xff)) + ++nNonWhiteCount; + } } - CPPUNIT_ASSERT_MESSAGE("Tdf93124: vertical alignment of text is incorrect!", nNonWhiteCount>100); + CPPUNIT_ASSERT_MESSAGE("Tdf93124: vertical alignment of text is incorrect!", nNonWhiteCount>100); + } xDocShRef->DoClose(); } |