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

Chris Sherlock (via logerrit) logerrit at kemper.freedesktop.org
Wed Oct 6 12:03:59 UTC 2021


 include/vcl/metaact.hxx   |    2 +-
 vcl/qa/cppunit/outdev.cxx |   45 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+), 1 deletion(-)

New commits:
commit 4fb0d442316e914d3a75e317d6756d95b920a3e1
Author:     Chris Sherlock <chris.sherlock79 at gmail.com>
AuthorDate: Wed Sep 29 12:10:24 2021 +1000
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Wed Oct 6 14:03:24 2021 +0200

    vcl: test OutputDevice::DrawPixel()
    
    Change-Id: I82651c6f41f46bb1097a69f3bcddcac2486a5baa
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122794
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/include/vcl/metaact.hxx b/include/vcl/metaact.hxx
index dfdabac2de24..dc14179712e1 100644
--- a/include/vcl/metaact.hxx
+++ b/include/vcl/metaact.hxx
@@ -130,7 +130,7 @@ public:
     void                SetColor(Color rColor) { maColor = rColor; }
 };
 
-class SAL_DLLPUBLIC_RTTI MetaPointAction final : public MetaAction
+class VCL_DLLPUBLIC MetaPointAction final : public MetaAction
 {
 private:
     Point               maPt;
diff --git a/vcl/qa/cppunit/outdev.cxx b/vcl/qa/cppunit/outdev.cxx
index 5bcac7c67f45..1c5bfe8d98e2 100644
--- a/vcl/qa/cppunit/outdev.cxx
+++ b/vcl/qa/cppunit/outdev.cxx
@@ -66,6 +66,7 @@ public:
     void testSystemTextColor();
     void testShouldDrawWavePixelAsRect();
     void testGetWaveLineSize();
+    void testDrawPixel();
 
     CPPUNIT_TEST_SUITE(VclOutdevTest);
     CPPUNIT_TEST(testVirtualDevice);
@@ -105,6 +106,7 @@ public:
     CPPUNIT_TEST(testSystemTextColor);
     CPPUNIT_TEST(testShouldDrawWavePixelAsRect);
     CPPUNIT_TEST(testGetWaveLineSize);
+    CPPUNIT_TEST(testDrawPixel);
     CPPUNIT_TEST_SUITE_END();
 };
 
@@ -1021,6 +1023,49 @@ void VclOutdevTest::testGetWaveLineSize()
     }
 }
 
+void VclOutdevTest::testDrawPixel()
+{
+    {
+        ScopedVclPtrInstance<VirtualDevice> pVDev;
+        GDIMetaFile aMtf;
+        aMtf.Record(pVDev.get());
+
+        pVDev->SetOutputSizePixel(Size(1, 1));
+        pVDev->SetLineColor(COL_RED);
+        pVDev->DrawPixel(Point(0, 0), COL_GREEN);
+
+        CPPUNIT_ASSERT_EQUAL_MESSAGE("Color not green", COL_GREEN, pVDev->GetPixel(Point(0, 0)));
+
+        MetaAction* pAction = aMtf.GetAction(aMtf.GetActionSize() - 1);
+        CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a pixel action", MetaActionType::PIXEL,
+                                     pAction->GetType());
+        MetaPixelAction* pPixelAction = dynamic_cast<MetaPixelAction*>(pAction);
+        CPPUNIT_ASSERT_EQUAL_MESSAGE("Pixel action has incorrect position", Point(0, 0),
+                                     pPixelAction->GetPoint());
+        CPPUNIT_ASSERT_EQUAL_MESSAGE("Pixel action is wrong color", COL_GREEN,
+                                     pPixelAction->GetColor());
+    }
+
+    {
+        ScopedVclPtrInstance<VirtualDevice> pVDev;
+        GDIMetaFile aMtf;
+        aMtf.Record(pVDev.get());
+
+        pVDev->SetOutputSizePixel(Size(1, 1));
+        pVDev->SetLineColor(COL_RED);
+        pVDev->DrawPixel(Point(0, 0));
+
+        CPPUNIT_ASSERT_EQUAL_MESSAGE("Color not red", COL_RED, pVDev->GetPixel(Point(0, 0)));
+
+        MetaAction* pAction = aMtf.GetAction(aMtf.GetActionSize() - 1);
+        CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a point action", MetaActionType::POINT,
+                                     pAction->GetType());
+        MetaPointAction* pPointAction = dynamic_cast<MetaPointAction*>(pAction);
+        CPPUNIT_ASSERT_EQUAL_MESSAGE("Pixel action has incorrect position", Point(0, 0),
+                                     pPointAction->GetPoint());
+    }
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(VclOutdevTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();


More information about the Libreoffice-commits mailing list