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

Chris Sherlock (via logerrit) logerrit at kemper.freedesktop.org
Thu Oct 7 14:56:32 UTC 2021


 vcl/qa/cppunit/outdev.cxx |   55 +++++++++++++++++++++++++++++++++++++---------
 1 file changed, 45 insertions(+), 10 deletions(-)

New commits:
commit d7358047d9bcee8368a940bfb75b41fb65f87514
Author:     Chris Sherlock <chris.sherlock79 at gmail.com>
AuthorDate: Thu Sep 30 20:26:26 2021 +1000
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Thu Oct 7 16:55:57 2021 +0200

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

diff --git a/vcl/qa/cppunit/outdev.cxx b/vcl/qa/cppunit/outdev.cxx
index ca3b1d0a11be..351392362ed6 100644
--- a/vcl/qa/cppunit/outdev.cxx
+++ b/vcl/qa/cppunit/outdev.cxx
@@ -23,6 +23,8 @@
 #include <bufferdevice.hxx>
 #include <window.h>
 
+const size_t INITIAL_SETUP_ACTION_COUNT = 5;
+
 class VclOutdevTest : public test::BootstrapFixture
 {
 public:
@@ -68,6 +70,7 @@ public:
     void testSystemTextColor();
     void testShouldDrawWavePixelAsRect();
     void testGetWaveLineSize();
+    void testErase();
     void testDrawPixel();
     void testDrawLine();
     void testDrawRect();
@@ -114,6 +117,7 @@ public:
     CPPUNIT_TEST(testSystemTextColor);
     CPPUNIT_TEST(testShouldDrawWavePixelAsRect);
     CPPUNIT_TEST(testGetWaveLineSize);
+    CPPUNIT_TEST(testErase);
     CPPUNIT_TEST(testDrawPixel);
     CPPUNIT_TEST(testDrawLine);
     CPPUNIT_TEST(testDrawRect);
@@ -1037,6 +1041,36 @@ void VclOutdevTest::testGetWaveLineSize()
     }
 }
 
+void VclOutdevTest::testErase()
+{
+    ScopedVclPtrInstance<VirtualDevice> pVDev;
+    GDIMetaFile aMtf;
+    aMtf.Record(pVDev.get());
+
+    // this actually triggers Erase()
+    pVDev->SetOutputSizePixel(Size(1, 1));
+    pVDev->Erase();
+
+    MetaAction* pAction = aMtf.GetAction(INITIAL_SETUP_ACTION_COUNT);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a line color action (start)", MetaActionType::LINECOLOR,
+                                 pAction->GetType());
+
+    pAction = aMtf.GetAction(1);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a fill color action (start)", MetaActionType::FILLCOLOR,
+                                 pAction->GetType());
+
+    pAction = aMtf.GetAction(2);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a rect action", MetaActionType::RECT, pAction->GetType());
+
+    pAction = aMtf.GetAction(3);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a line color action (end)", MetaActionType::LINECOLOR,
+                                 pAction->GetType());
+
+    pAction = aMtf.GetAction(4);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a fill color action (end)", MetaActionType::FILLCOLOR,
+                                 pAction->GetType());
+}
+
 void VclOutdevTest::testDrawPixel()
 {
     {
@@ -1044,13 +1078,14 @@ void VclOutdevTest::testDrawPixel()
         GDIMetaFile aMtf;
         aMtf.Record(pVDev.get());
 
+        // triggers an Erase()
         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);
+        MetaAction* pAction = aMtf.GetAction(INITIAL_SETUP_ACTION_COUNT + 1);
         CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a pixel action", MetaActionType::PIXEL,
                                      pAction->GetType());
         MetaPixelAction* pPixelAction = dynamic_cast<MetaPixelAction*>(pAction);
@@ -1071,7 +1106,7 @@ void VclOutdevTest::testDrawPixel()
 
         CPPUNIT_ASSERT_EQUAL_MESSAGE("Color not red", COL_RED, pVDev->GetPixel(Point(0, 0)));
 
-        MetaAction* pAction = aMtf.GetAction(aMtf.GetActionSize() - 1);
+        MetaAction* pAction = aMtf.GetAction(INITIAL_SETUP_ACTION_COUNT + 1);
         CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a point action", MetaActionType::POINT,
                                      pAction->GetType());
         MetaPointAction* pPointAction = dynamic_cast<MetaPointAction*>(pAction);
@@ -1090,7 +1125,7 @@ void VclOutdevTest::testDrawLine()
         pVDev->SetOutputSizePixel(Size(1, 100));
         pVDev->DrawLine(Point(0, 0), Point(0, 50));
 
-        MetaAction* pAction = aMtf.GetAction(aMtf.GetActionSize() - 1);
+        MetaAction* pAction = aMtf.GetAction(INITIAL_SETUP_ACTION_COUNT);
         CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a line action", MetaActionType::LINE, pAction->GetType());
         MetaLineAction* pLineAction = dynamic_cast<MetaLineAction*>(pAction);
         CPPUNIT_ASSERT_EQUAL_MESSAGE("Line start has incorrect position", Point(0, 0),
@@ -1115,7 +1150,7 @@ void VclOutdevTest::testDrawLine()
         pVDev->SetOutputSizePixel(Size(1, 100));
         pVDev->DrawLine(Point(0, 0), Point(0, 50), aLineInfo);
 
-        MetaAction* pAction = aMtf.GetAction(aMtf.GetActionSize() - 1);
+        MetaAction* pAction = aMtf.GetAction(INITIAL_SETUP_ACTION_COUNT);
         CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a line action", MetaActionType::LINE, pAction->GetType());
         MetaLineAction* pLineAction = dynamic_cast<MetaLineAction*>(pAction);
         CPPUNIT_ASSERT_EQUAL_MESSAGE("Line start has incorrect position", Point(0, 0),
@@ -1147,7 +1182,7 @@ void VclOutdevTest::testDrawRect()
         pVDev->SetOutputSizePixel(Size(1, 100));
         pVDev->DrawRect(tools::Rectangle(Point(0, 0), Size(50, 60)));
 
-        MetaAction* pAction = aMtf.GetAction(aMtf.GetActionSize() - 1);
+        MetaAction* pAction = aMtf.GetAction(INITIAL_SETUP_ACTION_COUNT);
         CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a rect action", MetaActionType::RECT, pAction->GetType());
         MetaRectAction* pRectAction = dynamic_cast<MetaRectAction*>(pAction);
         CPPUNIT_ASSERT_EQUAL_MESSAGE("Rectangle wrong", tools::Rectangle(Point(0, 0), Size(50, 60)),
@@ -1162,7 +1197,7 @@ void VclOutdevTest::testDrawRect()
         pVDev->SetOutputSizePixel(Size(1, 100));
         pVDev->DrawRect(tools::Rectangle(Point(0, 0), Size(50, 60)), 5, 10);
 
-        MetaAction* pAction = aMtf.GetAction(aMtf.GetActionSize() - 1);
+        MetaAction* pAction = aMtf.GetAction(INITIAL_SETUP_ACTION_COUNT);
         CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a rect action", MetaActionType::ROUNDRECT,
                                      pAction->GetType());
         MetaRoundRectAction* pRectAction = dynamic_cast<MetaRoundRectAction*>(pAction);
@@ -1184,7 +1219,7 @@ void VclOutdevTest::testDrawEllipse()
     pVDev->SetOutputSizePixel(Size(1, 100));
     pVDev->DrawEllipse(tools::Rectangle(Point(0, 0), Size(50, 60)));
 
-    MetaAction* pAction = aMtf.GetAction(aMtf.GetActionSize() - 1);
+    MetaAction* pAction = aMtf.GetAction(INITIAL_SETUP_ACTION_COUNT);
     CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a ellipse action", MetaActionType::ELLIPSE,
                                  pAction->GetType());
     MetaEllipseAction* pEllipseAction = dynamic_cast<MetaEllipseAction*>(pAction);
@@ -1203,7 +1238,7 @@ void VclOutdevTest::testDrawPie()
     pVDev->SetOutputSizePixel(Size(1, 100));
     pVDev->DrawPie(aRect, aRect.TopRight(), aRect.TopCenter());
 
-    MetaAction* pAction = aMtf.GetAction(aMtf.GetActionSize() - 1);
+    MetaAction* pAction = aMtf.GetAction(INITIAL_SETUP_ACTION_COUNT);
     CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a pie action", MetaActionType::PIE, pAction->GetType());
     MetaPieAction* pPieAction = dynamic_cast<MetaPieAction*>(pAction);
     CPPUNIT_ASSERT_EQUAL_MESSAGE("Pie rect wrong", aRect, pPieAction->GetRect());
@@ -1223,7 +1258,7 @@ void VclOutdevTest::testDrawChord()
     pVDev->SetOutputSizePixel(Size(1, 100));
     pVDev->DrawChord(aRect, Point(30, 31), Point(32, 33));
 
-    MetaAction* pAction = aMtf.GetAction(aMtf.GetActionSize() - 1);
+    MetaAction* pAction = aMtf.GetAction(INITIAL_SETUP_ACTION_COUNT);
     CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a chord action", MetaActionType::CHORD, pAction->GetType());
     MetaChordAction* pChordAction = dynamic_cast<MetaChordAction*>(pAction);
     CPPUNIT_ASSERT_EQUAL_MESSAGE("Chord rect wrong", aRect, pChordAction->GetRect());
@@ -1244,7 +1279,7 @@ void VclOutdevTest::testDrawArc()
     pVDev->SetOutputSizePixel(Size(1, 100));
     pVDev->DrawArc(aRect, Point(10, 11), Point(12, 13));
 
-    MetaAction* pAction = aMtf.GetAction(aMtf.GetActionSize() - 1);
+    MetaAction* pAction = aMtf.GetAction(INITIAL_SETUP_ACTION_COUNT);
     CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a arc action", MetaActionType::ARC, pAction->GetType());
     MetaArcAction* pArcAction = dynamic_cast<MetaArcAction*>(pAction);
     CPPUNIT_ASSERT_EQUAL_MESSAGE("Arc rect wrong", aRect, pArcAction->GetRect());


More information about the Libreoffice-commits mailing list