vcl/CppunitTest_vcl_bitmap_render_test.mk | 43 ++++++++++ vcl/Module_vcl.mk | 3 vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx | 96 +++++++++++++++++++++++ vcl/qa/cppunit/bitmaprender/data/tdf104141.gif |binary vcl/qa/cppunit/bitmaprender/data/tdf113918.png |binary 5 files changed, 141 insertions(+), 1 deletion(-)
New commits: commit eb5c0ccd47330fc726f4b4f854cf4cc518ac21cd Author: Vasily Melenchuk <[email protected]> Date: Mon Mar 26 10:57:59 2018 +0300 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 <[email protected]> Reviewed-by: Thorsten Behrens <[email protected]> diff --git a/vcl/CppunitTest_vcl_bitmap_render_test.mk b/vcl/CppunitTest_vcl_bitmap_render_test.mk new file mode 100644 index 000000000000..1d66e6a5aae4 --- /dev/null +++ b/vcl/CppunitTest_vcl_bitmap_render_test.mk @@ -0,0 +1,43 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# 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/. +# + +$(eval $(call gb_CppunitTest_CppunitTest,vcl_bitmap_render_test)) + +$(eval $(call gb_CppunitTest_add_exception_objects,vcl_bitmap_render_test, \ + vcl/qa/cppunit/bitmaprender/BitmapRenderTest \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,vcl_bitmap_render_test, \ + comphelper \ + cppu \ + cppuhelper \ + sal \ + svt \ + test \ + tl \ + unotest \ + vcl \ +)) + +$(eval $(call gb_CppunitTest_use_sdk_api,vcl_bitmap_render_test)) + +$(eval $(call gb_CppunitTest_use_ure,vcl_bitmap_render_test)) +$(eval $(call gb_CppunitTest_use_vcl,vcl_bitmap_render_test)) + +$(eval $(call gb_CppunitTest_use_externals,vcl_bitmap_render_test,boost_headers)) + +$(eval $(call gb_CppunitTest_use_components,vcl_bitmap_render_test,\ + configmgr/source/configmgr \ + i18npool/util/i18npool \ + ucb/source/core/ucb1 \ +)) + +$(eval $(call gb_CppunitTest_use_configuration,vcl_bitmap_render_test)) + +# vim: set noet sw=4 ts=4: diff --git a/vcl/Module_vcl.mk b/vcl/Module_vcl.mk index 59e5b9c2045f..bfd6bdf09c8e 100644 --- a/vcl/Module_vcl.mk +++ b/vcl/Module_vcl.mk @@ -191,7 +191,8 @@ $(eval $(call gb_Module_add_check_targets,vcl,\ CppunitTest_vcl_jpeg_read_write_test \ CppunitTest_vcl_svm_test \ CppunitTest_vcl_pdfexport \ - CppunitTest_vcl_errorhandler \ + CppunitTest_vcl_errorhandler \ + CppunitTest_vcl_bitmap_render_test \ )) 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 new file mode 100644 index 000000000000..d6390fdaa3c9 Binary files /dev/null and b/vcl/qa/cppunit/bitmaprender/data/tdf104141.gif differ diff --git a/vcl/qa/cppunit/bitmaprender/data/tdf113918.png b/vcl/qa/cppunit/bitmaprender/data/tdf113918.png new file mode 100644 index 000000000000..dd49897d99ff Binary files /dev/null and b/vcl/qa/cppunit/bitmaprender/data/tdf113918.png differ _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
