Kaydet (Commit) eb5c0ccd authored tarafından Vasily Melenchuk's avatar Vasily Melenchuk Kaydeden (comit) Thorsten Behrens

Unittests for bugs with 1bit images rendering problems

Fix was done in 25cd8436 and has
impact on tdf104141, tdf113918, tdf115297 and some others.

Change-Id: I8868dc1463b6f30b871a4f1b3129657f5bcb38f3
Reviewed-on: https://gerrit.libreoffice.org/51855Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarThorsten Behrens <Thorsten.Behrens@CIB.de>
üst 0fab443f
# -*- 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:
......@@ -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 \
))
......
/* -*- 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: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment