diff options
author | Chris Sherlock <chris.sherlock79@gmail.com> | 2021-10-02 23:04:02 +1000 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2021-10-22 14:39:36 +0200 |
commit | 82275140a56750302265a5be21236ae7a15f16e6 (patch) | |
tree | 683867a4b6091e4dde0a328da0272cdf15dc4ef0 /vcl/qa | |
parent | 9436f7e2ffb41c278107aa4e6fd6914937994cbd (diff) |
vcl: move variable declar's closer to 1st use in DrawComplexGradientToMetaFile
Change-Id: Id626799d1b077e649f67a8abf335a63efd15d433
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123000
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl/qa')
-rw-r--r-- | vcl/qa/cppunit/outdev.cxx | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/vcl/qa/cppunit/outdev.cxx b/vcl/qa/cppunit/outdev.cxx index 3779d9b96536..5e05a5acd48b 100644 --- a/vcl/qa/cppunit/outdev.cxx +++ b/vcl/qa/cppunit/outdev.cxx @@ -95,6 +95,7 @@ public: void testDrawGradient_rect_axial(); void testDrawGradient_polygon_linear(); void testDrawGradient_polygon_axial(); + void testDrawGradient_rect_complex(); CPPUNIT_TEST_SUITE(VclOutdevTest); CPPUNIT_TEST(testVirtualDevice); @@ -153,6 +154,7 @@ public: CPPUNIT_TEST(testDrawGradient_rect_axial); CPPUNIT_TEST(testDrawGradient_polygon_linear); CPPUNIT_TEST(testDrawGradient_polygon_axial); + CPPUNIT_TEST(testDrawGradient_rect_complex); CPPUNIT_TEST_SUITE_END(); }; @@ -2277,6 +2279,7 @@ void VclOutdevTest::testDrawGradient_polygon_linear() Gradient aGradient(GradientStyle::Linear, COL_RED, COL_WHITE); aGradient.SetBorder(100); + pVDev->DrawGradient(aPolyPolygon, aGradient); size_t nIndex = ClipGradientTest(aMtf, INITIAL_SETUP_ACTION_COUNT); @@ -2296,6 +2299,7 @@ void VclOutdevTest::testDrawGradient_polygon_axial() Gradient aGradient(GradientStyle::Axial, COL_RED, COL_WHITE); aGradient.SetBorder(100); + pVDev->DrawGradient(aPolyPolygon, aGradient); size_t nIndex = ClipGradientTest(aMtf, INITIAL_SETUP_ACTION_COUNT); @@ -2303,6 +2307,61 @@ void VclOutdevTest::testDrawGradient_polygon_axial() TestAxialStripes(aMtf, 3, nIndex); } +static size_t TestComplexStripes(GDIMetaFile& rMtf, size_t nTimes, size_t nIndex) +{ + nIndex++; + MetaAction* pAction = rMtf.GetAction(nIndex); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a fill color action", MetaActionType::FILLCOLOR, + pAction->GetType()); + + for (size_t i = 1; i < nTimes; i++) + { + nIndex++; + pAction = rMtf.GetAction(nIndex); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a polypolygon action", MetaActionType::POLYPOLYGON, + pAction->GetType()); + + nIndex++; + pAction = rMtf.GetAction(nIndex); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a fill color action", MetaActionType::FILLCOLOR, + pAction->GetType()); + } + + nIndex++; + pAction = rMtf.GetAction(nIndex); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a fill color action", MetaActionType::FILLCOLOR, + pAction->GetType()); + + nIndex++; + pAction = rMtf.GetAction(nIndex); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a polypolygon action", MetaActionType::POLYGON, + pAction->GetType()); + + return nIndex; +} + +void VclOutdevTest::testDrawGradient_rect_complex() +{ + ScopedVclPtrInstance<VirtualDevice> pVDev; + GDIMetaFile aMtf; + aMtf.Record(pVDev.get()); + + tools::Rectangle aRect(Point(10, 10), Size(40, 40)); + pVDev->SetOutputSizePixel(Size(1000, 1000)); + + Gradient aGradient(GradientStyle::Square, COL_RED, COL_WHITE); + aGradient.SetBorder(10); + pVDev->DrawGradient(aRect, aGradient); + + size_t nIndex = INITIAL_SETUP_ACTION_COUNT; + + MetaAction* pAction = aMtf.GetAction(nIndex); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a gradient action (rectangle area)", MetaActionType::GRADIENT, + pAction->GetType()); + + nIndex = TestComplexStripes(aMtf, 40, nIndex); +} + CPPUNIT_TEST_SUITE_REGISTRATION(VclOutdevTest); CPPUNIT_PLUGIN_IMPLEMENT(); |