[Libreoffice-commits] core.git: vcl/qa

Luboš Luňák (via logerrit) logerrit at kemper.freedesktop.org
Wed Mar 24 20:10:44 UTC 2021


 vcl/qa/cppunit/skia/skia.cxx |   23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

New commits:
commit b9eca45f56bbb8bf0acf25469e9f5a9918584e4e
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Wed Mar 24 15:22:16 2021 +0100
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Wed Mar 24 21:09:55 2021 +0100

    add a unittest for tdf#132367
    
    Change-Id: I7f694cd830f3aaf7a41fde66c896e6510f2d92e3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113043
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lunak at collabora.com>

diff --git a/vcl/qa/cppunit/skia/skia.cxx b/vcl/qa/cppunit/skia/skia.cxx
index 6ed0b884955d..2ca53bbdc2a9 100644
--- a/vcl/qa/cppunit/skia/skia.cxx
+++ b/vcl/qa/cppunit/skia/skia.cxx
@@ -44,6 +44,7 @@ public:
     void testDelayedScale();
     void testTdf137329();
     void testTdf140848();
+    void testTdf132367();
 
     CPPUNIT_TEST_SUITE(SkiaTest);
     CPPUNIT_TEST(testBitmapErase);
@@ -55,6 +56,7 @@ public:
     CPPUNIT_TEST(testDelayedScale);
     CPPUNIT_TEST(testTdf137329);
     CPPUNIT_TEST(testTdf140848);
+    CPPUNIT_TEST(testTdf132367);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -425,6 +427,27 @@ void SkiaTest::testTdf140848()
     CPPUNIT_ASSERT_EQUAL(COL_WHITE, device->GetPixel(Point(1200, 100)));
 }
 
+void SkiaTest::testTdf132367()
+{
+    if (!SkiaHelper::isVCLSkiaEnabled())
+        return;
+    ScopedVclPtr<VirtualDevice> device = VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT);
+    device->SetOutputSizePixel(Size(2, 2));
+    device->SetBackground(Wallpaper(COL_BLACK));
+    device->Erase();
+    device->DrawPixel(Point(1, 1), COL_WHITE);
+    // This will make the bitmap store data in SkImage.
+    Bitmap bitmap = device->GetBitmap(Point(0, 0), Size(2, 2));
+    // Scaling will only set up delayed scaling of the SkImage.
+    bitmap.Scale(Size(4, 4), BmpScaleFlag::NearestNeighbor);
+    // Now it will need to be converted to pixel buffer, check it's converted properly
+    // from the SkImage.
+    BitmapReadAccess access(bitmap);
+    CPPUNIT_ASSERT_EQUAL(tools::Long(4), access.Width());
+    CPPUNIT_ASSERT_EQUAL(tools::Long(4), access.Height());
+    CPPUNIT_ASSERT_EQUAL(BitmapColor(COL_WHITE), access.GetColor(3, 3));
+}
+
 } // namespace
 
 CPPUNIT_TEST_SUITE_REGISTRATION(SkiaTest);


More information about the Libreoffice-commits mailing list