summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorChris Sherlock <chris.sherlock79@gmail.com>2021-09-29 16:17:40 +1000
committerTomaž Vajngerl <quikee@gmail.com>2021-10-06 14:04:12 +0200
commitd4b68f063cbb3c490e1ad084c3f9eb30c6a8c93a (patch)
tree9b1983f962e243ab4f1242d152d6febc792dae60 /vcl
parent4fb0d442316e914d3a75e317d6756d95b920a3e1 (diff)
vcl: test OutputDevice::DrawLine()
Change-Id: I17691623e28a75080a1a46099796ec24bab3b91d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122819 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/qa/cppunit/outdev.cxx65
1 files changed, 63 insertions, 2 deletions
diff --git a/vcl/qa/cppunit/outdev.cxx b/vcl/qa/cppunit/outdev.cxx
index 1c5bfe8d98e2..9a93d8402b95 100644
--- a/vcl/qa/cppunit/outdev.cxx
+++ b/vcl/qa/cppunit/outdev.cxx
@@ -9,6 +9,10 @@
#include <test/bootstrapfixture.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <basegfx/vector/b2enums.hxx>
+
+#include <vcl/lineinfo.hxx>
#include <vcl/print.hxx>
#include <vcl/virdev.hxx>
#include <vcl/window.hxx>
@@ -19,8 +23,6 @@
#include <bufferdevice.hxx>
#include <window.h>
-#include <basegfx/matrix/b2dhommatrix.hxx>
-
class VclOutdevTest : public test::BootstrapFixture
{
public:
@@ -67,6 +69,7 @@ public:
void testShouldDrawWavePixelAsRect();
void testGetWaveLineSize();
void testDrawPixel();
+ void testDrawLine();
CPPUNIT_TEST_SUITE(VclOutdevTest);
CPPUNIT_TEST(testVirtualDevice);
@@ -107,6 +110,7 @@ public:
CPPUNIT_TEST(testShouldDrawWavePixelAsRect);
CPPUNIT_TEST(testGetWaveLineSize);
CPPUNIT_TEST(testDrawPixel);
+ CPPUNIT_TEST(testDrawLine);
CPPUNIT_TEST_SUITE_END();
};
@@ -1066,6 +1070,63 @@ void VclOutdevTest::testDrawPixel()
}
}
+void VclOutdevTest::testDrawLine()
+{
+ {
+ ScopedVclPtrInstance<VirtualDevice> pVDev;
+ GDIMetaFile aMtf;
+ aMtf.Record(pVDev.get());
+
+ pVDev->SetOutputSizePixel(Size(1, 100));
+ pVDev->DrawLine(Point(0, 0), Point(0, 50));
+
+ MetaAction* pAction = aMtf.GetAction(aMtf.GetActionSize() - 1);
+ 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),
+ pLineAction->GetStartPoint());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Line start has incorrect position", Point(0, 50),
+ pLineAction->GetEndPoint());
+ }
+
+ {
+ ScopedVclPtrInstance<VirtualDevice> pVDev;
+ GDIMetaFile aMtf;
+ aMtf.Record(pVDev.get());
+
+ LineInfo aLineInfo(LineStyle::Dash, 10);
+ aLineInfo.SetDashCount(5);
+ aLineInfo.SetDashLen(10);
+ aLineInfo.SetDotCount(3);
+ aLineInfo.SetDotLen(13);
+ aLineInfo.SetDistance(8);
+ aLineInfo.SetLineJoin(basegfx::B2DLineJoin::Bevel);
+
+ pVDev->SetOutputSizePixel(Size(1, 100));
+ pVDev->DrawLine(Point(0, 0), Point(0, 50), aLineInfo);
+
+ MetaAction* pAction = aMtf.GetAction(aMtf.GetActionSize() - 1);
+ 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),
+ pLineAction->GetStartPoint());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Line start has incorrect position", Point(0, 50),
+ pLineAction->GetEndPoint());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Dash count wrong", static_cast<sal_uInt16>(5),
+ pLineAction->GetLineInfo().GetDashCount());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Dash len wrong", static_cast<double>(10),
+ pLineAction->GetLineInfo().GetDashLen());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Dot count wrong", static_cast<sal_uInt16>(3),
+ pLineAction->GetLineInfo().GetDotCount());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Dot len wrong", static_cast<double>(13),
+ pLineAction->GetLineInfo().GetDotLen());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Distance wrong", static_cast<double>(8),
+ pLineAction->GetLineInfo().GetDistance());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Line join", basegfx::B2DLineJoin::Bevel,
+ pLineAction->GetLineInfo().GetLineJoin());
+ }
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(VclOutdevTest);
CPPUNIT_PLUGIN_IMPLEMENT();