diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2021-04-19 16:25:58 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2021-04-20 14:18:42 +0200 |
commit | 17e9789f6c0b676484609b61e3abbebca8c93f88 (patch) | |
tree | c5bf4f0bcc4cdbf39161273b376645ef8b601512 /tools | |
parent | 764360df78535befcc4806736fcbaedbe0e34ea1 (diff) |
reduce copy pasta with Color::GetLuminance()
Change-Id: I2eda3607a3be6ee56f0a9ddd14131be783b9698a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114294
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qa/cppunit/test_color.cxx | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tools/qa/cppunit/test_color.cxx b/tools/qa/cppunit/test_color.cxx index 05616b8f64a2..f3ffd9c692cd 100644 --- a/tools/qa/cppunit/test_color.cxx +++ b/tools/qa/cppunit/test_color.cxx @@ -25,6 +25,7 @@ public: void testGetColorError(); void testInvert(); void testBColor(); + void testLuminance(); CPPUNIT_TEST_SUITE(Test); CPPUNIT_TEST(testVariables); @@ -33,6 +34,7 @@ public: CPPUNIT_TEST(testGetColorError); CPPUNIT_TEST(testInvert); CPPUNIT_TEST(testBColor); + CPPUNIT_TEST(testLuminance); CPPUNIT_TEST_SUITE_END(); }; @@ -218,6 +220,18 @@ void Test::testBColor() } +void Test::testLuminance() +{ + CPPUNIT_ASSERT_EQUAL(sal_uInt8(0), COL_BLACK.GetLuminance()); + CPPUNIT_ASSERT_EQUAL(sal_uInt8(255), COL_WHITE.GetLuminance()); + CPPUNIT_ASSERT_EQUAL(sal_uInt8(128), Color(128, 128, 128).GetLuminance()); + CPPUNIT_ASSERT(COL_WHITE.IsBright()); + CPPUNIT_ASSERT(COL_BLACK.IsDark()); + CPPUNIT_ASSERT(Color(249, 250, 251).IsBright()); + CPPUNIT_ASSERT(Color(9, 10, 11).IsDark()); + CPPUNIT_ASSERT(COL_WHITE.GetLuminance() > COL_BLACK.GetLuminance()); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); } |