diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2016-06-07 18:07:43 +0900 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2017-01-03 13:23:30 +0000 |
commit | 441e79dc9e7a1ef8db30ed6a8dc0a5872ff3bf4b (patch) | |
tree | d8622a19ce9b62af6c6804b012c7789c445a8b15 /sd | |
parent | 28e1680182666c13599b744efca8e0ebd08706d5 (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
(cherry picked from commit f08e1630ae56e6f3335a11020e6d2c33c4ce2863)
Reviewed-on: https://gerrit.libreoffice.org/32692
Reviewed-by: Michael Stahl <mstahl@redhat.com>
Tested-by: Jenkins <ci@libreoffice.org>
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 b639c196207f..0defbc46ae08 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -1310,18 +1310,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(); } |