diff options
author | Vasily Melenchuk <Vasily.Melenchuk@cib.de> | 2018-03-26 10:57:59 +0300 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2018-04-20 23:58:57 +0200 |
commit | eb5c0ccd47330fc726f4b4f854cf4cc518ac21cd (patch) | |
tree | 07897573e63d83906d8dc48f1721186bc217a65d /vcl/qa | |
parent | 0fab443fc5016d3088e485210a13f121a1ec1ee9 (diff) |
Unittests for bugs with 1bit images rendering problems
Fix was done in 25cd843664919974f0d21ca7a0b02cc43e9eeabb and has
impact on tdf104141, tdf113918, tdf115297 and some others.
Change-Id: I8868dc1463b6f30b871a4f1b3129657f5bcb38f3
Reviewed-on: https://gerrit.libreoffice.org/51855
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'vcl/qa')
-rw-r--r-- | vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx | 96 | ||||
-rw-r--r-- | vcl/qa/cppunit/bitmaprender/data/tdf104141.gif | bin | 0 -> 12205 bytes | |||
-rw-r--r-- | vcl/qa/cppunit/bitmaprender/data/tdf113918.png | bin | 0 -> 20043 bytes |
3 files changed, 96 insertions, 0 deletions
diff --git a/vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx b/vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx new file mode 100644 index 000000000000..2ee32a812d55 --- /dev/null +++ b/vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx @@ -0,0 +1,96 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <unotest/filters-test.hxx> +#include <test/bootstrapfixture.hxx> + +#include <vcl/virdev.hxx> +#include <vcl/salbtype.hxx> +#include <vcl/bitmapaccess.hxx> +#include <vcl/wrkwin.hxx> + +#include <tools/stream.hxx> +#include <vcl/pngwrite.hxx> + +#include <vcl/graphicfilter.hxx> + +class BitmapRenderTest : public test::BootstrapFixture +{ + OUString maDataUrl; + + OUString getFullUrl(const OUString& sFileName) + { + return m_directories.getURLFromSrc(maDataUrl) + sFileName; + } + +public: + BitmapRenderTest() + : BootstrapFixture(true, false) + , maDataUrl("/vcl/qa/cppunit/bitmaprender/data/") + { + } + + void testTdf104141(); + void testTdf113918(); + + CPPUNIT_TEST_SUITE(BitmapRenderTest); + CPPUNIT_TEST(testTdf104141); + CPPUNIT_TEST(testTdf113918); + CPPUNIT_TEST_SUITE_END(); +}; + +void BitmapRenderTest::testTdf104141() +{ + ScopedVclPtrInstance<VirtualDevice> pVDev; + pVDev->SetOutputSizePixel(Size(400, 400)); + pVDev->SetBackground(Wallpaper(COL_GREEN)); + pVDev->Erase(); + + // Load animated GIF and draw it on green background + GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter(); + Graphic aGraphic; + const OUString aURL(getFullUrl("tdf104141.gif")); + SvFileStream aFileStream(aURL, StreamMode::READ); + ErrCode bResult = rFilter.ImportGraphic(aGraphic, aURL, aFileStream); + CPPUNIT_ASSERT_EQUAL(ERRCODE_NONE, bResult); + BitmapEx aBitmap = aGraphic.GetBitmapEx(); + pVDev->DrawBitmapEx(Point(20, 20), aBitmap); + + // Check drawing resuts: ensure that it contains transparent (green) pixels +#if !defined MACOSX //TODO: on Mac colors are drifted, so exact compare fails + CPPUNIT_ASSERT_EQUAL(COL_GREEN, pVDev->GetPixel(Point(21, 21))); +#endif +} + +void BitmapRenderTest::testTdf113918() +{ + ScopedVclPtrInstance<VirtualDevice> pVDev; + pVDev->SetOutputSizePixel(Size(2480, 3508)); + pVDev->SetBackground(Wallpaper(COL_GREEN)); + pVDev->Erase(); + + GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter(); + Graphic aGraphic; + const OUString aURL(getFullUrl("tdf113918.png")); + SvFileStream aFileStream(aURL, StreamMode::READ); + ErrCode bResult = rFilter.ImportGraphic(aGraphic, aURL, aFileStream); + CPPUNIT_ASSERT_EQUAL(ERRCODE_NONE, bResult); + BitmapEx aBitmap = aGraphic.GetBitmapEx(); + pVDev->DrawBitmapEx(Point(0, 0), aBitmap); + + // Ensure that image is drawn with gray color from palette + CPPUNIT_ASSERT_EQUAL(COL_WHITE, pVDev->GetPixel(Point(21, 21))); + CPPUNIT_ASSERT_EQUAL(Color(0x979797), pVDev->GetPixel(Point(1298, 1368))); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(BitmapRenderTest); + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/qa/cppunit/bitmaprender/data/tdf104141.gif b/vcl/qa/cppunit/bitmaprender/data/tdf104141.gif Binary files differnew file mode 100644 index 000000000000..d6390fdaa3c9 --- /dev/null +++ b/vcl/qa/cppunit/bitmaprender/data/tdf104141.gif diff --git a/vcl/qa/cppunit/bitmaprender/data/tdf113918.png b/vcl/qa/cppunit/bitmaprender/data/tdf113918.png Binary files differnew file mode 100644 index 000000000000..dd49897d99ff --- /dev/null +++ b/vcl/qa/cppunit/bitmaprender/data/tdf113918.png |