diff options
author | Chris Sherlock <chris.sherlock79@gmail.com> | 2021-10-02 14:42:01 +1000 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2021-10-18 20:22:39 +0200 |
commit | ed92e40aea759d435ec1c05877e6480654a06ab6 (patch) | |
tree | f17c311b0e3af859ad1a4bfa6d08f983ded43153 /vcl | |
parent | 9142d19ddc751e05041471aa1bbeca2f06729522 (diff) |
vcl: test OutputDevice::DrawPolyPolygon()
Change-Id: I166f715489ecff3095ccfb485153629050bfca20
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122977
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/qa/cppunit/outdev.cxx | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/vcl/qa/cppunit/outdev.cxx b/vcl/qa/cppunit/outdev.cxx index 799a7fdc8708..df5d8b2c9bf4 100644 --- a/vcl/qa/cppunit/outdev.cxx +++ b/vcl/qa/cppunit/outdev.cxx @@ -13,6 +13,7 @@ #include <basegfx/matrix/b2dhommatrix.hxx> #include <basegfx/numeric/ftools.hxx> #include <basegfx/polygon/b2dpolygon.hxx> +#include <basegfx/polygon/b2dpolypolygon.hxx> #include <basegfx/vector/b2enums.hxx> #include <vcl/lineinfo.hxx> @@ -86,6 +87,7 @@ public: void testDrawWaveLine(); void testDrawPolyLine(); void testDrawPolygon(); + void testDrawPolyPolygon(); CPPUNIT_TEST_SUITE(VclOutdevTest); CPPUNIT_TEST(testVirtualDevice); @@ -138,6 +140,7 @@ public: CPPUNIT_TEST(testDrawWaveLine); CPPUNIT_TEST(testDrawPolyLine); CPPUNIT_TEST(testDrawPolygon); + CPPUNIT_TEST(testDrawPolyPolygon); CPPUNIT_TEST_SUITE_END(); }; @@ -1947,6 +1950,69 @@ void VclOutdevTest::testDrawPolygon() } } +static tools::PolyPolygon createPolyPolygon() +{ + tools::Polygon aPolygon(4); + + aPolygon.SetPoint(Point(1, 8), 0); + aPolygon.SetPoint(Point(2, 7), 1); + aPolygon.SetPoint(Point(3, 6), 2); + aPolygon.SetPoint(Point(4, 5), 3); + + tools::PolyPolygon aPolyPolygon(aPolygon); + aPolyPolygon.Optimize(PolyOptimizeFlags::CLOSE); + + return aPolyPolygon; +} + +void VclOutdevTest::testDrawPolyPolygon() +{ + { + ScopedVclPtrInstance<VirtualDevice> pVDev; + GDIMetaFile aMtf; + aMtf.Record(pVDev.get()); + + pVDev->SetOutputSizePixel(Size(100, 100)); + + tools::PolyPolygon aPolyPolygon = createPolyPolygon(); + + pVDev->DrawPolyPolygon(aPolyPolygon); + + MetaAction* pAction = aMtf.GetAction(INITIAL_SETUP_ACTION_COUNT); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a polypolygon action", MetaActionType::POLYPOLYGON, + pAction->GetType()); + + MetaPolyPolygonAction* pPolyPolygonAction = dynamic_cast<MetaPolyPolygonAction*>(pAction); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Not the same polypolygon in polypolygon action", aPolyPolygon, + pPolyPolygonAction->GetPolyPolygon()); + } + + { + ScopedVclPtrInstance<VirtualDevice> pVDev; + GDIMetaFile aMtf; + aMtf.Record(pVDev.get()); + + pVDev->SetOutputSizePixel(Size(100, 100)); + + tools::PolyPolygon aPolyPolygon = createPolyPolygon(); + + basegfx::B2DPolyPolygon aB2DPolyPolygon(aPolyPolygon.getB2DPolyPolygon()); + + pVDev->DrawPolyPolygon(aB2DPolyPolygon); + + MetaAction* pAction = aMtf.GetAction(INITIAL_SETUP_ACTION_COUNT); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a polypolygon action", MetaActionType::POLYPOLYGON, + pAction->GetType()); + + /* these should match, but the equality operator does not work on PolyPolygon for some reason + + MetaPolyPolygonAction* pPolyPolygonAction = dynamic_cast<MetaPolyPolygonAction*>(pAction); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Not the same polypolygon in polypolygon action", aPolyPolygon, + pPolyPolygonAction->GetPolyPolygon()); + */ + } +} + CPPUNIT_TEST_SUITE_REGISTRATION(VclOutdevTest); CPPUNIT_PLUGIN_IMPLEMENT(); |