diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2023-08-01 22:06:31 +0200 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2023-08-21 08:57:15 +0200 |
commit | 73ec9c71689525ff14db219238083ff75028f8c8 (patch) | |
tree | 0afd210299bc810296ed9cb3d9a0297a54123b83 /oox | |
parent | e60ef8651cfb30335471d1622e58c13eebc7d58b (diff) |
Tests with color stops to assert Color and not BColor values
For testing color stops of a gradient we don't need to assert super
precise values (doubls to the n-th decimal point) as long the end
results in the same (8-bit) Color value. So change the tests to
convert the BColor that is in gradient color stops to Color and
assert the Color value.
Change-Id: Ibd7661e2f72955a0778e822df1fae568973be357
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155360
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'oox')
-rw-r--r-- | oox/qa/unit/drawingml.cxx | 12 | ||||
-rw-r--r-- | oox/qa/unit/shape.cxx | 50 |
2 files changed, 26 insertions, 36 deletions
diff --git a/oox/qa/unit/drawingml.cxx b/oox/qa/unit/drawingml.cxx index 3f2876c97e41..0eeec8ab7488 100644 --- a/oox/qa/unit/drawingml.cxx +++ b/oox/qa/unit/drawingml.cxx @@ -194,8 +194,16 @@ CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testGradientMultiStepTransparency) const basegfx::BColorStops aColorStops(aTransparence.ColorStops); CPPUNIT_ASSERT_EQUAL(size_t(5), aColorStops.size()); - CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[4].getStopOffset(), 1.0)); - CPPUNIT_ASSERT_EQUAL(aColorStops[4].getStopColor(), basegfx::BColor(0.0, 0.0, 0.0)); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00, aColorStops[0].getStopOffset(), 1E-3); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.19, aColorStops[1].getStopOffset(), 1E-3); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.35, aColorStops[2].getStopOffset(), 1E-3); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.58, aColorStops[3].getStopOffset(), 1E-3); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.00, aColorStops[4].getStopOffset(), 1E-3); + CPPUNIT_ASSERT_EQUAL(Color(0xffffff), Color(aColorStops[0].getStopColor())); + CPPUNIT_ASSERT_EQUAL(Color(0x9e9e9e), Color(aColorStops[1].getStopColor())); + CPPUNIT_ASSERT_EQUAL(Color(0x363636), Color(aColorStops[2].getStopColor())); + CPPUNIT_ASSERT_EQUAL(Color(0x000000), Color(aColorStops[3].getStopColor())); + CPPUNIT_ASSERT_EQUAL(Color(0x000000), Color(aColorStops[4].getStopColor())); } CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testShapeTextAlignment) diff --git a/oox/qa/unit/shape.cxx b/oox/qa/unit/shape.cxx index 605834d6c0fc..522673803ae0 100644 --- a/oox/qa/unit/shape.cxx +++ b/oox/qa/unit/shape.cxx @@ -475,11 +475,9 @@ CPPUNIT_TEST_FIXTURE(OoxShapeTest, testWriterFontwork3) CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size()); CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0)); - CPPUNIT_ASSERT_EQUAL(aColorStops[0].getStopColor(), basegfx::BColor(0.0, 0.0, 1.0)); + CPPUNIT_ASSERT_EQUAL(Color(0x0000ff), Color(aColorStops[0].getStopColor())); CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 1.0)); - CPPUNIT_ASSERT_EQUAL( - aColorStops[1].getStopColor(), - basegfx::BColor(0.96862745098039216, 0.58823529411764708, 0.27450980392156865)); + CPPUNIT_ASSERT_EQUAL(Color(0xf79646), Color(aColorStops[1].getStopColor())); CPPUNIT_ASSERT_EQUAL(sal_Int16(690), aGradient.Angle); CPPUNIT_ASSERT_EQUAL(sal_Int16(0), aGradient.XOffset); @@ -500,11 +498,9 @@ CPPUNIT_TEST_FIXTURE(OoxShapeTest, testWriterFontwork3) CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size()); CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.40000000000000002)); - CPPUNIT_ASSERT_EQUAL( - aColorStops[0].getStopColor(), - basegfx::BColor(0.96862745098039216, 0.58823529411764708, 0.27450980392156865)); + CPPUNIT_ASSERT_EQUAL(Color(0xf79646), Color(aColorStops[0].getStopColor())); CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 1.0)); - CPPUNIT_ASSERT_EQUAL(aColorStops[1].getStopColor(), basegfx::BColor(0.0, 0.0, 1.0)); + CPPUNIT_ASSERT_EQUAL(Color(0x0000ff), Color(aColorStops[1].getStopColor())); CPPUNIT_ASSERT_EQUAL(sal_Int16(900), aGradient.Angle); CPPUNIT_ASSERT_EQUAL(sal_Int16(50), aGradient.XOffset); @@ -525,11 +521,9 @@ CPPUNIT_TEST_FIXTURE(OoxShapeTest, testWriterFontwork3) CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size()); CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0)); - CPPUNIT_ASSERT_EQUAL( - aColorStops[0].getStopColor(), - basegfx::BColor(0.96862745098039216, 0.58823529411764708, 0.27450980392156865)); + CPPUNIT_ASSERT_EQUAL(Color(0xf79646), Color(aColorStops[0].getStopColor())); CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 1.0)); - CPPUNIT_ASSERT_EQUAL(aColorStops[1].getStopColor(), basegfx::BColor(0.0, 0.0, 1.0)); + CPPUNIT_ASSERT_EQUAL(Color(0x0000ff), Color(aColorStops[1].getStopColor())); CPPUNIT_ASSERT_EQUAL(sal_Int16(900), aGradient.Angle); CPPUNIT_ASSERT_EQUAL(sal_Int16(100), aGradient.XOffset); @@ -642,11 +636,9 @@ CPPUNIT_TEST_FIXTURE(OoxShapeTest, testImportWordArtGradient) CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size()); CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0)); - CPPUNIT_ASSERT_EQUAL(aColorStops[0].getStopColor(), - basegfx::BColor(1.0, 0.75294117647058822, 0.0)); + CPPUNIT_ASSERT_EQUAL(Color(0xffc000), Color(aColorStops[0].getStopColor())); CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 1.0)); - CPPUNIT_ASSERT_EQUAL(aColorStops[1].getStopColor(), - basegfx::BColor(0.75294117647058822, 0.0, 0.0)); + CPPUNIT_ASSERT_EQUAL(Color(0xc00000), Color(aColorStops[1].getStopColor())); CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_LINEAR, aGradient.Style); CPPUNIT_ASSERT_EQUAL(sal_Int16(690), aGradient.Angle); @@ -675,11 +667,9 @@ CPPUNIT_TEST_FIXTURE(OoxShapeTest, testImportWordArtGradient) CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size()); CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0)); - CPPUNIT_ASSERT_EQUAL(aColorStops[0].getStopColor(), - basegfx::BColor(0.0, 0.51372549019607838, 0.8784313725490196)); + CPPUNIT_ASSERT_EQUAL(Color(0x0083e0), Color(aColorStops[0].getStopColor())); CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 1.0)); - CPPUNIT_ASSERT_EQUAL(aColorStops[1].getStopColor(), - basegfx::BColor(0.90196078431372551, 0.90196078431372551, 0.0)); + CPPUNIT_ASSERT_EQUAL(Color(0xe6e600), Color(aColorStops[1].getStopColor())); CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_RADIAL, aGradient.Style); CPPUNIT_ASSERT_EQUAL(sal_Int16(50), aGradient.XOffset); @@ -692,13 +682,9 @@ CPPUNIT_TEST_FIXTURE(OoxShapeTest, testImportWordArtGradient) // Transparency is encoded in gray color. CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size()); CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0)); - CPPUNIT_ASSERT_EQUAL( - aColorStops[0].getStopColor(), - basegfx::BColor(0.40000000000000002, 0.40000000000000002, 0.40000000000000002)); + CPPUNIT_ASSERT_EQUAL(Color(0x666666), Color(aColorStops[0].getStopColor())); CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 1.0)); - CPPUNIT_ASSERT_EQUAL( - aColorStops[1].getStopColor(), - basegfx::BColor(0.29999999999999999, 0.29999999999999999, 0.29999999999999999)); + CPPUNIT_ASSERT_EQUAL(Color(0x4d4d4d), Color(aColorStops[1].getStopColor())); CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_RADIAL, aGradient.Style); CPPUNIT_ASSERT_EQUAL(sal_Int16(50), aGradient.XOffset); @@ -732,13 +718,9 @@ CPPUNIT_TEST_FIXTURE(OoxShapeTest, testImportWordArtGradient) CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size()); CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0)); - CPPUNIT_ASSERT_EQUAL( - aColorStops[0].getStopColor(), - basegfx::BColor(0.26666666666666666, 0.44705882352941179, 0.7686274509803922)); + CPPUNIT_ASSERT_EQUAL(Color(0x4472c4), Color(aColorStops[0].getStopColor())); CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 1.0)); - CPPUNIT_ASSERT_EQUAL( - aColorStops[1].getStopColor(), - basegfx::BColor(0.26666666666666666, 0.44705882352941179, 0.7686274509803922)); + CPPUNIT_ASSERT_EQUAL(Color(0x4472c4), Color(aColorStops[1].getStopColor())); CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_RECT, aGradient.Style); CPPUNIT_ASSERT_EQUAL(sal_Int16(100), aGradient.XOffset); @@ -751,9 +733,9 @@ CPPUNIT_TEST_FIXTURE(OoxShapeTest, testImportWordArtGradient) // Transparency is encoded in gray color. CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size()); CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0)); - CPPUNIT_ASSERT_EQUAL(aColorStops[0].getStopColor(), basegfx::BColor(0.0, 0.0, 0.0)); + CPPUNIT_ASSERT_EQUAL(Color(0x000000), Color(aColorStops[0].getStopColor())); CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 1.0)); - CPPUNIT_ASSERT_EQUAL(aColorStops[1].getStopColor(), basegfx::BColor(1.0, 1.0, 1.0)); + CPPUNIT_ASSERT_EQUAL(Color(0xFFFFFF), Color(aColorStops[1].getStopColor())); CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_RECT, aGradient.Style); CPPUNIT_ASSERT_EQUAL(sal_Int16(100), aGradient.XOffset); |