calc: on editing invalidation of view with different zoom is wrong
[LibreOffice.git] / vcl / qa / cppunit / XpmFilterTest.cxx
blob1c24de1e131ec9d93431f7adbf0d1b12fad949c2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include <test/bootstrapfixture.hxx>
12 #include <vcl/bitmapex.hxx>
13 #include <tools/stream.hxx>
14 #include <filter/XpmReader.hxx>
15 #include <unotools/tempfile.hxx>
17 class XpmFilterTest : public test::BootstrapFixture
19 public:
20 OUString maDataUrl;
21 OUString getFullUrl(std::u16string_view sFileName)
23 return m_directories.getURLFromSrc(maDataUrl) + sFileName;
25 XpmFilterTest()
26 : maDataUrl(u"/vcl/qa/cppunit/data/")
31 CPPUNIT_TEST_FIXTURE(XpmFilterTest, testXPM_8bit)
33 SvFileStream aFileStream(getFullUrl(u"XPM_8.xpm"), StreamMode::READ);
34 Graphic aGraphic;
35 CPPUNIT_ASSERT(ImportXPM(aFileStream, aGraphic));
36 auto aBitmap = aGraphic.GetBitmapEx();
37 CPPUNIT_ASSERT_EQUAL(tools::Long(4), aBitmap.GetSizePixel().Width());
38 CPPUNIT_ASSERT_EQUAL(tools::Long(4), aBitmap.GetSizePixel().Height());
39 CPPUNIT_ASSERT_EQUAL(vcl::PixelFormat::N8_BPP, aBitmap.getPixelFormat());
40 CPPUNIT_ASSERT_EQUAL(COL_LIGHTBLUE, aBitmap.GetPixelColor(0, 0));
41 CPPUNIT_ASSERT_EQUAL(COL_LIGHTRED, aBitmap.GetPixelColor(2, 0));
42 CPPUNIT_ASSERT_EQUAL(COL_YELLOW, aBitmap.GetPixelColor(0, 2));
43 CPPUNIT_ASSERT_EQUAL(COL_LIGHTGREEN, aBitmap.GetPixelColor(2, 2));
46 CPPUNIT_TEST_FIXTURE(XpmFilterTest, testXPM_4bit)
48 SvFileStream aFileStream(getFullUrl(u"XPM_4.xpm"), StreamMode::READ);
49 Graphic aGraphic;
50 CPPUNIT_ASSERT(ImportXPM(aFileStream, aGraphic));
51 auto aBitmap = aGraphic.GetBitmapEx();
52 CPPUNIT_ASSERT_EQUAL(tools::Long(4), aBitmap.GetSizePixel().Width());
53 CPPUNIT_ASSERT_EQUAL(tools::Long(4), aBitmap.GetSizePixel().Height());
54 CPPUNIT_ASSERT_EQUAL(vcl::PixelFormat::N8_BPP, aBitmap.getPixelFormat());
55 CPPUNIT_ASSERT_EQUAL(COL_LIGHTBLUE, aBitmap.GetPixelColor(0, 0));
56 CPPUNIT_ASSERT_EQUAL(COL_LIGHTRED, aBitmap.GetPixelColor(2, 0));
57 CPPUNIT_ASSERT_EQUAL(COL_YELLOW, aBitmap.GetPixelColor(0, 2));
58 CPPUNIT_ASSERT_EQUAL(COL_LIGHTGREEN, aBitmap.GetPixelColor(2, 2));
61 CPPUNIT_TEST_FIXTURE(XpmFilterTest, testXPM_1bit)
63 SvFileStream aFileStream(getFullUrl(u"XPM_1.xpm"), StreamMode::READ);
64 Graphic aGraphic;
65 CPPUNIT_ASSERT(ImportXPM(aFileStream, aGraphic));
66 auto aBitmap = aGraphic.GetBitmapEx();
67 CPPUNIT_ASSERT_EQUAL(tools::Long(10), aBitmap.GetSizePixel().Width());
68 CPPUNIT_ASSERT_EQUAL(tools::Long(10), aBitmap.GetSizePixel().Height());
69 CPPUNIT_ASSERT_EQUAL(vcl::PixelFormat::N1_BPP, aBitmap.getPixelFormat());
70 CPPUNIT_ASSERT_EQUAL(Color(0xffffff), aBitmap.GetPixelColor(0, 0));
71 CPPUNIT_ASSERT_EQUAL(Color(0x72d1c8), aBitmap.GetPixelColor(1, 1));
72 CPPUNIT_ASSERT_EQUAL(Color(0x72d1c8), aBitmap.GetPixelColor(8, 8));
73 CPPUNIT_ASSERT_EQUAL(Color(0xffffff), aBitmap.GetPixelColor(9, 9));
76 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */